Module Name: othersrc Committed By: agc Date: Mon Jan 14 05:20:40 UTC 2013
Modified Files: othersrc/external/bsd/netdiff/dist: diffreg.c Log Message: minor cosmetics - also ignore case if we're using our (abstracted) fread() eqivalent function, not just in the single character case. This wouldn't have produced wrong results, but would have made it much more inefficient, since the initial "do files differ?" question would have given a false positive. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 othersrc/external/bsd/netdiff/dist/diffreg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: othersrc/external/bsd/netdiff/dist/diffreg.c diff -u othersrc/external/bsd/netdiff/dist/diffreg.c:1.5 othersrc/external/bsd/netdiff/dist/diffreg.c:1.6 --- othersrc/external/bsd/netdiff/dist/diffreg.c:1.5 Mon Jan 14 01:54:23 2013 +++ othersrc/external/bsd/netdiff/dist/diffreg.c Mon Jan 14 05:20:40 2013 @@ -353,15 +353,25 @@ diff_ftell(file_t *f) } static size_t -diff_fread(void *ptr, size_t size, size_t c, file_t *f) +diff_fread(diff_t *diff, void *ptr, size_t size, size_t c, file_t *f) { + size_t cc; + size_t i; + char *p; + if (f->mapped) { memcpy(ptr, &f->mapped[f->curpos], c * size); f->curpos += (c * size); - return c; + cc = c; } else { - return fread(ptr, size, c, f->fp); + cc = fread(ptr, size, c, f->fp); } + if (DIFF_GET_FLAG(diff, 'i')) { + for (i = 0, p = ptr ; i < cc ; i++) { + p[i] = tolower((uint8_t)p[i]); + } + } + return cc; } static int @@ -420,27 +430,27 @@ diff_fsetpos(file_t *f, const fpos_t *po static int files_differ(diff_t *diff, file_t *f, int flags) { - char buf1[BUFSIZ], buf2[BUFSIZ]; - size_t i, j; + size_t cc[2]; + char buf1[BUFSIZ * 10]; + char buf2[BUFSIZ * 10]; if ((flags & (D_EMPTY1|D_EMPTY2)) || diff->st[0].st_size != diff->st[1].st_size || (diff->st[0].st_mode & S_IFMT) != (diff->st[1].st_mode & S_IFMT)) { return 1; } for (;;) { - i = diff_fread(buf1, 1, sizeof(buf1), &f[0]); - j = diff_fread(buf2, 1, sizeof(buf2), &f[1]); - - if (i != j) { + cc[0] = diff_fread(diff, buf1, 1, sizeof(buf1), &f[0]); + cc[1] = diff_fread(diff, buf2, 1, sizeof(buf2), &f[1]); + if (cc[0] != cc[1]) { return 1; } - if (i == 0 && j == 0) { + if (cc[0] == 0 && cc[1] == 0) { if (diff_ferror(&f[0]) || diff_ferror(&f[1])) { return 1; } return 0; } - if (memcmp(buf1, buf2, i) != 0) { + if (memcmp(buf1, buf2, cc[0]) != 0) { return 1; } } @@ -1057,7 +1067,7 @@ print_context_header(diff_t *diff, const #define ISIDENT(x) (isalpha((uint8_t)x) || (x) == '_' || (x) == '$') static char * -match_function(stone_t *s, const long *offsets, int lineno, file_t *f) +match_function(diff_t *diff, stone_t *s, const long *offsets, int lineno, file_t *f) { const char *state; size_t nc; @@ -1072,7 +1082,7 @@ match_function(stone_t *s, const long *o if (nc >= sizeof(buf)) { nc = sizeof(buf) - 1; } - nc = diff_fread(buf, 1, nc, f); + nc = diff_fread(diff, buf, 1, nc, f); if (nc > 0) { buf[nc] = '\0'; buf[strcspn(buf, "\n")] = '\0'; @@ -1241,7 +1251,7 @@ dump_context_vec(diff_t *diff, stone_t * diff_printf(diff, "***************"); if (SHOW_C_FUNCTION(diff)) { - func = match_function(s, f[0].offsets, lowa-1, &f[0]); + func = match_function(diff, s, f[0].offsets, lowa-1, &f[0]); if (func != NULL) { diff_printf(diff, " %s", func); } @@ -1343,7 +1353,7 @@ dump_unified_vec(diff_t *diff, stone_t * uni_range(diff, lowc, upd); diff_printf(diff, " @@"); if (SHOW_C_FUNCTION(diff)) { - func = match_function(s, f[0].offsets, lowa-1, &f[0]); + func = match_function(diff, s, f[0].offsets, lowa-1, &f[0]); if (func != NULL) { diff_printf(diff, " %s", func); }