diff options
author | Roland McGrath <roland@gnu.org> | 2002-11-08 22:10:01 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2002-11-08 22:10:01 +0000 |
commit | e8c1660f7ba480c5a17103b557941fc6db7a5146 (patch) | |
tree | 71673df7864e35860bd8c7e8d2f3424fdb1dffc9 /string/test-strcspn.c | |
parent | e0bc9a8d13290de5328ae49311493246f406e0bd (diff) | |
download | glibc-e8c1660f7ba480c5a17103b557941fc6db7a5146.tar.gz glibc-e8c1660f7ba480c5a17103b557941fc6db7a5146.tar.xz glibc-e8c1660f7ba480c5a17103b557941fc6db7a5146.zip |
* string/test-strchr.c (stupid_strchr): New function.
(do_random_tests): Make sure the string is zero terminated. * string/test-strpbrk.c (stupid_strpbrk): New function. (do_random_tests): Make sure the string is zero terminated. * string/test-strcmp.c (stupid_strcmp): New function. (do_random_tests): Make sure the strings are zero terminated. * string/test-strspn.c (stupid_strspn): New function. (simple_strspn): Rename rej argument to acc. (do_random_tests): Make sure the string is zero terminated. * string/test-strcspn.c (stupid_strcspn): New function. * string/test-strncpy.c (stupid_strncpy): New function. * string/test-stpncpy.c (stupid_stpncpy): New function. * string/test-strncmp.c (stupid_strncmp): New function. (do_random_tests): Make sure the strings are zero terminated. * string/test-string.h (impl_t): Change test into long. (IMPL): Add __attribute__((aligned (sizeof (void *)))).
Diffstat (limited to 'string/test-strcspn.c')
-rw-r--r-- | string/test-strcspn.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/string/test-strcspn.c b/string/test-strcspn.c index 0fd65cd988..b5631790b6 100644 --- a/string/test-strcspn.c +++ b/string/test-strcspn.c @@ -25,7 +25,9 @@ typedef size_t (*proto_t) (const char *, const char *); size_t simple_strcspn (const char *, const char *); +size_t stupid_strcspn (const char *, const char *); +IMPL (stupid_strcspn, 0) IMPL (simple_strcspn, 0) IMPL (strcspn, 1) @@ -34,7 +36,7 @@ simple_strcspn (const char *s, const char *rej) { const char *r, *str = s; char c; - + while ((c = *s++) != '\0') for (r = rej; *r != '\0'; ++r) if (*r == c) @@ -42,4 +44,17 @@ simple_strcspn (const char *s, const char *rej) return s - str - 1; } +size_t +stupid_strcspn (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 i; + return i; +} + #include "test-strpbrk.c" |