This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: B19, EGCS 1.1: Strcasecmp uses uppercase?


Hi Steven,


Steven van Dijk wrote:
>         char * s1 = "String";
>         char * s2 = "S_";
> 
>         printf("Comparing s1 with s2 returns: %d\n", strcasecmp(s1,s2));
> ...
> On my system (using b19, no patches and EGCS 1.1) I get:
> Comparing s1 with s2 returns: -11
> 
> and on the Unix system I get:
> Comparing s1 with s2 returns: 21

I just checked it out. As you probably already know, '_' is *between*
the upper case letters and the lower case letters in ASCII. So the sort
order of '_' in strcasecmp() depends on whether the implementation maps
letters to lower case or to upper case before comparing (it must do one
or the other).

strcasecmp() is not in the ANSI or POSIX standards. I looked it up in
the man pages on my Linux box. The man page doesn't say, whether
strcasecmp() is supposed to user lower case or upper case. It says the
function originates from BSD 4.3, so maybe somebody could look it up in
the docs on a FreeBSD or NetBSD machine.


> The program I am porting expects "_" to be smaller than "t" and therefore
> crashes.

That would count as a bad bug in the program in my view. Given the
function is rather non-standard, I would not expect more from the
function on a random platform than what it's name implies. If you need
more than that, you should probably reimplement the desired
functionality.


so long, benny
======================================
Benjamin Riefenstahl (benny@crocodial.de)
Crocodial Communications EntwicklungsGmbH
Ruhrstr. 61, D-22761 Hamburg, Germany
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]