Skip to content

Commit 2d3988e

Browse files
authored
Support for rb_io_mode_t (#129)
Companion PR to <ruby/ruby#7894>.
1 parent cb80e8d commit 2d3988e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ext/stringio/extconf.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: false
22
require 'mkmf'
33
if RUBY_ENGINE == 'ruby'
4+
have_type("rb_io_mode_t", "ruby/io.h")
5+
46
create_makefile('stringio')
57
else
68
File.write('Makefile', dummy_makefile("").join)

ext/stringio/stringio.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ STRINGIO_VERSION = "3.1.6";
3535
# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
3636
#endif
3737

38+
#ifndef HAVE_TYPE_RB_IO_MODE_T
39+
typedef int rb_io_mode_t;
40+
#endif
41+
3842
struct StringIO {
3943
VALUE string;
4044
rb_encoding *enc;
4145
long pos;
4246
long lineno;
43-
int flags;
47+
rb_io_mode_t flags;
4448
int count;
4549
};
4650

@@ -1852,7 +1856,8 @@ strio_set_encoding(int argc, VALUE *argv, VALUE self)
18521856
enc = rb_find_encoding(ext_enc);
18531857
if (!enc) {
18541858
rb_io_enc_t convconfig;
1855-
int oflags, fmode;
1859+
int oflags;
1860+
rb_io_mode_t fmode;
18561861
VALUE vmode = rb_str_append(rb_str_new_cstr("r:"), ext_enc);
18571862
rb_io_extract_modeenc(&vmode, 0, Qnil, &oflags, &fmode, &convconfig);
18581863
enc = convconfig.enc2;

0 commit comments

Comments
 (0)