johan@nlgvax.UUCP (Johan Stevenson) (11/28/88)
This message contains a shar wrapping of the following files:
$ crc *
27554 1900 Makefile.cdif
45926 830 fdopen.c
58025 617 fgetc.c
12884 721 fputc.c
21360 514 popen.cdif
This posting fixes the following problems:
- fdopen.c: added
- popen.c: reference to _exit() replaced by exit()
- fgetc.c replaces getc.c
- fputc.c replaces putc.c
- fgetc.c maintained _count incorrectly
- Makefile: fdopen.c added, getc/putc repaced by fgetc/fputc
The renaming of getc/putc is cosmetic, but the old situation proved
to confuse many people.
These four library modules are now identical to MINIX-PC 1.3c.
Go to an empty directory, feed the lines following the cut mark
to the shell, check the table above with the output of /usr/bin/crc
and install as follows:
$ cp * /usr/src/lib
$ cd /usr/src/lib
$ patch Makefile <Makefile.cdif
$ patch popen.c <popen.cdif
$ mv getc.c getc.c.orig
$ mv putc.c putc.c.orig
$ make libc.a
$ cp libc.a /usr/lib/libc.a
Note that I needed to 'chmem =50000 /usr/bin/make'. Good luck.
--
Johan W. Stevenson johan@pcg.philips.nl Philips Research
------------------------------------------------------------------------
: This is a shar archive. Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
echo 'Extracting Makefile.cdif'
sed 's/^X//' > Makefile.cdif << '+ END-OF-FILE Makefile.cdif'
X*** lib/Makefile.orig Thu Apr 28 16:03:40 1988
X--- lib/Makefile Sun Nov 27 15:05:09 1988
X***************
X*** 3,9 ****
X AS = cc -c -DATARI_ST -DACK
X
X CFLAGS = -O -I../include -DATARI_ST -DACK
X! O1 = gtty.o stty.o termcap.o \
X ctime.o popen.o puts.o qsort.o system.o \
X abort.o abs.o access.o atol.o chdir.o chmod.o \
X chown.o chroot.o cleanup.o crypt.o ctype.o dup.o dup2.o \
X--- 3,9 ----
X AS = cc -c -DATARI_ST -DACK
X
X CFLAGS = -O -I../include -DATARI_ST -DACK
X! O1 = gtty.o stty.o termcap.o fdopen.o \
X ctime.o popen.o puts.o qsort.o system.o \
X abort.o abs.o access.o atol.o chdir.o chmod.o \
X chown.o chroot.o cleanup.o crypt.o ctype.o dup.o dup2.o \
X***************
X*** 14,22 ****
X fstat.o itoa.o kill.o link.o lseek.o mknod.o \
X mktemp.o getpid.o mount.o open.o perror.o pipe.o printk.o
X O3 = prints.o rand.o regexp.o index.o regsub.o rindex.o scanf.o \
X! getc.o printdat.o read.o setbuf.o malloc.o bcopy.o brk.o \
X! setgid.o setuid.o sleep.o alarm.o pause.o signal.o stcatch.o \
X! sprintf.o doprintf.o putc.o stat.o stb.o stderr.o stime.o \
X strcat.o strcmp.o strcpy.o strlen.o strncat.o strncmp.o strncpy.o
X O4 = sync.o syslib.o time.o times.o umask.o umount.o ungetc.o \
X unlink.o utime.o wait.o write.o call.o message.o stbrksz.o \
X--- 14,22 ----
X fstat.o itoa.o kill.o link.o lseek.o mknod.o \
X mktemp.o getpid.o mount.o open.o perror.o pipe.o printk.o
X O3 = prints.o rand.o regexp.o index.o regsub.o rindex.o scanf.o \
X! fgetc.o printdat.o read.o setbuf.o malloc.o bcopy.o brk.o \
X! setgid.o setuid.o sleep.o alarm.o pause.o signal.o stcatch.o \
X! sprintf.o doprintf.o fputc.o stat.o stb.o stderr.o stime.o \
X strcat.o strcmp.o strcpy.o strlen.o strncat.o strncmp.o strncpy.o
X O4 = sync.o syslib.o time.o times.o umask.o umount.o ungetc.o \
X unlink.o utime.o wait.o write.o call.o message.o stbrksz.o \
+ END-OF-FILE Makefile.cdif
chmod 644 Makefile.cdif
echo 'CRC SENT: 27554 1900 Makefile.cdif'
echo -n 'CRC RCVD: '
crc Makefile.cdif
echo 'Extracting fdopen.c'
sed 's/^X//' > fdopen.c << '+ END-OF-FILE fdopen.c'
X/* fdopen - YAH (yet another hack) hacked from fopen.c */
X
X#include <stdio.h>
X
X#define PMODE 0644
X
X
XFILE *fdopen(fd,mode)
Xint fd;
Xchar *mode;
X{
X register int i;
X FILE *fp;
X char *malloc();
X int flags = 0;
X
X for (i = 0; _io_table[i] != 0 ; i++)
X if ( i >= NFILES )
X return(NULL);
X
X switch(*mode){
X
X case 'w':
X flags |= WRITEMODE;
X break;
X
X case 'a':
X flags |= WRITEMODE;
X lseek(fd,0L,2);
X break;
X
X case 'r':
X flags |= READMODE;
X break;
X
X default:
X return(NULL);
X }
X
X
X if (( fp = (FILE *) malloc (sizeof( FILE))) == NULL )
X return(NULL);
X
X
X fp->_count = 0;
X fp->_fd = fd;
X fp->_flags = flags;
X fp->_buf = malloc( BUFSIZ );
X if ( fp->_buf == NULL )
X fp->_flags |= UNBUFF;
X else
X fp->_flags |= IOMYBUF;
X
X fp->_ptr = fp->_buf;
X _io_table[i] = fp;
X return(fp);
X}
+ END-OF-FILE fdopen.c
chmod 644 fdopen.c
echo 'CRC SENT: 45926 830 fdopen.c'
echo -n 'CRC RCVD: '
crc fdopen.c
echo 'Extracting fgetc.c'
sed 's/^X//' > fgetc.c << '+ END-OF-FILE fgetc.c'
X#include <stdio.h>
X
X
X
Xfgetc(iop)
XFILE *iop;
X{
X int ch;
X
X if ( testflag(iop, (_EOF | _ERR )))
X return (EOF);
X
X if ( !testflag(iop, READMODE) )
X return (EOF);
X
X if (iop->_count <= 0){
X
X if ( testflag(iop, UNBUFF) )
X iop->_count = read(iop->_fd,&ch,1);
X else
X iop->_count = read(iop->_fd,iop->_buf,BUFSIZ);
X
X if (iop->_count <= 0){
X if (iop->_count == 0)
X iop->_flags |= _EOF;
X else
X iop->_flags |= _ERR;
X
X return (EOF);
X }
X else
X iop->_ptr = iop->_buf;
X }
X
X iop->_count--; /* account one char */
X if (testflag(iop,UNBUFF))
X return (ch & CMASK);
X else
X return (*iop->_ptr++ & CMASK);
X}
X
+ END-OF-FILE fgetc.c
chmod 644 fgetc.c
echo 'CRC SENT: 58025 617 fgetc.c'
echo -n 'CRC RCVD: '
crc fgetc.c
echo 'Extracting fputc.c'
sed 's/^X//' > fputc.c << '+ END-OF-FILE fputc.c'
X#include <stdio.h>
X
Xextern int (*__cleanup)();
Xextern int _cleanup();
X
Xfputc(ch, iop)
Xchar ch;
XFILE *iop;
X{
X int n,
X didwrite = 0;
X
X if (testflag(iop, (_ERR | _EOF)))
X return (EOF);
X
X if ( !testflag(iop,WRITEMODE))
X return(EOF);
X
X if ( testflag(iop,UNBUFF)){
X n = write(iop->_fd,&ch,1);
X iop->_count = 1;
X didwrite++;
X }
X else{
X __cleanup = _cleanup;
X *iop->_ptr++ = ch;
X if ((++iop->_count) >= BUFSIZ && !testflag(iop,STRINGS) ){
X n = write(iop->_fd,iop->_buf,iop->_count);
X iop->_ptr = iop->_buf;
X didwrite++;
X }
X }
X
X if (didwrite){
X if (n<=0 || iop->_count != n){
X if (n < 0)
X iop->_flags |= _ERR;
X else
X iop->_flags |= _EOF;
X return (EOF);
X }
X iop->_count=0;
X }
X return(ch & CMASK);
X}
X
+ END-OF-FILE fputc.c
chmod 644 fputc.c
echo 'CRC SENT: 12884 721 fputc.c'
echo -n 'CRC RCVD: '
crc fputc.c
echo 'Extracting popen.cdif'
sed 's/^X//' > popen.cdif << '+ END-OF-FILE popen.cdif'
X*** lib/popen.c.orig Sun Jan 3 20:55:19 1988
X--- lib/popen.c Wed Nov 23 21:51:09 1988
X***************
X*** 27,33 ****
X dup2(piped[!Xtype], !Xtype);
X close(piped[!Xtype]);
X execl("/bin/sh", "sh", "-c", command, (char *) 0);
X! _exit(127); /* like system() ??? */
X }
X
X pids[piped[Xtype]] = pid;
X--- 27,33 ----
X dup2(piped[!Xtype], !Xtype);
X close(piped[!Xtype]);
X execl("/bin/sh", "sh", "-c", command, (char *) 0);
X! exit(127); /* like system() ??? */
X }
X
X pids[piped[Xtype]] = pid;
+ END-OF-FILE popen.cdif
chmod 644 popen.cdif
echo 'CRC SENT: 21360 514 popen.cdif'
echo -n 'CRC RCVD: '
crc popen.cdif
exit 0