add directory study
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#include <stdio.h>
|
||||
|
||||
double atof();
|
||||
|
||||
void dump(m)
|
||||
|
||||
double m;
|
||||
|
||||
{
|
||||
int i;
|
||||
long *p;
|
||||
|
||||
p = (long *) &m;
|
||||
for (i = sizeof(double)/sizeof(long); i--; p++)
|
||||
printf("%08lx ", *p);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
int ok;
|
||||
double a;
|
||||
double b;
|
||||
int bytes;
|
||||
char buf[1024];
|
||||
FILE *tmp;
|
||||
|
||||
tmp = tmpfile();
|
||||
|
||||
while (gets(buf) != (char *) NULL) {
|
||||
fprintf(tmp, "%s %s\n", buf, buf);
|
||||
}
|
||||
|
||||
rewind(tmp);
|
||||
|
||||
for (;;) {
|
||||
ok = fscanf(tmp, "%lf%n", &a, &bytes);
|
||||
if (ok == EOF)
|
||||
break;
|
||||
printf("%d bytes read %sok\n", bytes, ok ? "" : "not ");
|
||||
if (! ok)
|
||||
break;
|
||||
fgets(buf, sizeof(buf), tmp);
|
||||
b = atof(buf);
|
||||
printf("%.15lg ", a);
|
||||
dump(a); printf("\n");
|
||||
printf("%.15lg ", b);
|
||||
dump(b); printf(" Difference %g\n", a-b);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
double n;
|
||||
int i;
|
||||
|
||||
for (n = 1.0, i = 0; i < 300; i++, n *= 10.0)
|
||||
printf("%.16g\n", n);
|
||||
|
||||
for (n = 1.0, i = 0; i < 300; i++, n /= 10.0)
|
||||
printf("%.16g\n", n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char *argv;
|
||||
|
||||
{
|
||||
int exp;
|
||||
char buf[1024];
|
||||
double num;
|
||||
int i;
|
||||
double atof();
|
||||
|
||||
if (argc > 1) {
|
||||
for (i = 0; i < 20; i++) {
|
||||
for (exp = -300; exp <= 300; exp++) {
|
||||
sprintf(buf, "1e%d", exp);
|
||||
sscanf(buf, "%lf", &num);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < 20; i++) {
|
||||
for (exp = -300; exp <= 300; exp++) {
|
||||
sprintf(buf, "1e%d", exp);
|
||||
num = atof(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/* Here is a list of test values. Try:
|
||||
*
|
||||
* grep ^+ xfptest.c | xfptest | more
|
||||
|
||||
+30 1234567890.12345678901234567890
|
||||
+30 123456789012345678901234567890
|
||||
+30 0.00000123456789012345678901234567890
|
||||
+0 0.987654321
|
||||
+0 0.123456789
|
||||
+1 0.987654321
|
||||
+1 0.123456789
|
||||
+2 0.0987654321
|
||||
+2 0.0123456789
|
||||
+1 0.00000997654321
|
||||
+2 0.00000997654321
|
||||
+2 0.00987654321
|
||||
+2 0.00123456789
|
||||
+2 99.9999999999
|
||||
+16 2.22044604925031e-16
|
||||
+16 1.79769313486231e+308
|
||||
+16 2.2250738585071e-308
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
int p;
|
||||
int b;
|
||||
double f;
|
||||
|
||||
for (;;) {
|
||||
if (scanf("%d%lf", &p, &f) != 2)
|
||||
break;
|
||||
b = printf("F %.*lf\nF %#.*lf\n", p, f, p, f);
|
||||
printf("%d bytes\n", b);
|
||||
b = printf("E %.*le\nE %#.*le\n", p, f, p, f);
|
||||
printf("%d bytes\n", b);
|
||||
b = printf("G %.*lg\nG %#.*lg\n", p, f, p, f);
|
||||
printf("%d bytes\n", b);
|
||||
putchar('\n');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
o _rename.c needs help for kernel to work properly.
|
||||
o a+ with three argument open emulation may not function properly
|
||||
when several processes attempt to write to a file simultaneously.
|
||||
@@ -0,0 +1,259 @@
|
||||
EStdio Installation For Minix
|
||||
============================
|
||||
|
||||
This package provides a complete replacement for Minix stdio. It implements all
|
||||
the functions required for ANSI and POSIX 1003.1-1988 compatibility. The
|
||||
resulting code is slightly larger but considerably faster. The following are
|
||||
run times for the test programs found in the TEST subdirectory. Each program
|
||||
writes about 256k of output to /dev/null. The programs were compiled using
|
||||
Bruce Evans' bcc in 16-bit mode on a 20MHz 386.
|
||||
|
||||
EStdio Minix Stdio
|
||||
ten real 4.0 user 3.7 sys 0.1 real 11.0 user 7.2 sys 3.3
|
||||
putc real 1.0 user 0.8 sys 0.2 real 5.0 user 4.6 sys 0.2
|
||||
fputs real 2.0 user 0.9 sys 0.1 real 5.0 user 4.9 sys 0.2
|
||||
nfputs real 13.0 user 1.5 sys 11.1 real 3:18.0 user 18.5 sys 2:58.9
|
||||
fwrite real 0.0 user 0.0 sys 0.0 real 6.0 user 5.9 sys 0.1
|
||||
sprintf real 4.0 user 3.8 sys 0.0 real 11.0 user 10.7 sys 0.0
|
||||
printf real 4.0 user 3.9 sys 0.1 real 14.0 user 10.8 sys 2.9
|
||||
nprintf real 48.0 user 12.6 sys 35.1 real 3:23.0 user 21.1 sys 3:01.7
|
||||
printfs real 1.0 user 1.2 sys 0.1 real 18.0 user 9.6 sys 8.5
|
||||
putchar real 2.0 user 0.8 sys 0.1 real 5.0 user 4.4 sys 0.2
|
||||
|
||||
Site Description
|
||||
----------------
|
||||
|
||||
A site description is required for stdio to compile properly. There are two
|
||||
methods for generating this. Both methods will require you to run the
|
||||
installation script yinstall.sh.
|
||||
|
||||
The installation script is run from the INSTALL directory:
|
||||
|
||||
cd INSTALL # must be in INSTALL subdirectory
|
||||
sh yinstall.sh
|
||||
|
||||
If your site is a standard Minix site, a preconfigured description will be
|
||||
available. Respond `y' to the question regarding the use of a preconfigured
|
||||
site description and select the ack configuration.
|
||||
|
||||
If your site is not a standard Minix site, or the preconfigured site
|
||||
description is broken, you will have to run the installation script and answer
|
||||
`n' to the question about the preconfigured site description. The script will
|
||||
then attempt to determine all the parameters required to describe your site in
|
||||
order to compile stdio.
|
||||
|
||||
Prerecorded answer files are also available in files with a .ans suffix. These
|
||||
files are generated by running the installation script interactively using tee:
|
||||
|
||||
cd INSTALL
|
||||
tee machine.ans | sh yinstall.sh
|
||||
|
||||
Remember to terminate the session with a ^D after all the questions have been
|
||||
answered. The site file can be regenerated directly from the answer file by
|
||||
feeding it directly into the installation script:
|
||||
|
||||
cd INSTALL
|
||||
sh yinstall.sh < machine.ans
|
||||
|
||||
Making the Library
|
||||
------------------
|
||||
|
||||
If you have floating point support installed (Peter Housel's floating point
|
||||
library in /usr/lib/fplib.a), then you will have to make the floating point
|
||||
linkages:
|
||||
|
||||
make stdiofp
|
||||
|
||||
This will create a series of stubs and floating point support code with the
|
||||
names *.f for the *scan* and *print* functions. The main stdio code modules
|
||||
are kept in libc.a. This makes the libraries easier to maintain.
|
||||
|
||||
Now you can proceed to make the library proper:
|
||||
|
||||
make stdio
|
||||
|
||||
To begin with, I suggest that you build the stdio exercise program first. This
|
||||
is done as follows:
|
||||
|
||||
make test
|
||||
|
||||
After xercise has been constructed, it can be run by typing:
|
||||
|
||||
TEST/exercise
|
||||
|
||||
Verify that all the exercises complete successfully.
|
||||
|
||||
Installation with BCC
|
||||
---------------------
|
||||
|
||||
If you have Bruce Evans 386 kit and are working with bcc, the easiest way to
|
||||
install the library is to move the entire directory tree to
|
||||
/usr/src/lib/estdio. The makelib script should be in the directory
|
||||
/usr/src/lib/bcc.
|
||||
|
||||
You will have to edit the makelib script to activate usage of estdio.
|
||||
Furthermore I prefer to use perror() included in estdio. The following patches
|
||||
indicate the changes required to makelib:
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*** makelib.orig Sat Jul 28 11:12:48 1990
|
||||
--- makelib Sat Jul 28 11:13:34 1990
|
||||
***************
|
||||
*** 17,19 ****
|
||||
# Nonstandard library directories to be built. Comment out the lines not used.
|
||||
! # earlstdiodir=../e20 # Earl Chew's stdio
|
||||
# localdir=../local
|
||||
--- 17,19 ----
|
||||
# Nonstandard library directories to be built. Comment out the lines not used.
|
||||
! earlstdiodir=../estdio # Earl Chew's stdio
|
||||
# localdir=../local
|
||||
***************
|
||||
*** 162,163 ****
|
||||
--- 162,164 ----
|
||||
s/^gets.c$//
|
||||
+ s/^perror.c$//
|
||||
s/^printf.c$//
|
||||
***************
|
||||
*** 211,213 ****
|
||||
ar r $tmplibdir/libc.a \
|
||||
! `cat Liborder | sed -e 's/perror.o//'` ;;
|
||||
*) make $option ;;
|
||||
--- 212,214 ----
|
||||
ar r $tmplibdir/libc.a \
|
||||
! `cat Liborder` ;;
|
||||
*) make $option ;;
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
You should ensure that the new stdio.h has been installed in /usr/include:
|
||||
|
||||
mv /usr/include/stdio.h /usr/include/stdio.h.orig
|
||||
mv ../estdio/stdio.h /usr/include
|
||||
chown bin /usr/include/stdio.h
|
||||
chgrp bin /usr/include/stdio.h
|
||||
chmod 644 /usr/include/stdio.h
|
||||
|
||||
The easiest and safest way to proceed from here is to clean out the entire
|
||||
library with:
|
||||
|
||||
sh makelib [86|386] clean
|
||||
|
||||
Now you can rebuild the library to suit whichever flavour system you are
|
||||
running:
|
||||
|
||||
sh makelib [86|386]
|
||||
|
||||
Installation with ACK
|
||||
---------------------
|
||||
|
||||
If you are using the standard Minix distribution system, the easiest way to
|
||||
obtain a library is to type:
|
||||
|
||||
cd INSTALL # must be in INSTALL subdirectory
|
||||
sh yminix.sh
|
||||
|
||||
The script will use libc.a and libfp.a (if available) to generate properly
|
||||
ordered libraries. The script will ask before it touches and remakes those
|
||||
modules in the existing system library which refer to stdio.
|
||||
|
||||
The generated libraries will be left in the subdirectory INSTALL/libc. If your
|
||||
site does not match the assumptions made by this script you will either have to
|
||||
edit the script or make the library by hand.
|
||||
|
||||
It is probably wise to keep the old stdio.h so that you'll have something
|
||||
to fall back on when ast posts upgrades:
|
||||
|
||||
mv /usr/include/stdio.h /usr/include/stdio.h.orig
|
||||
|
||||
It is also wise to keep the old libraries:
|
||||
|
||||
mv /usr/lib/libc.a /usr/lib/libc.a.orig
|
||||
mv /usr/lib/fplib.a /usr/lib/fplib.a.orig
|
||||
|
||||
Now you can install the new stdio.h:
|
||||
|
||||
chown bin stdio.h
|
||||
chgrp bin stdio.h
|
||||
chmod 644 stdio.h
|
||||
mv stdio.h /usr/include
|
||||
|
||||
Finally, the libraries can be copied across:
|
||||
|
||||
chown bin libc/*.a
|
||||
chgrp bin libc/*.a
|
||||
chmod 644 libc/*.a
|
||||
mv libc/*.a /usr/lib
|
||||
|
||||
Manual Library Installation
|
||||
---------------------------
|
||||
|
||||
This section provides some information for those who cannot install stdio
|
||||
using the yminix.sh script.
|
||||
|
||||
Before stdio can be installed in the library, it is necessary to re-compile
|
||||
some of the library modules that make use of stdio. These are:
|
||||
|
||||
ansi/assert.c
|
||||
ansi/system.c
|
||||
other/curses.c
|
||||
other/getopt.c
|
||||
other/getpass.c
|
||||
other/lock.c
|
||||
other/nlist.c
|
||||
other/popen.c
|
||||
other/regexp.c
|
||||
other/regsub.c
|
||||
other/termcap.c
|
||||
posix/getlogin.c
|
||||
|
||||
The modules provided by stdio will supercede the following files in the
|
||||
Minix library:
|
||||
|
||||
ansi/exit.s
|
||||
ansi/fclose.s
|
||||
ansi/fflush.s
|
||||
ansi/fgetc.s
|
||||
ansi/fgets.s
|
||||
ansi/fopen.s
|
||||
ansi/fprintf.s
|
||||
ansi/fputc.s
|
||||
ansi/fputs.s
|
||||
ansi/fread.s
|
||||
ansi/freopen.s
|
||||
ansi/fseek.s
|
||||
ansi/ftell.s
|
||||
ansi/fwrite.s
|
||||
ansi/gets.s
|
||||
ansi/perror.s
|
||||
ansi/puts.s
|
||||
ansi/scanf.s
|
||||
ansi/setbuf.s
|
||||
ansi/sprintf.s
|
||||
ansi/tmpnam.s
|
||||
ansi/ungetc.s
|
||||
ansi/vsprintf.s
|
||||
other/cleanup.s
|
||||
other/doprintf.s
|
||||
other/printdat.s
|
||||
posix/ctermid.s
|
||||
posix/cuserid.s
|
||||
posix/fdopen.s
|
||||
|
||||
The following files supersede those in the floating point library:
|
||||
fprintf.s
|
||||
printf.s
|
||||
sprintf.s
|
||||
vfprintf.s
|
||||
vprintf.s
|
||||
vsprintf.s
|
||||
|
||||
The shell script yminix.sh will generate a library from all the components. It
|
||||
assumes that the library modules are in:
|
||||
|
||||
/usr/src/lib/ansi
|
||||
/usr/src/lib/other
|
||||
/usr/src/lib/posix
|
||||
/usr/src/lib/ibm
|
||||
/usr/lib/libc.a
|
||||
/usr/lib/fplib.a
|
||||
|
||||
--ooOoo--
|
||||
@@ -0,0 +1,46 @@
|
||||
yinstall
|
||||
========
|
||||
|
||||
You can try the yinstall script to generate the appropriate values for
|
||||
config.h. Once the script runs successfully, it should generate files
|
||||
named site.h and stdio.h. The file site.h is included in config.h. stdio.h
|
||||
should be installed in /usr/include or some such place and is also included
|
||||
in stdiolib.h. If this fails, you'll have do this manually.
|
||||
|
||||
config.h
|
||||
========
|
||||
|
||||
Environment dependent definitions should be encapsulated within this file.
|
||||
Refer to the section at the head of the file for a list of the definitions
|
||||
which control the code. The definitions themselves are taken from site.h
|
||||
which is generated by the installation script.
|
||||
|
||||
stdio.h
|
||||
=======
|
||||
|
||||
The book says that this file must be self-sufficient. This causes problems
|
||||
since stdio requires knowledge of size_t and whether to use varargs or
|
||||
stdargs.
|
||||
|
||||
The definition of size_t is wrapped within _SIZE_T. It may be necessary to wrap
|
||||
this using another name depending on the other components of the C library.
|
||||
|
||||
__STDC__ is used to control the varargs/stdargs stuff as well as the inclusion
|
||||
of prototypes.
|
||||
|
||||
(unsigned char) casting in Minix is broken. Unfortunately, stdio.h cannot
|
||||
include config.h thus the kludges for this have to be made independently of
|
||||
config.h. __STDIO_UCHAR__ defines the number of bits to mask off to get a
|
||||
int to unsigned char to int. If this is defined to be 0, then it is assumed
|
||||
that an (unsigned char) cast will work.
|
||||
|
||||
stdiolib.h
|
||||
==========
|
||||
|
||||
This sets up _all_ the maros for the stdio code. It makes use of config.h and
|
||||
stdio.h. Apart from the function prototype stuff, this file attempts to hide
|
||||
the underlying _iobuf implementation from the stdio code through the use of
|
||||
macros. This has been useful, particularly when I chose to change the _iobuf
|
||||
structure to use multiple buffer pointers instead of the usual single _ptr.
|
||||
|
||||
You shouldn't have to to modify this file at all.
|
||||
@@ -0,0 +1,17 @@
|
||||
n
|
||||
y
|
||||
ack
|
||||
|
||||
y
|
||||
y
|
||||
y
|
||||
y
|
||||
y
|
||||
n
|
||||
y
|
||||
y
|
||||
y
|
||||
n
|
||||
0
|
||||
n
|
||||
y
|
||||
@@ -0,0 +1,450 @@
|
||||
*** stdio.g Thu Jul 26 22:15:17 1990
|
||||
--- stdio.h Sun Nov 4 08:51:48 1990
|
||||
***************
|
||||
*** 21,36 ****
|
||||
*/
|
||||
|
||||
/* Site specific definitions */
|
||||
! /*+*/
|
||||
! /*efine _STDIO_P_(x)*/
|
||||
! /*efine _STDIO_VA_*/
|
||||
! /*efine _STDIO_UCHAR_*/
|
||||
! /*efine _STDIO_VA_LIST_*/
|
||||
! /*efine _STDIO_SIZE_T_*/
|
||||
! /*efine _STDIO_USIZE_T_*/
|
||||
! /*efine _STDIO_NULL*/
|
||||
! /*efine NULL*/
|
||||
! /*-*/
|
||||
|
||||
/* Definitions based on ANSI compiler */
|
||||
#ifdef __STDC__
|
||||
--- 21,36 ----
|
||||
*/
|
||||
|
||||
/* Site specific definitions */
|
||||
! /*@*/
|
||||
! #undef NULL
|
||||
! #ifndef NULL
|
||||
! # define NULL 0
|
||||
! #endif
|
||||
! #define _STDIO_UCHAR_ 0xFF
|
||||
! #define _STDIO_VA_LIST_ char *
|
||||
! #define _STDIO_SIZE_T_ unsigned int /* type returned by sizeof */
|
||||
! #define _STDIO_USIZE_T_ unsigned int
|
||||
! /*=*/
|
||||
|
||||
/* Definitions based on ANSI compiler */
|
||||
#ifdef __STDC__
|
||||
*** site.h Sun Nov 4 08:53:53 1990
|
||||
--- site.h Sun Nov 4 08:53:53 1990
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,30 ----
|
||||
+ /*efine NDEBUG*/
|
||||
+ /*efine HIDDEN*/
|
||||
+ #define NOFLOAT
|
||||
+ #define ERRLIST
|
||||
+ #define STDARG
|
||||
+ #define LIMITS
|
||||
+ /*efine CHAR_BIT*/
|
||||
+ /*efine UINT_MAX*/
|
||||
+ /*efine ULONG_MAX*/
|
||||
+ /*efine INT_MAX*/
|
||||
+ /*efine LONG_MAX*/
|
||||
+ /*efine HUGE_VAL*/
|
||||
+ /*efine UNSIGNEDCHAR*/
|
||||
+ #define MEMORY
|
||||
+ /*efine MYMEMCPY*/
|
||||
+ /*efine MYMEMCHR*/
|
||||
+ /*efine MYMEMSET*/
|
||||
+ #define STRING
|
||||
+ #define TOLOWER(c) tolower(c)
|
||||
+ #define OPEN3
|
||||
+ #define RENAME
|
||||
+ #define UNISTD
|
||||
+ /*efine MODE_T mode_t*/
|
||||
+ /*efine UID_T uid_t*/
|
||||
+ #define VOIDSIGNAL
|
||||
+ #define SYSTYPES
|
||||
+ /*efine DENORMAL*/
|
||||
+ /*efine TRUNCATE*/
|
||||
+ /*efine LMR*/
|
||||
+ /*efine POWERS*/
|
||||
*** Makefile Sun Nov 4 08:53:55 1990
|
||||
--- Makefile Sun Nov 4 08:53:55 1990
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,328 ----
|
||||
+
|
||||
+ #min _MINIX
|
||||
+ CPP =/usr/lib/cpp -P -D_MINIX
|
||||
+ FPCC =$(CC) -f
|
||||
+ CC =cc
|
||||
+ FPLD =$(LD)
|
||||
+ LD =$(CC) -i
|
||||
+ RANLIB =echo
|
||||
+ LORDER =lorder
|
||||
+ TSORT =tsort
|
||||
+
|
||||
+
|
||||
+
|
||||
+ Installdir =INSTALL/
|
||||
+ Testdir =TEST/
|
||||
+ Fptestdir =FPTEST/
|
||||
+ Define =-D_MINIX -D_POSIX_SOURCE
|
||||
+ Include =-I.
|
||||
+ Libraries =stdio.a
|
||||
+ MathLibraries =-f
|
||||
+ FPLib =stdiofp.a
|
||||
+ StdioLib =stdio.a
|
||||
+
|
||||
+ All =README *.x *.c *.g *.h \
|
||||
+ makefile.cpp makefile.nix makefile.min \
|
||||
+ $(Testdir)*.c $(Testdir)*.sh \
|
||||
+ $(Fptestdir)*.c \
|
||||
+ $(Installdir)*.c $(Installdir)*.sh \
|
||||
+ $(Installdir)*.txt $(Installdir)*.sit \
|
||||
+ $(Installdir)*.ans
|
||||
+
|
||||
+ Everyone =nix min dos
|
||||
+
|
||||
+ CFLAGS= $(Define) $(Include) -LIB -c
|
||||
+
|
||||
+ FPOBJ= \
|
||||
+ _f_cvt.s _f_fprintf.s _f_fscanf.s \
|
||||
+ _f_guard.s _f_pow10.s _f_printf.s \
|
||||
+ _f_scanf.s _f_sprintf.s _f_sscanf.s \
|
||||
+ _f_tvc.s _f_vfprintf.s _f_vprintf.s \
|
||||
+ _f_vsprintf.s
|
||||
+
|
||||
+ LIBOBJ= \
|
||||
+ _allocbuf.s _bfs.s _bread.s \
|
||||
+ _bwrite.s _err.s _errlist.s \
|
||||
+ _fgetlx.s _file.s _fopen.s \
|
||||
+ _freebuf.s _in.s _ioread.s \
|
||||
+ _iowrite.s _ipow10.s _open3.s \
|
||||
+ _os.s _out.s _rename.s \
|
||||
+ _rlbf.s _stdio.s _update.s \
|
||||
+ _utoa.s _vfprintf.s _vfscanf.s \
|
||||
+ _vscanf.s _vsscanf.s _xassert.s \
|
||||
+ _z_cvt.s _z_tvc.s _zatexit.s \
|
||||
+ _zerr.s _zout.s _zrlbf.s \
|
||||
+ _zwrapup.s atexit.s clearerr.s \
|
||||
+ ctermid.s cuserid.s exit.s \
|
||||
+ fclose.s fdopen.s feof.s \
|
||||
+ ferror.s fflush.s fgetc.s \
|
||||
+ fgetpos.s fgets.s fileno.s \
|
||||
+ fopen.s fprintf.s fputc.s \
|
||||
+ fputs.s fread.s freopen.s \
|
||||
+ fscanf.s fseek.s fsetpos.s \
|
||||
+ ftell.s fwrite.s getc.s \
|
||||
+ getchar.s gets.s getw.s \
|
||||
+ perror.s printf.s putc.s \
|
||||
+ putchar.s puts.s putw.s \
|
||||
+ remove.s rewind.s scanf.s \
|
||||
+ setbuf.s setvbuf.s sprintf.s \
|
||||
+ sscanf.s tmpfile.s tmpnam.s \
|
||||
+ ungetc.s vfprintf.s vprintf.s \
|
||||
+ vsprintf.s
|
||||
+
|
||||
+ .SUFFIXES: .s .c
|
||||
+ .c.s:
|
||||
+ $(CC) $(CFLAGS) $<
|
||||
+
|
||||
+ test:
|
||||
+ -cd $(Testdir) ; \
|
||||
+ for f in *.c ; do \
|
||||
+ n=`basename $$f .c` ; \
|
||||
+ $(CC) $(CFLAGS) -I.. $$n.c ; \
|
||||
+ $(LD) -o $$n $$n.s ../stdio.a ; \
|
||||
+ done
|
||||
+
|
||||
+ fptest:
|
||||
+ -cd $(Fptestdir) ; \
|
||||
+ for f in *.c ; do \
|
||||
+ n=`basename $$f .c` ; \
|
||||
+ $(FPCC) $(CFLAGS) -I.. $$n.c ; \
|
||||
+ $(FPLD) -o $$n $$n.s ../stdiofp.a ../stdio.a $(MathLibraries) ; \
|
||||
+ done
|
||||
+
|
||||
+ update:
|
||||
+ -if test -z "$(LIBC)" ; then \
|
||||
+ echo Usage: make update LIBC=library ; \
|
||||
+ else \
|
||||
+ ar t $(LIBC) | sed -e 's/ //g' | sort > libc.files ; \
|
||||
+ ar rv $(LIBC) `ls *.o | comm -12 - libc.files` ; \
|
||||
+ rm -f libc.files ; \
|
||||
+ $(RANLIB) $(LIBC); \
|
||||
+ fi
|
||||
+
|
||||
+ # Library dependencies
|
||||
+
|
||||
+ $(FPOBJ) $(LIBOBJ): stdiolib.h stdio.h
|
||||
+
|
||||
+ Hide: site.h
|
||||
+ rm -f Hidden
|
||||
+ -if grep -s "define HIDDEN" site.h ; then \
|
||||
+ $(CPP) stub.x >Hidden ; \
|
||||
+ for f in `grep '^.define [a-z]' hidden.h | \
|
||||
+ sed 's/^.define \([a-z]*\).*/\1/'` ; do \
|
||||
+ echo $${f} ; \
|
||||
+ sed -e "s/XYZ/$${f}/g" < Hidden > _u_$${f}.x ; \
|
||||
+ libpack < _u_$${f}.x > _u_$${f}.s ; \
|
||||
+ done ; \
|
||||
+ fi
|
||||
+ echo -n >Hide
|
||||
+
|
||||
+ # Put together a library
|
||||
+
|
||||
+ FPobjects: $(FPOBJ)
|
||||
+
|
||||
+ FPorder: $(FPOBJ) Hide
|
||||
+ echo -n >FPorder
|
||||
+ -if test -f Hidden ; then \
|
||||
+ ls _u_*print*.s _u_*scan*.s >> FPorder ; \
|
||||
+ fi
|
||||
+ ls $(FPOBJ) > FPorder.tmp
|
||||
+ $(LORDER) `cat FPorder.tmp` | $(TSORT) >> FPorder; \
|
||||
+ rm -f FPorder.tmp FPsort.tmp
|
||||
+
|
||||
+ FParchive: FPorder
|
||||
+ rm -f $(FPLib)
|
||||
+ ar cr $(FPLib) `cat FPorder`
|
||||
+ $(RANLIB) stdiofp.a
|
||||
+
|
||||
+ Liborder: $(LIBOBJ) Hide
|
||||
+ echo -n >Liborder
|
||||
+ -if test -f Hidden ; then \
|
||||
+ ls _u_*.s >> Liborder ; \
|
||||
+ fi
|
||||
+ ls $(LIBOBJ) > Liborder.tmp
|
||||
+ $(LORDER) `cat Liborder.tmp` | $(TSORT) >> Liborder; \
|
||||
+ rm -f Liborder.tmp
|
||||
+
|
||||
+ stdio $(StdioLib): Liborder
|
||||
+ rm -f $(StdioLib)
|
||||
+ ar cr $(StdioLib) `cat Liborder`
|
||||
+ $(RANLIB) stdio.a
|
||||
+
|
||||
+ stdiofp $(FPLib):
|
||||
+ $(MAKE) FPobjects "CC=$(FPCC)" "LD=$(FPLD)"
|
||||
+ $(MAKE) FParchive
|
||||
+
|
||||
+ # Pretty list of objects
|
||||
+
|
||||
+ fpfiles:
|
||||
+ ls _f_*.c | sed -e 's/\.c/.O/g' | \
|
||||
+ pr -3 -l1 -t -w60 > FPfiles
|
||||
+ sed -e 's/O *$$/O \\/' -e '$$s/ \\$$//' < FPfiles > FPfiles.new
|
||||
+ mv FPfiles.new FPfiles
|
||||
+
|
||||
+ libfiles:
|
||||
+ ls [_a-wz]*.c | sed -e '/^_f_/d' -e 's/\.c/.O/g' | \
|
||||
+ pr -3 -l1 -t -w60 > Libfiles
|
||||
+ sed -e 's/O *$$/O \\/' -e '$$s/ \\$$//' < Libfiles > Libfiles.new
|
||||
+ mv Libfiles.new Libfiles
|
||||
+
|
||||
+ # Clean
|
||||
+
|
||||
+ clean:
|
||||
+ rm -f $(LIBOBJ)
|
||||
+ rm -f $(FPOBJ)
|
||||
+ rm -f _u_*
|
||||
+ rm -f $(StdioLib) $(FPLib)
|
||||
+ rm -f $(Testdir)*.s $(Fptestdir)*.s $(Installdir)*.s
|
||||
+ for d in $(Testdir) $(Fptestdir) $(Installdir) ; do \
|
||||
+ cd $$d ; \
|
||||
+ rm -f core *.out ; \
|
||||
+ for f in *.c ; do \
|
||||
+ e=`basename $$f .c` ; \
|
||||
+ rm -f -o $$e ; \
|
||||
+ done ; \
|
||||
+ cd .. ; \
|
||||
+ done
|
||||
+ rm -f *~ core *.out *order Hid* test.dat
|
||||
+ rm -f *files *.tmp
|
||||
+ rm -f estdio.u* estdio.[01]?
|
||||
+
|
||||
+ # Site
|
||||
+
|
||||
+ site:
|
||||
+ -cdiff stdio.g stdio.h > $(Installdir)ack.sit
|
||||
+ -if test ! -f site.h ; then \
|
||||
+ echo site.h not installed ; \
|
||||
+ else \
|
||||
+ LINES=`wc -l < site.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** site.h $${DATE}" >> $(Installdir)ack.sit ; \
|
||||
+ echo "--- site.h $${DATE}" >> $(Installdir)ack.sit ; \
|
||||
+ echo "***************" >> $(Installdir)ack.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)ack.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)ack.sit ; \
|
||||
+ sed -e 's/^/+ /' < site.h >> $(Installdir)ack.sit ; \
|
||||
+ fi
|
||||
+ -if test ! -f Makefile ; then \
|
||||
+ echo Makefile not installed ; \
|
||||
+ else \
|
||||
+ LINES=`wc -l < Makefile | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** Makefile $${DATE}" >> $(Installdir)ack.sit ; \
|
||||
+ echo "--- Makefile $${DATE}" >> $(Installdir)ack.sit ; \
|
||||
+ echo "***************" >> $(Installdir)ack.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)ack.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)ack.sit ; \
|
||||
+ sed -e 's/^/+ /' < Makefile >> $(Installdir)ack.sit ; \
|
||||
+ fi
|
||||
+ -if test -s errlist.h ; then \
|
||||
+ LINES=`wc -l < errlist.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** errlist.h $${DATE}" >> $(Installdir)ack.sit ; \
|
||||
+ echo "--- errlist.h $${DATE}" >> $(Installdir)ack.sit ; \
|
||||
+ echo "***************" >> $(Installdir)ack.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)ack.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)ack.sit ; \
|
||||
+ sed -e 's/^/+ /' < errlist.h >> $(Installdir)ack.sit ; \
|
||||
+ fi
|
||||
+ -if test -s powers.h ; then \
|
||||
+ LINES=`wc -l < powers.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** powers.h $${DATE}" >> $(Installdir)ack.sit ; \
|
||||
+ echo "--- powers.h $${DATE}" >> $(Installdir)ack.sit ; \
|
||||
+ echo "***************" >> $(Installdir)ack.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)ack.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)ack.sit ; \
|
||||
+ sed -e 's/^/+ /' < powers.h >> $(Installdir)ack.sit ; \
|
||||
+ fi
|
||||
+ -if test -s lmr.h ; then \
|
||||
+ LINES=`wc -l < lmr.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** lmr.h $${DATE}" >> $(Installdir)ack.sit ; \
|
||||
+ echo "--- lmr.h $${DATE}" >> $(Installdir)ack.sit ; \
|
||||
+ echo "***************" >> $(Installdir)ack.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)ack.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)ack.sit ; \
|
||||
+ sed -e 's/^/+ /' < lmr.h >> $(Installdir)ack.sit ; \
|
||||
+ fi
|
||||
+
|
||||
+ # Distribution
|
||||
+
|
||||
+ distribution:
|
||||
+ ls $(All) | \
|
||||
+ sed -e '/^stdio\.h/d' \
|
||||
+ -e '/^site\.h/d' \
|
||||
+ -e '/^errlist\.h/d' \
|
||||
+ -e '/^powers\.h/d' \
|
||||
+ -e '/^lmr\.h/d' \
|
||||
+ -e '/^_u_/d' > files
|
||||
+
|
||||
+ # Arc
|
||||
+
|
||||
+ arc: distribution
|
||||
+ rm -f estdio.arc
|
||||
+ arc a estdio.arc @files
|
||||
+
|
||||
+ # Tar
|
||||
+
|
||||
+ tar estdio.taz: distribution
|
||||
+ rm -f estdio.taz
|
||||
+ tar cvf - `cat files` | compress -b13 > estdio.taz
|
||||
+
|
||||
+ # Distribution by tar parts
|
||||
+
|
||||
+ uu: distribution
|
||||
+ rm -f estdio.u*
|
||||
+ tar cvf - `cat files` | \
|
||||
+ compress -b13 | \
|
||||
+ uuencode estdio.taz | \
|
||||
+ split -300 - estdio.u
|
||||
+ for f in estdio.u* ; do \
|
||||
+ echo '------ Cut Here ------' > uu.tmp ; \
|
||||
+ cat $$f >> uu.tmp ; \
|
||||
+ echo '------ Cut Here ------' >> uu.tmp ; \
|
||||
+ mv uu.tmp $$f ; \
|
||||
+ done
|
||||
+
|
||||
+ # Shell archive
|
||||
+
|
||||
+ shar: distribution
|
||||
+ rm -f estdio.[0-9][0-9]*
|
||||
+ sed -e '/^site\.h/d' \
|
||||
+ -e '/^stdio\.h/d' \
|
||||
+ -e 's%.*\.x%& Assembler stub%' \
|
||||
+ -e 's%^TEST/.*%& Exercise file%' \
|
||||
+ -e 's%^FPTEST/.*%& Exercise file%' \
|
||||
+ -e 's%^INSTALL/.*\.c%& Installation file%' \
|
||||
+ -e 's%^INSTALL/.*\.sh%& Installation script%' \
|
||||
+ -e 's%^INSTALL/.*\.txt%& Documentation%' \
|
||||
+ -e 's%^INSTALL/.*\.sit%& Differences for preconfigured sites%' \
|
||||
+ -e 's%^INSTALL/.*\.ans%& Answer file for generating sites%' \
|
||||
+ -e 's%^makefile.cpp$$%& Cppmake file%' \
|
||||
+ -e 's%^makefile.[a-z]*$$%& Makefile%' \
|
||||
+ -e 's%^[0-9a-z_]*\.g$$%& Header file source%' \
|
||||
+ -e 's%^[0-9a-z_]*\.h$$%& Header file%' \
|
||||
+ -e 's%^_z.*\.c$$%& Stdio fake source code%' \
|
||||
+ -e 's%^[0-9a-z_]*\.c$$%& Stdio source code%' < files > MANIFEST
|
||||
+ shar -a -n estdio -C -b13 -c -o estdio -l 40 MANIFEST `cat files`
|
||||
+
|
||||
+ # Dust and dirt
|
||||
+
|
||||
+ lint:
|
||||
+ lint -n $(Include) $(Define) `echo $(LIBOBJ) | sed 's/\.o/.c/g'`
|
||||
+
|
||||
+ # Makefiles
|
||||
+
|
||||
+ makefiles:
|
||||
+ -for w in $(Everyone) ; do \
|
||||
+ n=`grep "^.$$w " <makefile.cpp | sed 's/^.[^ ]* //'` ; \
|
||||
+ echo $$n ; \
|
||||
+ if test _MINIX = $$n ; then \
|
||||
+ cppmake -o makefile.$$w ; \
|
||||
+ rm -f Makefile ; \
|
||||
+ cp makefile.$$w Makefile ; \
|
||||
+ else \
|
||||
+ cppmake -U_MINIX -D$$n -o makefile.$$w ; \
|
||||
+ fi ; \
|
||||
+ done
|
||||
*** errlist.h Sun Nov 4 08:53:58 1990
|
||||
--- errlist.h Sun Nov 4 08:53:58 1990
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,40 ----
|
||||
+ /* EUNKNOWN 0 */ "Unknown error",
|
||||
+ /* EPERM 1 */ "Not owner",
|
||||
+ /* ENOENT 2 */ "No such file or directory",
|
||||
+ /* ESRCH 3 */ "No such process",
|
||||
+ /* EINTR 4 */ "Interrupted system call",
|
||||
+ /* EIO 5 */ "I/O error",
|
||||
+ /* ENXIO 6 */ "No such device or address",
|
||||
+ /* E2BIG 7 */ "Arg list too long",
|
||||
+ /* ENOEXEC 8 */ "Exec format error",
|
||||
+ /* EBADF 9 */ "Bad file number",
|
||||
+ /* ECHILD 10 */ "No children",
|
||||
+ /* EAGAIN 11 */ "No more processes",
|
||||
+ /* ENOMEM 12 */ "Not enough core",
|
||||
+ /* EACCES 13 */ "Permission denied",
|
||||
+ /* EFAULT 14 */ "Bad address",
|
||||
+ /* ENOTBLK 15 */ "Block device required",
|
||||
+ /* EBUSY 16 */ "Mount device busy",
|
||||
+ /* EEXIST 17 */ "File exists",
|
||||
+ /* EXDEV 18 */ "Cross-device link",
|
||||
+ /* ENODEV 19 */ "No such device",
|
||||
+ /* ENOTDIR 20 */ "Not a directory",
|
||||
+ /* EISDIR 21 */ "Is a directory",
|
||||
+ /* EINVAL 22 */ "Invalid argument",
|
||||
+ /* ENFILE 23 */ "File table overflow",
|
||||
+ /* EMFILE 24 */ "Too many open files",
|
||||
+ /* ENOTTY 25 */ "Not a typewriter",
|
||||
+ /* ETXTBSY 26 */ "Text file busy",
|
||||
+ /* EFBIG 27 */ "File too large",
|
||||
+ /* ENOSPC 28 */ "No space left on device",
|
||||
+ /* ESPIPE 29 */ "Illegal seek",
|
||||
+ /* EROFS 30 */ "Read-only file system",
|
||||
+ /* EMLINK 31 */ "Too many links",
|
||||
+ /* EPIPE 32 */ "Broken pipe",
|
||||
+ /* EDOM 33 */ "Math argument",
|
||||
+ /* ERANGE 34 */ "Result too large",
|
||||
+ /* EDEADLK 35 */ "Resource deadlock avoided",
|
||||
+ /* ENAMETOOLONG 36 */ "Filename too long",
|
||||
+ /* ENOLCK 37 */ "No locks available",
|
||||
+ /* ENOSYS 38 */ "Function not implemented",
|
||||
+ /* ENOTEMPTY 39 */ "Directory not empty"
|
||||
@@ -0,0 +1,17 @@
|
||||
n
|
||||
y
|
||||
bcc
|
||||
makefile.nix
|
||||
y
|
||||
y
|
||||
y
|
||||
y
|
||||
y
|
||||
n
|
||||
y
|
||||
n
|
||||
3
|
||||
n
|
||||
y
|
||||
n
|
||||
y
|
||||
@@ -0,0 +1,443 @@
|
||||
*** stdio.g Thu Jul 26 22:15:17 1990
|
||||
--- stdio.h Sun Nov 4 08:42:50 1990
|
||||
***************
|
||||
*** 21,36 ****
|
||||
*/
|
||||
|
||||
/* Site specific definitions */
|
||||
! /*+*/
|
||||
! /*efine _STDIO_P_(x)*/
|
||||
! /*efine _STDIO_VA_*/
|
||||
! /*efine _STDIO_UCHAR_*/
|
||||
! /*efine _STDIO_VA_LIST_*/
|
||||
! /*efine _STDIO_SIZE_T_*/
|
||||
! /*efine _STDIO_USIZE_T_*/
|
||||
! /*efine _STDIO_NULL*/
|
||||
! /*efine NULL*/
|
||||
! /*-*/
|
||||
|
||||
/* Definitions based on ANSI compiler */
|
||||
#ifdef __STDC__
|
||||
--- 21,35 ----
|
||||
*/
|
||||
|
||||
/* Site specific definitions */
|
||||
! /*@*/
|
||||
! #ifndef NULL
|
||||
! # define NULL ((void *)0)
|
||||
! #endif
|
||||
! #define _STDIO_UCHAR_ 0
|
||||
! #define _STDIO_VA_LIST_ char *
|
||||
! #define _STDIO_SIZE_T_ unsigned int /* type returned by sizeof */
|
||||
! #define _STDIO_USIZE_T_ unsigned int
|
||||
! /*=*/
|
||||
|
||||
/* Definitions based on ANSI compiler */
|
||||
#ifdef __STDC__
|
||||
*** site.h Sun Nov 4 08:44:03 1990
|
||||
--- site.h Sun Nov 4 08:44:03 1990
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,30 ----
|
||||
+ /*efine NDEBUG*/
|
||||
+ /*efine HIDDEN*/
|
||||
+ #define NOFLOAT
|
||||
+ #define ERRLIST
|
||||
+ #define STDARG
|
||||
+ #define LIMITS
|
||||
+ /*efine CHAR_BIT*/
|
||||
+ /*efine UINT_MAX*/
|
||||
+ /*efine ULONG_MAX*/
|
||||
+ /*efine INT_MAX*/
|
||||
+ /*efine LONG_MAX*/
|
||||
+ /*efine HUGE_VAL*/
|
||||
+ #define UNSIGNEDCHAR
|
||||
+ #define MEMORY
|
||||
+ /*efine MYMEMCPY*/
|
||||
+ /*efine MYMEMCHR*/
|
||||
+ /*efine MYMEMSET*/
|
||||
+ #define STRING
|
||||
+ #define TOLOWER(c) tolower(c)
|
||||
+ #define OPEN3
|
||||
+ #define RENAME
|
||||
+ #define UNISTD
|
||||
+ /*efine MODE_T mode_t*/
|
||||
+ /*efine UID_T uid_t*/
|
||||
+ #define VOIDSIGNAL
|
||||
+ #define SYSTYPES
|
||||
+ /*efine DENORMAL*/
|
||||
+ /*efine TRUNCATE*/
|
||||
+ /*efine LMR*/
|
||||
+ /*efine POWERS*/
|
||||
*** Makefile Sun Nov 4 08:44:04 1990
|
||||
--- Makefile Sun Nov 4 08:44:04 1990
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,322 ----
|
||||
+ #nix _UNIX
|
||||
+ CPP =/usr/lib/cpp -P -I/usr/include -D_MINIX -D_POSIX_SOURCE
|
||||
+ FPCC =
|
||||
+ CC =cc -c
|
||||
+ FPLD =
|
||||
+ LD =cc -o
|
||||
+ RANLIB =:
|
||||
+ LORDER =echo
|
||||
+ TSORT =cat
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+ Installdir =INSTALL/
|
||||
+ Testdir =TEST/
|
||||
+ Fptestdir =FPTEST/
|
||||
+ Define =-D_MINIX -D_POSIX_SOURCE
|
||||
+ Include =-I.
|
||||
+ Libraries =stdio.a
|
||||
+ MathLibraries =
|
||||
+ FPLib =stdiofp.a
|
||||
+ StdioLib =stdio.a
|
||||
+
|
||||
+ All =README *.x *.c *.g *.h \
|
||||
+ makefile.cpp makefile.nix makefile.min \
|
||||
+ $(Testdir)*.c $(Testdir)*.sh \
|
||||
+ $(Fptestdir)*.c \
|
||||
+ $(Installdir)*.c $(Installdir)*.sh \
|
||||
+ $(Installdir)*.txt $(Installdir)*.sit \
|
||||
+ $(Installdir)*.ans
|
||||
+
|
||||
+ Everyone =nix min dos
|
||||
+
|
||||
+ CFLAGS= $(Define) $(Include)
|
||||
+
|
||||
+ FPOBJ= \
|
||||
+ _f_cvt.o _f_fprintf.o _f_fscanf.o \
|
||||
+ _f_guard.o _f_pow10.o _f_printf.o \
|
||||
+ _f_scanf.o _f_sprintf.o _f_sscanf.o \
|
||||
+ _f_tvc.o _f_vfprintf.o _f_vprintf.o \
|
||||
+ _f_vsprintf.o
|
||||
+
|
||||
+ LIBOBJ= \
|
||||
+ _allocbuf.o _bfs.o _bread.o \
|
||||
+ _bwrite.o _err.o _errlist.o \
|
||||
+ _fgetlx.o _file.o _fopen.o \
|
||||
+ _freebuf.o _in.o _ioread.o \
|
||||
+ _iowrite.o _ipow10.o _open3.o \
|
||||
+ _os.o _out.o _rename.o \
|
||||
+ _rlbf.o _stdio.o _update.o \
|
||||
+ _utoa.o _vfprintf.o _vfscanf.o \
|
||||
+ _vscanf.o _vsscanf.o _xassert.o \
|
||||
+ _z_cvt.o _z_tvc.o _zatexit.o \
|
||||
+ _zerr.o _zout.o _zrlbf.o \
|
||||
+ _zwrapup.o atexit.o clearerr.o \
|
||||
+ ctermid.o cuserid.o exit.o \
|
||||
+ fclose.o fdopen.o feof.o \
|
||||
+ ferror.o fflush.o fgetc.o \
|
||||
+ fgetpos.o fgets.o fileno.o \
|
||||
+ fopen.o fprintf.o fputc.o \
|
||||
+ fputs.o fread.o freopen.o \
|
||||
+ fscanf.o fseek.o fsetpos.o \
|
||||
+ ftell.o fwrite.o getc.o \
|
||||
+ getchar.o gets.o getw.o \
|
||||
+ perror.o printf.o putc.o \
|
||||
+ putchar.o puts.o putw.o \
|
||||
+ remove.o rewind.o scanf.o \
|
||||
+ setbuf.o setvbuf.o sprintf.o \
|
||||
+ sscanf.o tmpfile.o tmpnam.o \
|
||||
+ ungetc.o vfprintf.o vprintf.o \
|
||||
+ vsprintf.o
|
||||
+
|
||||
+ .SUFFIXES: .o .c
|
||||
+ .c.o:
|
||||
+ $(CC) $(CFLAGS) $<
|
||||
+
|
||||
+ test:
|
||||
+ -cd $(Testdir) ; \
|
||||
+ for f in *.c ; do \
|
||||
+ n=`basename $$f .c` ; \
|
||||
+ $(CC) $(CFLAGS) -I.. $$n.c ; \
|
||||
+ $(LD) $$n $$n.o ../stdio.a ; \
|
||||
+ done
|
||||
+
|
||||
+ fptest:
|
||||
+ -cd $(Fptestdir) ; \
|
||||
+ for f in *.c ; do \
|
||||
+ n=`basename $$f .c` ; \
|
||||
+ $(FPCC) $(CFLAGS) -I.. $$n.c ; \
|
||||
+ $(FPLD) $$n $$n.o ../stdiofp.a ../stdio.a $(MathLibraries) ; \
|
||||
+ done
|
||||
+
|
||||
+ update:
|
||||
+ -if test -z "$(LIBC)" ; then \
|
||||
+ echo Usage: make update LIBC=library ; \
|
||||
+ else \
|
||||
+ ar t $(LIBC) | sed -e 's/ //g' | sort > libc.files ; \
|
||||
+ ar rv $(LIBC) `ls *.o | comm -12 - libc.files` ; \
|
||||
+ rm -f libc.files ; \
|
||||
+ $(RANLIB) $(LIBC); \
|
||||
+ fi
|
||||
+
|
||||
+ # Library dependencies
|
||||
+
|
||||
+ $(FPOBJ) $(LIBOBJ): stdiolib.h stdio.h
|
||||
+
|
||||
+ Hide: site.h
|
||||
+ rm -f Hidden
|
||||
+ -if grep -s "define HIDDEN" site.h ; then \
|
||||
+ $(CPP) stub.x >Hidden ; \
|
||||
+ for f in `grep '^.define [a-z]' hidden.h | \
|
||||
+ sed 's/^.define \([a-z]*\).*/\1/'` ; do \
|
||||
+ echo $${f} ; \
|
||||
+ sed -e "s/XYZ/$${f}/g" < Hidden > _u_$${f}.s ; \
|
||||
+ as -o _u_$${f}.o _u_$${f}.s ; \
|
||||
+ done ; \
|
||||
+ fi
|
||||
+ echo -n >Hide
|
||||
+
|
||||
+ # Put together a library
|
||||
+
|
||||
+ FPobjects: $(FPOBJ)
|
||||
+
|
||||
+ FPorder: $(FPOBJ) Hide
|
||||
+ echo -n >FPorder
|
||||
+ -if test -f Hidden ; then \
|
||||
+ ls _u_*print*.o _u_*scan*.o >> FPorder ; \
|
||||
+ fi
|
||||
+ ls $(FPOBJ) > FPorder.tmp
|
||||
+ $(LORDER) `cat FPorder.tmp` | $(TSORT) >> FPorder; \
|
||||
+ rm -f FPorder.tmp FPsort.tmp
|
||||
+
|
||||
+ FParchive: FPorder
|
||||
+ rm -f $(FPLib)
|
||||
+ ar cr $(FPLib) `cat FPorder`
|
||||
+ $(RANLIB) stdiofp.a
|
||||
+
|
||||
+ Liborder: $(LIBOBJ) Hide
|
||||
+ echo -n >Liborder
|
||||
+ -if test -f Hidden ; then \
|
||||
+ ls _u_*.o >> Liborder ; \
|
||||
+ fi
|
||||
+ ls $(LIBOBJ) > Liborder.tmp
|
||||
+ $(LORDER) `cat Liborder.tmp` | $(TSORT) >> Liborder; \
|
||||
+ rm -f Liborder.tmp
|
||||
+
|
||||
+ stdio $(StdioLib): Liborder
|
||||
+ rm -f $(StdioLib)
|
||||
+ ar cr $(StdioLib) `cat Liborder`
|
||||
+ $(RANLIB) stdio.a
|
||||
+
|
||||
+ stdiofp $(FPLib):
|
||||
+ $(MAKE) FPobjects "CC=$(FPCC)" "LD=$(FPLD)"
|
||||
+ $(MAKE) FParchive
|
||||
+
|
||||
+ # Pretty list of objects
|
||||
+
|
||||
+ fpfiles:
|
||||
+ ls _f_*.c | sed -e 's/\.c/.O/g' | \
|
||||
+ pr -3 -l1 -t -w60 > FPfiles
|
||||
+ sed -e 's/O *$$/O \\/' -e '$$s/ \\$$//' < FPfiles > FPfiles.new
|
||||
+ mv FPfiles.new FPfiles
|
||||
+
|
||||
+ libfiles:
|
||||
+ ls [_a-wz]*.c | sed -e '/^_f_/d' -e 's/\.c/.O/g' | \
|
||||
+ pr -3 -l1 -t -w60 > Libfiles
|
||||
+ sed -e 's/O *$$/O \\/' -e '$$s/ \\$$//' < Libfiles > Libfiles.new
|
||||
+ mv Libfiles.new Libfiles
|
||||
+
|
||||
+ # Clean
|
||||
+
|
||||
+ clean:
|
||||
+ rm -f $(LIBOBJ)
|
||||
+ rm -f $(FPOBJ)
|
||||
+ rm -f _u_*
|
||||
+ rm -f $(StdioLib) $(FPLib)
|
||||
+ rm -f $(Testdir)*.o $(Fptestdir)*.o $(Installdir)*.o
|
||||
+ for d in $(Testdir) $(Fptestdir) $(Installdir) ; do \
|
||||
+ cd $$d ; \
|
||||
+ rm -f core *.out ; \
|
||||
+ for f in *.c ; do \
|
||||
+ e=`basename $$f .c` ; \
|
||||
+ rm -f $$e ; \
|
||||
+ done ; \
|
||||
+ cd .. ; \
|
||||
+ done
|
||||
+ rm -f *~ core *.out *order Hid* test.dat
|
||||
+ rm -f *files *.tmp
|
||||
+ rm -f estdio.u* estdio.[01]?
|
||||
+
|
||||
+ # Site
|
||||
+
|
||||
+ site:
|
||||
+ -cdiff stdio.g stdio.h > $(Installdir)bcc.sit
|
||||
+ -if test ! -f site.h ; then \
|
||||
+ echo site.h not installed ; \
|
||||
+ else \
|
||||
+ LINES=`wc -l < site.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** site.h $${DATE}" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "--- site.h $${DATE}" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "***************" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)bcc.sit ; \
|
||||
+ sed -e 's/^/+ /' < site.h >> $(Installdir)bcc.sit ; \
|
||||
+ fi
|
||||
+ -if test ! -f Makefile ; then \
|
||||
+ echo Makefile not installed ; \
|
||||
+ else \
|
||||
+ LINES=`wc -l < Makefile | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** Makefile $${DATE}" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "--- Makefile $${DATE}" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "***************" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)bcc.sit ; \
|
||||
+ sed -e 's/^/+ /' < Makefile >> $(Installdir)bcc.sit ; \
|
||||
+ fi
|
||||
+ -if test -s errlist.h ; then \
|
||||
+ LINES=`wc -l < errlist.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** errlist.h $${DATE}" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "--- errlist.h $${DATE}" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "***************" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)bcc.sit ; \
|
||||
+ sed -e 's/^/+ /' < errlist.h >> $(Installdir)bcc.sit ; \
|
||||
+ fi
|
||||
+ -if test -s powers.h ; then \
|
||||
+ LINES=`wc -l < powers.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** powers.h $${DATE}" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "--- powers.h $${DATE}" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "***************" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)bcc.sit ; \
|
||||
+ sed -e 's/^/+ /' < powers.h >> $(Installdir)bcc.sit ; \
|
||||
+ fi
|
||||
+ -if test -s lmr.h ; then \
|
||||
+ LINES=`wc -l < lmr.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** lmr.h $${DATE}" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "--- lmr.h $${DATE}" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "***************" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)bcc.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)bcc.sit ; \
|
||||
+ sed -e 's/^/+ /' < lmr.h >> $(Installdir)bcc.sit ; \
|
||||
+ fi
|
||||
+
|
||||
+ # Distribution
|
||||
+
|
||||
+ distribution:
|
||||
+ ls $(All) | \
|
||||
+ sed -e '/^stdio\.h/d' \
|
||||
+ -e '/^site\.h/d' \
|
||||
+ -e '/^errlist\.h/d' \
|
||||
+ -e '/^powers\.h/d' \
|
||||
+ -e '/^lmr\.h/d' \
|
||||
+ -e '/^_u_/d' > files
|
||||
+
|
||||
+ # Arc
|
||||
+
|
||||
+ arc: distribution
|
||||
+ rm -f estdio.arc
|
||||
+ arc a estdio.arc @files
|
||||
+
|
||||
+ # Tar
|
||||
+
|
||||
+ tar estdio.taz: distribution
|
||||
+ rm -f estdio.taz
|
||||
+ tar cvf - `cat files` | compress -b13 > estdio.taz
|
||||
+
|
||||
+ # Distribution by tar parts
|
||||
+
|
||||
+ uu: distribution
|
||||
+ rm -f estdio.u*
|
||||
+ tar cvf - `cat files` | \
|
||||
+ compress -b13 | \
|
||||
+ uuencode estdio.taz | \
|
||||
+ split -300 - estdio.u
|
||||
+ for f in estdio.u* ; do \
|
||||
+ echo '------ Cut Here ------' > uu.tmp ; \
|
||||
+ cat $$f >> uu.tmp ; \
|
||||
+ echo '------ Cut Here ------' >> uu.tmp ; \
|
||||
+ mv uu.tmp $$f ; \
|
||||
+ done
|
||||
+
|
||||
+ # Shell archive
|
||||
+
|
||||
+ shar: distribution
|
||||
+ rm -f estdio.[0-9][0-9]*
|
||||
+ sed -e '/^site\.h/d' \
|
||||
+ -e '/^stdio\.h/d' \
|
||||
+ -e 's%.*\.x%& Assembler stub%' \
|
||||
+ -e 's%^TEST/.*%& Exercise file%' \
|
||||
+ -e 's%^FPTEST/.*%& Exercise file%' \
|
||||
+ -e 's%^INSTALL/.*\.c%& Installation file%' \
|
||||
+ -e 's%^INSTALL/.*\.sh%& Installation script%' \
|
||||
+ -e 's%^INSTALL/.*\.txt%& Documentation%' \
|
||||
+ -e 's%^INSTALL/.*\.sit%& Differences for preconfigured sites%' \
|
||||
+ -e 's%^INSTALL/.*\.ans%& Answer file for generating sites%' \
|
||||
+ -e 's%^makefile.cpp$$%& Cppmake file%' \
|
||||
+ -e 's%^makefile.[a-z]*$$%& Makefile%' \
|
||||
+ -e 's%^[0-9a-z_]*\.g$$%& Header file source%' \
|
||||
+ -e 's%^[0-9a-z_]*\.h$$%& Header file%' \
|
||||
+ -e 's%^_z.*\.c$$%& Stdio fake source code%' \
|
||||
+ -e 's%^[0-9a-z_]*\.c$$%& Stdio source code%' < files > MANIFEST
|
||||
+ shar -a -n estdio -C -b13 -c -o estdio -l 40 MANIFEST `cat files`
|
||||
+
|
||||
+ # Dust and dirt
|
||||
+
|
||||
+ lint:
|
||||
+ lint -n $(Include) $(Define) `echo $(LIBOBJ) | sed 's/\.o/.c/g'`
|
||||
+
|
||||
+ # Makefiles
|
||||
+
|
||||
+ makefiles:
|
||||
+ -for w in $(Everyone) ; do \
|
||||
+ n=`grep "^.$$w " <makefile.cpp | sed 's/^.[^ ]* //'` ; \
|
||||
+ echo $$n ; \
|
||||
+ cppmake -D$$n -o makefile.$$w ; \
|
||||
+ done
|
||||
*** errlist.h Sun Nov 4 08:44:05 1990
|
||||
--- errlist.h Sun Nov 4 08:44:05 1990
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,40 ----
|
||||
+ /* EUNKNOWN 0 */ "Unknown error",
|
||||
+ /* EPERM 1 */ "Not owner",
|
||||
+ /* ENOENT 2 */ "No such file or directory",
|
||||
+ /* ESRCH 3 */ "No such process",
|
||||
+ /* EINTR 4 */ "Interrupted system call",
|
||||
+ /* EIO 5 */ "I/O error",
|
||||
+ /* ENXIO 6 */ "No such device or address",
|
||||
+ /* E2BIG 7 */ "Arg list too long",
|
||||
+ /* ENOEXEC 8 */ "Exec format error",
|
||||
+ /* EBADF 9 */ "Bad file number",
|
||||
+ /* ECHILD 10 */ "No children",
|
||||
+ /* EAGAIN 11 */ "No more processes",
|
||||
+ /* ENOMEM 12 */ "Not enough core",
|
||||
+ /* EACCES 13 */ "Permission denied",
|
||||
+ /* EFAULT 14 */ "Bad address",
|
||||
+ /* ENOTBLK 15 */ "Block device required",
|
||||
+ /* EBUSY 16 */ "Mount device busy",
|
||||
+ /* EEXIST 17 */ "File exists",
|
||||
+ /* EXDEV 18 */ "Cross-device link",
|
||||
+ /* ENODEV 19 */ "No such device",
|
||||
+ /* ENOTDIR 20 */ "Not a directory",
|
||||
+ /* EISDIR 21 */ "Is a directory",
|
||||
+ /* EINVAL 22 */ "Invalid argument",
|
||||
+ /* ENFILE 23 */ "File table overflow",
|
||||
+ /* EMFILE 24 */ "Too many open files",
|
||||
+ /* ENOTTY 25 */ "Not a typewriter",
|
||||
+ /* ETXTBSY 26 */ "Text file busy",
|
||||
+ /* EFBIG 27 */ "File too large",
|
||||
+ /* ENOSPC 28 */ "No space left on device",
|
||||
+ /* ESPIPE 29 */ "Illegal seek",
|
||||
+ /* EROFS 30 */ "Read-only file system",
|
||||
+ /* EMLINK 31 */ "Too many links",
|
||||
+ /* EPIPE 32 */ "Broken pipe",
|
||||
+ /* EDOM 33 */ "Math argument",
|
||||
+ /* ERANGE 34 */ "Result too large",
|
||||
+ /* EDEADLK 35 */ "Resource deadlock avoided",
|
||||
+ /* ENAMETOOLONG 36 */ "Filename too long",
|
||||
+ /* ENOLCK 37 */ "No locks available",
|
||||
+ /* ENOSYS 38 */ "Function not implemented",
|
||||
+ /* ENOTEMPTY 39 */ "Directory not empty"
|
||||
@@ -0,0 +1,5 @@
|
||||
ack Minix compiler environment
|
||||
bcc Minix with bcc
|
||||
tcc TurboC cross compiler environment for Minix
|
||||
pyr Pyramid bsd environment
|
||||
sun Sun bsd environment
|
||||
@@ -0,0 +1,24 @@
|
||||
n
|
||||
y
|
||||
sun
|
||||
|
||||
n
|
||||
/postg/cechew/gcc/sol/usr/include
|
||||
n
|
||||
/postg/cechew/gcc/sol/usr/lib/gcc-cpp -P
|
||||
n
|
||||
gcc -o
|
||||
n
|
||||
gcc -ansi -pedantic -Wall -o
|
||||
y
|
||||
y
|
||||
y
|
||||
y
|
||||
y
|
||||
y
|
||||
n
|
||||
-D_SUN -D_POSIX_SOURCE -D_BSD -DMAXFLOAT=99.e999
|
||||
y
|
||||
y
|
||||
n
|
||||
y
|
||||
@@ -0,0 +1,577 @@
|
||||
*** stdio.g Fri Jul 27 08:15:17 1990
|
||||
--- stdio.h Tue Nov 6 15:59:00 1990
|
||||
***************
|
||||
*** 21,36 ****
|
||||
*/
|
||||
|
||||
/* Site specific definitions */
|
||||
! /*+*/
|
||||
! /*efine _STDIO_P_(x)*/
|
||||
! /*efine _STDIO_VA_*/
|
||||
! /*efine _STDIO_UCHAR_*/
|
||||
! /*efine _STDIO_VA_LIST_*/
|
||||
! /*efine _STDIO_SIZE_T_*/
|
||||
! /*efine _STDIO_USIZE_T_*/
|
||||
! /*efine _STDIO_NULL*/
|
||||
! /*efine NULL*/
|
||||
! /*-*/
|
||||
|
||||
/* Definitions based on ANSI compiler */
|
||||
#ifdef __STDC__
|
||||
--- 21,35 ----
|
||||
*/
|
||||
|
||||
/* Site specific definitions */
|
||||
! /*@*/
|
||||
! #ifndef NULL
|
||||
! # define NULL ((void *)0)
|
||||
! #endif
|
||||
! #define _STDIO_UCHAR_ 0
|
||||
! #define _STDIO_VA_LIST_ char *
|
||||
! #define _STDIO_SIZE_T_ int
|
||||
! #define _STDIO_USIZE_T_ unsigned int
|
||||
! /*=*/
|
||||
|
||||
/* Definitions based on ANSI compiler */
|
||||
#ifdef __STDC__
|
||||
*** site.h Tue Nov 6 16:03:54 EST 1990
|
||||
--- site.h Tue Nov 6 16:03:54 EST 1990
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,41 ----
|
||||
+ /*efine NDEBUG*/
|
||||
+ /*efine HIDDEN*/
|
||||
+ /*efine NOFLOAT*/
|
||||
+ /*efine ERRLIST*/
|
||||
+ #define STDARG
|
||||
+ #define LIMITS
|
||||
+ #define FLOAT
|
||||
+ /*efine DBL_DIG*/
|
||||
+ #define LDBL_DIG 15
|
||||
+ /*efine DBL_MAX_10_EXP*/
|
||||
+ #define LDBL_MAX_10_EXP 308
|
||||
+ #define LDBL_MAX 1.79769313486232e+308
|
||||
+ /*efine DBL_MAX*/
|
||||
+ /*efine FLT_RADIX*/
|
||||
+ #define HUGE_VAL HUGE
|
||||
+ #define UNSIGNEDCHAR
|
||||
+ #include <memory.h>
|
||||
+ #define MEMORY
|
||||
+ /*efine MYMEMCPY*/
|
||||
+ /*efine MYMEMCHR*/
|
||||
+ /*efine MYMEMSET*/
|
||||
+ #define STRING
|
||||
+ #define TOLOWER(c) (isupper((c))?tolower((c)):(c))
|
||||
+ #define OPEN3
|
||||
+ #define RENAME
|
||||
+ /*efine UNISTD*/
|
||||
+ #define STDIN_FILENO 0
|
||||
+ #define STDOUT_FILENO 1
|
||||
+ #define STDERR_FILENO 2
|
||||
+ /*efine MODE_T mode_t*/
|
||||
+ /*efine UID_T uid_t*/
|
||||
+ /*efine VOIDSIGNAL*/
|
||||
+ #define SYSTYPES
|
||||
+ typedef int pid_t; /* best guess */
|
||||
+ typedef int uid_t; /* best guess */
|
||||
+ typedef int mode_t; /* best guess */
|
||||
+ #define _SIZE_T
|
||||
+ #define DENORMAL
|
||||
+ #define TRUNCATE
|
||||
+ #define LMR
|
||||
+ #define POWERS
|
||||
*** Makefile Tue Nov 6 16:03:56 EST 1990
|
||||
--- Makefile Tue Nov 6 16:03:56 EST 1990
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,322 ----
|
||||
+ #nix _UNIX
|
||||
+ CPP =/postg/cechew/gcc/sol/usr/lib/gcc-cpp -P -D_SUN -D_POSIX_SOURCE -D_BSD -DMAXFLOAT=99.e999
|
||||
+ FPCC =gcc -ansi -pedantic -Wall -c
|
||||
+ CC =gcc -ansi -pedantic -Wall -c
|
||||
+ FPLD =gcc -ansi -pedantic -Wall -o
|
||||
+ LD =gcc -ansi -pedantic -Wall -o
|
||||
+ RANLIB =ranlib
|
||||
+ LORDER =echo
|
||||
+ TSORT =cat
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+ Installdir =INSTALL/
|
||||
+ Testdir =TEST/
|
||||
+ Fptestdir =FPTEST/
|
||||
+ Define =-D_SUN -D_POSIX_SOURCE -D_BSD -DMAXFLOAT=99.e999
|
||||
+ Include =-I.
|
||||
+ Libraries =stdio.a
|
||||
+ MathLibraries =-lm
|
||||
+ FPLib =stdiofp.a
|
||||
+ StdioLib =stdio.a
|
||||
+
|
||||
+ All =README *.x *.c *.g *.h \
|
||||
+ makefile.cpp makefile.nix makefile.min \
|
||||
+ $(Testdir)*.c $(Testdir)*.sh \
|
||||
+ $(Fptestdir)*.c \
|
||||
+ $(Installdir)*.c $(Installdir)*.sh \
|
||||
+ $(Installdir)*.txt $(Installdir)*.sit \
|
||||
+ $(Installdir)*.ans
|
||||
+
|
||||
+ Everyone =nix min dos
|
||||
+
|
||||
+ CFLAGS= $(Define) $(Include)
|
||||
+
|
||||
+ FPOBJ= \
|
||||
+ _f_cvt.o _f_fprintf.o _f_fscanf.o \
|
||||
+ _f_guard.o _f_pow10.o _f_printf.o \
|
||||
+ _f_scanf.o _f_sprintf.o _f_sscanf.o \
|
||||
+ _f_tvc.o _f_vfprintf.o _f_vprintf.o \
|
||||
+ _f_vsprintf.o
|
||||
+
|
||||
+ LIBOBJ= \
|
||||
+ _allocbuf.o _bfs.o _bread.o \
|
||||
+ _bwrite.o _err.o _errlist.o \
|
||||
+ _fgetlx.o _file.o _fopen.o \
|
||||
+ _freebuf.o _in.o _ioread.o \
|
||||
+ _iowrite.o _ipow10.o _open3.o \
|
||||
+ _os.o _out.o _rename.o \
|
||||
+ _rlbf.o _stdio.o _update.o \
|
||||
+ _utoa.o _vfprintf.o _vfscanf.o \
|
||||
+ _vscanf.o _vsscanf.o _xassert.o \
|
||||
+ _z_cvt.o _z_tvc.o _zatexit.o \
|
||||
+ _zerr.o _zout.o _zrlbf.o \
|
||||
+ _zwrapup.o atexit.o clearerr.o \
|
||||
+ ctermid.o cuserid.o exit.o \
|
||||
+ fclose.o fdopen.o feof.o \
|
||||
+ ferror.o fflush.o fgetc.o \
|
||||
+ fgetpos.o fgets.o fileno.o \
|
||||
+ fopen.o fprintf.o fputc.o \
|
||||
+ fputs.o fread.o freopen.o \
|
||||
+ fscanf.o fseek.o fsetpos.o \
|
||||
+ ftell.o fwrite.o getc.o \
|
||||
+ getchar.o gets.o getw.o \
|
||||
+ perror.o printf.o putc.o \
|
||||
+ putchar.o puts.o putw.o \
|
||||
+ remove.o rewind.o scanf.o \
|
||||
+ setbuf.o setvbuf.o sprintf.o \
|
||||
+ sscanf.o tmpfile.o tmpnam.o \
|
||||
+ ungetc.o vfprintf.o vprintf.o \
|
||||
+ vsprintf.o
|
||||
+
|
||||
+ .SUFFIXES: .o .c
|
||||
+ .c.o:
|
||||
+ $(CC) $(CFLAGS) $<
|
||||
+
|
||||
+ test:
|
||||
+ -cd $(Testdir) ; \
|
||||
+ for f in *.c ; do \
|
||||
+ n=`basename $$f .c` ; \
|
||||
+ $(CC) $(CFLAGS) -I.. $$n.c ; \
|
||||
+ $(LD) $$n $$n.o ../stdio.a ; \
|
||||
+ done
|
||||
+
|
||||
+ fptest:
|
||||
+ -cd $(Fptestdir) ; \
|
||||
+ for f in *.c ; do \
|
||||
+ n=`basename $$f .c` ; \
|
||||
+ $(FPCC) $(CFLAGS) -I.. $$n.c ; \
|
||||
+ $(FPLD) $$n $$n.o ../stdiofp.a ../stdio.a $(MathLibraries) ; \
|
||||
+ done
|
||||
+
|
||||
+ update:
|
||||
+ -if test -z "$(LIBC)" ; then \
|
||||
+ echo Usage: make update LIBC=library ; \
|
||||
+ else \
|
||||
+ ar t $(LIBC) | sed -e 's/ //g' | sort > libc.files ; \
|
||||
+ ar rv $(LIBC) `ls *.o | comm -12 - libc.files` ; \
|
||||
+ rm -f libc.files ; \
|
||||
+ $(RANLIB) $(LIBC); \
|
||||
+ fi
|
||||
+
|
||||
+ # Library dependencies
|
||||
+
|
||||
+ $(FPOBJ) $(LIBOBJ): stdiolib.h stdio.h
|
||||
+
|
||||
+ Hide: site.h
|
||||
+ rm -f Hidden
|
||||
+ -if grep -s "define HIDDEN" site.h ; then \
|
||||
+ $(CPP) stub.x >Hidden ; \
|
||||
+ for f in `grep '^.define [a-z]' hidden.h | \
|
||||
+ sed 's/^.define \([a-z]*\).*/\1/'` ; do \
|
||||
+ echo $${f} ; \
|
||||
+ sed -e "s/XYZ/$${f}/g" < Hidden > _u_$${f}.s ; \
|
||||
+ as -o _u_$${f}.o _u_$${f}.s ; \
|
||||
+ done ; \
|
||||
+ fi
|
||||
+ echo -n >Hide
|
||||
+
|
||||
+ # Put together a library
|
||||
+
|
||||
+ FPobjects: $(FPOBJ)
|
||||
+
|
||||
+ FPorder: $(FPOBJ) Hide
|
||||
+ echo -n >FPorder
|
||||
+ -if test -f Hidden ; then \
|
||||
+ ls _u_*print*.o _u_*scan*.o >> FPorder ; \
|
||||
+ fi
|
||||
+ ls $(FPOBJ) > FPorder.tmp
|
||||
+ $(LORDER) `cat FPorder.tmp` | $(TSORT) >> FPorder; \
|
||||
+ rm -f FPorder.tmp FPsort.tmp
|
||||
+
|
||||
+ FParchive: FPorder
|
||||
+ rm -f $(FPLib)
|
||||
+ ar cr $(FPLib) `cat FPorder`
|
||||
+ $(RANLIB) stdiofp.a
|
||||
+
|
||||
+ Liborder: $(LIBOBJ) Hide
|
||||
+ echo -n >Liborder
|
||||
+ -if test -f Hidden ; then \
|
||||
+ ls _u_*.o >> Liborder ; \
|
||||
+ fi
|
||||
+ ls $(LIBOBJ) > Liborder.tmp
|
||||
+ $(LORDER) `cat Liborder.tmp` | $(TSORT) >> Liborder; \
|
||||
+ rm -f Liborder.tmp
|
||||
+
|
||||
+ stdio $(StdioLib): Liborder
|
||||
+ rm -f $(StdioLib)
|
||||
+ ar cr $(StdioLib) `cat Liborder`
|
||||
+ $(RANLIB) stdio.a
|
||||
+
|
||||
+ stdiofp $(FPLib):
|
||||
+ $(MAKE) FPobjects "CC=$(FPCC)" "LD=$(FPLD)"
|
||||
+ $(MAKE) FParchive
|
||||
+
|
||||
+ # Pretty list of objects
|
||||
+
|
||||
+ fpfiles:
|
||||
+ ls _f_*.c | sed -e 's/\.c/.O/g' | \
|
||||
+ pr -3 -l1 -t -w60 > FPfiles
|
||||
+ sed -e 's/O *$$/O \\/' -e '$$s/ \\$$//' < FPfiles > FPfiles.new
|
||||
+ mv FPfiles.new FPfiles
|
||||
+
|
||||
+ libfiles:
|
||||
+ ls [_a-wz]*.c | sed -e '/^_f_/d' -e 's/\.c/.O/g' | \
|
||||
+ pr -3 -l1 -t -w60 > Libfiles
|
||||
+ sed -e 's/O *$$/O \\/' -e '$$s/ \\$$//' < Libfiles > Libfiles.new
|
||||
+ mv Libfiles.new Libfiles
|
||||
+
|
||||
+ # Clean
|
||||
+
|
||||
+ clean:
|
||||
+ rm -f $(LIBOBJ)
|
||||
+ rm -f $(FPOBJ)
|
||||
+ rm -f _u_*
|
||||
+ rm -f $(StdioLib) $(FPLib)
|
||||
+ rm -f $(Testdir)*.o $(Fptestdir)*.o $(Installdir)*.o
|
||||
+ for d in $(Testdir) $(Fptestdir) $(Installdir) ; do \
|
||||
+ cd $$d ; \
|
||||
+ rm -f core *.out ; \
|
||||
+ for f in *.c ; do \
|
||||
+ e=`basename $$f .c` ; \
|
||||
+ rm -f $$e ; \
|
||||
+ done ; \
|
||||
+ cd .. ; \
|
||||
+ done
|
||||
+ rm -f *~ core *.out *order Hid* test.dat
|
||||
+ rm -f *files *.tmp
|
||||
+ rm -f estdio.u* estdio.[01]?
|
||||
+
|
||||
+ # Site
|
||||
+
|
||||
+ site:
|
||||
+ -diff -c stdio.g stdio.h > $(Installdir)sun.sit
|
||||
+ -if test ! -f site.h ; then \
|
||||
+ echo site.h not installed ; \
|
||||
+ else \
|
||||
+ LINES=`wc -l < site.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** site.h $${DATE}" >> $(Installdir)sun.sit ; \
|
||||
+ echo "--- site.h $${DATE}" >> $(Installdir)sun.sit ; \
|
||||
+ echo "***************" >> $(Installdir)sun.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)sun.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)sun.sit ; \
|
||||
+ sed -e 's/^/+ /' < site.h >> $(Installdir)sun.sit ; \
|
||||
+ fi
|
||||
+ -if test ! -f Makefile ; then \
|
||||
+ echo Makefile not installed ; \
|
||||
+ else \
|
||||
+ LINES=`wc -l < Makefile | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** Makefile $${DATE}" >> $(Installdir)sun.sit ; \
|
||||
+ echo "--- Makefile $${DATE}" >> $(Installdir)sun.sit ; \
|
||||
+ echo "***************" >> $(Installdir)sun.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)sun.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)sun.sit ; \
|
||||
+ sed -e 's/^/+ /' < Makefile >> $(Installdir)sun.sit ; \
|
||||
+ fi
|
||||
+ -if test -s errlist.h ; then \
|
||||
+ LINES=`wc -l < errlist.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** errlist.h $${DATE}" >> $(Installdir)sun.sit ; \
|
||||
+ echo "--- errlist.h $${DATE}" >> $(Installdir)sun.sit ; \
|
||||
+ echo "***************" >> $(Installdir)sun.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)sun.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)sun.sit ; \
|
||||
+ sed -e 's/^/+ /' < errlist.h >> $(Installdir)sun.sit ; \
|
||||
+ fi
|
||||
+ -if test -s powers.h ; then \
|
||||
+ LINES=`wc -l < powers.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** powers.h $${DATE}" >> $(Installdir)sun.sit ; \
|
||||
+ echo "--- powers.h $${DATE}" >> $(Installdir)sun.sit ; \
|
||||
+ echo "***************" >> $(Installdir)sun.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)sun.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)sun.sit ; \
|
||||
+ sed -e 's/^/+ /' < powers.h >> $(Installdir)sun.sit ; \
|
||||
+ fi
|
||||
+ -if test -s lmr.h ; then \
|
||||
+ LINES=`wc -l < lmr.h | sed 's/ //g'` ; \
|
||||
+ DATE=`date` ; \
|
||||
+ echo "*** lmr.h $${DATE}" >> $(Installdir)sun.sit ; \
|
||||
+ echo "--- lmr.h $${DATE}" >> $(Installdir)sun.sit ; \
|
||||
+ echo "***************" >> $(Installdir)sun.sit ; \
|
||||
+ echo "*** 0 ****" >> $(Installdir)sun.sit ; \
|
||||
+ echo "--- 1,$${LINES} ----" >> $(Installdir)sun.sit ; \
|
||||
+ sed -e 's/^/+ /' < lmr.h >> $(Installdir)sun.sit ; \
|
||||
+ fi
|
||||
+
|
||||
+ # Distribution
|
||||
+
|
||||
+ distribution:
|
||||
+ ls $(All) | \
|
||||
+ sed -e '/^stdio\.h/d' \
|
||||
+ -e '/^site\.h/d' \
|
||||
+ -e '/^errlist\.h/d' \
|
||||
+ -e '/^powers\.h/d' \
|
||||
+ -e '/^lmr\.h/d' \
|
||||
+ -e '/^_u_/d' > files
|
||||
+
|
||||
+ # Arc
|
||||
+
|
||||
+ arc: distribution
|
||||
+ rm -f estdio.arc
|
||||
+ arc a estdio.arc @files
|
||||
+
|
||||
+ # Tar
|
||||
+
|
||||
+ tar estdio.taz: distribution
|
||||
+ rm -f estdio.taz
|
||||
+ tar cvf - `cat files` | compress -b13 > estdio.taz
|
||||
+
|
||||
+ # Distribution by tar parts
|
||||
+
|
||||
+ uu: distribution
|
||||
+ rm -f estdio.u*
|
||||
+ tar cvf - `cat files` | \
|
||||
+ compress -b13 | \
|
||||
+ uuencode estdio.taz | \
|
||||
+ split -300 - estdio.u
|
||||
+ for f in estdio.u* ; do \
|
||||
+ echo '------ Cut Here ------' > uu.tmp ; \
|
||||
+ cat $$f >> uu.tmp ; \
|
||||
+ echo '------ Cut Here ------' >> uu.tmp ; \
|
||||
+ mv uu.tmp $$f ; \
|
||||
+ done
|
||||
+
|
||||
+ # Shell archive
|
||||
+
|
||||
+ shar: distribution
|
||||
+ rm -f estdio.[0-9][0-9]*
|
||||
+ sed -e '/^site\.h/d' \
|
||||
+ -e '/^stdio\.h/d' \
|
||||
+ -e 's%.*\.x%& Assembler stub%' \
|
||||
+ -e 's%^TEST/.*%& Exercise file%' \
|
||||
+ -e 's%^FPTEST/.*%& Exercise file%' \
|
||||
+ -e 's%^INSTALL/.*\.c%& Installation file%' \
|
||||
+ -e 's%^INSTALL/.*\.sh%& Installation script%' \
|
||||
+ -e 's%^INSTALL/.*\.txt%& Documentation%' \
|
||||
+ -e 's%^INSTALL/.*\.sit%& Differences for preconfigured sites%' \
|
||||
+ -e 's%^INSTALL/.*\.ans%& Answer file for generating sites%' \
|
||||
+ -e 's%^makefile.cpp$$%& Cppmake file%' \
|
||||
+ -e 's%^makefile.[a-z]*$$%& Makefile%' \
|
||||
+ -e 's%^[0-9a-z_]*\.g$$%& Header file source%' \
|
||||
+ -e 's%^[0-9a-z_]*\.h$$%& Header file%' \
|
||||
+ -e 's%^_z.*\.c$$%& Stdio fake source code%' \
|
||||
+ -e 's%^[0-9a-z_]*\.c$$%& Stdio source code%' < files > MANIFEST
|
||||
+ shar -a -n estdio -C -b13 -c -o estdio -l 40 MANIFEST `cat files`
|
||||
+
|
||||
+ # Dust and dirt
|
||||
+
|
||||
+ lint:
|
||||
+ lint -n $(Include) $(Define) `echo $(LIBOBJ) | sed 's/\.o/.c/g'`
|
||||
+
|
||||
+ # Makefiles
|
||||
+
|
||||
+ makefiles:
|
||||
+ -for w in $(Everyone) ; do \
|
||||
+ n=`grep "^.$$w " <makefile.cpp | sed 's/^.[^ ]* //'` ; \
|
||||
+ echo $$n ; \
|
||||
+ cppmake -D$$n -o makefile.$$w ; \
|
||||
+ done
|
||||
*** powers.h Tue Nov 6 16:03:59 EST 1990
|
||||
--- powers.h Tue Nov 6 16:03:59 EST 1990
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,154 ----
|
||||
+ #define NEGEXPONENT -79
|
||||
+ #define POSEXPONENT 0
|
||||
+ #ifdef SMALL
|
||||
+ #undef SMALL
|
||||
+ /* 53 bit table generated by ypow10 */
|
||||
+
|
||||
+ 1020396463,-1744830464, 993762648, 1449953230, /* 1e-15 */
|
||||
+ /* 0x3cd203af, 0x98000000, 0x3b3b9d58, 0x566c87ce, */
|
||||
+ 1023837339,-2147483648, 996836526, 1812441538, /* 1e-14 */
|
||||
+ /* 0x3d06849b, 0x80000000, 0x3b6a84ae, 0x6c07a9c2, */
|
||||
+ 1027352002, 1744830464, 995253664, 1889092397, /* 1e-13 */
|
||||
+ /* 0x3d3c25c2, 0x68000000, 0x3b525da0, 0x7099432d, */
|
||||
+ 1030854553,-2147483648, 1001578145, 295170687, /* 1e-12 */
|
||||
+ /* 0x3d719799, 0x80000000, 0x3bb2dea1, 0x1197f27f, */
|
||||
+ 1034288511, -536870912, 1005033033, 1442705183, /* 1e-11 */
|
||||
+ /* 0x3da5fd7f, 0xe0000000, 0x3be79649, 0x55fdef1f, */
|
||||
+ 1037794527, -671088640, 1008565211,-1417843993, /* 1e-10 */
|
||||
+ /* 0x3ddb7cdf, 0xd8000000, 0x3c1d7bdb, 0xab7d6ae7, */
|
||||
+ 1041313291, -402653184, 1008954186, 1500714625, /* 1e-09 */
|
||||
+ /* 0x3e112e0b, 0xe8000000, 0x3c236b4a, 0x59731681, */
|
||||
+ 1044740494, -536870912, 1016169569, -822280766, /* 1e-08 */
|
||||
+ /* 0x3e45798e, 0xe0000000, 0x3c918461, 0xcefcfdc2, */
|
||||
+ 1048238066,-1744830464, 1019602298, 1119632691, /* 1e-07 */
|
||||
+ /* 0x3e7ad7f2, 0x98000000, 0x3cc5e57a, 0x42bc3d33, */
|
||||
+ 1051772663,-1610612736, 1021754801,-1495885570, /* 1e-06 */
|
||||
+ /* 0x3eb0c6f7, 0xa0000000, 0x3ce6bdb1, 0xa6d698fe, */
|
||||
+ 1055193269,-2013265920, 1025273118, 277626686, /* 1e-05 */
|
||||
+ /* 0x3ee4f8b5, 0x88000000, 0x3d1c6d1e, 0x108c3f3e, */
|
||||
+ 1058682594, -402653184, 1030283801, 1697371075, /* 1e-04 */
|
||||
+ /* 0x3f1a36e2, 0xe8000000, 0x3d68e219, 0x652bd3c3, */
|
||||
+ 1062232653, -805306368, 1034390863, -549755814, /* 1e-03 */
|
||||
+ /* 0x3f50624d, 0xd0000000, 0x3da78d4f, 0xdf3b645a, */
|
||||
+ 1065646817, 1073741824, 1039054929, -343597384, /* 1e-02 */
|
||||
+ /* 0x3f847ae1, 0x40000000, 0x3deeb851, 0xeb851eb8, */
|
||||
+ 1069128089,-1744830464, 1039767961,-1717986918, /* 1e-01 */
|
||||
+ /* 0x3fb99999, 0x98000000, 0x3df99999, 0x9999999a, */
|
||||
+ /* 53 bit table generated by ypow10 */
|
||||
+
|
||||
+ 1072693248, 0, /* 1e000 */
|
||||
+ /* 0x3ff00000, 0x 0, */
|
||||
+ 1076101120, 0, /* 1e001 */
|
||||
+ /* 0x40240000, 0x 0, */
|
||||
+ 1079574528, 0, /* 1e002 */
|
||||
+ /* 0x40590000, 0x 0, */
|
||||
+ 1083129856, 0, /* 1e003 */
|
||||
+ /* 0x408f4000, 0x 0, */
|
||||
+ 1086556160, 0, /* 1e004 */
|
||||
+ /* 0x40c38800, 0x 0, */
|
||||
+ 1090021888, 0, /* 1e005 */
|
||||
+ /* 0x40f86a00, 0x 0, */
|
||||
+ 1093567616, 0, /* 1e006 */
|
||||
+ /* 0x412e8480, 0x 0, */
|
||||
+ 1097011920, 0, /* 1e007 */
|
||||
+ /* 0x416312d0, 0x 0, */
|
||||
+ 1100470148, 0, /* 1e008 */
|
||||
+ /* 0x4197d784, 0x 0, */
|
||||
+ 1104006501, 0, /* 1e009 */
|
||||
+ /* 0x41cdcd65, 0x 0, */
|
||||
+ 1107468383, 536870912, /* 1e010 */
|
||||
+ /* 0x4202a05f, 0x20000000, */
|
||||
+ 1110919286, -402653184, /* 1e011 */
|
||||
+ /* 0x42374876, 0xe8000000, */
|
||||
+ 1114446484,-1577058304, /* 1e012 */
|
||||
+ /* 0x426d1a94, 0xa2000000, */
|
||||
+ 1117925532, -448790528, /* 1e013 */
|
||||
+ /* 0x42a2309c, 0xe5400000, */
|
||||
+ 1121369284, 512753664, /* 1e014 */
|
||||
+ /* 0x42d6bcc4, 0x1e900000, */
|
||||
+ 1124887541, 640942080, /* 1e015 */
|
||||
+ /* 0x430c6bf5, 0x26340000, */
|
||||
+ #endif
|
||||
+ #ifdef LARGE
|
||||
+ #undef LARGE
|
||||
+ /* 53 bit table generated by ypow10 */
|
||||
+
|
||||
+ 96570939,-1744830464, 68794891, 1227202545, /* 1e-304 */
|
||||
+ /* 0x 5c18e3b, 0x98000000, 0x 419ba0b, 0x49259ff1, */
|
||||
+ 152272281, -939524096, 124862901, 1656465266, /* 1e-288 */
|
||||
+ /* 0x 9137d99, 0xc8000000, 0x 77141b5, 0x62bba772, */
|
||||
+ 207987601, -805306368, 180727666, 498298137, /* 1e-272 */
|
||||
+ /* 0x c65a391, 0xd0000000, 0x ac5af72, 0x1db36d19, */
|
||||
+ 263718440, 1610612736, 236106173, 211615049, /* 1e-256 */
|
||||
+ /* 0x fb80628, 0x60000000, 0x e12b1bd, 0x c9cfd49, */
|
||||
+ 319466507, -134217728, 290168421,-1012009411, /* 1e-240 */
|
||||
+ /* 0x130aac0b, 0xf8000000, 0x114b9e65, 0xc3adf63d, */
|
||||
+ 375233703,-1744830464, 347481368,-1486957956, /* 1e-224 */
|
||||
+ /* 0x165d9ca7, 0x98000000, 0x14b62518, 0xa75ed27c, */
|
||||
+ 430993435, -805306368, 404004562, 1580212516, /* 1e-208 */
|
||||
+ /* 0x19b0701b, 0xd0000000, 0x18149ed2, 0x5e302124, */
|
||||
+ 486686704, 1744830464, 460040721, -435995214, /* 1e-192 */
|
||||
+ /* 0x1d023ff0, 0x68000000, 0x1b6baa11, 0xe6033db2, */
|
||||
+ 542393060, -134217728, 514537675, 3127470, /* 1e-176 */
|
||||
+ /* 0x205442e4, 0xf8000000, 0x1eab38cb, 0x 2fb8ae, */
|
||||
+ 598113948, 268435456, 569629555,-1600955923, /* 1e-160 */
|
||||
+ /* 0x23a67e9c, 0x10000000, 0x21f3db73, 0xa09359ed, */
|
||||
+ 653850967, 1207959552, 626474537,-1050378446, /* 1e-144 */
|
||||
+ /* 0x26f8f957, 0x48000000, 0x25573e29, 0xc1647f32, */
|
||||
+ 709605896, -939524096, 682504798, 1917867582, /* 1e-128 */
|
||||
+ /* 0x2a4bba08, 0xc8000000, 0x28ae325e, 0x7250563e, */
|
||||
+ 765380710,-1342177280, 738097202, -373381469, /* 1e-112 */
|
||||
+ /* 0x2d9ec866, 0xb0000000, 0x2bfe7832, 0xe9bea6a3, */
|
||||
+ 821106304, 1476395008, 794558138,-1446147858, /* 1e-96 */
|
||||
+ /* 0x30f11680, 0x58000000, 0x2f5bfeba, 0xa9cd88ee, */
|
||||
+ 876804268, 268435456, 850212228,-1932333465, /* 1e-80 */
|
||||
+ /* 0x3442f8ac, 0x10000000, 0x32ad3584, 0x8cd2ee67, */
|
||||
+ 932515837, 1073741824, 905171612, -187523182, /* 1e-64 */
|
||||
+ /* 0x37950ffd, 0x40000000, 0x35f3d29c, 0xf4d29f92, */
|
||||
+ 988242511,-2013265920, 959689086,-1051110047, /* 1e-48 */
|
||||
+ /* 0x3ae7624f, 0x88000000, 0x3933b17e, 0xc1595561, */
|
||||
+ 1043985955, -805306368, 1016504988, -899861521, /* 1e-32 */
|
||||
+ /* 0x3e39f623, 0xd0000000, 0x3c96a29c, 0xca5d33ef, */
|
||||
+ 1099748018,-1879048192, 1072652838, -257055209, /* 1e-16 */
|
||||
+ /* 0x418cd2b2, 0x90000000, 0x3fef6226, 0xf0ada617, */
|
||||
+ /* 53 bit table generated by ypow10 */
|
||||
+
|
||||
+ 1128383353, 805306368, 1102021120, 0, /* 1e016 */
|
||||
+ /* 0x4341c379, 0x30000000, 0x41af8200, 0x 0, */
|
||||
+ 1184086197,-1342177280, 1156847032, 1523513360, /* 1e032 */
|
||||
+ /* 0x4693b8b5, 0xb0000000, 0x44f415b8, 0x5acef810, */
|
||||
+ 1239803185,-1610612736, 1209284878, 1465539011, /* 1e048 */
|
||||
+ /* 0x49e5e531, 0xa0000000, 0x4814390e, 0x575a59c3, */
|
||||
+ 1295535875, -402653184, 1265893279, 1303017855, /* 1e064 */
|
||||
+ /* 0x4d384f03, 0xe8000000, 0x4b73ff9f, 0x4daa797f, */
|
||||
+ 1351285999, 1342177280, 1322192821, -268978073, /* 1e080 */
|
||||
+ /* 0x508afcef, 0x50000000, 0x4ecf0fb5, 0xeff7b867, */
|
||||
+ 1407055477, 1610612736, 1378272667, 346211792, /* 1e096 */
|
||||
+ /* 0x53ddf675, 0x60000000, 0x5226c59b, 0x14a2c5d0, */
|
||||
+ 1462804981,-1207959552, 1429415014, 1405123674, /* 1e112 */
|
||||
+ /* 0x5730a1f5, 0xb8000000, 0x55332466, 0x53c07c5a, */
|
||||
+ 1518499656, -134217728, 1489174995, 431983838, /* 1e128 */
|
||||
+ /* 0x5a827748, 0xf8000000, 0x58c301d3, 0x19bf8cde, */
|
||||
+ 1574207575, 939524096, 1543938894,-1684177831, /* 1e144 */
|
||||
+ /* 0x5dd48057, 0x38000000, 0x5c06a34e, 0x9b9d7c59, */
|
||||
+ 1629930196, 536870912, 1602600947, 198519742, /* 1e160 */
|
||||
+ /* 0x6126c2d4, 0x20000000, 0x5f85bff3, 0x bd52bbe, */
|
||||
+ 1685669140, 1342177280, 1656849819,-1080853124, /* 1e176 */
|
||||
+ /* 0x64794514, 0x50000000, 0x62c1859b, 0xbf937d7c, */
|
||||
+ 1741426206, -268435456, 1711960654,-1428878472, /* 1e192 */
|
||||
+ /* 0x67cc0e1e, 0xf0000000, 0x660a724e, 0xaad50b78, */
|
||||
+ 1797203393,-2147483648, 1769642945, 815977400, /* 1e208 */
|
||||
+ /* 0x6b1f25c1, 0x80000000, 0x697a9bc1, 0x30a2d3b8, */
|
||||
+ 1852918354, -671088640, 1826615710, 1687667039, /* 1e224 */
|
||||
+ /* 0x6e714a52, 0xd8000000, 0x6cdff19e, 0x6497c15f, */
|
||||
+ 1908617780, -671088640, 1881795423,-1951213979, /* 1e240 */
|
||||
+ /* 0x71c33234, 0xd8000000, 0x7029eb5f, 0x8bb2d665, */
|
||||
+ 1964330973, 2013265920, 1937624828, -280564002, /* 1e256 */
|
||||
+ /* 0x75154fdd, 0x78000000, 0x737dcefc, 0xef46eede, */
|
||||
+ 2020059450, 671088640, 1990545211, 2030343771, /* 1e272 */
|
||||
+ /* 0x7867a93a, 0x28000000, 0x76a54f3b, 0x7904965b, */
|
||||
+ 2075804895,-2147483648, 2047433834, 797733763, /* 1e288 */
|
||||
+ /* 0x7bba44df, 0x80000000, 0x7a095c6a, 0x2f8c7383, */
|
||||
+ 2131569179, -536870912, 2103448126, 1107207139, /* 1e304 */
|
||||
+ /* 0x7f0d2a1b, 0xe0000000, 0x7d60123e, 0x41fea3e3, */
|
||||
+ #endif
|
||||
*** lmr.h Tue Nov 6 16:04:01 EST 1990
|
||||
--- lmr.h Tue Nov 6 16:04:01 EST 1990
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,4 ----
|
||||
+ /* 53 figit table generated by ylmr */
|
||||
+
|
||||
+ 2145386495, -1,
|
||||
+ /* 0x7fdfffff, 0xffffffff, LDBL_MAX / FLT_RADIX */
|
||||
@@ -0,0 +1,7 @@
|
||||
extern int bcopy();
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
return bcopy();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
int main()
|
||||
|
||||
{
|
||||
int flt_radix;
|
||||
double fullmantissa, e, m, f, g;
|
||||
|
||||
/* Decide on the radix. The way this is done is to generate e, the
|
||||
* smallest power of two for which 1 + e == 1. Once, e is discovered
|
||||
* determine the least m > e. The radix is then m - e.
|
||||
*/
|
||||
for (e = 1.0; 1 + e != e; e *= 2.0)
|
||||
;
|
||||
for (m = 1.0; e + m == e; m += 1.0)
|
||||
;
|
||||
g = e + m;
|
||||
flt_radix = g - e;
|
||||
|
||||
/* Generate a mantissa full of flt_radix-1 digits.
|
||||
*/
|
||||
for (fullmantissa = 0, f = flt_radix-1; ; ) {
|
||||
g = fullmantissa + f;
|
||||
if (g + 1 == g) break;
|
||||
fullmantissa = g;
|
||||
f *= flt_radix;
|
||||
}
|
||||
fullmantissa /= f/(flt_radix-1);
|
||||
|
||||
/* See if it is possible to divide it down into a denormalised number.
|
||||
*/
|
||||
for (;;) {
|
||||
g = fullmantissa / flt_radix;
|
||||
if (g * flt_radix != fullmantissa)
|
||||
break;
|
||||
fullmantissa = g;
|
||||
}
|
||||
|
||||
exit(g/flt_radix == 0.0);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct err {
|
||||
int errno;
|
||||
char *name;
|
||||
char *desc;
|
||||
} errlist[] = {
|
||||
{ 0, "EUNKNOWN", "Unknown error" }
|
||||
#include "yerrlist.h"
|
||||
};
|
||||
|
||||
int nerr = sizeof(errlist)/sizeof(errlist[0]);
|
||||
|
||||
int cmp(x, y) struct err *x, *y; { return x->errno - y->errno; }
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
int i;
|
||||
int bound;
|
||||
char yn[2];
|
||||
void exit();
|
||||
void qsort();
|
||||
|
||||
qsort(&errlist[0], nerr, sizeof(errlist[0]), cmp);
|
||||
|
||||
for (i = 0; i < nerr; i++) {
|
||||
if (islower(errlist[i].desc[0]))
|
||||
errlist[i].desc[0] = toupper(errlist[i].desc[0]);
|
||||
}
|
||||
|
||||
bound = errlist[nerr-1].errno;
|
||||
for (i = 0; i < nerr; i++) {
|
||||
if (errlist[i].errno != i) {
|
||||
fprintf(stderr, "There is a discontinuity in error numbers following:\n\
|
||||
%-15.15s %3d %s\n", errlist[i-1].name, errlist[i-1].errno, errlist[i-1].desc);
|
||||
yn[0] = '?';
|
||||
while (yn[0] == '?') {
|
||||
fprintf(stderr,
|
||||
"\nIs it acceptable to only include errors up to this point? [yn?] ");
|
||||
fflush(stderr);
|
||||
yn[0] = 'n';
|
||||
scanf("%1s", &yn[0]);
|
||||
if (yn[0] == '?') {
|
||||
fputs("Including errors up to this point will generate a small\n",
|
||||
stderr);
|
||||
fputs("table of error messages. However, this table may be\n",
|
||||
stderr);
|
||||
fputs("incomplete. You will have to determine whether your\n",
|
||||
stderr);
|
||||
fputs("operating system will generate error numbers beyond this\n",
|
||||
stderr);
|
||||
fputs("bound.\n", stderr);
|
||||
fputs("\n", stderr);
|
||||
fputs("Answering `y' is suitable for Minix.\n", stderr);
|
||||
}
|
||||
}
|
||||
if (yn[0] == 'y') {
|
||||
bound = errlist[i-1].errno;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
bound = -1;
|
||||
while (bound < 0) {
|
||||
fprintf(stderr,
|
||||
"Enter an acceptable bound on the error numbers: [%%d] ");
|
||||
fflush(stderr);
|
||||
bound = -1;
|
||||
scanf("%d", &bound);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nerr; i++) {
|
||||
if (errlist[i].errno > bound)
|
||||
break;
|
||||
if (i != 0)
|
||||
printf(",\n");
|
||||
printf("/* %-15.15s %3d */ \"%s\"", errlist[i].name,
|
||||
errlist[i].errno,
|
||||
errlist[i].desc);
|
||||
}
|
||||
printf("\n");
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
|
||||
jmp_buf errjmp;
|
||||
|
||||
void exception(sig)
|
||||
|
||||
int sig;
|
||||
|
||||
{
|
||||
longjmp(errjmp, 1);
|
||||
}
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char *argv[];
|
||||
|
||||
{
|
||||
int dbl_dig;
|
||||
int dbl_min_10_exp;
|
||||
int dbl_max_10_exp;
|
||||
int dbl_mant_dig;
|
||||
int flt_radix;
|
||||
int dbl_max_exp;
|
||||
int dbl_min_exp;
|
||||
double dbl_epsilon;
|
||||
double dbl_max;
|
||||
double dbl_min;
|
||||
int strcmp();
|
||||
double fullmantissa, e, m, f, g;
|
||||
int i, d, r;
|
||||
|
||||
if (argc > 2)
|
||||
exit(1);
|
||||
|
||||
/* Decide on the radix. The way this is done is to generate e, the
|
||||
* smallest power of two for which 1 + e == 1. Once, e is discovered
|
||||
* determine the least m > e. The radix is then m - e.
|
||||
*/
|
||||
for (e = 1.0; 1 + e != e; e *= 2.0)
|
||||
;
|
||||
for (m = 1.0; e + m == e; m += 1.0)
|
||||
;
|
||||
g = e + m;
|
||||
flt_radix = g - e;
|
||||
|
||||
/* Determine the smallest positive number for which 1 + x != 1.
|
||||
* This is done by dividing a single bigit by the radix until
|
||||
* 1 + x = 1.
|
||||
*/
|
||||
for (e = 1.0; ; ) {
|
||||
f = e / flt_radix;
|
||||
if (1 + f == 1)
|
||||
break;
|
||||
e = f;
|
||||
}
|
||||
dbl_epsilon = e;
|
||||
|
||||
/* Determine the number of digits in the mantissa. This is done
|
||||
* by filling the mantissa with one digits. When the mantissa
|
||||
* overflows, the least significant digits will be lost. When
|
||||
* an attempt is made to undo the operation, the result will
|
||||
* not equal the original.
|
||||
*/
|
||||
for (d = 0, m = 0.0, f = 1.0; ; f *= flt_radix) {
|
||||
g = m + f;
|
||||
if (g - f != m)
|
||||
break;
|
||||
m = g;
|
||||
d++;
|
||||
}
|
||||
dbl_mant_dig = d;
|
||||
|
||||
/* Generate a mantissa full of flt_radix-1 digits. This will be
|
||||
* used later for other calculations.
|
||||
*/
|
||||
for (fullmantissa = 0, f = flt_radix-1, d = dbl_mant_dig; d > 0; d--) {
|
||||
fullmantissa += f;
|
||||
f *= flt_radix;
|
||||
}
|
||||
fullmantissa /= f/(flt_radix-1);
|
||||
|
||||
/* Determine the largest exponent. Assume that when the representation
|
||||
* saturates, either SIGFPE or result is infinity will occur.
|
||||
*/
|
||||
signal(SIGFPE, exception);
|
||||
if (setjmp(errjmp) == 0) {
|
||||
for (d = 0, f = 1.0/flt_radix; ; d++) {
|
||||
f *= flt_radix;
|
||||
if (f == f / flt_radix)
|
||||
break;
|
||||
}
|
||||
}
|
||||
signal(SIGFPE, SIG_DFL);
|
||||
dbl_max_exp = d;
|
||||
|
||||
/* Determine the smallest exponent. Assume that when the representation
|
||||
* underflows, the result will be zero, or denormalised.
|
||||
*/
|
||||
for (m = fullmantissa, d = 0; ; --d) {
|
||||
f = m / flt_radix;
|
||||
if (f == 0)
|
||||
break;
|
||||
if (f * flt_radix != m)
|
||||
break;
|
||||
m = f;
|
||||
}
|
||||
dbl_min_exp = d;
|
||||
|
||||
/* Determine the number of decimal digits held by the mantissa. This
|
||||
* can be done by introducing 9s until bits fall off.
|
||||
*/
|
||||
for (d = 1, f = 9; ; d++) {
|
||||
g = f * 10 + 9;
|
||||
if (f != (g - 9) / 10)
|
||||
break;
|
||||
f = g;
|
||||
}
|
||||
dbl_dig = d;
|
||||
|
||||
/* Determine the largest number held by the representation. This
|
||||
* is done by multiplying a full mantissa by flt_radix^dbl_max_exp.
|
||||
*/
|
||||
for (m = fullmantissa, d = dbl_max_exp; d > 0; m *= flt_radix, d--)
|
||||
;
|
||||
dbl_max = m;
|
||||
|
||||
/* Determine the power of ten held by the floating point representation.
|
||||
*/
|
||||
for (f = 1, d = 0; f <= dbl_max/10; d++)
|
||||
f *= 10;
|
||||
dbl_max_10_exp = d;
|
||||
|
||||
/* Determine the smallest (normalised) number held by the representation.
|
||||
* Denormalisation can be caught be simultaneously dividing down a full
|
||||
* mantissa.
|
||||
*/
|
||||
for (m = fullmantissa, e = 1.0/flt_radix; ; ) {
|
||||
f = e / flt_radix;
|
||||
if (f == 0)
|
||||
break;
|
||||
g = m / flt_radix;
|
||||
if (g * flt_radix != m)
|
||||
break;
|
||||
e = f;
|
||||
m = g;
|
||||
}
|
||||
dbl_min = e;
|
||||
|
||||
/* Determine the smallest (normalised) power of ten held by the representation.
|
||||
* This is done by repeatedly dividing down by 10.
|
||||
*/
|
||||
for (d = 0, m = 1.0; ; d--) {
|
||||
f = m / 10;
|
||||
if (f == 0)
|
||||
break;
|
||||
if (f < dbl_min)
|
||||
break;
|
||||
m = f;
|
||||
}
|
||||
dbl_min_10_exp = d;
|
||||
|
||||
/* Print results */
|
||||
|
||||
if (argc < 2 || strcmp(argv[1], "DBL_EPSILON") == 0)
|
||||
printf("#define DBL_EPSILON %.*lg\n", dbl_dig, dbl_epsilon);
|
||||
if (argc < 2 || strcmp(argv[1], "DBL_DIG") == 0)
|
||||
printf("#define DBL_DIG %d\n", dbl_dig);
|
||||
if (argc < 2 || strcmp(argv[1], "DBL_MANT_DIG") == 0)
|
||||
printf("#define DBL_MANT_DIG %d\n", dbl_mant_dig);
|
||||
if (argc < 2 || strcmp(argv[1], "DBL_MAX") == 0)
|
||||
printf("#define DBL_MAX %.*lg\n", dbl_dig, dbl_max);
|
||||
if (argc < 2 || strcmp(argv[1], "DBL_MAX_10_EXP") == 0)
|
||||
printf("#define DBL_MAX_10_EXP %d\n", dbl_max_10_exp);
|
||||
if (argc < 2 || strcmp(argv[1], "DBL_MAX_EXP") == 0)
|
||||
printf("#define DBL_MAX_EXP %d\n", dbl_max_exp);
|
||||
if (argc < 2 || strcmp(argv[1], "DBL_MIN") == 0)
|
||||
printf("#define DBL_MIN %.*lg\n", dbl_dig, dbl_min);
|
||||
if (argc < 2 || strcmp(argv[1], "DBL_MIN_10_EXP") == 0)
|
||||
printf("#define DBL_MIN_10_EXP %d\n", dbl_min_10_exp);
|
||||
if (argc < 2 || strcmp(argv[1], "DBL_MIN_EXP") == 0)
|
||||
printf("#define DBL_MIN_EXP %d\n", dbl_min_exp);
|
||||
|
||||
if (argc < 2 || strcmp(argv[1], "LDBL_EPSILON") == 0)
|
||||
printf("#define LDBL_EPSILON %.*lg\n", dbl_dig, dbl_epsilon);
|
||||
if (argc < 2 || strcmp(argv[1], "LDBL_DIG") == 0)
|
||||
printf("#define LDBL_DIG %d\n", dbl_dig);
|
||||
if (argc < 2 || strcmp(argv[1], "LDBL_MANT_DIG") == 0)
|
||||
printf("#define LDBL_MANT_DIG %d\n", dbl_mant_dig);
|
||||
if (argc < 2 || strcmp(argv[1], "LDBL_MAX") == 0)
|
||||
printf("#define LDBL_MAX %.*lg\n", dbl_dig, dbl_max);
|
||||
if (argc < 2 || strcmp(argv[1], "LDBL_MAX_10_EXP") == 0)
|
||||
printf("#define LDBL_MAX_10_EXP %d\n", dbl_max_10_exp);
|
||||
if (argc < 2 || strcmp(argv[1], "LDBL_MAX_EXP") == 0)
|
||||
printf("#define LDBL_MAX_EXP %d\n", dbl_max_exp);
|
||||
if (argc < 2 || strcmp(argv[1], "LDBL_MIN") == 0)
|
||||
printf("#define LDBL_MIN %.*lg\n", dbl_dig, dbl_min);
|
||||
if (argc < 2 || strcmp(argv[1], "LDBL_MIN_10_EXP") == 0)
|
||||
printf("#define LDBL_MIN_10_EXP %d\n", dbl_min_10_exp);
|
||||
if (argc < 2 || strcmp(argv[1], "LDBL_MIN_EXP") == 0)
|
||||
printf("#define LDBL_MIN_EXP %d\n", dbl_min_exp);
|
||||
|
||||
if (argc < 2 || strcmp(argv[1], "FLT_RADIX") == 0)
|
||||
printf("#define FLT_RADIX %d\n", flt_radix);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
|
||||
struct err {
|
||||
int errno;
|
||||
char *name;
|
||||
} errlist[512];
|
||||
int errs = 0;
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
int err;
|
||||
int i, j;
|
||||
char *p;
|
||||
char name[512];
|
||||
void *malloc();
|
||||
int strlen();
|
||||
char *strcpy();
|
||||
|
||||
while (scanf("%s%d", name, &err) == 2) {
|
||||
errlist[errs].errno = err;
|
||||
errlist[errs].name = (char *) malloc((unsigned) strlen(name)+1);
|
||||
(void) strcpy(errlist[errs].name, name);
|
||||
errs++;
|
||||
}
|
||||
|
||||
printf("/* EUNKNOWN 0 */ \"Unknown error\"");
|
||||
for (err = 0, i = 1; i < sys_nerr; i++) {
|
||||
for (j = err; j < errs; j++) {
|
||||
if (errlist[j].errno == i) {
|
||||
err = j+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == errs)
|
||||
p = "ENONYMOUS";
|
||||
else
|
||||
p = errlist[j].name;
|
||||
printf(",\n");
|
||||
printf("/* %-15.15s %3d */ \"%s\"", p, i, sys_errlist[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char *argv[];
|
||||
|
||||
{
|
||||
char c;
|
||||
unsigned int ui = ~0;
|
||||
unsigned long ul = ~0;
|
||||
int char_bit;
|
||||
int j;
|
||||
void exit();
|
||||
int strcmp();
|
||||
|
||||
if (argc > 2)
|
||||
exit(1);
|
||||
|
||||
for (char_bit = 0, j = 1; (c = j), c != 0; char_bit++, j <<= 1)
|
||||
;
|
||||
|
||||
if (argc < 2 || strcmp(argv[1], "CHAR_BIT") == 0)
|
||||
printf("#define CHAR_BIT %d\n", char_bit);
|
||||
if (argc < 2 || strcmp(argv[1], "UINT_MAX") == 0)
|
||||
printf("#define UINT_MAX %u\n", ui);
|
||||
if (argc < 2 || strcmp(argv[1], "ULONG_MAX") == 0)
|
||||
printf("#define ULONG_MAX %lu\n", ul);
|
||||
if (argc < 2 || strcmp(argv[1], "INT_MAX") == 0)
|
||||
printf("#define INT_MAX %d\n", (int) (ui >> 1));
|
||||
if (argc < 2 || strcmp(argv[1], "LONG_MAX") == 0)
|
||||
printf("#define LONG_MAX %ld\n", (int) (ul >> 1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
#include "../site.h"
|
||||
#ifdef FLOAT
|
||||
# include <float.h>
|
||||
# if DBL_MANT_DIG < LDBL_MANT_DIG && \
|
||||
DBL_MAX_EXP < LDBL_MAX_EXP && \
|
||||
DBL_MIN_EXP > LDBL_MIN_EXP
|
||||
# define LONGDOUBLE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef LONGDOUBLE
|
||||
typedef long double longdouble;
|
||||
#else
|
||||
typedef double longdouble;
|
||||
# undef LDBL_DIG
|
||||
# define LDBL_DIG DBL_DIG
|
||||
# undef LDBL_EPSILON
|
||||
# define LDBL_EPSILON DBL_EPSILON
|
||||
# undef LDBL_MANT_DIG
|
||||
# define LDBL_MANT_DIG DBL_MANT_DIG
|
||||
# undef LDBL_MAX
|
||||
# define LDBL_MAX DBL_MAX
|
||||
# undef LDBL_MAX_10_EXP
|
||||
# define LDBL_MAX_10_EXP DBL_MAX_10_EXP
|
||||
# undef LDBL_MAX_EXP
|
||||
# define LDBL_MAX_EXP DBL_MAX_EXP
|
||||
# undef LDBL_MIN
|
||||
# define LDBL_MIN DBL_MIN
|
||||
# undef LDBL_MIN_10_EXP
|
||||
# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||
# undef LDBL_MIN_EXP
|
||||
# define LDBL_MIN_EXP DBL_MIN_EXP
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Dump the floating point number as long words */
|
||||
|
||||
void dump(n, m)
|
||||
|
||||
char *n;
|
||||
longdouble m;
|
||||
|
||||
{
|
||||
char b[128];
|
||||
int *p;
|
||||
int i;
|
||||
int iwidth;
|
||||
int xwidth;
|
||||
|
||||
iwidth = sizeof(int) < 4 ? 7 : 11;
|
||||
xwidth = sizeof(int) * 2;
|
||||
|
||||
p = (int *) &m;
|
||||
printf(" ");
|
||||
for (i = sizeof(longdouble)/sizeof(int); i--; p++)
|
||||
printf("%*d,", iwidth, *p);
|
||||
printf("\n");
|
||||
|
||||
p = (int *) &m;
|
||||
printf("/* ");
|
||||
for (i = sizeof(longdouble)/sizeof(int); i--; p++)
|
||||
printf("0x%*x, ", xwidth, *p);
|
||||
printf(" %s */\n", n);
|
||||
}
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
longdouble f, m;
|
||||
longdouble fullmantissa;
|
||||
int d;
|
||||
|
||||
printf("/* %d figit table generated by ylmr */\n\n", LDBL_MANT_DIG);
|
||||
|
||||
/* Generate a mantissa full of flt_radix-1 digits. This will be
|
||||
* used later for other calculations.
|
||||
*/
|
||||
for (fullmantissa = 0, f = FLT_RADIX-1, d = DBL_MANT_DIG; d > 0; d--) {
|
||||
fullmantissa += f;
|
||||
f *= FLT_RADIX;
|
||||
}
|
||||
fullmantissa /= f/(FLT_RADIX-1);
|
||||
|
||||
/* Determine the largest number held by the representation. This
|
||||
* is done by multiplying a full mantissa by flt_radix^dbl_max_exp.
|
||||
*/
|
||||
for (m = fullmantissa, d = DBL_MAX_EXP; d > 0; m *= FLT_RADIX, d--)
|
||||
;
|
||||
|
||||
dump("LDBL_MAX / FLT_RADIX", m/FLT_RADIX);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Locate the stdio directory
|
||||
#
|
||||
|
||||
swd=`cd ..; pwd`
|
||||
|
||||
#
|
||||
# Make the work directory
|
||||
#
|
||||
|
||||
if test ! -d libc ; then
|
||||
mkdir libc
|
||||
else
|
||||
rm -f libc/*
|
||||
fi
|
||||
cd libc
|
||||
cwd=`pwd`
|
||||
|
||||
#
|
||||
# Check for recompilation
|
||||
#
|
||||
echo -n 'Do you want to recompile affected library files? [yn] '
|
||||
read RECOMPILE
|
||||
|
||||
#
|
||||
# Update the floating point library
|
||||
#
|
||||
if test -f /usr/lib/libfp.a ; then
|
||||
echo Updating floating point library...
|
||||
ar x /usr/lib/libfp.a
|
||||
cp ${swd}/_f_*.s .
|
||||
if test -f ${swd}/Hidden ; then
|
||||
cp ${swd}/_u_*print*.s ${swd}/_u_*scan*.s .
|
||||
fi
|
||||
lorder *.s | tsort > FPorder
|
||||
ar cq libfp.a `cat FPorder`
|
||||
rm -f *.s
|
||||
fi
|
||||
|
||||
#
|
||||
# Touch and make all affected files in the old library
|
||||
#
|
||||
ANSI="assert system "
|
||||
OTHER="curses getopt getpass lock nlist popen regexp regsub termcap "
|
||||
POSIX="getlogin "
|
||||
cd /usr/src/lib
|
||||
if test "${RECOMPILE}" = "y" ; then
|
||||
cd ansi
|
||||
for g in `echo ${ANSI}` ; do
|
||||
touch ${g}.c
|
||||
make f=${g}
|
||||
done
|
||||
fi
|
||||
if test "${RECOMPILE}" = "y" ; then
|
||||
cd ../other
|
||||
for g in `echo ${OTHER}` ; do
|
||||
touch ${g}.c
|
||||
make f=${g}
|
||||
done
|
||||
fi
|
||||
if test "${RECOMPILE}" = "y" ; then
|
||||
cd ../posix
|
||||
for g in `echo ${POSIX}` ; do
|
||||
touch ${g}.c
|
||||
make f=${g}
|
||||
done
|
||||
fi
|
||||
cd ${cwd}
|
||||
|
||||
#
|
||||
# Find the compiler support files
|
||||
#
|
||||
echo Finding compiler support modules...
|
||||
ar pv /usr/lib/libc.a | libupack | sed -n -e '
|
||||
:start
|
||||
/^p - / {
|
||||
s/^p - //
|
||||
h
|
||||
n
|
||||
b start
|
||||
}
|
||||
/^ *\.define *[^_]/ {
|
||||
x
|
||||
/^..*$/ p
|
||||
s/.*//
|
||||
x
|
||||
n
|
||||
b start
|
||||
}' > c.tmp
|
||||
ar x /usr/lib/libc.a `cat c.tmp`
|
||||
rm -f c.tmp
|
||||
|
||||
#
|
||||
# Copy all the library files
|
||||
#
|
||||
echo -n Copying Minix library...
|
||||
echo -n ' ansi'
|
||||
cp /usr/src/lib/ansi/*.s .
|
||||
echo -n ' other'
|
||||
cp /usr/src/lib/other/*.s .
|
||||
echo -n ' posix'
|
||||
cp /usr/src/lib/posix/*.s .
|
||||
echo -n ' ibm'
|
||||
cd /usr/src/lib/ibm
|
||||
for f in *.s ; do
|
||||
libpack < ${f} > ${cwd}/${f}
|
||||
done
|
||||
echo ''
|
||||
cd ${cwd}
|
||||
rm -f crtso.s prtso.s head.s end.s
|
||||
|
||||
#
|
||||
# Delete the superseded files
|
||||
#
|
||||
echo Superseding stdio modules...
|
||||
rm -f exit.s fclose.s fflush.s fgetc.s fgets.s fopen.s fprintf.s \
|
||||
fputc.s fputs.s fread.s freopen.s fseek.s ftell.s fwrite.s \
|
||||
gets.s perror.s puts.s scanf.s setbuf.s sprintf.s tmpnam.s \
|
||||
ungetc.s vsprintf.s cleanup.s doprintf.s printdat.s ctermid.s \
|
||||
cuserid.s fdopen.s
|
||||
|
||||
#
|
||||
# Copy the new stdio files
|
||||
#
|
||||
echo Copying new stdio modules...
|
||||
cp ${swd}/[_a-wz]*.s .
|
||||
rm -f _f_*.s
|
||||
|
||||
#
|
||||
# Generate the order
|
||||
#
|
||||
echo Generating library order...
|
||||
lorder *.s | tsort > Order
|
||||
|
||||
#
|
||||
# Make library
|
||||
#
|
||||
echo Generating library...
|
||||
rm -f libc.a
|
||||
ar cq libc.a `cat Order`
|
||||
rm -f *.s
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifdef USESTDDEF
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifdef USESTDIO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
Null NULL
|
||||
@@ -0,0 +1,18 @@
|
||||
#include <errno.h>
|
||||
|
||||
extern char *sys_errlist[1];
|
||||
extern int sys_nerr;
|
||||
|
||||
int perror() {}
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
char *s;
|
||||
int i;
|
||||
|
||||
s = sys_errlist[0];
|
||||
i = sys_nerr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,582 @@
|
||||
/*
|
||||
* Calculate powers of ten
|
||||
*
|
||||
* This code will compute the required bit string for accurate power
|
||||
* of ten tables.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define WORD_BIT 16
|
||||
#define LOBYTE(x) ((x) & 0x0000ffffL)
|
||||
#define HIBYTE(x) LOBYTE(((x) >> WORD_BIT))
|
||||
#define BIT(x,y) ((x) & (1 << y))
|
||||
#define BIGWORD(h,l) ((((long)LOBYTE(h)) << WORD_BIT) + LOBYTE(l))
|
||||
|
||||
typedef unsigned int WORD;
|
||||
|
||||
typedef struct {
|
||||
int words;
|
||||
WORD *word;
|
||||
} NUMBER;
|
||||
|
||||
#ifdef __STDC__
|
||||
typedef long double longdouble;
|
||||
#else
|
||||
typedef double longdouble;
|
||||
#endif
|
||||
|
||||
void *malloc();
|
||||
void *realloc();
|
||||
void free();
|
||||
int atoi();
|
||||
double atof();
|
||||
|
||||
int ldbl_mant_bit;
|
||||
int guards = 0;
|
||||
int verbose = 0;
|
||||
|
||||
/* Determine number of bits in representation */
|
||||
|
||||
void initbits()
|
||||
|
||||
{
|
||||
longdouble m, f, g;
|
||||
|
||||
for (ldbl_mant_bit = 0, m = 0.0, f = 1.0; ; f *= 2.0) {
|
||||
g = m + f;
|
||||
if (g - f != m)
|
||||
break;
|
||||
m = g;
|
||||
ldbl_mant_bit++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Memory allocation with error trap */
|
||||
|
||||
void *xmalloc(n)
|
||||
|
||||
unsigned n;
|
||||
|
||||
{
|
||||
void *p;
|
||||
|
||||
if ((p = malloc(n)) == (void *) NULL) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Memory reallocation with error trap */
|
||||
|
||||
void *xrealloc(p, n)
|
||||
|
||||
void *p;
|
||||
unsigned n;
|
||||
|
||||
{
|
||||
if ((p = realloc(p, n)) == (void *) NULL) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Allocate a new number */
|
||||
|
||||
NUMBER *newnumber()
|
||||
|
||||
{
|
||||
NUMBER *p;
|
||||
|
||||
p = (NUMBER *) xmalloc(sizeof(*p));
|
||||
p->words = 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Set number to a value */
|
||||
|
||||
void setnumber(p, v)
|
||||
|
||||
NUMBER *p;
|
||||
int v;
|
||||
|
||||
{
|
||||
if (p->words != 0)
|
||||
free(p->word);
|
||||
|
||||
p->word = (WORD *) xmalloc(sizeof(*p->word));
|
||||
p->word[0] = v;
|
||||
p->words = 1;
|
||||
}
|
||||
|
||||
/* Set number to be fixed point with specified bits */
|
||||
|
||||
void setfixed(p, b)
|
||||
|
||||
NUMBER *p;
|
||||
int b;
|
||||
|
||||
{
|
||||
int i;
|
||||
|
||||
p->words = 1 + (b + WORD_BIT - 1) / WORD_BIT;
|
||||
p->word = (WORD *) xrealloc(p->word, sizeof(*p->word) * p->words);
|
||||
for (i = 1; i < p->words; i++)
|
||||
p->word[i] = 0;
|
||||
}
|
||||
|
||||
/* Multiply one number by another */
|
||||
|
||||
void multiply(p, q)
|
||||
|
||||
NUMBER *p, *q;
|
||||
|
||||
{
|
||||
NUMBER r;
|
||||
int i, j;
|
||||
long carry;
|
||||
long sum;
|
||||
|
||||
r.words = p->words + q->words;
|
||||
r.word = (WORD *) xmalloc(sizeof(*r.word) * r.words);
|
||||
|
||||
for (i = 0; i < r.words; i++)
|
||||
r.word[i] = 0;
|
||||
|
||||
for (i = 0; i < p->words; i++) {
|
||||
carry = 0;
|
||||
for (j = 0; j < q->words; j++) {
|
||||
sum = r.word[i+j] + carry + (long) p->word[i] * q->word[j];
|
||||
r.word[i+j] = (WORD) LOBYTE(sum);
|
||||
carry = HIBYTE(sum);
|
||||
}
|
||||
r.word[i+j] = (WORD) carry;
|
||||
}
|
||||
|
||||
if (carry == 0)
|
||||
r.words--;
|
||||
|
||||
assert(r.word[r.words-1] != 0);
|
||||
|
||||
free(p->word);
|
||||
*p = r;
|
||||
}
|
||||
|
||||
/* Divide fixed point number by a small integer */
|
||||
|
||||
void fixdivint(p, n)
|
||||
|
||||
NUMBER *p;
|
||||
unsigned int n;
|
||||
|
||||
{
|
||||
int i;
|
||||
long rem;
|
||||
|
||||
for (rem = 0, i = 0; i < p->words; i++) {
|
||||
rem = BIGWORD(rem, p->word[i]);
|
||||
p->word[i] = rem / n;
|
||||
rem %= n;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate scale factor */
|
||||
|
||||
longdouble toscale(off)
|
||||
|
||||
int off;
|
||||
|
||||
{
|
||||
longdouble m;
|
||||
|
||||
m = 1.0;
|
||||
if (off > 0) {
|
||||
while (off-- > 0)
|
||||
m *= 2.0;
|
||||
}
|
||||
else {
|
||||
while (off++ < 0)
|
||||
m /= 2.0;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
/* Convert fixed point to double */
|
||||
|
||||
void fixtodouble(p, unit, f, g)
|
||||
|
||||
NUMBER *p;
|
||||
longdouble unit;
|
||||
longdouble *f, *g;
|
||||
|
||||
{
|
||||
int w, ww;
|
||||
int b, bb;
|
||||
int i;
|
||||
int lastbit;
|
||||
longdouble scale;
|
||||
longdouble highscale;
|
||||
longdouble lowscale;
|
||||
longdouble m;
|
||||
|
||||
b = WORD_BIT-1;
|
||||
w = 1;
|
||||
|
||||
scale = 1.0;
|
||||
highscale = 1.0;
|
||||
lowscale = 1.0;
|
||||
|
||||
*f = 0.0;
|
||||
*g = 0.0;
|
||||
|
||||
for (; BIT(p->word[w], b) == 0; scale *= 2.0) {
|
||||
if (b != 0)
|
||||
b--;
|
||||
else if (w == p->words-1)
|
||||
return;
|
||||
else {
|
||||
w++;
|
||||
b = WORD_BIT-1;
|
||||
}
|
||||
}
|
||||
|
||||
if (guards) {
|
||||
for (m = 0.0, i = 0; i < ldbl_mant_bit/2; i++) {
|
||||
m *= 2.0;
|
||||
highscale *= 2.0;
|
||||
if (BIT(p->word[w], b) != 0)
|
||||
m += unit;
|
||||
if (b != 0)
|
||||
b--;
|
||||
else if (w == p->words-1) {
|
||||
m /= highscale;
|
||||
*f = m / scale;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
w++;
|
||||
b = WORD_BIT-1;
|
||||
}
|
||||
}
|
||||
|
||||
m /= highscale;
|
||||
*f = m / scale;
|
||||
|
||||
for (; BIT(p->word[w], b) == 0; lowscale *= 2.0) {
|
||||
if (b != 0)
|
||||
b--;
|
||||
else if (w == p->words-1)
|
||||
return;
|
||||
else {
|
||||
w++;
|
||||
b = WORD_BIT-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (m = 0.0, i = 0; i < ldbl_mant_bit; i++) {
|
||||
m *= 2.0;
|
||||
lowscale *= 2.0;
|
||||
if ((lastbit = BIT(p->word[w], b)) != 0)
|
||||
m += unit;
|
||||
if (b != 0)
|
||||
b--;
|
||||
else if (w == p->words-1) {
|
||||
m /= highscale;
|
||||
m /= lowscale;
|
||||
*g = m / scale;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
w++;
|
||||
b = WORD_BIT-1;
|
||||
}
|
||||
}
|
||||
|
||||
if (BIT(p->word[w], b) != 0) {
|
||||
for (ww = w, bb = b; ; ) {
|
||||
if (bb != 0)
|
||||
bb--;
|
||||
else if (ww != p->words-1) {
|
||||
ww++;
|
||||
bb = WORD_BIT-1;
|
||||
}
|
||||
else {
|
||||
if (lastbit != 0)
|
||||
m += unit;
|
||||
break;
|
||||
}
|
||||
if (BIT(p->word[ww], bb) != 0) {
|
||||
m += unit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m /= highscale;
|
||||
m /= lowscale;
|
||||
*g = m / scale;
|
||||
}
|
||||
|
||||
/* Convert integer to double */
|
||||
|
||||
void todouble(p, unit, f, g)
|
||||
|
||||
NUMBER *p;
|
||||
longdouble unit;
|
||||
longdouble *f, *g;
|
||||
|
||||
{
|
||||
int w, ww;
|
||||
int b, bb;
|
||||
int lastbit;
|
||||
int i;
|
||||
longdouble m;
|
||||
|
||||
w = p->words-1;
|
||||
b = WORD_BIT-1;
|
||||
|
||||
*f = 0.0;
|
||||
*g = 0.0;
|
||||
|
||||
for (; BIT(p->word[w], b) == 0; b--)
|
||||
;
|
||||
|
||||
if (guards) {
|
||||
for (m = 0.0, i = 0; i < ldbl_mant_bit/2; i++) {
|
||||
m *= 2.0;
|
||||
if (BIT(p->word[w], b) != 0)
|
||||
m += unit;
|
||||
if (b != 0)
|
||||
b--;
|
||||
else if (w == 0) {
|
||||
*f = m;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
w--;
|
||||
b = WORD_BIT-1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = w*WORD_BIT + b + 1; i--; )
|
||||
m *= 2.0;
|
||||
|
||||
*f = m;
|
||||
|
||||
for (; BIT(p->word[w], b) == 0; ) {
|
||||
if (b != 0)
|
||||
b--;
|
||||
else if (w == 0)
|
||||
return;
|
||||
else {
|
||||
w--;
|
||||
b = WORD_BIT-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (m = 0.0, i = 0; i < ldbl_mant_bit; i++) {
|
||||
m *= 2.0;
|
||||
if ((lastbit = BIT(p->word[w], b)) != 0)
|
||||
m += unit;
|
||||
if (b != 0)
|
||||
b--;
|
||||
else if (w == 0) {
|
||||
*g = m;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
w--;
|
||||
b = WORD_BIT-1;
|
||||
}
|
||||
}
|
||||
|
||||
if (BIT(p->word[w], b) != 0) {
|
||||
for (ww = w, bb = b; ; ) {
|
||||
if (bb != 0)
|
||||
bb--;
|
||||
else if (ww != 0) {
|
||||
ww--;
|
||||
bb = WORD_BIT-1;
|
||||
}
|
||||
else {
|
||||
if (lastbit != 0)
|
||||
m += unit;
|
||||
break;
|
||||
}
|
||||
if (BIT(p->word[ww], bb) != 0) {
|
||||
m += unit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = w*WORD_BIT + b + 1; i--; )
|
||||
m *= 2.0;
|
||||
|
||||
*g = m;
|
||||
}
|
||||
|
||||
/* Dump the floating point number as long words */
|
||||
|
||||
void dump(n, f, g)
|
||||
|
||||
int n;
|
||||
longdouble f, g;
|
||||
|
||||
{
|
||||
char b[128];
|
||||
longdouble m;
|
||||
longdouble a;
|
||||
double aa;
|
||||
int *p;
|
||||
int i;
|
||||
int iwidth;
|
||||
int xwidth;
|
||||
|
||||
iwidth = sizeof(int) < 4 ? 7 : 11;
|
||||
xwidth = sizeof(int) * 2;
|
||||
|
||||
printf(" ");
|
||||
if (guards) {
|
||||
p = (int *) &f;
|
||||
for (i = sizeof(longdouble)/sizeof(int); i--; p++)
|
||||
printf("%*d,", iwidth, *p);
|
||||
}
|
||||
p = (int *) &g;
|
||||
for (i = sizeof(longdouble)/sizeof(int); i--; p++)
|
||||
printf("%*d,", iwidth, *p);
|
||||
printf(" /* 1e%03d */\n", n);
|
||||
|
||||
printf("/* ");
|
||||
if (guards) {
|
||||
p = (int *) &f;
|
||||
for (i = sizeof(longdouble)/sizeof(int); i--; p++)
|
||||
printf("0x%*x, ", xwidth, *p);
|
||||
}
|
||||
p = (int *) &g;
|
||||
for (i = sizeof(longdouble)/sizeof(int); i--; p++)
|
||||
printf("0x%*x, ", xwidth, *p);
|
||||
printf("*/\n");
|
||||
|
||||
if (verbose) {
|
||||
m = f + g;
|
||||
p = (int *) &m;
|
||||
printf("/* ");
|
||||
for (i = sizeof(longdouble)/sizeof(int); i--; p++)
|
||||
printf("0x%*x, ", xwidth, *p);
|
||||
printf(" ypow10 */\n");
|
||||
|
||||
sprintf(b, "1e%d", n);
|
||||
|
||||
a = atof(b);
|
||||
p = (int *) &a;
|
||||
printf("/* ");
|
||||
for (i = sizeof(longdouble)/sizeof(int); i--; p++)
|
||||
printf("0x%*x, ", xwidth, *p);
|
||||
printf(" atof() */");
|
||||
if (a != m)
|
||||
printf(" /*!*/");
|
||||
printf("\n");
|
||||
|
||||
sscanf(b, "%lf", &aa);
|
||||
a = aa;
|
||||
p = (int *) &a;
|
||||
printf("/* ");
|
||||
for (i = sizeof(longdouble)/sizeof(int); i--; p++)
|
||||
printf("0x%*x, ", xwidth, *p);
|
||||
printf(" scanf() */");
|
||||
if (a != m)
|
||||
printf(" /*!*/");
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
NUMBER *ten;
|
||||
NUMBER *x;
|
||||
longdouble unit;
|
||||
longdouble f, g;
|
||||
longdouble (*powtab)[2];
|
||||
int j, k;
|
||||
int n, low, high, step;
|
||||
int offset;
|
||||
int arg;
|
||||
|
||||
if (argc != 5 && argc != 6) {
|
||||
fprintf(stderr, "Usage: ypower [vg] low high step offset\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (argc == 5)
|
||||
arg = 1;
|
||||
else {
|
||||
arg = 2;
|
||||
for (j = 0; argv[1][j]; j++) {
|
||||
switch (argv[1][j]) {
|
||||
case 'v': verbose = 1; break;
|
||||
case 'g': guards = 1; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
low = atoi(argv[arg + 0]);
|
||||
high = atoi(argv[arg + 1]);
|
||||
step = atoi(argv[arg + 2]);
|
||||
offset = atoi(argv[arg + 3]);
|
||||
unit = toscale(offset);
|
||||
|
||||
if (low < 0 && (high >= 0 || step >= 0)) {
|
||||
fprintf(stderr, "Inconsistent negative powers\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (low >= 0 && (high < 0 || step < 0)) {
|
||||
fprintf(stderr, "Inconsistent positive powers\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
initbits();
|
||||
|
||||
printf("/* %d bit table generated by ypow10 */\n\n", ldbl_mant_bit);
|
||||
|
||||
if (low >= 0) {
|
||||
ten = newnumber();
|
||||
x = newnumber();
|
||||
setnumber(ten, 10);
|
||||
setnumber(x, 1);
|
||||
for (j = 0, n = low; n <= high; n += step) {
|
||||
for (; j < n; j++)
|
||||
multiply(x, ten);
|
||||
todouble(x, unit, &f, &g);
|
||||
dump(n, f, g);
|
||||
}
|
||||
}
|
||||
else {
|
||||
x = newnumber();
|
||||
setnumber(x, 1);
|
||||
setfixed(x, -high*8);
|
||||
powtab = (longdouble (*)[2]) xmalloc((low-high-step)/(-step)*sizeof(*powtab));
|
||||
for (k = j = 0, n = low; n >= high; n += step, k++) {
|
||||
for (; j > n; j--)
|
||||
fixdivint(x, 10);
|
||||
fixtodouble(x, unit, &powtab[k][0], &powtab[k][1]);
|
||||
}
|
||||
for (j = k; --j >= 0; ) {
|
||||
n -= step;
|
||||
dump(n, powtab[j][0], powtab[j][1]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
int main()
|
||||
|
||||
{
|
||||
return rename("a", "b");
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <errno.h>
|
||||
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
extern int __errlist;
|
||||
|
||||
int perror() {}
|
||||
|
||||
int main() { char *s; s = sys_errlist[0]; __errlist = sys_nerr; }
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
printf("unsigned ");
|
||||
if (sizeof(size_t) <= sizeof(unsigned short) &&
|
||||
sizeof(unsigned short) < sizeof(int))
|
||||
printf("short");
|
||||
else if (sizeof(size_t) <= sizeof(int))
|
||||
printf("int");
|
||||
else
|
||||
printf("long");
|
||||
putchar('\n');
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#ifndef __STDC__
|
||||
This is not ANSI C
|
||||
#endif
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
argv[i] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
FILE="$1"
|
||||
BASENAME=`basename $FILE .c`
|
||||
NAME=`echo $BASENAME | sed -e 's/[a-zA-Z0-9_]/& /g' -e 's/ *$//'`
|
||||
BYTES=`echo $NAME | wc -c`
|
||||
LPAD=`expr \( 74 - $BYTES \) / 2`
|
||||
RPAD=`expr 74 - $BYTES - $LPAD`
|
||||
(echo $LPAD $RPAD; echo "$NAME") | awk '
|
||||
BEGIN { line = 0; }
|
||||
{ if (line == 0) {
|
||||
lpad = 0 + $1;
|
||||
rpad = 0 + $2;
|
||||
line++;
|
||||
next;
|
||||
}
|
||||
else {
|
||||
printf("/*");
|
||||
for (i = 0; i < lpad; i++)
|
||||
printf(" ");
|
||||
printf("%s", $0);
|
||||
for (i = 0; i < rpad; i++)
|
||||
printf(" ");
|
||||
printf("*/\n");
|
||||
next;
|
||||
}
|
||||
}'
|
||||
@@ -0,0 +1,13 @@
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
double x;
|
||||
int i;
|
||||
|
||||
x = 1.9;
|
||||
|
||||
return (i = x) > x;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
int main()
|
||||
|
||||
{
|
||||
int x = ~0;
|
||||
void exit();
|
||||
|
||||
exit(((int) ((unsigned char) x)) == x);
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
char c;
|
||||
int i, j;
|
||||
|
||||
for (i = 0, j = 1; (c = j), c != 0; i++, j <<= 1)
|
||||
;
|
||||
printf("0x%x\n", j-1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
25
study/linux-travel/minix-386/estdio21.tar/estdio21/README
Normal file
25
study/linux-travel/minix-386/estdio21.tar/estdio21/README
Normal file
@@ -0,0 +1,25 @@
|
||||
EStdio Version 2.1
|
||||
|
||||
Copyright (c) 1990 Earl Chew
|
||||
|
||||
Feel free to copy, use and distribute this software provided:
|
||||
|
||||
1. you do not pretend that you wrote it
|
||||
2. you leave this copyright notice intact
|
||||
3. you do not attempt to make money from it.
|
||||
|
||||
Installation instructions are provided in the INSTALL directory. Test programs
|
||||
are provided in the FPTEST and TEST directories.
|
||||
|
||||
Thanks to Bruce Evans for putting up with the pre-release versions and for his
|
||||
suggestions and comments.
|
||||
|
||||
Version 2.1:
|
||||
30-Oct-1990 Fixed interpretation of precision for %g.
|
||||
Typo in _f_cvt.c [richard@aiai.ed.ac.uk (Richard Tobin)].
|
||||
Retry after partial writes.
|
||||
Make varargs conform to manual page.
|
||||
|
||||
Version 2.0a:
|
||||
03-Aug-1990 Changed __stdiosize_t unsigned check so ack won't complain.
|
||||
Bitten by truncated ack names again in exercise.c.
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
int ch;
|
||||
|
||||
while ((ch = getchar()) != EOF)
|
||||
putchar(ch);
|
||||
return ferror(stdout);
|
||||
}
|
||||
@@ -0,0 +1,836 @@
|
||||
/* E x e r c i s e
|
||||
*
|
||||
* This program exercises the stdio routines. It does not validate the
|
||||
* routines but provides a convenient way to quickly check the functionality
|
||||
* of the code.
|
||||
*/
|
||||
|
||||
#ifdef _BSD
|
||||
# include <strings.h>
|
||||
#else
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#define UCHAR(x) ((int) ((x) & 0xff))
|
||||
|
||||
#define DEC -123
|
||||
#define INT 255
|
||||
#define UNS (~0)
|
||||
#define TESTFILE "test.dat"
|
||||
#define LARGEBUFS 16
|
||||
#ifdef MSDOS
|
||||
# define TTY "con"
|
||||
#else
|
||||
# define TTY "/dev/tty"
|
||||
#endif
|
||||
|
||||
extern void *malloc(); /* memory allocator */
|
||||
extern unsigned sleep(); /* sleep routine */
|
||||
extern char *strcpy(); /* string copy */
|
||||
extern char *strcat(); /* string concatenation */
|
||||
extern int strcmp(); /* string compare */
|
||||
extern void exit(); /* exit */
|
||||
|
||||
FILE *fp; /* per test file pointer */
|
||||
|
||||
/*
|
||||
* Line Buffered Write Test
|
||||
*
|
||||
* Write to a terminal. This tests that the output buffer is
|
||||
* flushed on receipt of a \n.
|
||||
*/
|
||||
|
||||
void lbw_test()
|
||||
|
||||
{
|
||||
int i;
|
||||
|
||||
puts("\nLine buffered write test");
|
||||
if ((fp = fopen(TTY, "w")) != NULL) {
|
||||
puts("<pause>ABCDEFGH");
|
||||
puts("<pause>ABCD<pause>EFGH");
|
||||
for (i = 0; i < 8; i++)
|
||||
putc('A'+i, fp), sleep(1);
|
||||
putc('\n', fp);
|
||||
for (i = 0; i < 8; i++) {
|
||||
putc('A'+i, fp);
|
||||
if (i == 3)
|
||||
fflush(fp);
|
||||
sleep(1);
|
||||
}
|
||||
fclose(fp);
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Unbuffered Write Test
|
||||
*
|
||||
* Test that characters are written directly to the output device
|
||||
* when the stream is unbuffered.
|
||||
*/
|
||||
|
||||
void ubw_test()
|
||||
|
||||
{
|
||||
int i;
|
||||
|
||||
puts("\nUnbuffered write test");
|
||||
if ((fp = fopen(TTY, "w")) != NULL) {
|
||||
setbuf(fp, (char *) 0);
|
||||
puts("A<pause>B<pause>C<pause>D<pause>E<pause>F<pause>G<pause>H<pause>");
|
||||
puts("A<pause>B<pause>C<pause>D<pause>E<pause>F<pause>G<pause>H<pause>");
|
||||
for (i = 0; i < 8; i++)
|
||||
putc('A'+i, fp), sleep(1);
|
||||
putc('\n', fp);
|
||||
for (i = 0; i < 8; i++)
|
||||
putc('A'+i, fp), sleep(1);
|
||||
fclose(fp);
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Buffered Write Test
|
||||
*
|
||||
* Test that the data is written to the terminal on a per buffer
|
||||
* basis.
|
||||
*/
|
||||
|
||||
void bw_test()
|
||||
|
||||
{
|
||||
int i;
|
||||
|
||||
puts("\nFully buffered write test");
|
||||
if ((fp = fopen(TTY, "w")) != NULL) {
|
||||
setvbuf(fp, (char *) 0, _IOFBF, 4);
|
||||
puts("<pause>ABCD<pause>EFGH<pause>");
|
||||
puts("ABC<pause>DEFG<pause>H");
|
||||
for (i = 0; i < 8; i++)
|
||||
putc('A'+i, fp), sleep(1);
|
||||
putc('\n', fp);
|
||||
for (i = 0; i < 8; i++)
|
||||
putc('A'+i, fp), sleep(1);
|
||||
fclose(fp);
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
|
||||
/* Formatted Output Test
|
||||
*
|
||||
* This exercises the output formatting code.
|
||||
*/
|
||||
|
||||
void fp_test()
|
||||
|
||||
{
|
||||
int i, j, k, l;
|
||||
char buf[7];
|
||||
char *prefix = buf;
|
||||
char tp[20];
|
||||
|
||||
puts("\nFormatted output test");
|
||||
printf("prefix 6d 6o 6x 6X 6u\n");
|
||||
strcpy(prefix, "%");
|
||||
for (i = 0; i < 2; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
for (k = 0; k < 2; k++) {
|
||||
for (l = 0; l < 2; l++) {
|
||||
strcpy(prefix, "%");
|
||||
if (i == 0) strcat(prefix, "-");
|
||||
if (j == 0) strcat(prefix, "+");
|
||||
if (k == 0) strcat(prefix, "#");
|
||||
if (l == 0) strcat(prefix, "0");
|
||||
printf("%5s |", prefix);
|
||||
strcpy(tp, prefix);
|
||||
strcat(tp, "6d |");
|
||||
printf(tp, DEC);
|
||||
strcpy(tp, prefix);
|
||||
strcat(tp, "6o |");
|
||||
printf(tp, INT);
|
||||
strcpy(tp, prefix);
|
||||
strcat(tp, "6x |");
|
||||
printf(tp, INT);
|
||||
strcpy(tp, prefix);
|
||||
strcat(tp, "6X |");
|
||||
printf(tp, INT);
|
||||
strcpy(tp, prefix);
|
||||
strcat(tp, "6u |");
|
||||
printf(tp, UNS);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* String Output Test
|
||||
*
|
||||
* Test the string printf code.
|
||||
*/
|
||||
|
||||
void sw_test()
|
||||
|
||||
{
|
||||
int i;
|
||||
char buf[80];
|
||||
|
||||
puts("\nTest sprintf functionality");
|
||||
puts("13 bytes in 'Testing 1 2 3'");
|
||||
i = sprintf(buf, "Testing %d %d %d", 1, 2, 3);
|
||||
printf("%d bytes in '%s'\n", i, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* String Input Test
|
||||
*
|
||||
* Test the string scanf code.
|
||||
*/
|
||||
|
||||
void sr_test()
|
||||
|
||||
{
|
||||
int i, j;
|
||||
char buf[80];
|
||||
|
||||
puts("\nTest sscanf functionality");
|
||||
puts("2 items yielding 25 and 'thompson'");
|
||||
i = sscanf("25 thompson", "%d%s", &j, buf);
|
||||
printf("%d items yielding %d and '%s'\n", i, j, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* File Write and Read Test
|
||||
*
|
||||
* Test that a file can be written to and read from.
|
||||
*/
|
||||
|
||||
void frw_test()
|
||||
|
||||
{
|
||||
int i, j, k;
|
||||
char buf[80];
|
||||
|
||||
puts("\nFile write and read check");
|
||||
if ((fp = fopen(TESTFILE, "w")) != NULL) {
|
||||
puts("3 items yielding 56, 789 and '56'");
|
||||
puts("1 item yielding 'a72'");
|
||||
fprintf(fp, "56789 0123 56a72");
|
||||
if (freopen(TESTFILE, "r", fp) != fp)
|
||||
puts("Cannot open file for reading");
|
||||
else {
|
||||
i = fscanf(fp, "%2d%d%*d %[0-9]", &j, &k, buf);
|
||||
printf("%d items yielding %d, %d and '%s'\n", i, j, k, buf);
|
||||
i = fscanf(fp, "%s", buf);
|
||||
printf("%d item yielding '%s'\n", i, buf);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* File Seek Test
|
||||
*
|
||||
* Test that seek operations within files work.
|
||||
*/
|
||||
|
||||
void fs_test()
|
||||
|
||||
{
|
||||
int i, j;
|
||||
|
||||
puts("\nFile seek test");
|
||||
if ((fp = fopen(TESTFILE, "w")) != NULL) {
|
||||
for (i = 0; i < 256; i++)
|
||||
putc(i, fp);
|
||||
if (freopen(TESTFILE, "r", fp) != fp)
|
||||
puts("Cannot open file for reading");
|
||||
else {
|
||||
for (i = 1; i <= 255; i++) {
|
||||
printf("\r%3d ", i);
|
||||
fflush(stdout);
|
||||
fseek(fp, (long) -i, SEEK_END);
|
||||
if ((j = getc(fp)) != 256-i) {
|
||||
printf("SEEK_END failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
if (fseek(fp, (long) i, SEEK_SET)) {
|
||||
puts("Cannot SEEK_SET");
|
||||
break;
|
||||
}
|
||||
if ((j = getc(fp)) != i) {
|
||||
printf("SEEK_SET failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
if (fseek(fp, (long) i, SEEK_SET)) {
|
||||
puts("Cannot SEEK_SET");
|
||||
break;
|
||||
}
|
||||
if (fseek(fp, (long) (i >= 128 ? -128 : 128), SEEK_CUR)) {
|
||||
puts("Cannot SEEK_CUR");
|
||||
break;
|
||||
}
|
||||
if ((j = getc(fp)) != (i >= 128 ? i-128 : i+128)) {
|
||||
printf("SEEK_CUR failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > 255)
|
||||
puts("ok");
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test gets()
|
||||
*
|
||||
* Checks that gets() works.
|
||||
*/
|
||||
|
||||
void gets_test()
|
||||
|
||||
{
|
||||
char buf[80];
|
||||
|
||||
puts("\nGets functionality");
|
||||
puts("... Type a line and have it echoed ...");
|
||||
gets(buf);
|
||||
puts(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fputs Test
|
||||
*
|
||||
* Check that fputs() works into unbuffered streams.
|
||||
*/
|
||||
|
||||
void fputs_test()
|
||||
|
||||
{
|
||||
puts("\nUnbuffered fputs test");
|
||||
if ((fp = fopen(TTY, "w")) != NULL) {
|
||||
setbuf(fp, (char *) 0);
|
||||
puts("ABCDEFGH<pause>");
|
||||
puts("ABCDEFGH<pause>");
|
||||
fputs("ABCDEFGH", fp), sleep(1);
|
||||
fputs("\nABCDEFGH", fp), sleep(1);
|
||||
fclose(fp);
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fprintf Test
|
||||
*
|
||||
* Check that fprintf() works into unbuffered streams.
|
||||
*/
|
||||
|
||||
void fprint_test()
|
||||
|
||||
{
|
||||
puts("\nUnbuffered fprintf test");
|
||||
if ((fp = fopen(TTY, "w")) != NULL) {
|
||||
setbuf(fp, (char *) 0);
|
||||
puts("ABCDEFGH<pause>");
|
||||
puts("ABCDEFGH<pause>");
|
||||
fprintf(fp, "ABCDEFGH"), sleep(1);
|
||||
fprintf(fp, "\nABCDEFGH"), sleep(1);
|
||||
fclose(fp);
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fgets Test
|
||||
*
|
||||
* Check that fgets() works.
|
||||
*/
|
||||
|
||||
void fgets_test()
|
||||
|
||||
{
|
||||
char buf[80];
|
||||
|
||||
puts("\nFgets functionality");
|
||||
puts("a");
|
||||
puts("<pause>ab");
|
||||
puts("<pause>abc");
|
||||
puts("<pause>abcd");
|
||||
puts("<pause>abcde");
|
||||
puts("<pause>abcdef");
|
||||
puts("<pause>abcdefg<pause>");
|
||||
puts("<pause>abcdefg<pause>h");
|
||||
if ((fp = fopen(TESTFILE, "w")) != NULL) {
|
||||
fputs("a\n", fp);
|
||||
fputs("ab\n", fp);
|
||||
fputs("abc\n", fp);
|
||||
fputs("abcd\n", fp);
|
||||
fputs("abcde\n", fp);
|
||||
fputs("abcdef\n", fp);
|
||||
fputs("abcdefg\n", fp);
|
||||
fputs("abcdefgh\n", fp);
|
||||
fclose(fp);
|
||||
if ((fp = fopen(TESTFILE, "r")) != NULL) {
|
||||
while (fgets(buf, 8, fp) != NULL) {
|
||||
fputs(buf, stdout);
|
||||
fflush(stdout);
|
||||
sleep(1);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Word Read and Write Test
|
||||
*
|
||||
* Check that putw and getw work.
|
||||
*/
|
||||
|
||||
void word_test()
|
||||
|
||||
{
|
||||
int i, j;
|
||||
|
||||
puts("\nPutw and Readw Test");
|
||||
if ((fp = fopen(TESTFILE, "w")) != NULL) {
|
||||
for (i = 0; i < 256; i++)
|
||||
putw(i, fp);
|
||||
putc(0, fp);
|
||||
fclose(fp);
|
||||
if ((fp = fopen(TESTFILE, "r")) != NULL) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
printf("\r%3d", i);
|
||||
fflush(stdout);
|
||||
if ((j = getw(fp)) != i) {
|
||||
printf(" failed %d", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 256 /* && getw(fp) == EOF && feof(fp)*/)
|
||||
fputs(" ok", stdout);
|
||||
puts("");
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Append Test
|
||||
*
|
||||
* Check that appends go to the end of the file.
|
||||
*/
|
||||
|
||||
void a_test()
|
||||
|
||||
{
|
||||
int ch;
|
||||
|
||||
puts("\nAppend Test");
|
||||
if ((fp = fopen(TESTFILE, "w")) != NULL) {
|
||||
putc('a', fp);
|
||||
if ((fp = freopen(TESTFILE, "a", fp)) == NULL) {
|
||||
puts("Cannot freopen file");
|
||||
return;
|
||||
}
|
||||
if (fseek(fp, 0L, 0) == EOF) {
|
||||
puts("Cannot fseek to start");
|
||||
return;
|
||||
}
|
||||
putc('@', fp);
|
||||
if ((fp = freopen(TESTFILE, "r", fp)) == NULL) {
|
||||
puts("Cannot freopen file");
|
||||
return;
|
||||
}
|
||||
if ((ch = getc(fp)) != 'a')
|
||||
printf("Failed a - %c\n", ch);
|
||||
else if ((ch = getc(fp)) != '@')
|
||||
printf("Failed @ - %c\n", ch);
|
||||
else if ((ch = getc(fp)) != EOF)
|
||||
printf("Failed EOF - %d\n", ch);
|
||||
else
|
||||
puts("Ok");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write and Read Update Test
|
||||
*
|
||||
* Write a file in update mode, then try to read it.
|
||||
*/
|
||||
|
||||
void uwr_test()
|
||||
|
||||
{
|
||||
int i, j;
|
||||
|
||||
puts("\nWrite and Read Update Test");
|
||||
if ((fp = fopen(TESTFILE, "w+")) != NULL) {
|
||||
for (i = 0; i < (3*BUFSIZ)/2; i++)
|
||||
putc(i, fp);
|
||||
rewind(fp);
|
||||
for (i = 0; i < (3*BUFSIZ)/2; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
j = getc(fp);
|
||||
if (j != UCHAR(i)) {
|
||||
printf(" failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == (3*BUFSIZ)/2)
|
||||
puts(" ok");
|
||||
if (getc(fp) != EOF)
|
||||
puts(" failed to find eof");
|
||||
else {
|
||||
for (i = 0; i < BUFSIZ/2; i++)
|
||||
putc(i, fp);
|
||||
fseek(fp, (long) (3*BUFSIZ)/2, SEEK_SET);
|
||||
for (i = 0; i < BUFSIZ/2; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
j = getc(fp);
|
||||
if (j != UCHAR(i)) {
|
||||
printf(" failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == BUFSIZ/2)
|
||||
puts(" ok");
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write, Append and Read Update Test
|
||||
*
|
||||
* Write a file in update mode, close it, append to it and read it.
|
||||
*/
|
||||
|
||||
void uawr_test()
|
||||
|
||||
{
|
||||
int i, j;
|
||||
|
||||
puts("\nWrite, Append and Read Update Test");
|
||||
if ((fp = fopen(TESTFILE, "w")) != NULL) {
|
||||
for (i = 0; i < (3*BUFSIZ)/2; i++)
|
||||
putc(i, fp);
|
||||
fclose(fp);
|
||||
if ((fp = fopen(TESTFILE, "a+")) != NULL) {
|
||||
for (i = 0; i < BUFSIZ/2; i++)
|
||||
putc(i, fp);
|
||||
fseek(fp, (long) (3*BUFSIZ)/2, SEEK_SET);
|
||||
for (i = 0; i < BUFSIZ/2; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
j = getc(fp);
|
||||
if (j != UCHAR(i)) {
|
||||
printf(" failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == BUFSIZ/2)
|
||||
puts(" ok");
|
||||
rewind(fp);
|
||||
for (i = 0; i < (3*BUFSIZ)/2; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
j = getc(fp);
|
||||
if (j != UCHAR(i)) {
|
||||
printf(" failed at %d\n", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == (3*BUFSIZ)/2)
|
||||
puts(" ok");
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write, Read, Write and Read Update Test
|
||||
*
|
||||
* Write a file in update mode, read it, write it and read it.
|
||||
*/
|
||||
|
||||
void uwrwr_test()
|
||||
|
||||
{
|
||||
int i, j;
|
||||
|
||||
puts("\nWrite, Read, Write and Read Update Test");
|
||||
if ((fp = fopen(TESTFILE, "w")) != NULL) {
|
||||
for (i = 0; i < (3*BUFSIZ)/2; i++)
|
||||
putc(i, fp);
|
||||
fclose(fp);
|
||||
if ((fp = fopen(TESTFILE, "r+")) != NULL) {
|
||||
for (i = 0; i < (3*BUFSIZ)/2; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
j = getc(fp);
|
||||
if (j != UCHAR(i)) {
|
||||
printf(" failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == (3*BUFSIZ)/2)
|
||||
puts(" ok");
|
||||
if (getc(fp) != EOF)
|
||||
puts(" failed to find eof");
|
||||
else {
|
||||
for (i = 0; i < BUFSIZ/2; i++)
|
||||
putc(i, fp);
|
||||
rewind(fp);
|
||||
for (i = 0; i < (3*BUFSIZ)/2; i++)
|
||||
putc((3*BUFSIZ)/2-i, fp);
|
||||
fseek(fp, (long) (3*BUFSIZ)/2, SEEK_SET);
|
||||
for (i = 0; i < BUFSIZ/2; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
j = getc(fp);
|
||||
if (j != UCHAR(i)) {
|
||||
printf(" failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == BUFSIZ/2)
|
||||
puts(" ok");
|
||||
rewind(fp);
|
||||
for (i = 0; i < (3*BUFSIZ)/2; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
j = getc(fp);
|
||||
if (j != UCHAR((3*BUFSIZ)/2-i)) {
|
||||
printf(" failed %d\n", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == (3*BUFSIZ)/2)
|
||||
puts(" ok");
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fwrite Test
|
||||
*
|
||||
* Test fwrite with small loads and large loads.
|
||||
*/
|
||||
|
||||
void fwrite_test()
|
||||
|
||||
{
|
||||
unsigned int i, j;
|
||||
char buf[1023];
|
||||
char bbuf[3071];
|
||||
double sqrt();
|
||||
void free();
|
||||
char *p;
|
||||
|
||||
puts("\nFwrite Test");
|
||||
if ((fp = fopen(TESTFILE, "w+")) != NULL) {
|
||||
|
||||
for (i = 0; i < sizeof(buf); i++)
|
||||
buf[i] = i;
|
||||
for (i = 0; i < sizeof(bbuf); i++)
|
||||
bbuf[i] = 19-i;
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
if (fwrite(buf, 1, sizeof(buf), fp) != sizeof(buf)) {
|
||||
puts(" failed\n");
|
||||
return;
|
||||
}
|
||||
putc(0, fp);
|
||||
}
|
||||
puts(" small write ok");
|
||||
rewind(fp);
|
||||
for (i = 0; i < 256; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
for (j = 0; j < sizeof(buf); j++) {
|
||||
if (getc(fp) != UCHAR(j)) {
|
||||
puts(" failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (getc(fp) != 0) {
|
||||
puts(" failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
puts(" verified ok");
|
||||
|
||||
rewind(fp);
|
||||
for (i = 0; i < 256; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
if (fwrite(bbuf, 1, sizeof(bbuf), fp) != sizeof(bbuf)) {
|
||||
puts(" failed\n");
|
||||
return;
|
||||
}
|
||||
putc(0, fp);
|
||||
}
|
||||
puts(" large write ok");
|
||||
rewind(fp);
|
||||
for (i = 0; i < 256; i++) {
|
||||
printf("\r%4d", i);
|
||||
fflush(stdout);
|
||||
for (j = 0; j < sizeof(bbuf); j++) {
|
||||
if (getc(fp) != UCHAR(19-j)) {
|
||||
puts(" failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (getc(fp) != 0) {
|
||||
puts(" failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
puts(" verified ok");
|
||||
|
||||
rewind(fp);
|
||||
if ((p = (char *) malloc(48*1024)) == 0) {
|
||||
puts("No memory for large write test");
|
||||
return;
|
||||
}
|
||||
for (j = 13, i = 48*1024; --i; j++)
|
||||
p[i] = j;
|
||||
fwrite(p, 48*1024, 1, fp);
|
||||
rewind(fp);
|
||||
for (i = 48*1024; --i; )
|
||||
p[i] = 0;
|
||||
fread(p, 48*1024, 1, fp);
|
||||
for (j = 13, i = 48*1024; --i; j++) {
|
||||
if (i % 1024 == 0) {
|
||||
printf("\r%5u", i);
|
||||
fflush(stdout);
|
||||
}
|
||||
if (p[i] != (char) j) {
|
||||
printf("\r%5u failed %d instead of %d\n", i, p[i], UCHAR(j));
|
||||
free(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
printf("\r%5u ok\n", i);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test the exit code
|
||||
*
|
||||
* Load an exit handler and check buffer flushing.
|
||||
*/
|
||||
|
||||
static void handler()
|
||||
|
||||
{
|
||||
fputs("Exit handler called ok\n", fp);
|
||||
fflush(fp);
|
||||
fputs("Buffer flush ok\n", fp);
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
void exit_test()
|
||||
|
||||
{
|
||||
int atexit();
|
||||
|
||||
puts("\nExit Test");
|
||||
if ((fp = fopen(TTY, "w")) == NULL) {
|
||||
puts("Cannot open tty for exit test");
|
||||
return;
|
||||
}
|
||||
setvbuf(fp, (char *) 0, _IOFBF, BUFSIZ);
|
||||
if (atexit(handler) != 0)
|
||||
puts("Exit handler not lodged");
|
||||
}
|
||||
|
||||
/* Temporary File Test
|
||||
*
|
||||
* Check the names produced by tmpnam.
|
||||
*/
|
||||
|
||||
void tmp_test()
|
||||
|
||||
{
|
||||
int i;
|
||||
char buf[20];
|
||||
char *tf;
|
||||
|
||||
puts("\nTemporary File Names");
|
||||
for (i = 10; i--; ) {
|
||||
tf = tmpnam((char *) 0);
|
||||
fputs(tf, stdout);
|
||||
if (strlen(tf) == L_tmpnam-1)
|
||||
puts(" ok");
|
||||
else
|
||||
puts(" failed");
|
||||
}
|
||||
if ((fp = tmpfile()) == 0) {
|
||||
puts("Cannot make temporary file");
|
||||
return;
|
||||
}
|
||||
printf("Temporary file");
|
||||
fputs("123456", fp);
|
||||
rewind(fp);
|
||||
fgets(buf, 20, fp);
|
||||
if (strcmp(buf, "123456") != 0)
|
||||
puts(" failed");
|
||||
else
|
||||
puts(" ok");
|
||||
}
|
||||
|
||||
/* Id test
|
||||
*/
|
||||
|
||||
void id_test()
|
||||
|
||||
{
|
||||
fputs("User id : ", stdout);
|
||||
puts(cuserid((char *) 0));
|
||||
fputs("Terminal : ", stdout);
|
||||
puts(ctermid((char *) 0));
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
id_test();
|
||||
lbw_test();
|
||||
ubw_test();
|
||||
bw_test();
|
||||
fp_test();
|
||||
sw_test();
|
||||
sr_test();
|
||||
frw_test();
|
||||
fs_test();
|
||||
fputs_test();
|
||||
fprint_test();
|
||||
gets_test();
|
||||
fgets_test();
|
||||
word_test();
|
||||
fwrite_test();
|
||||
a_test();
|
||||
uwr_test();
|
||||
uawr_test();
|
||||
uwrwr_test();
|
||||
tmp_test();
|
||||
exit_test();
|
||||
remove(TESTFILE);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
int main()
|
||||
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int atoi();
|
||||
|
||||
i = atoi(argv[1]);
|
||||
|
||||
while (i--)
|
||||
for (j = 1024/16; j; j--)
|
||||
fputs("123456789012345\n", stdout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
char *malloc();
|
||||
void exit();
|
||||
char *b;
|
||||
int j;
|
||||
int atoi();
|
||||
|
||||
if ((b = malloc(48*1024)) == 0) {
|
||||
puts("No memory for buffer");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
j = atoi(argv[1]);
|
||||
while (j) {
|
||||
if (j > 48) {
|
||||
fwrite(b, 1023, 48, stdout);
|
||||
j -= 48;
|
||||
}
|
||||
else {
|
||||
fwrite(b, 1023, 1, stdout);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int atoi();
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
i = atoi(argv[1]);
|
||||
|
||||
while (i--)
|
||||
for (j = 1024/16; j; j--)
|
||||
fputs("123456789012345\n", stdout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int atoi();
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
i = atoi(argv[1]);
|
||||
while (i--) {
|
||||
for (j = 1024/(4*16); j; j--) {
|
||||
printf("123456789012345\n\
|
||||
%15s\n\
|
||||
%15d\n\
|
||||
%15ld\n",
|
||||
"Test Test", 0x7fff, 0x7fffffffL);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
|
||||
extern int errno;
|
||||
|
||||
int main()
|
||||
|
||||
{
|
||||
errno = -5;
|
||||
perror("Error 1 is ");
|
||||
errno = 65536;
|
||||
perror("Error 2 is ");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int atoi();
|
||||
|
||||
i = atoi(argv[1]);
|
||||
while (i--) {
|
||||
for (j = 1024/(4*16); j; j--) {
|
||||
printf("123456789012345\n\
|
||||
%15s\n\
|
||||
%15d\n\
|
||||
%15ld\n",
|
||||
"Test Test", 0x7fff, 0x7fffffffL);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int atoi();
|
||||
|
||||
i = atoi(argv[1]);
|
||||
|
||||
while (i--)
|
||||
for (j = 1024/16; j; j--)
|
||||
printf("123456789012345\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
int i, j;
|
||||
int atoi();
|
||||
|
||||
i = atoi(argv[1]);
|
||||
while (i--)
|
||||
for (j = 512; j; j--) {
|
||||
putchar('a');
|
||||
putchar('\n');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int atoi();
|
||||
|
||||
i = atoi(argv[1]);
|
||||
|
||||
while (i--)
|
||||
for (j = 1024/16; j; j--) {
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('1');
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int atoi();
|
||||
char buf[1024];
|
||||
|
||||
i = atoi(argv[1]);
|
||||
while (i--) {
|
||||
for (j = 1024/(4*16); j; j--) {
|
||||
sprintf(buf, "123456789012345\n\
|
||||
%15s\n\
|
||||
%15d\n\
|
||||
%15ld\n",
|
||||
"Test Test", 0x7fff, 0x7fffffffL);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(argc, argv)
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{
|
||||
long d;
|
||||
int i, j;
|
||||
int atoi();
|
||||
|
||||
i = atoi(argv[1]);
|
||||
while (i--) {
|
||||
for (j = 1024/((7 + 6 + 5) * 3 * 16); j; j--) {
|
||||
for (d = 1; d < 10000000L; d *= 10)
|
||||
printf("%15ld %15lx %15lo\n", d, d, d);
|
||||
for (d = 1; d < 0x1000000L; d <<= 4)
|
||||
printf("%15ld %15lx %15lo\n", d, d, d);
|
||||
for (d = 1; d < 0100000L; d <<= 3)
|
||||
printf("%15ld %15lx %15lo\n", d, d, d);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#/bin/sh
|
||||
|
||||
echo -n "ten "
|
||||
echo `/bin/time ./ten 256 2>&1 >/dev/null`
|
||||
echo -n "putc "
|
||||
echo `/bin/time ./putc 256 2>&1 >/dev/null`
|
||||
echo -n "fputs "
|
||||
echo `/bin/time ./fputs 256 2>&1 >/dev/null`
|
||||
echo -n "nfputs "
|
||||
echo `/bin/time ./nfputs 256 2>&1 >/dev/null`
|
||||
echo -n "fwrite "
|
||||
echo `/bin/time ./fwrite 256 2>&1 >/dev/null`
|
||||
echo -n "sprintf "
|
||||
echo `/bin/time ./sprintf 256 2>&1 >/dev/null`
|
||||
echo -n "printf "
|
||||
echo `/bin/time ./printf 256 2>&1 >/dev/null`
|
||||
echo -n "nprintf "
|
||||
echo `/bin/time ./nprintf 256 2>&1 >/dev/null`
|
||||
echo -n "printfs "
|
||||
echo `/bin/time ./printfs 256 2>&1 >/dev/null`
|
||||
echo -n "putchar "
|
||||
echo `/bin/time ./putchar 256 2>&1 >/dev/null`
|
||||
@@ -0,0 +1,53 @@
|
||||
/* _ a l l o c b u f */
|
||||
|
||||
/* Malloc a buffer for a stream. Unbuffered streams use the built
|
||||
* in buffers. Streams connected to terminals use small buffers.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
__stdiosize_t __allocbuf F1(register FILE *,fp)
|
||||
|
||||
{
|
||||
register int i; /* pool scanner */
|
||||
|
||||
if (! TESTFLAG(fp, _IONBF)) {
|
||||
fp->__bufsiz = BUFSIZ;
|
||||
|
||||
if (isatty(fileno(fp))) {
|
||||
fp->__bufsiz = TTYBUFSIZ;
|
||||
if (TESTFLAG(fp, _IOWRITE))
|
||||
SETFLAG(fp, _IOLBF);
|
||||
}
|
||||
|
||||
#if TTYBUFSIZ > BUFSIZ
|
||||
<< TTYBUFSIZE overruns BUFSIZ for buffer pool >>
|
||||
#endif
|
||||
|
||||
for (i = 0; i < POOLSIZE; i++) {
|
||||
if (__iob[i] != NULL) {
|
||||
fp->__base = __iob[i];
|
||||
__iob[i] = NULL;
|
||||
SETFLAG(fp, _IOPOOLBUF);
|
||||
goto Gotbuffer;
|
||||
}
|
||||
}
|
||||
|
||||
if ((fp->__base = (__stdiobuf_t *) malloc(BUFSIZ)) != NULL)
|
||||
SETFLAG(fp, _IOMYBUF);
|
||||
else {
|
||||
CLEARFLAG(fp, (_IOFBF | _IOLBF));
|
||||
SETFLAG(fp, _IONBF);
|
||||
}
|
||||
}
|
||||
|
||||
if (TESTFLAG(fp, _IONBF)) {
|
||||
fp->__base = &fp->__buf;
|
||||
fp->__bufsiz = sizeof(fp->__buf);
|
||||
}
|
||||
|
||||
Gotbuffer:
|
||||
return fp->__bufsiz;
|
||||
}
|
||||
32
study/linux-travel/minix-386/estdio21.tar/estdio21/_bfs.c
Normal file
32
study/linux-travel/minix-386/estdio21.tar/estdio21/_bfs.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* _ b f s */
|
||||
|
||||
/* These are dummy functions that are used to return default success
|
||||
* or failure values.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
/*ARGSUSED*/
|
||||
|
||||
int __bffls F2(int, ch, FILE *, fp)
|
||||
|
||||
{
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
|
||||
int __bffil F1(FILE *, fp)
|
||||
|
||||
{
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
|
||||
int __btfls F1(FILE *, fp)
|
||||
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
88
study/linux-travel/minix-386/estdio21.tar/estdio21/_bread.c
Normal file
88
study/linux-travel/minix-386/estdio21.tar/estdio21/_bread.c
Normal file
@@ -0,0 +1,88 @@
|
||||
/* _ b r e a d */
|
||||
|
||||
/* This set of routines replaces the original __filbuf() function. The
|
||||
* FILE structure vectors the fill call to the appropriate routine.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
/* Fill read buffer
|
||||
*
|
||||
* __brd is the main function that fills the output buffer
|
||||
* then reads a character.
|
||||
*/
|
||||
static int __brd F1(register FILE *, fp)
|
||||
|
||||
{
|
||||
register int bytes; /* bytes read */
|
||||
|
||||
bytes = 0;
|
||||
|
||||
if (GETFLAG(fp, (_IOREAD | _IOERR | _IOEOF)) == _IOREAD) {
|
||||
|
||||
/* Flush related output stream */
|
||||
if (GETFLAG(fp, _IOSTDX) == _IOSTDIN && __Zout != NULL &&
|
||||
(ALLFLAGS(fp) & ALLFLAGS(__Zout) & _IOLBF) != 0)
|
||||
(void) FFLUSH(__Zout);
|
||||
|
||||
/* Read data into the buffer */
|
||||
bytes = __ioread(fileno(fp), (char *) fp->__base,
|
||||
TESTFLAG(fp, _IONBF) ? 1 : fp->__bufsiz);
|
||||
|
||||
if (bytes <= 0) {
|
||||
SETFLAG(fp, bytes ? (_IOERR|_IOEOF) : _IOEOF);
|
||||
bytes = 0;
|
||||
}
|
||||
else if (TESTFLAG(fp, _IOLBF) &&
|
||||
__Zrlbf != (__stdiosize_t (*) P((FILE *, __stdiosize_t))) NULL)
|
||||
bytes = (*__Zrlbf)(fp, bytes);
|
||||
|
||||
INITREADBUFFER(fp, bytes);
|
||||
}
|
||||
|
||||
return bytes ? FGETC(fp) : EOF;
|
||||
}
|
||||
|
||||
/* Flush a read buffer
|
||||
*
|
||||
* __brdflush is a function that flushes the input buffer.
|
||||
*/
|
||||
static int __brdflush F1(register FILE *, fp)
|
||||
|
||||
{
|
||||
if (! TESTFLAG(fp, _IOERR)) {
|
||||
if (! TESTFLAG(fp, _IOEOF) &&
|
||||
lseek(fileno(fp), (long) (-BYTESINREADBUFFER(fp)), SEEK_CUR) == -1L)
|
||||
SETFLAG(fp, _IOERR);
|
||||
INITREADBUFFER(fp, 0);
|
||||
return 0;
|
||||
}
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* Check and initialise a readonly stream
|
||||
*
|
||||
* __brdonly is intended for read only streams. It will check
|
||||
* that the stream has a buffer. The fill function will then
|
||||
* be directed to __brd.
|
||||
*/
|
||||
int __brdonly F1(register FILE *, fp)
|
||||
|
||||
{
|
||||
__stdiobuf_t *p; /* pointer to end */
|
||||
|
||||
p = fp->__rend;
|
||||
|
||||
if (TESTFLAG(fp, _IOINSERT)) {
|
||||
CLEARFLAG(fp, _IOINSERT);
|
||||
FINSERT(fp);
|
||||
}
|
||||
|
||||
INITREADBUFFER(fp, 0);
|
||||
SETFILBUF(fp, __brd);
|
||||
SETFLUSH(fp, __brdflush);
|
||||
|
||||
return p ? 0 : __brd(fp);
|
||||
}
|
||||
112
study/linux-travel/minix-386/estdio21.tar/estdio21/_bwrite.c
Normal file
112
study/linux-travel/minix-386/estdio21.tar/estdio21/_bwrite.c
Normal file
@@ -0,0 +1,112 @@
|
||||
/* _ b w r i t e */
|
||||
|
||||
/* This set of routines replaces the original __flsbuf() function. The
|
||||
* FILE structure vectors the flush call to the appropriate routine.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
/* Flush all streams
|
||||
*
|
||||
* Flushes all output buffers. This ensures that all streams
|
||||
* are written out and closed. It's main purpose is to ensure
|
||||
* that all streams are flushed on exit. exit() knows about
|
||||
* the existence of __ioflush.
|
||||
*/
|
||||
void __ioflush F0()
|
||||
|
||||
{
|
||||
register FILE *fp; /* pointer to current descriptor */
|
||||
|
||||
for (fp = __iop; fp != NULL; fp = fp->__next) {
|
||||
(void) FFLUSH(fp);
|
||||
(void) close(fileno(fp));
|
||||
}
|
||||
}
|
||||
|
||||
/* Flush a write buffer and write a character
|
||||
*
|
||||
* __bwr is the main function that flushes the output buffer
|
||||
* then writes a character.
|
||||
*/
|
||||
static int __bwr F2(register int, c, register FILE *, fp)
|
||||
|
||||
{
|
||||
if (GETFLAG(fp, (_IOWRITE | _IOERR)) == _IOWRITE) {
|
||||
for (;;) {
|
||||
if (UNUSEDINWRITEBUFFER(fp) > 0) {
|
||||
if (((FPUTC(c, fp) != '\n' || ! TESTFLAG(fp, _IOLBF)) &&
|
||||
! TESTFLAG(fp, _IONBF)) || ! FFLUSH(fp))
|
||||
return UCHAR(c);
|
||||
break;
|
||||
}
|
||||
if (FFLUSH(fp))
|
||||
break;
|
||||
}
|
||||
}
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* Flush a write buffer
|
||||
*
|
||||
* __bwrflush is a function that flushes the output buffer.
|
||||
*/
|
||||
static int __bwrflush F1(register FILE *, fp)
|
||||
|
||||
{
|
||||
register __stdiosize_t length; /* bytes to write */
|
||||
|
||||
if (! TESTFLAG(fp, _IOERR)
|
||||
#ifndef OPEN3
|
||||
&& (! TESTFLAG(fp, _IOAPPEND) || lseek(fileno(fp), 0L, SEEK_END) != -1L)
|
||||
#endif
|
||||
) {
|
||||
length = BYTESINWRITEBUFFER(fp);
|
||||
INITWRITEBUFFER(fp);
|
||||
if (__iowrite(fileno(fp), (char *) fp->__base, length) == length)
|
||||
return 0;
|
||||
}
|
||||
SETFLAG(fp, _IOERR);
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* Check and initialise a writeonly stream
|
||||
*
|
||||
* __bwronly is intended for write only streams. It will check
|
||||
* that the stream has a buffer. The flush function will then
|
||||
* be directed to __bwr.
|
||||
*/
|
||||
int __bwronly F2(int, c, register FILE *, fp)
|
||||
|
||||
{
|
||||
__stdiobuf_t *p; /* pointer to end */
|
||||
int streamtype; /* type of stream */
|
||||
|
||||
p = fp->__wend;
|
||||
|
||||
__Zwrapup = __ioflush;
|
||||
|
||||
if ((streamtype = GETFLAG(fp, _IOSTDX)) == _IOSTDOUT)
|
||||
__Zout = fp;
|
||||
else if (streamtype == _IOSTDERR)
|
||||
__Zerr = fp;
|
||||
|
||||
if (TESTFLAG(fp, _IOINSERT)) {
|
||||
CLEARFLAG(fp, _IOINSERT);
|
||||
FINSERT(fp);
|
||||
if (__Zout == fp && isatty(fileno(fp))) {
|
||||
#if _IOFBF != 0
|
||||
CLEARFLAG(fp, _IOFBF);
|
||||
#endif
|
||||
SETFLAG(fp, _IOLBF);
|
||||
}
|
||||
}
|
||||
|
||||
INITWRITEBUFFER(fp);
|
||||
SETFLSBUF(fp, __bwr);
|
||||
SETFLUSH(fp, __bwrflush);
|
||||
|
||||
return p ? 0 : __bwr(c, fp);
|
||||
}
|
||||
11
study/linux-travel/minix-386/estdio21.tar/estdio21/_err.c
Normal file
11
study/linux-travel/minix-386/estdio21.tar/estdio21/_err.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/* _ e r r */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
FILE __stderr = {NULL, NULL, NULL, NULL,
|
||||
&__stderr.__buf, 1,
|
||||
_IOSTDERR|_IOINSERT|_IOWRITE|_IONBF,
|
||||
STDERR_FILENO, 0,
|
||||
__bffil, __bwronly, __btfls, NULL};
|
||||
@@ -0,0 +1,21 @@
|
||||
/* _ e r r l i s t */
|
||||
|
||||
/* This encodes a table of system error messages for perror.
|
||||
* The error messages themselves are stored as a sequence
|
||||
* of strings in errlist.h. This code is conditionally
|
||||
* compiled since we prefer to use the one in the system itself.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#ifdef ERRLIST
|
||||
int __errlist = 1; /* installation flag */
|
||||
|
||||
char *sys_errlist[] = {
|
||||
#include "errlist.h"
|
||||
};
|
||||
|
||||
int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]);
|
||||
#endif
|
||||
479
study/linux-travel/minix-386/estdio21.tar/estdio21/_f_cvt.c
Normal file
479
study/linux-travel/minix-386/estdio21.tar/estdio21/_f_cvt.c
Normal file
@@ -0,0 +1,479 @@
|
||||
/* _ f _ c v t */
|
||||
|
||||
/* This code implements the %f, %g and %e formats for output conversion
|
||||
* of floating point numbers. It is called from _vfprintf().
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
#include <math.h>
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#if '0'+1 != '1' || '1'+1 != '2' || '2'+1 != '3' || '3'+1 != '4' || \
|
||||
'4'+1 != '5' || '5'+1 != '6' || '6'+1 != '7' || '7'+1 != '8' || \
|
||||
'8'+1 != '9'
|
||||
<< Violation of collating sequence assumption >>
|
||||
#endif
|
||||
|
||||
#define LOG_10_2 (0.301029996) /* log_10(2) */
|
||||
|
||||
char __xfpcvt = 0; /* linkage for library */
|
||||
|
||||
/* Break into sign, mantissa and exponent
|
||||
*
|
||||
* The mantissa and exponent are extracted (base 10). This requires
|
||||
* some conversion from the internal floating point representation.
|
||||
*/
|
||||
|
||||
static void __signmanexp F4(longdouble, x, int *, s, longdouble *, m, int *, e)
|
||||
|
||||
{
|
||||
int exp; /* exponent */
|
||||
int expoffset; /* exponent offset */
|
||||
unsigned int uxp; /* absolute value of exponent */
|
||||
int exp10; /* exponent base 10 */
|
||||
longdouble fexp10; /* floating exponent base 10 */
|
||||
longdouble mantissa; /* extracted mantissa */
|
||||
|
||||
/* Take absolute value */
|
||||
*s = 0;
|
||||
if (x < 0.0) {
|
||||
*s = 1;
|
||||
x = -x;
|
||||
}
|
||||
|
||||
/* Break into mantissa and exponent */
|
||||
(void) LFREXP(x, &exp);
|
||||
|
||||
/* Scale exponent 1.0 <= man < 2.0 */
|
||||
if (x != 0)
|
||||
exp--;
|
||||
|
||||
/* Generate magnitude for scaling */
|
||||
expoffset = 0;
|
||||
uxp = exp >= 0 ? exp : -exp;
|
||||
fexp10 = LOG_10_2 * uxp;
|
||||
exp10 = (int) fexp10;
|
||||
#ifndef TRUNCATE
|
||||
if (exp10 > fexp10)
|
||||
exp10--;
|
||||
#endif
|
||||
if (exp < 0)
|
||||
exp10 = -exp10;
|
||||
|
||||
/* Divide or multiply by scale to obtain mantissa */
|
||||
for (;;) {
|
||||
|
||||
/* Check for denormalised operands */
|
||||
if (exp10 < LDBL_MIN_10_EXP) {
|
||||
#ifdef DENORMAL
|
||||
x *= __pow10(LDBL_MIN_10_EXP - exp10);
|
||||
expoffset -= LDBL_MIN_10_EXP - exp10;
|
||||
exp10 = LDBL_MIN_10_EXP;
|
||||
#else
|
||||
exp10 = 0;
|
||||
mantissa = 0.0;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
mantissa = x / __pow10(exp10);
|
||||
|
||||
if (exp10 >= 0) {
|
||||
if (mantissa >= 10.0) {
|
||||
exp10++;
|
||||
if (mantissa > 10.0)
|
||||
continue;
|
||||
mantissa = 1.0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (mantissa < 1.0) {
|
||||
exp10--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
*e = exp10 + expoffset;
|
||||
*m = mantissa;
|
||||
}
|
||||
|
||||
/* Convert mantissa into string
|
||||
*
|
||||
* The mantissa m == 0 || 1 <= m < 10, is converted to a string with
|
||||
* fracdigits fractional digits and intdigits integer digits. If
|
||||
* idp != 0, a decimal point will be inserted fracdigits from the end.
|
||||
* The converted string will be rounded. The function will return the
|
||||
* number of digits in the integer part (in case this has increased due
|
||||
* to rounding). If intdigits == 0, rounding will still occur, only the
|
||||
* fractional digits will be returned in the buffer. The function will
|
||||
* subtract the number of trailing zeros from *trailing. The returned
|
||||
* string is *not* null terminated.
|
||||
*/
|
||||
|
||||
static int __mantostr F6(char *, p, longdouble, m,
|
||||
int, intdigits, int, fracdigits,
|
||||
int *, trailing, int, idp)
|
||||
|
||||
{
|
||||
int i; /* index */
|
||||
int j; /* index */
|
||||
int d; /* current digit */
|
||||
long digs; /* current digits */
|
||||
long power; /* power of 10 to extract top digit */
|
||||
longdouble fpower; /* power of 10 to extract digits */
|
||||
longdouble fdigs; /* digits in floating point */
|
||||
longguard gm; /* guarded mantissa */
|
||||
int zeros; /* trailing zeros */
|
||||
int dp; /* decimal point adjustment */
|
||||
char *q, *r; /* buffer indices */
|
||||
|
||||
/* The following code requires fpower * m->number not to lose accuracy.
|
||||
* This means that __Mipow10 must be at most HALFMANTDIGITS.
|
||||
*/
|
||||
ASSERT(__Mipow10 <= HALFMANTDIGITS);
|
||||
|
||||
/* Convert the required number of digits */
|
||||
ASSERT(intdigits + fracdigits != 0);
|
||||
|
||||
for (dp = 1, zeros = 0, q = p, i = intdigits+fracdigits; i != 0; dp = 0) {
|
||||
j = __Mipow10;
|
||||
if (j > i)
|
||||
j = i;
|
||||
i -= j;
|
||||
|
||||
fpower = __fpow10[j-dp];
|
||||
if (dp == 0)
|
||||
m *= fpower;
|
||||
else {
|
||||
gm.number = m;
|
||||
gm.guard = 0.0;
|
||||
gm.exponent = 0;
|
||||
__gguard(&gm);
|
||||
gm.number *= fpower;
|
||||
gm.guard *= fpower;
|
||||
m = __gnumber(&gm);
|
||||
}
|
||||
|
||||
m = LMODF(m, &fdigs);
|
||||
digs = fdigs;
|
||||
|
||||
while (j--) {
|
||||
power = __ipow10[j];
|
||||
d = digs / power;
|
||||
if (d == 0)
|
||||
zeros++;
|
||||
else
|
||||
zeros = 0;
|
||||
*q++ = '0' + d;
|
||||
digs -= d * power;
|
||||
}
|
||||
}
|
||||
|
||||
/* Round converted digit stream */
|
||||
if (m >= 0.5) {
|
||||
for (zeros = 0, r = q; ++(*--r) > '9'; ) {
|
||||
*r = '0';
|
||||
zeros++;
|
||||
if (r == p) {
|
||||
if (intdigits++ == 0) {
|
||||
*trailing -= zeros;
|
||||
return 1;
|
||||
}
|
||||
*r = '1';
|
||||
*q++ = '0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute number of trailing zeros */
|
||||
if (zeros > fracdigits)
|
||||
zeros = fracdigits;
|
||||
*trailing -= zeros;
|
||||
|
||||
/* Insert decimal point */
|
||||
if (idp != 0) {
|
||||
for (r = q, i = fracdigits; i--; )
|
||||
*q-- = *--r;
|
||||
*r = '.';
|
||||
}
|
||||
|
||||
return intdigits;
|
||||
}
|
||||
|
||||
/* Convert floating point to string
|
||||
*
|
||||
* A vector of components is constructed in fv[]. The length of the
|
||||
* vector is returned by the function. The length of the string made
|
||||
* up of the vectors is returned in *length. The workspace used in
|
||||
* constructing the significant digits is passed in buf. fflag encodes
|
||||
* the format as follows:
|
||||
*
|
||||
* format
|
||||
* %f F_FPFORMATF
|
||||
* %e F_FPFORMATE
|
||||
* %g F_FPFORMATG
|
||||
* %E F_FPFORMATE F_FPCAPITAL
|
||||
* %G F_FPFORMATG F_FPCAPITAL
|
||||
*/
|
||||
|
||||
int __cvt F6(__stdiosize_t *, length, FV *, fv,
|
||||
char *, buf, VA_LIST *, argp, int, precision, int, fflag)
|
||||
|
||||
{
|
||||
int sign; /* sign of number */
|
||||
int intpart; /* integer */
|
||||
int fracpart; /* fraction */
|
||||
int exppart; /* exponent */
|
||||
int intfill; /* filler for integer (pre dp) */
|
||||
int fracfill; /* filler for fraction */
|
||||
int pointfill; /* filler after dp */
|
||||
int exponent; /* exponent */
|
||||
int *zeros; /* chopping of trailing zeros */
|
||||
int digits; /* significant digits */
|
||||
int lsd; /* least significant digit */
|
||||
int maxfltdigits; /* digits to generate */
|
||||
char *bp; /* buffer pointer */
|
||||
int fvx; /* format vector index */
|
||||
longdouble x; /* number to convert */
|
||||
longdouble mantissa; /* mantissa */
|
||||
int rubbish; /* dumping ground */
|
||||
|
||||
fvx = 0;
|
||||
bp = buf;
|
||||
x = (fflag & F_LONGDOUBLE) ? VA_ARG(*argp, longdouble)
|
||||
: VA_ARG(*argp, double);
|
||||
__signmanexp(x, &sign, &mantissa, &exponent);
|
||||
|
||||
/* Constrain digit generation */
|
||||
maxfltdigits = MAXFLTDIGITS;
|
||||
if (exponent < LDBL_MIN_10_EXP-1)
|
||||
if ((maxfltdigits -= LDBL_MIN_10_EXP - 1 - exponent) <= 0)
|
||||
maxfltdigits = 1;
|
||||
|
||||
/* Force sign if required */
|
||||
if (sign)
|
||||
*bp++ = '-';
|
||||
else if (fflag & F_SHOWSIGN)
|
||||
*bp++ = '+';
|
||||
fv[0].att = FV_F_VECTOR;
|
||||
fv[0].len = bp - buf;
|
||||
fv[0].arg = buf;
|
||||
fvx++;
|
||||
|
||||
/* Trailing zero check */
|
||||
zeros = (fflag & (F_FPFORMATG | F_ALTERNATE)) == F_FPFORMATG
|
||||
? &fracpart : &rubbish;
|
||||
fracpart = precision;
|
||||
|
||||
/* No fill */
|
||||
intfill = 0;
|
||||
pointfill = 0;
|
||||
fracfill = 0;
|
||||
|
||||
/* Check for %f or %g not forcing %e format */
|
||||
if ((fflag & F_FPFORMATF) ||
|
||||
((fflag & F_FPFORMATG) && (exponent >= -4 && exponent < fracpart))) {
|
||||
|
||||
/* Integer part starts here */
|
||||
if (exponent >= 0) {
|
||||
|
||||
/* %g format keeps the number of significant digits constant */
|
||||
if (fflag & F_FPFORMATG) {
|
||||
digits = fracpart;
|
||||
fracpart -= exponent + 1;
|
||||
}
|
||||
|
||||
/* Integer part */
|
||||
intpart = exponent + 1;
|
||||
|
||||
/* Restrain digit generation */
|
||||
if (intpart + fracpart > maxfltdigits) {
|
||||
if (intpart > maxfltdigits) {
|
||||
intfill = intpart - maxfltdigits;
|
||||
intpart = maxfltdigits;
|
||||
fracfill = fracpart;
|
||||
fracpart = 0;
|
||||
}
|
||||
else {
|
||||
fracfill = intpart + fracpart - maxfltdigits;
|
||||
fracpart = maxfltdigits - intpart;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert mantissa to digit string */
|
||||
intpart = __mantostr(bp, mantissa, intpart, fracpart, zeros, 1);
|
||||
|
||||
/* Rounding increased number of significant digits */
|
||||
if ((fflag & F_FPFORMATG) && intpart > digits) {
|
||||
exponent++;
|
||||
bp[0] = '1';
|
||||
bp[1] = '.';
|
||||
fracpart = 0;
|
||||
fracfill = (fflag & F_ALTERNATE) != 0 ? precision-1 : 0;
|
||||
goto ForceG;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
bp[0] = '0';
|
||||
bp[1] = '.';
|
||||
intpart = 1;
|
||||
|
||||
if (fracpart >= -exponent) {
|
||||
|
||||
/* Leading zeros in notation */
|
||||
pointfill = -exponent-1;
|
||||
fracpart -= pointfill;
|
||||
if (fracpart > maxfltdigits) {
|
||||
fracfill = fracpart - maxfltdigits;
|
||||
fracpart = maxfltdigits;
|
||||
}
|
||||
|
||||
/* Convert significant digits in mantissa */
|
||||
if (__mantostr(&bp[2], mantissa, 0, fracpart, zeros, 0)) {
|
||||
|
||||
/* Rounded up --- %f || fracpart == 0 */
|
||||
if (pointfill == 0)
|
||||
bp[0] = '1';
|
||||
else {
|
||||
bp[2] = '1';
|
||||
fracfill += fracpart;
|
||||
fracpart = 1;
|
||||
pointfill--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* fracpart < -exponent --- no significant digits in fraction window */
|
||||
else {
|
||||
lsd = mantissa;
|
||||
#ifndef TRUNCATE
|
||||
if (lsd > mantissa)
|
||||
lsd--;
|
||||
#endif
|
||||
|
||||
if (exponent == -1) {
|
||||
|
||||
/* fracpart == 0 and exponent == -1 */
|
||||
if (lsd >= 5)
|
||||
bp[0] = '1';
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
lsd = fracpart == -exponent-1 && lsd >= 5;
|
||||
if (fracpart == 0 ||
|
||||
(fflag & (F_FPFORMATG | F_ALTERNATE)) == F_FPFORMATG && lsd == 0)
|
||||
|
||||
/* fracpart == 0 and exponent <= -2 or %g and rounded to zero */
|
||||
fracpart = 0;
|
||||
|
||||
/* Rounding to zero with fracpart != 0 && exponent <= -2 */
|
||||
else {
|
||||
pointfill = fracpart-1;
|
||||
bp[2] = "01"[lsd];
|
||||
fracpart = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Integer part */
|
||||
fv[fvx].att = FV_F_VECTOR;
|
||||
fv[fvx].len = intpart;
|
||||
fv[fvx].arg = bp;
|
||||
bp += intpart;
|
||||
if (intfill != 0) {
|
||||
fv[++fvx].att = FV_F_PADDING;
|
||||
fv[fvx].len = intfill;
|
||||
fv[fvx].arg = __zfill;
|
||||
fv[++fvx].att = FV_F_VECTOR;
|
||||
fv[fvx].len = 0;
|
||||
fv[fvx].arg = bp;
|
||||
}
|
||||
|
||||
/* Decimal point, leading zeros and leading fractional part */
|
||||
if (fracpart != 0 ||
|
||||
(fflag & F_ALTERNATE) != 0 ||
|
||||
(fflag & F_FPFORMATF) != 0 && fracfill != 0) {
|
||||
fv[fvx].len++;
|
||||
bp++;
|
||||
}
|
||||
if (pointfill != 0) {
|
||||
fv[++fvx].att = FV_F_PADDING;
|
||||
fv[fvx].len = pointfill;
|
||||
fv[fvx].arg = __zfill;
|
||||
fv[++fvx].att = FV_F_VECTOR;
|
||||
fv[fvx].len = 0;
|
||||
fv[fvx].arg = bp;
|
||||
}
|
||||
fv[fvx].len += fracpart;
|
||||
bp += fracpart;
|
||||
|
||||
/* Trailing zeros */
|
||||
if (fracfill == 0 || (fflag & (F_FPFORMATG | F_ALTERNATE)) == F_FPFORMATG)
|
||||
fracfill = 0;
|
||||
else {
|
||||
fv[++fvx].att = FV_F_PADDING;
|
||||
fv[fvx].len = fracfill;
|
||||
fv[fvx].arg = __zfill;
|
||||
}
|
||||
|
||||
*length = (bp - buf) + fracfill + pointfill + intfill;
|
||||
|
||||
return fvx+1;
|
||||
}
|
||||
|
||||
/* Must be %e or %g forcing %e */
|
||||
if ((fflag & F_FPFORMATG) && precision > 0)
|
||||
fracpart--;
|
||||
if (fracpart > maxfltdigits - 1) {
|
||||
fracfill = fracpart - maxfltdigits + 1;
|
||||
fracpart = maxfltdigits - 1;
|
||||
}
|
||||
|
||||
if (__mantostr(bp, mantissa, 1, fracpart, zeros, 1) == 2) {
|
||||
exponent++;
|
||||
bp[1] = '.';
|
||||
bp[2] = '0';
|
||||
}
|
||||
|
||||
/* Count mantissa digits and decimal point */
|
||||
ForceG:
|
||||
fv[fvx].att = FV_F_VECTOR;
|
||||
fv[fvx].len = 1 + fracpart;
|
||||
if (fracpart != 0 ||
|
||||
(fflag & F_ALTERNATE) != 0 ||
|
||||
(fflag & F_FPFORMATG) == 0 && precision > 1)
|
||||
fv[fvx].len++;
|
||||
fv[fvx].arg = bp;
|
||||
bp += fv[fvx].len;
|
||||
|
||||
/* Convert exponent */
|
||||
if (fracfill != 0 && (fflag & F_FPFORMATE)) {
|
||||
fv[++fvx].att = FV_F_PADDING;
|
||||
fv[fvx].len = fracfill;
|
||||
fv[fvx].arg = __zfill;
|
||||
fv[++fvx].att = FV_F_VECTOR;
|
||||
fv[fvx].len = 0;
|
||||
fv[fvx].arg = bp;
|
||||
}
|
||||
|
||||
bp[0] = (fflag & F_FPCAPITAL) ? 'E' : 'e';
|
||||
|
||||
if (exponent >= 0)
|
||||
bp[1] = '+';
|
||||
else {
|
||||
bp[1] = '-';
|
||||
exponent = -exponent;
|
||||
}
|
||||
|
||||
exppart = __utoa(&bp[2], (unsigned int) exponent, 2) - bp;
|
||||
fv[fvx].len += exppart;
|
||||
*length = (bp - buf) + exppart + fracfill;
|
||||
|
||||
return fvx+1;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/* _ f _ f p r i n t f */
|
||||
|
||||
#include "fprintf.c"
|
||||
|
||||
static char *linkage = &__xfpcvt;
|
||||
@@ -0,0 +1,5 @@
|
||||
/* _ f _ f s c a n f */
|
||||
|
||||
#include "fscanf.c"
|
||||
|
||||
static char *linkage = &__xfptvc;
|
||||
106
study/linux-travel/minix-386/estdio21.tar/estdio21/_f_guard.c
Normal file
106
study/linux-travel/minix-386/estdio21.tar/estdio21/_f_guard.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/* _ f _ g u a r d */
|
||||
|
||||
/* This code implements a floating point number with added guard bits.
|
||||
* Each number is stored with only half the mantissa of the number used.
|
||||
* The least significant bits are combined with the guard bits and are
|
||||
* stored in the guard.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
#include <math.h>
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
/* Generate guard
|
||||
*
|
||||
* The mantissa of a->number is split into two. The least significant
|
||||
* bits are added to a->guard. The most significant bits remain in a->number.
|
||||
*/
|
||||
void __gguard F1(longguard *, a)
|
||||
|
||||
{
|
||||
#if FLT_RADIX == 2
|
||||
#define FLTSHIFT 1
|
||||
#endif
|
||||
#if FLT_RADIX == 4
|
||||
#define FLTSHIFT 2
|
||||
#endif
|
||||
#if FLT_RADIX == 8
|
||||
#define FLTSHIFT 3
|
||||
#endif
|
||||
#if FLT_RADIX == 16
|
||||
#define FLTSHIFT 4
|
||||
#endif
|
||||
#ifdef FLTSHIFT
|
||||
double m; /* normalised mantissa */
|
||||
double g; /* guard part of mantissa */
|
||||
int exp; /* exponent */
|
||||
|
||||
m = LFREXP(a->number, &exp);
|
||||
exp -= LDBL_MANT_DIG/2*FLTSHIFT;
|
||||
m = LLDEXP(m, LDBL_MANT_DIG/2*FLTSHIFT);
|
||||
g = LMODF(m, &m);
|
||||
a->number = LLDEXP(m, exp);
|
||||
a->guard += LLDEXP(g, exp);
|
||||
#else
|
||||
<< Extra code required to support guard generation >>
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Multiply and return unguarded
|
||||
*
|
||||
* Perform (a * b) and return the result in a longdouble.
|
||||
*/
|
||||
longdouble __gmul F2(register longguard *, a, register longguard *, b)
|
||||
|
||||
{
|
||||
longdouble r; /* result */
|
||||
|
||||
r = a->guard * b->guard;
|
||||
r += a->number * b->guard;
|
||||
r += a->guard * b->number;
|
||||
r += a->number * b->number;
|
||||
|
||||
return LLDEXP(r, a->exponent+b->exponent);
|
||||
}
|
||||
|
||||
/* Multiply and return guarded
|
||||
*
|
||||
* Perform (a * b) and return the guarded result in r.
|
||||
*/
|
||||
void __ggmul F3(longguard *, r, longguard *, a, longguard *, b)
|
||||
|
||||
{
|
||||
r->guard = a->guard * b->guard
|
||||
+ a->number * b->guard
|
||||
+ a->guard * b->number;
|
||||
r->number = a->number * b->number;
|
||||
r->exponent = a->exponent + b->exponent;
|
||||
}
|
||||
|
||||
/* Convert guarded to unguarded
|
||||
*
|
||||
* Combine g->number and g->guard to return a longdouble.
|
||||
*/
|
||||
longdouble __gnumber F1(register longguard *, g)
|
||||
|
||||
{
|
||||
longdouble r; /* result */
|
||||
|
||||
r = g->number + g->guard;
|
||||
return g->exponent ? LLDEXP(r, g->exponent) : r;
|
||||
}
|
||||
|
||||
/* Normalise out exponent in guard
|
||||
*
|
||||
* Scale g->number and g->guard so that g->exponent is zero.
|
||||
*/
|
||||
void __gnormal F1(register longguard *, g)
|
||||
|
||||
{
|
||||
if (g->exponent) {
|
||||
g->number = LLDEXP(g->number, g->exponent);
|
||||
g->guard = LLDEXP(g->guard, g->exponent);
|
||||
g->exponent = 0;
|
||||
}
|
||||
}
|
||||
163
study/linux-travel/minix-386/estdio21.tar/estdio21/_f_pow10.c
Normal file
163
study/linux-travel/minix-386/estdio21.tar/estdio21/_f_pow10.c
Normal file
@@ -0,0 +1,163 @@
|
||||
/* _ f _ p o w 1 0 */
|
||||
|
||||
/* Floating point powers of ten.
|
||||
*
|
||||
* __gpow10 computes 10**y where y is an integer. It returns the
|
||||
* result as a guarded longdouble.
|
||||
*
|
||||
* __pow10 is the same as __gpow10 but returns an unguarded longdouble.
|
||||
*
|
||||
* __mpow10 is the smallest power available. __Mpow10 is the largest
|
||||
* power available.
|
||||
*
|
||||
* __fpow10 is a pointer into the small power table for floating point
|
||||
* versions of __ipow10. At least __Mipow10 values are available.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
#include <math.h>
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
/* Floating point power table indices
|
||||
*
|
||||
* These indices yield important offsets into the power tables:
|
||||
*
|
||||
* N_SMALLPOWERS number of longdoubles in the small power table
|
||||
* N_LARGEPOWERS number of longdoubles in the large power table
|
||||
* B_SMALLPOWERS longdouble index to locate 1e0
|
||||
* B_LARGEPOWERS longdouble index to locate largest negative power
|
||||
* M_SMALLPOWERS largest power in small power table plus one
|
||||
* M_LARGEPOWERS largest power in large power table
|
||||
*/
|
||||
#define N_SMALLPOWERS (sizeof(smallpowers) / sizeof(longdouble))
|
||||
#define B_SMALLPOWERS ((N_SMALLPOWERS - 1) / 3 * 2)
|
||||
#define M_SMALLPOWERS ((N_SMALLPOWERS - 1) / 3 + 1)
|
||||
#define N_LARGEPOWERS (sizeof(largepowers) / sizeof(longdouble))
|
||||
#define B_LARGEPOWERS (N_LARGEPOWERS / 2 - 2)
|
||||
#define M_LARGEPOWERS (N_LARGEPOWERS / 4 * M_SMALLPOWERS)
|
||||
|
||||
#ifdef POWERS
|
||||
static int smallpowers[] = {
|
||||
#define SMALL
|
||||
#include "powers.h"
|
||||
};
|
||||
static int largepowers[] = {
|
||||
#define LARGE
|
||||
#include "powers.h"
|
||||
};
|
||||
#else
|
||||
static longdouble smallpowers[] = {
|
||||
1e-15, 0e0, 1e-14, 0e0, 1e-13, 0e0, 1e-12, 0e0,
|
||||
1e-11, 0e0, 1e-10, 0e0, 1e-9, 0e0, 1e-8, 0e0,
|
||||
1e-7, 0e0, 1e-6, 0e0, 1e-5, 0e0, 1e-4, 0e0,
|
||||
1e-3, 0e0, 1e-2, 0e0, 1e-1, 0e0,
|
||||
1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7,
|
||||
1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15,
|
||||
};
|
||||
static longdouble largepowers[] = {
|
||||
#if LDBL_MAX_10_EXP >= 320
|
||||
<< Large power table needs to be extended >>
|
||||
#endif
|
||||
1e-304, 0e0, 1e-288, 0e0, 1e-272, 0e0,
|
||||
1e-256, 0e0, 1e-240, 0e0, 1e-224, 0e0, 1e-208, 0e0,
|
||||
1e-192, 0e0, 1e-176, 0e0, 1e-160, 0e0, 1e-144, 0e0,
|
||||
1e-128, 0e0, 1e-112, 0e0, 1e-96, 0e0, 1e-80, 0e0,
|
||||
1e-64, 0e0, 1e-48, 0e0, 1e-32, 0e0, 1e-16, 0e0,
|
||||
1e016, 0e0, 1e032, 0e0, 1e048, 0e0, 1e064, 0e0,
|
||||
1e080, 0e0, 1e096, 0e0, 1e112, 0e0, 1e128, 0e0,
|
||||
1e144, 0e0, 1e160, 0e0, 1e176, 0e0, 1e192, 0e0,
|
||||
1e208, 0e0, 1e224, 0e0, 1e240, 0e0, 1e256, 0e0,
|
||||
1e272, 0e0, 1e288, 0e0, 1e304, 0e0,
|
||||
};
|
||||
#endif
|
||||
|
||||
int __mpow10 = 1 - M_LARGEPOWERS - M_SMALLPOWERS;
|
||||
int __Mpow10 = LDBL_MAX_10_EXP;
|
||||
|
||||
/* Small floating point powers of ten
|
||||
*
|
||||
* Ensure that at least __Mipow10 values are available.
|
||||
*/
|
||||
|
||||
longdouble *__fpow10 = &((longdouble *) smallpowers)[B_SMALLPOWERS];
|
||||
|
||||
static longdouble __xpow10 F2(int, exp, longguard *, r)
|
||||
|
||||
{
|
||||
unsigned int aexp; /* absolute value of exponent */
|
||||
int seg; /* large power index */
|
||||
int off; /* small power index */
|
||||
longdouble *p; /* array pointer */
|
||||
longguard n; /* guarded multiplicand */
|
||||
longguard m; /* guarded multiplier */
|
||||
|
||||
aexp = exp < 0 ? -exp : exp;
|
||||
|
||||
if (aexp < M_SMALLPOWERS) {
|
||||
if (exp < 0)
|
||||
exp *= 2;
|
||||
p = &((longdouble *) smallpowers)[exp + B_SMALLPOWERS];
|
||||
if (r == NULL)
|
||||
return exp < 0 ? p[0] + p[1] : p[0];
|
||||
else {
|
||||
r->number = p[0];
|
||||
r->guard = exp < 0 ? p[1] : 0.0;
|
||||
r->exponent = 0;
|
||||
if (exp > HALFMANTDIGITS)
|
||||
__gguard(r);
|
||||
}
|
||||
}
|
||||
|
||||
else if (exp >= __mpow10 && exp <= __Mpow10) {
|
||||
|
||||
seg = aexp / M_SMALLPOWERS;
|
||||
off = aexp - (seg * M_SMALLPOWERS);
|
||||
|
||||
if (exp >= 0)
|
||||
m.exponent = POSEXPONENT;
|
||||
else {
|
||||
seg = 1 - seg;
|
||||
off = -off;
|
||||
off *= 2;
|
||||
m.exponent = NEGEXPONENT;
|
||||
}
|
||||
p = &((longdouble *) smallpowers)[off + B_SMALLPOWERS];
|
||||
n.number = p[0];
|
||||
n.guard = off < 0 ? p[1] : 0.0;
|
||||
n.exponent = 0;
|
||||
__gguard(&n);
|
||||
|
||||
p = &((longdouble *) largepowers)[2*seg + B_LARGEPOWERS];
|
||||
m.number = p[0];
|
||||
m.guard = p[1];
|
||||
|
||||
if (r == NULL)
|
||||
return __gmul(&n, &m);
|
||||
else {
|
||||
__ggmul(r, &n, &m);
|
||||
__gguard(r);
|
||||
}
|
||||
}
|
||||
|
||||
else if (r == NULL)
|
||||
return HUGE_VAL;
|
||||
else {
|
||||
r->number = HUGE_VAL;
|
||||
r->guard = 0.0;
|
||||
r->exponent = 0;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void __gpow10 F2(int, exp, longguard *, r)
|
||||
|
||||
{
|
||||
(void) __xpow10(exp, r);
|
||||
}
|
||||
|
||||
longdouble __pow10 F1(int, exp)
|
||||
|
||||
{
|
||||
return __xpow10(exp, (longguard *) NULL);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/* _ f _ p r i n t f */
|
||||
|
||||
#include "printf.c"
|
||||
|
||||
static char *linkage = &__xfpcvt;
|
||||
@@ -0,0 +1,5 @@
|
||||
/* _ f _ s c a n f */
|
||||
|
||||
#include "scanf.c"
|
||||
|
||||
static char *linkage = &__xfptvc;
|
||||
@@ -0,0 +1,5 @@
|
||||
/* _ f _ s p r i n t f */
|
||||
|
||||
#include "sprintf.c"
|
||||
|
||||
static char *linkage = &__xfpcvt;
|
||||
@@ -0,0 +1,5 @@
|
||||
/* _ f _ s s c a n f */
|
||||
|
||||
#include "sscanf.c"
|
||||
|
||||
static char *linkage = &__xfptvc;
|
||||
280
study/linux-travel/minix-386/estdio21.tar/estdio21/_f_tvc.c
Normal file
280
study/linux-travel/minix-386/estdio21.tar/estdio21/_f_tvc.c
Normal file
@@ -0,0 +1,280 @@
|
||||
/* _ f _ t v c */
|
||||
|
||||
/* This code implements the %f, %g and %e formats for input conversion
|
||||
* of floating point numbers. It is called from _vfscanf().
|
||||
*/
|
||||
|
||||
extern int __mpow10;
|
||||
|
||||
#include "stdiolib.h"
|
||||
#include <math.h>
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#define NEXTCH() (nbytes++, ch = getc(fp))
|
||||
|
||||
#if '0'+1 != '1' || '1'+1 != '2' || '2'+1 != '3' || '3'+1 != '4' || \
|
||||
'4'+1 != '5' || '5'+1 != '6' || '6'+1 != '7' || '7'+1 != '8' || \
|
||||
'8'+1 != '9'
|
||||
<< Violation of collating sequence assumption >>
|
||||
#endif
|
||||
|
||||
char __xfptvc = 0; /* linkage for library */
|
||||
|
||||
/****************************************************************/
|
||||
/* Assume that division or multiplication by FLT_RADIX is exact */
|
||||
/****************************************************************/
|
||||
|
||||
int __tvc F5(FILE *, fp, int, width, VA_LIST *, argp, int, fptype, char *, ok)
|
||||
|
||||
{
|
||||
int ch; /* look-ahead character */
|
||||
int nbytes; /* bytes scanned */
|
||||
int fracpart; /* fractional part of mantissa */
|
||||
longguard mant; /* mantissa */
|
||||
longdouble Mantissa; /* result */
|
||||
int exponent; /* exponent */
|
||||
int digits; /* significant digits */
|
||||
char haveexp; /* exponent exists */
|
||||
char scannedzeros; /* scanned leading zeros */
|
||||
char negative; /* negative */
|
||||
char expnegative; /* exponent negative */
|
||||
long imantissa; /* mantissa collection */
|
||||
int imantdigs; /* digits collected */
|
||||
int gdigits; /* guard digits */
|
||||
int normexp; /* exponent for normalised number */
|
||||
int expoffset; /* offset for exponent */
|
||||
longguard pow10; /* guarded power of ten */
|
||||
char *dbp; /* point to digit insertion */
|
||||
char *edbp; /* end of digit buffer */
|
||||
char dbuf[3*LDBL_DIG/2]; /* digit buffer */
|
||||
int i; /* index */
|
||||
static longdouble flt_radix = FLT_RADIX;/* exponent radix */
|
||||
#ifdef LMR
|
||||
static int ldbl_max_radix[sizeof(longdouble)/sizeof(int)] = {
|
||||
#include "lmr.h"
|
||||
};
|
||||
#else
|
||||
static longdouble ldbl_max_radix[1];
|
||||
#endif
|
||||
|
||||
ch = getc(fp);
|
||||
nbytes = 0;
|
||||
fracpart = 0;
|
||||
negative = 0;
|
||||
expnegative = 0;
|
||||
exponent = 0;
|
||||
haveexp = 0;
|
||||
scannedzeros = 0;
|
||||
*ok = 0;
|
||||
dbp = &dbuf[0];
|
||||
edbp = &dbuf[sizeof(dbuf)/sizeof(dbuf[0])];
|
||||
|
||||
#ifndef LMR
|
||||
ldbl_max_radix[0] = LDBL_MAX / FLT_RADIX;
|
||||
#endif
|
||||
|
||||
/* Leading sign bit */
|
||||
if (width != 0) {
|
||||
if (ch == '-') {
|
||||
negative++;
|
||||
NEXTCH();
|
||||
width--;
|
||||
} else if (ch == '+') {
|
||||
NEXTCH();
|
||||
width--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Skip leading zeros in integer part */
|
||||
while (width != 0 && ch == '0') {
|
||||
NEXTCH();
|
||||
width--;
|
||||
scannedzeros = 1;
|
||||
}
|
||||
|
||||
/* Integer part */
|
||||
while (width != 0 && ch >= '0' && ch <= '9') {
|
||||
if (dbp < edbp)
|
||||
*dbp++ = ch;
|
||||
else
|
||||
fracpart--;
|
||||
NEXTCH();
|
||||
width--;
|
||||
}
|
||||
|
||||
/* Fractional part */
|
||||
if (width != 0 && ch == '.') {
|
||||
NEXTCH();
|
||||
width--;
|
||||
|
||||
/* Skip leading zeros in fractional part */
|
||||
if (dbp == &dbuf[0]) {
|
||||
while (width != 0 && ch == '0') {
|
||||
NEXTCH();
|
||||
width--;
|
||||
fracpart++;
|
||||
scannedzeros = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fractional part proper */
|
||||
while (width != 0 && ch >= '0' && ch <= '9') {
|
||||
if (dbp < edbp) {
|
||||
*dbp++ = ch;
|
||||
fracpart++;
|
||||
}
|
||||
NEXTCH();
|
||||
width--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Discard trailing zeros */
|
||||
for (digits = dbp - &dbuf[0]; digits > 0 && *--dbp == '0'; digits--)
|
||||
fracpart--;
|
||||
|
||||
/* Validate mantissa */
|
||||
if (scannedzeros == 0 && digits == 0)
|
||||
goto Failed;
|
||||
|
||||
/* Convert digits */
|
||||
imantissa = 0;
|
||||
imantdigs = 0;
|
||||
gdigits = 0;
|
||||
mant.number = 0.0;
|
||||
mant.guard = 0.0;
|
||||
mant.exponent = 0;
|
||||
for (dbp = &dbuf[0], i = 0; i < digits; imantdigs++, i++, dbp++) {
|
||||
if (i != LDBL_DIG/2 && imantdigs < __Mipow10)
|
||||
imantissa = imantissa * 10 + (dbp[0] - '0');
|
||||
else {
|
||||
if (i == LDBL_DIG/2)
|
||||
mant.number = imantissa;
|
||||
else {
|
||||
mant.guard = mant.guard * __fpow10[imantdigs] + imantissa;
|
||||
gdigits += imantdigs;
|
||||
}
|
||||
imantissa = dbp[0] - '0';
|
||||
imantdigs = 0;
|
||||
}
|
||||
}
|
||||
if (imantdigs != 0) {
|
||||
if (i <= LDBL_DIG/2)
|
||||
mant.number = imantissa;
|
||||
else {
|
||||
mant.guard = mant.guard * __fpow10[imantdigs] + imantissa;
|
||||
gdigits += imantdigs;
|
||||
}
|
||||
}
|
||||
if (gdigits != 0)
|
||||
mant.guard /= __fpow10[gdigits];
|
||||
|
||||
/* In order to ensure that LDBL_MIN is able to be scanned properly
|
||||
* it is necessary the normalised decimal mantissa need only a single
|
||||
* guarded multiplication to convert it into the required number.
|
||||
*/
|
||||
ASSERT(LDBL_DIG/2 - 1 + LDBL_MIN_10_EXP >= __mpow10);
|
||||
|
||||
/* Exponent */
|
||||
if (width != 0 && (ch == 'e' || ch == 'E')) {
|
||||
NEXTCH();
|
||||
width--;
|
||||
if (width != 0) {
|
||||
if (ch == '-') {
|
||||
expnegative = 1;
|
||||
NEXTCH();
|
||||
width--;
|
||||
} else if (ch == '+') {
|
||||
NEXTCH();
|
||||
width--;
|
||||
}
|
||||
}
|
||||
|
||||
expoffset = digits - fracpart - 1;
|
||||
if (expnegative)
|
||||
expoffset = -expoffset;
|
||||
|
||||
while (width != 0 && ch >= '0' && ch <= '9') {
|
||||
haveexp = 1;
|
||||
if (exponent + expoffset <= LDBL_MAX_10_EXP)
|
||||
exponent = exponent * 10 + (ch - '0');
|
||||
NEXTCH();
|
||||
width--;
|
||||
}
|
||||
if (haveexp == 0)
|
||||
goto Failed;
|
||||
if (expnegative)
|
||||
exponent = -exponent;
|
||||
}
|
||||
|
||||
/* Merge mantissa and exponent */
|
||||
exponent += gdigits - fracpart;
|
||||
|
||||
if (exponent < 0) {
|
||||
|
||||
while (exponent < __mpow10) {
|
||||
__gpow10(__mpow10, &pow10);
|
||||
__ggmul(&mant, &mant, &pow10);
|
||||
__gguard(&mant);
|
||||
exponent -= __mpow10;
|
||||
}
|
||||
|
||||
__gpow10(exponent, &pow10);
|
||||
Mantissa = __gmul(&mant, &pow10);
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
normexp = exponent + (digits - gdigits) - 1;
|
||||
|
||||
/* Magnitude of number is too great */
|
||||
if (normexp > LDBL_MAX_10_EXP)
|
||||
Mantissa = HUGE_VAL;
|
||||
|
||||
/* Exponent is in range or on limit */
|
||||
else {
|
||||
while (exponent > LDBL_MAX_10_EXP) {
|
||||
__gpow10(LDBL_MAX_10_EXP, &pow10);
|
||||
__ggmul(&mant, &mant, &pow10);
|
||||
__gguard(&mant);
|
||||
exponent -= LDBL_MAX_10_EXP;
|
||||
}
|
||||
|
||||
/* Number is well within range */
|
||||
if (normexp < LDBL_MAX_10_EXP) {
|
||||
__gpow10(exponent, &pow10);
|
||||
Mantissa = __gmul(&mant, &pow10);
|
||||
}
|
||||
|
||||
/* Number may overflow and is close to the limit of the representation. */
|
||||
else {
|
||||
__gpow10(gdigits - digits + 1, &pow10);
|
||||
__ggmul(&mant, &mant, &pow10);
|
||||
__gguard(&mant);
|
||||
__gpow10(LDBL_MAX_10_EXP, &pow10);
|
||||
Mantissa = __gmul(&mant, &pow10);
|
||||
Mantissa /= flt_radix;
|
||||
if (Mantissa <= * (longdouble *) &ldbl_max_radix[0])
|
||||
Mantissa *= flt_radix;
|
||||
else
|
||||
Mantissa = HUGE_VAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Merge sign */
|
||||
if (negative)
|
||||
Mantissa = -Mantissa;
|
||||
|
||||
/* Generate result */
|
||||
*ok = 1;
|
||||
switch (fptype) {
|
||||
case 1: * VA_ARG(*argp, longdouble *) = Mantissa; break;
|
||||
case 2: * VA_ARG(*argp, double *) = Mantissa; break;
|
||||
case 3: * VA_ARG(*argp, float *) = Mantissa; break;
|
||||
}
|
||||
|
||||
Failed:
|
||||
ungetc(ch, fp);
|
||||
return nbytes;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/* _ f _ v f p r i n t f */
|
||||
|
||||
#include "vfprintf.c"
|
||||
|
||||
static char *linkage = &__xfpcvt;
|
||||
@@ -0,0 +1,5 @@
|
||||
/* _ f _ v p r i n t f */
|
||||
|
||||
#include "vprintf.c"
|
||||
|
||||
static char *linkage = &__xfpcvt;
|
||||
@@ -0,0 +1,5 @@
|
||||
/* _ f _ v s p r i n t f */
|
||||
|
||||
#include "vsprintf.c"
|
||||
|
||||
static char *linkage = &__xfpcvt;
|
||||
68
study/linux-travel/minix-386/estdio21.tar/estdio21/_fgetlx.c
Normal file
68
study/linux-travel/minix-386/estdio21.tar/estdio21/_fgetlx.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/* _ f g e t l x
|
||||
*
|
||||
* Read a line from stream
|
||||
*
|
||||
* The line is read from the specified stream into the named
|
||||
* buffer. At most n-1 characters are read. Reading will stop
|
||||
* when the buffer is filled, or when a newline character is
|
||||
* read. The buffer is null terminated. The newline is included
|
||||
* in the string.
|
||||
*
|
||||
* The function returns a pointer to the null terminator at the
|
||||
* end of the buffer. If no characters were read because of EOF,
|
||||
* a null pointer is returned.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
char *__fgetlx F3(char *, buf, __stdiosize_t, n, register FILE *, fp)
|
||||
|
||||
{
|
||||
register __stdiobuf_t *s; /* output buffer */
|
||||
__stdiobuf_t *r; /* output buffer */
|
||||
__stdiobuf_t *q; /* input buffer pointer */
|
||||
int ch; /* character read */
|
||||
__stdiosize_t bytesleft; /* bytes left in current load */
|
||||
__stdiosize_t bytesread; /* bytes read */
|
||||
|
||||
if (n <= 1)
|
||||
return n > 0 ? (buf[0] = 0, buf) : (char *) (NULL);
|
||||
|
||||
if (GETFLAG(fp, _IOSTDX) == _IOSTDIN && __Zout != NULL &&
|
||||
(ALLFLAGS(fp) & ALLFLAGS(__Zout) & _IOLBF) != 0)
|
||||
(void) FFLUSH(__Zout);
|
||||
|
||||
for (s = (__stdiobuf_t *) buf, --n; ; ) {
|
||||
if ((bytesleft = BYTESINREADBUFFER(fp)) != 0) {
|
||||
if (bytesleft > n)
|
||||
bytesleft = n;
|
||||
n -= bytesleft;
|
||||
q = GETREADPTR(fp);
|
||||
|
||||
if ((r = (__stdiobuf_t *) MEMCHR(q, '\n', (size_t) bytesleft)) != NULL)
|
||||
bytesread = r - q + 1;
|
||||
|
||||
else {
|
||||
bytesread = bytesleft;
|
||||
bytesleft = 0;
|
||||
}
|
||||
|
||||
MEMCPY(s, q, (size_t) bytesread);
|
||||
|
||||
s += bytesread;
|
||||
|
||||
SETREADPTR(fp, q + bytesread);
|
||||
}
|
||||
*s = 0;
|
||||
if (bytesleft != 0 || n == 0)
|
||||
return (char *) (s);
|
||||
if ((ch = getc(fp)) == EOF)
|
||||
return s == (__stdiobuf_t *) buf ? (char *) (NULL) : (char *) (s);
|
||||
if ((*s++ = ch) == '\n' || --n == 0) {
|
||||
*s = 0;
|
||||
return (char *) (s);
|
||||
}
|
||||
}
|
||||
}
|
||||
79
study/linux-travel/minix-386/estdio21.tar/estdio21/_file.c
Normal file
79
study/linux-travel/minix-386/estdio21.tar/estdio21/_file.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/* _ f i l e
|
||||
*
|
||||
* Allocate a stream descriptor
|
||||
*
|
||||
* Allocate and initialise a FILE structure. If the pointer passed
|
||||
* to the function is NULL, a FILE will be allocated, otherwise
|
||||
* the one specified will be used. The function will return
|
||||
* a pointer to the FILE structure, or NULL if it fails.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#if _IOREAD != 1 || _IOWRITE != 2
|
||||
_IOREAD == 1 and _IOWRITE == 2 assumed
|
||||
#endif
|
||||
|
||||
static int (*filtable[]) P((FILE *)) =
|
||||
{__brdupdate, __brdonly, __bffil};
|
||||
|
||||
static int (*flstable[]) P((int, FILE *)) =
|
||||
{__bwrupdate, __bffls, __bwronly};
|
||||
|
||||
FILE *__file F3(register FILE *, fp, int, fd, register short, flags)
|
||||
|
||||
{
|
||||
|
||||
/* Retain flags and insert if necessary */
|
||||
if (fp != NULL) {
|
||||
if (TESTFLAG(fp, _IOINSERT)) {
|
||||
CLEARFLAG(fp, _IOINSERT);
|
||||
FINSERT(fp);
|
||||
}
|
||||
flags |= GETFLAG(fp, _IORETAIN);
|
||||
}
|
||||
|
||||
/* Allocate or find a file structure */
|
||||
else {
|
||||
for (fp = __iop; fp != NULL && TESTFLAG(fp, ~_IORETAIN); fp = fp->__next) {
|
||||
if (fileno(fp) == fd) {
|
||||
/* Multiple fdopen() on a file descriptor is debatable */
|
||||
/* Error return here breaks too many broken programs! */
|
||||
/* return NULL; */
|
||||
__freebuf(fp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Retain flags on existing descriptors */
|
||||
if (fp != NULL)
|
||||
flags |= GETFLAG(fp, _IORETAIN);
|
||||
|
||||
/* No existing descriptor */
|
||||
else {
|
||||
if ((fp = (FILE *) malloc(sizeof(*fp))) == NULL)
|
||||
return NULL;
|
||||
|
||||
FINSERT(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Stream descriptor needs to be initialised */
|
||||
fp->__rend = NULL;
|
||||
fp->__rptr = NULL;
|
||||
fp->__wend = NULL;
|
||||
fp->__wptr = NULL;
|
||||
fp->__base = NULL;
|
||||
fp->__flag = flags;
|
||||
fp->__file = fd;
|
||||
fp->__bufsiz = __allocbuf(fp);
|
||||
|
||||
flags &= _IOREAD | _IOWRITE;
|
||||
fp->__filbuf = filtable[flags];
|
||||
fp->__flsbuf = flstable[flags];
|
||||
fp->__flush = __btfls;
|
||||
|
||||
return fp;
|
||||
}
|
||||
73
study/linux-travel/minix-386/estdio21.tar/estdio21/_fopen.c
Normal file
73
study/linux-travel/minix-386/estdio21.tar/estdio21/_fopen.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/* _ f o p e n
|
||||
*
|
||||
* Open a file
|
||||
*
|
||||
* This function scans the mode with which a channel should be
|
||||
* opened. It then opens the channel using that mode and returns
|
||||
* the channel number to the caller. On error, the value -1 will
|
||||
* be returned.
|
||||
*
|
||||
* If the function succeeds, the flags argument will be set to the
|
||||
* mode with which the channel was opened. If the fd argument is
|
||||
* -1, the channel will be allocated, otherwise the specified channel
|
||||
* will be used.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#define CREATMODE 0666 /* mode to creat file */
|
||||
|
||||
int __fopen F4(CONST char *, name,
|
||||
CONST char *, mode,
|
||||
int, fd,
|
||||
register short *, flags)
|
||||
|
||||
{
|
||||
register int openmode; /* mode for open */
|
||||
int readwrite; /* basic mode */
|
||||
int update; /* read and write required */
|
||||
|
||||
readwrite = *mode++;
|
||||
|
||||
if (*mode == 'b')
|
||||
mode++;
|
||||
if ((update = *mode == '+') != 0) {
|
||||
*flags = _IORW;
|
||||
openmode = O_RDWR;
|
||||
}
|
||||
|
||||
if (readwrite == 'r') {
|
||||
|
||||
if (! update) {
|
||||
*flags = _IOREAD;
|
||||
openmode = O_RDONLY;
|
||||
}
|
||||
|
||||
if (fd < 0)
|
||||
fd = open(name, openmode, CREATMODE);
|
||||
}
|
||||
|
||||
else {
|
||||
if (! update) {
|
||||
*flags = _IOWRITE;
|
||||
openmode = O_WRONLY;
|
||||
}
|
||||
|
||||
openmode |= O_CREAT;
|
||||
if (readwrite != 'a')
|
||||
openmode |= O_TRUNC;
|
||||
else {
|
||||
openmode |= O_APPEND;
|
||||
#ifndef OPEN3
|
||||
*flags |= _IOAPPEND;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (fd < 0)
|
||||
fd = open(name, openmode, CREATMODE);
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/* _ f r e e b u f
|
||||
*
|
||||
* Deallocate a buffer to a stream
|
||||
*
|
||||
* Return the allocated buffer to the free pool or to the heap. Return
|
||||
* zero on success, non-zero on failure.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
void __freebuf F1(register FILE *,fp)
|
||||
|
||||
{
|
||||
int i; /* pool scanner */
|
||||
|
||||
if (TESTFLAG(fp, _IOMYBUF))
|
||||
free(fp->__base);
|
||||
|
||||
else if (TESTFLAG(fp, _IOPOOLBUF)) {
|
||||
for (i = 0; i < POOLSIZE; i++) {
|
||||
if (__iob[i] == NULL) {
|
||||
__iob[i] = fp->__base;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT(i < POOLSIZE);
|
||||
}
|
||||
|
||||
CLEARFLAG(fp, (_IOMYBUF | _IOPOOLBUF));
|
||||
}
|
||||
13
study/linux-travel/minix-386/estdio21.tar/estdio21/_in.c
Normal file
13
study/linux-travel/minix-386/estdio21.tar/estdio21/_in.c
Normal file
@@ -0,0 +1,13 @@
|
||||
/* _ i n */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
static __stdiobuf_t __bin[BUFSIZ];
|
||||
|
||||
FILE __stdin = {NULL, NULL, NULL, NULL,
|
||||
&__bin[0], sizeof(__bin)/sizeof(__bin[0]),
|
||||
_IOSTDIN|_IOINSERT|_IOREAD|_IOFBF|_IOPOOLBUF,
|
||||
STDIN_FILENO, 0,
|
||||
__brdonly, __bffls, __btfls, NULL};
|
||||
26
study/linux-travel/minix-386/estdio21.tar/estdio21/_ioread.c
Normal file
26
study/linux-travel/minix-386/estdio21.tar/estdio21/_ioread.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* _ i o r e a d */
|
||||
|
||||
/* Call read(2) repeatedly to read data. Return the number of bytes read.
|
||||
* Unlike _iowrite(), this will not retry the read until the required
|
||||
* number of bytes have been transferred. This is so that streams
|
||||
* that attach to things like terminals will be able to return their
|
||||
* natural record lengths.
|
||||
*/
|
||||
|
||||
#include <stdiolib.h>
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
__stdiosize_t __ioread F3(int, fd, char *, p, __stdiosize_t, n)
|
||||
|
||||
{
|
||||
register int r; /* bytes read by read call */
|
||||
|
||||
if (n > INT_MAX)
|
||||
n = INT_MAX;
|
||||
do
|
||||
r = read(fd, p, n);
|
||||
while (r == -1 && (errno == EINTR || errno == EAGAIN));
|
||||
|
||||
return r < 0 ? 0 : r;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/* _ i o w r i t e */
|
||||
|
||||
/* Call write(2) repeatedly until all data written or an error occurs. Returns
|
||||
* the number of bytes written.
|
||||
*/
|
||||
|
||||
#include <stdiolib.h>
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
__stdiosize_t __iowrite F3(int, fd, char *, p, __stdiosize_t, n)
|
||||
|
||||
{
|
||||
register int wrote; /* bytes written by write call */
|
||||
register __stdiosize_t wb; /* byte to write each call */
|
||||
__stdiosize_t w; /* total bytes written */
|
||||
|
||||
for (w = 0; ; p += wrote) {
|
||||
wb = n;
|
||||
if (wb > INT_MAX)
|
||||
wb = INT_MAX;
|
||||
do
|
||||
wrote = write(fd, p, (unsigned int) wb);
|
||||
while (wrote == -1 && (errno == EINTR || errno == EAGAIN));
|
||||
if (wrote == -1)
|
||||
break;
|
||||
w += wrote;
|
||||
if ((n -= wrote) == 0)
|
||||
break;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
16
study/linux-travel/minix-386/estdio21.tar/estdio21/_ipow10.c
Normal file
16
study/linux-travel/minix-386/estdio21.tar/estdio21/_ipow10.c
Normal file
@@ -0,0 +1,16 @@
|
||||
/* _ i p o w 1 0 */
|
||||
|
||||
/* __ipow10 is a static table of integral powers of ten. The highest
|
||||
* power of ten stored in the table is obtained from __Mipow10.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
long __ipow10[] = {
|
||||
1L, 10L, 100L, 1000L, 10000L,
|
||||
100000L, 1000000L, 10000000L, 100000000L, 1000000000L,
|
||||
};
|
||||
|
||||
int __Mipow10 = sizeof(__ipow10) / sizeof(__ipow10[0]) - 1;
|
||||
76
study/linux-travel/minix-386/estdio21.tar/estdio21/_open3.c
Normal file
76
study/linux-travel/minix-386/estdio21.tar/estdio21/_open3.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/* _ o p e n 3 */
|
||||
|
||||
/* For those ancient systems without three argument opens, we fake it.
|
||||
* The following code works for:
|
||||
*
|
||||
* r O_RDONLY
|
||||
* w O_WRONLY | O_CREAT | O_TRUNC
|
||||
* a O_WRONLY | O_CREAT | O_APPEND
|
||||
* r+ O_RDWR
|
||||
* w+ O_RDWR | O_CREAT | O_TRUNC
|
||||
* a+ O_RDWR | O_CREAT | O_APPEND
|
||||
* other modes may not work
|
||||
*
|
||||
* Code based on open3.c from Bruce Evan's stdio. It is necessary to
|
||||
* set the umask to zero so that creat works implies that open works.
|
||||
* The O_APPEND mode is ignored since two argument opens don't support
|
||||
* it at all.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
/*VARARGS2*/
|
||||
/*ARGSUSED*/
|
||||
|
||||
#ifndef OPEN3
|
||||
|
||||
#undef open
|
||||
|
||||
int __open3 F2V(CONST char *, path, int, mode,
|
||||
|
||||
{
|
||||
VA_LIST, arg, /* argument vector */
|
||||
register int fd; /* file descriptor */
|
||||
register int fmode; /* file mode */
|
||||
int mask; /* saved umask */
|
||||
int perms; /* permissions */
|
||||
|
||||
VA_START(arg, mode);)
|
||||
|
||||
/* Take fast local copy of mode */
|
||||
fmode = mode;
|
||||
|
||||
/* r, a, r+ and a+ modes */
|
||||
if ((fmode & O_TRUNC) == 0) {
|
||||
if ((fd = open(path, fmode & (O_WRONLY|O_RDONLY|O_RDWR))) >= 0 ||
|
||||
(fmode & O_CREAT) == 0 ||
|
||||
errno != ENOENT)
|
||||
goto Done;
|
||||
|
||||
/* Fall through on a and a+ modes => couldn't open because ENOENT */
|
||||
}
|
||||
|
||||
/* Extract file permissions */
|
||||
perms = VA_ARG(arg, int);
|
||||
|
||||
/* w and a modes */
|
||||
if ((fmode & (O_WRONLY|O_RDONLY|O_RDWR)) != O_RDWR)
|
||||
fd = creat(path, perms);
|
||||
|
||||
/* w+ and a+ modes */
|
||||
else {
|
||||
mask = umask(0);
|
||||
if ((fd = creat(path, perms)) >= 0) {
|
||||
(void) close(fd);
|
||||
fd = open(path, O_RDWR);
|
||||
(void) chmod(path, ~mask & perms);
|
||||
}
|
||||
(void) umask(mask);
|
||||
}
|
||||
|
||||
Done:
|
||||
VA_END(arg);
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
14
study/linux-travel/minix-386/estdio21.tar/estdio21/_os.c
Normal file
14
study/linux-travel/minix-386/estdio21.tar/estdio21/_os.c
Normal file
@@ -0,0 +1,14 @@
|
||||
/* _ o s */
|
||||
|
||||
/* Miscellaneous support code. This depends on the configuration
|
||||
* file.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
/* Miscellaneous operating system support code */
|
||||
|
||||
#define SOURCE
|
||||
#include "config.h"
|
||||
13
study/linux-travel/minix-386/estdio21.tar/estdio21/_out.c
Normal file
13
study/linux-travel/minix-386/estdio21.tar/estdio21/_out.c
Normal file
@@ -0,0 +1,13 @@
|
||||
/* _ o u t */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
static __stdiobuf_t __bout[BUFSIZ];
|
||||
|
||||
FILE __stdout = {NULL, NULL, NULL, NULL,
|
||||
&__bout[0], sizeof(__bout)/sizeof(__bout[0]),
|
||||
_IOSTDOUT|_IOINSERT|_IOWRITE|_IOFBF|_IOPOOLBUF,
|
||||
STDOUT_FILENO, 0,
|
||||
__bffil, __bwronly, __btfls, NULL};
|
||||
72
study/linux-travel/minix-386/estdio21.tar/estdio21/_rename.c
Normal file
72
study/linux-travel/minix-386/estdio21.tar/estdio21/_rename.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/* _ r e n a m e */
|
||||
|
||||
/* The file named in the from part is given the name in the to
|
||||
* part. Return EOF if something goes wrong, otherwise return 0.
|
||||
*
|
||||
* This code is attributed to Freeman Pascal.
|
||||
*
|
||||
* rename() will not rename across file systems or file types.
|
||||
* If an attempt is made to copy across file systems both files
|
||||
* will be left intact and an error will be returned. This
|
||||
* is Posix conformant.
|
||||
*
|
||||
* Problems:
|
||||
*
|
||||
* o During the unlink(to), link(from, to) phase, to momentarily
|
||||
* points nowhere in direct contravention of the Posix standard.
|
||||
*
|
||||
* o Directories aren't handled properly:
|
||||
*
|
||||
* . link() and unlink() won't work on directories unless
|
||||
* you're superuser
|
||||
* . some systems don't have mkdir() and rmdir() and
|
||||
* . even if they did, there would still be the small
|
||||
* window of time in which the to link points nowhere.
|
||||
*
|
||||
* Patchlevel 2.2
|
||||
*
|
||||
* Edit History:
|
||||
* 08-Oct-1989 Do nothing if files are the same.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#ifndef RENAME
|
||||
|
||||
int rename F2(CONST char *, from, CONST char *, to)
|
||||
|
||||
{
|
||||
struct stat s_to, s_from;
|
||||
signal_t s_int, s_hup, s_quit;
|
||||
register int ret;
|
||||
|
||||
if (stat(from, &s_from) != 0)
|
||||
return -1;
|
||||
else {
|
||||
if (stat(to, &s_to) == 0) {
|
||||
if (s_to.st_dev == s_from.st_dev) {
|
||||
errno = EXDEV;
|
||||
return -1;
|
||||
}
|
||||
else if (s_to.st_ino == s_from.st_ino)
|
||||
return 0;
|
||||
}
|
||||
|
||||
s_int = signal(SIGINT, SIG_IGN);
|
||||
s_hup = signal(SIGHUP, SIG_IGN);
|
||||
s_quit = signal(SIGQUIT, SIG_IGN);
|
||||
|
||||
ret = unlink(to);
|
||||
if ((ret = link(from, to)) == 0)
|
||||
ret = unlink(from);
|
||||
|
||||
(void) signal(SIGINT, s_int);
|
||||
(void) signal(SIGHUP, s_hup);
|
||||
(void) signal(SIGQUIT, s_quit);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
28
study/linux-travel/minix-386/estdio21.tar/estdio21/_rlbf.c
Normal file
28
study/linux-travel/minix-386/estdio21.tar/estdio21/_rlbf.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* _ r l b f */
|
||||
|
||||
/* This function provides line buffered read support. When reading
|
||||
* from a line buffered stream, it is necessary to discard any
|
||||
* readahead. This function is dynamically linked to __Zrlbf by
|
||||
* setvbuf to minimise code size when line buffered input is not
|
||||
* required.
|
||||
*
|
||||
* This function scans the input buffer and returns a shortened
|
||||
* buffer size. If no \n is found, the buffer size is returned.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
__stdiosize_t __rlbf F2(register FILE *, fp, register __stdiosize_t, bytes)
|
||||
|
||||
{
|
||||
__stdiobuf_t *nlp; /* \n pointer */
|
||||
int offset; /* offset back to one past \n */
|
||||
|
||||
return ((nlp = (__stdiobuf_t *) MEMCHR(fp->__base, '\n', (size_t) bytes))
|
||||
!= NULL &&
|
||||
(offset = nlp - (fp->__base + bytes) + 1) != 0 &&
|
||||
lseek(fileno(fp), (off_t) offset, SEEK_CUR) != -1L)
|
||||
? bytes + offset : bytes;
|
||||
}
|
||||
15
study/linux-travel/minix-386/estdio21.tar/estdio21/_stdio.c
Normal file
15
study/linux-travel/minix-386/estdio21.tar/estdio21/_stdio.c
Normal file
@@ -0,0 +1,15 @@
|
||||
/* _ s t d i o */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
FILE *__iop; /* stream list pointer */
|
||||
/* bss cleared at startup */
|
||||
|
||||
__stdiobuf_t *__iob[POOLSIZE]; /* buffer pool */
|
||||
/* bss cleared at startup */
|
||||
|
||||
#ifdef MSDOS
|
||||
int _fmode = O_BINARY;
|
||||
#endif
|
||||
51
study/linux-travel/minix-386/estdio21.tar/estdio21/_update.c
Normal file
51
study/linux-travel/minix-386/estdio21.tar/estdio21/_update.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/* _ u p d a t e */
|
||||
|
||||
/* This file contains the additional buffering functions required
|
||||
* to implement the update modes of access (r+, w+ and a+).
|
||||
*
|
||||
* The functions perform adjustments to the FILE descriptor before
|
||||
* passing control to the appropriate rdonly or wronly function.
|
||||
*
|
||||
* The functions are placed here so that they will not be linked
|
||||
* in to a basic stdio application unless they are absolutely
|
||||
* necessary (specifically if __fopen() or fseek() are used).
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
/* Check and initialise a read update stream
|
||||
*
|
||||
* __brdupdate is intended for read/write streams. It will check
|
||||
* that the stream has a buffer and will cope with direction
|
||||
* changes. The fill function will then be directed to __brd.
|
||||
*/
|
||||
int __brdupdate F1(register FILE *, fp)
|
||||
|
||||
{
|
||||
if (TESTFLAG(fp, (_IOWRITE | _IOEOF | _IOERR)))
|
||||
return EOF;
|
||||
|
||||
SETFLAG(fp, _IOREAD);
|
||||
|
||||
return __brdonly(fp);
|
||||
}
|
||||
|
||||
/* Check and initialise a write update stream.
|
||||
*
|
||||
* __bwrupdate is intended for read/write streams. It will check
|
||||
* that the stream has a buffer and will cope with direction
|
||||
* changes. The flush function will then be directed to __bwr.
|
||||
*/
|
||||
int __bwrupdate F2(int, c, register FILE *, fp)
|
||||
|
||||
{
|
||||
if (GETFLAG(fp, (_IOREAD | _IOEOF)) == _IOREAD || TESTFLAG(fp, _IOERR))
|
||||
return EOF;
|
||||
|
||||
SETFLAG(fp, _IOWRITE);
|
||||
CLEARFLAG(fp, _IOREAD);
|
||||
|
||||
return __bwronly(c, fp);
|
||||
}
|
||||
25
study/linux-travel/minix-386/estdio21.tar/estdio21/_utoa.c
Normal file
25
study/linux-travel/minix-386/estdio21.tar/estdio21/_utoa.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* _ x u t o a */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#if '0'+1 != '1' || '1'+1 != '2' || '2'+1 != '3' || '3'+1 != '4' || \
|
||||
'4'+1 != '5' || '5'+1 != '6' || '6'+1 != '7' || '7'+1 != '8' || \
|
||||
'8'+1 != '9'
|
||||
<< Violation of collating sequence assumption >>
|
||||
#endif
|
||||
|
||||
char *__utoa F3(char *, p, register unsigned int, n, int, ndigits)
|
||||
|
||||
{
|
||||
register int quotient; /* divided by 10 */
|
||||
|
||||
quotient = 0;
|
||||
if (--ndigits > 0 || n >= 10)
|
||||
p = __utoa(p, quotient = (n / 10), ndigits);
|
||||
|
||||
*p++ = (n - (((quotient << 2) + quotient) << 1)) + '0';
|
||||
|
||||
return p;
|
||||
}
|
||||
682
study/linux-travel/minix-386/estdio21.tar/estdio21/_vfprintf.c
Normal file
682
study/linux-travel/minix-386/estdio21.tar/estdio21/_vfprintf.c
Normal file
@@ -0,0 +1,682 @@
|
||||
/* _ v f p r i n t f */
|
||||
|
||||
/* This function performs all the formatted printing. Floating point
|
||||
* requests are forwarded to lower level floating point conversion
|
||||
* functions. The function must not drag in all of the stdio library
|
||||
* so that sprintf() can be used by programs which don't necessarily
|
||||
* want the rest of stdio.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
#include <ctype.h>
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
/* Number to string conversion
|
||||
*
|
||||
* Separate routines are provided to convert numbers from binary to
|
||||
* string representations for each base. Furthermore, long to int
|
||||
* front end functions are provided in order to improve performance
|
||||
* of long conversions.
|
||||
*/
|
||||
|
||||
/* These definitions provide the masks necessary to convert longs
|
||||
* where longs are wider than the natural word size. The %ld format
|
||||
* requires the largest power of ten that will fit into an integer.
|
||||
* For an integer of N bits, highest power of ten that will fit in
|
||||
* N.log_10 2.
|
||||
*/
|
||||
|
||||
#if LONG_MAX != INT_MAX
|
||||
# define UINTBITS (CHAR_BIT * sizeof(unsigned int))
|
||||
# define HEXSHIFT (UINTBITS/4*4)
|
||||
# define HEXMASK ((unsigned int) ((1L << HEXSHIFT) - 1))
|
||||
# define HEXDIGITS (UINTBITS/4)
|
||||
# define OCTSHIFT (UINTBITS/3*3)
|
||||
# define OCTMASK ((unsigned int) ((1L << OCTSHIFT) - 1))
|
||||
# define OCTDIGITS (UINTBITS/3)
|
||||
# define DECDIGITS (UINTBITS * 301 / 1000)
|
||||
#endif
|
||||
|
||||
/* Radix descriptor table entry */
|
||||
|
||||
typedef struct radix {
|
||||
char *(*utoa) P((unsigned int, char *, char *));
|
||||
/* int to string function */
|
||||
#if LONG_MAX != INT_MAX
|
||||
char *(*ultoa) P((unsigned long, char *, struct radix *));
|
||||
/* long to string function */
|
||||
int lshift; /* bit shift */
|
||||
unsigned int lmask; /* bit mask */
|
||||
int ldigits; /* digits per section */
|
||||
#endif
|
||||
char *conv; /* conversion table */
|
||||
} RADIX;
|
||||
|
||||
/* Function prototypes for unsigned and unsigned long convertors */
|
||||
|
||||
typedef char * (*utof) P((unsigned int, char *, char *));
|
||||
typedef char * (*ultof) P((unsigned int, char *, RADIX *));
|
||||
|
||||
/* unsigned int to string convertors */
|
||||
|
||||
static char *__utod F3(register unsigned int, n,
|
||||
register char *, p,
|
||||
char *, conv)
|
||||
|
||||
{
|
||||
unsigned int q;
|
||||
|
||||
do {
|
||||
q = n / 10;
|
||||
*--p = (n - q*10) + '0';
|
||||
} while ((n = q) != 0);
|
||||
return p;
|
||||
}
|
||||
|
||||
static char *__utoo F3(register unsigned int, n,
|
||||
register char *, p,
|
||||
char *, conv)
|
||||
|
||||
{
|
||||
do {
|
||||
*--p = (n & 0x7) + '0';
|
||||
} while ((n >>= 3) != 0);
|
||||
return p;
|
||||
}
|
||||
|
||||
static char *__utox F3(register unsigned int, n,
|
||||
register char *, p,
|
||||
char *, conv)
|
||||
|
||||
{
|
||||
do {
|
||||
*--p = conv[n & 0xf];
|
||||
} while ((n >>= 4) != 0);
|
||||
return p;
|
||||
}
|
||||
|
||||
/* unsigned long to string convertors */
|
||||
|
||||
#if LONG_MAX != INT_MAX
|
||||
static char *__ultod F3(unsigned long, n, char *, p, RADIX *, r)
|
||||
|
||||
{
|
||||
unsigned long q;
|
||||
unsigned int d;
|
||||
char *t;
|
||||
int i;
|
||||
|
||||
ASSERT(DECDIGITS <= __Mipow10);
|
||||
|
||||
for (;;) {
|
||||
q = n / __ipow10[DECDIGITS];
|
||||
d = n - q * __ipow10[DECDIGITS];
|
||||
t = (*r->utoa)(d, p, NULL);
|
||||
if ((n = q) == 0)
|
||||
break;
|
||||
for (i = DECDIGITS - (p - t); i--; )
|
||||
*--t = '0';
|
||||
p = t;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
static char *__ultob F3(unsigned long, n, char *, p, RADIX *, r)
|
||||
|
||||
{
|
||||
int i;
|
||||
char *t;
|
||||
|
||||
for (;;) {
|
||||
t = (*r->utoa)((unsigned int) n & r->lmask, p, r->conv);
|
||||
if ((n >>= r->lshift) == 0)
|
||||
break;
|
||||
for (i = r->ldigits - (p - t); i--; )
|
||||
*--t = '0';
|
||||
p = t;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Digit to character conversion table */
|
||||
|
||||
static char __lconv[] = "0123456789abcdef";
|
||||
static char __uconv[] = "0123456789ABCDEF";
|
||||
|
||||
/* Entries in radix descriptor table */
|
||||
|
||||
#define N_RADIX (sizeof(__radix)/sizeof(__radix[0]))
|
||||
#define R_DECIMAL 0
|
||||
#define R_HEXL 1
|
||||
#define R_HEXU 2
|
||||
#define R_OCTAL 3
|
||||
|
||||
/* Radix descriptor table */
|
||||
|
||||
#if LONG_MAX != INT_MAX
|
||||
#define LONG(ultoa,lshift,lmask,ldigits) (ultoa),(lshift),(lmask),(ldigits),
|
||||
#else
|
||||
#define LONG(ultoa,lshift,lmask,ldigits)
|
||||
#endif
|
||||
|
||||
static RADIX __radix[] = {
|
||||
{__utod, LONG(__ultod, 0, 0, 0) NULL}, /* %d %u */
|
||||
{__utox, LONG(__ultob, HEXSHIFT, HEXMASK, HEXDIGITS) __lconv},/* %x */
|
||||
{__utox, LONG(__ultob, HEXSHIFT, HEXMASK, HEXDIGITS) __uconv},/* %X */
|
||||
{__utoo, LONG(__ultob, OCTSHIFT, OCTMASK, OCTDIGITS) NULL}, /* %o */
|
||||
};
|
||||
|
||||
/* Formatted component vector print
|
||||
*
|
||||
* This function prints component vectors of the output string.
|
||||
*/
|
||||
|
||||
static void __printv F3(register FILE *, fp, int, vc, register FV *, vp)
|
||||
|
||||
{
|
||||
__stdiobuf_t *wp; /* output buffer pointer */
|
||||
__stdiobuf_t *p; /* buffer pointer */
|
||||
int pad; /* padding only */
|
||||
__stdiosize_t wb; /* bytes to write */
|
||||
__stdiosize_t wf; /* free bytes in buffer */
|
||||
__stdiosize_t len; /* length of string */
|
||||
|
||||
for (len = 0; ;) {
|
||||
|
||||
/* Gauge the amount of free space in the stream buffer */
|
||||
if (! TESTFLAG(fp, _IONBF))
|
||||
wf = UNUSEDINWRITEBUFFER(fp);
|
||||
else {
|
||||
fp->__wptr = fp->__wend = fp->__base = &fp->__buf;
|
||||
wf = 0;
|
||||
}
|
||||
wp = GETWRITEPTR(fp);
|
||||
|
||||
for (;;) {
|
||||
if ((wb = len) != 0 && wf != 0) {
|
||||
|
||||
if (wb > wf)
|
||||
wb = wf;
|
||||
|
||||
wf -= wb;
|
||||
len -= wb;
|
||||
|
||||
if (pad != 0)
|
||||
MEMSET((char *) wp, *p, (size_t) wb);
|
||||
else {
|
||||
MEMCPY((char *) wp, (char *) p, (size_t) wb);
|
||||
p += wb;
|
||||
}
|
||||
|
||||
wp += wb;
|
||||
}
|
||||
|
||||
/* Determine the nature and size of the next string to write */
|
||||
if (len == 0) {
|
||||
if (vc == 0) {
|
||||
SETWRITEPTR(fp, wp);
|
||||
return;
|
||||
}
|
||||
|
||||
pad = vp->att & FV_F_PADDING;
|
||||
len = vp->len;
|
||||
p = (__stdiobuf_t *) vp->arg;
|
||||
vc--;
|
||||
vp++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Flush a filled stream buffer */
|
||||
if (TESTFLAG(fp, _IONBF)) {
|
||||
fp->__base = p;
|
||||
if (pad != 0 && wb > PWRITEAHEAD)
|
||||
wb = PWRITEAHEAD;
|
||||
len -= wb;
|
||||
wp = p + wb;
|
||||
}
|
||||
SETWRITEPTR(fp, wp);
|
||||
(void) FFLUSH(fp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Filler strings */
|
||||
|
||||
#if PWRITEAHEAD != 4
|
||||
<< Print buffer write ahead assumed to be 4 >>
|
||||
#else
|
||||
char __zfill[PWRITEAHEAD] = { /* zero fill */
|
||||
'0', '0', '0', '0' };
|
||||
static char __bfill[PWRITEAHEAD] = { /* blank fill */
|
||||
' ', ' ', ' ', ' ' };
|
||||
#endif
|
||||
|
||||
/* Format indicator */
|
||||
|
||||
#if 0 < '%'
|
||||
# define FMTCH(x) ( (x) <= '%' )
|
||||
#else
|
||||
# define FMTCH(x) ( (x) >= '%' )
|
||||
#endif
|
||||
|
||||
int __vfprintf F3(FILE *, fp, CONST char *, fmt, VA_LIST, args)
|
||||
|
||||
{
|
||||
register __stdiobuf_t *wp; /* direct write pointer */
|
||||
register __stdiobuf_t *sp; /* format string pointer */
|
||||
register __stdiobuf_t *we; /* end of output buffer */
|
||||
__stdiobuf_t *pb; /* line buffered scan point */
|
||||
__stdiobuf_t *sb; /* base of this format */
|
||||
|
||||
int c; /* conversion temporary */
|
||||
|
||||
char *p, *q; /* pointers into workspace */
|
||||
|
||||
int flag; /* flags */
|
||||
|
||||
FV leftfill; /* left fill */
|
||||
|
||||
__stdiosize_t bytes; /* bytes output */
|
||||
__stdiosize_t width; /* field width */
|
||||
__stdiosize_t precision; /* precision */
|
||||
__stdiosize_t length; /* raw length of output */
|
||||
|
||||
char sign; /* conversion is signed */
|
||||
char negative; /* number is negative */
|
||||
long vl; /* conversion temporary */
|
||||
RADIX *radix; /* radix descriptor */
|
||||
int vi; /* conversion temporary */
|
||||
|
||||
int fvc; /* vector count */
|
||||
int fvx; /* vector index */
|
||||
FV *fvp; /* vector scanner */
|
||||
FV fv[FV_ARGS]; /* formatted vectors */
|
||||
|
||||
char buf[PBUFFERSIZE]; /* workspace */
|
||||
|
||||
if (CHECKWRITE(fp))
|
||||
return 0;
|
||||
|
||||
/* Initialise once for buffered streams */
|
||||
fv[FV_FMTPREFIX].att = FV_F_VECTOR;
|
||||
fv[FV_FMTPREFIX].len = 0;
|
||||
|
||||
/* Buffer start for line buffered streams */
|
||||
pb = GETWRITEPTR(fp);
|
||||
|
||||
bytes = 0;
|
||||
|
||||
for (sp = (__stdiobuf_t *) fmt; ;) {
|
||||
|
||||
/* Scan for format specifier */
|
||||
sb = sp;
|
||||
if (TESTFLAG(fp, _IONBF)) {
|
||||
fv[FV_FMTPREFIX].arg = (char *) sb;
|
||||
if ((sp = strchr((char *) sb, '%')) != NULL)
|
||||
fv[FV_FMTPREFIX].len = sp - sb;
|
||||
else {
|
||||
length = strlen((char *) sb);
|
||||
bytes += length;
|
||||
sb = sp = "";
|
||||
fv[FV_FMTPREFIX].len = length;
|
||||
__printv(fp, 1, &fv[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (;;) {
|
||||
|
||||
wp = GETWRITEPTR(fp);
|
||||
we = GETWRITELIMIT(fp);
|
||||
|
||||
if (BUFFERSIZE(fp) >= PWRITEAHEAD) {
|
||||
we -= PWRITEAHEAD;
|
||||
while (wp < we) {
|
||||
if (FMTCH(wp[0] = sp[0]) && (wp[0] == 0 || wp[0] == '%'))
|
||||
goto Format0;
|
||||
if (FMTCH(wp[1] = sp[1]) && (wp[1] == 0 || wp[1] == '%'))
|
||||
goto Format1;
|
||||
if (FMTCH(wp[2] = sp[2]) && (wp[2] == 0 || wp[2] == '%'))
|
||||
goto Format2;
|
||||
if (FMTCH(wp[3] = sp[3]) && (wp[3] == 0 || wp[3] == '%'))
|
||||
goto Format3;
|
||||
sp += PWRITEAHEAD;
|
||||
wp += PWRITEAHEAD;
|
||||
}
|
||||
we += PWRITEAHEAD;
|
||||
}
|
||||
for (; wp < we; wp++, sp++) {
|
||||
if (FMTCH(wp[0] = sp[0]) && (wp[0] == 0 || wp[0] == '%'))
|
||||
goto Format0;
|
||||
}
|
||||
SETWRITEPTR(fp, wp);
|
||||
FFLUSH(fp);
|
||||
}
|
||||
|
||||
Format3: wp += 3; sp += 3; goto Format0;
|
||||
Format2: wp += 2; sp += 2; goto Format0;
|
||||
Format1: wp += 1; sp += 1; goto Format0;
|
||||
Format0:
|
||||
|
||||
SETWRITEPTR(fp, wp);
|
||||
}
|
||||
|
||||
/* Format or end of format found */
|
||||
bytes += sp - sb;
|
||||
|
||||
if (*sp == 0)
|
||||
break;
|
||||
sp++;
|
||||
|
||||
/* Initialise conversion variables */
|
||||
p = q = &buf[sizeof(buf)-1];
|
||||
|
||||
flag = 0;
|
||||
leftfill.arg = __bfill;
|
||||
width = 0;
|
||||
|
||||
/* Switch through all the format options */
|
||||
Parse_again:
|
||||
switch (c = *sp++) {
|
||||
|
||||
case '-': flag |= F_LEFTJUSTIFY; goto Parse_again;
|
||||
case '+': flag |= F_SHOWSIGN; goto Parse_again;
|
||||
case ' ': flag |= F_BLANKPREFIX; goto Parse_again;
|
||||
case '#': flag |= F_ALTERNATE; goto Parse_again;
|
||||
|
||||
/* Check for field width and precision */
|
||||
case '*':
|
||||
if ((c = VA_ARG(args, int)) < 0) {
|
||||
flag |= F_LEFTJUSTIFY;
|
||||
c = -c;
|
||||
}
|
||||
width = c;
|
||||
c = *sp++;
|
||||
goto Precision;
|
||||
|
||||
/* Zero fill and field width */
|
||||
case '0':
|
||||
leftfill.arg = __zfill;
|
||||
c = *sp++;
|
||||
|
||||
case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9':
|
||||
for (; c >= '0' && c <= '9'; c = *sp++) {
|
||||
width *= 10;
|
||||
width += (c - '0');
|
||||
}
|
||||
|
||||
case '.':
|
||||
Precision:
|
||||
if (c == '.') {
|
||||
c = *sp++;
|
||||
if (c == '*') {
|
||||
if ((c = VA_ARG(args, int)) >= 0) {
|
||||
flag |= F_PRECISION;
|
||||
precision = c;
|
||||
}
|
||||
sp++;
|
||||
}
|
||||
else if (c >= '0' && c <= '9') {
|
||||
flag |= F_PRECISION;
|
||||
precision = 0;
|
||||
for (; c >= '0' && c <= '9'; c = *sp++) {
|
||||
precision *= 10;
|
||||
precision += (c - '0');
|
||||
}
|
||||
}
|
||||
}
|
||||
sp--;
|
||||
goto Parse_again;
|
||||
|
||||
/* Short indication */
|
||||
case 'h':
|
||||
flag = (flag & ~(F_SHORT | F_LONG | F_LONGDOUBLE)) | F_SHORT;
|
||||
goto Parse_again;
|
||||
|
||||
/* Long indication */
|
||||
case 'l':
|
||||
flag = (flag & ~(F_SHORT | F_LONG | F_LONGDOUBLE)) | F_LONG;
|
||||
goto Parse_again;
|
||||
|
||||
/* Long double indication */
|
||||
case 'L':
|
||||
flag = (flag & ~(F_SHORT | F_LONG | F_LONGDOUBLE)) | F_LONGDOUBLE;
|
||||
goto Parse_again;
|
||||
|
||||
/* Number of bytes output */
|
||||
case 'n':
|
||||
*(VA_ARG(args, int *)) = bytes;
|
||||
continue;
|
||||
|
||||
/* Pointer */
|
||||
case 'p':
|
||||
flag = (flag & ~(F_SHORT | F_LONG | F_LONGDOUBLE)) |
|
||||
F_LONG * (sizeof(void *) == sizeof(long));
|
||||
sign = 0;
|
||||
radix = &__radix[R_HEXL];
|
||||
goto oxud;
|
||||
|
||||
/* Integer conversions */
|
||||
case 'X':
|
||||
flag |= F_0X;
|
||||
sign = 0;
|
||||
radix = &__radix[R_HEXU];
|
||||
goto oxud;
|
||||
|
||||
case 'x':
|
||||
sign = 0;
|
||||
radix = &__radix[R_HEXL];
|
||||
goto oxud;
|
||||
|
||||
case 'u':
|
||||
sign = 0;
|
||||
radix = &__radix[R_DECIMAL];
|
||||
goto oxud;
|
||||
|
||||
case 'o':
|
||||
sign = 0;
|
||||
radix = &__radix[R_OCTAL];
|
||||
goto oxud;
|
||||
|
||||
case 'i':
|
||||
case 'd':
|
||||
sign = 1;
|
||||
radix = &__radix[R_DECIMAL];
|
||||
|
||||
oxud:
|
||||
if ((flag & F_LONG) != 0) {
|
||||
if (sign) vl = VA_ARG(args, long);
|
||||
else vl = VA_ARG(args, unsigned long);
|
||||
if ((negative = sign && vl < 0) != 0)
|
||||
vl = -vl;
|
||||
#if LONG_MAX != INT_MAX
|
||||
q = (*radix->ultoa)((unsigned long) vl, q, radix);
|
||||
#else
|
||||
q = (*radix->utoa)((unsigned int) vl, q, radix->conv);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
if ((flag & F_SHORT) != 0)
|
||||
if (sign) vi = (int) VA_ARG(args, short);
|
||||
else vi = (int) VA_ARG(args, unsigned short);
|
||||
else
|
||||
if (sign) vi = (int) VA_ARG(args, int);
|
||||
else vi = (int) VA_ARG(args, unsigned);
|
||||
if ((negative = (sign && vi < 0)) != 0)
|
||||
vi = -vi;
|
||||
q = (*radix->utoa)((unsigned int) vi, q, radix->conv);
|
||||
}
|
||||
|
||||
if ((flag & F_PRECISION) != 0 && precision > width) {
|
||||
width = precision;
|
||||
leftfill.arg = __zfill;
|
||||
}
|
||||
|
||||
fv[FV_INTINT].att = FV_F_VECTOR;
|
||||
fv[FV_INTINT].len = p - q;
|
||||
fv[FV_INTINT].arg = q;
|
||||
fv[FV_INTSIGN].att = FV_F_VECTOR;
|
||||
fv[FV_INTSIGN].len = 0;
|
||||
fvc = FV_INTARGS;
|
||||
|
||||
if (negative) {
|
||||
fv[FV_INTSIGN].len++;
|
||||
*--q = '-';
|
||||
}
|
||||
else if (sign) {
|
||||
if ((flag & F_SHOWSIGN) != 0) {
|
||||
fv[FV_INTSIGN].len++;
|
||||
*--q = '+';
|
||||
}
|
||||
else if ((flag & F_BLANKPREFIX) != 0) {
|
||||
fv[FV_INTSIGN].len++;
|
||||
*--q = ' ';
|
||||
}
|
||||
}
|
||||
if ((flag & F_ALTERNATE) != 0) {
|
||||
if (radix == &__radix[R_OCTAL]) {
|
||||
fv[FV_INTSIGN].len++;
|
||||
*--q = '0';
|
||||
}
|
||||
else if (radix == &__radix[R_HEXL] || radix == &__radix[R_HEXU]) {
|
||||
fv[FV_INTSIGN].len += 2;
|
||||
*--q = (flag & F_0X) != 0 ? 'X' : 'x';
|
||||
*--q = '0';
|
||||
}
|
||||
}
|
||||
fv[FV_INTSIGN].arg = q;
|
||||
length = p - q;
|
||||
break;
|
||||
|
||||
/* Floating point formats */
|
||||
case 'f':
|
||||
flag |= F_FPFORMATF;
|
||||
goto Fconvert;
|
||||
|
||||
case 'E':
|
||||
flag |= F_FPCAPITAL;
|
||||
case 'e':
|
||||
flag |= F_FPFORMATE;
|
||||
goto Fconvert;
|
||||
|
||||
case 'G':
|
||||
flag |= F_FPCAPITAL;
|
||||
case 'g':
|
||||
flag |= F_FPFORMATG;
|
||||
Fconvert:
|
||||
if ((flag & F_PRECISION) == 0) precision = 6;
|
||||
fvc = FV_FMTARGS
|
||||
+ __cvt(&length, &fv[FV_FMTARGS], buf, &args, precision, flag);
|
||||
ASSERT(fvc <= FV_ARGS);
|
||||
break;
|
||||
|
||||
/* Single character format */
|
||||
case 'c':
|
||||
*--q = VA_ARG(args, int);
|
||||
goto Simple_vector;
|
||||
|
||||
/* String format */
|
||||
case 's':
|
||||
if ((q = VA_ARG(args, char *)) == NULL)
|
||||
q = "(null)";
|
||||
if ((flag & F_PRECISION) == 0)
|
||||
p = q + strlen(q);
|
||||
else {
|
||||
if ((p = (char *) MEMCHR(q, 0, (size_t) precision)) == NULL)
|
||||
p = q + precision;
|
||||
}
|
||||
goto Simple_vector;
|
||||
|
||||
/* Default just print it */
|
||||
default:
|
||||
*--q = sp[-1];
|
||||
|
||||
/* Construct a simple vector */
|
||||
Simple_vector:
|
||||
length = p - q;
|
||||
fv[FV_INTINT].att = FV_F_VECTOR;
|
||||
fv[FV_INTINT].len = length;
|
||||
fv[FV_INTINT].arg = q;
|
||||
fv[FV_INTSIGN].att = FV_F_VECTOR;
|
||||
fv[FV_INTSIGN].len = 0;
|
||||
fvc = FV_INTARGS;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Start vector index */
|
||||
fvx = 0;
|
||||
fvp = &fv[0];
|
||||
bytes += length;
|
||||
|
||||
/* Subtract to find padding required --- no padding */
|
||||
if (width <= length) {
|
||||
width = 0;
|
||||
|
||||
fv[FV_FMTARGS+1].len += fv[FV_FMTARGS].len;
|
||||
fv[FV_FMTARGS+1].arg -= fv[FV_FMTARGS].len;
|
||||
fv[FV_FMTARGS].len = 0;
|
||||
}
|
||||
|
||||
/* Some padding required (may be right or left) */
|
||||
else {
|
||||
width -= length;
|
||||
|
||||
/* Required right justification (padding on left) */
|
||||
if ((flag & F_LEFTJUSTIFY) == 0) {
|
||||
|
||||
/* Print format string first */
|
||||
#if FV_FMTARGS != 1
|
||||
<< FV_FMTARGS assumed to be 1 >>
|
||||
#else
|
||||
if (fvp->len > 0)
|
||||
__printv(fp, FV_FMTARGS, fvp);
|
||||
#endif
|
||||
fvp += FV_FMTARGS;
|
||||
fvx += FV_FMTARGS;
|
||||
|
||||
/* Check for negative and zero fill */
|
||||
if (leftfill.arg == __zfill && fv[FV_FMTARGS].len != 0) {
|
||||
__printv(fp, 1, &fv[FV_FMTARGS]);
|
||||
fvx++;
|
||||
fvp++;
|
||||
}
|
||||
|
||||
/* Now output the rest of the padding */
|
||||
bytes += width;
|
||||
leftfill.att = FV_F_PADDING;
|
||||
leftfill.len = width;
|
||||
width = 0;
|
||||
__printv(fp, 1, &leftfill);
|
||||
}
|
||||
}
|
||||
|
||||
/* Output the string proper */
|
||||
__printv(fp, fvc-fvx, fvp);
|
||||
|
||||
/* Check for required right padding */
|
||||
if (width != 0) {
|
||||
bytes += width;
|
||||
leftfill.att = FV_F_PADDING;
|
||||
leftfill.len = width;
|
||||
leftfill.arg = __bfill;
|
||||
__printv(fp, 1, &leftfill);
|
||||
}
|
||||
}
|
||||
|
||||
/* Flush line buffered streams */
|
||||
if (TESTFLAG(fp, _IOLBF)) {
|
||||
length = bytes;
|
||||
if (bytes + pb != GETWRITEPTR(fp)) {
|
||||
pb = fp->__base;
|
||||
length = BYTESINWRITEBUFFER(fp);
|
||||
}
|
||||
pb = (__stdiobuf_t *) MEMCHR(pb, '\n', (size_t) length);
|
||||
if (pb != NULL)
|
||||
(void) FFLUSH(fp);
|
||||
}
|
||||
|
||||
return ferror(fp) ? EOF : bytes;
|
||||
}
|
||||
343
study/linux-travel/minix-386/estdio21.tar/estdio21/_vfscanf.c
Normal file
343
study/linux-travel/minix-386/estdio21.tar/estdio21/_vfscanf.c
Normal file
@@ -0,0 +1,343 @@
|
||||
/* _ v f s c a n f */
|
||||
|
||||
/* This funcion forms the basis for all the scanf family of functions.
|
||||
* The function returns EOF on end of input, and a short count for
|
||||
* missing or illegal data items. Hooks are provided for the floating
|
||||
* point input routines.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include "stdiolib.h"
|
||||
#include "bitset.h"
|
||||
|
||||
#define CHARSET (1 << CHAR_BIT)
|
||||
|
||||
#define BLANK(c) isspace(c) /* was ((c) == ' ' || (c) == '\t') */
|
||||
#define NEXTCH() (nbytes++, ch = getc(fp))
|
||||
#define ENDFIELD() \
|
||||
if (fieldok) { \
|
||||
if (! noassign) items++; \
|
||||
} \
|
||||
else \
|
||||
goto Putback;
|
||||
|
||||
/* Conversion of each digit to the internal number representation
|
||||
* relies on the fact that the character codes for '0-'9', the
|
||||
* codes for 'a'-'f' and the codes for 'A'-'F' are each ordered
|
||||
* consecutively.
|
||||
*/
|
||||
|
||||
#if '0'+1 != '1' || '1'+1 != '2' || '2'+1 != '3' || '3'+1 != '4' || \
|
||||
'4'+1 != '5' || '5'+1 != '6' || '6'+1 != '7' || '7'+1 != '8' || \
|
||||
'8'+1 != '9' || \
|
||||
'a'+1 != 'b' || 'b'+1 != 'c' || 'c'+1 != 'd' || 'd'+1 != 'e' || \
|
||||
'e'+1 != 'f' || \
|
||||
'A'+1 != 'B' || 'B'+1 != 'C' || 'C'+1 != 'D' || 'D'+1 != 'E' || \
|
||||
'E'+1 != 'F'
|
||||
<< Violation of collating sequence assumption >>
|
||||
#endif
|
||||
|
||||
int __vfscanf F3(register FILE *, fp, register CONST char *, fmt, VA_LIST, args)
|
||||
|
||||
{
|
||||
int items; /* number of items done */
|
||||
int ch; /* next character */
|
||||
int lch; /* lowercase version of character */
|
||||
int i; /* general index */
|
||||
int nbytes; /* bytes read */
|
||||
char *p; /* string pointer */
|
||||
char skipspace; /* force white space skip */
|
||||
char noassign; /* do not do assignment */
|
||||
char longdoubleflag; /* pointer is longdouble */
|
||||
char longflag; /* pointer is long */
|
||||
char shortflag; /* pointer is short */
|
||||
char fieldok; /* this field parsed ok */
|
||||
char invertedset; /* inverted set */
|
||||
char sign; /* conversion is signed */
|
||||
char negative; /* number is negative */
|
||||
int fieldwidth; /* width of field */
|
||||
unsigned radix; /* radix for conversion */
|
||||
unsigned lastdigit; /* last digit (0-9) in radix */
|
||||
long longv; /* long value for conversion */
|
||||
bitstring(cset, CHARSET); /* set for %[] */
|
||||
|
||||
/* Prime the look ahead character */
|
||||
if ((ch = getc(fp)) == EOF)
|
||||
return EOF;
|
||||
|
||||
for (nbytes = items = 0; ; fmt++) {
|
||||
|
||||
/* Skip whitespace in format */
|
||||
for (skipspace = 0; BLANK(*fmt); fmt++)
|
||||
skipspace = 1;
|
||||
|
||||
/* Check for end of format or end of input */
|
||||
if (*fmt == 0 || ch == EOF)
|
||||
goto Putback;
|
||||
|
||||
/* Check for verbatim character */
|
||||
if (*fmt != '%') {
|
||||
while (BLANK(ch))
|
||||
NEXTCH();
|
||||
|
||||
if (ch != *fmt)
|
||||
goto Putback;
|
||||
|
||||
NEXTCH();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Format precursor seen --- see if assignment required */
|
||||
if ((noassign = *++fmt == '*') != 0)
|
||||
fmt++;
|
||||
|
||||
/* Check for width specification */
|
||||
fieldwidth = -1;
|
||||
if (*fmt >= '0' && *fmt <= '9') {
|
||||
for (fieldwidth = 0; *fmt >= '0' && *fmt <= '9'; )
|
||||
fieldwidth = fieldwidth * 10 + *fmt++ - '0';
|
||||
}
|
||||
|
||||
/* Check for long, short or longdouble pointers */
|
||||
if ((longflag = *fmt == 'l') != 0 ||
|
||||
(shortflag = *fmt == 'h') != 0 ||
|
||||
(longdoubleflag = *fmt == 'L') != 0)
|
||||
fmt++;
|
||||
|
||||
/* Skip whitespace in the input stream */
|
||||
if (skipspace || (*fmt != 'c' && *fmt != '[')) {
|
||||
while (isspace(ch))
|
||||
NEXTCH();
|
||||
}
|
||||
|
||||
/* Assume that field is not parsed */
|
||||
fieldok = 0;
|
||||
|
||||
/* Initialise number conversion --- assume unsigned decimal */
|
||||
longv = 0;
|
||||
negative = 0;
|
||||
sign = 0;
|
||||
radix = 10;
|
||||
lastdigit = '9';
|
||||
|
||||
switch (*fmt) {
|
||||
|
||||
/* Bytes read */
|
||||
case 'n':
|
||||
*(VA_ARG(args, int *)) = nbytes;
|
||||
break;
|
||||
|
||||
/* Pointer */
|
||||
case 'p':
|
||||
longflag = sizeof(void *) > sizeof(unsigned int);
|
||||
radix = 16;
|
||||
goto oxud;
|
||||
|
||||
/* General integer */
|
||||
case 'i':
|
||||
|
||||
/* Octal or hexadecimal indication */
|
||||
if (fieldwidth != 0 && ch == '0') {
|
||||
NEXTCH();
|
||||
if (--fieldwidth != 0) {
|
||||
if (ch == 'x' || ch == 'X') {
|
||||
NEXTCH();
|
||||
radix = 16;
|
||||
}
|
||||
else {
|
||||
radix = 8;
|
||||
lastdigit = '7';
|
||||
}
|
||||
}
|
||||
goto atoi;
|
||||
}
|
||||
/* Fall through to signed decimal */
|
||||
|
||||
case 'd': sign = 1; goto oxud;
|
||||
case 'o': radix = 8; lastdigit = '7'; goto oxud;
|
||||
case 'x': radix = 16;
|
||||
case 'u':
|
||||
|
||||
oxud:
|
||||
|
||||
/* Look for sign if number is signed */
|
||||
if (fieldwidth != 0) {
|
||||
if (sign) {
|
||||
if (ch == '+') {
|
||||
NEXTCH();
|
||||
fieldwidth--;
|
||||
}
|
||||
else if (ch == '-') {
|
||||
negative = 1;
|
||||
NEXTCH();
|
||||
fieldwidth--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Look for leading 0x for hexadecimal */
|
||||
else {
|
||||
if (radix == 16 && ch == '0') {
|
||||
NEXTCH();
|
||||
if (--fieldwidth != 0) {
|
||||
if (ch != 'x' && ch != 'X')
|
||||
fieldok = 1;
|
||||
else {
|
||||
NEXTCH();
|
||||
fieldwidth--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
atoi:
|
||||
|
||||
/* Scan and convert */
|
||||
while (fieldwidth < 0 || fieldwidth--) {
|
||||
if (ch >= '0' && ch <= lastdigit)
|
||||
ch -= '0';
|
||||
else if (ch == EOF)
|
||||
break;
|
||||
else {
|
||||
lch = TOLOWER(ch);
|
||||
if (lch >= 'a' && (lch += 10 - 'a') < radix)
|
||||
ch = lch;
|
||||
else
|
||||
break;
|
||||
}
|
||||
longv = longv * radix + ch;
|
||||
NEXTCH();
|
||||
fieldok = 1;
|
||||
}
|
||||
|
||||
/* Complete the conversion */
|
||||
if (! noassign) {
|
||||
if (negative)
|
||||
longv = -longv;
|
||||
if (longflag)
|
||||
if (sign) *VA_ARG(args, long *) = longv;
|
||||
else *VA_ARG(args, unsigned long *) = longv;
|
||||
else if (shortflag)
|
||||
if (sign) *VA_ARG(args, short *) = (short) longv;
|
||||
else *VA_ARG(args, unsigned short *) = (unsigned short) longv;
|
||||
else
|
||||
if (sign) *VA_ARG(args, int *) = (int) longv;
|
||||
else *VA_ARG(args, unsigned int *) = (unsigned int) longv;
|
||||
}
|
||||
ENDFIELD();
|
||||
break;
|
||||
|
||||
/* Floating point */
|
||||
case 'e':
|
||||
case 'f':
|
||||
case 'g':
|
||||
(void) ungetc(ch, fp);
|
||||
if (noassign)
|
||||
i = 0;
|
||||
else {
|
||||
if (longdoubleflag)
|
||||
i = 1;
|
||||
else if (longflag)
|
||||
i = 2;
|
||||
else
|
||||
i = 3;
|
||||
}
|
||||
nbytes += __tvc(fp, fieldwidth, &args, i, &fieldok);
|
||||
ch = getc(fp);
|
||||
ENDFIELD();
|
||||
break;
|
||||
|
||||
/* Single character */
|
||||
case 'c':
|
||||
if (fieldwidth == -1)
|
||||
fieldwidth = 1;
|
||||
|
||||
/* Initialise the string pointer */
|
||||
if (! noassign)
|
||||
p = VA_ARG(args, char *);
|
||||
|
||||
while (fieldwidth-- && ch >= 0) {
|
||||
if (! noassign)
|
||||
*p++ = ch;
|
||||
NEXTCH();
|
||||
fieldok = 1;
|
||||
}
|
||||
ENDFIELD();
|
||||
break;
|
||||
|
||||
case 's':
|
||||
|
||||
/* Initialise the string pointer */
|
||||
if (! noassign)
|
||||
p = VA_ARG(args, char *);
|
||||
|
||||
while (fieldwidth < 0 || fieldwidth--) {
|
||||
if (ch <= 0 || BLANK(ch))
|
||||
break;
|
||||
if (! noassign)
|
||||
*p++ = ch;
|
||||
NEXTCH();
|
||||
fieldok = 1;
|
||||
}
|
||||
|
||||
/* Terminate the string with a null */
|
||||
if (! noassign)
|
||||
*p++ = 0;
|
||||
ENDFIELD();
|
||||
break;
|
||||
|
||||
case '[':
|
||||
|
||||
/* Clear the bit set */
|
||||
bitempty(cset, CHARSET);
|
||||
|
||||
/* Check for inverted set */
|
||||
if ((invertedset = *++fmt == '^') != 0)
|
||||
fmt++;
|
||||
|
||||
/* Check for right bracket in set */
|
||||
if (*fmt == ']')
|
||||
bitset(cset, *fmt++);
|
||||
|
||||
/* Scan search set, setting bits */
|
||||
while (*fmt != 0 && *fmt != ']') {
|
||||
if (fmt[1] != '-' || fmt[2] == ']' || fmt[2] == 0 || fmt[0] > fmt[2])
|
||||
bitset(cset, *fmt++);
|
||||
else {
|
||||
for (i = fmt[0]; i <= fmt[2]; i++)
|
||||
bitset(cset, i);
|
||||
fmt += 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for unsatisfactory set construction */
|
||||
if (*fmt != ']')
|
||||
goto Putback;
|
||||
|
||||
/* Initialise string pointer */
|
||||
if (! noassign)
|
||||
p = VA_ARG(args, char *);
|
||||
|
||||
/* Scan input for satisfactory characters */
|
||||
while (fieldwidth < 0 || fieldwidth--) {
|
||||
if (BLANK(ch) || ch <= 0 || ! (bittest(cset, ch) ^ invertedset))
|
||||
break;
|
||||
if (! noassign)
|
||||
*p++ = ch;
|
||||
NEXTCH();
|
||||
fieldok = 1;
|
||||
}
|
||||
|
||||
/* Terminate string with null */
|
||||
if (! noassign)
|
||||
*p++ = 0;
|
||||
ENDFIELD();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore the look ahead character */
|
||||
Putback:
|
||||
(void) ungetc(ch, fp);
|
||||
return items;
|
||||
}
|
||||
11
study/linux-travel/minix-386/estdio21.tar/estdio21/_vscanf.c
Normal file
11
study/linux-travel/minix-386/estdio21.tar/estdio21/_vscanf.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/* _ v s c a n f */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
int __vscanf F2(CONST char *, fmt, VA_LIST, args)
|
||||
|
||||
{
|
||||
return __vfscanf(stdin, fmt, args);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/* _ v s s c a n f */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
int __vsscanf F3(CONST char *, buf, CONST char *, fmt, VA_LIST, args)
|
||||
|
||||
{
|
||||
FILE f; /* temporary file */
|
||||
|
||||
f.__flag = _IOREAD | _IOSTRING;
|
||||
f.__base = (__stdiobuf_t *) buf;
|
||||
f.__bufsiz = strlen(buf);
|
||||
|
||||
f.__filbuf = __bffil;
|
||||
f.__flsbuf = __bffls;
|
||||
f.__flush = __bffil;
|
||||
|
||||
INITREADBUFFER(&f, f.__bufsiz);
|
||||
|
||||
return __vfscanf(&f, fmt, args);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/* _ x a s s e r t */
|
||||
|
||||
/* This code aborts the stdio package with an assertion failure
|
||||
* message. This is required since the standard assertion macro
|
||||
* may use stdio to print the error message.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
int __xassert F1(char *, file)
|
||||
|
||||
{
|
||||
static char *failure = "Assertion failed in stdio module ";
|
||||
|
||||
(void) __iowrite(STDERR_FILENO, failure, strlen(failure));
|
||||
(void) __iowrite(STDERR_FILENO, file, strlen(file));
|
||||
(void) __iowrite(STDERR_FILENO, "\n", 1);
|
||||
abort();
|
||||
return 0;
|
||||
}
|
||||
23
study/linux-travel/minix-386/estdio21.tar/estdio21/_z_cvt.c
Normal file
23
study/linux-travel/minix-386/estdio21.tar/estdio21/_z_cvt.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/* _ z _ c v t */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
/*ARGSUSED*/
|
||||
|
||||
int __cvt F6(__stdiosize_t *, length, FV *, fv,
|
||||
char *, buf, VA_LIST *, argp, int, precision, int, fflag)
|
||||
|
||||
{
|
||||
static char nfpm[] = { '(','N','o',' ',
|
||||
'F','l','o','a','t','i','n','g',' ',
|
||||
'P','o','i','n','t',')' };
|
||||
fv[0].att = FV_F_VECTOR;
|
||||
fv[0].len = 0;
|
||||
fv[1].att = FV_F_VECTOR;
|
||||
fv[1].len = sizeof(nfpm);
|
||||
fv[1].arg = nfpm;
|
||||
*length = sizeof(nfpm);
|
||||
|
||||
return 2;
|
||||
}
|
||||
12
study/linux-travel/minix-386/estdio21.tar/estdio21/_z_tvc.c
Normal file
12
study/linux-travel/minix-386/estdio21.tar/estdio21/_z_tvc.c
Normal file
@@ -0,0 +1,12 @@
|
||||
/* _ z _ t v c */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
/*ARGSUSED*/
|
||||
|
||||
int __tvc F5(FILE *, fp, int, width, VA_LIST *, argp, int, fptype, char *, ok)
|
||||
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/* _ z a t e x i t */
|
||||
|
||||
/* This file contains a pointer to the exit handler dispatch code.
|
||||
* It is initialise to NULL and set by atexit(). It is used by
|
||||
* exit() to call the exit handler code.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
void (*__Zatexit) F0(); /* exit handler pointer */
|
||||
/* bss cleared at startup */
|
||||
13
study/linux-travel/minix-386/estdio21.tar/estdio21/_zerr.c
Normal file
13
study/linux-travel/minix-386/estdio21.tar/estdio21/_zerr.c
Normal file
@@ -0,0 +1,13 @@
|
||||
/* _ z e r r */
|
||||
|
||||
/* This file contains a pointer to stderr. It is initialised to
|
||||
* NULL and set by _bwronly(). It is used by perror() to flush
|
||||
* stderr.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
FILE *__Zerr; /* stderr pointer */
|
||||
/* bss cleared at startup */
|
||||
13
study/linux-travel/minix-386/estdio21.tar/estdio21/_zout.c
Normal file
13
study/linux-travel/minix-386/estdio21.tar/estdio21/_zout.c
Normal file
@@ -0,0 +1,13 @@
|
||||
/* _ z o u t */
|
||||
|
||||
/* This file contains a pointer to stdout. It is initialised to
|
||||
* NULL and set by _bwronly(). It is used by _brd(), fread() and
|
||||
* _fgetlx() to flush stdout on reads.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
FILE *__Zout; /* stdout pointer */
|
||||
/* bss cleared at startup */
|
||||
13
study/linux-travel/minix-386/estdio21.tar/estdio21/_zrlbf.c
Normal file
13
study/linux-travel/minix-386/estdio21.tar/estdio21/_zrlbf.c
Normal file
@@ -0,0 +1,13 @@
|
||||
/* _ z r l b f */
|
||||
|
||||
/* This file contains a pointer to __rlbf(). It is initialised to
|
||||
* NULL and set by setvbuf(). It is used by _brd() to adjust line
|
||||
* buffered input streams.
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
__stdiosize_t (*__Zrlbf) P((FILE *, __stdiosize_t)); /* rlbf() pointer */
|
||||
/* bss cleared at startup */
|
||||
@@ -0,0 +1,13 @@
|
||||
/* _ z w r a p u p */
|
||||
|
||||
/* __wrapup points at the stdio wrap up function which is called from
|
||||
* exit(). This is initialised to NULL. When _bwr() is called, it
|
||||
* initialises __wrapup to point to __ioflush().
|
||||
*/
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
void (*__Zwrapup) F0(); /* clean up pointer */
|
||||
/* bss cleared at startup */
|
||||
33
study/linux-travel/minix-386/estdio21.tar/estdio21/atexit.c
Normal file
33
study/linux-travel/minix-386/estdio21.tar/estdio21/atexit.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/* a t e x i t */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#define MAX_HANDLERS 32 /* maximum number of handlers */
|
||||
|
||||
/* Exit handler list */
|
||||
static atexit_t __exithandlers[MAX_HANDLERS] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
/* Exit handler list pointer */
|
||||
static atexit_t *__exitpointer = &__exithandlers[0];
|
||||
|
||||
static void doexit F0()
|
||||
|
||||
{
|
||||
for ( ; __exitpointer > &__exithandlers[0]; )
|
||||
(*(*--__exitpointer))();
|
||||
}
|
||||
|
||||
int atexit F1(atexit_t, fn)
|
||||
|
||||
{
|
||||
__Zatexit = doexit;
|
||||
|
||||
return (__exitpointer < &__exithandlers[MAX_HANDLERS])
|
||||
? (*__exitpointer++ = fn, 0)
|
||||
: -1;
|
||||
}
|
||||
95
study/linux-travel/minix-386/estdio21.tar/estdio21/bitset.h
Normal file
95
study/linux-travel/minix-386/estdio21.tar/estdio21/bitset.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/* b i t s e t
|
||||
*
|
||||
* (C) Copyright C E Chew
|
||||
*
|
||||
* Feel free to copy, use and distribute this software provided:
|
||||
*
|
||||
* 1. you do not pretend that you wrote it
|
||||
* 2. you leave this copyright notice intact.
|
||||
*
|
||||
* This implements a set of operators to manipulate bitsets
|
||||
* is a machine independent way. It may be necessary for other
|
||||
* machines to set up the constants at the front (such as the
|
||||
* width of int, etc).
|
||||
*
|
||||
* To avoid double evaluation of the argument in some of the
|
||||
* macros, define the data structure as follows:
|
||||
*
|
||||
* 1. the bitset is int []
|
||||
* 2. the first int will be used as scratch int [0]
|
||||
* 3. all the following elements will be used for the bitset proper
|
||||
*
|
||||
* Patchlevel 2.0
|
||||
*
|
||||
* Edit History:
|
||||
*/
|
||||
|
||||
/* Declare the relative sizing of the components */
|
||||
|
||||
#define _BITELEMENT unsigned int
|
||||
#define _BITSINCHAR CHAR_BIT
|
||||
|
||||
/* Determine how many bits there are in an elemental bitset */
|
||||
|
||||
#define _BITS (sizeof(_BITELEMENT)*_BITSINCHAR)
|
||||
|
||||
/* Declare the relative offsets of the pieces in the structure */
|
||||
|
||||
#define _BIT_SCRATCH_ 0
|
||||
#define _BIT_SET_ 1
|
||||
|
||||
/* Define how to find a bit within a bitset */
|
||||
|
||||
#define _BITSIZE_(n) (((n)+_BITS-1)/_BITS)
|
||||
#define _BITGROUP_(n) ((n)/_BITS)
|
||||
#define _BITMASK_(n) (1<<((n)%_BITS))
|
||||
|
||||
/* Define how to find a bit within the data structure */
|
||||
|
||||
#define _BITSIZE(n) (_BITSIZE_(n)+_BIT_SET_)
|
||||
#define _BITGROUP(n) (_BITGROUP_(n)+_BIT_SET_)
|
||||
#define _BITMASK(n) (_BITMASK_(n))
|
||||
|
||||
/*
|
||||
* Declare a bitset of length n bits
|
||||
*/
|
||||
|
||||
#define bitstring(name, n) _BITELEMENT name[_BITSIZE(n)]
|
||||
|
||||
/*
|
||||
* Clear all elements of the bitset
|
||||
*/
|
||||
|
||||
#define bitempty(name, n) MEMSET((char *) &name[_BIT_SET_], 0, \
|
||||
(size_t) (_BITSIZE_(n)*sizeof(_BITELEMENT)))
|
||||
|
||||
/*
|
||||
* Set all elements of the bitset
|
||||
*/
|
||||
|
||||
#define bitfill(name, n) (_BITFILL(&name[_BIT_SET_], ~0, \
|
||||
_BITSIZE_(n)*sizeof(_BITELEMENT)))
|
||||
|
||||
/*
|
||||
* Set one bit in the bitset
|
||||
*/
|
||||
|
||||
#define bitset(name, n) (name[_BIT_SCRATCH_]=(n), \
|
||||
name[_BITGROUP(name[_BIT_SCRATCH_])] |= \
|
||||
_BITMASK(name[_BIT_SCRATCH_]))
|
||||
|
||||
/*
|
||||
* Clear one bit in the bitset
|
||||
*/
|
||||
|
||||
#define bitclear(name, n) (name[_BIT_SCRATCH_]=(n), \
|
||||
name[_BITGROUP(name[_BIT_SCRATCH_])] &= \
|
||||
~_BITMASK(name[_BIT_SCRATCH_]))
|
||||
|
||||
/*
|
||||
* Test one bit in the bitset
|
||||
*/
|
||||
|
||||
#define bittest(name, n) (name[_BIT_SCRATCH_]=(n), \
|
||||
name[_BITGROUP(name[_BIT_SCRATCH_])] & \
|
||||
_BITMASK(name[_BIT_SCRATCH_]))
|
||||
@@ -0,0 +1,14 @@
|
||||
/* c l e a r e r r */
|
||||
|
||||
#include "stdiolib.h"
|
||||
|
||||
#define MACRO_SHADOW
|
||||
#include "hidden.h"
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
void clearerr F1(FILE *, fp)
|
||||
|
||||
{
|
||||
CLEARFLAG(fp, (_IOEOF | _IOERR));
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user