aboutsummaryrefslogtreecommitdiffstats
path: root/ext/zlib
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-10 03:43:22 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-10 03:43:22 +0000
commitf9ce30e66f9197a6b1e3530f257cf73d29de7e8c (patch)
tree1b26f0ce6a628a7f404032e3841e7ae5d87bff03 /ext/zlib
parente1044147fd8c8eb214727095735a764998956643 (diff)
downloadruby-f9ce30e66f9197a6b1e3530f257cf73d29de7e8c.tar.gz
* ext/zlib/zlib.c (rb_gzreader_external_encoding):
define GzipReader#external_encoding. [Bug #10900] * test/zlib/test_zlib.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/zlib')
-rw-r--r--ext/zlib/zlib.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 9c2b7b624f..564f5c83ca 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -4237,6 +4237,17 @@ rb_gzreader_readlines(int argc, VALUE *argv, VALUE obj)
return dst;
}
+/*
+ * Document-method: Zlib::GzipReader#external_encoding
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_external_encoding(VALUE self)
+{
+ return rb_enc_from_encoding(get_gzfile(self)->enc);
+}
+
#endif /* GZIP_SUPPORT */
void
@@ -4505,6 +4516,7 @@ Init_zlib(void)
rb_define_method(cGzipReader, "each_line", rb_gzreader_each, -1);
rb_define_method(cGzipReader, "lines", rb_gzreader_lines, -1);
rb_define_method(cGzipReader, "readlines", rb_gzreader_readlines, -1);
+ rb_define_method(cGzipReader, "external_encoding", rb_gzreader_external_encoding, 0);
/* The OS code of current host */
rb_define_const(mZlib, "OS_CODE", INT2FIX(OS_CODE));