aboutsummaryrefslogtreecommitdiff
path: root/string/test-strncpy.c
diff options
context:
space:
mode:
Diffstat (limited to 'string/test-strncpy.c')
-rw-r--r--string/test-strncpy.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/string/test-strncpy.c b/string/test-strncpy.c
index 5aa51692bb..11ff30eebf 100644
--- a/string/test-strncpy.c
+++ b/string/test-strncpy.c
@@ -24,7 +24,9 @@
# include "test-string.h"
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)
@@ -41,6 +43,19 @@ 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 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;
+}
#endif
typedef char *(*proto_t) (char *, const char *, size_t);