aboutsummaryrefslogtreecommitdiff
path: root/string
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /string
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.xz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
2.5-18.1
Diffstat (limited to 'string')
-rw-r--r--string/Makefile10
-rw-r--r--string/_strerror.c68
-rw-r--r--string/argz-replace.c5
-rw-r--r--string/bcopy.c29
-rw-r--r--string/bits/string3.h87
-rw-r--r--string/bug-envz1.c76
-rw-r--r--string/bug-strtok1.c45
-rw-r--r--string/bzero.c83
-rw-r--r--string/envz.c4
-rw-r--r--string/ffs.c55
-rw-r--r--string/ffsll.c42
-rw-r--r--string/memccpy.c46
-rw-r--r--string/memchr.c215
-rw-r--r--string/memcmp.c381
-rw-r--r--string/memcpy.c65
-rw-r--r--string/memmem.c58
-rw-r--r--string/memmove.c112
-rw-r--r--string/mempcpy.c69
-rw-r--r--string/memrchr.c210
-rw-r--r--string/memset.c91
-rw-r--r--string/rawmemchr.c189
-rw-r--r--string/stpcpy.c55
-rw-r--r--string/stpncpy.c100
-rw-r--r--string/strcasecmp.c74
-rw-r--r--string/strcasecmp_l.c23
-rw-r--r--string/strcasestr.c142
-rw-r--r--string/strcat.c52
-rw-r--r--string/strchr.c191
-rw-r--r--string/strchrnul.c170
-rw-r--r--string/strcmp.c47
-rw-r--r--string/strcoll.c6
-rw-r--r--string/strcpy.c50
-rw-r--r--string/strcspn.c51
-rw-r--r--string/string-inlines.c35
-rw-r--r--string/strlen.c153
-rw-r--r--string/strncase.c76
-rw-r--r--string/strncase_l.c25
-rw-r--r--string/strncat.c85
-rw-r--r--string/strncmp.c73
-rw-r--r--string/strncpy.c87
-rw-r--r--string/strnlen.c161
-rw-r--r--string/strpbrk.c46
-rw-r--r--string/strrchr.c50
-rw-r--r--string/strsep.c70
-rw-r--r--string/strsignal.c6
-rw-r--r--string/strspn.c47
-rw-r--r--string/strstr.c123
-rw-r--r--string/strtok.c66
-rw-r--r--string/strtok_r.c79
-rw-r--r--string/strxfrm_l.c17
-rw-r--r--string/test-memccpy.c6
-rw-r--r--string/test-memchr.c13
-rw-r--r--string/test-memcmp.c8
-rw-r--r--string/test-memcpy.c10
-rw-r--r--string/test-memmove.c10
-rw-r--r--string/test-memset.c16
-rw-r--r--string/test-strcat.c9
-rw-r--r--string/test-strchr.c14
-rw-r--r--string/test-strcmp.c8
-rw-r--r--string/test-strcpy.c9
-rw-r--r--string/test-strlen.c9
-rw-r--r--string/test-strncmp.c85
-rw-r--r--string/test-strncpy.c10
-rw-r--r--string/test-strpbrk.c19
-rw-r--r--string/test-strrchr.c16
-rw-r--r--string/test-strspn.c14
-rw-r--r--string/tester.c37
-rw-r--r--string/tst-strfry.c15
-rw-r--r--string/tst-strxfrm2.c83
-rw-r--r--string/wordcopy.c413
-rw-r--r--string/xpg-strerror.c57
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