[vala/staging] Revert "Make more use of native GLib.Regex syntax"



commit 0c0c4e6fec54a78c1b41a218dd669d78dbdc046a
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Dec 27 07:41:09 2021 +0100

    Revert "Make more use of native GLib.Regex syntax"
    
    This reverts commit b2ef0ed8d2c37a813f9ad8b35c7a7e4a1d639e1c.

 ccode/valaccodewriter.vala    | 5 ++++-
 libvaladoc/errorreporter.vala | 7 ++++++-
 vala/valareport.vala          | 9 ++++++++-
 3 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala
index 11a3b0e31..21cc41720 100644
--- a/ccode/valaccodewriter.vala
+++ b/ccode/valaccodewriter.vala
@@ -48,6 +48,8 @@ public class Vala.CCodeWriter {
                get { return _bol; }
        }
 
+       static GLib.Regex fix_indent_regex;
+
        private string temp_filename;
        private bool file_exists;
 
@@ -244,7 +246,8 @@ public class Vala.CCodeWriter {
                        bool first = true;
 
                        // discard tabs at beginning of line
-                       unowned Regex fix_indent_regex = /^\t+/;
+                       if (fix_indent_regex == null)
+                               fix_indent_regex = new GLib.Regex ("^\t+");;
 
                        foreach (unowned string line in text.split ("\n")) {
                                if (!first) {
diff --git a/libvaladoc/errorreporter.vala b/libvaladoc/errorreporter.vala
index b6035e0fe..68b09a8ef 100644
--- a/libvaladoc/errorreporter.vala
+++ b/libvaladoc/errorreporter.vala
@@ -137,7 +137,12 @@ public class Valadoc.ErrorReporter : Object {
         * }}}
         */
        public bool set_colors (string str) {
-               unowned Regex val_regex = /^\\s*[0-9]+(;[0-9]*)*\\s*$/;
+               Regex val_regex;
+               try {
+                       val_regex = new Regex ("^\\s*[0-9]+(;[0-9]*)*\\s*$");
+               } catch (RegexError e) {
+                       assert_not_reached ();
+               }
 
                string error_color = null;
                string warning_color = null;
diff --git a/vala/valareport.vala b/vala/valareport.vala
index 9665c2d11..3d3a95fc8 100644
--- a/vala/valareport.vala
+++ b/vala/valareport.vala
@@ -106,6 +106,8 @@ public class Vala.Report {
 
        public bool enable_warnings { get; set; default = true; }
 
+       static GLib.Regex val_regex;
+
        /**
         * Set all colors by string
         *
@@ -114,7 +116,12 @@ public class Vala.Report {
         * }}}
         */
        public bool set_colors (string str, Report.Colored colored_output = Report.Colored.AUTO) {
-               unowned Regex val_regex = /^\\s*[0-9]+(;[0-9]*)*\\s*$/;
+               try {
+                       if (val_regex == null)
+                               val_regex = new Regex ("^\\s*[0-9]+(;[0-9]*)*\\s*$");
+               } catch (RegexError e) {
+                       assert_not_reached ();
+               }
 
                string error_color = null;
                string warning_color = null;


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