From 79c977cf0a61b5f2ad724323c1676ba7e3abb2cc Mon Sep 17 00:00:00 2001 From: Jeff Morriss Date: Tue, 28 Oct 2014 21:43:12 -0400 Subject: Remove the optional strncasecmp.{h,c} target (for systems that don't have that API). strncasecmp() has been prohibited for years (in favor of the g_ascii_ version). Change-Id: I64b7c29099b1c5240757e2026fe3490096a84755 Reviewed-on: https://code.wireshark.org/review/4980 Petri-Dish: Anders Broman Tested-by: Petri Dish Buildbot Reviewed-by: Jeff Morriss --- ConfigureChecks.cmake | 11 --------- config.h.win32 | 5 ----- configure.ac | 13 ----------- wsutil/Makefile.am | 6 +---- wsutil/Makefile.common | 3 +-- wsutil/strncasecmp.c | 61 -------------------------------------------------- wsutil/strncasecmp.h | 40 --------------------------------- wsutil/strptime.c | 11 ++++----- 8 files changed, 6 insertions(+), 144 deletions(-) delete mode 100644 wsutil/strncasecmp.c delete mode 100644 wsutil/strncasecmp.h diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index cfa63150ea..010187237c 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -91,17 +91,6 @@ check_function_exists("mkdtemp" HAVE_MKDTEMP) check_function_exists("mkstemp" HAVE_MKSTEMP) check_function_exists("setresgid" HAVE_SETRESGID) check_function_exists("setresuid" HAVE_SETRESUID) - -# -# Windows doesn't have strncasecmp, but does have stricmp, which has -# the same signature and behavior. We #define strncasecmp to stricmp -# on Windows. -# -if(WIN32) - check_function_exists("stricmp" HAVE_STRNCASECMP) -else() - check_function_exists("strncasecmp" HAVE_STRNCASECMP) -endif() check_function_exists("strptime" HAVE_STRPTIME) check_function_exists("sysconf" HAVE_SYSCONF) diff --git a/config.h.win32 b/config.h.win32 index a5cdf7435d..84995abce9 100644 --- a/config.h.win32 +++ b/config.h.win32 @@ -217,10 +217,6 @@ /* Define to have ntddndis.h */ @HAVE_NTDDNDIS_H@ -/* Define to 1 if you have the strncasecmp function. */ -/* Actually, we don't, but we have strnicmp, and #define strncasecmp to strnicmp below */ -#define HAVE_STRNCASECMP 1 - /* Define if you have the strptime function. */ /* #undef HAVE_STRPTIME 1 */ @@ -242,7 +238,6 @@ #define _WIN32_WINNT _WIN32_WINNT_WINXP #endif -#define strncasecmp strnicmp #define popen _popen #define pclose _pclose diff --git a/configure.ac b/configure.ac index c40d12b4fc..b63ade608d 100644 --- a/configure.ac +++ b/configure.ac @@ -2568,19 +2568,6 @@ AC_CHECK_FUNC(getopt, GETOPT_LO="wsgetopt.lo") AC_SUBST(GETOPT_LO) -AC_CHECK_FUNC(strncasecmp, - [ - STRNCASECMP_INCLUDES="" - STRNCASECMP_LO="" - AC_DEFINE(HAVE_STRNCASECMP, 1, [Define to 1 if you have the strncasecmp function.]) - ], - [ - STRNCASECMP_INCLUDES="strncasecmp.h" - STRNCASECMP_LO="strncasecmp.lo" - ]) -AC_SUBST(STRNCASECMP_INCLUDES) -AC_SUBST(STRNCASECMP_LO) - AC_CHECK_FUNCS(mkstemp mkdtemp) AC_SEARCH_LIBS(inet_aton, [socket nsl], diff --git a/wsutil/Makefile.am b/wsutil/Makefile.am index 063ff9fb02..040c90e64d 100644 --- a/wsutil/Makefile.am +++ b/wsutil/Makefile.am @@ -21,8 +21,7 @@ ACLOCAL_AMFLAGS = `../aclocal-flags` # Optional headers for ABI checking -wsutil_optional_abi_includes = \ - @STRNCASECMP_INCLUDES@ +wsutil_optional_abi_includes = # Header files for functions in libwsutil's ABI on this platform. libwsutil_abi_INCLUDES = \ @@ -36,7 +35,6 @@ wsutil_optional_objects = \ @INET_ATON_LO@ \ @INET_NTOP_LO@ \ @INET_PTON_LO@ \ - @STRNCASECMP_LO@ \ @STRPTIME_LO@ if SSE42_SUPPORTED @@ -78,8 +76,6 @@ EXTRA_libwsutil_la_SOURCES= \ inet_ntop.c \ inet_pton.c \ inet_v6defs.h \ - strncasecmp.c \ - strncasecmp.h \ strptime.c \ strptime.h \ wsgetopt.c \ diff --git a/wsutil/Makefile.common b/wsutil/Makefile.common index 48fa8b090f..f59f4c2af2 100644 --- a/wsutil/Makefile.common +++ b/wsutil/Makefile.common @@ -133,8 +133,7 @@ libwsutil_nonrepl_INCLUDES = \ # Header files that are not generated from other files LIBWSUTIL_INCLUDES = \ - $(libwsutil_nonrepl_INCLUDES) \ - strncasecmp.h + $(libwsutil_nonrepl_INCLUDES) # # Editor modelines - https://www.wireshark.org/tools/modelines.html diff --git a/wsutil/strncasecmp.c b/wsutil/strncasecmp.c deleted file mode 100644 index 5dea7599d5..0000000000 --- a/wsutil/strncasecmp.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (C) 1992, 1996 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU C Library; see the file COPYING.LIB. If - not, write to the Free Software Foundation, Inc., 51 Franklin Street, - Fifth Floor, Boston, MA 02110-1301 USA. */ - -#include -#include - -#include "wsutil/strncasecmp.h" - -/* Compare no more than N characters of S1 and S2, - ignoring case, returning less than, equal to or - greater than zero if S1 is lexicographically less - than, equal to or greater than S2. */ -int -strncasecmp (const char *s1, const char *s2, size_t n) -{ - register const unsigned char *p1 = (const unsigned char *) s1; - register const unsigned char *p2 = (const unsigned char *) s2; - unsigned char c1, c2; - - if (p1 == p2 || n == 0) - return 0; - - do - { - c1 = tolower (*p1++); - c2 = tolower (*p2++); - if (c1 == '\0' || c1 != c2) - return c1 - c2; - } while (--n > 0); - - return c1 - c2; -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local Variables: - * c-basic-offset: 2 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * ex: set shiftwidth=2 tabstop=8 expandtab: - * :indentSize=2:tabSize=8:noTabs=true: - */ diff --git a/wsutil/strncasecmp.h b/wsutil/strncasecmp.h deleted file mode 100644 index f5f0feb391..0000000000 --- a/wsutil/strncasecmp.h +++ /dev/null @@ -1,40 +0,0 @@ -/* strncasecmp.h - * - * Wireshark - Network traffic analyzer - * By Gerald Combs - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __STRNCASECMP_H__ -#define __STRNCASECMP_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include "ws_symbol_export.h" - -/* - * Version of "strncasecmp()", for the benefit of OSes that don't have it. - */ -WS_DLL_PUBLIC int strncasecmp (const char *, const char *, size_t); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/wsutil/strptime.c b/wsutil/strptime.c index 5a1eec1db1..d69a0199f3 100644 --- a/wsutil/strptime.c +++ b/wsutil/strptime.c @@ -30,10 +30,7 @@ #include #include #include - -#ifndef HAVE_STRNCASECMP -#include "wsutil/strncasecmp.h" -#endif +#include #ifdef _LIBC # include "../locale/localeinfo.h" @@ -75,13 +72,13 @@ localtime_r (t, tp) #if defined __GNUC__ && __GNUC__ >= 2 # define match_string(cs1, s2) \ ({ size_t len = strlen (cs1); \ - int result = strncasecmp ((cs1), (s2), len) == 0; \ + int result = g_ascii_strncasecmp ((cs1), (s2), len) == 0; \ if (result) (s2) += len; \ result; }) #else /* Oh come on. Get a reasonable compiler. */ # define match_string(cs1, s2) \ - (strncasecmp ((cs1), (s2), strlen (cs1)) ? 0 : ((s2) += strlen (cs1), 1)) + (g_ascii_strncasecmp ((cs1), (s2), strlen (cs1)) ? 0 : ((s2) += strlen (cs1), 1)) #endif /* We intentionally do not use isdigit() for testing because this will lead to problems with the wide character version. */ @@ -117,7 +114,7 @@ localtime_r (t, tp) while (*alts != '\0') \ { \ size_t len = strlen (alts); \ - if (strncasecmp (alts, rp, len) == 0) \ + if (g_ascii_strncasecmp (alts, rp, len) == 0) \ break; \ alts += len + 1; \ ++val; \ -- cgit v1.2.1