diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-01-03 17:00:25 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-01-03 17:00:25 +0000 |
commit | 1aadea5917b691d2fac2dcb96da3ed366c10b870 (patch) | |
tree | 502d4e1de24f3031e4a0138e0fca707746f82a50 /string | |
parent | 56b6e214d5d3bfa72fb999b496999fab14937575 (diff) | |
download | glibc-1aadea5917b691d2fac2dcb96da3ed366c10b870.zip glibc-1aadea5917b691d2fac2dcb96da3ed366c10b870.tar.gz glibc-1aadea5917b691d2fac2dcb96da3ed366c10b870.tar.bz2 |
Update.
2000-01-03 Andreas Jaeger <aj@suse.de>
* include/resolv.h: Remove declarations for __ns_name_ntop and
__ns_name_unpack since those are available in resolv/arpa/nameser.h.
2000-01-03 Andreas Jaeger <aj@suse.de>
* time/tst-strptime.c (test_tm): Add tests for all fields of
struct tm.
2000-01-03 Ulrich Drepper <drepper@cygnus.com>
* string/bits/string2.h (__strsep_g): Don't handle empty __S special.
2000-01-03 Andreas Jaeger <aj@suse.de>
* string/tester.c (test_strsep): Add one more test.
2000-01-03 Philip Blundell <philb@gnu.org>
* string/tester.c (test_mempcpy): New function.
(main): Call it.
(test_memcpy): Test unaligned cases too.
* sysdeps/arm/bits/string.h (_HAVE_STRING_ARCH_mempcpy): Define.
* sysdeps/arm/fpu/bits/mathdef.h: New file.
* nss/Makefile: Add rules to build makedb.
Diffstat (limited to 'string')
-rw-r--r-- | string/bits/string2.h | 4 | ||||
-rw-r--r-- | string/tester.c | 64 |
2 files changed, 65 insertions, 3 deletions
diff --git a/string/bits/string2.h b/string/bits/string2.h index 336aafe..db6ba97 100644 --- a/string/bits/string2.h +++ b/string/bits/string2.h @@ -1,5 +1,5 @@ /* Machine-independant string function optimizations. - Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -1165,7 +1165,7 @@ __STRING_INLINE char * __strsep_g (char **__s, __const char *__reject) { register char *__retval = *__s; - if (__retval == NULL || *__retval == '\0') + if (__retval == NULL) return NULL; if ((*__s = strpbrk (__retval, __reject)) != NULL) *(*__s)++ = '\0'; diff --git a/string/tester.c b/string/tester.c index d9043e0..ebb65ce 100644 --- a/string/tester.c +++ b/string/tester.c @@ -1,5 +1,5 @@ /* Tester for string functions. - Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000 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 @@ -928,6 +928,13 @@ test_strsep (void) equal(ptr, "", 83); check(ptr == one, 84); check(cp == NULL, 85); + + *one = '\0'; /* Empty string and no token. */ + cp = one; + ptr = strsep(&cp, ""); + equal(ptr, "", 86); + check(ptr == one , 87); + check(cp == NULL, 88); } void @@ -990,6 +997,7 @@ test_memchr (void) void test_memcpy (void) { + int i; it = "memcpy"; check(memcpy(one, "abc", 4) == one, 1); /* Returned value. */ equal(one, "abc", 2); /* Did the copy go right? */ @@ -1007,6 +1015,57 @@ test_memcpy (void) (void) memcpy(two, one, 9); equal(two, "hi there", 5); /* Just paranoia. */ equal(one, "hi there", 6); /* Stomped on source? */ + + for (i = 0; i < 16; i++) + { + const char *x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + strcpy (one, x); + check (memcpy (one + i, "hi there", 9) == one + i, + 7 + (i * 6)); /* Unaligned destination. */ + check (memcmp (one, x, i) == 0, 8 + (i * 6)); /* Wrote under? */ + equal (one + i, "hi there", 9 + (i * 6)); + check (one[i + 9] == 'x', 10 + (i * 6)); /* Wrote over? */ + check (memcpy (two, one + i, 9) == two, + 11 + (i * 6)); /* Unaligned source. */ + equal (two, "hi there", 12 + (i * 6)); + } +} + +void +test_mempcpy (void) +{ + int i; + it = "mempcpy"; + check(mempcpy(one, "abc", 4) == one + 4, 1); /* Returned value. */ + equal(one, "abc", 2); /* Did the copy go right? */ + + (void) strcpy(one, "abcdefgh"); + (void) mempcpy(one+1, "xyz", 2); + equal(one, "axydefgh", 3); /* Basic test. */ + + (void) strcpy(one, "abc"); + (void) mempcpy(one, "xyz", 0); + equal(one, "abc", 4); /* Zero-length copy. */ + + (void) strcpy(one, "hi there"); + (void) strcpy(two, "foo"); + (void) mempcpy(two, one, 9); + equal(two, "hi there", 5); /* Just paranoia. */ + equal(one, "hi there", 6); /* Stomped on source? */ + + for (i = 0; i < 16; i++) + { + const char *x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + strcpy (one, x); + check (mempcpy (one + i, "hi there", 9) == one + i + 9, + 7 + (i * 6)); /* Unaligned destination. */ + check (memcmp (one, x, i) == 0, 8 + (i * 6)); /* Wrote under? */ + equal (one + i, "hi there", 9 + (i * 6)); + check (one[i + 9] == 'x', 10 + (i * 6)); /* Wrote over? */ + check (mempcpy (two, one + i, 9) == two + 9, + 11 + (i * 6)); /* Unaligned source. */ + equal (two, "hi there", 12 + (i * 6)); + } } void @@ -1295,6 +1354,9 @@ main (void) /* memmove - must work on overlap. */ test_memmove (); + /* mempcpy */ + test_mempcpy (); + /* memccpy. */ test_memccpy (); |