[前][次][番号順一覧][スレッド一覧]

ruby-changes:2594

From: ko1@a...
Date: 2 Dec 2007 22:08:21 +0900
Subject: [ruby-changes:2594] nobu - Ruby:r14085 (trunk): * parse.y (parser_tokadd_mbchar): fix for ASCII chars.

nobu	2007-12-02 22:08:03 +0900 (Sun, 02 Dec 2007)

  New Revision: 14085

  Modified files:
    trunk/ChangeLog
    trunk/parse.y

  Log:
    * parse.y (parser_tokadd_mbchar): fix for ASCII chars.  [ruby-dev:32432]
    
    * parse.y (parser_parse_string, parser_here_document): prevent false
      error messages.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=14085&r2=14084
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14085&r2=14084

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14084)
+++ ChangeLog	(revision 14085)
@@ -1,3 +1,10 @@
+Sun Dec  2 22:08:01 2007  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (parser_tokadd_mbchar): fix for ASCII chars.  [ruby-dev:32432]
+
+	* parse.y (parser_parse_string, parser_here_document): prevent false
+	  error messages.
+
 Sun Dec  2 20:43:22 2007  Tanaka Akira  <akr@f...>
 
 	* re.c (unescape_escaped_nonascii): fix mbclen argument.
Index: parse.y
===================================================================
--- parse.y	(revision 14084)
+++ parse.y	(revision 14085)
@@ -5304,7 +5304,7 @@
 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 @@
 		      &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 @@
     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 @@
 	}
 	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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]