summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--error.c73
2 files changed, 44 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index f80011a97f..a2acc6b061 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jun 21 07:06:52 2012 Koichi Sasada <ko1@atdot.net>
+
+ * 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@fsij.org>
* process.c (rb_execarg_fixup): take a VALUE argument instead of
diff --git a/error.c b/error.c
index eabc3c9eb3..a1987fec95 100644
--- a/error.c
+++ b/error.c
@@ -99,7 +99,42 @@ compile_snprintf(char *buf, long len, const char *file, int line, const char *fm
}
}
-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 @@ rb_compile_error_with_enc(const char *file, int line, void *enc, const char *fmt
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 @@ rb_compile_error(const char *file, int line, const char *fmt, ...)
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 @@ rb_compile_error_append(const char *fmt, ...)
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 @@ Init_syserr(void)
#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");
- }
-}