Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
801bc9e3
Commit
801bc9e3
authored
Mar 17, 2013
by
FUKUZAWA-Tadashi
Committed by
Masaki Muranaka
Mar 19, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix about escaping '\n'
parent
e5a66685
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
10 deletions
+34
-10
src/parse.y
src/parse.y
+19
-7
test/t/literals.rb
test/t/literals.rb
+15
-3
No files found.
src/parse.y
View file @
801bc9e3
...
@@ -3535,7 +3535,7 @@ parse_string(parser_state *p)
...
@@ -3535,7 +3535,7 @@ parse_string(parser_state *p)
char buf[256];
char buf[256];
snprintf(buf, sizeof(buf), "can't find string \"%s\" anywhere before EOF", hinf->term);
snprintf(buf, sizeof(buf), "can't find string \"%s\" anywhere before EOF", hinf->term);
yyerror(p, buf);
yyerror(p, buf);
return 0;
return 0;
}
}
yylval.nd = new_str(p, tok(p), toklen(p));
yylval.nd = new_str(p, tok(p), toklen(p));
return tSTRING_MID;
return tSTRING_MID;
...
@@ -3558,6 +3558,11 @@ parse_string(parser_state *p)
...
@@ -3558,6 +3558,11 @@ parse_string(parser_state *p)
if (c == end || c == beg) {
if (c == end || c == beg) {
tokadd(p, c);
tokadd(p, c);
}
}
else if ((c == '\n') && (type & STR_FUNC_ARRAY)) {
p->lineno++;
p->column = 0;
tokadd(p, '\n');
}
else {
else {
pushback(p, c);
pushback(p, c);
tokadd(p, read_escape(p));
tokadd(p, read_escape(p));
...
@@ -3570,14 +3575,14 @@ parse_string(parser_state *p)
...
@@ -3570,14 +3575,14 @@ parse_string(parser_state *p)
case '\n':
case '\n':
p->lineno++;
p->lineno++;
p->column = 0;
p->column = 0;
continue
;
break
;
case '\\':
case '\\':
c = '\\';
break;
break;
default:
default:
tokadd(p, '\\');
if (! ISSPACE(c))
tokadd(p, '\\');
}
}
}
}
tokadd(p, c);
tokadd(p, c);
...
@@ -3601,7 +3606,12 @@ parse_string(parser_state *p)
...
@@ -3601,7 +3606,12 @@ parse_string(parser_state *p)
}
}
if ((type & STR_FUNC_ARRAY) && ISSPACE(c)) {
if ((type & STR_FUNC_ARRAY) && ISSPACE(c)) {
if (toklen(p) == 0) {
if (toklen(p) == 0) {
do {} while (ISSPACE(c = nextc(p)));
do {
if (c == '\n') {
p->lineno++;
p->column = 0;
}
} while (ISSPACE(c = nextc(p)));
pushback(p, c);
pushback(p, c);
return tLITERAL_DELIM;
return tLITERAL_DELIM;
} else {
} else {
...
@@ -3681,8 +3691,10 @@ heredoc_identifier(parser_state *p)
...
@@ -3681,8 +3691,10 @@ heredoc_identifier(parser_state *p)
quote = TRUE;
quote = TRUE;
newtok(p);
newtok(p);
while ((c = nextc(p)) != -1 && c != term) {
while ((c = nextc(p)) != -1 && c != term) {
if (c == '\n')
if (c == '\n') {
c = -1;
c = -1;
break;
}
tokadd(p, c);
tokadd(p, c);
}
}
if (c == -1) {
if (c == -1) {
...
...
test/t/literals.rb
View file @
801bc9e3
...
@@ -140,6 +140,11 @@ assert('Literals Array', '8.7.6.4') do
...
@@ -140,6 +140,11 @@ assert('Literals Array', '8.7.6.4') do
#{
-
1
}
1
#{
-
1
}
1
2
#{
2
}
2
#{
2
}
}
}
h
=
%W(a
\n
b
test
\
abc
c
\
d
x
\y
x
\\
y x
\\\y
)
test1
=
(
a
==
[
'abc3def'
,
'}g'
]
and
test1
=
(
a
==
[
'abc3def'
,
'}g'
]
and
b
==
[
'abc'
,
'5'
,
'def'
,
'(g'
]
and
b
==
[
'abc'
,
'5'
,
'def'
,
'(g'
]
and
...
@@ -147,7 +152,8 @@ assert('Literals Array', '8.7.6.4') do
...
@@ -147,7 +152,8 @@ assert('Literals Array', '8.7.6.4') do
d
==
[
'9'
]
and
d
==
[
'9'
]
and
e
==
[]
and
e
==
[]
and
f
==
[
'[ab'
,
'cd][ef]'
]
and
f
==
[
'[ab'
,
'cd][ef]'
]
and
g
==
[
'ab'
,
'-11'
,
'22'
]
g
==
[
'ab'
,
'-11'
,
'22'
]
and
h
==
[
"a
\n
b"
,
'test abc'
,
"c
\n
d"
,
"xy"
,
"x
\\
y"
,
"x
\\
y"
]
)
)
a
=
%w{abc#{1+2}def
\}
g}
a
=
%w{abc#{1+2}def
\}
g}
...
@@ -161,6 +167,11 @@ assert('Literals Array', '8.7.6.4') do
...
@@ -161,6 +167,11 @@ assert('Literals Array', '8.7.6.4') do
#{-1}1
#{-1}1
2#{2}
2#{2}
}
}
h
=
%w(a\nb
test\ abc
c\
d
x\y x
\\
y x
\\
\y)
test2
=
(
a
==
[
'abc#{1+2}def'
,
'}g'
]
and
test2
=
(
a
==
[
'abc#{1+2}def'
,
'}g'
]
and
b
==
[
'abc'
,
'#{2+3}'
,
'def'
,
'(g'
]
and
b
==
[
'abc'
,
'#{2+3}'
,
'def'
,
'(g'
]
and
...
@@ -168,8 +179,9 @@ assert('Literals Array', '8.7.6.4') do
...
@@ -168,8 +179,9 @@ assert('Literals Array', '8.7.6.4') do
d
==
[
'#{4+5}'
]
and
d
==
[
'#{4+5}'
]
and
e
==
[]
and
e
==
[]
and
f
==
[
'[ab'
,
'cd][ef]'
]
and
f
==
[
'[ab'
,
'cd][ef]'
]
and
g
==
[
'ab'
,
'#{-1}1'
,
'2#{2}'
]
g
==
[
'ab'
,
'#{-1}1'
,
'2#{2}'
]
and
)
h
==
[
"a
\\
nb"
,
"test abc"
,
"c
\n
d"
,
"x
\\
y"
,
"x
\\
y"
,
"x
\\\\
y"
]
)
test1
and
test2
test1
and
test2
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment