static char *c_patterns[] = {
/* Idioms that don't convey any meaning in isolation */
- "return [a-z]+", "return -?[01]+",
- "goto +[a-z]+", "exit *\\([01]\\)",
+ "return [a-z]+", "return [01]+",
+ "goto +[a-z]+", "exit *[01]",
/* Pragmas */
- "/\\* *ARGSUSED *\\*/",
- "/\\* *NOTREACHED *\\*/",
- "/\\* *FALL *THRO?UG?H? *\\*/",
+ " ARGSUSED ",
+ " NOTREACHED ",
+ " FALL *THRO?UG?H? ",
/* Bare C keywords */
" auto ", " break ", " case "," continue ", " default ", " do ", " else ",
" enum ", " if ", " goto "," return ", " switch ", " while ", " int ",
" long ", " short ", " static ", " struct ", " typedef ", " union ",
" void ",
- /* Preprocessor constructs (# has already been stripped)*/
- "^ *define","^ *endif","^ *else", "^ *ifdef ","^ *ifndef ",
+ /* Preprocessor constructs (# has already been stripped) */
+ "^ define"," endif"," else", " ifdef "," ifndef ",
/* Common preprocessor macros, not significant by themselves. */
" ASSERT ", " EXTERN ", " FALSE ", " NULL "," STATIC ", " TRUE ",
/* Macro include lines are noise, too. */
- "^ *include.*","^ *line.*",
+ " include .*"," line .*",
/* Common error macros. */
" EFAULT ",
" EINVAL ",
fputs(legend, stdout);
for (np = obarray; np < obarray + hashcount; np++)
- {
- fprintf(stdout, "%2d: %s %s:%d:%d",
- np-obarray,
- hash_dump(np->hash.hash),
- np->file->name, np->hash.start, np->hash.end);
- if (np->hash.flags)
+ if (!(np->hash.flags & INTERNAL_FLAG))
{
- fputc('\t', stdout);
- dump_flags(np->hash.flags, stdout);
- fprintf(stdout, " (0x%02x)", np->hash.flags);
+ fprintf(stdout, "%2d: %s %s:%d:%d",
+ np-obarray,
+ hash_dump(np->hash.hash),
+ np->file->name, np->hash.start, np->hash.end);
+ if (np->hash.flags)
+ {
+ fputc('\t', stdout);
+ dump_flags(np->hash.flags, stdout);
+ fprintf(stdout, " (0x%02x)", np->hash.flags);
+ }
+ fputc('\n', stdout);
}
- fputc('\n', stdout);
- }
}
void report_time(char *legend, ...)
p[i].hash.start = min(p[i].hash.start, q[i].hash.start);
p[i].hash.end = max(p[i].hash.end, q[i].hash.end);
p[i].hash.flags |= q[i].hash.flags;
+ q[i].hash.flags = INTERNAL_FLAG; /* used only in debug code */
}
return(1);
}
* The technique: first mark...
*/
if (SORTHASHCMP(obarray, obarray+1))
- obarray[0].hash.flags = UNIQUE_FLAG;
+ obarray[0].hash.flags = INTERNAL_FLAG;
for (np = obarray+1; np < obarray + hashcount-1; np++)
if (SORTHASHCMP(np, np-1) && SORTHASHCMP(np, np+1))
- np->hash.flags = UNIQUE_FLAG;
+ np->hash.flags = INTERNAL_FLAG;
if (SORTHASHCMP(obarray+hashcount-2, obarray+hashcount-1))
- obarray[hashcount-1].hash.flags = UNIQUE_FLAG;
+ obarray[hashcount-1].hash.flags = INTERNAL_FLAG;
/* ...then sweep. */
for (mp = np = obarray; np < obarray + hashcount; np++)
- if (np->hash.flags != UNIQUE_FLAG)
+ if (np->hash.flags != INTERNAL_FLAG)
*mp++ = *np;
/* now we get to reduce the memory footprint */
report_time("Compaction reduced %d shreds to %d",
if (!sametree(np[i].file->name, np[(i+1) % nmatches].file->name))
heterogenous++;
if (!heterogenous)
+ {
+ np[i].hash.flags = INTERNAL_FLAG; /* used only in debug code */
continue;
+ }
if (debug)
{
dump_array("After removing uniques.\n", obarray, hashcount);
report_time("%d range groups after removing unique hashes", matchcount);
mergecount = collapse_ranges(hitlist, matchcount);
+ if (debug)
+ dump_array("After merging ranges.\n", obarray, hashcount);
report_time("%d range groups after merging", mergecount);
/*
#define C_CODE 0x01 /* identified as C code */
#define SHELL_CODE 0x02 /* identified as shell code */
#define CATEGORIZED 0x03 /* we can significance-test this */
-#define UNIQUE_FLAG 0x80 /* internal use only */
+#define INTERNAL_FLAG 0x80 /* internal use only */
};
#define SORTHASHCMP(s, t) hash_compare((s)->hash.hash, (t)->hash.hash)
#define endswith(suff) !strcmp(suff, file + strlen(file) - strlen(suff))
if (endswith(".c") || endswith(".h") || endswith(".html"))
return(1);
- else if (endswith(".o") || endswith("~"))
+ else if (endswith(".o") || endswith("~") || endswith(".bdf"))
return(0);
else if (strstr(file, "CVS") || strstr(file,"RCS") || strstr(file,"SCCS"))
return(0);