xmlto html-nochunks scf-standard.xml
test1: comparator
- @comparator -w -C -d test test1-a test1-b
+ @comparator -C -d test test1-a test1-b
test2: comparator
- @comparator -w -C -d test test2-a test2-b
+ @comparator -C -d test test2-a test2-b
test3: comparator
- @comparator -w -C -d test test3-a test3-b
+ @comparator -C -d test test3-a test3-b
install: comparator.1 uninstall
install -m 755 -o 0 -g 0 -d $(ROOT)/usr/bin/
<cmdsynopsis>
<command>comparator</command>
<arg choice='opt'>-c</arg>
+ <arg choice='opt'>-C</arg>
<arg choice='opt'>-d <replaceable>dir</replaceable></arg>
<arg choice='opt'>-o <replaceable>file</replaceable></arg>
+ <arg choice='opt'>-r</arg>
<arg choice='opt'>-s <replaceable>shredsize</replaceable></arg>
<arg choice='opt'>-w</arg>
- <arg choice='opt'>-C</arg>
<arg choice='opt'>-x</arg>
<arg choice='plain' rep='repeat'>path</arg>
<sbr/>
removed. This is recommended for comparing C code; it prevents the
comparison from being fooled by differences in indent style.</para>
+<para>The <option>-r</option> option removes comments. This is
+only effective in conjunction with <option>-C</option>.</para>
+
<para>The <option>-x</option> enables some debugging output. It
is for developers; if you need to understand it, read the code.</para>
buf[0] = '\0';
if (remove_whitespace)
strcat(buf, "remove-whitespace,");
+ if (remove_comments)
+ strcat(buf, "remove-comments,");
if (remove_braces)
strcat(buf, "remove-braces,");
if (buf[0])
static void usage(void)
{
- fprintf(stderr,"usage: shredtree [-c] [-d dir ] [-o file] [-s shredsize] [-w] [-x] path...\n");
+ fprintf(stderr,"usage: comparator [-c] [-C] [-d dir ] [-r] [-o file] [-s shredsize] [-w] [-x] path...\n");
fprintf(stderr," -c = generate SCF files\n");
+ fprintf(stderr," -C = apply C normalizations\n");
fprintf(stderr," -d dir = change directory before digesting.\n");
fprintf(stderr," -o file = write to the specified file.\n");
+ fprintf(stderr," -r = renove comments\n");
fprintf(stderr," -s size = set shred size (default %d)\n", shredsize);
fprintf(stderr," -w = remove whitespace.\n");
fprintf(stderr," -x = debug, display chunks in output.\n");
compile_only = file_only = 0;
dir = outfile = NULL;
- while ((status = getopt(argc, argv, "cCd:ho:s:wx")) != EOF)
+ while ((status = getopt(argc, argv, "cCd:ho:rs:wx")) != EOF)
{
switch (status)
{
break;
case 'C':
- remove_braces = 1;
+ remove_whitespace = remove_braces = 1;
break;
case 'd':
outfile = optarg;
break;
+ case 'r':
+ remove_comments = 1;
+
case 's':
shredsize = atoi(optarg);
break;
dummy_scf.hash_method = "MD5";
buf[0] == '\0';
if (remove_whitespace)
- strcat(buf, "remove-whitespace,");
+ strcat(buf, "remove-whitespace, ");
+ if (remove_comments)
+ strcat(buf, "remove-comments, ");
if (remove_braces)
- strcat(buf, "remove-braces,");
+ strcat(buf, "remove-braces, ");
if (buf[0])
buf[strlen(buf)-1] = '\0';
else
/* control bits, meant to be set at startup */
extern int remove_braces;
extern int remove_whitespace;
+extern int remove_comments;
extern int debug;
extern int shredsize;
/* control bits, meant to be set at startup */
int remove_braces = 0;
int remove_whitespace = 0;
+int remove_comments = 0;
int shredsize = 3;
struct item
static int normalize(char *buf)
/* normalize a buffer in place, return 0 if it should be skipped */
{
+ if (remove_comments && remove_braces) /* remove_c_comments */
+ {
+ char *start = strstr(buf, "/*"), *end = strstr(buf, "*/");
+
+ if (start && end && start < end)
+ strcpy(start, end+2);
+ }
if (remove_whitespace) /* strip whitespace, ignore blank lines */
{
char *tp, *sp;