aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-08-06 18:11:29 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-08-06 18:11:29 -0700
commit07c628471c1b37f125e3766f0e95089168603b87 (patch)
treed1cb0c39e1b51ee1980bf05cc1760dc9e3ddfdf3
parent78034539773a3be2113fed80c39878d2727d6ef2 (diff)
Changed it so --replace makes context default to `all`, but --inplace
doesn't, so it can still be easily used as a filter.
-rw-r--r--bp.c3
1 files changed, 2 insertions, 1 deletions
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)