Skip to content

Commit

Permalink
Add GRegex for regular expression matching. (#50075)
Browse files Browse the repository at this point in the history
2007-03-15  Marco Barisione <[email protected]>

	Add GRegex for regular expression matching.  (#50075)

	* configure.in: Handle GRegex compilation.

	* glib/gregex.c:
	* glib/gregex.h: Code for GRegex.

	* glib/Makefile.am:
	* glib/makefile.msc.in: Updated makefiles.

	* glib/pcre/*: Internal copy of PCRE.

	* glib/update-pcre/*: Stuff to automatically update the internal PCRE
	to a newer version.

	* tests/regex-test.c:
	* tests/Makefile.am:
	* tests/makefile.msc.in: Add tests for GRegex.

svn path=/trunk/; revision=5408
  • Loading branch information
barisione authored and Marco Barisione committed Mar 15, 2007
1 parent af86717 commit 0196d63
Show file tree
Hide file tree
Showing 54 changed files with 26,185 additions and 11 deletions.
21 changes: 21 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
2007-03-15 Marco Barisione <[email protected]>

Add GRegex for regular expression matching. (#50075)

* configure.in: Handle GRegex compilation.

* glib/gregex.c:
* glib/gregex.h: Code for GRegex.

* glib/Makefile.am:
* glib/makefile.msc.in: Updated makefiles.

* glib/pcre/*: Internal copy of PCRE.

* glib/update-pcre/*: Stuff to automatically update the internal PCRE
to a newer version.

* tests/regex-test.c:
* tests/Makefile.am:
* tests/makefile.msc.in: Add tests for GRegex.

2007-03-15 Chris Wilson <[email protected]>

* glib/gmain.c (g_main_dispatch): Replace a
Expand Down
72 changes: 71 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ AM_CONDITIONAL(MS_LIB_AVAILABLE, [test x$ms_librarian = xyes])
if test "$glib_native_win32" != yes; then
# libtool option to control which symbols are exported
# right now, symbols starting with _ are not exported
LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"'
LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^g.*"'
else
# We currently use .def files on Windows
LIBTOOL_EXPORT_OPTIONS=
Expand Down Expand Up @@ -2146,6 +2146,74 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
[broken_poll="no (cross compiling)"])
AC_MSG_RESULT($broken_poll)

dnl *********************
dnl *** GRegex checks ***
dnl *********************
PCRE_REQUIRED_VERSION=7.0

# Check if we should compile GRegex
AC_ARG_ENABLE(regex, AC_HELP_STRING([--disable-regex],
[disable the compilation of GRegex]),
[case "${enableval}" in
yes) enable_regex=true ;;
no) enable_regex=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-regex) ;;
esac],
[enable_regex=true])

AM_CONDITIONAL(ENABLE_REGEX, $enable_regex)

if test x$enable_regex = xtrue; then
# Check if we should use the internal or the system-supplied pcre
AC_ARG_WITH(pcre,
[AC_HELP_STRING([--with-pcre=@<:@internal/system@:>@],
[specify whether to use the internal or the
system-supplied PCRE library])])

AM_CONDITIONAL(USE_SYSTEM_PCRE, [test "x$with_pcre" = xsystem])

if test "x$with_pcre" = xsystem; then
PKG_CHECK_MODULES(PCRE,
libpcre >= $PCRE_REQUIRED_VERSION)
AC_CACHE_CHECK([for Unicode support in PCRE],glib_cv_pcre_has_unicode,[
CFLAGS="$PCRE_CFLAGS" LDFLAGS="$PCRE_LIBS"
AC_TRY_RUN([#include <pcre.h>
int main () {
int support;
pcre_config (PCRE_CONFIG_UTF8, &support);
if (!support)
return 1;
pcre_config (PCRE_CONFIG_UNICODE_PROPERTIES, &support);
if (!support)
return 1;
return 0;
}],
glib_cv_pcre_has_unicode=yes,
glib_cv_pcre_has_unicode=no,
glib_cv_pcre_has_unicode=yes)])
if test "$glib_cv_pcre_has_unicode" = "no"; then
AC_MSG_ERROR([*** The system-supplied PCRE does not support Unicode properties or UTF-8.])
fi
AC_SUBST(PCRE_CFLAGS)
AC_SUBST(PCRE_LIBS)
AC_DEFINE(USE_SYSTEM_PCRE, [], [using the system-supplied PCRE library])
else
# If using gcc 4 pass -Wno-pointer-sign when compiling the internal PCRE
if test x"$GCC" = xyes; then
AC_MSG_CHECKING([whether gcc understands -Wno-pointer-sign])
if test [`$CC --version | sed -e 's/[^0-9]*\([0-9]\).*/\1/' -e q`] -ge 4; then
PCRE_WARN_CFLAGS="$PCRE_WARN_CFLAGS -Wno-pointer-sign"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
fi
AC_SUBST(PCRE_WARN_CFLAGS)
else
AM_CONDITIONAL(USE_SYSTEM_PCRE, false])
fi

dnl **********************
dnl *** Win32 API libs ***
dnl **********************
Expand Down Expand Up @@ -2864,6 +2932,8 @@ Makefile
glib/Makefile
glib/libcharset/Makefile
glib/gnulib/Makefile
glib/pcre/Makefile
glib/update-pcre/Makefile
gmodule/Makefile
gmodule/gmoduleconf.h
gobject/Makefile
Expand Down
14 changes: 14 additions & 0 deletions docs/reference/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
2007-03-15 Marco Barisione <[email protected]>

Add GRegex for regular expression matching. (#50075)

* glib/Makefile.am:
* glib/glib-docs.sgml:
* glib/glib-sections.txt:
* glib/tmpl/glib-unused.sgml:
* glib/regex-syntax.sgml:
* glib/tmpl/gregex-unused.sgml:
* glib/tmpl/gregex.sgml: Add GRegex.

* glib/building.sgml: Document build options for GRegex.

2007-03-14 Stefan Kost <[email protected]>

* gobject/tmpl/gparamspec.sgml:
Expand Down
5 changes: 4 additions & 1 deletion docs/reference/glib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ IGNORE_HFILES= \
gmirroringtable.h \
gscripttable.h \
glib-mirroring-tab \
gnulib
gnulib \
pcre \
update-pcre

# Extra options to supply to gtkdoc-mkdb
MKDB_OPTIONS=--sgml-mode --output-format=xml --ignore-files=trio
Expand All @@ -55,6 +57,7 @@ content_files = \
changes.sgml \
compiling.sgml \
resources.sgml \
regex-syntax.sgml \
version.xml \
glib-gettextize.xml

Expand Down
72 changes: 72 additions & 0 deletions docs/reference/glib/building.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ How to compile GLib itself
e.g. POSIX threads, DCE threads or Solaris threads.
</para>
</listitem>
<listitem>
<para>
GRegex uses the the <ulink url="http://www.pcre.org/">PCRE library</ulink>
for regular expression matching. The default is to use the internal
version of PCRE that is patched to use GLib for memory management
and Unicode handling. If you prefer to use the system-supplied PCRE
library you can pass the --with-pcre=system option to configure,
but it is not recommended.
</para>
</listitem>
</itemizedlist>

</refsect1>
Expand Down Expand Up @@ -177,6 +187,13 @@ How to compile GLib itself
<group>
<arg>--with-threads=[none|posix|dce|win32]</arg>
</group>
<group>
<arg>--disable-regex</arg>
<arg>--enable-regex</arg>
</group>
<group>
<arg>--with-pcre=[internal|system]</arg>
</group>
<group>
<arg>--disable-included-printf</arg>
<arg>--enable-included-printf</arg>
Expand Down Expand Up @@ -361,6 +378,61 @@ How to compile GLib itself
</para>
</formalpara>

<formalpara>
<title><systemitem>--disable-regex</systemitem> and
<systemitem>--enable-regex</systemitem></title>

<para>
Do not compile GLib with regular expression support.
GLib will be smaller because it will not need the
PCRE library. This is however not recommended, as
programs may need GRegex.
</para>
</formalpara>

<formalpara>
<title><systemitem>--with-pcre</systemitem></title>

<para>
Specify whether to use the internal or the system-supplied
PCRE library.
<itemizedlist>
<listitem><para>
'internal' means that GRegex will be compiled to use
the internal PCRE library.
</para></listitem>

<listitem><para>
'system' means that GRegex will be compiled to use
the system-supplied PCRE library.
</para></listitem>
</itemizedlist>
Using the internal PCRE is the preferred solution:
<itemizedlist>
<listitem>
<para>
System-supplied PCRE has a separated copy of the big tables
used for Unicode handling.
</para>
</listitem>
<listitem>
<para>
Some systems have PCRE libraries compiled without some needed
features, such as UTF-8 and Unicode support.
</para>
</listitem>
<listitem>
<para>
PCRE uses some global variables for memory management and
other features. In the rare case of a program using both
GRegex and PCRE (maybe indirectly through a library),
this variables could lead to problems when they are modified.
</para>
</listitem>
</itemizedlist>
</para>
</formalpara>

<formalpara>
<title><systemitem>--disable-included-printf</systemitem> and
<systemitem>--enable-included-printf</systemitem></title>
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/glib/glib-docs.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<!ENTITY glib-Bookmarkfile SYSTEM "xml/bookmarkfile.xml">
<!ENTITY glib-Base64 SYSTEM "xml/base64.xml">
<!ENTITY glib-i18n SYSTEM "xml/i18n.xml">
<!ENTITY glib-Regex SYSTEM "xml/gregex.xml">
<!ENTITY glib-Version SYSTEM "xml/version.xml">

<!ENTITY glib-Compiling SYSTEM "compiling.sgml">
Expand All @@ -69,6 +70,7 @@
<!ENTITY glib-Running SYSTEM "running.sgml">
<!ENTITY glib-Resources SYSTEM "resources.sgml">
<!ENTITY glib-Changes SYSTEM "changes.sgml">
<!ENTITY glib-RegexSyntax SYSTEM "regex-syntax.sgml">

<!ENTITY glib-gettextize SYSTEM "glib-gettextize.xml">

Expand Down Expand Up @@ -101,6 +103,7 @@ synchronize their operation.
&glib-Compiling;
&glib-Running;
&glib-Changes;
&glib-RegexSyntax;
&glib-Resources;

</chapter>
Expand Down Expand Up @@ -151,6 +154,7 @@ synchronize their operation.
&glib-Shell;
&glib-Option;
&glib-Pattern-Matching;
&glib-Regex;
&glib-Markup;
&glib-Keyfile;
&glib-Bookmarkfile;
Expand Down
44 changes: 44 additions & 0 deletions docs/reference/glib/glib-sections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,50 @@ g_pattern_match_string
g_pattern_match_simple
</SECTION>

<SECTION>
<TITLE>Perl-compatible regular expressions</TITLE>
<FILE>gregex</FILE>
GRegexError
G_REGEX_ERROR
GRegexCompileFlags
GRegexMatchFlags
GRegex
GRegexEvalCallback
g_regex_new
g_regex_free
g_regex_optimize
g_regex_copy
g_regex_get_pattern
g_regex_clear
g_regex_match_simple
g_regex_match
g_regex_match_full
g_regex_match_next
g_regex_match_next_full
g_regex_match_all
g_regex_match_all_full
g_regex_get_match_count
g_regex_is_partial_match
g_regex_fetch
g_regex_fetch_pos
g_regex_fetch_named
g_regex_fetch_named_pos
g_regex_fetch_all
g_regex_get_string_number
g_regex_split_simple
g_regex_split
g_regex_split_full
g_regex_split_next
g_regex_split_next_full
g_regex_expand_references
g_regex_replace
g_regex_replace_literal
g_regex_replace_eval
g_regex_escape_string
<SUBSECTION Private>
g_regex_error_quark
</SECTION>

<SECTION>
<TITLE>Message Logging</TITLE>
<FILE>messages</FILE>
Expand Down
Loading

0 comments on commit 0196d63

Please sign in to comment.