Use strncasecmp if we can, instead of our own homegrown strncmp_nocase
authorAlan Coopersmith <alan.coopersmith@sun.com>
Tue, 17 Jul 2007 22:57:10 +0000 (15:57 -0700)
committerAlan Coopersmith <alan.coopersmith@sun.com>
Tue, 17 Jul 2007 22:57:10 +0000 (15:57 -0700)
configure.ac
handle.c

index 089720f..4216294 100644 (file)
@@ -31,6 +31,8 @@ AM_CONFIG_HEADER(config.h)
 AC_PROG_CC
 AC_PROG_INSTALL
 
+AC_CHECK_FUNCS([strncasecmp])
+
 # Checks for pkg-config packages
 PKG_CHECK_MODULES(DEP, x11)
 AC_SUBST(DEP_CFLAGS)
index 61e819f..5d457b4 100644 (file)
--- a/handle.c
+++ b/handle.c
@@ -28,6 +28,7 @@ from The Open Group.
 */
 /* $XFree86: xc/programs/xmodmap/handle.c,v 3.6 2001/07/25 15:05:27 dawes Exp $ */
 
+#include "config.h"
 #include <X11/Xos.h>
 #include <X11/Xlib.h>
 #include <stdio.h>
@@ -791,8 +792,9 @@ do_clear(char *line, int len)
     add_to_work_queue (uop);
 }
 
+#ifndef HAVE_STRNCASECMP
 static int 
-strncmp_nocase(const char *a, const char *b, int n)
+strncasecmp(const char *a, const char *b, int n)
 {
     int i;
     int a1, b1;
@@ -809,7 +811,7 @@ strncmp_nocase(const char *a, const char *b, int n)
     }
     return 0;
 }
-
+#endif
 
 /*
  * do_pointer = get list of numbers of the form
@@ -851,7 +853,7 @@ do_pointer(char *line, int len)
     line += n, len -= n;
 
     i = 0;
-    if (len < 7 || strncmp_nocase (line, "default", 7) != 0) {
+    if (len < 7 || strncasecmp (line, "default", 7) != 0) {
        while (len > 0) {
            n = skip_space (line, len);
            line += n, len -= n;