summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/qf.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/bin/qf.c b/bin/qf.c
index 98c897ce..0a79307e 100644
--- a/bin/qf.c
+++ b/bin/qf.c
@@ -54,37 +54,31 @@ static void push(struct Line line) {
 }
 
 static void parse(struct Line line) {
-	char *text = line.text;
-	size_t sep = strcspn(text, ":");
-	if (!text[sep]) {
+	line.path = strsep(&line.text, ":");
+	if (!line.text) {
 		line.type = Text;
+		line.text = line.path;
 		if (lines.len) line.path = lines.ptr[lines.len-1].path;
 		push(line);
 		return;
 	}
-	line.path = text;
-	text[sep] = '\0';
-	line.text = &text[sep+1];
-	if (
-		!lines.len ||
-		!lines.ptr[lines.len-1].path ||
-		strcmp(line.path, lines.ptr[lines.len-1].path)
-	) {
-		if (lines.len) {
-			push((struct Line) { .type = Text, .text = " " });
-		}
+	struct Line prev = {0};
+	if (lines.len) prev = lines.ptr[lines.len-1];
+	if (!prev.path || strcmp(line.path, prev.path)) {
+		if (lines.len) push((struct Line) { .type = Text, .text = " " });
 		line.type = File;
 		push(line);
 	}
 	char *rest;
 	line.nr = strtoul(line.text, &rest, 10);
-	line.type = Match;
-	if (rest != line.text && rest[0] == ':') {
+	if (rest > line.text && rest[0] == ':') {
 		line.type = Match;
 		line.text = &rest[1];
-	} else if (rest != line.text && rest[0] == '-') {
+	} else if (rest > line.text && rest[0] == '-') {
 		line.type = Context;
 		line.text = &rest[1];
+	} else {
+		line.type = Text;
 	}
 	push(line);
 }
June McEnroe 2019-02-20Use $PWD in html.sh to pass absolute path to manJune McEnroe 2019-02-20Factor out html.sh and produce html for all sourcesJune McEnroe 2019-02-20Add Dirk Gently's Holistic Detective AgencyJune McEnroe 2019-02-20Move /opt/pkg after /usr in PATHJune McEnroe 2019-02-20Set man_hard_wrap in nvimJune McEnroe 2019-02-18Use hi -o anchor in upJune McEnroe 2019-02-18Don't match nested parentheses in Tag for CJune McEnroe 2019-02-18Match whitespace between * [] {}June McEnroe 2019-02-18Fix function-like #define regexJune McEnroe 2019-02-18Match Tag in RustJune McEnroe 2019-02-18Match sh functions as TagJune McEnroe 2019-02-18Match Sh and Ss as Tag in mdocJune McEnroe 2019-02-18Match statics and typedefs as TagJune McEnroe 2019-02-18Clean up htmlHeaderJune McEnroe 2019-02-18Remove hi line numberingJune McEnroe 2019-02-18Add Tag class to hiJune McEnroe 2019-02-17Generate HTML with hi -n -f html -o anchorJune McEnroe 2019-02-17Add hi -f html -o anchor for line number linksJune McEnroe 2019-02-17Simplify temp trap in upJune McEnroe 2019-02-17Add line numbers to hiJune McEnroe 2019-02-17Always split spans after newlinesJune McEnroe 2019-02-15Color format specifiers light cyan in vimJune McEnroe 2019-02-15Highlight Interp as yellowJune McEnroe 2019-02-15Highlight strings in sh command substitutionsJune McEnroe 2019-02-15Add nmap gpJune McEnroe 2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe 2019-02-13Add forgotten "sixth" book of H2G2June McEnroe