From 1a26cd81c08c008f8252ca03211705ce4951bab2 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 13 Jan 2013 09:09:19 -0800 Subject: Use strcasecmp if available, instead of downcasing string before strcmp Signed-off-by: Alan Coopersmith --- configure.ac | 3 +++ xrefresh.c | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) 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]) diff --git a/xrefresh.c b/xrefresh.c index b160112..8b16873 100644 --- a/xrefresh.c +++ b/xrefresh.c @@ -50,14 +50,21 @@ SOFTWARE. * screen. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include #include #include -#include #include +#ifndef HAVE_STRCASECMP +# include +#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); } -- cgit v1.2.3