Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
aee29d90
Commit
aee29d90
authored
Jan 12, 2011
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix trac #640, long string literals with escapes.
parent
43a3dbea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
Cython/Compiler/StringEncoding.py
Cython/Compiler/StringEncoding.py
+17
-3
No files found.
Cython/Compiler/StringEncoding.py
View file @
aee29d90
...
...
@@ -232,9 +232,23 @@ def escape_byte_string(s):
append
(
c
)
return
join_bytes
(
l
).
decode
(
'ISO-8859-1'
)
def
split_string_literal
(
s
):
def
split_string_literal
(
s
,
limit
=
2000
):
# MSVC can't handle long string literals.
if
len
(
s
)
<
2047
:
if
len
(
s
)
<
limit
:
return
s
else
:
return
'""'
.
join
([
s
[
i
:
i
+
2000
]
for
i
in
range
(
0
,
len
(
s
),
2000
)]).
replace
(
r'\""'
,
'""
\
\
'
)
start
=
0
chunks
=
[]
while
start
<
len
(
s
):
end
=
start
+
limit
if
len
(
s
)
>
end
-
4
and
'
\
\
'
in
s
[
end
-
4
:
end
]:
end
-=
4
-
s
[
end
-
4
:
end
].
find
(
'
\
\
'
)
# just before the backslash
while
s
[
end
-
1
]
==
'
\
\
'
:
end
-=
1
if
end
==
start
:
# must have been a long line of backslashes
end
=
start
+
limit
-
(
limit
%
2
)
-
4
break
chunks
.
append
(
s
[
start
:
end
])
start
=
end
return
'""'
.
join
(
chunks
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment