summaryrefslogtreecommitdiff
path: root/lib/regcomp.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-05-05 15:36:33 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2022-05-05 15:37:40 -0700
commit9007e10a0fc94190404c6a988f7d52d162901940 (patch)
treebec4b170622a185f9feacde07e864f32c7ca71b2 /lib/regcomp.c
parent7e9d364b663613fd907f92de31e996463ef7d03c (diff)
downloademacs-9007e10a0fc94190404c6a988f7d52d162901940.tar.gz
Gnulib update via admin/merge-gnulib
Diffstat (limited to 'lib/regcomp.c')
-rw-r--r--lib/regcomp.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/regcomp.c b/lib/regcomp.c
index b607c85320f..122c3de58c3 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -2038,15 +2038,25 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
}
switch (c)
{
- case '-':
- token->type = OP_CHARSET_RANGE;
- break;
case ']':
token->type = OP_CLOSE_BRACKET;
break;
case '^':
token->type = OP_NON_MATCH_LIST;
break;
+ case '-':
+ /* In V7 Unix grep and Unix awk and mawk, [...---...]
+ (3 adjacent minus signs) stands for a single minus sign.
+ Support that without breaking anything else. */
+ if (! (re_string_cur_idx (input) + 2 < re_string_length (input)
+ && re_string_peek_byte (input, 1) == '-'
+ && re_string_peek_byte (input, 2) == '-'))
+ {
+ token->type = OP_CHARSET_RANGE;
+ break;
+ }
+ re_string_skip_bytes (input, 2);
+ FALLTHROUGH;
default:
token->type = CHARACTER;
}