View | Details | Raw Unified | Return to bug 46413
Collapse All | Expand All

(-)grep-3.7-alt1/AUTHORS (-1 / +1 lines)
Lines 1-4 Link Here
1
  Copyright (C) 1992, 1997-2002, 2004-2022 Free Software Foundation, Inc.
1
  Copyright (C) 1992, 1997-2002, 2004-2023 Free Software Foundation, Inc.
2
2
3
  Copying and distribution of this file, with or without modification,
3
  Copying and distribution of this file, with or without modification,
4
  are permitted in any medium without royalty provided the copyright
4
  are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/cfg.mk (-4 / +6 lines)
Lines 1-5 Link Here
1
# Customize maint.mk                           -*- makefile -*-
1
# Customize maint.mk                           -*- makefile -*-
2
# Copyright (C) 2009-2022 Free Software Foundation, Inc.
2
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
3
3
4
# This program is free software: you can redistribute it and/or modify
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
5
# it under the terms of the GNU General Public License as published by
Lines 31-37 Link Here
31
# Tests not to run as part of "make distcheck".
31
# Tests not to run as part of "make distcheck".
32
local-checks-to-skip =			\
32
local-checks-to-skip =			\
33
  sc_indent				\
33
  sc_indent				\
34
  sc_texinfo_acronym
34
  sc_texinfo_acronym			\
35
  sc_unportable_grep_q
35
36
36
# Tools used to bootstrap this package, used for "announcement".
37
# Tools used to bootstrap this package, used for "announcement".
37
bootstrap-tools = autoconf,automake,gnulib
38
bootstrap-tools = autoconf,automake,gnulib
Lines 67-73 Link Here
67
# 1127556 9e
68
# 1127556 9e
68
export XZ_OPT = -6e
69
export XZ_OPT = -6e
69
70
70
old_NEWS_hash = f4973b8b2470d613d782203aac8e8304
71
old_NEWS_hash = acc0cb77b06cc80cd3d8811590cdd5f0
71
72
72
# We prefer to spell it back-reference, as POSIX does.
73
# We prefer to spell it back-reference, as POSIX does.
73
sc_prohibit_backref:
74
sc_prohibit_backref:
Lines 97-102 Link Here
97
FILTER_LONG_LINES =							\
98
FILTER_LONG_LINES =							\
98
  /^[^:]*\.diff:[^:]*:@@ / d;						\
99
  /^[^:]*\.diff:[^:]*:@@ / d;						\
99
  \|^[^:]*TODO:| d;							\
100
  \|^[^:]*TODO:| d;							\
101
  \|^[^:]*doc/fdl.texi:| d;						\
100
  \|^[^:]*man/help2man:| d;						\
102
  \|^[^:]*man/help2man:| d;						\
101
  \|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d;				\
103
  \|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d;				\
102
  \|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
104
  \|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
Lines 178-182 Link Here
178
	  | xargs grep -lw timeout					\
180
	  | xargs grep -lw timeout					\
179
	  | xargs grep -FLw require_timeout_				\
181
	  | xargs grep -FLw require_timeout_				\
180
	  | $(GREP) .							\
182
	  | $(GREP) .							\
181
	  && { echo '$(ME): timeout withtout use of require_timeout_'	\
183
	  && { echo '$(ME): timeout without use of require_timeout_'	\
182
	    1>&2; exit 1; } || :
184
	    1>&2; exit 1; } || :
(-)grep-3.7-alt1/ChangeLog-2009 (-19 / +19 lines)
Lines 1407-1413 Link Here
1407
        is put in different compiled structure patterns[]. The patterns
1407
        is put in different compiled structure patterns[]. The patterns
1408
        are given to dfacomp() and kwsmusts() as is.
1408
        are given to dfacomp() and kwsmusts() as is.
1409
        (Ecompile): Likewised.
1409
        (Ecompile): Likewised.
1410
        (Fcompile): Reverse to the old behaviour of compiling the enire
1410
        (Fcompile): Reverse to the old behaviour of compiling the entire
1411
        patterns in one shot.
1411
        patterns in one shot.
1412
        (EGexecute): If falling to GNU regex for the matching, loop in the
1412
        (EGexecute): If falling to GNU regex for the matching, loop in the
1413
        array of compile patterns[] to find a match.
1413
        array of compile patterns[] to find a match.
Lines 1457-1463 Link Here
1457
        (xrealloc): Removed using lib/xmalloc.c.
1457
        (xrealloc): Removed using lib/xmalloc.c.
1458
        (xmalloc): Removed using lib/xmalloc.c
1458
        (xmalloc): Removed using lib/xmalloc.c
1459
        (main): Register with atexit() to check for error on stdout.
1459
        (main): Register with atexit() to check for error on stdout.
1460
        * configure.in: Check for atexit(), call jm_MALLOC, jm_RELLOC and
1460
        * configure.in: Check for atexit(), call jm_MALLOC, jm_REALLOC and
1461
        jm_PREREQ_ERROR.
1461
        jm_PREREQ_ERROR.
1462
        * tests/bre.awk: Removed the hack to drain the buffer since we
1462
        * tests/bre.awk: Removed the hack to drain the buffer since we
1463
        always fclose(stdout) atexit.
1463
        always fclose(stdout) atexit.
Lines 1541-1547 Link Here
1541
        * src/exclude.h: New file.
1541
        * src/exclude.h: New file.
1542
        * src/grep.c (main): Took the GNU tar code to handle
1542
        * src/grep.c (main): Took the GNU tar code to handle
1543
        the option --include, --exclude, --exclude-from.
1543
        the option --include, --exclude, --exclude-from.
1544
        Files are check for a match, with exlude_filename ().
1544
        Files are check for a match, with exclude_filename ().
1545
        New option --exclude-from.
1545
        New option --exclude-from.
1546
        * src/savedir.c: Call exclude_filename() to check for
1546
        * src/savedir.c: Call exclude_filename() to check for
1547
        file pattern exclusion or inclusion.
1547
        file pattern exclusion or inclusion.
Lines 1592-1598 Link Here
1592
1592
1593
        * m4/dosfile.m4 (AC_DOSFILE): Move AC_DEFINEs out of AC_CACHE_CHECK.
1593
        * m4/dosfile.m4 (AC_DOSFILE): Move AC_DEFINEs out of AC_CACHE_CHECK.
1594
1594
1595
2001-02-17  Alain Malgoire
1595
2001-02-17  Alain Magloire
1596
1596
1597
        * doc/grep.texi: Document the new options and the new behaviour
1597
        * doc/grep.texi: Document the new options and the new behaviour
1598
        back-references are local.  Use excerpt from Karl Berry regex
1598
        back-references are local.  Use excerpt from Karl Berry regex
Lines 1699-1706 Link Here
1699
        (color): Rename color variable to color_option.
1699
        (color): Rename color variable to color_option.
1700
        Removed 'always|never|auto' arguments, not necessary for grep.
1700
        Removed 'always|never|auto' arguments, not necessary for grep.
1701
        (exclude_pattern): new variable, holder for the file pattern.
1701
        (exclude_pattern): new variable, holder for the file pattern.
1702
        (include_pattern): new variable, hoder for the file pattern.
1702
        (include_pattern): new variable, holder for the file pattern.
1703
        * src/savedir.c: Signature change, take two new argmuments.
1703
        * src/savedir.c: Signature change, take two new arguments.
1704
        * doc/grep.texi: Document, new options.
1704
        * doc/grep.texi: Document, new options.
1705
        * doc/grep.man: Document, new options.
1705
        * doc/grep.man: Document, new options.
1706
1706
Lines 1712-1718 Link Here
1712
1712
1713
2001-02-09  Alain Magloire
1713
2001-02-09  Alain Magloire
1714
1714
1715
        Patch from Ulrich Drepper to provide hilighting.
1715
        Patch from Ulrich Drepper to provide highlighting.
1716
1716
1717
        * src/grep.c: New option --color.
1717
        * src/grep.c: New option --color.
1718
        (color): New static var.
1718
        (color): New static var.
Lines 1722-1728 Link Here
1722
        to find the offset of the matching string.
1722
        to find the offset of the matching string.
1723
        * src/savedir.c: Take advantage of _DIRENT_HAVE_TYPE if supported.
1723
        * src/savedir.c: Take advantage of _DIRENT_HAVE_TYPE if supported.
1724
        * src/search.c (EGexecute, Fexecute, Pexecute): Take a new argument
1724
        * src/search.c (EGexecute, Fexecute, Pexecute): Take a new argument
1725
        when doing exact match for the color hiligting.
1725
        when doing exact match for the color highlighting.
1726
1726
1727
2000-09-01  Brian Youmans
1727
2000-09-01  Brian Youmans
1728
1728
Lines 1792-1798 Link Here
1792
1792
1793
2000-06-02  Paul Eggert
1793
2000-06-02  Paul Eggert
1794
1794
1795
        Problen noted by Gerald Stoller <gerald_stoller@hotmail.com>
1795
        Problem noted by Gerald Stoller <gerald_stoller@hotmail.com>
1796
1796
1797
        * src/grep.c (main): POSIX says that -q overrides -l, which
1797
        * src/grep.c (main): POSIX says that -q overrides -l, which
1798
        in turn overrides the other output options.  Fix grep to
1798
        in turn overrides the other output options.  Fix grep to
Lines 2208-2214 Link Here
2208
        on pre-OpenVMS 7.x systems; general overhaul.
2208
        on pre-OpenVMS 7.x systems; general overhaul.
2209
        * src/getpagesize.h: Reinstate support for different pagesizes on
2209
        * src/getpagesize.h: Reinstate support for different pagesizes on
2210
        VAX and Alpha. Work around problem with DEC C compiler.
2210
        VAX and Alpha. Work around problem with DEC C compiler.
2211
        * src/vms_fab.c: Cast to some assigments; fixed typo argcp vs. argp.
2211
        * src/vms_fab.c: Cast to some assignments; fixed typo argcp vs. argp.
2212
        * src/vms_fab.h: Added new include files to avoid warnings about
2212
        * src/vms_fab.h: Added new include files to avoid warnings about
2213
        undefined function prototypes.
2213
        undefined function prototypes.
2214
        Those patches were provided by Martin P.J. Zinser (zinser@decus.de).
2214
        Those patches were provided by Martin P.J. Zinser (zinser@decus.de).
Lines 2670-2676 Link Here
2670
2670
2671
1999-03-16 Volker Borchert
2671
1999-03-16 Volker Borchert
2672
2672
2673
        * configure.in: Use case case ... esac for  checking Visual C++.
2673
        * configure.in: Use case ... esac for  checking Visual C++.
2674
        When ${CC} contains options it was not recognize.
2674
        When ${CC} contains options it was not recognize.
2675
2675
2676
1999-03-07 Paul Eggert
2676
1999-03-07 Paul Eggert
Lines 2764-2770 Link Here
2764
2764
2765
1999-02-10 Alain Magloire
2765
1999-02-10 Alain Magloire
2766
2766
2767
        * bootstrap/{Makefile{try,am},REAMDE} : skeleton
2767
        * bootstrap/{Makefile{try,am},README} : skeleton
2768
        provided for system lacking the tools to autoconfigure.
2768
        provided for system lacking the tools to autoconfigure.
2769
2769
2770
        * src/{e,f,}grepmat.c: added guard [HAVE_CONFIG_H]
2770
        * src/{e,f,}grepmat.c: added guard [HAVE_CONFIG_H]
Lines 2858-2864 Link Here
2858
        * doc/Makefile.am djgpp/Makefile.am m4/Makefile.am vms/Makefile.am:
2858
        * doc/Makefile.am djgpp/Makefile.am m4/Makefile.am vms/Makefile.am:
2859
        New files.
2859
        New files.
2860
2860
2861
        * m4/progtest.m4: proctect '[]' from m4.
2861
        * m4/progtest.m4: protect '[]' from m4.
2862
        Noted by Eli Z.
2862
        Noted by Eli Z.
2863
2863
2864
        * PATCHES-AC: New file, add the patch for autoconf in the dist.
2864
        * PATCHES-AC: New file, add the patch for autoconf in the dist.
Lines 3333-3339 Link Here
3333
        Suggested by Harald Hanche-Olsen.
3333
        Suggested by Harald Hanche-Olsen.
3334
3334
3335
        * src/grep.c (main): '-f /dev/null' now specifies no patterns
3335
        * src/grep.c (main): '-f /dev/null' now specifies no patterns
3336
        and therfore matches nothing.
3336
        and therefore matches nothing.
3337
        Reported by Jorge Stolfi.
3337
        Reported by Jorge Stolfi.
3338
        Patched by Paul Eggert.
3338
        Patched by Paul Eggert.
3339
3339
Lines 3368-3374 Link Here
3368
        * src/grep.c: reverse back to greping directories,
3368
        * src/grep.c: reverse back to greping directories,
3369
        One could skip the error message by defining
3369
        One could skip the error message by defining
3370
        SKIP_DIR_ERROR. There is no clear way of doing
3370
        SKIP_DIR_ERROR. There is no clear way of doing
3371
        things, I hope to setle this on the next majore release
3371
        things, I hope to settle this on the next major release
3372
        Thanks Paul Eggert, Eli Zaretskii and gnits for the
3372
        Thanks Paul Eggert, Eli Zaretskii and gnits for the
3373
        exchange.
3373
        exchange.
3374
3374
Lines 3427-3433 Link Here
3427
        (setmatcher) [HAVE_SETRLIMIT]: Set re_max_failures so that the
3427
        (setmatcher) [HAVE_SETRLIMIT]: Set re_max_failures so that the
3428
        matcher won't ever overflow the stack.
3428
        matcher won't ever overflow the stack.
3429
        (main) [__MSDOS__, _WIN32]: Handle backslashes and drive letters
3429
        (main) [__MSDOS__, _WIN32]: Handle backslashes and drive letters
3430
        in argv[0], remove the .exe suffix, and downcase the prgram name.
3430
        in argv[0], remove the .exe suffix, and downcase the program name.
3431
        [O_BINARY]: Pass additional DOS-specific options to getopt_long
3431
        [O_BINARY]: Pass additional DOS-specific options to getopt_long
3432
        and handle them.  Call stat before attempting to open the file, in
3432
        and handle them.  Call stat before attempting to open the file, in
3433
        case it is a directory (DOS will fail the open call for
3433
        case it is a directory (DOS will fail the open call for
Lines 3497-3503 Link Here
3497
        regex package. Change the way the tests were done to be more
3497
        regex package. Change the way the tests were done to be more
3498
        conformant to automake.
3498
        conformant to automake.
3499
3499
3500
        * configure.in: added --disable-regex for folks with their own fuctions.
3500
        * configure.in: added --disable-regex for folks with their own functions.
3501
3501
3502
        * grep-20d : available for testing
3502
        * grep-20d : available for testing
3503
3503
Lines 3551-3557 Link Here
3551
3551
3552
        * check.sh, scriptgen.awk: fix grep paths.
3552
        * check.sh, scriptgen.awk: fix grep paths.
3553
3553
3554
        * change the directory strucure: grep is now in src to comply with
3554
        * change the directory structure: grep is now in src to comply with
3555
        gettext.m4.
3555
        gettext.m4.
3556
3556
3557
        * grep.c version.c [VERSION]: got rid of version.c,
3557
        * grep.c version.c [VERSION]: got rid of version.c,
Lines 3648-3653 Link Here
3648
3648
3649
        * Version 2.0 released.
3649
        * Version 2.0 released.
3650
3650
3651
Copyright (C) 1998-2022 Free Software Foundation, Inc.
3651
Copyright (C) 1998-2023 Free Software Foundation, Inc.
3652
Copying and distribution of this file, with or without modification,
3652
Copying and distribution of this file, with or without modification,
3653
  are permitted provided the copyright notice and this notice are preserved.
3653
  are permitted provided the copyright notice and this notice are preserved.
(-)grep-3.7-alt1/configure.ac (-6 / +4 lines)
Lines 1-7 Link Here
1
dnl
1
dnl
2
dnl autoconf input file for GNU grep
2
dnl autoconf input file for GNU grep
3
dnl
3
dnl
4
dnl Copyright (C) 1997-2006, 2009-2022 Free Software Foundation, Inc.
4
dnl Copyright (C) 1997-2006, 2009-2023 Free Software Foundation, Inc.
5
dnl
5
dnl
6
dnl This file is part of GNU grep.
6
dnl This file is part of GNU grep.
7
dnl
7
dnl
Lines 68-78 Link Here
68
AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
68
AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs])
69
69
70
# The test suite needs to know if we have a working perl.
70
# The test suite needs to know if we have a working perl.
71
# FIXME: this is suboptimal.  Ideally, we would be able to call gl_PERL
71
AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no])
72
# with an ACTION-IF-NOT-FOUND argument ...
73
cu_have_perl=yes
74
case $PERL in *"/missing "*) cu_have_perl=no;; esac
75
AM_CONDITIONAL([HAVE_PERL], [test $cu_have_perl = yes])
76
72
77
# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
73
# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
78
# ------------------------------------------------
74
# ------------------------------------------------
Lines 142-147 Link Here
142
  gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
138
  gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
143
  gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
139
  gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
144
  gl_WARN_ADD([-Wno-cast-function-type]) # sig-handler.h's sa_handler_t cast
140
  gl_WARN_ADD([-Wno-cast-function-type]) # sig-handler.h's sa_handler_t cast
141
  gl_WARN_ADD([-Wno-deprecated-declarations]) # clang complains about sprintf
145
142
146
  # In spite of excluding -Wlogical-op above, it is enabled, as of
143
  # In spite of excluding -Wlogical-op above, it is enabled, as of
147
  # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
144
  # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
Lines 215-220 Link Here
215
AM_CONDITIONAL([USE_INCLUDED_REGEX], [test "$ac_use_included_regex" = yes])
212
AM_CONDITIONAL([USE_INCLUDED_REGEX], [test "$ac_use_included_regex" = yes])
216
if test "$ac_use_included_regex" = no; then
213
if test "$ac_use_included_regex" = no; then
217
  AC_MSG_WARN([Included lib/regex.c not used])
214
  AC_MSG_WARN([Included lib/regex.c not used])
215
  AC_DEFINE([USE_INCLUDED_REGEX], 1, [building with included regex code])
218
fi
216
fi
219
217
220
gl_FUNC_PCRE
218
gl_FUNC_PCRE
(-)grep-3.7-alt1/doc/grep.in.1 (-67 / +27 lines)
Lines 244-249 Link Here
244
.RB ( \-\^\-regexp )
244
.RB ( \-\^\-regexp )
245
option, search for all patterns given.
245
option, search for all patterns given.
246
The empty file contains zero patterns, and therefore matches nothing.
246
The empty file contains zero patterns, and therefore matches nothing.
247
If
248
.IR FILE
249
is
250
.B \-
251
, read patterns from standard input.
247
.TP
252
.TP
248
.BR \-i ", " \-\^\-ignore\-case
253
.BR \-i ", " \-\^\-ignore\-case
249
Ignore case distinctions in patterns and input data,
254
Ignore case distinctions in patterns and input data,
Lines 279-288 Link Here
279
.B ^
284
.B ^
280
and
285
and
281
.BR $ .
286
.BR $ .
282
.TP
283
.B \-y
284
Obsolete synonym for
285
.BR \-i .
286
.SS "General Output Control"
287
.SS "General Output Control"
287
.TP
288
.TP
288
.BR \-c ", " \-\^\-count
289
.BR \-c ", " \-\^\-count
Lines 299-307 Link Here
299
on the terminal.
300
on the terminal.
300
The colors are defined by the environment variable
301
The colors are defined by the environment variable
301
.BR GREP_COLORS .
302
.BR GREP_COLORS .
302
The deprecated environment variable
303
.B GREP_COLOR
304
is still supported, but its setting does not have priority.
305
.I WHEN
303
.I WHEN
306
is
304
is
307
.BR never ", " always ", or " auto .
305
.BR never ", " always ", or " auto .
Lines 321-326 Link Here
321
Stop reading a file after
319
Stop reading a file after
322
.I NUM
320
.I NUM
323
matching lines.
321
matching lines.
322
If
323
.I NUM
324
is zero,
325
.B grep
326
stops right away without reading input.
327
A
328
.I NUM
329
of \-1 is treated as infinity and
330
.B grep
331
does not stop; this is the default.
324
If the input is standard input from a regular file,
332
If the input is standard input from a regular file,
325
and
333
and
326
.I NUM
334
.I NUM
Lines 712-723 Link Here
712
.BR \-U ", " \-\^\-binary
720
.BR \-U ", " \-\^\-binary
713
Treat the file(s) as binary.
721
Treat the file(s) as binary.
714
By default, under MS-DOS and MS-Windows,
722
By default, under MS-DOS and MS-Windows,
715
.BR grep
723
.B grep
716
guesses whether a file is text or binary as described for the
724
guesses whether a file is text or binary as described for the
717
.B \-\^\-binary\-files
725
.B \-\^\-binary\-files
718
option.
726
option.
719
If
727
If
720
.BR grep
728
.B grep
721
decides the file is a text file, it strips the CR characters from the
729
decides the file is a text file, it strips the CR characters from the
722
original file contents (to make regular expressions with
730
original file contents (to make regular expressions with
723
.B ^
731
.B ^
Lines 753-765 Link Here
753
understands three different versions of regular expression syntax:
761
understands three different versions of regular expression syntax:
754
\*(lqbasic\*(rq (BRE), \*(lqextended\*(rq (ERE) and \*(lqperl\*(rq (PCRE).
762
\*(lqbasic\*(rq (BRE), \*(lqextended\*(rq (ERE) and \*(lqperl\*(rq (PCRE).
755
In GNU
763
In GNU
756
.B grep
764
.BR grep ,
757
there is no difference in available functionality between basic and
765
basic and extended regular expressions are merely different notations
758
extended syntaxes.
766
for the same pattern-matching functionality.
759
In other implementations, basic regular expressions are less powerful.
767
In other implementations, basic regular expressions are ordinarily
768
less powerful than extended, though occasionally it is the other way around.
760
The following description applies to extended regular expressions;
769
The following description applies to extended regular expressions;
761
differences for basic regular expressions are summarized afterwards.
770
differences for basic regular expressions are summarized afterwards.
762
Perl-compatible regular expressions give additional functionality, and are
771
Perl-compatible regular expressions have different functionality, and are
763
documented in
772
documented in
764
.BR pcre2syntax (3)
773
.BR pcre2syntax (3)
765
and
774
and
Lines 1003-1036 Link Here
1003
.B "locale \-a"
1012
.B "locale \-a"
1004
lists locales that are currently available.
1013
lists locales that are currently available.
1005
.TP
1014
.TP
1006
.B GREP_COLOR
1007
This variable specifies the color used to highlight matched (non-empty) text.
1008
It is deprecated in favor of
1009
.BR GREP_COLORS ,
1010
but still supported.
1011
The
1012
.BR mt ,
1013
.BR ms ,
1014
and
1015
.B mc
1016
capabilities of
1017
.B GREP_COLORS
1015
.B GREP_COLORS
1018
have priority over it.
1016
Controls how the
1019
It can only specify the color used to highlight
1017
.B \-\^\-color
1020
the matching non-empty text in any matching line
1018
option highlights output.
1021
(a selected line when the
1022
.B \-v
1023
command-line option is omitted,
1024
or a context line when
1025
.B \-v
1026
is specified).
1027
The default is
1028
.BR 01;31 ,
1029
which means a bold red foreground text on the terminal's default background.
1030
.TP
1031
.B GREP_COLORS
1032
Specifies the colors and other attributes
1033
used to highlight various parts of the output.
1034
Its value is a colon-separated list of capabilities
1019
Its value is a colon-separated list of capabilities
1035
that defaults to
1020
that defaults to
1036
.B ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36
1021
.B ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36
Lines 1264-1301 Link Here
1264
Also, POSIX requires that unrecognized options be diagnosed as
1249
Also, POSIX requires that unrecognized options be diagnosed as
1265
\*(lqillegal\*(rq, but since they are not really against the law the default
1250
\*(lqillegal\*(rq, but since they are not really against the law the default
1266
is to diagnose them as \*(lqinvalid\*(rq.
1251
is to diagnose them as \*(lqinvalid\*(rq.
1267
.B POSIXLY_CORRECT
1268
also disables \fB_\fP\fIN\fP\fB_GNU_nonoption_argv_flags_\fP,
1269
described below.
1270
.TP
1271
\fB_\fP\fIN\fP\fB_GNU_nonoption_argv_flags_\fP
1272
(Here
1273
.I N
1274
is
1275
.BR grep 's
1276
numeric process ID.)  If the
1277
.IR i th
1278
character of this environment variable's value is
1279
.BR 1 ,
1280
do not consider the
1281
.IR i th
1282
operand of
1283
.B grep
1284
to be an option, even if it appears to be one.
1285
A shell can put this variable in the environment for each command it runs,
1286
specifying which operands are the results of file name wildcard
1287
expansion and therefore should not be treated as options.
1288
This behavior is available only with the GNU C library, and only
1289
when
1290
.B POSIXLY_CORRECT
1291
is not set.
1292
.
1252
.
1293
.SH NOTES
1253
.SH NOTES
1294
This man page is maintained only fitfully;
1254
This man page is maintained only fitfully;
1295
the full documentation is often more up-to-date.
1255
the full documentation is often more up-to-date.
1296
.
1256
.
1297
.SH COPYRIGHT
1257
.SH COPYRIGHT
1298
Copyright 1998-2000, 2002, 2005-2022 Free Software Foundation, Inc.
1258
Copyright 1998-2000, 2002, 2005-2023 Free Software Foundation, Inc.
1299
.PP
1259
.PP
1300
This is free software;
1260
This is free software;
1301
see the source for copying conditions.
1261
see the source for copying conditions.
(-)grep-3.7-alt1/doc/grep.texi (-108 / +293 lines)
Lines 30-36 Link Here
30
@copying
30
@copying
31
This manual is for @command{grep}, a pattern matching engine.
31
This manual is for @command{grep}, a pattern matching engine.
32
32
33
Copyright @copyright{} 1999--2002, 2005, 2008--2022 Free Software Foundation,
33
Copyright @copyright{} 1999--2002, 2005, 2008--2023 Free Software Foundation,
34
Inc.
34
Inc.
35
35
36
@quotation
36
@quotation
Lines 202-207 Link Here
202
Obtain patterns from @var{file}, one per line.
202
Obtain patterns from @var{file}, one per line.
203
If this option is used multiple times or is combined with the
203
If this option is used multiple times or is combined with the
204
@option{-e} (@option{--regexp}) option, search for all patterns given.
204
@option{-e} (@option{--regexp}) option, search for all patterns given.
205
When @var{file} is @samp{-}, read patterns from standard input.
205
The empty file contains zero patterns, and therefore matches nothing.
206
The empty file contains zero patterns, and therefore matches nothing.
206
(@option{-f} is specified by POSIX.)
207
(@option{-f} is specified by POSIX.)
207
208
Lines 223-229 Link Here
223
it yields ``S''.  Another example: the lowercase German letter ``ß''
224
it yields ``S''.  Another example: the lowercase German letter ``ß''
224
(U+00DF, LATIN SMALL LETTER SHARP S) is normally capitalized as the
225
(U+00DF, LATIN SMALL LETTER SHARP S) is normally capitalized as the
225
two-character string ``SS'' but it does not match ``SS'', and it might
226
two-character string ``SS'' but it does not match ``SS'', and it might
226
not match the uppercase letter ``ẞ'' (U+1E9E, LATIN CAPITAL LETTER
227
not match the uppercase letter
228
@c texinfo version 2023-03-04.12 complains about the following, saying
229
@c "Character missing, sorry: LONG S."  For now, omit it if tex.
230
@ifnottex
231
``ẞ''
232
@end ifnottex
233
(U+1E9E, LATIN CAPITAL LETTER
227
SHARP S) even though lowercasing the latter yields the former.
234
SHARP S) even though lowercasing the latter yields the former.
228
235
229
@option{-y} is an obsolete synonym that is provided for compatibility.
236
@option{-y} is an obsolete synonym that is provided for compatibility.
Lines 265-272 Link Here
265
regular expression with @samp{\<} and @samp{\>}.  For example, although
272
regular expression with @samp{\<} and @samp{\>}.  For example, although
266
@samp{grep -w @@} matches a line containing only @samp{@@}, @samp{grep
273
@samp{grep -w @@} matches a line containing only @samp{@@}, @samp{grep
267
'\<@@\>'} cannot match any line because @samp{@@} is not a
274
'\<@@\>'} cannot match any line because @samp{@@} is not a
268
word constituent.  @xref{The Backslash Character and Special
275
word constituent.  @xref{Special Backslash Expressions}.
269
Expressions}.
270
276
271
@item -x
277
@item -x
272
@itemx --line-regexp
278
@itemx --line-regexp
Lines 301-307 Link Here
301
@opindex --color
307
@opindex --color
302
@opindex --colour
308
@opindex --colour
303
@cindex highlight, color, colour
309
@cindex highlight, color, colour
304
Surround the matched (non-empty) strings, matching lines, context lines,
310
Surround matched non-empty strings, matching lines, context lines,
305
file names, line numbers, byte offsets, and separators (for fields and
311
file names, line numbers, byte offsets, and separators (for fields and
306
groups of context lines) with escape sequences to display them in color
312
groups of context lines) with escape sequences to display them in color
307
on the terminal.
313
on the terminal.
Lines 309-319 Link Here
309
and default to @samp{ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36}
315
and default to @samp{ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36}
310
for bold red matched text, magenta file names, green line numbers,
316
for bold red matched text, magenta file names, green line numbers,
311
green byte offsets, cyan separators, and default terminal colors otherwise.
317
green byte offsets, cyan separators, and default terminal colors otherwise.
312
The deprecated environment variable @env{GREP_COLOR} is still supported,
318
@xref{Environment Variables}.
313
but its setting does not have priority;
319
314
it defaults to @samp{01;31} (bold red)
320
@var{WHEN} is @samp{always} to use colors, @samp{never} to not use
315
which only covers the color for matched text.
321
colors, or @samp{auto} to use colors if standard output is associated
316
@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
322
with a terminal device and the @env{TERM} environment variable's value
323
suggests that the terminal supports colors.
324
Plain @option{--color} is treated like @option{--color=auto};
325
if no @option{--color} option is given, the default is @option{--color=never}.
317
326
318
@item -L
327
@item -L
319
@itemx --files-without-match
328
@itemx --files-without-match
Lines 341-346 Link Here
341
@opindex --max-count
350
@opindex --max-count
342
@cindex max-count
351
@cindex max-count
343
Stop after the first @var{num} selected lines.
352
Stop after the first @var{num} selected lines.
353
If @var{num} is zero, @command{grep} stops right away without reading input.
354
A @var{num} of @minus{}1 is treated as infinity and @command{grep}
355
does not stop; this is the default.
356
344
If the input is standard input from a regular file,
357
If the input is standard input from a regular file,
345
and @var{num} selected lines are output,
358
and @var{num} selected lines are output,
346
@command{grep} ensures that the standard input is positioned
359
@command{grep} ensures that the standard input is positioned
Lines 381-387 Link Here
381
@opindex -o
394
@opindex -o
382
@opindex --only-matching
395
@opindex --only-matching
383
@cindex only matching
396
@cindex only matching
384
Print only the matched (non-empty) parts of matching lines,
397
Print only the matched non-empty parts of matching lines,
385
with each such part on a separate output line.
398
with each such part on a separate output line.
386
Output lines use the same delimiters as input, and delimiters are null
399
Output lines use the same delimiters as input, and delimiters are null
387
bytes if @option{-z} (@option{--null-data}) is also used (@pxref{Other
400
bytes if @option{-z} (@option{--null-data}) is also used (@pxref{Other
Lines 813-820 Link Here
813
@node Environment Variables
826
@node Environment Variables
814
@section Environment Variables
827
@section Environment Variables
815
828
816
The behavior of @command{grep} is affected
829
The behavior of @command{grep} is affected by several environment
817
by the following environment variables.
830
variables, the most important of which control the locale, which
831
specifies how @command{grep} interprets characters in its patterns and
832
data.
818
833
819
@vindex LANGUAGE @r{environment variable}
834
@vindex LANGUAGE @r{environment variable}
820
@vindex LC_ALL @r{environment variable}
835
@vindex LC_ALL @r{environment variable}
Lines 826-833 Link Here
826
in that order.
841
in that order.
827
The first of these variables that is set specifies the locale.
842
The first of these variables that is set specifies the locale.
828
For example, if @env{LC_ALL} is not set,
843
For example, if @env{LC_ALL} is not set,
829
but @env{LC_COLLATE} is set to @samp{pt_BR},
844
but @env{LC_COLLATE} is set to @samp{pt_BR.UTF-8},
830
then the Brazilian Portuguese locale is used
845
then a Brazilian Portuguese locale is used
831
for the @env{LC_COLLATE} category.
846
for the @env{LC_COLLATE} category.
832
As a special case for @env{LC_MESSAGES} only, the environment variable
847
As a special case for @env{LC_MESSAGES} only, the environment variable
833
@env{LANGUAGE} can contain a colon-separated list of languages that
848
@env{LANGUAGE} can contain a colon-separated list of languages that
Lines 839-845 Link Here
839
with national language support (NLS).
854
with national language support (NLS).
840
The shell command @code{locale -a} lists locales that are currently available.
855
The shell command @code{locale -a} lists locales that are currently available.
841
856
842
Many of the environment variables in the following list let you
857
@cindex environment variables
858
The following environment variables affect the behavior of @command{grep}.
859
860
@table @env
861
862
@item GREP_COLOR
863
@vindex GREP_COLOR @r{environment variable}
864
@cindex highlight markers
865
This obsolescent variable interacts with @env{GREP_COLORS}
866
confusingly, and @command{grep} warns if it is set and is not
867
overridden by @env{GREP_COLORS}.  Instead of
868
@samp{GREP_COLOR='@var{color}'}, you can use
869
@samp{GREP_COLORS='mt=@var{color}'}.
870
871
@item GREP_COLORS
872
@vindex GREP_COLORS @r{environment variable}
873
@cindex highlight markers
874
This variable controls how the @option{--color} option highlights output.
875
Its value is a colon-separated list of @code{terminfo} capabilities
876
that defaults to @samp{ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36}
877
with the @samp{rv} and @samp{ne} boolean capabilities omitted (i.e., false).
878
The two-letter capability names
879
refer to terminal ``capabilities,'' the ability
880
of a terminal to highlight text, or change its color, and so on.
881
These capabilities are stored in an online database and accessed by
882
the @code{terminfo} library.
883
Non-empty capability values
843
control highlighting using
884
control highlighting using
844
Select Graphic Rendition (SGR)
885
Select Graphic Rendition (SGR)
845
commands interpreted by the terminal or terminal emulator.
886
commands interpreted by the terminal or terminal emulator.
Lines 867-904 Link Here
867
and @samp{48;5;0} to @samp{48;5;255}
908
and @samp{48;5;0} to @samp{48;5;255}
868
for 88-color and 256-color modes background colors.
909
for 88-color and 256-color modes background colors.
869
910
870
The two-letter names used in the @env{GREP_COLORS} environment variable
871
(and some of the others) refer to terminal ``capabilities,'' the ability
872
of a terminal to highlight text, or change its color, and so on.
873
These capabilities are stored in an online database and accessed by
874
the @code{terminfo} library.
875
876
@cindex environment variables
877
878
@table @env
879
880
@item GREP_COLOR
881
@vindex GREP_COLOR @r{environment variable}
882
@cindex highlight markers
883
This variable specifies the color used to highlight matched (non-empty) text.
884
It is deprecated in favor of @env{GREP_COLORS}, but still supported.
885
The @samp{mt}, @samp{ms}, and @samp{mc} capabilities of @env{GREP_COLORS}
886
have priority over it.
887
It can only specify the color used to highlight
888
the matching non-empty text in any matching line
889
(a selected line when the @option{-v} command-line option is omitted,
890
or a context line when @option{-v} is specified).
891
The default is @samp{01;31},
892
which means a bold red foreground text on the terminal's default background.
893
894
@item GREP_COLORS
895
@vindex GREP_COLORS @r{environment variable}
896
@cindex highlight markers
897
This variable specifies the colors and other attributes
898
used to highlight various parts of the output.
899
Its value is a colon-separated list of @code{terminfo} capabilities
900
that defaults to @samp{ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36}
901
with the @samp{rv} and @samp{ne} boolean capabilities omitted (i.e., false).
902
Supported capabilities are as follows.
911
Supported capabilities are as follows.
903
912
904
@table @code
913
@table @code
Lines 1009-1015 Link Here
1009
@cindex national language support
1018
@cindex national language support
1010
@cindex NLS
1019
@cindex NLS
1011
These variables specify the locale for the @env{LC_COLLATE} category,
1020
These variables specify the locale for the @env{LC_COLLATE} category,
1012
which might affect how range expressions like @samp{[a-z]} are
1021
which might affect how range expressions like @samp{a-z} are
1013
interpreted.
1022
interpreted.
1014
1023
1015
@item LC_ALL
1024
@item LC_ALL
Lines 1052-1071 Link Here
1052
by default,
1061
by default,
1053
such options are permuted to the front of the operand list
1062
such options are permuted to the front of the operand list
1054
and are treated as options.
1063
and are treated as options.
1055
Also, @env{POSIXLY_CORRECT} disables special handling of an
1056
invalid bracket expression.  @xref{invalid-bracket-expr}.
1057
1064
1058
@item _@var{N}_GNU_nonoption_argv_flags_
1065
@item TERM
1059
@vindex _@var{N}_GNU_nonoption_argv_flags_ @r{environment variable}
1066
@vindex TERM @r{environment variable}
1060
(Here @code{@var{N}} is @command{grep}'s numeric process ID.)
1067
This variable specifies the output terminal type, which can affect
1061
If the @var{i}th character of this environment variable's value is @samp{1},
1068
what the @option{--color} option does.  @xref{General Output Control}.
1062
do not consider the @var{i}th operand of @command{grep} to be an option,
1063
even if it appears to be one.
1064
A shell can put this variable in the environment for each command it runs,
1065
specifying which operands are the results of file name wildcard expansion
1066
and therefore should not be treated as options.
1067
This behavior is available only with the GNU C library,
1068
and only when @env{POSIXLY_CORRECT} is not set.
1069
1069
1070
@end table
1070
@end table
1071
1071
Lines 1148-1153 Link Here
1148
@samp{grep@ -P} may warn of unimplemented features.
1148
@samp{grep@ -P} may warn of unimplemented features.
1149
@xref{Other Options}.
1149
@xref{Other Options}.
1150
1150
1151
For documentation, refer to @url{https://www.pcre.org/}, with these caveats:
1152
@itemize
1153
@item
1154
@samp{\d} matches only the ten ASCII digits
1155
(and @samp{\D} matches the complement), regardless of locale.
1156
Use @samp{\p@{Nd@}} to also match non-ASCII digits.
1157
(The behavior of @samp{\d} and @samp{\D} is unspecified after
1158
in-regexp directives like @samp{(?aD)}.)
1159
1160
@item
1161
Although PCRE tracks the syntax and semantics of Perl's regular
1162
expressions, the match is not always exact.  For example, Perl
1163
evolves and a Perl installation may predate or postdate the PCRE2
1164
installation on the same host, or their Unicode versions may differ,
1165
or Perl and PCRE2 may disagree about an obscure construct.
1166
1167
@item
1168
By default, @command{grep} applies each regexp to a line at a time,
1169
so the @samp{(?s)} directive (making @samp{.} match line breaks)
1170
is generally ineffective.
1171
However, with @option{-z} (@option{--null-data}) it can work:
1172
@example
1173
$ printf 'a\nb\n' |grep -zP '(?s)a.b'
1174
a
1175
b
1176
@end example
1177
But beware: with the @option{-z} (@option{--null-data}) and a file
1178
containing no NUL byte, grep must read the entire file into memory
1179
before processing any of it.
1180
Thus, it will exhaust memory and fail for some large files.
1181
@end itemize
1182
1151
@end table
1183
@end table
1152
1184
1153
1185
Lines 1162-1183 Link Here
1162
three different versions of regular expression syntax:
1194
three different versions of regular expression syntax:
1163
basic (BRE), extended (ERE), and Perl-compatible (PCRE).
1195
basic (BRE), extended (ERE), and Perl-compatible (PCRE).
1164
In GNU @command{grep},
1196
In GNU @command{grep},
1165
there is no difference in available functionality between the basic and
1197
basic and extended regular expressions are merely different notations
1166
extended syntaxes.
1198
for the same pattern-matching functionality.
1167
In other implementations, basic regular expressions are less powerful.
1199
In other implementations, basic regular expressions are ordinarily
1200
less powerful than extended, though occasionally it is the other way around.
1168
The following description applies to extended regular expressions;
1201
The following description applies to extended regular expressions;
1169
differences for basic regular expressions are summarized afterwards.
1202
differences for basic regular expressions are summarized afterwards.
1170
Perl-compatible regular expressions give additional functionality, and
1203
Perl-compatible regular expressions have different functionality, and
1171
are documented in the @i{pcre2syntax}(3) and @i{pcre2pattern}(3) manual
1204
are documented in the @i{pcre2syntax}(3) and @i{pcre2pattern}(3) manual
1172
pages, but work only if PCRE is available in the system.
1205
pages, but work only if PCRE is available in the system.
1173
1206
1174
@menu
1207
@menu
1175
* Fundamental Structure::
1208
* Fundamental Structure::
1176
* Character Classes and Bracket Expressions::
1209
* Character Classes and Bracket Expressions::
1177
* The Backslash Character and Special Expressions::
1210
* Special Backslash Expressions::
1178
* Anchoring::
1211
* Anchoring::
1179
* Back-references and Subexpressions::
1212
* Back-references and Subexpressions::
1180
* Basic vs Extended::
1213
* Basic vs Extended::
1214
* Problematic Expressions::
1181
* Character Encoding::
1215
* Character Encoding::
1182
* Matching Non-ASCII::
1216
* Matching Non-ASCII::
1183
@end menu
1217
@end menu
Lines 1257-1265 Link Here
1257
matches any string formed by concatenating two substrings
1291
matches any string formed by concatenating two substrings
1258
that respectively match the concatenated expressions.
1292
that respectively match the concatenated expressions.
1259
1293
1260
Two regular expressions may be joined by the infix operator @samp{|};
1294
@cindex alternatives in regular expressions
1261
the resulting regular expression
1295
Two regular expressions may be joined by the infix operator @samp{|}.
1262
matches any string matching either alternate expression.
1296
The resulting regular expression matches any string matching either of
1297
the two expressions, which are called @dfn{alternatives}.
1263
1298
1264
Repetition takes precedence over concatenation,
1299
Repetition takes precedence over concatenation,
1265
which in turn takes precedence over alternation.
1300
which in turn takes precedence over alternation.
Lines 1267-1272 Link Here
1267
to override these precedence rules and form a subexpression.
1302
to override these precedence rules and form a subexpression.
1268
An unmatched @samp{)} matches just itself.
1303
An unmatched @samp{)} matches just itself.
1269
1304
1305
Not every character string is a valid regular expression.
1306
@xref{Problematic Expressions}.
1307
1270
@node Character Classes and Bracket Expressions
1308
@node Character Classes and Bracket Expressions
1271
@section Character Classes and Bracket Expressions
1309
@section Character Classes and Bracket Expressions
1272
1310
Lines 1294-1300 Link Here
1294
In other locales, the sorting sequence is not specified, and
1332
In other locales, the sorting sequence is not specified, and
1295
@samp{[a-d]} might be equivalent to @samp{[abcd]} or to
1333
@samp{[a-d]} might be equivalent to @samp{[abcd]} or to
1296
@samp{[aBbCcDd]}, or it might fail to match any character, or the set of
1334
@samp{[aBbCcDd]}, or it might fail to match any character, or the set of
1297
characters that it matches might even be erratic.
1335
characters that it matches might be erratic, or it might be invalid.
1298
To obtain the traditional interpretation
1336
To obtain the traditional interpretation
1299
of bracket expressions, you can use the @samp{C} locale by setting the
1337
of bracket expressions, you can use the @samp{C} locale by setting the
1300
@env{LC_ALL} environment variable to the value @samp{C}.
1338
@env{LC_ALL} environment variable to the value @samp{C}.
Lines 1397-1408 Link Here
1397
part of the symbolic names, and must be included in addition to
1435
part of the symbolic names, and must be included in addition to
1398
the brackets delimiting the bracket expression.
1436
the brackets delimiting the bracket expression.
1399
1437
1400
@anchor{invalid-bracket-expr}
1401
If you mistakenly omit the outer brackets, and search for say, @samp{[:upper:]},
1438
If you mistakenly omit the outer brackets, and search for say, @samp{[:upper:]},
1402
GNU @command{grep} prints a diagnostic and exits with status 2, on
1439
GNU @command{grep} prints a diagnostic and exits with status 2, on
1403
the assumption that you did not intend to search for the nominally
1440
the assumption that you did not intend to search for the
1404
equivalent regular expression: @samp{[:epru]}.
1441
regular expression @samp{[:epru]}.
1405
Set the @env{POSIXLY_CORRECT} environment variable to disable this feature.
1406
1442
1407
Special characters lose their special meaning inside bracket expressions.
1443
Special characters lose their special meaning inside bracket expressions.
1408
1444
Lines 1433-1439 Link Here
1433
1469
1434
@item -
1470
@item -
1435
represents the range if it's not first or last in a list or the ending point
1471
represents the range if it's not first or last in a list or the ending point
1436
of a range.
1472
of a range.  To make the @samp{-} a list item, it is best to put it last.
1437
1473
1438
@item ^
1474
@item ^
1439
represents the characters not in the list.
1475
represents the characters not in the list.
Lines 1442-1449 Link Here
1442
1478
1443
@end table
1479
@end table
1444
1480
1445
@node The Backslash Character and Special Expressions
1481
@node Special Backslash Expressions
1446
@section The Backslash Character and Special Expressions
1482
@section Special Backslash Expressions
1447
@cindex backslash
1483
@cindex backslash
1448
1484
1449
The @samp{\} character followed by a special character is a regular
1485
The @samp{\} character followed by a special character is a regular
Lines 1478-1488 Link Here
1478
@item \S
1514
@item \S
1479
Match non-whitespace, it is a synonym for @samp{[^[:space:]]}.
1515
Match non-whitespace, it is a synonym for @samp{[^[:space:]]}.
1480
1516
1517
@item \]
1518
Match @samp{]}.
1519
1520
@item \@}
1521
Match @samp{@}}.
1522
1481
@end table
1523
@end table
1482
1524
1483
For example, @samp{\brat\b} matches the separate word @samp{rat},
1525
For example, @samp{\brat\b} matches the separate word @samp{rat},
1484
@samp{\Brat\B} matches @samp{crate} but not @samp{furry rat}.
1526
@samp{\Brat\B} matches @samp{crate} but not @samp{furry rat}.
1485
1527
1528
The behavior of @command{grep} is unspecified if a unescaped backslash
1529
is not followed by a special character, a nonzero digit, or a
1530
character in the above list.  Although @command{grep} might issue a
1531
diagnostic and/or give the backslash an interpretation now, its
1532
behavior may change if the syntax of regular expressions is extended
1533
in future versions.
1534
1486
@node Anchoring
1535
@node Anchoring
1487
@section Anchoring
1536
@section Anchoring
1488
@cindex anchoring
1537
@cindex anchoring
Lines 1518-1565 Link Here
1518
@section Basic vs Extended Regular Expressions
1567
@section Basic vs Extended Regular Expressions
1519
@cindex basic regular expressions
1568
@cindex basic regular expressions
1520
1569
1521
In basic regular expressions the characters @samp{?}, @samp{+},
1570
Basic regular expressions differ from extended regular expressions
1571
in the following ways:
1572
1573
@itemize
1574
@item
1575
The characters @samp{?}, @samp{+},
1522
@samp{@{}, @samp{|}, @samp{(}, and @samp{)} lose their special meaning;
1576
@samp{@{}, @samp{|}, @samp{(}, and @samp{)} lose their special meaning;
1523
instead use the backslashed versions @samp{\?}, @samp{\+}, @samp{\@{},
1577
instead use the backslashed versions @samp{\?}, @samp{\+}, @samp{\@{},
1524
@samp{\|}, @samp{\(}, and @samp{\)}.  Also, a backslash is needed
1578
@samp{\|}, @samp{\(}, and @samp{\)}.  Also, a backslash is needed
1525
before an interval expression's closing @samp{@}}, and an unmatched
1579
before an interval expression's closing @samp{@}}.
1526
@code{\)} is invalid.
1580
1581
@item
1582
An unmatched @samp{\)} is invalid.
1583
1584
@item
1585
If an unescaped @samp{^} appears neither first, nor directly after
1586
@samp{\(} or @samp{\|}, it is treated like an ordinary character and
1587
is not an anchor.
1588
1589
@item
1590
If an unescaped @samp{$} appears neither last, nor directly before
1591
@samp{\|} or @samp{\)}, it is treated like an ordinary character and
1592
is not an anchor.
1593
1594
@item
1595
If an unescaped @samp{*} appears first, or appears directly after
1596
@samp{\(} or @samp{\|} or anchoring @samp{^}, it is treated like an
1597
ordinary character and is not a repetition operator.
1598
@end itemize
1599
1600
@node Problematic Expressions
1601
@section Problematic Regular Expressions
1527
1602
1528
Portable scripts should avoid the following constructs, as
1603
@cindex invalid regular expressions
1529
POSIX says they produce unspecified results:
1604
@cindex unspecified behavior in regular expressions
1605
Some strings are @dfn{invalid regular expressions} and cause
1606
@command{grep} to issue a diagnostic and fail.  For example, @samp{xy\1}
1607
is invalid because there is no parenthesized subexpression for the
1608
back-reference @samp{\1} to refer to.
1609
1610
Also, some regular expressions have @dfn{unspecified behavior} and
1611
should be avoided even if @command{grep} does not currently diagnose
1612
them.  For example, @samp{xy\0} has unspecified behavior because
1613
@samp{0} is not a special character and @samp{\0} is not a special
1614
backslash expression (@pxref{Special Backslash Expressions}).
1615
Unspecified behavior can be particularly problematic because the set
1616
of matched strings might be only partially specified, or not be
1617
specified at all, or the expression might even be invalid.
1618
1619
The following regular expression constructs are invalid on all
1620
platforms conforming to POSIX, so portable scripts can assume that
1621
@command{grep} rejects these constructs:
1530
1622
1531
@itemize @bullet
1623
@itemize @bullet
1532
@item
1624
@item
1533
Extended regular expressions that use back-references.
1625
A basic regular expression containing a back-reference @samp{\@var{n}}
1626
preceded by fewer than @var{n} closing parentheses.  For example,
1627
@samp{\(a\)\2} is invalid.
1628
1534
@item
1629
@item
1535
Basic regular expressions that use @samp{\?}, @samp{\+}, or @samp{\|}.
1630
A bracket expression containing @samp{[:} that does not start a
1631
character class; and similarly for @samp{[=} and @samp{[.}.  For
1632
example, @samp{[a[:b]} and @samp{[a[:ouch:]b]} are invalid.
1633
@end itemize
1634
1635
GNU @command{grep} treats the following constructs as invalid.
1636
However, other @command{grep} implementations might allow them, so
1637
portable scripts should not rely on their being invalid:
1638
1639
@itemize @bullet
1536
@item
1640
@item
1537
Empty parenthesized regular expressions like @samp{()}.
1641
Unescaped @samp{\} at the end of a regular expression.
1642
1538
@item
1643
@item
1539
Empty alternatives (as in, e.g, @samp{a|}).
1644
Unescaped @samp{[} that does not start a bracket expression.
1645
1540
@item
1646
@item
1541
Repetition operators that immediately follow empty expressions,
1647
A @samp{\@{} in a basic regular expression that does not start an
1542
unescaped @samp{$}, or other repetition operators.
1648
interval expression.
1649
1543
@item
1650
@item
1544
Interval expressions containing repetition counts greater than 255.
1651
A basic regular expression with unbalanced @samp{\(} or @samp{\)},
1652
or an extended regular expression with unbalanced @samp{(}.
1653
1545
@item
1654
@item
1546
A backslash escaping an ordinary character (e.g., @samp{\S}),
1655
In the POSIX locale, a range expression like @samp{z-a} that
1547
unless it is a back-reference.
1656
represents zero elements.  A non-GNU @command{grep} might treat it as
1657
a valid range that never matches.
1658
1548
@item
1659
@item
1549
An unescaped @samp{[} that is not part of a bracket expression.
1660
An interval expression with a repetition count greater than 32767.
1661
(The portable POSIX limit is 255, and even interval expressions with
1662
smaller counts can be impractically slow on all known implementations.)
1663
1550
@item
1664
@item
1551
In extended regular expressions, an unescaped @samp{@{} that is not
1665
A bracket expression that contains at least three elements, the first
1552
part of an interval expression.
1666
and last of which are both @samp{:}, or both @samp{.}, or both
1667
@samp{=}.  For example, a non-GNU @command{grep} might treat
1668
@samp{[:alpha:]} like @samp{[[:alpha:]]}, or like @samp{[:ahlp]}.
1553
@end itemize
1669
@end itemize
1554
1670
1555
@cindex interval expressions
1671
The following constructs have well-defined behavior in GNU
1556
GNU @samp{grep@ -E} treats @samp{@{} as special
1672
@command{grep}.  However, they have unspecified behavior elsewhere, so
1557
only if it begins a valid interval expression.
1673
portable scripts should avoid them:
1558
For example, the command
1674
1559
@samp{grep@ -E@ '@{1'} searches for the two-character string @samp{@{1}
1675
@itemize @bullet
1560
instead of reporting a syntax error in the regular expression.
1676
@item
1561
POSIX allows this behavior as an extension, but portable scripts
1677
Special backslash expressions like @samp{\b}, @samp{\<}, and @samp{\]}.
1562
should avoid it.
1678
@xref{Special Backslash Expressions}.
1679
1680
@item
1681
A basic regular expression that uses @samp{\?}, @samp{\+}, or @samp{\|}.
1682
1683
@item
1684
An extended regular expression that uses back-references.
1685
1686
@item
1687
An empty regular expression, subexpression, or alternative.  For
1688
example, @samp{(a|bc|)} is not portable; a portable equivalent is
1689
@samp{(a|bc)?}.
1690
1691
@item
1692
In a basic regular expression, an anchoring @samp{^} that appears
1693
directly after @samp{\(}, or an anchoring @samp{$} that appears
1694
directly before @samp{\)}.
1695
1696
@item
1697
In a basic regular expression, a repetition operator that
1698
directly follows another repetition operator.
1699
1700
@item
1701
In an extended regular expression, unescaped @samp{@{}
1702
that does not begin a valid interval expression.
1703
GNU @command{grep} treats the @samp{@{} as an ordinary character.
1704
1705
@item
1706
A null character or an encoding error in either pattern or input data.
1707
@xref{Character Encoding}.
1708
1709
@item
1710
An input file that ends in a non-newline character,
1711
where GNU @command{grep} silently supplies a newline.
1712
@end itemize
1713
1714
The following constructs have unspecified behavior, in both GNU
1715
and other @command{grep} implementations.  Scripts should avoid
1716
them whenever possible.
1717
1718
@itemize
1719
@item
1720
A backslash escaping an ordinary character, unless it is a
1721
back-reference like @samp{\1} or a special backslash expression like
1722
@samp{\<} or @samp{\b}.  @xref{Special Backslash Expressions}.  For
1723
example, @samp{\x} has unspecified behavior now, and a future version
1724
of @command{grep} might specify @samp{\x} to have a new behavior.
1725
1726
@item
1727
A repetition operator that appears directly after an anchor, or at the
1728
start of a complete regular expression, parenthesized subexpression,
1729
or alternative.  For example, @samp{+|^*(+a|?-b)} has unspecified
1730
behavior, whereas @samp{\+|^\*(\+a|\?-b)} is portable.
1731
1732
@item
1733
A range expression outside the POSIX locale.  For example, in some
1734
locales @samp{[a-z]} might match some characters that are not
1735
lowercase letters, or might not match some lowercase letters, or might
1736
be invalid.  With GNU @command{grep} it is not documented whether
1737
these range expressions use native code points, or use the collating
1738
sequence specified by the @env{LC_COLLATE} category, or have some
1739
other interpretation.  Outside the POSIX locale, it is portable to use
1740
@samp{[[:lower:]]} to match a lower-case letter, or
1741
@samp{[abcdefghijklmnopqrstuvwxyz]} to match an ASCII lower-case
1742
letter.
1743
1744
@end itemize
1563
1745
1564
@node Character Encoding
1746
@node Character Encoding
1565
@section Character Encoding
1747
@section Character Encoding
Lines 1865-1871 Link Here
1865
2047
1866
To match empty lines, use the pattern @samp{^$}.  To match blank
2048
To match empty lines, use the pattern @samp{^$}.  To match blank
1867
lines, use the pattern @samp{^[[:blank:]]*$}.  To match no lines at
2049
lines, use the pattern @samp{^[[:blank:]]*$}.  To match no lines at
1868
all, use the command @samp{grep -f /dev/null}.
2050
all, use an extended regular expression like @samp{a^} or @samp{$a}.
2051
To match every line, a portable script should use a pattern like
2052
@samp{^} instead of the empty pattern, as POSIX does not specify the
2053
behavior of the empty pattern.
1869
2054
1870
@item
2055
@item
1871
How can I search in both standard input and in files?
2056
How can I search in both standard input and in files?
Lines 1947-1958 Link Here
1947
that were the counterparts of the modern @samp{grep -E} and @samp{grep -F}.
2132
that were the counterparts of the modern @samp{grep -E} and @samp{grep -F}.
1948
Although breaking up @command{grep} into three programs was perhaps
2133
Although breaking up @command{grep} into three programs was perhaps
1949
useful on the small computers of the 1970s, @command{egrep} and
2134
useful on the small computers of the 1970s, @command{egrep} and
1950
@command{fgrep} were not standardized by POSIX and are no longer needed.
2135
@command{fgrep} were deemed obsolescent by POSIX in 1992,
1951
In the current GNU implementation, @command{egrep} and @command{fgrep}
2136
removed from POSIX in 2001, deprecated by GNU Grep 2.5.3 in 2007,
1952
issue a warning and then act like their modern counterparts;
2137
and changed to issue obsolescence warnings by GNU Grep 3.8 in 2022;
1953
eventually, they are planned to be removed entirely.
2138
eventually, they are planned to be removed entirely.
1954
2139
1955
If you prefer the old names, you can use use your own substitutes,
2140
If you prefer the old names, you can use your own substitutes,
1956
such as a shell script named @command{egrep} with the following
2141
such as a shell script named @command{egrep} with the following
1957
contents:
2142
contents:
1958
2143
(-)grep-3.7-alt1/doc/Makefile.am (-1 / +1 lines)
Lines 1-7 Link Here
1
# Process this file with automake to create Makefile.in
1
# Process this file with automake to create Makefile.in
2
# Makefile.am for grep/doc.
2
# Makefile.am for grep/doc.
3
#
3
#
4
# Copyright 2008-2022 Free Software Foundation, Inc.
4
# Copyright 2008-2023 Free Software Foundation, Inc.
5
#
5
#
6
# This program is free software; you can redistribute it and/or modify
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/lib/colorize.h (-1 / +1 lines)
Lines 1-6 Link Here
1
/* Output colorization.
1
/* Output colorization.
2
2
3
   Copyright 2011-2022 Free Software Foundation, Inc.
3
   Copyright 2011-2023 Free Software Foundation, Inc.
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
6
   the Free Software Foundation; either version 3, or (at your option)
6
   the Free Software Foundation; either version 3, or (at your option)
(-)grep-3.7-alt1/lib/colorize-posix.c (-1 / +1 lines)
Lines 1-5 Link Here
1
/* Output colorization.
1
/* Output colorization.
2
   Copyright 2011-2022 Free Software Foundation, Inc.
2
   Copyright 2011-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/lib/colorize-w32.c (-1 / +1 lines)
Lines 1-5 Link Here
1
/* Output colorization on MS-Windows.
1
/* Output colorization on MS-Windows.
2
   Copyright 2011-2022 Free Software Foundation, Inc.
2
   Copyright 2011-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/lib/Makefile.am (-1 / +1 lines)
Lines 1-4 Link Here
1
# Copyright 1997-1998, 2005-2022 Free Software Foundation, Inc.
1
# Copyright 1997-1998, 2005-2023 Free Software Foundation, Inc.
2
#
2
#
3
# This program is free software; you can redistribute it and/or modify
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
4
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/m4/pcre.m4 (-2 / +5 lines)
Lines 1-6 Link Here
1
# pcre.m4 - check for PCRE library support
1
# pcre.m4 - check for PCRE library support
2
2
3
# Copyright (C) 2010-2022 Free Software Foundation, Inc.
3
# Copyright (C) 2010-2023 Free Software Foundation, Inc.
4
# This file is free software; the Free Software Foundation
4
# This file is free software; the Free Software Foundation
5
# gives unlimited permission to copy and/or distribute it,
5
# gives unlimited permission to copy and/or distribute it,
6
# with or without modifications, as long as this notice is preserved.
6
# with or without modifications, as long as this notice is preserved.
Lines 21-27 Link Here
21
  use_pcre=no
21
  use_pcre=no
22
22
23
  if test $test_pcre != no; then
23
  if test $test_pcre != no; then
24
    PKG_CHECK_MODULES([PCRE], [libpcre2-8], [], [: ${PCRE_LIBS=-lpcre2-8}])
24
25
    if test -z "${PCRE_CFLAGS+set}" && test -z "${PCRE_LIBS+set}"; then
26
      PKG_CHECK_MODULES([PCRE], [libpcre2-8], [], [: ${PCRE_LIBS=-lpcre2-8}])
27
    fi
25
28
26
    AC_CACHE_CHECK([for pcre2_compile], [pcre_cv_have_pcre2_compile],
29
    AC_CACHE_CHECK([for pcre2_compile], [pcre_cv_have_pcre2_compile],
27
      [pcre_saved_CFLAGS=$CFLAGS
30
      [pcre_saved_CFLAGS=$CFLAGS
(-)grep-3.7-alt1/Makefile.am (-1 / +1 lines)
Lines 1-6 Link Here
1
# Process this file with automake to create Makefile.in
1
# Process this file with automake to create Makefile.in
2
#
2
#
3
# Copyright 1997-1998, 2005-2022 Free Software Foundation, Inc.
3
# Copyright 1997-1998, 2005-2023 Free Software Foundation, Inc.
4
#
4
#
5
# This program is free software; you can redistribute it and/or modify
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
6
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/NEWS (-2 / +94 lines)
Lines 1-6 Link Here
1
GNU grep NEWS                                    -*- outline -*-
1
GNU grep NEWS                                    -*- outline -*-
2
2
3
* Noteworthy changes in release ?.? (????-??-??) [?]
3
* Noteworthy changes in release 3.11 (2023-05-13) [stable]
4
5
** Bug fixes
6
7
  With -P, patterns like [\d] now work again.  Fixing this has caused
8
  grep to revert to the behavior of grep 3.8, in that patterns like \w
9
  and \b go back to using ASCII rather than Unicode interpretations.
10
  However, future versions of GNU grep and/or PCRE2 are likely to fix
11
  this and change the behavior of \w and \b back to Unicode again,
12
  without breaking [\d] as 3.10 did.
13
  [bug introduced in grep 3.10]
14
15
  grep no longer fails on files dated after the year 2038,
16
  when running on 32-bit x86 and ARM hosts using glibc 2.34+.
17
  [bug introduced in grep 3.9]
18
19
  grep -P no longer fails to match patterns using negated classes
20
  like \D or \W when linked with PCRE2 10.34 or newer.
21
  [bug introduced in grep 3.8]
22
23
24
** Changes in behavior
25
26
  grep --version now prints a line describing the version of PCRE2 it uses.
27
  For example, it prints this when built with the very latest from git:
28
    grep -P uses PCRE2 10.43-DEV 2023-04-14
29
  or this with what's currently available in Fedora 37:
30
    grep -P uses PCRE2 10.40 2022-04-14
31
32
  previous versions of grep wouldn't respect the user provided settings for
33
  PCRE_CFLAGS and PCRE_LIBS when building if a libpcre2-8 pkg-config module
34
  was found.
35
36
37
* Noteworthy changes in release 3.10 (2023-03-22) [stable]
38
39
** Bug fixes
40
41
  With -P, \d now matches only ASCII digits, regardless of PCRE
42
  options/modes. The changes in grep-3.9 to make \b and \w work
43
  properly had the undesirable side effect of making \d also match
44
  e.g., the Arabic digits: ٠١٢٣٤٥٦٧٨٩.  With grep-3.9, -P '\d+'
45
  would match that ten-digit (20-byte) string. Now, to match such
46
  a digit, you would use \p{Nd}. Similarly, \D is now mapped to [^0-9].
47
  [bug introduced in grep 3.9]
48
49
50
* Noteworthy changes in release 3.9 (2023-03-05) [stable]
51
52
** Bug fixes
53
54
  With -P, some non-ASCII UTF8 characters were not recognized as
55
  word-constituent due to our omission of the PCRE2_UCP flag. E.g.,
56
  given f(){ echo Perú|LC_ALL=en_US.UTF-8 grep -Po "$1"; } and
57
  this command, echo $(f 'r\w'):$(f '.\b'), before it would print ":r".
58
  After the fix, it prints the correct results: "rú:ú".
59
60
  When given multiple patterns the last of which has a back-reference,
61
  grep no longer sometimes mistakenly matches lines in some cases.
62
  [Bug#36148#13 introduced in grep 3.4]
63
64
65
* Noteworthy changes in release 3.8 (2022-09-02) [stable]
4
66
5
** Changes in behavior
67
** Changes in behavior
6
68
Lines 11-21 Link Here
11
  release 2.5.3 (2007), now warn that they are obsolescent and should
73
  release 2.5.3 (2007), now warn that they are obsolescent and should
12
  be replaced by grep -E and grep -F.
74
  be replaced by grep -E and grep -F.
13
75
76
  The confusing GREP_COLOR environment variable is now obsolescent.
77
  Instead of GREP_COLOR='xxx', use GREP_COLORS='mt=xxx'.  grep now
78
  warns if GREP_COLOR is used and is not overridden by GREP_COLORS.
79
  Also, grep now treats GREP_COLOR like GREP_COLORS by silently
80
  ignoring it if it attempts to inject ANSI terminal escapes.
81
82
  Regular expressions with stray backslashes now cause warnings, as
83
  their unspecified behavior can lead to unexpected results.
84
  For example, '\a' and 'a' are not always equivalent
85
  <https://bugs.gnu.org/39678>.  Similarly, regular expressions or
86
  subexpressions that start with a repetition operator now also cause
87
  warnings due to their unspecified behavior; for example, *a(+b|{1}c)
88
  now has three reasons to warn.  The warnings are intended as a
89
  transition aid; they are likely to be errors in future releases.
90
91
  Regular expressions like [:space:] are now errors even if
92
  POSIXLY_CORRECT is set, since POSIX now allows the GNU behavior.
93
14
** Bug fixes
94
** Bug fixes
15
95
96
  In locales using UTF-8 encoding, the regular expression '.' no
97
  longer sometimes fails to match Unicode characters U+D400 through
98
  U+D7FF (some Hangul Syllables, and Hangul Jamo Extended-B) and
99
  Unicode characters U+108000 through U+10FFFF (half of Supplemental
100
  Private Use Area plane B).
101
  [bug introduced in grep 3.4]
102
16
  The -s option no longer suppresses "binary file matches" messages.
103
  The -s option no longer suppresses "binary file matches" messages.
17
  [Bug#51860 introduced in grep 3.5]
104
  [Bug#51860 introduced in grep 3.5]
18
105
106
** Documentation improvements
107
108
  The manual now covers unspecified behavior in patterns like \x, (+),
109
  and range expressions outside the POSIX locale.
110
19
111
20
* Noteworthy changes in release 3.7 (2021-08-14) [stable]
112
* Noteworthy changes in release 3.7 (2021-08-14) [stable]
21
113
Lines 1293-1299 Link Here
1293
I was changing it anyway I decided to do a general cleanup.
1385
I was changing it anyway I decided to do a general cleanup.
1294
1386
1295
========================================================================
1387
========================================================================
1296
Copyright (C) 1992, 1997-2002, 2004-2022 Free Software Foundation, Inc.
1388
Copyright (C) 1992, 1997-2002, 2004-2023 Free Software Foundation, Inc.
1297
1389
1298
  Copying and distribution of this file, with or without modification,
1390
  Copying and distribution of this file, with or without modification,
1299
  are permitted in any medium without royalty provided the copyright
1391
  are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/po/POTFILES.in (-1 / +2 lines)
Lines 1-6 Link Here
1
# List of files which containing translatable strings.
1
# List of files which containing translatable strings.
2
#
2
#
3
# Copyright 1997-1998, 2005-2022 Free Software Foundation, Inc.
3
# Copyright 1997-1998, 2005-2023 Free Software Foundation, Inc.
4
#
4
#
5
# This program is free software; you can redistribute it and/or modify
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
6
# it under the terms of the GNU General Public License as published by
Lines 29-33 Link Here
29
lib/regcomp.c
29
lib/regcomp.c
30
lib/version-etc.c
30
lib/version-etc.c
31
lib/xalloc-die.c
31
lib/xalloc-die.c
32
src/dfasearch.c
32
src/grep.c
33
src/grep.c
33
src/pcresearch.c
34
src/pcresearch.c
(-)grep-3.7-alt1/README (-1 / +1 lines)
Lines 1-4 Link Here
1
  Copyright (C) 1992, 1997-2002, 2004-2022 Free Software Foundation, Inc.
1
  Copyright (C) 1992, 1997-2002, 2004-2023 Free Software Foundation, Inc.
2
2
3
  Copying and distribution of this file, with or without modification,
3
  Copying and distribution of this file, with or without modification,
4
  are permitted in any medium without royalty provided the copyright
4
  are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/README-alpha (-1 / +1 lines)
Lines 1-4 Link Here
1
  Copyright (C) 1992, 1997-2002, 2004-2022 Free Software Foundation, Inc.
1
  Copyright (C) 1992, 1997-2002, 2004-2023 Free Software Foundation, Inc.
2
2
3
  Copying and distribution of this file, with or without modification,
3
  Copying and distribution of this file, with or without modification,
4
  are permitted in any medium without royalty provided the copyright
4
  are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/src/dfasearch.c (-31 / +35 lines)
Lines 1-5 Link Here
1
/* dfasearch.c - searching subroutines using dfa and regex for grep.
1
/* dfasearch.c - searching subroutines using dfa and regex for grep.
2
   Copyright 1992, 1998, 2000, 2007, 2009-2022 Free Software Foundation, Inc.
2
   Copyright 1992, 1998, 2000, 2007, 2009-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
Lines 53-66 Link Here
53
  die (EXIT_TROUBLE, 0, "%s", mesg);
53
  die (EXIT_TROUBLE, 0, "%s", mesg);
54
}
54
}
55
55
56
/* For now, the sole dfawarn-eliciting condition (use of a regexp
57
   like '[:lower:]') is unequivocally an error, so treat it as such,
58
   when possible.  */
59
void
56
void
60
dfawarn (char const *mesg)
57
dfawarn (char const *mesg)
61
{
58
{
62
  if (!getenv ("POSIXLY_CORRECT"))
59
  error (0, 0, _("warning: %s"), mesg);
63
    dfaerror (mesg);
64
}
60
}
65
61
66
/* If the DFA turns out to have some set of fixed strings one of
62
/* If the DFA turns out to have some set of fixed strings one of
Lines 148-173 Link Here
148
               idx_t pcount, idx_t lineno, reg_syntax_t syntax_bits,
144
               idx_t pcount, idx_t lineno, reg_syntax_t syntax_bits,
149
               bool syntax_only)
145
               bool syntax_only)
150
{
146
{
151
  struct re_pattern_buffer pat0;
147
  struct re_pattern_buffer pat;
152
  struct re_pattern_buffer *pat = syntax_only ? &pat0 : &dc->patterns[pcount];
148
  pat.buffer = NULL;
153
  pat->buffer = NULL;
149
  pat.allocated = 0;
154
  pat->allocated = 0;
155
150
156
  /* Do not use a fastmap with -i, to work around glibc Bug#20381.  */
151
  /* Do not use a fastmap with -i, to work around glibc Bug#20381.  */
157
  verify (UCHAR_MAX < IDX_MAX);
152
  static_assert (UCHAR_MAX < IDX_MAX);
158
  idx_t uchar_max = UCHAR_MAX;
153
  idx_t uchar_max = UCHAR_MAX;
159
  pat->fastmap = (syntax_only | match_icase) ? NULL : ximalloc (uchar_max + 1);
154
  pat.fastmap = (syntax_only | match_icase) ? NULL : ximalloc (uchar_max + 1);
160
155
161
  pat->translate = NULL;
156
  pat.translate = NULL;
162
157
163
  if (syntax_only)
158
  if (syntax_only)
164
    re_set_syntax (syntax_bits | RE_NO_SUB);
159
    re_set_syntax (syntax_bits | RE_NO_SUB);
165
  else
160
  else
166
    re_set_syntax (syntax_bits);
161
    re_set_syntax (syntax_bits);
167
162
168
  char const *err = re_compile_pattern (p, len, pat);
163
  char const *err = re_compile_pattern (p, len, &pat);
169
  if (!err)
164
  if (!err)
170
    return true;
165
    {
166
      if (syntax_only)
167
        regfree (&pat);
168
      else
169
        dc->patterns[pcount] = pat;
170
171
      return true;
172
    }
173
174
  free (pat.fastmap);
171
175
172
  /* Emit a filename:lineno: prefix for patterns taken from files.  */
176
  /* Emit a filename:lineno: prefix for patterns taken from files.  */
173
  idx_t pat_lineno;
177
  idx_t pat_lineno;
Lines 200-206 Link Here
200
204
201
  if (match_icase)
205
  if (match_icase)
202
    syntax_bits |= RE_ICASE;
206
    syntax_bits |= RE_ICASE;
203
  int dfaopts = eolbyte ? 0 : DFA_EOL_NUL;
207
  int dfaopts = (DFA_CONFUSING_BRACKETS_ERROR | DFA_STRAY_BACKSLASH_WARN
208
                 | DFA_PLUS_WARN
209
                 | (syntax_bits & RE_CONTEXT_INDEP_OPS ? DFA_STAR_WARN : 0)
210
                 | (eolbyte ? 0 : DFA_EOL_NUL));
204
  dfasyntax (dc->dfa, &localeinfo, syntax_bits, dfaopts);
211
  dfasyntax (dc->dfa, &localeinfo, syntax_bits, dfaopts);
205
  bool bs_safe = !localeinfo.multibyte | localeinfo.using_utf8;
212
  bool bs_safe = !localeinfo.multibyte | localeinfo.using_utf8;
206
213
Lines 254-261 Link Here
254
          dc->patterns++;
261
          dc->patterns++;
255
        }
262
        }
256
263
257
      re_set_syntax (syntax_bits);
258
259
      if (!regex_compile (dc, p, len, dc->pcount, lineno, syntax_bits,
264
      if (!regex_compile (dc, p, len, dc->pcount, lineno, syntax_bits,
260
                          !backref))
265
                          !backref))
261
        compilation_failed = true;
266
        compilation_failed = true;
Lines 274-293 Link Here
274
  if (compilation_failed)
279
  if (compilation_failed)
275
    exit (EXIT_TROUBLE);
280
    exit (EXIT_TROUBLE);
276
281
277
  if (prev <= patlim)
282
  if (patlim < prev)
283
    buflen--;
284
  else if (pattern < prev)
278
    {
285
    {
279
      if (pattern < prev)
286
      idx_t prevlen = patlim - prev;
280
        {
287
      buf = xirealloc (buf, buflen + prevlen);
281
          idx_t prevlen = patlim - prev;
288
      memcpy (buf + buflen, prev, prevlen);
282
          buf = xirealloc (buf, buflen + prevlen);
289
      buflen += prevlen;
283
          memcpy (buf + buflen, prev, prevlen);
290
    }
284
          buflen += prevlen;
291
  else
285
        }
292
    {
286
      else
293
      buf = pattern;
287
        {
294
      buflen = size;
288
          buf = pattern;
289
          buflen = size;
290
        }
291
    }
295
    }
292
296
293
  /* In the match_words and match_lines cases, we use a different pattern
297
  /* In the match_words and match_lines cases, we use a different pattern
(-)grep-3.7-alt1/src/die.h (-2 / +1 lines)
Lines 1-5 Link Here
1
/* Report an error and exit.
1
/* Report an error and exit.
2
   Copyright 2016-2022 Free Software Foundation, Inc.
2
   Copyright 2016-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
Lines 20-26 Link Here
20
#define DIE_H
20
#define DIE_H
21
21
22
#include <error.h>
22
#include <error.h>
23
#include <stdbool.h>
24
#include <verify.h>
23
#include <verify.h>
25
24
26
/* Like 'error (STATUS, ...)', except STATUS must be a nonzero constant.
25
/* Like 'error (STATUS, ...)', except STATUS must be a nonzero constant.
(-)grep-3.7-alt1/src/grep.c (-11 / +32 lines)
Lines 1-5 Link Here
1
/* grep.c - main driver file for grep.
1
/* grep.c - main driver file for grep.
2
   Copyright (C) 1992, 1997-2002, 2004-2022 Free Software Foundation, Inc.
2
   Copyright (C) 1992, 1997-2002, 2004-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
Lines 24-29 Link Here
24
#include <wchar.h>
24
#include <wchar.h>
25
#include <inttypes.h>
25
#include <inttypes.h>
26
#include <stdarg.h>
26
#include <stdarg.h>
27
#include <stdckdint.h>
27
#include <stdint.h>
28
#include <stdint.h>
28
#include <stdio.h>
29
#include <stdio.h>
29
#include "system.h"
30
#include "system.h"
Lines 40-46 Link Here
40
#include "fcntl-safer.h"
41
#include "fcntl-safer.h"
41
#include "fts_.h"
42
#include "fts_.h"
42
#include "getopt.h"
43
#include "getopt.h"
43
#include "getprogname.h"
44
#include "grep.h"
44
#include "grep.h"
45
#include "hash.h"
45
#include "hash.h"
46
#include "intprops.h"
46
#include "intprops.h"
Lines 295-302 Link Here
295
         This only leaves red, magenta, green, and cyan (and their bold
295
         This only leaves red, magenta, green, and cyan (and their bold
296
         counterparts) and possibly bold blue.  */
296
         counterparts) and possibly bold blue.  */
297
/* The color strings used for matched text.
297
/* The color strings used for matched text.
298
   The user can overwrite them using the deprecated
298
   The user can overwrite them using the GREP_COLORS environment variable.  */
299
   environment variable GREP_COLOR or the new GREP_COLORS.  */
300
static const char *selected_match_color = "01;31";	/* bold red */
299
static const char *selected_match_color = "01;31";	/* bold red */
301
static const char *context_match_color  = "01;31";	/* bold red */
300
static const char *context_match_color  = "01;31";	/* bold red */
302
301
Lines 899-905 Link Here
899
add_count (intmax_t a, idx_t b)
898
add_count (intmax_t a, idx_t b)
900
{
899
{
901
  intmax_t sum;
900
  intmax_t sum;
902
  if (!INT_ADD_OK (a, b, &sum))
901
  if (ckd_add (&sum, a, b))
903
    die (EXIT_TROUBLE, 0, _("input is too large to count"));
902
    die (EXIT_TROUBLE, 0, _("input is too large to count"));
904
  return sum;
903
  return sum;
905
}
904
}
Lines 983-989 Link Here
983
              off_t to_be_read = st->st_size - bufoffset;
982
              off_t to_be_read = st->st_size - bufoffset;
984
              ptrdiff_t a;
983
              ptrdiff_t a;
985
              if (0 <= to_be_read
984
              if (0 <= to_be_read
986
                  && INT_ADD_OK (to_be_read, save + min_after_buflim, &a))
985
                  && !ckd_add (&a, to_be_read, save + min_after_buflim))
987
                alloc_max = MAX (a, bufalloc + incr_min);
986
                alloc_max = MAX (a, bufalloc + incr_min);
988
            }
987
            }
989
988
Lines 1436-1442 Link Here
1436
/* Replace all NUL bytes in buffer P (which ends at LIM) with EOL.
1435
/* Replace all NUL bytes in buffer P (which ends at LIM) with EOL.
1437
   This avoids running out of memory when binary input contains a long
1436
   This avoids running out of memory when binary input contains a long
1438
   sequence of zeros, which would otherwise be considered to be part
1437
   sequence of zeros, which would otherwise be considered to be part
1439
   of a long line.  P[LIM] should be EOL.  */
1438
   of a long line.  *LIM should be EOL.  */
1440
static void
1439
static void
1441
zap_nuls (char *p, char *lim, char eol)
1440
zap_nuls (char *p, char *lim, char eol)
1442
{
1441
{
Lines 1584-1590 Link Here
1584
         the buffer, 0 means there is no incomplete last line).  */
1583
         the buffer, 0 means there is no incomplete last line).  */
1585
      oldc = beg[-1];
1584
      oldc = beg[-1];
1586
      beg[-1] = eol;
1585
      beg[-1] = eol;
1587
      /* FIXME: use rawmemrchr if/when it exists, since we have ensured
1586
      /* If rawmemrchr existed it could be used here, since we have ensured
1588
         that this use of memrchr is guaranteed never to return NULL.  */
1587
         that this use of memrchr is guaranteed never to return NULL.  */
1589
      lim = memrchr (beg - 1, eol, buflim - beg + 1);
1588
      lim = memrchr (beg - 1, eol, buflim - beg + 1);
1590
      ++lim;
1589
      ++lim;
Lines 2830-2836 Link Here
2830
      version_etc (stdout, getprogname (), PACKAGE_NAME, VERSION,
2829
      version_etc (stdout, getprogname (), PACKAGE_NAME, VERSION,
2831
                   (char *) NULL);
2830
                   (char *) NULL);
2832
      puts (_("Written by Mike Haertel and others; see\n"
2831
      puts (_("Written by Mike Haertel and others; see\n"
2833
              "<https://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>."));
2832
              "<https://git.savannah.gnu.org/cgit/grep.git/tree/AUTHORS>."));
2833
#if HAVE_LIBPCRE
2834
      Pprint_version ();
2835
#endif
2834
      return EXIT_SUCCESS;
2836
      return EXIT_SUCCESS;
2835
    }
2837
    }
2836
2838
Lines 2849-2856 Link Here
2849
    }
2851
    }
2850
  else if (optind < argc)
2852
  else if (optind < argc)
2851
    {
2853
    {
2854
      /* If a command-line regular expression operand starts with '\-',
2855
         skip the '\'.  This suppresses a stray-backslash warning if a
2856
         script uses the non-POSIX "grep '\-x'" to avoid treating
2857
         '-x' as an option.  */
2858
      char const *pat = argv[optind++];
2859
      bool skip_bs = (matcher != F_MATCHER_INDEX
2860
                      && pat[0] == '\\' && pat[1] == '-');
2861
2852
      /* Make a copy so that it can be reallocated or freed later.  */
2862
      /* Make a copy so that it can be reallocated or freed later.  */
2853
      pattern_array = keys = xstrdup (argv[optind++]);
2863
      pattern_array = keys = xstrdup (pat + skip_bs);
2854
      idx_t patlen = strlen (keys);
2864
      idx_t patlen = strlen (keys);
2855
      keys[patlen] = '\n';
2865
      keys[patlen] = '\n';
2856
      keycc = update_patterns (keys, 0, patlen + 1, "");
2866
      keycc = update_patterns (keys, 0, patlen + 1, "");
Lines 2912-2921 Link Here
2912
      /* Legacy.  */
2922
      /* Legacy.  */
2913
      char *userval = getenv ("GREP_COLOR");
2923
      char *userval = getenv ("GREP_COLOR");
2914
      if (userval != NULL && *userval != '\0')
2924
      if (userval != NULL && *userval != '\0')
2915
        selected_match_color = context_match_color = userval;
2925
        for (char *q = userval; *q == ';' || c_isdigit (*q); q++)
2926
          if (!q[1])
2927
            {
2928
              selected_match_color = context_match_color = userval;
2929
              break;
2930
            }
2916
2931
2917
      /* New GREP_COLORS has priority.  */
2932
      /* New GREP_COLORS has priority.  */
2918
      parse_grep_colors ();
2933
      parse_grep_colors ();
2934
2935
      /* Warn if GREP_COLOR has an effect, since it's deprecated.  */
2936
      if (selected_match_color == userval || context_match_color == userval)
2937
        error (0, 0, _("warning: GREP_COLOR='%s' is deprecated;"
2938
                       " use GREP_COLORS='mt=%s'"),
2939
               userval, userval);
2919
    }
2940
    }
2920
2941
2921
  initialize_unibyte_mask ();
2942
  initialize_unibyte_mask ();
(-)grep-3.7-alt1/src/grep.h (-2 / +1 lines)
Lines 1-5 Link Here
1
/* grep.h - interface to grep driver for searching subroutines.
1
/* grep.h - interface to grep driver for searching subroutines.
2
   Copyright (C) 1992, 1998, 2001, 2007, 2009-2022 Free Software Foundation,
2
   Copyright (C) 1992, 1998, 2001, 2007, 2009-2023 Free Software Foundation,
3
   Inc.
3
   Inc.
4
4
5
   This program is free software; you can redistribute it and/or modify
5
   This program is free software; you can redistribute it and/or modify
Lines 20-26 Link Here
20
#ifndef GREP_GREP_H
20
#ifndef GREP_GREP_H
21
#define GREP_GREP_H 1
21
#define GREP_GREP_H 1
22
22
23
#include <stdbool.h>
24
#include <idx.h>
23
#include <idx.h>
25
24
26
/* The following flags are exported from grep for the matchers
25
/* The following flags are exported from grep for the matchers
(-)grep-3.7-alt1/src/kwsearch.c (-1 / +1 lines)
Lines 1-5 Link Here
1
/* kwsearch.c - searching subroutines using kwset for grep.
1
/* kwsearch.c - searching subroutines using kwset for grep.
2
   Copyright 1992, 1998, 2000, 2007, 2009-2022 Free Software Foundation, Inc.
2
   Copyright 1992, 1998, 2000, 2007, 2009-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/src/kwset.c (-3 / +4 lines)
Lines 1-5 Link Here
1
/* kwset.c - search for any of a set of keywords.
1
/* kwset.c - search for any of a set of keywords.
2
   Copyright (C) 1989, 1998, 2000, 2005, 2007, 2009-2022 Free Software
2
   Copyright (C) 1989, 1998, 2000, 2005, 2007, 2009-2023 Free Software
3
   Foundation, Inc.
3
   Foundation, Inc.
4
4
5
   This program is free software; you can redistribute it and/or modify
5
   This program is free software; you can redistribute it and/or modify
Lines 27-36 Link Here
27
27
28
#include "kwset.h"
28
#include "kwset.h"
29
29
30
#include <stdckdint.h>
30
#include <stdint.h>
31
#include <stdint.h>
31
#include <sys/types.h>
32
#include <sys/types.h>
33
32
#include "system.h"
34
#include "system.h"
33
#include "intprops.h"
34
#include "memchr2.h"
35
#include "memchr2.h"
35
#include "obstack.h"
36
#include "obstack.h"
36
#include "xalloc.h"
37
#include "xalloc.h"
Lines 674-680 Link Here
674
675
675
  /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2).  */
676
  /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2).  */
676
  idx_t len12;
677
  idx_t len12;
677
  if (INT_MULTIPLY_OK (len, 12, &len12) && len12 < size)
678
  if (!ckd_mul (&len12, len, 12) && len12 < size)
678
    /* 11 is not a bug, the initial offset happens only once.  */
679
    /* 11 is not a bug, the initial offset happens only once.  */
679
    for (ep = text + size - 11 * len; tp <= ep; )
680
    for (ep = text + size - 11 * len; tp <= ep; )
680
      {
681
      {
(-)grep-3.7-alt1/src/kwset.h (-2 / +1 lines)
Lines 1-5 Link Here
1
/* kwset.h - header declaring the keyword set library.
1
/* kwset.h - header declaring the keyword set library.
2
   Copyright (C) 1989, 1998, 2005, 2007, 2009-2022 Free Software Foundation,
2
   Copyright (C) 1989, 1998, 2005, 2007, 2009-2023 Free Software Foundation,
3
   Inc.
3
   Inc.
4
4
5
   This program is free software; you can redistribute it and/or modify
5
   This program is free software; you can redistribute it and/or modify
Lines 20-26 Link Here
20
/* Written August 1989 by Mike Haertel.  */
20
/* Written August 1989 by Mike Haertel.  */
21
21
22
#include <stddef.h>
22
#include <stddef.h>
23
#include <stdbool.h>
24
23
25
#include <idx.h>
24
#include <idx.h>
26
25
(-)grep-3.7-alt1/src/Makefile.am (-1 / +1 lines)
Lines 1-5 Link Here
1
## Process this file with automake to create Makefile.in
1
## Process this file with automake to create Makefile.in
2
# Copyright 1997-1998, 2005-2022 Free Software Foundation, Inc.
2
# Copyright 1997-1998, 2005-2023 Free Software Foundation, Inc.
3
#
3
#
4
# This program is free software; you can redistribute it and/or modify
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
5
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/src/pcresearch.c (-20 / +58 lines)
Lines 1-5 Link Here
1
/* pcresearch.c - searching subroutines using PCRE for grep.
1
/* pcresearch.c - searching subroutines using PCRE for grep.
2
   Copyright 2000, 2007, 2009-2022 Free Software Foundation, Inc.
2
   Copyright 2000, 2007, 2009-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
Lines 17-25 Link Here
17
   02110-1301, USA.  */
17
   02110-1301, USA.  */
18
18
19
#include <config.h>
19
#include <config.h>
20
20
#include "search.h"
21
#include "search.h"
21
#include "die.h"
22
#include "die.h"
22
23
24
#include <stdckdint.h>
25
23
#define PCRE2_CODE_UNIT_WIDTH 8
26
#define PCRE2_CODE_UNIT_WIDTH 8
24
#include <pcre2.h>
27
#include <pcre2.h>
25
28
Lines 32-37 Link Here
32
# define PCRE2_ERROR_DEPTHLIMIT PCRE2_ERROR_RECURSIONLIMIT
35
# define PCRE2_ERROR_DEPTHLIMIT PCRE2_ERROR_RECURSIONLIMIT
33
# define pcre2_set_depth_limit pcre2_set_recursion_limit
36
# define pcre2_set_depth_limit pcre2_set_recursion_limit
34
#endif
37
#endif
38
#ifndef PCRE2_EXTRA_ASCII_BSD
39
# define PCRE2_EXTRA_ASCII_BSD 0
40
#endif
41
42
/* Use PCRE2_MATCH_INVALID_UTF if supported and not buggy;
43
   see <https://github.com/PCRE2Project/pcre2/issues/224>.
44
   Assume the bug will be fixed after PCRE2 10.42.  */
45
#if defined PCRE2_MATCH_INVALID_UTF && 10 < PCRE2_MAJOR + (42 < PCRE2_MINOR)
46
enum { MATCH_INVALID_UTF = PCRE2_MATCH_INVALID_UTF };
47
#else
48
enum { MATCH_INVALID_UTF = 0 };
49
#endif
35
50
36
struct pcre_comp
51
struct pcre_comp
37
{
52
{
Lines 68-73 Link Here
68
  free (ptr);
83
  free (ptr);
69
}
84
}
70
85
86
void
87
Pprint_version (void)
88
{
89
  char buf[128];
90
  if (sizeof buf <= pcre2_config (PCRE2_CONFIG_VERSION, buf))
91
    abort ();
92
  printf (_("\ngrep -P uses PCRE2 %s\n"), buf);
93
}
94
71
/* Match the already-compiled PCRE pattern against the data in SUBJECT,
95
/* Match the already-compiled PCRE pattern against the data in SUBJECT,
72
   of size SEARCH_BYTES and starting with offset SEARCH_OFFSET, with
96
   of size SEARCH_BYTES and starting with offset SEARCH_OFFSET, with
73
   options OPTIONS.
97
   options OPTIONS.
Lines 104-110 Link Here
104
        {
128
        {
105
          uint32_t lim;
129
          uint32_t lim;
106
          pcre2_config (PCRE2_CONFIG_DEPTHLIMIT, &lim);
130
          pcre2_config (PCRE2_CONFIG_DEPTHLIMIT, &lim);
107
          if (INT_MULTIPLY_WRAPV (lim, 2, &lim))
131
          if (ckd_mul (&lim, lim, 2))
108
            return e;
132
            return e;
109
          if (!pc->mcontext)
133
          if (!pc->mcontext)
110
            pc->mcontext = pcre2_match_context_create (pc->gcontext);
134
            pc->mcontext = pcre2_match_context_create (pc->gcontext);
Lines 115-130 Link Here
115
    }
139
    }
116
}
140
}
117
141
118
/* Return true if E is an error code for bad UTF-8, and if pcre2_match
142
/* Return true if E is an error code for bad UTF-8.  */
119
   could return E because PCRE lacks PCRE2_MATCH_INVALID_UTF.  */
120
static bool
143
static bool
121
bad_utf8_from_pcre2 (int e)
144
bad_utf8_from_pcre2 (int e)
122
{
145
{
123
#ifdef PCRE2_MATCH_INVALID_UTF
124
  return false;
125
#else
126
  return PCRE2_ERROR_UTF8_ERR21 <= e && e <= PCRE2_ERROR_UTF8_ERR1;
146
  return PCRE2_ERROR_UTF8_ERR21 <= e && e <= PCRE2_ERROR_UTF8_ERR1;
127
#endif
128
}
147
}
129
148
130
/* Compile the -P style PATTERN, containing SIZE bytes that are
149
/* Compile the -P style PATTERN, containing SIZE bytes that are
Lines 144-172 Link Here
144
163
145
  if (localeinfo.multibyte)
164
  if (localeinfo.multibyte)
146
    {
165
    {
166
      uint32_t unicode;
167
      if (pcre2_config (PCRE2_CONFIG_UNICODE, &unicode) < 0 || !unicode)
168
        die (EXIT_TROUBLE, 0,
169
             _("-P supports only unibyte locales on this platform"));
147
      if (! localeinfo.using_utf8)
170
      if (! localeinfo.using_utf8)
148
        die (EXIT_TROUBLE, 0, _("-P supports only unibyte and UTF-8 locales"));
171
        die (EXIT_TROUBLE, 0, _("-P supports only unibyte and UTF-8 locales"));
172
149
      flags |= PCRE2_UTF;
173
      flags |= PCRE2_UTF;
174
175
      /* If supported, consider invalid UTF-8 as a barrier not an error.  */
176
      flags |= MATCH_INVALID_UTF;
177
178
      /* If PCRE2_EXTRA_ASCII_BSD is available, use PCRE2_UCP
179
         so that \d does not have the undesirable effect of matching
180
         non-ASCII digits.  Otherwise (i.e., with PCRE2 10.42 and earlier),
181
         escapes like \w have only their ASCII interpretations,
182
         but that's better than the confusion that would ensue if \d
183
         matched non-ASCII digits.  */
184
      flags |= PCRE2_EXTRA_ASCII_BSD ? PCRE2_UCP : 0;
185
150
#if 0
186
#if 0
151
      /* Do not match individual code units but only UTF-8.  */
187
      /* Do not match individual code units but only UTF-8.  */
152
      flags |= PCRE2_NEVER_BACKSLASH_C;
188
      flags |= PCRE2_NEVER_BACKSLASH_C;
153
#endif
189
#endif
154
#ifdef PCRE2_MATCH_INVALID_UTF
155
      /* Consider invalid UTF-8 as a barrier, instead of error.  */
156
      flags |= PCRE2_MATCH_INVALID_UTF;
157
#endif
158
    }
190
    }
159
191
160
  /* FIXME: Remove this restriction.  */
192
  /* FIXME: Remove this restriction.  */
161
  if (rawmemchr (pattern, '\n') != patlim)
193
  if (rawmemchr (pattern, '\n') != patlim)
162
    die (EXIT_TROUBLE, 0, _("the -P option only supports a single pattern"));
194
    die (EXIT_TROUBLE, 0, _("the -P option only supports a single pattern"));
163
195
196
#ifdef PCRE2_EXTRA_MATCH_LINE
197
  uint32_t extra_options = (PCRE2_EXTRA_ASCII_BSD
198
                            | (match_lines ? PCRE2_EXTRA_MATCH_LINE : 0));
199
  pcre2_set_compile_extra_options (ccontext, extra_options);
200
#endif
201
164
  void *re_storage = NULL;
202
  void *re_storage = NULL;
165
  if (match_lines)
203
  if (match_lines)
166
    {
204
    {
167
#ifdef PCRE2_EXTRA_MATCH_LINE
205
#ifndef PCRE2_EXTRA_MATCH_LINE
168
      pcre2_set_compile_extra_options (ccontext, PCRE2_EXTRA_MATCH_LINE);
169
#else
170
      static char const /* These sizes omit trailing NUL.  */
206
      static char const /* These sizes omit trailing NUL.  */
171
        xprefix[4] = "^(?:", xsuffix[2] = ")$";
207
        xprefix[4] = "^(?:", xsuffix[2] = ")$";
172
      idx_t re_size = size + sizeof xprefix + sizeof xsuffix;
208
      idx_t re_size = size + sizeof xprefix + sizeof xsuffix;
Lines 193-199 Link Here
193
      size = re_size;
229
      size = re_size;
194
    }
230
    }
195
231
196
  pcre2_set_character_tables (ccontext, pcre2_maketables (gcontext));
232
  if (!localeinfo.multibyte)
233
    pcre2_set_character_tables (ccontext, pcre2_maketables (gcontext));
234
197
  pc->cre = pcre2_compile ((PCRE2_SPTR) pattern, size, flags,
235
  pc->cre = pcre2_compile ((PCRE2_SPTR) pattern, size, flags,
198
                           &ec, &e, ccontext);
236
                           &ec, &e, ccontext);
199
  if (!pc->cre)
237
  if (!pc->cre)
Lines 210-218 Link Here
210
  pc->mcontext = NULL;
248
  pc->mcontext = NULL;
211
  pc->data = pcre2_match_data_create_from_pattern (pc->cre, gcontext);
249
  pc->data = pcre2_match_data_create_from_pattern (pc->cre, gcontext);
212
250
213
  ec = pcre2_jit_compile (pc->cre, PCRE2_JIT_COMPLETE);
251
  /* Ignore any failure return from pcre2_jit_compile, as that merely
214
  if (ec && ec != PCRE2_ERROR_JIT_BADOPTION && ec != PCRE2_ERROR_NOMEMORY)
252
     means JIT won't be used during matching.  */
215
    die (EXIT_TROUBLE, 0, _("JIT internal error: %d"), ec);
253
  pcre2_jit_compile (pc->cre, PCRE2_JIT_COMPLETE);
216
254
217
  /* The PCRE documentation says that a 32 KiB stack is the default.  */
255
  /* The PCRE documentation says that a 32 KiB stack is the default.  */
218
  pc->jit_stack = NULL;
256
  pc->jit_stack = NULL;
Lines 280-286 Link Here
280
318
281
          e = jit_exec (pc, subject, line_end - subject,
319
          e = jit_exec (pc, subject, line_end - subject,
282
                        search_offset, options);
320
                        search_offset, options);
283
          if (!bad_utf8_from_pcre2 (e))
321
          if (MATCH_INVALID_UTF || !bad_utf8_from_pcre2 (e))
284
            break;
322
            break;
285
323
286
          idx_t valid_bytes = pcre2_get_startchar (pc->data);
324
          idx_t valid_bytes = pcre2_get_startchar (pc->data);
(-)grep-3.7-alt1/src/search.h (-1 / +2 lines)
Lines 1-5 Link Here
1
/* search.c - searching subroutines using dfa, kwset and regex for grep.
1
/* search.c - searching subroutines using dfa, kwset and regex for grep.
2
   Copyright 1992, 1998, 2000, 2007, 2009-2022 Free Software Foundation, Inc.
2
   Copyright 1992, 1998, 2000, 2007, 2009-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
Lines 65-70 Link Here
65
/* pcresearch.c */
65
/* pcresearch.c */
66
extern void *Pcompile (char *, idx_t, reg_syntax_t, bool);
66
extern void *Pcompile (char *, idx_t, reg_syntax_t, bool);
67
extern ptrdiff_t Pexecute (void *, char const *, idx_t, idx_t *, char const *);
67
extern ptrdiff_t Pexecute (void *, char const *, idx_t, idx_t *, char const *);
68
extern void Pprint_version (void);
68
69
69
/* grep.c */
70
/* grep.c */
70
extern struct localeinfo localeinfo;
71
extern struct localeinfo localeinfo;
(-)grep-3.7-alt1/src/searchutils.c (-1 / +1 lines)
Lines 1-5 Link Here
1
/* searchutils.c - helper subroutines for grep's matchers.
1
/* searchutils.c - helper subroutines for grep's matchers.
2
   Copyright 1992, 1998, 2000, 2007, 2009-2022 Free Software Foundation, Inc.
2
   Copyright 1992, 1998, 2000, 2007, 2009-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/src/system.h (-1 / +1 lines)
Lines 1-5 Link Here
1
/* Portability cruft.  Include after config.h and sys/types.h.
1
/* Portability cruft.  Include after config.h and sys/types.h.
2
   Copyright 1996, 1998-2000, 2007, 2009-2022 Free Software Foundation, Inc.
2
   Copyright 1996, 1998-2000, 2007, 2009-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/backref (-1 / +9 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test for back-references and other things.
2
# Test for back-references and other things.
3
#
3
#
4
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
Lines 43-46 Link Here
43
        failures=1
43
        failures=1
44
fi
44
fi
45
45
46
# https://bugs.gnu.org/36148#13
47
echo 'Total failed: 2 (1 ignored)' |
48
    grep -e '^Total failed: 0$' -e '^Total failed: \([0-9]*\) (\1 ignored)$'
49
if test $? -ne 1 ; then
50
        echo "Backref: Multiple -e test, test #5 failed"
51
        failures=1
52
fi
53
46
Exit $failures
54
Exit $failures
(-)grep-3.7-alt1/tests/backref-alt (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test for a bug in glibc's regex code as of 2015-09-19.
2
# Test for a bug in glibc's regex code as of 2015-09-19.
3
#
3
#
4
# Copyright 2015-2022 Free Software Foundation, Inc.
4
# Copyright 2015-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/backslash-dot (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# This once failed to match: echo . | grep '\.'
2
# This once failed to match: echo . | grep '\.'
3
#
3
#
4
# Copyright (C) 2020-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2020-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/backslash-s-and-repetition-operators (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Ensure that \s and \S work with repetition operators.
2
# Ensure that \s and \S work with repetition operators.
3
#
3
#
4
# Copyright (C) 2013-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2013-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/backslash-s-vs-invalid-multibyte (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Ensure that neither \s nor \S matches an invalid multibyte character.
2
# Ensure that neither \s nor \S matches an invalid multibyte character.
3
#
3
#
4
# Copyright (C) 2013-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2013-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/big-hole (+1 lines)
Lines 4-9 Link Here
4
. "${srcdir=.}/init.sh"; path_prepend_ ../src
4
. "${srcdir=.}/init.sh"; path_prepend_ ../src
5
5
6
expensive_
6
expensive_
7
require_perl_
7
8
8
# Skip this test if there is no usable SEEK_HOLE support,
9
# Skip this test if there is no usable SEEK_HOLE support,
9
# as is the case with linux-3.5.0 on ext4 and tmpfs file systems.
10
# as is the case with linux-3.5.0 on ext4 and tmpfs file systems.
(-)grep-3.7-alt1/tests/binary-file-matches (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test for the "binary file ... matches" diagnostic.
2
# Test for the "binary file ... matches" diagnostic.
3
#
3
#
4
# Copyright (C) 2020-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2020-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/bre (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Regression test for GNU grep.
2
# Regression test for GNU grep.
3
#
3
#
4
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/bre.awk (-1 / +1 lines)
Lines 1-4 Link Here
1
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
1
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
2
#
2
#
3
# Copying and distribution of this file, with or without modification,
3
# Copying and distribution of this file, with or without modification,
4
# are permitted in any medium without royalty provided the copyright
4
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/case-fold-titlecase (-2 / +2 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Check that case folding works even with titlecase and similarly odd chars.
2
# Check that case folding works even with titlecase and similarly odd chars.
3
3
4
# Copyright 2014-2022 Free Software Foundation, Inc.
4
# Copyright 2014-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
Lines 168-174 Link Here
168
done
168
done
169
169
170
# Try a unibyte test with ISO 8859-7, if available.
170
# Try a unibyte test with ISO 8859-7, if available.
171
if test "$(get-mb-cur-max el_GR.iso88597)" -eq 1; then
171
if test "$(get-mb-cur-max el_GR.iso88597)" = 1; then
172
  LC_ALL=el_GR.iso88597
172
  LC_ALL=el_GR.iso88597
173
  export LC_ALL
173
  export LC_ALL
174
174
(-)grep-3.7-alt1/tests/c-locale (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Regression test for GNU grep.
2
# Regression test for GNU grep.
3
#
3
#
4
# Copyright 2016-2022 Free Software Foundation, Inc.
4
# Copyright 2016-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/Coreutils.pm (-1 / +1 lines)
Lines 1-7 Link Here
1
package Coreutils;
1
package Coreutils;
2
# This is a testing framework.
2
# This is a testing framework.
3
3
4
# Copyright (C) 1998-2015, 2017-2022 Free Software Foundation, Inc.
4
# Copyright (C) 1998-2015, 2017-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/count-newline (-1 / +1 lines)
Lines 2-8 Link Here
2
# Test that newline is counted correctly even when the transition
2
# Test that newline is counted correctly even when the transition
3
# table is rebuilt.
3
# table is rebuilt.
4
4
5
# Copyright 2014-2022 Free Software Foundation, Inc.
5
# Copyright 2014-2023 Free Software Foundation, Inc.
6
6
7
# This program is free software: you can redistribute it and/or modify
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
8
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/CuSkip.pm (-1 / +1 lines)
Lines 1-7 Link Here
1
package CuSkip;
1
package CuSkip;
2
# Skip a test: emit diag to log and to stderr, and exit 77
2
# Skip a test: emit diag to log and to stderr, and exit 77
3
3
4
# Copyright (C) 2011-2015, 2017-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2011-2015, 2017-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/CuTmpdir.pm (-1 / +1 lines)
Lines 1-7 Link Here
1
package CuTmpdir;
1
package CuTmpdir;
2
# create, then chdir into a temporary sub-directory
2
# create, then chdir into a temporary sub-directory
3
3
4
# Copyright (C) 2007-2015, 2017-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2007-2015, 2017-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/dfa-coverage (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Exercise the final reachable code in dfa.c's match_mb_charset.
2
# Exercise the final reachable code in dfa.c's match_mb_charset.
3
3
4
# Copyright (C) 2012-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2012-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/dfa-heap-overrun (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Trigger a heap overrun in grep-2.6..grep-2.8.
2
# Trigger a heap overrun in grep-2.6..grep-2.8.
3
3
4
# Copyright (C) 2011-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2011-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/dfa-invalid-utf8 (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test whether "grep '.'" matches invalid UTF-8 byte sequences.
2
# Test whether "grep '.'" matches invalid UTF-8 byte sequences.
3
#
3
#
4
# Copyright 2019-2022 Free Software Foundation, Inc.
4
# Copyright 2019-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/empty (-1 / +1 lines)
Lines 2-8 Link Here
2
# test that the empty file means no pattern
2
# test that the empty file means no pattern
3
# and an empty pattern means match all.
3
# and an empty pattern means match all.
4
#
4
#
5
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
5
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
6
#
6
#
7
# Copying and distribution of this file, with or without modification,
7
# Copying and distribution of this file, with or without modification,
8
# are permitted in any medium without royalty provided the copyright
8
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/empty-line-mb (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Exercise bugs in grep-2.13 with -i, -n and an RE of ^$ in a multi-byte locale.
2
# Exercise bugs in grep-2.13 with -i, -n and an RE of ^$ in a multi-byte locale.
3
#
3
#
4
# Copyright (C) 2012-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2012-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/encoding-error (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test grep's behavior on encoding errors.
2
# Test grep's behavior on encoding errors.
3
#
3
#
4
# Copyright 2015-2022 Free Software Foundation, Inc.
4
# Copyright 2015-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/envvar-check (-1 / +1 lines)
Lines 1-7 Link Here
1
# -*- sh -*-
1
# -*- sh -*-
2
# Check environment variables for sane values while testing.
2
# Check environment variables for sane values while testing.
3
3
4
# Copyright (C) 2000-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2000-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/ere (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Regression test for GNU grep.
2
# Regression test for GNU grep.
3
#
3
#
4
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/ere.awk (-1 / +1 lines)
Lines 1-4 Link Here
1
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
1
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
2
#
2
#
3
# Copying and distribution of this file, with or without modification,
3
# Copying and distribution of this file, with or without modification,
4
# are permitted in any medium without royalty provided the copyright
4
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/false-match-mb-non-utf8 (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test for false matches in grep 2.19..2.26 in multibyte, non-UTF8 locales
2
# Test for false matches in grep 2.19..2.26 in multibyte, non-UTF8 locales
3
#
3
#
4
# Copyright (C) 2016-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2016-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/fgrep-longest (-1 / +1 lines)
Lines 2-8 Link Here
2
# With multiple matches, grep -Fo could print a shorter one.
2
# With multiple matches, grep -Fo could print a shorter one.
3
# This bug affected grep versions 2.26 through 2.27.
3
# This bug affected grep versions 2.26 through 2.27.
4
#
4
#
5
# Copyright (C) 2017-2022 Free Software Foundation, Inc.
5
# Copyright (C) 2017-2023 Free Software Foundation, Inc.
6
#
6
#
7
# Copying and distribution of this file, with or without modification,
7
# Copying and distribution of this file, with or without modification,
8
# are permitted in any medium without royalty provided the copyright
8
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/file (-1 / +1 lines)
Lines 4-10 Link Here
4
# grep -F -f pattern_file file
4
# grep -F -f pattern_file file
5
# grep -G -f pattern_file file
5
# grep -G -f pattern_file file
6
#
6
#
7
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
7
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
8
#
8
#
9
# Copying and distribution of this file, with or without modification,
9
# Copying and distribution of this file, with or without modification,
10
# are permitted in any medium without royalty provided the copyright
10
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/filename-lineno.pl (-1 / +1 lines)
Lines 4-10 Link Here
4
# file or line number from which the offending regular expression came.
4
# file or line number from which the offending regular expression came.
5
# With 2.26, now, each such diagnostic has a "FILENAME:LINENO: " prefix.
5
# With 2.26, now, each such diagnostic has a "FILENAME:LINENO: " prefix.
6
6
7
# Copyright (C) 2016-2022 Free Software Foundation, Inc.
7
# Copyright (C) 2016-2023 Free Software Foundation, Inc.
8
8
9
# This program is free software: you can redistribute it and/or modify
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
10
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/fmbtest (-5 / +5 lines)
Lines 1-5 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
2
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
3
#
3
#
4
# Copying and distribution of this file, with or without modification,
4
# Copying and distribution of this file, with or without modification,
5
# are permitted in any medium without royalty provided the copyright
5
# are permitted in any medium without royalty provided the copyright
Lines 53-73 Link Here
53
for mode in F G E; do
53
for mode in F G E; do
54
54
55
test1=$(echo $(LC_ALL=$cz grep -${mode} -f cspatfile csinput |
55
test1=$(echo $(LC_ALL=$cz grep -${mode} -f cspatfile csinput |
56
               tr -cs '0-9' '[ *]'))
56
               tr '\n' ' ' | tr -cd '0-9 '))
57
if test "$test1" != "11 12 13 14 15 16 17 18"; then
57
if test "$test1" != "11 12 13 14 15 16 17 18"; then
58
  echo "Test #1 ${mode} failed: $test1"
58
  echo "Test #1 ${mode} failed: $test1"
59
  failures=1
59
  failures=1
60
fi
60
fi
61
61
62
test2=$(echo $(LC_ALL=$cz grep -${mode}i -f cspatfile csinput |
62
test2=$(echo $(LC_ALL=$cz grep -${mode}i -f cspatfile csinput |
63
               tr -cs '0-9' '[ *]'))
63
               tr '\n' ' ' | tr -cd '0-9 '))
64
if test "$test2" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
64
if test "$test2" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
65
  echo "Test #2 ${mode} failed: $test2"
65
  echo "Test #2 ${mode} failed: $test2"
66
  failures=1
66
  failures=1
67
fi
67
fi
68
68
69
test3=$(echo $(LC_ALL=$cz grep -${mode}i -e 'ČÍšE' -e 'Čas' csinput |
69
test3=$(echo $(LC_ALL=$cz grep -${mode}i -e 'ČÍšE' -e 'Čas' csinput |
70
               tr -cs '0-9' '[ *]'))
70
               tr '\n' ' ' | tr -cd '0-9 '))
71
if test "$test3" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
71
if test "$test3" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
72
  echo "Test #3 ${mode} failed: $test3"
72
  echo "Test #3 ${mode} failed: $test3"
73
  failures=1
73
  failures=1
Lines 115-121 Link Here
115
for mode in G E; do
115
for mode in G E; do
116
116
117
test8=$(echo $(LC_ALL=$cz grep -${mode}i -e 'Č.šE' -e 'Č[a-f]s' csinput |
117
test8=$(echo $(LC_ALL=$cz grep -${mode}i -e 'Č.šE' -e 'Č[a-f]s' csinput |
118
               tr -cs '0-9' '[ *]'))
118
               tr '\n' ' ' | tr -cd '0-9 '))
119
if test "$test8" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
119
if test "$test8" != "01 02 07 08 10 11 12 13 14 15 16 17 18 19 20"; then
120
  echo "Test #8 ${mode} failed: $test8"
120
  echo "Test #8 ${mode} failed: $test8"
121
  failures=1
121
  failures=1
(-)grep-3.7-alt1/tests/foad1 (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test various combinations of command-line options.
2
# Test various combinations of command-line options.
3
#
3
#
4
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/get-mb-cur-max.c (-3 / +1 lines)
Lines 1-5 Link Here
1
/* Auxiliary program to detect support for a locale.
1
/* Auxiliary program to detect support for a locale.
2
   Copyright 2010-2022 Free Software Foundation, Inc.
2
   Copyright 2010-2023 Free Software Foundation, Inc.
3
3
4
   This program is free software; you can redistribute it and/or modify
4
   This program is free software; you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
5
   it under the terms of the GNU General Public License as published by
Lines 21-28 Link Here
21
#include <stdio.h>
21
#include <stdio.h>
22
#include <stdlib.h>
22
#include <stdlib.h>
23
23
24
#include "getprogname.h"
25
26
int
24
int
27
main (int argc, char **argv)
25
main (int argc, char **argv)
28
{
26
{
(-)grep-3.7-alt1/tests/hash-collision-perf (-2 / +3 lines)
Lines 2-8 Link Here
2
# Test for this performance regression:
2
# Test for this performance regression:
3
# grep-3.5 and 3.6 would take O(N^2) time for some sets of input regexps.
3
# grep-3.5 and 3.6 would take O(N^2) time for some sets of input regexps.
4
4
5
# Copyright 2020-2022 Free Software Foundation, Inc.
5
# Copyright 2020-2023 Free Software Foundation, Inc.
6
6
7
# This program is free software: you can redistribute it and/or modify
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
8
# it under the terms of the GNU General Public License as published by
Lines 21-26 Link Here
21
21
22
fail=0
22
fail=0
23
23
24
require_perl_
25
24
: > empty || framework_failure_
26
: > empty || framework_failure_
25
27
26
# Construct a test case that consumes enough CPU time that we don't
28
# Construct a test case that consumes enough CPU time that we don't
Lines 42-48 Link Here
42
# Deliberately recording in an unused variable so it
44
# Deliberately recording in an unused variable so it
43
# shows up in set -x output, in case this test fails.
45
# shows up in set -x output, in case this test fails.
44
ratio=$(expr "$large_ms" / "$small_ms")
46
ratio=$(expr "$large_ms" / "$small_ms")
45
warn_ ratio=$ratio
46
47
47
# The duration of the latter run must be no more than 10 times
48
# The duration of the latter run must be no more than 10 times
48
# that of the former.  Using recent versions prior to this fix,
49
# that of the former.  Using recent versions prior to this fix,
(-)grep-3.7-alt1/tests/help-version (-1 / +1 lines)
Lines 2-8 Link Here
2
# Make sure all of these programs work properly
2
# Make sure all of these programs work properly
3
# when invoked with --help or --version.
3
# when invoked with --help or --version.
4
4
5
# Copyright (C) 2000-2022 Free Software Foundation, Inc.
5
# Copyright (C) 2000-2023 Free Software Foundation, Inc.
6
6
7
# This program is free software: you can redistribute it and/or modify
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
8
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/high-bit-range (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Exercise high-bit-set unibyte-in-[...]-range bug.
2
# Exercise high-bit-set unibyte-in-[...]-range bug.
3
3
4
# Copyright (C) 2011-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2011-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/init.cfg (-4 / +19 lines)
Lines 48-57 Link Here
48
48
49
require_pcre_()
49
require_pcre_()
50
{
50
{
51
  echo . | grep -P . 2>err || {
51
  case $LC_ALL in
52
    test $? -eq 1 && fail_ PCRE available, but does not work.
52
    *.UTF-8)
53
    skip_ no PCRE support
53
      printf '\303\241\n' | grep -P '^.$' 2>err || {
54
  }
54
        test $? -eq 1 && fail_ PCRE available, but does not work
55
        skip_ no PCRE Unicode support
56
      };;
57
    *)
58
      echo . | grep -P '^.$' 2>err || {
59
        test $? -eq 1 && fail_ PCRE available, but does not work.
60
        skip_ no PCRE support
61
      };;
62
  esac
55
  compare /dev/null err || fail_ PCRE available, but stderr not empty.
63
  compare /dev/null err || fail_ PCRE available, but stderr not empty.
56
}
64
}
57
65
Lines 138-143 Link Here
138
  skip_ "$locale locale not found"
146
  skip_ "$locale locale not found"
139
}
147
}
140
148
149
# Skip the current test if we lack Perl.
150
require_perl_()
151
{
152
  test "$PERL" && $PERL -e 'use warnings' > /dev/null 2>&1 \
153
    || skip_ 'configure did not find a usable version of Perl'
154
}
155
141
expensive_()
156
expensive_()
142
{
157
{
143
  if test "$RUN_EXPENSIVE_TESTS" != yes; then
158
  if test "$RUN_EXPENSIVE_TESTS" != yes; then
(-)grep-3.7-alt1/tests/initial-tab (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Exercise -T.
2
# Exercise -T.
3
3
4
# Copyright 2016-2022 Free Software Foundation, Inc.
4
# Copyright 2016-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/init.sh (-23 / +29 lines)
Lines 1-6 Link Here
1
# source this file; set up for tests
1
# source this file; set up for tests
2
2
3
# Copyright (C) 2009-2022 Free Software Foundation, Inc.
3
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
4
4
5
# This program is free software: you can redistribute it and/or modify
5
# This program is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
6
# it under the terms of the GNU General Public License as published by
Lines 271-282 Link Here
271
#
271
#
272
# First, try to use the mktemp program.
272
# First, try to use the mktemp program.
273
# Failing that, we'll roll our own mktemp-like function:
273
# Failing that, we'll roll our own mktemp-like function:
274
#  - try to get random bytes from /dev/urandom
274
#  - try to get random bytes from /dev/urandom, mapping them to file-name bytes
275
#  - failing that, generate output from a combination of quickly-varying
275
#  - failing that, generate output from a combination of quickly-varying
276
#      sources and gzip.  Ignore non-varying gzip header, and extract
276
#      sources and awk.
277
#      "random" bits from there.
277
#  - try to create the desired directory.
278
#  - given those bits, map to file-name bytes using tr, and try to create
279
#      the desired directory.
280
#  - make only $MAX_TRIES_ attempts
278
#  - make only $MAX_TRIES_ attempts
281
279
282
# Helper function.  Print $N pseudo-random bytes from a-zA-Z0-9.
280
# Helper function.  Print $N pseudo-random bytes from a-zA-Z0-9.
Lines 296-315 Link Here
296
    return
294
    return
297
  fi
295
  fi
298
296
299
  n_plus_50_=`expr $n_ + 50`
297
  # Fall back on quickly-varying sources + awk.
300
  cmds_='date; date +%N; free; who -a; w; ps auxww; ps -ef'
298
  # Limit awk program to 7th Edition Unix so that it works even on Solaris 10.
301
  data_=` (eval "$cmds_") 2>&1 | gzip `
302
299
303
  # Ensure that $data_ has length at least 50+$n_
300
  (date; date +%N; free; who -a; w; ps auxww; ps -ef) 2>&1 | awk '
304
  while :; do
301
     BEGIN {
305
    len_=`echo "$data_"|wc -c`
302
       n = '"$n_"'
306
    test $n_plus_50_ -le $len_ && break;
303
       for (i = 0; i < 256; i++)
307
    data_=` (echo "$data_"; eval "$cmds_") 2>&1 | gzip `
304
         ordinal[sprintf ("%c", i)] = i
308
  done
305
     }
309
306
     {
310
  echo "$data_" \
307
       for (i = 1; i <= length; i++)
311
    | dd bs=1 skip=50 count=$n_ 2>/dev/null \
308
         a[ai++ % n] += ordinal[substr ($0, i, 1)]
312
    | LC_ALL=C tr -c $chars_ 01234567$chars_$chars_$chars_
309
     }
310
     END {
311
       chars = "'"$chars_"'"
312
       charslen = length (chars)
313
       for (i = 0; i < n; i++)
314
         printf "%s", substr (chars, a[i] % charslen + 1, 1)
315
       printf "\n"
316
     }
317
  '
313
}
318
}
314
319
315
mktempd_ ()
320
mktempd_ ()
Lines 641-658 Link Here
641
646
642
for diff_opt_ in -u -U3 -c '' no; do
647
for diff_opt_ in -u -U3 -c '' no; do
643
  test "$diff_opt_" != no &&
648
  test "$diff_opt_" != no &&
644
    diff_out_=`exec 2>/dev/null; diff $diff_opt_ "$0" "$0" < /dev/null` &&
649
    diff_out_=`exec 2>/dev/null
650
      LC_ALL=C diff $diff_opt_ "$0" "$0" < /dev/null` &&
645
    break
651
    break
646
done
652
done
647
if test "$diff_opt_" != no; then
653
if test "$diff_opt_" != no; then
648
  if test -z "$diff_out_"; then
654
  if test -z "$diff_out_"; then
649
    compare_ () { diff $diff_opt_ "$@"; }
655
    compare_ () { LC_ALL=C diff $diff_opt_ "$@"; }
650
  else
656
  else
651
    compare_ ()
657
    compare_ ()
652
    {
658
    {
653
      # If no differences were found, AIX and HP-UX 'diff' produce output
659
      # If no differences were found, AIX and HP-UX 'diff' produce output
654
      # like "No differences encountered".  Hide this output.
660
      # like "No differences encountered".  Hide this output.
655
      diff $diff_opt_ "$@" > diff.out
661
      LC_ALL=C diff $diff_opt_ "$@" > diff.out
656
      diff_status_=$?
662
      diff_status_=$?
657
      test $diff_status_ -eq 0 || cat diff.out || diff_status_=2
663
      test $diff_status_ -eq 0 || cat diff.out || diff_status_=2
658
      rm -f diff.out || diff_status_=2
664
      rm -f diff.out || diff_status_=2
Lines 697-700 Link Here
697
setup_ "$@"
703
setup_ "$@"
698
# This trap is here, rather than in the setup_ function, because some
704
# This trap is here, rather than in the setup_ function, because some
699
# shells run the exit trap at shell function exit, rather than script exit.
705
# shells run the exit trap at shell function exit, rather than script exit.
700
trap remove_tmp_ 0
706
trap remove_tmp_ EXIT
(-)grep-3.7-alt1/tests/khadafy (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Regression test for GNU grep.
2
# Regression test for GNU grep.
3
#
3
#
4
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/kwset-abuse (-1 / +1 lines)
Lines 2-8 Link Here
2
# Evoke a segfault in a hard-to-reach code path of kwset.c.
2
# Evoke a segfault in a hard-to-reach code path of kwset.c.
3
# This bug affected grep versions 2.19 through 2.21.
3
# This bug affected grep versions 2.19 through 2.21.
4
#
4
#
5
# Copyright (C) 2015-2022 Free Software Foundation, Inc.
5
# Copyright (C) 2015-2023 Free Software Foundation, Inc.
6
#
6
#
7
# This program is free software: you can redistribute it and/or modify
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
8
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/long-pattern-perf (-3 / +18 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# grep-2.21 would incur a 100x penalty for 10x increase in regexp length
2
# grep-2.21 would incur a 100x penalty for 10x increase in regexp length
3
3
4
# Copyright 2015-2022 Free Software Foundation, Inc.
4
# Copyright 2015-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
Lines 24-29 Link Here
24
# system load during the two test runs, so we'll mark it as
24
# system load during the two test runs, so we'll mark it as
25
# "expensive", making it less likely to be run by regular users.
25
# "expensive", making it less likely to be run by regular users.
26
expensive_
26
expensive_
27
require_perl_
27
28
28
echo x > in || framework_failure_
29
echo x > in || framework_failure_
29
# Note that we want 10x the byte count (not line count) in the larger file.
30
# Note that we want 10x the byte count (not line count) in the larger file.
Lines 31-38 Link Here
31
cat r r r r r r r r r r > re-10x || framework_failure_
32
cat r r r r r r r r r r > re-10x || framework_failure_
32
mv r re || framework_failure_
33
mv r re || framework_failure_
33
34
34
base_ms=$(user_time_ 1 grep -f re in    ) || fail=1
35
returns_ 0 user_time_ 1 grep -f re in > base-ms \
35
b10x_ms=$(user_time_ 1 grep -f re-10x in) || fail=1
36
    || framework_failure_ 'failed to compute baseline timing'
37
base_ms=$(cat base-ms)
38
39
# This test caused trouble on at least two types of fringe hosts: those
40
# with very little memory (a 1.5GB RAM Solaris host) and a Linux/s390x
41
# (emulated with qemu-system-s390x). The former became unusable due to
42
# mem requirements of the 2nd test, and the latter ended up taking >35x
43
# more time than the base case. Skipping this test for any system using
44
# more than this many milliseconds for the first case should avoid those
45
# false-positive failures while skipping the test on few other systems.
46
test 800 -lt "$base_ms" && skip_ "this base-case test took too long"
47
48
returns_ 0 user_time_ 1 grep -f re-10x in > b10x-ms \
49
    || framework_failure_ 'failed to compute 10x timing'
50
b10x_ms=$(cat b10x-ms)
36
51
37
# Increasing the length of the regular expression by a factor
52
# Increasing the length of the regular expression by a factor
38
# of 10 should cause no more than a 10x increase in duration.
53
# of 10 should cause no more than a 10x increase in duration.
(-)grep-3.7-alt1/tests/Makefile.am (-3 / +18 lines)
Lines 1-5 Link Here
1
## Process this file with automake to create Makefile.in
1
## Process this file with automake to create Makefile.in
2
# Copyright 1997-1998, 2005-2022 Free Software Foundation, Inc.
2
# Copyright 1997-1998, 2005-2023 Free Software Foundation, Inc.
3
#
3
#
4
# This program is free software; you can redistribute it and/or modify
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
5
# it under the terms of the GNU General Public License as published by
Lines 46-58 Link Here
46
# The triple-backref test is expected to fail with both the system
46
# The triple-backref test is expected to fail with both the system
47
# matcher (i.e., with glibc) and with the included matcher.
47
# matcher (i.e., with glibc) and with the included matcher.
48
# Both matchers need to be fixed.
48
# Both matchers need to be fixed.
49
# FIXME-2015: Remove this once the glibc and gnulib bugs are fixed.
49
# FIXME-2025: Remove this once the glibc and gnulib bugs are fixed.
50
XFAIL_TESTS = triple-backref
50
XFAIL_TESTS = triple-backref
51
51
52
# The glibc-infloop test is expected to fail with both the system
53
# matcher (i.e., with glibc) and with the included matcher.
54
# Both matchers need to be fixed.
55
# FIXME-2025: Remove this once the glibc and gnulib bugs are fixed.
56
XFAIL_TESTS += glibc-infloop
57
52
# Equivalence classes are only supported when using the system
58
# Equivalence classes are only supported when using the system
53
# matcher (which means only with glibc).
59
# matcher (which means only with glibc).
54
# The included matcher needs to be fixed.
60
# The included matcher needs to be fixed.
55
# FIXME-2015: Remove this once the gnulib bug is fixed.
61
# FIXME-2025: Remove this once the gnulib bug is fixed.
56
if USE_INCLUDED_REGEX
62
if USE_INCLUDED_REGEX
57
XFAIL_TESTS += equiv-classes
63
XFAIL_TESTS += equiv-classes
58
else
64
else
Lines 83-88 Link Here
83
  case-fold-titlecase				\
89
  case-fold-titlecase				\
84
  char-class-multibyte				\
90
  char-class-multibyte				\
85
  char-class-multibyte2				\
91
  char-class-multibyte2				\
92
  color-colors					\
86
  context-0					\
93
  context-0					\
87
  count-newline					\
94
  count-newline					\
88
  dfa-coverage					\
95
  dfa-coverage					\
Lines 107-115 Link Here
107
  fillbuf-long-line				\
114
  fillbuf-long-line				\
108
  fmbtest					\
115
  fmbtest					\
109
  foad1						\
116
  foad1						\
117
  glibc-infloop					\
110
  grep-dev-null					\
118
  grep-dev-null					\
111
  grep-dev-null-out				\
119
  grep-dev-null-out				\
112
  grep-dir					\
120
  grep-dir					\
121
  hangul-syllable				\
113
  hash-collision-perf				\
122
  hash-collision-perf				\
114
  help-version					\
123
  help-version					\
115
  high-bit-range				\
124
  high-bit-range				\
Lines 137-142 Link Here
137
  options					\
146
  options					\
138
  pcre						\
147
  pcre						\
139
  pcre-abort					\
148
  pcre-abort					\
149
  pcre-ascii-digits				\
140
  pcre-context					\
150
  pcre-context					\
141
  pcre-count					\
151
  pcre-count					\
142
  pcre-infloop					\
152
  pcre-infloop					\
Lines 145-150 Link Here
145
  pcre-jitstack					\
155
  pcre-jitstack					\
146
  pcre-o					\
156
  pcre-o					\
147
  pcre-utf8					\
157
  pcre-utf8					\
158
  pcre-utf8-bug224				\
159
  pcre-utf8-w					\
148
  pcre-w					\
160
  pcre-w					\
149
  pcre-wx-backref				\
161
  pcre-wx-backref				\
150
  pcre-z					\
162
  pcre-z					\
Lines 174-184 Link Here
174
  unibyte-bracket-expr				\
186
  unibyte-bracket-expr				\
175
  unibyte-negated-circumflex			\
187
  unibyte-negated-circumflex			\
176
  utf8-bracket					\
188
  utf8-bracket					\
189
  version-pcre					\
177
  warn-char-classes				\
190
  warn-char-classes				\
178
  word-delim-multibyte				\
191
  word-delim-multibyte				\
179
  word-multi-file				\
192
  word-multi-file				\
180
  word-multibyte				\
193
  word-multibyte				\
181
  write-error-msg				\
194
  write-error-msg				\
195
  y2038-vs-32-bit				\
182
  yesno						\
196
  yesno						\
183
  z-anchor-newline
197
  z-anchor-newline
184
198
Lines 249-254 Link Here
249
  srcdir='$(srcdir)'				\
263
  srcdir='$(srcdir)'				\
250
  top_srcdir='$(top_srcdir)'			\
264
  top_srcdir='$(top_srcdir)'			\
251
  CC='$(CC)'					\
265
  CC='$(CC)'					\
266
  CONFIG_HEADER='$(abs_top_builddir)/$(CONFIG_INCLUDE)' \
252
  GREP_TEST_NAME=`echo $$tst|sed 's,^\./,,;s,/,-,g'` \
267
  GREP_TEST_NAME=`echo $$tst|sed 's,^\./,,;s,/,-,g'` \
253
  MAKE=$(MAKE)					\
268
  MAKE=$(MAKE)					\
254
  MALLOC_PERTURB_=$(MALLOC_PERTURB_)		\
269
  MALLOC_PERTURB_=$(MALLOC_PERTURB_)		\
(-)grep-3.7-alt1/tests/many-regex-performance (-3 / +4 lines)
Lines 3-9 Link Here
3
# grep-3.4 would require O(N^2) RSS for N regexps
3
# grep-3.4 would require O(N^2) RSS for N regexps
4
# grep-3.5 requires O(N) in the most common cases.
4
# grep-3.5 requires O(N) in the most common cases.
5
5
6
# Copyright 2020-2022 Free Software Foundation, Inc.
6
# Copyright 2020-2023 Free Software Foundation, Inc.
7
7
8
# This program is free software: you can redistribute it and/or modify
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
9
# it under the terms of the GNU General Public License as published by
Lines 26-40 Link Here
26
# system load during the two test runs, so we'll mark it as
26
# system load during the two test runs, so we'll mark it as
27
# "expensive", making it less likely to be run by regular users.
27
# "expensive", making it less likely to be run by regular users.
28
expensive_
28
expensive_
29
require_perl_
29
30
30
# Make the quick/small input large enough so that even on high-end
31
# Make the quick/small input large enough so that even on high-end
31
# systems this first invocation takes at least 10ms of user time.
32
# systems this first invocation takes at least 10ms of user time.
32
word_list=/usr/share/dict/linux.words
33
word_list=/usr/share/dict/linux.words
33
34
34
# If $word_list does not exist, generate an input that exibhits
35
# If $word_list does not exist, generate an input that exhibits
35
# similar performance characteristics.
36
# similar performance characteristics.
36
if ! test -f $word_list; then
37
if ! test -f $word_list; then
37
  # Generate data comprable to that word list.
38
  # Generate data comparable to that word list.
38
  # Note how all "words" start with "a", and that there is
39
  # Note how all "words" start with "a", and that there is
39
  # a small percentage of lines with at least one "." metachar.
40
  # a small percentage of lines with at least one "." metachar.
40
  # This requires /dev/urandom, so if it's not present, skip
41
  # This requires /dev/urandom, so if it's not present, skip
(-)grep-3.7-alt1/tests/match-lines (-1 / +1 lines)
Lines 3-9 Link Here
3
# grep -F -x -o PAT print an extra newline for each match.
3
# grep -F -x -o PAT print an extra newline for each match.
4
# This would fail for grep-2.19 and grep-2.20.
4
# This would fail for grep-2.19 and grep-2.20.
5
5
6
# Copyright 2014-2022 Free Software Foundation, Inc.
6
# Copyright 2014-2023 Free Software Foundation, Inc.
7
7
8
# This program is free software: you can redistribute it and/or modify
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
9
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/mb-dot-newline (-1 / +1 lines)
Lines 2-8 Link Here
2
# Trigger a bug in the DFA matcher.
2
# Trigger a bug in the DFA matcher.
3
# This would fail for grep-2.20.
3
# This would fail for grep-2.20.
4
4
5
# Copyright 2014-2022 Free Software Foundation, Inc.
5
# Copyright 2014-2023 Free Software Foundation, Inc.
6
6
7
# This program is free software: you can redistribute it and/or modify
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
8
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/mb-non-UTF8-overrun (-1 / +1 lines)
Lines 2-8 Link Here
2
# grep would sometimes read beyond end of input, when using a non-UTF8
2
# grep would sometimes read beyond end of input, when using a non-UTF8
3
# multibyte locale.
3
# multibyte locale.
4
4
5
# Copyright 2014-2022 Free Software Foundation, Inc.
5
# Copyright 2014-2023 Free Software Foundation, Inc.
6
6
7
# This program is free software: you can redistribute it and/or modify
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
8
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/mb-non-UTF8-perf-Fw (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Test for a performance regression with -Fw and a non-UTF8 multibyte locale.
2
# Test for a performance regression with -Fw and a non-UTF8 multibyte locale.
3
3
4
# Copyright 2019-2022 Free Software Foundation, Inc.
4
# Copyright 2019-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/mb-non-UTF8-performance (-1 / +2 lines)
Lines 3-9 Link Here
3
# The 200x is on an Intel i7-based system.
3
# The 200x is on an Intel i7-based system.
4
# On an AMD FX-4100, it would take up to 2500x longer.
4
# On an AMD FX-4100, it would take up to 2500x longer.
5
5
6
# Copyright 2014-2022 Free Software Foundation, Inc.
6
# Copyright 2014-2023 Free Software Foundation, Inc.
7
7
8
# This program is free software: you can redistribute it and/or modify
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
9
# it under the terms of the GNU General Public License as published by
Lines 26-31 Link Here
26
# system load during the two test runs, so we'll mark it as
26
# system load during the two test runs, so we'll mark it as
27
# "expensive", making it less likely to be run by regular users.
27
# "expensive", making it less likely to be run by regular users.
28
expensive_
28
expensive_
29
require_perl_
29
30
30
# Make the input large enough so that even on high-end systems
31
# Make the input large enough so that even on high-end systems
31
# the unibyte test takes at least 10ms of user time.
32
# the unibyte test takes at least 10ms of user time.
(-)grep-3.7-alt1/tests/mb-non-UTF8-word-boundary (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# grep -Fw could false-match when using a non-UTF8 multibyte locale.
2
# grep -Fw could false-match when using a non-UTF8 multibyte locale.
3
3
4
# Copyright 2019-2022 Free Software Foundation, Inc.
4
# Copyright 2019-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/multibyte-white-space (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test whether \s matches SP and UTF-8 multi-byte white space characters.
2
# Test whether \s matches SP and UTF-8 multi-byte white space characters.
3
#
3
#
4
# Copyright (C) 2013-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2013-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/multiple-begin-or-end-line (-1 / +1 lines)
Lines 2-8 Link Here
2
# Test a pattern of multiple begin or end line constraints.
2
# Test a pattern of multiple begin or end line constraints.
3
# This would mistakenly print a line when using grep-2.19.
3
# This would mistakenly print a line when using grep-2.19.
4
4
5
# Copyright 2014-2022 Free Software Foundation, Inc.
5
# Copyright 2014-2023 Free Software Foundation, Inc.
6
6
7
# This program is free software: you can redistribute it and/or modify
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
8
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/null-byte (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Test NUL bytes in patterns and data.
2
# Test NUL bytes in patterns and data.
3
3
4
# Copyright 2014-2022 Free Software Foundation, Inc.
4
# Copyright 2014-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/options (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test for POSIX options for grep
2
# Test for POSIX options for grep
3
#
3
#
4
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/pcre (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Simple PCRE tests.
2
# Simple PCRE tests.
3
#
3
#
4
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/pcre-abort (-1 / +1 lines)
Lines 2-8 Link Here
2
# Show that grep handles PCRE2_ERROR_MATCHLIMIT.
2
# Show that grep handles PCRE2_ERROR_MATCHLIMIT.
3
# In grep-2.8, it would abort.
3
# In grep-2.8, it would abort.
4
#
4
#
5
# Copyright (C) 2011-2022 Free Software Foundation, Inc.
5
# Copyright (C) 2011-2023 Free Software Foundation, Inc.
6
#
6
#
7
# Copying and distribution of this file, with or without modification,
7
# Copying and distribution of this file, with or without modification,
8
# are permitted in any medium without royalty provided the copyright
8
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/pcre-count (-1 / +1 lines)
Lines 2-8 Link Here
2
# grep -P / grep -Pc are inconsistent results
2
# grep -P / grep -Pc are inconsistent results
3
# This bug affected grep versions 2.21 through 2.22.
3
# This bug affected grep versions 2.21 through 2.22.
4
#
4
#
5
# Copyright (C) 2015-2022 Free Software Foundation, Inc.
5
# Copyright (C) 2015-2023 Free Software Foundation, Inc.
6
#
6
#
7
# Copying and distribution of this file, with or without modification,
7
# Copying and distribution of this file, with or without modification,
8
# are permitted in any medium without royalty provided the copyright
8
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/pcre-infloop (-1 / +1 lines)
Lines 2-8 Link Here
2
# With some versions of libpcre, apparently including 8.35,
2
# With some versions of libpcre, apparently including 8.35,
3
# the following would trigger an infinite loop in its match function.
3
# the following would trigger an infinite loop in its match function.
4
4
5
# Copyright 2014-2022 Free Software Foundation, Inc.
5
# Copyright 2014-2023 Free Software Foundation, Inc.
6
6
7
# This program is free software: you can redistribute it and/or modify
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
8
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/pcre-invalid-utf8-infloop (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Ensure that grep -oaP doesn't infloop for invalid multi-byte input
2
# Ensure that grep -oaP doesn't infloop for invalid multi-byte input
3
#
3
#
4
# Copyright (C) 2015-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2015-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/pcre-invalid-utf8-input (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Ensure that grep -P doesn't abort or infloop for invalid multi-byte input
2
# Ensure that grep -P doesn't abort or infloop for invalid multi-byte input
3
#
3
#
4
# Copyright (C) 2013-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2013-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/pcre-jitstack (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Grep 2.21 would report "grep: internal PCRE error: -27"
2
# Grep 2.21 would report "grep: internal PCRE error: -27"
3
#
3
#
4
# Copyright 2015-2022 Free Software Foundation, Inc.
4
# Copyright 2015-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/pcre-o (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Ensure that grep -oP doesn't cause internal error at match.
2
# Ensure that grep -oP doesn't cause internal error at match.
3
#
3
#
4
# Copyright (C) 2014-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2014-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/pcre-utf8 (-2 / +2 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Ensure that, with -P, Unicode \p{} symbols are correctly matched.
2
# Ensure that, with -P, Unicode \p{} symbols are correctly matched.
3
#
3
#
4
# Copyright (C) 2012-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2012-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
Lines 14-20 Link Here
14
fail=0
14
fail=0
15
15
16
echo '$' | LC_ALL=en_US.UTF-8 grep -qP '\p{S}' \
16
echo '$' | LC_ALL=en_US.UTF-8 grep -qP '\p{S}' \
17
  || skip_ 'PCRE support is compiled out, or it does not support properties'
17
  || skip_ 'PCRE unicode support is compiled out'
18
18
19
euro='\342\202\254 euro'
19
euro='\342\202\254 euro'
20
printf "$euro\\n" > in || framework_failure_
20
printf "$euro\\n" > in || framework_failure_
(-)grep-3.7-alt1/tests/pcre-w (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Before grep-2.19, grep -Pw %% would match %% enclosed in word boundaries
2
# Before grep-2.19, grep -Pw %% would match %% enclosed in word boundaries
3
#
3
#
4
# Copyright (C) 2014-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2014-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/pcre-wx-backref (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Before grep-2.19, grep -P and -w/-x would not work with a back-reference.
2
# Before grep-2.19, grep -P and -w/-x would not work with a back-reference.
3
#
3
#
4
# Copyright (C) 2014-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2014-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/posix-bracket (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Check various bracket expressions in the POSIX locale.
2
# Check various bracket expressions in the POSIX locale.
3
3
4
# Copyright 2014-2022 Free Software Foundation, Inc.
4
# Copyright 2014-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/proc (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test the /proc file system if available.
2
# Test the /proc file system if available.
3
3
4
# Copyright 2016-2022 Free Software Foundation, Inc.
4
# Copyright 2016-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/skip-read (-6 / +4 lines)
Lines 9-20 Link Here
9
9
10
for opts in '-m0 y' '-f /dev/null' '-v ""'; do
10
for opts in '-m0 y' '-f /dev/null' '-v ""'; do
11
  for matcher in '' -E -F; do
11
  for matcher in '' -E -F; do
12
    for file in /dev/null no-such-file; do
12
    eval returns_ 1 grep $opts $matcher no-such-file > out || fail=1
13
      eval returns_ 1 grep $opts $matcher no-such-file > out || fail=1
13
    compare /dev/null out || fail=1
14
      compare /dev/null out || fail=1
14
    eval returns_ 1 grep -l $opts $matcher /dev/null > out || fail=1
15
      eval returns_ 1 grep -l $opts $matcher /dev/null > out || fail=1
15
    compare /dev/null out || fail=1
16
      compare /dev/null out || fail=1
17
    done
18
    eval returns_ 1 grep -L $opts $matcher /dev/null > out || fail=1
16
    eval returns_ 1 grep -L $opts $matcher /dev/null > out || fail=1
19
    compare exp out || fail=1
17
    compare exp out || fail=1
20
    eval returns_ 1 grep -L $opts $matcher /dev/null > /dev/null || fail=1
18
    eval returns_ 1 grep -L $opts $matcher /dev/null > /dev/null || fail=1
(-)grep-3.7-alt1/tests/spencer1 (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Regression test for GNU grep.
2
# Regression test for GNU grep.
3
# Copyright (C) 1988 Henry Spencer.
3
# Copyright (C) 1988 Henry Spencer.
4
# Copyright (C) 2009-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/spencer1.awk (-1 / +1 lines)
Lines 1-5 Link Here
1
# Copyright (C) 1988 Henry Spencer.
1
# Copyright (C) 1988 Henry Spencer.
2
# Copyright (C) 2009-2022 Free Software Foundation, Inc.
2
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
3
#
3
#
4
# Copying and distribution of this file, with or without modification,
4
# Copying and distribution of this file, with or without modification,
5
# are permitted in any medium without royalty provided the copyright
5
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/spencer1-locale (-1 / +1 lines)
Lines 2-8 Link Here
2
# Regression test for GNU grep.
2
# Regression test for GNU grep.
3
#
3
#
4
# Copyright (C) 1988 Henry Spencer.
4
# Copyright (C) 1988 Henry Spencer.
5
# Copyright (C) 2009-2022 Free Software Foundation, Inc.
5
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
6
#
6
#
7
# Copying and distribution of this file, with or without modification,
7
# Copying and distribution of this file, with or without modification,
8
# are permitted in any medium without royalty provided the copyright
8
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/spencer1-locale.awk (-1 / +1 lines)
Lines 1-5 Link Here
1
# Copyright (C) 1988 Henry Spencer.
1
# Copyright (C) 1988 Henry Spencer.
2
# Copyright (C) 2009-2022 Free Software Foundation, Inc.
2
# Copyright (C) 2009-2023 Free Software Foundation, Inc.
3
#
3
#
4
# Copying and distribution of this file, with or without modification,
4
# Copying and distribution of this file, with or without modification,
5
# are permitted in any medium without royalty provided the copyright
5
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/spencer1.tests (-1 / +3 lines)
Lines 58-64 Link Here
58
0@a\(b@a(b
58
0@a\(b@a(b
59
0@a\(*b@ab
59
0@a\(*b@ab
60
0@a\(*b@a((b
60
0@a\(*b@a((b
61
1@a\x@a\x
61
0@a\\x@a\x
62
0@a[\]x@a\x
63
1@ax@a\x
62
1@abc)@-
64
1@abc)@-
63
2@(abc@-
65
2@(abc@-
64
0@((a))@abc
66
0@((a))@abc
(-)grep-3.7-alt1/tests/status (-1 / +1 lines)
Lines 5-11 Link Here
5
#  1 no match
5
#  1 no match
6
#  2 file not found
6
#  2 file not found
7
#
7
#
8
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
8
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
9
#
9
#
10
# Copying and distribution of this file, with or without modification,
10
# Copying and distribution of this file, with or without modification,
11
# are permitted in any medium without royalty provided the copyright
11
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/surrogate-pair (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Check the handling of characters outside the Unicode BMP.
2
# Check the handling of characters outside the Unicode BMP.
3
3
4
# Copyright (C) 2013-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2013-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/surrogate-search (-5 / +10 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Check characters outside the Unicode BMP in the search string.
2
# Check characters outside the Unicode BMP in the search string.
3
3
4
# Copyright 2021-2022 Free Software Foundation, Inc.
4
# Copyright 2021-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
Lines 28-42 Link Here
28
28
29
fail=0
29
fail=0
30
30
31
s_pair=$(printf '\360\220\220\205')
32
printf '%s\n' "$s_pair" > in || framework_failure_
33
34
LC_ALL=en_US.UTF-8
31
LC_ALL=en_US.UTF-8
35
export LC_ALL
32
export LC_ALL
36
33
34
# On platforms like 32-bit AIX where WCHAR_MAX == 0xFFFF, skip this check,
35
# since the corresponding Unicode characters are not supported.
36
printf '\360\220\200\200\n' >in || framework_failure_
37
grep '^.$' in >out || fail=1
38
compare in out || skip_ 'platform does not support U+10000'
39
40
printf '\360\220\220\205\n' > in || framework_failure_
41
37
for opt in '' -i -E -F -iE -iF; do
42
for opt in '' -i -E -F -iE -iF; do
38
  grep --file=in $opt in > out 2>&1 || fail=1
43
  grep --file=in $opt in > out 2>&1 || fail=1
39
  compare out in || fail=1
44
  compare in out || fail=1
40
done
45
done
41
46
42
Exit $fail
47
Exit $fail
(-)grep-3.7-alt1/tests/symlink (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Check that "grep -r" does the right thing with symbolic links.
2
# Check that "grep -r" does the right thing with symbolic links.
3
3
4
# Copyright (C) 2012-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2012-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/triple-backref (-1 / +2 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test for a bug in glibc's regex code as of September 7, 2014.
2
# Test for a bug in glibc's regex code as of September 7, 2014.
3
#
3
#
4
# Copyright (C) 2014-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2014-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
Lines 24-29 Link Here
24
warn_ "$ME_: expect malfunction on glibc systems due to" \
24
warn_ "$ME_: expect malfunction on glibc systems due to" \
25
   "https://sourceware.org/bugzilla/show_bug.cgi?id=11053"
25
   "https://sourceware.org/bugzilla/show_bug.cgi?id=11053"
26
26
27
# While with glibc-2.35, it no longer aborts, the empty result is still wrong:
27
timeout 10 grep -E '(.?)(.?)(.?)\3\2\1' in > out || fail=1
28
timeout 10 grep -E '(.?)(.?)(.?)\3\2\1' in > out || fail=1
28
compare out in || fail=1
29
compare out in || fail=1
29
30
(-)grep-3.7-alt1/tests/turkish-eyes (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Ensure that case-insensitive matching works with all Turkish i's
2
# Ensure that case-insensitive matching works with all Turkish i's
3
3
4
# Copyright (C) 2014-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2014-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/turkish-I (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# grep -i in UTF-8: missing NL in output on line containing I WITH DOT (U+0130)
2
# grep -i in UTF-8: missing NL in output on line containing I WITH DOT (U+0130)
3
3
4
# Copyright (C) 2011-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2011-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/turkish-I-without-dot (-1 / +1 lines)
Lines 3-9 Link Here
3
# (like "I" in the tr_TR.utf8 locale) whose lower-case representation
3
# (like "I" in the tr_TR.utf8 locale) whose lower-case representation
4
# occupies more bytes (two in this case, for 0xc4b1, aka U+0131).
4
# occupies more bytes (two in this case, for 0xc4b1, aka U+0131).
5
5
6
# Copyright (C) 2011-2022 Free Software Foundation, Inc.
6
# Copyright (C) 2011-2023 Free Software Foundation, Inc.
7
7
8
# This program is free software: you can redistribute it and/or modify
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
9
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/two-chars (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Check for grep -F with two patterns consisting of the same char.
2
# Check for grep -F with two patterns consisting of the same char.
3
#
3
#
4
# Copyright 2016-2022 Free Software Foundation, Inc.
4
# Copyright 2016-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/two-files (-1 / +1 lines)
Lines 2-8 Link Here
2
# Read two files, of increasing size.
2
# Read two files, of increasing size.
3
# With ASAN, this would have triggered a false-positive read of poisoned memory.
3
# With ASAN, this would have triggered a false-positive read of poisoned memory.
4
#
4
#
5
# Copyright 2015-2022 Free Software Foundation, Inc.
5
# Copyright 2015-2023 Free Software Foundation, Inc.
6
#
6
#
7
# Copying and distribution of this file, with or without modification,
7
# Copying and distribution of this file, with or without modification,
8
# are permitted in any medium without royalty provided the copyright
8
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/unibyte-binary (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Test binary files in unibyte locales with encoding errors
2
# Test binary files in unibyte locales with encoding errors
3
3
4
# Copyright 2016-2022 Free Software Foundation, Inc.
4
# Copyright 2016-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/unibyte-bracket-expr (-1 / +1 lines)
Lines 5-11 Link Here
5
# ru_RU.KOI8-R for any C whose wide-char representation differed from
5
# ru_RU.KOI8-R for any C whose wide-char representation differed from
6
# its single-byte equivalent.
6
# its single-byte equivalent.
7
7
8
# Copyright (C) 2011-2022 Free Software Foundation, Inc.
8
# Copyright (C) 2011-2023 Free Software Foundation, Inc.
9
9
10
# This program is free software: you can redistribute it and/or modify
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
11
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/unibyte-negated-circumflex (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Exercise a bug where [^^-^] was treated as if it were [^-^].
2
# Exercise a bug where [^^-^] was treated as if it were [^-^].
3
3
4
# Copyright 2014-2022 Free Software Foundation, Inc.
4
# Copyright 2014-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/utf8-bracket (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Check bracket expressions in a UTF-8 locale.
2
# Check bracket expressions in a UTF-8 locale.
3
3
4
# Copyright 2015-2022 Free Software Foundation, Inc.
4
# Copyright 2015-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/warn-char-classes (-4 lines)
Lines 17-26 Link Here
17
returns_ 1 grep '[[:space:]]' x 2> err || fail=1
17
returns_ 1 grep '[[:space:]]' x 2> err || fail=1
18
test -s err && fail=1
18
test -s err && fail=1
19
19
20
# disabled by POSIXLY_CORRECT
21
returns_ 1 env POSIXLY_CORRECT=yes grep '[:space:]' x 2> err || fail=1
22
test -s err && fail=1
23
24
# patterns that are considered valid
20
# patterns that are considered valid
25
returns_ 1 grep '[::]' x 2> err || fail=1
21
returns_ 1 grep '[::]' x 2> err || fail=1
26
test -s err && fail=1
22
test -s err && fail=1
(-)grep-3.7-alt1/tests/write-error-msg (-1 / +1 lines)
Lines 1-7 Link Here
1
#!/bin/sh
1
#!/bin/sh
2
# Ensure that output errors are reported with errno information.
2
# Ensure that output errors are reported with errno information.
3
3
4
# Copyright 2016-2022 Free Software Foundation, Inc.
4
# Copyright 2016-2023 Free Software Foundation, Inc.
5
5
6
# This program is free software: you can redistribute it and/or modify
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/tests/yesno (-1 / +1 lines)
Lines 1-7 Link Here
1
#! /bin/sh
1
#! /bin/sh
2
# Test feature interaction of -C, -v, -o, and -m.
2
# Test feature interaction of -C, -v, -o, and -m.
3
#
3
#
4
# Copyright (C) 2001, 2006, 2009-2022 Free Software Foundation, Inc.
4
# Copyright (C) 2001, 2006, 2009-2023 Free Software Foundation, Inc.
5
#
5
#
6
# Copying and distribution of this file, with or without modification,
6
# Copying and distribution of this file, with or without modification,
7
# are permitted in any medium without royalty provided the copyright
7
# are permitted in any medium without royalty provided the copyright
(-)grep-3.7-alt1/tests/z-anchor-newline (-1 / +1 lines)
Lines 2-8 Link Here
2
# grep -z with an anchor in the regex could mistakenly match text
2
# grep -z with an anchor in the regex could mistakenly match text
3
# including a newline.
3
# including a newline.
4
4
5
# Copyright 2016-2022 Free Software Foundation, Inc.
5
# Copyright 2016-2023 Free Software Foundation, Inc.
6
6
7
# This program is free software: you can redistribute it and/or modify
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
8
# it under the terms of the GNU General Public License as published by
(-)grep-3.7-alt1/THANKS.in (+5 lines)
Lines 28-33 Link Here
28
David O'Brien                       obrien@freebsd.org
28
David O'Brien                       obrien@freebsd.org
29
'Drake' Daham Wang                  drakewang@gmail.com
29
'Drake' Daham Wang                  drakewang@gmail.com
30
Egmont Koblinger                    egmont@gmail.com
30
Egmont Koblinger                    egmont@gmail.com
31
Emanuele Torre                      torreemanuele6@gmail.com
31
Fernando Basso                      fernandobasso.br@gmail.com
32
Fernando Basso                      fernandobasso.br@gmail.com
32
Florian La Roche                    laroche@redhat.com
33
Florian La Roche                    laroche@redhat.com
33
François Pinard                     pinard@iro.umontreal.ca
34
François Pinard                     pinard@iro.umontreal.ca
Lines 35-40 Link Here
35
Grant McDorman                      grant@isgtec.com
36
Grant McDorman                      grant@isgtec.com
36
Greg Boyd                           gboyd.ccsf@gmail.com
37
Greg Boyd                           gboyd.ccsf@gmail.com
37
Greg Louis                          glouis@dynamicro.on.ca
38
Greg Louis                          glouis@dynamicro.on.ca
39
Gro-Tsen                            https://twitter.com/gro_tsen
38
Guglielmo 'bond' Bondioni           g.bondioni@libero.it
40
Guglielmo 'bond' Bondioni           g.bondioni@libero.it
39
H. Merijn Brand                     h.m.brand@hccnet.nl
41
H. Merijn Brand                     h.m.brand@hccnet.nl
40
Harald Hanche-Olsen                 hanche@math.ntnu.no
42
Harald Hanche-Olsen                 hanche@math.ntnu.no
Lines 50-58 Link Here
50
John Hughes                         john@nitelite.calvacom.fr
52
John Hughes                         john@nitelite.calvacom.fr
51
Jorge Stolfi                        stolfi@dcc.unicamp.br
53
Jorge Stolfi                        stolfi@dcc.unicamp.br
52
Karl Heuer                          kwzh@gnu.org
54
Karl Heuer                          kwzh@gnu.org
55
Karl Pettersson                     karl.pettersson@klpn.se
53
Kaveh R. Ghazi                      ghazi@caip.rutgers.edu
56
Kaveh R. Ghazi                      ghazi@caip.rutgers.edu
54
Kazuro Furukawa                     furukawa@apricot.kek.jp
57
Kazuro Furukawa                     furukawa@apricot.kek.jp
55
Keith Bostic                        bostic@bsdi.com
58
Keith Bostic                        bostic@bsdi.com
59
Koen Claessen                       koen@chalmers.se
56
Krishna Sethuraman                  krishna@sgihub.corp.sgi.com
60
Krishna Sethuraman                  krishna@sgihub.corp.sgi.com
57
Kurt D Schwehr                      kdschweh@insci14.ucsd.edu
61
Kurt D Schwehr                      kdschweh@insci14.ucsd.edu
58
Ludovic Courtès                     ludo@gnu.org
62
Ludovic Courtès                     ludo@gnu.org
Lines 77-82 Link Here
77
Roland Roberts                      rroberts@muller.com
81
Roland Roberts                      rroberts@muller.com
78
Ruslan Ermilov                      ru@freebsd.org
82
Ruslan Ermilov                      ru@freebsd.org
79
Santiago Vila                       sanvila@unex.es
83
Santiago Vila                       sanvila@unex.es
84
Sebastian Carlos                    sebaaa1754@gmail.com
80
Shannon Hill                        hill@synnet.com
85
Shannon Hill                        hill@synnet.com
81
Sotiris Vassilopoulos               Sotiris.Vassilopoulos@betatech.gr
86
Sotiris Vassilopoulos               Sotiris.Vassilopoulos@betatech.gr
82
Standish Parsley                    adsspamtrap01@yahoo.com
87
Standish Parsley                    adsspamtrap01@yahoo.com
(-)grep-3.7-alt1/TODO (-1 / +1 lines)
Lines 1-6 Link Here
1
Things to do for GNU grep
1
Things to do for GNU grep
2
2
3
  Copyright (C) 1992, 1997-2002, 2004-2022 Free Software Foundation, Inc.
3
  Copyright (C) 1992, 1997-2002, 2004-2023 Free Software Foundation, Inc.
4
4
5
  Copying and distribution of this file, with or without modification,
5
  Copying and distribution of this file, with or without modification,
6
  are permitted in any medium without royalty provided the copyright
6
  are permitted in any medium without royalty provided the copyright

Return to bug 46413