diff options
author | Hye-Shik Chang <hyeshik@gmail.com> | 2003-12-29 01:36:01 (GMT) |
---|---|---|
committer | Hye-Shik Chang <hyeshik@gmail.com> | 2003-12-29 01:36:01 (GMT) |
commit | 7db07e697286c8bedb7d8c320203ddbc7a98bad2 (patch) | |
tree | ee6402f92fd62ec87498c767b4eb626639cd76d9 | |
parent | f1ca7f561c6e02509e17414825305ebcbd6f72b0 (diff) | |
download | cpython-7db07e697286c8bedb7d8c320203ddbc7a98bad2.zip cpython-7db07e697286c8bedb7d8c320203ddbc7a98bad2.tar.gz cpython-7db07e697286c8bedb7d8c320203ddbc7a98bad2.tar.bz2 |
Fix gcc 3.3 warnings related to Py_UNICODE_WIDE.
-rw-r--r-- | Objects/unicodectype.c | 5 | ||||
-rw-r--r-- | Python/codecs.c | 22 |
2 files changed, 24 insertions, 3 deletions
diff --git a/Objects/unicodectype.c b/Objects/unicodectype.c index 106726d..7a330d9 100644 --- a/Objects/unicodectype.c +++ b/Objects/unicodectype.c @@ -36,9 +36,12 @@ gettyperecord(Py_UNICODE code) { int index; +#ifdef Py_UNICODE_WIDE if (code >= 0x110000) index = 0; - else { + else +#endif + { index = index1[(code>>SHIFT)]; index = index2[(index<<SHIFT)+(code&((1<<SHIFT)-1))]; } diff --git a/Python/codecs.c b/Python/codecs.c index 3675f3c..a208898 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -563,12 +563,17 @@ PyObject *PyCodec_XMLCharRefReplaceErrors(PyObject *exc) ressize += 2+3+1; else if (*p<10000) ressize += 2+4+1; +#ifndef Py_UNICODE_WIDE + else + ressize += 2+5+1; +#else else if (*p<100000) ressize += 2+5+1; else if (*p<1000000) ressize += 2+6+1; else ressize += 2+7+1; +#endif } /* allocate replacement */ res = PyUnicode_FromUnicode(NULL, ressize); @@ -600,6 +605,12 @@ PyObject *PyCodec_XMLCharRefReplaceErrors(PyObject *exc) digits = 4; base = 1000; } +#ifndef Py_UNICODE_WIDE + else { + digits = 5; + base = 10000; + } +#else else if (*p<100000) { digits = 5; base = 10000; @@ -612,6 +623,7 @@ PyObject *PyCodec_XMLCharRefReplaceErrors(PyObject *exc) digits = 7; base = 1000000; } +#endif while (digits-->0) { *outp++ = '0' + c/base; c %= base; @@ -655,9 +667,12 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc) return NULL; startp = PyUnicode_AS_UNICODE(object); for (p = startp+start, ressize = 0; p < startp+end; ++p) { +#ifdef Py_UNICODE_WIDE if (*p >= 0x00010000) ressize += 1+1+8; - else if (*p >= 0x100) { + else +#endif + if (*p >= 0x100) { ressize += 1+1+4; } else @@ -670,6 +685,7 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc) p < startp+end; ++p) { Py_UNICODE c = *p; *outp++ = '\\'; +#ifdef Py_UNICODE_WIDE if (c >= 0x00010000) { *outp++ = 'U'; *outp++ = hexdigits[(c>>28)&0xf]; @@ -679,7 +695,9 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc) *outp++ = hexdigits[(c>>12)&0xf]; *outp++ = hexdigits[(c>>8)&0xf]; } - else if (c >= 0x100) { + else +#endif + if (c >= 0x100) { *outp++ = 'u'; *outp++ = hexdigits[(c>>12)&0xf]; *outp++ = hexdigits[(c>>8)&0xf]; |