diff options
| author | Jakub Jelinek <jakub@redhat.com> | 2007-07-12 18:26:36 +0000 |
|---|---|---|
| committer | Jakub Jelinek <jakub@redhat.com> | 2007-07-12 18:26:36 +0000 |
| commit | 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch) | |
| tree | 2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /string | |
| parent | 7d58530341304d403a6626d7f7a1913165fe2f32 (diff) | |
| download | glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.xz glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip | |
2.5-18.1
Diffstat (limited to 'string')
71 files changed, 4818 insertions, 143 deletions
diff --git a/string/Makefile b/string/Makefile index 66469f586e..f087022b3c 100644 --- a/string/Makefile +++ b/string/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-1999,2000,2001,2002 Free Software Foundation, Inc. +# Copyright (C) 1991-2002, 2005, 2006, 2007 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 @@ -52,8 +52,9 @@ strop-tests := memchr memcmp memcpy memmove mempcpy memset memccpy \ 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 \ - $(addprefix test-,$(strop-tests)) + tst-strtok tst-strxfrm bug-strcoll1 tst-strfry \ + bug-strtok1 $(addprefix test-,$(strop-tests)) \ + bug-envz1 tst-strxfrm2 distribute := memcopy.h pagecopy.h tst-svc.expect test-string.h @@ -63,11 +64,14 @@ tester-ENV = LANGUAGE=C inl-tester-ENV = LANGUAGE=C noinl-tester-ENV = LANGUAGE=C tst-strxfrm-ENV = LOCPATH=$(common-objpfx)localedata +tst-strxfrm2-ENV = LOCPATH=$(common-objpfx)localedata bug-strcoll1-ENV = LOCPATH=$(common-objpfx)localedata +CFLAGS-inl-tester.c = -fno-builtin CFLAGS-noinl-tester.c = -fno-builtin CFLAGS-tst-strlen.c = -fno-builtin CFLAGS-stratcliff.c = -fno-builtin CFLAGS-test-ffs.c = -fno-builtin +CFLAGS-tst-inlcall.c = -fno-builtin ifeq ($(cross-compiling),no) tests: $(objpfx)tst-svc.out diff --git a/string/_strerror.c b/string/_strerror.c new file mode 100644 index 0000000000..cb5d9e3609 --- /dev/null +++ b/string/_strerror.c @@ -0,0 +1,68 @@ +/* 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 + 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <libintl.h> +#include <stdio.h> +#include <string.h> +#include <sys/param.h> +#include <stdio-common/_itoa.h> + +/* It is critical here that we always use the `dcgettext' function for + the message translation. Since <libintl.h> only defines the macro + `dgettext' to use `dcgettext' for optimizing programs this is not + always guaranteed. */ +#ifndef dgettext +# include <locale.h> /* We need LC_MESSAGES. */ +# define dgettext(domainname, msgid) dcgettext (domainname, msgid, LC_MESSAGES) +#endif + +/* Return a string describing the errno code in ERRNUM. */ +char * +__strerror_r (int errnum, char *buf, size_t buflen) +{ + 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. */ + char numbuf[21]; + const char *unk = _("Unknown error "); + const size_t unklen = strlen (unk); + char *p, *q; + + numbuf[20] = '\0'; + p = _itoa_word (errnum, &numbuf[20], 10, 0); + + /* Now construct the result while taking care for the destination + buffer size. */ + q = __mempcpy (buf, unk, MIN (unklen, buflen)); + if (unklen < buflen) + memcpy (q, p, MIN ((size_t) (&numbuf[21] - p), buflen - unklen)); + + /* Terminate the string in any case. */ + if (buflen > 0) + buf[buflen - 1] = '\0'; + + return buf; + } + + return (char *) _(_sys_errlist_internal[errnum]); +} +weak_alias (__strerror_r, strerror_r) +libc_hidden_def (__strerror_r) diff --git a/string/argz-replace.c b/string/argz-replace.c index 3c4062488e..1b0eb15fd7 100644 --- a/string/argz-replace.c +++ b/string/argz-replace.c @@ -1,5 +1,5 @@ /* String replacement in an argz vector - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -121,8 +121,7 @@ __argz_replace (char **argz, size_t *argz_len, const char *str, const char *with if (! delayed_copy) /* We never found any instances of str. */ { - if (src) - free (src); + free (src); *argz = dst; *argz_len = dst_len; } diff --git a/string/bcopy.c b/string/bcopy.c new file mode 100644 index 0000000000..3f16b884ac --- /dev/null +++ b/string/bcopy.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1991, 1992, 1997 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 |
