[vte] regex: Always set the GError from the PCRE2 error



commit 08a2fbb5e53b46ec2aaa4cc9e9af0fa0fb8b7044
Author: Christian Persch <chpe gnome org>
Date:   Sat Dec 26 12:27:22 2015 +0100

    regex: Always set the GError from the PCRE2 error
    
    Fix a thinko; PCRE2 does return positive and negative error codes.

 src/vte/vteenums.h |    2 +-
 src/vteregex.cc    |   16 ++++++----------
 2 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/src/vte/vteenums.h b/src/vte/vteenums.h
index 3fa4a47..a0777bb 100644
--- a/src/vte/vteenums.h
+++ b/src/vte/vteenums.h
@@ -125,7 +125,7 @@ typedef enum {
  *   built without PCRE2 support
  *
  * An enum type for regex errors. In addition to the values listed above,
- * any PCRE2_ERR* value (which areall negative values) may occur.
+ * any PCRE2 error values may occur.
  *
  * Since: 0.44
  */
diff --git a/src/vteregex.cc b/src/vteregex.cc
index 3deebba..7ecc575 100644
--- a/src/vteregex.cc
+++ b/src/vteregex.cc
@@ -76,17 +76,13 @@ static gboolean
 set_gerror_from_pcre_error(int errcode,
                            GError **error)
 {
-        if (errcode < 0) {
-                PCRE2_UCHAR8 buf[128];
-                int n;
-
-                n = pcre2_get_error_message_8(errcode, buf, sizeof (buf));
-                g_assert(n >= 0);
-                g_set_error_literal(error, VTE_REGEX_ERROR, errcode, (const char*)buf);
-                return FALSE;
-        }
+        PCRE2_UCHAR8 buf[128];
+        int n;
 
-        return TRUE;
+        n = pcre2_get_error_message_8(errcode, buf, sizeof (buf));
+        g_assert(n >= 0);
+        g_set_error_literal(error, VTE_REGEX_ERROR, errcode, (const char*)buf);
+        return FALSE;
 }
 
 #else


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