Use system pcre if present

master
Yevgen Muntyan 2006-05-01 01:54:47 -05:00
parent 1f67912dcf
commit 3685b6a86e
5 changed files with 205 additions and 157 deletions

View File

@ -9,8 +9,8 @@ AC_DEFUN([MOO_AC_FLAGS],[
moo_top_src_dir=`cd $srcdir && pwd`
moo_top_build_dir=`cd ./$ac_top_builddir && pwd`
MOO_CFLAGS="-I$moo_top_src_dir/moo $GTK_CFLAGS -DXDG_PREFIX=_moo_edit_xdg -DG_LOG_DOMAIN=\\\"Moo\\\" -D__MOO__ -DMOO_MARSHALS_H=\\\"mooutils/moomarshals.h\\\""
MOO_LIBS="$GTK_LIBS"
MOO_CFLAGS="-I$moo_top_src_dir/moo $GTK_CFLAGS $MOO_PCRE_CFLAGS -DXDG_PREFIX=_moo_edit_xdg -DG_LOG_DOMAIN=\\\"Moo\\\" -D__MOO__ -DMOO_MARSHALS_H=\\\"mooutils/moomarshals.h\\\""
MOO_LIBS="$GTK_LIBS $MOO_PCRE_LIBS"
if test x$MOO_USE_FAM = xyes; then
MOO_LIBS="$MOO_LIBS $FAM_LIBS"

View File

@ -5,122 +5,160 @@
#
AC_DEFUN([MOO_AC_PCRE],[
dnl Provide the current PCRE version information. Do not use numbers
dnl with leading zeros for the minor version, as they end up in a C
dnl macro, and may be treated as octal constants. Stick to single
dnl digits for minor numbers less than 10. There are unlikely to be
dnl that many releases anyway.
AC_ARG_WITH([system-pcre],
AC_HELP_STRING([--with-system-pcre], [whether to use system copy of pcre library (default = AUTO)]),[
if test x$with_system_pcre = "xyes"; then
MOO_BUILD_PCRE="no"
else
MOO_BUILD_PCRE="yes"
fi
],[
MOO_BUILD_PCRE="auto"
])
PCRE_MAJOR=6
PCRE_MINOR=4
PCRE_DATE=05-Sep-2005
PCRE_VERSION=${PCRE_MAJOR}.${PCRE_MINOR}
if test x$MOO_BUILD_PCRE != xyes; then
PKG_CHECK_MODULES(MOO_PCRE, [libpcre >= 6.4], [
MOO_BUILD_PCRE="no"
AC_MSG_NOTICE([using installed libpcre])
], [
if test x$MOO_BUILD_PCRE = xno; then
AC_MSG_ERROR([libpcre of version 6.4 or higher not found])
else
AC_MSG_NOTICE([libpcre of version 6.4 or higher not found, building own copy])
MOO_BUILD_PCRE="yes"
fi
])
fi
AC_DEFINE([PCRE_MAJOR], $PCRE_MAJOR, [pcre library major version])
AC_DEFINE([PCRE_MINOR], $PCRE_MINOR, [pcre library minor version])
AC_DEFINE([PCRE_DATE], $PCRE_DATE, [pcre library release date])
dnl Default values for miscellaneous macros
AC_DEFINE(POSIX_MALLOC_THRESHOLD, 10, [POSIX_MALLOC_THRESHOLD])
AC_HEADER_STDC
AC_CHECK_HEADERS(limits.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_TYPES([long long], [pcre_have_long_long="1"], [pcre_have_long_long="0"])
AC_CHECK_TYPES([unsigned long long], [pcre_have_ulong_long="1"], [pcre_have_ulong_long="0"])
AC_SUBST(pcre_have_long_long)
AC_SUBST(pcre_have_ulong_long)
dnl Checks for library functions.
AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll)
dnl Handle --enable-utf8
AC_DEFINE(SUPPORT_UTF8, , [SUPPORT_UTF8])
# XXX
# dnl Handle --enable-unicode-properties
AC_DEFINE(SUPPORT_UCP, , [SUPPORT_UCP])
AM_CONDITIONAL(MOO_BUILD_PCRE, test x$MOO_BUILD_PCRE = xyes)
if test x$MOO_BUILD_PCRE = xyes; then
AC_DEFINE(MOO_BUILD_PCRE, , [MOO_BUILD_PCRE - bulid pcre library])
fi
AC_DEFINE(PCRE_EXPORT, , [PCRE_EXPORT - empty since we do not need pcre api be exported])
## ===================================================================
## build pcre
##
if test x$MOO_BUILD_PCRE = xyes; then
# dnl Handle --enable-newline-is-cr
#
# AC_ARG_ENABLE(newline-is-cr,
# [ --enable-newline-is-cr use CR as the newline character],
# if test "$enableval" = "yes"; then
# NEWLINE=-DNEWLINE=13
# fi
# )
#
# dnl Handle --enable-newline-is-lf
#
# AC_ARG_ENABLE(newline-is-lf,
# [ --enable-newline-is-lf use LF as the newline character],
# if test "$enableval" = "yes"; then
# NEWLINE=-DNEWLINE=10
# fi
# )
AC_DEFINE(NEWLINE, '\n', [The value of NEWLINE determines the newline character])
dnl Provide the current PCRE version information. Do not use numbers
dnl with leading zeros for the minor version, as they end up in a C
dnl macro, and may be treated as octal constants. Stick to single
dnl digits for minor numbers less than 10. There are unlikely to be
dnl that many releases anyway.
# XXX
# dnl Handle --enable-ebcdic
#
# AC_ARG_ENABLE(ebcdic,
# [ --enable-ebcdic assume EBCDIC coding rather than ASCII],
# if test "$enableval" == "yes"; then
# EBCDIC=-DEBCDIC=1
# fi
# )
AC_DEFINE(EBCDIC, 0, [If you are compiling for a system that uses EBCDIC instead of ASCII dnl
character codes, define this macro as 1.])
PCRE_MAJOR=6
PCRE_MINOR=4
PCRE_DATE=05-Sep-2005
PCRE_VERSION=${PCRE_MAJOR}.${PCRE_MINOR}
AC_DEFINE([PCRE_MAJOR], $PCRE_MAJOR, [pcre library major version])
AC_DEFINE([PCRE_MINOR], $PCRE_MINOR, [pcre library minor version])
AC_DEFINE([PCRE_DATE], $PCRE_DATE, [pcre library release date])
dnl Default values for miscellaneous macros
AC_DEFINE(POSIX_MALLOC_THRESHOLD, 10, [POSIX_MALLOC_THRESHOLD])
AC_HEADER_STDC
AC_CHECK_HEADERS(limits.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_TYPES([long long], [pcre_have_long_long="1"], [pcre_have_long_long="0"])
AC_CHECK_TYPES([unsigned long long], [pcre_have_ulong_long="1"], [pcre_have_ulong_long="0"])
AC_SUBST(pcre_have_long_long)
AC_SUBST(pcre_have_ulong_long)
dnl Checks for library functions.
AC_CHECK_FUNCS(bcopy memmove strerror strtoq strtoll)
dnl Handle --enable-utf8
AC_DEFINE(SUPPORT_UTF8, , [SUPPORT_UTF8])
# XXX
# dnl Handle --enable-unicode-properties
AC_DEFINE(SUPPORT_UCP, , [SUPPORT_UCP])
# dnl Handle --disable-stack-for-recursion
#
# AC_ARG_ENABLE(stack-for-recursion,
# [ --disable-stack-for-recursion disable use of stack recursion when matching],
# if test "$enableval" = "no"; then
# NO_RECURSE=-DNO_RECURSE
# fi
# )
AC_DEFINE(PCRE_EXPORT, , [PCRE_EXPORT - empty since we do not need pcre api be exported])
# dnl Handle --with-link-size=n
# AC_ARG_WITH(link-size,
# [ --with-link-size=2 internal link size (2, 3, or 4 allowed)],
# LINK_SIZE=-DLINK_SIZE=$withval
# )
AC_DEFINE(LINK_SIZE, 2, [The value of LINK_SIZE determines the number of bytes used to store dnl
links as offsets within the compiled regex. The default is 2, which allows for dnl
compiled patterns up to 64K long. This covers the vast majority of cases. dnl
However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows for dnl
longer patterns in extreme cases.])
# dnl Handle --enable-newline-is-cr
#
# AC_ARG_ENABLE(newline-is-cr,
# [ --enable-newline-is-cr use CR as the newline character],
# if test "$enableval" = "yes"; then
# NEWLINE=-DNEWLINE=13
# fi
# )
#
# dnl Handle --enable-newline-is-lf
#
# AC_ARG_ENABLE(newline-is-lf,
# [ --enable-newline-is-lf use LF as the newline character],
# if test "$enableval" = "yes"; then
# NEWLINE=-DNEWLINE=10
# fi
# )
AC_DEFINE(NEWLINE, '\n', [The value of NEWLINE determines the newline character])
# XXX
# dnl Handle --enable-ebcdic
#
# AC_ARG_ENABLE(ebcdic,
# [ --enable-ebcdic assume EBCDIC coding rather than ASCII],
# if test "$enableval" == "yes"; then
# EBCDIC=-DEBCDIC=1
# fi
# )
AC_DEFINE(EBCDIC, 0, [If you are compiling for a system that uses EBCDIC instead of ASCII dnl
character codes, define this macro as 1.])
# dnl Handle --with-match_limit=n
#
# AC_ARG_WITH(match-limit,
# [ --with-match-limit=10000000 default limit on internal looping)],
# MATCH_LIMIT=-DMATCH_LIMIT=$withval
# )
AC_DEFINE(MATCH_LIMIT, 10000000, [The value of MATCH_LIMIT determines the default number of times the match() dnl
function can be called during a single execution of pcre_exec(). (There is a dnl
runtime method of setting a different limit.) The limit exists in order to dnl
catch runaway regular expressions that take for ever to determine that they do dnl
not match. The default is set very large so that it does not accidentally catch dnl
legitimate cases.])
# dnl Handle --disable-stack-for-recursion
#
# AC_ARG_ENABLE(stack-for-recursion,
# [ --disable-stack-for-recursion disable use of stack recursion when matching],
# if test "$enableval" = "no"; then
# NO_RECURSE=-DNO_RECURSE
# fi
# )
# dnl Handle --with-link-size=n
# AC_ARG_WITH(link-size,
# [ --with-link-size=2 internal link size (2, 3, or 4 allowed)],
# LINK_SIZE=-DLINK_SIZE=$withval
# )
AC_DEFINE(LINK_SIZE, 2, [The value of LINK_SIZE determines the number of bytes used to store dnl
links as offsets within the compiled regex. The default is 2, which allows for dnl
compiled patterns up to 64K long. This covers the vast majority of cases. dnl
However, PCRE can also be compiled to use 3 or 4 bytes instead. This allows for dnl
longer patterns in extreme cases.])
AC_SUBST(PCRE_MAJOR)
AC_SUBST(PCRE_MINOR)
AC_SUBST(PCRE_DATE)
AC_SUBST(PCRE_VERSION)
# dnl Handle --with-match_limit=n
#
# AC_ARG_WITH(match-limit,
# [ --with-match-limit=10000000 default limit on internal looping)],
# MATCH_LIMIT=-DMATCH_LIMIT=$withval
# )
AC_DEFINE(MATCH_LIMIT, 10000000, [The value of MATCH_LIMIT determines the default number of times the match() dnl
function can be called during a single execution of pcre_exec(). (There is a dnl
runtime method of setting a different limit.) The limit exists in order to dnl
catch runaway regular expressions that take for ever to determine that they do dnl
not match. The default is set very large so that it does not accidentally catch dnl
legitimate cases.])
AC_SUBST(PCRE_MAJOR)
AC_SUBST(PCRE_MINOR)
AC_SUBST(PCRE_DATE)
AC_SUBST(PCRE_VERSION)
fi
]) # end of MOO_AC_PCRE

View File

@ -27,7 +27,7 @@
</ignoreparts>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<description></description>
<secondaryLanguages>
<language>C</language>
</secondaryLanguages>
@ -49,21 +49,21 @@
</run>
<configurations>
<debug>
<configargs>--enable-debug=full --enable-all-gcc-warnings </configargs>
<configargs>--enable-debug=full --enable-all-gcc-warnings</configargs>
<builddir>build/debug</builddir>
<ccompiler>kdevgccoptions</ccompiler>
<cxxcompiler>kdevgppoptions</cxxcompiler>
<f77compiler>kdevg77options</f77compiler>
<cflags>-O0 -g3</cflags>
<topsourcedir/>
<cppflags/>
<ccompilerbinary/>
<cxxcompilerbinary/>
<f77compilerbinary/>
<f77flags/>
<topsourcedir></topsourcedir>
<cppflags></cppflags>
<ccompilerbinary></ccompilerbinary>
<cxxcompilerbinary></cxxcompilerbinary>
<f77compilerbinary></f77compilerbinary>
<f77flags></f77flags>
<envvars/>
<ldflags/>
<cxxflags/>
<ldflags></ldflags>
<cxxflags></cxxflags>
</debug>
<gtk-print>
<configargs>--enable-debug --enable-all-gcc-warnings --without-python --prefix=/usr/local/gtk-print</configargs>
@ -221,15 +221,15 @@
</kdevautoproject>
<kdevdebugger>
<general>
<dbgshell/>
<dbgshell></dbgshell>
<programargs>--g-fatal-warnings</programargs>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>true</floatingtoolbar>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
</general>
<display>
<staticmembers>true</staticmembers>
@ -291,16 +291,16 @@
</kdevdoctreeview>
<kdevfilecreate>
<filetypes>
<type icon="source" ext="g" name="GAP source" create="template" >
<type icon="source" ext="g" create="template" name="GAP source" >
<descr>A new empty GAP source file</descr>
</type>
<type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
<type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
<descr>A new empty C++ file.</descr>
</type>
<type icon="source_h" ext="h" name="C/C++ Header" create="template" >
<type icon="source_h" ext="h" create="template" name="C/C++ Header" >
<descr>A new empty header file for C/C++.</descr>
</type>
<type icon="source_c" ext="c" name="C Source" create="template" >
<type icon="source_c" ext="c" create="template" name="C Source" >
<descr>A new empty C file.</descr>
</type>
</filetypes>
@ -327,7 +327,7 @@
</codecompletion>
<references/>
<creategettersetter>
<prefixGet/>
<prefixGet></prefixGet>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>
@ -337,7 +337,7 @@
<qt>
<used>false</used>
<version>3</version>
<root/>
<root></root>
</qt>
</kdevcppsupport>
<kdevdocumentation>

View File

@ -49,12 +49,18 @@
* mooutils/eggregex.c
*****************************************************************************/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "moo/mooutils/eggregex.h"
#ifdef MOO_BUILD_PCRE
#include "moo/mooutils/pcre/pcre.h"
#include <glib.h>
#else
#include <pcre.h>
#endif
/* FIXME when this is in glib */
#define _(s) s
@ -109,8 +115,8 @@ egg_regex_new (const gchar *pattern,
gint erroffset;
gint capture_count;
_pcre_malloc = (gpointer (*) (size_t)) g_malloc;
_pcre_free = g_free;
pcre_malloc = (gpointer (*) (size_t)) g_malloc;
pcre_free = g_free;
regex->ref_count = 1;
@ -126,8 +132,8 @@ egg_regex_new (const gchar *pattern,
regex->match_opts = match_options | PCRE_NO_UTF8_CHECK;
/* compile the pattern */
regex->regex = _pcre_compile (pattern, regex->compile_opts,
&errmsg, &erroffset, NULL);
regex->regex = pcre_compile (pattern, regex->compile_opts,
&errmsg, &erroffset, NULL);
/* if the compilation failed, set the error member and return
* immediately */
@ -144,8 +150,8 @@ egg_regex_new (const gchar *pattern,
/* otherwise, find out how many sub patterns exist in this pattern,
* and setup the offsets array and n_offsets accordingly */
_pcre_fullinfo (regex->regex, regex->extra,
PCRE_INFO_CAPTURECOUNT, &capture_count);
pcre_fullinfo (regex->regex, regex->extra,
PCRE_INFO_CAPTURECOUNT, &capture_count);
regex->n_offsets = (capture_count + 1) * 3;
regex->offsets = g_new0 (gint, regex->n_offsets);
@ -235,7 +241,7 @@ egg_regex_optimize (EggRegex *regex,
g_return_if_fail (regex != NULL && regex->regex != NULL);
regex->extra = _pcre_study (regex->regex, 0, &errmsg);
regex->extra = pcre_study (regex->regex, 0, &errmsg);
if (errmsg)
{
@ -280,10 +286,10 @@ egg_regex_match (EggRegex *regex,
regex->string_len = string_len;
/* perform the match */
regex->matches = _pcre_exec (regex->regex, regex->extra,
string, regex->string_len, 0,
regex->match_opts | match_options,
regex->offsets, regex->n_offsets);
regex->matches = pcre_exec (regex->regex, regex->extra,
string, regex->string_len, 0,
regex->match_opts | match_options,
regex->offsets, regex->n_offsets);
/* if the regex matched, set regex->pos to the character past the
* end of the match.
@ -312,10 +318,10 @@ egg_regex_match_extended (EggRegex *regex,
regex->string_len = string_len;
/* perform the match */
regex->matches = _pcre_exec (regex->regex, regex->extra,
string, regex->string_len, string_index,
regex->match_opts | match_options,
regex->offsets, regex->n_offsets);
regex->matches = pcre_exec (regex->regex, regex->extra,
string, regex->string_len, string_index,
regex->match_opts | match_options,
regex->offsets, regex->n_offsets);
/* if the regex matched, set regex->pos to the character past the
* end of the match.
@ -369,11 +375,11 @@ egg_regex_match_next (EggRegex *regex,
}
/* perform the match */
regex->matches = _pcre_exec (regex->regex, regex->extra,
string + regex->pos,
regex->string_len - regex->pos,
0, regex->match_opts | match_options,
regex->offsets, regex->n_offsets);
regex->matches = pcre_exec (regex->regex, regex->extra,
string + regex->pos,
regex->string_len - regex->pos,
0, regex->match_opts | match_options,
regex->offsets, regex->n_offsets);
/* if the regex matched, adjust the offsets array to take into account
* the fact that the string they're out of is shorter than the string
@ -419,8 +425,8 @@ egg_regex_fetch (EggRegex *regex,
if (match_num >= regex->matches)
return NULL;
_pcre_get_substring (string, regex->offsets, regex->matches,
match_num, (const char **)&match);
pcre_get_substring (string, regex->offsets, regex->matches,
match_num, (const char **)&match);
return match;
}
@ -472,9 +478,9 @@ egg_regex_fetch_named (EggRegex *regex,
{
gchar *match;
_pcre_get_named_substring (regex->regex,
string, regex->offsets, regex->matches,
name, (const char **)&match);
pcre_get_named_substring (regex->regex,
string, regex->offsets, regex->matches,
name, (const char **)&match);
return match;
}
@ -500,8 +506,8 @@ egg_regex_fetch_all (EggRegex *regex,
if (regex->matches < 0)
return NULL;
_pcre_get_substring_list (string, regex->offsets,
regex->matches, (const char ***)&listptr);
pcre_get_substring_list (string, regex->offsets,
regex->matches, (const char ***)&listptr);
if (listptr)
{
@ -1376,5 +1382,5 @@ egg_regex_get_string_number (EggRegex *regex,
{
g_return_val_if_fail (regex != NULL, PCRE_ERROR_NULL);
g_return_val_if_fail (name != NULL, PCRE_ERROR_NULL);
return _pcre_get_stringnumber (regex->regex, name);
return pcre_get_stringnumber (regex->regex, name);
}

View File

@ -28,9 +28,13 @@ moopcre_sources = \
$(moopcre)/ucp.h \
$(moopcre)/ucpinternal.h
$(moopcre)/pcre_internal.h: $(moopcre)/pcre.h
if MOO_BUILD_PCRE
moo_sources += $(moopcre_sources)
else
moo_extra_dist += $(moopcre_sources)
endif
moo_extra_dist += \
$(moopcre)/AUTHORS \
$(moopcre)/COPYING \