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
05533ff0
Commit
05533ff0
authored
Jan 13, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Plain Diff
Merge
https://github.com/cython/cython
parents
49623f86
59921a82
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
16 deletions
+66
-16
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-2
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+4
-11
Cython/Compiler/StringEncoding.py
Cython/Compiler/StringEncoding.py
+17
-3
tests/run/strliterals.pyx
tests/run/strliterals.pyx
+43
-0
No files found.
Cython/Compiler/ModuleNode.py
View file @
05533ff0
...
...
@@ -6,7 +6,7 @@ import cython
from
cython
import
set
cython
.
declare
(
Naming
=
object
,
Options
=
object
,
PyrexTypes
=
object
,
TypeSlots
=
object
,
error
=
object
,
warning
=
object
,
py_object_type
=
object
,
UtilityCode
=
object
,
escape_byte_string
=
object
,
EncodedString
=
object
)
EncodedString
=
object
)
import
os
,
time
from
PyrexTypes
import
CPtrType
...
...
@@ -26,7 +26,7 @@ from Errors import error, warning
from
PyrexTypes
import
py_object_type
from
Cython.Utils
import
open_new_file
,
replace_suffix
from
Code
import
UtilityCode
from
StringEncoding
import
escape_byte_string
,
EncodedString
from
StringEncoding
import
EncodedString
def
check_c_declarations_pxd
(
module_node
):
...
...
Cython/Compiler/Parsing.py
View file @
05533ff0
...
...
@@ -766,17 +766,10 @@ def p_string_literal(s, kind_override=None):
has_non_ASCII_literal_characters
=
True
elif
sy
==
'ESCAPE'
:
if
is_raw
:
if
systr
==
u'
\
\
\
n
'
:
chars
.
append
(
u'
\
\
\
n
'
)
elif
systr
==
u'
\
\
\
"
'
:
chars
.
append
(
u'"'
)
elif
systr
==
u'
\
\
\
'
'
:
chars
.
append
(
u"'"
)
else
:
chars
.
append
(
systr
)
if
is_python3_source
and
not
has_non_ASCII_literal_characters
\
and
check_for_non_ascii_characters
(
systr
):
has_non_ASCII_literal_characters
=
True
chars
.
append
(
systr
)
if
is_python3_source
and
not
has_non_ASCII_literal_characters
\
and
check_for_non_ascii_characters
(
systr
):
has_non_ASCII_literal_characters
=
True
else
:
c
=
systr
[
1
]
if
c
in
u"01234567"
:
...
...
Cython/Compiler/StringEncoding.py
View file @
05533ff0
...
...
@@ -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
)
tests/run/strliterals.pyx
View file @
05533ff0
This diff is collapsed.
Click to expand it.
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