| www.delorie.com/djgpp/bugs/show.cgi | search |
strlwr and strupr dont work correctly when string contains extended ascii codes like ñ,Ñ,á,é etc., wich you need in spanish. I extracted de 2.01 versions of this functions and patch the 2.02 libc, and avery thing worked fine.
This bug appeared in v2.02 because the ctype macros, including toupper and tolower, no longer AND their argument with 0xff (the latter doesn't work with EOF), and because 8-bit characters are sign-extended to negative values when converted to an int.
Apply the following patch to strlwr.c and strupr.c; this is fixed in CVS
and will be in v2.03.
*** src/libc/compat/string/strlwr.c~0 Sat Mar 11 22:53:40 1995
--- src/libc/compat/string/strlwr.c Sun Jun 13 18:33:32 1999
*************** strlwr(char *_s)
*** 8,14 ****
char *rv = _s;
while (*_s)
{
! *_s = tolower(*_s);
_s++;
}
return rv;
--- 8,14 ----
char *rv = _s;
while (*_s)
{
! *_s = tolower((unsigned char)*_s);
_s++;
}
return rv;
*** src/libc/compat/string/strupr.c~0 Sat Mar 11 22:53:48 1995
--- src/libc/compat/string/strupr.c Sun Jun 13 18:36:52 1999
*************** strupr(char *_s)
*** 8,14 ****
char *rv = _s;
while (*_s)
{
! *_s = toupper(*_s);
_s++;
}
return rv;
--- 8,14 ----
char *rv = _s;
while (*_s)
{
! *_s = toupper((unsigned char)*_s);
_s++;
}
return rv;| webmaster donations bookstore | delorie software privacy |
| Copyright © 2010 by DJ Delorie | Updated Jul 2010 |