aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-12-30 16:24:59 -0800
committerBruce Hill <bruce@bruce-hill.com>2020-12-30 16:24:59 -0800
commitbc2ddc0408e47cbc12b0f7d0c0abae943fc74b83 (patch)
treec56f6a177113c5a8029586a3e8da542c0a3efea6
parenteeec0acd0a92bf2e94b3168642faba92ba649178 (diff)
Print filenames when replacing in-place
-rw-r--r--bpeg.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bpeg.c b/bpeg.c
index 8c5f44a..438c302 100644
--- a/bpeg.c
+++ b/bpeg.c
@@ -99,10 +99,11 @@ static int run_match(grammar_t *g, const char *filename, vm_op_t *pattern, unsig
0, f->end - f->contents);
json_match(f->contents, m, (flags & BPEG_VERBOSE) ? 1 : 0);
printf("]}}\n");
- } else if (flags & BPEG_INPLACE) {
+ } else if (flags & BPEG_INPLACE && filename) {
FILE *out = fopen(filename, "w");
print_match(out, f, m, 0);
fclose(out);
+ printf("%s\n", filename);
} else {
if (printed_matches > 1)
fputc('\n', stdout);