From ed65e8b4f02a6da7f1c5d85984a9ccf6a94d0181 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 12 May 2008 18:49:34 -0700 Subject: Check for strcasestr and workaround it on systems without it --- config/hal.c | 13 +++++++++++++ configure.ac | 2 +- include/dix-config.h.in | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/config/hal.c b/config/hal.c index 67ffa0304..e197cb1b4 100644 --- a/config/hal.c +++ b/config/hal.c @@ -260,7 +260,17 @@ device_added(LibHalContext *hal_ctx, const char *udi) * Since we can't predict the order in which the keys * arrive, we need to store them. */ +#ifndef HAVE_STRCASESTR + int psi_key_len = strlen(psi_key); + char *lower_psi_key = xalloc(psi_key_len + 1); + + CopyISOLatin1Lowered((unsigned char *) lower_psi_key, + (unsigned char *) psi_key, + psi_key_len); + if ((tmp = strstr(lower_psi_key, "xkb"))) +#else if ((tmp = strcasestr(psi_key, "xkb"))) +#endif { if (!strcasecmp(&tmp[3], "layout")) { @@ -289,6 +299,9 @@ device_added(LibHalContext *hal_ctx, const char *udi) add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val); xfree(tmp_val); } +#ifndef HAVE_STRCASESTR + xfree(lower_psi_key); +#endif } } else if (!strncasecmp(psi_key, LIBHAL_XKB_PROP_KEY, sizeof(LIBHAL_XKB_PROP_KEY)-1)){ diff --git a/configure.ac b/configure.ac index d78f12292..8716ba51d 100644 --- a/configure.ac +++ b/configure.ac @@ -191,7 +191,7 @@ dnl Checks for library functions. AC_FUNC_VPRINTF AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \ strtol getopt getopt_long vsnprintf walkcontext backtrace \ - getisax getzoneid shmctl64]) + getisax getzoneid shmctl64 strcasestr]) AC_FUNC_ALLOCA dnl Old HAS_* names used in os/*.c. AC_CHECK_FUNC([getdtablesize], diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 387f65aa1..914ce4947 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -205,6 +205,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `strcasestr' function. */ +#undef HAVE_STRCASESTR + /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR -- cgit v1.2.3