summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-02 00:58:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-02 00:58:10 +0000
commitfcc41855e72523e2bf3b3c285bec6e296b974352 (patch)
tree58f59eff35bb82989143b52b18a7ac3a814d36e4 /parse.y
parent0f0db4163d632fac904fc5c0994571fc3054338a (diff)
* parse.y (parser_tokadd_string, parser_yylex): ignore a backslash
which prefixes an non-ascii character, which has no escape syntax. [ruby-core:39222] [Ruby 1.9 - Bug #5262] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y8
1 files changed, 8 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 1678c027de..6e7c23006c 100644
--- a/parse.y
+++ b/parse.y
@@ -5411,6 +5411,7 @@ parser_str_new(const char *p, long n, rb_encoding *enc, int func, rb_encoding *e
}
#define lex_goto_eol(parser) ((parser)->parser_lex_p = (parser)->parser_lex_pend)
+#define lex_eol_p() (lex_p >= lex_pend)
#define peek(c) peek_n((c), 0)
#define peek_n(c,n) (lex_p+(n) < lex_pend && (c) == (unsigned char)lex_p[n])
@@ -5920,6 +5921,8 @@ parser_tokadd_string(struct parser_params *parser,
continue;
default:
+ if (c == -1) return -1;
+ if (!ISASCII(c)) goto non_ascii;
if (func & STR_FUNC_REGEXP) {
pushback(c);
if ((c = tokadd_escape(&enc)) < 0)
@@ -5945,6 +5948,7 @@ parser_tokadd_string(struct parser_params *parser,
}
}
else if (!parser_isascii()) {
+ non_ascii:
has_nonascii = 1;
if (enc != *encp) {
mixed_error(enc, *encp);
@@ -7003,6 +7007,10 @@ parser_yylex(struct parser_params *parser)
tokadd(c);
}
}
+ else if (!lex_eol_p() && !(c = *lex_p, ISASCII(c))) {
+ nextc();
+ if (tokadd_mbchar(c) == -1) return 0;
+ }
else {
c = read_escape(0, &enc);
tokadd(c);