/* return flags that apply to this line */
{
if (active == 0)
- return(SIGNIFICANT);
+ return(0);
else
{
char *sp, *tp;
char buf[BUFSIZ];
- int changed, significant;
+ int changed, insignificant;
/* change all punctuation to spaces */
buf[0] = ' ';
} while
(changed);
-
- significant = !(buf[0] == '\0' || strspn(buf, " ") == strlen(buf));
-
- return (active | (significant ? SIGNIFICANT : 0));
+ return (buf[0] == '\0' || strspn(buf, " ") == strlen(buf));
}
}
/* dump tokens corresponding to a flag set */
{
fputc(' ', fp);
- if (flags & SIGNIFICANT)
- fputs(" significant", fp);
+ if (flags & INSIGNIFICANT)
+ fputs(" insignificant", fp);
if (flags & C_CODE)
fputs(" C", fp);
if (flags & SHELL_CODE)
{
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;
+ /*
+ * The insignificance bit in the merged range should be cleared
+ * if the range being merged in is significant. This is important;
+ * it means that significance propagates as spabs merge.
+ */
+ p[i].hash.flags &=~ q[i].hash.flags;
q[i].hash.flags = INTERNAL_FLAG; /* used only in debug code */
}
return(1);
if (matchsize >= maxsize)
maxsize = matchsize;
+
+ /*
+ * This odd-looking bit of logic, deals with an
+ * annoying edge case. Sometimes we'll get boilerplate C
+ * stuff in both a C and a text file. To cope, propagate
+ * insignificance -- if we know from one context that a
+ * particular span of text is not interesting, declare it
+ * uninteresting everywhere.
+ */
flags |= rp->hash.flags;
}
* point of doing it this way is to allow significance bits to
* propagate through range merges.
*/
- if (maxsize < minsize || !(nofilter || (flags & SIGNIFICANT)))
+ if (maxsize < minsize || (!nofilter && (flags & INSIGNIFICANT)))
continue;
for (i=0; i < match->nmatches; i++)
linenum_t start, end;
hashval_t hash;
flag_t flags;
-#define SIGNIFICANT 0x40 /* something in this is not pure syntax */
+#define INSIGNIFICANT 0x40 /* pure syntax in a programming language */
#define C_CODE 0x01 /* identified as C code */
#define SHELL_CODE 0x02 /* identified as shell code */
#define CATEGORIZED 0x03 /* we can significance-test this */
/* create new shred */
display[shredsize-1].line = strdup(buf);
display[shredsize-1].start = linecount;
- display[shredsize-1].flags = filter_pass(buf);
+ display[shredsize-1].flags = filter_pass(buf) ? INSIGNIFICANT : 0;
/* flush completed chunk */
if (accepted >= shredsize)