ruby-changes:24107
From: ko1 <ko1@a...>
Date: Thu, 21 Jun 2012 07:26:01 +0900 (JST)
Subject: [ruby-changes:24107] ko1:r36158 (trunk): * error.c (err_append): rename err_append() to compile_err_append()
ko1 2012-06-21 07:25:46 +0900 (Thu, 21 Jun 2012) New Revision: 36158 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36158 Log: * error.c (err_append): rename err_append() to compile_err_append() and move definition body. err_append() is used only by compiling. Modified files: trunk/ChangeLog trunk/error.c Index: ChangeLog =================================================================== --- ChangeLog (revision 36157) +++ ChangeLog (revision 36158) @@ -1,3 +1,8 @@ +Thu Jun 21 07:06:52 2012 Koichi Sasada <ko1@a...> + + * error.c (err_append): rename err_append() to compile_err_append() + and move definition body. err_append() is used only by compiling. + Thu Jun 21 06:21:54 2012 Tanaka Akira <akr@f...> * process.c (rb_execarg_fixup): take a VALUE argument instead of Index: error.c =================================================================== --- error.c (revision 36157) +++ error.c (revision 36158) @@ -99,8 +99,43 @@ } } -static void err_append(const char*, rb_encoding *); +static void +compile_err_append(const char *s, rb_encoding *enc) +{ + rb_thread_t *th = GET_THREAD(); + VALUE err = th->errinfo; + rb_block_t *prev_base_block = th->base_block; + th->base_block = 0; + /* base_block should be zero while normal Ruby execution */ + /* after this line, any Ruby code *can* run */ + if (th->mild_compile_error) { + if (!RTEST(err)) { + err = rb_exc_new3(rb_eSyntaxError, + rb_enc_str_new(s, strlen(s), enc)); + th->errinfo = err; + } + else { + VALUE str = rb_obj_as_string(err); + + rb_str_cat2(str, "\n"); + rb_str_cat2(str, s); + th->errinfo = rb_exc_new3(rb_eSyntaxError, str); + } + } + else { + if (!RTEST(err)) { + err = rb_exc_new2(rb_eSyntaxError, "compile error"); + th->errinfo = err; + } + rb_write_error(s); + rb_write_error("\n"); + } + + /* returned to the parser world */ + th->base_block = prev_base_block; +} + void rb_compile_error_with_enc(const char *file, int line, void *enc, const char *fmt, ...) { @@ -110,7 +145,7 @@ va_start(args, fmt); compile_snprintf(buf, BUFSIZ, file, line, fmt, args); va_end(args); - err_append(buf, (rb_encoding *)enc); + compile_err_append(buf, (rb_encoding *)enc); } void @@ -122,7 +157,7 @@ va_start(args, fmt); compile_snprintf(buf, BUFSIZ, file, line, fmt, args); va_end(args); - err_append(buf, NULL); + compile_err_append(buf, NULL); } void @@ -134,7 +169,7 @@ va_start(args, fmt); vsnprintf(buf, BUFSIZ, fmt, args); va_end(args); - err_append(buf, NULL); + compile_err_append(buf, NULL); } static void @@ -1985,33 +2020,3 @@ #undef defined_error #undef undefined_error } - -static void -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_new3(rb_eSyntaxError, - rb_enc_str_new(s, strlen(s), enc)); - th->errinfo = err; - } - else { - VALUE str = rb_obj_as_string(err); - - rb_str_cat2(str, "\n"); - rb_str_cat2(str, s); - th->errinfo = rb_exc_new3(rb_eSyntaxError, str); - } - } - else { - if (!RTEST(err)) { - err = rb_exc_new2(rb_eSyntaxError, "compile error"); - th->errinfo = err; - } - rb_write_error(s); - rb_write_error("\n"); - } -} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/