diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2022-05-24 16:14:12 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2022-05-24 17:46:39 -0700 |
commit | 15466174352557a5f9993aba8afb0cf9397b5b2c (patch) | |
tree | 32402dc582a72caa5052e239a4bb3a30775d65ad /src | |
parent | 8e0c90966da12c25689c662515731af3c7177d99 (diff) | |
download | grep-15466174352557a5f9993aba8afb0cf9397b5b2c.tar.gz |
grep: warn about ‘(+x)’ etc.
These expressions are not portable and don’t always work as
expected, so warn about them. For example, “grep -E '(+)'”
doesn’t act like “grep '\(\+\)'”.
* src/dfasearch.c (GEAcompile): Warn about a repetition op at the
start of a regular expression or subexpression, except for ‘*’ in
BREs which is portable.
Diffstat (limited to 'src')
-rw-r--r-- | src/dfasearch.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/dfasearch.c b/src/dfasearch.c index 7547a8a3..8d832f0c 100644 --- a/src/dfasearch.c +++ b/src/dfasearch.c @@ -197,6 +197,8 @@ GEAcompile (char *pattern, idx_t size, reg_syntax_t syntax_bits, if (match_icase) syntax_bits |= RE_ICASE; int dfaopts = (DFA_CONFUSING_BRACKETS_ERROR | DFA_STRAY_BACKSLASH_WARN + | DFA_PLUS_WARN + | (syntax_bits & RE_CONTEXT_INDEP_OPS ? DFA_STAR_WARN : 0) | (eolbyte ? 0 : DFA_EOL_NUL)); dfasyntax (dc->dfa, &localeinfo, syntax_bits, dfaopts); bool bs_safe = !localeinfo.multibyte | localeinfo.using_utf8; |