aboutsummaryrefslogtreecommitdiff
path: root/printmatch.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2023-05-06 13:43:32 -0400
committerBruce Hill <bruce@bruce-hill.com>2023-05-06 13:43:32 -0400
commit6f5bb02b923c1402eba04ce78033317da401971e (patch)
tree7b43203ca28667b8d3526445b1ee2aff8bf43495 /printmatch.c
parent0050a6fc064f7700d9940bf4fd381c7a072652a6 (diff)
Use tagged union style for extra safety and concision
Diffstat (limited to 'printmatch.c')
-rw-r--r--printmatch.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/printmatch.c b/printmatch.c
index c079b23..2cbd511 100644
--- a/printmatch.c
+++ b/printmatch.c
@@ -200,8 +200,9 @@ int fprint_match(FILE *out, const char *file_start, match_t *m, print_options_t
{
int printed = 0;
if (m->pat->type == BP_REPLACE) {
- const char *text = m->pat->args.replace.text;
- const char *end = &text[m->pat->args.replace.len];
+ auto rep = Match(m->pat, BP_REPLACE);
+ const char *text = rep->text;
+ const char *end = &text[rep->len];
if (opts && opts->replace_color) printed += fprintf(out, "%s", opts->replace_color);
// TODO: clean up the line numbering code