Pre-ansification changes for bin/diff
authorNick Downing <downing.nick@gmail.com>
Sun, 29 Jan 2017 14:50:04 +0000 (01:50 +1100)
committerNick Downing <downing.nick@gmail.com>
Sun, 29 Jan 2017 15:22:01 +0000 (02:22 +1100)
bin/diff/Makefile
bin/diff/diff.c
bin/diff/diff.h
bin/diff/diffdir.c
bin/diff/diffh.c
bin/diff/diffreg.c
bin/diff/groups.txt [new file with mode: 0644]

index 2c35f96..bc0eb52 100644 (file)
@@ -13,10 +13,10 @@ OBJS=       diff.o diffdir.o diffreg.o
 all: diff diffh
 
 diff: ${OBJS}
-       cc ${CFLAGS} -o diff ${OBJS} ${LDFLAGS}
+       ${CC} ${CFLAGS} -o diff ${OBJS} ${LDFLAGS}
 
 diffh: diffh.o
-       cc -o diffh diffh.o ${LDFLAGS}
+       ${CC} -o diffh diffh.o ${LDFLAGS}
 
 clean:
        rm -f diff diffh ${OBJS} diffh.o
index d0436c2..efe7e47 100644 (file)
@@ -5,6 +5,64 @@ static char sccsid[] = "@(#)diff.c 4.6 4/3/86";
  * diff - driver and subroutines
  */
 
+/* moved here from diff.h which now just declares them extern */
+/*
+ * Output format options
+ */
+int    opt;
+int    tflag;                  /* expand tabs on output */
+
+/*
+ * Algorithm related options
+ */
+int    hflag;                  /* -h, use halfhearted DIFFH */
+int    bflag;                  /* ignore blanks in comparisons */
+int    wflag;                  /* totally ignore blanks in comparisons */
+int    iflag;                  /* ignore case in comparisons */
+
+/*
+ * Options on hierarchical diffs.
+ */
+int    lflag;                  /* long output format with header */
+int    rflag;                  /* recursively trace directories */
+int    sflag;                  /* announce files which are same */
+char   *start;                 /* do file only if name >= this */
+
+/*
+ * Variables for -I D_IFDEF option.
+ */
+int    wantelses;              /* -E */
+char   *ifdef1;                /* String for -1 */
+char   *ifdef2;                /* String for -2 */
+char   *endifname;             /* What we will print on next #endif */
+int    inifdef;
+
+/*
+ * Variables for -c context option.
+ */
+int    context;                /* lines of context to be printed */
+
+/*
+ * State for exit status.
+ */
+int    status;
+int    anychange;
+char   *tempfile;              /* used when comparing against std input */
+
+/*
+ * Variables for diffdir.
+ */
+char   **diffargv;             /* option list to pass to recursive diffs */
+
+/*
+ * Input file names.
+ * With diffdir, file1 and file2 are allocated BUFSIZ space,
+ * and padded with a '/', and then efile0 and efile1 point after
+ * the '/'.
+ */
+char   *file1, *file2, *efile1, *efile2;
+struct stat stb1, stb2;
+
 char   diff[] = DIFF;
 char   diffh[] = DIFFH;
 char   pr[] = PR;
@@ -196,7 +254,7 @@ ralloc(p,n)
 char *p;
 {
        register char *q;
-       char *realloc();
+       void *realloc();
 
        if ((q = realloc(p, (unsigned)n)) == NULL)
                noroom();
index 7c11a5f..bdc5f6b 100644 (file)
@@ -14,7 +14,7 @@
 /*
  * Output format options
  */
-int    opt;
+extern int     opt;
 
 #define        D_NORMAL        0       /* Normal output */
 #define        D_EDIT          -1      /* Editor script out */
@@ -24,49 +24,49 @@ int opt;
 #define        D_NREVERSE      4       /* Reverse ed script with numbered
                                   lines and no trailing . */
 
-int    tflag;                  /* expand tabs on output */
+extern int     tflag;                  /* expand tabs on output */
 
 /*
  * Algorithm related options
  */
-int    hflag;                  /* -h, use halfhearted DIFFH */
-int    bflag;                  /* ignore blanks in comparisons */
-int    wflag;                  /* totally ignore blanks in comparisons */
-int    iflag;                  /* ignore case in comparisons */
+extern int     hflag;                  /* -h, use halfhearted DIFFH */
+extern int     bflag;                  /* ignore blanks in comparisons */
+extern int     wflag;                  /* totally ignore blanks in comparisons */
+extern int     iflag;                  /* ignore case in comparisons */
 
 /*
  * Options on hierarchical diffs.
  */
-int    lflag;                  /* long output format with header */
-int    rflag;                  /* recursively trace directories */
-int    sflag;                  /* announce files which are same */
-char   *start;                 /* do file only if name >= this */
+extern int     lflag;                  /* long output format with header */
+extern int     rflag;                  /* recursively trace directories */
+extern int     sflag;                  /* announce files which are same */
+extern char    *start;                 /* do file only if name >= this */
 
 /*
  * Variables for -I D_IFDEF option.
  */
-int    wantelses;              /* -E */
-char   *ifdef1;                /* String for -1 */
-char   *ifdef2;                /* String for -2 */
-char   *endifname;             /* What we will print on next #endif */
-int    inifdef;
+extern int     wantelses;              /* -E */
+extern char    *ifdef1;                /* String for -1 */
+extern char    *ifdef2;                /* String for -2 */
+extern char    *endifname;             /* What we will print on next #endif */
+extern int     inifdef;
 
 /*
  * Variables for -c context option.
  */
-int    context;                /* lines of context to be printed */
+extern int     context;                /* lines of context to be printed */
 
 /*
  * State for exit status.
  */
-int    status;
-int    anychange;
-char   *tempfile;              /* used when comparing against std input */
+extern int     status;
+extern int     anychange;
+extern char    *tempfile;              /* used when comparing against std input */
 
 /*
  * Variables for diffdir.
  */
-char   **diffargv;             /* option list to pass to recursive diffs */
+extern char    **diffargv;             /* option list to pass to recursive diffs */
 
 /*
  * Input file names.
@@ -74,8 +74,8 @@ char  **diffargv;             /* option list to pass to recursive diffs */
  * and padded with a '/', and then efile0 and efile1 point after
  * the '/'.
  */
-char   *file1, *file2, *efile1, *efile2;
-struct stat stb1, stb2;
+extern char    *file1, *file2, *efile1, *efile2;
+extern struct  stat stb1, stb2;
 
 char   *malloc(), *talloc(), *ralloc();
 char   *savestr(), *splice(), *splicen();
index 8475267..ff86c92 100644 (file)
@@ -110,6 +110,7 @@ diffdir(argv)
        }
 }
 
+static
 setfile(fpp, epp, file)
        char **fpp, **epp;
        char *file;
@@ -128,6 +129,7 @@ setfile(fpp, epp, file)
        *epp = cp;
 }
 
+static
 scanpr(dp, test, title, file1, efile1, file2, efile2)
        register struct dir *dp;
        int test;
@@ -153,6 +155,7 @@ scanpr(dp, test, title, file1, efile1, file2, efile2)
        }
 }
 
+static
 only(dp, which)
        struct dir *dp;
        int which;
@@ -163,9 +166,9 @@ only(dp, which)
        printf("Only in %.*s: %s\n", efile - file - 1, file, dp->d_entry);
 }
 
-int    entcmp();
+static int     entcmp();
 
-struct dir *
+static struct dir *
 setupdir(cp)
        char *cp;
 {
@@ -213,12 +216,14 @@ setupdir(cp)
        return (dp);
 }
 
+static
 entcmp(d1, d2)
        struct dir *d1, *d2;
 {
        return (strcmp(d1->d_entry, d2->d_entry));
 }
 
+static
 compare(dp)
        register struct dir *dp;
 {
@@ -309,8 +314,9 @@ closem:
        close(f1); close(f2);
 }
 
-char   *prargs[] = { "pr", "-h", 0, "-f", 0, 0 };
+static char    *prargs[] = { "pr", "-h", 0, "-f", 0, 0 };
 
+static
 calldiff(wantpr)
        char *wantpr;
 {
@@ -370,6 +376,7 @@ calldiff(wantpr)
 
 #include <a.out.h>
 
+static
 ascii(f)
        int f;
 {
@@ -395,6 +402,7 @@ ascii(f)
 /*
  * THIS IS CRUDE.
  */
+static
 useless(cp)
 register char *cp;
 {
index 6a6ff49..c0a4798 100644 (file)
@@ -23,7 +23,7 @@ char *getl(f,n)
 long n;
 {
        register char *t;
-       char *malloc();
+       void *malloc();
        register delta, nt;
 again:
        delta = n - lineno[f];
index 0c95e04..e45b30f 100644 (file)
@@ -262,7 +262,7 @@ same:
        done();
 }
 
-char *
+static char *
 copytemp()
 {
        char buf[BUFSIZ];
@@ -289,7 +289,7 @@ copytemp()
        return (tempfile);
 }
 
-char *
+static char *
 splice(dir, file)
        char *dir, *file;
 {
@@ -309,6 +309,7 @@ splice(dir, file)
        return (savestr(buf));
 }
 
+static
 prepare(i, fd)
        int i;
        FILE *fd;
@@ -326,6 +327,7 @@ prepare(i, fd)
        file[i] = p;
 }
 
+static
 prune()
 {
        register i,j;
@@ -343,6 +345,7 @@ prune()
        }
 }
 
+static
 equiv(a,n,b,m,c)
 struct line *a, *b;
 int *c;
@@ -371,6 +374,7 @@ int *c;
        c[j] = -1;
 }
 
+static
 stone(a,n,b,c)
 int *a;
 int *b;
@@ -412,6 +416,7 @@ register int *c;
        return(k);
 }
 
+static
 newcand(x,y,pred)
 {
        register struct cand *q;
@@ -423,6 +428,7 @@ newcand(x,y,pred)
        return(clen-1);
 }
 
+static
 search(c, k, y)
 int *c;
 {
@@ -447,6 +453,7 @@ int *c;
        return(l+1);
 }
 
+static
 unravel(p)
 {
        register int i;
@@ -464,6 +471,7 @@ unravel(p)
 to confounding by hashing (which result in "jackpot")
 2.  collect random access indexes to the two files */
 
+static
 check()
 {
        register int i, j;
@@ -563,6 +571,7 @@ check()
 */
 }
 
+static
 sort(a,n)      /*shellsort CACM #201*/
 struct line *a;
 {
@@ -598,6 +607,7 @@ struct line *a;
        }
 }
 
+static
 unsort(f, l, b)
 struct line *f;
 int *b;
@@ -612,6 +622,7 @@ int *b;
        free((char *)a);
 }
 
+static
 skipline(f)
 {
        register i, c;
@@ -622,6 +633,7 @@ skipline(f)
        return(i);
 }
 
+static
 output()
 {
        int m;
@@ -689,6 +701,7 @@ struct      context_vec     *context_vec_start,
    and this means that there were lines appended (beginning at b).
    If c is greater than d then there are lines missing from the to file.
 */
+static
 change(a,b,c,d)
 {
        int ch;
@@ -779,6 +792,7 @@ change(a,b,c,d)
        }
 }
 
+static
 range(a,b,separator)
 char *separator;
 {
@@ -788,6 +802,7 @@ char *separator;
        }
 }
 
+static
 fetch(f,a,b,lb,s,oldfile)
 long *f;
 FILE *lb;
@@ -867,6 +882,7 @@ char *s;
  * arranging line in 7-bit bytes and then
  * summing 1-s complement in 16-bit hunks 
  */
+static
 readhash(f)
 register FILE *f;
 {
@@ -934,6 +950,7 @@ register FILE *f;
 
 #include <a.out.h>
 
+static
 asciifile(f)
        FILE *f;
 {
@@ -958,6 +975,7 @@ asciifile(f)
 
 
 /* dump accumulated "context" diff changes */
+static
 dump_context_vec()
 {
        register int    a, b, c, d;
diff --git a/bin/diff/groups.txt b/bin/diff/groups.txt
new file mode 100644 (file)
index 0000000..0522006
--- /dev/null
@@ -0,0 +1,3 @@
+diff.c diff.h
+diffdir.c diff.h
+diffreg.c diff.h