diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-12-22 09:16:52 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2021-12-22 09:16:52 +0100 |
commit | b2ef0ed8d2c37a813f9ad8b35c7a7e4a1d639e1c (patch) | |
tree | c6e10da018379be6b67f6118c5e6f15189f77a3b | |
parent | 73cd47c7c474d4601766a10e413e4e7512b810f2 (diff) | |
download | vala-b2ef0ed8d2c37a813f9ad8b35c7a7e4a1d639e1c.tar.gz |
Make more use of native GLib.Regex syntax
-rw-r--r-- | ccode/valaccodewriter.vala | 5 | ||||
-rw-r--r-- | libvaladoc/errorreporter.vala | 7 | ||||
-rw-r--r-- | vala/valareport.vala | 9 |
3 files changed, 3 insertions, 18 deletions
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala index 21cc41720..11a3b0e31 100644 --- a/ccode/valaccodewriter.vala +++ b/ccode/valaccodewriter.vala @@ -48,8 +48,6 @@ public class Vala.CCodeWriter { get { return _bol; } } - static GLib.Regex fix_indent_regex; - private string temp_filename; private bool file_exists; @@ -246,8 +244,7 @@ public class Vala.CCodeWriter { bool first = true; // discard tabs at beginning of line - if (fix_indent_regex == null) - fix_indent_regex = new GLib.Regex ("^\t+");; + unowned Regex fix_indent_regex = /^\t+/; foreach (unowned string line in text.split ("\n")) { if (!first) { diff --git a/libvaladoc/errorreporter.vala b/libvaladoc/errorreporter.vala index 68b09a8ef..b6035e0fe 100644 --- a/libvaladoc/errorreporter.vala +++ b/libvaladoc/errorreporter.vala @@ -137,12 +137,7 @@ public class Valadoc.ErrorReporter : Object { * }}} */ public bool set_colors (string str) { - Regex val_regex; - try { - val_regex = new Regex ("^\\s*[0-9]+(;[0-9]*)*\\s*$"); - } catch (RegexError e) { - assert_not_reached (); - } + unowned Regex val_regex = /^\\s*[0-9]+(;[0-9]*)*\\s*$/; string error_color = null; string warning_color = null; diff --git a/vala/valareport.vala b/vala/valareport.vala index 3d3a95fc8..9665c2d11 100644 --- a/vala/valareport.vala +++ b/vala/valareport.vala @@ -106,8 +106,6 @@ public class Vala.Report { public bool enable_warnings { get; set; default = true; } - static GLib.Regex val_regex; - /** * Set all colors by string * @@ -116,12 +114,7 @@ public class Vala.Report { * }}} */ public bool set_colors (string str, Report.Colored colored_output = Report.Colored.AUTO) { - try { - if (val_regex == null) - val_regex = new Regex ("^\\s*[0-9]+(;[0-9]*)*\\s*$"); - } catch (RegexError e) { - assert_not_reached (); - } + unowned Regex val_regex = /^\\s*[0-9]+(;[0-9]*)*\\s*$/; string error_color = null; string warning_color = null; |