grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v3.10-9-gfd2d0f7


From: Paul Eggert
Subject: grep branch, master, updated. v3.10-9-gfd2d0f7
Date: Mon, 10 Apr 2023 19:16:14 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  fd2d0f7165d390ce4b4d08acf25552f6635d9ecb (commit)
      from  3b15d738978fb5e4a865f5f6e99a08e8fc840948 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=fd2d0f7165d390ce4b4d08acf25552f6635d9ecb


commit fd2d0f7165d390ce4b4d08acf25552f6635d9ecb
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 10 11:31:58 2023 -0700

    grep: improve PCRE2 version output
    
    * src/grep.c: No need to include pcre2.h.
    (main) [HAVE_LIBPCRE]: Call Pprint_version instead of
    doing it ourselves.
    * src/pcresearch.c (Pprint_version): New function.
    It also checks belatedly for buffer overflow, and
    says "grep -P uses PCRE2" instead of "Built with PCRE".
    * tests/version-pcre: Adjust test to match.

diff --git a/NEWS b/NEWS
index 029aaf1..3fdf4fe 100644
--- a/NEWS
+++ b/NEWS
@@ -18,9 +18,9 @@ GNU grep NEWS                                    -*- outline 
-*-
 
   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
+    grep -P uses PCRE2 10.43-DEV 2023-01-15
   or this with what's currently available in Fedora 37:
-    Built with PCRE 10.40 2022-04-14
+    grep -P uses PCRE2 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 bd776e8..491dd02 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -29,11 +29,6 @@
 #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"
@@ -2836,10 +2831,7 @@ main (int argc, char **argv)
       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);
+      Pprint_version ();
 #endif
       return EXIT_SUCCESS;
     }
diff --git a/src/pcresearch.c b/src/pcresearch.c
index e77509c..9e2f393 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -74,6 +74,15 @@ private_free (void *ptr, _GL_UNUSED void *unused)
   free (ptr);
 }
 
+void
+Pprint_version (void)
+{
+  char buf[128];
+  if (sizeof buf <= pcre2_config (PCRE2_CONFIG_VERSION, buf))
+    abort ();
+  printf (_("\ngrep -P uses PCRE2 %s\n"), buf);
+}
+
 /* Match the already-compiled PCRE pattern against the data in SUBJECT,
    of size SEARCH_BYTES and starting with offset SEARCH_OFFSET, with
    options OPTIONS.
diff --git a/src/search.h b/src/search.h
index 61d6562..ebb9d07 100644
--- a/src/search.h
+++ b/src/search.h
@@ -65,6 +65,7 @@ extern ptrdiff_t Fexecute (void *, char const *, idx_t, idx_t 
*, char const *);
 /* pcresearch.c */
 extern void *Pcompile (char *, idx_t, reg_syntax_t, bool);
 extern ptrdiff_t Pexecute (void *, char const *, idx_t, idx_t *, char const *);
+extern void Pprint_version (void);
 
 /* grep.c */
 extern struct localeinfo localeinfo;
diff --git a/tests/version-pcre b/tests/version-pcre
index d18daa6..c7bb182 100755
--- a/tests/version-pcre
+++ b/tests/version-pcre
@@ -12,4 +12,4 @@
 grep -q '^#define HAVE_LIBPCRE 1' "$CONFIG_HEADER" \
   || skip_ 'built without PCRE support'
 
-grep --version | grep -qP '^Built with PCRE [\d.]+'
+grep --version | grep -qP '^grep -P uses PCRE2 [\d.]+'

-----------------------------------------------------------------------

Summary of changes:
 NEWS               |  4 ++--
 src/grep.c         | 10 +---------
 src/pcresearch.c   |  9 +++++++++
 src/search.h       |  1 +
 tests/version-pcre |  2 +-
 5 files changed, 14 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]