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
38b32a55
Commit
38b32a55
authored
Jan 20, 2013
by
Masamitsu MURASE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify handling of Quoted non-expanded literal strings.
parent
58398338
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
28 deletions
+32
-28
src/parse.y
src/parse.y
+32
-28
No files found.
src/parse.y
View file @
38b32a55
...
@@ -3434,36 +3434,39 @@ parse_string(parser_state *p, int term)
...
@@ -3434,36 +3434,39 @@ parse_string(parser_state *p, int term)
}
}
static node*
static node*
qstring_node(parser_state *p, int
term
)
qstring_node(parser_state *p, int
beg, int end
)
{
{
int c;
int c;
int nest_level = 0;
newtok(p);
newtok(p);
while ((c = nextc(p)) !=
term
) {
while ((c = nextc(p)) !=
end || nest_level != 0
) {
if (c == -1) {
if (c == -1) {
yyerror(p, "unterminated string meets end of file");
yyerror(p, "unterminated string meets end of file");
return 0;
return 0;
}
}
if (c == '\\') {
else if (c == beg) {
nest_level++;
}
else if (c == end) {
nest_level--;
}
else if (c == '\\') {
c = nextc(p);
c = nextc(p);
switch (c) {
if (c != beg && c != end) {
case '\n':
switch (c) {
p->lineno++;
case '\n':
p->column = 0;
p->lineno++;
continue;
p->column = 0;
continue;
case '\\':
c = '\\';
case '\\':
break;
c = '\\';
break;
case '\'':
if (term == '\'') {
default:
c = '\'';
tokadd(p, '\\');
break;
}
}
/* fall through */
default:
tokadd(p, '\\');
}
}
}
}
tokadd(p, c);
tokadd(p, c);
...
@@ -3475,12 +3478,12 @@ qstring_node(parser_state *p, int term)
...
@@ -3475,12 +3478,12 @@ qstring_node(parser_state *p, int term)
}
}
static int
static int
parse_qstring(parser_state *p, int
term
)
parse_qstring(parser_state *p, int
beg, int end
)
{
{
node *nd = qstring_node(p,
term
);
node *nd = qstring_node(p,
beg, end
);
if (nd) {
if (nd) {
yylval.nd = n
ew_str(p, tok(p), toklen(p))
;
yylval.nd = n
d
;
return tSTRING;
return tSTRING;
}
}
return 0;
return 0;
...
@@ -3714,7 +3717,7 @@ parser_yylex(parser_state *p)
...
@@ -3714,7 +3717,7 @@ parser_yylex(parser_state *p)
return tSTRING_BEG;
return tSTRING_BEG;
case '\'':
case '\'':
return parse_qstring(p,
c
);
return parse_qstring(p,
'\'', '\''
);
case '?':
case '?':
if (IS_END()) {
if (IS_END()) {
...
@@ -4317,7 +4320,7 @@ parser_yylex(parser_state *p)
...
@@ -4317,7 +4320,7 @@ parser_yylex(parser_state *p)
case '%':
case '%':
if (IS_BEG()) {
if (IS_BEG()) {
int term;
int
beg = 0,
term;
#if 0
#if 0
int paren;
int paren;
#endif
#endif
...
@@ -4329,7 +4332,7 @@ parser_yylex(parser_state *p)
...
@@ -4329,7 +4332,7 @@ parser_yylex(parser_state *p)
c = 'Q';
c = 'Q';
}
}
else {
else {
term = nextc(p);
beg =
term = nextc(p);
if (isalnum(term)) {
if (isalnum(term)) {
yyerror(p, "unknown type of %string");
yyerror(p, "unknown type of %string");
return 0;
return 0;
...
@@ -4362,7 +4365,8 @@ parser_yylex(parser_state *p)
...
@@ -4362,7 +4365,8 @@ parser_yylex(parser_state *p)
#if 0
#if 0
p->lex_strterm = new_strterm(p, str_squote, term, paren);
p->lex_strterm = new_strterm(p, str_squote, term, paren);
#endif
#endif
return tSTRING_BEG;
p->sterm = 0;
return parse_qstring(p, beg, term);
case 'W':
case 'W':
#if 0
#if 0
...
...
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