aboutsummaryrefslogtreecommitdiff
path: root/stdio-common
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 /stdio-common
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.xz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
2.5-18.1
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/Makefile11
-rw-r--r--stdio-common/Versions5
-rw-r--r--stdio-common/_itoa.c5
-rw-r--r--stdio-common/asprintf.c12
-rw-r--r--stdio-common/bits/printf-ldbl.h24
-rw-r--r--stdio-common/bug16.c43
-rw-r--r--stdio-common/bug17.c31
-rw-r--r--stdio-common/ctermid.c36
-rw-r--r--stdio-common/cuserid.c35
-rw-r--r--stdio-common/dprintf.c9
-rw-r--r--stdio-common/errlist.c37
-rw-r--r--stdio-common/flockfile.c30
-rw-r--r--stdio-common/fprintf.c10
-rw-r--r--stdio-common/fscanf.c6
-rw-r--r--stdio-common/ftrylockfile.c31
-rw-r--r--stdio-common/funlockfile.c30
-rw-r--r--stdio-common/fxprintf.c56
-rw-r--r--stdio-common/perror.c7
-rw-r--r--stdio-common/printf-parsemb.c5
-rw-r--r--stdio-common/printf-prs.c7
-rw-r--r--stdio-common/printf.c8
-rw-r--r--stdio-common/printf.h6
-rw-r--r--stdio-common/printf_fp.c139
-rw-r--r--stdio-common/printf_fphex.c493
-rw-r--r--stdio-common/printf_size.c6
-rw-r--r--stdio-common/psignal.c25
-rw-r--r--stdio-common/remove.c33
-rw-r--r--stdio-common/rename.c41
-rw-r--r--stdio-common/renameat.c50
-rw-r--r--stdio-common/scanf.c5
-rw-r--r--stdio-common/siglist.c38
-rw-r--r--stdio-common/snprintf.c8
-rw-r--r--stdio-common/sprintf.c12
-rw-r--r--stdio-common/sscanf.c12
-rw-r--r--stdio-common/tempname.c59
-rw-r--r--stdio-common/test-vfprintf.c8
-rw-r--r--stdio-common/tfformat.c18
-rw-r--r--stdio-common/tmpfile.c66
-rw-r--r--stdio-common/tmpfile64.c3
-rw-r--r--stdio-common/tst-fgets.c20
-rw-r--r--stdio-common/tst-fmemopen2.c68
-rw-r--r--stdio-common/tst-fwrite.c70
-rw-r--r--stdio-common/tst-printf.c11
-rw-r--r--stdio-common/tst-printf.sh14
-rw-r--r--stdio-common/tst-put-error.c33
-rw-r--r--stdio-common/tst-sprintf.c21
-rw-r--r--stdio-common/tst-sprintf2.c82
-rw-r--r--stdio-common/tstdiomisc.c12
-rw-r--r--stdio-common/tstscanf.c4
-rw-r--r--stdio-common/vfprintf.c113
-rw-r--r--stdio-common/vfscanf.c183
-rw-r--r--stdio-common/vprintf.c9
52 files changed, 1835 insertions, 265 deletions
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 3a66f1d021..7bd368bdca 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1991-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
@@ -21,7 +21,7 @@
#
subdir := stdio-common
-headers := printf.h stdio_ext.h
+headers := stdio_ext.h printf.h bits/printf-ldbl.h
routines := \
ctermid cuserid \
@@ -33,14 +33,14 @@ routines := \
perror psignal \
tmpfile tmpfile64 tmpnam tmpnam_r tempnam tempname \
getline getw putw \
- remove rename \
+ remove rename renameat \
flockfile ftrylockfile funlockfile
install-others = $(inst_includedir)/bits/stdio_lim.h
include ../Makeconfig
-aux := errlist siglist printf-parsemb printf-parsewc
+aux := errlist siglist printf-parsemb printf-parsewc fxprintf
distribute := _itoa.h _itowa.h _i18n_number.h \
printf-parse.h stdio_lim.h.in tst-unbputc.sh tst-printf.sh
@@ -53,7 +53,8 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
scanf11 scanf12 tst-tmpnam tst-cookie tst-obprintf tst-sscanf \
tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \
tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
- tst-popen tst-unlockedio
+ tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
+ tst-fwrite bug16 bug17 tst-sprintf2
test-srcs = tst-unbputc tst-printf
diff --git a/stdio-common/Versions b/stdio-common/Versions
index 1dbce1a124..2f64429346 100644
--- a/stdio-common/Versions
+++ b/stdio-common/Versions
@@ -37,7 +37,7 @@ libc {
tempnam; tmpfile; tmpnam; tmpnam_r;
# v*
- vfprintf; vfscanf; vprintf;
+ vfprintf; vfscanf; vprintf;
}
GLIBC_2.1 {
# p*
@@ -46,6 +46,9 @@ libc {
# t*
tmpfile; tmpfile64;
}
+ GLIBC_2.4 {
+ renameat;
+ }
GLIBC_PRIVATE {
# global variables
_itoa_lower_digits;
diff --git a/stdio-common/_itoa.c b/stdio-common/_itoa.c
index f61b23fceb..285fde2ab9 100644
--- a/stdio-common/_itoa.c
+++ b/stdio-common/_itoa.c
@@ -1,5 +1,5 @@
/* Internal function for converting integers to ASCII.
- Copyright (C) 1994, 1995, 1996, 1999, 2000, 2002, 2003, 2004
+ Copyright (C) 1994, 1995, 1996, 1999, 2000, 2002, 2003, 2004, 2007
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Torbjorn Granlund <tege@matematik.su.se>
@@ -269,6 +269,7 @@ _itoa (value, buflim, base, upper_case)
default:
{
+ char *bufend = buflim;
#if BITS_PER_MP_LIMB == 64
mp_limb_t base_multiplier = brec->base_multiplier;
if (brec->flag)
@@ -454,6 +455,8 @@ _itoa (value, buflim, base, upper_case)
}
while (n != 0);
#endif
+ if (buflim == bufend)
+ *--buflim = '0';
}
break;
}
diff --git a/stdio-common/asprintf.c b/stdio-common/asprintf.c
index 2c466d28d5..66e766ebfb 100644
--- a/stdio-common/asprintf.c
+++ b/stdio-common/asprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1997, 1998, 2002, 2004
+/* Copyright (C) 1991, 1995, 1997, 1998, 2002, 2004, 2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -20,7 +20,7 @@
#include <stdarg.h>
#include <stdio.h>
-#include <libio/libioP.h>
+#include <libioP.h>
#define vasprintf(s, f, a) _IO_vasprintf (s, f, a)
#undef __asprintf
@@ -28,7 +28,7 @@
allocated with malloc and stored in *STRING_PTR. */
/* VARARGS2 */
int
-__asprintf (char **string_ptr, const char *format, ...)
+___asprintf (char **string_ptr, const char *format, ...)
{
va_list arg;
int done;
@@ -39,5 +39,7 @@ __asprintf (char **string_ptr, const char *format, ...)
return done;
}
-INTDEF(__asprintf)
-weak_alias (__asprintf, asprintf)
+INTDEF2(___asprintf, __asprintf)
+
+ldbl_strong_alias (___asprintf, __asprintf)
+ldbl_weak_alias (___asprintf, asprintf)
diff --git a/stdio-common/bits/printf-ldbl.h b/stdio-common/bits/printf-ldbl.h
new file mode 100644
index 0000000000..cbdc3f1cbc
--- /dev/null
+++ b/stdio-common/bits/printf-ldbl.h
@@ -0,0 +1,24 @@
+/* -mlong-double-64 compatibility mode for <printf.h> functions.
+ Copyright (C) 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. */
+
+#ifndef _PRINTF_H
+# error "Never include <bits/printf-ldbl.h> directly; use <printf.h> instead."
+#endif
+
+__LDBL_REDIR_DECL (printf_size)
diff --git a/stdio-common/bug16.c b/stdio-common/bug16.c
new file mode 100644
index 0000000000..84269f3b6d
--- /dev/null
+++ b/stdio-common/bug16.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <string.h>
+
+struct
+{
+ long double val;
+ const char str[4][7];
+} tests[] =
+{
+ { 0x0.FFFFp+0L, { "0X1P+0", "0X2P-1", "0X4P-2", "0X8P-3" } },
+ { 0x0.FFFFp+1L, { "0X1P+1", "0X2P+0", "0X4P-1", "0X8P-2" } },
+ { 0x0.FFFFp+2L, { "0X1P+2", "0X2P+1", "0X4P+0", "0X8P-1" } },
+ { 0x0.FFFFp+3L, { "0X1P+3", "0X2P+2", "0X4P+1", "0X8P+0" } }
+};
+
+static int
+do_test (void)
+{
+ char buf[100];
+ int ret = 0;
+
+ for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
+ {
+ snprintf (buf, sizeof (buf), "%.0LA", tests[i].val);
+
+ size_t j;
+ for (j = 0; j < 4; ++j)
+ if (strcmp (buf, tests[i].str[j]) == 0)
+ break;
+
+ if (j == 4)
+ {
+ printf ("%zd: got \"%s\", expected \"%s\" or equivalent\n",
+ i, buf, tests[i].str[0]);
+ ret = 1;
+ }
+ }
+
+ return ret;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/stdio-common/bug17.c b/stdio-common/bug17.c
new file mode 100644
index 0000000000..2ef398674b
--- /dev/null
+++ b/stdio-common/bug17.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <string.h>
+
+static int
+do_test (void)
+{
+ static const char expect[] = "0, 0, 0";
+ char buf[100];
+ int status = 0;
+
+ static const char fmt1[] = "%0d, %0ld, %0lld";
+ snprintf (buf, sizeof (buf), fmt1, 0, 0L, 0LL);
+ if (strcmp (buf, expect) != 0)
+ {
+ printf ("\"%s\": got \"%s\", expected \"%s\"\n", fmt1, buf, expect);
+ status = 1;
+ }
+
+ static const char fmt2[] = "%0u, %0lu, %0llu";
+ snprintf (buf, sizeof (buf), fmt2, 0u, 0uL, 0uLL);
+ if (strcmp (buf, expect) != 0)
+ {
+ printf ("\"%s\": got \"%s\", expected \"%s\"\n", fmt2, buf, expect);
+ status = 1;
+ }
+
+ return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/stdio-common/ctermid.c b/stdio-common/ctermid.c
new file mode 100644
index 0000000000..e4d94eada2
--- /dev/null
+++ b/stdio-common/ctermid.c
@@ -0,0 +1,36 @@
+/* Copyright (C) 1991, 1995, 1996, 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
+ 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 <errno.h>
+#include <stdio.h>
+
+
+/* Return the name of the controlling terminal.
+ If S is not NULL, the name is copied into it (it should be at
+ least L_ctermid bytes long), otherwise a static buffer is used. */
+char *
+ctermid (s)
+ char *s;
+{
+ __set_errno (ENOSYS);
+ return NULL;
+}
+
+
+stub_warning (ctermid)
+#include <stub-tag.h>
diff --git a/stdio-common/cuserid.c b/stdio-common/cuserid.c
new file mode 100644
index 0000000000..826972f4de
--- /dev/null
+++ b/stdio-common/cuserid.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1991, 1995, 1996, 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
+ 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 <stdio.h>
+#include <errno.h>
+
+/* Return the username of the caller.
+ If S is not NULL, it points to a buffer of at least L_cuserid bytes
+ into which the name is copied; otherwise, a static buffer is used. */
+char *
+cuserid (s)
+ char *s;
+{
+ __set_errno (ENOSYS);
+ return NULL;
+}
+