Added 'strncasecmp' to the list of functions to be searched for. Added a
authorPhil Schwan <pschwan@cmu.edu>
Thu, 5 Nov 1998 01:36:36 +0000 (01:36 +0000)
committerPhil Schwan <phils@src.gnome.org>
Thu, 5 Nov 1998 01:36:36 +0000 (01:36 +0000)
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'

13 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
configure.in
glib.h
glib/glib.h
glib/gstrfuncs.c
gstrfuncs.c

index 261fbb2..f89a573 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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'
+       * gstrfuncs.c: (g_strncasecmp) new function modeled closely after
+       'g_strcasecmp'
+
 Wed Nov  4 15:06:44 PST 1998 Manish Singh <yosh@gimp.org>
 
        * config.h.win32 (new file)
index 261fbb2..f89a573 100644 (file)
@@ -1,3 +1,11 @@
+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'
+       * gstrfuncs.c: (g_strncasecmp) new function modeled closely after
+       'g_strcasecmp'
+
 Wed Nov  4 15:06:44 PST 1998 Manish Singh <yosh@gimp.org>
 
        * config.h.win32 (new file)
index 261fbb2..f89a573 100644 (file)
@@ -1,3 +1,11 @@
+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'
+       * gstrfuncs.c: (g_strncasecmp) new function modeled closely after
+       'g_strcasecmp'
+
 Wed Nov  4 15:06:44 PST 1998 Manish Singh <yosh@gimp.org>
 
        * config.h.win32 (new file)
index 261fbb2..f89a573 100644 (file)
@@ -1,3 +1,11 @@
+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'
+       * gstrfuncs.c: (g_strncasecmp) new function modeled closely after
+       'g_strcasecmp'
+
 Wed Nov  4 15:06:44 PST 1998 Manish Singh <yosh@gimp.org>
 
        * config.h.win32 (new file)
index 261fbb2..f89a573 100644 (file)
@@ -1,3 +1,11 @@
+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'
+       * gstrfuncs.c: (g_strncasecmp) new function modeled closely after
+       'g_strcasecmp'
+
 Wed Nov  4 15:06:44 PST 1998 Manish Singh <yosh@gimp.org>
 
        * config.h.win32 (new file)
index 261fbb2..f89a573 100644 (file)
@@ -1,3 +1,11 @@
+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'
+       * gstrfuncs.c: (g_strncasecmp) new function modeled closely after
+       'g_strcasecmp'
+
 Wed Nov  4 15:06:44 PST 1998 Manish Singh <yosh@gimp.org>
 
        * config.h.win32 (new file)
index 261fbb2..f89a573 100644 (file)
@@ -1,3 +1,11 @@
+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'
+       * gstrfuncs.c: (g_strncasecmp) new function modeled closely after
+       'g_strcasecmp'
+
 Wed Nov  4 15:06:44 PST 1998 Manish Singh <yosh@gimp.org>
 
        * config.h.win32 (new file)
index 261fbb2..f89a573 100644 (file)
@@ -1,3 +1,11 @@
+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'
+       * gstrfuncs.c: (g_strncasecmp) new function modeled closely after
+       'g_strcasecmp'
+
 Wed Nov  4 15:06:44 PST 1998 Manish Singh <yosh@gimp.org>
 
        * config.h.win32 (new file)
index 709d548..40eb7e5 100644 (file)
@@ -233,7 +233,7 @@ AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
 AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
 
 # Check for some functions
-AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf strcasecmp)
+AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf strcasecmp strncasecmp)
 
 # Check for sys_errlist
 AC_MSG_CHECKING(for sys_errlist)
diff --git a/glib.h b/glib.h
index 72941f7..9e93836 100644 (file)
--- a/glib.h
+++ b/glib.h
@@ -1402,6 +1402,9 @@ gchar*     g_strerror             (gint         errnum);
 gchar*  g_strsignal            (gint         signum);
 gint    g_strcasecmp           (const gchar *s1,
                                 const gchar *s2);
+gint    g_strncasecmp          (const gchar *s1,
+                                const gchar *s2,
+                                guint        n);
 void    g_strdown              (gchar       *string);
 void    g_strup                (gchar       *string);
 void    g_strreverse           (gchar       *string);
index 72941f7..9e93836 100644 (file)
@@ -1402,6 +1402,9 @@ gchar*     g_strerror             (gint         errnum);
 gchar*  g_strsignal            (gint         signum);
 gint    g_strcasecmp           (const gchar *s1,
                                 const gchar *s2);
+gint    g_strncasecmp          (const gchar *s1,
+                                const gchar *s2,
+                                guint        n);
 void    g_strdown              (gchar       *string);
 void    g_strup                (gchar       *string);
 void    g_strreverse           (gchar       *string);
index c01877b..ad28978 100644 (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,
index c01877b..ad28978 100644 (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,