]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
scanner: Accept \R and \N escape sequences in regex literals
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 14 May 2018 07:31:32 +0000 (09:31 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 21 May 2018 19:13:48 +0000 (21:13 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=749576

tests/Makefile.am
tests/parser/bug749576.vala [new file with mode: 0644]
vala/valageniescanner.vala
vala/valascanner.vala

index 8bdd1d7547275b527c213e5c55c2a1db614110c8..f27cd25a6b9eca97100d92f9f1872e1ef2644f43 100644 (file)
@@ -268,6 +268,7 @@ TESTS = \
        gir/bug742012.test \
        gir/bug788775.test \
        gir/delegate-alias-without-target.test \
+       parser/bug749576.vala \
        $(NULL)
 
 NON_NULL_TESTS = \
diff --git a/tests/parser/bug749576.vala b/tests/parser/bug749576.vala
new file mode 100644 (file)
index 0000000..8aa961a
--- /dev/null
@@ -0,0 +1,29 @@
+void main() {
+       unowned string a = "first line\nnext line";
+       unowned string b = "first line\rnext line";
+       unowned string c = "first \tline\r\nnext \tline";
+
+       assert (/\Rnext/.match (a));
+       assert (/\Rnext/.match (b));
+       assert (/\Rnext/.match (c));
+
+       try {
+               var r = new Regex ("\\Rnext");
+               assert (r.match (a));
+
+               var r2 = new Regex ("""\Rnext""");
+               assert (r2.match (a));
+       } catch {
+       }
+
+       assert (/\Nline/.match (c));
+
+       try {
+               var r = new Regex ("\\Nline");
+               assert (r.match (c));
+
+               var r2 = new Regex ("""\Nline""");
+               assert (r2.match (c));
+       } catch {
+       }
+}
index 95a89842d7d9abbe5e5f9cad652aa23d3c42beb7..8de367c361a97cfffa9c3843e7fe3023fd00444f 100644 (file)
@@ -208,7 +208,9 @@ public class Vala.Genie.Scanner {
                                                case 'B':
                                                case 'f':
                                                case 'n':
+                                               case 'N':
                                                case 'r':
+                                               case 'R':
                                                case 't':
                                                case 'a':
                                                case 'A':
index 8b50a59d4eb94c90b80796c7a316b886f334e867..7c4c75c0c2ad340210ec33c961bfc54b832fcba8 100644 (file)
@@ -193,7 +193,9 @@ public class Vala.Scanner {
                                                case 'B':
                                                case 'f':
                                                case 'n':
+                                               case 'N':
                                                case 'r':
+                                               case 'R':
                                                case 't':
                                                case 'v':
                                                case 'a':