diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-13 09:41:22 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-13 09:41:22 +0000 |
commit | 23b4c10dd8dcde2b955072ef0f014bb291866e89 (patch) | |
tree | 409c0ab5297eb4291302655bc5354d30ddddd64b /sprintf.c | |
parent | 6b1bae96414470aba86b8ba7a5822d7d634da8d9 (diff) | |
download | bundler-23b4c10dd8dcde2b955072ef0f014bb291866e89.tar.gz |
* sprintf.c (rb_enc_vsprintf): can be used for ASCII compatible
encodings only.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r-- | sprintf.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -1168,7 +1168,13 @@ rb_enc_vsprintf(rb_encoding *enc, const char *fmt, va_list ap) f._bf._size = 0; f._w = 120; result = rb_str_buf_new(f._w); - if (enc) rb_enc_associate(result, enc); + if (enc) { + if (!rb_enc_asciicompat(enc)) { + rb_raise(rb_eArgError, "cannot construct ASCII-incompatible encoding string: %s", + rb_enc_name(enc)); + } + rb_enc_associate(result, enc); + } f._bf._base = (unsigned char *)result; f._p = (unsigned char *)RSTRING_PTR(result); RBASIC(result)->klass = 0; |