From 28f540f45bbacd939bfd07f213bcad2bf730b1bf Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 18 Feb 1995 01:27:10 +0000 Subject: initial import --- stdio/.cvsignore | 4 + stdio/Makefile | 114 +++++ stdio/_itoa.c | 45 ++ stdio/_itoa.h | 54 +++ stdio/asprintf.c | 39 ++ stdio/bug1.c | 28 ++ stdio/bug1.input | 1 + stdio/bug2.c | 12 + stdio/bug3.c | 52 ++ stdio/bug4.c | 50 ++ stdio/bug5.c | 60 +++ stdio/bug6.c | 27 ++ stdio/bug6.input | 1 + stdio/bug7.c | 53 +++ stdio/clearerr.c | 31 ++ stdio/dprintf.c | 37 ++ stdio/errnobug.c | 60 +++ stdio/fclose.c | 69 +++ stdio/feof.c | 37 ++ stdio/ferror.c | 37 ++ stdio/fflush.c | 45 ++ stdio/fgetc.c | 35 ++ stdio/fgetpos.c | 40 ++ stdio/fgets.c | 121 +++++ stdio/fileno.c | 48 ++ stdio/fmemopen.c | 108 +++++ stdio/fopen.c | 110 +++++ stdio/fopncook.c | 48 ++ stdio/fpioconst.c | 401 ++++++++++++++++ stdio/fpioconst.h | 52 ++ stdio/fprintf.c | 38 ++ stdio/fputc.c | 35 ++ stdio/fputs.c | 35 ++ stdio/fread.c | 128 +++++ stdio/freopen.c | 74 +++ stdio/fscanf.c | 38 ++ stdio/fseek.c | 177 +++++++ stdio/fsetpos.c | 37 ++ stdio/ftell.c | 54 +++ stdio/fwrite.c | 208 ++++++++ stdio/gen-mpn-copy | 31 ++ stdio/getc.c | 5 + stdio/getchar.c | 30 ++ stdio/getdelim.c | 173 +++++++ stdio/getline.c | 33 ++ stdio/gets.c | 59 +++ stdio/getw.c | 33 ++ stdio/glue.c | 114 +++++ stdio/gmp-impl.h | 283 +++++++++++ stdio/gmp.h | 525 ++++++++++++++++++++ stdio/internals.c | 667 ++++++++++++++++++++++++++ stdio/longlong.h | 1295 ++++++++++++++++++++++++++++++++++++++++++++++++++ stdio/memstream.c | 177 +++++++ stdio/mp_clz_tab.c | 39 ++ stdio/newstream.c | 54 +++ stdio/obstream.c | 187 ++++++++ stdio/perror.c | 42 ++ stdio/printf-prs.c | 211 ++++++++ stdio/printf.c | 37 ++ stdio/printf.h | 114 +++++ stdio/printf_fp.c | 991 ++++++++++++++++++++++++++++++++++++++ stdio/psignal.c | 49 ++ stdio/putc.c | 5 + stdio/putchar.c | 30 ++ stdio/puts.c | 32 ++ stdio/putw.c | 31 ++ stdio/reg-printf.c | 47 ++ stdio/rewind.c | 33 ++ stdio/scanf.c | 37 ++ stdio/setbuf.c | 30 ++ stdio/setbuffer.c | 30 ++ stdio/setlinebuf.c | 29 ++ stdio/setvbuf.c | 85 ++++ stdio/snprintf.c | 39 ++ stdio/sprintf.c | 37 ++ stdio/sscanf.c | 37 ++ stdio/stdio.h | 681 ++++++++++++++++++++++++++ stdio/tempnam.c | 50 ++ stdio/temptest.c | 31 ++ stdio/test-fseek.c | 67 +++ stdio/test-fwrite.c | 68 +++ stdio/test-popen.c | 67 +++ stdio/test_rdwr.c | 129 +++++ stdio/tmpfile.c | 43 ++ stdio/tmpnam.c | 42 ++ stdio/tst-fileno.c | 37 ++ stdio/tst-printf.c | 298 ++++++++++++ stdio/tstgetln.c | 46 ++ stdio/tstgetln.input | 3 + stdio/tstscanf.c | 100 ++++ stdio/tstscanf.input | 7 + stdio/ungetc.c | 58 +++ stdio/vasprintf.c | 86 ++++ stdio/vdprintf.c | 51 ++ stdio/vfprintf.c | 907 +++++++++++++++++++++++++++++++++++ stdio/vfscanf.c | 570 ++++++++++++++++++++++ stdio/vprintf.c | 33 ++ stdio/vscanf.c | 32 ++ stdio/vsnprintf.c | 56 +++ stdio/vsprintf.c | 50 ++ stdio/vsscanf.c | 58 +++ stdio/xbug.c | 63 +++ 102 files changed, 11927 insertions(+) create mode 100644 stdio/.cvsignore create mode 100644 stdio/Makefile create mode 100644 stdio/_itoa.c create mode 100644 stdio/_itoa.h create mode 100644 stdio/asprintf.c create mode 100644 stdio/bug1.c create mode 100644 stdio/bug1.input create mode 100644 stdio/bug2.c create mode 100644 stdio/bug3.c create mode 100644 stdio/bug4.c create mode 100644 stdio/bug5.c create mode 100644 stdio/bug6.c create mode 100644 stdio/bug6.input create mode 100644 stdio/bug7.c create mode 100644 stdio/clearerr.c create mode 100644 stdio/dprintf.c create mode 100644 stdio/errnobug.c create mode 100644 stdio/fclose.c create mode 100644 stdio/feof.c create mode 100644 stdio/ferror.c create mode 100644 stdio/fflush.c create mode 100644 stdio/fgetc.c create mode 100644 stdio/fgetpos.c create mode 100644 stdio/fgets.c create mode 100644 stdio/fileno.c create mode 100644 stdio/fmemopen.c create mode 100644 stdio/fopen.c create mode 100644 stdio/fopncook.c create mode 100644 stdio/fpioconst.c create mode 100644 stdio/fpioconst.h create mode 100644 stdio/fprintf.c create mode 100644 stdio/fputc.c create mode 100644 stdio/fputs.c create mode 100644 stdio/fread.c create mode 100644 stdio/freopen.c create mode 100644 stdio/fscanf.c create mode 100644 stdio/fseek.c create mode 100644 stdio/fsetpos.c create mode 100644 stdio/ftell.c create mode 100644 stdio/fwrite.c create mode 100644 stdio/gen-mpn-copy create mode 100644 stdio/getc.c create mode 100644 stdio/getchar.c create mode 100644 stdio/getdelim.c create mode 100644 stdio/getline.c create mode 100644 stdio/gets.c create mode 100644 stdio/getw.c create mode 100644 stdio/glue.c create mode 100644 stdio/gmp-impl.h create mode 100644 stdio/gmp.h create mode 100644 stdio/internals.c create mode 100644 stdio/longlong.h create mode 100644 stdio/memstream.c create mode 100644 stdio/mp_clz_tab.c create mode 100644 stdio/newstream.c create mode 100644 stdio/obstream.c create mode 100644 stdio/perror.c create mode 100644 stdio/printf-prs.c create mode 100644 stdio/printf.c create mode 100644 stdio/printf.h create mode 100644 stdio/printf_fp.c create mode 100644 stdio/psignal.c create mode 100644 stdio/putc.c create mode 100644 stdio/putchar.c create mode 100644 stdio/puts.c create mode 100644 stdio/putw.c create mode 100644 stdio/reg-printf.c create mode 100644 stdio/rewind.c create mode 100644 stdio/scanf.c create mode 100644 stdio/setbuf.c create mode 100644 stdio/setbuffer.c create mode 100644 stdio/setlinebuf.c create mode 100644 stdio/setvbuf.c create mode 100644 stdio/snprintf.c create mode 100644 stdio/sprintf.c create mode 100644 stdio/sscanf.c create mode 100644 stdio/stdio.h create mode 100644 stdio/tempnam.c create mode 100644 stdio/temptest.c create mode 100644 stdio/test-fseek.c create mode 100644 stdio/test-fwrite.c create mode 100644 stdio/test-popen.c create mode 100644 stdio/test_rdwr.c create mode 100644 stdio/tmpfile.c create mode 100644 stdio/tmpnam.c create mode 100644 stdio/tst-fileno.c create mode 100644 stdio/tst-printf.c create mode 100644 stdio/tstgetln.c create mode 100644 stdio/tstgetln.input create mode 100644 stdio/tstscanf.c create mode 100644 stdio/tstscanf.input create mode 100644 stdio/ungetc.c create mode 100644 stdio/vasprintf.c create mode 100644 stdio/vdprintf.c create mode 100644 stdio/vfprintf.c create mode 100644 stdio/vfscanf.c create mode 100644 stdio/vprintf.c create mode 100644 stdio/vscanf.c create mode 100644 stdio/vsnprintf.c create mode 100644 stdio/vsprintf.c create mode 100644 stdio/vsscanf.c create mode 100644 stdio/xbug.c (limited to 'stdio') diff --git a/stdio/.cvsignore b/stdio/.cvsignore new file mode 100644 index 0000000000..1f69fd919a --- /dev/null +++ b/stdio/.cvsignore @@ -0,0 +1,4 @@ +*.gz *.Z *.tar *.tgz +=* +TODO COPYING* AUTHORS copyr-* copying.* +glibc-* diff --git a/stdio/Makefile b/stdio/Makefile new file mode 100644 index 0000000000..579426186f --- /dev/null +++ b/stdio/Makefile @@ -0,0 +1,114 @@ +# 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. +# +subdir := stdio + +headers := stdio.h stdio_lim.h printf.h + +routines := \ + ctermid cuserid \ + feof ferror clearerr fileno \ + newstream fopen freopen fdopen fopncook fmemopen \ + setbuf setvbuf setbuffer setlinebuf \ + fseek ftell rewind fgetpos fsetpos \ + 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 \ + fread fwrite \ + ungetc \ + fgetc getc getchar getw \ + fputc putc putchar putw \ + fgets gets fputs puts \ + getdelim getline \ + perror psignal \ + tmpfile tmpnam tempnam tempname \ + fclose fflush \ + remove rename \ + memstream obstream \ + internals sysd-stdio pipestream stdio_init libc_fatal + +# Several mpn functions from GNU MP are used by the printf_fp function. +mpn-routines := add_1 add_n addmul_1 cmp divmod divmod_1 udiv_qrnnd \ + lshift rshift mod_1 mul mul_1 mul_n sub_n submul_1 +mpn-headers = longlong.h gmp.h gmp-impl.h gmp-mparam.h asm-syntax.h + +routines := $(strip $(routines) $(mpn-routines)) \ + dbl2mpn ldbl2mpn \ + mpn2flt mpn2dbl mpn2ldbl +aux := errlist siglist defs glue mp_clz_tab fpioconst +distribute = $(mpn-headers) gen-mpn-copy _itoa.h fpioconst.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 + + +ifdef gmp-srcdir + +gmp-srcdir := $(firstword $(filter-out ..//%,$(..)$(gmp-srcdir) $(gmp-srcdir))) + +# Copy the mpn source files we use from the GNU MP source directory. +# `gmp-srcdir' is set by doing `configure --with-gmp=DIR'. +# (Do not try this at home. You need an as yet unreleased version of GNU MP.) + +mpn-sysdep := $(addsuffix .c,$(mpn-routines)) \ + $(addsuffix .S,$(mpn-routines)) \ + $(addsuffix .s,$(mpn-routines)) gmp-mparam.h asm-syntax.h + +mpn-try := $(addprefix $(gmp-srcdir)/mpn/*/,$(mpn-sysdep)) +mpn-found := $(wildcard $(mpn-try)) +mpn-found := $(filter-out $(patsubst %.S,%.s,$(filter %.s,$(mpn-found))),\ + $(mpn-found)) + +include mpn-copy.mk +%.mk: gen-%; sh $< > $@ + +mpn-copy-1 := $(patsubst $(gmp-srcdir)/mpn/%,$(sysdep_dir)/%,$(mpn-found)) +mpn-copy-sysdep := $(mpn-copy-sysdep) $(mpn-copy-1) +$(mpn-copy-1): $(sysdep_dir)/%: $(ignore gmp2glibc.sed) $(gmp-srcdir)/mpn/% + $(gmp2glibc) + +mpn-stuff = $(mpn-copy-sysdep) $(mpn-copy) + +# chmod so I don't edit them by mistake. +define gmp2glibc +$(ignore sed -f $^ > $@-tmp) +cp $< $@-tmp +chmod a-w $@-tmp +mv -f $@-tmp $@ +endef + +mpn-copy = $(filter-out $(mpn-sysdep),$(mpn-headers) mp_clz_tab.c) +$(mpn-copy): %: $(ignore gmp2glibc.sed) $(gmp-srcdir)/%; $(gmp2glibc) + +.PHONY: copy-mpn clean-mpn +copy-mpn: $(mpn-stuff) +clean-mpn: + rm -f $(mpn-stuff) + +endif diff --git a/stdio/_itoa.c b/stdio/_itoa.c new file mode 100644 index 0000000000..b781b1ea88 --- /dev/null +++ b/stdio/_itoa.c @@ -0,0 +1,45 @@ +/* Internal function for converting integers to ASCII. +Copyright (C) 1994 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. */ + +#include +#include "_itoa.h" + +/* Lower-case digits. */ +CONST char _itoa_lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; +/* Upper-case digits. */ +CONST char _itoa_upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + +char * +DEFUN(_itoa, (value, buflim, base, upper_case), + unsigned long long int value AND char *buflim AND + unsigned int base AND int upper_case) +{ + /* Base-36 digits for numbers. */ + CONST char *digits = upper_case ? _itoa_upper_digits : _itoa_lower_digits; + + register char *bp = buflim; + + while (value > 0) + { + *--bp = digits[value % base]; + value /= base; + } + + return bp; +} diff --git a/stdio/_itoa.h b/stdio/_itoa.h new file mode 100644 index 0000000000..791ce6c87f --- /dev/null +++ b/stdio/_itoa.h @@ -0,0 +1,54 @@ +/* Internal function for converting integers to ASCII. +Copyright (C) 1994 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. */ + +#ifndef _ITOA_H +#define _ITOA_H +#include + +extern const char _itoa_lower_digits[], _itoa_upper_digits[]; + +/* Convert VALUE into ASCII in base BASE (2..36). + Write backwards starting the character just before BUFLIM. + Return the address of the first (left-to-right) character in the number. + Use upper case letters iff UPPER_CASE is nonzero. */ + +extern char *_itoa __P ((unsigned long long int value, char *buflim, + unsigned int base, int upper_case)); + +#if defined (__GNUC__) && defined (__OPTIMIZE__) +extern __inline char * +_itoa (unsigned long long int value, char *buflim, + unsigned int base, int upper_case) +{ + /* Base-36 digits for numbers. */ + const char *digits = upper_case ? _itoa_upper_digits : _itoa_lower_digits; + + register char *bp = buflim; + + while (value > 0) + { + *--bp = digits[value % base]; + value /= base; + } + + return bp; +} +#endif + +#endif /* itoa.h */ diff --git a/stdio/asprintf.c b/stdio/asprintf.c new file mode 100644 index 0000000000..9b69800f73 --- /dev/null +++ b/stdio/asprintf.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1991 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. */ + +#include +#include +#include + + +/* Write formatted output from FORMAT to a string which is + allocated with malloc and stored in *STRING_PTR. */ +/* VARARGS2 */ +int +DEFUN(asprintf, (string_ptr, format), + char **string_ptr AND CONST char *format DOTS) +{ + va_list arg; + int done; + + va_start(arg, format); + done = vasprintf(string_ptr, format, arg); + va_end(arg); + + return done; +} diff --git a/stdio/bug1.c b/stdio/bug1.c new file mode 100644 index 0000000000..755bc4231b --- /dev/null +++ b/stdio/bug1.c @@ -0,0 +1,28 @@ +#include +#include +#include + +int +DEFUN_VOID(main) +{ + char *bp; + size_t size; + FILE *stream; + int lose = 0; + + stream = open_memstream (&bp, &size); + fprintf (stream, "hello"); + fflush (stream); + printf ("buf = %s, size = %d\n", bp, size); + lose |= size != 5; + lose |= strncmp (bp, "hello", size); + fprintf (stream, ", world"); + fclose (stream); + printf ("buf = %s, size = %d\n", bp, size); + lose |= size != 12; + lose |= strncmp (bp, "hello, world", 12); + + puts (lose ? "Test FAILED!" : "Test succeeded."); + + return lose; +} diff --git a/stdio/bug1.input b/stdio/bug1.input new file mode 100644 index 0000000000..5595fa46c0 --- /dev/null +++ b/stdio/bug1.input @@ -0,0 +1 @@ +95 diff --git a/stdio/bug2.c b/stdio/bug2.c new file mode 100644 index 0000000000..2b34c890bf --- /dev/null +++ b/stdio/bug2.c @@ -0,0 +1,12 @@ +#include +#include + +int +DEFUN_VOID(main) +{ + int i; + puts ("This should print \"wow = I\" for I from 0 to 39 inclusive."); + for (i = 0; i < 40; i++) + printf ("%s = %d\n", "wow", i); + return 0; +} diff --git a/stdio/bug3.c b/stdio/bug3.c new file mode 100644 index 0000000000..0f3c7f1087 --- /dev/null +++ b/stdio/bug3.c @@ -0,0 +1,52 @@ +#include +#include +#include + +int +DEFUN_VOID(main) +{ + FILE *f; + int i; + + f = fopen("bugtest", "w+"); + for (i=0; i<9000; i++) + putc ('x', f); + fseek (f, 8180L, 0); + fwrite ("Where does this text go?", 1, 24, f); + fflush (f); + + rewind (f); + for (i=0; i<9000; i++) + { + int j; + + if ((j = getc(f)) != 'x') + { + if (i != 8180) + { + printf ("Test FAILED!"); + return 1; + } + else + { + char buf[25]; + + buf[0] = j; + fread (buf + 1, 1, 23, f); + buf[24] = '\0'; + if (strcmp (buf, "Where does this text go?") != 0) + { + printf ("%s\nTest FAILED!\n", buf); + return 1; + } + i += 23; + } + } + } + + fclose(f); + + puts ("Test succeeded."); + + return 0; +} diff --git a/stdio/bug4.c b/stdio/bug4.c new file mode 100644 index 0000000000..8e67f1d7b9 --- /dev/null +++ b/stdio/bug4.c @@ -0,0 +1,50 @@ +#ifdef _LIBC +#include +#endif +#include +#include +#include + +int stdio_block_read = 1, stdio_block_write = 1; + +int +DEFUN(main, (argc, argv), + int argc AND char **argv) +{ + FILE *f; + int i; + char buffer[31]; + + while ((i = getopt (argc, argv, "rw")) != EOF) + switch (i) + { + case 'r': + stdio_block_read = 0; + break; + case 'w': + stdio_block_write = 0; + break; + } + + f = fopen("bugtest", "w+"); + for (i=0; i<9000; i++) { + putc('x', f); + } + fseek(f, 8180L, 0); + fwrite("Where does this text come from?", 1, 31, f); + fseek(f, 8180L, 0); + fread(buffer, 1, 31, f); + fwrite(buffer, 1, 31, stdout); + fclose(f); + + if (!memcmp (buffer, "Where does this text come from?", 31)) + { + puts ("\nTest succeeded."); + return 0; + } + else + { + puts ("\nTest FAILED!"); + return 1; + } +} diff --git a/stdio/bug5.c b/stdio/bug5.c new file mode 100644 index 0000000000..218af31352 --- /dev/null +++ b/stdio/bug5.c @@ -0,0 +1,60 @@ +/* If stdio is working correctly, after this is run infile and outfile + will have the same contents. If the bug (found in GNU C library 0.3) + exhibits itself, outfile will be missing the 2nd through 1023rd + characters. */ + +#include +#include +#include +#include + +static char buf[8192]; + +int +DEFUN_VOID(main) +{ + FILE *in; + FILE *out; + static char inname[] = "infile"; + static char outname[] = "outfile"; + int i; + + /* Create a test file. */ + in = fopen (inname, "w+"); + if (in == NULL) + { + perror (inname); + return 1; + } + for (i = 0; i < 1000; ++i) + fprintf (in, "%d\n", i); + + out = fopen (outname, "w"); + if (out == NULL) + { + perror (outname); + return 1; + } + if (fseek (in, 0L, SEEK_SET) != 0) + abort (); + putc (getc (in), out); + i = fread (buf, 1, sizeof (buf), in); + if (i == 0) + { + perror ("fread"); + return 1; + } + if (fwrite (buf, 1, i, out) != i) + { + perror ("fwrite"); + return 1; + } + fclose (in); + fclose (out); + + puts ("There should be no further output from this test."); + fflush (stdout); + execlp ("cmp", "cmp", inname, outname, (char *) NULL); + perror ("execlp: cmp"); + exit (1); +} diff --git a/stdio/bug6.c b/stdio/bug6.c new file mode 100644 index 0000000000..4a37ab2584 --- /dev/null +++ b/stdio/bug6.c @@ -0,0 +1,27 @@ +#include +#include + +int +DEFUN_VOID(main) +{ + char buf[80]; + int i; + int lost = 0; + + scanf ("%2s", buf); + lost |= (buf[0] != 'X' || buf[1] != 'Y' || buf[2] != '\0'); + if (lost) + puts ("test of %2s failed."); + scanf (" "); + scanf ("%d", &i); + lost |= (i != 1234); + if (lost) + puts ("test of %d failed."); + scanf ("%c", buf); + lost |= (buf[0] != 'L'); + if (lost) + puts ("test of %c failed.\n"); + + puts (lost ? "Test FAILED!" : "Test succeeded."); + return lost; +} diff --git a/stdio/bug6.input b/stdio/bug6.input new file mode 100644 index 0000000000..d996e399c3 --- /dev/null +++ b/stdio/bug6.input @@ -0,0 +1 @@ +XY 1234L diff --git a/stdio/bug7.c b/stdio/bug7.c new file mode 100644 index 0000000000..af06f8d6a5 --- /dev/null +++ b/stdio/bug7.c @@ -0,0 +1,53 @@ +/* Regression test for fseek and freopen bugs. */ + +#include + +int +main () +{ + int lose = 0; + char filename[] = "/tmp/foo"; + FILE *fp; + + fp = fopen (filename, "w+"); + fprintf (fp, "Hello world!\n"); + fflush (fp); + fseek (fp, 5L, SEEK_SET); + if (fseek (fp, -1L, SEEK_CUR) < 0) + { + printf ("seek failed\n"); + lose = 1; + } + fclose (fp); + remove (filename); + + { + FILE *file1; + FILE *file2; + char filename1[] = "/tmp/foo"; + char filename2[] = "/tmp/bar"; + int ch; + + file1 = fopen (filename1, "w"); + fclose (file1); + + file2 = fopen (filename2, "w"); + fputc ('x', file2); + fclose (file2); + + file1 = fopen (filename1, "r"); + file2 = freopen (filename2, "r", file1); + if ((ch = fgetc (file2)) != 'x') + { + printf ("wrong character in reopened file, value = %d\n", ch); + lose = 1; + } + fclose (file1); + fclose (file2); + remove (filename1); + remove (filename2); + } + + puts (lose ? "Test FAILED!" : "Test succeeded."); + return lose; +} diff --git a/stdio/clearerr.c b/stdio/clearerr.c new file mode 100644 index 0000000000..1a9feaa413 --- /dev/null +++ b/stdio/clearerr.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1991 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. */ + +#include +#include +#include + +#undef clearerr + + +/* Clear the EOF and error indicators for STREAM. */ +void +DEFUN(clearerr, (stream), FILE *stream) +{ + __clearerr(stream); +} diff --git a/stdio/dprintf.c b/stdio/dprintf.c new file mode 100644 index 0000000000..fc9faa4ca2 --- /dev/null +++ b/stdio/dprintf.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1991 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. */ + +#include +#include +#include + + +/* Write formatted output to D, according to the format string FORMAT. */ +/* VARARGS2 */ +int +DEFUN(dprintf, (d, format), int d AND CONST char *format DOTS) +{ + va_list arg; + int done; + + va_start(arg, format); + done = vdprintf(d, format, arg); + va_end(arg); + + return done; +} diff --git a/stdio/errnobug.c b/stdio/errnobug.c new file mode 100644 index 0000000000..cf17be30a2 --- /dev/null +++ b/stdio/errnobug.c @@ -0,0 +1,60 @@ +/* Regression test for reported old bug that errno is clobbered + by the first successful output to a stream on an unseekable object. +Copyright (C) 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. */ + +#include +#include +#include + +int +main (void) +{ + int fd[2]; + FILE *f; + + /* Get a stream that cannot seek. */ + + if (pipe (fd)) + { + perror ("pipe"); + return 1; + } + f = fdopen (fd[1], "w"); + if (f == NULL) + { + perror ("fdopen"); + return 1; + } + + errno = 0; + if (fputs ("fnord", f)) + { + perror ("fputs"); + return 1; + } + + if (errno) + { + perror ("errno gratuitously set -- TEST FAILED"); + return 1; + } + + puts ("Test succeeded."); + return 0; +} diff --git a/stdio/fclose.c b/stdio/fclose.c new file mode 100644 index 0000000000..becb85802f --- /dev/null +++ b/stdio/fclose.c @@ -0,0 +1,69 @@ +/* Copyright (C) 1991 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. */ + +#include +#include +#include +#include +#include + + +/* Close a stream. */ +int +DEFUN(fclose, (stream), register FILE *stream) +{ + int status; + + if (stream == NULL) + { + /* Close all streams. */ + register FILE *f; + for (f = __stdio_head; f != NULL; f = f->__next) + if (__validfp(f)) + (void) fclose(f); + return 0; + } + + if (!__validfp(stream)) + { + errno = EINVAL; + return EOF; + } + + if (stream->__mode.__write && + /* Flush the buffer. */ + __flshfp (stream, EOF) == EOF) + return EOF; + + /* Free the buffer's storage. */ + if (stream->__buffer != NULL && !stream->__userbuf) + free(stream->__buffer); + + /* Close the system file descriptor. */ + if (stream->__io_funcs.__close != NULL) + status = (*stream->__io_funcs.__close)(stream->__cookie); + else if (!stream->__seen && stream->__cookie != NULL) + status = __stdio_close(stream->__cookie); + else + status = 0; + + /* Nuke the stream, making it available for re-use. */ + __invalidate(stream); + + return status < 0 ? EOF : 0; +} diff --git a/stdio/feof.c b/stdio/feof.c new file mode 100644 index 0000000000..c18300f6b5 --- /dev/null +++ b/stdio/feof.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1991 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. */ + +#include +#include +#include + +#undef feof + + +/* Return non-zero if STREAM has its EOF indicator set. */ +int +DEFUN(feof, (stream), FILE *stream) +{ + if (!__validfp(stream)) + { + errno = EINVAL; + return(-1); + } + + return(stream->__eof); +} diff --git a/stdio/ferror.c b/stdio/ferror.c new file mode 100644 index 0000000000..ed8f74401a --- /dev/null +++ b/stdio/ferror.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1991 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. */ + +#include +#include +#include + +#undef ferror + + +/* Return non-zero if STREAM has its error indicator set. */ +int +DEFUN(ferror, (stream), FILE *stream) +{ + if (!__validfp(stream)) + { + errno = EINVAL; + return(-1); + } + + return(stream->__error); +} diff --git a/stdio/fflush.c b/stdio/fflush.c new file mode 100644 index 0000000000..a6d52ba3e7 --- /dev/null +++ b/stdio/fflush.c @@ -0,0 +1,45 @@ +/* Copyright (C) 1991 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. */ + +#include +#include +#include +#include + +/* Flush STREAM's buffer. + If STREAM is NULL, flush the buffers of all streams that are writing. */ +int +DEFUN(fflush, (stream), register FILE *stream) +{ + if (stream == NULL) + { + int lossage = 0; + for (stream = __stdio_head; stream != NULL; stream = stream->__next) + if (__validfp(stream) && stream->__mode.__write) + lossage |= fflush(stream) == EOF; + return lossage ? EOF : 0; + } + + if (!__validfp(stream) || !stream->__mode.__write) + { + errno = EINVAL; + return EOF; + } + + return __flshfp(stream, EOF); +} diff --git a/stdio/fgetc.c b/stdio/fgetc.c new file mode 100644 index 0000000000..7f01090294 --- /dev/null +++ b/stdio/fgetc.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1991 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. */ + +#include +#include +#include + + +/* Read a character from STREAM. */ +int +DEFUN(fgetc, (stream), FILE *stream) +{ + if (!__validfp(stream) || !stream->__mode.__read) + { + errno = EINVAL; + return EOF; + } + + return __getc(stream); +} diff --git a/stdio/fgetpos.c b/stdio/fgetpos.c new file mode 100644 index 0000000000..cb6a1588ba --- /dev/null +++ b/stdio/fgetpos.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1991 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. */ + +#include +#include +#include + +#undef fgetpos + + +/* Put the current position of STREAM in *POS. */ +int +DEFUN(fgetpos, (stream, pos), FILE *stream AND fpos_t *pos) +{ + if (!__validfp(stream) || pos == NULL) + { + errno = EINVAL; + return(-1); + } + + *pos = ftell(stream); + if (*pos < 0L) + return(-1); + return(0); +} diff --git a/stdio/fgets.c b/stdio/fgets.c new file mode 100644 index 0000000000..e9e53c88dd --- /dev/null +++ b/stdio/fgets.c @@ -0,0 +1,121 @@ +/* Copyright (C) 1991, 1992, 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. */ + +#include +#include +#include +#include + +/* Reads characters from STREAM into S, until either a newline character + is read, N - 1 characters have been read, or EOF is seen. Returns + the newline, unlike gets. Finishes by appending a null character and + returning S. If EOF is seen before any characters have been written + to S, the function returns NULL without appending the null character. + If there is a file error, always return NULL. */ +char * +DEFUN(fgets, (s, n, stream), char *s AND int n AND register FILE *stream) +{ + register char *p = s; + + if (!__validfp(stream) || s == NULL || n <= 0) + { + errno = EINVAL; + return NULL; + } + + if (ferror (stream)) + return NULL; + + if (stream->__buffer == NULL && stream->__userbuf) + { + /* Unbuffered stream. Not much optimization to do. */ + register int c = 0; + while (--n > 0 && (c = getc (stream)) != EOF) + if ((*p++ = c) == '\n') + break; + if (c == EOF && (p == s || ferror (stream))) + return NULL; + *p = '\0'; + return s; + } + + /* Leave space for the null. */ + --n; + + if (n > 0 && + (!stream->__seen || stream->__buffer == NULL || stream->__pushed_back)) + { + /* Do one with getc to allocate a buffer. */ + int c = getc (stream); + if (c == EOF) + return NULL; + *p++ = c; + if (c == '\n') + { + *p = '\0'; + return s; + } + else + --n; + } + + while (n > 0) + { + size_t i; + char *found; + + i = stream->__get_limit - stream->__bufp; + if (i == 0) + { + /* Refill the buffer. */ + int c = __fillbf (stream); + if (c == EOF) + break; + *p++ = c; + --n; + if (c == '\n') + { + *p = '\0'; + return s; + } + i = stream->__get_limit - stream->__bufp; + } + + if (i > n) + i = n; + + found = (char *) __memccpy ((PTR) p, stream->__bufp, '\n', i); + + if (found != NULL) + { + stream->__bufp += found - p; + p = found; + break; + } + + stream->__bufp += i; + n -= i; + p += i; + } + + if (p == s) + return NULL; + + *p = '\0'; + return ferror (stream) ? NULL : s; +} diff --git a/stdio/fileno.c b/stdio/fileno.c new file mode 100644 index 0000000000..da55300c8b --- /dev/null +++ b/stdio/fileno.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1991, 1993, 1994 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. */ + +#include +#include +#include + +/* Return the system file descriptor associated with STREAM. */ +int +DEFUN(fileno, (stream), FILE *stream) +{ + extern void __stdio_check_funcs __P ((FILE *)); + + if (! __validfp (stream)) + { + errno = EINVAL; + return -1; + } + + __stdio_check_funcs (stream); + + if (stream->__io_funcs.__fileno == NULL) + { +#ifdef EOPNOTSUPP + errno = EOPNOTSUPP; +#else + errno = ENOSYS; +#endif + return -1; + } + + return (*stream->__io_funcs.__fileno) (stream->__cookie); +} diff --git a/stdio/fmemopen.c b/stdio/fmemopen.c new file mode 100644 index 0000000000..42a137a2c8 --- /dev/null +++ b/stdio/fmemopen.c @@ -0,0 +1,108 @@ +/* Copyright (C) 1991, 1992, 1993 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. */ + +#include +#include +#include +#include +#include +#include + + +/* Defined in fopen.c. */ +extern int EXFUN(__getmode, (CONST char *mode, __io_mode *mptr)); + +/* Open a new stream that will read and/or write from the buffer in + S, which is of LEN bytes. If the mode indicates appending, the + buffer pointer is set to point to the first '\0' in the buffer. + If S is NULL, the buffer is allocated by malloc and will be freed + when the stream is closed. The only purpose of this is to write + things and then read what's been written. If LEN is zero, writes will + always return errors and reads will always return end-of-file. + + The stream is set up such that seeks and tells will always fail and + once the buffer is full of written characters or empty of characters + to read, attempted writes always return an output error and attempted + reads always return end-of-file. */ +FILE * +DEFUN(fmemopen, (s, len, mode), + PTR s AND size_t len AND CONST char *mode) +{ + __io_mode m; + register FILE *stream; + + if (!__getmode (mode, &m)) + return NULL; + + stream = __newstream (); + if (stream == NULL) + return NULL; + + stream->__mode = m; + + /* Input gets EOF. */ + stream->__room_funcs.__input = NULL; + /* Output gets error. */ + stream->__room_funcs.__output = NULL; + + /* Do nothing for close. */ + stream->__io_funcs.__close = NULL; + /* Can't seek outside the buffer. */ + stream->__io_funcs.__seek = NULL; + /* There is no associated file descriptor to fetch. */ + stream->__io_funcs.__fileno = NULL; + + stream->__seen = 1; + + stream->__userbuf = s != NULL && len > 0; + if (s == NULL) + { + s = malloc (len); + if (s == NULL) + { + int save = errno; + (void) fclose (stream); + errno = save; + return NULL; + } + } + + stream->__buffer = (char *) s; + stream->__bufsize = len; + + stream->__bufp = stream->__buffer; + stream->__get_limit = (stream->__buffer + + (stream->__mode.__read ? stream->__bufsize : 0)); + stream->__put_limit = (stream->__buffer + + (stream->__mode.__write ? stream->__bufsize : 0)); + stream->__cookie = NULL; + + if (stream->__mode.__append) + { + char *p = memchr (stream->__bufp, '\0', + stream->__get_limit - stream->__bufp); + if (p == NULL) + stream->__bufp = stream->__get_limit; + else + stream->__bufp = p; + } + else if (stream->__mode.__truncate) + memset ((PTR) stream->__buffer, 0, len); + + return stream; +} diff --git a/stdio/fopen.c b/stdio/fopen.c new file mode 100644 index 0000000000..fba6ac436a --- /dev/null +++ b/stdio/fopen.c @@ -0,0 +1,110 @@ +/* Copyright (C) 1991, 1992, 1993 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. */ + +#include +#include +#include +#include +#include +#include + + +#define badmode() return ((errno = EINVAL), 0) + +/* Dissect the given mode string into an __io_mode. */ +int +DEFUN(__getmode, (mode, mptr), CONST char *mode AND __io_mode *mptr) +{ + register unsigned char i; + + if (mode == NULL) + badmode (); + + memset ((PTR) mptr, 0, sizeof (*mptr)); + + switch (*mode) + { + case 'a': + mptr->__write = mptr->__create = mptr->__append = 1; + break; + case 'w': + mptr->__write = mptr->__create = mptr->__truncate = 1; + break; + case 'r': + mptr->__read = 1; + break; + default: + badmode (); + } + + for (i = 1; i < 3; ++i) + { + ++mode; + if (*mode == '\0') + break; + switch (*mode) + { + case '+': + mptr->__read = mptr->__write = 1; + break; + case 'b': + mptr->__binary = 1; + break; + } + } + + if (!mptr->__read && !mptr->__write) + badmode (); + + mptr->__exclusive = *mode == 'x'; + + return 1; +} + +/* Open a new stream on the given file. */ +FILE * +DEFUN(fopen, (filename, mode), CONST char *filename AND CONST char *mode) +{ + FILE *stream; + __io_mode m; + + if (filename == NULL) + { + errno = EINVAL; + return NULL; + } + + if (!__getmode (mode, &m)) + return NULL; + + stream = __newstream (); + if (stream == NULL) + return NULL; + + if (__stdio_open (filename, m, &stream->__cookie)) + { + int save = errno; + (void) fclose (stream); + errno = save; + return NULL; + } + + stream->__mode = m; + + return stream; +} diff --git a/stdio/fopncook.c b/stdio/fopncook.c new file mode 100644 index 0000000000..b61bdda959 --- /dev/null +++ b/stdio/fopncook.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1991, 1992 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. */ + +#include +#include + + +/* Defined in fopen.c. */ +extern int EXFUN(__getmode, (CONST char *mode, __io_mode *mptr)); + +/* Open a new stream on the given magic cookie descriptor. */ +FILE * +DEFUN(fopencookie, (cookie, mode, functions), + PTR cookie AND CONST char *mode AND __io_functions functions) +{ + __io_mode m; + FILE *f; + + if (!__getmode (mode, &m)) + return NULL; + + f = __newstream (); + if (f == NULL) + return NULL; + + f->__cookie = cookie; + f->__mode = m; + f->__io_funcs = functions; + f->__room_funcs = __default_room_functions; + f->__seen = 1; + + return f; +} diff --git a/stdio/fpioconst.c b/stdio/fpioconst.c new file mode 100644 index 0000000000..231cae34ed --- /dev/null +++ b/stdio/fpioconst.c @@ -0,0 +1,401 @@ +/* Table of MP integer constants 10^(2^i), used for floating point <-> decimal. +Copyright (C) 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. */ + +#include "fpioconst.h" +#include /* This defines BITS_PER_MP_LIMB. */ + +/* First page : 32-bit limbs + Second page : 64-bit limbs + Last page : table of pointers + */ + +#if BITS_PER_MP_LIMB == 32 + +/* Table with constants of 10^(2^i), i=0..12 for 32-bit limbs. */ + +static const mp_limb _ten_p0[] = + { 0x00000000, 0x00000000, 0x0000000a }; +static const mp_limb _ten_p1[] = + { 0x00000000, 0x00000000, 0x00000064 }; +static const mp_limb _ten_p2[] = + { 0x00000000, 0x00000000, 0x00002710 }; +static const mp_limb _ten_p3[] = + { 0x00000000, 0x00000000, 0x05f5e100 }; +static const mp_limb _ten_p4[] = + { 0x00000000, 0x00000000, 0x6fc10000, 0x002386f2 }; +static const mp_limb _ten_p5[] = + { 0x00000000, 0x00000000, 0x00000000, 0x85acef81, 0x2d6d415b, 0x000004ee }; +static const mp_limb _ten_p6[] = + { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xbf6a1f01, 0x6e38ed64, + 0xdaa797ed, 0xe93ff9f4, 0x00184f03 }; +static const mp_limb _ten_p7[] = + { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x2e953e01, 0x03df9909, 0x0f1538fd, 0x2374e42f, 0xd3cff5ec, 0xc404dc08, + 0xbccdb0da, 0xa6337f19, 0xe91f2603, 0x0000024e }; +static const mp_limb _ten_p8[] = + { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x982e7c01, 0xbed3875b, + 0xd8d99f72, 0x12152f87, 0x6bde50c6, 0xcf4a6e70, 0xd595d80f, 0x26b2716e, + 0xadc666b0, 0x1d153624, 0x3c42d35a, 0x63ff540e, 0xcc5573c0, 0x65f9ef17, + 0x55bc28f2, 0x80dcc7f7, 0xf46eeddc, 0x5fdcefce, 0x000553f7 }; +static const mp_limb _ten_p9[] = + { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xfc6cf801, 0x77f27267, 0x8f9546dc, 0x5d96976f, 0xb83a8a97, 0xc31e1ad9, + 0x46c40513, 0x94e65747, 0xc88976c1, 0x4475b579, 0x28f8733b, 0xaa1da1bf, + 0x703ed321, 0x1e25cfea, 0xb21a2f22, 0xbc51fb2e, 0x96e14f5d, 0xbfa3edac, + 0x329c57ae, 0xe7fc7153, 0xc3fc0695, 0x85a91924, 0xf95f635e, 0xb2908ee0, + 0x93abade4, 0x1366732a, 0x9449775c, 0x69be5b0e, 0x7343afac, 0xb099bc81, + 0x45a71d46, 0xa2699748, 0x8cb07303, 0x8a0b1f13, 0x8cab8a97, 0xc1d238d9, + 0x633415d4, 0x0000001c }; +static const mp_limb _ten_p10[] = + { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2919f001, 0xf55b2b72, + 0x6e7c215b, 0x1ec29f86, 0x991c4e87, 0x15c51a88, 0x140ac535, 0x4c7d1e1a, + 0xcc2cd819, 0x0ed1440e, 0x896634ee, 0x7de16cfb, 0x1e43f61f, 0x9fce837d, + 0x231d2b9c, 0x233e55c7, 0x65dc60d7, 0xf451218b, 0x1c5cd134, 0xc9635986, + 0x922bbb9f, 0xa7e89431, 0x9f9f2a07, 0x62be695a, 0x8e1042c4, 0x045b7a74, + 0x1abe1de3, 0x8ad822a5, 0xba34c411, 0xd814b505, 0xbf3fdeb3, 0x8fc51a16, + 0xb1b896bc, 0xf56deeec, 0x31fb6bfd, 0xb6f4654b, 0x101a3616, 0x6b7595fb, + 0xdc1a47fe, 0x80d98089, 0x80bda5a5, 0x9a202882, 0x31eb0f66, 0xfc8f1f90, + 0x976a3310, 0xe26a7b7e, 0xdf68368a, 0x3ce3a0b8, 0x8e4262ce, 0x75a351a2, + 0x6cb0b6c9, 0x44597583, 0x31b5653f, 0xc356e38a, 0x35faaba6, 0x0190fba0, + 0x9fc4ed52, 0x88bc491b, 0x1640114a, 0x005b8041, 0xf4f3235e, 0x1e8d4649, + 0x36a8de06, 0x73c55349, 0xa7e6bd2a, 0xc1a6970c, 0x47187094, 0xd2db49ef, + 0x926c3f5b, 0xae6209d4, 0x2d433949, 0x34f4a3c6, 0xd4305d94, 0xd9d61a05, + 0x00000325 }; +static const mp_limb _ten_p11[] = + { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x1333e001, 0xe3096865, 0xb27d4d3f, 0x49e28dcf, 0xec2e4721, 0xee87e354, + 0xb6067584, 0x368b8abb, 0xa5e5a191, 0x2ed56d55, 0xfd827773, 0xea50d142, + 0x51b78db2, 0x98342c9e, 0xc850dabc, 0x866ed6f1, 0x19342c12, 0x92794987, + 0xd2f869c2, 0x66912e4a, 0x71c7fd8f, 0x57a7842d, 0x235552eb, 0xfb7fedcc, + 0xf3861ce0, 0x38209ce1, 0x9713b449, 0x34c10134, 0x8c6c54de, 0xa7a8289c, + 0x2dbb6643, 0xe3cb64f3, 0x8074ff01, 0xe3892ee9, 0x10c17f94, 0xa8f16f92, + 0xa8281ed6, 0x967abbb3, 0x5a151440, 0x9952fbed, 0x13b41e44, 0xafe609c3, + 0xa2bca416, 0xf111821f, 0xfb1264b4, 0x91bac974, 0xd6c7d6ab, 0x8e48ff35, + 0x4419bd43, 0xc4a65665, 0x685e5510, 0x33554c36, 0xab498697, 0x0dbd21fe, + 0x3cfe491d, 0x982da466, 0xcbea4ca7, 0x9e110c7b, 0x79c56b8a, 0x5fc5a047, + 0x84d80e2e, 0x1aa9f444, 0x730f203c, 0x6a57b1ab, 0xd752f7a6, 0x87a7dc62, + 0x944545ff, 0x40660460, 0x77c1a42f, 0xc9ac375d, 0xe866d7ef, 0x744695f0, + 0x81428c85, 0xa1fc6b96, 0xd7917c7b, 0x7bf03c19, 0x5b33eb41, 0x5715f791, + 0x8f6cae5f, 0xdb0708fd, 0xb125ac8e, 0x785ce6b7, 0x56c6815b, 0x6f46eadb, + 0x4eeebeee, 0x195355d8, 0xa244de3c, 0x9d7389c0, 0x53761abd, 0xcf99d019, + 0xde9ec24b, 0x0d76ce39, 0x70beb181, 0x2e55ecee, 0xd5f86079, 0xf56d9d4b, + 0xfb8886fb, 0x13ef5a83, 0x408f43c5, 0x3f3389a4, 0xfad37943, 0x58ccf45c, + 0xf82df846, 0x415c7f3e, 0x2915e818, 0x8b3d5cf4, 0x6a445f27, 0xf8dbb57a, + 0xca8f0070, 0x8ad803ec, 0xb2e87c34, 0x038f9245, 0xbedd8a6c, 0xc7c9dee0, + 0x0eac7d56, 0x2ad3fa14, 0xe0de0840, 0xf775677c, 0xf1bd0ad5, 0x92be221e, + 0x87fa1fb9, 0xce9d04a4, 0xd2c36fa9, 0x3f6f7024, 0xb028af62, 0x907855ee, + 0xd83e49d6, 0x4efac5dc, 0xe7151aab, 0x77cd8c6b, 0x0a753b7d, 0x0af908b4, + 0x8c983623, 0xe50f3027, 0x94222771, 0x1d08e2d6, 0xf7e928e6, 0xf2ee5ca6, + 0x1b61b93c, 0x11eb962b, 0x9648b21c, 0xce2bcba1, 0x34f77154, 0x7bbebe30, + 0xe526a319, 0x8ce329ac, 0xde4a74d2, 0xb5dc53d5, 0x0009e8b3 }; +static const mp_limb _ten_p12[] = + { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2a67c001, 0xd4724e8d, + 0x8efe7ae7, 0xf89a1e90, 0xef084117, 0x54e05154, 0x13b1bb51, 0x506be829, + 0xfb29b172, 0xe599574e, 0xf0da6146, 0x806c0ed3, 0xb86ae5be, 0x45155e93, + 0xc0591cc2, 0x7e1e7c34, 0x7c4823da, 0x1d1f4cce, 0x9b8ba1e8, 0xd6bfdf75, + 0xe341be10, 0xc2dfae78, 0x016b67b2, 0x0f237f1a, 0x3dbeabcd, 0xaf6a2574, + 0xcab3e6d7, 0x142e0e80, 0x61959127, 0x2c234811, 0x87009701, 0xcb4bf982, + 0xf8169c84, 0x88052f8c, 0x68dde6d4, 0xbc131761, 0xff0b0905, 0x54ab9c41, + 0x7613b224, 0x1a1c304e, 0x3bfe167b, 0x441c2d47, 0x4f6cea9c, 0x78f06181, + 0xeb659fb8, 0x30c7ae41, 0x947e0d0e, 0xa1ebcad7, 0xd97d9556, 0x2130504d, + 0x1a8309cb, 0xf2acd507, 0x3f8ec72a, 0xfd82373a, 0x95a842bc, 0x280f4d32, + 0xf3618ac0, 0x811a4f04, 0x6dc3a5b4, 0xd3967a1b, 0x15b8c898, 0xdcfe388f, + 0x454eb2a0, 0x8738b909, 0x10c4e996, 0x2bd9cc11, 0x3297cd0c, 0x655fec30, + 0xae0725b1, 0xf4090ee8, 0x037d19ee, 0x398c6fed, 0x3b9af26b, 0xc994a450, + 0xb5341743, 0x75a697b2, 0xac50b9c1, 0x3ccb5b92, 0xffe06205, 0xa8329761, + 0xdfea5242, 0xeb83cadb, 0xe79dadf7, 0x3c20ee69, 0x1e0a6817, 0x7021b97a, + 0x743074fa, 0x176ca776, 0x77fb8af6, 0xeca19beb, 0x92baf1de, 0xaf63b712, + 0xde35c88b, 0xa4eb8f8c, 0xe137d5e9, 0x40b464a0, 0x87d1cde8, 0x42923bbd, + 0xcd8f62ff, 0x2e2690f3, 0x095edc16, 0x59c89f1b, 0x1fa8fd5d, 0x5138753d, + 0x390a2b29, 0x80152f18, 0x2dd8d925, 0xf984d83e, 0x7a872e74, 0xc19e1faf, + 0xed4d542d, 0xecf9b5d0, 0x9462ea75, 0xc53c0adf, 0x0caea134, 0x37a2d439, + 0xc8fa2e8a, 0x2181327e, 0x6e7bb827, 0x2d240820, 0x50be10e0, 0x5893d4b8, + 0xab312bb9, 0x1f2b2322, 0x440b3f25, 0xbf627ede, 0x72dac789, 0xb608b895, + 0x78787e2a, 0x86deb3f0, 0x6fee7aab, 0xbb9373f4, 0x27ecf57b, 0xf7d8b57e, + 0xfca26a9f, 0x3d04e8d2, 0xc9df13cb, 0x3172826a, 0xcd9e8d7c, 0xa8fcd8e0, + 0xb2c39497, 0x307641d9, 0x1cc939c1, 0x2608c4cf, 0xb6d1c7bf, 0x3d326a7e, + 0xeeaf19e6, 0x8e13e25f, 0xee63302b, 0x2dfe6d97, 0x25971d58, 0xe41d3cc4, + 0x0a80627c, 0xab8db59a, 0x9eea37c8, 0xe90afb77, 0x90ca19cf, 0x9ee3352c, + 0x3613c850, 0xfe78d682, 0x788f6e50, 0x5b060904, 0xb71bd1a4, 0x3fecb534, + 0xb32c450c, 0x20c33857, 0xa6e9cfda, 0x0239f4ce, 0x48497187, 0xa19adb95, + 0xb492ed8a, 0x95aca6a8, 0x4dcd6cd9, 0xcf1b2350, 0xfbe8b12a, 0x1a67778c, + 0x38eb3acc, 0xc32da383, 0xfb126ab1, 0xa03f40a8, 0xed5bf546, 0xe9ce4724, + 0x4c4a74fd, 0x73a130d8, 0xd9960e2d, 0xa2ebd6c1, 0x94ab6feb, 0x6f233b7c, + 0x49126080, 0x8e7b9a73, 0x4b8c9091, 0xd298f999, 0x35e836b5, 0xa96ddeff, + 0x96119b31, 0x6b0dd9bc, 0xc6cc3f8d, 0x282566fb, 0x72b882e7, 0xd6769f3b, + 0xa674343d, 0x00fc509b, 0xdcbf7789, 0xd6266a3f, 0xae9641fd, 0x4e89541b, + 0x11953407, 0x53400d03, 0x8e0dd75a, 0xe5b53345, 0x108f19ad, 0x108b89bc, + 0x41a4c954, 0xe03b2b63, 0x437b3d7f, 0x97aced8e, 0xcbd66670, 0x2c5508c2, + 0x650ebc69, 0x5c4f2ef0, 0x904ff6bf, 0x9985a2df, 0x9faddd9e, 0x5ed8d239, + 0x25585832, 0xe3e51cb9, 0x0ff4f1d4, 0x56c02d9a, 0x8c4ef804, 0xc1a08a13, + 0x13fd01c8, 0xe6d27671, 0xa7c234f4, 0x9d0176cc, 0xd0d73df2, 0x4d8bfa89, + 0x544f10cd, 0x2b17e0b2, 0xb70a5c7d, 0xfd86fe49, 0xdf373f41, 0x214495bb, + 0x84e857fd, 0x00d313d5, 0x0496fcbe, 0xa4ba4744, 0xe8cac982, 0xaec29e6e, + 0x87ec7038, 0x7000a519, 0xaeee333b, 0xff66e42c, 0x8afd6b25, 0x03b4f63b, + 0xbd7991dc, 0x5ab8d9c7, 0x2ed4684e, 0x48741a6c, 0xaf06940d, 0x2fdc6349, + 0xb03d7ecd, 0xe974996f, 0xac7867f9, 0x52ec8721, 0xbcdd9d4a, 0x8edd2d00, + 0x3557de06, 0x41c759f8, 0x3956d4b9, 0xa75409f2, 0x123cd8a1, 0xb6100fab, + 0x3e7b21e2, 0x2e8d623b, 0x92959da2, 0xbca35f77, 0x200c03a5, 0x35fcb457, + 0x1bb6c6e4, 0xf74eb928, 0x3d5d0b54, 0x87cc1d21, 0x4964046f, 0x18ae4240, + 0xd868b275, 0x8bd2b496, 0x1c5563f4, 0xc234d8f5, 0xf868e970, 0xf9151fff, + 0xae7be4a2, 0x271133ee, 0xbb0fd922, 0x25254932, 0xa60a9fc0, 0x104bcd64, + 0x30290145, 0x00000062 }; + +#define LAST_POW10 12 + +#elif BITS_PER_MP_LIMB == 64 + +/* Table with constants of 10^(2^i), i=0..12 for 64-bit limbs. */ + +static const mp_limb _ten_p0[] = + { 0x0000000000000000, 0x000000000000000a }; +static const mp_limb _ten_p1[] = + { 0x0000000000000000, 0x0000000000000064 }; +static const mp_limb _ten_p2[] = + { 0x0000000000000000, 0x0000000000002710 }; +static const mp_limb _ten_p3[] = + { 0x0000000000000000, 0x0000000005f5e100 }; +static const mp_limb _ten_p4[] = + { 0x0000000000000000, 0x002386f26fc10000 }; +static const mp_limb _ten_p5[] = + { 0x0000000000000000, 0x85acef8100000000, 0x000004ee2d6d415b }; +static const mp_limb _ten_p6[] = + { 0x0000000000000000, 0x0000000000000000, 0x6e38ed64bf6a1f01, + 0xe93ff9f4daa797ed, 0x0000000000184f03 }; +static const mp_limb _ten_p7[] = + { 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x03df99092e953e01, 0x2374e42f0f1538fd, 0xc404dc08d3cff5ec, + 0xa6337f19bccdb0da, 0x0000024ee91f2603 }; +static const mp_limb _ten_p8[] = + { 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0xbed3875b982e7c01, + 0x12152f87d8d99f72, 0xcf4a6e706bde50c6, 0x26b2716ed595d80f, + 0x1d153624adc666b0, 0x63ff540e3c42d35a, 0x65f9ef17cc5573c0, + 0x80dcc7f755bc28f2, 0x5fdcefcef46eeddc, 0x00000000000553f7 }; +static const mp_limb _ten_p9[] = + { 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x77f27267fc6cf801, 0x5d96976f8f9546dc, 0xc31e1ad9b83a8a97, + 0x94e6574746c40513, 0x4475b579c88976c1, 0xaa1da1bf28f8733b, + 0x1e25cfea703ed321, 0xbc51fb2eb21a2f22, 0xbfa3edac96e14f5d, + 0xe7fc7153329c57ae, 0x85a91924c3fc0695, 0xb2908ee0f95f635e, + 0x1366732a93abade4, 0x69be5b0e9449775c, 0xb099bc817343afac, + 0xa269974845a71d46, 0x8a0b1f138cb07303, 0xc1d238d98cab8a97, + 0x0000001c633415d4 }; +static const mp_limb _ten_p10[] = + { 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, + 0x0000000000000000, 0x0000000000000000, 0