=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/diff_internals.c,v retrieving revision 1.16 retrieving revision 1.17 diff -c -r1.16 -r1.17 *** src/usr.bin/cvs/diff_internals.c 2008/01/31 20:11:28 1.16 --- src/usr.bin/cvs/diff_internals.c 2008/02/03 18:18:44 1.17 *************** *** 1,4 **** ! /* $OpenBSD: diff_internals.c,v 1.16 2008/01/31 20:11:28 tobias Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: diff_internals.c,v 1.17 2008/02/03 18:18:44 tobias Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. *************** *** 179,184 **** --- 179,186 ---- static void equiv(struct line *, int, struct line *, int, int *); static void unravel(int); static void unsort(struct line *, int, int *); + static void diff_head(void); + static void rdiff_head(void); static void change(FILE *, FILE *, int, int, int, int); static void sort(struct line *, int); static int ignoreline(char *); *************** *** 194,202 **** static char *match_function(const long *, int, FILE *); static char *preadline(int, size_t, off_t); ! static int aflag, bflag, dflag, iflag, tflag, Tflag, wflag; static int context = 3; int diff_format = D_NORMAL; int diff_pflag = 0; char *diff_file = NULL; RCSNUM *diff_rev1 = NULL; --- 196,205 ---- static char *match_function(const long *, int, FILE *); static char *preadline(int, size_t, off_t); ! static int aflag, bflag, dflag, tflag, Tflag, wflag; static int context = 3; int diff_format = D_NORMAL; + int diff_iflag = 0; int diff_pflag = 0; char *diff_file = NULL; RCSNUM *diff_rev1 = NULL; *************** *** 303,309 **** lastline = 0; lastmatchline = 0; context_vec_ptr = context_vec_start - 1; ! chrtran = (iflag ? cup2low : clow2low); if (out != NULL) diffbuf = out; --- 306,312 ---- lastline = 0; lastmatchline = 0; context_vec_ptr = context_vec_start - 1; ! chrtran = (diff_iflag ? cup2low : clow2low); if (out != NULL) diffbuf = out; *************** *** 634,640 **** ixnew[j] = ctnew += skipline(f2); j++; } ! if (bflag == 1 || wflag == 1 || iflag == 1) { for (;;) { c = getc(f1); d = getc(f2); --- 637,643 ---- ixnew[j] = ctnew += skipline(f2); j++; } ! if (bflag == 1 || wflag == 1 || diff_iflag == 1) { for (;;) { c = getc(f1); d = getc(f2); *************** *** 852,857 **** --- 855,944 ---- return (ret == 0); /* if it matched, it should be ignored. */ } + static void + diff_head(void) + { + char buf[64]; + struct tm *t; + time_t curr_time; + + if (diff_rev1 != NULL) { + t = gmtime(&stb1.st_mtime); + } else { + time(&curr_time); + t = localtime(&curr_time); + } + + (void)strftime(buf, sizeof(buf), "%d %b %G %H:%M:%S -0000", t); + diff_output("%s %s %s", diff_format == D_CONTEXT ? "***" : "---", + diff_file, buf); + + if (diff_rev1 != NULL) { + rcsnum_tostr(diff_rev1, buf, sizeof(buf)); + diff_output("\t%s", buf); + } + + diff_output("\n"); + + if (diff_rev2 != NULL) + t = gmtime(&stb2.st_mtime); + else { + time(&curr_time); + t = localtime(&curr_time); + } + + (void)strftime(buf, sizeof(buf), "%d %b %G %H:%M:%S -0000", t); + diff_output("%s %s %s", diff_format == D_CONTEXT ? "---" : "+++", + diff_file, buf); + + if (diff_rev2 != NULL) { + rcsnum_tostr(diff_rev2, buf, sizeof(buf)); + diff_output("\t%s", buf); + } + + diff_output("\n"); + } + + static void + rdiff_head(void) + { + char buf[64]; + struct tm *t; + time_t curr_time; + + if (diff_rev1 != NULL) { + t = localtime(&stb1.st_mtime); + } else { + time(&curr_time); + t = localtime(&curr_time); + } + + diff_output("%s ", diff_format == D_CONTEXT ? "***" : "---"); + + if (diff_rev1 == NULL) { + diff_output("%s", CVS_PATH_DEVNULL); + t = gmtime(&stb1.st_atime); + } else { + rcsnum_tostr(diff_rev1, buf, sizeof(buf)); + diff_output("%s:%s", diff_file, buf); + } + + (void)strftime(buf, sizeof(buf), "%a %b %e %H:%M:%S %G", t); + diff_output("\t%s\n", buf); + + if (diff_rev2 != NULL) { + t = localtime(&stb2.st_mtime); + } else { + time(&curr_time); + t = localtime(&curr_time); + } + + (void)strftime(buf, sizeof(buf), "%a %b %e %H:%M:%S %G", t); + + diff_output("%s %s %s\n", diff_format == D_CONTEXT ? "---" : "+++", + diff_file, buf); + } + /* * Indicate that there is a difference between lines a and b of the from file * to get to lines c to d of the to file. If a is greater then b then there *************** *** 863,870 **** change(FILE *f1, FILE *f2, int a, int b, int c, int d) { static size_t max_context = 64; - char buf[64]; - struct tm *t; int i; if (diff_format != D_IFDEF && a > b && c > d) --- 950,955 ---- *************** *** 911,945 **** /* * Print the context/unidiff header first time through. */ ! t = localtime(&stb1.st_mtime); ! (void)strftime(buf, sizeof(buf), ! "%d %b %G %H:%M:%S", t); - diff_output("%s %s %s", - diff_format == D_CONTEXT ? "***" : "---", diff_file, - buf); - - if (diff_rev1 != NULL) { - rcsnum_tostr(diff_rev1, buf, sizeof(buf)); - diff_output("\t%s", buf); - } - - diff_output("\n"); - - t = localtime(&stb2.st_mtime); - (void)strftime(buf, sizeof(buf), - "%d %b %G %H:%M:%S", t); - - diff_output("%s %s %s", - diff_format == D_CONTEXT ? "---" : "+++", diff_file, - buf); - - if (diff_rev2 != NULL) { - rcsnum_tostr(diff_rev2, buf, sizeof(buf)); - diff_output("\t%s", buf); - } - - diff_output("\n"); anychange = 1; } else if (a > context_vec_ptr->b + (2 * context) + 1 && c > context_vec_ptr->d + (2 * context) + 1) { --- 996,1006 ---- /* * Print the context/unidiff header first time through. */ ! if (cvs_cmdop == CVS_OP_RDIFF) ! rdiff_head(); ! else ! diff_head(); anychange = 1; } else if (a > context_vec_ptr->b + (2 * context) + 1 && c > context_vec_ptr->d + (2 * context) + 1) { *************** *** 1072,1078 **** sum = 1; space = 0; if (bflag != 1 && wflag != 1) { ! if (iflag == 1) for (i = 0; (t = getc(f)) != '\n'; i++) { if (t == EOF) { if (i == 0) --- 1133,1139 ---- sum = 1; space = 0; if (bflag != 1 && wflag != 1) { ! if (diff_iflag == 1) for (i = 0; (t = getc(f)) != '\n'; i++) { if (t == EOF) { if (i == 0)