mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Merge branch '419_broken_search_glib_less_2_14'
* 419_broken_search_glib_less_2_14: Now project don't compile if version of glib less than 2.14 and no have pcre library Removed support of POSIX regexp. Now handled only glib-regexp and pcre Ticket 419: (search broken in editor/viewer on glib <2.14)
This commit is contained in:
commit
a3fcab9f50
@ -1,5 +1,7 @@
|
||||
m4_include([m4.include/ac_onceonly.m4])
|
||||
m4_include([m4.include/ax_path_lib_pcre.m4])
|
||||
m4_include([m4.include/dx_doxygen.m4])
|
||||
m4_include([m4.include/mc-check-search-type.m4])
|
||||
m4_include([m4.include/mc-mcserver.m4])
|
||||
m4_include([m4.include/ac-get-fs-info.m4])
|
||||
m4_include([m4.include/mc-use-termcap.m4])
|
||||
|
@ -327,11 +327,7 @@ linux*)
|
||||
;;
|
||||
esac
|
||||
|
||||
$PKG_CONFIG --max-version 2.14 glib-2.0
|
||||
if test $? -eq 0
|
||||
then
|
||||
AX_PATH_LIB_PCRE
|
||||
fi
|
||||
MC_CHECK_SEARCH_TYPE
|
||||
|
||||
dnl
|
||||
dnl Check nroff and the options it supports
|
||||
@ -636,4 +632,5 @@ Configuration:
|
||||
With subshell support: ${subshell}
|
||||
Internal editor: ${edit_msg}
|
||||
Support for charset: ${charset_msg}
|
||||
Search type: ${SEARCH_TYPE}
|
||||
"
|
||||
|
22
m4.include/mc-check-search-type.m4
Normal file
22
m4.include/mc-check-search-type.m4
Normal file
@ -0,0 +1,22 @@
|
||||
dnl @synopsis MC_VERSION
|
||||
dnl
|
||||
dnl Check search type in mc. Currently used glib-regexp or pcre
|
||||
dnl
|
||||
dnl @author Slava Zanko <slavazanko@gmail.com>
|
||||
dnl @version 2009-06-19
|
||||
dnl @license GPL
|
||||
dnl @copyright Free Software Foundation, Inc.
|
||||
|
||||
AC_DEFUN([MC_CHECK_SEARCH_TYPE],[
|
||||
|
||||
$PKG_CONFIG --max-version 2.14 glib-2.0
|
||||
if test $? -eq 0; then
|
||||
AX_PATH_LIB_PCRE
|
||||
if test x"${PCRE_LIBS}" = x; then
|
||||
AC_MSG_ERROR([Your system have glib < 2.14 and don't have pcre library (or pcre devel stuff)])
|
||||
fi
|
||||
SEARCH_TYPE="pcre"
|
||||
else
|
||||
SEARCH_TYPE="glib-regexp"
|
||||
fi
|
||||
])
|
@ -6,11 +6,7 @@
|
||||
#if GLIB_CHECK_VERSION (2, 14, 0)
|
||||
#define mc_search_regex_t GRegex
|
||||
#else
|
||||
# if HAVE_LIBPCRE
|
||||
# define mc_search_regex_t pcre
|
||||
# else
|
||||
# define mc_search_regex_t regex_t
|
||||
# endif
|
||||
#define mc_search_regex_t pcre
|
||||
#endif
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
@ -251,25 +251,12 @@ mc_search__regex_found_cond_one (mc_search_t * mc_search, mc_search_regex_t * re
|
||||
}
|
||||
mc_search->num_rezults = g_match_info_get_match_count (mc_search->regex_match_info);
|
||||
#else
|
||||
#if HAVE_LIBPCRE
|
||||
mc_search->num_rezults = pcre_exec (regex, mc_search->regex_match_info,
|
||||
search_str->str, search_str->len, 0, 0, mc_search->iovector,
|
||||
MC_SEARCH__NUM_REPLACE_ARGS);
|
||||
if (mc_search->num_rezults < 0) {
|
||||
return COND__NOT_FOUND;
|
||||
}
|
||||
#else /* HAVE_LIBPCRE */
|
||||
|
||||
if (regexec (regex, search_str->str, MC_SEARCH__NUM_REPLACE_ARGS, mc_search->regex_match_info, 0))
|
||||
return COND__NOT_FOUND;
|
||||
|
||||
for (mc_search->num_rezults = 0; mc_search->num_rezults < MC_SEARCH__NUM_REPLACE_ARGS;
|
||||
mc_search->num_rezults++) {
|
||||
if (mc_search->regex_match_info[mc_search->num_rezults].rm_eo == 0)
|
||||
break;
|
||||
|
||||
}
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
return COND__FOUND_OK;
|
||||
|
||||
@ -345,13 +332,8 @@ mc_search_regex__get_token_by_num (const mc_search_t * mc_search, gsize index)
|
||||
#if GLIB_CHECK_VERSION (2, 14, 0)
|
||||
g_match_info_fetch_pos (mc_search->regex_match_info, index, &fnd_start, &fnd_end);
|
||||
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
#if HAVE_LIBPCRE
|
||||
fnd_start = mc_search->iovector[index * 2 + 0];
|
||||
fnd_end = mc_search->iovector[index * 2 + 1];
|
||||
#else /* HAVE_LIBPCRE */
|
||||
fnd_start = mc_search->regex_match_info[index].rm_so;
|
||||
fnd_end = mc_search->regex_match_info[index].rm_eo;
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
|
||||
if (fnd_end - fnd_start == 0)
|
||||
@ -519,7 +501,6 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * mc_sea
|
||||
return;
|
||||
}
|
||||
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
#if HAVE_LIBPCRE
|
||||
mc_search_cond->regex_handle =
|
||||
pcre_compile (mc_search_cond->str->str, PCRE_EXTRA, &error, &erroffset, NULL);
|
||||
if (mc_search_cond->regex_handle == NULL) {
|
||||
@ -537,21 +518,6 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * mc_sea
|
||||
return;
|
||||
}
|
||||
}
|
||||
#else /* HAVE_LIBPCRE */
|
||||
mc_search_cond->regex_handle = g_malloc0 (sizeof (regex_t));
|
||||
erroffset = regcomp (mc_search_cond->regex_handle, mc_search_cond->str->str, REG_EXTENDED);
|
||||
if (erroffset) {
|
||||
size_t err_len = regerror (erroffset, mc_search_cond->regex_handle, NULL, 0);
|
||||
error = g_malloc (err_len + 1);
|
||||
regerror (erroffset, mc_search_cond->regex_handle, error, err_len);
|
||||
mc_search->error = MC_SEARCH_E_REGEX_COMPILE;
|
||||
mc_search->error_str = error;
|
||||
regfree (mc_search_cond->regex_handle);
|
||||
mc_search_cond->regex_handle = NULL;
|
||||
return;
|
||||
}
|
||||
mc_search->regex_match_info = g_new0 (mc_search_matchinfo_t, MC_SEARCH__NUM_REPLACE_ARGS);
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
}
|
||||
|
||||
@ -600,13 +566,8 @@ mc_search__run_regex (mc_search_t * mc_search, const void *user_data,
|
||||
#if GLIB_CHECK_VERSION (2, 14, 0)
|
||||
g_match_info_fetch_pos (mc_search->regex_match_info, 0, &start_pos, &end_pos);
|
||||
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
#if HAVE_LIBPCRE
|
||||
start_pos = mc_search->iovector[0];
|
||||
end_pos = mc_search->iovector[1];
|
||||
#else /* HAVE_LIBPCRE */
|
||||
start_pos = mc_search->regex_match_info[0].rm_so;
|
||||
end_pos = mc_search->regex_match_info[0].rm_eo;
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
if (found_len)
|
||||
*found_len = end_pos - start_pos;
|
||||
|
@ -145,13 +145,8 @@ mc_search__cond_struct_free (mc_search_cond_t * mc_search_cond)
|
||||
if (mc_search_cond->regex_handle)
|
||||
g_regex_unref (mc_search_cond->regex_handle);
|
||||
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
#if HAVE_LIBPCRE
|
||||
if (mc_search_cond->regex_handle)
|
||||
free (mc_search_cond->regex_handle);
|
||||
#else /* HAVE_LIBPCRE */
|
||||
if (mc_search_cond->regex_handle)
|
||||
regfree (mc_search_cond->regex_handle);
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
|
||||
g_free (mc_search_cond);
|
||||
@ -217,13 +212,8 @@ mc_search_free (mc_search_t * mc_search)
|
||||
if (mc_search->regex_match_info)
|
||||
g_match_info_free (mc_search->regex_match_info);
|
||||
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
#if HAVE_LIBPCRE
|
||||
if (mc_search->regex_match_info)
|
||||
free (mc_search->regex_match_info);
|
||||
#else /* HAVE_LIBPCRE */
|
||||
if (mc_search->regex_match_info)
|
||||
g_free (mc_search->regex_match_info);
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
|
||||
if (mc_search->regex_buffer != NULL)
|
||||
@ -405,11 +395,7 @@ mc_search_getstart_rezult_by_num (mc_search_t * mc_search, int index)
|
||||
g_match_info_fetch_pos (mc_search->regex_match_info, index, &start_pos, &end_pos);
|
||||
return (int) start_pos;
|
||||
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
#if HAVE_LIBPCRE
|
||||
return mc_search->iovector[index * 2];
|
||||
#else /* HAVE_LIBPCRE */
|
||||
return mc_search->regex_match_info[index].rm_so;
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
|
||||
}
|
||||
@ -429,11 +415,7 @@ mc_search_getend_rezult_by_num (mc_search_t * mc_search, int index)
|
||||
g_match_info_fetch_pos (mc_search->regex_match_info, index, &start_pos, &end_pos);
|
||||
return (int) end_pos;
|
||||
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
#if HAVE_LIBPCRE
|
||||
return mc_search->iovector[index * 2 + 1];
|
||||
#else /* HAVE_LIBPCRE */
|
||||
return mc_search->regex_match_info[index].rm_eo;
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
|
||||
}
|
||||
|
@ -6,14 +6,7 @@
|
||||
#include "../src/global.h" /* <glib.h> */
|
||||
|
||||
#if ! GLIB_CHECK_VERSION (2, 14, 0)
|
||||
# if HAVE_LIBPCRE
|
||||
# include <pcre.h>
|
||||
# else
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <sys/types.h>
|
||||
# include <regex.h>
|
||||
# endif
|
||||
# include <pcre.h>
|
||||
#endif
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
@ -25,11 +18,7 @@ typedef int (*mc_search_fn) (const void *user_data, gsize char_offset);
|
||||
#if GLIB_CHECK_VERSION (2, 14, 0)
|
||||
#define mc_search_matchinfo_t GMatchInfo
|
||||
#else
|
||||
# if HAVE_LIBPCRE
|
||||
# define mc_search_matchinfo_t pcre_extra
|
||||
# else
|
||||
# define mc_search_matchinfo_t regmatch_t
|
||||
# endif
|
||||
# define mc_search_matchinfo_t pcre_extra
|
||||
#endif
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
@ -86,9 +75,7 @@ typedef struct mc_search_struct {
|
||||
mc_search_matchinfo_t *regex_match_info;
|
||||
GString *regex_buffer;
|
||||
#if ! GLIB_CHECK_VERSION (2, 14, 0)
|
||||
#if HAVE_LIBPCRE
|
||||
int iovector[MC_SEARCH__NUM_REPLACE_ARGS * 2];
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
#endif /* ! GLIB_CHECK_VERSION (2, 14, 0) */
|
||||
|
||||
/* private data */
|
||||
|
Loading…
Reference in New Issue
Block a user