From bb605e68d4945f2f8667babaf09da26333f8b605 Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Fri, 19 Nov 2021 22:25:32 +0100 Subject: [PATCH] Print the PCRE version Also add PCRE2 to contrib/config.make and config.make-Darwin. This is a complement to 6f609b193844ffe8a2287d0846c52d74bd6b83db. --- configure.ac | 1 + contrib/config.make | 4 ++++ contrib/config.make-Darwin | 12 ++++++++++-- src/tig.c | 15 +++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index ba03e5028..cf55c658f 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,7 @@ AS_IF([test "x$with_pcre" != xno], [ AS_IF([test "x$ac_cv_header_pcre2posix_h" = xyes], [ AC_CHECK_LIB([pcre2-posix], [regexec], [ AC_DEFINE([HAVE_PCRE2], [1], [Define if you have PCRE2]) + AC_DEFINE([PCRE2_CODE_UNIT_WIDTH], [8], [ ]) LIBS="$LIBS -lpcre2-posix -lpcre2-8" ]) ]) diff --git a/contrib/config.make b/contrib/config.make index b2adda8fb..e656a3660 100755 --- a/contrib/config.make +++ b/contrib/config.make @@ -11,6 +11,10 @@ CPPFLAGS = -DHAVE_NCURSESW_CURSES_H #LDLIBS += -lreadline #CPPFLAGS += -DHAVE_READLINE +# Use PCRE2. +#LDLIBS += -lpcre2-posix -lpcre2-8 +#CPPFLAGS += -DHAVE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 + # Uncomment to enable work-around for missing setenv(). #NO_SETENV=y diff --git a/contrib/config.make-Darwin b/contrib/config.make-Darwin index b08ed0a9d..95055dc12 100644 --- a/contrib/config.make-Darwin +++ b/contrib/config.make-Darwin @@ -6,7 +6,7 @@ export XML_CATALOG_FILES=/usr/local/etc/xml/catalog TIG_CFLAGS += -DHAVE_EXECINFO_H TIG_LDLIBS = -liconv -NCURSES_DIR = $(wildcard /usr/local/opt/ncurses) +NCURSES_DIR ?= $(wildcard /usr/local/opt/ncurses) ifneq ($(NCURSES_DIR),) TIG_NCURSES = -lncursesw @@ -16,7 +16,7 @@ else TIG_CPPFLAGS += -DHAVE_CURSES_H endif -READLINE_DIR = $(wildcard /usr/local/opt/readline) +READLINE_DIR ?= $(wildcard /usr/local/opt/readline) ifneq ($(READLINE_DIR),) TIG_LDLIBS += -lreadline @@ -24,4 +24,12 @@ ifneq ($(READLINE_DIR),) TIG_CPPFLAGS += -I$(READLINE_DIR)/include -DHAVE_READLINE endif +PCRE2_DIR ?= $(wildcard /usr/local/opt/pcre2) + +ifneq ($(PCRE2_DIR),) + TIG_LDLIBS += -lpcre2-posix -lpcre2-8 + TIG_LDFLAGS += -L$(PCRE2_DIR)/lib + TIG_CPPFLAGS += -I$(PCRE2_DIR)/include -DHAVE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 +endif + # vim: ft=make: diff --git a/src/tig.c b/src/tig.c index 1c332f526..c6b107536 100644 --- a/src/tig.c +++ b/src/tig.c @@ -54,6 +54,12 @@ #include #endif /* HAVE_READLINE */ +#if defined HAVE_PCRE2 +#include +#elif defined HAVE_PCRE +#include +#endif + static bool forward_request_to_child(struct view *child, enum request request) { @@ -542,6 +548,9 @@ parse_options(int argc, const char *argv[], bool pager_mode) seen_dashdash = true; } else if (!strcmp(opt, "-v") || !strcmp(opt, "--version")) { +#if defined HAVE_PCRE2 + char pcre2_version[64]; +#endif printf("tig version %s\n", TIG_VERSION); #ifdef NCURSES_VERSION printf("%s version %s.%d\n", @@ -554,6 +563,12 @@ parse_options(int argc, const char *argv[], bool pager_mode) #endif #ifdef HAVE_READLINE printf("readline version %s\n", rl_library_version); +#endif +#if defined HAVE_PCRE2 + pcre2_config(PCRE2_CONFIG_VERSION, pcre2_version); + printf("PCRE2 version %s\n", pcre2_version); +#elif defined HAVE_PCRE + printf("PCRE version %s\n", pcre_version()); #endif exit(EXIT_SUCCESS);