diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-01-13 09:09:19 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-01-13 09:20:48 -0800 |
commit | 1a26cd81c08c008f8252ca03211705ce4951bab2 (patch) | |
tree | 52805f5cc13622cf8e72bef8396933c4a1c6ea6a | |
parent | 865c7c3da3a827cff080a763613d02729e9d4e33 (diff) |
Use strcasecmp if available, instead of downcasing string before strcmp
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | xrefresh.c | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index e5a23e1..2077a10 100644 --- a/configure.ac +++ b/configure.ac @@ -27,6 +27,7 @@ AC_INIT([xrefresh], [1.0.4], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xrefresh]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) +AC_USE_SYSTEM_EXTENSIONS # Initialize Automake AM_INIT_AUTOMAKE([foreign dist-bzip2]) @@ -38,6 +39,8 @@ m4_ifndef([XORG_MACROS_VERSION], XORG_MACROS_VERSION(1.8) XORG_DEFAULT_OPTIONS +AC_CHECK_FUNCS([strcasecmp]) + # Checks for pkg-config packages PKG_CHECK_MODULES(XREFRESH, [x11 xproto >= 7.0.17]) @@ -50,14 +50,21 @@ SOFTWARE. * screen. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <stdio.h> #include <errno.h> #include <X11/Xos.h> #include <X11/Xlib.h> #include <X11/Xutil.h> -#include <ctype.h> #include <stdlib.h> +#ifndef HAVE_STRCASECMP +# include <ctype.h> +#endif + static Window win; static char *ProgramName; @@ -95,14 +102,21 @@ parse_boolean_option(char *option) { "on", 1 }, { "y", 1 }, { "yes", 1 }, { "true", 1 }, { NULL, -1 }}; register const struct _booltable *t; + +#ifndef HAVE_STRCASECMP register char *cp; for (cp = option; *cp; cp++) { if (isascii (*cp) && isupper (*cp)) *cp = tolower (*cp); } +#endif for (t = booltable; t->name; t++) { +#ifdef HAVE_STRCASECMP + if (strcasecmp (option, t->name) == 0) return (t->value); +#else if (strcmp (option, t->name) == 0) return (t->value); +#endif } return (-1); } |