diff options
author | Phil Schwan <pschwan@cmu.edu> | 1998-11-05 01:36:36 +0000 |
---|---|---|
committer | Phil Schwan <phils@src.gnome.org> | 1998-11-05 01:36:36 +0000 |
commit | 59f6876dedd0cdb77e22aad3fa85f87aa153845d (patch) | |
tree | c48d940921045a963931bdfea88d3e59d6b98221 /gstrfuncs.c | |
parent | 2701b4b563de0a063f4d979f5cd2f2dff04acfa0 (diff) |
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'
Diffstat (limited to 'gstrfuncs.c')
-rw-r--r-- | gstrfuncs.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gstrfuncs.c b/gstrfuncs.c index c01877bd7..ad28978ee 100644 --- a/gstrfuncs.c +++ b/gstrfuncs.c @@ -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, |