Commit Diff


commit - 78eecffc27a77c02d95f8ab9dffb7d8ec7dba733
commit + 666f7b101a108aff1b7d4ddf36521f55159db286
blob - 39feae5e961f4c715e6113fd560171ffad07d234
blob + 72fb0a4237f9d9947232991ee298f261c8dbc38d
--- tog/tog.c
+++ tog/tog.c
@@ -3134,6 +3134,7 @@ add_matched_line(int *wtotal, const char *line, int wl
     WINDOW *window, int skipcol, regmatch_t *regmatch)
 {
 	const struct got_error *err = NULL;
+	char *exstr = NULL;
 	wchar_t *wline = NULL;
 	int rme, rms, n, width, scrollx;
 	int width0 = 0, width1 = 0, width2 = 0;
@@ -3144,16 +3145,22 @@ add_matched_line(int *wtotal, const char *line, int wl
 	rms = regmatch->rm_so;
 	rme = regmatch->rm_eo;
 
+	err = expand_tab(&exstr, line);
+	if (err)
+		return err;
+
 	/* Split the line into 3 segments, according to match offsets. */
-	seg0 = strndup(line, rms);
-	if (seg0 == NULL)
-		return got_error_from_errno("strndup");
-	seg1 = strndup(line + rms, rme - rms);
+	seg0 = strndup(exstr, rms);
+	if (seg0 == NULL) {
+		err = got_error_from_errno("strndup");
+		goto done;
+	}
+	seg1 = strndup(exstr + rms, rme - rms);
 	if (seg1 == NULL) {
 		err = got_error_from_errno("strndup");
 		goto done;
 	}
-	seg2 = strdup(line + rme);
+	seg2 = strdup(exstr + rme);
 	if (seg1 == NULL) {
 		err = got_error_from_errno("strndup");
 		goto done;
@@ -3228,6 +3235,7 @@ add_matched_line(int *wtotal, const char *line, int wl
 	}
 done:
 	free(wline);
+	free(exstr);
 	free(seg0);
 	free(seg1);
 	free(seg2);