[vte] regex: Require PCRE2



commit 4003f01ef2e732ae313bcf870c5364cfa6cf372f
Author: Christian Persch <chpe gnome org>
Date:   Thu Aug 4 17:51:44 2016 +0200

    regex: Require PCRE2
    
    Drop --without-pcre2 and just require PCRE2 to be present.

 configure.ac            |   23 +-------
 src/Makefile.am         |    3 -
 src/app.vala            |   28 ++-------
 src/vte.cc              |  155 ++++++++++++++++-------------------------------
 src/vteapp.c            |   17 +-----
 src/vtegtk.cc           |    8 ---
 src/vteinternal.hh      |   17 +----
 src/vteregex.cc         |   57 +-----------------
 src/vteregexinternal.hh |    2 -
 9 files changed, 64 insertions(+), 246 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 281438f..9110b40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -233,26 +233,6 @@ fi
 
 AM_CONDITIONAL([WITH_GNUTLS],[test "$with_gnutls" = "yes"])
 
-# 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([libpcre2-8 version $PCRE2_REQUIRED requested but not found. Use --without-pcre2 to 
disable PCRE2])])
-
-  AC_DEFINE([WITH_PCRE2],[1],[Define to 1 to enable pcre2 support])
-fi
-
-AM_CONDITIONAL([WITH_PCRE2],[test "$with_pcre2" = "yes"])
-
 # GLIB tools
 
 AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal])
@@ -281,7 +261,7 @@ AC_CHECK_FUNCS([ceil floor round])
 
 # Search for the required modules.
 
-VTE_PKGS="glib-2.0 >= $GLIB_REQUIRED gobject-2.0 pango >= $PANGO_REQUIRED gtk+-$GTK_API_VERSION >= 
$GTK_REQUIRED gobject-2.0 gio-2.0 gio-unix-2.0 zlib $GNUTLS_PKGS $PCRE2_PKGS"
+VTE_PKGS="glib-2.0 >= $GLIB_REQUIRED gobject-2.0 pango >= $PANGO_REQUIRED gtk+-$GTK_API_VERSION >= 
$GTK_REQUIRED gobject-2.0 gio-2.0 gio-unix-2.0 zlib libpcre2-8 >= $PCRE2_REQUIRED $GNUTLS_PKGS"
 PKG_CHECK_MODULES([VTE],[$VTE_PKGS])
 AC_SUBST([VTE_PKGS])
 
@@ -448,7 +428,6 @@ cat <<EOF | tee -a config.log
 
 Configuration for libvte $VERSION for gtk+-$GTK_API_VERSION
        GNUTLS: $with_gnutls
-        PCRE2: $with_pcre2
        Installing Glade catalogue: $enable_glade_catalogue
        Debugging: $enable_debug
        Introspection: $enable_introspection
diff --git a/src/Makefile.am b/src/Makefile.am
index 3fd0f3a..8d72475 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -307,9 +307,6 @@ endif
 if HAVE_GTK_3_16
 vte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_VALAFLAGS += -D GTK_3_16
 endif
-if WITH_PCRE2
-vte_@VTE_API_MAJOR_VERSION@_@VTE_API_MINOR_VERSION@_VALAFLAGS += -D WITH_PCRE2
-endif
 
 CLEANFILES += \
        app.c \
diff --git a/src/app.vala b/src/app.vala
index 275ae3a..4fef749 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -39,9 +39,7 @@ class SearchPopover : Gtk.Popover
   private bool regex_multiline = false;
   private string? regex_pattern = null;
   private GLib.Regex? regex_gregex = null;
-#if WITH_PCRE2
   private Vte.Regex? regex_regex = null;
-#endif
 
   public SearchPopover(Vte.Terminal term,
                        Gtk.Widget relative_to)
@@ -73,11 +71,8 @@ class SearchPopover : Gtk.Popover
 
   private bool have_regex()
   {
-    return regex_gregex != null
-#if WITH_PCRE2
-      || regex_regex != null
-#endif
-      ;
+    return regex_gregex != null ||
+      regex_regex != null;
   }
 
   private void update_sensitivity()
@@ -95,9 +90,7 @@ class SearchPopover : Gtk.Popover
     bool caseless = false;
     bool multiline = false;
     GLib.Regex? gregex = null;
-#if WITH_PCRE2
     Vte.Regex? regex = null;
-#endif
 
     search_text = search_entry.get_text();
     caseless = !match_case_checkbutton.active;
@@ -123,7 +116,6 @@ class SearchPopover : Gtk.Popover
 
     if (search_text.length != 0) {
       try {
-#if WITH_PCRE2
         if (!App.Options.no_pcre) {
           uint32 flags;
 
@@ -141,9 +133,7 @@ class SearchPopover : Gtk.Popover
             if (e.code != -45 /* PCRE2_ERROR_JIT_BADOPTION */) /* JIT not supported */
               printerr("JITing regex \"%s\" failed: %s\n", pattern, e.message);
           }
-        } else
-#endif /* WITH_PCRE2 */
-        {
+        } else {
           GLib.RegexCompileFlags flags;
 
           flags = GLib.RegexCompileFlags.OPTIMIZE;
@@ -158,25 +148,19 @@ class SearchPopover : Gtk.Popover
         regex_pattern = pattern;
         search_entry.set_tooltip_text(null);
       } catch (Error e) {
-#if WITH_PCRE2
         regex = null;
-#endif
         gregex = null;
         search_entry.set_tooltip_text(e.message);
       }
     } else {
-#if WITH_PCRE2
       regex = null;
-#endif
       gregex = null;
       search_entry.set_tooltip_text(null);
     }
 
-#if WITH_PCRE2
     if (!App.Options.no_pcre)
       terminal.search_set_regex(regex, 0);
     else
-#endif
       terminal.search_set_gregex(gregex, 0);
 
     update_sensitivity();
@@ -396,7 +380,7 @@ class Window : Gtk.ApplicationWindow
     for (int i = 0; i < dingus.length; ++i) {
       try {
         int tag;
-#if WITH_PCRE2
+
         if (!App.Options.no_pcre) {
           Vte.Regex regex;
 
@@ -411,9 +395,7 @@ class Window : Gtk.ApplicationWindow
           }
 
           tag = terminal.match_add_regex(regex, 0);
-        } else 
-#endif
-        {
+        } else {
           GLib.Regex regex;
 
           regex = new GLib.Regex(dingus[i],
diff --git a/src/vte.cc b/src/vte.cc
index 0348b3b..d77d162 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -1365,8 +1365,6 @@ VteTerminalPrivate::match_rowcol_to_offset(vte::grid::column_t column,
         return true;
 }
 
-#ifdef WITH_PCRE2
-
 /* creates a pcre match context with appropriate limits */
 pcre2_match_context_8 *
 VteTerminalPrivate::create_match_context()
@@ -1586,8 +1584,6 @@ VteTerminalPrivate::match_check_internal_pcre(vte::grid::column_t column,
        return dingu_match;
 }
 
-#endif /* WITH_PCRE2 */
-
 /*
  * vte_terminal_match_check_internal:
  * @terminal:
@@ -1623,11 +1619,7 @@ VteTerminalPrivate::match_check_internal(vte::grid::column_t column,
         *start = 0;
         *end = 0;
 
-#ifdef WITH_PCRE2
         return match_check_internal_pcre(column, row, tag, start, end);
-#else
-        return nullptr;
-#endif
 }
 
 char *
@@ -1832,7 +1824,6 @@ VteTerminalPrivate::regex_match_check_extra(GdkEvent *event,
                                             guint32 match_flags,
                                             char **matches)
 {
-#ifdef WITH_PCRE2
        gsize offset, sattr, eattr;
         pcre2_match_data_8 *match_data;
         pcre2_match_context_8 *match_context;
@@ -1882,9 +1873,6 @@ VteTerminalPrivate::regex_match_check_extra(GdkEvent *event,
         pcre2_match_context_free_8(match_context);
 
         return any_matches;
-#else
-        return false;
-#endif
 }
 
 /* Emit an adjustment changed signal on our adjustment object. */
@@ -10729,8 +10717,6 @@ VteTerminalPrivate::write_contents_sync (GOutputStream *stream,
 
 /* TODO Add properties & signals */
 
-#ifdef WITH_PCRE2
-
 /*
  * VteTerminalPrivate::search_set_regex:
  * @regex: (allow-none): a #VteRegex, or %nullptr
@@ -10762,8 +10748,6 @@ VteTerminalPrivate::search_set_regex (VteRegex *regex,
         return true;
 }
 
-#endif /* WITH_PCRE2 */
-
 bool
 VteTerminalPrivate::search_set_wrap_around(bool wrap)
 {
@@ -10775,11 +10759,8 @@ VteTerminalPrivate::search_set_wrap_around(bool wrap)
 }
 
 bool
-VteTerminalPrivate::search_rows(
-#ifdef WITH_PCRE2
-                                pcre2_match_context_8 *match_context,
+VteTerminalPrivate::search_rows(pcre2_match_context_8 *match_context,
                                 pcre2_match_data_8 *match_data,
-#endif
                                 vte::grid::row_t start_row,
                                 vte::grid::row_t end_row,
                                 bool backward)
@@ -10802,44 +10783,40 @@ VteTerminalPrivate::search_rows(
                             nullptr,
                             &row_text_length);
 
-#ifdef WITH_PCRE2
-                int (* match_fn) (const pcre2_code_8 *,
-                                  PCRE2_SPTR8, PCRE2_SIZE, PCRE2_SIZE, uint32_t,
-                                  pcre2_match_data_8 *, pcre2_match_context_8 *);
-                gsize *ovector, so, eo;
-                int r;
+        int (* match_fn) (const pcre2_code_8 *,
+                          PCRE2_SPTR8, PCRE2_SIZE, PCRE2_SIZE, uint32_t,
+                          pcre2_match_data_8 *, pcre2_match_context_8 *);
+        gsize *ovector, so, eo;
+        int r;
 
-                if (_vte_regex_get_jited(m_search_regex.regex))
-                        match_fn = pcre2_jit_match_8;
-                else
-                        match_fn = pcre2_match_8;
-
-                r = match_fn(_vte_regex_get_pcre(m_search_regex.regex),
-                             (PCRE2_SPTR8)row_text, row_text_length , /* subject, length */
-                             0, /* start offset */
-                             m_search_regex.match_flags |
-                             PCRE2_NO_UTF_CHECK | PCRE2_NOTEMPTY | PCRE2_PARTIAL_SOFT /* FIXME: HARD? */,
-                             match_data,
-                             match_context);
-
-                if (r == PCRE2_ERROR_NOMATCH)
-                        return false;
-                // FIXME: handle partial matches (PCRE2_ERROR_PARTIAL)
-                if (r < 0)
-                        return false;
+        if (_vte_regex_get_jited(m_search_regex.regex))
+                match_fn = pcre2_jit_match_8;
+        else
+                match_fn = pcre2_match_8;
 
-                ovector = pcre2_get_ovector_pointer_8(match_data);
-                so = ovector[0];
-                eo = ovector[1];
-                if (G_UNLIKELY(so == PCRE2_UNSET || eo == PCRE2_UNSET))
-                        return false;
-
-                start = so;
-                end = eo;
-                word = g_strndup(row_text, end - start);
-#else
+        r = match_fn(_vte_regex_get_pcre(m_search_regex.regex),
+                     (PCRE2_SPTR8)row_text, row_text_length , /* subject, length */
+                     0, /* start offset */
+                     m_search_regex.match_flags |
+                     PCRE2_NO_UTF_CHECK | PCRE2_NOTEMPTY | PCRE2_PARTIAL_SOFT /* FIXME: HARD? */,
+                     match_data,
+                     match_context);
+
+        if (r == PCRE2_ERROR_NOMATCH)
+                return false;
+        // FIXME: handle partial matches (PCRE2_ERROR_PARTIAL)
+        if (r < 0)
                 return false;
-#endif /* WITH_PCRE2 */
+
+        ovector = pcre2_get_ovector_pointer_8(match_data);
+        so = ovector[0];
+        eo = ovector[1];
+        if (G_UNLIKELY(so == PCRE2_UNSET || eo == PCRE2_UNSET))
+                return false;
+
+        start = so;
+        end = eo;
+        word = g_strndup(row_text, end - start);
 
        /* Fetch text again, with attributes */
        g_free (row_text);
@@ -10880,11 +10857,8 @@ VteTerminalPrivate::search_rows(
 }
 
 bool
-VteTerminalPrivate::search_rows_iter(
-#ifdef WITH_PCRE2
-                                     pcre2_match_context_8 *match_context,
+VteTerminalPrivate::search_rows_iter(pcre2_match_context_8 *match_context,
                                      pcre2_match_data_8 *match_data,
-#endif
                                      vte::grid::row_t start_row,
                                      vte::grid::row_t end_row,
                                      bool backward)
@@ -10902,11 +10876,8 @@ VteTerminalPrivate::search_rows_iter(
                                row = find_row_data(iter_start_row);
                        } while (row && row->attr.soft_wrapped);
 
-                       if (search_rows(
-#ifdef WITH_PCRE2
-                                                      match_context, match_data,
-#endif
-                                                      iter_start_row, iter_end_row, backward))
+                       if (search_rows(match_context, match_data,
+                                        iter_start_row, iter_end_row, backward))
                                return true;
                }
        } else {
@@ -10919,11 +10890,8 @@ VteTerminalPrivate::search_rows_iter(
                                iter_end_row++;
                        } while (row && row->attr.soft_wrapped);
 
-                       if (search_rows(
-#ifdef WITH_PCRE2
-                                                      match_context, match_data,
-#endif
-                                                      iter_start_row, iter_end_row, backward))
+                       if (search_rows(match_context, match_data,
+                                        iter_start_row, iter_end_row, backward))
                                return true;
                }
        }
@@ -10937,20 +10905,17 @@ VteTerminalPrivate::search_find (bool backward)
         vte::grid::row_t buffer_start_row, buffer_end_row;
         vte::grid::row_t last_start_row, last_end_row;
         bool match_found = true;
-#ifdef WITH_PCRE2
-        pcre2_match_context_8 *match_context = nullptr;
-        pcre2_match_data_8 *match_data = nullptr;
-#endif
+
+        if (m_search_regex.regex == nullptr)
+                return false;
 
        /* TODO
         * Currently We only find one result per extended line, and ignore columns
         * Moreover, the whole search thing is implemented very inefficiently.
         */
 
-#ifdef WITH_PCRE2
-        match_context = create_match_context();
-        match_data = pcre2_match_data_create_8(256 /* should be plenty */, nullptr /* general context */);
-#endif
+        auto match_context = create_match_context();
+        auto match_data = pcre2_match_data_create_8(256 /* should be plenty */, nullptr /* general context 
*/);
 
        buffer_start_row = _vte_ring_delta (m_screen->row_data);
        buffer_end_row = _vte_ring_next (m_screen->row_data);
@@ -10968,18 +10933,12 @@ VteTerminalPrivate::search_find (bool backward)
        /* If search fails, we make an empty selection at the last searched
         * position... */
        if (backward) {
-               if (search_rows_iter (
-#ifdef WITH_PCRE2
-                                                   match_context, match_data,
-#endif
-                                                   buffer_start_row, last_start_row, backward))
+               if (search_rows_iter (match_context, match_data,
+                                      buffer_start_row, last_start_row, backward))
                        goto found;
                if (m_search_wrap_around &&
-                   search_rows_iter (
-#ifdef WITH_PCRE2
-                                                   match_context, match_data,
-#endif
-                                                   last_end_row, buffer_end_row, backward))
+                   search_rows_iter (match_context, match_data,
+                                      last_end_row, buffer_end_row, backward))
                        goto found;
                if (m_has_selection) {
                        if (m_search_wrap_around)
@@ -10989,18 +10948,12 @@ VteTerminalPrivate::search_find (bool backward)
                }
                 match_found = false;
        } else {
-               if (search_rows_iter (
-#ifdef WITH_PCRE2
-                                                   match_context, match_data,
-#endif
-                                                   last_end_row, buffer_end_row, backward))
+               if (search_rows_iter (match_context, match_data,
+                                      last_end_row, buffer_end_row, backward))
                        goto found;
                if (m_search_wrap_around &&
-                   search_rows_iter (
-#ifdef WITH_PCRE2
-                                                   match_context, match_data,
-#endif
-                                                   buffer_start_row, last_start_row, backward))
+                   search_rows_iter (match_context, match_data,
+                                      buffer_start_row, last_start_row, backward))
                        goto found;
                if (m_has_selection) {
                        if (m_search_wrap_around)
@@ -11013,12 +10966,8 @@ VteTerminalPrivate::search_find (bool backward)
 
  found:
 
-#ifdef WITH_PCRE2
-        if (match_data)
-                pcre2_match_data_free_8(match_data);
-        if (match_context)
-                pcre2_match_context_free_8(match_context);
-#endif
+        pcre2_match_data_free_8(match_data);
+        pcre2_match_context_free_8(match_context);
 
        return match_found;
 }
diff --git a/src/vteapp.c b/src/vteapp.c
index f0163f1..96a3732 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -33,9 +33,7 @@
 #undef VTE_DISABLE_DEPRECATED
 #include <vte/vte.h>
 
-#ifdef WITH_PCRE2
 #include "vtepcre2.h"
-#endif
 
 #include <glib/gi18n.h>
 
@@ -48,9 +46,7 @@ static const char *builtin_dingus[] = {
   NULL
 };
 
-#ifdef WITH_PCRE2
 static gboolean use_gregex = FALSE;
-#endif
 
 static void
 window_title_changed(GtkWidget *widget, gpointer win)
@@ -169,7 +165,6 @@ button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer data)
                                vte_terminal_match_remove(terminal, tag);
                        }
                }
-#ifdef WITH_PCRE2
                 if (!use_gregex) {
                         VteRegex *regex = vte_regex_new_for_match("\\d+", -1, PCRE2_UTF, NULL);
                         has_extra_match = vte_terminal_event_check_regex_simple(terminal,
@@ -178,9 +173,7 @@ button_pressed(GtkWidget *widget, GdkEventButton *event, gpointer data)
                                                                                 0,
                                                                                 &extra_match);
                         vte_regex_unref(regex);
-                } else
-#endif
-                {
+                } else {
                         GRegex *regex = g_regex_new("\\d+", 0, 0, NULL);
                         has_extra_match = vte_terminal_event_check_gregex_simple(terminal,
                                                                                  (GdkEvent*)event,
@@ -565,7 +558,6 @@ add_dingus (VteTerminal *terminal,
         for (i = 0; dingus[i]; ++i) {
                 GRegex *gregex = NULL;
                 GError *error = NULL;
-#ifdef WITH_PCRE2
                 VteRegex *regex = NULL;
 
                 if (!use_gregex)
@@ -573,7 +565,6 @@ add_dingus (VteTerminal *terminal,
                                                         PCRE2_UTF | PCRE2_NO_UTF_CHECK,
                                                         &error);
                 else
-#endif
                         gregex = g_regex_new(dingus[i], G_REGEX_OPTIMIZE | G_REGEX_MULTILINE, 0, &error);
 
                 if (error) {
@@ -583,17 +574,13 @@ add_dingus (VteTerminal *terminal,
                         continue;
                 }
 
-#ifdef WITH_PCRE2
                 if (!use_gregex)
                         id = vte_terminal_match_add_regex(terminal, regex, 0);
                 else
-#endif
                         id = vte_terminal_match_add_gregex(terminal, gregex, 0);
 
-#ifdef WITH_PCRE2
                 if (regex)
                         vte_regex_unref(regex);
-#endif
                 if (gregex)
                         g_regex_unref (gregex);
 
@@ -659,13 +646,11 @@ main(int argc, char **argv)
                        G_OPTION_ARG_STRING_ARRAY, &dingus,
                        "Add regex highlight", NULL
                },
-#ifdef WITH_PCRE2
                {
                        "gregex", 0, 0,
                        G_OPTION_ARG_NONE, &use_gregex,
                        "Use GRegex instead of PCRE2", NULL
                },
-#endif
                {
                        "no-rewrap", 'R', G_OPTION_FLAG_REVERSE,
                        G_OPTION_ARG_NONE, &rewrap,
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index d875a95..4be6f96 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -1517,12 +1517,6 @@ vte_get_features (void)
 #else
                 "-GNUTLS"
 #endif
-                " "
-#ifdef WITH_PCRE2
-                "+PCRE2"
-#else
-                "-PCRE2"
-#endif
                 ;
 }
 
@@ -2012,12 +2006,10 @@ vte_terminal_search_set_regex (VteTerminal *terminal,
                                VteRegex    *regex,
                                guint32      flags)
 {
-#ifdef WITH_PCRE2
         g_return_if_fail(VTE_IS_TERMINAL(terminal));
         g_return_if_fail(regex == NULL || _vte_regex_has_purpose(regex, VteRegexPurpose::search));
 
         IMPL(terminal)->search_set_regex(regex, flags);
-#endif
 }
 
 /**
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index a5f1bbe..cff2157 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -26,10 +26,8 @@
 #include "vteconv.h"
 #include "buffer.h"
 
-#ifdef WITH_PCRE2
 #include "vtepcre2.h"
 #include "vteregexinternal.hh"
-#endif
 
 typedef enum {
         VTE_REGEX_CURSOR_GDKCURSOR,
@@ -984,7 +982,7 @@ public:
                                     gsize *offset_ptr,
                                     gsize *sattr_ptr,
                                     gsize *eattr_ptr);
-#ifdef WITH_PCRE2
+
         pcre2_match_context_8 *create_match_context();
         bool match_check_pcre(pcre2_match_data_8 *match_data,
                               pcre2_match_context_8 *match_context,
@@ -1003,7 +1001,6 @@ public:
                                         int *tag,
                                         gsize *start,
                                         gsize *end);
-#endif
 
         char *match_check_internal(vte::grid::column_t column,
                                    vte::grid::row_t row,
@@ -1025,24 +1022,16 @@ public:
         void feed_focus_event_initial();
         void maybe_feed_focus_event(bool in);
 
-#ifdef WITH_PCRE2
         bool search_set_regex (VteRegex *regex,
                                guint32 flags);
-#endif
 
-        bool search_rows(
-#ifdef WITH_PCRE2
-                         pcre2_match_context_8 *match_context,
+        bool search_rows(pcre2_match_context_8 *match_context,
                          pcre2_match_data_8 *match_data,
-#endif
                          vte::grid::row_t start_row,
                          vte::grid::row_t end_row,
                          bool backward);
-        bool search_rows_iter(
-#ifdef WITH_PCRE2
-                              pcre2_match_context_8 *match_context,
+        bool search_rows_iter(pcre2_match_context_8 *match_context,
                               pcre2_match_data_8 *match_data,
-#endif
                               vte::grid::row_t start_row,
                               vte::grid::row_t end_row,
                               bool backward);
diff --git a/src/vteregex.cc b/src/vteregex.cc
index d6b6a29..039f289 100644
--- a/src/vteregex.cc
+++ b/src/vteregex.cc
@@ -27,30 +27,19 @@
 #include "vtemacros.h"
 #include "vteenums.h"
 #include "vteregex.h"
-
-#ifdef WITH_PCRE2
 #include "vtepcre2.h"
-#endif /* WITH_PCRE2 */
 
 #include "vteregexinternal.hh"
 
 struct _VteRegex {
         volatile int ref_count;
         VteRegexPurpose purpose;
-#ifdef WITH_PCRE2
         pcre2_code_8 *code;
-#endif /* WITH_PCRE2 */
 };
 
-#ifdef WITH_PCRE2
 #define DEFAULT_COMPILE_OPTIONS (PCRE2_UTF)
 #define JIT_OPTIONS (PCRE2_JIT_COMPLETE)
 #define DEFAULT_MATCH_OPTIONS (0)
-#else
-#define DEFAULT_COMPILE_OPTIONS (0
-#define JIT_OPTIONS (0)
-#define DEFAULT_MATCH_OPTIONS (0)
-#endif /* WITH_PCRE2 */
 
 /* GRegex translation */
 
@@ -81,8 +70,6 @@ translate_flags(FlagTranslation const* const table,
 
 /* internal */
 
-#ifdef WITH_PCRE2
-
 static VteRegex *
 regex_new(pcre2_code_8 *code,
           VteRegexPurpose purpose)
@@ -117,18 +104,6 @@ set_gerror_from_pcre_error(int errcode,
         return FALSE;
 }
 
-#else
-
-static gboolean
-set_unsupported_error(GError **error)
-{
-        g_set_error_literal(error, VTE_REGEX_ERROR, VTE_REGEX_ERROR_NOT_SUPPORTED,
-                            "PCRE2 not supported");
-        return FALSE;
-}
-
-#endif /* WITH_PCRE2 */
-
 G_DEFINE_BOXED_TYPE(VteRegex, vte_regex,
                     vte_regex_ref, (GBoxedFreeFunc)vte_regex_unref)
 
@@ -147,9 +122,8 @@ vte_regex_ref(VteRegex *regex)
 {
         g_return_val_if_fail (regex, NULL);
 
-#ifdef WITH_PCRE2
         g_atomic_int_inc (&regex->ref_count);
-#endif
+
         return regex;
 }
 
@@ -167,10 +141,9 @@ vte_regex_unref(VteRegex *regex)
 {
         g_return_val_if_fail (regex, NULL);
 
-#ifdef WITH_PCRE2
         if (g_atomic_int_dec_and_test (&regex->ref_count))
                 regex_free (regex);
-#endif
+
         return NULL;
 }
 
@@ -181,7 +154,6 @@ vte_regex_new(VteRegexPurpose purpose,
               guint32     flags,
               GError    **error)
 {
-#ifdef WITH_PCRE2
         pcre2_code_8 *code;
         int r, errcode;
         guint32 v;
@@ -217,10 +189,6 @@ vte_regex_new(VteRegexPurpose purpose,
         }
 
         return regex_new(code, purpose);
-#else
-        set_unsupported_error(error);
-        return NULL;
-#endif /* WITH_PCRE2 */
 }
 
 VteRegex *
@@ -231,7 +199,6 @@ _vte_regex_new_gregex(VteRegexPurpose purpose,
 
         guint32 pflags = 0;
 
-#ifdef WITH_PCRE2
         static FlagTranslation const table[] = {
                 { G_REGEX_CASELESS,        PCRE2_CASELESS        },
                 { G_REGEX_MULTILINE,       PCRE2_MULTILINE       },
@@ -252,7 +219,6 @@ _vte_regex_new_gregex(VteRegexPurpose purpose,
         if (gflags != 0) {
                 g_warning("Incompatible GRegex compile flags left untranslated: %08x", gflags);
         }
-#endif
 
         GError *err = nullptr;
         auto regex = vte_regex_new(purpose, g_regex_get_pattern(gregex), -1, pflags, &err);
@@ -362,7 +328,6 @@ VteRegex *
 vte_regex_new_pcre(pcre2_code_8 *code,
                    GError      **error)
 {
-#ifdef WITH_PCRE2
         guint32 flags;
 
         g_return_val_if_fail(code != NULL, NULL);
@@ -373,10 +338,6 @@ vte_regex_new_pcre(pcre2_code_8 *code,
         g_return_val_if_fail(flags & PCRE2_NEVER_BACKSLASH_C, NULL);
 
         return regex_new(code);
-#else
-        set_unsupported_error(error);
-        return NULL;
-#endif
 }
 #endif
 
@@ -387,7 +348,6 @@ _vte_regex_has_purpose(VteRegex *regex,
         return regex->purpose == purpose;
 }
 
-#ifdef WITH_PCRE2
 /*
  * _vte_regex_get_pcre:
  * @regex: a #VteRegex
@@ -398,15 +358,10 @@ _vte_regex_has_purpose(VteRegex *regex,
 const pcre2_code_8 *
 _vte_regex_get_pcre(VteRegex *regex)
 {
-#ifdef WITH_PCRE2
         g_return_val_if_fail(regex != NULL, NULL);
 
         return regex->code;
-#else
-        return NULL;
-#endif
 }
-#endif
 
 /**
  * vte_regex_jit:
@@ -421,7 +376,6 @@ vte_regex_jit(VteRegex *regex,
               guint     flags,
               GError  **error)
 {
-#ifdef WITH_PCRE2
         int r;
 
         g_return_val_if_fail(regex != NULL, FALSE);
@@ -431,9 +385,6 @@ vte_regex_jit(VteRegex *regex,
                 return set_gerror_from_pcre_error(r, error);
 
         return TRUE;
-#else
-        return set_unsupported_error(error);
-#endif /* WITH_PCRE2 */
 }
 
 /*
@@ -447,7 +398,6 @@ vte_regex_jit(VteRegex *regex,
 gboolean
 _vte_regex_get_jited(VteRegex *regex)
 {
-#ifdef WITH_PCRE2
         PCRE2_SIZE s;
         int r;
 
@@ -456,7 +406,4 @@ _vte_regex_get_jited(VteRegex *regex)
         r = pcre2_pattern_info_8(regex->code, PCRE2_INFO_JITSIZE, &s);
 
         return r == 0 && s != 0;
-#else
-        return FALSE;
-#endif
 }
diff --git a/src/vteregexinternal.hh b/src/vteregexinternal.hh
index eaf42dc..95f4b7d 100644
--- a/src/vteregexinternal.hh
+++ b/src/vteregexinternal.hh
@@ -27,9 +27,7 @@ gboolean _vte_regex_has_purpose(VteRegex *regex,
 
 gboolean _vte_regex_get_jited(VteRegex *regex);
 
-#ifdef WITH_PCRE2
 const pcre2_code_8 *_vte_regex_get_pcre (VteRegex *regex);
-#endif
 
 /* GRegex translation */
 VteRegex *_vte_regex_new_gregex(VteRegexPurpose purpose,


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