From b98f587a7fe5651c0477907aa07c753b0894f143 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 16 Jun 2015 08:47:43 +0200 Subject: [PATCH] replace str{,n}casecmp by _str{,n}icmp when available The "strings.h" header should also only get included when strcasecmp or strncasecmp are available. Signed-off-by: Sven Verdoolaege --- configure.ac | 10 ++++++++++ isl_config_post.h | 12 ++++++++++++ isl_stream.c | 1 - pip.c | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1a501e02..a65d7b02 100644 --- a/configure.ac +++ b/configure.ac @@ -76,6 +76,16 @@ if test "x$ac_cv_have_decl_ffs" = xno -a \ "x$ac_cv_have_decl__BitScanForward" = xno; then AC_MSG_ERROR([No ffs implementation found]) fi +AC_CHECK_DECLS([strcasecmp,strncasecmp],[],[],[#include ]) +AC_CHECK_DECLS([_stricmp,_strnicmp],[],[],[#include ]) +if test "x$ac_cv_have_decl_strcasecmp" = xno -a \ + "x$ac_cv_have_decl__stricmp" = xno; then + AC_MSG_ERROR([No strcasecmp implementation found]) +fi +if test "x$ac_cv_have_decl_strncasecmp" = xno -a \ + "x$ac_cv_have_decl__strnicmp" = xno; then + AC_MSG_ERROR([No strncasecmp implementation found]) +fi AC_SUBST(CLANG_CXXFLAGS) AC_SUBST(CLANG_LDFLAGS) diff --git a/isl_config_post.h b/isl_config_post.h index 8b609564..bcc46ea6 100644 --- a/isl_config_post.h +++ b/isl_config_post.h @@ -15,6 +15,18 @@ int isl_ffs(int i); #define ffs isl_ffs #endif +#if HAVE_DECL_STRCASECMP || HAVE_DECL_STRNCASECMP +#include +#endif + +#if !HAVE_DECL_STRCASECMP && HAVE_DECL__STRICMP +#define strcasecmp _stricmp +#endif + +#if !HAVE_DECL_STRNCASECMP && HAVE_DECL__STRNICMP +#define strncasecmp _strnicmp +#endif + #ifdef GCC_WARN_UNUSED_RESULT #define WARN_UNUSED GCC_WARN_UNUSED_RESULT #else diff --git a/isl_stream.c b/isl_stream.c index ee62aca5..cf1fd5e7 100644 --- a/isl_stream.c +++ b/isl_stream.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/pip.c b/pip.c index 449293bd..72b2bef6 100644 --- a/pip.c +++ b/pip.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -22,6 +21,7 @@ #include #include #include +#include /* The input of this program is the same as that of the "example" program * from the PipLib distribution, except that the "big parameter column" -- 2.11.4.GIT