summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Dalessio <mike.dalessio@gmail.com>2023-08-19 22:18:43 -0400
committerJemma Issroff <jemmaissroff@gmail.com>2023-08-21 10:33:45 -0700
commit05c59995fa192c2e8c23196ccef61e2cc369d223 (patch)
treefc300cde05c2dde4bf88ae10c0c7bb307260b77c
parentdcc8afe9a40b94f5b678b8fc39e4c30ba63594c0 (diff)
[ruby/yarp] fix: newline tracking for nl-terminated % %q %Q
https://github.com/ruby/yarp/commit/1e4940864b
-rw-r--r--test/yarp/fixtures/newline-terminated-things.txt11
-rw-r--r--test/yarp/snapshots/newline-terminated-things.txt15
-rw-r--r--yarp/yarp.c2
3 files changed, 25 insertions, 3 deletions
diff --git a/test/yarp/fixtures/newline-terminated-things.txt b/test/yarp/fixtures/newline-terminated-things.txt
index 27e7c62e8e..3faf45ab4a 100644
--- a/test/yarp/fixtures/newline-terminated-things.txt
+++ b/test/yarp/fixtures/newline-terminated-things.txt
@@ -1,2 +1,13 @@
+# note that %i, %I, %w, and %W do not support newline termination in CRuby
+
+%
+foo
+
+%q
+foo
+
+%Q
+foo
+
%r
foo
diff --git a/test/yarp/snapshots/newline-terminated-things.txt b/test/yarp/snapshots/newline-terminated-things.txt
index e68ea1658e..946eb44a36 100644
--- a/test/yarp/snapshots/newline-terminated-things.txt
+++ b/test/yarp/snapshots/newline-terminated-things.txt
@@ -1,6 +1,15 @@
-ProgramNode(0...7)(
+ProgramNode(76...106)(
[],
- StatementsNode(0...7)(
- [RegularExpressionNode(0...7)((0...3), (3...6), (6...7), "foo", 0)]
+ StatementsNode(76...106)(
+ [StringNode(76...82)((76...78), (78...81), (81...82), "foo"),
+ StringNode(83...90)((83...86), (86...89), (89...90), "foo"),
+ StringNode(91...98)((91...94), (94...97), (97...98), "foo"),
+ RegularExpressionNode(99...106)(
+ (99...102),
+ (102...105),
+ (105...106),
+ "foo",
+ 0
+ )]
)
)
diff --git a/yarp/yarp.c b/yarp/yarp.c
index 1725e108a0..8cc1130952 100644
--- a/yarp/yarp.c
+++ b/yarp/yarp.c
@@ -6224,6 +6224,7 @@ parser_lex(yp_parser_t *parser) {
if (parser->current.end < parser->end) {
lex_mode_push_string(parser, false, false, lex_mode_incrementor(*parser->current.end), lex_mode_terminator(*parser->current.end));
+ yp_newline_list_check_append(&parser->newline_list, parser->current.end);
parser->current.end++;
}
@@ -6234,6 +6235,7 @@ parser_lex(yp_parser_t *parser) {
if (parser->current.end < parser->end) {
lex_mode_push_string(parser, true, false, lex_mode_incrementor(*parser->current.end), lex_mode_terminator(*parser->current.end));
+ yp_newline_list_check_append(&parser->newline_list, parser->current.end);
parser->current.end++;
}