mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* 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
This commit is contained in:
		
							parent
							
								
									0c14c3ab0b
								
							
						
					
					
						commit
						d88957abad
					
				
					 3 changed files with 24 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,11 @@
 | 
			
		|||
Sun May 10 12:41:18 2015  Masaki Matsushita <glass.saga@gmail.com>
 | 
			
		||||
 | 
			
		||||
	* ext/zlib/zlib.c (rb_gzreader_external_encoding):
 | 
			
		||||
	  define GzipReader#external_encoding.
 | 
			
		||||
	  [Bug #10900]
 | 
			
		||||
 | 
			
		||||
	* test/zlib/test_zlib.rb: test for above.
 | 
			
		||||
 | 
			
		||||
Sun May 10 11:57:48 2015  Masaki Matsushita <glass.saga@gmail.com>
 | 
			
		||||
 | 
			
		||||
	* ext/win32ole/win32ole_variant.c: fix typo "indicies".
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -953,7 +953,10 @@ if defined? Zlib
 | 
			
		|||
        content = (0..255).to_a.pack('c*')
 | 
			
		||||
        Zlib::GzipWriter.wrap(t) {|gz| gz.print(content) }
 | 
			
		||||
 | 
			
		||||
        read_all = Zlib::GzipReader.open(t.path) {|gz| gz.read }
 | 
			
		||||
        read_all = Zlib::GzipReader.open(t.path) do |gz|
 | 
			
		||||
          assert_equal(Encoding.default_external, gz.external_encoding)
 | 
			
		||||
          gz.read
 | 
			
		||||
        end
 | 
			
		||||
        assert_equal(Encoding.default_external, read_all.encoding)
 | 
			
		||||
 | 
			
		||||
        # chunks are in BINARY regardless of encoding settings
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue