Remove isc_string_strcasestr implementation and clean up the header and headers

This commit is contained in:
Ondřej Surý
2018-04-05 13:44:25 +02:00
parent 11f26b42e3
commit 7278c455bc
3 changed files with 14 additions and 63 deletions

View 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 */

View File

@@ -40,15 +40,11 @@
/*! \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);
}

View 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