Mail Archives: djgpp/2001/07/29/06:09:32
Hi,
I have some problems with the strupr and strlower functions and the ones
which are based upon, like stricmp.
If strupr finds a non ASCI character like 128 or higher it breaks at that
point leaving the string incomplete or it places illegal characters there.
The right behaviour would be to leave the character as it is. Maybe it is
something with signed or unsigned characters, since it only happens with
characters higher or equal than 128.
I looked at the sources and found that strupr calls toupper, so I tried
that - with the same result. So I copied the source of toupper in my own C
souzrce to debug it - and the error is gone. Mysterious ! What can be the
mistake. Is there somethink run wrong when making libc? I have writte a
small test application to demonstrate that. Maybe you can figure something
out.
BTW. How can I rebuilt libc. The makefile only gives error messages.
#include <string.h>
// if you skip this include and insert a copy of the tolower function here
all works fine
int main()
{
unsigned char s1[256],s2[256];
int i;
for (i=32;i<256-32;i++) s1[i-32]=i;
s1[i]=0;
puts("strlwr:");
puts(s1);
strcpy(s2,s1);
strlwr(s2);
puts(s2);
puts("");
puts("strupr:");
puts(s1);
strcpy(s2,s1);
strupr(s2);
puts(s2);
puts("");
for (i=32;i<256;i++)
{
printf("%i:%i (%c:%c)\n",i,tolower(i),i,tolower(i));
getch();
}
return 0;
}
- Raw text -