aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-08 14:20:24 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-08 14:20:24 -0400
commit6f4261c80a770c75f1df33aed3a7454b1704c4e6 (patch)
tree1fa96da40766a9efe3c1b63b9cbf43b49b693c78
parente60f1b17e081b8fed4702de004fedf03e845f49e (diff)
Print quotes around string literal patterns when explaining matches
-rw-r--r--printmatch.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/printmatch.c b/printmatch.c
index a3197f1..9dccb10 100644
--- a/printmatch.c
+++ b/printmatch.c
@@ -62,6 +62,8 @@ static void _explain_matches(match_node_t *firstmatch, int depth, const char *te
// input, instead of something the user typed in)
if (viz_type >= text && viz_type <= &text[textlen])
printf("\033[%zuG\033[0;2m\"\033[%s;1m", 2*textlen+3, color);
+ else if (viz->pat->type == BP_STRING && (viz->end - viz->start) == (long)viz_typelen)
+ printf("\033[%zuG\033[%s;1m\"", 2*textlen+3, color);
else
printf("\033[%zuG\033[%s;1m", 2*textlen+3, color);
@@ -75,6 +77,8 @@ static void _explain_matches(match_node_t *firstmatch, int depth, const char *te
if (viz_type >= text && viz_type <= &text[textlen])
printf("\033[0;2m\"");
+ else if (viz->pat->type == BP_STRING && (viz->end - viz->start) == (long)viz_typelen)
+ printf("\"");
printf("\033[m");