[vala/0.38] scanner: Accept \R and \N escape sequences in regex literals
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.38] scanner: Accept \R and \N escape sequences in regex literals
- Date: Mon, 21 May 2018 16:25:03 +0000 (UTC)
commit 250ce01ac06b5546862645dcecff094b6fc813d5
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon May 14 09:31:32 2018 +0200
scanner: Accept \R and \N escape sequences in regex literals
https://bugzilla.gnome.org/show_bug.cgi?id=749576
tests/Makefile.am | 1 +
tests/parser/bug749576.vala | 29 +++++++++++++++++++++++++++++
vala/valageniescanner.vala | 2 ++
vala/valascanner.vala | 2 ++
4 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f64269f..f9dfaff 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -355,6 +355,7 @@ TESTS = \
parser/preprocessor.vala \
parser/template.vala \
parser/tuple.vala \
+ parser/bug749576.vala \
$(NULL)
NON_NULL_TESTS = \
diff --git a/tests/parser/bug749576.vala b/tests/parser/bug749576.vala
new file mode 100644
index 0000000..8aa961a
--- /dev/null
+++ b/tests/parser/bug749576.vala
@@ -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 {
+ }
+}
diff --git a/vala/valageniescanner.vala b/vala/valageniescanner.vala
index e232a77..d5d0136 100644
--- a/vala/valageniescanner.vala
+++ b/vala/valageniescanner.vala
@@ -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':
diff --git a/vala/valascanner.vala b/vala/valascanner.vala
index 8b50a59..7c4c75c 100644
--- a/vala/valascanner.vala
+++ b/vala/valascanner.vala
@@ -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':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]