summaryrefslogtreecommitdiff
path: root/string
diff options
context:
space:
mode:
Diffstat (limited to 'string')
-rw-r--r--string/stratcliff.c4
-rw-r--r--string/tester.c13
2 files changed, 15 insertions, 2 deletions
diff --git a/string/stratcliff.c b/string/stratcliff.c
index ebe565968e..6115d2f8db 100644
--- a/string/stratcliff.c
+++ b/string/stratcliff.c
@@ -1,5 +1,5 @@
/* Test for string function add boundaries of usable memory.
- Copyright (C) 1996 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -41,7 +41,7 @@ main (int argc, char *argv[])
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
dest = (char *) mmap (NULL, 3*size, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
- if (adr == (char *)-1L || dest == (char *)-1L)
+ if (adr == MAP_FAILED || dest == MAP_FAILED)
{
if (errno == ENOSYS)
puts ("No test, mmap not available.");
diff --git a/string/tester.c b/string/tester.c
index 23d0af8acb..0e65442063 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -107,6 +107,19 @@ main (void)
(void) strcpy (one, "");
equal (one, "", 7); /* Boundary condition. */
+ /* A closely related function is stpcpy. */
+ it = "stpcpy";
+ check ((stpcpy (one, "abcde") - one) == 5, 1);
+ equal (one, "abcde", 2);
+
+ check ((stpcpy (one, "x") - one) == 1, 3);
+ equal (one, "x", 4); /* Writeover. */
+ equal (one+2, "cde", 5); /* Wrote too much? */
+
+ check ((stpcpy (stpcpy (stpcpy (one, "a"), "b"), "c") - one) == 3, 6);
+ equal (one, "abc", 7);
+ equal (one + 4, "e", 8);
+
/* stpncpy. */
it = "stpncpy";