From 77113cf667e1f4fbccc337b508d0f81b1f4b7563 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Thu, 2 Jun 2022 21:30:03 -0400 Subject: Don't duplicate path string --- bin/qf.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/bin/qf.c b/bin/qf.c index 3b4f5851..98c897ce 100644 --- a/bin/qf.c +++ b/bin/qf.c @@ -55,15 +55,16 @@ static void push(struct Line line) { static void parse(struct Line line) { char *text = line.text; - size_t sep = strcspn(line.text, ":"); - if (!line.text[sep]) { + size_t sep = strcspn(text, ":"); + if (!text[sep]) { line.type = Text; + if (lines.len) line.path = lines.ptr[lines.len-1].path; push(line); return; } - line.path = strndup(line.text, sep); - if (!line.path) err(EX_OSERR, "strndup"); - line.text += sep + 1; + line.path = text; + text[sep] = '\0'; + line.text = &text[sep+1]; if ( !lines.len || !lines.ptr[lines.len-1].path || @@ -77,15 +78,13 @@ static void parse(struct Line line) { } char *rest; line.nr = strtoul(line.text, &rest, 10); + line.type = Match; if (rest != line.text && rest[0] == ':') { line.type = Match; line.text = &rest[1]; } else if (rest != line.text && rest[0] == '-') { line.type = Context; line.text = &rest[1]; - } else { - line.type = Text; - line.text = text; } push(line); } -- cgit 1.4.1 /ui-plain.c?h=1.4.1&id=42d5476f258e7909682f1b611da00d64507d45c6'>tree commit diff
path: root/ui-plain.c (unfollow)
Commit message (Expand)Author
2013-04-08Remove redundant calls to fmt("%s", ...)John Keeping
2013-04-08Convert cgit_print_error to a variadic functionJohn Keeping
2013-04-08shared.c: add strbuf_ensure_endJohn Keeping
2013-04-08html.c: add various strbuf and varadic helpersJohn Keeping
2013-04-08Mark char* fields in struct cgit_page as constJohn Keeping
2013-04-08Fix out-of-bounds memory accesses with virtual_root=""John Keeping
2013-04-08ui-refs.c: Refactor print_tag()Lukas Fleischer
2013-04-08ui-refs.c: Remove global header variableLukas Fleischer
2013-04-08html.c: Replace strdup() with xstrdup()Lukas Fleischer
2013-04-08Always #include corresponding .h in .c filesJohn Keeping
2013-04-08cgit.mk: fix dependency handlingJohn Keeping
2013-04-08Makefile: re-include cgit.conf in cgit.mkJohn Keeping
2013-04-08Do not unnecessarily strdup() environment variablesLukas Fleischer
2013-04-08Maŕk cgit_environment members constLukas Fleischer
2013-04-08Return const char * in cgit_{httpscheme, hosturl, rooturl}()Lukas Fleischer
2013-04-08Update git to v1.8.2.1John Keeping
2013-04-07ui-blob: don't segfault when no path is givenJohn Keeping
2013-03-20Convert pager navigation into a unordered listLukas Fleischer
2013-03-20Makefile: remove CGIT-CFLAGS files in clean stageJason A. Donenfeld
2013-03-20ui-summary.c: Move urls variable into print_urls()Lukas Fleischer
2013-03-20Fix colspan valuesLukas Fleischer
2013-03-20html: check return value of writeJason A. Donenfeld
2013-03-20ui-shared: squelch compiler warning.Jason A. Donenfeld
2013-03-20cgit.mk: Use SHELL_PATH_SQ to run gen-version.shJohn Keeping
2013-03-20cgit.mk: don't rebuild everything if CGIT_VERSION changesJohn Keeping
2013-03-20ui-patch: use cgit_version not CGIT_VERSIONJohn Keeping
2013-03-20Makefile: re-use Git's Makefile where possibleJohn Keeping