From 5e4c481d93333bfc3d4d3607c8d54c6d29d5bd23 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Mon, 9 Sep 2019 16:30:02 +0200 Subject: [PATCH] Yes, strcasecmp is always available, configure. --- configure | 13 ------------- configure.ac | 1 - include/dns.h | 10 ---------- include/setup.h.in | 6 ------ include/sys.h | 4 ---- include/windows/setup.h | 1 - src/crule.c | 3 +-- src/match.c | 31 ++++++------------------------- src/modules/dccallow.c | 4 ++-- src/modules/message.c | 6 +++--- 10 files changed, 12 insertions(+), 67 deletions(-) diff --git a/configure b/configure index 43738f2da..0efd80b8c 100755 --- a/configure +++ b/configure @@ -5883,19 +5883,6 @@ $as_echo "#define HAVE_EXPLICIT_BZERO /**/" >>confdefs.h fi done -for ac_func in strcasecmp -do : - ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" -if test "x$ac_cv_func_strcasecmp" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STRCASECMP 1 -_ACEOF - -$as_echo "#define GOT_STRCASECMP /**/" >>confdefs.h - -fi -done - for ac_func in syslog do : ac_fn_c_check_func "$LINENO" "syslog" "ac_cv_func_syslog" diff --git a/configure.ac b/configure.ac index 7ca6c81e5..98594aa75 100644 --- a/configure.ac +++ b/configure.ac @@ -359,7 +359,6 @@ AC_CHECK_FUNCS(strtok,,AC_DEFINE([NEED_STRTOK], [], [Define if you need the strt AC_CHECK_FUNCS(strerror,,AC_DEFINE([NEED_STRERROR], [], [Define if you need the strerror function.])) AC_CHECK_FUNCS(strtoul,,STRTOUL="strtoul.o") AC_CHECK_FUNCS(explicit_bzero,AC_DEFINE([HAVE_EXPLICIT_BZERO], [], [Define if you have explicit_bzero])) -AC_CHECK_FUNCS(strcasecmp,AC_DEFINE([GOT_STRCASECMP], [], [Define if you have strcasecmp])) AC_CHECK_FUNCS(syslog,AC_DEFINE([HAVE_SYSLOG], [], [Define if you have syslog])) AC_SUBST(STRTOUL) AC_SUBST(CRYPTOLIB) diff --git a/include/dns.h b/include/dns.h index 2bc22630d..282bf7beb 100644 --- a/include/dns.h +++ b/include/dns.h @@ -1,16 +1,6 @@ /* OMG... OMG! WHAT AN INCLUDE HORROR !!! */ -#undef strcasecmp -#undef strncasecmp #include #include -#undef strcasecmp -#undef strncasecmp -#ifndef GOT_STRCASECMP -#define strcasecmp mycmp -#define strncasecmp myncmp -#endif - - typedef enum { DNSREQ_CLIENT = 1, diff --git a/include/setup.h.in b/include/setup.h.in index 18b3e7362..c6674a433 100644 --- a/include/setup.h.in +++ b/include/setup.h.in @@ -25,9 +25,6 @@ /* Define if you have the header file. */ #undef GLOBH -/* Define if you have strcasecmp */ -#undef GOT_STRCASECMP - /* Define if ssl library has SSL_CTX_set1_curves_list */ #undef HAS_SSL_CTX_SET1_CURVES_LIST @@ -97,9 +94,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H -/* Define to 1 if you have the `strcasecmp' function. */ -#undef HAVE_STRCASECMP - /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR diff --git a/include/sys.h b/include/sys.h index d25ac226e..54785b204 100644 --- a/include/sys.h +++ b/include/sys.h @@ -65,10 +65,6 @@ #include #include #endif -#ifndef GOT_STRCASECMP -#define strcasecmp mycmp -#define strncasecmp myncmp -#endif #ifndef _WIN32 #include diff --git a/include/windows/setup.h b/include/windows/setup.h index da4ecf2dd..f71448dfd 100644 --- a/include/windows/setup.h +++ b/include/windows/setup.h @@ -41,7 +41,6 @@ #define PREFIX_AQ #define LIST_SHOW_MODES #ifndef mode_t -#define GOT_STRCASECMP #define strcasecmp _strcasecmp #define strncasecmp _strncasecmp #define HAVE_EXPLICIT_BZERO diff --git a/src/crule.c b/src/crule.c index de85701b0..079ed7739 100644 --- a/src/crule.c +++ b/src/crule.c @@ -49,7 +49,6 @@ ID_Copyright("(C) Tony Vincell"); #include #include #define BadPtr(x) (!(x) || (*(x) == '\0')) -#define mycmp strcasecmp #endif #if defined(CR_DEBUG) || defined(CR_CHKCONF) @@ -562,7 +561,7 @@ int crule_parsefunction(crule_treeptr *funcrootp, int *next_tokp, char **rulept { for (funcnum = 0;; funcnum++) { - if (mycmp(crule_funclist[funcnum].name, funcname) == 0) + if (strcasecmp(crule_funclist[funcnum].name, funcname) == 0) break; if (crule_funclist[funcnum].name[0] == '\0') return (CR_UNKNWFUNC); diff --git a/src/match.c b/src/match.c index 1b91bdb3e..7dee6fac4 100644 --- a/src/match.c +++ b/src/match.c @@ -203,10 +203,12 @@ char *collapse(char *pattern) } -/* - * Case insensitive comparison of two NULL terminated strings. - * - * returns 0, if s1 equal to s2 +/* Case insensitive comparison of two NULL terminated strings, + * using the "IRC nick comparisson" rules. Or, well, partially + * anyway. + * Should be used for NICK-related comparissons. And probably + * not even then, since this does not deal with multibyte. + * @returns 0, if s1 equal to s2 * <0, if s1 lexicographically less than s2 * >0, if s1 lexicographically greater than s2 */ @@ -229,27 +231,6 @@ int smycmp(const char *s1, const char *s2) return (res); } - -int myncmp(const char *str1, const char *str2, int n) -{ - u_char *s1; - u_char *s2; - int res; - - s1 = (u_char *)str1; - s2 = (u_char *)str2; - - while ((res = toupper(*s1) - toupper(*s2)) == 0) - { - s1++; - s2++; - n--; - if (n == 0 || (*s1 == '\0' && *s2 == '\0')) - return 0; - } - return (res); -} - u_char tolowertab[] = { 0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, diff --git a/src/modules/dccallow.c b/src/modules/dccallow.c index 073b4ff1d..9f42cbb02 100644 --- a/src/modules/dccallow.c +++ b/src/modules/dccallow.c @@ -133,7 +133,7 @@ CMD_FUNC(m_dccallow) } del_dccallow(sptr, acptr); } else - if (!didlist && !myncmp(s, "list", 4)) + if (!didlist && !strncasecmp(s, "list", 4)) { didanything = didlist = 1; sendnumericfmt(sptr, RPL_DCCINFO, "The following users are on your dcc allow list:"); @@ -147,7 +147,7 @@ CMD_FUNC(m_dccallow) } sendnumeric(sptr, RPL_ENDOFDCCLIST, s); } else - if (!didhelp && !myncmp(s, "help", 4)) + if (!didhelp && !strncasecmp(s, "help", 4)) { didanything = didhelp = 1; for(ptr = dcc_help; *ptr; ptr++) diff --git a/src/modules/message.c b/src/modules/message.c index 15e2e3df6..aedd175a1 100644 --- a/src/modules/message.c +++ b/src/modules/message.c @@ -581,9 +581,9 @@ int size_string, ret; ctcp = &text[1]; /* Most likely a DCC send .. */ - if (!myncmp(ctcp, "DCC SEND ", 9)) + if (!strncasecmp(ctcp, "DCC SEND ", 9)) ctcp = text + 10; - else if (!myncmp(ctcp, "DCC RESUME ", 11)) + else if (!strncasecmp(ctcp, "DCC RESUME ", 11)) ctcp = text + 12; else return 1; /* something else, allow */ @@ -660,7 +660,7 @@ int size_string; ctcp = &text[1]; /* Most likely a DCC send .. */ - if (!myncmp(ctcp, "DCC SEND ", 9)) + if (!strncasecmp(ctcp, "DCC SEND ", 9)) ctcp = text + 10; else return 1; /* something else, allow */