From 822f710ade459954384d9f6980c156b73c5ad198 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Tue, 19 Jan 2021 23:33:49 -0500 Subject: Prefer tag matches not preceded by [[:alnum:]] Otherwise the "id" in "void" matches for "void id". --- bin/htagml.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bin/htagml.c') diff --git a/bin/htagml.c b/bin/htagml.c index 3d555dc8..a3a4101d 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"); -- cgit 1.4.1