Re: Re[4]: Wanted: a good flag for Win32 and an m4 guru

---------

From: Daniel Stenberg (daniel@haxx.se)
Date: Wed Jan 03 2001 - 06:47:21 CST


On Tue, 2 Jan 2001, Rev. Bob 'Bob' Crispen wrote:

> Actually, I did it a quick and dirty way (ignoring the possibility that
> both strcasecmp and stricmp were missing):
>
> #ifndef HAVE_STRCASECMP
> #define strcasecmp stricmp
> #endif

What about this then:

#ifndef HAVE_STRCASECMP
# ifdef HAVE_STRICMP
# define strcasecmp(x,y) stricmp(x,y)
# else
# ifdef HAVE_STRCMPI
# define strcasecmp(x,y) strcmpi(x,y)
# else
# /* no case insensitive function available */
# define USE_OUR_OWN_STRCASECMP
# endif
# endif

# ifdef USE_OUR_OWN_STRCASECMP
int strcasecmp(const char *first, const char *second)
{
  while (*first && *second) {
    if (toupper((int)*first) != toupper((int)*second))
      break;
    first++;
    second++;
  }
  return toupper((int)*first) - toupper((int)*second);
}
# endif

#endif /* HAVE_STRCASECMP */

> And just to add to the amusement, I've seen the function called strcmpi()
> somewhere.

Yes. Well, if you stick the above stuff in a header file somewhere. I'll add
the checks for stricmp() and strcmpi() to the configure script.

-- 
      Daniel Stenberg - http://daniel.haxx.se - +46-705-44 31 77
   ech`echo xiun|tr nu oc|sed 'sx\([sx]\)\([xoi]\)xo un\2\1 is xg'`ol

---------

This archive was generated by hypermail 2.1.5.