summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-20 22:25:46 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-20 22:25:46 +0000
commit0cfee328281d98790e527f562eb2c89df51f6452 (patch)
tree801a17b2b117bafc66db4e25e771cfcad0f15db1 /error.c
parentd73d3a743b78ed3532abb9ae97f0b4300963b15f (diff)
* error.c (err_append): rename err_append() to compile_err_append()
and move definition body. err_append() is used only by compiling. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c73
1 files changed, 39 insertions, 34 deletions
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");
- }
-}