From 14bf063c29b6a10b1e1dbbab099875a0de14c419 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 9 Jul 2004 00:34:16 +0000 Subject: [PATCH] Patched version that got sent to Alan Burlison. --- comparator.spec | 5 ++++- comparator.xml | 2 +- hash.c | 1 + hashgen.py | 2 +- linebyline.c | 4 ++-- main.c | 11 ++++++----- shred.h | 8 +++++++- shredtree.c | 8 ++++---- 8 files changed, 26 insertions(+), 15 deletions(-) diff --git a/comparator.spec b/comparator.spec index ef6bb72..1841c6f 100644 --- a/comparator.spec +++ b/comparator.spec @@ -1,6 +1,6 @@ Name: comparator Summary: fast comparison of large source-code trees -Version: 2.4 +Version: 2.5 Release: 1 License: GPL Group: Utilities @@ -44,6 +44,9 @@ cp comparator.py "$RPM_BUILD_ROOT"${pylib} %{_libdir}/python*/site-packages/comparator.py %changelog +* Thu Jul 8 2004 Eric S. Raymond - 2.5-1 +- Alan Burlinson's tweaks to ease porting to SunOS. + * Thu Mar 11 2004 Eric S. Raymond 2.4-1 - Fixed strtok() bug apparently introduced by C library change. Added -n, -f, and -F options to filterator. diff --git a/comparator.xml b/comparator.xml index 7dbd341..4261b86 100644 --- a/comparator.xml +++ b/comparator.xml @@ -163,7 +163,7 @@ numbers in the output report will nevertheless be correct). characters. This is recommended for comparing C code; it prevents the comparison from being fooled by differences in indent style. -The option removes comments in +The option removes comments in C files, All // comments are removed, but only "winged" /* comments with the start and end of comment on the same line are ignored; also, block /* comments are retained, but the beginning /* and ending */ are diff --git a/hash.c b/hash.c index d6d45ca..58737bb 100644 --- a/hash.c +++ b/hash.c @@ -1,4 +1,5 @@ /* hash.c -- hash and digest computation for comparator */ +#include #include "hash.h" #ifndef FORCE_MD5 diff --git a/hashgen.py b/hashgen.py index 85bad6c..efad28f 100755 --- a/hashgen.py +++ b/hashgen.py @@ -15,7 +15,7 @@ def tablegen(maxlen, width): sys.stdout.write('\n\t') m = md5.new() m.update(`i` + `j`) - sys.stdout.write('0x' + m.hexdigest()[-(width*2):] + "LL,") + sys.stdout.write('0x' + m.hexdigest()[-(width*2):] + "ULL,") print "}, /* end char %02x */" % i print "};" diff --git a/linebyline.c b/linebyline.c index 795b9ce..1ad022f 100644 --- a/linebyline.c +++ b/linebyline.c @@ -54,7 +54,7 @@ static regex_t shell_regexps[sizeof(shell_patterns)/sizeof(*shell_patterns)]; static linenum_t linecount; -int analyzer_init(unsigned char *buf) +int analyzer_init(const char *buf) /* initialize line filtering */ { int i; @@ -75,7 +75,7 @@ int analyzer_init(unsigned char *buf) exit(1); } - cp = strtok(strdup(buf), ", "); + cp = strtok(strdup((const char *)buf), ", "); if (strcmp(cp, "line-oriented")) return(1); while (cp = strtok(NULL, ", ")) diff --git a/main.c b/main.c index ca829ff..5876d2b 100644 --- a/main.c +++ b/main.c @@ -1,10 +1,14 @@ /* main.c -- main sequence of comparator */ +#include #include #include #include #include #include +#ifdef __sun +#include +#endif #include #include #include @@ -509,11 +513,8 @@ main(int argc, char *argv[]) /* special case if user gave exactly one tree */ if (!compile_only && argcount == 1) { - char *olddir = NULL; - if (dir) { - olddir = getcwd(NULL, 0); /* may fail off Linux */ chdir(dir); } write_scf(argv[optind], redirect(outfile)); @@ -548,7 +549,7 @@ main(int argc, char *argv[]) if (dir) { - olddir = getcwd(NULL, 0); /* may fail off Linux */ + olddir = getcwd(NULL, PATH_MAX); chdir(dir); } write_scf(source, ofp); @@ -560,7 +561,7 @@ main(int argc, char *argv[]) { if (dir) { - olddir = getcwd(NULL, 0); /* may fail off Linux */ + olddir = getcwd(NULL, PATH_MAX); chdir(dir); } init_scf(source, scf, 0); diff --git a/shred.h b/shred.h index d774e99..ec52954 100644 --- a/shred.h +++ b/shred.h @@ -3,6 +3,12 @@ #include #include +/* Solaris typedefs */ +#ifdef __sun +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; +#endif + #ifndef LARGEFILES /* * 65,536 lines should be enough, but make it possible to compile with 32 bits. @@ -59,7 +65,7 @@ feature_t; struct analyzer_t /* structure describing a feature analyzer */ { - int (*init)(unsigned char *); + int (*init)(const char *); void (*mode)(int); feature_t *(*get)(const struct filehdr_t *, FILE *, linenum_t *); void (*free)(const char *); diff --git a/shredtree.c b/shredtree.c index a87ccf4..f061520 100644 --- a/shredtree.c +++ b/shredtree.c @@ -42,14 +42,14 @@ static int file_count; static int eligible(const char *file) /* is the specified file eligible to be compared? */ { + if (strstr(file, "CVS") || strstr(file,"RCS") || strstr(file,"SCCS")) + return(0); /* fast check for the most common suffixes */ #define endswith(suff) !strcmp(suff, file + strlen(file) - strlen(suff)) - if (endswith(".c") || endswith(".h") || endswith(".html")) + else if (endswith(".c") || endswith(".h") || endswith(".html")) return(1); else if (endswith(".o") || endswith("~") || endswith(".bdf")) return(0); - else if (strstr(file, "CVS") || strstr(file,"RCS") || strstr(file,"SCCS")) - return(0); #undef endswith else { @@ -100,7 +100,7 @@ static struct hash_t emit_chunk(shred *display, int linecount) { if (debug) fprintf(stderr, "%d (%02x): '%s'\n", i, display[i].flags, display[i].feature); - hash_update(display[i].feature, strlen(display[i].feature)); + hash_update((unsigned char*) display[i].feature, strlen(display[i].feature)); out.flags |= display[i].flags; } hash_complete(&out.hash); -- 2.43.0