Added 'strncasecmp' to the list of functions to be searched for. Added a

1998-11-04  Phil Schwan  <pschwan@cmu.edu>

        * configure.in: Added 'strncasecmp' to the list of functions to be
        searched for.
        * glib.h: Added a prototype for 'g_strncasecmp'
        * strfuncs.c: (g_strncasecmp) new function modeled closely after
        'g_strcasecmp'
This commit is contained in:
Phil Schwan
1998-11-05 01:36:36 +00:00
committed by Phil Schwan
parent 2701b4b563
commit 59f6876ded
13 changed files with 135 additions and 1 deletions

View File

@@ -975,6 +975,38 @@ g_strcasecmp (const gchar *s1,
#endif
}
gint
g_strncasecmp (const gchar *s1,
const gchar *s2,
guint n)
{
#ifdef HAVE_STRNCASECMP
return strncasecmp (s1, s2, n);
#else
gint c1, c2;
g_return_val_if_fail (s1 != NULL, 0);
g_return_val_if_fail (s2 != NULL, 0);
while (n-- && *s1 && *s2)
{
/* According to A. Cox, some platforms have islower's that
* don't work right on non-uppercase
*/
c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1;
c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2;
if (c1 != c2)
return (c1 - c2);
s1++; s2++;
}
if (n)
return (((gint)(guchar) *s1) - ((gint)(guchar) *s2));
else
return 0;
#endif
}
gchar*
g_strdelimit (gchar *string,
const gchar *delimiters,