[glib/wip/pcre-update: 4/8] regex: Remove internal copy of libpcre



commit beef0a92abab1eebf9fb1882e7ebf26a6facfc50
Author: Christian Persch <chpe gnome org>
Date:   Sat Nov 22 19:36:11 2014 +0100

    regex: Remove internal copy of libpcre
    
    The internal copy of libpcre is at version 8.31, which is outdated, buggy
    and vulnerable. Updating to a more recent version is difficult because
    glib doesn't contain all the neccessary unicode data tables, see
    [https://bugzilla.gnome.org/show_bug.cgi?id=689791] and
    [https://bugzilla.gnome.org/show_bug.cgi?id=684222].
    
    The reason for copying libpcre into glib was that it is patched to use
    the glib unicode data tables instead of its own. However, it turns out
    that libgio-2.0 links to libselinux, which in turn links to libpcre.
    This means that all gtk+/gnome applications actually have two copies of
    libpcre, more than negating any savings from the shared unicode tables.
    
    Bump the required pcre version to the latest, which is 8.36.
    
    Keep the --with-pcre configure switch which will be repurposed to select
    between pcre and pcre2 soon.

 configure.ac                   |   29 +-
 glib/Makefile.am               |   25 +-
 glib/gregex.c                  |    4 -
 glib/pcre/COPYING              |    5 -
 glib/pcre/Makefile.am          |   64 -
 glib/pcre/makefile.msc         |   30 -
 glib/pcre/pcre.h               |  507 ---
 glib/pcre/pcre_byte_order.c    |  288 --
 glib/pcre/pcre_chartables.c    |  198 -
 glib/pcre/pcre_compile.c       | 8215 ----------------------------------------
 glib/pcre/pcre_config.c        |  170 -
 glib/pcre/pcre_dfa_exec.c      | 3613 ------------------
 glib/pcre/pcre_exec.c          | 7146 ----------------------------------
 glib/pcre/pcre_fullinfo.c      |  206 -
 glib/pcre/pcre_get.c           |  587 ---
 glib/pcre/pcre_globals.c       |   90 -
 glib/pcre/pcre_internal.h      | 2334 ------------
 glib/pcre/pcre_jit_compile.c   | 7499 ------------------------------------
 glib/pcre/pcre_newline.c       |  184 -
 glib/pcre/pcre_ord2utf8.c      |   97 -
 glib/pcre/pcre_string_utils.c  |  168 -
 glib/pcre/pcre_study.c         | 1534 --------
 glib/pcre/pcre_tables.c        |  602 ---
 glib/pcre/pcre_valid_utf8.c    |  299 --
 glib/pcre/pcre_xclass.c        |  198 -
 glib/pcre/ucp.h                |  179 -
 glib/tests/regex.c             |    7 +-
 glib/update-pcre/Makefile.am   |    6 -
 glib/update-pcre/digitab.patch |   94 -
 glib/update-pcre/memory.patch  |   40 -
 glib/update-pcre/ucp.patch     |  834 ----
 glib/update-pcre/update.sh     |  159 -
 32 files changed, 14 insertions(+), 35397 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f32071e..f5e9b44 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2461,16 +2461,15 @@ dnl *********************
 dnl *** GRegex checks ***
 dnl *********************
 
-PCRE_REQUIRED_VERSION=8.13
+PCRE_REQUIRED_VERSION=8.36
 
-# Check if we should use the internal or the system-supplied pcre
-AC_ARG_WITH(pcre,
-            [AS_HELP_STRING([--with-pcre=@<:@internal/system@:>@],
-                            [whether to use system PCRE [default=internal]])])
+# Check which pcre we should use
+AC_ARG_WITH([pcre],
+            [AS_HELP_STRING([--with-pcre=@<:@pcre@:>@],
+                            [which pcre library to use (default: pcre)])],
+            [],[with_pcre=pcre])
 
-AM_CONDITIONAL(USE_SYSTEM_PCRE, [test "x$with_pcre" = xsystem])
-
-AS_IF([ test "x$with_pcre" = xsystem], [
+AS_IF([ test "x$with_pcre" != xno], [
   PKG_CHECK_MODULES(PCRE,
                     libpcre >= $PCRE_REQUIRED_VERSION)
   AC_CACHE_CHECK([for Unicode support in PCRE],glib_cv_pcre_has_unicode,[
@@ -2499,21 +2498,11 @@ AS_IF([ test "x$with_pcre" = xsystem], [
   fi
   AC_SUBST(PCRE_CFLAGS)
   AC_SUBST(PCRE_LIBS)
-  AC_DEFINE(USE_SYSTEM_PCRE, [], [using the system-supplied PCRE library])
   PCRE_REQUIRES=libpcre
   AC_SUBST(PCRE_REQUIRES)
 ], [
-  # If using gcc 4 pass -Wno-pointer-sign when compiling the internal PCRE
-  AS_IF([ test x"$GCC" = xyes], [
-    AC_MSG_CHECKING([whether compiler understands -Wno-pointer-sign])
-    save_CFLAGS="$CFLAGS"
-    CFLAGS="$CFLAGS -Wno-pointer-sign"
-    AC_TRY_COMPILE([],[],[PCRE_WARN_CFLAGS="$PCRE_WARN_CFLAGS -Wno-pointer-sign"
-                          AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
-    CFLAGS="$save_CFLAGS"
-  ])
+  AC_MSG_ERROR([building without pcre is not supported])
 ])
-AC_SUBST(PCRE_WARN_CFLAGS)
 
 dnl **********************
 dnl *** Win32 API libs ***
@@ -3599,8 +3588,6 @@ glib/Makefile
 glib/glib.stp
 glib/libcharset/Makefile
 glib/gnulib/Makefile
-glib/pcre/Makefile
-glib/update-pcre/Makefile
 glib/tests/Makefile
 gmodule/Makefile
 gmodule/gmoduleconf.h
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 1b9e081..21f7b9f 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -26,21 +26,14 @@ PRINTF_SUBDIR = gnulib
 printf_la = gnulib/libgnulib.la
 endif 
 
-if USE_SYSTEM_PCRE
-else
-MAYBE_PCRE = pcre 
-endif
-
-SUBDIRS = libcharset $(PRINTF_SUBDIR) $(MAYBE_PCRE) update-pcre . tests
-DIST_SUBDIRS = libcharset gnulib pcre update-pcre tests
+SUBDIRS = libcharset $(PRINTF_SUBDIR) . tests
+DIST_SUBDIRS = libcharset gnulib tests
 
 AM_CPPFLAGS =                          \
        $(glib_INCLUDES)                \
-       $(pcre_inc)                     \
        -DG_LOG_DOMAIN=\"GLib\"         \
        $(GLIB_DEBUG_FLAGS)             \
-       -DGLIB_COMPILATION              \
-       -DPCRE_STATIC
+       -DGLIB_COMPILATION
 
 AM_CFLAGS = $(GLIB_WARN_CFLAGS)
 
@@ -339,16 +332,8 @@ glib_win32_res = glib-win32-res.o
 glib_win32_res_ldflag = -Wl,$(glib_win32_res)
 endif
 
-if USE_SYSTEM_PCRE
-pcre_lib = $(PCRE_LIBS)
-pcre_inc = $(PCRE_CFLAGS)
-else
-pcre_lib = pcre/libpcre.la
-pcre_inc =
-endif
-
-libglib_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS)
-libglib_2_0_la_LIBADD = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @ICONV_LIBS@ 
@G_LIBS_EXTRA@ $(pcre_lib) $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD)
+libglib_2_0_la_CFLAGS = $(AM_CFLAGS) $(GLIB_HIDDEN_VISIBILITY_CFLAGS) $(PCRE_CFLAGS)
+libglib_2_0_la_LIBADD = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ @ICONV_LIBS@ 
@G_LIBS_EXTRA@ $(PCRE_LIBS) $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD)
 libglib_2_0_la_DEPENDENCIES = libcharset/libcharset.la $(printf_la) @GIO@ @GSPAWN@ @PLATFORMDEP@ 
$(glib_win32_res) $(glib_def)
 
 libglib_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \
diff --git a/glib/gregex.c b/glib/gregex.c
index 1022dfb..0658041 100644
--- a/glib/gregex.c
+++ b/glib/gregex.c
@@ -23,11 +23,7 @@
 
 #include <string.h>
 
-#ifdef USE_SYSTEM_PCRE
 #include <pcre.h>
-#else
-#include "pcre/pcre.h"
-#endif
 
 #include "gtypes.h"
 #include "gregex.h"
diff --git a/glib/tests/regex.c b/glib/tests/regex.c
index b886b06..92679b9 100644
--- a/glib/tests/regex.c
+++ b/glib/tests/regex.c
@@ -2446,7 +2446,7 @@ main (int argc, char *argv[])
   /* Test that othercasing in our pcre/glib integration is bug-for-bug compatible
    * with pcre's internal tables. Bug #678273 */
   TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "DŽ", -1, 0, 0, TRUE);
-  TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "Dž", -1, 0, 0, FALSE);
+  TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "Dž", -1, 0, 0, TRUE);
   TEST_MATCH("[DŽ]", G_REGEX_CASELESS, 0, "dž", -1, 0, 0, TRUE);
 
   /* TEST_MATCH_NEXT#(pattern, string, string_len, start_position, ...) */
@@ -2628,11 +2628,6 @@ main (int argc, char *argv[])
   TEST_EXPAND("a", "a", "\\0130", FALSE, "X");
   TEST_EXPAND("a", "a", "\\\\\\0", FALSE, "\\a");
   TEST_EXPAND("a(?P<G>.)c", "xabcy", "X\\g<G>X", FALSE, "XbX");
-#ifndef USE_SYSTEM_PCRE
-  /* PCRE >= 8.34 no longer allows this usage. */
-  TEST_EXPAND("(.)(?P<1>.)", "ab", "\\1", FALSE, "a");
-  TEST_EXPAND("(.)(?P<1>.)", "ab", "\\g<1>", FALSE, "a");
-#endif
   TEST_EXPAND(".", EURO, "\\0", FALSE, EURO);
   TEST_EXPAND("(.)", EURO, "\\1", FALSE, EURO);
   TEST_EXPAND("(?P<G>.)", EURO, "\\g<G>", FALSE, EURO);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]