cechew@bruce.OZ (Earl Chew) (09/06/89)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 2)." # Contents: Makefile.dos Makefile.unx _fakfls.c.cdif _flsbuf.c.cdif # atexit.c.cdif exercise.c.cdif exit.c.cdif sscanf.c.cdif # stdio.h.cdif stdiolib.h.cdif # Wrapped by cechew@bruce on Wed Sep 6 11:22:41 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile.dos' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile.dos'\" else echo shar: Extracting \"'Makefile.dos'\" \(2201 characters\) sed "s/^X//" >'Makefile.dos' <<'END_OF_FILE' X# NdMakefile for TurboC X# XSTDIO= stdio.lib XEXIT= exit.lib XLIBOBJ= _allocbu.obj _filbuf.obj _file.obj _flsbuf.obj \ X _fopen.obj _slot.obj atexit.obj fclose.obj \ X fdopen.obj fflush.obj fgetc.obj fgets.obj \ X fopen.obj fprintf.obj fputc.obj fputs.obj \ X fread.obj freopen.obj fscanf.obj fseek.obj \ X ftell.obj fwrite.obj gets.obj getw.obj \ X printf.obj puts.obj putw.obj rewind.obj \ X scanf.obj setbuf.obj setvbuf.obj sprintf.obj \ X sscanf.obj stdio.obj ungetc.obj vfprintf.obj \ X vfscanf.obj vprintf.obj vscanf.obj vsprintf.obj \ X vsscanf.obj XEXOBJ= exit.obj _fakfls.obj X# X.SUFFIXES: .obj .c X.c.obj: X tcc -c $< X# Xexercise.out: exercise.obj $(STDIO) $(EXIT) X link /st:4096/m/noi/f \minix\lib\tc\sepi&d+\minix\lib\tc\c0+exercise.obj,exercise,,$(STDIO)+$(EXIT)+\minix\lib\mxtc+\tc\lib\cs X /minix/tools/dos2out -d exercise.exe X /minix/tools/chmem =64000 exercise.out X# Xall: exercise.out tputc.out tprintf.out tfwrite.out texit.out Xtiming: tputc.out tprintf.out tfwrite.out texit.out X# Xtexit.out: texit.obj $(STDIO) $(EXIT) X link /st:4096/m/noi/f \minix\lib\tc\sepi&d+\minix\lib\tc\c0+texit.obj,texit,,$(STDIO)+$(EXIT)+\minix\lib\mxtc+\tc\lib\cs X /minix/tools/dos2out -d texit.exe X /minix/tools/chmem =64000 texit.out X# Xtputc.out: tputc.obj $(STDIO) $(EXIT) X link /st:4096/m/noi/f \minix\lib\tc\sepi&d+\minix\lib\tc\c0+tputc.obj,tputc,,$(STDIO)+$(EXIT)+\minix\lib\mxtc+\tc\lib\cs X /minix/tools/dos2out -d tputc.exe X /minix/tools/chmem =64000 tputc.out X# Xtprintf.out: tprintf.obj $(STDIO) $(EXIT) X link /st:4096/m/noi/f \minix\lib\tc\sepi&d+\minix\lib\tc\c0+tprintf.obj,tprintf,,$(STDIO)+$(EXIT)+\minix\lib\mxtc+\tc\lib\cs X /minix/tools/dos2out -d tprintf.exe X /minix/tools/chmem =64000 tprintf.out X# Xtfwrite.out: tfwrite.obj $(STDIO) $(EXIT) X link /st:4096/m/noi/f \minix\lib\tc\sepi&d+\minix\lib\tc\c0+tfwrite.obj,tfwrite,,$(STDIO)+$(EXIT)+\minix\lib\mxtc+\tc\lib\cs X /minix/tools/dos2out -d tfwrite.exe X /minix/tools/chmem =64000 tfwrite.out X# X$(EXIT): $(EXOBJ) X rm -f $(EXIT) X lib $(EXIT) + $(EXOBJ) ; X# X$(STDIO): $(LIBOBJ) X rm -f $(STDIO) X lib $(STDIO) + $(LIBOBJ) ; Xexercise.obj: stdio.h Xtexit.obj: Xtfwrite.obj: stdio.h Xtprintf.obj: stdio.h Xtputc.obj: stdio.h X$(EXOBJ) $(LIBOBJ): stdiolib.h stdio.h END_OF_FILE if test 2201 -ne `wc -c <'Makefile.dos'`; then echo shar: \"'Makefile.dos'\" unpacked with wrong size! fi # end of 'Makefile.dos' fi if test -f 'Makefile.unx' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile.unx'\" else echo shar: Extracting \"'Makefile.unx'\" \(1199 characters\) sed "s/^X//" >'Makefile.unx' <<'END_OF_FILE' X# Makefile for BSD X# XCFLAGS= -I. -I/usr/include -DBSD X# XSTDIO= stdio.a XLIBOBJ= _allocbu.o _filbuf.o _file.o _flsbuf.o \ X _fopen.o _slot.o atexit.o fclose.o \ X fdopen.o fflush.o fgetc.o fgets.o \ X fopen.o fprintf.o fputc.o fputs.o \ X fread.o freopen.o fscanf.o fseek.o \ X ftell.o fwrite.o gets.o getw.o \ X printf.o puts.o putw.o rewind.o \ X scanf.o setbuf.o setvbuf.o sprintf.o \ X sscanf.o stdio.o ungetc.o vfprintf.o \ X vfscanf.o vprintf.o vscanf.o vsprintf.o \ X vsscanf.o XEXIT= exit.o _fakfls.o X# Xexercise: exercise.o $(STDIO) X cc -o exercise exercise.o $(STDIO) X# Xall: exercise tputc tprintf tfwrite texit Xtiming: tputc tprintf tfwrite texit X# Xtexit: texit.o $(STDIO) X cc -o texit texit.o $(STDIO) X# Xtputc: tputc.o $(STDIO) X cc -o tputc tputc.o $(STDIO) X# Xtprintf: tprintf.o $(STDIO) X cc -o tprintf tprintf.o $(STDIO) X# Xtfwrite: tfwrite.o $(STDIO) X cc -o tfwrite tfwrite.o $(STDIO) X# X$(STDIO): $(LIBOBJ) $(EXIT) X /bin/rm -f $(STDIO) X ar cr $(STDIO) `lorder $(LIBOBJ) | tsort` $(EXIT) X# Xexercise.o: stdio.h Xtexit.o: Xtfwrite.o: stdio.h Xtprintf.o: stdio.h Xtputc.o: stdio.h X$(LIBOBJ) $(EXIT): stdiolib.h stdio.h X# Xlint: X lint -n -I. -I/usr/include -DBSD `echo $(LIBOBJ) $(EXIT) | sed 's/\.o/.c/g'` END_OF_FILE if test 1199 -ne `wc -c <'Makefile.unx'`; then echo shar: \"'Makefile.unx'\" unpacked with wrong size! fi # end of 'Makefile.unx' fi if test -f '_fakfls.c.cdif' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'_fakfls.c.cdif'\" else echo shar: Extracting \"'_fakfls.c.cdif'\" \(1227 characters\) sed "s/^X//" >'_fakfls.c.cdif' <<'END_OF_FILE' X*** Old/_fakfls.c Tue Sep 5 16:12:58 1989 X--- New/_fakfls.c Wed Sep 6 09:12:12 1989 X*************** X*** 1,7 X /* _ f a k f l s X * X! * Fake _ioflush() for exit() so that stdio won't be hauled into X! * programs that don't need it. X * X * Patchlevel 1.0 X * X X--- 1,7 ----- X /* _ f a k f l s X * X! * Fake _ioflush() for exit() so that stdio won't be hauled in X! * for programs that don't need it. X * X * Patchlevel 1.1 X * X*************** X*** 3,9 X * Fake _ioflush() for exit() so that stdio won't be hauled into X * programs that don't need it. X * X! * Patchlevel 1.0 X * X * Edit History: X * 05-Sep-1989 Created. X X--- 3,9 ----- X * Fake _ioflush() for exit() so that stdio won't be hauled in X * for programs that don't need it. X * X! * Patchlevel 1.1 X * X * Edit History: X * 06-Sep-1989 Add _ioexit() so that the exit handler dispatch X*************** X*** 6,11 X * Patchlevel 1.0 X * X * Edit History: X * 05-Sep-1989 Created. X */ X X X--- 6,14 ----- X * Patchlevel 1.1 X * X * Edit History: X+ * 06-Sep-1989 Add _ioexit() so that the exit handler dispatch X+ * table can be initialised properly. Took it out X+ * again when exit.c was changed. X * 05-Sep-1989 Created. X */ X END_OF_FILE if test 1227 -ne `wc -c <'_fakfls.c.cdif'`; then echo shar: \"'_fakfls.c.cdif'\" unpacked with wrong size! fi # end of '_fakfls.c.cdif' fi if test -f '_flsbuf.c.cdif' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'_flsbuf.c.cdif'\" else echo shar: Extracting \"'_flsbuf.c.cdif'\" \(1173 characters\) sed "s/^X//" >'_flsbuf.c.cdif' <<'END_OF_FILE' X*** Old/_flsbuf.c Tue Sep 5 16:12:41 1989 X--- New/_flsbuf.c Wed Sep 6 10:47:23 1989 X*************** X*** 19,25 X * The function returns the character that was written to the X * file, otherwise EOF on error. X * X! * Patchlevel 1.1 X * X * Edit History: X * 05-Sep-1989 Change SETCLEANUP to SETIOFLUSH. Add _ioflush() X X--- 19,25 ----- X * The function returns the character that was written to the X * file, otherwise EOF on error. X * X! * Patchlevel 1.2 X * X * Edit History: X * 06-Sep-1989 Declare c as unsigned char in _flsbuf(). X*************** X*** 22,27 X * Patchlevel 1.1 X * X * Edit History: X * 05-Sep-1989 Change SETCLEANUP to SETIOFLUSH. Add _ioflush() X * and _ioexit(). X */ X X--- 22,28 ----- X * Patchlevel 1.2 X * X * Edit History: X+ * 06-Sep-1989 Declare c as unsigned char in _flsbuf(). X * 05-Sep-1989 Change SETCLEANUP to SETIOFLUSH. Add _ioflush() X * and _ioexit(). X */ X*************** X*** 47,53 X X int _flsbuf(c, fp) X X! char c; /* character to write */ X FILE *fp; /* stream */ X X { X X--- 48,54 ----- X X int _flsbuf(c, fp) X X! unsigned char c; /* character to write */ X FILE *fp; /* stream */ X X { END_OF_FILE if test 1173 -ne `wc -c <'_flsbuf.c.cdif'`; then echo shar: \"'_flsbuf.c.cdif'\" unpacked with wrong size! fi # end of '_flsbuf.c.cdif' fi if test -f 'atexit.c.cdif' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'atexit.c.cdif'\" else echo shar: Extracting \"'atexit.c.cdif'\" \(968 characters\) sed "s/^X//" >'atexit.c.cdif' <<'END_OF_FILE' X*** Old/atexit.c Tue Sep 5 13:56:49 1989 X--- New/atexit.c Wed Sep 6 10:49:51 1989 X*************** X*** 6,12 X * order. The routine returns zero on failure (list overflow) and X * non-zero on success. X * X! * Patchlevel 1.0 X * X * Edit History: X * 05-Sep-1989 Created. X X--- 6,12 ----- X * order. The routine returns zero on failure (list overflow) and X * non-zero on success. X * X! * Patchlevel 1.1 X * X * Edit History: X * 06-Sep-1989 Added lint control. X*************** X*** 9,14 X * Patchlevel 1.0 X * X * Edit History: X * 05-Sep-1989 Created. X */ X X X--- 9,15 ----- X * Patchlevel 1.1 X * X * Edit History: X+ * 06-Sep-1989 Added lint control. X * 05-Sep-1989 Created. X */ X X*************** X*** 13,18 X */ X X #include "stdiolib.h" X X extern void (**_exit_hp)(); /* exit handler pointer */ X X X--- 14,21 ----- X */ X X #include "stdiolib.h" X+ X+ /*LINTLIBRARY*/ X X extern void (**_exit_hp)(); /* exit handler pointer */ X END_OF_FILE if test 968 -ne `wc -c <'atexit.c.cdif'`; then echo shar: \"'atexit.c.cdif'\" unpacked with wrong size! fi # end of 'atexit.c.cdif' fi if test -f 'exercise.c.cdif' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'exercise.c.cdif'\" else echo shar: Extracting \"'exercise.c.cdif'\" \(672 characters\) sed "s/^X//" >'exercise.c.cdif' <<'END_OF_FILE' X*** Old/exercise.c Tue Sep 5 14:39:45 1989 X--- New/exercise.c Tue Sep 5 22:56:32 1989 X*************** X*** 25,30 X #endif X X extern void sleep(); /* sleep routine */ X X FILE *fp; /* per test file pointer */ X X X--- 25,31 ----- X #endif X X extern void sleep(); /* sleep routine */ X+ extern void exit(); /* exit */ X X FILE *fp; /* per test file pointer */ X X*************** X*** 655,661 X puts("\nExit Test"); X if (atexit(handler) == 0) { X puts("Exit handler not lodged"); X! exit(1); X } X } X X X--- 656,662 ----- X puts("\nExit Test"); X if (atexit(handler) == 0) { X puts("Exit handler not lodged"); X! return; X } X } X END_OF_FILE if test 672 -ne `wc -c <'exercise.c.cdif'`; then echo shar: \"'exercise.c.cdif'\" unpacked with wrong size! fi # end of 'exercise.c.cdif' fi if test -f 'exit.c.cdif' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'exit.c.cdif'\" else echo shar: Extracting \"'exit.c.cdif'\" \(2440 characters\) sed "s/^X//" >'exit.c.cdif' <<'END_OF_FILE' X*** Old/exit.c Tue Sep 5 15:37:23 1989 X--- New/exit.c Wed Sep 6 10:50:24 1989 X*************** X*** 5,11 X * Finally the stdio exit handler, _ioflush(), is called, followed by an X * _exit(). X * X! * Patchlevel 1.0 X * X * Edit History: X * 05-Sep-1989 Created. X X--- 5,11 ----- X * Finally the stdio exit handler, _ioflush(), is called, followed by an X * _exit(). X * X! * Patchlevel 1.1 X * X * Edit History: X * 06-Sep-1989 Corrected prototypes. Correct exit handler table X*************** X*** 8,13 X * Patchlevel 1.0 X * X * Edit History: X * 05-Sep-1989 Created. X */ X X X--- 8,15 ----- X * Patchlevel 1.1 X * X * Edit History: X+ * 06-Sep-1989 Corrected prototypes. Correct exit handler table X+ * initialisation. Lint control. X * 05-Sep-1989 Created. X */ X X*************** X*** 13,18 X X #include "stdiolib.h" X X #define MAX_HANDLERS 15 /* maximum number of handlers */ X X void exit P(()); /* exit coming up */ X X--- 15,22 ----- X X #include "stdiolib.h" X X+ /*LINTLIBRARY*/ X+ X #define MAX_HANDLERS 15 /* maximum number of handlers */ X X void exit P((int)); /* exit coming up */ X*************** X*** 15,21 X X #define MAX_HANDLERS 15 /* maximum number of handlers */ X X! void exit P(()); /* exit coming up */ X X /* Exit handler list */ X static void (*_exit_list[MAX_HANDLERS+1]) P((void)) = {exit}; X X--- 19,25 ----- X X #define MAX_HANDLERS 15 /* maximum number of handlers */ X X! void exit P((int)); /* exit coming up */ X X /* Exit handler list */ X static void (*_exit_list[MAX_HANDLERS+1]) P((void)) = {_ioflush}; X*************** X*** 18,24 X void exit P(()); /* exit coming up */ X X /* Exit handler list */ X! static void (*_exit_list[MAX_HANDLERS+1]) P((void)) = {exit}; X X /* Exit handler list pointer */ X void (**_exit_hp) P(()) = &_exit_list[MAX_HANDLERS]; X X--- 22,28 ----- X void exit P((int)); /* exit coming up */ X X /* Exit handler list */ X! static void (*_exit_list[MAX_HANDLERS+1]) P((void)) = {_ioflush}; X X /* Exit handler list pointer */ X void (**_exit_hp) P(()) = &_exit_list[MAX_HANDLERS]; X*************** X*** 28,34 X int status; /* exit status */ X X { X! void _exit P((void)); /* exit */ X X for ( ; _exit_hp < &_exit_list[MAX_HANDLERS]; ) X (*++_exit_hp)(); X X--- 32,38 ----- X int status; /* exit status */ X X { X! void _exit P((int)); /* exit */ X X for ( ; _exit_hp < &_exit_list[MAX_HANDLERS]; ) X (*++_exit_hp)(); END_OF_FILE if test 2440 -ne `wc -c <'exit.c.cdif'`; then echo shar: \"'exit.c.cdif'\" unpacked with wrong size! fi # end of 'exit.c.cdif' fi if test -f 'sscanf.c.cdif' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sscanf.c.cdif'\" else echo shar: Extracting \"'sscanf.c.cdif'\" \(307 characters\) sed "s/^X//" >'sscanf.c.cdif' <<'END_OF_FILE' X*** Old/sscanf.c Tue Sep 5 15:45:14 1989 X--- New/sscanf.c Wed Sep 6 10:37:57 1989 X*************** X*** 12,18 X X /*LINTLIBRARY*/ X /*VARARGS2*/ X! /*ARSGUSED*/ X X int sscanf(buf, fmt, va_alist) X X X--- 12,18 ----- X X /*LINTLIBRARY*/ X /*VARARGS2*/ X! /*ARGSUSED*/ X X int sscanf(buf, fmt, va_alist) X END_OF_FILE if test 307 -ne `wc -c <'sscanf.c.cdif'`; then echo shar: \"'sscanf.c.cdif'\" unpacked with wrong size! fi # end of 'sscanf.c.cdif' fi if test -f 'stdio.h.cdif' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdio.h.cdif'\" else echo shar: Extracting \"'stdio.h.cdif'\" \(1509 characters\) sed "s/^X//" >'stdio.h.cdif' <<'END_OF_FILE' X*** Old/stdio.h Tue Sep 5 16:38:35 1989 X--- New/stdio.h Wed Sep 6 10:48:36 1989 X*************** X*** 12,18 X * X * Definitions and user interface for the stream io package. X * X! * Patchlevel 1.1 X * X * Edit History: X * 05-Sep-1989 Make self reliant by removing dependency on proto.h X X--- 12,18 ----- X * X * Definitions and user interface for the stream io package. X * X! * Patchlevel 1.2 X * X * Edit History: X * 06-Sep-1989 Cast (x) to (unsigned char) in call to _flsbuf(). X*************** X*** 15,20 X * Patchlevel 1.1 X * X * Edit History: X * 05-Sep-1989 Make self reliant by removing dependency on proto.h X * and varargs.h. X * 04-Sep-1989 Undo change to putc() since it makes it so much X X--- 15,21 ----- X * Patchlevel 1.2 X * X * Edit History: X+ * 06-Sep-1989 Cast (x) to (unsigned char) in call to _flsbuf(). X * 05-Sep-1989 Make self reliant by removing dependency on proto.h X * and varargs.h. X * 04-Sep-1989 Undo change to putc() since it makes it so much X*************** X*** 80,86 X X #define putc(x,p) ((p)->_ptr<(p)->_end\ X ?(int)(*(p)->_ptr++=(unsigned char)(x))\ X! :_flsbuf((x),(p))) X #define putchar(x) putc(x,stdout) X X #define fileno(p) ((p)->_file) X X--- 81,87 ----- X X #define putc(x,p) ((p)->_ptr<(p)->_end\ X ?(int)(*(p)->_ptr++=(unsigned char)(x))\ X! :_flsbuf((unsigned char)(x),(p))) X #define putchar(x) putc(x,stdout) X X #define fileno(p) ((p)->_file) END_OF_FILE if test 1509 -ne `wc -c <'stdio.h.cdif'`; then echo shar: \"'stdio.h.cdif'\" unpacked with wrong size! fi # end of 'stdio.h.cdif' fi if test -f 'stdiolib.h.cdif' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdiolib.h.cdif'\" else echo shar: Extracting \"'stdiolib.h.cdif'\" \(1967 characters\) sed "s/^X//" >'stdiolib.h.cdif' <<'END_OF_FILE' X*** Old/stdiolib.h Tue Sep 5 16:39:01 1989 X--- New/stdiolib.h Wed Sep 6 10:54:44 1989 X*************** X*** 11,17 X * useful macro definitions that make the code a bit easier to X * write. X * X! * Patchlevel 1.1 X * X * Edit History: X * 05-Sep-1989 Remove dependency on MINIX define. Define P() instead X X--- 11,17 ----- X * useful macro definitions that make the code a bit easier to X * write. X * X! * Patchlevel 1.2 X * X * Edit History: X * 06-Sep-1989 Cast first argument of _flsbuf(). X*************** X*** 14,19 X * Patchlevel 1.1 X * X * Edit History: X * 05-Sep-1989 Remove dependency on MINIX define. Define P() instead X * of Prototype() (apparently less distracting). Use X * atexit() instead of __cleanup for better portability. X X--- 14,20 ----- X * Patchlevel 1.2 X * X * Edit History: X+ * 06-Sep-1989 Cast first argument of _flsbuf(). X * 05-Sep-1989 Remove dependency on MINIX define. Define P() instead X * of Prototype() (apparently less distracting). Use X * atexit() instead of __cleanup for better portability. X*************** X*** 73,79 X * This version of putc is explicitly for unbuffered streams. A X * call is made directly to the buffer flushing code. X */ X! #define NPUTC(x,p) ( _flsbuf((x),(p)) ) X X /* Putc without line buffering X * X X--- 74,80 ----- X * This version of putc is explicitly for unbuffered streams. A X * call is made directly to the buffer flushing code. X */ X! #define NPUTC(x,p) ( _flsbuf((unsigned char)(x),(p)) ) X X /* Putc without line buffering X * X*************** X*** 83,89 X #define PUTC(x,p) ( \ X (p)->_ptr < (p)->_base + (p)->_bufsiz \ X ? (int) (*(p)->_ptr++ = (unsigned char)(x)) \ X! : _flsbuf((x),(p)) \ X ) X X /* Initialise an output buffer X X--- 84,90 ----- X #define PUTC(x,p) ( \ X (p)->_ptr < (p)->_base + (p)->_bufsiz \ X ? (int) (*(p)->_ptr++ = (unsigned char)(x)) \ X! : _flsbuf((unsigned char)(x),(p)) \ X ) X X /* Initialise an output buffer END_OF_FILE if test 1967 -ne `wc -c <'stdiolib.h.cdif'`; then echo shar: \"'stdiolib.h.cdif'\" unpacked with wrong size! fi # end of 'stdiolib.h.cdif' fi echo shar: End of archive 1 \(of 2\). cp /dev/null ark1isdone MISSING="" for I in 1 2 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked both archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0