From: Nick Downing Date: Sun, 29 Jan 2017 15:22:13 +0000 (+1100) Subject: Ansified bin/diff X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=16aa7908f4536c879afe71ed9082f6ca9627100e;p=43bsd.git Ansified bin/diff --- diff --git a/bin/diff/diff.c b/bin/diff/diff.c index efe7e47..86f1ec8 100644 --- a/bin/diff/diff.c +++ b/bin/diff/diff.c @@ -1,6 +1,17 @@ +/*#include gen.h*/ +#include +#include +/*#include gen.h*/ +/*#include gen.h*/ +#include +/*#include diff.h*/ +#include "diff.h" + +#if defined(DOSCCS) && !defined(lint) static char sccsid[] = "@(#)diff.c 4.6 4/3/86"; +#endif -#include "diff.h" +/*#include "diff.h"*/ /* * diff - driver and subroutines */ @@ -67,10 +78,7 @@ char diff[] = DIFF; char diffh[] = DIFFH; char pr[] = PR; -main(argc, argv) - int argc; - char **argv; -{ +int main(argc, argv) int argc; char **argv; { register char *argp; ifdef1 = "FILE1"; ifdef2 = "FILE2"; @@ -204,10 +212,7 @@ main(argc, argv) done(); } -char * -savestr(cp) - register char *cp; -{ +char *savestr(cp) register char *cp; { register char *dp = malloc(strlen(cp)+1); if (dp == 0) { @@ -218,30 +223,23 @@ savestr(cp) return (dp); } -min(a,b) - int a,b; -{ +int min(a, b) int a; int b; { return (a < b ? a : b); } -max(a,b) - int a,b; -{ +int max(a, b) int a; int b; { return (a > b ? a : b); } -done() -{ +int done() { if (tempfile) unlink(tempfile); exit(status); } -char * -talloc(n) -{ +char *talloc(n) int n; { register char *p; if ((p = malloc((unsigned)n)) != NULL) @@ -249,10 +247,7 @@ talloc(n) noroom(); } -char * -ralloc(p,n) -char *p; -{ +char *ralloc(p, n) char *p; int n; { register char *q; void *realloc(); @@ -261,8 +256,7 @@ char *p; return(q); } -noroom() -{ +int noroom() { fprintf(stderr, "diff: files too big, try -h\n"); done(); } diff --git a/bin/diff/diff.h b/bin/diff/diff.h index bdc5f6b..682d0cc 100644 --- a/bin/diff/diff.h +++ b/bin/diff/diff.h @@ -1,15 +1,20 @@ +#ifndef _DIFF_H_ +#define _DIFF_H_ + +#include + /* diff.h 4.7 85/08/16 */ /* * diff - common declarations */ -#include -#include -#include -#include -#include -#include +/*#include */ +/*#include */ +/*#include */ +/*#include */ +/*#include */ +/*#include */ /* * Output format options @@ -77,9 +82,35 @@ extern char **diffargv; /* option list to pass to recursive diffs */ extern char *file1, *file2, *efile1, *efile2; extern struct stat stb1, stb2; -char *malloc(), *talloc(), *ralloc(); -char *savestr(), *splice(), *splicen(); -char *mktemp(), *copytemp(), *rindex(); -int done(); +/*char *malloc(), *talloc(), *ralloc();*/ +/*char *savestr(), *splice(), *splicen();*/ +/*char *mktemp(), *copytemp(), *rindex();*/ +/*int done();*/ extern char diffh[], diff[], pr[]; + +#ifndef __P +#ifdef __STDC__ +#define __P(args) args +#else +#define __P(args) () +#endif +#endif + +/* diff.c */ +int 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)); +char *talloc __P((int n)); +char *ralloc __P((char *p, int n)); +int noroom __P((void)); + +/* diffdir.c */ +int diffdir __P((char **argv)); + +/* diffreg.c */ +int diffreg __P((void)); + +#endif diff --git a/bin/diff/diffdir.c b/bin/diff/diffdir.c index ff86c92..e661074 100644 --- a/bin/diff/diffdir.c +++ b/bin/diff/diffdir.c @@ -1,6 +1,22 @@ +/*#include gen.h*/ +#include +#include +/*#include gen.h*/ +/*#include gen.h*/ +/*#include gen.h*/ +/*#include a.out.h*/ +#include +/*#include gen.h*/ +/*#include diff.h*/ +/*#include diff.h*/ +#include +#include "diff.h" + +#if defined(DOSCCS) && !defined(lint) static char *sccsid = "@(#)diffdir.c 4.9 (Berkeley) 8/28/84"; +#endif -#include "diff.h" +/*#include "diff.h"*/ /* * diff - directory comparison */ @@ -18,13 +34,21 @@ struct dir { char *d_entry; }; -struct dir *setupdir(); +/*struct dir *setupdir();*/ int header; char title[2*BUFSIZ], *etitle; -diffdir(argv) - char **argv; -{ +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 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 ascii __P((int f)); +static useless __P((register char *cp)); + +int diffdir(argv) char **argv; { register struct dir *d1, *d2; struct dir *dir1, *dir2; register int i; @@ -110,11 +134,7 @@ diffdir(argv) } } -static -setfile(fpp, epp, file) - char **fpp, **epp; - char *file; -{ +static setfile(fpp, epp, file) char **fpp; char **epp; char *file; { register char *cp; *fpp = malloc(BUFSIZ); @@ -129,12 +149,7 @@ setfile(fpp, epp, file) *epp = cp; } -static -scanpr(dp, test, title, file1, efile1, file2, efile2) - register struct dir *dp; - int test; - char *title, *file1, *efile1, *file2, *efile2; -{ +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; { int titled = 0; for (; dp->d_entry; dp++) { @@ -155,23 +170,16 @@ scanpr(dp, test, title, file1, efile1, file2, efile2) } } -static -only(dp, which) - struct dir *dp; - int which; -{ +static only(dp, which) struct dir *dp; int which; { char *file = which == 1 ? file1 : file2; char *efile = which == 1 ? efile1 : efile2; printf("Only in %.*s: %s\n", efile - file - 1, file, dp->d_entry); } -static int entcmp(); +/*static int entcmp();*/ -static struct dir * -setupdir(cp) - char *cp; -{ +static struct dir *setupdir(cp) char *cp; { register struct dir *dp = 0, *ep; register struct direct *rp; register int nitems, n; @@ -216,17 +224,11 @@ setupdir(cp) return (dp); } -static -entcmp(d1, d2) - struct dir *d1, *d2; -{ +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 compare(dp) register struct dir *dp; { register int i, j; int f1, f2, fmt1, fmt2; struct stat stb1, stb2; @@ -316,10 +318,7 @@ closem: static char *prargs[] = { "pr", "-h", 0, "-f", 0, 0 }; -static -calldiff(wantpr) - char *wantpr; -{ +static calldiff(wantpr) char *wantpr; { int pid, status, status2, pv[2]; prargs[2] = wantpr; @@ -374,12 +373,9 @@ calldiff(wantpr) */ } -#include +/*#include */ -static -ascii(f) - int f; -{ +static ascii(f) int f; { char buf[BUFSIZ]; register int cnt; register char *cp; @@ -402,10 +398,7 @@ ascii(f) /* * THIS IS CRUDE. */ -static -useless(cp) -register char *cp; -{ +static useless(cp) register char *cp; { if (cp[0] == '.') { if (cp[1] == '\0') diff --git a/bin/diff/diffh.c b/bin/diff/diffh.c index c0a4798..323d66d 100644 --- a/bin/diff/diffh.c +++ b/bin/diff/diffh.c @@ -1,9 +1,17 @@ +/*#include gen.h*/ +#include +#include +/*#include diff.h*/ +#include "diff.h" + +#if defined(DOSCCS) && !defined(lint) static char sccsid[] = "@(#)diffh.c 4.4 11/27/85"; +#endif -#include -#include -#include -#include +/*#include */ +/*#include */ +/*#include */ +/*#include */ #define C 3 #define RANGE 30 @@ -19,9 +27,29 @@ int debug = 0; FILE *file[2]; /* return pointer to line n of file f*/ -char *getl(f,n) -long n; -{ +#ifndef __P +#ifdef __STDC__ +#define __P(args) args +#else +#define __P(args) () +#endif +#endif + +char *getl __P((int f, long n)); +int clrl __P((int f, long n)); +int 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)); +int cmp __P((char *s, char *t)); +FILE *dopen __P((char *f1, char *f2)); +int progerr __P((char *s)); +int error __P((char *s, char *t)); +int hardsynch __P((void)); + +char *getl(f, n) int f; long n; { register char *t; void *malloc(); register delta, nt; @@ -54,9 +82,7 @@ again: } /*remove thru line n of file f from storage*/ -clrl(f,n) -long n; -{ +int clrl(f, n) int f; long n; { register i,j; j = n-lineno[f]+1; for(i=0;i+j gen.h*/ +/*#include gen.h*/ +#include +#include +/*#include gen.h*/ +/*#include gen.h*/ +/*#include a.out.h*/ +#include +/*#include gen.h*/ +/*#include diff.h*/ +/*#include gen.h*/ +#include "diff.h" + +#if defined(DOSCCS) && !defined(lint) static char sccsid[] = "@(#)diffreg.c 4.16 3/29/86"; +#endif -#include "diff.h" +/*#include "diff.h"*/ /* * diff - compare two files. */ @@ -71,7 +86,7 @@ static char sccsid[] = "@(#)diffreg.c 4.16 3/29/86"; #define prints(s) fputs(s,stdout) FILE *input[2]; -FILE *fopen(); +/*FILE *fopen();*/ struct cand { int x; @@ -138,8 +153,28 @@ char cup2low[256] = { 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff }; -diffreg() -{ +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 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 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 readhash __P((register FILE *f)); +static asciifile __P((FILE *f)); +static dump_context_vec __P((void)); + +int diffreg() { register int i, j; FILE *f1, *f2; char buf1[BUFSIZ], buf2[BUFSIZ]; @@ -262,9 +297,7 @@ same: done(); } -static char * -copytemp() -{ +static char *copytemp() { char buf[BUFSIZ]; register int i, f; @@ -289,10 +322,7 @@ copytemp() return (tempfile); } -static char * -splice(dir, file) - char *dir, *file; -{ +static char *splice(dir, file) char *dir; char *file; { char *tail; char buf[BUFSIZ]; @@ -309,11 +339,7 @@ splice(dir, file) return (savestr(buf)); } -static -prepare(i, fd) - int i; - FILE *fd; -{ +static prepare(i, fd) int i; FILE *fd; { register struct line *p; register j,h; @@ -327,9 +353,7 @@ prepare(i, fd) file[i] = p; } -static -prune() -{ +static prune() { register i,j; for(pref=0;prefb?b:a); if(a +/*#include */ -static -asciifile(f) - FILE *f; -{ +static asciifile(f) FILE *f; { char buf[BUFSIZ]; register int cnt; register char *cp; @@ -973,11 +952,8 @@ asciifile(f) return (1); } - /* dump accumulated "context" diff changes */ -static -dump_context_vec() -{ +static dump_context_vec() { register int a, b, c, d; register char ch; register struct context_vec *cvp = context_vec_start;