Date: Thu, 05 Jul 2012 04:20:31 +0000 From: jhagewood@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r238986 - in soc2012/jhagewood: diff diff/diff sdiff sdiff/sdiff Message-ID: <20120705042031.886B3106566B@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhagewood Date: Thu Jul 5 04:20:30 2012 New Revision: 238986 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238986 Log: Modified: soc2012/jhagewood/diff/diff/diffreg.c soc2012/jhagewood/diff/hagewood-diff.patch soc2012/jhagewood/sdiff/hagewood-sdiff.patch soc2012/jhagewood/sdiff/sdiff/sdiff.c Modified: soc2012/jhagewood/diff/diff/diffreg.c ============================================================================== --- soc2012/jhagewood/diff/diff/diffreg.c Thu Jul 5 00:52:23 2012 (r238985) +++ soc2012/jhagewood/diff/diff/diffreg.c Thu Jul 5 04:20:30 2012 (r238986) @@ -1354,22 +1354,20 @@ static int istextfile(FILE *f) { - char buf[BUFSIZ]; - int cnt, check_size; + int i, check_size; + char ch; if (aflag || f == NULL) return (1); rewind(f); - fread(buf, 1, BUFSIZ, f); - if (BUFSIZ >= MAX_CHECK) - check_size = MAX_CHECK; - else - check_size = BUFSIZ; - /* - * XXX Currently returns NULL even for file with no NULL chars? - if (memchr(buf, '\0', check_size) != NULL) { - return (0); - }*/ + for (i = 0; i <= MAX_CHECK || ch != EOF; i++) { + ch = fgetc(f); + if (ch == '\0') { + rewind(f); + return (0); + } + } + rewind(f); return (1); } Modified: soc2012/jhagewood/diff/hagewood-diff.patch ============================================================================== --- soc2012/jhagewood/diff/hagewood-diff.patch Thu Jul 5 00:52:23 2012 (r238985) +++ soc2012/jhagewood/diff/hagewood-diff.patch Thu Jul 5 04:20:30 2012 (r238986) @@ -664,7 +664,7 @@ if (stat(path1, &stb1) != 0) { diff -rupN jhagewood/diff/diff-orig/diffreg.c jhagewood/diff/diff/diffreg.c --- jhagewood/diff/diff-orig/diffreg.c 2012-07-02 15:05:57.000000000 -0400 -+++ jhagewood/diff/diff/diffreg.c 2012-07-03 16:22:08.000000000 -0400 ++++ jhagewood/diff/diff/diffreg.c 2012-07-05 04:19:42.000000000 -0400 @@ -62,15 +62,13 @@ * @(#)diffreg.c 8.1 (Berkeley) 6/6/93 */ @@ -1178,7 +1178,7 @@ sum = 1; space = 0; -@@ -1305,20 +1346,30 @@ readhash(FILE *f) +@@ -1305,20 +1346,28 @@ readhash(FILE *f) return (sum == 0 ? 1 : sum); } @@ -1193,8 +1193,8 @@ { - char buf[BUFSIZ]; - int i, cnt; -+ char buf[BUFSIZ]; -+ int cnt, check_size; ++ int i, check_size; ++ char ch; if (aflag || f == NULL) return (1); @@ -1203,21 +1203,18 @@ - cnt = fread(buf, 1, sizeof(buf), f); - for (i = 0; i < cnt; i++) - if (!isprint(buf[i]) && !isspace(buf[i])) -- return (0); -+ fread(buf, 1, BUFSIZ, f); -+ if (BUFSIZ >= MAX_CHECK) -+ check_size = MAX_CHECK; -+ else -+ check_size = BUFSIZ; -+ /* -+ * XXX Currently returns NULL even for file with no NULL chars? -+ if (memchr(buf, '\0', check_size) != NULL) { -+ return (0); -+ }*/ ++ for (i = 0; i <= MAX_CHECK || ch != EOF; i++) { ++ ch = fgetc(f); ++ if (ch == '\0') { ++ rewind(f); + return (0); ++ } ++ } ++ rewind(f); return (1); } -@@ -1327,10 +1378,10 @@ asciifile(FILE *f) +@@ -1327,10 +1376,10 @@ asciifile(FILE *f) static char * match_function(const long *f, int pos, FILE *file) { @@ -1232,7 +1229,7 @@ lastline = pos; while (pos > last) { -@@ -1342,7 +1393,6 @@ match_function(const long *f, int pos, F +@@ -1342,7 +1391,6 @@ match_function(const long *f, int pos, F if (nc > 0) { buf[nc] = '\0'; buf[strcspn(buf, "\n")] = '\0'; @@ -1240,7 +1237,7 @@ if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { if (begins_with(buf, "private:")) { if (!state) -@@ -1373,9 +1423,9 @@ static void +@@ -1373,9 +1421,9 @@ static void dump_context_vec(FILE *f1, FILE *f2) { struct context_vec *cvp = context_vec_start; @@ -1253,7 +1250,7 @@ if (context_vec_start > context_vec_ptr) return; -@@ -1390,8 +1440,8 @@ dump_context_vec(FILE *f1, FILE *f2) +@@ -1390,8 +1438,8 @@ dump_context_vec(FILE *f1, FILE *f2) if (pflag) { f = match_function(ixold, lowa-1, f1); if (f != NULL) { @@ -1264,7 +1261,7 @@ } } printf("\n*** "); -@@ -1478,9 +1528,9 @@ static void +@@ -1478,9 +1526,9 @@ static void dump_unified_vec(FILE *f1, FILE *f2) { struct context_vec *cvp = context_vec_start; @@ -1277,7 +1274,7 @@ if (context_vec_start > context_vec_ptr) return; -@@ -1491,19 +1541,19 @@ dump_unified_vec(FILE *f1, FILE *f2) +@@ -1491,19 +1539,19 @@ dump_unified_vec(FILE *f1, FILE *f2) lowc = MAX(1, cvp->c - context); upd = MIN(len[1], context_vec_ptr->d + context); @@ -1303,7 +1300,7 @@ /* * Output changes in "unified" diff format--the old and new lines -@@ -1551,16 +1601,43 @@ dump_unified_vec(FILE *f1, FILE *f2) +@@ -1551,16 +1599,43 @@ dump_unified_vec(FILE *f1, FILE *f2) static void print_header(const char *file1, const char *file2) { Modified: soc2012/jhagewood/sdiff/hagewood-sdiff.patch ============================================================================== --- soc2012/jhagewood/sdiff/hagewood-sdiff.patch Thu Jul 5 00:52:23 2012 (r238985) +++ soc2012/jhagewood/sdiff/hagewood-sdiff.patch Thu Jul 5 04:20:30 2012 (r238986) @@ -1,6 +1,6 @@ diff -rupN jhagewood/sdiff/sdiff-orig/sdiff.c jhagewood/sdiff/sdiff/sdiff.c --- jhagewood/sdiff/sdiff-orig/sdiff.c 2012-07-02 15:05:58.000000000 -0400 -+++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-03 16:56:41.000000000 -0400 ++++ jhagewood/sdiff/sdiff/sdiff.c 2012-07-03 17:10:59.000000000 -0400 @@ -34,7 +34,7 @@ #include "common.h" #include "extern.h" @@ -20,18 +20,16 @@ /* pid from the diff parent (if applicable) */ DIFF_PID, -@@ -363,7 +364,9 @@ main(int argc, char **argv) +@@ -363,7 +364,7 @@ main(int argc, char **argv) diffargv[diffargc++] = NULL; /* Subtract column divider and divide by two. */ - width = (wflag - 3) / 2; + width = ((wflag - 3) / 2) - 2; -+ if (!wflag) -+ width = ((wflag - 3) / 2); /* Make sure line_width can fit in size_t. */ if (width > (SIZE_MAX - 3) / 2) errx(2, "width is too large: %zu", width); -@@ -383,7 +386,6 @@ main(int argc, char **argv) +@@ -383,7 +384,6 @@ main(int argc, char **argv) err(2, "child could not duplicate descriptor"); /* Free unused descriptor. */ close(fd[1]); Modified: soc2012/jhagewood/sdiff/sdiff/sdiff.c ============================================================================== --- soc2012/jhagewood/sdiff/sdiff/sdiff.c Thu Jul 5 00:52:23 2012 (r238985) +++ soc2012/jhagewood/sdiff/sdiff/sdiff.c Thu Jul 5 04:20:30 2012 (r238986) @@ -365,8 +365,6 @@ /* Subtract column divider and divide by two. */ width = ((wflag - 3) / 2) - 2; - if (!wflag) - width = ((wflag - 3) / 2); /* Make sure line_width can fit in size_t. */ if (width > (SIZE_MAX - 3) / 2) errx(2, "width is too large: %zu", width);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120705042031.886B3106566B>