summaryrefslogtreecommitdiffstats
path: root/Python/codecs.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-14 00:13:11 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-14 00:13:11 (GMT)
commitf5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda (patch)
tree0eb7ea39ee5a60f384db53d5729b48d73986920d /Python/codecs.c
parente506437b52507609772e8141fdbb5ad2e17471bb (diff)
downloadcpython-f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda.zip
cpython-f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda.tar.gz
cpython-f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda.tar.bz2
Issue #13088: Add shared Py_hexdigits constant to format a number into base 16
Diffstat (limited to 'Python/codecs.c')
-rw-r--r--Python/codecs.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index 79dfe89..006d288 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -11,6 +11,8 @@ Copyright (c) Corporation for National Research Initiatives.
#include "Python.h"
#include <ctype.h>
+const char *Py_hexdigits = "0123456789abcdef";
+
/* --- Codec Registry ----------------------------------------------------- */
/* Import the standard encodings package which will register the first
@@ -673,8 +675,6 @@ PyObject *PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
}
}
-static const char *hexdigits = "0123456789abcdef";
-
PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
{
#ifndef Py_UNICODE_WIDE
@@ -731,22 +731,22 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
}
if (c >= 0x00010000) {
*outp++ = 'U';
- *outp++ = hexdigits[(c>>28)&0xf];
- *outp++ = hexdigits[(c>>24)&0xf];
- *outp++ = hexdigits[(c>>20)&0xf];
- *outp++ = hexdigits[(c>>16)&0xf];
- *outp++ = hexdigits[(c>>12)&0xf];
- *outp++ = hexdigits[(c>>8)&0xf];
+ *outp++ = Py_hexdigits[(c>>28)&0xf];
+ *outp++ = Py_hexdigits[(c>>24)&0xf];
+ *outp++ = Py_hexdigits[(c>>20)&0xf];
+ *outp++ = Py_hexdigits[(c>>16)&0xf];
+ *outp++ = Py_hexdigits[(c>>12)&0xf];
+ *outp++ = Py_hexdigits[(c>>8)&0xf];
}
else if (c >= 0x100) {
*outp++ = 'u';
- *outp++ = hexdigits[(c>>12)&0xf];
- *outp++ = hexdigits[(c>>8)&0xf];
+ *outp++ = Py_hexdigits[(c>>12)&0xf];
+ *outp++ = Py_hexdigits[(c>>8)&0xf];
}
else
*outp++ = 'x';
- *outp++ = hexdigits[(c>>4)&0xf];
- *outp++ = hexdigits[c&0xf];
+ *outp++ = Py_hexdigits[(c>>4)&0xf];
+ *outp++ = Py_hexdigits[c&0xf];
}
restuple = Py_BuildValue("(On)", res, end);