ast@cs.vu.nl (Andy Tanenbaum) (06/29/87)
: 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
echo Extracting \R\E\A\D\_\M\E
sed 's/^X//' > \R\E\A\D\_\M\E << '+ END-OF-FILE '\R\E\A\D\_\M\E
XI am almost done with the MINIX 1.2 release. P-H does not have any kind of
Xupgrade policy. If you buy the first edition of a book, that does not give
Xyou any right to a discount on the second edition. They don't even have a
Xlist of who bought MINIX 1.1, so they couldn't even implement such a policy
Xif they wanted to. For the benefit of readers of this news group, I will
Xpost most of the changes that I have made, so you can upgrade yourself.
XPlease in fact do so, and if you post subsequent changes, do so relative to
XMINIX 1.2 if at all possible. In any event, when posting diffs, specify
Xwhich version 1.1 or 1.2 was the base. Bug reports in any of the 1.2 programs
Xare welcome, and should be posted or mailed to me.
X
XThe diff listings were made with Erik Baalbergen's diff, which will be included
Xin 1.2 and is the "official" diff. An up-to-date version of that diff.c is
Xincluded in this file. To update, say, your old cp.c, do as follows:
XFirst compile fix.c and put it on fix. This is the "official" MINIX patch-type
Xprogram. It was orginally posted by Erik Baalbergen as "patch," but I changed
Xthe name to fix to avoid confusion with Larry Wall's program, which is much
Xfancier (and much bigger). Then, to fix, say, cp.c, do the following:
X
Xcp cp.c cp.c.old
Xfix cp.c.old cp.diff >cp.c
X
XRepeat this process for each file to be fixed. The files that are new I
Xhave posted in their entirety in a separate posting.
X
XI will be away for about 3 weeks, so if there are problems, post them to the
Xnet and see if you can figure them out collectively.
X
XAndy Tanenbaum (ast@cs.vu.nl)
X
X-------------------------------------------------------------------------
XHere is a listing of the new or modified files in commands.
X-rw-r--r-- 1 ast 10506 Jun 29 20:59 ar.c
X-rw-r--r-- 1 ast 622 Jun 29 20:59 basename.c
X-rw-r--r-- 1 ast 1406 Jun 29 20:59 cat.c
X-rw-r--r-- 1 ast 10899 Jun 29 20:59 cc.c
X-rw-r--r-- 1 ast 2891 Jun 29 20:59 cp.c
X-rw-r--r-- 1 ast 3611 Jun 29 20:59 cpdir.c
X-rw-r--r-- 1 ast 2979 Jun 29 20:59 df.c
X-rw-r--r-- 1 ast 5376 Jun 29 21:03 diff.c
X-rw-r--r-- 1 ast 20167 Jun 29 20:59 dosread.c
X-rw-r--r-- 1 ast 4363 Jun 29 20:59 du.c
X-rw-r--r-- 1 ast 2763 Jun 29 20:59 expr.c
X-rw-r--r-- 1 ast 28692 Jun 29 20:59 find.c
X-rw-r--r-- 1 ast 3506 Jun 29 21:07 fix.c
X-rw-r--r-- 1 ast 1265 Jun 29 20:59 head.c
X-rw-r--r-- 1 ast 1082 Jun 29 20:59 ln.c
X-rw-r--r-- 1 ast 1211 Jun 29 20:59 login.c
X-rw-r--r-- 1 ast 12924 Jun 29 20:59 ls.c
X-rw-r--r-- 1 ast 51610 Jun 29 20:59 make.c
X-rw-r--r-- 1 ast 24065 Jun 29 20:59 mkfs.c
X-rw-r--r-- 1 ast 4523 Jun 29 20:59 more.c
X-rw-r--r-- 1 ast 3184 Jun 29 20:59 mv.c
X-rw-r--r-- 1 ast 5193 Jun 29 20:59 od.c
X-rw-r--r-- 1 ast 2384 Jun 29 20:59 passwd.c
X-rw-r--r-- 1 ast 6562 Jun 29 20:59 pr.c
X-rw-r--r-- 1 ast 1635 Jun 29 20:59 pwd.c
X-rw-r--r-- 1 ast 14451 Jun 29 20:59 readfs.c
X-rw-r--r-- 1 ast 3002 Jun 29 20:59 rmdir.c
X-rw-r--r-- 1 ast 20250 Jun 29 20:59 roff.c
X-rw-r--r-- 1 ast 1977 Jun 29 20:59 split.c
X-rw-r--r-- 1 ast 9382 Jun 29 20:59 tar.c
X-rw-r--r-- 1 ast 4115 Jun 29 20:59 test.c
X-rw-r--r-- 1 ast 3393 Jun 29 20:59 uudecode.c
X-rw-r--r-- 1 ast 1822 Jun 29 20:59 uuencode.c
X-rw-r--r-- 1 ast 2920 Jun 29 20:59 wc.c
X
XHere are the sums of the above files. There were made on a VAX, so the block
Xsizes will be off by a factor of 2, but the sums should be ok.
X39677 11 ar.c
X38334 1 basename.c
X00126 2 cat.c
X15390 11 cc.c
X00802 3 cp.c
X36999 4 cpdir.c
X01111 3 df.c
X50498 6 diff.c
X19389 20 dosread.c
X42103 5 du.c
X09684 3 expr.c
X06369 29 find.c
X06970 4 fix.c
X01392 2 head.c
X21556 2 ln.c
X06704 2 login.c
X28118 13 ls.c
X03475 51 make.c
X50786 24 mkfs.c
X15911 5 more.c
X26091 4 mv.c
X50949 6 od.c
X53805 3 passwd.c
X16635 7 pr.c
X14023 2 pwd.c
X53130 15 readfs.c
X45906 3 rmdir.c
X04713 20 roff.c
X29787 2 split.c
X33176 10 tar.c
X57177 5 test.c
X15350 4 uudecode.c
X13877 2 uuencode.c
X30936 3 wc.c
X
X
+ END-OF-FILE READ_ME
chmod 'u=rw,g=r,o=r' \R\E\A\D\_\M\E
set `sum \R\E\A\D\_\M\E`
sum=$1
case $sum in
30564) :;;
*) echo 'Bad sum in '\R\E\A\D\_\M\E >&2
esac
echo Extracting \a\r\.\d\i\f\f
sed 's/^X//' > \a\r\.\d\i\f\f << '+ END-OF-FILE '\a\r\.\d\i\f\f
X244c244
X< ar_fd = open_archive(argv[2], (show_fl || pr_fl) ? READ : APPEND);
X---
X> ar_fd = open_archive(argv[2], (show_fl || pr_fl || ex_fl) ? READ : APPEND);
+ END-OF-FILE ar.diff
chmod 'u=rw,g=r,o=r' \a\r\.\d\i\f\f
set `sum \a\r\.\d\i\f\f`
sum=$1
case $sum in
26299) :;;
*) echo 'Bad sum in '\a\r\.\d\i\f\f >&2
esac
echo Extracting \b\a\s\e\n\a\m\e\.\d\i\f\f
sed 's/^X//' > \b\a\s\e\n\a\m\e\.\d\i\f\f << '+ END-OF-FILE '\b\a\s\e\n\a\m\e\.\d\i\f\f
X27c27
X< prints("%s \n",d);
X---
X> prints("%s\n",d);
X35,36c35,36
X< prints("%s \n",c);
X< }
X---
X> prints("%s\n",c);
X> }
+ END-OF-FILE basename.diff
chmod 'u=rw,g=r,o=r' \b\a\s\e\n\a\m\e\.\d\i\f\f
set `sum \b\a\s\e\n\a\m\e\.\d\i\f\f`
sum=$1
case $sum in
07740) :;;
*) echo 'Bad sum in '\b\a\s\e\n\a\m\e\.\d\i\f\f >&2
esac
echo Extracting \c\a\t\.\d\i\f\f
sed 's/^X//' > \c\a\t\.\d\i\f\f << '+ END-OF-FILE '\c\a\t\.\d\i\f\f
X86c86
X< if (write(1, buffer, next - buffer) <= 0) quit();
X---
X> if (write(1, buffer, (int) (next - buffer)) <= 0) quit();
+ END-OF-FILE cat.diff
chmod 'u=rw,g=r,o=r' \c\a\t\.\d\i\f\f
set `sum \c\a\t\.\d\i\f\f`
sum=$1
case $sum in
13846) :;;
*) echo 'Bad sum in '\c\a\t\.\d\i\f\f >&2
esac
echo Extracting \c\c\.\d\i\f\f
sed 's/^X//' > \c\c\.\d\i\f\f << '+ END-OF-FILE '\c\c\.\d\i\f\f
X1,5c1,6
X< /* $Header: cc.c,v 1.2 86/08/26 09:40:10 erikb Locked $
X< Driver for the CEMCOM compiler: works like /bin/cc and accepts the
X< options accepted by /bin/cc and /usr/em/bin/ack.
X< Derived from: "cem.c,v 1.5 86/01/20 11:10:29 erikb Exp"
X<
X---
X> /*
X> Driver for the CEMCOM compiler.
X> Derived from: "cem.c,v 1.5 86/01/20 11:10:29 erikb Exp"
X> Author: Erik Baalbergen
X>
X> Log:
X14c15
X< Author: Erik Baalbergen
X---
X> Various minor corrections for MINIX (Mar 18, 1987)
X30c31
X< !!!!_SEE_BELOW_!!!
X---
X> !!!!_SEE_BELOW_!!!
X42c43
X< /* #define MEM640K */
X---
X> /* #define MEM640K */
X67,69d67
X< /* object sizes */
X< char *V_FLAG = "-Vs2.2w2.2i2.2l4.2f4.2d8.2p2.2";
X<
X84a83
X>
X190,195d188
X< case 'L':
X< if (strcmp(&str[1], "LIB") == 0) {
X< append(&OPT_FLAGS, "-L");
X< break;
X< }
X< /*FALLTHROUGH*/
X204a198
X> append(&ASLD_FLAGS, str);
X211,212c205,211
X<
X< default:
X---
X> case 'L':
X> if (strcmp(&str[1], "LIB") == 0) {
X> append(&OPT_FLAGS, "-L");
X> break;
X> }
X> /*FALLTHROUGH*/
X> default: /* -i goes here! */
X218a218
X> append(&CEM_FLAGS, "-L"); /* disable profiling */
X254d253
X< append(call1, V_FLAG);
X274d272
X< append(call, V_FLAG);
X417,420c415,421
X< if (*--p1 == '.')
X< *p1 = '\0';
X< while (*dst++ = *p2++);
X< *p1 = '.';
X---
X> if (*--p1 == '.') {
X> *p1 = '\0';
X> while (*dst++ = *p2++);
X> *p1 = '.';
X> }
X> else
X> while (*dst++ = *p2++);
+ END-OF-FILE cc.diff
chmod 'u=rw,g=r,o=r' \c\c\.\d\i\f\f
set `sum \c\c\.\d\i\f\f`
sum=$1
case $sum in
62048) :;;
*) echo 'Bad sum in '\c\c\.\d\i\f\f >&2
esac
echo Extracting \c\p\.\d\i\f\f
sed 's/^X//' > \c\p\.\d\i\f\f << '+ END-OF-FILE '\c\p\.\d\i\f\f
X47a48
X> exit(0);
+ END-OF-FILE cp.diff
chmod 'u=rw,g=r,o=r' \c\p\.\d\i\f\f
set `sum \c\p\.\d\i\f\f`
sum=$1
case $sum in
31554) :;;
*) echo 'Bad sum in '\c\p\.\d\i\f\f >&2
esac
echo Extracting \d\f\.\d\i\f\f
sed 's/^X//' > \d\f\.\d\i\f\f << '+ END-OF-FILE '\d\f\.\d\i\f\f
X37d36
X< extern char *itoa();
X133a133
X> return(0);
X146a147
X> extern char *itoa();
+ END-OF-FILE df.diff
chmod 'u=rw,g=r,o=r' \d\f\.\d\i\f\f
set `sum \d\f\.\d\i\f\f`
sum=$1
case $sum in
26779) :;;
*) echo 'Bad sum in '\d\f\.\d\i\f\f >&2
esac
echo Extracting \d\i\f\f\.\c
sed 's/^X//' > \d\i\f\f\.\c << '+ END-OF-FILE '\d\i\f\f\.\c
X/* diff - print differences between 2 files Author: Erik Baalbergen */
X
X/* Poor man's implementation of diff(1)
X - no options available
X - may give more output than other diffs, due to the straight-forward algorithm
X - runs out of memory if the differing chunks become too large
X - input line length should not exceed LINELEN; longer lines are truncated,
X while only the first LINELEN characters are compared
X
X Please report bugs and suggestions to erikb@cs.vu.nl
X*/
X#include "stdio.h"
XFILE *fopen();
X
X#define LINELEN 128
X
Xchar *prog;
Xint diffs = 0;
X
Xmain(argc, argv)
X char **argv;
X{
X FILE *fp1 = NULL, *fp2 = NULL;
X
X prog = *argv++;
X if (argc != 3)
X fatal("use: %s file1 file2", prog);
X if (strcmp(argv[0], "-") == 0)
X fp1 = stdin;
X else
X if (strcmp(argv[1], "-") == 0)
X fp2 = stdin;
X if (fp1 == NULL && (fp1 = fopen(argv[0], "r")) == NULL)
X fatal("can't read %s", argv[0]);
X if (fp2 == NULL && (fp2 = fopen(argv[1], "r")) == NULL)
X fatal("can't read %s", argv[1]);
X diff(fp1, fp2);
X exit(diffs > 0);
X}
X
Xfatal(fmt, s)
X char *fmt, *s;
X{
X fprintf(stderr, "%s: ", prog);
X fprintf(stderr, fmt, s);
X fprintf(stderr, "\n");
X exit(2);
X}
X
X/* the line module */
Xchar *malloc();
Xchar *fgets();
X
Xstruct line {
X struct line *l_next;
X char l_text[LINELEN + 2];
X};
X
Xstruct line *freelist = 0;
X
Xstruct line *
Xnew_line()
X{
X register struct line *l;
X
X if (l = freelist)
X freelist = freelist->l_next;
X else
X if ((l = (struct line *)malloc(sizeof(struct line))) == 0)
X fatal("out of memory");
X return l;
X}
X
Xfree_line(l)
X register struct line *l;
X{
X l->l_next = freelist;
X freelist = l;
X}
X
X#define equal_line(l1, l2) (strcmp((l1)->l_text, (l2)->l_text) == 0)
X
Xint equal_3(l1, l2)
X struct line *l1, *l2;
X{
X register int i;
X
X for (i=0; i<3 && l1 && l2; ++i, l1=l1->l_next, l2=l2->l_next) {
X if (!equal_line(l1, l2))
X return 0;
X }
X return (i==3);
X}
X
Xstruct line *
Xread_line(fp)
X FILE *fp;
X{
X register struct line *l = new_line();
X register char *p;
X register int c;
X
X (p = &(l->l_text[LINELEN]))[1] = '\377';
X if (fgets(l->l_text, LINELEN + 2, fp) == NULL) {
X free_line(l);
X return 0;
X }
X if (p[1] != '\377' && *p != '\n') {
X while ((c = fgetc(fp)) != '\n' && c != EOF) {}
X *p++ = '\n';
X *p = '\0';
X }
X l->l_next = 0;
X return l;
X}
X
X/* file window handler */
Xstruct f {
X struct line *f_bwin, *f_ewin;
X struct line *f_aside;
X int f_linecnt; /* line number in file of last advanced line */
X FILE *f_fp;
X};
X
Xadvance(f)
X register struct f *f;
X{
X register struct line *l;
X
X if (l = f->f_bwin) {
X if (f->f_ewin == l)
X f->f_bwin = f->f_ewin = 0;
X else
X f->f_bwin = l->l_next;
X free_line(l);
X (f->f_linecnt)++;
X }
X}
X
Xaside(f, l)
X struct f *f;
X struct line *l;
X{
X register struct line *ll;
X
X if (ll = l->l_next) {
X while (ll->l_next)
X ll = ll->l_next;
X ll->l_next = f->f_aside;
X f->f_aside = l->l_next;
X l->l_next = 0;
X f->f_ewin = l;
X }
X}
X
Xstruct line *
Xnext(f)
X register struct f *f;
X{
X register struct line *l;
X
X if (l = f->f_aside) {
X f->f_aside = l->l_next;
X l->l_next = 0;
X }
X else
X l = read_line(f->f_fp);
X if (l) {
X if (f->f_bwin == 0)
X f->f_bwin = f->f_ewin = l;
X else {
X f->f_ewin->l_next = l;
X f->f_ewin = l;
X }
X }
X return l;
X}
X
Xinit_f(f, fp)
X register struct f *f;
X FILE *fp;
X{
X f->f_bwin = f->f_ewin = f->f_aside = 0;
X f->f_linecnt = 0;
X f->f_fp = fp;
X}
X
Xupdate(f, s)
X register struct f *f;
X char *s;
X{
X while (f->f_bwin && f->f_bwin != f->f_ewin) {
X printf("%s%s", s, f->f_bwin->l_text);
X advance(f);
X }
X}
X
X/* diff procedure */
Xdiff(fp1, fp2)
X FILE *fp1, *fp2;
X{
X struct f f1, f2;
X struct line *l1, *s1, *b1, *l2, *s2, *b2;
X register struct line *ll;
X
X init_f(&f1, fp1);
X init_f(&f2, fp2);
X l1 = next(&f1);
X l2 = next(&f2);
X while (l1 && l2) {
X if (equal_line(l1, l2)) {
Xequal:
X advance(&f1);
X advance(&f2);
X l1 = next(&f1);
X l2 = next(&f2);
X continue;
X }
X s1 = b1 = l1;
X s2 = b2 = l2;
X /* read several more lines */
X next(&f1); next(&f1);
X next(&f2); next(&f2);
X /* start searching */
Xsearch:
X if ((l2 = next(&f2)) == 0)
X continue;
X ll = s1;
X b2 = b2->l_next;
X do {
X if (equal_3(ll, b2)) {
X aside(&f1, ll);
X aside(&f2, b2);
X differ(&f1, &f2);
X goto equal;
X }
X } while (ll = ll->l_next);
X if ((l1 = next(&f1)) == 0)
X continue;
X ll = s2;
X b1 = b1->l_next;
X do {
X if (equal_3(ll, b1)) {
X aside(&f2, ll);
X aside(&f1, b1);
X differ(&f1, &f2);
X goto equal;
X }
X } while (ll = ll->l_next);
X goto search;
X }
X /* one of the files reached EOF */
X if (l1) /* eof on 2 */
X while (next(&f1)) {}
X if (l2)
X while (next(&f2)) {}
X f1.f_ewin = 0;
X f2.f_ewin = 0;
X differ(&f1, &f2);
X}
X
Xdiffer(f1, f2)
X register struct f *f1, *f2;
X{
X int cnt1 = f1->f_linecnt, len1 = wlen(f1), cnt2 = f2->f_linecnt,
X len2 = wlen(f2);
X
X if ((len1 = wlen(f1)) || (len2 = wlen(f2))) {
X if (len1 == 0) {
X printf("%da", cnt1);
X range(cnt2 + 1, cnt2 + len2);
X }
X else
X if (len2 == 0) {
X range(cnt1 + 1, cnt1 + len1);
X printf("d%d", cnt2);
X }
X else {
X range(cnt1 + 1, cnt1 + len1);
X putchar('c');
X range(cnt2 + 1, cnt2 + len2);
X }
X putchar('\n');
X if (len1)
X update(f1, "< ");
X if (len1 && len2)
X printf("---\n");
X if (len2)
X update(f2, "> ");
X diffs++;
X }
X}
X
Xwlen(f)
X struct f *f;
X{
X register cnt = 0;
X register struct line *l = f->f_bwin, *e = f->f_ewin;
X
X while (l && l != e) {
X cnt++;
X l = l->l_next;
X }
X return cnt;
X}
X
Xrange(a, b)
X{
X printf(((a == b) ? "%d" : "%d,%d"), a, b);
X}
+ END-OF-FILE diff.c
chmod 'u=rw,g=r,o=r' \d\i\f\f\.\c
set `sum \d\i\f\f\.\c`
sum=$1
case $sum in
50498) :;;
*) echo 'Bad sum in '\d\i\f\f\.\c >&2
esac
echo Extracting \d\o\s\r\e\a\d\.\d\i\f\f
sed 's/^X//' > \d\o\s\r\e\a\d\.\d\i\f\f << '+ END-OF-FILE '\d\o\s\r\e\a\d\.\d\i\f\f
X16c16
X< #define DRIVE "/dev/fdX"
X---
X> #define DRIVE "/dev/atX"
X279c279
X< while (*pathname != '/' && *pathname && i < 11)
X---
X> while (*pathname != '/' && *pathname && i < 12)
X494,506c494,502
X< for (i = 0, ptr = name; i < 8 && *ptr != '.' && *ptr; i++)
X< entry->d_name[i] = *ptr++;
X< while (i < 8)
X< entry->d_name[i++] = ' ';
X< r = strlen(name);
X< while (r && name[r - 1] != '.')
X< r--;
X<
X< i = 0;
X< while (r && i < 3 && name[r])
X< entry->d_ext[i++] = name[r++];
X< while (i < 3)
X< entry->d_ext[i++] = ' ';
X---
X> bcopy(" ",&entry->d_name[0],11); /* clear entry */
X> for (i = 0, ptr = name; i < 8 && *ptr != '.' && *ptr; i++)
X> entry->d_name[i] = *ptr++;
X> while (*ptr != '.' && *ptr)
X> ptr++;
X> if (*ptr == '.')
X> ptr++;
X> for (i=0;i < 3 && *ptr; i++)
X> entry->d_ext[i] = *ptr++;
X584c580
X< day -= mon_len[i];
X---
X> day -= mon_len[i++];
X641c637
X< return (buffer - begin);
X---
X> return (int) (buffer - begin);
X819c815
X< write(2, buf, buf_ptr - buf);
X---
X> write(2, buf, (int) (buf_ptr - buf));
+ END-OF-FILE dosread.diff
chmod 'u=rw,g=r,o=r' \d\o\s\r\e\a\d\.\d\i\f\f
set `sum \d\o\s\r\e\a\d\.\d\i\f\f`
sum=$1
case $sum in
27353) :;;
*) echo 'Bad sum in '\d\o\s\r\e\a\d\.\d\i\f\f >&2
esac
echo Extracting \h\e\a\d\.\d\i\f\f
sed 's/^X//' > \h\e\a\d\.\d\i\f\f << '+ END-OF-FILE '\h\e\a\d\.\d\i\f\f
X1a2,3
X> /* change to use putc() instead of prints() -- Dean Long 3/7/87 */
X>
X8d9
X< char lbuf[256];
X43,44c44,47
X< else
X< do_file(n);
X---
X> else {
X> do_file(n);
X> fflush(stdout);
X> }
X48d50
X< fflush(stdout);
X57,58c59,70
X< /* Print the first 'n' lines of a file. */
X< while (n--) do_line();
X---
X> int c;
X>
X> /* Print the first 'n' lines of a file. */
X> while(n)
X> switch (c = getc(stdin)) {
X> case EOF :
X> return;
X> case '\n':
X> --n;
X> default :
X> putc((char)c, stdout);
X> }
X62,80c74,79
X< do_line()
X< {
X< /* Print one line. */
X<
X< char c, *cp;
X< cp = lbuf;
X< while ( (c = getc(stdin)) != '\n') *cp++ = c;
X< *cp++ = '\n';
X< *cp++ = 0;
X< prints("%s",lbuf);
X< }
X<
X<
X< usage()
X< {
X< std_err("Usage: head [-n] [file ...]\n");
X< exit(1);
X< }
X<
X---
X> usage()
X> {
X> std_err("Usage: head [-n] [file ...]\n");
X> exit(1);
X> }
X>
+ END-OF-FILE head.diff
chmod 'u=rw,g=r,o=r' \h\e\a\d\.\d\i\f\f
set `sum \h\e\a\d\.\d\i\f\f`
sum=$1
case $sum in
26082) :;;
*) echo 'Bad sum in '\h\e\a\d\.\d\i\f\f >&2
esac
echo Extracting \l\n\.\d\i\f\f
sed 's/^X//' > \l\n\.\d\i\f\f << '+ END-OF-FILE '\l\n\.\d\i\f\f
X11a12
X> char *last_comp();
+ END-OF-FILE ln.diff
chmod 'u=rw,g=r,o=r' \l\n\.\d\i\f\f
set `sum \l\n\.\d\i\f\f`
sum=$1
case $sum in
44606) :;;
*) echo 'Bad sum in '\l\n\.\d\i\f\f >&2
esac
echo Extracting \l\o\g\i\n\.\d\i\f\f
sed 's/^X//' > \l\o\g\i\n\.\d\i\f\f << '+ END-OF-FILE '\l\o\g\i\n\.\d\i\f\f
X55,57c55,57
X< execl(pwd->pw_shell, "-", 0);
X< }
X< execl("/bin/sh", "-", 0);
X---
X> execl(pwd->pw_shell, "-", (char *) 0);
X> }
X> execl("/bin/sh", "-", (char *) 0);
+ END-OF-FILE login.diff
chmod 'u=rw,g=r,o=r' \l\o\g\i\n\.\d\i\f\f
set `sum \l\o\g\i\n\.\d\i\f\f`
sum=$1
case $sum in
14607) :;;
*) echo 'Bad sum in '\l\o\g\i\n\.\d\i\f\f >&2
esac
echo Extracting \l\s\.\d\i\f\f
sed 's/^X//' > \l\s\.\d\i\f\f << '+ END-OF-FILE '\l\s\.\d\i\f\f
X359c359,366
X< fprintf(stdout, "%s\n",fp->name);
X---
X> m = 0;
X> p1 = fp->name;
X> while (*p1 != 0 && (m < DIRNAMELEN || *p1 == '/') ) {
X> fprintf(stdout, "%c", *p1);
X> m = (*p1 == '/' ? 0 : m + 1);
X> p1++;
X> }
X> fprintf(stdout, "\n");
+ END-OF-FILE ls.diff
chmod 'u=rw,g=r,o=r' \l\s\.\d\i\f\f
set `sum \l\s\.\d\i\f\f`
sum=$1
case $sum in
63056) :;;
*) echo 'Bad sum in '\l\s\.\d\i\f\f >&2
esac
echo Extracting \m\a\k\e\.\d\i\f\f
sed 's/^X//' > \m\a\k\e\.\d\i\f\f << '+ END-OF-FILE '\m\a\k\e\.\d\i\f\f
X153c153
X< /* sysV and MONIX and LATTICE */
X---
X> /* sysV and MINIX and LATTICE */
X1899c1899
X< execl(SHELL,"sh","-c",cmd,0);
X---
X> execl(SHELL, "sh", "-c", cmd, (char *) 0);
+ END-OF-FILE make.diff
chmod 'u=rw,g=r,o=r' \m\a\k\e\.\d\i\f\f
set `sum \m\a\k\e\.\d\i\f\f`
sum=$1
case $sum in
25797) :;;
*) echo 'Bad sum in '\m\a\k\e\.\d\i\f\f >&2
esac
echo Extracting \m\k\f\s\.\d\i\f\f
sed 's/^X//' > \m\k\f\s\.\d\i\f\f << '+ END-OF-FILE '\m\k\f\s\.\d\i\f\f
X5c5
X< * with blocksize = zonesize. During the course of action the
X---
X> * with blocksize = zonesize. During the course of time the
X10,12c10,12
X< * To compile this program for MS-DOS, say cc -DDOS mkfs.c diskio.asm
X< * To compile this program for UNIX, say cc -DUNIX mkfs.c
X< * To compile this program for MINIX, say cc mkfs.c
X---
X> * To compile this program for MS-DOS, use: cc -DDOS mkfs.c diskio.asm
X> * To compile this program for UNIX, use: cc -DUNIX mkfs.c
X> * To compile this program for MINIX, use: cc mkfs.c
X32a33,34
X> #undef major
X> #undef minor
X73,75c75,77
X< nrinodes, lct=1, disk, fd, print=0, file=0, override=0, simple=0;
X<
X< long current_time;
X---
X> nrinodes, lct=1, disk, fd, print=0, file=0, override=0, simple=0, dflag;
X>
X> long current_time, bin_time;
X106,108c108,119
X< /* process parameters and switches */
X<
X< current_time = time(0L);
X---
X>
X> /* Get two times, the current time and the mod time of the binary of
X> * mkfs itself. When the -d flag is used, the later time is put into
X> * the i_modtimes of all the files. This feature is useful when producing
X> * a set of file systems, and one wants all the times to be identical.
X> * First you set the time of the mkfs binary to what you want, then go.
X> */
X> current_time = time(0L); /* time mkfs is being run */
X> stat(argv[0], &statbuf);
X> bin_time = statbuf.st_mtime; /* time when mkfs binary was last modified */
X>
X> /* process parameters and switches */
X128c139,140
X< default :
X---
X> case 'd' : current_time = bin_time; dflag=1; break;
X> default :
X364a377
X> long timeval;
X375c388,389
X< if (ct) add_zone (inode, z, (long) j, file_time(f) );
X---
X> timeval = (dflag ? current_time : file_time(f) );
X> if (ct) add_zone (inode, z, (long) j, timeval );
X448c462,463
X< int b, off, blk[INTS_PER_BLOCK], indir, i;
X---
X> int b, off, indir, i;
X> zone_nr blk[NR_INDIRECTS];
X472,474c487,489
X< for (i = 0; i < INTS_PER_BLOCK; i++)
X< if (blk[i] == 0) {
X< blk[i] = z;
X---
X> for (i = 0; i < NR_INDIRECTS; i++)
X> if (blk[i] == 0) {
X> blk[i] = (zone_nr) z;
X622c637
X< for (k = 0; k < MAX_TOKEN; k++) parse[k] = 0;
X---
X> for (k = 0; k < MAX_TOKENS; k++) parse[k] = 0;
+ END-OF-FILE mkfs.diff
chmod 'u=rw,g=r,o=r' \m\k\f\s\.\d\i\f\f
set `sum \m\k\f\s\.\d\i\f\f`
sum=$1
case $sum in
07826) :;;
*) echo 'Bad sum in '\m\k\f\s\.\d\i\f\f >&2
esac
echo Extracting \m\v\.\d\i\f\f
sed 's/^X//' > \m\v\.\d\i\f\f << '+ END-OF-FILE '\m\v\.\d\i\f\f
X1c1,4
X< /* mv - move files Author: Adri Koppes */
X---
X> /* mv - move files Author: Adri Koppes
X> *
X> * 4/25/87 - J. Paradis Bug fixes for directory handling
X> */
X7c10
X< struct stat st;
X---
X> struct stat st, st1;
X26,37c29,32
X< if ((st.st_mode & S_IFMT) == S_IFDIR) {
X< if (!stat(argv[2], &st) && (st.st_mode & S_IFMT) == S_IFDIR) {
X< std_err ("mv: target ");
X< std_err (argv[2]);
X< std_err (" exists\n");
X< exit (1);
X< }
X< }
X< else {
X< setgid (getgid ());
X< setuid (getuid ());
X< }
X---
X>
X> setgid (getgid ());
X> setuid (getuid ());
X>
X67a63,73
X> char name[64];
X>
X> /* It's too dangerous to fool with "." or ".." ! */
X> if((strcmp(old, ".") == 0) || (strcmp(old, "..") == 0)) {
X> cant(old);
X> }
X>
X> /* Don't move a file to itself. */
X> if (stat(old, &st)==0 && stat(new, &st1)==0 && st.st_dev == st1.st_dev &&
X> st.st_ino == st1.st_ino)
X> cant(old);
X73c79
X< char name[64], *p, *rindex();
X---
X> char *p, *rindex();
X91c97
X< execl ("/bin/cp", "cp", old, new, 0);
X---
X> execl ("/bin/cp", "cp", old, new, (char *) 0);
X103,114c109,164
X< utime (new, &st.st_atime);
X< unlink(old);
X< }
X<
X< cant(name)
X< char *name;
X< {
X< std_err("mv: can't move ");
X< std_err (name);
X< std_err ("\n");
X< exit (1);
X< }
X---
X>
X> /* If this was a directory that we moved, then we have
X> ** to update its ".." entry (in case it was moved some-
X> ** where else in the tree...)
X> */
X> if ((st.st_mode & S_IFMT) == S_IFDIR) {
X> int i;
X> char parent[64], dotdot[64];
X>
X> strcpy(parent, new);
X>
X> /* Determine the name for the parent of
X> ** the new name by counting back until we
X> ** hit a '/' or the begining of the string
X> */
X>
X> for(i = (strlen(parent) - 1); i > 0; i--) {
X> if(parent[i] == '/') break;
X> }
X>
X> /* If there are no slashes, then the name is
X> ** in the current directory, so its parent
X> ** is ".". Otherwise, the parent is the name
X> ** up to the last slash.
X> */
X> if(i == 0) {
X> strcpy(parent, ".");
X> }
X> else {
X> /* null-terminate name at last slash */
X> parent[i] = '\0';
X> }
X>
X> /* Unlink the ".." entry */
X> strcpy(dotdot, new);
X> strcat(dotdot, "/..");
X> unlink(dotdot);
X>
X> /* Now link it to its parent */
X> link(parent, dotdot);
X> }
X>
X> utime (new, &st.st_atime);
X> unlink(old);
X> }
X>
X> cant(name)
X> char *name;
X> {
X> std_err("mv: can't move ");
X> std_err (name);
X> std_err ("\n");
X> exit (1);
X> }
X>
X>
+ END-OF-FILE mv.diff
chmod 'u=rw,g=r,o=r' \m\v\.\d\i\f\f
set `sum \m\v\.\d\i\f\f`
sum=$1
case $sum in
56999) :;;
*) echo 'Bad sum in '\m\v\.\d\i\f\f >&2
esac
echo Extracting \o\d\.\d\i\f\f
sed 's/^X//' > \o\d\.\d\i\f\f << '+ END-OF-FILE '\o\d\.\d\i\f\f
X26c26
X< if (*p == '-') {
X---
X> if (argc > 1 && *p == '-') {
X168,169c168,169
X< bdump(words, k, c)
X< int words[8];
X---
X> bdump(bytes, k, c)
X> char bytes[16];
X174,186c174,176
X< int c1, c2;
X<
X< i = 0;
X< if (linenr++ != 1) printf(" ");
X< while (i < k) {
X< c1 = words[i>>1] & 0377;
X< c2 = (words[i>>1]>>8) & 0377;
X< byte(c1, c);
X< i++;
X< if (i == k) {printf("\n"); return;}
X< byte(c2, c);
X< i++;
X< }
X---
X>
X> if (linenr++ != 1) printf(" ");
X> for (i = 0; i < k; i++) byte(bytes[i] & 0377, c);
+ END-OF-FILE od.diff
chmod 'u=rw,g=r,o=r' \o\d\.\d\i\f\f
set `sum \o\d\.\d\i\f\f`
sum=$1
case $sum in
27139) :;;
*) echo 'Bad sum in '\o\d\.\d\i\f\f >&2
esac
echo Extracting \p\a\s\s\w\d\.\d\i\f\f
sed 's/^X//' > \p\a\s\s\w\d\.\d\i\f\f << '+ END-OF-FILE '\p\a\s\s\w\d\.\d\i\f\f
X50a51,54
X> if (password[0] == '\0') {
X> std_err("password cannot be null\n");
X> exit(1);
X> }
+ END-OF-FILE passwd.diff
chmod 'u=rw,g=r,o=r' \p\a\s\s\w\d\.\d\i\f\f
set `sum \p\a\s\s\w\d\.\d\i\f\f`
sum=$1
case $sum in
08089) :;;
*) echo 'Bad sum in '\p\a\s\s\w\d\.\d\i\f\f >&2
esac
echo Extracting \p\r\.\d\i\f\f
sed 's/^X//' > \p\r\.\d\i\f\f << '+ END-OF-FILE '\p\r\.\d\i\f\f
X257,259c257,260
X< do {
X< putchar(c);
X< } while ((c = getc(filep)) != '\n' && c != EOF);
X---
X> while (c != '\n' && c != EOF) {
X> putchar(c);
X> c = getc(filep);
X> }
+ END-OF-FILE pr.diff
chmod 'u=rw,g=r,o=r' \p\r\.\d\i\f\f
set `sum \p\r\.\d\i\f\f`
sum=$1
case $sum in
02036) :;;
*) echo 'Bad sum in '\p\r\.\d\i\f\f >&2
esac
echo Extracting \p\w\d\.\d\i\f\f
sed 's/^X//' > \p\w\d\.\d\i\f\f << '+ END-OF-FILE '\p\w\d\.\d\i\f\f
X12c12,13
X< register char name[128], *n;
X---
X> register *n;
X> char name[128];
+ END-OF-FILE pwd.diff
chmod 'u=rw,g=r,o=r' \p\w\d\.\d\i\f\f
set `sum \p\w\d\.\d\i\f\f`
sum=$1
case $sum in
20465) :;;
*) echo 'Bad sum in '\p\w\d\.\d\i\f\f >&2
esac
echo Extracting \r\m\d\i\r\.\d\i\f\f
sed 's/^X//' > \r\m\d\i\r\.\d\i\f\f << '+ END-OF-FILE '\r\m\d\i\r\.\d\i\f\f
X1c1,3
X< /* rmdir - remove a directory Author: Adri Koppes */
X---
X> /* rmdir - remove a directory Author: Adri Koppes
X> * (modified by Paul Polderman)
X> */
X29a32,33
X> extern char *rindex();
X>
X37a42
X> register char *p;
X49,55c54,60
X< strcpy (dots, dirname);
X< while (dirname[fd])
X< if (dirname[fd++] == '/')
X< sl = fd;
X< dots[sl] = '\0';
X< if (access (dots, 2)) {
X< stderr2(dirname, " no permission\n");
X---
X> if (p = rindex(dirname, '/'))
X> p++;
X> else
X> p = dirname;
X>
X> if (strcmp(p, ".") == 0 || strcmp(p, "..") == 0) {
X> stderr2(dirname, " will not remove \".\" or \"..\"\n");
X59,61c64,71
X< stat ("", &cwd);
X< if ((s.st_ino == cwd.st_ino) && (s.st_dev == cwd.st_dev)) {
X< std_err ("rmdir: can't remove current directory\n");
X---
X>
X> strcpy (dots, dirname);
X> while (dirname[fd])
X> if (dirname[fd++] == '/')
X> sl = fd;
X> dots[sl] = '\0';
X> if (access (dots, 2)) {
X> stderr2(dirname, " no permission\n");
X65,67c75,77
X< if ((fd = open (dirname, 0)) < 0) {
X< stderr2("can't read ", dirname);
X< std_err("\n");
X---
X> stat ("", &cwd);
X> if ((s.st_ino == cwd.st_ino) && (s.st_dev == cwd.st_dev)) {
X> std_err ("rmdir: can't remove current directory\n");
X70a81,86
X> if ((fd = open (dirname, 0)) < 0) {
X> stderr2("can't read ", dirname);
X> std_err("\n");
X> error++;
X> return;
X> }
X81,86c97,106
X< strcat (dots, "/.");
X< unlink (dots);
X< strcat (dots, ".");
X< unlink (dots);
X< if (unlink (dirname)) {
X< stderr2("can't remove ", dirname);
X---
X> strcat (dots, "/..");
X> patch_path(dots);
X> for (p = dots; *p; p++) /* find end of dots */
X> ;
X> unlink(dots); /* dirname/.. */
X> *(p - 1) = '\0';
X> unlink(dots); /* dirname/. */
X> *(p - 3) = '\0';
X> if (unlink(dots)) { /* dirname */
X> stderr2("can't remove ", dots);
X99a120,148
X>
X> patch_path(dir)
X> char *dir; /* pathname ending with "/.." */
X> {
X> register char *p, *s;
X> struct stat pst, st;
X>
X> if (stat(dir, &pst) < 0)
X> return;
X> p = dir;
X> while (*p == '/') p++;
X> while (1) {
X> s = p; /* remember start of new pathname part */
X> while (*p && *p != '/')
X> p++; /* find next slash */
X> if (*p == '\0')
X> return; /* if end of pathname, return */
X>
X> /* check if this part of pathname == the original pathname */
X> *p = '\0';
X> stat(dir, &st);
X> if (st.st_ino == pst.st_ino && st.st_dev == pst.st_dev
X> && strcmp(s, "..") == 0)
X> return;
X> /* if not, try next part */
X> *p++ = '/';
X> while (*p == '/') p++;
X> }
X> }
+ END-OF-FILE rmdir.diff
chmod 'u=rw,g=r,o=r' \r\m\d\i\r\.\d\i\f\f
set `sum \r\m\d\i\r\.\d\i\f\f`
sum=$1
case $sum in
26410) :;;
*) echo 'Bad sum in '\r\m\d\i\r\.\d\i\f\f >&2
esac
echo Extracting \r\o\f\f\.\d\i\f\f
sed 's/^X//' > \r\o\f\f\.\d\i\f\f << '+ END-OF-FILE '\r\o\f\f\.\d\i\f\f
X1c1,16
X< /* roff - text justifier Author: George Sicherman */
X---
X> /* roff - text justifier Author: George L. Sicherman */
X>
X> /*
X> * roff - C version.
X> * the Colonel. 19 May 1983.
X> *
X> * Copyright 1983 by G. L. Sicherman.
X> * You may use and alter this software freely for noncommercial ends
X> * so long as you leave this message alone.
X> *
X> * Fix by Tim Maroney, 31 Dec 1984.
X> * .hc implemented, 8 Feb 1985.
X> * Fix to hyphenating with underlining, 12 Feb 1985.
X> * Fixes to long-line hang and .bp by Dave Tutelman, 30 Mar 1985.
X> * Fix to centering valve with long input lines, 4 May 1987.
X> */
X14,16c29,32
X< #define UNDERL 0200
X<
X< char cumbuf[BUFSIZ];
X---
X> #define UNDERL '\200'
X>
X> char cumbuf[BUFSIZ];
X>
X48d63
X< int center = 0;
X67d81
X<
X120d133
X< done(0);
X128,130c141,143
X< char *ttyname();
X<
X< /* This routine is not needed --
X---
X> /* This routine is not needed.
X> char *ttyname();
X>
X138c151
X< */
X---
X> * ------- end of mesg */
X145,147c158,161
X< if (center || !o_fi) {
X< if (assylen) writeline(0,1);
X< else blankline();
X---
X> if (o_ce || !o_fi) {
X> if (assylen) writeline(0,1);
X> else blankline();
X> if (o_ce) o_ce--;
X213,214d226
X< center=o_ce;
X< if (o_ce) o_ce--;
X227a240,243
X> * Tutelman's fix #1, modified by the Colonel.
X> */
X> if (!o_fi || o_ce) goto giveup;
X> /*
X242c258
X< if (*hc!=o_hc) continue;
X---
X> if ((*hc&~UNDERL)!=o_hc) continue;
X293c309
X< for (t=s; *s; s++) if (*s != o_hc) *t++ = *s;
X---
X> for (t=s; *s; s++) if ((*s&~UNDERL) != o_hc) *t++ = *s;
X307c323
X< while (*s) n += (o_hc != *s++);
X---
X> while (*s) n += (o_hc != (~UNDERL & *s++));
X372,373c388,392
X< if (s>0) o_bp=page_no-r;
X< else if (s<0) o_bp=page_no+r;
X---
X> /*
X> * Tutelman's fix #2 - the signs were reversed!
X> */
X> if (s>0) o_bp=page_no+r;
X> else if (s<0) o_bp=page_no-r;
X388,389c407,412
X< nread(&o_ce);
X< writebreak();
X---
X> /*
X> * Fix to centering. Set counter _after_ breaking! --G.L.S.
X> */
X> nread(&r);
X> writebreak();
X> o_ce = r;
X735c758
X< if (c==EOF || c=='\n') break;;
X---
X> if (c==EOF || c=='\n') break;
X836c859
X< if (center) for (j=0; j<(o_ll-assylen+1)/2; j++) spit(' ');
X---
X> if (o_ce) for (j=0; j<(o_ll-assylen+1)/2; j++) spit(' ');
X1085c1108,1111
X< c = *t;
X---
X> /*
X> * fix - last char translates to space.
X> */
X> c = *t? *t: ' ';
X1123,1125c1149
X< * strhas - does string have character?
X< * USG and BSD both have this in their libraries. Now, if
X< * they could just agree on the name of the function ...
X---
X> * strhas - does string have character? Allow UNDERL flag.
X1132c1156
X< for (; *p; p++) if (*p==c) return p;
X---
X> for (; *p; p++) if ((*p&~UNDERL)==c) return p;
+ END-OF-FILE roff.diff
chmod 'u=rw,g=r,o=r' \r\o\f\f\.\d\i\f\f
set `sum \r\o\f\f\.\d\i\f\f`
sum=$1
case $sum in
00785) :;;
*) echo 'Bad sum in '\r\o\f\f\.\d\i\f\f >&2
esac
echo Extracting \s\p\l\i\t\.\d\i\f\f
sed 's/^X//' > \s\p\l\i\t\.\d\i\f\f << '+ END-OF-FILE '\s\p\l\i\t\.\d\i\f\f
X66c66
X< if (write(fd, base, index-base) != index-base)
X---
X> if (write(fd,base,(int)(index-base)) != (int)(index-base))
X73c73
X< if (write(fd, base, index - base) != index - base) quit();
X---
X> if (write(fd, base, (int) (index-base)) != (int) (index-base)) quit();
+ END-OF-FILE split.diff
chmod 'u=rw,g=r,o=r' \s\p\l\i\t\.\d\i\f\f
set `sum \s\p\l\i\t\.\d\i\f\f`
sum=$1
case $sum in
15949) :;;
*) echo 'Bad sum in '\s\p\l\i\t\.\d\i\f\f >&2
esac
echo Extracting \t\a\r\.\d\i\f\f
sed 's/^X//' > \t\a\r\.\d\i\f\f << '+ END-OF-FILE '\t\a\r\.\d\i\f\f
X60a61,62
X> char path[NAME_SIZE];
X> char pathname[NAME_SIZE];
X111,112c113,116
X< for (i = 3; i < argc; i++)
X< add_file(argv[i]);
X---
X> for (i = 3; i < argc; i++) {
X> add_file(argv[i]);
X> path[0] = '\0';
X> }
X248c252
X< execl(MKDIR, "mkdir", dir_name, 0);
X---
X> execl(MKDIR, "mkdir", dir_name, (char *) 0);
X281,283c285
X< char path[NAME_SIZE];
X<
X< char pathname[NAME_SIZE];
X---
X>
+ END-OF-FILE tar.diff
chmod 'u=rw,g=r,o=r' \t\a\r\.\d\i\f\f
set `sum \t\a\r\.\d\i\f\f`
sum=$1
case $sum in
59243) :;;
*) echo 'Bad sum in '\t\a\r\.\d\i\f\f >&2
esac
echo Extracting \w\c\.\d\i\f\f
sed 's/^X//' > \w\c\.\d\i\f\f << '+ END-OF-FILE '\w\c\.\d\i\f\f
X55c55
X< if (*cp++ == '-') {
X---
X> if (argc >1 && *cp++ == '-') {
+ END-OF-FILE wc.diff
chmod 'u=rw,g=r,o=r' \w\c\.\d\i\f\f
set `sum \w\c\.\d\i\f\f`
sum=$1
case $sum in
34156) :;;
*) echo 'Bad sum in '\w\c\.\d\i\f\f >&2
esac
echo Extracting \d\i\f\f\.\c
sed 's/^X//' > \d\i\f\f\.\c << '+ END-OF-FILE '\d\i\f\f\.\c
X/* diff - print differences between 2 files Author: Erik Baalbergen */
X
X/* Poor man's implementation of diff(1)
X - no options available
X - may give more output than other diffs, due to the straight-forward algorithm
X - runs out of memory if the differing chunks become too large
X - input line length should not exceed LINELEN; longer lines are truncated,
X while only the first LINELEN characters are compared
X
X Please report bugs and suggestions to erikb@cs.vu.nl
X*/
X#include "stdio.h"
XFILE *fopen();
X
X#define LINELEN 128
X
Xchar *prog;
Xint diffs = 0;
X
Xmain(argc, argv)
X char **argv;
X{
X FILE *fp1 = NULL, *fp2 = NULL;
X
X prog = *argv++;
X if (argc != 3)
X fatal("use: %s file1 file2", prog);
X if (strcmp(argv[0], "-") == 0)
X fp1 = stdin;
X else
X if (strcmp(argv[1], "-") == 0)
X fp2 = stdin;
X if (fp1 == NULL && (fp1 = fopen(argv[0], "r")) == NULL)
X fatal("can't read %s", argv[0]);
X if (fp2 == NULL && (fp2 = fopen(argv[1], "r")) == NULL)
X fatal("can't read %s", argv[1]);
X diff(fp1, fp2);
X exit(diffs > 0);
X}
X
Xfatal(fmt, s)
X char *fmt, *s;
X{
X fprintf(stderr, "%s: ", prog);
X fprintf(stderr, fmt, s);
X fprintf(stderr, "\n");
X exit(2);
X}
X
X/* the line module */
Xchar *malloc();
Xchar *fgets();
X
Xstruct line {
X struct line *l_next;
X char l_text[LINELEN + 2];
X};
X
Xstruct line *freelist = 0;
X
Xstruct line *
Xnew_line()
X{
X register struct line *l;
X
X if (l = freelist)
X freelist = freelist->l_next;
X else
X if ((l = (struct line *)malloc(sizeof(struct line))) == 0)
X fatal("out of memory");
X return l;
X}
X
Xfree_line(l)
X register struct line *l;
X{
X l->l_next = freelist;
X freelist = l;
X}
X
X#define equal_line(l1, l2) (strcmp((l1)->l_text, (l2)->l_text) == 0)
X
Xint equal_3(l1, l2)
X struct line *l1, *l2;
X{
X register int i;
X
X for (i=0; i<3 && l1 && l2; ++i, l1=l1->l_next, l2=l2->l_next) {
X if (!equal_line(l1, l2))
X return 0;
X }
X return (i==3);
X}
X
Xstruct line *
Xread_line(fp)
X FILE *fp;
X{
X register struct line *l = new_line();
X register char *p;
X register int c;
X
X (p = &(l->l_text[LINELEN]))[1] = '\377';
X if (fgets(l->l_text, LINELEN + 2, fp) == NULL) {
X free_line(l);
X return 0;
X }
X if (p[1] != '\377' && *p != '\n') {
X while ((c = fgetc(fp)) != '\n' && c != EOF) {}
X *p++ = '\n';
X *p = '\0';
X }
X l->l_next = 0;
X return l;
X}
X
X/* file window handler */
Xstruct f {
X struct line *f_bwin, *f_ewin;
X struct line *f_aside;
X int f_linecnt; /* line number in file of last advanced line */
X FILE *f_fp;
X};
X
Xadvance(f)
X register struct f *f;
X{
X register struct line *l;
X
X if (l = f->f_bwin) {
X if (f->f_ewin == l)
X f->f_bwin = f->f_ewin = 0;
X else
X f->f_bwin = l->l_next;
X free_line(l);
X (f->f_linecnt)++;
X }
X}
X
Xaside(f, l)
X struct f *f;
X struct line *l;
X{
X register struct line *ll;
X
X if (ll = l->l_next) {
X while (ll->l_next)
X ll = ll->l_next;
X ll->l_next = f->f_aside;
X f->f_aside = l->l_next;
X l->l_next = 0;
X f->f_ewin = l;
X }
X}
X
Xstruct line *
Xnext(f)
X register struct f *f;
X{
X register struct line *l;
X
X if (l = f->f_aside) {
X f->f_aside = l->l_next;
X l->l_next = 0;
X }
X else
X l = read_line(f->f_fp);
X if (l) {
X if (f->f_bwin == 0)
X f->f_bwin = f->f_ewin = l;
X else {
X f->f_ewin->l_next = l;
X f->f_ewin = l;
X }
X }
X return l;
X}
X
Xinit_f(f, fp)
X register struct f *f;
X FILE *fp;
X{
X f->f_bwin = f->f_ewin = f->f_aside = 0;
X f->f_linecnt = 0;
X f->f_fp = fp;
X}
X
Xupdate(f, s)
X register struct f *f;
X char *s;
X{
X while (f->f_bwin && f->f_bwin != f->f_ewin) {
X printf("%s%s", s, f->f_bwin->l_text);
X advance(f);
X }
X}
X
X/* diff procedure */
Xdiff(fp1, fp2)
X FILE *fp1, *fp2;
X{
X struct f f1, f2;
X struct line *l1, *s1, *b1, *l2, *s2, *b2;
X register struct line *ll;
X
X init_f(&f1, fp1);
X init_f(&f2, fp2);
X l1 = next(&f1);
X l2 = next(&f2);
X while (l1 && l2) {
X if (equal_line(l1, l2)) {
Xequal:
X advance(&f1);
X advance(&f2);
X l1 = next(&f1);
X l2 = next(&f2);
X continue;
X }
X s1 = b1 = l1;
X s2 = b2 = l2;
X /* read several more lines */
X next(&f1); next(&f1);
X next(&f2); next(&f2);
X /* start searching */
Xsearch:
X if ((l2 = next(&f2)) == 0)
X continue;
X ll = s1;
X b2 = b2->l_next;
X do {
X if (equal_3(ll, b2)) {
X aside(&f1, ll);
X aside(&f2, b2);
X differ(&f1, &f2);
X goto equal;
X }
X } while (ll = ll->l_next);
X if ((l1 = next(&f1)) == 0)
X continue;
X ll = s2;
X b1 = b1->l_next;
X do {
X if (equal_3(ll, b1)) {
X aside(&f2, ll);
X aside(&f1, b1);
X differ(&f1, &f2);
X goto equal;
X }
X } while (ll = ll->l_next);
X goto search;
X }
X /* one of the files reached EOF */
X if (l1) /* eof on 2 */
X while (next(&f1)) {}
X if (l2)
X while (next(&f2)) {}
X f1.f_ewin = 0;
X f2.f_ewin = 0;
X differ(&f1, &f2);
X}
X
Xdiffer(f1, f2)
X register struct f *f1, *f2;
X{
X int cnt1 = f1->f_linecnt, len1 = wlen(f1), cnt2 = f2->f_linecnt,
X len2 = wlen(f2);
X
X if ((len1 = wlen(f1)) || (len2 = wlen(f2))) {
X if (len1 == 0) {
X printf("%da", cnt1);
X range(cnt2 + 1, cnt2 + len2);
X }
X else
X if (len2 == 0) {
X range(cnt1 + 1, cnt1 + len1);
X printf("d%d", cnt2);
X }
X else {
X range(cnt1 + 1, cnt1 + len1);
X putchar('c');
X range(cnt2 + 1, cnt2 + len2);
X }
X putchar('\n');
X if (len1)
X update(f1, "< ");
X if (len1 && len2)
X printf("---\n");
X if (len2)
X update(f2, "> ");
X diffs++;
X }
X}
X
Xwlen(f)
X struct f *f;
X{
X register cnt = 0;
X register struct line *l = f->f_bwin, *e = f->f_ewin;
X
X while (l && l != e) {
X cnt++;
X l = l->l_next;
X }
X return cnt;
X}
X
Xrange(a, b)
X{
X printf(((a == b) ? "%d" : "%d,%d"), a, b);
X}
+ END-OF-FILE diff.c
chmod 'u=rw,g=r,o=r' \d\i\f\f\.\c
set `sum \d\i\f\f\.\c`
sum=$1
case $sum in
50498) :;;
*) echo 'Bad sum in '\d\i\f\f\.\c >&2
esac
echo Extracting \f\i\x\.\c
sed 's/^X//' > \f\i\x\.\c << '+ END-OF-FILE '\f\i\x\.\c
X/* fix - combine file and diff listing Author: Erik Baalbergen */
X
X/* Notes:
X * files old and old.fix are equal after the following commands
X diff old new > difflist
X fix old difflist > old.fix
X * the diff output is assumed to be produced by my diff program.
X * the difflist has the following form:
X difflist ::= chunk*
X chunk ::= append | delete | change ;
X append ::= n1 'a' n2 [',' n3]? '\n' ['> ' line '\n'](n3 - n2 + 1)
X delete ::= n1 [',' n2]? 'd' n3 '\n' ['< ' line '\n'](n2 - n1 + 1)
X change ::= n1 [',' n2]? 'c' n3 [',' n4]? '\n'
X ['< ' line '\n'](n2 - n1 + 1)
X '---\n'
X ['> ' line '\n'](n4 - n3 + 1)
X where
X - n[1234] is an unsigned integer
X - "[pat](expr)" means "(expr) occurences of pat"
X - "[pat]?" means "either pat or nothing"
X * the information in the diff listing is checked against the file to which
X it is applied; an error is printed if there is a conflict
X*/
X
X#include <stdio.h>
X
Xextern char *fgets();
Xextern FILE *fopen();
X#define LINELEN 1024
X
Xchar *prog = 0;
X
Xchar *
Xgetline(fp, b)
X FILE *fp;
X char *b;
X{
X if (fgets(b, LINELEN, fp) == NULL)
X fatal("unexpected eof");
X return b;
X}
X
X#define copy(str) printf("%s", str)
X
Xmain(argc, argv)
X char **argv;
X{
X char cmd, *fl, *fd, obuf[LINELEN], nbuf[LINELEN];
X int o1, o2, n1, n2, here;
X FILE *fpf, *fpd;
X
X prog = argv[0];
X if (argc != 3)
X fatal("use: %s original-file diff-list-file", prog);
X if ((fpf = fopen(argv[1], "r")) == NULL)
X fatal("can't read %s", argv[1]);
X if ((fpd = fopen(argv[2], "r")) == NULL)
X fatal("can't read %s", argv[2]);
X here = 0;
X while (getcommand(fpd, &o1, &o2, &cmd, &n1, &n2)) {
X while (here < o1 - 1) {
X here++;
X copy(getline(fpf, obuf));
X }
X switch (cmd) {
X case 'c':
X case 'd':
X if (cmd == 'd' && n1 != n2)
X fatal("delete count conflict");
X while (o1 <= o2) {
X fl = getline(fpf, obuf);
X here++;
X fd = getline(fpd, nbuf);
X if (strncmp(fd, "< ", 2))
X fatal("illegal delete line");
X if (strcmp(fl, fd + 2))
X fatal("delete line conflict");
X o1++;
X }
X if (cmd == 'd')
X break;
X if (strcmp(getline(fpd, nbuf), "---\n"))
X fatal("illegal separator in chunk");
X /*FALLTHROUGH*/
X case 'a':
X if (cmd == 'a') {
X if (o1 != o2)
X fatal("append count conflict");
X copy(getline(fpf, obuf));
X here++;
X }
X while (n1 <= n2) {
X if (strncmp(getline(fpd, nbuf), "> ", 2))
X fatal("illegal append line");
X copy(nbuf + 2);
X n1++;
X }
X break;
X }
X }
X while (fgets(obuf, LINELEN, fpf) != NULL)
X copy(obuf);
X exit(0);
X}
X
Xisdigit(c)
X char c;
X{
X return c >= '0' && c <= '9';
X}
X
Xchar *
Xrange(s, p1, p2)
X char *s;
X int *p1, *p2;
X{
X register int v1 = 0, v2;
X
X while (isdigit(*s))
X v1 = 10 * v1 + *s++ - '0';
X v2 = v1;
X if (*s == ',') {
X s++;
X v2 = 0;
X while (isdigit(*s))
X v2 = 10 * v2 + *s++ - '0';
X }
X if (v1 == 0 || v2 == 0 || v1 > v2)
X fatal("illegal range");
X *p1 = v1;
X *p2 = v2;
X return s;
X}
X
Xgetcommand(fp, o1, o2, pcmd, n1, n2)
X FILE *fp;
X int *o1, *o2, *n1, *n2;
X char *pcmd;
X{
X char buf[LINELEN];
X register char *s;
X char cmd;
X
X if ((s = fgets(buf, LINELEN, fp)) == NULL)
X return 0;
X s = range(s, o1, o2);
X if ((cmd = *s++) != 'a' && cmd != 'c' && cmd != 'd')
X fatal("illegal command");
X s = range(s, n1, n2);
X if (*s != '\n' && s[1] != '\0')
X fatal("extra characters at end of command: %s", s);
X *pcmd = cmd;
X return 1;
X}
X
Xfatal(s, a)
X char *s, *a;
X{
X fprintf(stderr, "%s: fatal: ", prog);
X fprintf(stderr, s, a);
X fprintf(stderr, "\n");
X exit(1);
X}
X
X
X
X
+ END-OF-FILE fix.c
chmod 'u=rw,g=r,o=r' \f\i\x\.\c
set `sum \f\i\x\.\c`
sum=$1
case $sum in
06970) :;;
*) echo 'Bad sum in '\f\i\x\.\c >&2
esac
ec =exp