diff options
author | Jakub Jelinek <jakub@redhat.com> | 2006-06-30 09:16:35 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2006-06-30 09:16:35 +0000 |
commit | ac7609f7998add41673e8428cf0bc824a40a1361 (patch) | |
tree | 016a7dba118f66dc209b26f930cf9dc4354d7d3b /string | |
parent | 2774ea772499f5779e846646824784a44377c69a (diff) |
Updated to fedora-glibc-20060630T0858cvs/fedora-glibc-2_4_90-12
Diffstat (limited to 'string')
-rw-r--r-- | string/Makefile | 3 | ||||
-rw-r--r-- | string/_strerror.c | 7 | ||||
-rw-r--r-- | string/bug-envz1.c | 76 | ||||
-rw-r--r-- | string/envz.c | 4 |
4 files changed, 84 insertions, 6 deletions
diff --git a/string/Makefile b/string/Makefile index 7c11c1ac22..a84ebebcaa 100644 --- a/string/Makefile +++ b/string/Makefile @@ -53,7 +53,8 @@ tests := tester inl-tester noinl-tester testcopy test-ffs \ tst-strlen stratcliff tst-svc tst-inlcall \ bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap \ tst-strtok tst-strxfrm bug-strcoll1 tst-strfry \ - bug-strtok1 $(addprefix test-,$(strop-tests)) + bug-strtok1 $(addprefix test-,$(strop-tests)) \ + bug-envz1 distribute := memcopy.h pagecopy.h tst-svc.expect test-string.h diff --git a/string/_strerror.c b/string/_strerror.c index f6f16ff2af..cb5d9e3609 100644 --- a/string/_strerror.c +++ b/string/_strerror.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991,93,95,96,97,98,2000,2002 Free Software Foundation, Inc. +/* Copyright (C) 1991,93,95,96,97,98,2000,2002,2006 + 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 @@ -35,8 +36,8 @@ char * __strerror_r (int errnum, char *buf, size_t buflen) { - if (errnum < 0 || errnum >= _sys_nerr_internal - || _sys_errlist_internal[errnum] == NULL) + if (__builtin_expect (errnum < 0 || errnum >= _sys_nerr_internal + || _sys_errlist_internal[errnum] == NULL, 0)) { /* Buffer we use to print the number in. For a maximum size for `int' of 8 bytes we never need more than 20 digits. */ diff --git a/string/bug-envz1.c b/string/bug-envz1.c new file mode 100644 index 0000000000..e8a60972b5 --- /dev/null +++ b/string/bug-envz1.c @@ -0,0 +1,76 @@ +/* Test for bug BZ #2703. */ +#include <stdio.h> +#include <envz.h> +#include <stdlib.h> +#include <string.h> + +static const struct +{ + const char *s; + int in_result; +} strs[] = +{ + { "a=1", 1 }, + { "b=2", 1 }, + { "(*)", 0 }, + { "(*)", 0 }, + { "e=5", 1 }, + { "f=", 1 }, + { "(*)", 0 }, + { "h=8", 1 }, + { "i=9", 1 }, + { "j", 0 } +}; + +#define nstrs (sizeof (strs) / sizeof (strs[0])) + + +static int +do_test (void) +{ + + size_t size = 0; + char *str = malloc (100); + if (str == NULL) + { + puts ("out of memory"); + return 1; + } + + char **argz = &str; + + for (int i = 0; i < nstrs; ++i) + argz_add_sep (argz, &size, strs[i].s, '\0'); + + printf ("calling envz_strip with size=%zu\n", size); + envz_strip (argz, &size); + + int result = 0; + printf ("new size=%zu\n", size); + for (int i = 0; i < nstrs; ++i) + if (strs[i].in_result) + { + char name[2]; + name[0] = strs[i].s[0]; + name[1] = '\0'; + + char *e = envz_entry (*argz, size, name); + if (e == NULL) + { + printf ("entry '%s' not found\n", name); + result = 1; + } + else if (strcmp (e, strs[i].s) != 0) + { + printf ("entry '%s' does not match: is '%s', expected '%s'\n", + name, e, strs[i].s); + result = 1; + } + } + + free (*argz); + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/string/envz.c b/string/envz.c index 5c5804c12b..a9d420212f 100644 --- a/string/envz.c +++ b/string/envz.c @@ -1,5 +1,5 @@ /* Routines for dealing with '\0' separated environment vectors - Copyright (C) 1995,96,97,98,2001,02 Free Software Foundation, Inc. + Copyright (C) 1995-1998,2001,2002,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.org> @@ -165,7 +165,7 @@ envz_strip (char **envz, size_t *envz_len) left -= entry_len; if (! strchr (entry, SEP)) /* Null entry. */ - memmove (entry + entry_len, entry, left); + memmove (entry, entry + entry_len, left); else entry += entry_len; } |