diff options
-rw-r--r-- | string/test-memccpy.c | 18 | ||||
-rw-r--r-- | string/test-memchr.c | 3 | ||||
-rw-r--r-- | string/test-memcmp.c | 1 | ||||
-rw-r--r-- | string/test-memcpy-support.h | 12 | ||||
-rw-r--r-- | string/test-memmem.c | 3 | ||||
-rw-r--r-- | string/test-memmove.c | 6 | ||||
-rw-r--r-- | string/test-mempcpy.c | 4 | ||||
-rw-r--r-- | string/test-memrchr.c | 3 | ||||
-rw-r--r-- | string/test-memset.c | 42 | ||||
-rw-r--r-- | string/test-strcasecmp.c | 25 | ||||
-rw-r--r-- | string/test-strcasestr.c | 11 | ||||
-rw-r--r-- | string/test-strcat.c | 3 | ||||
-rw-r--r-- | string/test-strchr.c | 16 | ||||
-rw-r--r-- | string/test-strcmp.c | 1 | ||||
-rw-r--r-- | string/test-strcpy.c | 4 | ||||
-rw-r--r-- | string/test-strlen.c | 2 | ||||
-rw-r--r-- | string/test-strncasecmp.c | 25 | ||||
-rw-r--r-- | string/test-strncat.c | 8 | ||||
-rw-r--r-- | string/test-strncmp.c | 1 | ||||
-rw-r--r-- | string/test-strncpy.c | 19 | ||||
-rw-r--r-- | string/test-strnlen.c | 3 | ||||
-rw-r--r-- | string/test-strpbrk.c | 21 | ||||
-rw-r--r-- | string/test-strrchr.c | 3 | ||||
-rw-r--r-- | string/test-strspn.c | 24 | ||||
-rw-r--r-- | string/test-strstr.c | 15 |
25 files changed, 43 insertions, 230 deletions
diff --git a/string/test-memccpy.c b/string/test-memccpy.c index ee2cf8b..c7cc866 100644 --- a/string/test-memccpy.c +++ b/string/test-memccpy.c @@ -20,13 +20,9 @@ #define TEST_NAME "memccpy" #include "test-string.h" -void *simple_memccpy (void *, const void *, int, size_t); -void *stupid_memccpy (void *, const void *, int, size_t); - -IMPL (stupid_memccpy, 0) -IMPL (simple_memccpy, 0) IMPL (memccpy, 1) +/* Naive implementation to verify results. */ void * simple_memccpy (void *dst, const void *src, int c, size_t n) { @@ -40,18 +36,6 @@ simple_memccpy (void *dst, const void *src, int c, size_t n) return NULL; } -void * -stupid_memccpy (void *dst, const void *src, int c, size_t n) -{ - void *p = memchr (src, c, n); - - if (p != NULL) - return mempcpy (dst, src, p - src + 1); - - memcpy (dst, src, n); - return NULL; -} - typedef void *(*proto_t) (void *, const void *, int c, size_t); static void diff --git a/string/test-memchr.c b/string/test-memchr.c index a461708..279a67e 100644 --- a/string/test-memchr.c +++ b/string/test-memchr.c @@ -44,11 +44,10 @@ #endif /* WIDE */ typedef CHAR *(*proto_t) (const CHAR *, int, size_t); -CHAR *SIMPLE_MEMCHR (const CHAR *, int, size_t); -IMPL (SIMPLE_MEMCHR, 0) IMPL (MEMCHR, 1) +/* Naive implementation to verify results. */ CHAR * SIMPLE_MEMCHR (const CHAR *s, int c, size_t n) { diff --git a/string/test-memcmp.c b/string/test-memcmp.c index 89ef341..181b689 100644 --- a/string/test-memcmp.c +++ b/string/test-memcmp.c @@ -85,7 +85,6 @@ SIMPLE_MEMCMP (const char *s1, const char *s2, size_t n) typedef int (*proto_t) (const CHAR *, const CHAR *, size_t); -IMPL (SIMPLE_MEMCMP, 0) IMPL (MEMCMP, 1) static int diff --git a/string/test-memcpy-support.h b/string/test-memcpy-support.h index 699c00c..0ea982b 100644 --- a/string/test-memcpy-support.h +++ b/string/test-memcpy-support.h @@ -29,12 +29,9 @@ #define TIMEOUT (8 * 60) #include "test-string.h" -char *simple_memcpy (char *, const char *, size_t); -char *builtin_memcpy (char *, const char *, size_t); - -IMPL (simple_memcpy, 0) -IMPL (builtin_memcpy, 0) IMPL (memcpy, 1) + +/* Naive implementation to verify results. */ char * simple_memcpy (char *dst, const char *src, size_t n) { @@ -44,11 +41,6 @@ simple_memcpy (char *dst, const char *src, size_t n) return ret; } -char * -builtin_memcpy (char *dst, const char *src, size_t n) -{ - return __builtin_memcpy (dst, src, n); -} #endif typedef char *(*proto_t) (char *, const char *, size_t); typedef uint32_t __attribute__ ((may_alias, aligned (1))) unaligned_uint32_t; diff --git a/string/test-memmem.c b/string/test-memmem.c index 37d3ea4..69803be 100644 --- a/string/test-memmem.c +++ b/string/test-memmem.c @@ -23,11 +23,10 @@ #include "test-string.h" typedef char *(*proto_t) (const void *, size_t, const void *, size_t); -void *simple_memmem (const void *, size_t, const void *, size_t); -IMPL (simple_memmem, 0) IMPL (memmem, 1) +/* Naive implementation to verify results. */ void * simple_memmem (const void *haystack, size_t haystack_len, const void *needle, size_t needle_len) diff --git a/string/test-memmove.c b/string/test-memmove.c index 8d9ac86..be8752e 100644 --- a/string/test-memmove.c +++ b/string/test-memmove.c @@ -29,23 +29,23 @@ char *simple_memmove (char *, const char *, size_t); #ifdef TEST_BCOPY typedef void (*proto_t) (const char *, char *, size_t); -void simple_bcopy (const char *, char *, size_t); -IMPL (simple_bcopy, 0) IMPL (bcopy, 1) +/* Naive implementation to verify results. */ void simple_bcopy (const char *src, char *dst, size_t n) { simple_memmove (dst, src, n); } + #else typedef char *(*proto_t) (char *, const char *, size_t); -IMPL (simple_memmove, 0) IMPL (memmove, 1) #endif +/* Naive implementation to verify results. */ char * inhibit_loop_to_libcall simple_memmove (char *dst, const char *src, size_t n) diff --git a/string/test-mempcpy.c b/string/test-mempcpy.c index 9637d02..75808b2 100644 --- a/string/test-mempcpy.c +++ b/string/test-mempcpy.c @@ -22,11 +22,9 @@ #define TEST_NAME "mempcpy" #include "test-string.h" -char *simple_mempcpy (char *, const char *, size_t); - -IMPL (simple_mempcpy, 0) IMPL (mempcpy, 1) +/* Naive implementation to verify results. */ char * simple_mempcpy (char *dst, const char *src, size_t n) { diff --git a/string/test-memrchr.c b/string/test-memrchr.c index 8d60d17..80419a6 100644 --- a/string/test-memrchr.c +++ b/string/test-memrchr.c @@ -21,11 +21,10 @@ #include "test-string.h" typedef char *(*proto_t) (const char *, int, size_t); -char *simple_memrchr (const char *, int, size_t); -IMPL (simple_memrchr, 0) IMPL (memrchr, 1) +/* Naive implementation to verify results. */ char * simple_memrchr (const char *s, int c, size_t n) { diff --git a/string/test-memset.c b/string/test-memset.c index ee548f6..00582c8 100644 --- a/string/test-memset.c +++ b/string/test-memset.c @@ -50,51 +50,19 @@ # define BIG_CHAR WCHAR_MAX #endif /* WIDE */ -CHAR *SIMPLE_MEMSET (CHAR *, int, size_t); - #ifdef TEST_BZERO typedef void (*proto_t) (char *, size_t); -void simple_bzero (char *, size_t); -void builtin_bzero (char *, size_t); - -IMPL (simple_bzero, 0) -IMPL (builtin_bzero, 0) -#ifdef TEST_EXPLICIT_BZERO +# ifdef TEST_EXPLICIT_BZERO IMPL (explicit_bzero, 1) -#else +# else IMPL (bzero, 1) -#endif - -void -simple_bzero (char *s, size_t n) -{ - SIMPLE_MEMSET (s, 0, n); -} - -void -builtin_bzero (char *s, size_t n) -{ - __builtin_bzero (s, n); -} +# endif #else typedef CHAR *(*proto_t) (CHAR *, int, size_t); - -IMPL (SIMPLE_MEMSET, 0) -# ifndef WIDE -char *builtin_memset (char *, int, size_t); -IMPL (builtin_memset, 0) -# endif /* !WIDE */ IMPL (MEMSET, 1) - -# ifndef WIDE -char * -builtin_memset (char *s, int c, size_t n) -{ - return __builtin_memset (s, c, n); -} -# endif /* !WIDE */ #endif /* !TEST_BZERO */ +/* Naive implementation to verify results. */ CHAR * inhibit_loop_to_libcall SIMPLE_MEMSET (CHAR *s, int c, size_t n) @@ -116,7 +84,7 @@ do_one_test (impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n, int s[n] = sentinel; SIMPLE_MEMSET(s, ~c, n); #ifdef TEST_BZERO - simple_bzero (buf, n); + SIMPLE_MEMSET (buf, 0, n); CALL (impl, s, n); if (memcmp (s, buf, n) != 0 || (space_below && s[-1] != sentinel) diff --git a/string/test-strcasecmp.c b/string/test-strcasecmp.c index 438a971..fe48d11 100644 --- a/string/test-strcasecmp.c +++ b/string/test-strcasecmp.c @@ -27,14 +27,11 @@ #include "test-string.h" typedef int (*proto_t) (const char *, const char *); -static int simple_strcasecmp (const char *, const char *); -static int stupid_strcasecmp (const char *, const char *); -IMPL (stupid_strcasecmp, 0) -IMPL (simple_strcasecmp, 0) IMPL (strcasecmp, 1) -static int +/* Naive implementation to verify results. */ +int simple_strcasecmp (const char *s1, const char *s2) { int ret; @@ -46,24 +43,6 @@ simple_strcasecmp (const char *s1, const char *s2) return ret; } -static int -stupid_strcasecmp (const char *s1, const char *s2) -{ - size_t ns1 = strlen (s1) + 1, ns2 = strlen (s2) + 1; - size_t n = ns1 < ns2 ? ns1 : ns2; - int ret = 0; - - while (n--) - { - if ((ret = ((unsigned char) tolower (*s1) - - (unsigned char) tolower (*s2))) != 0) - break; - ++s1; - ++s2; - } - return ret; -} - static void do_one_test (impl_t *impl, const char *s1, const char *s2, int exp_result) { diff --git a/string/test-strcasestr.c b/string/test-strcasestr.c index b73bcfe..0d39c62 100644 --- a/string/test-strcasestr.c +++ b/string/test-strcasestr.c @@ -21,15 +21,15 @@ #include "test-string.h" -#define STRCASESTR simple_strcasestr +#define STRCASESTR c_strcasestr #define NO_ALIAS #define __strncasecmp strncasecmp #define __strnlen strnlen #include "strcasestr.c" - +/* Naive implementation to verify results. */ static char * -stupid_strcasestr (const char *s1, const char *s2) +simple_strcasestr (const char *s1, const char *s2) { ssize_t s1len = strlen (s1); ssize_t s2len = strlen (s2); @@ -53,8 +53,7 @@ stupid_strcasestr (const char *s1, const char *s2) typedef char *(*proto_t) (const char *, const char *); -IMPL (stupid_strcasestr, 0) -IMPL (simple_strcasestr, 0) +IMPL (c_strcasestr, 0) IMPL (strcasestr, 1) @@ -129,7 +128,7 @@ check1 (void) const char s2[] = "OK"; char *exp_result; - exp_result = stupid_strcasestr (s1, s2); + exp_result = simple_strcasestr (s1, s2); FOR_EACH_IMPL (impl, 0) check_result (impl, s1, s2, exp_result); } diff --git a/string/test-strcat.c b/string/test-strcat.c index b5aab0f..59b953c 100644 --- a/string/test-strcat.c +++ b/string/test-strcat.c @@ -54,11 +54,10 @@ #endif /* WIDE */ typedef CHAR *(*proto_t) (CHAR *, const CHAR *); -CHAR *SIMPLE_STRCAT (CHAR *, const CHAR *); -IMPL (SIMPLE_STRCAT, 0) IMPL (STRCAT, 1) +/* Naive implementation to verify results. */ CHAR * SIMPLE_STRCAT (CHAR *dst, const CHAR *src) { diff --git a/string/test-strchr.c b/string/test-strchr.c index 4d2ab5f..631e377 100644 --- a/string/test-strchr.c +++ b/string/test-strchr.c @@ -35,7 +35,6 @@ #ifndef WIDE # ifdef USE_FOR_STRCHRNUL # define STRCHR strchrnul -# define stupid_STRCHR stupid_STRCHRNUL # define simple_STRCHR simple_STRCHRNUL # else # define STRCHR strchr @@ -51,7 +50,6 @@ # include <wchar.h> # ifdef USE_FOR_STRCHRNUL # define STRCHR wcschrnul -# define stupid_STRCHR stupid_WCSCHRNUL # define simple_STRCHR simple_WCSCHRNUL # else # define STRCHR wcschr @@ -74,18 +72,10 @@ typedef CHAR *(*proto_t) (const CHAR *, int); +/* Naive implementation to verify results. */ CHAR * simple_STRCHR (const CHAR *s, int c) { - for (; *s != (CHAR) c; ++s) - if (*s == '\0') - return NULLRET ((CHAR *) s); - return (CHAR *) s; -} - -CHAR * -stupid_STRCHR (const CHAR *s, int c) -{ size_t n = STRLEN (s) + 1; while (n--) @@ -94,8 +84,6 @@ stupid_STRCHR (const CHAR *s, int c) return NULLRET ((CHAR *) s - 1); } -IMPL (stupid_STRCHR, 0) -IMPL (simple_STRCHR, 0) IMPL (STRCHR, 1) static int @@ -231,7 +219,7 @@ check1 (void) { CHAR s[] __attribute__((aligned(16))) = L ("\xff"); CHAR c = L ('\xfe'); - CHAR *exp_result = stupid_STRCHR (s, c); + CHAR *exp_result = simple_STRCHR (s, c); FOR_EACH_IMPL (impl, 0) check_result (impl, s, c, exp_result); diff --git a/string/test-strcmp.c b/string/test-strcmp.c index ece03c6..2372e92 100644 --- a/string/test-strcmp.c +++ b/string/test-strcmp.c @@ -99,7 +99,6 @@ simple_strcmp (const char *s1, const char *s2) typedef int (*proto_t) (const CHAR *, const CHAR *); -IMPL (SIMPLE_STRCMP, 1) IMPL (STRCMP, 1) static int diff --git a/string/test-strcpy.c b/string/test-strcpy.c index 83b7707..7e7d10a 100644 --- a/string/test-strcpy.c +++ b/string/test-strcpy.c @@ -54,11 +54,9 @@ # define STRCPY wcscpy # endif -CHAR *SIMPLE_STRCPY (CHAR *, const CHAR *); - -IMPL (SIMPLE_STRCPY, 0) IMPL (STRCPY, 1) +/* Naive implementation to verify results. */ CHAR * SIMPLE_STRCPY (CHAR *dst, const CHAR *src) { diff --git a/string/test-strlen.c b/string/test-strlen.c index dd394da..21a9cc1 100644 --- a/string/test-strlen.c +++ b/string/test-strlen.c @@ -37,6 +37,7 @@ typedef size_t (*proto_t) (const CHAR *); +/* Naive implementation to verify results. */ size_t simple_STRLEN (const CHAR *s) { @@ -55,7 +56,6 @@ builtin_strlen (const CHAR *p) IMPL (builtin_strlen, 0) #endif -IMPL (simple_STRLEN, 0) IMPL (STRLEN, 1) diff --git a/string/test-strncasecmp.c b/string/test-strncasecmp.c index 1aebc37..126ced9 100644 --- a/string/test-strncasecmp.c +++ b/string/test-strncasecmp.c @@ -29,12 +29,10 @@ typedef int (*proto_t) (const char *, const char *, size_t); static int simple_strncasecmp (const char *, const char *, size_t); -static int stupid_strncasecmp (const char *, const char *, size_t); -IMPL (stupid_strncasecmp, 0) -IMPL (simple_strncasecmp, 0) IMPL (strncasecmp, 1) +/* Naive implementation to verify results. */ static int simple_strncasecmp (const char *s1, const char *s2, size_t n) { @@ -55,27 +53,6 @@ simple_strncasecmp (const char *s1, const char *s2, size_t n) } static int -stupid_strncasecmp (const char *s1, const char *s2, size_t max) -{ - size_t ns1 = strlen (s1) + 1; - size_t ns2 = strlen (s2) + 1; - size_t n = ns1 < ns2 ? ns1 : ns2; - if (n > max) - n = max; - int ret = 0; - - while (n--) - { - if ((ret = ((unsigned char) tolower (*s1) - - (unsigned char) tolower (*s2))) != 0) - break; - ++s1; - ++s2; - } - return ret; -} - -static int check_result (impl_t *impl, const char *s1, const char *s2, size_t n, int exp_result) { diff --git a/string/test-strncat.c b/string/test-strncat.c index 86ec101..5fcaa86 100644 --- a/string/test-strncat.c +++ b/string/test-strncat.c @@ -28,7 +28,6 @@ # define CHAR char # define UCHAR unsigned char # define SIMPLE_STRNCAT simple_strncat -# define STUPID_STRNCAT stupid_strncat # define STRLEN strlen # define MEMSET memset # define MEMCPY memcpy @@ -41,7 +40,6 @@ # define CHAR wchar_t # define UCHAR wchar_t # define SIMPLE_STRNCAT simple_wcsncat -# define STUPID_STRNCAT stupid_wcsncat # define STRLEN wcslen # define MEMSET wmemset # define MEMCPY wmemcpy @@ -51,14 +49,12 @@ #endif /* WIDE */ typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t); -CHAR *STUPID_STRNCAT (CHAR *, const CHAR *, size_t); -CHAR *SIMPLE_STRNCAT (CHAR *, const CHAR *, size_t); -IMPL (STUPID_STRNCAT, 0) IMPL (STRNCAT, 2) +/* Naive implementation to verify results. */ CHAR * -STUPID_STRNCAT (CHAR *dst, const CHAR *src, size_t n) +SIMPLE_STRNCAT (CHAR *dst, const CHAR *src, size_t n) { CHAR *ret = dst; while (*dst++ != '\0'); diff --git a/string/test-strncmp.c b/string/test-strncmp.c index 3e35142..693ab4d 100644 --- a/string/test-strncmp.c +++ b/string/test-strncmp.c @@ -88,7 +88,6 @@ simple_strncmp (const char *s1, const char *s2, size_t n) typedef int (*proto_t) (const CHAR *, const CHAR *, size_t); -IMPL (SIMPLE_STRNCMP, 0) IMPL (STRNCMP, 1) diff --git a/string/test-strncpy.c b/string/test-strncpy.c index 4ae08ab..f1f627a 100644 --- a/string/test-strncpy.c +++ b/string/test-strncpy.c @@ -47,21 +47,16 @@ # include "test-string.h" # ifndef WIDE # define SIMPLE_STRNCPY simple_strncpy -# define STUPID_STRNCPY stupid_strncpy # define STRNCPY strncpy # else # define SIMPLE_STRNCPY simple_wcsncpy -# define STUPID_STRNCPY stupid_wcsncpy # define STRNCPY wcsncpy # endif /* WIDE */ -CHAR *SIMPLE_STRNCPY (CHAR *, const CHAR *, size_t); -CHAR *STUPID_STRNCPY (CHAR *, const CHAR *, size_t); -IMPL (STUPID_STRNCPY, 0) -IMPL (SIMPLE_STRNCPY, 0) IMPL (STRNCPY, 1) +/* Naive implementation to verify results. */ CHAR * SIMPLE_STRNCPY (CHAR *dst, const CHAR *src, size_t n) { @@ -76,18 +71,6 @@ SIMPLE_STRNCPY (CHAR *dst, const CHAR *src, size_t n) return ret; } -CHAR * -STUPID_STRNCPY (CHAR *dst, const CHAR *src, size_t n) -{ - size_t nc = STRNLEN (src, n); - size_t i; - - for (i = 0; i < nc; ++i) - dst[i] = src[i]; - for (; i < n; ++i) - dst[i] = '\0'; - return dst; -} #endif /* !STRNCPY_RESULT */ typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t); diff --git a/string/test-strnlen.c b/string/test-strnlen.c index 726c630..83c4502 100644 --- a/string/test-strnlen.c +++ b/string/test-strnlen.c @@ -42,11 +42,10 @@ #endif /* !WIDE */ typedef size_t (*proto_t) (const CHAR *, size_t); -size_t SIMPLE_STRNLEN (const CHAR *, size_t); -IMPL (SIMPLE_STRNLEN, 0) IMPL (STRNLEN, 1) +/* Naive implementation to verify results. */ size_t SIMPLE_STRNLEN (const CHAR *s, size_t maxlen) { diff --git a/string/test-strpbrk.c b/string/test-strpbrk.c index 05fd81e..de8dc0a 100644 --- a/string/test-strpbrk.c +++ b/string/test-strpbrk.c @@ -47,22 +47,17 @@ # ifndef WIDE # define STRPBRK strpbrk # define SIMPLE_STRPBRK simple_strpbrk -# define STUPID_STRPBRK stupid_strpbrk # else # include <wchar.h> # define STRPBRK wcspbrk # define SIMPLE_STRPBRK simple_wcspbrk -# define STUPID_STRPBRK stupid_wcspbrk # endif /* WIDE */ typedef CHAR *(*proto_t) (const CHAR *, const CHAR *); -CHAR *SIMPLE_STRPBRK (const CHAR *, const CHAR *); -CHAR *STUPID_STRPBRK (const CHAR *, const CHAR *); -IMPL (STUPID_STRPBRK, 0) -IMPL (SIMPLE_STRPBRK, 0) IMPL (STRPBRK, 1) +/* Naive implementation to verify results. */ CHAR * SIMPLE_STRPBRK (const CHAR *s, const CHAR *rej) { @@ -72,22 +67,10 @@ SIMPLE_STRPBRK (const CHAR *s, const CHAR *rej) while ((c = *s++) != '\0') for (r = rej; *r != '\0'; ++r) if (*r == c) - return (CHAR *) s - 1; + return (CHAR *) s - 1; return NULL; } -CHAR * -STUPID_STRPBRK (const CHAR *s, const CHAR *rej) -{ - size_t ns = STRLEN (s), nrej = STRLEN (rej); - size_t i, j; - - for (i = 0; i < ns; ++i) - for (j = 0; j < nrej; ++j) - if (s[i] == rej[j]) - return (CHAR *) s + i; - return NULL; -} #endif /* !STRPBRK_RESULT */ static void diff --git a/string/test-strrchr.c b/string/test-strrchr.c index a610200..bf4decb 100644 --- a/string/test-strrchr.c +++ b/string/test-strrchr.c @@ -42,11 +42,10 @@ #endif typedef CHAR *(*proto_t) (const CHAR *, int); -CHAR *SIMPLE_STRRCHR (const CHAR *, int); -IMPL (SIMPLE_STRRCHR, 0) IMPL (STRRCHR, 1) +/* Naive implementation to verify results. */ CHAR * SIMPLE_STRRCHR (const CHAR *s, int c) { diff --git a/string/test-strspn.c b/string/test-strspn.c index 1680cb7..a9c4245 100644 --- a/string/test-strspn.c +++ b/string/test-strspn.c @@ -29,7 +29,6 @@ # define CHAR char # define UCHAR unsigned char # define SIMPLE_STRSPN simple_strspn -# define STUPID_STRSPN stupid_strspn # define STRLEN strlen # define STRCHR strchr # define BIG_CHAR CHAR_MAX @@ -40,7 +39,6 @@ # define CHAR wchar_t # define UCHAR wchar_t # define SIMPLE_STRSPN simple_wcsspn -# define STUPID_STRSPN stupid_wcsspn # define STRLEN wcslen # define STRCHR wcschr # define BIG_CHAR WCHAR_MAX @@ -48,13 +46,10 @@ #endif /* WIDE */ typedef size_t (*proto_t) (const CHAR *, const CHAR *); -size_t SIMPLE_STRSPN (const CHAR *, const CHAR *); -size_t STUPID_STRSPN (const CHAR *, const CHAR *); -IMPL (STUPID_STRSPN, 0) -IMPL (SIMPLE_STRSPN, 0) IMPL (STRSPN, 1) +/* Naive implementation to verify results. */ size_t SIMPLE_STRSPN (const CHAR *s, const CHAR *acc) { @@ -72,23 +67,6 @@ SIMPLE_STRSPN (const CHAR *s, const CHAR *acc) return s - str - 1; } -size_t -STUPID_STRSPN (const CHAR *s, const CHAR *acc) -{ - size_t ns = STRLEN (s), nacc = STRLEN (acc); - size_t i, j; - - for (i = 0; i < ns; ++i) - { - for (j = 0; j < nacc; ++j) - if (s[i] == acc[j]) - break; - if (j == nacc) - return i; - } - return i; -} - static void do_one_test (impl_t *impl, const CHAR *s, const CHAR *acc, size_t exp_res) { diff --git a/string/test-strstr.c b/string/test-strstr.c index 7f610f4..b1f2134 100644 --- a/string/test-strstr.c +++ b/string/test-strstr.c @@ -21,14 +21,14 @@ #include "test-string.h" -#define STRSTR simple_strstr +#define STRSTR c_strstr #define libc_hidden_builtin_def(arg) /* nothing */ #define __strnlen strnlen #include "strstr.c" - +/* Naive implementation to verify results. */ static char * -stupid_strstr (const char *s1, const char *s2) +simple_strstr (const char *s1, const char *s2) { ssize_t s1len = strlen (s1); ssize_t s2len = strlen (s2); @@ -52,8 +52,7 @@ stupid_strstr (const char *s1, const char *s2) typedef char *(*proto_t) (const char *, const char *); -IMPL (stupid_strstr, 0) -IMPL (simple_strstr, 0) +IMPL (c_strstr, 0) IMPL (strstr, 1) @@ -130,7 +129,7 @@ check1 (void) const char s2[] = "_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD_EF_BF_BD"; char *exp_result; - exp_result = stupid_strstr (s1, s2); + exp_result = simple_strstr (s1, s2); FOR_EACH_IMPL (impl, 0) check_result (impl, s1, s2, exp_result); } @@ -163,7 +162,7 @@ check2 (void) char *s2_page_cross = (void *) buf2 + page_size_real - 8; strcpy (s2_page_cross, s2_stack); - exp_result = stupid_strstr (s1_stack, s2_stack); + exp_result = simple_strstr (s1_stack, s2_stack); FOR_EACH_IMPL (impl, 0) { check_result (impl, s1_stack, s2_stack, exp_result); @@ -201,7 +200,7 @@ pr23637 (void) /* Ensure we don't match at the first 'x'. */ h[0] = 'x'; - char *exp_result = stupid_strstr (h, n); + char *exp_result = simple_strstr (h, n); FOR_EACH_IMPL (impl, 0) check_result (impl, h, n, exp_result); } |