From 07c628471c1b37f125e3766f0e95089168603b87 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 6 Aug 2021 18:11:29 -0700 Subject: Changed it so --replace makes context default to `all`, but --inplace doesn't, so it can still be easily used as a filter. --- bp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bp.c b/bp.c index 6a3e679..689432c 100644 --- a/bp.c +++ b/bp.c @@ -424,7 +424,6 @@ int main(int argc, char *argv[]) options.mode = MODE_INPLACE; options.print_filenames = false; options.format = FORMAT_PLAIN; - options.context_before = options.context_after = ALL_CONTEXT; } else if (BOOLFLAG("-G") || BOOLFLAG("--git")) { options.git_mode = true; } else if (BOOLFLAG("-i") || BOOLFLAG("--ignore-case")) { @@ -440,6 +439,8 @@ int main(int argc, char *argv[]) pattern = bp_replacement(replace_file, pattern, replace_file->start); if (!pattern) errx(EXIT_FAILURE, "Replacement failed to compile: %s", flag); + if (options.context_before == USE_DEFAULT_CONTEXT) options.context_before = ALL_CONTEXT; + if (options.context_after == USE_DEFAULT_CONTEXT) options.context_after = ALL_CONTEXT; } else if (FLAG("-g") || FLAG("--grammar")) { file_t *f = NULL; if (strlen(flag) > 3 && strncmp(&flag[strlen(flag)-3], ".bp", 3) == 0) -- cgit v1.2.3