Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,48 @@ dnl gnulib will handle getopt and error functions
dnl Check pcre2 availability
AC_MSG_CHECKING([whether PCRE2 support is requested])
AC_ARG_WITH([pcre2],
[AS_HELP_STRING([--with-pcre2],
[use pcre2 regex library @<:@default=check@:>@])],
[AS_HELP_STRING([--with-pcre2@<:@=PATH@:>@],
[use pcre2 regex library, optionally from PATH @<:@default=check@:>@])],
[], [with_pcre2=check])
LIBPCRE2=
AS_IF([test "x$with_pcre2" != xno],
[
AC_MSG_RESULT($with_pcre2)
dnl Handle custom path for PCRE2
AS_IF([test "x$with_pcre2" != xyes && test "x$with_pcre2" != xcheck],
[
dnl Custom path specified
PCRE2_CPPFLAGS="-I$with_pcre2/include"
PCRE2_LDFLAGS="-L$with_pcre2/lib"
save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
CPPFLAGS="$CPPFLAGS $PCRE2_CPPFLAGS"
LDFLAGS="$LDFLAGS $PCRE2_LDFLAGS"
])
AC_CHECK_HEADERS([pcre2posix.h], [], [LIBPCRE2=_missing_header])
AC_CHECK_LIB([pcre2-posix${LIBPCRE2}], [regexec],
[],
[if test "x$with_pcre2" != xcheck; then
AC_MSG_FAILURE(
[--with-pcre2 was given, but test for pcre2-posix failed])
fi]
[
dnl Success - add the flags permanently if custom path was used
AS_IF([test "x$with_pcre2" != xyes && test "x$with_pcre2" != xcheck],
[
CPPFLAGS="$save_CPPFLAGS $PCRE2_CPPFLAGS"
LDFLAGS="$save_LDFLAGS $PCRE2_LDFLAGS"
])
dnl Add the library to LIBS
LIBS="$LIBS -lpcre2-posix${LIBPCRE2}"
],
[
dnl Failure - restore original flags if custom path was used
AS_IF([test "x$with_pcre2" != xyes && test "x$with_pcre2" != xcheck],
[
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
])
if test "x$with_pcre2" != xcheck; then
AC_MSG_FAILURE(
[--with-pcre2 was given, but test for pcre2-posix failed])
fi
]
)
],
AC_MSG_RESULT(no)
Expand Down
9 changes: 7 additions & 2 deletions doc/patchutils.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2266,7 +2266,10 @@ will pipe patch of file #2 to vim - -R
<para>The regular expression is treated as POSIX Basic Regular
Expression syntax, unless the <option>-E</option> option is
given in which case POSIX Extended Regular Expression syntax
is used.</para>
is used. When compiled with PCRE2 support, PCRE regular expressions
are used instead of POSIX regular expressions, and the <option>-E</option>
option has no effect since PCRE already supports extended regular
expression features by default.</para>

<para>For example, to see the patches in
<filename>my.patch</filename> which contain the regular
Expand Down Expand Up @@ -2497,7 +2500,9 @@ will pipe patch of file #2 to vim - -R
<option>--extended-regexp</option></term>
<listitem>
<para>Use POSIX Extended Regular Expression
syntax.</para>
syntax. Note: when compiled with PCRE2 support, this option
has no effect as PCRE regular expressions are used by default
and already support extended regular expression features.</para>
</listitem>
</varlistentry>

Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ LIBGNU_LIBDEPS =
LIBGNU_LTLIBDEPS =
LIBINTL =
LIBOBJS =
LIBS = -lpcre2-posix
LIBS = -lpcre2-posix
LIMITS_H = limits.h
LN_S = ln -s
LOCALENAME_ENHANCE_LOCALE_FUNCS = 0
Expand Down
4 changes: 4 additions & 0 deletions src/filterdiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,11 @@ const char * syntax_str =
" -v, --verbose\n"
" verbose output -- use more than once for extra verbosity\n"
" -E, --extended-regexp (grepdiff)\n"
#ifdef HAVE_PCRE2POSIX_H
" this option has no effect as PCRE regexes are used by default (grepdiff)\n"
#else
" use extended regexps, like egrep (grepdiff)\n"
#endif
" -E, --empty-files-as-absent (lsdiff)\n"
" treat empty files as absent (lsdiff)\n"
" -f FILE, --file=FILE (grepdiff)\n"
Expand Down
27 changes: 27 additions & 0 deletions tests/grepdiff-pcre2-extended/run-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# Test for PCRE2 extended regexp functionality (GitHub issue #60)

. ${top_srcdir-.}/tests/common.sh

# Create a simple test diff with both patterns
cat << EOF > diff
--- file1
+++ file1
@@ -1,2 +1,3 @@
context
-old
+landblockelim
+blockall
EOF

# Test extended regexp pattern with -E flag
${GREPDIFF} -E 'landblockelim|blockall' diff 2>errors >output || exit 1

[ -s errors ] && exit 1

# Verify both patterns are found
if ! grep -q "file1" output; then
echo "ERROR: Extended regexp pattern failed to match"
exit 1
fi