From: Rico Tzschichholz Date: Mon, 14 May 2018 07:31:32 +0000 (+0200) Subject: scanner: Accept \R and \N escape sequences in regex literals X-Git-Tag: 0.38.10~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=250ce01ac06b5546862645dcecff094b6fc813d5;p=thirdparty%2Fvala.git scanner: Accept \R and \N escape sequences in regex literals https://bugzilla.gnome.org/show_bug.cgi?id=749576 --- diff --git a/tests/Makefile.am b/tests/Makefile.am index f64269fb1..f9dfaffd0 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 000000000..8aa961af0 --- /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 e232a77bc..d5d013642 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 8b50a59d4..7c4c75c0c 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':