[PATCH] strcmp on ARM needs to treat char as unsigned

Richard Earnshaw rearnsha@arm.com
Tue Mar 24 10:24:00 GMT 2009


On ARM char is unsigned, so strcmp needs to perform the comparison of
differing chars on that basis, for example (char)0xff > (char)0x01.
Unfortunately, the tricks I was playing in one of the sub-cases (both
strings aligned) was slightly too clever and the result was that it
treated chars as signed, but only if the strings had a mutual common
alignment.

I have one more patch, for big-endian strcmp (this function has become
the bane of my life recently), that I'll post shortly.

With acknowledgement to the guys at CodeSourcery, who found this problem
(and most of the others).

Fixed thus:

2009-03-23  Richard Earnshaw  <rearnsha@arm.com>

	* libc/machine/arm/strcmp.c (strcmp): Treat char as unsigned.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmp.patch
Type: text/x-patch
Size: 1436 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20090324/562f3698/attachment.bin>


More information about the Newlib mailing list