E582 Fix gcc 3.3 warnings related to Py_UNICODE_WIDE. · python/cpython@7db07e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7db07e6

Browse files
committed
Fix gcc 3.3 warnings related to Py_UNICODE_WIDE.
1 parent f1ca7f5 commit 7db07e6

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

Objects/unicodectype.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ gettyperecord(Py_UNICODE code)
3636
{
3737
int index;
3838

39+
#ifdef Py_UNICODE_WIDE
3940
if (code >= 0x110000)
4041
index = 0;
41-
else {
42+
else
43+
#endif
44+
{
4245
index = index1[(code>>SHIFT)];
4346
index = index2[(index<<SHIFT)+(code&((1<<SHIFT)-1))];
4447
}

Python/codecs.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,17 @@ PyObject *PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
563563
ressize += 2+3+1;
564564
else if (*p<10000)
565565
ressize += 2+4+1;
566+
#ifndef Py_UNICODE_WIDE
567+
else
568+
ressize += 2+5+1;
569+
#else
566570
else if (*p<100000)
567571
ressize += 2+5+1;
568572
else if (*p<1000000)
569573
ressize += 2+6+1;
570574
else
571575
ressize += 2+7+1;
576+
#endif
572577
}
573578
/* allocate replacement */
574579
res = PyUnicode_FromUnicode(NULL, ressize);
@@ -600,6 +605,12 @@ PyObject *PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
600605
digits = 4;
601606
base = 1000;
602607
}
608+
#ifndef Py_UNICODE_WIDE
609+
else {
610+
digits = 5;
611+
base = 10000;
612+
}
613+
#else
603614
else if (*p<100000) {
604615
digits = 5;
605616
base = 10000;
@@ -612,6 +623,7 @@ PyObject *PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
612623
digits = 7;
613624
base = 1000000;
614625
}
626+
#endif
615627
while (digits-->0) {
616628
*outp++ = '0' + c/base;
617629
c %= base;
@@ -655,9 +667,12 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
655667
return NULL;
656668
startp = PyUnicode_AS_UNICODE(object);
657669
for (p = startp+start, ressize = 0; p < startp+end; ++p) {
670+
#ifdef Py_UNICODE_WIDE
658671
if (*p >= 0x00010000)
659672
ressize += 1+1+8;
660-
else if (*p >= 0x100) {
673+
else
674+
#endif
675+
if (*p >= 0x100) {
661676
ressize += 1+1+4;
662677
}
663678
else
@@ -670,6 +685,7 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
670685
p < startp+end; ++p) {
671686
Py_UNICODE c = *p;
672687
*outp++ = '\\';
688+
#ifdef Py_UNICODE_WIDE
673689
if (c >= 0x00010000) {
674690
*outp++ = 'U';
675691
*outp++ = hexdigits[(c>>28)&0xf];
@@ -679,7 +695,9 @@ PyObject *PyCodec_BackslashReplaceErrors(PyObject *exc)
679695
*outp++ = hexdigits[(c>>12)&0xf];
680696
*outp++ = hexdigits[(c>>8)&0xf];
681697
}
682-
else if (c >= 0x100) {
698+
else
699+
#endif
700+
if (c >= 0x100) {
683701
*outp++ = 'u';
684702
*outp++ = hexdigits[(c>>12)&0xf];
685703
*outp++ = hexdigits[(c>>8)&0xf];

0 commit comments

Comments
 (0)
0