socsvn commit: r238284 - in soc2012/jhagewood/diff: . diff
jhagewood at FreeBSD.org
jhagewood at FreeBSD.org
Mon Jun 25 20:48:54 UTC 2012
Author: jhagewood
Date: Mon Jun 25 20:48:51 2012
New Revision: 238284
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238284
Log:
Modified:
soc2012/jhagewood/diff/TODO
soc2012/jhagewood/diff/diff/diffreg.c
soc2012/jhagewood/diff/hagewood-diff.patch
Modified: soc2012/jhagewood/diff/TODO
==============================================================================
--- soc2012/jhagewood/diff/TODO Mon Jun 25 19:59:08 2012 (r238283)
+++ soc2012/jhagewood/diff/TODO Mon Jun 25 20:48:51 2012 (r238284)
@@ -17,7 +17,7 @@
--speed-large-file INCOMPLETE
--ignore-tab-expansion IN PROGRESS Functionality implemented in check(), needs debugging. (Same problem as --ignore-blank-lines?)
--width INCOMPLETE
-Fix non-ascii character diffs COMPLETE Changed name of asciifile() to istextfile() and functionality.
+Fix non-ascii character diffs COMPLETE Changed name of asciifile() to istextfile() and checks to see if file is ELF format.
Notes:
@@ -25,9 +25,8 @@
- When using text files with non-ascii characters, diff will interpret them as binary files and output "Files [file1] and [file2] differ."
Very important compatibility problem with GNU diff, which will diff files that aren't strictly ascii.
- Error is associated with asciifile() in diffreg.c
- - FIX: Changed name of asciifile() to istextfile() (more appropriate), and instead of checking if every character in a file is printable, only check
- the first character.
- IMO, This is a sufficient test to check if a file is binary or a text-file.
+ - FIX: Changed name of asciifile() to istextfile() (more appropriate), and instead of checking if every character is ASCII, it checks the first 4 bytes
+ of the file to see if it is ELF format. If so, the file is considered a text file.
- With some files, modification times displayed in the timestamp for file1 are different than the time outputted by GNU diff.
- The -ignore-*-* options need some work.
Modified: soc2012/jhagewood/diff/diff/diffreg.c
==============================================================================
--- soc2012/jhagewood/diff/diff/diffreg.c Mon Jun 25 19:59:08 2012 (r238283)
+++ soc2012/jhagewood/diff/diff/diffreg.c Mon Jun 25 20:48:51 2012 (r238284)
@@ -1344,26 +1344,18 @@
return (sum == 0 ? 1 : sum);
}
-/*
- * Checks to see if a file appears to be a text file.
- */
static int
istextfile(FILE *f)
{
char buf[BUFSIZ];
+ int i, cnt;
if (aflag || f == NULL)
return (1);
rewind(f);
- /*
- * Checks the first 4 bytes of a file to see if it's ELF format.
- * If so, return 0.
- */
fread(buf, 1, sizeof(buf), f);
- if(buf[0] == 0x7F &&
- buf[1] == 0x45 &&
- buf[2] == 0x4C &&
- buf[3] == 0x46);
+ if(buf[0] == 0x7F && buf[1] == 0x45 &&
+ buf[2] == 0x4C && buf[3] == 0x46)
return (0);
return (1);
}
Modified: soc2012/jhagewood/diff/hagewood-diff.patch
==============================================================================
--- soc2012/jhagewood/diff/hagewood-diff.patch Mon Jun 25 19:59:08 2012 (r238283)
+++ soc2012/jhagewood/diff/hagewood-diff.patch Mon Jun 25 20:48:51 2012 (r238284)
@@ -537,7 +537,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-06-25 16:05:53.000000000 -0400
-+++ jhagewood/diff/diff/diffreg.c 2012-06-25 19:42:00.000000000 -0400
++++ jhagewood/diff/diff/diffreg.c 2012-06-25 19:58:16.000000000 -0400
@@ -62,15 +62,13 @@
* @(#)diffreg.c 8.1 (Berkeley) 6/6/93
*/
@@ -1042,13 +1042,9 @@
sum = 1;
space = 0;
-@@ -1305,19 +1344,26 @@ readhash(FILE *f)
- return (sum == 0 ? 1 : sum);
+@@ -1306,18 +1345,17 @@ readhash(FILE *f)
}
-+/*
-+ * Checks to see if a file appears to be a text file.
-+ */
static int
-asciifile(FILE *f)
+istextfile(FILE *f)
@@ -1056,6 +1052,7 @@
- char buf[BUFSIZ];
- int i, cnt;
+ char buf[BUFSIZ];
++ int i, cnt;
if (aflag || f == NULL)
return (1);
@@ -1064,19 +1061,13 @@
- cnt = fread(buf, 1, sizeof(buf), f);
- for (i = 0; i < cnt; i++)
- if (!isprint(buf[i]) && !isspace(buf[i]))
-+ /*
-+ * Checks the first 4 bytes of a file to see if it's ELF format.
-+ * If so, return 0.
-+ */
+ fread(buf, 1, sizeof(buf), f);
-+ if(buf[0] == 0x7F &&
-+ buf[1] == 0x45 &&
-+ buf[2] == 0x4C &&
-+ buf[3] == 0x46);
++ if(buf[0] == 0x7F && buf[1] == 0x45 &&
++ buf[2] == 0x4C && buf[3] == 0x46)
return (0);
return (1);
}
-@@ -1327,10 +1373,10 @@ asciifile(FILE *f)
+@@ -1327,10 +1365,10 @@ asciifile(FILE *f)
static char *
match_function(const long *f, int pos, FILE *file)
{
@@ -1091,7 +1082,7 @@
lastline = pos;
while (pos > last) {
-@@ -1342,7 +1388,6 @@ match_function(const long *f, int pos, F
+@@ -1342,7 +1380,6 @@ match_function(const long *f, int pos, F
if (nc > 0) {
buf[nc] = '\0';
buf[strcspn(buf, "\n")] = '\0';
@@ -1099,7 +1090,7 @@
if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
if (begins_with(buf, "private:")) {
if (!state)
-@@ -1373,9 +1418,9 @@ static void
+@@ -1373,9 +1410,9 @@ static void
dump_context_vec(FILE *f1, FILE *f2)
{
struct context_vec *cvp = context_vec_start;
@@ -1112,7 +1103,7 @@
if (context_vec_start > context_vec_ptr)
return;
-@@ -1390,8 +1435,8 @@ dump_context_vec(FILE *f1, FILE *f2)
+@@ -1390,8 +1427,8 @@ dump_context_vec(FILE *f1, FILE *f2)
if (pflag) {
f = match_function(ixold, lowa-1, f1);
if (f != NULL) {
@@ -1123,7 +1114,7 @@
}
}
printf("\n*** ");
-@@ -1478,9 +1523,9 @@ static void
+@@ -1478,9 +1515,9 @@ static void
dump_unified_vec(FILE *f1, FILE *f2)
{
struct context_vec *cvp = context_vec_start;
@@ -1136,7 +1127,7 @@
if (context_vec_start > context_vec_ptr)
return;
-@@ -1491,19 +1536,19 @@ dump_unified_vec(FILE *f1, FILE *f2)
+@@ -1491,19 +1528,19 @@ dump_unified_vec(FILE *f1, FILE *f2)
lowc = MAX(1, cvp->c - context);
upd = MIN(len[1], context_vec_ptr->d + context);
@@ -1162,7 +1153,7 @@
/*
* Output changes in "unified" diff format--the old and new lines
-@@ -1551,16 +1596,43 @@ dump_unified_vec(FILE *f1, FILE *f2)
+@@ -1551,16 +1588,43 @@ dump_unified_vec(FILE *f1, FILE *f2)
static void
print_header(const char *file1, const char *file2)
{
More information about the svn-soc-all
mailing list