From 68618a758d40b09cf2775fe881653310e1f14fdb Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Fri, 15 Jan 2021 15:06:31 -0500 Subject: Simplyify htagml match output --- bin/htagml.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'bin') diff --git a/bin/htagml.c b/bin/htagml.c index b95f6a96..f6971de4 100644 --- a/bin/htagml.c +++ b/bin/htagml.c @@ -51,7 +51,7 @@ static size_t escape(bool esc, const char *ptr, size_t len) { return len; } -static char *hstrstr(char *haystack, char *needle) { +static char *hstrstr(const char *haystack, const char *needle) { while (haystack) { char *elem = strchr(haystack, '<'); char *match = strstr(haystack, needle); @@ -169,25 +169,25 @@ int main(int argc, char *argv[]) { continue; } - char *text = tag->tag; - char *match = (pipe ? hstrstr(buf, text) : strstr(buf, text)); + size_t mlen = strlen(tag->tag); + char *match = (pipe ? hstrstr : strstr)(buf, tag->tag); if (!match && tag->tag[0] == 'M') { - text = "main"; - match = (pipe ? hstrstr(buf, text) : strstr(buf, text)); + mlen = 4; + match = (pipe ? hstrstr : strstr)(buf, "main"); } - if (match) escape(!pipe, buf, match - buf); + if (!match) { + mlen = strlen(buf) - 1; + match = buf; + } + escape(!pipe, buf, match - buf); printf("tag, strlen(tag->tag)); printf("\" href=\"#"); escape(true, tag->tag, strlen(tag->tag)); printf("\">"); - if (match) { - match += escape(!pipe, match, strlen(text)); - } else { - escape(!pipe, buf, strlen(buf)); - } + match += escape(!pipe, match, mlen); printf(""); - if (match) escape(!pipe, match, strlen(match)); + escape(!pipe, match, strlen(match)); } printf(pre ? "" : index ? "\n" : ""); } -- cgit 1.4.1 value='search'/>
path: root/bin/Makefile (unfollow)
Commit message (Expand)Author
2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe
2021-02-06Set root window to black on purple snowJune McEnroe
2021-02-06Add xmodmap configurationJune McEnroe
2021-02-06Add initial OpenBSD X configurationJune McEnroe
2021-02-06Add xterm output to schemeJune McEnroe