diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-10-09 20:01:19 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-10-09 20:01:19 +0200 |
commit | 3896c5809b49e72fbadc57da2189ff42aa2a5d02 (patch) | |
tree | 976132226affe5ff11686d86d01d059aa5eabc6c /string | |
parent | 52c6cb0bba348bf5f25ff2a213e04c0f3fc378aa (diff) | |
parent | 4dc1e6e42f1f602e1d2227e112f2db8dce9da763 (diff) |
Merge commit 'refs/top-bases/t/hurdsig-boot-fix' into t/hurdsig-boot-fix
Diffstat (limited to 'string')
126 files changed, 1037 insertions, 770 deletions
diff --git a/string/Makefile b/string/Makefile index 8424a6162d..9c87419ad9 100644 --- a/string/Makefile +++ b/string/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2015 Free Software Foundation, Inc. +# Copyright (C) 1991-2016 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 @@ -54,7 +54,7 @@ tests := tester inl-tester noinl-tester testcopy test-ffs \ tst-strtok tst-strxfrm bug-strcoll1 tst-strfry \ bug-strtok1 $(addprefix test-,$(strop-tests)) \ bug-envz1 tst-strxfrm2 tst-endian tst-svc2 \ - tst-strtok_r + tst-strtok_r bug-strcoll2 xtests = tst-strcoll-overflow @@ -75,4 +75,17 @@ ifeq ($(run-built-tests),yes) $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out cmp $^ > $@; \ $(evaluate-test) + +LOCALES := de_DE.UTF-8 en_US.ISO-8859-1 en_US.UTF-8 \ + tr_TR.ISO-8859-9 tr_TR.UTF-8 cs_CZ.UTF-8 \ + da_DK.ISO-8859-1 +include ../gen-locales.mk + +$(objpfx)test-strcasecmp.out: $(gen-locales) +$(objpfx)test-strncasecmp.out: $(gen-locales) +$(objpfx)tst-strxfrm.out: $(gen-locales) +$(objpfx)tst-strxfrm2.out: $(gen-locales) +# bug-strcoll2 needs cs_CZ.UTF-8 and da_DK.ISO-8859-1. +$(objpfx)bug-strcoll2.out: $(gen-locales) + endif diff --git a/string/_strerror.c b/string/_strerror.c index efe113e195..4f5d9a27ca 100644 --- a/string/_strerror.c +++ b/string/_strerror.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/argz-addsep.c b/string/argz-addsep.c index 9240db2107..677f0eeb3b 100644 --- a/string/argz-addsep.c +++ b/string/argz-addsep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2015 Free Software Foundation, Inc. +/* Copyright (C) 1996-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. diff --git a/string/argz-append.c b/string/argz-append.c index d16edfbb77..e8d3812a9c 100644 --- a/string/argz-append.c +++ b/string/argz-append.c @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated arg vectors. - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.ai.mit.edu> diff --git a/string/argz-count.c b/string/argz-count.c index 0dca5c2f6d..1556112228 100644 --- a/string/argz-count.c +++ b/string/argz-count.c @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated arg vectors. - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.ai.mit.edu> diff --git a/string/argz-create.c b/string/argz-create.c index 96a45f61ac..c287054795 100644 --- a/string/argz-create.c +++ b/string/argz-create.c @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated arg vectors. - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.ai.mit.edu> diff --git a/string/argz-ctsep.c b/string/argz-ctsep.c index 0b732d72d4..a3858ea771 100644 --- a/string/argz-ctsep.c +++ b/string/argz-ctsep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2015 Free Software Foundation, Inc. +/* Copyright (C) 1996-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996. diff --git a/string/argz-delete.c b/string/argz-delete.c index 8176a7cbed..f274f41ac7 100644 --- a/string/argz-delete.c +++ b/string/argz-delete.c @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated arg vectors. - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.org> diff --git a/string/argz-extract.c b/string/argz-extract.c index 757146b180..d8270ed92d 100644 --- a/string/argz-extract.c +++ b/string/argz-extract.c @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated arg vectors. - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.org> diff --git a/string/argz-insert.c b/string/argz-insert.c index e161e22923..71e70eeaf6 100644 --- a/string/argz-insert.c +++ b/string/argz-insert.c @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated arg vectors. - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.ai.mit.edu> diff --git a/string/argz-next.c b/string/argz-next.c index b1531fe96d..72ef39c313 100644 --- a/string/argz-next.c +++ b/string/argz-next.c @@ -1,5 +1,5 @@ /* Iterate through the elements of an argz block. - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.org> diff --git a/string/argz-replace.c b/string/argz-replace.c index 26b0682ed4..924ff6f4d9 100644 --- a/string/argz-replace.c +++ b/string/argz-replace.c @@ -1,5 +1,5 @@ /* String replacement in an argz vector - Copyright (C) 1997-2015 Free Software Foundation, Inc. + Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.ai.mit.edu> diff --git a/string/argz-stringify.c b/string/argz-stringify.c index 398cabcf1a..254b7c5f7b 100644 --- a/string/argz-stringify.c +++ b/string/argz-stringify.c @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated arg vectors. - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.org> diff --git a/string/argz.h b/string/argz.h index bb62a31995..c1bc5f736c 100644 --- a/string/argz.h +++ b/string/argz.h @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated arg vectors. - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 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 diff --git a/string/basename.c b/string/basename.c index 4caabca8f0..9c811be375 100644 --- a/string/basename.c +++ b/string/basename.c @@ -1,5 +1,5 @@ /* Return the name-within-directory of a file name. - Copyright (C) 1996-2015 Free Software Foundation, Inc. + Copyright (C) 1996-2016 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 diff --git a/string/bcopy.c b/string/bcopy.c index f74e589449..b3ccd28dd7 100644 --- a/string/bcopy.c +++ b/string/bcopy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/bits/string2.h b/string/bits/string2.h index 764517689b..8200ef173d 100644 --- a/string/bits/string2.h +++ b/string/bits/string2.h @@ -1,5 +1,5 @@ /* Machine-independant string function optimizations. - Copyright (C) 1997-2015 Free Software Foundation, Inc. + Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -46,7 +46,7 @@ # endif #endif -#if _STRING_ARCH_unaligned +#if _STRING_INLINE_unaligned /* If we can do unaligned memory accesses we must know the endianess. */ # include <endian.h> # include <bits/types.h> @@ -95,7 +95,7 @@ __STRING2_COPY_TYPE (8); /* Set N bytes of S to C. */ #if !defined _HAVE_STRING_ARCH_memset # if !__GNUC_PREREQ (3, 0) -# if _STRING_ARCH_unaligned +# if _STRING_INLINE_unaligned # define memset(s, c, n) \ (__extension__ (__builtin_constant_p (n) && (n) <= 16 \ ? ((n) == 1 \ @@ -223,7 +223,7 @@ __STRING2_COPY_TYPE (8); # endif # if !__GNUC_PREREQ (3, 0) || defined _FORCE_INLINES -# if _STRING_ARCH_unaligned +# if _STRING_INLINE_unaligned # ifndef _FORCE_INLINES # define __mempcpy_args(src) \ ((const char *) (src))[0], ((const char *) (src))[2], \ @@ -419,7 +419,7 @@ extern void *__rawmemchr (const void *__s, int __c); : strcpy (dest, src))) # endif -# if _STRING_ARCH_unaligned +# if _STRING_INLINE_unaligned # ifndef _FORCE_INLINES # define __strcpy_args(src) \ __extension__ __STRING2_SMALL_GET16 (src, 0), \ @@ -598,7 +598,7 @@ __strcpy_small (char *__dest, # endif # if !__GNUC_PREREQ (3, 0) || defined _FORCE_INLINES -# if _STRING_ARCH_unaligned +# if _STRING_INLINE_unaligned # ifndef _FORCE_INLINES # define __stpcpy_args(src) \ __extension__ __STRING2_SMALL_GET16 (src, 0), \ diff --git a/string/bits/string3.h b/string/bits/string3.h index f48293595a..dd8db68aa2 100644 --- a/string/bits/string3.h +++ b/string/bits/string3.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2015 Free Software Foundation, Inc. +/* Copyright (C) 2004-2016 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 @@ -136,7 +136,7 @@ __fortify_function char * __NTH (stpncpy (char *__dest, const char *__src, size_t __n)) { if (__bos (__dest) != (size_t) -1 - && (!__builtin_constant_p (__n) || __n <= __bos (__dest))) + && (!__builtin_constant_p (__n) || __n > __bos (__dest))) return __stpncpy_chk (__dest, __src, __n, __bos (__dest)); return __stpncpy_alias (__dest, __src, __n); } diff --git a/string/bug-strcoll2.c b/string/bug-strcoll2.c new file mode 100644 index 0000000000..870d51e50c --- /dev/null +++ b/string/bug-strcoll2.c @@ -0,0 +1,92 @@ +/* Bug 18589: sort-test.sh fails at random. + Copyright (C) 2015-2016 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <stdio.h> +#include <string.h> +#include <locale.h> + +/* An incorrect strcoll optimization resulted in incorrect + results from strcoll for cs_CZ and da_DK. */ + +int +test_cs_CZ (void) +{ + const char t1[] = "config"; + const char t2[] = "choose"; + if (setlocale (LC_ALL, "cs_CZ.UTF-8") == NULL) + { + perror ("setlocale"); + return 1; + } + /* In Czech the digraph ch sorts after c, therefore we expect + config to sort before choose. */ + int a = strcoll (t1, t2); + int b = strcoll (t2, t1); + printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, a); + printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, b); + if (a < 0 && b > 0) + { + puts ("PASS: config < choose"); + return 0; + } + else + { + puts ("FAIL: Wrong sorting in cs_CZ.UTF-8."); + return 1; + } +} + +int +test_da_DK (void) +{ + const char t1[] = "AS"; + const char t2[] = "AA"; + if (setlocale (LC_ALL, "da_DK.ISO-8859-1") == NULL) + { + perror ("setlocale"); + return 1; + } + /* AA should be treated as the last letter of the Danish alphabet, + hence sorting after AS. */ + int a = strcoll (t1, t2); + int b = strcoll (t2, t1); + printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, a); + printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, b); + if (a < 0 && b > 0) + { + puts ("PASS: AS < AA"); + return 0; + } + else + { + puts ("FAIL: Wrong sorting in da_DK.ISO-8859-1"); + return 1; + } +} + +static int +do_test (void) +{ + int err = 0; + err |= test_cs_CZ (); + err |= test_da_DK (); + return err; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/string/byteswap.h b/string/byteswap.h index 99a8969e40..d98618c67e 100644 --- a/string/byteswap.h +++ b/string/byteswap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2015 Free Software Foundation, Inc. +/* Copyright (C) 1997-2016 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 diff --git a/string/bzero.c b/string/bzero.c index 43e2b38780..f2b3d0fd09 100644 --- a/string/bzero.c +++ b/string/bzero.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). diff --git a/string/endian.h b/string/endian.h index c0a5ddd5f1..b13ddaa7ad 100644 --- a/string/endian.h +++ b/string/endian.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2015 Free Software Foundation, Inc. +/* Copyright (C) 1992-2016 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 diff --git a/string/envz.c b/string/envz.c index fc999525b0..68343f3d45 100644 --- a/string/envz.c +++ b/string/envz.c @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated environment vectors - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.org> diff --git a/string/envz.h b/string/envz.h index d1066fa977..1f75f3de52 100644 --- a/string/envz.h +++ b/string/envz.h @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated environment vectors - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 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 diff --git a/string/ffs.c b/string/ffs.c index a30deeb36a..9294750031 100644 --- a/string/ffs.c +++ b/string/ffs.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). @@ -24,8 +24,7 @@ /* Find the first bit set in I. */ int -__ffs (i) - int i; +__ffs (int i) { static const unsigned char table[] = { diff --git a/string/ffsll.c b/string/ffsll.c index 2c89171d03..6bddc55278 100644 --- a/string/ffsll.c +++ b/string/ffsll.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). @@ -24,8 +24,7 @@ /* Find the first bit set in I. */ int -ffsll (i) - long long int i; +ffsll (long long int i) { unsigned long long int x = i & -i; diff --git a/string/memccpy.c b/string/memccpy.c index d9ed6975ef..58da4d3ed5 100644 --- a/string/memccpy.c +++ b/string/memccpy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 @@ -20,21 +20,22 @@ #undef __memccpy #undef memccpy +#ifdef MEMCCPY +# define __memccpy MEMCCPY +#endif + /* Copy no more than N bytes of SRC to DEST, stopping when C is found. Return the position in DEST one byte past where C was copied, or NULL if C was not found in the first N bytes of SRC. */ void * __memccpy (void *dest, const void *src, int c, size_t n) { - const char *s = src; - char *d = dest; - const char x = c; - size_t i = n; + void *p = memchr (src, c, n); - while (i-- > 0) - if ((*d++ = *s++) == x) - return d; + if (p != NULL) + return __mempcpy (dest, src, p - src + 1); + memcpy (dest, src, n); return NULL; } diff --git a/string/memchr.c b/string/memchr.c index 6896465600..ca9fd99f21 100644 --- a/string/memchr.c +++ b/string/memchr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and diff --git a/string/memcmp.c b/string/memcmp.c index 41e058629d..135bb689ec 100644 --- a/string/memcmp.c +++ b/string/memcmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). @@ -93,8 +93,7 @@ typedef unsigned char byte; static int memcmp_bytes (op_t, op_t) __THROW; static int -memcmp_bytes (a, b) - op_t a, b; +memcmp_bytes (op_t a, op_t b) { long int srcp1 = (long int) &a; long int srcp2 = (long int) &b; @@ -118,10 +117,7 @@ static int memcmp_common_alignment (long, long, size_t) __THROW; objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for memory operations on `op_t's. */ static int -memcmp_common_alignment (srcp1, srcp2, len) - long int srcp1; - long int srcp2; - size_t len; +memcmp_common_alignment (long int srcp1, long int srcp2, size_t len) { op_t a0, a1; op_t b0, b1; @@ -205,10 +201,7 @@ static int memcmp_not_common_alignment (long, long, size_t) __THROW; `op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory operations on `op_t', but SRCP1 *should be unaligned*. */ static int -memcmp_not_common_alignment (srcp1, srcp2, len) - long int srcp1; - long int srcp2; - size_t len; +memcmp_not_common_alignment (long int srcp1, long int srcp2, size_t len) { op_t a0, a1, a2, a3; op_t b0, b1, b2, b3; @@ -308,10 +301,7 @@ memcmp_not_common_alignment (srcp1, srcp2, len) } int -MEMCMP (s1, s2, len) - const __ptr_t s1; - const __ptr_t s2; - size_t len; +MEMCMP (const __ptr_t s1, const __ptr_t s2, size_t len) { op_t a0; op_t b0; diff --git a/string/memcpy.c b/string/memcpy.c index 4a585086fc..e4aa4dd208 100644 --- a/string/memcpy.c +++ b/string/memcpy.c @@ -1,6 +1,6 @@ /* Copy memory to memory until the specified number of bytes has been copied. Overlap is NOT handled correctly. - Copyright (C) 1991-2015 Free Software Foundation, Inc. + Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). @@ -24,10 +24,7 @@ #undef memcpy void * -memcpy (dstpp, srcpp, len) - void *dstpp; - const void *srcpp; - size_t len; +memcpy (void *dstpp, const void *srcpp, size_t len) { unsigned long int dstp = (long int) dstpp; unsigned long int srcp = (long int) srcpp; diff --git a/string/memfrob.c b/string/memfrob.c index ef4bcf0a15..d14ef5606c 100644 --- a/string/memfrob.c +++ b/string/memfrob.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2015 Free Software Foundation, Inc. +/* Copyright (C) 1992-2016 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 diff --git a/string/memmem.c b/string/memmem.c index 8a81f6574f..d4083dccc0 100644 --- a/string/memmem.c +++ b/string/memmem.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/memmove.c b/string/memmove.c index 5748256519..f0a145eacd 100644 --- a/string/memmove.c +++ b/string/memmove.c @@ -1,6 +1,6 @@ /* Copy memory to memory until the specified number of bytes has been copied. Overlap is handled correctly. - Copyright (C) 1991-2015 Free Software Foundation, Inc. + Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). @@ -41,10 +41,7 @@ rettype inhibit_loop_to_libcall -MEMMOVE (a1, a2, len) - a1const void *a1; - a2const void *a2; - size_t len; +MEMMOVE (a1const void *a1, a2const void *a2, size_t len) { unsigned long int dstp = (long int) dest; unsigned long int srcp = (long int) src; diff --git a/string/memory.h b/string/memory.h index e65629661d..10ecaa24ba 100644 --- a/string/memory.h +++ b/string/memory.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/mempcpy.c b/string/mempcpy.c index 03f5d0d0a2..b39a00cec7 100644 --- a/string/mempcpy.c +++ b/string/mempcpy.c @@ -1,7 +1,7 @@ /* Copy memory to memory until the specified number of bytes has been copied, return pointer to following byte. Overlap is NOT handled correctly. - Copyright (C) 1991-2015 Free Software Foundation, Inc. + Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). diff --git a/string/memrchr.c b/string/memrchr.c index 0c8fd84901..b9b0c9e802 100644 --- a/string/memrchr.c +++ b/string/memrchr.c @@ -1,5 +1,5 @@ /* memrchr -- find the last occurrence of a byte in a memory block - Copyright (C) 1991-2015 Free Software Foundation, Inc. + Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and @@ -61,10 +61,7 @@ __memrchr #else MEMRCHR #endif - (s, c_in, n) - const __ptr_t s; - int c_in; - size_t n; + (const __ptr_t s, int c_in, size_t n) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -96,15 +93,8 @@ MEMRCHR The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ - - if (sizeof (longword) != 4 && sizeof (longword) != 8) - abort (); - -#if LONG_MAX <= LONG_MAX_32_BITS - magic_bits = 0x7efefeff; -#else - magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff; -#endif + magic_bits = -1; + magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1; /* Set up a longword, each of whose bytes is C. */ charmask = c | (c << 8); diff --git a/string/memset.c b/string/memset.c index 18faf06e42..a17f1a0d5b 100644 --- a/string/memset.c +++ b/string/memset.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 @@ -22,10 +22,7 @@ void * inhibit_loop_to_libcall -memset (dstpp, c, len) - void *dstpp; - int c; - size_t len; +memset (void *dstpp, int c, size_t len) { long int dstp = (long int) dstpp; diff --git a/string/rawmemchr.c b/string/rawmemchr.c index 05b22be24e..fa3176d6ac 100644 --- a/string/rawmemchr.c +++ b/string/rawmemchr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and @@ -53,9 +53,7 @@ /* Find the first occurrence of C in S. */ __ptr_t -RAWMEMCHR (s, c_in) - const __ptr_t s; - int c_in; +RAWMEMCHR (const __ptr_t s, int c_in) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -86,15 +84,8 @@ RAWMEMCHR (s, c_in) The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ - - if (sizeof (longword) != 4 && sizeof (longword) != 8) - abort (); - -#if LONG_MAX <= LONG_MAX_32_BITS - magic_bits = 0x7efefeff; -#else - magic_bits = ((unsigned long int) 0x7efefefe << 32) | 0xfefefeff; -#endif + magic_bits = -1; + magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1; /* Set up a longword, each of whose bytes is C. */ charmask = c | (c << 8); diff --git a/string/stpcpy.c b/string/stpcpy.c index ecfb8d9255..46e876c28f 100644 --- a/string/stpcpy.c +++ b/string/stpcpy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2015 Free Software Foundation, Inc. +/* Copyright (C) 1992-2016 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 @@ -25,25 +25,17 @@ #undef __stpcpy #undef stpcpy -#ifndef weak_alias -# define __stpcpy stpcpy +#ifndef STPCPY +# define STPCPY __stpcpy #endif /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ char * -__stpcpy (dest, src) - char *dest; - const char *src; +STPCPY (char *dest, const char *src) { size_t len = strlen (src); return memcpy (dest, src, len + 1) + len; } -#ifdef libc_hidden_def -libc_hidden_def (__stpcpy) -#endif -#ifdef weak_alias weak_alias (__stpcpy, stpcpy) -#endif -#ifdef libc_hidden_builtin_def +libc_hidden_def (__stpcpy) libc_hidden_builtin_def (stpcpy) -#endif diff --git a/string/stpncpy.c b/string/stpncpy.c index eb65a5f46f..0cafc84217 100644 --- a/string/stpncpy.c +++ b/string/stpncpy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993-2015 Free Software Foundation, Inc. +/* Copyright (C) 1993-2016 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 @@ -15,8 +15,6 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -/* This is almost copied from strncpy.c, written by Torbjorn Granlund. */ - #ifdef HAVE_CONFIG_H # include <config.h> #endif @@ -41,59 +39,12 @@ weak_alias (__stpncpy, stpncpy) char * STPNCPY (char *dest, const char *src, size_t n) { - char c; - char *s = dest; - - if (n >= 4) - { - size_t n4 = n >> 2; - - for (;;) - { - c = *src++; - *dest++ = c; - if (c == '\0') - break; - c = *src++; - *dest++ = c; - if (c == '\0') - break; - c = *src++; - *dest++ = c; - if (c == '\0') - break; - c = *src++; - *dest++ = c; - if (c == '\0') - break; - if (--n4 == 0) - goto last_chars; - } - n -= dest - s; - goto zero_fill; - } - - last_chars: - n &= 3; - if (n == 0) + size_t size = __strnlen (src, n); + memcpy (dest, src, size); + dest += size; + if (size == n) return dest; - - for (;;) - { - c = *src++; - --n; - *dest++ = c; - if (c == '\0') - break; - if (n == 0) - return dest; - } - - zero_fill: - while (n-- > 0) - dest[n] = '\0'; - - return dest - 1; + return memset (dest, '\0', n - size); } #ifdef weak_alias libc_hidden_def (__stpncpy) diff --git a/string/str-two-way.h b/string/str-two-way.h index f32df4a6f2..dcf1d65aaf 100644 --- a/string/str-two-way.h +++ b/string/str-two-way.h @@ -1,5 +1,5 @@ /* Byte-wise substring search, using the Two-Way algorithm. - Copyright (C) 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2008-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Eric Blake <ebb9@byu.net>, 2008. diff --git a/string/stratcliff.c b/string/stratcliff.c index e161307542..463a045b26 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-2015 Free Software Foundation, Inc. + Copyright (C) 1996-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/string/strcasecmp.c b/string/strcasecmp.c index 6b14912a8b..38372a55db 100644 --- a/string/strcasecmp.c +++ b/string/strcasecmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 @@ -34,21 +34,16 @@ #endif #ifdef USE_IN_EXTENDED_LOCALE_MODEL -# define LOCALE_PARAM , loc -# define LOCALE_PARAM_DECL __locale_t loc; +# define LOCALE_PARAM , __locale_t loc #else # define LOCALE_PARAM -# define LOCALE_PARAM_DECL #endif /* Compare S1 and S2, ignoring case, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. */ int -__strcasecmp (s1, s2 LOCALE_PARAM) - const char *s1; - const char *s2; - LOCALE_PARAM_DECL +__strcasecmp (const char *s1, const char *s2 LOCALE_PARAM) { #if defined _LIBC && !defined USE_IN_EXTENDED_LOCALE_MODEL __locale_t loc = _NL_CURRENT_LOCALE; diff --git a/string/strcasecmp_l.c b/string/strcasecmp_l.c index 4debd1bc9d..84c4149852 100644 --- a/string/strcasecmp_l.c +++ b/string/strcasecmp_l.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2015 Free Software Foundation, Inc. +/* Copyright (C) 1997-2016 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 diff --git a/string/strcasestr.c b/string/strcasestr.c index 400fab874d..734af6556d 100644 --- a/string/strcasestr.c +++ b/string/strcasestr.c @@ -1,5 +1,5 @@ /* Return the offset of one string within another. - Copyright (C) 1994-2015 Free Software Foundation, Inc. + Copyright (C) 1994-2016 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 diff --git a/string/strcat.c b/string/strcat.c index 6e1f1ab932..f229e4d831 100644 --- a/string/strcat.c +++ b/string/strcat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 @@ -19,9 +19,13 @@ #undef strcat +#ifndef STRCAT +# define STRCAT strcat +#endif + /* Append SRC on the end of DEST. */ char * -strcat (char *dest, const char *src) +STRCAT (char *dest, const char *src) { strcpy (dest + strlen (dest), src); return dest; diff --git a/string/strchr.c b/string/strchr.c index 5f900750a3..25c2fe4771 100644 --- a/string/strchr.c +++ b/string/strchr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and @@ -25,9 +25,13 @@ #undef strchr +#ifndef STRCHR +# define STRCHR strchr +#endif + /* Find the first occurrence of C in S. */ char * -strchr (const char *s, int c_in) +STRCHR (const char *s, int c_in) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -60,13 +64,8 @@ strchr (const char *s, int c_in) The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ - switch (sizeof (longword)) - { - case 4: magic_bits = 0x7efefeffL; break; - case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break; - default: - abort (); - } + magic_bits = -1; + magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1; /* Set up a longword, each of whose bytes is C. */ charmask = c | (c << 8); @@ -180,7 +179,7 @@ strchr (const char *s, int c_in) } #ifdef weak_alias -#undef index +# undef index weak_alias (strchr, index) #endif libc_hidden_builtin_def (strchr) diff --git a/string/strchrnul.c b/string/strchrnul.c index 2678f1de0a..629db465b8 100644 --- a/string/strchrnul.c +++ b/string/strchrnul.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and @@ -33,9 +33,7 @@ /* Find the first occurrence of C in S or the final NUL byte. */ char * -STRCHRNUL (s, c_in) - const char *s; - int c_in; +STRCHRNUL (const char *s, int c_in) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; @@ -66,13 +64,8 @@ STRCHRNUL (s, c_in) The 1-bits make sure that carries propagate to the next 0-bit. The 0-bits provide holes for carries to fall into. */ - switch (sizeof (longword)) - { - case 4: magic_bits = 0x7efefeffL; break; - case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break; - default: - abort (); - } + magic_bits = -1; + magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1; /* Set up a longword, each of whose bytes is C. */ charmask = c | (c << 8); diff --git a/string/strcmp.c b/string/strcmp.c index 4d4c044660..4b16f9946b 100644 --- a/string/strcmp.c +++ b/string/strcmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 @@ -19,11 +19,15 @@ #undef strcmp +#ifndef STRCMP +# define STRCMP strcmp +#endif + /* Compare S1 and S2, returning less than, equal to or greater than zero if S1 is lexicographically less than, equal to or greater than S2. */ int -strcmp (const char *p1, const char *p2) +STRCMP (const char *p1, const char *p2) { const unsigned char *s1 = (const unsigned char *) p1; const unsigned char *s2 = (const unsigned char *) p2; diff --git a/string/strcoll.c b/string/strcoll.c index aba64158cd..7449197244 100644 --- a/string/strcoll.c +++ b/string/strcoll.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2015 Free Software Foundation, Inc. +/* Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@cygnus.com>, 1995. diff --git a/string/strcoll_l.c b/string/strcoll_l.c index 8f1225fc7a..4d1e3ab15e 100644 --- a/string/strcoll_l.c +++ b/string/strcoll_l.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2015 Free Software Foundation, Inc. +/* Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@gnu.org>, 1995. @@ -29,7 +29,6 @@ # define STRING_TYPE char # define USTRING_TYPE unsigned char # define STRCOLL __strcoll_l -# define STRDIFF __strdiff # define STRCMP strcmp # define WEIGHT_H "../locale/weight.h" # define SUFFIX MB @@ -42,20 +41,6 @@ #include "../locale/localeinfo.h" #include WEIGHT_H -#define MASK_UTF8_7BIT (1 << 7) -#define MASK_UTF8_START (3 << 6) - -size_t -STRDIFF (const STRING_TYPE *s, const STRING_TYPE *t) -{ - size_t n; - - for (n = 0; *s != '\0' && *s++ == *t++; ++n) - continue; - - return n; -} - /* Track status while looking for sequences in a string. */ typedef struct { @@ -269,29 +254,9 @@ STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, __locale_t l) const USTRING_TYPE *extra; const int32_t *indirect; - /* In case there is no locale specific sort order (C / POSIX). */ if (nrules == 0) return STRCMP (s1, s2); - /* Fast forward to the position of the first difference. Needs to be - encoding aware as the byte-by-byte comparison can stop in the middle - of a char sequence for multibyte encodings like UTF-8. */ - uint_fast32_t encoding = - current->values[_NL_ITEM_INDEX (_NL_COLLATE_ENCODING_TYPE)].word; - if (encoding != __cet_other) - { - size_t diff = STRDIFF (s1, s2); - if (diff > 0) - { - if (encoding == __cet_utf8 && (*(s1 + diff) & MASK_UTF8_7BIT) != 0) - do - diff--; - while (diff > 0 && (*(s1 + diff) & MASK_UTF8_START) != MASK_UTF8_START); - s1 += diff; - s2 += diff; - } - } - /* Catch empty strings. */ if (__glibc_unlikely (*s1 == '\0') || __glibc_unlikely (*s2 == '\0')) return (*s1 != '\0') - (*s2 != '\0'); @@ -358,8 +323,7 @@ STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, __locale_t l) byte-level comparison to ensure that we don't waste time going through multiple passes for totally equal strings before proceeding to subsequent passes. */ - if (pass == 0 && encoding == __cet_other && - STRCMP (s1, s2) == 0) + if (pass == 0 && STRCMP (s1, s2) == 0) return result; else break; diff --git a/string/strcpy.c b/string/strcpy.c index 3ebb51bfd9..f049e62211 100644 --- a/string/strcpy.c +++ b/string/strcpy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 @@ -20,9 +20,13 @@ #undef strcpy +#ifndef STRCPY +# define STRCPY strcpy +#endif + /* Copy SRC to DEST. */ char * -strcpy (char *dest, const char *src) +STRCPY (char *dest, const char *src) { return memcpy (dest, src, strlen (src) + 1); } diff --git a/string/strcspn.c b/string/strcspn.c index 2694d2ab0e..8888919639 100644 --- a/string/strcspn.c +++ b/string/strcspn.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/strdup.c b/string/strdup.c index 8ba33babae..21e8ee2a79 100644 --- a/string/strdup.c +++ b/string/strdup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/strerror.c b/string/strerror.c index 824d09f759..7319c56b2f 100644 --- a/string/strerror.c +++ b/string/strerror.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 @@ -26,8 +26,7 @@ libc_freeres_ptr (static char *buf); char * -strerror (errnum) - int errnum; +strerror (int errnum) { char *ret = __strerror_r (errnum, NULL, 0); int saved_errno; diff --git a/string/strerror_l.c b/string/strerror_l.c index 2ed78b5f83..13f7606c3e 100644 --- a/string/strerror_l.c +++ b/string/strerror_l.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2015 Free Software Foundation, Inc. +/* Copyright (C) 2007-2016 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 diff --git a/string/strfry.c b/string/strfry.c index e4ecd3c757..87b69fcc31 100644 --- a/string/strfry.c +++ b/string/strfry.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2015 Free Software Foundation, Inc. +/* Copyright (C) 1992-2016 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 diff --git a/string/string-inlines.c b/string/string-inlines.c index 0445be74cb..16db3ea308 100644 --- a/string/string-inlines.c +++ b/string/string-inlines.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2015 Free Software Foundation, Inc. +/* Copyright (C) 1999-2016 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 diff --git a/string/string.h b/string/string.h index 54a4d39a53..1f3e348834 100644 --- a/string/string.h +++ b/string/string.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 @@ -636,6 +636,25 @@ extern char *basename (const char *__filename) __THROW __nonnull ((1)); # endif #endif +#if defined __USE_GNU && defined __OPTIMIZE__ \ + && defined __extern_always_inline && __GNUC_PREREQ (3,2) +# if !defined _FORCE_INLINES && !defined _HAVE_STRING_ARCH_mempcpy + +#undef mempcpy +#undef __mempcpy +#define mempcpy(dest, src, n) __mempcpy_inline (dest, src, n) +#define __mempcpy(dest, src, n) __mempcpy_inline (dest, src, n) + +__extern_always_inline void * +__mempcpy_inline (void *__restrict __dest, + const void *__restrict __src, size_t __n) +{ + return (char *) memcpy (__dest, __src, __n) + __n; +} + +# endif +#endif + __END_DECLS #endif /* string.h */ diff --git a/string/strings.h b/string/strings.h index 028361ac99..e372a331b3 100644 --- a/string/strings.h +++ b/string/strings.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/strlen.c b/string/strlen.c index d066bde577..4943ce2ce3 100644 --- a/string/strlen.c +++ b/string/strlen.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Torbjorn Granlund (tege@sics.se), with help from Dan Sahlin (dan@sics.se); @@ -23,10 +23,14 @@ #undef strlen +#ifndef STRLEN +# define STRLEN strlen +#endif + /* Return the length of the null-terminated string STR. Scan for the null terminator quickly by testing four bytes at a time. */ size_t -strlen (const char *str) +STRLEN (const char *str) { const char *char_ptr; const unsigned long int *longword_ptr; diff --git a/string/strncase.c b/string/strncase.c index a8fc046c09..e0aad264fa 100644 --- a/string/strncase.c +++ b/string/strncase.c @@ -1,6 +1,6 @@ /* Compare at most N characters of two strings without taking care for the case. - Copyright (C) 1992-2015 Free Software Foundation, Inc. + Copyright (C) 1992-2016 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 @@ -36,11 +36,9 @@ #endif #ifdef USE_IN_EXTENDED_LOCALE_MODEL -# define LOCALE_PARAM , loc -# define LOCALE_PARAM_DECL __locale_t loc; +# define LOCALE_PARAM , __locale_t loc #else # define LOCALE_PARAM -# define LOCALE_PARAM_DECL #endif /* Compare no more than N characters of S1 and S2, @@ -48,11 +46,7 @@ greater than zero if S1 is lexicographically less than, equal to or greater than S2. */ int -__strncasecmp (s1, s2, n LOCALE_PARAM) - const char *s1; - const char *s2; - size_t n; - LOCALE_PARAM_DECL +__strncasecmp (const char *s1, const char *s2, size_t n LOCALE_PARAM) { #if defined _LIBC && !defined USE_IN_EXTENDED_LOCALE_MODEL __locale_t loc = _NL_CURRENT_LOCALE; diff --git a/string/strncase_l.c b/string/strncase_l.c index b0e360d5cf..8de6acbdef 100644 --- a/string/strncase_l.c +++ b/string/strncase_l.c @@ -1,6 +1,6 @@ /* Compare at most N characters of two strings without taking care for the case using given locale. - Copyright (C) 1997-2015 Free Software Foundation, Inc. + Copyright (C) 1997-2016 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 diff --git a/string/strncat.c b/string/strncat.c index 12572aebdb..8b00a10d93 100644 --- a/string/strncat.c +++ b/string/strncat.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/strncmp.c b/string/strncmp.c index 2a1137aaf2..b77a33452b 100644 --- a/string/strncmp.c +++ b/string/strncmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/strncpy.c b/string/strncpy.c index 37af5aaad0..cbd85e1a4c 100644 --- a/string/strncpy.c +++ b/string/strncpy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 @@ -16,68 +16,19 @@ <http://www.gnu.org/licenses/>. */ #include <string.h> -#include <memcopy.h> #undef strncpy #ifndef STRNCPY -#define STRNCPY strncpy + #define STRNCPY strncpy #endif char * STRNCPY (char *s1, const char *s2, size_t n) { - char c; - char *s = s1; - - --s1; - - if (n >= 4) - { - size_t n4 = n >> 2; - - for (;;) - { - c = *s2++; - *++s1 = c; - if (c == '\0') - break; - c = *s2++; - *++s1 = c; - if (c == '\0') - break; - c = *s2++; - *++s1 = c; - if (c == '\0') - break; - c = *s2++; - *++s1 = c; - if (c == '\0') - break; - if (--n4 == 0) - goto last_chars; - } - s1++; - n = n - (s1 - s); - memset (s1, '\0', n); - return s; - } - - last_chars: - n &= 3; - if (n == 0) - return s; - - do - { - c = *s2++; - *++s1 = c; - if (--n == 0) - return s; - } - while (c != '\0'); - - memset (s1 + 1, '\0', n); - return s; + size_t size = __strnlen (s2, n); + if (size != n) + memset (s1 + size, '\0', n - size); + return memcpy (s1, s2, size); } libc_hidden_builtin_def (strncpy) diff --git a/string/strndup.c b/string/strndup.c index 15b19f720a..51a1969146 100644 --- a/string/strndup.c +++ b/string/strndup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2015 Free Software Foundation, Inc. +/* Copyright (C) 1996-2016 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 @@ -37,9 +37,7 @@ char *malloc (); #endif char * -__strndup (s, n) - const char *s; - size_t n; +__strndup (const char *s, size_t n) { size_t len = __strnlen (s, n); char *new = (char *) malloc (len + 1); diff --git a/string/strnlen.c b/string/strnlen.c index d2bb843fdd..b2b0664391 100644 --- a/string/strnlen.c +++ b/string/strnlen.c @@ -1,5 +1,5 @@ /* Find the length of STRING, but scan at most MAXLEN characters. - Copyright (C) 1991-2015 Free Software Foundation, Inc. + Copyright (C) 1991-2016 Free Software Foundation, Inc. Contributed by Jakub Jelinek <jakub@redhat.com>. Based on strlen written by Torbjorn Granlund (tege@sics.se), diff --git a/string/strpbrk.c b/string/strpbrk.c index 4f1d9b72bb..fddd473ad7 100644 --- a/string/strpbrk.c +++ b/string/strpbrk.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/strrchr.c b/string/strrchr.c index b70a832ddc..a07457e21b 100644 --- a/string/strrchr.c +++ b/string/strrchr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/strsep.c b/string/strsep.c index e77fbf2905..1054774048 100644 --- a/string/strsep.c +++ b/string/strsep.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2015 Free Software Foundation, Inc. +/* Copyright (C) 1992-2016 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 diff --git a/string/strsignal.c b/string/strsignal.c index 01c01e2dc7..706d6d30dc 100644 --- a/string/strsignal.c +++ b/string/strsignal.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 @@ -20,7 +20,7 @@ #include <stdlib.h> #include <string.h> #include <libintl.h> -#include <bits/libc-lock.h> +#include <libc-lock.h> static __libc_key_t key; diff --git a/string/strspn.c b/string/strspn.c index 4a1422bcea..f0635c156a 100644 --- a/string/strspn.c +++ b/string/strspn.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/strstr.c b/string/strstr.c index 045e878da3..4bf3e1aa73 100644 --- a/string/strstr.c +++ b/string/strstr.c @@ -1,5 +1,5 @@ /* Return the offset of one string within another. - Copyright (C) 1994-2015 Free Software Foundation, Inc. + Copyright (C) 1994-2016 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 diff --git a/string/strtok.c b/string/strtok.c index 97acd4a05a..7a4574db5c 100644 --- a/string/strtok.c +++ b/string/strtok.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 diff --git a/string/strtok_r.c b/string/strtok_r.c index 9e558ee9bc..f351304766 100644 --- a/string/strtok_r.c +++ b/string/strtok_r.c @@ -1,5 +1,5 @@ /* Reentrant string tokenizer. Generic version. - Copyright (C) 1991-2015 Free Software Foundation, Inc. + Copyright (C) 1991-2016 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 diff --git a/string/strverscmp.c b/string/strverscmp.c index 38bf5e2e6f..96d4227cd5 100644 --- a/string/strverscmp.c +++ b/string/strverscmp.c @@ -1,5 +1,5 @@ /* Compare strings while treating digits characters numerically. - Copyright (C) 1997-2015 Free Software Foundation, Inc. + Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jean-François Bignolles <bignolle@ecoledoc.ibp.fr>, 1997. @@ -39,9 +39,7 @@ */ int -__strverscmp (s1, s2) - const char *s1; - const char *s2; +__strverscmp (const char *s1, const char *s2) { const unsigned char *p1 = (const unsigned char *) s1; const unsigned char *p2 = (const unsigned char *) s2; diff --git a/string/strxfrm.c b/string/strxfrm.c index 65f8062940..7a315cf87d 100644 --- a/string/strxfrm.c +++ b/string/strxfrm.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2015 Free Software Foundation, Inc. +/* Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@cygnus.com>, 1995. diff --git a/string/strxfrm_l.c b/string/strxfrm_l.c index 8b61ea2b20..22e24d37d8 100644 --- a/string/strxfrm_l.c +++ b/string/strxfrm_l.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2015 Free Software Foundation, Inc. +/* Copyright (C) 1995-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@gnu.org>, 1995. diff --git a/string/swab.c b/string/swab.c index f75e26f894..cbd8d570d1 100644 --- a/string/swab.c +++ b/string/swab.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992-2015 Free Software Foundation, Inc. +/* Copyright (C) 1992-2016 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 diff --git a/string/test-bcopy.c b/string/test-bcopy.c index 1f6af1528f..d71e76e5c6 100644 --- a/string/test-bcopy.c +++ b/string/test-bcopy.c @@ -1,5 +1,5 @@ /* Test and measure bcopy functions. - Copyright (C) 2012-2015 Free Software Foundation, Inc. + Copyright (C) 2012-2016 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 diff --git a/string/test-bzero.c b/string/test-bzero.c index f32173d07b..47b88a5ecd 100644 --- a/string/test-bzero.c +++ b/string/test-bzero.c @@ -1,5 +1,5 @@ /* Test and measure bzero functions. - Copyright (C) 2012-2015 Free Software Foundation, Inc. + Copyright (C) 2012-2016 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 diff --git a/string/test-ffs.c b/string/test-ffs.c index afbaaf7b5d..035b63db2a 100644 --- a/string/test-ffs.c +++ b/string/test-ffs.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994-2015 Free Software Foundation, Inc. +/* Copyright (C) 1994-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil), On-Line Applications Research Corporation. diff --git a/string/test-memccpy.c b/string/test-memccpy.c index f42de2fc9a..9884c80b0a 100644 --- a/string/test-memccpy.c +++ b/string/test-memccpy.c @@ -1,5 +1,5 @@ /* Test and measure memccpy functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. diff --git a/string/test-memchr.c b/string/test-memchr.c index 19c89781b2..449a19ae59 100644 --- a/string/test-memchr.c +++ b/string/test-memchr.c @@ -1,5 +1,5 @@ -/* Test and measure memchr functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. +/* Test memchr functions. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -18,28 +18,49 @@ <http://www.gnu.org/licenses/>. */ #define TEST_MAIN -#define TEST_NAME "memchr" +#ifndef WIDE +# define TEST_NAME "memchr" +#else +# define TEST_NAME "wmemchr" +#endif /* WIDE */ #include "test-string.h" -typedef char *(*proto_t) (const char *, int, size_t); -char *simple_memchr (const char *, int, size_t); - -IMPL (simple_memchr, 0) -IMPL (memchr, 1) - -char * -simple_memchr (const char *s, int c, size_t n) +#ifndef WIDE +# define MEMCHR memchr +# define CHAR char +# define UCHAR unsigned char +# define SIMPLE_MEMCHR simple_memchr +# define BIG_CHAR CHAR_MAX +# define SMALL_CHAR 127 +#else +# include <wchar.h> +# define MEMCHR wmemchr +# define CHAR wchar_t +# define UCHAR wchar_t +# define SIMPLE_MEMCHR simple_wmemchr +# define BIG_CHAR WCHAR_MAX +# define SMALL_CHAR 1273 +#endif /* WIDE */ + +typedef CHAR *(*proto_t) (const CHAR *, int, size_t); +CHAR *SIMPLE_MEMCHR (const CHAR *, int, size_t); + +IMPL (SIMPLE_MEMCHR, 0) +IMPL (MEMCHR, 1) + +CHAR * +SIMPLE_MEMCHR (const CHAR *s, int c, size_t n) { while (n--) - if (*s++ == (char) c) - return (char *) s - 1; + if (*s++ == (CHAR) c) + return (CHAR *) s - 1; return NULL; } static void -do_one_test (impl_t *impl, const char *s, int c, size_t n, char *exp_res) +do_one_test (impl_t *impl, const CHAR *s, int c, size_t n, CHAR *exp_res) { - char *res = CALL (impl, s, c, n); + CHAR *res = CALL (impl, s, c, n); if (res != exp_res) { error (0, 0, "Wrong result in function %s %p %p", impl->name, @@ -53,34 +74,36 @@ static void do_test (size_t align, size_t pos, size_t len, int seek_char) { size_t i; - char *result; + CHAR *result; align &= 7; - if (align + len >= page_size) + if ((align + len) * sizeof (CHAR) >= page_size) return; + CHAR *buf = (CHAR *) (buf1); + for (i = 0; i < len; ++i) { - buf1[align + i] = 1 + 23 * i % 127; - if (buf1[align + i] == seek_char) - buf1[align + i] = seek_char + 1; + buf[align + i] = 1 + 23 * i % SMALL_CHAR; + if (buf[align + i] == seek_char) + buf[align + i] = seek_char + 1; } - buf1[align + len] = 0; + buf[align + len] = 0; if (pos < len) { - buf1[align + pos] = seek_char; - buf1[align + len] = -seek_char; - result = (char *) (buf1 + align + pos); + buf[align + pos] = seek_char; + buf[align + len] = -seek_char; + result = (CHAR *) (buf + align + pos); } else { result = NULL; - buf1[align + len] = seek_char; + buf[align + len] = seek_char; } FOR_EACH_IMPL (impl, 0) - do_one_test (impl, (char *) (buf1 + align), seek_char, len, result); + do_one_test (impl, (CHAR *) (buf + align), seek_char, len, result); } static void @@ -88,8 +111,8 @@ do_random_tests (void) { size_t i, j, n, align, pos, len; int seek_char; - char *result; - unsigned char *p = buf1 + page_size - 512; + CHAR *result; + UCHAR *p = (UCHAR *) (buf1 + page_size) - 512; for (n = 0; n < ITERATIONS; n++) { @@ -101,11 +124,11 @@ do_random_tests (void) if (pos >= len) len = pos + (random () & 7); if (len + align >= 512) - len = 512 - align - (random () & 7); - seek_char = random () & 255; + len = 512 - align - (random () & 7); + seek_char = random () & BIG_CHAR; j = len + align + 64; if (j > 512) - j = 512; + j = 512; for (i = 0; i < j; i++) { @@ -113,7 +136,7 @@ do_random_tests (void) p[i] = seek_char; else { - p[i] = random () & 255; + p[i] = random () & BIG_CHAR; if (i < pos + align && p[i] == seek_char) p[i] = seek_char + 13; } @@ -124,17 +147,17 @@ do_random_tests (void) size_t r = random (); if ((r & 31) == 0) len = ~(uintptr_t) (p + align) - ((r >> 5) & 31); - result = (char *) (p + pos + align); + result = (CHAR *) (p + pos + align); } else result = NULL; FOR_EACH_IMPL (impl, 1) - if (CALL (impl, (char *) (p + align), seek_char, len) != result) + if (CALL (impl, (CHAR *) (p + align), seek_char, len) != result) { error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %d, %zd, %zd) %p != %p, p %p", n, impl->name, align, seek_char, len, pos, - CALL (impl, (char *) (p + align), seek_char, len), + CALL (impl, (CHAR *) (p + align), seek_char, len), result, p); ret = 1; } diff --git a/string/test-memcmp.c b/string/test-memcmp.c index 488f9c1253..fa1bcefc0e 100644 --- a/string/test-memcmp.c +++ b/string/test-memcmp.c @@ -1,5 +1,5 @@ /* Test and measure memcmp functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. Added wmemcmp support by Liubov Dmitrieva <liubov.dmitrieva@gmail.com>, 2011. diff --git a/string/test-memcpy.c b/string/test-memcpy.c index 51fbd92122..2a0994ca98 100644 --- a/string/test-memcpy.c +++ b/string/test-memcpy.c @@ -1,5 +1,5 @@ /* Test and measure memcpy functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. diff --git a/string/test-memmem.c b/string/test-memmem.c index 9e8917ccc3..e8ce80b608 100644 --- a/string/test-memmem.c +++ b/string/test-memmem.c @@ -1,5 +1,5 @@ /* Test and measure memmem functions. - Copyright (C) 2008-2015 Free Software Foundation, Inc. + Copyright (C) 2008-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@redhat.com>, 2008. diff --git a/string/test-memmove.c b/string/test-memmove.c index 9742efaab9..d2ab3f3c8d 100644 --- a/string/test-memmove.c +++ b/string/test-memmove.c @@ -1,5 +1,5 @@ /* Test and measure memmove functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. diff --git a/string/test-mempcpy.c b/string/test-mempcpy.c index 6d25d87d6b..f4969c24a5 100644 --- a/string/test-mempcpy.c +++ b/string/test-mempcpy.c @@ -1,5 +1,5 @@ /* Test and measure mempcpy functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. diff --git a/string/test-memrchr.c b/string/test-memrchr.c index b06ea9ec68..4d2e35b062 100644 --- a/string/test-memrchr.c +++ b/string/test-memrchr.c @@ -1,5 +1,5 @@ /* Test and measure memrchr functions. - Copyright (C) 2013-2015 Free Software Foundation, Inc. + Copyright (C) 2013-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. diff --git a/string/test-memset.c b/string/test-memset.c index 9f3af468b0..fee3bdf37f 100644 --- a/string/test-memset.c +++ b/string/test-memset.c @@ -1,5 +1,5 @@ -/* Test and measure memset functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. +/* Test memset functions. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -21,12 +21,33 @@ #ifdef TEST_BZERO # define TEST_NAME "bzero" #else -# define TEST_NAME "memset" -#endif +# ifndef WIDE +# define TEST_NAME "memset" +# else +# define TEST_NAME "wmemset" +# endif /* WIDE */ +#endif /* !TEST_BZERO */ #define MIN_PAGE_SIZE 131072 #include "test-string.h" -char *simple_memset (char *, int, size_t); +#ifndef WIDE +# define MEMSET memset +# define CHAR char +# define UCHAR unsigned char +# define SIMPLE_MEMSET simple_memset +# define MEMCMP memcmp +# define BIG_CHAR CHAR_MAX +#else +# include <wchar.h> +# define MEMSET wmemset +# define CHAR wchar_t +# define UCHAR wchar_t +# define SIMPLE_MEMSET simple_wmemset +# define MEMCMP wmemcmp +# define BIG_CHAR WCHAR_MAX +#endif /* WIDE */ + +CHAR *SIMPLE_MEMSET (CHAR *, int, size_t); #ifdef TEST_BZERO typedef void (*proto_t) (char *, size_t); @@ -40,7 +61,7 @@ IMPL (bzero, 1) void simple_bzero (char *s, size_t n) { - simple_memset (s, 0, n); + SIMPLE_MEMSET (s, 0, n); } void @@ -49,44 +70,48 @@ builtin_bzero (char *s, size_t n) __builtin_bzero (s, n); } #else -typedef char *(*proto_t) (char *, int, size_t); -char *builtin_memset (char *, int, size_t); +typedef CHAR *(*proto_t) (CHAR *, int, size_t); -IMPL (simple_memset, 0) +IMPL (SIMPLE_MEMSET, 0) +# ifndef WIDE +char *builtin_memset (char *, int, size_t); IMPL (builtin_memset, 0) -IMPL (memset, 1) +# endif /* !WIDE */ +IMPL (MEMSET, 1) +# ifndef WIDE char * builtin_memset (char *s, int c, size_t n) { return __builtin_memset (s, c, n); } -#endif +# endif /* !WIDE */ +#endif /* !TEST_BZERO */ -char * +CHAR * inhibit_loop_to_libcall -simple_memset (char *s, int c, size_t n) +SIMPLE_MEMSET (CHAR *s, int c, size_t n) { - char *r = s, *end = s + n; + CHAR *r = s, *end = s + n; while (r < end) *r++ = c; return s; } static void -do_one_test (impl_t *impl, char *s, int c __attribute ((unused)), size_t n) +do_one_test (impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n) { - char tstbuf[n]; + CHAR tstbuf[n]; #ifdef TEST_BZERO simple_bzero (tstbuf, n); CALL (impl, s, n); if (memcmp (s, tstbuf, n) != 0) #else - char *res = CALL (impl, s, c, n); + CHAR *res = CALL (impl, s, c, n); if (res != s - || simple_memset (tstbuf, c, n) != tstbuf - || memcmp (s, tstbuf, n) != 0) -#endif + || SIMPLE_MEMSET (tstbuf, c, n) != tstbuf + || MEMCMP (s, tstbuf, n) != 0) +#endif /* !TEST_BZERO */ { error (0, 0, "Wrong result in function %s", impl->name); ret = 1; @@ -98,11 +123,11 @@ static void do_test (size_t align, int c, size_t len) { align &= 7; - if (align + len > page_size) + if ((align + len) * sizeof (CHAR) > page_size) return; FOR_EACH_IMPL (impl, 0) - do_one_test (impl, (char *) buf1 + align, c, len); + do_one_test (impl, (CHAR *) (buf1) + align, c, len); } #ifndef TEST_BZERO @@ -111,18 +136,19 @@ do_random_tests (void) { size_t i, j, k, n, align, len, size; int c, o; - unsigned char *p, *res; + UCHAR *p, *res; + UCHAR *p2 = (UCHAR *) buf2; - for (i = 0; i < 65536; ++i) - buf2[i] = random () & 255; + for (i = 0; i < 65536 / sizeof (CHAR); ++i) + p2[i] = random () & BIG_CHAR; for (n = 0; n < ITERATIONS; n++) { if ((random () & 31) == 0) - size = 65536; + size = 65536 / sizeof (CHAR); else size = 512; - p = buf1 + page_size - size; + p = (UCHAR *) (buf1 + page_size) - size; len = random () & (size - 1); align = size - len - (random () & 31); if (align > size) @@ -132,10 +158,10 @@ do_random_tests (void) if ((random () & 7) == 0) c = 0; else - c = random () & 255; - o = random () & 255; + c = random () & BIG_CHAR; + o = random () & BIG_CHAR; if (o == c) - o = (c + 1) & 255; + o = (c + 1) & BIG_CHAR; j = len + align + 128; if (j > size) j = size; @@ -152,11 +178,11 @@ do_random_tests (void) { for (i = 0; i < len; ++i) { - p[i + align] = buf2[i]; + p[i + align] = p2[i]; if (p[i + align] == c) p[i + align] = o; } - res = (unsigned char *) CALL (impl, (char *) p + align, c, len); + res = (UCHAR *) CALL (impl, (CHAR *) p + align, c, len); if (res != p + align) { error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %d, %zd) %p != %p", @@ -190,7 +216,7 @@ do_random_tests (void) } } } -#endif +#endif /* !TEST_BZERO */ int test_main (void) diff --git a/string/test-rawmemchr.c b/string/test-rawmemchr.c index 9c952ef62f..f53c89786b 100644 --- a/string/test-rawmemchr.c +++ b/string/test-rawmemchr.c @@ -1,5 +1,5 @@ /* Test and measure memchr functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. diff --git a/string/test-stpcpy.c b/string/test-stpcpy.c index 3d138d9cae..ce325e67b7 100644 --- a/string/test-stpcpy.c +++ b/string/test-stpcpy.c @@ -1,5 +1,5 @@ -/* Test and measure stpcpy functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. +/* Test stpcpy functions. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -19,19 +19,34 @@ #define STRCPY_RESULT(dst, len) ((dst) + (len)) #define TEST_MAIN -#define TEST_NAME "stpcpy" +#ifndef WIDE +# define TEST_NAME "stpcpy" +#else +# define TEST_NAME "wcpcpy" +#endif /* !WIDE */ #include "test-string.h" - -char *simple_stpcpy (char *, const char *); - -IMPL (simple_stpcpy, 0) -IMPL (stpcpy, 1) - -char * -simple_stpcpy (char *dst, const char *src) +#ifndef WIDE +# define CHAR char +# define SIMPLE_STPCPY simple_stpcpy +# define STPCPY stpcpy +#else +# include <wchar.h> +# define CHAR wchar_t +# define SIMPLE_STPCPY simple_wcpcpy +# define STPCPY wcpcpy +#endif /* !WIDE */ + +CHAR *SIMPLE_STPCPY (CHAR *, const CHAR *); + +IMPL (SIMPLE_STPCPY, 0) +IMPL (STPCPY, 1) + +CHAR * +SIMPLE_STPCPY (CHAR *dst, const CHAR *src) { while ((*dst++ = *src++) != '\0'); return dst - 1; } +#undef CHAR #include "test-strcpy.c" diff --git a/string/test-stpncpy.c b/string/test-stpncpy.c index 1adab34e57..af8f5000e7 100644 --- a/string/test-stpncpy.c +++ b/string/test-stpncpy.c @@ -1,5 +1,5 @@ /* Test and measure stpncpy functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -19,18 +19,36 @@ #define STRNCPY_RESULT(dst, len, n) ((dst) + ((len) > (n) ? (n) : (len))) #define TEST_MAIN -#define TEST_NAME "stpncpy" +#ifndef WIDE +# define TEST_NAME "stpncpy" +#else +# define TEST_NAME "wcpncpy" +#endif /* WIDE */ #include "test-string.h" +#ifndef WIDE +# define CHAR char +# define SIMPLE_STPNCPY simple_stpncpy +# define STUPID_STPNCPY stupid_stpncpy +# define STPNCPY stpncpy +# define STRNLEN strnlen +#else +# include <wchar.h> +# define CHAR wchar_t +# define SIMPLE_STPNCPY simple_wcpncpy +# define STUPID_STPNCPY stupid_wcpncpy +# define STPNCPY wcpncpy +# define STRNLEN wcsnlen +#endif /* WIDE */ -char *simple_stpncpy (char *, const char *, size_t); -char *stupid_stpncpy (char *, const char *, size_t); +CHAR *SIMPLE_STPNCPY (CHAR *, const CHAR *, size_t); +CHAR *STUPID_STPNCPY (CHAR *, const CHAR *, size_t); -IMPL (stupid_stpncpy, 0) -IMPL (simple_stpncpy, 0) -IMPL (stpncpy, 1) +IMPL (STUPID_STPNCPY, 0) +IMPL (SIMPLE_STPNCPY, 0) +IMPL (STPNCPY, 1) -char * -simple_stpncpy (char *dst, const char *src, size_t n) +CHAR * +SIMPLE_STPNCPY (CHAR *dst, const CHAR *src, size_t n) { while (n--) if ((*dst++ = *src++) == '\0') @@ -44,10 +62,10 @@ simple_stpncpy (char *dst, const char *src, size_t n) return dst; } -char * -stupid_stpncpy (char *dst, const char *src, size_t n) +CHAR * +STUPID_STPNCPY (CHAR *dst, const CHAR *src, size_t n) { - size_t nc = strnlen (src, n); + size_t nc = STRNLEN (src, n); size_t i; for (i = 0; i < nc; ++i) @@ -57,4 +75,5 @@ stupid_stpncpy (char *dst, const char *src, size_t n) return dst + nc; } +#undef CHAR #include "test-strncpy.c" diff --git a/string/test-strcasecmp.c b/string/test-strcasecmp.c index 382dcdcd81..63ae2a2ef5 100644 --- a/string/test-strcasecmp.c +++ b/string/test-strcasecmp.c @@ -1,5 +1,5 @@ /* Test and measure strcasecmp functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. diff --git a/string/test-strcasestr.c b/string/test-strcasestr.c index 489dc84205..dea89471f9 100644 --- a/string/test-strcasestr.c +++ b/string/test-strcasestr.c @@ -1,5 +1,5 @@ /* Test and measure strcasestr functions. - Copyright (C) 2010-2015 Free Software Foundation, Inc. + Copyright (C) 2010-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@redhat.com>, 2010. diff --git a/string/test-strcat.c b/string/test-strcat.c index 0a97e25484..1dda0215b8 100644 --- a/string/test-strcat.c +++ b/string/test-strcat.c @@ -1,5 +1,5 @@ -/* Test and measure strcat functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. +/* Test strcat functions. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -18,19 +18,52 @@ <http://www.gnu.org/licenses/>. */ #define TEST_MAIN -#define TEST_NAME "strcat" +#ifndef WIDE +# define TEST_NAME "strcat" +#else +# define TEST_NAME "wcscat" +#endif /* WIDE */ #include "test-string.h" -typedef char *(*proto_t) (char *, const char *); -char *simple_strcat (char *, const char *); +#ifndef WIDE +# define STRCAT strcat +# define CHAR char +# define UCHAR unsigned char +# define sfmt "s" +# define SIMPLE_STRCAT simple_strcat +# define STRLEN strlen +# define STRCMP strcmp +# define MEMSET memset +# define MEMCPY memcpy +# define MEMCMP memcmp +# define BIG_CHAR CHAR_MAX +# define SMALL_CHAR 127 +#else +# include <wchar.h> +# define STRCAT wcscat +# define CHAR wchar_t +# define UCHAR wchar_t +# define sfmt "ls" +# define SIMPLE_STRCAT simple_wcscat +# define STRLEN wcslen +# define STRCMP wcscmp +# define MEMSET wmemset +# define MEMCPY wmemcpy +# define MEMCMP wmemcmp +# define BIG_CHAR WCHAR_MAX +# define SMALL_CHAR 1273 +#endif /* WIDE */ -IMPL (simple_strcat, 0) -IMPL (strcat, 1) +typedef CHAR *(*proto_t) (CHAR *, const CHAR *); +CHAR *SIMPLE_STRCAT (CHAR *, const CHAR *); -char * -simple_strcat (char *dst, const char *src) +IMPL (SIMPLE_STRCAT, 0) +IMPL (STRCAT, 1) + +CHAR * +SIMPLE_STRCAT (CHAR *dst, const CHAR *src) { - char *ret = dst; + CHAR *ret = dst; while (*dst++ != '\0'); --dst; while ((*dst++ = *src++) != '\0'); @@ -38,9 +71,9 @@ simple_strcat (char *dst, const char *src) } static void -do_one_test (impl_t *impl, char *dst, const char *src) +do_one_test (impl_t *impl, CHAR *dst, const CHAR *src) { - size_t k = strlen (dst); + size_t k = STRLEN (dst); if (CALL (impl, dst, src) != dst) { error (0, 0, "Wrong result in function %s %p %p", impl->name, @@ -49,9 +82,9 @@ do_one_test (impl_t *impl, char *dst, const char *src) return; } - if (strcmp (dst + k, src) != 0) + if (STRCMP (dst + k, src) != 0) { - error (0, 0, "Wrong result in function %s dst \"%s\" src \"%s\"", + error (0, 0, "Wrong result in function %s dst \"%" sfmt "\" src \"%" sfmt "\"", impl->name, dst, src); ret = 1; return; @@ -62,18 +95,18 @@ static void do_test (size_t align1, size_t align2, size_t len1, size_t len2, int max_char) { size_t i; - char *s1, *s2; + CHAR *s1, *s2; align1 &= 7; - if (align1 + len1 >= page_size) + if ((align1 + len1) * sizeof (CHAR) >= page_size) return; align2 &= 7; - if (align2 + len1 + len2 >= page_size) + if ((align2 + len1 + len2) * sizeof (CHAR) >= page_size) return; - s1 = (char *) (buf1 + align1); - s2 = (char *) (buf2 + align2); + s1 = (CHAR *) (buf1) + align1; + s2 = (CHAR *) (buf2) + align2; for (i = 0; i < len1; ++i) s1[i] = 32 + 23 * i % (max_char - 32); @@ -93,9 +126,10 @@ static void do_random_tests (void) { size_t i, j, n, align1, align2, len1, len2; - unsigned char *p1 = buf1 + page_size - 512; - unsigned char *p2 = buf2 + page_size - 512; - unsigned char *res; + UCHAR *p1 = (UCHAR *) (buf1 + page_size) - 512; + UCHAR *p2 = (UCHAR *) (buf2 + page_size) - 512; + UCHAR *p3 = (UCHAR *) buf1; + UCHAR *res; for (n = 0; n < ITERATIONS; n++) { @@ -132,26 +166,26 @@ do_random_tests (void) p1[i] = 0; else { - p1[i] = random () & 255; + p1[i] = random () & BIG_CHAR; if (i >= align1 && i < len1 + align1 && !p1[i]) - p1[i] = (random () & 127) + 3; + p1[i] = (random () & SMALL_CHAR) + 3; } } for (i = 0; i < len2; i++) { - buf1[i] = random () & 255; - if (!buf1[i]) - buf1[i] = (random () & 127) + 3; + p3[i] = random () & BIG_CHAR; + if (!p3[i]) + p3[i] = (random () & SMALL_CHAR) + 3; } - buf1[len2] = 0; + p3[len2] = 0; FOR_EACH_IMPL (impl, 1) { - memset (p2 - 64, '\1', align2 + 64); - memset (p2 + align2 + len2 + 1, '\1', 512 - align2 - len2 - 1); - memcpy (p2 + align2, buf1, len2 + 1); - res = (unsigned char *) CALL (impl, (char *) (p2 + align2), - (char *) (p1 + align1)); + MEMSET (p2 - 64, '\1', align2 + 64); + MEMSET (p2 + align2 + len2 + 1, '\1', 512 - align2 - len2 - 1); + MEMCPY (p2 + align2, p3, len2 + 1); + res = (UCHAR *) CALL (impl, (CHAR *) (p2 + align2), + (CHAR *) (p1 + align1)); if (res != p2 + align2) { error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd %zd) %p != %p", @@ -169,7 +203,7 @@ do_random_tests (void) break; } } - if (memcmp (p2 + align2, buf1, len2)) + if (MEMCMP (p2 + align2, p3, len2)) { error (0, 0, "Iteration %zd - garbage in string before, %s (%zd, %zd, %zd, %zd)", n, impl->name, align1, align2, len1, len2); @@ -185,7 +219,7 @@ do_random_tests (void) break; } } - if (memcmp (p1 + align1, p2 + align2 + len2, len1 + 1)) + if (MEMCMP (p1 + align1, p2 + align2 + len2, len1 + 1)) { error (0, 0, "Iteration %zd - different strings, %s (%zd, %zd, %zd, %zd)", n, impl->name, align1, align2, len1, len2); @@ -209,26 +243,26 @@ test_main (void) for (i = 0; i < 16; ++i) { - do_test (0, 0, i, i, 127); - do_test (0, 0, i, i, 255); - do_test (0, i, i, i, 127); - do_test (i, 0, i, i, 255); + do_test (0, 0, i, i, SMALL_CHAR); + do_test (0, 0, i, i, BIG_CHAR); + do_test (0, i, i, i, SMALL_CHAR); + do_test (i, 0, i, i, BIG_CHAR); } for (i = 1; i < 8; ++i) { - do_test (0, 0, 8 << i, 8 << i, 127); - do_test (8 - i, 2 * i, 8 << i, 8 << i, 127); - do_test (0, 0, 8 << i, 2 << i, 127); - do_test (8 - i, 2 * i, 8 << i, 2 << i, 127); + do_test (0, 0, 8 << i, 8 << i, SMALL_CHAR); + do_test (8 - i, 2 * i, 8 << i, 8 << i, SMALL_CHAR); + do_test (0, 0, 8 << i, 2 << i, SMALL_CHAR); + do_test (8 - i, 2 * i, 8 << i, 2 << i, SMALL_CHAR); } for (i = 1; i < 8; ++i) { - do_test (i, 2 * i, 8 << i, 1, 127); - do_test (2 * i, i, 8 << i, 1, 255); - do_test (i, i, 8 << i, 10, 127); - do_test (i, i, 8 << i, 10, 255); + do_test (i, 2 * i, 8 << i, 1, SMALL_CHAR); + do_test (2 * i, i, 8 << i, 1, BIG_CHAR); + do_test (i, i, 8 << i, 10, SMALL_CHAR); + do_test (i, i, 8 << i, 10, BIG_CHAR); } do_random_tests (); diff --git a/string/test-strchr.c b/string/test-strchr.c index ea06c43d7f..27e403d257 100644 --- a/string/test-strchr.c +++ b/string/test-strchr.c @@ -1,5 +1,5 @@ -/* Test and measure STRCHR functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. +/* Test STRCHR functions. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. Added wcschr support by Liubov Dmitrieva <liubov.dmitrieva@gmail.com>, 2011 @@ -24,10 +24,14 @@ # define TEST_NAME "strchrnul" # else # define TEST_NAME "strchr" -# endif +# endif /* !USE_FOR_STRCHRNUL */ #else -# define TEST_NAME "wcschr" -#endif +# ifdef USE_FOR_STRCHRNUL +# define TEST_NAME "wcschrnul" +# else +# define TEST_NAME "wcschr" +# endif /* !USE_FOR_STRCHRNUL */ +#endif /* WIDE */ #include "test-string.h" #ifndef WIDE @@ -37,7 +41,7 @@ # define simple_STRCHR simple_STRCHRNUL # else # define STRCHR strchr -# endif +# endif /* !USE_FOR_STRCHRNUL */ # define STRLEN strlen # define CHAR char # define BIG_CHAR CHAR_MAX @@ -47,7 +51,13 @@ # define L(s) s #else # include <wchar.h> -# define STRCHR wcschr +# ifdef USE_FOR_STRCHRNUL +# define STRCHR wcschrnul +# define stupid_STRCHR stupid_WCSCHRNUL +# define simple_STRCHR simple_WCSCHRNUL +# else +# define STRCHR wcschr +# endif /* !USE_FOR_STRCHRNUL */ # define STRLEN wcslen # define CHAR wchar_t # define BIG_CHAR WCHAR_MAX @@ -55,13 +65,13 @@ # define SMALL_CHAR 851 # define UCHAR wchar_t # define L(s) L ## s -#endif +#endif /* WIDE */ #ifdef USE_FOR_STRCHRNUL # define NULLRET(endptr) endptr #else # define NULLRET(endptr) NULL -#endif +#endif /* !USE_FOR_STRCHRNUL */ typedef CHAR *(*proto_t) (const CHAR *, int); diff --git a/string/test-strchrnul.c b/string/test-strchrnul.c index 8c6bb0fa7f..f635b82a28 100644 --- a/string/test-strchrnul.c +++ b/string/test-strchrnul.c @@ -1,6 +1,6 @@ /* Test and measure strchrnul function. - Copyright (C) 2011-2015 Free Software Foundation, Inc. + Copyright (C) 2011-2016 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 diff --git a/string/test-strcmp.c b/string/test-strcmp.c index dc4ba6f9b4..8d4772a658 100644 --- a/string/test-strcmp.c +++ b/string/test-strcmp.c @@ -1,5 +1,5 @@ /* Test and measure strcmp and wcscmp functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. Added wcscmp support by Liubov Dmitrieva <liubov.dmitrieva@gmail.com>, 2011. diff --git a/string/test-strcpy.c b/string/test-strcpy.c index f0f1dddb40..4e925b1e95 100644 --- a/string/test-strcpy.c +++ b/string/test-strcpy.c @@ -1,5 +1,5 @@ /* Test and measure strcpy functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. Added wcscpy support by Liubov Dmitrieva <liubov.dmitrieva@gmail.com>, 2011 diff --git a/string/test-strcspn.c b/string/test-strcspn.c index b60a048c5c..d0a731569c 100644 --- a/string/test-strcspn.c +++ b/string/test-strcspn.c @@ -1,5 +1,5 @@ -/* Test and measure strcspn functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. +/* Test strcspn functions. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -20,22 +20,41 @@ #define STRPBRK_RESULT(s, pos) (pos) #define RES_TYPE size_t #define TEST_MAIN -#define TEST_NAME "strcspn" +#ifndef WIDE +# define TEST_NAME "strcspn" +#else +# define TEST_NAME "wcscspn" +#endif /* WIDE */ #include "test-string.h" -typedef size_t (*proto_t) (const char *, const char *); -size_t simple_strcspn (const char *, const char *); -size_t stupid_strcspn (const char *, const char *); +#ifndef WIDE +# define STRCSPN strcspn +# define CHAR char +# define SIMPLE_STRCSPN simple_strcspn +# define STUPID_STRCSPN stupid_strcspn +# define STRLEN strlen +#else +# include <wchar.h> +# define STRCSPN wcscspn +# define CHAR wchar_t +# define SIMPLE_STRCSPN simple_wcscspn +# define STUPID_STRCSPN stupid_wcscspn +# define STRLEN wcslen +#endif /* WIDE */ -IMPL (stupid_strcspn, 0) -IMPL (simple_strcspn, 0) -IMPL (strcspn, 1) +typedef size_t (*proto_t) (const CHAR *, const CHAR *); +size_t SIMPLE_STRCSPN (const CHAR *, const CHAR *); +size_t STUPID_STRCSPN (const CHAR *, const CHAR *); + +IMPL (STUPID_STRCSPN, 0) +IMPL (SIMPLE_STRCSPN, 0) +IMPL (STRCSPN, 1) size_t -simple_strcspn (const char *s, const char *rej) +SIMPLE_STRCSPN (const CHAR *s, const CHAR *rej) { - const char *r, *str = s; - char c; + const CHAR *r, *str = s; + CHAR c; while ((c = *s++) != '\0') for (r = rej; *r != '\0'; ++r) @@ -45,9 +64,9 @@ simple_strcspn (const char *s, const char *rej) } size_t -stupid_strcspn (const char *s, const char *rej) +STUPID_STRCSPN (const CHAR *s, const CHAR *rej) { - size_t ns = strlen (s), nrej = strlen (rej); + size_t ns = STRLEN (s), nrej = STRLEN (rej); size_t i, j; for (i = 0; i < ns; ++i) @@ -57,4 +76,6 @@ stupid_strcspn (const char *s, const char *rej) return i; } +#undef CHAR +#undef STRLEN #include "test-strpbrk.c" diff --git a/string/test-string.h b/string/test-string.h index d8bd45b00b..728a7c226a 100644 --- a/string/test-string.h +++ b/string/test-string.h @@ -1,5 +1,5 @@ /* Test and measure string and memory functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. diff --git a/string/test-strlen.c b/string/test-strlen.c index 2c88efae4b..1838b12d51 100644 --- a/string/test-strlen.c +++ b/string/test-strlen.c @@ -1,5 +1,5 @@ /* Test and measure STRLEN functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. Added wcslen support by Liubov Dmitrieva <liubov.dmitrieva@gmail.com>, 2011 diff --git a/string/test-strncasecmp.c b/string/test-strncasecmp.c index de27d86779..08f7a492fb 100644 --- a/string/test-strncasecmp.c +++ b/string/test-strncasecmp.c @@ -1,5 +1,5 @@ /* Test and measure strncasecmp functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. diff --git a/string/test-strncat.c b/string/test-strncat.c index 366e6fccb5..0e9db236ef 100644 --- a/string/test-strncat.c +++ b/string/test-strncat.c @@ -1,5 +1,5 @@ -/* Test and measure strncat functions. - Copyright (C) 2011-2015 Free Software Foundation, Inc. +/* Test strncat functions. + Copyright (C) 2011-2016 Free Software Foundation, Inc. Contributed by Intel Corporation. The GNU C Library is free software; you can redistribute it and/or @@ -17,33 +17,64 @@ <http://www.gnu.org/licenses/>. */ #define TEST_MAIN -#define TEST_NAME "strncat" +#ifndef WIDE +# define TEST_NAME "strncat" +#else +# define TEST_NAME "wcsncat" +#endif /* WIDE */ #include "test-string.h" -typedef char *(*proto_t) (char *, const char *, size_t); -char *stupid_strncat (char *, const char *, size_t); -char *simple_strncat (char *, const char *, size_t); +#ifndef WIDE +# define STRNCAT strncat +# define CHAR char +# define UCHAR unsigned char +# define SIMPLE_STRNCAT simple_strncat +# define STUPID_STRNCAT stupid_strncat +# define STRLEN strlen +# define MEMSET memset +# define MEMCPY memcpy +# define MEMCMP memcmp +# define BIG_CHAR CHAR_MAX +# define SMALL_CHAR 127 +#else +# include <wchar.h> +# define STRNCAT wcsncat +# define CHAR wchar_t +# define UCHAR wchar_t +# define SIMPLE_STRNCAT simple_wcsncat +# define STUPID_STRNCAT stupid_wcsncat +# define STRLEN wcslen +# define MEMSET wmemset +# define MEMCPY wmemcpy +# define MEMCMP wmemcmp +# define BIG_CHAR WCHAR_MAX +# define SMALL_CHAR 1273 +#endif /* WIDE */ -IMPL (stupid_strncat, 0) -IMPL (strncat, 2) +typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t); +CHAR *STUPID_STRNCAT (CHAR *, const CHAR *, size_t); +CHAR *SIMPLE_STRNCAT (CHAR *, const CHAR *, size_t); -char * -stupid_strncat (char *dst, const char *src, size_t n) +IMPL (STUPID_STRNCAT, 0) +IMPL (STRNCAT, 2) + +CHAR * +STUPID_STRNCAT (CHAR *dst, const CHAR *src, size_t n) { - char *ret = dst; + CHAR *ret = dst; while (*dst++ != '\0'); --dst; while (n--) - if ( (*dst++ = *src++) == '\0') + if ((*dst++ = *src++) == '\0') return ret; *dst = '\0'; return ret; } static void -do_one_test (impl_t *impl, char *dst, const char *src, size_t n) +do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t n) { - size_t k = strlen (dst); + size_t k = STRLEN (dst); if (CALL (impl, dst, src, n) != dst) { error (0, 0, "Wrong result in function %s %p != %p", impl->name, @@ -52,10 +83,10 @@ do_one_test (impl_t *impl, char *dst, const char *src, size_t n) return; } - size_t len = strlen (src); - if (memcmp (dst + k, src, len + 1 > n ? n : len + 1) != 0) + size_t len = STRLEN (src); + if (MEMCMP (dst + k, src, len + 1 > n ? n : len + 1) != 0) { - error (0, 0, "Incorrect cancatination in function %s", + error (0, 0, "Incorrect concatenation in function %s", impl->name); ret = 1; return; @@ -74,20 +105,20 @@ do_test (size_t align1, size_t align2, size_t len1, size_t len2, size_t n, int max_char) { size_t i; - char *s1, *s2; + CHAR *s1, *s2; align1 &= 7; - if (align1 + len1 >= page_size) + if ((align1 + len1) * sizeof (CHAR) >= page_size) return; - if (align1 + n > page_size) + if ((align1 + n) * sizeof (CHAR) > page_size) return; align2 &= 7; - if (align2 + len1 + len2 >= page_size) + if ((align2 + len1 + len2) * sizeof (CHAR) >= page_size) return; - if (align2 + len1 + n > page_size) + if ((align2 + len1 + n) * sizeof (CHAR) > page_size) return; - s1 = (char *) (buf1 + align1); - s2 = (char *) (buf2 + align2); + s1 = (CHAR *) (buf1) + align1; + s2 = (CHAR *) (buf2) + align2; for (i = 0; i < len1; ++i) s1[i] = 32 + 23 * i % (max_char - 32); @@ -107,9 +138,10 @@ static void do_random_tests (void) { size_t i, j, n, align1, align2, len1, len2, N; - unsigned char *p1 = buf1 + page_size - 512; - unsigned char *p2 = buf2 + page_size - 512; - unsigned char *res; + UCHAR *p1 = (UCHAR *) (buf1 + page_size) - 512; + UCHAR *p2 = (UCHAR *) (buf2 + page_size) - 512; + UCHAR *p3 = (UCHAR *) buf1; + UCHAR *res; fprintf (stdout, "Number of iterations in random test = %zd\n", ITERATIONS); for (n = 0; n < ITERATIONS; n++) @@ -148,26 +180,26 @@ do_random_tests (void) p1[i] = 0; else { - p1[i] = random () & 255; + p1[i] = random () & BIG_CHAR; if (i >= align1 && i < len1 + align1 && !p1[i]) - p1[i] = (random () & 127) + 3; + p1[i] = (random () & SMALL_CHAR) + 3; } } for (i = 0; i < len2; i++) { - buf1[i] = random () & 255; - if (!buf1[i]) - buf1[i] = (random () & 127) + 3; + p3[i] = random () & BIG_CHAR; + if (!p3[i]) + p3[i] = (random () & SMALL_CHAR) + 3; } - buf1[len2] = 0; + p3[len2] = 0; FOR_EACH_IMPL (impl, 1) { - memset (p2 - 64, '\1', align2 + 64); - memset (p2 + align2 + len2 + 1, '\1', 512 - align2 - len2 - 1); - memcpy (p2 + align2, buf1, len2 + 1); - res = (unsigned char *) CALL (impl, (char *) (p2 + align2), - (char *) (p1 + align1), N); + MEMSET (p2 - 64, '\1', align2 + 64); + MEMSET (p2 + align2 + len2 + 1, '\1', 512 - align2 - len2 - 1); + MEMCPY (p2 + align2, p3, len2 + 1); + res = (UCHAR *) CALL (impl, (CHAR *) (p2 + align2), + (CHAR *) (p1 + align1), N); if (res != p2 + align2) { error (0, 0, "Iteration %zd - wrong result in function %s " @@ -187,7 +219,7 @@ do_random_tests (void) break; } } - if (memcmp (p2 + align2, buf1, len2)) + if (MEMCMP (p2 + align2, p3, len2)) { error (0, 0, "Iteration %zd - garbage in string before, %s " "(%zd, %zd, %zd, %zd, %zd)", @@ -220,7 +252,7 @@ do_random_tests (void) ret = 1; } } - if (memcmp (p1 + align1, p2 + align2 + len2, + if (MEMCMP (p1 + align1, p2 + align2 + len2, (len1 + 1) > N ? N : len1 + 1)) { error (0, 0, "Iteration %zd - different strings, %s " @@ -233,7 +265,7 @@ do_random_tests (void) } int -main (void) +test_main (void) { size_t i, n; @@ -246,28 +278,30 @@ main (void) for (n = 2; n <= 2048; n*=4) { - do_test (0, 2, 2, 2, n, 127); - do_test (0, 0, 4, 4, n, 127); - do_test (4, 0, 4, 4, n, 255); - do_test (0, 0, 8, 8, n, 127); - do_test (0, 8, 8, 8, n, 127); + do_test (0, 2, 2, 2, n, SMALL_CHAR); + do_test (0, 0, 4, 4, n, SMALL_CHAR); + do_test (4, 0, 4, 4, n, BIG_CHAR); + do_test (0, 0, 8, 8, n, SMALL_CHAR); + do_test (0, 8, 8, 8, n, SMALL_CHAR); for (i = 1; i < 8; ++i) { - do_test (0, 0, 8 << i, 8 << i, n, 127); - do_test (8 - i, 2 * i, 8 << i, 8 << i, n, 127); - do_test (0, 0, 8 << i, 2 << i, n, 127); - do_test (8 - i, 2 * i, 8 << i, 2 << i, n, 127); + do_test (0, 0, 8 << i, 8 << i, n, SMALL_CHAR); + do_test (8 - i, 2 * i, 8 << i, 8 << i, n, SMALL_CHAR); + do_test (0, 0, 8 << i, 2 << i, n, SMALL_CHAR); + do_test (8 - i, 2 * i, 8 << i, 2 << i, n, SMALL_CHAR); } for (i = 1; i < 8; ++i) { - do_test (i, 2 * i, 8 << i, 1, n, 127); - do_test (2 * i, i, 8 << i, 1, n, 255); - do_test (i, i, 8 << i, 10, n, 127); + do_test (i, 2 * i, 8 << i, 1, n, SMALL_CHAR); + do_test (2 * i, i, 8 << i, 1, n, BIG_CHAR); + do_test (i, i, 8 << i, 10, n, SMALL_CHAR); } } do_random_tests (); return ret; } + +#include "../test-skeleton.c" diff --git a/string/test-strncmp.c b/string/test-strncmp.c index fb57a9bdc5..8c0a331fc8 100644 --- a/string/test-strncmp.c +++ b/string/test-strncmp.c @@ -1,5 +1,5 @@ /* Test strncmp and wcsncmp functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. diff --git a/string/test-strncpy.c b/string/test-strncpy.c index d1c312a3a2..75b4170e90 100644 --- a/string/test-strncpy.c +++ b/string/test-strncpy.c @@ -1,5 +1,5 @@ -/* Test and measure strncpy functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. +/* Test strncpy functions. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -17,23 +17,56 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#ifdef WIDE +# include <wchar.h> +# define CHAR wchar_t +# define UCHAR wchar_t +# define BIG_CHAR WCHAR_MAX +# define SMALL_CHAR 1273 +# define MEMCMP wmemcmp +# define MEMSET wmemset +# define STRNLEN wcsnlen +#else +# define CHAR char +# define UCHAR unsigned char +# define BIG_CHAR CHAR_MAX +# define SMALL_CHAR 127 +# define MEMCMP memcmp +# define MEMSET memset +# define STRNLEN strnlen +#endif /* !WIDE */ + + #ifndef STRNCPY_RESULT # define STRNCPY_RESULT(dst, len, n) dst # define TEST_MAIN -# define TEST_NAME "strncpy" +# ifndef WIDE +# define TEST_NAME "strncpy" +# else +# define TEST_NAME "wcsncpy" +# endif /* WIDE */ # include "test-string.h" +# ifndef WIDE +# define SIMPLE_STRNCPY simple_strncpy +# define STUPID_STRNCPY stupid_strncpy +# define STRNCPY strncpy +# else +# define SIMPLE_STRNCPY simple_wcsncpy +# define STUPID_STRNCPY stupid_wcsncpy +# define STRNCPY wcsncpy +# endif /* WIDE */ -char *simple_strncpy (char *, const char *, size_t); -char *stupid_strncpy (char *, const char *, size_t); +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) +IMPL (STUPID_STRNCPY, 0) +IMPL (SIMPLE_STRNCPY, 0) +IMPL (STRNCPY, 1) -char * -simple_strncpy (char *dst, const char *src, size_t n) +CHAR * +SIMPLE_STRNCPY (CHAR *dst, const CHAR *src, size_t n) { - char *ret = dst; + CHAR *ret = dst; while (n--) if ((*dst++ = *src++) == '\0') { @@ -44,10 +77,10 @@ simple_strncpy (char *dst, const char *src, size_t n) return ret; } -char * -stupid_strncpy (char *dst, const char *src, size_t n) +CHAR * +STUPID_STRNCPY (CHAR *dst, const CHAR *src, size_t n) { - size_t nc = strnlen (src, n); + size_t nc = STRNLEN (src, n); size_t i; for (i = 0; i < nc; ++i) @@ -56,12 +89,12 @@ stupid_strncpy (char *dst, const char *src, size_t n) dst[i] = '\0'; return dst; } -#endif +#endif /* !STRNCPY_RESULT */ -typedef char *(*proto_t) (char *, const char *, size_t); +typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t); static void -do_one_test (impl_t *impl, char *dst, const char *src, size_t len, size_t n) +do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t len, size_t n) { if (CALL (impl, dst, src, n) != STRNCPY_RESULT (dst, len, n)) { @@ -71,7 +104,7 @@ do_one_test (impl_t *impl, char *dst, const char *src, size_t len, size_t n) return; } - if (memcmp (dst, src, len > n ? n : len) != 0) + if (memcmp (dst, src, (len > n ? n : len) * sizeof (CHAR)) != 0) { error (0, 0, "Wrong result in function %s", impl->name); ret = 1; @@ -96,23 +129,26 @@ static void do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char) { size_t i; - char *s1, *s2; + CHAR *s1, *s2; +/* For wcsncpy: align1 and align2 here mean alignment not in bytes, + but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t)). */ align1 &= 7; - if (align1 + len >= page_size) + if ((align1 + len) * sizeof (CHAR) >= page_size) return; align2 &= 7; - if (align2 + len >= page_size) + if ((align2 + len) * sizeof (CHAR) >= page_size) return; - s1 = (char *) (buf1 + align1); - s2 = (char *) (buf2 + align2); + s1 = (CHAR *) (buf1) + align1; + s2 = (CHAR *) (buf2) + align2; for (i = 0; i < len; ++i) s1[i] = 32 + 23 * i % (max_char - 32); s1[len] = 0; - for (i = len + 1; i + align1 < page_size && i < len + 64; ++i) + for (i = len + 1; (i + align1) * sizeof (CHAR) < page_size && i < len + 64; + ++i) s1[i] = 32 + 32 * i % (max_char - 32); FOR_EACH_IMPL (impl, 0) @@ -123,12 +159,16 @@ static void do_random_tests (void) { size_t i, j, n, align1, align2, len, size, mode; - unsigned char *p1 = buf1 + page_size - 512; - unsigned char *p2 = buf2 + page_size - 512; - unsigned char *res; + UCHAR *p1 = (UCHAR *) (buf1 + page_size) - 512; + UCHAR *p2 = (UCHAR *) (buf2 + page_size) - 512; + UCHAR *res; for (n = 0; n < ITERATIONS; n++) { + /* For wcsncpy: align1 and align2 here mean align not in bytes, + but in wchar_ts, in bytes it will equal to align * (sizeof + (wchar_t)). */ + mode = random (); if (mode & 1) { @@ -166,7 +206,7 @@ do_random_tests (void) { size = random () & 511; if (size + j > 512) - size = 512 - j - (random() & 31); + size = 512 - j - (random () & 31); } else size = 512 - j; @@ -182,18 +222,17 @@ do_random_tests (void) p1[i] = 0; else { - p1[i] = random () & 255; + p1[i] = random () & BIG_CHAR; if (i >= align1 && i < len + align1 && !p1[i]) - p1[i] = (random () & 127) + 3; + p1[i] = (random () & SMALL_CHAR) + 3; } } FOR_EACH_IMPL (impl, 1) { - memset (p2 - 64, '\1', 512 + 64); - res = (unsigned char *) CALL (impl, - (char *) (p2 + align2), - (char *) (p1 + align1), size); + MEMSET (p2 - 64, '\1', 512 + 64); + res = (UCHAR *) CALL (impl, (CHAR *) (p2 + align2), + (CHAR *) (p1 + align1), size); if (res != STRNCPY_RESULT (p2 + align2, len, size)) { error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %zd, %zd) %p != %p", @@ -235,7 +274,7 @@ do_random_tests (void) j = len + 1; if (size < j) j = size; - if (memcmp (p1 + align1, p2 + align2, j)) + if (MEMCMP (p1 + align1, p2 + align2, j)) { error (0, 0, "Iteration %zd - different strings, %s (%zd, %zd, %zd)", n, impl->name, align1, align2, len); @@ -259,22 +298,22 @@ test_main (void) for (i = 1; i < 8; ++i) { - do_test (i, i, 16, 16, 127); - do_test (i, i, 16, 16, 255); - do_test (i, 2 * i, 16, 16, 127); - do_test (2 * i, i, 16, 16, 255); - do_test (8 - i, 2 * i, 1 << i, 2 << i, 127); - do_test (2 * i, 8 - i, 2 << i, 1 << i, 127); - do_test (8 - i, 2 * i, 1 << i, 2 << i, 255); - do_test (2 * i, 8 - i, 2 << i, 1 << i, 255); + do_test (i, i, 16, 16, SMALL_CHAR); + do_test (i, i, 16, 16, BIG_CHAR); + do_test (i, 2 * i, 16, 16, SMALL_CHAR); + do_test (2 * i, i, 16, 16, BIG_CHAR); + do_test (8 - i, 2 * i, 1 << i, 2 << i, SMALL_CHAR); + do_test (2 * i, 8 - i, 2 << i, 1 << i, SMALL_CHAR); + do_test (8 - i, 2 * i, 1 << i, 2 << i, BIG_CHAR); + do_test (2 * i, 8 - i, 2 << i, 1 << i, BIG_CHAR); } for (i = 1; i < 8; ++i) { - do_test (0, 0, 4 << i, 8 << i, 127); - do_test (0, 0, 16 << i, 8 << i, 127); - do_test (8 - i, 2 * i, 4 << i, 8 << i, 127); - do_test (8 - i, 2 * i, 16 << i, 8 << i, 127); + do_test (0, 0, 4 << i, 8 << i, SMALL_CHAR); + do_test (0, 0, 16 << i, 8 << i, SMALL_CHAR); + do_test (8 - i, 2 * i, 4 << i, 8 << i, SMALL_CHAR); + do_test (8 - i, 2 * i, 16 << i, 8 << i, SMALL_CHAR); } do_random_tests (); diff --git a/string/test-strnlen.c b/string/test-strnlen.c index 96797e156b..5149820ab3 100644 --- a/string/test-strnlen.c +++ b/string/test-strnlen.c @@ -1,5 +1,5 @@ -/* Test and measure strlen functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. +/* Test strlen functions. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -18,17 +18,36 @@ <http://www.gnu.org/licenses/>. */ #define TEST_MAIN -#define TEST_NAME "strnlen" +#ifndef WIDE +# define TEST_NAME "strnlen" +#else +# define TEST_NAME "wcsnlen" +#endif /* !WIDE */ #include "test-string.h" -typedef size_t (*proto_t) (const char *, size_t); -size_t simple_strnlen (const char *, size_t); - -IMPL (simple_strnlen, 0) -IMPL (strnlen, 1) +#ifndef WIDE +# define STRNLEN strnlen +# define CHAR char +# define BIG_CHAR CHAR_MAX +# define MIDDLE_CHAR 127 +# define SIMPLE_STRNLEN simple_strnlen +#else +# include <wchar.h> +# define STRNLEN wcsnlen +# define CHAR wchar_t +# define BIG_CHAR WCHAR_MAX +# define MIDDLE_CHAR 1121 +# define SIMPLE_STRNLEN simple_wcsnlen +#endif /* !WIDE */ + +typedef size_t (*proto_t) (const CHAR *, size_t); +size_t SIMPLE_STRNLEN (const CHAR *, size_t); + +IMPL (SIMPLE_STRNLEN, 0) +IMPL (STRNLEN, 1) size_t -simple_strnlen (const char *s, size_t maxlen) +SIMPLE_STRNLEN (const CHAR *s, size_t maxlen) { size_t i; @@ -37,7 +56,7 @@ simple_strnlen (const char *s, size_t maxlen) } static void -do_one_test (impl_t *impl, const char *s, size_t maxlen, size_t exp_len) +do_one_test (impl_t *impl, const CHAR *s, size_t maxlen, size_t exp_len) { size_t len = CALL (impl, s, maxlen); if (len != exp_len) @@ -54,23 +73,25 @@ do_test (size_t align, size_t len, size_t maxlen, int max_char) { size_t i; - align &= 7; - if (align + len >= page_size) + align &= 63; + if ((align + len) * sizeof (CHAR) >= page_size) return; + CHAR *buf = (CHAR *) (buf1); + for (i = 0; i < len; ++i) - buf1[align + i] = 1 + 7 * i % max_char; - buf1[align + len] = 0; + buf[align + i] = 1 + 11111 * i % max_char; + buf[align + len] = 0; FOR_EACH_IMPL (impl, 0) - do_one_test (impl, (char *) (buf1 + align), maxlen, MIN (len, maxlen)); + do_one_test (impl, (CHAR *) (buf + align), maxlen, MIN (len, maxlen)); } static void do_random_tests (void) { size_t i, j, n, align, len; - unsigned char *p = buf1 + page_size - 512; + CHAR *p = (CHAR *) (buf1 + page_size - 512 * sizeof (CHAR)); for (n = 0; n < ITERATIONS; n++) { @@ -97,25 +118,25 @@ do_random_tests (void) FOR_EACH_IMPL (impl, 1) { if (len > 0 - && CALL (impl, (char *) (p + align), len - 1) != len - 1) + && CALL (impl, (CHAR *) (p + align), len - 1) != len - 1) { error (0, 0, "Iteration %zd (limited) - wrong result in function %s (%zd) %zd != %zd, p %p", n, impl->name, align, - CALL (impl, (char *) (p + align), len - 1), len - 1, p); + CALL (impl, (CHAR *) (p + align), len - 1), len - 1, p); ret = 1; } - if (CALL (impl, (char *) (p + align), len) != len) + if (CALL (impl, (CHAR *) (p + align), len) != len) { error (0, 0, "Iteration %zd (exact) - wrong result in function %s (%zd) %zd != %zd, p %p", n, impl->name, align, - CALL (impl, (char *) (p + align), len), len, p); + CALL (impl, (CHAR *) (p + align), len), len, p); ret = 1; } - if (CALL (impl, (char *) (p + align), len + 1) != len) + if (CALL (impl, (CHAR *) (p + align), len + 1) != len) { error (0, 0, "Iteration %zd (long) - wrong result in function %s (%zd) %zd != %zd, p %p", n, impl->name, align, - CALL (impl, (char *) (p + align), len + 1), len, p); + CALL (impl, (CHAR *) (p + align), len + 1), len, p); ret = 1; } } @@ -136,34 +157,34 @@ test_main (void) for (i = 1; i < 8; ++i) { - do_test (0, i, i - 1, 127); - do_test (0, i, i, 127); - do_test (0, i, i + 1, 127); + do_test (0, i, i - 1, MIDDLE_CHAR); + do_test (0, i, i, MIDDLE_CHAR); + do_test (0, i, i + 1, MIDDLE_CHAR); } for (i = 1; i < 8; ++i) { - do_test (i, i, i - 1, 127); - do_test (i, i, i, 127); - do_test (i, i, i + 1, 127); + do_test (i, i, i - 1, MIDDLE_CHAR); + do_test (i, i, i, MIDDLE_CHAR); + do_test (i, i, i + 1, MIDDLE_CHAR); } for (i = 2; i <= 10; ++i) { - do_test (0, 1 << i, 5000, 127); - do_test (1, 1 << i, 5000, 127); + do_test (0, 1 << i, 5000, MIDDLE_CHAR); + do_test (1, 1 << i, 5000, MIDDLE_CHAR); } for (i = 1; i < 8; ++i) - do_test (0, i, 5000, 255); + do_test (0, i, 5000, BIG_CHAR); for (i = 1; i < 8; ++i) - do_test (i, i, 5000, 255); + do_test (i, i, 5000, BIG_CHAR); for (i = 2; i <= 10; ++i) { - do_test (0, 1 << i, 5000, 255); - do_test (1, 1 << i, 5000, 255); + do_test (0, 1 << i, 5000, BIG_CHAR); + do_test (1, 1 << i, 5000, BIG_CHAR); } do_random_tests (); diff --git a/string/test-strpbrk.c b/string/test-strpbrk.c index b4ac389a71..0cd643c042 100644 --- a/string/test-strpbrk.c +++ b/string/test-strpbrk.c @@ -1,5 +1,5 @@ /* Test and measure strpbrk functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -17,50 +17,82 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#ifndef WIDE +# define CHAR char +# define UCHAR unsigned char +# define STRLEN strlen +# define STRCHR strchr +# define BIG_CHAR CHAR_MAX +# define SMALL_CHAR 127 +#else +# include <wchar.h> +# define CHAR wchar_t +# define UCHAR wchar_t +# define STRLEN wcslen +# define STRCHR wcschr +# define BIG_CHAR WCHAR_MAX +# define SMALL_CHAR 1273 +#endif /* WIDE */ + #ifndef STRPBRK_RESULT # define STRPBRK_RESULT(s, pos) ((s)[(pos)] ? (s) + (pos) : NULL) -# define RES_TYPE char * +# define RES_TYPE CHAR * # define TEST_MAIN -# define TEST_NAME "strpbrk" +# ifndef WIDE +# define TEST_NAME "strpbrk" +# else +# define TEST_NAME "wcspbrk" +# endif /* WIDE */ # include "test-string.h" -typedef char *(*proto_t) (const char *, const char *); -char *simple_strpbrk (const char *, const char *); -char *stupid_strpbrk (const char *, const char *); +# ifndef WIDE +# define STRPBRK strpbrk +# define SIMPLE_STRPBRK simple_strpbrk +# define STUPID_STRPBRK stupid_strpbrk +# else +# include <wchar.h> +# define STRPBRK wcspbrk +# define SIMPLE_STRPBRK simple_wcspbrk +# define STUPID_STRPBRK stupid_wcspbrk +# endif /* WIDE */ + +typedef CHAR *(*proto_t) (const CHAR *, const CHAR *); +CHAR *SIMPLE_STRPBRK (const CHAR *, const CHAR *); +CHAR *STUPID_STRPBRK (const CHAR *, const CHAR *); -IMPL (stupid_strpbrk, 0) -IMPL (simple_strpbrk, 0) -IMPL (strpbrk, 1) +IMPL (STUPID_STRPBRK, 0) +IMPL (SIMPLE_STRPBRK, 0) +IMPL (STRPBRK, 1) -char * -simple_strpbrk (const char *s, const char *rej) +CHAR * +SIMPLE_STRPBRK (const CHAR *s, const CHAR *rej) { - const char *r; - char c; + const CHAR *r; + CHAR c; while ((c = *s++) != '\0') for (r = rej; *r != '\0'; ++r) if (*r == c) - return (char *) s - 1; + return (CHAR *) s - 1; return NULL; } -char * -stupid_strpbrk (const char *s, const char *rej) +CHAR * +STUPID_STRPBRK (const CHAR *s, const CHAR *rej) { - size_t ns = strlen (s), nrej = strlen (rej); + size_t ns = STRLEN (s), nrej = STRLEN (rej); size_t i, j; for (i = 0; i < ns; ++i) for (j = 0; j < nrej; ++j) if (s[i] == rej[j]) - return (char *) s + i; + return (CHAR *) s + i; return NULL; } -#endif +#endif /* !STRPBRK_RESULT */ static void -do_one_test (impl_t *impl, const char *s, const char *rej, RES_TYPE exp_res) +do_one_test (impl_t *impl, const CHAR *s, const CHAR *rej, RES_TYPE exp_res) { RES_TYPE res = CALL (impl, s, rej); if (res != exp_res) @@ -78,35 +110,35 @@ do_test (size_t align, size_t pos, size_t len) size_t i; int c; RES_TYPE result; - char *rej, *s; + CHAR *rej, *s; align &= 7; - if (align + pos + 10 >= page_size || len > 240) + if ((align + pos + 10) * sizeof (CHAR) >= page_size || len > 240) return; - rej = (char *) (buf2 + (random () & 255)); - s = (char *) (buf1 + align); + rej = (CHAR *) (buf2) + (random () & 255); + s = (CHAR *) (buf1) + align; for (i = 0; i < len; ++i) { - rej[i] = random () & 255; + rej[i] = random () & BIG_CHAR; if (!rej[i]) - rej[i] = random () & 255; + rej[i] = random () & BIG_CHAR; if (!rej[i]) - rej[i] = 1 + (random () & 127); + rej[i] = 1 + (random () & SMALL_CHAR); } rej[len] = '\0'; - for (c = 1; c <= 255; ++c) - if (strchr (rej, c) == NULL) + for (c = 1; c <= BIG_CHAR; ++c) + if (STRCHR (rej, c) == NULL) break; for (i = 0; i < pos; ++i) { - s[i] = random () & 255; - if (strchr (rej, s[i])) + s[i] = random () & BIG_CHAR; + if (STRCHR (rej, s[i])) { - s[i] = random () & 255; - if (strchr (rej, s[i])) + s[i] = random () & BIG_CHAR; + if (STRCHR (rej, s[i])) s[i] = c; } } @@ -114,7 +146,7 @@ do_test (size_t align, size_t pos, size_t len) if (s[pos]) { for (i = pos + 1; i < pos + 10; ++i) - s[i] = random () & 255; + s[i] = random () & BIG_CHAR; s[i] = '\0'; } result = STRPBRK_RESULT (s, pos); @@ -129,8 +161,8 @@ do_random_tests (void) size_t i, j, n, align, pos, len, rlen; RES_TYPE result; int c; - unsigned char *p = buf1 + page_size - 512; - unsigned char *rej; + UCHAR *p = (UCHAR *) (buf1 + page_size) - 512; + UCHAR *rej; for (n = 0; n < ITERATIONS; n++) { @@ -147,18 +179,18 @@ do_random_tests (void) rlen = random () & 63; else rlen = random () & 15; - rej = buf2 + page_size - rlen - 1 - (random () & 7); + rej = (UCHAR *) (buf2 + page_size) - rlen - 1 - (random () & 7); for (i = 0; i < rlen; ++i) { - rej[i] = random () & 255; + rej[i] = random () & BIG_CHAR; if (!rej[i]) - rej[i] = random () & 255; + rej[i] = random () & BIG_CHAR; if (!rej[i]) - rej[i] = 1 + (random () & 127); + rej[i] = 1 + (random () & SMALL_CHAR); } rej[i] = '\0'; - for (c = 1; c <= 255; ++c) - if (strchr ((char *) rej, c) == NULL) + for (c = 1; c <= BIG_CHAR; ++c) + if (STRCHR ((CHAR *) rej, c) == NULL) break; j = (pos > len ? pos : len) + align + 64; if (j > 512) @@ -171,27 +203,27 @@ do_random_tests (void) else if (i == pos + align) p[i] = rej[random () % (rlen + 1)]; else if (i < align || i > pos + align) - p[i] = random () & 255; + p[i] = random () & BIG_CHAR; else { - p[i] = random () & 255; - if (strchr ((char *) rej, p[i])) + p[i] = random () & BIG_CHAR; + if (STRCHR ((CHAR *) rej, p[i])) { - p[i] = random () & 255; - if (strchr ((char *) rej, p[i])) + p[i] = random () & BIG_CHAR; + if (STRCHR ((CHAR *) rej, p[i])) p[i] = c; } } } - result = STRPBRK_RESULT ((char *) (p + align), pos < len ? pos : len); + result = STRPBRK_RESULT ((CHAR *) (p + align), pos < len ? pos : len); FOR_EACH_IMPL (impl, 1) - if (CALL (impl, (char *) (p + align), (char *) rej) != result) + if (CALL (impl, (CHAR *) (p + align), (CHAR *) rej) != result) { error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %p, %zd, %zd, %zd) %p != %p", n, impl->name, align, rej, rlen, pos, len, - (void *) CALL (impl, (char *) (p + align), (char *) rej), + (void *) CALL (impl, (CHAR *) (p + align), (CHAR *) rej), (void *) result); ret = 1; } diff --git a/string/test-strrchr.c b/string/test-strrchr.c index d8d826e536..9a102959bd 100644 --- a/string/test-strrchr.c +++ b/string/test-strrchr.c @@ -1,5 +1,5 @@ /* Test and measure STRCHR functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. Added wcsrrchr support by Liubov Dmitrieva <liubov.dmitrieva@gmail.com>, diff --git a/string/test-strspn.c b/string/test-strspn.c index 89fef8726c..98b51dab0e 100644 --- a/string/test-strspn.c +++ b/string/test-strspn.c @@ -1,5 +1,5 @@ /* Test and measure strspn functions. - Copyright (C) 1999-2015 Free Software Foundation, Inc. + Copyright (C) 1999-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Jakub Jelinek <jakub@redhat.com>, 1999. @@ -18,22 +18,49 @@ <http://www.gnu.org/licenses/>. */ #define TEST_MAIN -#define TEST_NAME "strspn" +#ifndef WIDE +# define TEST_NAME "strspn" +#else +# define TEST_NAME "wcsspn" +#endif /* WIDE */ #include "test-string.h" -typedef size_t (*proto_t) (const char *, const char *); -size_t simple_strspn (const char *, const char *); -size_t stupid_strspn (const char *, const char *); - -IMPL (stupid_strspn, 0) -IMPL (simple_strspn, 0) -IMPL (strspn, 1) +#ifndef WIDE +# define STRSPN strspn +# define CHAR char +# define UCHAR unsigned char +# define SIMPLE_STRSPN simple_strspn +# define STUPID_STRSPN stupid_strspn +# define STRLEN strlen +# define STRCHR strchr +# define BIG_CHAR CHAR_MAX +# define SMALL_CHAR 127 +#else +# include <wchar.h> +# define STRSPN wcsspn +# define CHAR wchar_t +# define UCHAR wchar_t +# define SIMPLE_STRSPN simple_wcsspn +# define STUPID_STRSPN stupid_wcsspn +# define STRLEN wcslen +# define STRCHR wcschr +# define BIG_CHAR WCHAR_MAX +# define SMALL_CHAR 1273 +#endif /* WIDE */ + +typedef size_t (*proto_t) (const CHAR *, const CHAR *); +size_t SIMPLE_STRSPN (const CHAR *, const CHAR *); +size_t STUPID_STRSPN (const CHAR *, const CHAR *); + +IMPL (STUPID_STRSPN, 0) +IMPL (SIMPLE_STRSPN, 0) +IMPL (STRSPN, 1) size_t -simple_strspn (const char *s, const char *acc) +SIMPLE_STRSPN (const CHAR *s, const CHAR *acc) { - const char *r, *str = s; - char c; + const CHAR *r, *str = s; + CHAR c; while ((c = *s++) != '\0') { @@ -47,9 +74,9 @@ simple_strspn (const char *s, const char *acc) } size_t -stupid_strspn (const char *s, const char *acc) +STUPID_STRSPN (const CHAR *s, const CHAR *acc) { - size_t ns = strlen (s), nacc = strlen (acc); + size_t ns = STRLEN (s), nacc = STRLEN (acc); size_t i, j; for (i = 0; i < ns; ++i) @@ -64,7 +91,7 @@ stupid_strspn (const char *s, const char *acc) } static void -do_one_test (impl_t *impl, const char *s, const char *acc, size_t exp_res) +do_one_test (impl_t *impl, const CHAR *s, const CHAR *acc, size_t exp_res) { size_t res = CALL (impl, s, acc); if (res != exp_res) @@ -80,34 +107,34 @@ static void do_test (size_t align, size_t pos, size_t len) { size_t i; - char *acc, *s; + CHAR *acc, *s; align &= 7; - if (align + pos + 10 >= page_size || len > 240 || ! len) + if ((align + pos + 10) * sizeof (CHAR) >= page_size || len > 240 || ! len) return; - acc = (char *) (buf2 + (random () & 255)); - s = (char *) (buf1 + align); + acc = (CHAR *) (buf2) + (random () & 255); + s = (CHAR *) (buf1) + align; for (i = 0; i < len; ++i) { - acc[i] = random () & 255; + acc[i] = random () & BIG_CHAR; if (!acc[i]) - acc[i] = random () & 255; + acc[i] = random () & BIG_CHAR; if (!acc[i]) - acc[i] = 1 + (random () & 127); + acc[i] = 1 + (random () & SMALL_CHAR); } acc[len] = '\0'; for (i = 0; i < pos; ++i) s[i] = acc[random () % len]; - s[pos] = random () & 255; - if (strchr (acc, s[pos])) + s[pos] = random () & BIG_CHAR; + if (STRCHR (acc, s[pos])) s[pos] = '\0'; else { for (i = pos + 1; i < pos + 10; ++i) - s[i] = random () & 255; + s[i] = random () & BIG_CHAR; s[i] = '\0'; } @@ -119,8 +146,8 @@ static void do_random_tests (void) { size_t i, j, n, align, pos, alen, len; - unsigned char *p = buf1 + page_size - 512; - unsigned char *acc; + UCHAR *p = (UCHAR *) (buf1 + page_size) - 512; + UCHAR *acc; for (n = 0; n < ITERATIONS; n++) { @@ -138,14 +165,14 @@ do_random_tests (void) len = random () & 511; if (len + align >= 512) len = 511 - align - (random () & 7); - acc = buf2 + page_size - alen - 1 - (random () & 7); + acc = (UCHAR *) (buf2 + page_size) - alen - 1 - (random () & 7); for (i = 0; i < alen; ++i) { - acc[i] = random () & 255; + acc[i] = random () & BIG_CHAR; if (!acc[i]) - acc[i] = random () & 255; + acc[i] = random () & BIG_CHAR; if (!acc[i]) - acc[i] = 1 + (random () & 127); + acc[i] = 1 + (random () & SMALL_CHAR); } acc[i] = '\0'; j = (pos > len ? pos : len) + align + 64; @@ -158,23 +185,23 @@ do_random_tests (void) p[i] = '\0'; else if (i == pos + align) { - p[i] = random () & 255; - if (strchr ((char *) acc, p[i])) + p[i] = random () & BIG_CHAR; + if (STRCHR ((CHAR *) acc, p[i])) p[i] = '\0'; } else if (i < align || i > pos + align) - p[i] = random () & 255; + p[i] = random () & BIG_CHAR; else p[i] = acc [random () % alen]; } FOR_EACH_IMPL (impl, 1) - if (CALL (impl, (char *) (p + align), - (char *) acc) != (pos < len ? pos : len)) + if (CALL (impl, (CHAR *) (p + align), + (CHAR *) acc) != (pos < len ? pos : len)) { error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %p, %zd, %zd, %zd) %zd != %zd", n, impl->name, align, acc, alen, pos, len, - CALL (impl, (char *) (p + align), (char *) acc), + CALL (impl, (CHAR *) (p + align), (CHAR *) acc), (pos < len ? pos : len)); ret = 1; } diff --git a/string/test-strstr.c b/string/test-strstr.c index cb2c2f6164..763edab20b 100644 --- a/string/test-strstr.c +++ b/string/test-strstr.c @@ -1,5 +1,5 @@ /* Test and measure strstr functions. - Copyright (C) 2010-2015 Free Software Foundation, Inc. + Copyright (C) 2010-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@redhat.com>, 2010. diff --git a/string/testcopy.c b/string/testcopy.c index 8302f8eeca..1c9d22b5fb 100644 --- a/string/testcopy.c +++ b/string/testcopy.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1990-2015 Free Software Foundation, Inc. +/* Copyright (C) 1990-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). diff --git a/string/tester.c b/string/tester.c index f957ed29d4..7c36591d8d 100644 --- a/string/tester.c +++ b/string/tester.c @@ -1,5 +1,5 @@ /* Tester for string functions. - Copyright (C) 1995-2015 Free Software Foundation, Inc. + Copyright (C) 1995-2016 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 diff --git a/string/tst-bswap.c b/string/tst-bswap.c index ea4b195469..fdab5fc816 100644 --- a/string/tst-bswap.c +++ b/string/tst-bswap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2015 Free Software Foundation, Inc. +/* Copyright (C) 2000-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>. diff --git a/string/tst-endian.c b/string/tst-endian.c index 8684bb232b..7d39131a68 100644 --- a/string/tst-endian.c +++ b/string/tst-endian.c @@ -3,6 +3,20 @@ #include <inttypes.h> #include <stdio.h> #include <stdint.h> +#include <libc-internal.h> + +#if __GNUC_PREREQ (6, 0) +/* GCC 6.0 warns on big endian systems about: + htobeXX (beXXtoh (i)) != i + warning: self-comparison always evaluates to false [-Wtautological-compare] + because htobeXX(x) and beXXtoh(x) is defined to (x) + in string/endian.h on big endian systems. + The same applies to htoleXX/leXXtoh on little endian systems. */ +# define DIAG_IGNORE_NEEDS_COMMENT_TAUTOLOGICAL_COMPARE() \ + DIAG_IGNORE_NEEDS_COMMENT (6, "-Wtautological-compare") +#else +# define DIAG_IGNORE_NEEDS_COMMENT_TAUTOLOGICAL_COMPARE() +#endif static int do_test (void) @@ -13,6 +27,8 @@ do_test (void) { if (i < UINT64_C (65536)) { + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT_TAUTOLOGICAL_COMPARE (); if (htobe16 (be16toh (i)) != i) { printf ("htobe16 (be16toh (%" PRIx64 ")) == %" PRIx16 "\n", @@ -25,6 +41,7 @@ do_test (void) i, (uint16_t) htole16 (le16toh (i))); result = 1; } + DIAG_POP_NEEDS_COMMENT; uint16_t n[2]; n[__BYTE_ORDER == __LITTLE_ENDIAN] = bswap_16 (i); @@ -45,6 +62,8 @@ do_test (void) if (i < UINT64_C (4294967296)) { + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT_TAUTOLOGICAL_COMPARE (); if (htobe32 (be32toh (i)) != i) { printf ("htobe32 (be32toh (%" PRIx64 ")) == %" PRIx32 "\n", @@ -57,6 +76,7 @@ do_test (void) i, (uint32_t) htole32 (le32toh (i))); result = 1; } + DIAG_POP_NEEDS_COMMENT; uint32_t n[2]; n[__BYTE_ORDER == __LITTLE_ENDIAN] = bswap_32 (i); @@ -75,6 +95,8 @@ do_test (void) } } + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT_TAUTOLOGICAL_COMPARE (); if (htobe64 (be64toh (i)) != i) { printf ("htobe64 (be64toh (%" PRIx64 ")) == %" PRIx64 "\n", @@ -87,6 +109,7 @@ do_test (void) i, htole64 (le64toh (i))); result = 1; } + DIAG_POP_NEEDS_COMMENT; uint64_t n[2]; n[__BYTE_ORDER == __LITTLE_ENDIAN] = bswap_64 (i); diff --git a/string/tst-inlcall.c b/string/tst-inlcall.c index 79bf223af4..9769263677 100644 --- a/string/tst-inlcall.c +++ b/string/tst-inlcall.c @@ -1,5 +1,5 @@ /* Tester for calling inline string functions. - Copyright (C) 1998-2015 Free Software Foundation, Inc. + Copyright (C) 1998-2016 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 diff --git a/string/tst-strcoll-overflow.c b/string/tst-strcoll-overflow.c index 34d8a9cde3..9b130ab90f 100644 --- a/string/tst-strcoll-overflow.c +++ b/string/tst-strcoll-overflow.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2015 Free Software Foundation, Inc. +/* Copyright (C) 2013-2016 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 diff --git a/string/tst-strlen.c b/string/tst-strlen.c index 8cbe441975..8376831de5 100644 --- a/string/tst-strlen.c +++ b/string/tst-strlen.c @@ -5,8 +5,8 @@ #include <stdio.h> #include <string.h> -int -main(int argc, char *argv[]) +static int +do_test (void) { static const size_t lens[] = { 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4 }; @@ -53,3 +53,6 @@ strnlen failed for base=%Zu, words=%Zu, and last=%Zu (is %zd, expected %zd)\n", } return 0; } + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/string/tst-strtok_r.c b/string/tst-strtok_r.c index 8d5e39162a..8bd20220c6 100644 --- a/string/tst-strtok_r.c +++ b/string/tst-strtok_r.c @@ -1,5 +1,5 @@ /* Test strtok_r regression for BZ #14229. - Copyright (C) 2012-2015 Free Software Foundation, Inc. + Copyright (C) 2012-2016 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 diff --git a/string/tst-strxfrm2.c b/string/tst-strxfrm2.c index d5a1115338..bea5aa2cea 100644 --- a/string/tst-strxfrm2.c +++ b/string/tst-strxfrm2.c @@ -5,6 +5,8 @@ static int do_test (void) { + static const char test_locale[] = "de_DE.UTF-8"; + int res = 0; char buf[20]; @@ -38,9 +40,9 @@ do_test (void) res = 1; } - if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL) + if (setlocale (LC_ALL, test_locale) == NULL) { - puts ("setlocale failed"); + printf ("cannot set locale \"%s\"\n", test_locale); res = 1; } else diff --git a/string/tst-svc.c b/string/tst-svc.c index 1ee5342aa9..1b0da3efe5 100644 --- a/string/tst-svc.c +++ b/string/tst-svc.c @@ -13,8 +13,8 @@ compare (const void *p1, const void *p2) return strverscmp (*((char **) p1), *((char **) p2)); } -int -main (int argc, char *argv[]) +static int +do_test (void) { char line[MAX_LINE_SIZE + 1]; char *str[MAX_STRINGS]; @@ -43,3 +43,6 @@ main (int argc, char *argv[]) return EXIT_SUCCESS; } + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/string/wordcopy.c b/string/wordcopy.c index c84eb68723..87eb1a6f3c 100644 --- a/string/wordcopy.c +++ b/string/wordcopy.c @@ -1,5 +1,5 @@ /* _memcopy.c -- subroutines for memory copy functions. - Copyright (C) 1991-2015 Free Software Foundation, Inc. + Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Torbjorn Granlund (tege@sics.se). diff --git a/string/xpg-strerror.c b/string/xpg-strerror.c index 7ca85405fe..d34d5031a8 100644 --- a/string/xpg-strerror.c +++ b/string/xpg-strerror.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Copyright (C) 1991-2016 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 |