mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Don't use sscanf(s, "%x", &c) to parse \xX... escapes; hardcode it.
This commit is contained in:
parent
f6a84db034
commit
ed1100f3b6
1 changed files with 10 additions and 3 deletions
|
@ -36,7 +36,6 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
XXX (it's currently the first item of the co_const tuple)
|
XXX (it's currently the first item of the co_const tuple)
|
||||||
XXX Generate simple jump for break/return outside 'try...finally'
|
XXX Generate simple jump for break/return outside 'try...finally'
|
||||||
XXX Allow 'continue' inside try-finally
|
XXX Allow 'continue' inside try-finally
|
||||||
XXX New 1-byte opcode for loading None
|
|
||||||
XXX New opcode for loading the initial index for a for loop
|
XXX New opcode for loading the initial index for a for loop
|
||||||
XXX other JAR tricks?
|
XXX other JAR tricks?
|
||||||
*/
|
*/
|
||||||
|
@ -922,11 +921,19 @@ parsestr(s)
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
if (isxdigit(Py_CHARMASK(*s))) {
|
if (isxdigit(Py_CHARMASK(*s))) {
|
||||||
sscanf(s, "%x", &c);
|
unsigned int x = 0;
|
||||||
*p++ = c;
|
|
||||||
do {
|
do {
|
||||||
|
c = Py_CHARMASK(*s);
|
||||||
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';
|
||||||
} while (isxdigit(Py_CHARMASK(*s)));
|
} while (isxdigit(Py_CHARMASK(*s)));
|
||||||
|
*p++ = x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue