[gnome-terminal] all: Remove GRegex use and require PCRE2



commit ef7a345fedd40a69836dfb9c226983e95f0d2e1f
Author: Christian Persch <chpe gnome org>
Date:   Thu Aug 4 17:56:27 2016 +0200

    all: Remove GRegex use and require PCRE2
    
    Now that vte requires PCRE2, there's no need anymore for
    the --without-pcre2 configure switch.

 configure.ac                  |   26 ++------------------------
 src/terminal-screen.c         |   35 +----------------------------------
 src/terminal-search-popover.c |   34 ----------------------------------
 src/terminal-search-popover.h |    4 ----
 src/terminal-window.c         |   16 ----------------
 5 files changed, 3 insertions(+), 112 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 704c055..6eeb79d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,27 +77,6 @@ for target in $($PKG_CONFIG --variable targets gdk-$GTK_API_VERSION); do
   esac
 done
 
-# PCRE2
-
-AC_MSG_CHECKING([whether PCRE2 support is requested])
-AC_ARG_WITH([pcre2],
-  [AS_HELP_STRING([--without-pcre2],[Disable pcre2 support])],
-  [],[with_pcre2=yes])
-AC_MSG_RESULT([$with_pcre2])
-
-PCRE2_PKGS=
-if test "$with_pcre2" = "yes"; then
-  PCRE2_PKGS="libpcre2-8 >= $PCRE2_REQUIRED"
-
-  PKG_CHECK_MODULES([PCRE2],[$PCRE2_PKGS],,
-    [AC_MSG_ERROR([PCRE2 requested but libpcre2-8 not found. Use --without-pcre2 to disable PCRE2])])
-
-  AC_DEFINE([WITH_PCRE2],[1],[Define to 1 to enable pcre2 support])
-  EXTRA_DEPS="$EXTRA_DEPS $PCRE2_PKGS"
-fi
-
-AM_CONDITIONAL([WITH_PCRE2],[test "$with_pcre2" = "yes"])
-
 # pkg-config checks
 
 PKG_CHECK_MODULES([TERM],
@@ -108,8 +87,8 @@ PKG_CHECK_MODULES([TERM],
    gsettings-desktop-schemas >= $GSETTINGS_DESKTOP_SCHEMAS_REQUIRED
    dconf >= $DCONF_REQUIRED
    uuid
-   $PLATFORM_DEPS
-   $PCRE2_PKGS])
+   libpcre2-8 >= $PCRE2_REQUIRED
+   $PLATFORM_DEPS])
 
 # ****
 # Vala
@@ -409,7 +388,6 @@ gnome-terminal-$VERSION:
       prefix:                 ${prefix}
       source code location:   ${srcdir}
       compiler:               ${CC}
-      PCRE2:                  ${with_pcre2}
       gterminal:              ${enable_gterminal}
       DBus interface dir:     ${dbusinterfacedir}
       DBus service dir:       ${dbusservicedir}
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index d7858b2..9a0b450 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -19,10 +19,7 @@
 #include "config.h"
 #define _GNU_SOURCE /* for dup3 */
 
-#ifdef WITH_PCRE2
 #include "terminal-pcre2.h"
-#endif
-
 #include "terminal-regex.h"
 #include "terminal-screen.h"
 
@@ -184,13 +181,8 @@ static const TerminalRegexPattern extra_regex_patterns[] = {
   { "(0[Xx][[:xdigit:]]+|[[:digit:]]+)", FLAVOR_NUMBER },
 };
 
-#ifdef WITH_PCRE2
 static VteRegex **url_regexes;
 static VteRegex **extra_regexes;
-#else
-static GRegex **url_regexes;
-static GRegex **extra_regexes;
-#endif
 static TerminalURLFlavor *url_regex_flavors;
 static TerminalURLFlavor *extra_regex_flavors;
 static guint n_url_regexes;
@@ -223,27 +215,18 @@ free_tag_data (TagData *tagdata)
 static void
 precompile_regexes (const TerminalRegexPattern *regex_patterns,
                     guint n_regexes,
-#ifdef WITH_PCRE2
                     VteRegex ***regexes,
-#else
-                    GRegex ***regexes,
-#endif
                     TerminalURLFlavor **regex_flavors)
 {
   guint i;
 
-#ifdef WITH_PCRE2
   *regexes = g_new0 (VteRegex*, n_regexes);
-#else
-  *regexes = g_new0 (GRegex*, n_regexes);
-#endif
   *regex_flavors = g_new0 (TerminalURLFlavor, n_regexes);
 
   for (i = 0; i < n_regexes; ++i)
     {
       GError *error = NULL;
 
-#ifdef WITH_PCRE2
       (*regexes)[i] = vte_regex_new_for_match (regex_patterns[i].pattern, -1,
                                                PCRE2_UTF | PCRE2_NO_UTF_CHECK | PCRE2_MULTILINE,
                                                &error);
@@ -254,13 +237,6 @@ precompile_regexes (const TerminalRegexPattern *regex_patterns,
         g_printerr ("Failed to JIT regex '%s': %s\n", regex_patterns[i].pattern, error->message);
         g_clear_error (&error);
       }
-#else
-      (*regexes)[i] = g_regex_new (regex_patterns[i].pattern,
-                                   G_REGEX_OPTIMIZE |
-                                   G_REGEX_MULTILINE,
-                                   0, &error);
-      g_assert_no_error (error);
-#endif
 
       (*regex_flavors)[i] = regex_patterns[i].flavor;
     }
@@ -386,11 +362,7 @@ terminal_screen_init (TerminalScreen *screen)
 
       tag_data = g_slice_new (TagData);
       tag_data->flavor = url_regex_flavors[i];
-#ifdef WITH_PCRE2
       tag_data->tag = vte_terminal_match_add_regex (terminal, url_regexes[i], 0);
-#else
-      tag_data->tag = vte_terminal_match_add_gregex (terminal, url_regexes[i], 0);
-#endif
       vte_terminal_match_set_cursor_type (terminal, tag_data->tag, URL_MATCH_CURSOR);
 
       priv->match_tags = g_slist_prepend (priv->match_tags, tag_data);
@@ -2002,12 +1974,7 @@ terminal_screen_check_extra (TerminalScreen *screen,
   memset(matches, 0, sizeof(char*) * n_extra_regexes);
 
   if (
-#ifdef WITH_PCRE2
-      vte_terminal_event_check_regex_simple(
-#else
-      vte_terminal_event_check_gregex_simple(
-#endif
-                                             VTE_TERMINAL (screen),
+      vte_terminal_event_check_regex_simple (VTE_TERMINAL (screen),
                                              event,
                                              extra_regexes,
                                              n_extra_regexes,
diff --git a/src/terminal-search-popover.c b/src/terminal-search-popover.c
index 198dc64..4dbc195 100644
--- a/src/terminal-search-popover.c
+++ b/src/terminal-search-popover.c
@@ -23,10 +23,7 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
-#ifdef WITH_PCRE2
 #include "terminal-pcre2.h"
-#endif
-
 #include "terminal-search-popover.h"
 #include "terminal-intl.h"
 #include "terminal-window.h"
@@ -68,11 +65,7 @@ struct _TerminalSearchPopoverPrivate
   gboolean regex_caseless;
   gboolean regex_multiline;
   char *regex_pattern;
-#ifdef WITH_PCRE2
   VteRegex *regex;
-#else
-  GRegex *regex;
-#endif
 };
 
 enum {
@@ -283,18 +276,13 @@ update_regex (TerminalSearchPopover *popover)
     return;
 
   if (priv->regex) {
-#ifdef WITH_PCRE2
     vte_regex_unref (priv->regex);
-#else
-    g_regex_unref (priv->regex);
-#endif
   }
 
   g_clear_pointer (&priv->regex_pattern, g_free);
 
   /* FIXME: if comping the regex fails, show the error message somewhere */
   if (search_text[0] != '\0') {
-#ifdef WITH_PCRE2
     guint32 compile_flags;
 
     compile_flags = PCRE2_UTF | PCRE2_NO_UTF_CHECK;
@@ -308,17 +296,7 @@ update_regex (TerminalSearchPopover *popover)
         (!vte_regex_jit (priv->regex, PCRE2_JIT_COMPLETE, NULL) ||
          !vte_regex_jit (priv->regex, PCRE2_JIT_PARTIAL_SOFT, NULL))) {
     }
-#else
-    GRegexCompileFlags compile_flags;
 
-    compile_flags = G_REGEX_OPTIMIZE;
-    if (caseless)
-      compile_flags |= G_REGEX_CASELESS;
-    if (multiline)
-      compile_flags |= G_REGEX_MULTILINE;
-
-    priv->regex = g_regex_new (pattern, compile_flags, 0, &error);
-#endif
     if (priv->regex != NULL)
       gs_transfer_out_value (&priv->regex_pattern, &pattern);
   } else {
@@ -431,11 +409,7 @@ terminal_search_popover_finalize (GObject *object)
   TerminalSearchPopoverPrivate *priv = PRIV (popover);
 
   if (priv->regex) {
-#ifdef WITH_PCRE2
     vte_regex_unref (priv->regex);
-#else
-    g_regex_unref (priv->regex);
-#endif
   }
 
   g_free (priv->regex_pattern);
@@ -504,11 +478,7 @@ terminal_search_popover_class_init (TerminalSearchPopoverClass *klass)
 
   pspecs[PROP_REGEX] =
     g_param_spec_boxed ("regex", NULL, NULL,
-#ifdef WITH_PCRE2
                         VTE_TYPE_REGEX,
-#else
-                        G_TYPE_REGEX,
-#endif
                         G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
 
   pspecs[PROP_WRAP_AROUND] =
@@ -556,11 +526,7 @@ terminal_search_popover_new (GtkWidget *relative_to_widget)
  *
  * Returns: (transfer none): the search regex, or %NULL
  */
-#ifdef WITH_PCRE2
 VteRegex *
-#else
-GRegex *
-#endif
 terminal_search_popover_get_regex (TerminalSearchPopover *popover)
 {
   g_return_val_if_fail (TERMINAL_IS_SEARCH_POPOVER (popover), NULL);
diff --git a/src/terminal-search-popover.h b/src/terminal-search-popover.h
index 813f0f3..10771d9 100644
--- a/src/terminal-search-popover.h
+++ b/src/terminal-search-popover.h
@@ -39,11 +39,7 @@ GType terminal_search_popover_get_type (void);
 
 TerminalSearchPopover *terminal_search_popover_new (GtkWidget *relative_to_widget);
 
-#ifdef WITH_PCRE2
 VteRegex *
-#else
-GRegex *
-#endif
           terminal_search_popover_get_regex (TerminalSearchPopover *popover);
 
 gboolean terminal_search_popover_get_wrap_around (TerminalSearchPopover *popover);
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 82b1b10..46676a5 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -911,21 +911,13 @@ search_popover_notify_regex_cb (TerminalSearchPopover *popover,
                                 TerminalWindow *window)
 {
   TerminalWindowPrivate *priv = window->priv;
-#ifdef WITH_PCRE2
   VteRegex *regex;
-#else
-  GRegex *regex;
-#endif
 
   if (G_UNLIKELY (priv->active_screen == NULL))
     return;
 
   regex = terminal_search_popover_get_regex (popover);
-#ifdef WITH_PCRE2
   vte_terminal_search_set_regex (VTE_TERMINAL (priv->active_screen), regex, 0);
-#else
-  vte_terminal_search_set_gregex (VTE_TERMINAL (priv->active_screen), regex, 0);
-#endif
 
   terminal_window_update_search_sensitivity (priv->active_screen, window);
 }
@@ -1000,11 +992,7 @@ action_find_cb (GSimpleAction *action,
   } else if (g_str_equal (mode, "previous")) {
     vte_terminal_search_find_previous (VTE_TERMINAL (priv->active_screen));
   } else if (g_str_equal (mode, "clear")) {
-#ifdef WITH_PCRE2
     vte_terminal_search_set_regex (VTE_TERMINAL (priv->active_screen), NULL, 0);
-#else
-    vte_terminal_search_set_gregex (VTE_TERMINAL (priv->active_screen), NULL, 0);
-#endif
   } else
     return;
 }
@@ -1813,11 +1801,7 @@ terminal_window_update_search_sensitivity (TerminalScreen *screen,
   if (screen != priv->active_screen)
     return;
 
-#ifdef WITH_PCRE2
   can_search = vte_terminal_search_get_regex (VTE_TERMINAL (screen)) != NULL;
-#else
-  can_search = vte_terminal_search_get_gregex (VTE_TERMINAL (screen)) != NULL;
-#endif
 
   action = gtk_action_group_get_action (priv->action_group, "SearchFindNext");
   gtk_action_set_sensitive (action, can_search);


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