594 Commits

Author SHA1 Message Date
Jim Meyering
c635f7dd92 maint: update copyright dates 2026-01-02 16:42:12 -08:00
Jim Meyering
682f7f693d tests: write-error-msg: avoid false-failure
* tests/write-error-msg: Do not require that a disk full
diagnostic include additional information. In some cases, there
is no valid errno value, so we cannot provide more information.
This was exposed by a patch that coincidentally caused the length
of grep's help output to be precisely 4096 bytes long.
Reported in https://bugs.gnu.org/77800
2025-05-14 10:56:16 -07:00
Jim Meyering
bd7250ca36 tests: mb-non-UTF8-perf-Fw: undo previous change
* tests/mb-non-UTF8-perf-Fw: Ugh. I misread the code and
didn't even test.  Given circumstances and the new timing that's
well within the 30-second timeout, I think there's no point
in trying to accommodate systems that are so overburdened they
trigger this failure. Reported by Grisha Levit.
2025-04-09 09:58:53 -07:00
Jim Meyering
f8bb8c519e tests: mb-non-UTF8-perf-Fw:: avoid false failure on overloaded systems
* tests/mb-non-UTF8-perf-Fw: Raise timeout from 1 to 3s
to accommodate slow systems.  Reported by Nelson Beebe in
https://lists.gnu.org/r/grep-devel/2025-04/msg00027.html
2025-04-09 09:05:57 -07:00
Jim Meyering
b197be563e tests: hash-collision-perf: avoid test hang on GNU/Hurd
This test would hang on GNU/Hurd because the perl code we use to measure
subsecond duration isn't ported, and that loop would never terminate.
* tests/hash-collision-perf: Detect the always-0 small_ms, and skip the test.
Reported by Bruno Haible in https://bugs.gnu.org/77613
2025-04-08 09:32:24 -07:00
Jim Meyering
52418599b3 grep: avoid regression with -mN and any of -q, -l, -L
* src/grep.c (grepbuf): Handle this case: echo x|grep -l -m1 .
making it print only the file name, and not the matched line.
(main): Set out_quiet also when exit_on_match (-q) is set, so
"echo x|grep -q -m1 ." no longer prints the matched line.
* tests/max-count-overread: Add those tests, from
https://bugs.gnu.org/68989#21
2025-04-08 09:32:24 -07:00
Paul Eggert
b1eaccd96d maint: update all copyright dates via "make update-copyright" 2025-01-01 19:15:26 -08:00
Paul Eggert
6ee856200a grep: revert recent \d change
I misread the email thread and thought there was consensus
for the \d change, but there was wasn’t so revert the change.
Also, document the resulting confusion
somewhat better than it was documented before.
* src/pcresearch.c, tests/pcre-ascii-digits, tests-pcre-utf8-w:
Revert recent \d change, restoring the behavior to that of grep 3.11.
2024-12-16 14:43:00 -07:00
Paul Eggert
eaca869822 grep: go back to 3.9 -P '\d' behavior
Treating \d differently from Perl was more trouble than it was worth.
* NEWS, doc/grep.texi (grep Programs): Document this.
* src/pcresearch.c (PCRE2_EXTRA_ASCII_BSD):
Remove.  All uses removed.
* tests/pcre-ascii-digits: Adjust to this change.
* tests/pcre-utf8-w: Revert to 3.9.
2024-12-14 14:15:00 -07:00
Paul Eggert
fce28c4a5e grep: fix -q suppression of diagnostics
Problem reported by Jan Černohorský (Bug#74159).
* src/grep.c (grepbuf): If exit_on_match, set stdout_errno to
avoid screwups on buggy OSes.  Also, ignore errseen since it
cannot be true here.
(main): Do not clear exit_failure if -q is given, as exit status
should be zero only if an input line is selected.
* tests/write-error-msg: Check that -q suppresses diagnostics
of output errors only if a match is found.
2024-11-01 22:46:33 -07:00
Jim Meyering
1c9e7544cf maint: modernize GNU GPL license comments
To accommodate a new syntax-check rule, ...
Make comments that suggested to write to an old FSF Franklin Street
address refer to https://www.gnu.org/licenses instead:

  git grep -l 'if not, write' |xargs \
  perl -0777 -pi -e 's{program; if not, write .*? USA\.}{program.  If not, see <https://www.gnu.org/licenses/>.}ms'
2024-09-08 09:45:52 -07:00
Bruno Haible
eda769be72 tests: Fix recognition of cs_CZ.UTF-8 locale on FreeBSD.
* tests/fmbtest: Use 'locale charmap' to determine the locale's encoding.
* tests/foad1: Likewise.
2024-07-09 14:44:46 +02:00
Collin Funk
3612f5e218 maint: import tests/init.sh from Gnulib during bootstrap
* bootstrap.conf (bootstrap_post_import_hook): Use gnulib-tool
--copy-file to import tests/init.sh.
* tests/init.sh: Remove file.
* .gitignore (/tests/init.sh): Add entry.
2024-07-04 12:54:56 -07:00
Paul Eggert
b9a8047099 grep: fix ‘grep -m2 pattern <file >/dev/null’
Problem reported by Grisha Levit <https://bugs.gnu.org/68989>.
* src/grep.c (grep, main): Don’t set done_on_match if -m is used.
* tests/max-count-overread: Add a test case.
2024-02-09 01:07:19 -08:00
Jim Meyering
e248db797a maint: update all copyright dates via "make update-copyright" 2024-01-05 09:19:41 -08:00
Jim Meyering
4810ea0838 build: update gnulib to latest; also update bootstrap and init.sh 2024-01-05 09:19:01 -08:00
Paul Eggert
f80b106d15 grep: omit propername, as it’s not used
Omit Gnulib’s propername module, as it has not been used since my
commit 3c0a36e514237132db711bfef57a74c64592c4e2 dated Thu Dec 20
16:35:55 2018 -0800.
* bootstrap.conf (avoided_gnulib_modules):
Do not avoid mbchar, as it is no longer pulled in by propername.
(gnulib_modules): Remove propername.
* src/Makefile.am (LDADD):
* tests/Makefile.am (LDADD): Remove $(LIBICONV); no longer needed.
* src/grep.c: Do not include propername.h.
2023-09-09 18:54:20 -07:00
Jim Meyering
180e8dd674 tests: actually package and run the new 100k-entries test
* tests/Makefile.am (TESTS): Include the new test file name,
100k-entries.
2023-08-20 12:42:14 -07:00
Jim Meyering
d1c3fbe772 doc: mention the 100,000-entry ENOTSUP bug
* NEWS: document the fixed bug.
* tests/100k-entries: New file, to test for this.
Reported by Vincent Lefevre via Santiago Ruano Rincón in
https://bugs.gnu.org/64773
Fixed by gnulib commit v0.1-6175-gd4d8abb39e.
2023-07-21 17:42:23 -07:00
Paul Eggert
105e432d7f maint: link with mbrtc32-required libraries
Add libraries now suggested by gnulib-tool.
* src/Makefile.am (LDADD):
* tests/Makefile.am (LDADD):
Add $(HARD_LOCALE_LIB), $(LIBC32CONV), $(LIBSIGSEGV),
$(LIBUNISTRING), $(MBRTOWC_LIB), $(SETLOCALE_NULL_LIB).
* tests/Makefile.am (LDADD):
Also add $(LIBCSTACK), $(LIBICONV), $(LIBTHREAD).
2023-07-11 18:14:40 -07:00
Carlo Marcelo Arenas Belón
fa4e6c8a77 pcre: work around a PCRE2_MATCH_INVALID_UTF bug
PCRE2 has a bug when using PCRE2_MATCH_INVALID_UTF: it would
sometimes fail to match patterns using negative classes
like \W and \D.

* NEWS (Bug fixes): Mention it.
* src/pcre2search.c: Restrict impact of the bug.
Do not use the problematic flag with broken versions of PCRE2.
Also, generate locale tables only for single-byte locales,
as the PCRE2 documentation recommends this.
* tests/Makefile.am (TESTS): Add the file name
* tests/pcre-utf8-bug224: New file, to test for this.
2023-04-30 00:01:41 -07:00
Paul Eggert
fd2d0f7165 grep: improve PCRE2 version output
* src/grep.c: No need to include pcre2.h.
(main) [HAVE_LIBPCRE]: Call Pprint_version instead of
doing it ourselves.
* src/pcresearch.c (Pprint_version): New function.
It also checks belatedly for buffer overflow, and
says "grep -P uses PCRE2" instead of "Built with PCRE".
* tests/version-pcre: Adjust test to match.
2023-04-10 16:16:08 -07:00
Jim Meyering
3b15d73897 tests: skip y2038 test upon touch setup failure
* tests/y2038-vs-32-bit: Skip rather than fail, when
the touch -t 2039... setup fails.  That command failed
on a solaris10 sparc build farm host.
2023-04-10 07:22:25 -07:00
Jim Meyering
85e0e4fdd4 tests: add a known-failing glibc-infloop test
* tests/glibc-infloop: New file.
Based on the command from Koen Claessen
reported in https://bugs.gnu.org/62483
* configure.ac (USE_INCLUDED_REGEX): define.
* tests/Makefile.am (TESTS): Add the file name
* THANKS.in: Add name of reporter.
2023-04-09 22:22:42 -07:00
Jim Meyering
88b2d37c0a grep: --version: print pcre version info
PCRE is integral to the functioning of grep's -P option, so it is in our
interest to make it easy to see which version of PCRE grep uses.
* src/grep.c [HAVE_LIBPCRE]: Include <pcre2.h>.
[HAVE_LIBPCRE] (main): Print pcre version info.
* tests/version-pcre: New test for this.
* tests/Makefile.am (TESTS): Add the file name.
* NEWS (Changes in behavior): Mention it.
2023-04-09 22:22:42 -07:00
Jim Meyering
19d2275fd1 tests: test for the year-2038 bug
* tests/y2038-vs-32-bit: New file.
* tests/Makefile.am (TESTS): Add the file name
2023-04-09 22:22:42 -07:00
Paul Eggert
c63a0950ff grep: fix -P [\d] by fixing \w only if PCRE2 10.43
Our prepass-based fixes for the -P \d bug have caused repeated
further bugs.  Avoid the need for a prepass, by using PCRE2_UCP
only if PCRE2_EXTRA_ASCII_BSD is also supported.  Since the -P \w
bug was present from grep 2.5 through 3.8 it’s OK if we wait a
little longer to fix it.
* NEWS: Mention this.
* src/pcresearch.c (pcre_pattern_expand_backslash_d}: Remove.
Remove its use.
(Pcompile): Use PCRE2_UCP only if PCRE2_EXTRA_ASCII_BSD.
* tests/pcre-ascii-digits, tests/pcre-utf8-w:
Skip tests on older PCRE2 implementations.
2023-04-02 09:47:16 -07:00
Jim Meyering
98ee05b4dd grep: -P (--perl-regexp) \D once again works like [^0-9]
* NEWS: Mention \D, too.
* doc/grep.texi: Likewise
* src/pcresearch.c (pcre_pattern_expand_backslash_d): Handle \D.
Also, ifdef-out this new function and its call site when not needed.
* tests/pcre-ascii-digits: Test \D, too.
Tighten one test by using returns_ 1.
Add comments and tests that work only with 10.43 and newer.
Paul Eggert raised the issue of \D in https://bugs.gnu.org/62267#8
2023-03-19 13:36:23 -07:00
Jim Meyering
c83ffc197e grep: -P (--perl-regexp) \d: match only ASCII digits
Prior to grep-3.9, the PCRE matcher had always treated \d just
like [0-9]. grep-3.9's fix for \w and \b mistakenly relaxed \d
to also match multibyte digits.
* src/grep.c (P_MATCHER_INDEX): Define enum.
(pcre_pattern_expand_backslash_d): New function.
(main): Call it for -P.
* NEWS (Bug fixes): Mention it.
* doc/grep.texi: Document it: with -P, \d matches only ASCII digits.
Provide a PCRE documentation URL and an example of how
to use (?s) with -z.
* tests/pcre-ascii-digits: New test.
* tests/Makefile.am (TESTS): Add that file name.
Reported as https://bugs.gnu.org/62267
2023-03-18 17:08:09 -07:00
Bruno Haible
e00b27266a tests: avoid failure on Alpine Linux 3.17, due to non-POSIX compliant tr
* tests/fmbtest: Don't use [x*n] syntax in the tr options, since tr from
BusyBox 1.35 does not support it.
2023-03-05 07:10:37 -08:00
Paul Eggert
155cfb11e3 maint: stop including getprogname.h
It’s obsolete in bleeding-edge Gnulib.
* src/grep.c, tests/get-mb-cur-max.c: Don’t include getprogname.h.
Instead, rely on stdlib.h to declare getprogname.
2023-01-21 14:56:22 -06:00
Paul Eggert
516e855773 maint: spelling fixes 2023-01-16 01:19:41 -08:00
Paul Eggert
b63a992346 tests: fix test -eq problem
Do not use ‘test "" -eq 1’ when get-mb-cur-max fails,
as Bash complains about this.  Problem found on AIX.
2023-01-15 16:38:56 -08:00
Paul Eggert
4b60e9f353 tests: port U+10000+ to AIX 7.2
* tests/hangul-syllable, tests/surrogate-search:
32-bit AIX has WCHAR_MAX == 0xFFFF, and so cannot handle
U+10000 and greater.  Skip tests involving such chars
on this platform.
2023-01-15 16:38:56 -08:00
Paul Eggert
72ccd15d5c tests: update tests/init.sh
* tests/init.sh: Update from Gnulib.
2023-01-15 16:38:56 -08:00
Paul Eggert
6de66dd6be tests: omit duplicate tests
* tests/skip-read: Omit duplicates.  Reported by Bruno Haible in:
https://lists.gnu.org/r/grep-devel/2023-01/msg00003.html
2023-01-14 02:06:25 -08:00
Paul Eggert
231a3ea66d tests: better diagnostic for -P sans Unicode
* tests/init.cfg (require_pcre_): When in a UTF-8 locale, test
also for Unicode support so that it can be diagnosed differently
(Bug#60708).
2023-01-12 23:32:16 -08:00
Carlo Marcelo Arenas Belón
8f6a1e90e4 pcre: use UTF only when available in the library
Before this change, if linked with a PCRE library without unicode
any invocations of grep when using a UTF locale will error with:

  grep: this version of PCRE2 does not have Unicode support

* src/pcresearch.c: Check whether Unicode was compiled in.
* tests/pcre-utf8-w: Add check to skip test.
* tests/pcre-utf8: Update check.
2023-01-11 10:24:09 -08:00
Carlo Marcelo Arenas Belón
5e3b760f65 pcre: use UCP in UTF mode
This fixes a serious bug affecting word-boundary and word-constituent regular
expressions when the desired match involves non-ASCII UTF8 characters.
* src/pcresearch.c: Set PCRE2_UCP together with PCRE2_UTF
* tests/pcre-utf8-w: New file.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention this.
* THANKS.in: Add Gro-Tsen and Karl Petterson.
Reported by Gro-Tsen https://twitter.com/gro_tsen/status/1610972356972875777
via Karl Pettersson in https://github.com/PCRE2Project/pcre2/issues/185
This bug was present from grep-2.5, when --perl-regexp (-P) support was added.
2023-01-07 18:24:51 -08:00
Jim Meyering
45e1158a4b maint: update copyright dates 2023-01-01 20:36:23 -08:00
Paul Eggert
b061d24916 grep: bug: backref in last of multiple patterns
* NEWS: Mention this.
* src/dfasearch.c (GEAcompile): Trim trailing newline from
the last pattern, even if it has back-references and follows
a pattern that lacks back-references.
* tests/backref: Add test for this bug.
2022-12-05 14:17:29 -08:00
Jim Meyering
0acc194ae1 tests: long-pattern-perf: avoid FP failure on unusual systems
* tests/long-pattern-perf: Skip this test whenever the base
case takes more than 800ms.  See comment for details.
Reported by Bruno Haible in
https://lists.gnu.org/r/grep-devel/2022-07/msg00004.html
https://lists.gnu.org/r/grep-devel/2022-07/msg00006.html
2022-07-09 20:46:45 -07:00
Jim Meyering
aa8ca91c08 tests: long-pattern-perf: better handle exhausted virtual memory
* tests/long-pattern-perf: Don't fail due to a syntax error
when one of the subtests exhausts virtual memory. The larger
test (with a 2MiB regexp) needs about 870MiB of virtual memory.
Require that each timing run exit with status 0, else fail with
a framework_failure_. Reported by Bruno Haible in
https://lists.gnu.org/r/grep-devel/2022-07/msg00006.html
2022-07-03 11:46:09 -07:00
Jim Meyering
b47a3fb155 tests: note that triple-backref is still not fixed
* tests/triple-backref: I noticed that our sole XFAIL is still
required, in spite of a glibc comment that bug 11053 is fixed,
so confirmed that it no longer evokes an abort, but still fails
to produce the expected match.  I.e., this prints nothing:
echo a | grep -E '(.?)(.?)(.?)\3\2\1' -- it should print its input.
2022-07-03 10:21:49 -07:00
Jim Meyering
90bc5d93f1 tests: do not emit ratio of test durations
* tests/hash-collision-perf (ratio): Remove stray diagnostic.
2022-07-03 10:01:04 -07:00
Paul Eggert
0942f31bd8 maint: spelling fixes 2022-06-03 13:07:07 -07:00
Jim Meyering
d922927049 tests: placate syntax-check's sorted-test rule
* tests/Makefile.am (TESTS): Insert color-colors in sorted order.
2022-05-29 22:49:03 -07:00
Jim Meyering
5b98e7b7c2 build: sync init.sh from gnulib 2022-05-29 18:56:22 -07:00
Paul Eggert
d85711f694 tests: new test color-colors
* tests/Makefile.am (TESTS): Add it.
* tests/color-colors: New file.
2022-05-29 16:42:43 -07:00
Paul Eggert
80bcb074ae tests: port to platforms lacking Perl
* tests/init.cfg (require_perl_): New function.
* tests/big-hole, tests/hash-collision-perf, tests/long-pattern-perf:
* tests/many-regex-performance, tests/mb-non-UTF8-performance:
Use it.
2022-05-21 18:43:42 -07:00