From: benny AT crocodial DOT de (Benjamin Riefenstahl) Subject: Re: B19, EGCS 1.1: Strcasecmp uses uppercase? 28 Nov 1998 01:32:39 -0800 Message-ID: <365EF604.EC64ADEC.cygnus.gnu-win32@crocodial.de> References: <3 DOT 0 DOT 5 DOT 32 DOT 19981127103534 DOT 00947a10 AT pop DOT cs DOT uu DOT nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: gnu-win32 AT cygnus DOT com 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 AT crocodial DOT 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 AT cygnus DOT com" with one line of text: "help".