Post-ansification changes for bin/diff
authorNick Downing <downing.nick@gmail.com>
Sun, 29 Jan 2017 15:22:28 +0000 (02:22 +1100)
committerNick Downing <downing.nick@gmail.com>
Sun, 29 Jan 2017 15:34:16 +0000 (02:34 +1100)
bin/diff/conflicts.txt [new file with mode: 0644]
bin/diff/diff.c
bin/diff/diff.h
bin/diff/diffdir.c
bin/diff/diffh.c
bin/diff/diffreg.c
xify/cc.c

diff --git a/bin/diff/conflicts.txt b/bin/diff/conflicts.txt
new file mode 100644 (file)
index 0000000..d15a8fc
--- /dev/null
@@ -0,0 +1 @@
+diffh.c diff.h
index 86f1ec8..b364a95 100644 (file)
@@ -78,7 +78,7 @@ char  diff[] = DIFF;
 char   diffh[] = DIFFH;
 char   pr[] = PR;
 
-int main(argc, argv) int argc; char **argv; {
+void main(argc, argv) int argc; char **argv; {
        register char *argp;
 
        ifdef1 = "FILE1"; ifdef2 = "FILE2";
@@ -256,7 +256,7 @@ char *ralloc(p, n) char *p; int n; {
        return(q);
 }
 
-int noroom() {
+void noroom() {
        fprintf(stderr, "diff: files too big, try -h\n");
        done();
 }
index 682d0cc..6105b36 100644 (file)
@@ -97,20 +97,28 @@ extern      char diffh[], diff[], pr[];
 #endif
 #endif
 
+#ifndef NORETURN
+#ifdef __GNUC__
+#define NORETURN __attribute__ ((__noreturn__))
+#else
+#define NORETURN
+#endif
+#endif
+
 /* diff.c */
-int main __P((int argc, char **argv));
+void main __P((int argc, char **argv));
 char *savestr __P((register char *cp));
 int min __P((int a, int b));
 int max __P((int a, int b));
-int done __P((void));
+int done __P((void)) NORETURN;
 char *talloc __P((int n));
 char *ralloc __P((char *p, int n));
-int noroom __P((void));
+void noroom __P((void)) NORETURN;
 
 /* diffdir.c */
-int diffdir __P((char **argv));
+void diffdir __P((char **argv));
 
 /* diffreg.c */
-int diffreg __P((void));
+void diffreg __P((void));
 
 #endif
index e661074..1d14937 100644 (file)
@@ -38,17 +38,17 @@ struct dir {
 int    header;
 char   title[2*BUFSIZ], *etitle;
 
-static setfile __P((char **fpp, char **epp, char *file));
-static scanpr __P((register struct dir *dp, int test, char *title, char *file1, char *efile1, char *file2, char *efile2));
-static only __P((struct dir *dp, int which));
+static void setfile __P((char **fpp, char **epp, char *file));
+static void scanpr __P((register struct dir *dp, int test, char *title, char *file1, char *efile1, char *file2, char *efile2));
+static void only __P((struct dir *dp, int which));
 static struct dir *setupdir __P((char *cp));
 static entcmp __P((struct dir *d1, struct dir *d2));
-static compare __P((register struct dir *dp));
-static calldiff __P((char *wantpr));
+static void compare __P((register struct dir *dp));
+static void calldiff __P((char *wantpr));
 static ascii __P((int f));
 static useless __P((register char *cp));
 
-int diffdir(argv) char **argv; {
+void diffdir(argv) char **argv; {
        register struct dir *d1, *d2;
        struct dir *dir1, *dir2;
        register int i;
@@ -134,7 +134,7 @@ int diffdir(argv) char **argv; {
        }
 }
 
-static setfile(fpp, epp, file) char **fpp; char **epp; char *file; {
+static void setfile(fpp, epp, file) char **fpp; char **epp; char *file; {
        register char *cp;
 
        *fpp = malloc(BUFSIZ);
@@ -149,7 +149,7 @@ static setfile(fpp, epp, file) char **fpp; char **epp; char *file; {
        *epp = cp;
 }
 
-static scanpr(dp, test, title, file1, efile1, file2, efile2) register struct dir *dp; int test; char *title; char *file1; char *efile1; char *file2; char *efile2; {
+static void scanpr(dp, test, title, file1, efile1, file2, efile2) register struct dir *dp; int test; char *title; char *file1; char *efile1; char *file2; char *efile2; {
        int titled = 0;
 
        for (; dp->d_entry; dp++) {
@@ -170,7 +170,7 @@ static scanpr(dp, test, title, file1, efile1, file2, efile2) register struct dir
        }
 }
 
-static only(dp, which) struct dir *dp; int which; {
+static void only(dp, which) struct dir *dp; int which; {
        char *file = which == 1 ? file1 : file2;
        char *efile = which == 1 ? efile1 : efile2;
 
@@ -182,7 +182,7 @@ static only(dp, which) struct dir *dp; int which; {
 static struct dir *setupdir(cp) char *cp; {
        register struct dir *dp = 0, *ep;
        register struct direct *rp;
-       register int nitems, n;
+       register int nitems;
        DIR *dirp;
 
        dirp = opendir(cp);
@@ -220,7 +220,7 @@ static struct dir *setupdir(cp) char *cp; {
        }
        dp[nitems].d_entry = 0;         /* delimiter */
        closedir(dirp);
-       qsort(dp, nitems, sizeof (struct dir), entcmp);
+       qsort(dp, nitems, sizeof (struct dir), (int (*) __P((void *p0, void *p1)))entcmp);
        return (dp);
 }
 
@@ -228,11 +228,10 @@ static entcmp(d1, d2) struct dir *d1; struct dir *d2; {
        return (strcmp(d1->d_entry, d2->d_entry));
 }
 
-static compare(dp) register struct dir *dp; {
+static void compare(dp) register struct dir *dp; {
        register int i, j;
        int f1, f2, fmt1, fmt2;
        struct stat stb1, stb2;
-       int flag = 0;
        char buf1[BUFSIZ], buf2[BUFSIZ];
 
        strcpy(efile1, dp->d_entry);
@@ -318,7 +317,7 @@ closem:
 
 static char    *prargs[] = { "pr", "-h", 0, "-f", 0, 0 };
 
-static calldiff(wantpr) char *wantpr; {
+static void calldiff(wantpr) char *wantpr; {
        int pid, status, status2, pv[2];
 
        prargs[2] = wantpr;
index 323d66d..295e209 100644 (file)
@@ -1,8 +1,7 @@
 /*#include <ctype.h> gen.h*/
 #include <gen.h>
 #include <stdio.h>
-/*#include <sys/stat.h> diff.h*/
-#include "diff.h"
+#include <sys/stat.h>
 
 #if defined(DOSCCS) && !defined(lint)
 static char sccsid[] = "@(#)diffh.c 4.4 11/27/85";
@@ -36,16 +35,16 @@ FILE *file[2];
 #endif
 
 char *getl __P((int f, long n));
-int clrl __P((int f, long n));
-int movstr __P((register char *s, register char *t));
+void clrl __P((int f, long n));
+void movstr __P((register char *s, register char *t));
 int main __P((int argc, char **argv));
 int easysynch __P((void));
 int output __P((int a, int b));
-int change __P((long a, int b, long c, int d, char *s));
-int range __P((long a, int b));
+void change __P((long a, int b, long c, int d, char *s));
+void range __P((long a, int b));
 int cmp __P((char *s, char *t));
 FILE *dopen __P((char *f1, char *f2));
-int progerr __P((char *s));
+void progerr __P((char *s));
 int error __P((char *s, char *t));
 int hardsynch __P((void));
 
@@ -82,7 +81,7 @@ again:
 }
 
        /*remove thru line n of file f from storage*/
-int clrl(f, n) int f; long n; {
+void clrl(f, n) int f; long n; {
        register i,j;
        j = n-lineno[f]+1;
        for(i=0;i+j<ntext[f];i++)
@@ -91,7 +90,7 @@ int clrl(f, n) int f; long n; {
        ntext[f] -= j;
 }
 
-int movstr(s, t) register char *s; register char *t; {
+void movstr(s, t) register char *s; register char *t; {
        while(*t++= *s++)
                continue;
 }
@@ -197,14 +196,14 @@ int output(a, b) int a; int b; {
        return(1);
 }
 
-int change(a, b, c, d, s) long a; int b; long c; int d; char *s; {
+void change(a, b, c, d, s) long a; int b; long c; int d; char *s; {
        range(a,b);
        printf("%s",s);
        range(c,d);
        printf("\n");
 }
 
-int range(a, b) long a; int b; {
+void range(a, b) long a; int b; {
        if(b==INF)
                printf("%ld,$",a);
        else if(b==0)
@@ -255,7 +254,7 @@ FILE *dopen(f1, f2) char *f1; char *f2; {
        return(f);
 }
 
-int progerr(s) char *s; {
+void progerr(s) char *s; {
        error("program error ",s);
 }
 
index 9df1754..5d49d5d 100644 (file)
@@ -155,26 +155,26 @@ char      cup2low[256] = {
 
 static char *copytemp __P((void));
 static char *splice __P((char *dir, char *file));
-static prepare __P((int i, FILE *fd));
-static prune __P((void));
-static equiv __P((struct line *a, int n, struct line *b, int m, int *c));
+static void prepare __P((int i, FILE *fd));
+static void prune __P((void));
+static void equiv __P((struct line *a, int n, struct line *b, int m, int *c));
 static stone __P((int *a, int n, int *b, register int *c));
 static newcand __P((int x, int y, int pred));
 static search __P((int *c, int k, int y));
-static unravel __P((int p));
-static check __P((void));
-static sort __P((struct line *a, int n));
-static unsort __P((struct line *f, int l, int *b));
+static void unravel __P((int p));
+static void check __P((void));
+static void sort __P((struct line *a, int n));
+static void unsort __P((struct line *f, int l, int *b));
 static skipline __P((int f));
-static output __P((void));
-static change __P((int a, int b, int c, int d));
-static range __P((int a, int b, char *separator));
-static fetch __P((long *f, int a, int b, FILE *lb, char *s, int oldfile));
+static void output __P((void));
+static void change __P((int a, int b, int c, int d));
+static void range __P((int a, int b, char *separator));
+static void fetch __P((long *f, int a, int b, FILE *lb, char *s, int oldfile));
 static readhash __P((register FILE *f));
 static asciifile __P((FILE *f));
-static dump_context_vec __P((void));
+static void dump_context_vec __P((void));
 
-int diffreg() {
+void diffreg() {
        register int i, j;
        FILE *f1, *f2;
        char buf1[BUFSIZ], buf2[BUFSIZ];
@@ -301,10 +301,10 @@ static char *copytemp() {
        char buf[BUFSIZ];
        register int i, f;
 
-       signal(SIGHUP,done);
-       signal(SIGINT,done);
-       signal(SIGPIPE,done);
-       signal(SIGTERM,done);
+       signal(SIGHUP,(void (*) __P((int sig)))done);
+       signal(SIGINT,(void (*) __P((int sig)))done);
+       signal(SIGPIPE,(void (*) __P((int sig)))done);
+       signal(SIGTERM,(void (*) __P((int sig)))done);
        tempfile = mktemp("/tmp/dXXXXX");
        f = creat(tempfile,0600);
        if (f < 0) {
@@ -339,7 +339,7 @@ static char *splice(dir, file) char *dir; char *file; {
        return (savestr(buf));
 }
 
-static prepare(i, fd) int i; FILE *fd; {
+static void prepare(i, fd) int i; FILE *fd; {
        register struct line *p;
        register j,h;
 
@@ -353,7 +353,7 @@ static prepare(i, fd) int i; FILE *fd; {
        file[i] = p;
 }
 
-static prune() {
+static void prune() {
        register i,j;
        for(pref=0;pref<len[0]&&pref<len[1]&&
                file[0][pref+1].value==file[1][pref+1].value;
@@ -369,7 +369,7 @@ static prune() {
        }
 }
 
-static equiv(a, n, b, m, c) struct line *a; int n; struct line *b; int m; int *c; {
+static void equiv(a, n, b, m, c) struct line *a; int n; struct line *b; int m; int *c; {
        register int i, j;
        i = j = 1;
        while(i<=n && j<=m) {
@@ -463,7 +463,7 @@ static search(c, k, y) int *c; int k; int y; {
        return(l+1);
 }
 
-static unravel(p) int p; {
+static void unravel(p) int p; {
        register int i;
        register struct cand *q;
        for(i=0; i<=len[0]; i++)
@@ -479,7 +479,7 @@ static unravel(p) int p; {
 to confounding by hashing (which result in "jackpot")
 2.  collect random access indexes to the two files */
 
-static check() {
+static void check() {
        register int i, j;
        int jackpot;
        long ctold, ctnew;
@@ -577,7 +577,7 @@ static check() {
 */
 }
 
-static sort(a, n)      /*shellsort CACM #201*/ struct line *a; int n; {
+static void sort(a, n) /*shellsort CACM #201*/ struct line *a; int n; {
        struct line w;
        register int j,m;
        struct line *ai;
@@ -610,7 +610,7 @@ static sort(a, n)   /*shellsort CACM #201*/ struct line *a; int n; {
        }
 }
 
-static unsort(f, l, b) struct line *f; int l; int *b; {
+static void unsort(f, l, b) struct line *f; int l; int *b; {
        register int *a;
        register int i;
        a = (int *)talloc((l+1)*sizeof(int));
@@ -630,7 +630,7 @@ static skipline(f) int f; {
        return(i);
 }
 
-static output() {
+static void output() {
        int m;
        register int i0, i1, j1;
        int j0;
@@ -696,9 +696,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 a; int b; int c; int d; {
-       int ch;
-       int lowa,upb,lowc,upd;
+static void change(a, b, c, d) int a; int b; int c; int d; {
        struct stat stbuf;
 
        if (opt != D_IFDEF && a>b && c>d)
@@ -720,10 +718,6 @@ static change(a, b, c, d) int a; int b; int c; int d; {
                        context_vec_ptr = context_vec_start - 1;
                }
        }
-       if (a <= b && c <= d)
-               ch = 'c';
-       else
-               ch = (a <= b) ? 'd' : 'a';
        if(opt == D_CONTEXT) {
                /*
                 * if this new change is within 'context' lines of
@@ -785,14 +779,14 @@ static change(a, b, c, d) int a; int b; int c; int d; {
        }
 }
 
-static range(a, b, separator) int a; int b; char *separator; {
+static void range(a, b, separator) int a; int b; char *separator; {
        printf("%d", a>b?b:a);
        if(a<b) {
                printf("%s%d", separator, b);
        }
 }
 
-static fetch(f, a, b, lb, s, oldfile) long *f; int a; int b; FILE *lb; char *s; int oldfile; {
+static void fetch(f, a, b, lb, s, oldfile) long *f; int a; int b; FILE *lb; char *s; int oldfile; {
        register int i, j;
        register int c;
        register int col;
@@ -939,12 +933,8 @@ static asciifile(f) FILE *f; {
 
        fseek(f, (long)0, 0);
        cnt = fread(buf, 1, BUFSIZ, f);
-       if (cnt >= sizeof (struct exec)) {
-               struct exec hdr;
-               hdr = *(struct exec *)buf;
-               if (!N_BADMAG(hdr))
-                       return (0);
-       }
+       if (cnt >= sizeof (struct exec) && !N_BADMAG(*(struct exec *)buf))
+               return (0);
        cp = buf;
        while (--cnt >= 0)
                if (*cp++ & 0200)
@@ -953,7 +943,7 @@ static asciifile(f) FILE *f; {
 }
 
 /* dump accumulated "context" diff changes */
-static dump_context_vec() {
+static void dump_context_vec() {
        register int    a, b, c, d;
        register char   ch;
        register struct context_vec *cvp = context_vec_start;
@@ -995,15 +985,28 @@ static dump_context_vec() {
                                ch = (a <= b) ? 'd' : 'a';
 
                        if (ch == 'a')
+#if defined(__STDC__) || defined(lint)
+                               fetch(ixold,lowa,b,input[0],"  ",0);
+#else
                                fetch(ixold,lowa,b,input[0],"  ");
+#endif
                        else {
+#if defined(__STDC__) || defined(lint)
+                               fetch(ixold,lowa,a-1,input[0],"  ",0);
+                               fetch(ixold,a,b,input[0],ch == 'c' ? "! " : "- ",0);
+#else
                                fetch(ixold,lowa,a-1,input[0],"  ");
                                fetch(ixold,a,b,input[0],ch == 'c' ? "! " : "- ");
+#endif
                        }
                        lowa = b + 1;
                        cvp++;
                }
+#if defined(__STDC__) || defined(lint)
+               fetch(ixold, b+1, upb, input[0], "  ", 0);
+#else
                fetch(ixold, b+1, upb, input[0], "  ");
+#endif
        }
 
        /* output changes to the "new" file */
@@ -1029,15 +1032,28 @@ static dump_context_vec() {
                                ch = (a <= b) ? 'd' : 'a';
 
                        if (ch == 'd')
+#if defined(__STDC__) || defined(lint)
+                               fetch(ixnew,lowc,d,input[1],"  ",0);
+#else
                                fetch(ixnew,lowc,d,input[1],"  ");
+#endif
                        else {
+#if defined(__STDC__) || defined(lint)
+                               fetch(ixnew,lowc,c-1,input[1],"  ",0);
+                               fetch(ixnew,c,d,input[1],ch == 'c' ? "! " : "+ ",0);
+#else
                                fetch(ixnew,lowc,c-1,input[1],"  ");
                                fetch(ixnew,c,d,input[1],ch == 'c' ? "! " : "+ ");
+#endif
                        }
                        lowc = d + 1;
                        cvp++;
                }
+#if defined(__STDC__) || defined(lint)
+               fetch(ixnew, d+1, upd, input[1], "  ", 0);
+#else
                fetch(ixnew, d+1, upd, input[1], "  ");
+#endif
        }
 
        context_vec_ptr = context_vec_start - 1;
index 16afefd..d9d3ab7 100644 (file)
--- a/xify/cc.c
+++ b/xify/cc.c
@@ -378,6 +378,7 @@ int main(argc, argv) int argc; char **argv; {
                        --na;
                for (j = 0; j < np; ++j)
                        av[na++] = plist[j];
+               av[na++] = "-fno-strict-aliasing";
                if (proflag)
                        av[na++] = "-pg";
                if (gflag || Gflag)
@@ -388,6 +389,7 @@ int main(argc, argv) int argc; char **argv; {
                        av[na++] = "-Wno-deprecated-declarations";
                        av[na++] = "-Wno-maybe-uninitialized";
                        av[na++] = "-Wno-parentheses";
+                       av[na++] = "-Wno-strict-aliasing";
                        av[na++] = "-Wno-unused-result";
                }
                if (oflag)