Compare commits
10 Commits
1279ab4422
...
fb1686490b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb1686490b | ||
|
|
f013e440dc | ||
|
|
d500556976 | ||
|
|
db86faf1b3 | ||
|
|
56251527d8 | ||
|
|
29f901204f | ||
|
|
9490553cb9 | ||
|
|
6d1ac2d09e | ||
|
|
f099ca5103 | ||
|
|
065a6584d7 |
@ -1,4 +0,0 @@
|
||||
# Configuration file for the color grep utility
|
||||
|
||||
# 'none' shuts colorization off.
|
||||
#COLOR none
|
||||
56
backport-grep-avoid-sticky-problem-with-f-f.patch
Normal file
56
backport-grep-avoid-sticky-problem-with-f-f.patch
Normal file
@ -0,0 +1,56 @@
|
||||
From ad6de316cca655cd8b0b20b3e9dd18e7e98e443a Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Sat, 21 Aug 2021 10:44:17 -0700
|
||||
Subject: [PATCH 111/151] =?UTF-8?q?grep:=20avoid=20sticky=20problem=20with?=
|
||||
=?UTF-8?q?=20=E2=80=98-f=20-=20-f=20-=E2=80=99?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Inspired by bug#50129 even though this is a different bug.
|
||||
* src/grep.c (main): For ‘-f -’, use clearerr (stdin) after
|
||||
reading, so that ‘grep -f - -f -’ reads stdin twice even
|
||||
when stdin is a tty. Also, for ‘-f FILE’, report any
|
||||
I/O error when closing FILE.
|
||||
---
|
||||
src/grep.c | 17 +++++++++++------
|
||||
1 file changed, 11 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/grep.c b/src/grep.c
|
||||
index 7ba602d..c9ce65d 100644
|
||||
--- a/src/grep.c
|
||||
+++ b/src/grep.c
|
||||
@@ -2429,7 +2429,6 @@ main (int argc, char **argv)
|
||||
size_t cc;
|
||||
int opt, prepended;
|
||||
int prev_optind, last_recursive;
|
||||
- int fread_errno;
|
||||
intmax_t default_context;
|
||||
FILE *fp;
|
||||
exit_failure = EXIT_TROUBLE;
|
||||
@@ -2600,11 +2599,17 @@ main (int argc, char **argv)
|
||||
if (cc == 0)
|
||||
break;
|
||||
}
|
||||
- fread_errno = errno;
|
||||
- if (ferror (fp))
|
||||
- die (EXIT_TROUBLE, fread_errno, "%s", optarg);
|
||||
- if (fp != stdin)
|
||||
- fclose (fp);
|
||||
+ int err = errno;
|
||||
+ if (!ferror (fp))
|
||||
+ {
|
||||
+ err = 0;
|
||||
+ if (fp == stdin)
|
||||
+ clearerr (fp);
|
||||
+ else if (fclose (fp) != 0)
|
||||
+ err = errno;
|
||||
+ }
|
||||
+ if (err)
|
||||
+ die (EXIT_TROUBLE, err, "%s", optarg);
|
||||
/* Append final newline if file ended in non-newline. */
|
||||
if (oldcc != keycc && keys[keycc - 1] != '\n')
|
||||
keys[keycc++] = '\n';
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
88
backport-pcre-use-UCP-in-UTF-mode.patch
Normal file
88
backport-pcre-use-UCP-in-UTF-mode.patch
Normal file
@ -0,0 +1,88 @@
|
||||
From 5e3b760f65f13856e5717e5b9d935f5b4a615be3 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= <carenas@gmail.com>
|
||||
Date: Fri, 6 Jan 2023 19:34:56 -0800
|
||||
Subject: [PATCH] pcre: use UCP in UTF mode
|
||||
|
||||
This fixes a serious bug affecting word-boundary and word-constituent regular
|
||||
expressions when the desired match involves non-ASCII UTF8 characters.
|
||||
* src/pcresearch.c: Set PCRE2_UCP together with PCRE2_UTF
|
||||
* tests/pcre-utf8-w: New file.
|
||||
* tests/Makefile.am (TESTS): Add it.
|
||||
* NEWS (Bug fixes): Mention this.
|
||||
* THANKS.in: Add Gro-Tsen and Karl Petterson.
|
||||
Reported by Gro-Tsen https://twitter.com/gro_tsen/status/1610972356972875777
|
||||
via Karl Pettersson in https://github.com/PCRE2Project/pcre2/issues/185
|
||||
This bug was present from grep-2.5, when --perl-regexp (-P) support was added.
|
||||
|
||||
Reference:https://git.savannah.gnu.org/cgit/grep.git/commit?id=5e3b760f65f13856e5717e5b9d935f5b4a615be3
|
||||
Conflict:delete NEWS,ThANKS.in and change src/pcresearch.c
|
||||
---
|
||||
src/pcresearch.c | 2 +-
|
||||
tests/Makefile.am | 1 +
|
||||
tests/pcre-utf8-w | 28 ++++++++++++++++++++++++++++
|
||||
3 files changed, 30 insertions(+), 1 deletion(-)
|
||||
create mode 100755 tests/pcre-utf8-w
|
||||
|
||||
diff --git a/src/pcresearch.c b/src/pcresearch.c
|
||||
index 577995f..0127073 100644
|
||||
--- a/src/pcresearch.c
|
||||
+++ b/src/pcresearch.c
|
||||
@@ -136,7 +136,7 @@ Pcompile (char *pattern, size_t size, reg_syntax_t ignored, bool exact)
|
||||
{
|
||||
if (! localeinfo.using_utf8)
|
||||
die (EXIT_TROUBLE, 0, _("-P supports only unibyte and UTF-8 locales"));
|
||||
- flags |= PCRE_UTF8;
|
||||
+ flags |= (PCRE_UTF8 | PCRE_UCP);
|
||||
}
|
||||
|
||||
/* FIXME: Remove this restriction. */
|
||||
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
||||
index b05a126..d2968c6 100644
|
||||
--- a/tests/Makefile.am
|
||||
+++ b/tests/Makefile.am
|
||||
@@ -143,6 +143,7 @@ TESTS = \
|
||||
pcre-jitstack \
|
||||
pcre-o \
|
||||
pcre-utf8 \
|
||||
+ pcre-utf8-w \
|
||||
pcre-w \
|
||||
pcre-wx-backref \
|
||||
pcre-z \
|
||||
diff --git a/tests/pcre-utf8-w b/tests/pcre-utf8-w
|
||||
new file mode 100755
|
||||
index 0000000..4cd7db6
|
||||
--- /dev/null
|
||||
+++ b/tests/pcre-utf8-w
|
||||
@@ -0,0 +1,28 @@
|
||||
+#!/bin/sh
|
||||
+# Ensure non-ASCII UTF-8 characters are correctly identified as word-consituent
|
||||
+#
|
||||
+# Copyright (C) 2023 Free Software Foundation, Inc.
|
||||
+#
|
||||
+# Copying and distribution of this file, with or without modification,
|
||||
+# are permitted in any medium without royalty provided the copyright
|
||||
+# notice and this notice are preserved.
|
||||
+
|
||||
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
||||
+require_en_utf8_locale_
|
||||
+LC_ALL=en_US.UTF-8
|
||||
+export LC_ALL
|
||||
+require_pcre_
|
||||
+
|
||||
+fail=0
|
||||
+
|
||||
+echo 'Perú'> in || framework_failure_
|
||||
+
|
||||
+echo 'ú' > exp || framework_failure_
|
||||
+grep -Po '.\b' in > out || fail=1
|
||||
+compare exp out || fail=1
|
||||
+
|
||||
+echo 'rú' > exp || framework_failure_
|
||||
+grep -Po 'r\w' in > out || fail=1
|
||||
+compare exp out || fail=1
|
||||
+
|
||||
+Exit $fail
|
||||
--
|
||||
2.27.0
|
||||
|
||||
|
||||
0
colorgrep.csh
Normal file → Executable file
0
colorgrep.csh
Normal file → Executable file
0
colorgrep.sh
Normal file → Executable file
0
colorgrep.sh
Normal file → Executable file
@ -1,38 +0,0 @@
|
||||
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
||||
index 66fb461..c6e96e4 100644
|
||||
--- a/tests/Makefile.am
|
||||
+++ b/tests/Makefile.am
|
||||
@@ -55,10 +55,6 @@ XFAIL_TESTS = triple-backref
|
||||
# FIXME-2015: Remove this once the gnulib bug is fixed.
|
||||
if USE_INCLUDED_REGEX
|
||||
XFAIL_TESTS += equiv-classes
|
||||
-else
|
||||
-# The backslash-alt test fails for glibc, which needs to be fixed.
|
||||
-# FIXME-2015: Remove this once the glibc bug is fixed.
|
||||
-XFAIL_TESTS += backref-alt
|
||||
endif
|
||||
|
||||
TESTS = \
|
||||
diff --git a/tests/Makefile.in b/tests/Makefile.in
|
||||
index 55c72d0..04e64af 100644
|
||||
--- a/tests/Makefile.in
|
||||
+++ b/tests/Makefile.in
|
||||
@@ -108,9 +108,6 @@ check_PROGRAMS = get-mb-cur-max$(EXEEXT)
|
||||
# The included matcher needs to be fixed.
|
||||
# FIXME-2015: Remove this once the gnulib bug is fixed.
|
||||
@USE_INCLUDED_REGEX_TRUE@am__append_1 = equiv-classes
|
||||
-# The backslash-alt test fails for glibc, which needs to be fixed.
|
||||
-# FIXME-2015: Remove this once the glibc bug is fixed.
|
||||
-@USE_INCLUDED_REGEX_FALSE@am__append_2 = backref-alt
|
||||
subdir = tests
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
|
||||
@@ -1408,7 +1405,7 @@ LDADD = ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a
|
||||
# matcher (i.e., with glibc) and with the included matcher.
|
||||
# Both matchers need to be fixed.
|
||||
# FIXME-2015: Remove this once the glibc and gnulib bugs are fixed.
|
||||
-XFAIL_TESTS = triple-backref $(am__append_1) $(am__append_2)
|
||||
+XFAIL_TESTS = triple-backref $(am__append_1)
|
||||
TESTS = \
|
||||
backref \
|
||||
backref-alt \
|
||||
BIN
grep-3.1.tar.xz
BIN
grep-3.1.tar.xz
Binary file not shown.
@ -1,30 +0,0 @@
|
||||
diff --git a/src/grep.c b/src/grep.c
|
||||
index a2de03d..fd1b3a9 100644
|
||||
--- a/src/grep.c
|
||||
+++ b/src/grep.c
|
||||
@@ -1962,17 +1962,20 @@ Output control:\n\
|
||||
-D, --devices=ACTION how to handle devices, FIFOs and sockets;\n\
|
||||
ACTION is 'read' or 'skip'\n\
|
||||
-r, --recursive like --directories=recurse\n\
|
||||
- -R, --dereference-recursive likewise, but follow all symlinks\n\
|
||||
+ -R, --dereference-recursive\n\
|
||||
+ likewise, but follow all symlinks\n\
|
||||
"));
|
||||
printf (_("\
|
||||
- --include=FILE_PATTERN search only files that match FILE_PATTERN\n\
|
||||
- --exclude=FILE_PATTERN skip files and directories matching\
|
||||
+ --include=FILE_PATTERN\n\
|
||||
+ search only files that match FILE_PATTERN\n\
|
||||
+ --exclude=FILE_PATTERN\n\
|
||||
+ skip files and directories matching\
|
||||
FILE_PATTERN\n\
|
||||
--exclude-from=FILE skip files matching any file pattern from FILE\n\
|
||||
- --exclude-dir=PATTERN directories that match PATTERN will be skipped.\n\
|
||||
+ --exclude-dir=PATTERN directories that match PATTERN will be skipped.\n\
|
||||
"));
|
||||
printf (_("\
|
||||
- -L, --files-without-match print only names of FILEs with no selected lines\n\
|
||||
+ -L, --files-without-match print only names of FILEs with no selected lines\n\
|
||||
-l, --files-with-matches print only names of FILEs with selected lines\n\
|
||||
-c, --count print only a count of selected lines per FILE\n\
|
||||
-T, --initial-tab make tabs line up (if needed)\n\
|
||||
@ -1,61 +0,0 @@
|
||||
diff --git a/doc/grep.in.1 b/doc/grep.in.1
|
||||
index 40c9586..a4e89eb 100644
|
||||
--- a/doc/grep.in.1
|
||||
+++ b/doc/grep.in.1
|
||||
@@ -335,7 +335,7 @@ Print
|
||||
.I NUM
|
||||
lines of trailing context after matching lines.
|
||||
Places a line containing a group separator
|
||||
-.RB ( \-\^\- )
|
||||
+.RB "(described under " \-\^\-group\-separator )
|
||||
between contiguous groups of matches.
|
||||
With the
|
||||
.B \-o
|
||||
@@ -348,7 +348,7 @@ Print
|
||||
.I NUM
|
||||
lines of leading context before matching lines.
|
||||
Places a line containing a group separator
|
||||
-.RB ( \-\^\- )
|
||||
+.RB "(described under " \-\^\-group\-separator )
|
||||
between contiguous groups of matches.
|
||||
With the
|
||||
.B \-o
|
||||
@@ -361,13 +361,24 @@ Print
|
||||
.I NUM
|
||||
lines of output context.
|
||||
Places a line containing a group separator
|
||||
-.RB ( \-\^\- )
|
||||
+.RB "(described under " \-\^\-group\-separator )
|
||||
between contiguous groups of matches.
|
||||
With the
|
||||
.B \-o
|
||||
or
|
||||
.B \-\^\-only\-matching
|
||||
option, this has no effect and a warning is given.
|
||||
+.TP
|
||||
+.BI \-\^\-group\-separator= SEP
|
||||
+Use
|
||||
+.I SEP
|
||||
+as a group separator. By default
|
||||
+.I SEP
|
||||
+is double hyphen
|
||||
+.RB ( \-\^\- ).
|
||||
+.TP
|
||||
+.B \-\^\-no\-group-separator
|
||||
+Use empty string as a group separator.
|
||||
.SS "File and Directory Selection"
|
||||
.TP
|
||||
.BR \-a ", " \-\^\-text
|
||||
diff --git a/src/grep.c b/src/grep.c
|
||||
index 8d22aec..a2de03d 100644
|
||||
--- a/src/grep.c
|
||||
+++ b/src/grep.c
|
||||
@@ -1986,6 +1986,8 @@ Context control:\n\
|
||||
"));
|
||||
printf (_("\
|
||||
-NUM same as --context=NUM\n\
|
||||
+ --group-separator=SEP use SEP as a group separator\n\
|
||||
+ --no-group-separator use empty string as a group separator\n\
|
||||
--color[=WHEN],\n\
|
||||
--colour[=WHEN] use markers to highlight the matching strings;\n\
|
||||
WHEN is 'always', 'never', or 'auto'\n\
|
||||
BIN
grep-3.4.tar.xz
Normal file
BIN
grep-3.4.tar.xz
Normal file
Binary file not shown.
51
grep.spec
51
grep.spec
@ -1,18 +1,16 @@
|
||||
Name: grep
|
||||
Version: 3.1
|
||||
Release: 10
|
||||
Name: grep
|
||||
Version: 3.4
|
||||
Release: 4
|
||||
Summary: A string search utility
|
||||
License: GPLv3+
|
||||
URL: http://www.gnu.org/software/grep/
|
||||
Source0: https://ftp.gnu.org/gnu/grep/grep-%{version}.tar.xz
|
||||
Source1: colorgrep.sh
|
||||
Source2: colorgrep.csh
|
||||
Source3: GREP_COLORS
|
||||
Source4: grepconf.sh
|
||||
Source3: grepconf.sh
|
||||
|
||||
Patch0: grep-3.31-man-fix-gs.patch
|
||||
Patch1: grep-3.31-help-align.patch
|
||||
Patch2: grep-3.1-glibc-2.28-fix.patch
|
||||
Patch1: backport-grep-avoid-sticky-problem-with-f-f.patch
|
||||
Patch6001: backport-pcre-use-UCP-in-UTF-mode.patch
|
||||
|
||||
BuildRequires: gcc git pcre-devel >= 3.9-10 texinfo gettext
|
||||
Provides: /bin/egrep /bin/fgrep /bin/grep bundled(gnulib)
|
||||
@ -25,17 +23,18 @@ a specified pattern. By default, Grep outputs the matching lines.
|
||||
%autosetup -n %{name}-%{version} -p1
|
||||
|
||||
%build
|
||||
autoreconf
|
||||
%configure --without-included-regex --disable-silent-rules \
|
||||
CPPFLAGS="-I%{_includedir}/pcre" CFLAGS="$RPM_OPT_FLAGS"
|
||||
CPPFLAGS="-I%{_includedir}/pcre" CFLAGS="$RPM_OPT_FLAGS -fsigned-char"
|
||||
%make_build
|
||||
|
||||
%install
|
||||
%make_install
|
||||
rm -f $RPM_BUILD_ROOT%{_infodir}/dir
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
|
||||
|
||||
install -pm 644 %{SOURCE1} %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
|
||||
install -pm 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}
|
||||
install -Dpm 755 %{SOURCE4} $RPM_BUILD_ROOT%{_libexecdir}/grepconf.sh
|
||||
install -Dpm 755 %{SOURCE3} $RPM_BUILD_ROOT%{_libexecdir}/grepconf.sh
|
||||
|
||||
%pre
|
||||
%preun
|
||||
@ -47,17 +46,41 @@ make check
|
||||
|
||||
%files
|
||||
%{_datadir}/locale/*
|
||||
%config(noreplace) %{_sysconfdir}/profile.d/colorgrep.*sh
|
||||
%doc NEWS README THANKS TODO
|
||||
%license COPYING AUTHORS
|
||||
%{_bindir}/*grep
|
||||
%config(noreplace) %{_sysconfdir}/profile.d/colorgrep.*sh
|
||||
%config(noreplace) %{_sysconfdir}/GREP_COLORS
|
||||
%{_libexecdir}/grepconf.sh
|
||||
%{_infodir}/grep.info.gz
|
||||
%{_mandir}/man1/*grep.1.gz
|
||||
%{_libexecdir}/grepconf.sh
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Apr 24 2023 gaoruoshu<gaoruoshu@huawei.com> - 3.4-4
|
||||
- Type:bugfix
|
||||
- DESC:pcre: use UCP in UTF mode
|
||||
|
||||
* Thu Nov 3 2022 gaoruoshu<gaoruoshu@huawei.com> - 3.4-3
|
||||
- Added coloring aliases to fgrep egrep and grep
|
||||
|
||||
* Tue Feb 8 2022 yangzhuangzhuang<yangzhuangzhuang1@h-partners.com> - 3.4-2
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:avoid sticky problem with '-f - -f -'
|
||||
|
||||
* Wed Dec 15 2021 yangzhuangzhuang<yangzhuangzhuang1@huawei.com> - 3.4-1
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:add -fsigned-char option
|
||||
|
||||
* Tue Jan 7 2020 JeanLeo<liujianliu.liu@huawei.com> - 3.4-0
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:update software to version 3.4
|
||||
|
||||
* Mon Oct 21 2019 chengquan<chengquan3@huawei.com> - 3.1-10
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
0
grepconf.sh
Normal file → Executable file
0
grepconf.sh
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user