ast@cs.vu.nl (Andy Tanenbaum) (09/28/88)
: This is a shar archive. Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
: --------------------------- cut here --------------------------
PATH=/bin:/usr/bin:/usr/ucb
echo Extracting 'LISTING'
sed 's/^X//' > 'LISTING' << '+ END-OF-FILE ''LISTING'
Xtotal 46
X-rw-r--r-- 1 ast 495 Sep 26 22:23 bcmp.c.new
X-rw-r--r-- 1 ast 998 Sep 26 22:24 bsearch.c.new
X-rw-r--r-- 1 ast 329 Sep 26 22:24 bzero.c.new
X-rw-r--r-- 1 ast 619 Sep 26 22:24 ctermid.c.new
X-rw-r--r-- 1 ast 3297 Sep 26 22:24 ctime.c.cdif
X-rw-r--r-- 1 ast 553 Sep 26 22:24 cuserid.c.new
X-rw-r--r-- 1 ast 915 Sep 26 22:24 doprintf.c.cdif
X-rw-r--r-- 1 ast 1858 Sep 26 22:24 execlp.c.new
X-rw-r--r-- 1 ast 224 Sep 26 22:24 ffs.c.new
X-rw-r--r-- 1 ast 617 Sep 26 22:24 fgetc.c.new
X-rw-r--r-- 1 ast 313 Sep 26 22:24 fopen.c.cdif
X-rw-r--r-- 1 ast 721 Sep 26 22:24 fputc.c.new
X-rw-r--r-- 1 ast 2784 Sep 26 22:24 getcwd.c.new
X-rw-r--r-- 1 ast 1133 Sep 26 22:24 getenv.c.cdif
X-rw-r--r-- 1 ast 391 Sep 26 22:24 getgrent.c.cdif
X-rw-r--r-- 1 ast 429 Sep 26 22:24 getlogin.c.new
X-rw-r--r-- 1 ast 980 Sep 26 22:24 getpass.c.cdif
X-rw-r--r-- 1 ast 811 Sep 26 22:24 lsearch.c.new
X-rw-r--r-- 1 ast 296 Sep 26 22:24 memccpy.c.new
X-rw-r--r-- 1 ast 280 Sep 26 22:24 memchr.c.new
X-rw-r--r-- 1 ast 331 Sep 26 22:24 memcmp.c.new
X-rw-r--r-- 1 ast 691 Sep 26 22:24 memcpy.c.new
X-rw-r--r-- 1 ast 260 Sep 26 22:24 memset.c.new
X-rw-r--r-- 1 ast 1845 Sep 26 22:24 scanf.c.cdif
X-rw-r--r-- 1 ast 276 Sep 26 22:25 strchr.c.new
X-rw-r--r-- 1 ast 698 Sep 26 22:25 strcspn.c.new
X-rw-r--r-- 1 ast 670 Sep 26 22:25 strpbrk.c.new
X-rw-r--r-- 1 ast 301 Sep 26 22:25 strrchr.c.new
X-rw-r--r-- 1 ast 705 Sep 26 22:25 strspn.c.new
X-rw-r--r-- 1 ast 856 Sep 26 22:25 strstr.c.new
X-rw-r--r-- 1 ast 1663 Sep 26 22:25 strtok.c.new
X-rw-r--r-- 1 ast 278 Sep 26 22:25 swab.c.new
X-rw-r--r-- 1 ast 2104 Sep 26 22:25 termcap.c.cdif
X-rw-r--r-- 1 ast 1367 Sep 26 22:25 ttyname.c.new
+ END-OF-FILE LISTING
chmod 'u=rw,g=r,o=r' 'LISTING'
set `wc -c 'LISTING'`
count=$1
case $count in
1993) :;;
*) echo 'Bad character count in ''LISTING' >&2
echo 'Count should be 1993' >&2
esac
echo Extracting 'bcmp.c.new'
sed 's/^X//' > 'bcmp.c.new' << '+ END-OF-FILE ''bcmp.c.new'
X/* bcmp(3)
X *
X * Author: Terrence W. Holm Sep. 1988
X */
X
X
Xint bcmp( vector1, vector2, count )
X char *vector1;
X char *vector2;
X int count;
X
X {
X int word_count = count / sizeof(int);
X int byte_count = count & ( sizeof(int) - 1 );
X
X if ( vector1 == vector2 )
X return( 0 );
X
X while( --word_count >= 0 )
X if ( *((int *) vector1)++ != *((int *) vector2)++ )
X return( 1 );
X
X while( --byte_count >= 0 )
X if ( *vector1++ != *vector2++ )
X return( 1 );
X
X return( 0 );
X }
+ END-OF-FILE bcmp.c.new
chmod 'u=rw,g=r,o=r' 'bcmp.c.new'
set `wc -c 'bcmp.c.new'`
count=$1
case $count in
495) :;;
*) echo 'Bad character count in ''bcmp.c.new' >&2
echo 'Count should be 495' >&2
esac
echo Extracting 'bsearch.c.new'
sed 's/^X//' > 'bsearch.c.new' << '+ END-OF-FILE ''bsearch.c.new'
X/* bsearch(3)
X *
X * Author: Terrence Holm Aug. 1988
X *
X *
X * Performs a binary search for a given <key> within a sorted
X * table. The table contains <count> entries of size <width>
X * and starts at <base>.
X *
X * Entries are compared using keycmp( key, entry ), each argument
X * is a (char *), the function returns an int < 0, = 0 or > 0
X * according to the order of the two arguments.
X *
X * Bsearch(3) returns a pointer to the matching entry, if found,
X * otherwise NULL is returned.
X */
X
X#define NULL (char *) 0
X
X
Xchar *bsearch( key, base, count, width, keycmp )
X char *key;
X char *base;
X unsigned int count;
X unsigned int width;
X int (*keycmp)();
X
X {
X char *mid_point;
X int cmp;
X
X while ( count > 0 )
X {
X mid_point = base + width * (count >> 1);
X
X cmp = keycmp( key, mid_point );
X
X if ( cmp == 0 )
X return( mid_point );
X
X if ( cmp < 0 )
X count >>= 1;
X else
X {
X base = mid_point + width;
X count = (count - 1) >> 1;
X }
X }
X
X return( NULL );
X }
+ END-OF-FILE bsearch.c.new
chmod 'u=rw,g=r,o=r' 'bsearch.c.new'
set `wc -c 'bsearch.c.new'`
count=$1
case $count in
998) :;;
*) echo 'Bad character count in ''bsearch.c.new' >&2
echo 'Count should be 998' >&2
esac
echo Extracting 'bzero.c.new'
sed 's/^X//' > 'bzero.c.new' << '+ END-OF-FILE ''bzero.c.new'
X/* bzero(3)
X *
X * Author: Terrence W. Holm Sep. 1988
X */
X
X
Xbzero( vector, count )
X char *vector;
X int count;
X
X {
X int word_count = count / sizeof(int);
X int byte_count = count & ( sizeof(int) - 1 );
X
X while( --word_count >= 0 )
X *((int *) vector)++ = 0;
X
X while( --byte_count >= 0 )
X *vector++ = 0;
X }
+ END-OF-FILE bzero.c.new
chmod 'u=rw,g=r,o=r' 'bzero.c.new'
set `wc -c 'bzero.c.new'`
count=$1
case $count in
329) :;;
*) echo 'Bad character count in ''bzero.c.new' >&2
echo 'Count should be 329' >&2
esac
echo Extracting 'ctermid.c.new'
sed 's/^X//' > 'ctermid.c.new' << '+ END-OF-FILE ''ctermid.c.new'
X/* ctermid(3)
X *
X * Author: Terrence Holm Aug. 1988
X *
X *
X * Ctermid(3) returns a pointer to a string naming the controlling
X * terminal. If <name_space> is NULL then local static storage
X * is used, otherwise <name_space> must point to storage of at
X * least L_ctermid characters.
X *
X * Returns a pointer to "/dev/tty".
X */
X
X#include <stdio.h>
X
X#ifndef L_ctermid
X#define L_ctermid 9
X#endif
X
X
Xchar *ctermid( name_space )
X char *name_space;
X
X {
X static char termid[ L_ctermid ];
X
X if ( name_space == NULL )
X name_space = termid;
X
X strcpy( name_space, "/dev/tty" );
X
X return( name_space );
X }
+ END-OF-FILE ctermid.c.new
chmod 'u=rw,g=r,o=r' 'ctermid.c.new'
set `wc -c 'ctermid.c.new'`
count=$1
case $count in
619) :;;
*) echo 'Bad character count in ''ctermid.c.new' >&2
echo 'Count should be 619' >&2
esac
echo Extracting 'ctime.c.cdif'
sed 's/^X//' > 'ctime.c.cdif' << '+ END-OF-FILE ''ctime.c.cdif'
X*** /local/ast/minix/tape3b/lib/ctime.c Wed Jul 13 11:55:43 1988
X--- ctime.c Mon Sep 26 13:04:55 1988
X***************
X*** 8,27 ****
X "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
X };
X static char *days[] = {
X! "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
X };
X
X- /* To compute which date falls on which day of the week, we need to know the
X- * day of the week corresponding to Jan 1 of each year 1970 - 1999. The table
X- * newyear[] gives this, with 0 = Mon, 1 = Tue, 2 = Wed, ..., 6 = Sun. After
X- * Jan 1, 2000 this program will screw up. It probably won't be the only one.
X- */
X- static int newyear[] = {
X- 3, 4, 5, 0, 1, 2, 3, 5, 6, 0, /* 1970 - 1979 */
X- 1, 3, 4, 5, 6, 1, 2, 3, 4, 6, /* 1980 - 1989 */
X- 0, 1, 2, 4, 5, 6, 0, 2, 3, 4 /* 1990 - 1999 */
X- };
X-
X #define MIN 60L /* # seconds in a minute */
X #define HOUR (60 * MIN) /* # seconds in an hour */
X #define DAY (24 * HOUR) /* # seconds in a day */
X--- 8,16 ----
X "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
X };
X static char *days[] = {
X! "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
X };
X
X #define MIN 60L /* # seconds in a minute */
X #define HOUR (60 * MIN) /* # seconds in an hour */
X #define DAY (24 * HOUR) /* # seconds in a day */
X***************
X*** 35,40 ****
X--- 24,31 ----
X {
X register long t = *pt;
X
X+ long year;
X+
X tm.tm_year = 0;
X tm.tm_mon = 0;
X tm.tm_mday = 1;
X***************
X*** 43,63 ****
X tm.tm_sec = 0;
X
X /* t is elapsed time in seconds since Jan 1, 1970. */
X! while (t >= YEAR) { /* how many years can we subtract from t? */
X! if ((tm.tm_year % 4) == 2)
X! {
X! if ( t < YEAR + DAY )
X! break;
X! t -= DAY;
X! }
X tm.tm_year += 1;
X! t -= YEAR;
X }
X tm.tm_year += 1970;
X
X /* t is now the offset into the current year, in seconds. */
X! tm.tm_yday = (t/DAY); /* day # of the year, Jan 1 = 0 */
X! tm.tm_wday = ((newyear[tm.tm_year - 1970] + tm.tm_yday - 1) % 7) + 1;
X
X days_per_month[1] = 28;
X if ((tm.tm_year % 4) == 0) /* check for leap year */
X--- 34,48 ----
X tm.tm_sec = 0;
X
X /* t is elapsed time in seconds since Jan 1, 1970. */
X! tm.tm_wday = (int) (t/DAY + 4L) % 7; /* Jan 1, 1970 is 4th wday */
X! while (t >= (year=((tm.tm_year%4)==2) ? YEAR+DAY : YEAR)) {
X tm.tm_year += 1;
X! t -= year;
X }
X tm.tm_year += 1970;
X
X /* t is now the offset into the current year, in seconds. */
X! tm.tm_yday = (t/DAY); /* day # of the year, Jan 1 = 0 */
X
X days_per_month[1] = 28;
X if ((tm.tm_year % 4) == 0) /* check for leap year */
X***************
X*** 66,72 ****
X /* Compute month. */
X while (t >= (days_per_month[tm.tm_mon] * DAY))
X t -= days_per_month[tm.tm_mon++] * DAY;
X- tm.tm_mon++; /* Jan is month 1, not month 0 */
X
X /* Month established, now compute day of the month */
X while (t >= DAY) {
X--- 51,56 ----
X***************
X*** 91,97 ****
X
X /* Generate output in ASCII in buf. */
X sprintf(buf, "%s %s %2d %02d:%02d:%02d %d\n",
X! days[tm.tm_wday - 1], months[tm.tm_mon-1],
X tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_year);
X return buf;
X }
X--- 75,81 ----
X
X /* Generate output in ASCII in buf. */
X sprintf(buf, "%s %s %2d %02d:%02d:%02d %d\n",
X! days[tm.tm_wday], months[tm.tm_mon],
X tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_year);
X return buf;
X }
+ END-OF-FILE ctime.c.cdif
chmod 'u=rw,g=r,o=r' 'ctime.c.cdif'
set `wc -c 'ctime.c.cdif'`
count=$1
case $count in
3297) :;;
*) echo 'Bad character count in ''ctime.c.cdif' >&2
echo 'Count should be 3297' >&2
esac
echo Extracting 'cuserid.c.new'
sed 's/^X//' > 'cuserid.c.new' << '+ END-OF-FILE ''cuserid.c.new'
X/* cuserid(3)
X *
X * Author: Terrence W. Holm Sept. 1987
X */
X
X#include <stdio.h>
X#include <pwd.h>
X
X#ifndef L_cuserid
X#define L_cuserid 9
X#endif
X
Xextern struct passwd *getpwuid();
X
X
Xchar *cuserid( user_name )
X char *user_name;
X
X {
X static char userid[ L_cuserid ];
X struct passwd *pw_entry;
X
X if ( user_name == NULL )
X user_name = userid;
X
X pw_entry = getpwuid( geteuid() );
X
X if ( pw_entry == NULL )
X {
X *user_name = '\0';
X return( NULL );
X }
X
X strcpy( user_name, pw_entry->pw_name );
X
X return( user_name );
X }
+ END-OF-FILE cuserid.c.new
chmod 'u=rw,g=r,o=r' 'cuserid.c.new'
set `wc -c 'cuserid.c.new'`
count=$1
case $count in
553) :;;
*) echo 'Bad character count in ''cuserid.c.new' >&2
echo 'Count should be 553' >&2
esac
echo Extracting 'doprintf.c.cdif'
sed 's/^X//' > 'doprintf.c.cdif' << '+ END-OF-FILE ''doprintf.c.cdif'
X*** /local/ast/minix/tape3b/lib/doprintf.c Wed Jul 13 11:55:43 1988
X--- doprintf.c Mon Sep 26 13:04:55 1988
X***************
X*** 16,22 ****
X #endif
X
X static char *
X! itoa(p, num, radix)
X register char *p;
X register unsigned num;
X register radix;
X--- 16,22 ----
X #endif
X
X static char *
X! _itoa(p, num, radix)
X register char *p;
X register unsigned num;
X register radix;
X***************
X*** 182,188 ****
X break;
X }
X #endif
X! p = itoa(p, GETARG(int), c);
X break;
X case 'D':
X #ifndef NO_LONGD
X--- 182,188 ----
X break;
X }
X #endif
X! p = _itoa(p, GETARG(int), c);
X break;
X case 'D':
X #ifndef NO_LONGD
X***************
X*** 203,209 ****
X *p++ = '-';
X i = -i;
X }
X! p = itoa(p, i, 10);
X break;
X #ifdef NO_FLOAT
X case 'e':
X--- 203,209 ----
X *p++ = '-';
X i = -i;
X }
X! p = _itoa(p, i, 10);
X break;
X #ifdef NO_FLOAT
X case 'e':
+ END-OF-FILE doprintf.c.cdif
chmod 'u=rw,g=r,o=r' 'doprintf.c.cdif'
set `wc -c 'doprintf.c.cdif'`
count=$1
case $count in
915) :;;
*) echo 'Bad character count in ''doprintf.c.cdif' >&2
echo 'Count should be 915' >&2
esac
echo Extracting 'execlp.c.new'
sed 's/^X//' > 'execlp.c.new' << '+ END-OF-FILE ''execlp.c.new'
X/* execlp(3) and execvp(3)
X *
X * Author: Terrence W. Holm July 1988
X */
X
X/*
X * Execlp(3) and execvp(3) are like execl(3) and execv(3),
X * except that they use the environment variable $PATH as
X * a search list of possible locations for the executable
X * file, if <file> does not start with a '/'.
X *
X * The path search list is a list of directory names separated
X * by ':'s. If a colon appears at the beginning or end of the
X * list, or two appear together, then an empty prefix is
X * tried. If $PATH is not in the environment, it defaults to
X * ":/bin:/usr/bin".
X *
X * For example, if <file> is "sh", and the $PATH is
X * ":/bin:/usr/local:/usr/bin", then the attempts will be:
X * "sh", "/bin/sh", "/usr/local/sh" and "/usr/bin/sh".
X *
X * If the <file> is not an executable file in one of the
X * directories, then -1 is returned.
X */
X
X#include <errno.h>
X/* #include <string.h> */
X/* #include <unistd.h> */
X
X#ifndef X_OK
X#define X_OK 1
X#endif
X
X#define NULL (char *) 0
X
Xextern char *index();
Xextern char *getenv();
X
Xextern char **environ;
Xextern int errno;
X
X
Xexeclp( file, arg0 )
X char *file;
X char *arg0;
X
X {
X return( execvp( file, &arg0 ) );
X }
X
X
Xexecvp( file, argv )
X char *file;
X char *argv[];
X
X {
X char path_name[100];
X char *next;
X char *path = getenv( "PATH" );
X
X if ( path == NULL )
X path = ":/bin:/usr/bin";
X
X if ( file[0] == '/' )
X path = "";
X
X do {
X next = index( path, ':' );
X
X if ( next == NULL )
X strcpy( path_name, path );
X else
X {
X *path_name = '\0';
X strncat( path_name, path, next - path );
X path = next + 1;
X }
X
X if ( *path_name != '\0' )
X strcat( path_name, "/" );
X
X strcat( path_name, file );
X
X if ( access( path_name, X_OK ) == 0 )
X execve( path_name, argv, environ );
X } while ( next != NULL );
X
X errno = ENOENT;
X return( -1 );
X }
+ END-OF-FILE execlp.c.new
chmod 'u=rw,g=r,o=r' 'execlp.c.new'
set `wc -c 'execlp.c.new'`
count=$1
case $count in
1858) :;;
*) echo 'Bad character count in ''execlp.c.new' >&2
echo 'Count should be 1858' >&2
esac
echo Extracting 'ffs.c.new'
sed 's/^X//' > 'ffs.c.new' << '+ END-OF-FILE ''ffs.c.new'
X/* ffs(3)
X *
X * Author: Terrence W. Holm Sep. 1988
X */
X
X
Xint ffs( word )
X int word;
X
X {
X int i;
X
X if ( word == 0 )
X return( 0 );
X
X for ( i = 1; ; ++i, word >>= 1 )
X if ( word & 1 )
X return( i );
X }
+ END-OF-FILE ffs.c.new
chmod 'u=rw,g=r,o=r' 'ffs.c.new'
set `wc -c 'ffs.c.new'`
count=$1
case $count in
224) :;;
*) echo 'Bad character count in ''ffs.c.new' >&2
echo 'Count should be 224' >&2
esac
echo Extracting 'fgetc.c.new'
sed 's/^X//' > 'fgetc.c.new' << '+ END-OF-FILE ''fgetc.c.new'
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.new
chmod 'u=rw,g=r,o=r' 'fgetc.c.new'
set `wc -c 'fgetc.c.new'`
count=$1
case $count in
617) :;;
*) echo 'Bad character count in ''fgetc.c.new' >&2
echo 'Count should be 617' >&2
esac
echo Extracting 'fopen.c.cdif'
sed 's/^X//' > 'fopen.c.cdif' << '+ END-OF-FILE ''fopen.c.cdif'
X*** /local/ast/minix/tape3b/lib/fopen.c Wed Jul 13 11:55:45 1988
X--- fopen.c Mon Sep 26 13:04:57 1988
X***************
X*** 27,32 ****
X--- 27,33 ----
X break;
X
X case 'a':
X+ flags |= WRITEMODE;
X if (( fd = open(name,1)) < 0 )
X if(errno != ENOENT || (fd = creat(name, PMODE)) < 0)
X return(NULL);
+ END-OF-FILE fopen.c.cdif
chmod 'u=rw,g=r,o=r' 'fopen.c.cdif'
set `wc -c 'fopen.c.cdif'`
count=$1
case $count in
313) :;;
*) echo 'Bad character count in ''fopen.c.cdif' >&2
echo 'Count should be 313' >&2
esac
echo Extracting 'fputc.c.new'
sed 's/^X//' > 'fputc.c.new' << '+ END-OF-FILE ''fputc.c.new'
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.new
chmod 'u=rw,g=r,o=r' 'fputc.c.new'
set `wc -c 'fputc.c.new'`
count=$1
case $count in
721) :;;
*) echo 'Bad character count in ''fputc.c.new' >&2
echo 'Count should be 721' >&2
esac
echo Extracting 'getcwd.c.new'
sed 's/^X//' > 'getcwd.c.new' << '+ END-OF-FILE ''getcwd.c.new'
X/* getcwd(3)
X *
X * Author: Terrence W. Holm Aug. 1988
X *
X * Directly derived from Adri Koppes' pwd(1).
X */
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/dir.h>
X#include <errno.h>
X
X#define NULL (char *) 0
X#define O_RDONLY 0
X#define DIRECT_SIZE (sizeof (struct direct))
X#define PATH_MAX 127
X
Xextern char *rindex();
X
Xextern int errno;
X
X
Xchar *getcwd( buffer, size )
X char *buffer;
X int size;
X
X {
X static char path[ PATH_MAX + 1 ];
X struct stat current;
X
X if ( buffer == NULL || size == 0 )
X {
X errno = EINVAL;
X return( NULL );
X }
X
X path[0] = '\0';
X
X /* Get the inode for the current directory */
X
X if ( stat( ".", ¤t ) == -1 )
X return( NULL );
X
X if ( (current.st_mode & S_IFMT) != S_IFDIR )
X return( NULL );
X
X
X /* Run backwards up the directory tree, grabbing */
X /* directory names on the way. */
X
X while (1)
X {
X struct stat parent;
X struct direct d;
X int same_device = 0;
X int found = 0;
X int fd;
X
X /* Get the inode for the parent directory */
X
X if ( chdir( ".." ) == -1 )
X return( NULL );
X
X if ( stat( ".", &parent ) == -1 )
X return( NULL );
X
X if ( (parent.st_mode & S_IFMT) != S_IFDIR )
X return( NULL );
X
X if ( current.st_dev == parent.st_dev )
X same_device = 1;
X
X
X /* At the root, "." is the same as ".." */
X
X if ( same_device && current.st_ino == parent.st_ino )
X break;
X
X
X /* Search the parent directory for the current entry */
X
X if ( (fd = open( ".", O_RDONLY )) == -1 )
X return( NULL );
X
X while ( ! found && read(fd, &d, DIRECT_SIZE) == DIRECT_SIZE )
X {
X if ( same_device )
X {
X if ( current.st_ino == d.d_ino )
X found = 1;
X }
X else
X {
X static char temp_name[ DIRSIZ + 1 ];
X static struct stat dir_entry;
X
X temp_name[0] = '\0';
X strncat( temp_name, d.d_name, DIRSIZ );
X
X if ( stat( temp_name, &dir_entry ) == -1 )
X {
X close( fd );
X return( NULL );
X }
X
X if ( current.st_dev == dir_entry.st_dev &&
X current.st_ino == dir_entry.st_ino )
X found = 1;
X }
X }
X
X close( fd );
X
X if ( ! found )
X return( NULL );
X
X if ( strlen(path) + DIRSIZ + 1 > PATH_MAX )
X {
X errno = ERANGE;
X return( NULL );
X }
X
X strcat( path, "/" );
X strncat( path, d.d_name, DIRSIZ );
X
X current.st_dev = parent.st_dev;
X current.st_ino = parent.st_ino;
X }
X
X
X /* Copy the reversed path name into <buffer> */
X
X if ( strlen(path) + 1 > size )
X {
X errno = ERANGE;
X return( NULL );
X }
X
X if ( strlen(path) == 0 )
X {
X strcpy( buffer, "/" );
X return( buffer );
X }
X
X *buffer = '\0';
X
X {
X char *r;
X
X while ( (r = rindex( path, '/' )) != NULL )
X {
X strcat( buffer, r );
X *r = '\0';
X }
X }
X
X return( chdir( buffer ) ? NULL : buffer );
X }
+ END-OF-FILE getcwd.c.new
chmod 'u=rw,g=r,o=r' 'getcwd.c.new'
set `wc -c 'getcwd.c.new'`
count=$1
case $count in
2784) :;;
*) echo 'Bad character count in ''getcwd.c.new' >&2
echo 'Count should be 2784' >&2
esac
echo Extracting 'getenv.c.cdif'
sed 's/^X//' > 'getenv.c.cdif' << '+ END-OF-FILE ''getenv.c.cdif'
X*** /local/ast/minix/tape3b/lib/getenv.c Wed Jul 13 11:55:48 1988
X--- getenv.c Mon Sep 26 13:05:01 1988
X***************
X*** 1,21 ****
X! #define NULL (char *) 0
X
X! char *getenv(name)
X! register char *name;
X! {
X! extern char **environ;
X! register char **v = environ, *p, *q;
X
X! if (v && name) { /* added if statement */
X! while ((p = *v++) != NULL) { /* was, while((p = *v) != NULL */
X! q = name;
X! while (*p++ == *q)
X! if (*q++ == 0)
X! continue;
X! if (*(p - 1) != '=')
X! continue;
X! return(p);
X! }
X }
X- return(0);
X- }
X--- 1,34 ----
X! /* getenv(3)
X! *
X! * Author: Terrence W. Holm Aug. 1988
X! */
X
X! #define NULL (char *) 0
X
X! extern char **environ;
X!
X!
X! char *getenv( name )
X! char *name;
X! {
X! char **v;
X! register char *n;
X! register char *p;
X!
X! if ( environ == (char **) NULL || name == NULL )
X! return(NULL);
X!
X! for ( v = environ; *v != NULL; ++v )
X! {
X! n = name;
X! p = *v;
X!
X! while ( *n == *p && *n != '\0' )
X! ++n, ++p;
X!
X! if ( *n == '\0' && *p == '=' )
X! return( p + 1 );
X! }
X!
X! return(NULL);
X }
+ END-OF-FILE getenv.c.cdif
chmod 'u=rw,g=r,o=r' 'getenv.c.cdif'
set `wc -c 'getenv.c.cdif'`
count=$1
case $count in
1133) :;;
*) echo 'Bad character count in ''getenv.c.cdif' >&2
echo 'Count should be 1133' >&2
esac
echo Extracting 'getgrent.c.cdif'
sed 's/^X//' > 'getgrent.c.cdif' << '+ END-OF-FILE ''getgrent.c.cdif'
X*** /local/ast/minix/tape3b/lib/getgrent.c Wed Jul 13 11:55:49 1988
X--- getgrent.c Mon Sep 26 13:05:04 1988
X***************
X*** 63,69 ****
X
X static skip_period ()
X {
X! while (*_buf != ':')
X _buf++;
X *_buf++ = '\0';
X }
X--- 63,69 ----
X
X static skip_period ()
X {
X! while ((*_buf) && (*_buf != ':'))
X _buf++;
X *_buf++ = '\0';
X }
+ END-OF-FILE getgrent.c.cdif
chmod 'u=rw,g=r,o=r' 'getgrent.c.cdif'
set `wc -c 'getgrent.c.cdif'`
count=$1
case $count in
391) :;;
*) echo 'Bad character count in ''getgrent.c.cdif' >&2
echo 'Count should be 391' >&2
esac
echo Extracting 'getlogin.c.new'
sed 's/^X//' > 'getlogin.c.new' << '+ END-OF-FILE ''getlogin.c.new'
X/* getlogin(3)
X *
X * Author: Terrence W. Holm Aug. 1988
X */
X
X#include <stdio.h>
X#include <pwd.h>
X
X#ifndef L_cuserid
X#define L_cuserid 9
X#endif
X
Xextern struct passwd *getpwuid();
X
X
Xchar *getlogin()
X {
X static char userid[ L_cuserid ];
X struct passwd *pw_entry;
X
X pw_entry = getpwuid( getuid() );
X
X if ( pw_entry == NULL )
X return( NULL );
X
X strcpy( userid, pw_entry->pw_name );
X
X return( userid );
X }
+ END-OF-FILE getlogin.c.new
chmod 'u=rw,g=r,o=r' 'getlogin.c.new'
set `wc -c 'getlogin.c.new'`
count=$1
case $count in
429) :;;
*) echo 'Bad character count in ''getlogin.c.new' >&2
echo 'Count should be 429' >&2
esac
echo Extracting 'getpass.c.cdif'
sed 's/^X//' > 'getpass.c.cdif' << '+ END-OF-FILE ''getpass.c.cdif'
X*** /local/ast/minix/tape3b/lib/getpass.c Wed Jul 13 11:55:49 1988
X--- getpass.c Mon Sep 26 13:05:04 1988
X***************
X*** 5,22 ****
X char * getpass(prompt)
X char *prompt;
X {
X! int i = 0;
X struct sgttyb tty;
X
X prints(prompt);
X ioctl(0, TIOCGETP, &tty);
X! tty.sg_flags = 06020;
X ioctl(0, TIOCSETP, &tty);
X i = read(0, pwdbuf, 9);
X while (pwdbuf[i - 1] != '\n')
X read(0, &pwdbuf[i - 1], 1);
X pwdbuf[i - 1] = '\0';
X! tty.sg_flags = 06030;
X ioctl(0, TIOCSETP, &tty);
X prints("\n");
X return(pwdbuf);
X--- 5,23 ----
X char * getpass(prompt)
X char *prompt;
X {
X! int i = 0, save;
X struct sgttyb tty;
X
X prints(prompt);
X ioctl(0, TIOCGETP, &tty);
X! save = tty.sg_flags;
X! tty.sg_flags = tty.sg_flags & ~ECHO;
X ioctl(0, TIOCSETP, &tty);
X i = read(0, pwdbuf, 9);
X while (pwdbuf[i - 1] != '\n')
X read(0, &pwdbuf[i - 1], 1);
X pwdbuf[i - 1] = '\0';
X! tty.sg_flags = save;
X ioctl(0, TIOCSETP, &tty);
X prints("\n");
X return(pwdbuf);
+ END-OF-FILE getpass.c.cdif
chmod 'u=rw,g=r,o=r' 'getpass.c.cdif'
set `wc -c 'getpass.c.cdif'`
count=$1
case $count in
980) :;;
*) echo 'Bad character count in ''getpass.c.cdif' >&2
echo 'Count should be 980' >&2
esac
echo Extracting 'lsearch.c.new'
sed 's/^X//' > 'lsearch.c.new' << '+ END-OF-FILE ''lsearch.c.new'
X/* lsearch(3) and lfind(3)
X *
X * Author: Terrence W. Holm Sep. 1988
X */
X
X#define NULL (char *) 0
X
X
Xchar *lsearch( key, base, count, width, keycmp )
X char *key;
X char *base;
X unsigned *count;
X unsigned width;
X int (*keycmp)();
X
X {
X char *entry;
X char *last = base + *count * width;
X
X for ( entry = base; entry < last; entry += width )
X if ( keycmp( key, entry ) == 0 )
X return( entry );
X
X bcopy( key, last, width );
X *count += 1;
X return( last );
X }
X
X
X
Xchar *lfind( key, base, count, width, keycmp )
X char *key;
X char *base;
X unsigned *count;
X unsigned width;
X int (*keycmp)();
X
X {
X char *entry;
X char *last = base + *count * width;
X
X for ( entry = base; entry < last; entry += width )
X if ( keycmp( key, entry ) == 0 )
X return( entry );
X
X return( NULL );
X }
+ END-OF-FILE lsearch.c.new
chmod 'u=rw,g=r,o=r' 'lsearch.c.new'
set `wc -c 'lsearch.c.new'`
count=$1
case $count in
811) :;;
*) echo 'Bad character count in ''lsearch.c.new' >&2
echo 'Count should be 811' >&2
esac
echo Extracting 'memccpy.c.new'
sed 's/^X//' > 'memccpy.c.new' << '+ END-OF-FILE ''memccpy.c.new'
X/* memccpy(3)
X *
X * Author: Terrence W. Holm Sep. 1988
X */
X
X#define NULL (char *) 0
X
X
Xchar *memccpy( to, from, chr, count )
X char *to;
X char *from;
X int chr;
X int count;
X
X {
X while( --count >= 0 )
X if ( (*to++ = *from++) == chr )
X return( from );
X
X return( NULL );
X }
+ END-OF-FILE memccpy.c.new
chmod 'u=rw,g=r,o=r' 'memccpy.c.new'
set `wc -c 'memccpy.c.new'`
count=$1
case $count in
296) :;;
*) echo 'Bad character count in ''memccpy.c.new' >&2
echo 'Count should be 296' >&2
esac
echo Extracting 'memchr.c.new'
sed 's/^X//' > 'memchr.c.new' << '+ END-OF-FILE ''memchr.c.new'
X/* memchr(3)
X *
X * Author: Terrence W. Holm Sep. 1988
X */
X
X#define NULL (char *) 0
X
X
Xchar *memchr( vector, chr, count )
X char *vector;
X int chr;
X int count;
X
X {
X while( --count >= 0 )
X if ( *vector++ == chr )
X return( vector - 1 );
X
X return( NULL );
X }
+ END-OF-FILE memchr.c.new
chmod 'u=rw,g=r,o=r' 'memchr.c.new'
set `wc -c 'memchr.c.new'`
count=$1
case $count in
280) :;;
*) echo 'Bad character count in ''memchr.c.new' >&2
echo 'Count should be 280' >&2
esac
echo Extracting 'memcmp.c.new'
sed 's/^X//' > 'memcmp.c.new' << '+ END-OF-FILE ''memcmp.c.new'
X/* memcmp(3)
X *
X * Author: Terrence W. Holm Sep. 1988
X */
X
X
Xint memcmp( vector1, vector2, count )
X char *vector1;
X char *vector2;
X int count;
X
X {
X register int cmp;
X
X if ( vector1 == vector2 )
X return( 0 );
X
X while( --count >= 0 )
X if ( cmp = *vector1++ - *vector2++ )
X return( cmp );
X
X return( 0 );
X }
+ END-OF-FILE memcmp.c.new
chmod 'u=rw,g=r,o=r' 'memcmp.c.new'
set `wc -c 'memcmp.c.new'`
count=$1
case $count in
331) :;;
*) echo 'Bad character count in ''memcmp.c.new' >&2
echo 'Count should be 331' >&2
esac
echo Extracting 'memcpy.c.new'
sed 's/^X//' > 'memcpy.c.new' << '+ END-OF-FILE ''memcpy.c.new'
X/* memcpy(3)
X *
X * Author: Terrence W. Holm Sep. 1988
X */
X
X
Xchar *memcpy( to, from, count )
X char *to;
X char *from;
X int count;
X
X {
X int word_count = count / sizeof(int);
X int byte_count = count & ( sizeof(int) - 1 );
X char *temp_to = to;
X
X if ( to > from && to < from + count )
X {
X /* Must copy backwards */
X from += count;
X to += count;
X
X while( --byte_count >= 0 )
X *--to = *--from;
X
X while( --word_count >= 0 )
X *--((int *) to) = *--((int *) from);
X }
X else
X {
X while( --word_count >= 0 )
X *((int *) to)++ = *((int *) from)++;
X
X while( --byte_count >= 0 )
X *to++ = *from++;
X }
X
X return( temp_to );
X }
+ END-OF-FILE memcpy.c.new
chmod 'u=rw,g=r,o=r' 'memcpy.c.new'
set `wc -c 'memcpy.c.new'`
count=$1
case $count in
691) :;;
*) echo 'Bad character count in ''memcpy.c.new' >&2
echo 'Count should be 691' >&2
esac
echo Extracting 'memset.c.new'
sed 's/^X//' > 'memset.c.new' << '+ END-OF-FILE ''memset.c.new'
X/* memset(3)
X *
X * Author: Terrence W. Holm Sep. 1988
X */
X
X
Xchar *memset( vector, chr, count )
X char *vector;
X int chr;
X int count;
X
X {
X register char *memory = vector;
X
X while( --count >= 0 )
X *memory++ = chr;
X
X return( vector );
X }
+ END-OF-FILE memset.c.new
chmod 'u=rw,g=r,o=r' 'memset.c.new'
set `wc -c 'memset.c.new'`
count=$1
case $count in
260) :;;
*) echo 'Bad character count in ''memset.c.new' >&2
echo 'Count should be 260' >&2
esac
echo Extracting 'scanf.c.cdif'
sed 's/^X//' > 'scanf.c.cdif' << '+ END-OF-FILE ''scanf.c.cdif'
X*** /local/ast/minix/tape3b/lib/scanf.c Wed Jul 13 11:56:01 1988
X--- scanf.c Mon Sep 26 13:05:15 1988
X***************
X*** 162,168 ****
X goto all_done;
X ++format;
X rnc ();
X- ++done;
X continue;
X }
X ++format;
X--- 162,167 ----
X***************
X*** 234,241 ****
X else
X *(argp++)->uint_p = (unsigned) val;
X }
X! if (done_some)
X! ++done;
X else
X goto all_done;
X break;
X--- 233,241 ----
X else
X *(argp++)->uint_p = (unsigned) val;
X }
X! if (done_some) {
X! if(do_assign) ++done;
X! }
X else
X goto all_done;
X break;
X***************
X*** 250,256 ****
X }
X if (do_assign)
X argp++; /* done with this one */
X! if (done_some)
X ++done;
X break;
X case 's':
X--- 250,256 ----
X }
X if (do_assign)
X argp++; /* done with this one */
X! if (done_some && do_assign)
X ++done;
X break;
X case 's':
X***************
X*** 264,272 ****
X }
X if (do_assign) /* terminate the string */
X *(argp++)->chr_p = '\0';
X! if (done_some)
X! ++done;
X! else
X goto all_done;
X break;
X case '[':
X--- 264,272 ----
X }
X if (do_assign) /* terminate the string */
X *(argp++)->chr_p = '\0';
X! if (done_some) {
X! if(do_assign) ++done;
X! } else
X goto all_done;
X break;
X case '[':
X***************
X*** 299,307 ****
X *format = ']'; /* put it back */
X if (do_assign) /* terminate the string */
X *(argp++)->chr_p = '\0';
X! if (done_some)
X! ++done;
X! else
X goto all_done;
X break;
X } /* end switch */
X--- 299,307 ----
X *format = ']'; /* put it back */
X if (do_assign) /* terminate the string */
X *(argp++)->chr_p = '\0';
X! if (done_some) {
X! if(do_assign) ++done;
X! } else
X goto all_done;
X break;
X } /* end switch */
+ END-OF-FILE scanf.c.cdif
chmod 'u=rw,g=r,o=r' 'scanf.c.cdif'
set `wc -c 'scanf.c.cdif'`
count=$1
case $count in
1845) :;;
*) echo 'Bad character count in ''scanf.c.cdif' >&2
echo 'Count should be 1845' >&2
esac
echo Extracting 'strchr.c.new'
sed 's/^X//' > 'strchr.c.new' << '+ END-OF-FILE ''strchr.c.new'
X/* strchr(3)
X *
X * Derived from MINIX index(3)
X */
X
X
X#define NULL (char *) 0
X
X
Xchar *strchr( string, chr )
X register char *string;
X register char chr;
X
X {
X do {
X if ( *string == chr )
X return( string );
X } while ( *string++ != '\0' );
X
X return( NULL );
X }
+ END-OF-FILE strchr.c.new
chmod 'u=rw,g=r,o=r' 'strchr.c.new'
set `wc -c 'strchr.c.new'`
count=$1
case $count in
276) :;;
*) echo 'Bad character count in ''strchr.c.new' >&2
echo 'Count should be 276' >&2
esac
echo Extracting 'strcspn.c.new'
sed 's/^X//' > 'strcspn.c.new' << '+ END-OF-FILE ''strcspn.c.new'
X/* strcspn(3)
X *
X * Author: Terrence W. Holm July 1988
X *
X *
X * This function determines the length of a span from the
X * beginning of <string> which contains none of the
X * characters specified in <char_set>. The length of the
X * span is returned.
X */
X
X#define NULL (char *) 0
X
X
Xint strcspn( string, char_set )
X char *string;
X char *char_set;
X
X {
X register char *str;
X register char *chr;
X
X if ( string == NULL )
X return( 0 );
X
X if ( char_set == NULL )
X return( strlen(string) );
X
X for ( str = string; *str != '\0'; ++str )
X for ( chr = char_set; *chr != '\0'; ++chr )
X if ( *str == *chr )
X return( str - string );
X
X return( str - string );
X }
+ END-OF-FILE strcspn.c.new
chmod 'u=rw,g=r,o=r' 'strcspn.c.new'
set `wc -c 'strcspn.c.new'`
count=$1
case $count in
698) :;;
*) echo 'Bad character count in ''strcspn.c.new' >&2
echo 'Count should be 698' >&2
esac
echo Extracting 'strpbrk.c.new'
sed 's/^X//' > 'strpbrk.c.new' << '+ END-OF-FILE ''strpbrk.c.new'
X/* strpbrk(3)
X *
X * Author: Terrence W. Holm July 1988
X *
X *
X * Strpbrk(3) scans <string> for the first occurrence of a
X * character from the string <char_set>. If a character from
X * the <char_set> was found then a pointer to it within
X * <string> is returned, otherwise NULL is returned.
X */
X
X#define NULL (char *) 0
X
X
Xchar *strpbrk( string, char_set )
X char *string;
X char *char_set;
X
X {
X register char c;
X register char *p;
X
X if ( string == NULL || char_set == NULL )
X return( NULL );
X
X while ( (c = *string++) != '\0' )
X for ( p = char_set; *p != '\0'; ++p )
X if ( c == *p )
X return( string - 1 );
X
X return( NULL );
X }
+ END-OF-FILE strpbrk.c.new
chmod 'u=rw,g=r,o=r' 'strpbrk.c.new'
set `wc -c 'strpbrk.c.new'`
count=$1
case $count in
670) :;;
*) echo 'Bad character count in ''strpbrk.c.new' >&2
echo 'Count should be 670' >&2
esac
echo Extracting 'strrchr.c.new'
sed 's/^X//' > 'strrchr.c.new' << '+ END-OF-FILE ''strrchr.c.new'
X/* strrchr(3)
X *
X * Derived from MINIX rindex(3)
X */
X
X
X#define NULL (char *) 0
X
X
Xchar *strrchr( string, chr )
X register char *string;
X register char chr;
X
X {
X char *index = NULL;
X
X do {
X if ( *string == chr )
X index = string;
X } while ( *string++ != '\0' );
X
X return( index );
X }
+ END-OF-FILE strrchr.c.new
chmod 'u=rw,g=r,o=r' 'strrchr.c.new'
set `wc -c 'strrchr.c.new'`
count=$1
case $count in
301) :;;
*) echo 'Bad character count in ''strrchr.c.new' >&2
echo 'Count should be 301' >&2
esac
echo Extracting 'strspn.c.new'
sed 's/^X//' > 'strspn.c.new' << '+ END-OF-FILE ''strspn.c.new'
X/* strspn(3)
X *
X * Author: Terrence W. Holm July 1988
X *
X *
X * This function determines the length of a span from the
X * beginning of <string> which contains only characters
X * specified in <char_set>. The length of the span is
X * returned.
X */
X
X#define NULL (char *) 0
X
X
Xint strspn( string, char_set )
X char *string;
X char *char_set;
X
X {
X register char *str;
X register char *chr;
X
X if ( string == NULL || char_set == NULL )
X return( 0 );
X
X for ( str = string; *str != '\0'; ++str )
X {
X for ( chr = char_set; *chr != '\0'; ++chr )
X if ( *str == *chr )
X break;
X
X if ( *chr == '\0' )
X return( str - string );
X }
X
X return( str - string );
X }
+ END-OF-FILE strspn.c.new
chmod 'u=rw,g=r,o=r' 'strspn.c.new'
set `wc -c 'strspn.c.new'`
count=$1
case $count in
705) :;;
*) echo 'Bad character count in ''strspn.c.new' >&2
echo 'Count should be 705' >&2
esac
echo Extracting 'strstr.c.new'
sed 's/^X//' > 'strstr.c.new' << '+ END-OF-FILE ''strstr.c.new'
X/* strstr(3)
X *
X * Author: Terrence W. Holm July 1988
X *
X *
X * Finds the first occurrence of a substring, pointed to by
X * <substr>, within a string pointed to by <string>.
X * If the substring is found then a pointer to it within
X * <string> is returned, otherwise NULL is returned.
X */
X
X#define NULL (char *) 0
X
X
Xchar *strstr( string, substr )
X char *string;
X char *substr;
X
X {
X register char head_string;
X register char head_substr;
X
X if ( string == NULL || substr == NULL )
X return( NULL );
X
X head_substr = *substr++;
X
X while ( (head_string = *string++) != '\0' )
X if ( head_string == head_substr )
X {
X register char *tail_string = string;
X register char *tail_substr = substr;
X
X do {
X if ( *tail_substr == '\0' )
X return( string - 1 );
X } while ( *tail_string++ == *tail_substr++ );
X }
X
X return( NULL );
X }
+ END-OF-FILE strstr.c.new
chmod 'u=rw,g=r,o=r' 'strstr.c.new'
set `wc -c 'strstr.c.new'`
count=$1
case $count in
856) :;;
*) echo 'Bad character count in ''strstr.c.new' >&2
echo 'Count should be 856' >&2
esac
echo Extracting 'strtok.c.new'
sed 's/^X//' > 'strtok.c.new' << '+ END-OF-FILE ''strtok.c.new'
X/* strtok(3)
X *
X * Author: Terrence W. Holm July 1988
X *
X *
X * This function is used to divide up a string into tokens.
X * Strtok(3) is called with <string> pointing to the string
X * to be scanned and <char_set> pointing to a string which
X * consists of the set of separator characters. Tokens are
X * substrings bordered by separator characters. A pointer to
X * the first token encountered is returned. If <string> is
X * NULL then the scan is continued from the last token
X * returned. Each token is terminated by a '\0'. If there are
X * no tokens remaining in the string then NULL is returned.
X */
X
X#define NULL (char *) 0
X
X
Xchar *strtok( string, char_set )
X char *string;
X char *char_set;
X
X {
X static char *last_string = "";
X register char *chr;
X char *next_token;
X
X if ( string == NULL )
X string = last_string;
X
X if ( char_set == NULL )
X return( NULL );
X
X
X /* First skip over any separator characters */
X
X while ( *string != '\0' )
X {
X for ( chr = char_set; *chr != '\0'; ++chr )
X if ( *string == *chr )
X break;
X
X if ( *chr == '\0' )
X break;
X
X ++string;
X }
X
X
X /* Check if we have reached the end of the string */
X
X if ( *string == '\0' )
X return( NULL );
X
X
X /* If not, then we have found the next token */
X
X next_token = string;
X
X
X /* Scan for the end of this token */
X
X while ( *string != '\0' )
X {
X for ( chr = char_set; *chr != '\0'; ++chr )
X if ( *string == *chr )
X {
X *string = '\0';
X last_string = string + 1;
X return( next_token );
X }
X
X ++string;
X }
X
X last_string = string;
X return( next_token );
X }
+ END-OF-FILE strtok.c.new
chmod 'u=rw,g=r,o=r' 'strtok.c.new'
set `wc -c 'strtok.c.new'`
count=$1
case $count in
1663) :;;
*) echo 'Bad character count in ''strtok.c.new' >&2
echo 'Count should be 1663' >&2
esac
echo Extracting 'swab.c.new'
sed 's/^X//' > 'swab.c.new' << '+ END-OF-FILE ''swab.c.new'
X/* swab(3)
X *
X * Author: Terrence W. Holm Sep. 1988
X */
X
X
Xswab( from, to, count )
X char *from;
X char *to;
X int count;
X
X {
X register char temp;
X
X count >>= 1;
X
X while( --count >= 0 )
X {
X temp = *from++;
X *to++ = *from++;
X *to++ = temp;
X }
X }
+ END-OF-FILE swab.c.new
chmod 'u=rw,g=r,o=r' 'swab.c.new'
set `wc -c 'swab.c.new'`
count=$1
case $count in
278) :;;
*) echo 'Bad character count in ''swab.c.new' >&2
echo 'Count should be 278' >&2
esac
echo Extracting 'termcap.c.cdif'
sed 's/^X//' > 'termcap.c.cdif' << '+ END-OF-FILE ''termcap.c.cdif'
X*** /local/ast/minix/tape3b/lib/termcap.c Wed Jul 13 11:56:07 1988
X--- termcap.c Mon Sep 26 13:05:23 1988
X***************
X*** 13,18 ****
X--- 13,19 ----
X - Correct when TERM != name and TERMCAP is defined [tgetent]
X - Correct the comparison for the terminal name [tgetent]
X - Correct the value of ^x escapes [tgetstr]
X+ - Added %r to reverse row/column [tgoto]
X */
X
X #include <stdio.h>
X***************
X*** 23,29 ****
X #define ISDIGIT(x) ((x) >= '0' && (x) <= '9')
X
X char *capab; /* the capability itself */
X- int incr; /* set by %i flag */
X
X extern char *getenv(); /* new, improved getenv */
X extern FILE *fopen(); /* old fopen */
X--- 24,29 ----
X***************
X*** 233,239 ****
X {
X register char *rp;
X static char ret[24];
X! int *dp = &destcol;
X int argno = 0, numval;
X
X for (rp = ret ; *cm ; cm++) {
X--- 233,239 ----
X {
X register char *rp;
X static char ret[24];
X! int incr = 0;
X int argno = 0, numval;
X
X for (rp = ret ; *cm ; cm++) {
X***************
X*** 241,250 ****
X case '%' :
X switch(*++cm) {
X case '+' :
X! if (dp == NULL)
X! return("OOPS");
X! *rp++ = *dp + *++cm;
X! dp = (dp == &destcol) ? &destline : NULL;
X break;
X
X case '%' :
X--- 241,249 ----
X case '%' :
X switch(*++cm) {
X case '+' :
X! numval = (argno == 0 ? destline : destcol);
X! argno = 1 - argno;
X! *rp++ = numval + incr + *++cm;
X break;
X
X case '%' :
X***************
X*** 252,267 ****
X break;
X
X case 'i' :
X-
X incr = 1;
X break;
X
X case 'd' :
X numval = (argno == 0 ? destline : destcol);
X numval += incr;
X! argno++;
X *rp++ = '0' + (numval/10);
X *rp++ = '0' + (numval%10);
X break;
X }
X
X--- 251,269 ----
X break;
X
X case 'i' :
X incr = 1;
X break;
X
X case 'd' :
X numval = (argno == 0 ? destline : destcol);
X numval += incr;
X! argno = 1 - argno;
X *rp++ = '0' + (numval/10);
X *rp++ = '0' + (numval%10);
X+ break;
X+
X+ case 'r' :
X+ argno = 1;
X break;
X }
X
+ END-OF-FILE termcap.c.cdif
chmod 'u=rw,g=r,o=r' 'termcap.c.cdif'
set `wc -c 'termcap.c.cdif'`
count=$1
case $count in
2104) :;;
*) echo 'Bad character count in ''termcap.c.cdif' >&2
echo 'Count should be 2104' >&2
esac
echo Extracting 'ttyname.c.new'
sed 's/^X//' > 'ttyname.c.new' << '+ END-OF-FILE ''ttyname.c.new'
X/* ttyname(3)
X */
X
X#include <sys/types.h>
X#include <sys/dir.h>
X#include <sys/stat.h>
X
X#define NULL (char *) 0
X#define DEV "/dev/"
X
Xstatic char file_name[40];
X
X
Xchar *ttyname( tty_file_desc )
X int tty_file_desc;
X
X {
X int dev_dir_desc;
X struct direct dir_entry;
X struct stat tty_stat;
X struct stat dev_stat;
X
X /* Make sure the supplied file descriptor is for a terminal */
X
X if ( fstat(tty_file_desc, &tty_stat) < 0 )
X return( NULL );
X
X if ( (tty_stat.st_mode & S_IFMT) != S_IFCHR )
X return( NULL );
X
X
X /* Open /dev for reading */
X
X if ( (dev_dir_desc = open(DEV,0)) < 0 )
X return( NULL );
X
X while( read(dev_dir_desc, (char *) &dir_entry, sizeof (struct direct)) > 0 )
X {
X /* Find an entry in /dev with the same inode number */
X
X if ( tty_stat.st_ino != dir_entry.d_ino )
X continue;
X
X /* Put the name of the device in static storage */
X
X strcpy( file_name, DEV );
X strncat( file_name, dir_entry.d_name, sizeof (dir_entry.d_name) );
X
X /* Be absolutely certain the inodes match */
X
X if ( stat(file_name, &dev_stat) < 0 )
X continue;
X
X if ( (dev_stat.st_mode & S_IFMT) != S_IFCHR )
X continue;
X
X if ( tty_stat.st_ino == dev_stat.st_ino &&
X tty_stat.st_dev == dev_stat.st_dev &&
X tty_stat.st_rdev == dev_stat.st_rdev )
X {
X close( dev_dir_desc );
X return( file_name );
X }
X }
X
X close( dev_dir_desc );
X return( NULL );
X }
+ END-OF-FILE ttyname.c.new
chmod 'u=rw,g=r,o=r' 'ttyname.c.new'
set `wc -c 'ttyname.c.new'`
count=$1
case $count in
1367) :;;
*) echo 'Bad character count in ''ttyname.c.new' >&2
echo 'Count should be 1367' >&2
esac
exit 0