Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a10d4a6f
Commit
a10d4a6f
authored
Sep 02, 2000
by
Fredrik Lundh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed \x to consume exactly two hex digits. implements PEP-223
for 8-bit strings.
parent
07f40f5c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
16 deletions
+28
-16
Python/compile.c
Python/compile.c
+28
-16
No files found.
Python/compile.c
View file @
a10d4a6f
...
...
@@ -873,10 +873,11 @@ parsestr(char *s)
return
PyUnicode_DecodeUnicodeEscape
(
s
,
len
,
NULL
);
}
else
if
(
rawmode
||
strchr
(
s
,
'\\'
)
==
NULL
)
{
if
(
rawmode
||
strchr
(
s
,
'\\'
)
==
NULL
)
return
PyString_FromStringAndSize
(
s
,
len
);
}
v
=
PyString_FromStringAndSize
((
char
*
)
NULL
,
len
);
if
(
v
==
NULL
)
return
NULL
;
p
=
buf
=
PyString_AsString
(
v
);
end
=
s
+
len
;
while
(
s
<
end
)
{
...
...
@@ -909,24 +910,35 @@ parsestr(char *s)
*
p
++
=
c
;
break
;
case
'x'
:
if
(
isxdigit
(
Py_CHARMASK
(
*
s
)))
{
if
(
isxdigit
(
Py_CHARMASK
(
s
[
0
]))
&&
isxdigit
(
Py_CHARMASK
(
s
[
1
]
)))
{
unsigned
int
x
=
0
;
do
{
c
=
Py_CHARMASK
(
*
s
);
s
++
;
x
=
(
x
<<
4
)
&
~
0xF
;
if
(
isdigit
(
c
))
x
=
c
-
'0'
;
else
if
(
islower
(
c
))
x
=
10
+
c
-
'a'
;
else
x
=
10
+
c
-
'A'
;
x
=
x
<<
4
;
c
=
Py_CHARMASK
(
*
s
);
s
++
;
if
(
isdigit
(
c
))
x
+=
c
-
'0'
;
else
if
(
islower
(
c
))
x
+=
10
+
c
-
'a'
;
else
x
+=
10
+
c
-
'A'
;
}
while
(
isxdigit
(
Py_CHARMASK
(
*
s
)));
*
p
++
=
x
;
break
;
}
/* FALLTHROUGH */
default:
*
p
++
=
'\\'
;
*
p
++
=
s
[
-
1
];
break
;
PyErr_SetString
(
PyExc_ValueError
,
"invalid
\\
x escape"
);
Py_DECREF
(
v
);
return
NULL
;
default:
*
p
++
=
'\\'
;
*
p
++
=
s
[
-
1
];
break
;
}
}
_PyString_Resize
(
&
v
,
(
int
)(
p
-
buf
));
...
...
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