]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove isc_string_strcasestr implementation and clean up the header and headers
authorOndřej Surý <ondrej@sury.org>
Thu, 5 Apr 2018 11:44:25 +0000 (13:44 +0200)
committerOndřej Surý <ondrej@sury.org>
Thu, 12 Apr 2018 08:37:33 +0000 (10:37 +0200)
lib/isc/include/isc/string.h
lib/isc/string.c
lib/isc/win32/libisc.def.in

index 67ed24e61570d78e5eabc47b1d0f32531eb99944..9750163aa92b089877e22c65a135207d80ad5986 100644 (file)
@@ -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 <isc/formatcheck.h>
-#include <isc/int.h>
-#include <isc/lang.h>
-#include <isc/platform.h>
-#include <isc/types.h>
-
 #include <string.h>
 
-#ifdef ISC_PLATFORM_HAVESTRINGSH
-#include <strings.h>
-#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 */
index b1b985b6a2f92b3889da4562fc3601f9c32ead4b..ff37f61944ff405d2d40fadd91ffc853e2bb7e85 100644 (file)
 
 /*! \file */
 
-#include <config.h>
+#include <config.h>      // IWYU pragma: keep
 
-#include <ctype.h>
+#include <string.h>
 
-#include <isc/mem.h>
-#include <isc/print.h>
-#include <isc/region.h>
-#include <isc/string.h>
-#include <isc/util.h>
+#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);
-
-}
index fe4a6c2057d6af57df4004cb89e3b453b0c66681..72687aee2feeb16adbe3d83645b5c5bf39566dbc 100644 (file)
@@ -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