version 1.41, 2005/05/31 08:58:47 |
version 1.42, 2005/06/05 20:47:44 |
|
|
return (CVS_EX_DATA); |
return (CVS_EX_DATA); |
} |
} |
|
|
printf("%s", diffargs); |
cvs_printf("%s", diffargs); |
printf(" -r%s", buf); |
cvs_printf(" -r%s", buf); |
if (dap->rev2 != NULL) |
if (dap->rev2 != NULL) |
printf(" -r%s", dap->rev2); |
cvs_printf(" -r%s", dap->rev2); |
printf(" %s\n", diff_file); |
cvs_printf(" %s\n", diff_file); |
strlcpy(path_tmp1, "/tmp/diff1.XXXXXXXXXX", sizeof(path_tmp1)); |
strlcpy(path_tmp1, "/tmp/diff1.XXXXXXXXXX", sizeof(path_tmp1)); |
if (cvs_buf_write_stmp(b1, path_tmp1, 0600) == -1) { |
if (cvs_buf_write_stmp(b1, path_tmp1, 0600) == -1) { |
cvs_buf_free(b1); |
cvs_buf_free(b1); |
|
|
ixnew[j] = ctnew += skipline(f2); |
ixnew[j] = ctnew += skipline(f2); |
/* |
/* |
* if (jackpot) |
* if (jackpot) |
* fprintf(stderr, "jackpot\n"); |
* cvs_printf("jackpot\n"); |
*/ |
*/ |
} |
} |
|
|
|
|
#define c i0 |
#define c i0 |
if ((c = getc(f1)) == EOF) |
if ((c = getc(f1)) == EOF) |
return; |
return; |
putchar(c); |
cvs_putchar(c); |
} |
} |
#undef c |
#undef c |
} |
} |
|
|
static __inline void |
static __inline void |
range(int a, int b, char *separator) |
range(int a, int b, char *separator) |
{ |
{ |
printf("%d", a > b ? b : a); |
cvs_printf("%d", a > b ? b : a); |
if (a < b) |
if (a < b) |
printf("%s%d", separator, b); |
cvs_printf("%s%d", separator, b); |
} |
} |
|
|
static __inline void |
static __inline void |
uni_range(int a, int b) |
uni_range(int a, int b) |
{ |
{ |
if (a < b) |
if (a < b) |
printf("%d,%d", a, b - a + 1); |
cvs_printf("%d,%d", a, b - a + 1); |
else if (a == b) |
else if (a == b) |
printf("%d", b); |
cvs_printf("%d", b); |
else |
else |
printf("%d,0", b); |
cvs_printf("%d,0", b); |
} |
} |
|
|
static char * |
static char * |
|
|
/* |
/* |
* Print the context/unidiff header first time through. |
* Print the context/unidiff header first time through. |
*/ |
*/ |
printf("%s %s %s", |
cvs_printf("%s %s %s", |
format == D_CONTEXT ? "***" : "---", diff_file, |
format == D_CONTEXT ? "***" : "---", diff_file, |
ctime(&stb1.st_mtime)); |
ctime(&stb1.st_mtime)); |
printf("%s %s %s", |
cvs_printf("%s %s %s", |
format == D_CONTEXT ? "---" : "+++", diff_file, |
format == D_CONTEXT ? "---" : "+++", diff_file, |
ctime(&stb2.st_mtime)); |
ctime(&stb2.st_mtime)); |
anychange = 1; |
anychange = 1; |
|
|
return; |
return; |
case D_NORMAL: |
case D_NORMAL: |
range(a, b, ","); |
range(a, b, ","); |
putchar(a > b ? 'a' : c > d ? 'd' : 'c'); |
cvs_putchar(a > b ? 'a' : c > d ? 'd' : 'c'); |
if (format == D_NORMAL) |
if (format == D_NORMAL) |
range(c, d, ","); |
range(c, d, ","); |
putchar('\n'); |
cvs_putchar('\n'); |
break; |
break; |
case D_RCSDIFF: |
case D_RCSDIFF: |
if (a > b) |
if (a > b) |
printf("a%d %d\n", b, d - c + 1); |
cvs_printf("a%d %d\n", b, d - c + 1); |
else { |
else { |
printf("d%d %d\n", a, b - a + 1); |
cvs_printf("d%d %d\n", a, b - a + 1); |
|
|
if (!(c > d)) /* add changed lines */ |
if (!(c > d)) /* add changed lines */ |
printf("a%d %d\n", b, d - c + 1); |
cvs_printf("a%d %d\n", b, d - c + 1); |
} |
} |
break; |
break; |
} |
} |
|
|
} |
} |
i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0); |
i = fetch(ixnew, c, d, f2, format == D_NORMAL ? '>' : '\0', 0); |
if (inifdef) { |
if (inifdef) { |
printf("#endif /* %s */\n", ifdefname); |
cvs_printf("#endif /* %s */\n", ifdefname); |
inifdef = 0; |
inifdef = 0; |
} |
} |
} |
} |
|
|
/* print through if append (a>b), else to (nb: 0 vs 1 orig) */ |
/* print through if append (a>b), else to (nb: 0 vs 1 orig) */ |
nc = f[a > b ? b : a - 1] - curpos; |
nc = f[a > b ? b : a - 1] - curpos; |
for (i = 0; i < nc; i++) |
for (i = 0; i < nc; i++) |
putchar(getc(lb)); |
cvs_putchar(getc(lb)); |
} |
} |
if (a > b) |
if (a > b) |
return (0); |
return (0); |
if (format == D_IFDEF) { |
if (format == D_IFDEF) { |
if (inifdef) { |
if (inifdef) { |
printf("#else /* %s%s */\n", |
cvs_printf("#else /* %s%s */\n", |
oldfile == 1 ? "!" : "", ifdefname); |
oldfile == 1 ? "!" : "", ifdefname); |
} else { |
} else { |
if (oldfile) |
if (oldfile) |
printf("#ifndef %s\n", ifdefname); |
cvs_printf("#ifndef %s\n", ifdefname); |
else |
else |
printf("#ifdef %s\n", ifdefname); |
cvs_printf("#ifdef %s\n", ifdefname); |
} |
} |
inifdef = 1 + oldfile; |
inifdef = 1 + oldfile; |
} |
} |
|
|
fseek(lb, f[i - 1], SEEK_SET); |
fseek(lb, f[i - 1], SEEK_SET); |
nc = f[i] - f[i - 1]; |
nc = f[i] - f[i - 1]; |
if (format != D_IFDEF && ch != '\0') { |
if (format != D_IFDEF && ch != '\0') { |
putchar(ch); |
cvs_putchar(ch); |
if (Tflag && (format == D_NORMAL || format == D_CONTEXT |
if (Tflag && (format == D_NORMAL || format == D_CONTEXT |
|| format == D_UNIFIED)) |
|| format == D_UNIFIED)) |
putchar('\t'); |
cvs_putchar('\t'); |
else if (format != D_UNIFIED) |
else if (format != D_UNIFIED) |
putchar(' '); |
cvs_putchar(' '); |
} |
} |
col = 0; |
col = 0; |
for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) { |
for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) { |
|
|
} |
} |
if (c == '\t' && tflag) { |
if (c == '\t' && tflag) { |
do { |
do { |
putchar(' '); |
cvs_putchar(' '); |
} while (++col & 7); |
} while (++col & 7); |
} else { |
} else { |
putchar(c); |
cvs_putchar(c); |
col++; |
col++; |
} |
} |
} |
} |
|
|
lowc = MAX(1, cvp->c - context); |
lowc = MAX(1, cvp->c - context); |
upd = MIN(diff_len[1], context_vec_ptr->d + context); |
upd = MIN(diff_len[1], context_vec_ptr->d + context); |
|
|
printf("***************"); |
cvs_printf("***************"); |
if (pflag) { |
if (pflag) { |
f = match_function(ixold, lowa - 1, f1); |
f = match_function(ixold, lowa - 1, f1); |
if (f != NULL) { |
if (f != NULL) { |
putchar(' '); |
cvs_putchar(' '); |
fputs(f, stdout); |
cvs_printf("%s", f); |
} |
} |
} |
} |
printf("\n*** "); |
cvs_printf("\n*** "); |
range(lowa, upb, ","); |
range(lowa, upb, ","); |
printf(" ****\n"); |
cvs_printf(" ****\n"); |
|
|
/* |
/* |
* Output changes to the "old" file. The first loop suppresses |
* Output changes to the "old" file. The first loop suppresses |
|
|
fetch(ixold, b + 1, upb, f1, ' ', 0); |
fetch(ixold, b + 1, upb, f1, ' ', 0); |
} |
} |
/* output changes to the "new" file */ |
/* output changes to the "new" file */ |
printf("--- "); |
cvs_printf("--- "); |
range(lowc, upd, ","); |
range(lowc, upd, ","); |
printf(" ----\n"); |
cvs_printf(" ----\n"); |
|
|
do_output = 0; |
do_output = 0; |
for (cvp = context_vec_start; cvp <= context_vec_ptr; cvp++) |
for (cvp = context_vec_start; cvp <= context_vec_ptr; cvp++) |
|
|
lowc = MAX(1, cvp->c - context); |
lowc = MAX(1, cvp->c - context); |
upd = MIN(diff_len[1], context_vec_ptr->d + context); |
upd = MIN(diff_len[1], context_vec_ptr->d + context); |
|
|
fputs("@@ -", stdout); |
cvs_printf("@@ -"); |
uni_range(lowa, upb); |
uni_range(lowa, upb); |
fputs(" +", stdout); |
cvs_printf(" +"); |
uni_range(lowc, upd); |
uni_range(lowc, upd); |
fputs(" @@", stdout); |
cvs_printf(" @@"); |
if (pflag) { |
if (pflag) { |
f = match_function(ixold, lowa - 1, f1); |
f = match_function(ixold, lowa - 1, f1); |
if (f != NULL) { |
if (f != NULL) { |
putchar(' '); |
cvs_putchar(' '); |
fputs(f, stdout); |
cvs_printf("%s", f); |
} |
} |
} |
} |
putchar('\n'); |
cvs_putchar('\n'); |
|
|
/* |
/* |
* Output changes in "unified" diff format--the old and new lines |
* Output changes in "unified" diff format--the old and new lines |