summaryrefslogtreecommitdiff
path: root/string/test-stpncpy.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-11-08 22:10:01 +0000
committerRoland McGrath <roland@gnu.org>2002-11-08 22:10:01 +0000
commite8c1660f7ba480c5a17103b557941fc6db7a5146 (patch)
tree71673df7864e35860bd8c7e8d2f3424fdb1dffc9 /string/test-stpncpy.c
parente0bc9a8d13290de5328ae49311493246f406e0bd (diff)
downloadglibc-e8c1660f7ba480c5a17103b557941fc6db7a5146.tar.gz
* 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-stpncpy.c')
-rw-r--r--string/test-stpncpy.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/string/test-stpncpy.c b/string/test-stpncpy.c
index 5892c68dc1..5bcb1ddef4 100644
--- a/string/test-stpncpy.c
+++ b/string/test-stpncpy.c
@@ -23,7 +23,9 @@
#include "test-string.h"
char *simple_stpncpy (char *, const char *, size_t);
+char *stupid_stpncpy (char *, const char *, size_t);
+IMPL (stupid_stpncpy, 0)
IMPL (simple_stpncpy, 0)
IMPL (stpncpy, 1)
@@ -42,4 +44,17 @@ simple_stpncpy (char *dst, const char *src, size_t n)
return dst;
}
+char *
+stupid_stpncpy (char *dst, const char *src, size_t n)
+{
+ size_t ns = strlen (src);
+ size_t i, nc = n < ns ? n : ns;
+
+ for (i = 0; i < nc; ++i)
+ dst[i] = src[i];
+ for (; i < n; ++i)
+ dst[i] = '\0';
+ return dst + nc;
+}
+
#include "test-strncpy.c"