summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-02 13:08:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-02 13:08:03 +0000
commit1524572ce96fcef2871b2dcda3eaf3161b2b8469 (patch)
tree841fcf634ca6ccc86336046d2280b43e3c04880d /parse.y
parentc650096adf12f6a51604d455a6aae7314ab3d1e1 (diff)
* parse.y (parser_tokadd_mbchar): fix for ASCII chars. [ruby-dev:32432]
* parse.y (parser_parse_string, parser_here_document): prevent false error messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y15
1 files changed, 10 insertions, 5 deletions
diff --git a/parse.y b/parse.y
index 6e67fd92d2..12d2e8893b 100644
--- a/parse.y
+++ b/parse.y
@@ -5304,7 +5304,7 @@ static int
parser_tokadd_mbchar(struct parser_params *parser, int c)
{
int len = parser_mbclen();
- if (lex_p + len > lex_pend) {
+ if (len <= 0 || lex_p + len - 1 > lex_pend) {
compile_error(PARSER_ARG "illegal multibyte char");
return -1;
}
@@ -5491,11 +5491,13 @@ parser_parse_string(struct parser_params *parser, NODE *quote)
&enc) == -1) {
ruby_sourceline = nd_line(quote);
if (func & STR_FUNC_REGEXP) {
- compile_error(PARSER_ARG "unterminated regexp meets end of file");
+ if (parser->eofp)
+ compile_error(PARSER_ARG "unterminated regexp meets end of file");
return tREGEXP_END;
}
else {
- compile_error(PARSER_ARG "unterminated string meets end of file");
+ if (parser->eofp)
+ compile_error(PARSER_ARG "unterminated string meets end of file");
return tSTRING_END;
}
}
@@ -5625,6 +5627,7 @@ parser_here_document(struct parser_params *parser, NODE *here)
if ((c = nextc()) == -1) {
error:
compile_error(PARSER_ARG "can't find string \"%s\" anywhere before EOF", eos);
+ restore:
heredoc_restore(lex_strterm);
lex_strterm = 0;
return 0;
@@ -5678,8 +5681,10 @@ parser_here_document(struct parser_params *parser, NODE *here)
}
do {
pushback(c);
- if ((c = tokadd_string(func, '\n', 0, NULL,
- &enc)) == -1) goto error;
+ if ((c = tokadd_string(func, '\n', 0, NULL, &enc)) == -1) {
+ if (parser->eofp) goto error;
+ goto restore;
+ }
if (c != '\n') {
set_yylval_str(STR_NEW3(tok(), toklen(), enc, func));
return tSTRING_CONTENT;