summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-28 09:43:49 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-28 09:43:49 +0000
commit90d5bcf9104fe58887cf705b718a9c7b537b51a5 (patch)
treeddad772917567e032a6b34254ebdf4f9d321bbb0 /error.c
parent8af7ed60368c030e95ec782022538254d256d590 (diff)
* 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) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/error.c b/error.c
index bfbc86cce9..ab252a6d6b 100644
--- a/error.c
+++ b/error.c
@@ -88,7 +88,19 @@ compile_snprintf(char *buf, long len, const char *file, int line, const char *fm
}
}
-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, ...)
@@ -99,7 +111,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);
+ err_append(buf, NULL);
}
void
@@ -111,7 +123,7 @@ rb_compile_error_append(const char *fmt, ...)
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 @@ Init_syserr(void)
}
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 {