[Python-Dev] Re: [Python-checkins] python/dist/src/Objects unicodeobject.c, 2.204, 2.205 (original) (raw)

Hye-Shik Chang perky at i18n.org
Fri Dec 19 04:23:09 EST 2003


On Fri, Dec 19, 2003 at 09:30:27AM +0100, M.-A. Lemburg wrote:

perky at users.sourceforge.net wrote: >Update of /cvsroot/python/python/dist/src/Objects >In directory sc8-pr-cvs1:/tmp/cvs-serv1651/Objects > >Modified Files: > unicodeobject.c >Log Message: >SF #859573: Reduce compiler warnings on gcc 3.2 and above. > >Index: unicodeobject.c >*************** >*** 2204,2208 **** > > /* Latin-1 is equivalent to the first 256 ordinals in Unicode. */ >! if (size == 1 && (unsigned char)s < 256) {_ _> PyUNICODE r = (unsigned char)s; > return PyUnicodeFromUnicode(&r, 1); >--- 2212,2216 ---- > > /* Latin-1 is equivalent to the first 256 ordinals in Unicode. */ >! if (size == 1) { > PyUNICODE r = (unsigned char)s; > return PyUnicodeFromUnicode(&r, 1);

This "fix" doesn't look right. Please check.

gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Objects/unicodeobject.o Objects/unicodeobject.c Objects/unicodeobject.c: In function `PyUnicodeUCS2_DecodeLatin1': Objects/unicodeobject.c:2214: warning: comparison is always true due to limited range of data type

AFAIK, (unsigned char)s is always smaller than 256. Also decoding latin-1 can be done by just casting it into Py_UNICODE.

I'm sorry but can you explain more?

Hye-Shik



More information about the Python-Dev mailing list