From 1aadea5917b691d2fac2dcb96da3ed366c10b870 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 3 Jan 2000 17:00:25 +0000 Subject: Update. 2000-01-03 Andreas Jaeger * 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 * time/tst-strptime.c (test_tm): Add tests for all fields of struct tm. 2000-01-03 Ulrich Drepper * string/bits/string2.h (__strsep_g): Don't handle empty __S special. 2000-01-03 Andreas Jaeger * string/tester.c (test_strsep): Add one more test. 2000-01-03 Philip Blundell * 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. --- string/bits/string2.h | 4 ++-- string/tester.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 3 deletions(-) (limited to 'string') 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 , 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 (); -- cgit v1.1