Subject: Re: B19, EGCS 1.1: Strcasecmp uses uppercase?
From: [email-masked] (Benjamin Riefenstahl)

28 Nov 1998 01:32:39 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

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 ([email-masked])
Crocodial Communications EntwicklungsGmbH
Ruhrstr. 61, D-22761 Hamburg, Germany
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".