1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* parse.y (tokadd_string, parse_string, yylex): escaped terminator

is now interpreted as is.  [ruby-talk:82206]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2003-09-17 11:34:02 +00:00
parent 577fa4c6a8
commit d3b780b1cf
2 changed files with 16 additions and 49 deletions

View file

@ -1,3 +1,8 @@
Wed Sep 17 20:34:00 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (tokadd_string, parse_string, yylex): escaped terminator
is now interpreted as is. [ruby-talk:82206]
Wed Sep 17 18:52:36 2003 Minero Aoki <aamine@loveruby.net>
* test/fileutils/fileassertions.rb: new file.

52
parse.y
View file

@ -108,10 +108,6 @@ static int in_single = 0;
static int in_def = 0;
static int compile_for_eval = 0;
static ID cur_mid = 0;
static int quoted_term;
#define quoted_term_char ((unsigned char)quoted_term)
#define WHEN_QUOTED_TERM(x) ((quoted_term >= 0) && (x))
#define QUOTED_TERM_P(c) WHEN_QUOTED_TERM((c) == quoted_term_char)
static NODE *cond();
static NODE *logop();
@ -174,7 +170,6 @@ static void top_local_setup();
#define NODE_STRTERM NODE_ZARRAY /* nothing to gc */
#define NODE_HEREDOC NODE_ARRAY /* 1, 3 to gc */
#define ESCAPED_TERM (1 << CHAR_BIT)
#define SIGN_EXTEND(x,n) (((1<<(n))-1-((x)&~(~0<<(n))))^~(~0<<(n)))
#define nd_func u1.id
#if SIZEOF_SHORT == 2
@ -263,7 +258,7 @@ static void top_local_setup();
%type <node> mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node
%type <id> fitem variable sym symbol operation operation2 operation3
%type <id> cname fname op f_rest_arg
%type <num> f_norm_arg f_arg term_push
%type <num> f_norm_arg f_arg
%token tUPLUS /* unary+ */
%token tUMINUS /* unary- */
%token tPOW /* ** */
@ -2050,7 +2045,7 @@ string_content : tSTRING_CONTENT
lex_strterm = $<node>2;
$$ = NEW_EVSTR($3);
}
| tSTRING_DBEG term_push
| tSTRING_DBEG
{
$<node>$ = lex_strterm;
lex_strterm = 0;
@ -2058,11 +2053,10 @@ string_content : tSTRING_CONTENT
}
compstmt '}'
{
quoted_term = $2;
lex_strterm = $<node>3;
if (($$ = $4) && nd_type($$) == NODE_NEWLINE) {
lex_strterm = $<node>2;
if (($$ = $3) && nd_type($$) == NODE_NEWLINE) {
$$ = $$->nd_next;
rb_gc_force_recycle((VALUE)$4);
rb_gc_force_recycle((VALUE)$3);
}
$$ = new_evstr($$);
}
@ -2074,16 +2068,6 @@ string_dvar : tGVAR {$$ = NEW_GVAR($1);}
| backref
;
term_push : /* none */
{
if (($$ = quoted_term) == -1 &&
nd_type(lex_strterm) == NODE_STRTERM &&
!nd_paren(lex_strterm)) {
quoted_term = nd_term(lex_strterm);
}
}
;
symbol : tSYMBEG sym
{
lex_state = EXPR_END;
@ -2450,7 +2434,7 @@ static char *lex_pend;
static int
yyerror(msg)
char *msg;
const char *msg;
{
char *p, *pe, *buf;
int len, i;
@ -2535,7 +2519,6 @@ yycompile(f, line)
ruby_eval_tree = 0;
heredoc_end = 0;
lex_strterm = 0;
quoted_term = -1;
ruby_current_node = 0;
ruby_sourcefile = rb_source_filename(f);
n = yyparse();
@ -2993,10 +2976,6 @@ tokadd_string(func, term, paren, nest)
}
else if (c == '\\') {
c = nextc();
if (QUOTED_TERM_P(c)) {
pushback(c);
return c;
}
switch (c) {
case '\n':
if (func & STR_FUNC_QWORDS) break;
@ -3068,9 +3047,7 @@ parse_string(quote)
do {c = nextc();} while (ISSPACE(c));
space = 1;
}
if ((c == term && !quote->nd_nest) ||
(c == '\\' && WHEN_QUOTED_TERM(peek(quoted_term_char)) &&
(c = nextc()) == term)) {
if (c == term && !quote->nd_nest) {
if (func & STR_FUNC_QWORDS) {
quote->nd_func = -1;
return ' ';
@ -4095,13 +4072,6 @@ yylex()
goto retry; /* skip \\n */
}
pushback(c);
if (QUOTED_TERM_P(c)) {
if (!(quoted_term & ESCAPED_TERM)) {
rb_warn("escaped terminator '%c' inside string interpolation", c);
quoted_term |= ESCAPED_TERM;
}
goto retry;
}
return '\\';
case '%':
@ -4111,14 +4081,6 @@ yylex()
c = nextc();
quotation:
if (c == '\\' && WHEN_QUOTED_TERM(peek(quoted_term_char))) {
c = nextc();
if (!(quoted_term & ESCAPED_TERM)) {
rb_warn("escaped terminator '%s%c' inside string interpolation",
(c == '\'' ? "\\" : ""), c);
quoted_term |= ESCAPED_TERM;
}
}
if (!ISALNUM(c)) {
term = c;
c = 'Q';