]> thyrsus.com Git - comparator.git/commitdiff
Patched version that got sent to Alan Burlison.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 9 Jul 2004 00:34:16 +0000 (00:34 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 9 Jul 2004 00:34:16 +0000 (00:34 +0000)
comparator.spec
comparator.xml
hash.c
hashgen.py
linebyline.c
main.c
shred.h
shredtree.c

index ef6bb72a9b600b90463e8f056f94cfd0478ebb17..1841c6f7b87a5e29fdd4712ba0675ddabbf268e6 100644 (file)
@@ -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 <esr@snark.thyrsus.com> - 2.5-1
+- Alan Burlinson's tweaks to ease porting to SunOS.
+
 * Thu Mar 11 2004 Eric S. Raymond <esr@snark.thyrsus.com> 2.4-1
 - Fixed strtok() bug apparently introduced by C library change.
   Added -n, -f, and -F options to filterator.
index 7dbd34153c749da18d3fcc8e9db0ef964e145d95..4261b86457c94fa565c63acad3436f482db9814a 100644 (file)
@@ -163,7 +163,7 @@ numbers in the output report will nevertheless be correct).</para>
 characters.  This is recommended for comparing C code; it prevents the
 comparison from being fooled by differences in indent style.</para>
 
-<para>The <option>remove_comments</option> option removes comments in
+<para>The <option>remove-comments</option> 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 d6d45ca0f2f8d1988b821a41cda1685aa7b49d31..58737bba257d7f3ac17ff190a41f7f0ff5f0d730 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -1,4 +1,5 @@
 /* hash.c -- hash and digest computation for comparator */
+#include <stdio.h>
 #include "hash.h"
 
 #ifndef FORCE_MD5
index 85bad6c3c7c8178a75db3b326ae7c025a43ed0b8..efad28f6352c926ccbffe2de404b4cb5c23b407a 100755 (executable)
@@ -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 "};"
 
index 795b9ceac5c12a03c788bee477e10fc7ff635392..1ad022fa0e591ba64ae93ea5cc1b3defe39ab0dc 100644 (file)
@@ -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 ca829ffee6dbf9a3757ac656a67d2e5db05403e8..5876d2b4d1941e7c4f69e06297ffd1398a530484 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,10 +1,14 @@
 /* main.c -- main sequence of comparator */
 
+#include <limits.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <stdarg.h>
 #include <string.h>
 #include <stdlib.h>
+#ifdef __sun
+#include <alloca.h>
+#endif
 #include <sys/stat.h>
 #include <errno.h>
 #include <time.h>
@@ -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 d774e993f06ff3ff481f6b16a488d893a517f6e2..ec52954cf71edffbfbd9c089ea0b8a37685e5779 100644 (file)
--- a/shred.h
+++ b/shred.h
@@ -3,6 +3,12 @@
 #include <sys/types.h>
 #include <netinet/in.h>
 
+/* 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 *);
index a87ccf421ce5865fce583c1ec943498e399edc2f..f0615203672e7267181f2baf0dbdc48a4bf5ccfc 100644 (file)
@@ -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);