| Date: Sat, 29 Jan 2005 16:50:51 +0000
add diff -a
Diffstat:
M src/cmd/diff/diffio.c | 28 ++++++++++++++++++++++------
M src/cmd/diff/main.c | 15 ++++++++-------
2 files changed, 30 insertions(+), 13 deletions(-)
--- |
| t@@ -302,6 +302,7 @@ change(int a, int b, int c, int d)
range(a, b, " ");
break;
case 'c':
+ case 'a':
if(nchanges%1024 == 0)
changes = erealloc(changes, (nchanges+1024)*sizeof(changes[0]));
ch = &changes[nchanges++];
t@@ -348,24 +349,39 @@ flushchanges(void)
for(i=0; i len[0])
+ b = len[0];
+ if(d > len[1])
+ d = len[1];
+ if(mode == 'a'){
+ a = 1;
+ b = len[0];
+ c = 1;
+ d = len[1];
+ j = nchanges;
+ }
Bprint(&stdout, "%s:", file1);
range(a, b, ",");
Bprint(&stdout, " - ");
Bprint(&stdout, "%s:", file2);
range(c, d, ",");
Bputc(&stdout, '\n');
- at = a-Lines;
+ at = a;
for(; i ");
at = changes[i].b+1;
}
- fetch(ixold, at, b+Lines, input[0], " ");
+ fetch(ixold, at, b, input[0], " ");
}
nchanges = 0;
} |
| t@@ -8,7 +8,7 @@
Biobuf stdout;
-static char *tmp[] = {"/tmp/diff1", "/tmp/diff2"};
+static char *tmp[] = {"/tmp/diff1XXXXXXXXXXX", "/tmp/diff2XXXXXXXXXXX"};
static int whichtmp;
static char *progname;
static char usage[] = "diff [ -efmnbwr ] file1 ... file2\n";
t@@ -26,8 +26,6 @@ void
done(int status)
{
rmtmpfiles();
-Bflush(&stdout);
-Bterm(&stdout);
switch(status)
{
case 0:
t@@ -83,8 +81,11 @@ mktmpfile(int input, Dir **sb)
char buf[8192];
atnotify(catch, 1);
- p = tmp[whichtmp++];
+/*
+ p = mktemp(tmp[whichtmp++]);
fd = create(p, OWRITE, 0600);
+*/
+ fd = mkstemp(p=tmp[whichtmp++]);
if (fd < 0) {
panic(mflag ? 0: 2, "cannot create %s: %r\n", p);
return 0;
t@@ -172,7 +173,6 @@ diff(char *f, char *t, int level)
}
free(fsb);
free(tsb);
-
Return:
rmtmpfiles();
}
t@@ -189,10 +189,12 @@ main(int argc, char *argv[])
while (--argc && (*++argv)[0] == '-' && (*argv)[1]) {
for (p = *argv+1; *p; p++) {
switch (*p) {
- case 'c':
+
case 'e':
case 'f':
case 'n':
+ case 'c':
+ case 'a':
mode = *p;
break;
t@@ -238,7 +240,6 @@ main(int argc, char *argv[])
free(tsb);
for (i = 0; i < argc-1; i++)
diff(argv[i], argv[argc-1], 0);
-
done(anychange);
/*NOTREACHED*/
} |