[comp.os.minix] Minix stdio patches - 3 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 3 (of 5)."
# Contents:  fwrite.c.cdif printf.c.cdif proto.h.cdif scanf.c.cdif
#   sprintf.c.cdif sscanf.c.cdif stdio.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 'fwrite.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fwrite.c.cdif'\"
else
echo shar: Extracting \"'fwrite.c.cdif'\" \(4960 characters\)
sed "s/^X//" >'fwrite.c.cdif' <<'END_OF_FILE'
X*** Old/fwrite.c	Mon Sep  4 11:03:50 1989
X--- New/fwrite.c	Mon Sep  4 22:57:40 1989
X***************
X*** 5,11
X   * Writing stops when the correct number of items have been written
X   * or when the function encounters an error.
X   *
X!  * Patchlevel 1.0
X   *
X   * Edit History:
X   * 04-Sep-1989	Add code to deal with really large objects.
X
X--- 5,11 -----
X   * Writing stops when the correct number of items have been written
X   * or when the function encounters an error.
X   *
X!  * Patchlevel 1.1
X   *
X   * Edit History:
X   * 05-Sep-1989	Include limits.h if INT_MAX undefined so removing
X***************
X*** 8,13
X   * Patchlevel 1.0
X   *
X   * Edit History:
X   * 04-Sep-1989	Add code to deal with really large objects.
X   * 03-Sep-1989	Write to buffer only if it requires at most one call
X   *		to write(), otherwise use write() directly.
X
X--- 8,16 -----
X   * Patchlevel 1.1
X   *
X   * Edit History:
X+  * 05-Sep-1989	Include limits.h if INT_MAX undefined so removing
X+  *		need to define MINIX when compiling. Assign void *
X+  *		to unsigned char * to avoid casting problems.
X   * 04-Sep-1989	Add code to deal with really large objects.
X   * 03-Sep-1989	Write to buffer only if it requires at most one call
X   *		to write(), otherwise use write() directly.
X***************
X*** 22,28
X  # define INT_MAX	(MAXINT)
X  #endif
X  
X! #if	defined(MINIX) || defined(MSDOS) || defined(__MSDOS__)
X  # include <limits.h>
X  #endif
X  
X
X--- 25,31 -----
X  # define INT_MAX	(MAXINT)
X  #endif
X  
X! #if	!defined(INT_MAX)
X  # include <limits.h>
X  #endif
X  
X***************
X*** 28,34
X  
X  /*LINTLIBRARY*/
X  
X! int fwrite(p, size, nitems, fp)
X  
X  void *p;				/* buffer */
X  unsigned int size;			/* size of item */
X
X--- 31,37 -----
X  
X  /*LINTLIBRARY*/
X  
X! int fwrite(ptr, size, nitems, fp)
X  
X  void *ptr;				/* buffer */
X  unsigned int size;			/* size of item */
X***************
X*** 30,36
X  
X  int fwrite(p, size, nitems, fp)
X  
X! void *p;				/* buffer */
X  unsigned int size;			/* size of item */
X  unsigned int nitems;			/* number of items */
X  FILE *fp;				/* stream */
X
X--- 33,39 -----
X  
X  int fwrite(ptr, size, nitems, fp)
X  
X! void *ptr;				/* buffer */
X  unsigned int size;			/* size of item */
X  unsigned int nitems;			/* number of items */
X  FILE *fp;				/* stream */
X***************
X*** 38,43
X  {
X    int wrote;				/* bytes written in write call */
X    int write();				/* write call */
X  
X  /* Phase 1 --- Amount to write overflows INT_MAX */
X    unsigned int burstsize;		/* size aligned chunk to write */
X
X--- 41,47 -----
X  {
X    int wrote;				/* bytes written in write call */
X    int write();				/* write call */
X+   unsigned char *p;			/* buffer pointer */
X  
X  /* Phase 1 --- Amount to write overflows INT_MAX */
X    unsigned int burstsize;		/* size aligned chunk to write */
X***************
X*** 54,59
X    if ((itemsleft = nitems) == 0 || size == 0)
X      return 0;
X  
X  /* Very large objects */
X    if ((itemsperburst = INT_MAX / size) == 0) {
X      (void) fflush(fp);
X
X--- 58,66 -----
X    if ((itemsleft = nitems) == 0 || size == 0)
X      return 0;
X  
X+ /* Fix void * casting problems */
X+   p = (unsigned char *) ptr;
X+ 
X  /* Very large objects */
X    if ((itemsperburst = INT_MAX / size) == 0) {
X      (void) fflush(fp);
X***************
X*** 65,71
X  	if ((wrote = write(fileno(fp), (char *) p, (int) burstsize)) !=
X  	    burstsize)
X  	  return (nitems-itemsleft);
X! 	p = (void *) ((unsigned char *) p + burstsize);
X        } while ((bytesleft -= burstsize) != 0);
X      } while (--itemsleft);
X      return nitems;
X
X--- 72,78 -----
X  	if ((wrote = write(fileno(fp), (char *) p, (int) burstsize)) !=
X  	    burstsize)
X  	  return (nitems-itemsleft);
X! 	p += burstsize;
X        } while ((bytesleft -= burstsize) != 0);
X      } while (--itemsleft);
X      return nitems;
X***************
X*** 80,86
X  	wrote = 0;
X        return (nitems-itemsleft) + (wrote/size);
X      }
X!     p = (void *) ((unsigned char *) p + burstsize);
X      itemsleft -= itemsperburst;
X    }
X  
X
X--- 87,93 -----
X  	wrote = 0;
X        return (nitems-itemsleft) + (wrote/size);
X      }
X!     p += burstsize;
X      itemsleft -= itemsperburst;
X    }
X  
X***************
X*** 95,101
X      if (! HASBUFFER(fp)) {
X        if (_allocbuf(fp) < 0)
X  	return (nitems-itemsleft);
X!       SETCLEANUP();
X      }
X  
X  /* Partially filled write buffer */
X
X--- 102,108 -----
X      if (! HASBUFFER(fp)) {
X        if (_allocbuf(fp) < 0)
X  	return (nitems-itemsleft);
X!       SETIOFLUSH();
X      }
X  
X  /* Partially filled write buffer */
X***************
X*** 106,112
X  	  copybytes = bytesleft;
X  	wrote = copybytes;
X  	q = GETWRITEPTR(fp);
X! 	UNROLL_DO(fwritebytes, copybytes, (*q++ = *((unsigned char *) p)++));
X  	SETWRITEPTR(fp, q);
X  	if (bytesleft > wrote && fflush(fp) == EOF)
X  	  break;
X
X--- 113,119 -----
X  	  copybytes = bytesleft;
X  	wrote = copybytes;
X  	q = GETWRITEPTR(fp);
X! 	UNROLL_DO(fwritebytes, copybytes, *q++ = *p++);
X  	SETWRITEPTR(fp, q);
X  	if (bytesleft > wrote && fflush(fp) == EOF)
X  	  break;
END_OF_FILE
if test 4960 -ne `wc -c <'fwrite.c.cdif'`; then
    echo shar: \"'fwrite.c.cdif'\" unpacked with wrong size!
fi
# end of 'fwrite.c.cdif'
fi
if test -f 'printf.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'printf.c.cdif'\"
else
echo shar: Extracting \"'printf.c.cdif'\" \(282 characters\)
sed "s/^X//" >'printf.c.cdif' <<'END_OF_FILE'
X*** Old/printf.c	Sun Sep  3 13:57:30 1989
X--- New/printf.c	Tue Sep  5 15:44:43 1989
X***************
X*** 12,17
X  
X  /*LINTLIBRARY*/
X  /*VARARGS1*/
X  
X  int printf(fmt, va_alist)
X  
X
X--- 12,18 -----
X  
X  /*LINTLIBRARY*/
X  /*VARARGS1*/
X+ /*ARGSUSED*/
X  
X  int printf(fmt, va_alist)
X  
END_OF_FILE
if test 282 -ne `wc -c <'printf.c.cdif'`; then
    echo shar: \"'printf.c.cdif'\" unpacked with wrong size!
fi
# end of 'printf.c.cdif'
fi
if test -f 'proto.h.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'proto.h.cdif'\"
else
echo shar: Extracting \"'proto.h.cdif'\" \(538 characters\)
sed "s/^X//" >'proto.h.cdif' <<'END_OF_FILE'
X*** Old/proto.h	Sun Sep  3 13:59:24 1989
X--- /dev/null	Tue Sep  5 16:22:51 1989
X***************
X*** 1,19
X- /*
X-  *			ANSI Prototyping
X-  *
X-  * This file declares macros that are useful for conditionally
X-  * providing ANSI function prototypes.
X-  */
X- 
X- #ifndef	__PROTOTYPE_H__
X- #  define	__PROTOTYPE_H__
X- #  ifdef	__STDC__
X- #    define Prototype(x)	x
X- #    define Type(x,y)		x
X- #    define Declare(x)
X- #  else
X- #    define Prototype(x)	()
X- #    define Type(x,y)		y
X- #    define Declare(x)		x;
X- #  endif
X- #endif
X
X--- 0 -----
END_OF_FILE
if test 538 -ne `wc -c <'proto.h.cdif'`; then
    echo shar: \"'proto.h.cdif'\" unpacked with wrong size!
fi
# end of 'proto.h.cdif'
fi
if test -f 'scanf.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'scanf.c.cdif'\"
else
echo shar: Extracting \"'scanf.c.cdif'\" \(278 characters\)
sed "s/^X//" >'scanf.c.cdif' <<'END_OF_FILE'
X*** Old/scanf.c	Sun Sep  3 13:57:52 1989
X--- New/scanf.c	Tue Sep  5 15:44:53 1989
X***************
X*** 12,17
X  
X  /*LINTLIBRARY*/
X  /*VARARGS1*/
X  
X  int scanf(fmt, va_alist)
X  
X
X--- 12,18 -----
X  
X  /*LINTLIBRARY*/
X  /*VARARGS1*/
X+ /*ARGSUSED*/
X  
X  int scanf(fmt, va_alist)
X  
END_OF_FILE
if test 278 -ne `wc -c <'scanf.c.cdif'`; then
    echo shar: \"'scanf.c.cdif'\" unpacked with wrong size!
fi
# end of 'scanf.c.cdif'
fi
if test -f 'sprintf.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sprintf.c.cdif'\"
else
echo shar: Extracting \"'sprintf.c.cdif'\" \(296 characters\)
sed "s/^X//" >'sprintf.c.cdif' <<'END_OF_FILE'
X*** Old/sprintf.c	Sun Sep  3 13:58:10 1989
X--- New/sprintf.c	Tue Sep  5 15:45:07 1989
X***************
X*** 14,19
X  
X  /*LINTLIBRARY*/
X  /*VARARGS2*/
X  
X  int sprintf(buf, fmt, va_alist)
X  
X
X--- 14,20 -----
X  
X  /*LINTLIBRARY*/
X  /*VARARGS2*/
X+ /*ARGSUSED*/
X  
X  int sprintf(buf, fmt, va_alist)
X  
END_OF_FILE
if test 296 -ne `wc -c <'sprintf.c.cdif'`; then
    echo shar: \"'sprintf.c.cdif'\" unpacked with wrong size!
fi
# end of 'sprintf.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'\" \(292 characters\)
sed "s/^X//" >'sscanf.c.cdif' <<'END_OF_FILE'
X*** Old/sscanf.c	Sun Sep  3 13:58:16 1989
X--- New/sscanf.c	Tue Sep  5 15:45:14 1989
X***************
X*** 12,17
X  
X  /*LINTLIBRARY*/
X  /*VARARGS2*/
X  
X  int sscanf(buf, fmt, va_alist)
X  
X
X--- 12,18 -----
X  
X  /*LINTLIBRARY*/
X  /*VARARGS2*/
X+ /*ARSGUSED*/
X  
X  int sscanf(buf, fmt, va_alist)
X  
END_OF_FILE
if test 292 -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.c.cdif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'stdio.c.cdif'\"
else
echo shar: Extracting \"'stdio.c.cdif'\" \(1587 characters\)
sed "s/^X//" >'stdio.c.cdif' <<'END_OF_FILE'
X*** Old/stdio.c	Mon Sep  4 08:56:40 1989
X--- New/stdio.c	Tue Sep  5 16:39:17 1989
X***************
X*** 33,41
X   *	clearerr
X   *
X   * This file contains basic data structure declarations for the stdio
X!  * package. Runtime cleanup is done by _cleanup. This is inserted into
X!  * exit by _flsbuf since cleanup is only required if streams are
X!  * written to.
X   *
X   * Patchlevel 1.0
X   *
X
X--- 33,39 -----
X   *	clearerr
X   *
X   * This file contains basic data structure declarations for the stdio
X!  * package. Runtime cleanup is done by _ioflush.
X   *
X   * Patchlevel 1.1
X   *
X***************
X*** 37,43
X   * exit by _flsbuf since cleanup is only required if streams are
X   * written to.
X   *
X!  * Patchlevel 1.0
X   *
X   * Edit History:
X   */
X
X--- 35,41 -----
X   * This file contains basic data structure declarations for the stdio
X   * package. Runtime cleanup is done by _ioflush.
X   *
X!  * Patchlevel 1.1
X   *
X   * Edit History:
X   * 05-Sep-1989	Add _wrapstdio for cleaner system interface via
X***************
X*** 40,45
X   * Patchlevel 1.0
X   *
X   * Edit History:
X   */
X  
X  #if	defined(MSDOS)
X
X--- 38,45 -----
X   * Patchlevel 1.1
X   *
X   * Edit History:
X+  * 05-Sep-1989	Add _wrapstdio for cleaner system interface via
X+  *		atexit().
X   */
X  
X  #if	defined(MSDOS)
X***************
X*** 55,59
X  struct _iobuf *_iop[_NFILE] = {&_stdin, &_stdout, &_stderr};
X  
X  #if	defined(MSDOS)
X  extern int _fmode = O_BINARY;
X  #endif
X
X--- 55,60 -----
X  struct _iobuf *_iop[_NFILE] = {&_stdin, &_stdout, &_stderr};
X  
X  #if	defined(MSDOS)
X+ int _wrapstdio = 1;
X  extern int _fmode = O_BINARY;
X  #endif
END_OF_FILE
if test 1587 -ne `wc -c <'stdio.c.cdif'`; then
    echo shar: \"'stdio.c.cdif'\" unpacked with wrong size!
fi
# end of 'stdio.c.cdif'
fi
echo shar: End of archive 3 \(of 5\).
cp /dev/null ark3isdone
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