mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-12 10:53:23 +03:00
Ticket #4655: remove PCRE and PCRE2 search engines.
GRegex as PCRE wrapper was introduced in GLib-2.14. PCRE was required for MC on OSes with GLib < 2.14. Currently MC requires GLib >= 2.32. Since 2.73.2 (released at 2022-07-08), GRegex is based on PCRE2. We can remove PCRE and PCRE2 from MC and use GLib only. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
9f020f7bfd
commit
18c0c2fabb
5
.github/workflows/ci-ubuntu.yml
vendored
5
.github/workflows/ci-ubuntu.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get install -y autoconf autopoint check gettext libtool pkg-config
|
||||
sudo apt-get install -y e2fslibs-dev libaspell-dev libglib2.0-dev libgpm-dev libncurses5-dev libpcre2-dev libslang2-dev libssh2-1-dev libx11-dev unzip
|
||||
sudo apt-get install -y e2fslibs-dev libaspell-dev libglib2.0-dev libgpm-dev libncurses5-dev libslang2-dev libssh2-1-dev libx11-dev unzip
|
||||
|
||||
- name: Bootstrap build system
|
||||
run: ./autogen.sh
|
||||
@ -43,7 +43,7 @@ jobs:
|
||||
make check
|
||||
make install
|
||||
|
||||
- name: Build ncurses & pcre2 configuration
|
||||
- name: Build ncurses configuration
|
||||
run: |
|
||||
tar -xjf $(ls build-distrib/mc-*.tar.bz2) --one-top-level=build-ncurses
|
||||
cd build-ncurses
|
||||
@ -51,7 +51,6 @@ jobs:
|
||||
../configure \
|
||||
--prefix="$(pwd)/install" \
|
||||
--with-screen=ncurses \
|
||||
--with-search-engine=pcre2 \
|
||||
--enable-werror
|
||||
|
||||
make -j$(nproc)
|
||||
|
@ -6,8 +6,6 @@ m4_include([m4.include/gnulib/fsusage.m4])
|
||||
m4_include([m4.include/gnulib/mountlist.m4])
|
||||
m4_include([m4.include/gnulib/windows-stat-inodes.m4])
|
||||
m4_include([m4.include/gnulib/sys_types_h.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/ax_require_defined.m4])
|
||||
m4_include([m4.include/ax_check_compile_flag.m4])
|
||||
@ -16,7 +14,6 @@ m4_include([m4.include/ax_append_compile_flags.m4])
|
||||
m4_include([m4.include/mc-cflags.m4])
|
||||
m4_include([m4.include/mc-stdckdint.m4])
|
||||
m4_include([m4.include/ax_gcc_func_attribute.m4])
|
||||
m4_include([m4.include/mc-check-search-type.m4])
|
||||
m4_include([m4.include/mc-get-fs-info.m4])
|
||||
m4_include([m4.include/mc-with-x.m4])
|
||||
m4_include([m4.include/mc-use-termcap.m4])
|
||||
|
@ -228,7 +228,6 @@ dnl ############################################################################
|
||||
mc_CHECK_GLIB
|
||||
mc_G_MODULE_SUPPORTED
|
||||
mc_WITH_SCREEN
|
||||
mc_CHECK_SEARCH_TYPE
|
||||
dnl X11 support. Used to read keyboard modifiers when running under X11.
|
||||
mc_WITH_X
|
||||
|
||||
@ -751,7 +750,6 @@ Configuration:
|
||||
Internal editor: ${edit_msg}
|
||||
Diff viewer: ${diff_msg}
|
||||
Support for charset: ${charset_msg}
|
||||
Search type: ${SEARCH_TYPE}
|
||||
])
|
||||
|
||||
dnl option checking is disable by default due to AC_CONFIG_SUBDIRS
|
||||
|
@ -25,8 +25,6 @@ Build requirements for GNU Midnight Commander
|
||||
- https://invisible-island.net/ncurses/ncurses.html
|
||||
- gettext >= 0.18.2
|
||||
- https://www.gnu.org/software/gettext/
|
||||
- pcre or pcre2 (as an alternative to glib-regexp)
|
||||
- https://www.pcre.org
|
||||
- gpm (general purpose mouse daemon as an alternative to xterm mouse)
|
||||
- https://www.nico.schottelius.org/software/gpm/
|
||||
- libssh2 >= 1.2.8 (required only for sftp vfs)
|
||||
|
32
lib/search.h
32
lib/search.h
@ -7,14 +7,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef SEARCH_TYPE_PCRE
|
||||
# ifdef HAVE_PCRE2
|
||||
# define PCRE2_CODE_UNIT_WIDTH 8
|
||||
# include <pcre2.h>
|
||||
# else
|
||||
# include <pcre.h>
|
||||
# endif
|
||||
#endif
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
typedef enum mc_search_cbret_t mc_search_cbret_t;
|
||||
@ -25,19 +17,6 @@ typedef mc_search_cbret_t (*mc_update_fn) (const void *user_data, off_t char_off
|
||||
|
||||
#define MC_SEARCH__NUM_REPLACE_ARGS 64
|
||||
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
# define mc_search_matchinfo_t GMatchInfo
|
||||
#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
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
typedef enum
|
||||
@ -122,17 +101,8 @@ typedef struct mc_search_struct
|
||||
// some data for regexp
|
||||
int num_results;
|
||||
gboolean is_utf8;
|
||||
mc_search_matchinfo_t *regex_match_info;
|
||||
GMatchInfo *regex_match_info;
|
||||
GString *regex_buffer;
|
||||
#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];
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// private data
|
||||
|
||||
|
@ -3,16 +3,6 @@
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
# define mc_search_regex_t GRegex
|
||||
#else
|
||||
# ifdef HAVE_PCRE2
|
||||
# define mc_search_regex_t pcre2_code
|
||||
# else
|
||||
# define mc_search_regex_t pcre
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
typedef enum
|
||||
@ -32,7 +22,7 @@ typedef struct mc_search_cond_struct
|
||||
GString *str;
|
||||
GString *upper;
|
||||
GString *lower;
|
||||
mc_search_regex_t *regex_handle;
|
||||
GRegex *regex_handle;
|
||||
gchar *charset;
|
||||
} mc_search_cond_t;
|
||||
|
||||
|
@ -269,7 +269,6 @@ mc_search__cond_struct_new_regex_ci_str (const char *charset, const GString *ast
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
/* A thin wrapper above g_regex_match_full that makes sure the string passed
|
||||
* to it is valid UTF-8 (unless G_REGEX_RAW compile flag was set), as it is a
|
||||
* requirement by glib and it might crash otherwise. See: mc ticket 3449.
|
||||
@ -319,15 +318,12 @@ mc_search__g_regex_match_full_safe (const GRegex *regex, const gchar *string, gs
|
||||
g_free (string_safe);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static mc_search__found_cond_t
|
||||
mc_search__regex_found_cond_one (mc_search_t *lc_mc_search, mc_search_regex_t *regex,
|
||||
GString *search_str)
|
||||
mc_search__regex_found_cond_one (mc_search_t *lc_mc_search, GRegex *regex, GString *search_str)
|
||||
{
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
GError *mcerror = NULL;
|
||||
|
||||
if (!mc_search__g_regex_match_full_safe (regex, search_str->str, search_str->len, 0,
|
||||
@ -348,21 +344,7 @@ mc_search__regex_found_cond_one (mc_search_t *lc_mc_search, mc_search_regex_t *r
|
||||
return COND__NOT_FOUND;
|
||||
}
|
||||
lc_mc_search->num_results = g_match_info_get_match_count (lc_mc_search->regex_match_info);
|
||||
#else // SEARCH_TYPE_GLIB
|
||||
|
||||
lc_mc_search->num_results =
|
||||
# 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)
|
||||
{
|
||||
return COND__NOT_FOUND;
|
||||
}
|
||||
#endif
|
||||
return COND__FOUND_OK;
|
||||
}
|
||||
|
||||
@ -443,12 +425,7 @@ mc_search_regex__get_token_by_num (const mc_search_t *lc_mc_search, gsize lc_ind
|
||||
{
|
||||
int fnd_start = 0, fnd_end = 0;
|
||||
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
g_match_info_fetch_pos (lc_mc_search->regex_match_info, lc_index, &fnd_start, &fnd_end);
|
||||
#else // SEARCH_TYPE_GLIB
|
||||
fnd_start = lc_mc_search->iovector[lc_index * 2 + 0];
|
||||
fnd_end = lc_mc_search->iovector[lc_index * 2 + 1];
|
||||
#endif
|
||||
|
||||
if (fnd_end == fnd_start)
|
||||
return g_strdup ("");
|
||||
@ -807,7 +784,6 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t *lc_mc_s
|
||||
}
|
||||
|
||||
{
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
GError *mcerror = NULL;
|
||||
GRegexCompileFlags g_regex_options = G_REGEX_OPTIMIZE | G_REGEX_DOTALL;
|
||||
|
||||
@ -842,67 +818,6 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t *lc_mc_s
|
||||
g_error_free (mcerror);
|
||||
return;
|
||||
}
|
||||
#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;
|
||||
int erroffset;
|
||||
int pcre_options = PCRE_EXTRA | PCRE_MULTILINE;
|
||||
# endif
|
||||
|
||||
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;
|
||||
if (!lc_mc_search->is_case_sensitive)
|
||||
pcre_options |= PCRE_CASELESS;
|
||||
# endif
|
||||
}
|
||||
else if (!lc_mc_search->is_case_sensitive)
|
||||
{
|
||||
GString *tmp;
|
||||
|
||||
tmp = mc_search_cond->str;
|
||||
mc_search_cond->str = mc_search__cond_struct_new_regex_ci_str (charset, tmp);
|
||||
g_string_free (tmp, TRUE);
|
||||
}
|
||||
|
||||
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);
|
||||
# endif
|
||||
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);
|
||||
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);
|
||||
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_PTR_FREE (mc_search_cond->regex_handle);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
lc_mc_search->is_utf8 = str_isutf8 (charset);
|
||||
@ -985,12 +900,7 @@ mc_search__run_regex (mc_search_t *lc_mc_search, const void *user_data, off_t st
|
||||
switch (mc_search__regex_found_cond (lc_mc_search, lc_mc_search->regex_buffer))
|
||||
{
|
||||
case COND__FOUND_OK:
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
g_match_info_fetch_pos (lc_mc_search->regex_match_info, 0, &start_pos, &end_pos);
|
||||
#else // SEARCH_TYPE_GLIB
|
||||
start_pos = lc_mc_search->iovector[0];
|
||||
end_pos = lc_mc_search->iovector[1];
|
||||
#endif
|
||||
if (found_len != NULL)
|
||||
*found_len = end_pos - start_pos;
|
||||
lc_mc_search->normal_offset = lc_mc_search->start_buffer + start_pos;
|
||||
|
@ -71,10 +71,7 @@ mc_search__cond_struct_new (mc_search_t *lc_mc_search, const GString *str, const
|
||||
mc_search_cond = g_malloc0 (sizeof (mc_search_cond_t));
|
||||
mc_search_cond->str = mc_g_string_dup (str);
|
||||
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)
|
||||
{
|
||||
case MC_SEARCH_T_GLOB:
|
||||
@ -111,12 +108,8 @@ mc_search__cond_struct_free (gpointer data)
|
||||
g_string_free (mc_search_cond->str, TRUE);
|
||||
g_free (mc_search_cond->charset);
|
||||
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
if (mc_search_cond->regex_handle != NULL)
|
||||
g_regex_unref (mc_search_cond->regex_handle);
|
||||
#else // SEARCH_TYPE_GLIB
|
||||
g_free (mc_search_cond->regex_handle);
|
||||
#endif
|
||||
|
||||
g_free (mc_search_cond);
|
||||
}
|
||||
@ -188,12 +181,8 @@ mc_search_free (mc_search_t *lc_mc_search)
|
||||
if (lc_mc_search->prepared.conditions != NULL)
|
||||
g_ptr_array_free (lc_mc_search->prepared.conditions, TRUE);
|
||||
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
if (lc_mc_search->regex_match_info != NULL)
|
||||
g_match_info_free (lc_mc_search->regex_match_info);
|
||||
#else // SEARCH_TYPE_GLIB
|
||||
g_free (lc_mc_search->regex_match_info);
|
||||
#endif
|
||||
|
||||
if (lc_mc_search->regex_buffer != NULL)
|
||||
g_string_free (lc_mc_search->regex_buffer, TRUE);
|
||||
@ -282,13 +271,12 @@ mc_search_run (mc_search_t *lc_mc_search, const void *user_data, off_t start_sea
|
||||
mc_search_set_error (lc_mc_search, MC_SEARCH_E_INPUT, "%s", _ (STR_E_UNKNOWN_TYPE));
|
||||
return FALSE;
|
||||
}
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
|
||||
if (lc_mc_search->regex_match_info != NULL)
|
||||
{
|
||||
g_match_info_free (lc_mc_search->regex_match_info);
|
||||
lc_mc_search->regex_match_info = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
mc_search_set_error (lc_mc_search, MC_SEARCH_E_OK, NULL);
|
||||
|
||||
@ -455,7 +443,6 @@ mc_search_getstart_result_by_num (mc_search_t *lc_mc_search, int lc_index)
|
||||
return 0;
|
||||
if (lc_mc_search->search_type == MC_SEARCH_T_NORMAL)
|
||||
return 0;
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
{
|
||||
gint start_pos;
|
||||
gint end_pos;
|
||||
@ -463,9 +450,6 @@ mc_search_getstart_result_by_num (mc_search_t *lc_mc_search, int lc_index)
|
||||
g_match_info_fetch_pos (lc_mc_search->regex_match_info, lc_index, &start_pos, &end_pos);
|
||||
return (int) start_pos;
|
||||
}
|
||||
#else // SEARCH_TYPE_GLIB
|
||||
return lc_mc_search->iovector[lc_index * 2];
|
||||
#endif
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -477,7 +461,6 @@ mc_search_getend_result_by_num (mc_search_t *lc_mc_search, int lc_index)
|
||||
return 0;
|
||||
if (lc_mc_search->search_type == MC_SEARCH_T_NORMAL)
|
||||
return 0;
|
||||
#ifdef SEARCH_TYPE_GLIB
|
||||
{
|
||||
gint start_pos;
|
||||
gint end_pos;
|
||||
@ -485,9 +468,6 @@ mc_search_getend_result_by_num (mc_search_t *lc_mc_search, int lc_index)
|
||||
g_match_info_fetch_pos (lc_mc_search->regex_match_info, lc_index, &start_pos, &end_pos);
|
||||
return (int) end_pos;
|
||||
}
|
||||
#else // SEARCH_TYPE_GLIB
|
||||
return lc_mc_search->iovector[lc_index * 2 + 1];
|
||||
#endif
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -1,163 +0,0 @@
|
||||
# ===========================================================================
|
||||
# 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
|
||||
])
|
@ -1,69 +0,0 @@
|
||||
# ===========================================================================
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_path_lib_pcre.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_PATH_LIB_PCRE [(A/NA)]
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# check for pcre lib and set PCRE_LIBS and PCRE_CFLAGS accordingly.
|
||||
#
|
||||
# also provide --with-pcre option that may point to the $prefix of the
|
||||
# pcre installation - the macro will check $pcre/include and $pcre/lib to
|
||||
# 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_MSG_CHECKING([lib pcre])
|
||||
AC_ARG_WITH(pcre,
|
||||
[ --with-pcre[[=prefix]] compile xmlpcre part (via libpcre check)],,
|
||||
with_pcre="yes")
|
||||
if test ".$with_pcre" = ".no" ; then
|
||||
AC_MSG_RESULT([disabled])
|
||||
m4_ifval($2,$2)
|
||||
else
|
||||
AC_MSG_RESULT([(testing)])
|
||||
AC_CHECK_LIB(pcre, pcre_study)
|
||||
if test "$ac_cv_lib_pcre_pcre_study" = "yes" ; then
|
||||
PCRE_LIBS="-lpcre"
|
||||
AC_MSG_CHECKING([lib pcre])
|
||||
AC_MSG_RESULT([$PCRE_LIBS])
|
||||
m4_ifval($1,$1)
|
||||
else
|
||||
OLDLDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$with_pcre/lib"
|
||||
OLDCPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$with_pcre/include"
|
||||
AC_CHECK_LIB(pcre, pcre_compile)
|
||||
CPPFLAGS="$OLDCPPFLAGS"
|
||||
LDFLAGS="$OLDLDFLAGS"
|
||||
if test "$ac_cv_lib_pcre_pcre_compile" = "yes" ; then
|
||||
AC_MSG_RESULT(.setting PCRE_LIBS -L$with_pcre/lib -lpcre)
|
||||
PCRE_LIBS="-L$with_pcre/lib -lpcre"
|
||||
test -d "$with_pcre/include" && PCRE_CFLAGS="-I$with_pcre/include"
|
||||
AC_MSG_CHECKING([lib pcre])
|
||||
AC_MSG_RESULT([$PCRE_LIBS])
|
||||
m4_ifval($1,$1)
|
||||
else
|
||||
AC_MSG_CHECKING([lib pcre])
|
||||
AC_MSG_RESULT([no, (WARNING)])
|
||||
m4_ifval($2,$2)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([PCRE_LIBS])
|
||||
AC_SUBST([PCRE_CFLAGS])
|
||||
])
|
@ -1,64 +0,0 @@
|
||||
dnl @synopsis mc_CHECK_SEARCH_TYPE
|
||||
dnl
|
||||
dnl Check search type in mc. Currently used glib-regexp or pcre
|
||||
dnl
|
||||
dnl @author Slava Zanko <slavazanko@gmail.com>
|
||||
dnl @author Andrew Borodin <aborodin@vmail.ru>
|
||||
dnl @version 2023-03-22
|
||||
dnl @license GPL
|
||||
dnl @copyright Free Software Foundation, Inc.
|
||||
|
||||
AC_DEFUN([mc_CHECK_SEARCH_TYPE_PCRE],[
|
||||
AX_PATH_LIB_PCRE
|
||||
|
||||
if test x"${PCRE_LIBS}" = x; then
|
||||
AC_MSG_ERROR([$1])
|
||||
fi
|
||||
|
||||
SEARCH_TYPE="pcre"
|
||||
])
|
||||
|
||||
AC_DEFUN([mc_CHECK_SEARCH_TYPE_PCRE2],[
|
||||
AX_CHECK_PCRE2([8], [], [:])
|
||||
|
||||
if test $pcre2_cv_libpcre2 = yes; then
|
||||
SEARCH_TYPE="pcre2"
|
||||
else
|
||||
dnl pcre2 not found -- try pcre
|
||||
AC_MSG_WARN([Cannot find pcre2 library, trying pcre one...])
|
||||
mc_CHECK_SEARCH_TYPE_PCRE([$1])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([mc_CHECK_SEARCH_TYPE],[
|
||||
|
||||
AC_ARG_WITH([search-engine],
|
||||
AS_HELP_STRING([--with-search-engine=type],
|
||||
[Select low-level search engine @<:@glib|pcre|pcre2@:>@])
|
||||
)
|
||||
|
||||
case x$with_search_engine in
|
||||
xglib)
|
||||
SEARCH_TYPE="glib-regexp"
|
||||
;;
|
||||
xpcre)
|
||||
mc_CHECK_SEARCH_TYPE_PCRE([Cannot find pcre library])
|
||||
;;
|
||||
xpcre2)
|
||||
mc_CHECK_SEARCH_TYPE_PCRE2([Neither pcre2 nor pcre library found!])
|
||||
;;
|
||||
x)
|
||||
SEARCH_TYPE="glib-regexp"
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([Value of the search-engine is incorrect])
|
||||
;;
|
||||
esac
|
||||
|
||||
if test x"$SEARCH_TYPE" = x"glib-regexp"; then
|
||||
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
|
||||
])
|
Loading…
x
Reference in New Issue
Block a user