[gtksourceview] implregex: cleanup setting of regex errors



commit 127f0ad30b1344b254b259e0761cac92c5bd33ae
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jul 2 14:28:43 2021 -0700

    implregex: cleanup setting of regex errors

 gtksourceview/implregex.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/gtksourceview/implregex.c b/gtksourceview/implregex.c
index a18b1fbb..0e45a61d 100644
--- a/gtksourceview/implregex.c
+++ b/gtksourceview/implregex.c
@@ -132,25 +132,25 @@ static gboolean
 set_regex_error (GError **error,
                  int      rc)
 {
-       if (rc > 0)
+       if (rc < PCRE2_ERROR_NOMATCH && rc != PCRE2_ERROR_PARTIAL)
        {
-               return FALSE;
-       }
+               if (error != NULL)
+               {
+                       guchar errstr[128];
 
-       if (error != NULL)
-       {
-               guchar errstr[128];
+                       pcre2_get_error_message (rc, errstr, sizeof errstr - 1);
+                       errstr[sizeof errstr - 1] = 0;
 
-               pcre2_get_error_message (rc, errstr, sizeof errstr - 1);
-               errstr[sizeof errstr - 1] = 0;
+                       g_set_error_literal (error,
+                                            G_REGEX_ERROR,
+                                            G_REGEX_ERROR_MATCH,
+                                            (const gchar *)errstr);
+               }
 
-               g_set_error_literal (error,
-                                    G_REGEX_ERROR,
-                                    G_REGEX_ERROR_MATCH,
-                                    (const gchar *)errstr);
+               return TRUE;
        }
 
-       return TRUE;
+       return FALSE;
 }
 
 ImplRegex *


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