delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/11/30/19:02:04

From: DJ Delorie <dj AT delorie DOT com>
Subject: Re: strcasecmp revisited
30 Nov 1998 19:02:04 -0500 :
Message-ID: <366331FC.16D0AA06@delorie.com>
References: <19981130132257 DOT B15656 AT cygnus DOT com> <19981130152146 DOT A16484 DOT cygnus DOT cygwin32 DOT developers AT cygnus DOT com>
Mime-Version: 1.0
X-Mailer: Mozilla 4.5 [en] (X11; I; Linux 2.1.126 i586)
X-Accept-Language: en

Christopher Faylor wrote:
> That is almost what is happening now except for the tolower case.  Hmm.
> I just checked this behavior on Linux and it appears that I was just
> misinterpreting what was going on here.  Linux apparently does compare
> a non-alpha character to the lowercased character.  That's all it
> does.  So, my change was actually wrong.

DJGPP compares the tolower()d characters (strcasecmp is a stub that
chains to stricmp).  Nobody has complained yet :-)

/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
#include <string.h>
#include <ctype.h>

int
stricmp(const char *s1, const char *s2)
{
  while (tolower(*s1) == tolower(*s2))
  {
    if (*s1 == 0)
      return 0;
    s1++;
    s2++;
  }
  return (int)tolower(*s1) - (int)tolower(*s2);
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019