From 26984290eb4f20a4a2db2b8d461cd36a4a5b0e49 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 24 Dec 2015 08:25:44 +0000 Subject: preserve source file name encoding * compile.c (append_compile_error), parse.y (compile_error): preserve encoding of source file name in exceptions. * error.c (rb_compile_error_str, rb_compile_bug_str): add. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- error.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'error.c') diff --git a/error.c b/error.c index 0a7b2745a3..f2c86448e7 100644 --- a/error.c +++ b/error.c @@ -151,6 +151,20 @@ rb_compile_error(const char *file, int line, const char *fmt, ...) compile_err_append(str); } +void +rb_compile_error_str(VALUE file, int line, void *enc, const char *fmt, ...) +{ + va_list args; + VALUE str; + + va_start(args, fmt); + str = compile_snprintf(enc, NULL, + NIL_P(file) ? NULL : RSTRING_PTR(file), line, + fmt, args); + va_end(args); + compile_err_append(str); +} + void rb_compile_error_append(const char *fmt, ...) { @@ -477,6 +491,14 @@ rb_compile_bug(const char *file, int line, const char *fmt, ...) abort(); } +void +rb_compile_bug_str(VALUE file, int line, const char *fmt, ...) +{ + report_bug(RSTRING_PTR(file), line, fmt, NULL); + + abort(); +} + static const char builtin_types[][10] = { "", /* 0x00, */ "Object", -- cgit v1.2.3