+2022-04-21 Paul Eggert <eggert@cs.ucla.edu>
+
+ regex: match [...---...] like V7 grep
+ Problem reported by Arnold Robbins in:
+ https://bugs.gnu.org/20657
+ https://lists.gnu.org/r/bug-gnulib/2022-04/msg00053.html
+ * lib/regcomp.c (peek_token_bracket): Let [...---...] match '-'.
+ This is an extension to POSIX, and matches V7 Unix grep.
+
2022-04-20 Paul Eggert <eggert@cs.ucla.edu>
backupfile: fix bug when renaming simple backups
}
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;
}