From: Ondřej Surý Date: Thu, 5 Apr 2018 11:44:25 +0000 (+0200) Subject: Remove isc_string_strcasestr implementation and clean up the header and headers X-Git-Tag: v9.13.0~60^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7278c455bc24bb39af469f5af3444c2ef630da2e;p=thirdparty%2Fbind9.git Remove isc_string_strcasestr implementation and clean up the header and headers --- diff --git a/lib/isc/include/isc/string.h b/lib/isc/include/isc/string.h index 67ed24e6157..9750163aa92 100644 --- a/lib/isc/include/isc/string.h +++ b/lib/isc/include/isc/string.h @@ -9,42 +9,24 @@ * information regarding copyright ownership. */ -/* $Id: string.h,v 1.23 2007/09/13 04:48:16 each Exp $ */ - -#ifndef ISC_STRING_H -#define ISC_STRING_H 1 +#pragma once /*! \file isc/string.h */ -#include -#include -#include -#include -#include - #include -#ifdef ISC_PLATFORM_HAVESTRINGSH -#include -#endif - -#define ISC_STRING_MAGIC 0x5e +#include "isc/platform.h" +#include "isc/lang.h" ISC_LANG_BEGINDECLS -#ifdef ISC_PLATFORM_NEEDMEMMOVE -#define memmove(a,b,c) bcopy(b,a,c) -#endif - size_t isc_string_strlcpy(char *dst, const char *src, size_t size); - #ifdef ISC_PLATFORM_NEEDSTRLCPY #define strlcpy isc_string_strlcpy #endif - size_t isc_string_strlcat(char *dst, const char *src, size_t size); @@ -52,13 +34,4 @@ isc_string_strlcat(char *dst, const char *src, size_t size); #define strlcat isc_string_strlcat #endif -char * -isc_string_strcasestr(const char *big, const char *little); - -#ifdef ISC_PLATFORM_NEEDSTRCASESTR -#define strcasestr isc_string_strcasestr -#endif - ISC_LANG_ENDDECLS - -#endif /* ISC_STRING_H */ diff --git a/lib/isc/string.c b/lib/isc/string.c index b1b985b6a2f..ff37f61944f 100644 --- a/lib/isc/string.c +++ b/lib/isc/string.c @@ -40,15 +40,11 @@ /*! \file */ -#include +#include // IWYU pragma: keep -#include +#include -#include -#include -#include -#include -#include +#include "isc/string.h" // IWYU pragma: keep size_t isc_string_strlcpy(char *dst, const char *src, size_t size) @@ -60,15 +56,17 @@ isc_string_strlcpy(char *dst, const char *src, size_t size) /* Copy as many bytes as will fit */ if (n != 0U && --n != 0U) { do { - if ((*d++ = *s++) == 0) + if ((*d++ = *s++) == 0) { break; + } } while (--n != 0U); } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0U) { - if (size != 0U) + if (size != 0U) { *d = '\0'; /* NUL-terminate dst */ + } while (*s++) ; } @@ -85,13 +83,15 @@ isc_string_strlcat(char *dst, const char *src, size_t size) size_t dlen; /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0U && *d != '\0') + while (n-- != 0U && *d != '\0') { d++; + } dlen = d - dst; n = size - dlen; - if (n == 0U) + if (n == 0U) { return(dlen + strlen(s)); + } while (*s != '\0') { if (n != 1U) { *d++ = *s; @@ -103,24 +103,3 @@ isc_string_strlcat(char *dst, const char *src, size_t size) return(dlen + (s - src)); /* count does not include NUL */ } - -char * -isc_string_strcasestr(const char *str, const char *search) { - char c, sc, *s; - size_t len; - - if ((c = *search++) != 0) { - c = tolower((unsigned char) c); - len = strlen(search); - do { - do { - if ((sc = *str++) == 0) - return (NULL); - } while ((char) tolower((unsigned char) sc) != c); - } while (strncasecmp(str, search, len) != 0); - str--; - } - DE_CONST(str, s); - return (s); - -} diff --git a/lib/isc/win32/libisc.def.in b/lib/isc/win32/libisc.def.in index fe4a6c2057d..72687aee2fe 100644 --- a/lib/isc/win32/libisc.def.in +++ b/lib/isc/win32/libisc.def.in @@ -645,7 +645,6 @@ isc_stdio_sync isc_stdio_tell isc_stdio_write isc_stdtime_get -isc_string_strcasestr isc_string_strlcat isc_string_strlcpy isc_symtab_count