1
1

Merge branch '1396_with_search_engine'

* 1396_with_search_engine:
  Fixed bug in calculate version code when run under FreeBSD
  Ticket #1396 (need build option --with-search-engine for select regex engine)
Этот коммит содержится в:
Slava Zanko 2009-07-07 12:32:42 +03:00
родитель 348ab7303f 514cdf8340
Коммит 6e9059e2f3
7 изменённых файлов: 101 добавлений и 59 удалений

Просмотреть файл

@ -9,37 +9,43 @@ dnl
dnl the usual two ACTION-IF-FOUND / ACTION-IF-NOT-FOUND are supported
dnl and they can take advantage of the LIBS/CFLAGS additions.
dnl
dnl @category InstalledPackages
dnl @author Guido U. Draheim <guidod@gmx.de>
dnl @version 2006-10-13
dnl @author Slava Zanko <slavazanko@gmail.com>
dnl @version 2009-07-06
dnl @license GPLWithACException
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")
AC_ARG_WITH([pcre],
AC_HELP_STRING([--with-pcre[[=prefix]]].[ compile pcre 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)
if test ".$with_pcre" = ".yes" ; then
PCRE_CFLAGS="`pcre-config --cflags`"
PCRE_LIBS="`pcre-config --libs`"
else
OLDLDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$with_pcre/lib"
OLDCPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$with_pcre/include"
test_PCRE_LIBS="-L$with_pcre/lib"
test_PCRE_CFLAGS="-I$with_pcre/include"
OLDLDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $test_PCRE_LIBS"
OLDCFLAGS="$CFLAGS" ; CFLAGS="$CFLAGS $test_PCRE_CFLAGS"
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"
PCRE_LIBS=$test_PCRE_LIBS
test_PCRE_CFLAGS=$test_PCRE_CFLAGS
AC_MSG_CHECKING([lib pcre])
AC_MSG_RESULT([$PCRE_LIBS])
m4_ifval($1,$1)
@ -48,8 +54,14 @@ else
AC_MSG_RESULT([no, (WARNING)])
m4_ifval($2,$2)
fi
CFLAGS="$OLDCFLAGS"
LDFLAGS="$OLDLDFLAGS"
fi
fi
AC_SUBST([PCRE_LIBS])
AC_SUBST([PCRE_CFLAGS])
])

Просмотреть файл

@ -9,14 +9,44 @@ dnl @copyright Free Software Foundation, Inc.
AC_DEFUN([MC_CHECK_SEARCH_TYPE],[
AC_ARG_WITH([search-engine],
AC_HELP_STRING([--search-engine=type],
[Select low-level search engine (since glib >= 2.14). [[glib pcre]]])
)
case x$with_search_engine in
xglib)
SEARCH_TYPE="glib-regexp"
;;
xpcre)
SEARCH_TYPE="pcre"
;;
x)
SEARCH_TYPE="glib-regexp"
;;
*)
AC_MSG_ERROR([Value of the search-engine is incorrect])
;;
esac
$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"
if test ! x$with_search_engine = x -a x$SEARCH_TYPE = xglib; then
AC_MSG_ERROR([Selected 'glib' search engine, but you don't have glib >= 2.14])
fi
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
AC_DEFINE(SEARCH_TYPE_PCRE, 1, [Define to select 'pcre' search type])
else
SEARCH_TYPE="glib-regexp"
if test x$SEARCH_TYPE = xpcre; then
AX_PATH_LIB_PCRE
if test x"${PCRE_LIBS}" = x; then
AC_MSG_ERROR([Your system don't have pcre library (or pcre devel stuff)])
fi
AC_DEFINE(SEARCH_TYPE_PCRE, 1, [Define to select 'pcre' search type])
else
AC_DEFINE(SEARCH_TYPE_GLIB, 1, [Define to select 'glib-regexp' search type])
fi
fi
])

Просмотреть файл

@ -12,7 +12,7 @@ AC_DEFUN([MC_VERSION],[
${srcdir}/maint/version.sh ${srcdir}
fi
if test -f ${srcdir}/version.h; then
VERSION=$(cat ${srcdir}/version.h| grep '^#define MC_CURRENT_VERSION'| sed -r 's/.*"(.*)"$/\1/')
VERSION=$(grep '^#define MC_CURRENT_VERSION' ${srcdir}/version.h | sed 's/.*"\(.*\)"$/\1/')
else
VERSION="unknown"
fi

Просмотреть файл

@ -3,7 +3,7 @@
/*** typedefs(not structures) and defined constants **********************************************/
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
#define mc_search_regex_t GRegex
#else
#define mc_search_regex_t pcre

Просмотреть файл

@ -233,7 +233,7 @@ static mc_search__found_cond_t
mc_search__regex_found_cond_one (mc_search_t * mc_search, mc_search_regex_t * regex,
GString * search_str)
{
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
GError *error = NULL;
if (!g_regex_match_full
@ -250,14 +250,14 @@ mc_search__regex_found_cond_one (mc_search_t * mc_search, mc_search_regex_t * re
return COND__NOT_FOUND;
}
mc_search->num_rezults = g_match_info_get_match_count (mc_search->regex_match_info);
#else
#else /* SEARCH_TYPE_GLIB */
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;
}
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
#endif /* SEARCH_TYPE_GLIB */
return COND__FOUND_OK;
}
@ -329,12 +329,12 @@ mc_search_regex__get_token_by_num (const mc_search_t * mc_search, gsize index)
{
int fnd_start = 0, fnd_end = 0;
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
g_match_info_fetch_pos (mc_search->regex_match_info, index, &fnd_start, &fnd_end);
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
#else /* SEARCH_TYPE_GLIB */
fnd_start = mc_search->iovector[index * 2 + 0];
fnd_end = mc_search->iovector[index * 2 + 1];
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
#endif /* SEARCH_TYPE_GLIB */
if (fnd_end - fnd_start == 0)
return NULL;
@ -476,12 +476,12 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * mc_sea
mc_search_cond_t * mc_search_cond)
{
GString *tmp = NULL;
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
GError *error = NULL;
#else
#else /* SEARCH_TYPE_GLIB */
const char *error;
int erroffset;
#endif
#endif /* SEARCH_TYPE_GLIB */
if (!mc_search->is_case_sentitive) {
tmp = g_string_new_len (mc_search_cond->str->str, mc_search_cond->str->len);
@ -489,7 +489,7 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * mc_sea
mc_search_cond->str = mc_search__cond_struct_new_regex_ci_str (charset, tmp->str, tmp->len);
g_string_free (tmp, TRUE);
}
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
mc_search_cond->regex_handle =
g_regex_new (mc_search_cond->str->str, G_REGEX_OPTIMIZE | G_REGEX_RAW | G_REGEX_DOTALL, 0,
&error);
@ -500,7 +500,7 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * mc_sea
g_error_free (error);
return;
}
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
#else /* SEARCH_TYPE_GLIB */
mc_search_cond->regex_handle =
pcre_compile (mc_search_cond->str->str, PCRE_EXTRA, &error, &erroffset, NULL);
if (mc_search_cond->regex_handle == NULL) {
@ -518,7 +518,7 @@ mc_search__cond_struct_new_init_regex (const char *charset, mc_search_t * mc_sea
return;
}
}
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
#endif /* SEARCH_TYPE_GLIB */
}
/* --------------------------------------------------------------------------------------------- */
@ -563,12 +563,12 @@ mc_search__run_regex (mc_search_t * mc_search, const void *user_data,
switch (mc_search__regex_found_cond (mc_search, mc_search->regex_buffer)) {
case COND__FOUND_OK:
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
g_match_info_fetch_pos (mc_search->regex_match_info, 0, &start_pos, &end_pos);
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
#else /* SEARCH_TYPE_GLIB */
start_pos = mc_search->iovector[0];
end_pos = mc_search->iovector[1];
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
#endif /* SEARCH_TYPE_GLIB */
if (found_len)
*found_len = end_pos - start_pos;
mc_search->normal_offset = start_buffer + start_pos;

Просмотреть файл

@ -96,12 +96,12 @@ mc_search__cond_struct_free (mc_search_cond_t * mc_search_cond)
g_string_free (mc_search_cond->str, TRUE);
g_free (mc_search_cond->charset);
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
if (mc_search_cond->regex_handle)
g_regex_unref (mc_search_cond->regex_handle);
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
#else /* SEARCH_TYPE_GLIB */
g_free (mc_search_cond->regex_handle);
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
#endif /* SEARCH_TYPE_GLIB */
g_free (mc_search_cond);
}
@ -160,12 +160,12 @@ mc_search_free (mc_search_t * mc_search)
if (mc_search->conditions)
mc_search__conditions_free (mc_search->conditions);
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
if (mc_search->regex_match_info)
g_match_info_free (mc_search->regex_match_info);
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
#else /* SEARCH_TYPE_GLIB */
g_free (mc_search->regex_match_info);
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
#endif /* SEARCH_TYPE_GLIB */
if (mc_search->regex_buffer != NULL)
g_string_free (mc_search->regex_buffer, TRUE);
@ -235,12 +235,12 @@ mc_search_run (mc_search_t * mc_search, const void *user_data,
mc_search->error_str = g_strdup (_(STR_E_UNKNOWN_TYPE));
return FALSE;
}
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
if (mc_search->regex_match_info) {
g_match_info_free (mc_search->regex_match_info);
mc_search->regex_match_info = NULL;
}
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
#endif /* SEARCH_TYPE_GLIB */
mc_search->error = MC_SEARCH_E_OK;
g_free (mc_search->error_str);
@ -386,14 +386,14 @@ mc_search_getstart_rezult_by_num (mc_search_t * mc_search, int index)
return 0;
if (mc_search->search_type == MC_SEARCH_T_NORMAL)
return 0;
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
gint start_pos;
gint end_pos;
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) */
#else /* SEARCH_TYPE_GLIB */
return mc_search->iovector[index * 2];
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
#endif /* SEARCH_TYPE_GLIB */
}
@ -406,14 +406,14 @@ mc_search_getend_rezult_by_num (mc_search_t * mc_search, int index)
return 0;
if (mc_search->search_type == MC_SEARCH_T_NORMAL)
return 0;
#if GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_GLIB
gint start_pos;
gint end_pos;
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) */
#else /* SEARCH_TYPE_GLIB */
return mc_search->iovector[index * 2 + 1];
#endif /* GLIB_CHECK_VERSION (2, 14, 0) */
#endif /* SEARCH_TYPE_GLIB */
}

Просмотреть файл

@ -5,7 +5,7 @@
#include "../src/global.h" /* <glib.h> */
#if ! GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_PCRE
# include <pcre.h>
#endif
@ -15,8 +15,8 @@ typedef int (*mc_search_fn) (const void *user_data, gsize char_offset);
#define MC_SEARCH__NUM_REPLACE_ARGS 64
#if GLIB_CHECK_VERSION (2, 14, 0)
#define mc_search_matchinfo_t GMatchInfo
#ifdef SEARCH_TYPE_GLIB
# define mc_search_matchinfo_t GMatchInfo
#else
# define mc_search_matchinfo_t pcre_extra
#endif
@ -74,9 +74,9 @@ typedef struct mc_search_struct {
int num_rezults;
mc_search_matchinfo_t *regex_match_info;
GString *regex_buffer;
#if ! GLIB_CHECK_VERSION (2, 14, 0)
#ifdef SEARCH_TYPE_PCRE
int iovector[MC_SEARCH__NUM_REPLACE_ARGS * 2];
#endif /* ! GLIB_CHECK_VERSION (2, 14, 0) */
#endif /* SEARCH_TYPE_PCRE */
/* private data */