summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2010-03-20 10:52:20 +0100
committerJim Meyering <meyering@redhat.com>2010-03-20 11:00:31 +0100
commitbf498a94165496a987f3ac800d6542028ea85a2c (patch)
tree9e313db389b664d83b8092563f7dc3aa99c23259 /src
parent039f20526add807ab57ed08fd44279642f77c73d (diff)
downloadgrep-bf498a94165496a987f3ac800d6542028ea85a2c.tar.gz
reject reversed-endpoint ranges, with all regex variants
* src/search.c: Add RE_NO_EMPTY_RANGES to the syntax bits in three places, so that all of grep, egrep, and grep -E reject a range with reversed endpoints like '[b-a]'. This is required, when using the latest version of gnulib's regex module, since it now honors the RE_NO_EMPTY_RANGES flag, rather than acting as if it were always set. Based on a change by Matthew Burgess.
Diffstat (limited to 'src')
-rw-r--r--src/search.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/search.c b/src/search.c
index c986d48c..f2d9ed6e 100644
--- a/src/search.c
+++ b/src/search.c
@@ -260,7 +260,7 @@ is_mb_middle(const char **good, const char *buf, const char *end)
#ifdef EGREP_PROGRAM
COMPILE_FCT(Ecompile)
{
- reg_syntax_t syntax_bits = RE_SYNTAX_POSIX_EGREP;
+ reg_syntax_t syntax_bits = RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES;
#else
/* No __VA_ARGS__ in C89. So we have to do it this way. */
static COMPILE_RET
@@ -358,7 +358,9 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits)
COMPILE_FCT(Gcompile)
{
return GEAcompile (pattern, size,
- RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE);
+ (RE_SYNTAX_GREP
+ | RE_HAT_LISTS_NOT_NEWLINE
+ | RE_NO_EMPTY_RANGES));
}
COMPILE_FCT(Acompile)
@@ -368,7 +370,7 @@ COMPILE_FCT(Acompile)
COMPILE_FCT(Ecompile)
{
- return GEAcompile (pattern, size, RE_SYNTAX_POSIX_EGREP);
+ return GEAcompile (pattern, size, RE_SYNTAX_POSIX_EGREP | RE_NO_EMPTY_RANGES);
}
#endif /* !EGREP_PROGRAM */