[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: four small changes
From: |
Jim Meyering |
Subject: |
FYI: four small changes |
Date: |
Sun, 09 Apr 2023 22:42:25 -0700 |
I've just pushed a few small changes:
>From 19d2275fd1195f00e4ffc90a03b388c55d858681 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Mon, 3 Apr 2023 11:41:26 -0700
Subject: [PATCH 1/4] tests: test for the year-2038 bug
* tests/y2038-vs-32-bit: New file.
* tests/Makefile.am (TESTS): Add the file name
---
tests/Makefile.am | 1 +
tests/y2038-vs-32-bit | 13 +++++++++++++
2 files changed, 14 insertions(+)
create mode 100755 tests/y2038-vs-32-bit
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f195c8d..c9376b1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -183,6 +183,7 @@ TESTS = \
word-multi-file \
word-multibyte \
write-error-msg \
+ y2038-vs-32-bit \
yesno \
z-anchor-newline
diff --git a/tests/y2038-vs-32-bit b/tests/y2038-vs-32-bit
new file mode 100755
index 0000000..374f855
--- /dev/null
+++ b/tests/y2038-vs-32-bit
@@ -0,0 +1,13 @@
+#!/bin/sh
+# This would fail with grep-3.9 and 3.10 on 32-bit ARM and x86 hosts.
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+fail=0
+
+echo text > in || framework_failure_
+touch -t 203901010000 in || framework_failure_
+grep t in > out 2> err || fail=1
+compare in out || fail=1
+compare /dev/null err || fail=1
+
+Exit $fail
--
2.40.0.166.g140b9478da
>From 88b2d37c0a975b736841f66c1b64401bb4d329f3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Sat, 8 Apr 2023 18:16:46 -0700
Subject: [PATCH 2/4] grep: --version: print pcre version info
PCRE is integral to the functioning of grep's -P option, so it is in our
interest to make it easy to see which version of PCRE grep uses.
* src/grep.c [HAVE_LIBPCRE]: Include <pcre2.h>.
[HAVE_LIBPCRE] (main): Print pcre version info.
* tests/version-pcre: New test for this.
* tests/Makefile.am (TESTS): Add the file name.
* NEWS (Changes in behavior): Mention it.
---
NEWS | 8 ++++++++
src/grep.c | 11 +++++++++++
tests/Makefile.am | 2 ++
tests/version-pcre | 15 +++++++++++++++
4 files changed, 36 insertions(+)
create mode 100755 tests/version-pcre
diff --git a/NEWS b/NEWS
index 060e938..029aaf1 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,14 @@ GNU grep NEWS -*- outline
-*-
when running on 32-bit x86 and ARM hosts using glibc 2.34+.
[bug introduced in grep 3.9]
+** Changes in behavior
+
+ grep --version now prints a line describing the version of PCRE2 it uses.
+ For example, it prints this when built with the very latest from git:
+ Built with PCRE 10.43-DEV 2023-01-15
+ or this with what's currently available in Fedora 37:
+ Built with PCRE 10.40 2022-04-14
+
* Noteworthy changes in release 3.10 (2023-03-22) [stable]
diff --git a/src/grep.c b/src/grep.c
index 7547b64..bd776e8 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -29,6 +29,11 @@
#include <stdio.h>
#include "system.h"
+#if HAVE_LIBPCRE
+# define PCRE2_CODE_UNIT_WIDTH 8
+# include <pcre2.h>
+#endif
+
#include "argmatch.h"
#include "c-ctype.h"
#include "c-stack.h"
@@ -2830,6 +2835,12 @@ main (int argc, char **argv)
(char *) NULL);
puts (_("Written by Mike Haertel and others; see\n"
"<https://git.savannah.gnu.org/cgit/grep.git/tree/AUTHORS>."));
+#if HAVE_LIBPCRE
+ unsigned char buf[128];
+ (void) pcre2_config (PCRE2_CONFIG_VERSION, buf);
+ fputs (_("\nBuilt with PCRE "), stdout);
+ puts ((char *) buf);
+#endif
return EXIT_SUCCESS;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c9376b1..0ef96d4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -178,6 +178,7 @@ TESTS = \
unibyte-bracket-expr \
unibyte-negated-circumflex \
utf8-bracket \
+ version-pcre \
warn-char-classes \
word-delim-multibyte \
word-multi-file \
@@ -254,6 +255,7 @@ TESTS_ENVIRONMENT = \
srcdir='$(srcdir)' \
top_srcdir='$(top_srcdir)' \
CC='$(CC)' \
+ CONFIG_HEADER='$(abs_top_builddir)/$(CONFIG_INCLUDE)' \
GREP_TEST_NAME=`echo $$tst|sed 's,^\./,,;s,/,-,g'` \
MAKE=$(MAKE) \
MALLOC_PERTURB_=$(MALLOC_PERTURB_) \
diff --git a/tests/version-pcre b/tests/version-pcre
new file mode 100755
index 0000000..d18daa6
--- /dev/null
+++ b/tests/version-pcre
@@ -0,0 +1,15 @@
+#! /bin/sh
+# Test for presence of pcre version number in --version output.
+#
+# 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
+
+grep -q '^#define HAVE_LIBPCRE 1' "$CONFIG_HEADER" \
+ || skip_ 'built without PCRE support'
+
+grep --version | grep -qP '^Built with PCRE [\d.]+'
--
2.40.0.166.g140b9478da
>From 85e0e4fdd440ff41d12ce8f5fe7b30128a3cdb58 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Sat, 1 Apr 2023 21:01:01 -0700
Subject: [PATCH 3/4] tests: add a known-failing glibc-infloop test
* tests/glibc-infloop: New file.
Based on the command from Koen Claessen
reported in https://bugs.gnu.org/62483
* configure.ac (USE_INCLUDED_REGEX): define.
* tests/Makefile.am (TESTS): Add the file name
* THANKS.in: Add name of reporter.
---
THANKS.in | 1 +
configure.ac | 1 +
tests/Makefile.am | 11 +++++++++--
tests/glibc-infloop | 30 ++++++++++++++++++++++++++++++
4 files changed, 41 insertions(+), 2 deletions(-)
create mode 100755 tests/glibc-infloop
diff --git a/THANKS.in b/THANKS.in
index fd36192..06f8c54 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -56,6 +56,7 @@ Karl Pettersson karl.pettersson@klpn.se
Kaveh R. Ghazi ghazi@caip.rutgers.edu
Kazuro Furukawa furukawa@apricot.kek.jp
Keith Bostic bostic@bsdi.com
+Koen Claessen koen@chalmers.se
Krishna Sethuraman krishna@sgihub.corp.sgi.com
Kurt D Schwehr kdschweh@insci14.ucsd.edu
Ludovic Courtès ludo@gnu.org
diff --git a/configure.ac b/configure.ac
index 528349c..13ec905 100644
--- a/configure.ac
+++ b/configure.ac
@@ -212,6 +212,7 @@ dnl then the installer should configure
--with-included-regex.
AM_CONDITIONAL([USE_INCLUDED_REGEX], [test "$ac_use_included_regex" = yes])
if test "$ac_use_included_regex" = no; then
AC_MSG_WARN([Included lib/regex.c not used])
+ AC_DEFINE([USE_INCLUDED_REGEX], 1, [building with included regex code])
fi
gl_FUNC_PCRE
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0ef96d4..7718f24 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -46,13 +46,19 @@ LDADD = ../lib/libgreputils.a $(LIBINTL)
../lib/libgreputils.a
# The triple-backref test is expected to fail with both the system
# 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.
+# FIXME-2025: Remove this once the glibc and gnulib bugs are fixed.
XFAIL_TESTS = triple-backref
+# The glibc-infloop test is expected to fail with both the system
+# matcher (i.e., with glibc) and with the included matcher.
+# Both matchers need to be fixed.
+# FIXME-2025: Remove this once the glibc and gnulib bugs are fixed.
+XFAIL_TESTS += glibc-infloop
+
# Equivalence classes are only supported when using the system
# matcher (which means only with glibc).
# The included matcher needs to be fixed.
-# FIXME-2015: Remove this once the gnulib bug is fixed.
+# FIXME-2025: Remove this once the gnulib bug is fixed.
if USE_INCLUDED_REGEX
XFAIL_TESTS += equiv-classes
else
@@ -108,6 +114,7 @@ TESTS = \
fillbuf-long-line \
fmbtest \
foad1 \
+ glibc-infloop \
grep-dev-null \
grep-dev-null-out \
grep-dir \
diff --git a/tests/glibc-infloop b/tests/glibc-infloop
new file mode 100755
index 0000000..cc8dc23
--- /dev/null
+++ b/tests/glibc-infloop
@@ -0,0 +1,30 @@
+#!/bin/sh
+# This would infloop when using glibc's regex at least until glibc-2.36.
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+require_timeout_
+require_en_utf8_locale_
+
+fail=0
+
+cat <<\EOF > glibc-check.c
+#include <features.h>
+#ifdef __GLIBC__
+int ok;
+#else
+# error "not glibc"
+#endif
+EOF
+$CC -c glibc-check.c && glibc=1 || glibc=0
+
+grep '^#define USE_INCLUDED_REGEX 1' "$CONFIG_HEADER" \
+ && included_regex=1 || included_regex=0
+
+case $glibc:$included_regex in
+ 0:0) skip_ 'runs only with glibc or when built with the included regex'
+esac
+
+echo a > in || framework_failure_
+timeout 2 env LC_ALL=en_US.UTF-8 grep -E -w '((()|a)|())*' in || fail=1
+
+Exit $fail
--
2.40.0.166.g140b9478da
>From e4983bd587f318fb185ab8328587453abeee4c65 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@meta.com>
Date: Sun, 9 Apr 2023 20:46:34 -0700
Subject: [PATCH 4/4] build: update gnulib to latest
---
gnulib | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gnulib b/gnulib
index f61570c..217e359 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit f61570c0ef38744c93865172dcbac80e7d4e7b23
+Subproject commit 217e359999ad440f1ea3db44e7d7f6814b050c0d
--
2.40.0.166.g140b9478da
- FYI: four small changes,
Jim Meyering <=