[vte/wip/pcre2: 2/2] widget: Remove obsolete workaround



commit f2037b6fca8eef210cca99acf86b9fa51094667e
Author: Christian Persch <chpe gnome org>
Date:   Mon Sep 28 20:09:22 2015 +0200

    widget: Remove obsolete workaround
    
    This used to be necessary when working with glibc's regex, but is
    unnecessary for both GRegex and PCRE2.

 src/vte.cc |   31 ++++++++-----------------------
 1 files changed, 8 insertions(+), 23 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 1f09a65..997bacb 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -1503,7 +1503,7 @@ vte_terminal_match_check_internal_pcre(VteTerminal *terminal,
        struct vte_match_regex *regex = NULL;
        struct _VteCharAttributes *attr = NULL;
        gssize line_length, offset, sattr, eattr, start_blank, end_blank, position;
-       gchar *line, eol;
+       gchar *line;
         pcre2_match_data_8 *match_data;
         pcre2_match_context_8 *match_context;
         gsize *ovector;
@@ -1609,22 +1609,17 @@ vte_terminal_match_check_internal_pcre(VteTerminal *terminal,
        offset -= sattr;
        eattr -= sattr;
 
-        /* END identical */
-
        line = terminal->pvt->match_contents + sattr;
         line_length = eattr;
 
-       /* temporarily shorten the contents to this row */
-        // FIXME obsolete
-       eol = line[eattr];
-       line[eattr] = '\0';
-
        start_blank = 0;
        end_blank = eattr;
 
         //        _vte_debug_print(VTE_DEBUG_REGEX, "Cursor offset: %" G_GSSIZE_FORMAT " in line with length 
%" G_GSSIZE_FORMAT "): %*s\n",
         //                         offset, line_length, -(int)line_length, line);
 
+        /* END identical */
+
         match_context = create_match_context();
         match_data = pcre2_match_data_create_8(256 /* should be plenty */, NULL /* general context */);
 
@@ -1727,9 +1722,6 @@ vte_terminal_match_check_internal_pcre(VteTerminal *terminal,
 
                                 vte_terminal_set_cursor_from_regex_match(terminal, regex);
 
-                                // FIXME obsolete
-                                line[eattr] = eol;
-
                                 pcre2_match_data_free_8(match_data);
                                 pcre2_match_context_free_8(match_context);
                                 return result;
@@ -1758,9 +1750,6 @@ vte_terminal_match_check_internal_pcre(VteTerminal *terminal,
         pcre2_match_data_free_8(match_data);
         pcre2_match_context_free_8(match_context);
 
-        // FIXME obsolete
-       line[eattr] = eol;
-
         // FIXME: WTF is this doing and why?
        if (start != NULL) {
                *start = sattr + start_blank;
@@ -1784,7 +1773,7 @@ vte_terminal_match_check_internal_gregex(VteTerminal *terminal,
        struct vte_match_regex *regex = NULL;
        struct _VteCharAttributes *attr = NULL;
        gssize line_length, sattr, eattr;
-       gchar *line, eol;
+       gchar *line;
         GMatchInfo *match_info;
 
        _vte_debug_print(VTE_DEBUG_REGEX,
@@ -1888,21 +1877,18 @@ vte_terminal_match_check_internal_gregex(VteTerminal *terminal,
        offset -= sattr;
        eattr -= sattr;
 
-        /* END identical */
-
        /* temporarily shorten the contents to this row */
        line = terminal->pvt->match_contents + sattr;
         line_length = eattr;
 
-       eol = line[eattr];
-       line[eattr] = '\0';
-
        start_blank = 0;
        end_blank = eattr;
 
         //        _vte_debug_print(VTE_DEBUG_REGEX, "Cursor offset: %" G_GSSIZE_FORMAT " in line with length 
%" G_GSSIZE_FORMAT "): %*s\n",
         //                         offset, line_length, -(int)line_length, line);
 
+        /* END identical */
+
        /* Now iterate over each regex we need to match against. */
        for (i = 0; i < terminal->pvt->match_regexes->len; i++) {
                regex = &g_array_index(terminal->pvt->match_regexes,
@@ -1919,7 +1905,7 @@ vte_terminal_match_check_internal_gregex(VteTerminal *terminal,
                 * matches, so we'll have to skip each match until we
                 * stop getting matches. */
                 if (!g_regex_match_full(regex->regex.gregex.regex,
-                                        line, -1, 0,
+                                        line, line_length, 0,
                                         regex->regex.gregex.match_flags,
                                         &match_info,
                                         NULL)) {
@@ -1974,7 +1960,6 @@ vte_terminal_match_check_internal_gregex(VteTerminal *terminal,
                                        }
                                         vte_terminal_set_cursor_from_regex_match(terminal, regex);
                                         result = g_match_info_fetch(match_info, 0);
-                                       line[eattr] = eol;
 
                                         g_match_info_free(match_info);
                                        return result;
@@ -2000,7 +1985,7 @@ vte_terminal_match_check_internal_gregex(VteTerminal *terminal,
 
                 g_match_info_free(match_info);
        }
-       line[eattr] = eol;
+
        if (start != NULL) {
                *start = sattr + start_blank;
        }


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