[comp.os.minix] Minix stdio patches - 4 of 5

cechew@bruce.OZ (Earl Chew) (09/05/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 4 (of 5)."
# Contents:  stdio.h.cdif stdiolib.h.cdif texit.c.cdif
# Wrapped by cechew@bruce on Tue Sep  5 16:55:08 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
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'\" \(8955 characters\)
sed "s/^X//" >'stdio.h.cdif' <<'END_OF_FILE'
X*** Old/stdio.h	Mon Sep  4 10:51:05 1989
X--- New/stdio.h	Tue Sep  5 16:38:35 1989
X***************
X*** 3,8
X   *		Author: C. E. Chew
X   *		Date:   August 1989
X   *
X   * Definitions and user interface for the stream io package.
X   *
X   * Edit History:
X
X--- 3,15 -----
X   *		Author: C. E. Chew
X   *		Date:   August 1989
X   *
X+  * (C) Copyright C E Chew
X+  *
X+  * Feel free to copy, use and distribute this software provided:
X+  *
X+  *	1. you do not pretend that you wrote it
X+  *	2. you leave this copyright notice intact.
X+  *
X   * Definitions and user interface for the stream io package.
X   *
X   * Patchlevel 1.1
X***************
X*** 5,10
X   *
X   * Definitions and user interface for the stream io package.
X   *
X   * Edit History:
X   * 04-Sep-1989	Undo change to putc() since it makes it so much
X   *		more complicated and makes so little difference
X
X--- 12,19 -----
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   *		and varargs.h.
X***************
X*** 6,11
X   * Definitions and user interface for the stream io package.
X   *
X   * Edit History:
X   * 04-Sep-1989	Undo change to putc() since it makes it so much
X   *		more complicated and makes so little difference
X   *		to the speed.
X
X--- 15,22 -----
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   *		more complicated and makes so little difference
X   *		to the speed.
X***************
X*** 17,24
X   *		many moons ago.
X   */
X  
X! #include <proto.h>
X! #include <varargs.h>
X  
X  #define BUFSIZ 1024
X  #define _NFILE 20
X
X--- 28,34 -----
X   *		many moons ago.
X   */
X  
X! #if	!defined(__STDIO__)
X  
X  #define __STDIO__
X  
X***************
X*** 20,25
X  #include <proto.h>
X  #include <varargs.h>
X  
X  #define BUFSIZ 1024
X  #define _NFILE 20
X  
X
X--- 30,43 -----
X  
X  #if	!defined(__STDIO__)
X  
X+ #define __STDIO__
X+ 
X+ #if	defined(__STDC__)
X+ # define	__STDIO_P__(x)	x
X+ #else
X+ # define	__STDIO_P__(x)	()
X+ #endif
X+ 
X  #define BUFSIZ 1024
X  #define _NFILE 20
X  
X***************
X*** 56,62
X  #define stdout		(_iop[1])
X  #define stderr		(_iop[2])
X  
X! #define getc(p)		((p)->_ptr<(p)->_end?*(p)->_ptr++\
X  					    :_filbuf(p))
X  #define getchar()	getc(stdin)
X  
X
X--- 74,80 -----
X  #define stdout		(_iop[1])
X  #define stderr		(_iop[2])
X  
X! #define getc(p)		((p)->_ptr<(p)->_end?(int)(*(p)->_ptr++)\
X  					    :_filbuf(p))
X  #define getchar()	getc(stdin)
X  
X***************
X*** 60,67
X  					    :_filbuf(p))
X  #define getchar()	getc(stdin)
X  
X! #define putc(x,p)	((p)->_ptr<(p)->_end?*(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--- 78,86 -----
X  					    :_filbuf(p))
X  #define getchar()	getc(stdin)
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*** 70,77
X  #define ferror(p)	(((p)->_flag&_IOERR)!=0)
X  #define clearerr(p)	((p)->_flag&=~(_IOEOF|_IOERR))
X  
X! int	_filbuf		Prototype((FILE *));
X! int	_flsbuf		Prototype((int, FILE *));
X  
X  FILE 	*fopen		Prototype((char *, char *));
X  FILE	*fdopen		Prototype((int, char *));
X
X--- 89,96 -----
X  #define ferror(p)	(((p)->_flag&_IOERR)!=0)
X  #define clearerr(p)	((p)->_flag&=~(_IOEOF|_IOERR))
X  
X! int	_filbuf		__STDIO_P__((FILE *));
X! int	_flsbuf		__STDIO_P__((int, FILE *));
X  
X  FILE 	*fopen		__STDIO_P__((char *, char *));
X  FILE	*fdopen		__STDIO_P__((int, char *));
X***************
X*** 73,83
X  int	_filbuf		Prototype((FILE *));
X  int	_flsbuf		Prototype((int, FILE *));
X  
X! FILE 	*fopen		Prototype((char *, char *));
X! FILE	*fdopen		Prototype((int, char *));
X! FILE	*freopen	Prototype((char *, char *, FILE *));
X! int	fflush		Prototype((FILE *));
X! int	fclose		Prototype((FILE *));
X  
X  long	ftell		Prototype((FILE *));
X  int	fseek		Prototype((FILE *, long, int));
X
X--- 92,102 -----
X  int	_filbuf		__STDIO_P__((FILE *));
X  int	_flsbuf		__STDIO_P__((int, FILE *));
X  
X! FILE 	*fopen		__STDIO_P__((char *, char *));
X! FILE	*fdopen		__STDIO_P__((int, char *));
X! FILE	*freopen	__STDIO_P__((char *, char *, FILE *));
X! int	fflush		__STDIO_P__((FILE *));
X! int	fclose		__STDIO_P__((FILE *));
X  
X  long	ftell		__STDIO_P__((FILE *));
X  int	fseek		__STDIO_P__((FILE *, long, int));
X***************
X*** 79,87
X  int	fflush		Prototype((FILE *));
X  int	fclose		Prototype((FILE *));
X  
X! long	ftell		Prototype((FILE *));
X! int	fseek		Prototype((FILE *, long, int));
X! void	rewind		Prototype((FILE *));
X  
X  int	fgetc		Prototype((FILE *));
X  int	fputc		Prototype((int, FILE *));
X
X--- 98,106 -----
X  int	fflush		__STDIO_P__((FILE *));
X  int	fclose		__STDIO_P__((FILE *));
X  
X! long	ftell		__STDIO_P__((FILE *));
X! int	fseek		__STDIO_P__((FILE *, long, int));
X! void	rewind		__STDIO_P__((FILE *));
X  
X  int	fgetc		__STDIO_P__((FILE *));
X  int	fputc		__STDIO_P__((int, FILE *));
X***************
X*** 83,98
X  int	fseek		Prototype((FILE *, long, int));
X  void	rewind		Prototype((FILE *));
X  
X! int	fgetc		Prototype((FILE *));
X! int	fputc		Prototype((int, FILE *));
X! int	fread		Prototype((void *, unsigned int, unsigned int, FILE *));
X! int	fwrite		Prototype((void *, unsigned int, unsigned int, FILE *));
X! int	getw		Prototype((FILE *));
X! int	putw		Prototype((int, FILE *));
X! char	*gets		Prototype((char *));
X! char	*fgets		Prototype((char *, int, FILE *));
X! int	puts		Prototype((char *));
X! int	fputs		Prototype((char *, FILE *));
X  
X  int	ungetc		Prototype((int, FILE *));
X  
X
X--- 102,119 -----
X  int	fseek		__STDIO_P__((FILE *, long, int));
X  void	rewind		__STDIO_P__((FILE *));
X  
X! int	fgetc		__STDIO_P__((FILE *));
X! int	fputc		__STDIO_P__((int, FILE *));
X! int	fread		__STDIO_P__((void *, unsigned int,
X!                                      unsigned int, FILE *));
X! int	fwrite		__STDIO_P__((void *, unsigned int,
X!                                      unsigned int, FILE *));
X! int	getw		__STDIO_P__((FILE *));
X! int	putw		__STDIO_P__((int, FILE *));
X! char	*gets		__STDIO_P__((char *));
X! char	*fgets		__STDIO_P__((char *, int, FILE *));
X! int	puts		__STDIO_P__((char *));
X! int	fputs		__STDIO_P__((char *, FILE *));
X  
X  int	ungetc		__STDIO_P__((int, FILE *));
X  
X***************
X*** 94,100
X  int	puts		Prototype((char *));
X  int	fputs		Prototype((char *, FILE *));
X  
X! int	ungetc		Prototype((int, FILE *));
X  
X  int	printf		Prototype((char *, ...));
X  int	fprintf		Prototype((FILE *, char *, ...));
X
X--- 115,121 -----
X  int	puts		__STDIO_P__((char *));
X  int	fputs		__STDIO_P__((char *, FILE *));
X  
X! int	ungetc		__STDIO_P__((int, FILE *));
X  
X  int	printf		__STDIO_P__((char *, ...));
X  int	fprintf		__STDIO_P__((FILE *, char *, ...));
X***************
X*** 96,113
X  
X  int	ungetc		Prototype((int, FILE *));
X  
X! int	printf		Prototype((char *, ...));
X! int	fprintf		Prototype((FILE *, char *, ...));
X! int	sprintf		Prototype((char *, char *, ...));
X! int	vprintf		Prototype((char *, va_list));
X! int	vfprintf	Prototype((FILE *, char *, va_list));
X! int	vsprintf	Prototype((char *, char *, va_list));
X! int	scanf		Prototype((char *, ...));
X! int	fscanf		Prototype((FILE *, char *, ...));
X! int	sscanf		Prototype((char *, char *, ...));
X! int	vscanf		Prototype((char *, va_list));
X! int	vfscanf		Prototype((FILE *, char *, va_list));
X! int	vsscanf		Prototype((char *, char *, va_list));
X  
X  void	setbuf		Prototype((FILE *, char *));
X  int	setvbuf		Prototype((FILE *, char *, int, unsigned int));
X
X--- 117,134 -----
X  
X  int	ungetc		__STDIO_P__((int, FILE *));
X  
X! int	printf		__STDIO_P__((char *, ...));
X! int	fprintf		__STDIO_P__((FILE *, char *, ...));
X! int	sprintf		__STDIO_P__((char *, char *, ...));
X! int	vprintf		__STDIO_P__((char *, char *));
X! int	vfprintf	__STDIO_P__((FILE *, char *, char *));
X! int	vsprintf	__STDIO_P__((char *, char *, char *));
X! int	scanf		__STDIO_P__((char *, ...));
X! int	fscanf		__STDIO_P__((FILE *, char *, ...));
X! int	sscanf		__STDIO_P__((char *, char *, ...));
X! int	vscanf		__STDIO_P__((char *, char *));
X! int	vfscanf		__STDIO_P__((FILE *, char *, char *));
X! int	vsscanf		__STDIO_P__((char *, char *, char *));
X  
X  void	setbuf		__STDIO_P__((FILE *, char *));
X  int	setvbuf		__STDIO_P__((FILE *, char *, int, unsigned int));
X***************
X*** 109,113
X  int	vfscanf		Prototype((FILE *, char *, va_list));
X  int	vsscanf		Prototype((char *, char *, va_list));
X  
X! void	setbuf		Prototype((FILE *, char *));
X! int	setvbuf		Prototype((FILE *, char *, int, unsigned int));
X
X--- 130,135 -----
X  int	vfscanf		__STDIO_P__((FILE *, char *, char *));
X  int	vsscanf		__STDIO_P__((char *, char *, char *));
X  
X! void	setbuf		__STDIO_P__((FILE *, char *));
X! int	setvbuf		__STDIO_P__((FILE *, char *, int, unsigned int));
X! #endif
END_OF_FILE
if test 8955 -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'\" \(6525 characters\)
sed "s/^X//" >'stdiolib.h.cdif' <<'END_OF_FILE'
X*** Old/stdiolib.h	Mon Sep  4 09:02:08 1989
X--- New/stdiolib.h	Tue Sep  5 16:39:01 1989
X***************
X*** 1,5
X  /*			s t d i o l i b
X   *
X   * This include file is used by the stdio code. It provides some
X   * useful macro definitions that make the code a bit easier to
X   * write.
X
X--- 1,12 -----
X  /*			s t d i o l i b
X   *
X+  * (C) Copyright C E Chew
X+  *
X+  * Feel free to copy, use and distribute this software provided:
X+  *
X+  *	1. you do not pretend that you wrote it
X+  *	2. you leave this copyright notice intact.
X+  *
X   * This include file is used by the stdio code. It provides some
X   * useful macro definitions that make the code a bit easier to
X   * write.
X***************
X*** 4,10
X   * useful macro definitions that make the code a bit easier to
X   * write.
X   *
X!  * Edit History:
X   *
X   * 03-Sep-1989	Added BUFFERSIZE() and altered UNUSEDINBUFFER() to
X   *		accommodate line buffered streams. Added PUTC()
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*** 6,11
X   *
X   * Edit History:
X   *
X   * 03-Sep-1989	Added BUFFERSIZE() and altered UNUSEDINBUFFER() to
X   *		accommodate line buffered streams. Added PUTC()
X   *		and NPUTC() for non line buffered streams.
X
X--- 13,25 -----
X   *
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+  *		For ld type loaders, we can use a loader trick
X+  *		and not use an explicit call to atexit thus SETIOFLUSH
X+  *		can be empty (almost).
X   * 03-Sep-1989	Added BUFFERSIZE() and altered UNUSEDINBUFFER() to
X   *		accommodate line buffered streams. Added PUTC()
X   *		and NPUTC() for non line buffered streams.
X***************
X*** 12,17
X   */
X  
X  #include <stdio.h>
X  
X  #ifdef	MINIX
X  extern void (*__cleanup) Prototype(());	/* pointer to cleanup function */
X
X--- 26,33 -----
X   */
X  
X  #include <stdio.h>
X+ #include <varargs.h>
X+ #include <errno.h>
X  
X  #if	defined(__STDC__)
X  # define	P(x)	x
X***************
X*** 13,20
X  
X  #include <stdio.h>
X  
X! #ifdef	MINIX
X! extern void (*__cleanup) Prototype(());	/* pointer to cleanup function */
X  #endif
X  
X  void _cleanup	Prototype(());		/* cleanup function */
X
X--- 29,38 -----
X  #include <varargs.h>
X  #include <errno.h>
X  
X! #if	defined(__STDC__)
X! # define	P(x)	x
X! #else
X! # define	P(x)	()
X  #endif
X  
X  void _ioflush	P((void));		/* flush output */
X***************
X*** 17,27
X  extern void (*__cleanup) Prototype(());	/* pointer to cleanup function */
X  #endif
X  
X! void _cleanup	Prototype(());		/* cleanup function */
X! int _allocbuf	Prototype((FILE *));	/* internal buffering */
X! int _fopen	Prototype((char *, char *, int, short *)); /* fopen assist */
X! FILE **_slot	Prototype((FILE *));	/* find a slot */
X! FILE *_file	Prototype((FILE *, int, short)); /* initialise FILE */
X  
X  /* Flag manipulation macros */
X  
X
X--- 35,46 -----
X  # define	P(x)	()
X  #endif
X  
X! void _ioflush	P((void));		/* flush output */
X! void _ioexit	P((void));		/* exit linking function */
X! int _allocbuf	P((FILE *));		/* internal buffering */
X! int _fopen	P((char *, char *, int, short *)); /* fopen assist */
X! FILE **_slot	P((FILE *));		/* find a slot */
X! FILE *_file	P((FILE *, int, short)); /* initialise FILE */
X  
X  int atexit	P((void (*)(void)));	/* specify wrapup */
X  
X***************
X*** 23,28
X  FILE **_slot	Prototype((FILE *));	/* find a slot */
X  FILE *_file	Prototype((FILE *, int, short)); /* initialise FILE */
X  
X  /* Flag manipulation macros */
X  
X  #define TESTFLAG(f,x)	(((f)->_flag & (x)) != 0)
X
X--- 42,52 -----
X  FILE **_slot	P((FILE *));		/* find a slot */
X  FILE *_file	P((FILE *, int, short)); /* initialise FILE */
X  
X+ int atexit	P((void (*)(void)));	/* specify wrapup */
X+ 
X+ extern int _wrapstdio;			/* stdio wrap required */
X+ extern int errno;			/* system error number */
X+ 
X  /* Flag manipulation macros */
X  
X  #define TESTFLAG(f,x)	(((f)->_flag & (x)) != 0)
X***************
X*** 31,37
X  #define GETFLAG(f,x)	((f)->_flag & (x))
X  #define TOGGLEFLAG(f,x)	((f)->_flag ^= (x))
X  
X! /* Add _cleanup to exit code
X   *
X   * Check is _cleanup needs to be added to the exit code. If so then
X   * add it. This macro is run time system dependent.
X
X--- 55,61 -----
X  #define GETFLAG(f,x)	((f)->_flag & (x))
X  #define TOGGLEFLAG(f,x)	((f)->_flag ^= (x))
X  
X! /* Add _ioflush to exit code
X   *
X   * Check is _ioflush needs to be added to the exit code. If so then
X   * add it. This macro is run time system dependent.
X***************
X*** 33,39
X  
X  /* Add _cleanup to exit code
X   *
X!  * Check is _cleanup needs to be added to the exit code. If so then
X   * add it. This macro is run time system dependent.
X   */
X  #if	defined(MINIX)
X
X--- 57,63 -----
X  
X  /* Add _ioflush to exit code
X   *
X!  * Check is _ioflush needs to be added to the exit code. If so then
X   * add it. This macro is run time system dependent.
X   */
X  #if	defined(MSDOS)
X***************
X*** 36,43
X   * Check is _cleanup needs to be added to the exit code. If so then
X   * add it. This macro is run time system dependent.
X   */
X! #if	defined(MINIX)
X! # define SETCLEANUP() { if (__cleanup == NULL) __cleanup = _cleanup; }
X  #endif
X  #if	!defined(SETCLEANUP)
X  # define SETCLEANUP()
X
X--- 60,67 -----
X   * Check is _ioflush needs to be added to the exit code. If so then
X   * add it. This macro is run time system dependent.
X   */
X! #if	defined(MSDOS)
X! # define SETIOFLUSH() { if (_wrapstdio != 0) _wrapstdio = atexit(_ioflush); }
X  #endif
X  
X  #if	!defined(SETIOFLUSH)
X***************
X*** 39,46
X  #if	defined(MINIX)
X  # define SETCLEANUP() { if (__cleanup == NULL) __cleanup = _cleanup; }
X  #endif
X! #if	!defined(SETCLEANUP)
X! # define SETCLEANUP()
X  #endif
X  
X  /* Putc for non buffered streams
X
X--- 63,71 -----
X  #if	defined(MSDOS)
X  # define SETIOFLUSH() { if (_wrapstdio != 0) _wrapstdio = atexit(_ioflush); }
X  #endif
X! 
X! #if	!defined(SETIOFLUSH)
X! # define SETIOFLUSH() _ioexit()
X  #endif
X  
X  /* Putc for non buffered streams
X***************
X*** 57,63
X   */
X  #define PUTC(x,p) ( \
X    (p)->_ptr < (p)->_base + (p)->_bufsiz \
X!   ? *(p)->_ptr++ = (unsigned char)(x) \
X    : _flsbuf((x),(p)) \
X  )
X   
X
X--- 82,88 -----
X   */
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   
END_OF_FILE
if test 6525 -ne `wc -c <'stdiolib.h.cdif'`; then
    echo shar: \"'stdiolib.h.cdif'\" unpacked with wrong size!
fi
# end of 'stdiolib.h.cdif'
fi
if test -f 'texit.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'texit.c.cdif'\"
else
echo shar: Extracting \"'texit.c.cdif'\" \(137 characters\)
sed "s/^X//" >'texit.c.cdif' <<'END_OF_FILE'
X*** /dev/null	Tue Sep  5 16:22:51 1989
X--- New/texit.c	Tue Sep  5 14:48:13 1989
X***************
X*** 0
X
X--- 1,4 -----
X+ main()
X+ 
X+ {
X+ }
END_OF_FILE
if test 137 -ne `wc -c <'texit.c.cdif'`; then
    echo shar: \"'texit.c.cdif'\" unpacked with wrong size!
fi
# end of 'texit.c.cdif'
fi
echo shar: End of archive 4 \(of 5\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 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