diff options
author | Guido van Rossum <guido@python.org> | 1997-10-20 23:24:07 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-10-20 23:24:07 (GMT) |
commit | ed1100f3b63c79cc3da075b5c23f3d4fe25270c5 (patch) | |
tree | 5f97524297902d4a27767e06e794a2a1a24874d8 /Python/compile.c | |
parent | f6a84db034cdc5a403715391fc04294c5819417a (diff) | |
download | cpython-ed1100f3b63c79cc3da075b5c23f3d4fe25270c5.zip cpython-ed1100f3b63c79cc3da075b5c23f3d4fe25270c5.tar.gz cpython-ed1100f3b63c79cc3da075b5c23f3d4fe25270c5.tar.bz2 |
Don't use sscanf(s, "%x", &c) to parse \xX... escapes; hardcode it.
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Python/compile.c b/Python/compile.c index 80b7371..b4658e4 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -36,7 +36,6 @@ PERFORMANCE OF THIS SOFTWARE. XXX (it's currently the first item of the co_const tuple) XXX Generate simple jump for break/return outside '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 other JAR tricks? */ @@ -922,11 +921,19 @@ parsestr(s) break; case 'x': if (isxdigit(Py_CHARMASK(*s))) { - sscanf(s, "%x", &c); - *p++ = c; + 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'; } while (isxdigit(Py_CHARMASK(*s))); + *p++ = x; break; } /* FALLTHROUGH */ |