ruby-changes:18389
From: usa <ko1@a...>
Date: Tue, 28 Dec 2010 18:43:58 +0900 (JST)
Subject: [ruby-changes:18389] Ruby:r30412 (trunk): * re.c (rb_reg_expr_str): need to escape if the coderage is invalid.
usa 2010-12-28 18:43:49 +0900 (Tue, 28 Dec 2010) New Revision: 30412 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30412 Log: * re.c (rb_reg_expr_str): need to escape if the coderage is invalid. * error.c, include/ruby/intern.h (rb_compile_error_with_enc): new function to raise syntax error, with source encoding'ed message. * parse.y (compile_error): use above function. [ruby-core:33951] (#4217) Modified files: trunk/ChangeLog trunk/error.c trunk/include/ruby/intern.h trunk/parse.y Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 30411) +++ include/ruby/intern.h (revision 30412) @@ -209,6 +209,7 @@ PRINTF_ARGS(NORETURN(void rb_name_error(ID, const char*, ...)), 2, 3); NORETURN(void rb_invalid_str(const char*, const char*)); PRINTF_ARGS(void rb_compile_error(const char*, int, const char*, ...), 3, 4); +PRINTF_ARGS(void rb_compile_error_with_enc(const char*, int, void *, const char*, ...), 4, 5); PRINTF_ARGS(void rb_compile_error_append(const char*, ...), 1, 2); NORETURN(void rb_load_fail(const char*)); NORETURN(void rb_error_frozen(const char*)); Index: ChangeLog =================================================================== --- ChangeLog (revision 30411) +++ ChangeLog (revision 30412) @@ -1,3 +1,13 @@ +Tue Dec 28 18:36:38 2010 NAKAMURA Usaku <usa@r...> + + * re.c (rb_reg_expr_str): need to escape if the coderage is invalid. + + * error.c, include/ruby/intern.h (rb_compile_error_with_enc): new + function to raise syntax error, with source encoding'ed message. + + * parse.y (compile_error): use above function. + [ruby-core:33951] (#4217) + Tue Dec 28 07:37:38 2010 Tanaka Akira <akr@f...> * ruby.c: parenthesize macro arguments. Index: parse.y =================================================================== --- parse.y (revision 30411) +++ parse.y (revision 30412) @@ -308,6 +308,7 @@ #define ruby__end__seen (parser->parser_ruby__end__seen) #define ruby_sourceline (parser->parser_ruby_sourceline) #define ruby_sourcefile (parser->parser_ruby_sourcefile) +#define current_enc (parser->enc) #define yydebug (parser->parser_yydebug) #ifdef RIPPER #else @@ -586,8 +587,9 @@ # define compile_error ripper_compile_error # define PARSER_ARG parser, #else -# define compile_error parser->nerr++,rb_compile_error -# define PARSER_ARG ruby_sourcefile, ruby_sourceline, +# define rb_compile_error rb_compile_error_with_enc +# define compile_error parser->nerr++,rb_compile_error_with_enc +# define PARSER_ARG ruby_sourcefile, ruby_sourceline, current_enc, #endif /* Older versions of Yacc set YYMAXDEPTH to a very low value by default (150, Index: error.c =================================================================== --- error.c (revision 30411) +++ error.c (revision 30412) @@ -88,9 +88,21 @@ } } -static void err_append(const char*); +static void err_append(const char*, rb_encoding *); void +rb_compile_error_with_enc(const char *file, int line, void *enc, const char *fmt, ...) +{ + va_list args; + char buf[BUFSIZ]; + + va_start(args, fmt); + compile_snprintf(buf, BUFSIZ, file, line, fmt, args); + va_end(args); + err_append(buf, (rb_encoding *)enc); +} + +void rb_compile_error(const char *file, int line, const char *fmt, ...) { va_list args; @@ -99,7 +111,7 @@ va_start(args, fmt); compile_snprintf(buf, BUFSIZ, file, line, fmt, args); va_end(args); - err_append(buf); + err_append(buf, NULL); } void @@ -111,7 +123,7 @@ va_start(args, fmt); vsnprintf(buf, BUFSIZ, fmt, args); va_end(args); - err_append(buf); + err_append(buf, NULL); } static void @@ -1644,14 +1656,15 @@ } static void -err_append(const char *s) +err_append(const char *s, rb_encoding *enc) { rb_thread_t *th = GET_THREAD(); VALUE err = th->errinfo; if (th->mild_compile_error) { if (!RTEST(err)) { - err = rb_exc_new2(rb_eSyntaxError, s); + err = rb_exc_new3(rb_eSyntaxError, + rb_enc_str_new(s, strlen(s), enc)); th->errinfo = err; } else { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/