aboutsummaryrefslogtreecommitdiff
path: root/string
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-02-23 20:29:25 +0000
committerUlrich Drepper <drepper@redhat.com>2001-02-23 20:29:25 +0000
commitd436a9f71094ec7fc8e946058af20a1c167df791 (patch)
treea4b982297630c5af186566289301e8f084b18d04 /string
parent578af3381518983dccfb99df52cc917c43f38542 (diff)
downloadglibc-d436a9f71094ec7fc8e946058af20a1c167df791.zip
glibc-d436a9f71094ec7fc8e946058af20a1c167df791.tar.gz
glibc-d436a9f71094ec7fc8e946058af20a1c167df791.tar.bz2
Update.
2001-02-23 Andreas Jaeger <aj@suse.de> * string/tester.c (test_strtok_r): Add testcase. (test_strtok_r): Always initialize cp for proper checking. * sysdeps/generic/strtok.c (strtok): Handle case of first strtok returning NULL correctly. Patch by Fumitoshi UKAI <ukai@debian.or.jp>. * sysdeps/generic/strtok_r.c (__strtok_r): Likewise. 2001-02-23 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/aix/bits/types.h: Define __need_NULL before including <stddef.h>. * sysdeps/unix/sysv/aix/write.c: Define alias __libc_write. * include/libc-symbols.h (weak_alias): Don't use .weak if HAVE_ASM_GLOBAL_DOT_NAME is defined. Patches by Michael Keezer <mkeezer@redhat.com>. * sysdeps/generic/ftime.c: Don't include <sys/time.h> at all. Patch by Michael Keezer <mkeezer@redhat.com>. * sysdeps/unix/sysv/aix/Dist: Remove restf.S and savef.S. * sysdeps/unix/sysv/aix/Makefile [$(subdir) == misc] (sysdep_routines): Remove restf.S and savef.S. * sysdeps/unix/sysv/aix/restf.S. Removed. * sysdeps/unix/sysv/aix/savef.S. Removed. * sysdeps/powerpc/fprrest.S: Use C_TEXT to define label. Also define alternative names used on some platforms. * sysdeps/powerpc/fprsave.S: Likewise. * sysdeps/powerpc/gprrest0.S: Likewise. * sysdeps/powerpc/gprrest1.S: Likewise. * sysdeps/powerpc/gprsave0.S: Likewise. * sysdeps/powerpc/gprsave1.S: Likewise. Patch by Michael Keezer <mkeezer@redhat.com>.
Diffstat (limited to 'string')
-rw-r--r--string/tester.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/string/tester.c b/string/tester.c
index 1369b21..38a7580 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -1,5 +1,5 @@
/* Tester for string functions.
- Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -759,23 +759,28 @@ test_strtok_r (void)
{
it = "strtok_r";
(void) strcpy(one, "first, second, third");
+ cp = NULL; /* Always initialize cp to make sure it doesn't point to some old data. */
equal(strtok_r(one, ", ", &cp), "first", 1); /* Basic test. */
equal(one, "first", 2);
equal(strtok_r((char *)NULL, ", ", &cp), "second", 3);
equal(strtok_r((char *)NULL, ", ", &cp), "third", 4);
check(strtok_r((char *)NULL, ", ", &cp) == NULL, 5);
(void) strcpy(one, ", first, ");
+ cp = NULL;
equal(strtok_r(one, ", ", &cp), "first", 6); /* Extra delims, 1 tok. */
check(strtok_r((char *)NULL, ", ", &cp) == NULL, 7);
(void) strcpy(one, "1a, 1b; 2a, 2b");
+ cp = NULL;
equal(strtok_r(one, ", ", &cp), "1a", 8); /* Changing delim lists. */
equal(strtok_r((char *)NULL, "; ", &cp), "1b", 9);
equal(strtok_r((char *)NULL, ", ", &cp), "2a", 10);
(void) strcpy(two, "x-y");
+ cp = NULL;
equal(strtok_r(two, "-", &cp), "x", 11); /* New string before done. */
equal(strtok_r((char *)NULL, "-", &cp), "y", 12);
check(strtok_r((char *)NULL, "-", &cp) == NULL, 13);
(void) strcpy(one, "a,b, c,, ,d");
+ cp = NULL;
equal(strtok_r(one, ", ", &cp), "a", 14); /* Different separators. */
equal(strtok_r((char *)NULL, ", ", &cp), "b", 15);
equal(strtok_r((char *)NULL, " ,", &cp), "c", 16); /* Permute list too. */
@@ -783,25 +788,31 @@ test_strtok_r (void)
check(strtok_r((char *)NULL, ", ", &cp) == NULL, 18);
check(strtok_r((char *)NULL, ", ", &cp) == NULL, 19); /* Persistence. */
(void) strcpy(one, ", ");
+ cp = NULL;
check(strtok_r(one, ", ", &cp) == NULL, 20); /* No tokens. */
(void) strcpy(one, "");
+ cp = NULL;
check(strtok_r(one, ", ", &cp) == NULL, 21); /* Empty string. */
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 22); /* Persistence. */
(void) strcpy(one, "abc");
- equal(strtok_r(one, ", ", &cp), "abc", 22); /* No delimiters. */
- check(strtok_r((char *)NULL, ", ", &cp) == NULL, 23);
+ cp = NULL;
+ equal(strtok_r(one, ", ", &cp), "abc", 23); /* No delimiters. */
+ check(strtok_r((char *)NULL, ", ", &cp) == NULL, 24);
(void) strcpy(one, "abc");
- equal(strtok_r(one, "", &cp), "abc", 24); /* Empty delimiter list. */
- check(strtok_r((char *)NULL, "", &cp) == NULL, 25);
+ cp = NULL;
+ equal(strtok_r(one, "", &cp), "abc", 25); /* Empty delimiter list. */
+ check(strtok_r((char *)NULL, "", &cp) == NULL, 26);
(void) strcpy(one, "abcdefgh");
(void) strcpy(one, "a,b,c");
- equal(strtok_r(one, ",", &cp), "a", 26); /* Basics again... */
- equal(strtok_r((char *)NULL, ",", &cp), "b", 27);
- equal(strtok_r((char *)NULL, ",", &cp), "c", 28);
- check(strtok_r((char *)NULL, ",", &cp) == NULL, 29);
- equal(one+6, "gh", 30); /* Stomped past end? */
- equal(one, "a", 31); /* Stomped old tokens? */
- equal(one+2, "b", 32);
- equal(one+4, "c", 33);
+ cp = NULL;
+ equal(strtok_r(one, ",", &cp), "a", 27); /* Basics again... */
+ equal(strtok_r((char *)NULL, ",", &cp), "b", 28);
+ equal(strtok_r((char *)NULL, ",", &cp), "c", 29);
+ check(strtok_r((char *)NULL, ",", &cp) == NULL, 30);
+ equal(one+6, "gh", 31); /* Stomped past end? */
+ equal(one, "a", 32); /* Stomped old tokens? */
+ equal(one+2, "b", 33);
+ equal(one+4, "c", 34);
}
static void