aboutsummaryrefslogtreecommitdiffstats
path: root/marshal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-05 08:24:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-05 08:24:37 +0000
commit17a47a3358693d753a6139b28c73c63c0d6fda9f (patch)
treeec815fe264f352f0ad901c4837c015ae405a0d42 /marshal.c
parente10e309dcecd078df394b7a2966ec9a08f4c386d (diff)
downloadruby-17a47a3358693d753a6139b28c73c63c0d6fda9f.tar.gz
marshal.c: preserve encoding
* marshal.c (must_not_be_anonymous, class2path): preserve encoding in the exception messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/marshal.c b/marshal.c
index 2fe272100b..4aa03afeb9 100644
--- a/marshal.c
+++ b/marshal.c
@@ -189,31 +189,31 @@ static const rb_data_type_t dump_arg_data = {
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
};
-static const char *
+static VALUE
must_not_be_anonymous(const char *type, VALUE path)
{
char *n = RSTRING_PTR(path);
if (!rb_enc_asciicompat(rb_enc_get(path))) {
/* cannot occur? */
- rb_raise(rb_eTypeError, "can't dump non-ascii %s name", type);
+ rb_raise(rb_eTypeError, "can't dump non-ascii %s name % "PRIsVALUE,
+ type, path);
}
if (n[0] == '#') {
- rb_raise(rb_eTypeError, "can't dump anonymous %s %.*s", type,
- (int)RSTRING_LEN(path), n);
+ rb_raise(rb_eTypeError, "can't dump anonymous %s % "PRIsVALUE,
+ type, path);
}
- return n;
+ return path;
}
static VALUE
class2path(VALUE klass)
{
VALUE path = rb_class_path(klass);
- const char *n;
- n = must_not_be_anonymous((RB_TYPE_P(klass, T_CLASS) ? "class" : "module"), path);
+ must_not_be_anonymous((RB_TYPE_P(klass, T_CLASS) ? "class" : "module"), path);
if (rb_path_to_class(path) != rb_class_real(klass)) {
- rb_raise(rb_eTypeError, "%s can't be referred to", n);
+ rb_raise(rb_eTypeError, "% "PRIsVALUE" can't be referred to", path);
}
return path;
}