diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-21 12:56:48 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-21 12:56:48 +0000 |
| commit | d85267034f85756e07da25bc3584964c49f3a298 (patch) | |
| tree | a45b61004977fc8f10e1906bc4ad2c7f6a21595c /ext | |
| parent | 8932916c81e367ee5b06fb697c3f1c6561bf2bc3 (diff) | |
| download | ruby-d85267034f85756e07da25bc3584964c49f3a298.tar.gz ruby-d85267034f85756e07da25bc3584964c49f3a298.tar.xz ruby-d85267034f85756e07da25bc3584964c49f3a298.zip | |
* ext/zlib/zlib.c (rb_gzwriter_write): conversion should be done
using to_str, not to_s.
* ext/zlib/zlib.c (rb_gzwriter_write): need proper conversion
according to gz encoding.
* ext/zlib/zlib.c (rb_gzreader_ungetc): convert string encoding
before unget.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/zlib/zlib.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 8d349c49e..bc0716b83 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -2747,10 +2747,10 @@ rb_gzwriter_write(VALUE obj, VALUE str) { struct gzfile *gz = get_gzfile(obj); - if (TYPE(str) != T_STRING) { - str = rb_obj_as_string(str); + StringValue(str); + if (gz->enc2 && gz->enc2 != rb_ascii8bit_encoding()) { + str = rb_str_conv_enc(str, rb_enc_get(str), gz->enc2); } - str = rb_str_export(str); gzfile_write(gz, (Bytef*)RSTRING_PTR(str), RSTRING_LEN(str)); return INT2FIX(RSTRING_LEN(str)); } @@ -3075,6 +3075,11 @@ static VALUE rb_gzreader_ungetc(VALUE obj, VALUE s) { struct gzfile *gz = get_gzfile(obj); + + StringValue(s); + if (gz->enc2 && gz->enc2 != rb_ascii8bit_encoding()) { + s = rb_str_conv_enc(s, rb_enc_get(s), gz->enc2); + } gzfile_ungets(gz, (const Bytef*)RSTRING_PTR(s), RSTRING_LEN(s)); return Qnil; } |
