Skip to content

Commit

Permalink
Print the PCRE version
Browse files Browse the repository at this point in the history
Also add PCRE2 to contrib/config.make and config.make-Darwin.

This is a complement to 6f609b1.
  • Loading branch information
koutcher committed Nov 19, 2021
1 parent 15aab28 commit bb605e6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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"
])
])
Expand Down
4 changes: 4 additions & 0 deletions contrib/config.make
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 10 additions & 2 deletions contrib/config.make-Darwin
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,12 +16,20 @@ 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
TIG_LDFLAGS += -L$(READLINE_DIR)/lib
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:
15 changes: 15 additions & 0 deletions src/tig.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
#include <readline/readline.h>
#endif /* HAVE_READLINE */

#if defined HAVE_PCRE2
#include <pcre2.h>
#elif defined HAVE_PCRE
#include <pcre.h>
#endif

static bool
forward_request_to_child(struct view *child, enum request request)
{
Expand Down Expand Up @@ -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",
Expand All @@ -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);

Expand Down

0 comments on commit bb605e6

Please sign in to comment.