From 1a1d36f59624cdd0be6b131d4e9fb56bc772e3b5 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 29 Apr 2020 17:07:39 -0400 Subject: Highlight diff/index/---/+++ lines of patches as well --- html.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/html.c b/html.c index 850e070..ee9e966 100644 --- a/html.c +++ b/html.c @@ -14,8 +14,9 @@ * along with this program. If not, see . */ -#include +#include #include +#include #include #include #include @@ -225,11 +226,7 @@ static int htmlMarkupURLs(FILE *file, char *buf) { static regex_t regex; if (!regex.re_nsub) { int error = regcomp(®ex, Pattern, REG_EXTENDED); - if (error) { - char buf[256]; - regerror(error, ®ex, buf, sizeof(buf)); - errx(EX_SOFTWARE, "%s: %s", buf, Pattern); - } + assert(!error); } int error; @@ -281,15 +278,21 @@ static int htmlMarkup(FILE *file, const char *content) { patch = false; } - if (patch && !strncmp(buf, "@@", 2)) { + static const char *Pattern = "^(diff|index|---|[+]{3}|@@) "; + static regex_t regex; + if (!regex.re_nsub) { + error = regcomp(®ex, Pattern, REG_EXTENDED); + assert(!error); + } + if (patch && !regexec(®ex, buf, 0, NULL, 0)) { error = templateRender( file, TEMPLATE([line]), vars, escapeXML ); - } else if (patch && buf[0] == '-' && strncmp(buf, "---", 3)) { + } else if (patch && buf[0] == '-' && strcmp(buf, "---")) { error = templateRender( file, TEMPLATE([line]), vars, escapeXML ); - } else if (patch && buf[0] == '+' && strncmp(buf, "+++", 3)) { + } else if (patch && buf[0] == '+') { error = templateRender( file, TEMPLATE([line]), vars, escapeXML ); -- cgit 1.4.1 .3.0&ofs=50&follow=1'>root/ui-commit.c (unfollow)
Commit message (Expand)Author
2020-03-12tests: add tests for xz compressed snapshotsChristian Hesse
2020-02-26ui-snapshot: add support for lzip compressionHanspeter Portner
2020-02-17git: update to v2.25.1Christian Hesse
2020-01-13tests: allow to skip git version testsChristian Hesse
2020-01-13Bump versionJason A. Donenfeld
2020-01-13git: update to v2.25.0Christian Hesse
2019-12-11tests: skip tests if strace is not functionalChristian Hesse
2019-12-10git: update to v2.24.1Christian Hesse
2019-11-22ui-repolist: do not return unsigned (negative) valueChristian Hesse
2019-11-08git: update to v2.24.0Christian Hesse
2019-10-25git: update to v2.23.0Christian Hesse
2019-10-25git: update to v2.22.0Christian Hesse
2019-06-25ui-tree: allow per repository override for enable-blameChristian Hesse
2019-06-05tests: successfully validate rc versionsChristian Hesse
2019-06-05git: update to v2.21.0Christian Hesse
2019-06-05ui-ssdiff: ban strncat()Christian Hesse
2019-06-05global: make 'char *path' const where possibleChristian Hesse
2019-05-20ui-shared: restrict to 15 levelsJason A. Donenfeld
2019-02-23ui-diff,ui-tag: don't use htmlf with non-formatted stringsChris Mayo
2019-02-23ui-ssdiff: resolve HTML5 validation errorsChris Mayo
2019-01-03filters: migrate from luacrypto to luaosslJason A. Donenfeld
2019-01-02ui-shared: fix broken sizeof in title setting and rewriteJason A. Donenfeld
2018-12-09git: update to v2.20.0Christian Hesse
2018-11-25ui-blame: set repo for sbJason A. Donenfeld
2018-11-25auth-filter: pass url with query string attachedJason A. Donenfeld
2018-11-21git: use xz compressed archive for downloadChristian Hesse
2018-10-12git: update to v2.19.1Christian Hesse
2018-09-11ui-ssdiff: ban strcat()Christian Hesse
2018-09-11ui-ssdiff: ban strncpy()Christian Hesse
2018-09-11ui-shared: ban strcat()Christian Hesse
2018-09-11ui-patch: ban sprintf()Christian Hesse
2018-09-11ui-log: ban strncpy()Christian Hesse
2018-09-11ui-log: ban strcpy()Christian Hesse
2018-09-11parsing: ban sprintf()Christian Hesse
2018-09-11parsing: ban strncpy()Christian Hesse
2018-08-28filters: generate anchor links from markdownChristian Hesse
2018-08-03Bump version.Jason A. Donenfeld
2018-08-03clone: fix directory traversalJason A. Donenfeld
2018-08-03config: record repo.snapshot-prefix in the per-repo configKonstantin Ryabitsev