summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-05-21 01:38:39 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2022-05-21 02:41:20 -0700
commita368a60eb81ea6e3264e0c8c2cb12f2ee7f0585d (patch)
treebb635fe6a73b75f387af5f4ede2bf8c98d0b5a1d
parent2169fa36c9235d13bf64e20009fc3a639ca5670a (diff)
downloadgrep-a368a60eb81ea6e3264e0c8c2cb12f2ee7f0585d.tar.gz
grep: assume POSIX.1-2017 for [:space:]
* src/dfasearch.c (dfawarn): Always call dfaerror now, regardless of POSIXLY_CORRECT. * tests/warn-char-classes: Omit test of POSIX.1-2008 behavior, since POSIX.1-2017 allows the GNU behavior.
-rw-r--r--NEWS3
-rw-r--r--doc/grep.texi8
-rw-r--r--src/dfasearch.c8
-rwxr-xr-xtests/warn-char-classes4
4 files changed, 7 insertions, 16 deletions
diff --git a/NEWS b/NEWS
index fb0e4cf1..bf2ee50e 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,9 @@ GNU grep NEWS -*- outline -*-
release 2.5.3 (2007), now warn that they are obsolescent and should
be replaced by grep -E and grep -F.
+ Regular expressions like [:space:] are now errors even if
+ POSIXLY_CORRECT is set, since POSIX now allows the GNU behavior.
+
** Bug fixes
In locales using UTF-8 encoding, the regular expression '.' no
diff --git a/doc/grep.texi b/doc/grep.texi
index b073fa76..71e19e04 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -1056,8 +1056,6 @@ follow file names must be treated as file names;
by default,
such options are permuted to the front of the operand list
and are treated as options.
-Also, @env{POSIXLY_CORRECT} disables special handling of an
-invalid bracket expression. @xref{invalid-bracket-expr}.
@item _@var{N}_GNU_nonoption_argv_flags_
@vindex _@var{N}_GNU_nonoption_argv_flags_ @r{environment variable}
@@ -1401,12 +1399,10 @@ Note that the brackets in these class names are
part of the symbolic names, and must be included in addition to
the brackets delimiting the bracket expression.
-@anchor{invalid-bracket-expr}
If you mistakenly omit the outer brackets, and search for say, @samp{[:upper:]},
GNU @command{grep} prints a diagnostic and exits with status 2, on
-the assumption that you did not intend to search for the nominally
-equivalent regular expression: @samp{[:epru]}.
-Set the @env{POSIXLY_CORRECT} environment variable to disable this feature.
+the assumption that you did not intend to search for the
+regular expression @samp{[:epru]}.
Special characters lose their special meaning inside bracket expressions.
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 744b8f81..8f48296a 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -53,14 +53,10 @@ dfaerror (char const *mesg)
die (EXIT_TROUBLE, 0, "%s", mesg);
}
-/* For now, the sole dfawarn-eliciting condition (use of a regexp
- like '[:lower:]') is unequivocally an error, so treat it as such,
- when possible. */
-void
+_Noreturn void
dfawarn (char const *mesg)
{
- if (!getenv ("POSIXLY_CORRECT"))
- dfaerror (mesg);
+ dfaerror (mesg);
}
/* If the DFA turns out to have some set of fixed strings one of
diff --git a/tests/warn-char-classes b/tests/warn-char-classes
index b1db240d..0d87ce00 100755
--- a/tests/warn-char-classes
+++ b/tests/warn-char-classes
@@ -17,10 +17,6 @@ compare exp-err err || fail=1
returns_ 1 grep '[[:space:]]' x 2> err || fail=1
test -s err && fail=1
-# disabled by POSIXLY_CORRECT
-returns_ 1 env POSIXLY_CORRECT=yes grep '[:space:]' x 2> err || fail=1
-test -s err && fail=1
-
# patterns that are considered valid
returns_ 1 grep '[::]' x 2> err || fail=1
test -s err && fail=1