summary refs log tree commit diff
path: root/bin/htagml.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-19 23:33:49 -0500
committerJune McEnroe <june@causal.agency>2021-01-19 23:38:11 -0500
commit959b6cc5b728d67b561becc042e8d37cd4f54a9c (patch)
tree97a7233303e011fd3d8c70126c21c4adff4e6a80 /bin/htagml.c
parentEscape \ and / in mtags search patterns (diff)
downloadsrc-959b6cc5b728d67b561becc042e8d37cd4f54a9c.tar.gz
src-959b6cc5b728d67b561becc042e8d37cd4f54a9c.zip
Prefer tag matches not preceded by [[:alnum:]]
Otherwise the "id" in "void" matches for "void id".
Diffstat (limited to '')
-rw-r--r--bin/htagml.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/bin/htagml.c b/bin/htagml.c
index 8b7255ab..eb5128d1 100644
--- a/bin/htagml.c
+++ b/bin/htagml.c
@@ -182,6 +182,9 @@ int main(int argc, char *argv[]) {
 
 		size_t mlen = strlen(tag->tag);
 		char *match = (pipe ? hstrstr : strstr)(buf, tag->tag);
+		while (match > buf && isalnum(match[-1])) {
+			match = (pipe ? hstrstr : strstr)(&match[mlen], tag->tag);
+		}
 		if (!match && tag->tag[0] == 'M') {
 			mlen = 4;
 			match = (pipe ? hstrstr : strstr)(buf, "main");