Ticket #4450: support PCRE2 in the search engine.

* m4.include/ax_path_lib_pcre.m4: replace by recent version from GNU
Autoconf Archive.
  * m4.include/ax_check_pcre2.m4: get grom GNU Autoconf Archive.
  * m4.include/mc-check-search-type.m4: support both PCRE versions.
  * */*/Makefile.am: remove @CHECK_CFLAGS@ and @PCRE_LIBS@ ads they are
added via AX_PATH_LIB_PCRE and AX_CHECK_PCRE2.
  * lib/search.h, lib/search/: add support of PCRE2. Thanks broly <gagan@hotmail.com>
for the initial patch.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2023-03-22 21:50:11 +03:00
parent be3822cafa
commit 49624e473b
21 changed files with 311 additions and 87 deletions

View File

@ -66,6 +66,9 @@ Anton Chumak <nightfast@yahoo.co.uk>
Antonio Palama, DOS port <palama@posso.dm.unipi.it> Antonio Palama, DOS port <palama@posso.dm.unipi.it>
DOS port. DOS port.
broly <gagan@hotmail.com>
Support of PCRE2
Dmitry Koterov <dmitry.koterov@gmail.com> Dmitry Koterov <dmitry.koterov@gmail.com>
s3 extfs bugfixes and improvements s3 extfs bugfixes and improvements

View File

@ -6,6 +6,7 @@ m4_include([m4.include/gnulib/mountlist.m4])
m4_include([m4.include/gnulib/windows-stat-inodes.m4]) m4_include([m4.include/gnulib/windows-stat-inodes.m4])
m4_include([m4.include/gnulib/sys_types_h.m4]) m4_include([m4.include/gnulib/sys_types_h.m4])
m4_include([m4.include/ax_path_lib_pcre.m4]) m4_include([m4.include/ax_path_lib_pcre.m4])
m4_include([m4.include/ax_check_pcre2.m4])
m4_include([m4.include/dx_doxygen.m4]) m4_include([m4.include/dx_doxygen.m4])
m4_include([m4.include/ax_require_defined.m4]) m4_include([m4.include/ax_require_defined.m4])
m4_include([m4.include/ax_check_compile_flag.m4]) m4_include([m4.include/ax_check_compile_flag.m4])

View File

@ -375,8 +375,7 @@ Newer versions may work, but haven't been tested.
PCRE PCRE
---- ----
If the version of glib you have installed is older than 2.14.x, then you Both PCRE and PCRE2 libraries are supported.
also need to install PCRE library.
You can get PCRE from You can get PCRE from

View File

@ -73,5 +73,3 @@ if HAVE_GMODULE
else else
libmc_la_LIBADD += $(GLIB_LIBS) libmc_la_LIBADD += $(GLIB_LIBS)
endif endif
libmc_la_LIBADD += $(PCRE_LIBS)

View File

@ -6,4 +6,4 @@ libmcfilehighlight_la_SOURCES = \
ini-file-read.c \ ini-file-read.c \
internal.h internal.h
AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CPPFLAGS) AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS)

View File

@ -8,9 +8,13 @@
#include <sys/types.h> #include <sys/types.h>
#ifdef SEARCH_TYPE_PCRE #ifdef SEARCH_TYPE_PCRE
#ifdef HAVE_PCRE2
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#else
#include <pcre.h> #include <pcre.h>
#endif #endif
#endif /* SEARCH_TYPE_PCRE */
/*** typedefs(not structures) and defined constants **********************************************/ /*** typedefs(not structures) and defined constants **********************************************/
typedef enum mc_search_cbret_t mc_search_cbret_t; typedef enum mc_search_cbret_t mc_search_cbret_t;
@ -24,8 +28,15 @@ typedef mc_search_cbret_t (*mc_update_fn) (const void *user_data, gsize char_off
#ifdef SEARCH_TYPE_GLIB #ifdef SEARCH_TYPE_GLIB
#define mc_search_matchinfo_t GMatchInfo #define mc_search_matchinfo_t GMatchInfo
#else #else
#ifdef HAVE_PCRE2
/* no pcre_extra in PCRE2. pcre2_jit_compile (equivalent of pcre_study) handles
* all of this internally. but we can use this to hold the pcre2_matches data
* until the search is complete */
#define mc_search_matchinfo_t pcre2_match_data
#else
#define mc_search_matchinfo_t pcre_extra #define mc_search_matchinfo_t pcre_extra
#endif #endif
#endif
/*** enums ***************************************************************************************/ /*** enums ***************************************************************************************/
@ -102,7 +113,12 @@ typedef struct mc_search_struct
mc_search_matchinfo_t *regex_match_info; mc_search_matchinfo_t *regex_match_info;
GString *regex_buffer; GString *regex_buffer;
#ifdef SEARCH_TYPE_PCRE #ifdef SEARCH_TYPE_PCRE
#ifdef HAVE_PCRE2
/* pcre2 will provide a pointer to a match_data structure that can be manipulated like an iovector*/
size_t *iovector;
#else
int iovector[MC_SEARCH__NUM_REPLACE_ARGS * 2]; int iovector[MC_SEARCH__NUM_REPLACE_ARGS * 2];
#endif
#endif /* SEARCH_TYPE_PCRE */ #endif /* SEARCH_TYPE_PCRE */
/* private data */ /* private data */

View File

@ -9,4 +9,4 @@ libsearch_la_SOURCES = \
glob.c \ glob.c \
hex.c hex.c
AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CPPFLAGS) AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS)

View File

@ -6,8 +6,12 @@
#ifdef SEARCH_TYPE_GLIB #ifdef SEARCH_TYPE_GLIB
#define mc_search_regex_t GRegex #define mc_search_regex_t GRegex
#else #else
#ifdef HAVE_PCRE2
#define mc_search_regex_t pcre2_code
#else
#define mc_search_regex_t pcre #define mc_search_regex_t pcre
#endif #endif
#endif
/*** enums ***************************************************************************************/ /*** enums ***************************************************************************************/

View File

@ -345,9 +345,15 @@ mc_search__regex_found_cond_one (mc_search_t * lc_mc_search, mc_search_regex_t *
} }
lc_mc_search->num_results = g_match_info_get_match_count (lc_mc_search->regex_match_info); lc_mc_search->num_results = g_match_info_get_match_count (lc_mc_search->regex_match_info);
#else /* SEARCH_TYPE_GLIB */ #else /* SEARCH_TYPE_GLIB */
lc_mc_search->num_results = pcre_exec (regex, lc_mc_search->regex_match_info,
search_str->str, search_str->len, 0, 0, lc_mc_search->num_results =
lc_mc_search->iovector, MC_SEARCH__NUM_REPLACE_ARGS); #ifdef HAVE_PCRE2
pcre2_match (regex, (unsigned char *) search_str->str, search_str->len, 0, 0,
lc_mc_search->regex_match_info, NULL);
#else
pcre_exec (regex, lc_mc_search->regex_match_info, search_str->str, search_str->len, 0, 0,
lc_mc_search->iovector, MC_SEARCH__NUM_REPLACE_ARGS);
#endif
if (lc_mc_search->num_results < 0) if (lc_mc_search->num_results < 0)
{ {
return COND__NOT_FOUND; return COND__NOT_FOUND;
@ -835,15 +841,29 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_
return; return;
} }
#else /* SEARCH_TYPE_GLIB */ #else /* SEARCH_TYPE_GLIB */
#ifdef HAVE_PCRE2
int errcode;
char error[BUF_SMALL];
size_t erroffset;
int pcre_options = PCRE2_MULTILINE;
#else
const char *error; const char *error;
int erroffset; int erroffset;
int pcre_options = PCRE_EXTRA | PCRE_MULTILINE; int pcre_options = PCRE_EXTRA | PCRE_MULTILINE;
#endif
if (str_isutf8 (charset) && mc_global.utf8_display) if (str_isutf8 (charset) && mc_global.utf8_display)
{ {
#ifdef HAVE_PCRE2
pcre_options |= PCRE2_UTF;
if (!lc_mc_search->is_case_sensitive)
pcre_options |= PCRE2_CASELESS;
#else
pcre_options |= PCRE_UTF8; pcre_options |= PCRE_UTF8;
if (!lc_mc_search->is_case_sensitive) if (!lc_mc_search->is_case_sensitive)
pcre_options |= PCRE_CASELESS; pcre_options |= PCRE_CASELESS;
#endif
} }
else if (!lc_mc_search->is_case_sensitive) else if (!lc_mc_search->is_case_sensitive)
{ {
@ -855,14 +875,26 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * lc_mc_
} }
mc_search_cond->regex_handle = mc_search_cond->regex_handle =
#ifdef HAVE_PCRE2
pcre2_compile ((unsigned char *) mc_search_cond->str->str, PCRE2_ZERO_TERMINATED,
pcre_options, &errcode, &erroffset, NULL);
#else
pcre_compile (mc_search_cond->str->str, pcre_options, &error, &erroffset, NULL); pcre_compile (mc_search_cond->str->str, pcre_options, &error, &erroffset, NULL);
#endif
if (mc_search_cond->regex_handle == NULL) if (mc_search_cond->regex_handle == NULL)
{ {
#ifdef HAVE_PCRE2
pcre2_get_error_message (errcode, (unsigned char *) error, sizeof (error));
#endif
mc_search_set_error (lc_mc_search, MC_SEARCH_E_REGEX_COMPILE, "%s", error); mc_search_set_error (lc_mc_search, MC_SEARCH_E_REGEX_COMPILE, "%s", error);
return; return;
} }
#ifdef HAVE_PCRE2
if (pcre2_jit_compile (mc_search_cond->regex_handle, PCRE2_JIT_COMPLETE) && *error != '\0')
#else
lc_mc_search->regex_match_info = pcre_study (mc_search_cond->regex_handle, 0, &error); lc_mc_search->regex_match_info = pcre_study (mc_search_cond->regex_handle, 0, &error);
if (lc_mc_search->regex_match_info == NULL && error != NULL) if (lc_mc_search->regex_match_info == NULL && error != NULL)
#endif
{ {
mc_search_set_error (lc_mc_search, MC_SEARCH_E_REGEX_COMPILE, "%s", error); mc_search_set_error (lc_mc_search, MC_SEARCH_E_REGEX_COMPILE, "%s", error);
MC_PTR_FREE (mc_search_cond->regex_handle); MC_PTR_FREE (mc_search_cond->regex_handle);

View File

@ -71,7 +71,10 @@ mc_search__cond_struct_new (mc_search_t * lc_mc_search, const GString * str, con
mc_search_cond = g_malloc0 (sizeof (mc_search_cond_t)); mc_search_cond = g_malloc0 (sizeof (mc_search_cond_t));
mc_search_cond->str = mc_g_string_dup (str); mc_search_cond->str = mc_g_string_dup (str);
mc_search_cond->charset = g_strdup (charset); mc_search_cond->charset = g_strdup (charset);
#ifdef HAVE_PCRE2
lc_mc_search->regex_match_info = pcre2_match_data_create (MC_SEARCH__NUM_REPLACE_ARGS, NULL);
lc_mc_search->iovector = pcre2_get_ovector_pointer (lc_mc_search->regex_match_info);
#endif
switch (lc_mc_search->search_type) switch (lc_mc_search->search_type)
{ {
case MC_SEARCH_T_GLOB: case MC_SEARCH_T_GLOB:

View File

@ -0,0 +1,163 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_check_pcre2.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_PCRE2([bits], [action-if-found], [action-if-not-found])
#
# DESCRIPTION
#
# Search for an installed libpcre2-8 library. If nothing was specified
# when calling configure, it searches first in /usr/local and then in
# /usr, /opt/local and /sw. If the --with-pcre2=DIR is specified, it will
# try to find it in DIR/include/pcre2.h and DIR/lib/libpcre2-8. If
# --without-pcre2 is specified, the library is not searched at all.
#
# If 'bits' is empty or '8', PCRE2 8-bit character support is checked
# only. If 'bits' contains '16', PCRE2 8-bit and 16-bit character support
# are checked. If 'bits' contains '32', PCRE2 8-bit and 32-bit character
# support are checked. When 'bits' contains both '16' and '32', PCRE2
# 8-bit, 16-bit, and 32-bit character support is checked.
#
# If either the header file (pcre2.h), or the library (libpcre2-8) is not
# found, or the specified PCRE2 character bit width is not supported,
# shell commands 'action-if-not-found' is run. If 'action-if-not-found' is
# not specified, the configuration exits on error, asking for a valid
# PCRE2 installation directory or --without-pcre2.
#
# If both header file and library are found, and the specified PCRE2 bit
# widths are supported, shell commands 'action-if-found' is run. If
# 'action-if-found' is not specified, the default action appends
# '-I${PCRE2_HOME}/include' to CPFLAGS, appends '-L$PCRE2_HOME}/lib' to
# LDFLAGS, prepends '-lpcre2-8' to LIBS, and calls AC_DEFINE(HAVE_PCRE2).
# You should use autoheader to include a definition for this symbol in a
# config.h file. Sample usage in a C/C++ source is as follows:
#
# #ifdef HAVE_PCRE2
# #define PCRE2_CODE_UNIT_WIDTH 8
# #include <pcre2.h>
# #endif /* HAVE_PCRE2 */
#
# LICENSE
#
# Copyright (c) 2020 Robert van Engelen <engelen@acm.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 2
AC_DEFUN([AX_CHECK_PCRE2],
#
# Handle user hints
#
[AC_MSG_CHECKING(if PCRE2 is wanted)
pcre2_places="/usr/local /usr /opt/local /sw"
AC_ARG_WITH([pcre2],
[ --with-pcre2=DIR root directory path of PCRE2 installation @<:@defaults to
/usr/local or /usr if not found in /usr/local@:>@
--without-pcre2 to disable PCRE2 usage completely],
[if test "$withval" != "no" ; then
AC_MSG_RESULT(yes)
if test -d "$withval"
then
pcre2_places="$withval $pcre2_places"
else
AC_MSG_WARN([Sorry, $withval does not exist, checking usual places])
fi
else
pcre2_places=""
AC_MSG_RESULT(no)
fi],
[AC_MSG_RESULT(yes)])
#
# Locate PCRE2, if wanted
#
if test -n "${pcre2_places}"
then
# check the user supplied or any other more or less 'standard' place:
# Most UNIX systems : /usr/local and /usr
# MacPorts / Fink on OSX : /opt/local respectively /sw
for PCRE2_HOME in ${pcre2_places} ; do
if test -f "${PCRE2_HOME}/include/pcre2.h"; then break; fi
PCRE2_HOME=""
done
PCRE2_OLD_LDFLAGS=$LDFLAGS
PCRE2_OLD_CPPFLAGS=$CPPFLAGS
if test -n "${PCRE2_HOME}"; then
LDFLAGS="$LDFLAGS -L${PCRE2_HOME}/lib"
CPPFLAGS="$CPPFLAGS -I${PCRE2_HOME}/include"
fi
AC_LANG_PUSH([C])
AC_CHECK_LIB([pcre2-8], [pcre2_compile_8], [pcre2_cv_libpcre2=yes], [pcre2_cv_libpcre2=no])
AC_CHECK_HEADER([pcre2.h], [pcre2_cv_pcre2_h=yes], [pcre2_cv_pcre2_h=no], [#define PCRE2_CODE_UNIT_WIDTH 8])
case "$1" in
*16*)
AC_CHECK_LIB([pcre2-16], [pcre2_compile_16], [pcre2_cv_libpcre2_16=yes], [pcre2_cv_libpcre2_16=no])
AC_CHECK_HEADER([pcre2.h], [pcre2_cv_pcre2_16_h=yes], [pcre2_cv_pcre2_16_h=no], [#define PCRE2_CODE_UNIT_WIDTH 16])
if test "$pcre2_cv_libpcre2_16" = "no" || test "$pcre2_cv_pcre2_16_h" = "no"; then
pcre2_cv_libpcre2=no
fi
;;
esac
case "$1" in
*32*)
AC_CHECK_LIB([pcre2-32], [pcre2_compile_32], [pcre2_cv_libpcre2_32=yes], [pcre2_cv_libpcre2_32=no])
AC_CHECK_HEADER([pcre2.h], [pcre2_cv_pcre2_32_h=yes], [pcre2_cv_pcre2_32_h=no], [#define PCRE2_CODE_UNIT_WIDTH 32])
if test "$pcre2_cv_libpcre2_32" = "no" || test "$pcre2_cv_pcre2_32_h" = "no"; then
pcre2_cv_libpcre2=no
fi
esac
AC_LANG_POP([C])
if test "$pcre2_cv_libpcre2" = "yes" && test "$pcre2_cv_pcre2_h" = "yes"
then
#
# If both library and header were found, action-if-found
#
m4_ifblank([$2],[
CPPFLAGS="$CPPFLAGS -I${PCRE2_HOME}/include"
LDFLAGS="$LDFLAGS -L${PCRE2_HOME}/lib"
LIBS="-lpcre2-8 $LIBS"
AC_DEFINE([HAVE_PCRE2], [1],
[Define to 1 if you have `PCRE2' library (-lpcre2-$1)])
],[
# Restore variables
LDFLAGS="$PCRE2_OLD_LDFLAGS"
CPPFLAGS="$PCRE2_OLD_CPPFLAGS"
$2
])
else
#
# If either header or library was not found, action-if-not-found
#
m4_default([$3],[
AC_MSG_ERROR([either specify a valid PCRE2 installation with --with-pcre2=DIR or disable PCRE2 usage with --without-pcre2])
])
fi
fi
])

View File

@ -1,51 +1,59 @@
dnl @synopsis AX_PATH_LIB_PCRE [(A/NA)] # ===========================================================================
dnl # https://www.gnu.org/software/autoconf-archive/ax_path_lib_pcre.html
dnl check for pcre lib and set PCRE_LIBS and PCRE_CPPFLAGS accordingly. # ===========================================================================
dnl #
dnl also provide --with-pcre option that may point to the $prefix of # SYNOPSIS
dnl the pcre installation - the macro will check $pcre/include and #
dnl $pcre/lib to contain the necessary files. # AX_PATH_LIB_PCRE [(A/NA)]
dnl #
dnl the usual two ACTION-IF-FOUND / ACTION-IF-NOT-FOUND are supported # DESCRIPTION
dnl and they can take advantage of the LIBS/CFLAGS additions. #
dnl # check for pcre lib and set PCRE_LIBS and PCRE_CFLAGS accordingly.
dnl @author Guido U. Draheim <guidod@gmx.de> #
dnl @author Slava Zanko <slavazanko@gmail.com> # also provide --with-pcre option that may point to the $prefix of the
dnl @version 2009-07-06 # pcre installation - the macro will check $pcre/include and $pcre/lib to
dnl @license GPLWithACException # contain the necessary files.
#
# the usual two ACTION-IF-FOUND / ACTION-IF-NOT-FOUND are supported and
# they can take advantage of the LIBS/CFLAGS additions.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
#
# 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. This file is offered as-is, without any
# warranty.
#serial 9
AC_DEFUN([AX_PATH_LIB_PCRE],[dnl AC_DEFUN([AX_PATH_LIB_PCRE],[dnl
AC_MSG_CHECKING([lib pcre]) AC_MSG_CHECKING([lib pcre])
AC_ARG_WITH([pcre], AC_ARG_WITH(pcre,
AS_HELP_STRING([--with-pcre@<:@=prefix@:>@], [Compile pcre part (via libpcre check)]), [ --with-pcre[[=prefix]] compile xmlpcre part (via libpcre check)],,
, with_pcre="yes")
[with_pcre="yes"] if test ".$with_pcre" = ".no" ; then
)
if test x"$with_pcre" = "xno" ; then
AC_MSG_RESULT([disabled]) AC_MSG_RESULT([disabled])
m4_ifval($2,$2) m4_ifval($2,$2)
else else
AC_MSG_RESULT([(testing)]) AC_MSG_RESULT([(testing)])
AC_CHECK_LIB(pcre, pcre_study)
if test "x$with_pcre" = "xyes" ; then if test "$ac_cv_lib_pcre_pcre_study" = "yes" ; then
PCRE_CPPFLAGS="`pcre-config --cflags`" PCRE_LIBS="-lpcre"
PCRE_LIBS="`pcre-config --libs`" AC_MSG_CHECKING([lib pcre])
AC_MSG_RESULT([$PCRE_LIBS])
m4_ifval($1,$1)
else else
test_PCRE_LIBS="-L$with_pcre/lib" OLDLDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$with_pcre/lib"
test_PCRE_CPPFLAGS="-I$with_pcre/include" OLDCPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$with_pcre/include"
OLDLDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $test_PCRE_LIBS"
OLDCPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $test_PCRE_CPPFLAGS"
AC_CHECK_LIB(pcre, pcre_compile) AC_CHECK_LIB(pcre, pcre_compile)
CPPFLAGS="$OLDCPPFLAGS"
if test x"$ac_cv_lib_pcre_pcre_compile" = x"yes" ; then LDFLAGS="$OLDLDFLAGS"
AC_MSG_RESULT(setting PCRE_LIBS -L$with_pcre/lib -lpcre) if test "$ac_cv_lib_pcre_pcre_compile" = "yes" ; then
AC_MSG_RESULT(.setting PCRE_LIBS -L$with_pcre/lib -lpcre)
PCRE_LIBS=$test_PCRE_LIBS PCRE_LIBS="-L$with_pcre/lib -lpcre"
PCRE_CPPFLAGS=$test_PCRE_CPPFLAGS test -d "$with_pcre/include" && PCRE_CFLAGS="-I$with_pcre/include"
AC_MSG_CHECKING([lib pcre]) AC_MSG_CHECKING([lib pcre])
AC_MSG_RESULT([$PCRE_LIBS]) AC_MSG_RESULT([$PCRE_LIBS])
m4_ifval($1,$1) m4_ifval($1,$1)
@ -54,14 +62,8 @@ else
AC_MSG_RESULT([no, (WARNING)]) AC_MSG_RESULT([no, (WARNING)])
m4_ifval($2,$2) m4_ifval($2,$2)
fi fi
CPPFLAGS="$OLDCFPPLAGS"
LDFLAGS="$OLDLDFLAGS"
fi fi
fi fi
AC_SUBST([PCRE_LIBS]) AC_SUBST([PCRE_LIBS])
AC_SUBST([PCRE_CPPFLAGS]) AC_SUBST([PCRE_CFLAGS])
]) ])

View File

@ -3,28 +3,30 @@ dnl
dnl Check search type in mc. Currently used glib-regexp or pcre dnl Check search type in mc. Currently used glib-regexp or pcre
dnl dnl
dnl @author Slava Zanko <slavazanko@gmail.com> dnl @author Slava Zanko <slavazanko@gmail.com>
dnl @version 2009-06-19 dnl @author Andrew Borodin <aborodin@vmail.ru>
dnl @version 2023-03-22
dnl @license GPL dnl @license GPL
dnl @copyright Free Software Foundation, Inc. dnl @copyright Free Software Foundation, Inc.
AC_DEFUN([mc_CHECK_SEARCH_TYPE_PCRE],[ AC_DEFUN([mc_CHECK_SEARCH_TYPE_PCRE],[
AX_PATH_LIB_PCRE AX_PATH_LIB_PCRE
if test x"${PCRE_LIBS}" = x; then if test x"${PCRE_LIBS}" = x; then
AC_MSG_ERROR([Your system don't have pcre library (or pcre devel stuff)]) AC_MSG_ERROR([$1])
else
SEARCH_TYPE="pcre"
AC_DEFINE(SEARCH_TYPE_PCRE, 1, [Define to select 'pcre' search type])
fi fi
SEARCH_TYPE="pcre"
]) ])
AC_DEFUN([mc_CHECK_SEARCH_TYPE_PCRE2],[
AX_CHECK_PCRE2([8], [], [:])
AC_DEFUN([mc_CHECK_SEARCH_TYPE_GLIB],[ if test $pcre2_cv_libpcre2 = yes; then
$PKG_CONFIG --max-version 2.14 glib-2.0 SEARCH_TYPE="pcre2"
if test $? -eq 0; then
AC_MSG_RESULT([[Selected 'glib' search engine, but you don't have glib >= 2.14. Trying to use 'pcre' engine], (WARNING)])
mc_CHECK_SEARCH_TYPE_PCRE
else else
AC_DEFINE(SEARCH_TYPE_GLIB, 1, [Define to select 'glib-regexp' search type]) dnl pcre2 not found -- try pcre
AC_MSG_WARN([Cannot find pcre2 library, trying pcre one...])
mc_CHECK_SEARCH_TYPE_PCRE([$1])
fi fi
]) ])
@ -33,14 +35,18 @@ AC_DEFUN([mc_CHECK_SEARCH_TYPE],[
AC_ARG_WITH([search-engine], AC_ARG_WITH([search-engine],
AS_HELP_STRING([--with-search-engine=type], AS_HELP_STRING([--with-search-engine=type],
[Select low-level search engine (since glib >= 2.14) @<:@glib|pcre@:>@]) [Select low-level search engine @<:@glib|pcre|pcre2@:>@])
) )
case x$with_search_engine in case x$with_search_engine in
xglib) xglib)
SEARCH_TYPE="glib-regexp" SEARCH_TYPE="glib-regexp"
;; ;;
xpcre) xpcre)
mc_CHECK_SEARCH_TYPE_PCRE mc_CHECK_SEARCH_TYPE_PCRE([Cannot find pcre library])
;;
xpcre2)
mc_CHECK_SEARCH_TYPE_PCRE2([Neither pcre2 nor pcre library found!])
;; ;;
x) x)
SEARCH_TYPE="glib-regexp" SEARCH_TYPE="glib-regexp"
@ -51,6 +57,8 @@ AC_DEFUN([mc_CHECK_SEARCH_TYPE],[
esac esac
if test x"$SEARCH_TYPE" = x"glib-regexp"; then if test x"$SEARCH_TYPE" = x"glib-regexp"; then
mc_CHECK_SEARCH_TYPE_GLIB AC_DEFINE(SEARCH_TYPE_GLIB, 1, [Define to select 'glib-regexp' search type])
else
AC_DEFINE(SEARCH_TYPE_PCRE, 1, [Define to select 'pcre2' or 'pcre' search type])
fi fi
]) ])

View File

@ -5,4 +5,4 @@ libdiffviewer_la_SOURCES = \
search.c \ search.c \
ydiff.c ydiff.h ydiff.c ydiff.h
AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CPPFLAGS) AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS)

View File

@ -30,4 +30,4 @@ libedit_la_SOURCES += \
endif endif
endif endif
AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CPPFLAGS) AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)

View File

@ -30,7 +30,7 @@ libmcfilemanager_la_SOURCES = \
# Unmaintained, unsupported, etc # Unmaintained, unsupported, etc
# listmode.c listmode.h # listmode.c listmode.h
AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CPPFLAGS) AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS)
if ENABLE_EXT2FS_ATTR if ENABLE_EXT2FS_ATTR
libmcfilemanager_la_SOURCES += \ libmcfilemanager_la_SOURCES += \

View File

@ -1,5 +1,5 @@
AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(LIBSSH_CFLAGS) $(PCRE_CPPFLAGS) AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(LIBSSH_CFLAGS)
noinst_LTLIBRARIES = libvfs-sftpfs.la noinst_LTLIBRARIES = libvfs-sftpfs.la

View File

@ -18,4 +18,4 @@ libmcviewer_la_SOURCES = \
nroff.c \ nroff.c \
search.c search.c
AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(PCRE_CPPFLAGS) AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS)

View File

@ -4,11 +4,10 @@ AM_CPPFLAGS = \
$(GLIB_CFLAGS) \ $(GLIB_CFLAGS) \
-I$(top_srcdir) \ -I$(top_srcdir) \
-I$(top_srcdir)/lib/search \ -I$(top_srcdir)/lib/search \
@CHECK_CFLAGS@ \ @CHECK_CFLAGS@
@PCRE_CPPFLAGS@
LIBS = @CHECK_LIBS@ \ LIBS = @CHECK_LIBS@ \
$(top_builddir)/lib/libmc.la @PCRE_LIBS@ $(top_builddir)/lib/libmc.la
if ENABLE_MCLIB if ENABLE_MCLIB
LIBS += $(GLIB_LIBS) LIBS += $(GLIB_LIBS)

View File

@ -4,15 +4,13 @@ AM_CPPFLAGS = \
-DTEST_SHARE_DIR=\"$(abs_srcdir)\" \ -DTEST_SHARE_DIR=\"$(abs_srcdir)\" \
$(GLIB_CFLAGS) \ $(GLIB_CFLAGS) \
-I$(top_srcdir) \ -I$(top_srcdir) \
@CHECK_CFLAGS@ \ @CHECK_CFLAGS@
@PCRE_CPPFLAGS@
AM_LDFLAGS = @TESTS_LDFLAGS@ AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS = @CHECK_LIBS@ \ LIBS = @CHECK_LIBS@ \
$(top_builddir)/src/libinternal.la \ $(top_builddir)/src/libinternal.la \
$(top_builddir)/lib/libmc.la \ $(top_builddir)/lib/libmc.la
@PCRE_LIBS@
if ENABLE_MCLIB if ENABLE_MCLIB
LIBS += $(GLIB_LIBS) LIBS += $(GLIB_LIBS)

View File

@ -5,15 +5,13 @@ AM_CPPFLAGS = \
-I$(top_srcdir) \ -I$(top_srcdir) \
-I$(top_srcdir)/lib/vfs \ -I$(top_srcdir)/lib/vfs \
-DTEST_SHARE_DIR=\"$(abs_srcdir)\" \ -DTEST_SHARE_DIR=\"$(abs_srcdir)\" \
@CHECK_CFLAGS@ \ @CHECK_CFLAGS@
@PCRE_CPPFLAGS@
AM_LDFLAGS = @TESTS_LDFLAGS@ AM_LDFLAGS = @TESTS_LDFLAGS@
LIBS = @CHECK_LIBS@ \ LIBS = @CHECK_LIBS@ \
$(top_builddir)/src/libinternal.la \ $(top_builddir)/src/libinternal.la \
$(top_builddir)/lib/libmc.la \ $(top_builddir)/lib/libmc.la
@PCRE_LIBS@
if ENABLE_MCLIB if ENABLE_MCLIB
LIBS += $(GLIB_LIBS) LIBS += $(GLIB_LIBS)