aboutsummaryrefslogtreecommitdiff
path: root/stdio-common
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-10-17 00:41:39 +0000
committerRoland McGrath <roland@gnu.org>1995-10-17 00:41:39 +0000
commitdeab9deadc372fe1a367aef2e78c0d8f2885bf23 (patch)
tree367eaf76a86934f3883f950da5719ca581185ca5 /stdio-common
parent10fd03c6014206b3775be893727f282c4c709ebf (diff)
downloadglibc-deab9deadc372fe1a367aef2e78c0d8f2885bf23.tar.xz
glibc-deab9deadc372fe1a367aef2e78c0d8f2885bf23.zip
* Makefile (subdirs): Replace stdio with stdio-common and $(stdio).
* configure.in: Grok arg --enable-libio. ($stdio = libio): Define USE_IN_LIBIO. * config.h.in (USE_IN_LIBIO): Add #undef. * config.make.in (stdio): New variable, set by configure. * Makeconfig (stdio): New variable. * stdio.h [USE_IN_LIBIO]: Include libio/stdio.h instead of stdio/stdio.h. * stdio-common/Makefile: New file. * stdio/Makefile: Half the contents moved to stdio-common/Makefile. * stdio/_itoa.c: Moved to stdio-common. * stdio/_itoa.h: Moved to stdio-common. * stdio/asprintf.c: Moved to stdio-common. * stdio/bug1.c: Moved to stdio-common. * stdio/bug1.input: Moved to stdio-common. * stdio/bug2.c: Moved to stdio-common. * stdio/bug3.c: Moved to stdio-common. * stdio/bug4.c: Moved to stdio-common. * stdio/bug5.c: Moved to stdio-common. * stdio/bug6.c: Moved to stdio-common. * stdio/bug6.input: Moved to stdio-common. * stdio/bug7.c: Moved to stdio-common. * stdio/dprintf.c: Moved to stdio-common. * stdio/errnobug.c: Moved to stdio-common. * stdio/getline.c: Moved to stdio-common. * stdio/getw.c: Moved to stdio-common. * stdio/perror.c: Moved to stdio-common. * stdio/printf-parse.h: Moved to stdio-common. * stdio/printf-prs.c: Moved to stdio-common. * stdio/printf.c: Moved to stdio-common. * stdio/printf.h: Moved to stdio-common. * stdio/printf_fp.c: Moved to stdio-common. * stdio/psignal.c: Moved to stdio-common. * stdio/putw.c: Moved to stdio-common. * stdio/reg-printf.c: Moved to stdio-common. * stdio/scanf.c: Moved to stdio-common. * stdio/snprintf.c: Moved to stdio-common. * stdio/sprintf.c: Moved to stdio-common. * stdio/sscanf.c: Moved to stdio-common. * stdio/tempnam.c: Moved to stdio-common. * stdio/temptest.c: Moved to stdio-common. * stdio/test-fseek.c: Moved to stdio-common. * stdio/test-fwrite.c: Moved to stdio-common. * stdio/test-popen.c: Moved to stdio-common. * stdio/test_rdwr.c: Moved to stdio-common. * stdio/tmpfile.c: Moved to stdio-common. * stdio/tmpnam.c: Moved to stdio-common. * stdio/tst-fileno.c: Moved to stdio-common. * stdio/tst-printf.c: Moved to stdio-common. * stdio/tstgetln.c: Moved to stdio-common. * stdio/tstgetln.input: Moved to stdio-common. * stdio/tstscanf.c: Moved to stdio-common. * stdio/tstscanf.input: Moved to stdio-common. * stdio/vfprintf.c: Moved to stdio-common. * stdio/vfscanf.c: Moved to stdio-common. * stdio/vprintf.c: Moved to stdio-common. * stdio/xbug.c: Moved to stdio-common. * sysdeps/generic/Makefile (siglist.c rules): Do this in subdir stdio-common instead of stdio. * sysdeps/unix/Makefile (errlist.c rules): Likewise. * stdio-common/asprintf.c [USE_IN_LIBIO]: Call libio primitive function. * stdio-common/dprintf.c: Likewise. * stdio-common/printf.c: Likewise. * stdio-common/scanf.c: Likewise. * stdio-common/snprintf.c: Likewise. * stdio-common/sprintf.c: Likewise. * stdio-common/sscanf.c: Likewise. * stdio-common/vprintf.c: Likewise. * Makerules: Include $(+depfiles) directly instead of generating depend-$(subdir). (depend-$(subdir)): Target removed. (common-clean): Don't remove depend-$(subdir).
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/Makefile47
-rw-r--r--stdio-common/_itoa.c418
-rw-r--r--stdio-common/_itoa.h32
-rw-r--r--stdio-common/asprintf.c42
-rw-r--r--stdio-common/bug1.c28
-rw-r--r--stdio-common/bug1.input1
-rw-r--r--stdio-common/bug2.c12
-rw-r--r--stdio-common/bug3.c52
-rw-r--r--stdio-common/bug4.c50
-rw-r--r--stdio-common/bug5.c60
-rw-r--r--stdio-common/bug6.c27
-rw-r--r--stdio-common/bug6.input1
-rw-r--r--stdio-common/bug7.c53
-rw-r--r--stdio-common/dprintf.c41
-rw-r--r--stdio-common/errnobug.c60
-rw-r--r--stdio-common/fprintf.c38
-rw-r--r--stdio-common/fscanf.c38
-rw-r--r--stdio-common/getline.c33
-rw-r--r--stdio-common/getw.c33
-rw-r--r--stdio-common/perror.c42
-rw-r--r--stdio-common/printf-parse.h388
-rw-r--r--stdio-common/printf-prs.c72
-rw-r--r--stdio-common/printf.c40
-rw-r--r--stdio-common/printf.h124
-rw-r--r--stdio-common/printf_fp.c990
-rw-r--r--stdio-common/psignal.c49
-rw-r--r--stdio-common/putw.c31
-rw-r--r--stdio-common/reg-printf.c47
-rw-r--r--stdio-common/scanf.c40
-rw-r--r--stdio-common/snprintf.c43
-rw-r--r--stdio-common/sprintf.c41
-rw-r--r--stdio-common/sscanf.c41
-rw-r--r--stdio-common/tempnam.c50
-rw-r--r--stdio-common/temptest.c31
-rw-r--r--stdio-common/test-fseek.c67
-rw-r--r--stdio-common/test-fwrite.c68
-rw-r--r--stdio-common/test-popen.c67
-rw-r--r--stdio-common/test_rdwr.c130
-rw-r--r--stdio-common/tmpfile.c43
-rw-r--r--stdio-common/tmpnam.c42
-rw-r--r--stdio-common/tst-fileno.c37
-rw-r--r--stdio-common/tst-printf.c298
-rw-r--r--stdio-common/tstgetln.c46
-rw-r--r--stdio-common/tstgetln.input3
-rw-r--r--stdio-common/tstscanf.c100
-rw-r--r--stdio-common/tstscanf.input7
-rw-r--r--stdio-common/vasprintf.c86
-rw-r--r--stdio-common/vdprintf.c51
-rw-r--r--stdio-common/vfprintf.c858
-rw-r--r--stdio-common/vfscanf.c624
-rw-r--r--stdio-common/vprintf.c37
-rw-r--r--stdio-common/vscanf.c32
-rw-r--r--stdio-common/vsnprintf.c56
-rw-r--r--stdio-common/vsprintf.c50
-rw-r--r--stdio-common/vsscanf.c58
-rw-r--r--stdio-common/xbug.c63
56 files changed, 5918 insertions, 0 deletions
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
new file mode 100644
index 0000000000..6ca6c7d1d3
--- /dev/null
+++ b/stdio-common/Makefile
@@ -0,0 +1,47 @@
+# Copyright (C) 1991, 1992, 1993, 1994, 1995 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 Library General Public License as
+# published by the Free Software Foundation; either version 2 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
+# Library General Public License for more details.
+
+# You should have received a copy of the GNU Library General Public
+# License along with the GNU C Library; see the file COPYING.LIB. If
+# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+# Cambridge, MA 02139, USA.
+
+#
+# Specific makefile for stdio-common.
+#
+subdir := stdio-common
+
+headers := stdio_lim.h printf.h
+
+routines := \
+ ctermid cuserid \
+ vfprintf vprintf printf_fp reg-printf printf-prs _itoa \
+ vsnprintf vsprintf vasprintf \
+ fprintf printf snprintf sprintf asprintf \
+ dprintf vdprintf \
+ vfscanf vscanf vsscanf \
+ fscanf scanf sscanf \
+ perror psignal \
+ tmpfile tmpnam tempnam tempname \
+ getline getw putw \
+ remove rename
+aux := errlist siglist
+distribute := _itoa.h printf-parse.h
+
+tests := tst-printf tstscanf test_rdwr test-popen tstgetln test-fseek \
+ temptest tst-fileno test-fwrite \
+ xbug errnobug \
+ bug1 bug2 bug3 bug4 bug5 bug6 bug7
+
+
+include ../Rules
diff --git a/stdio-common/_itoa.c b/stdio-common/_itoa.c
new file mode 100644
index 0000000000..caa8179624
--- /dev/null
+++ b/stdio-common/_itoa.c
@@ -0,0 +1,418 @@
+/* Internal function for converting integers to ASCII.
+Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+Contributed by Torbjorn Granlund <tege@matematik.su.se>
+and Ulrich Drepper <drepper@gnu.ai.mit.edu>.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+#include <gmp-mparam.h>
+#include "../stdlib/gmp.h"
+#include "../stdlib/gmp-impl.h"
+#include "../stdlib/longlong.h"
+
+#include "_itoa.h"
+
+
+/* Canonize environment. For some architectures not all values might
+ be defined in the GMP header files. */
+#ifndef UMUL_TIME
+# define UMUL_TIME 1
+#endif
+#ifndef UDIV_TIME
+# define UDIV_TIME 1
+#endif
+
+/* Control memory layout. */
+#ifdef PACK
+# undef PACK
+# define PACK __attribute__ ((packed))
+#else
+# define PACK
+#endif
+
+
+/* Declare local types. */
+struct base_table_t
+{
+#if (UDIV_TIME > 2 * UMUL_TIME)
+ mp_limb base_multiplier;
+#endif
+ char flag;
+ char post_shift;
+#if BITS_PER_MP_LIMB == 32
+ struct
+ {
+ char normalization_steps;
+ char ndigits;
+ mp_limb base PACK;
+#if UDIV_TIME > 2 * UMUL_TIME
+ mp_limb base_ninv PACK;
+#endif
+ } big;
+#endif
+};
+
+/* To reduce the memory needed we include some fields of the tables
+ only confitionally. */
+#if BITS_PER_MP_LIMB == 32
+# if UDIV_TIME > 2 * UMUL_TIME
+# define SEL1(X) X,
+# define SEL2(X) ,X
+# else
+# define SEL1(X)
+# define SEL2(X)
+# endif
+#endif
+
+
+/* Local variables. */
+static const struct base_table_t base_table[] =
+{
+#if BITS_PER_MP_LIMB == 64
+ /* 2 */ {0ul, 1, 1},
+ /* 3 */ {0xaaaaaaaaaaaaaaabul, 0, 1},
+ /* 4 */ {0ul, 1, 2},
+ /* 5 */ {0xcccccccccccccccdul, 0, 2},
+ /* 6 */ {0xaaaaaaaaaaaaaaabul, 0, 2},
+ /* 7 */ {0x2492492492492493ul, 1, 3},
+ /* 8 */ {0ul, 1, 3},
+ /* 9 */ {0xe38e38e38e38e38ful, 0, 3},
+ /* 10 */ {0xcccccccccccccccdul, 0, 3},
+ /* 11 */ {0x2e8ba2e8ba2e8ba3ul, 0, 1},
+ /* 12 */ {0xaaaaaaaaaaaaaaabul, 0, 3},
+ /* 13 */ {0x4ec4ec4ec4ec4ec5ul, 0, 2},
+ /* 14 */ {0x2492492492492493ul, 1, 4},
+ /* 15 */ {0x8888888888888889ul, 0, 3},
+ /* 16 */ {0ul, 1, 4},
+ /* 17 */ {0xf0f0f0f0f0f0f0f1ul, 0, 4},
+ /* 18 */ {0xe38e38e38e38e38ful, 0, 4},
+ /* 19 */ {0xd79435e50d79435ful, 0, 4},
+ /* 20 */ {0xcccccccccccccccdul, 0, 4},
+ /* 21 */ {0x8618618618618619ul, 1, 5},
+ /* 22 */ {0x2e8ba2e8ba2e8ba3ul, 0, 2},
+ /* 23 */ {0x642c8590b21642c9ul, 1, 5},
+ /* 24 */ {0xaaaaaaaaaaaaaaabul, 0, 4},
+ /* 25 */ {0x47ae147ae147ae15ul, 1, 5},
+ /* 26 */ {0x4ec4ec4ec4ec4ec5ul, 0, 3},
+ /* 27 */ {0x97b425ed097b425ful, 0, 4},
+ /* 28 */ {0x2492492492492493ul, 1, 5},
+ /* 29 */ {0x1a7b9611a7b9611bul, 1, 5},
+ /* 30 */ {0x8888888888888889ul, 0, 4},
+ /* 31 */ {0x0842108421084211ul, 1, 5},
+ /* 32 */ {0ul, 1, 5},
+ /* 33 */ {0x0f83e0f83e0f83e1ul, 0, 1},
+ /* 34 */ {0xf0f0f0f0f0f0f0f1ul, 0, 5},
+ /* 35 */ {0xea0ea0ea0ea0ea0ful, 0, 5},
+ /* 36 */ {0xe38e38e38e38e38ful, 0, 5}
+#endif
+#if BITS_PER_MP_LIMB == 32
+ /* 2 */ {SEL1(0ul) 1, 1, {0, 31, 0x80000000ul SEL2(0xfffffffful)}},
+ /* 3 */ {SEL1(0xaaaaaaabul) 0, 1, {0, 20, 0xcfd41b91ul SEL2(0x3b563c24ul)}},
+ /* 4 */ {SEL1(0ul) 1, 2, {1, 15, 0x40000000ul SEL2(0xfffffffful)}},
+ /* 5 */ {SEL1(0xcccccccdul) 0, 2, {1, 13, 0x48c27395ul SEL2(0xc25c2684ul)}},
+ /* 6 */ {SEL1(0xaaaaaaabul) 0, 2, {0, 12, 0x81bf1000ul SEL2(0xf91bd1b6ul)}},
+ /* 7 */ {SEL1(0x24924925ul) 1, 3, {1, 11, 0x75db9c97ul SEL2(0x1607a2cbul)}},
+ /* 8 */ {SEL1(0ul) 1, 3, {1, 10, 0x40000000ul SEL2(0xfffffffful)}},
+ /* 9 */ {SEL1(0x38e38e39ul) 0, 1, {0, 10, 0xcfd41b91ul SEL2(0x3b563c24ul)}},
+ /* 10 */ {SEL1(0xcccccccdul) 0, 3, {2, 9, 0x3b9aca00ul SEL2(0x12e0be82ul)}},
+ /* 11 */ {SEL1(0xba2e8ba3ul) 0, 3, {0, 9, 0x8c8b6d2bul SEL2(0xd24cde04ul)}},
+ /* 12 */ {SEL1(0xaaaaaaabul) 0, 3, {3, 8, 0x19a10000ul SEL2(0x3fa39ab5ul)}},
+ /* 13 */ {SEL1(0x4ec4ec4ful) 0, 2, {2, 8, 0x309f1021ul SEL2(0x50f8ac5ful)}},
+ /* 14 */ {SEL1(0x24924925ul) 1, 4, {1, 8, 0x57f6c100ul SEL2(0x74843b1eul)}},
+ /* 15 */ {SEL1(0x88888889ul) 0, 3, {0, 8, 0x98c29b81ul SEL2(0xad0326c2ul)}},
+ /* 16 */ {SEL1(0ul) 1, 4, {3, 7, 0x10000000ul SEL2(0xfffffffful)}},
+ /* 17 */ {SEL1(0xf0f0f0f1ul) 0, 4, {3, 7, 0x18754571ul SEL2(0x4ef0b6bdul)}},
+ /* 18 */ {SEL1(0x38e38e39ul) 0, 2, {2, 7, 0x247dbc80ul SEL2(0xc0fc48a1ul)}},
+ /* 19 */ {SEL1(0xaf286bcbul) 1, 5, {2, 7, 0x3547667bul SEL2(0x33838942ul)}},
+ /* 20 */ {SEL1(0xcccccccdul) 0, 4, {1, 7, 0x4c4b4000ul SEL2(0xad7f29abul)}},
+ /* 21 */ {SEL1(0x86186187ul) 1, 5, {1, 7, 0x6b5a6e1dul SEL2(0x313c3d15ul)}},
+ /* 22 */ {SEL1(0xba2e8ba3ul) 0, 4, {0, 7, 0x94ace180ul SEL2(0xb8cca9e0ul)}},
+ /* 23 */ {SEL1(0xb21642c9ul) 0, 4, {0, 7, 0xcaf18367ul SEL2(0x42ed6de9ul)}},
+ /* 24 */ {SEL1(0xaaaaaaabul) 0, 4, {4, 6, 0x0b640000ul SEL2(0x67980e0bul)}},
+ /* 25 */ {SEL1(0x51eb851ful) 0, 3, {4, 6, 0x0e8d4a51ul SEL2(0x19799812ul)}},
+ /* 26 */ {SEL1(0x4ec4ec4ful) 0, 3, {3, 6, 0x1269ae40ul SEL2(0xbce85396ul)}},
+ /* 27 */ {SEL1(0x2f684bdbul) 1, 5, {3, 6, 0x17179149ul SEL2(0x62c103a9ul)}},
+ /* 28 */ {SEL1(0x24924925ul) 1, 5, {3, 6, 0x1cb91000ul SEL2(0x1d353d43ul)}},
+ /* 29 */ {SEL1(0x8d3dcb09ul) 0, 4, {2, 6, 0x23744899ul SEL2(0xce1deceaul)}},
+ /* 30 */ {SEL1(0x88888889ul) 0, 4, {2, 6, 0x2b73a840ul SEL2(0x790fc511ul)}},
+ /* 31 */ {SEL1(0x08421085ul) 1, 5, {2, 6, 0x34e63b41ul SEL2(0x35b865a0ul)}},
+ /* 32 */ {SEL1(0ul) 1, 5, {1, 6, 0x40000000ul SEL2(0xfffffffful)}},
+ /* 33 */ {SEL1(0x3e0f83e1ul) 0, 3, {1, 6, 0x4cfa3cc1ul SEL2(0xa9aed1b3ul)}},
+ /* 34 */ {SEL1(0xf0f0f0f1ul) 0, 5, {1, 6, 0x5c13d840ul SEL2(0x63dfc229ul)}},
+ /* 35 */ {SEL1(0xd41d41d5ul) 1, 6, {1, 6, 0x6d91b519ul SEL2(0x2b0fee30ul)}},
+ /* 36 */ {SEL1(0x38e38e39ul) 0, 3, {0, 6, 0x81bf1000ul SEL2(0xf91bd1b6ul)}}
+#endif
+};
+
+/* Lower-case digits. */
+static const char _itoa_lower_digits[]
+ = "0123456789abcdefghijklmnopqrstuvwxyz";
+/* Upper-case digits. *