From: Eric S. Raymond Date: Fri, 11 Jun 1993 23:59:34 +0000 (+0000) Subject: Tightened pattern recognition for references. X-Git-Tag: 1.6~7 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=63cc70906a8314e0343c5473daae4f2d47624c5e;p=vh.git Tightened pattern recognition for references. --- diff --git a/vh.1 b/vh.1 index d2eb278..6bb09f1 100644 --- a/vh.1 +++ b/vh.1 @@ -118,10 +118,13 @@ wrong places; it will let you know if your index is out of date. If the first character of the text file is not a `=', the code also assumes: -2. Reference targets begin with a `:' at the left margin and are bounded +2. Reference text may not begin with whitespace, single- or double-quote, nor + end with a semicolon. + +3. Reference targets begin with a `:' at the left margin and are bounded on the right by another `:' (an optional second `:' may follow that). -This second rule is useful for filtering out false hits from the index. +These rules are useful for filtering out false hits from the index. .SH FILES A copy of vh called `foo' would require the following: .TP 3.5i diff --git a/vh.c b/vh.c index 8daea7a..e96eaba 100644 --- a/vh.c +++ b/vh.c @@ -1159,6 +1159,7 @@ char *name; long lnum = 1; char refbuf[LNSZ + 1], *refpt = refbuf; int c, len = 0, depth = 0; + bool goforit = FALSE; /* time for consistency check */ initbrowse(name); @@ -1181,18 +1182,19 @@ char *name; ungetc(c = fgetc(vht->fp), vht->fp); if (isprint(c)) ++depth; + goforit = (c != '"' && c != '\'' && !isspace(c)); } else if (depth > 0 && c == RTAG) { ++len; --depth; - if (depth == 0 && refpt != refbuf) + if (depth == 0 && refpt != refbuf && goforit && refpt[-1] != ';') { *refpt = '\0'; if (xlocate(refbuf) < 0) (void) printf(DANGLING, name, TXT, lnum, refbuf); - refpt = refbuf; } + refpt = refbuf; } else if (depth != 0) {