From f3eb2e99cdca225a66ae2d78f59abe2fa0d85482 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 7 Sep 2021 13:38:57 -0700 Subject: Fixes for inplace modifications --- bp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bp.c') diff --git a/bp.c b/bp.c index b4727cd..5e77a17 100644 --- a/bp.c +++ b/bp.c @@ -290,6 +290,10 @@ static int process_file(def_t *defs, const char *filename, pat_t *pattern) } else if (options.mode == MODE_JSON) { matches += print_matches_as_json(defs, f, pattern); } else if (options.mode == MODE_INPLACE) { + match_t *m = next_match(defs, f, NULL, pattern, options.skip, options.ignorecase); + if (m) recycle_if_unused(&m); + else return 0; + // Ensure the file is resident in memory: if (f->mmapped) { file_t *copy = spoof_file(NULL, f->filename, f->start, (ssize_t)(f->end - f->start)); @@ -430,7 +434,7 @@ int main(int argc, char *argv[]) } else if (BOOLFLAG("-I") || BOOLFLAG("--inplace")) { options.mode = MODE_INPLACE; options.print_filenames = false; - options.format = FORMAT_PLAIN; + options.format = FORMAT_BARE; } else if (BOOLFLAG("-G") || BOOLFLAG("--git")) { options.git_mode = true; } else if (BOOLFLAG("-i") || BOOLFLAG("--ignore-case")) { -- cgit v1.2.3