diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-09-07 13:38:57 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-09-07 13:38:57 -0700 |
| commit | f3eb2e99cdca225a66ae2d78f59abe2fa0d85482 (patch) | |
| tree | dc1e535b1f736845d55273ca8c4dd10c1a89a9ef | |
| parent | 58fef531ebf01b1c12589e4e50c712d351d9bfaa (diff) | |
Fixes for inplace modifications
| -rw-r--r-- | bp.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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")) { |
