diff options
-rw-r--r-- | ext/kgio/extconf.rb | 1 | ||||
-rw-r--r-- | ext/kgio/kgio_ext.c | 1 | ||||
-rw-r--r-- | ext/kgio/missing/ancient_ruby.h | 19 |
3 files changed, 21 insertions, 0 deletions
diff --git a/ext/kgio/extconf.rb b/ext/kgio/extconf.rb index 09d710b..dcc1418 100644 --- a/ext/kgio/extconf.rb +++ b/ext/kgio/extconf.rb @@ -15,6 +15,7 @@ else end have_func('rb_io_ascii8bit_binmode') have_func('rb_thread_blocking_region') +have_func('rb_str_set_len') dir_config('kgio') create_makefile('kgio_ext') diff --git a/ext/kgio/kgio_ext.c b/ext/kgio/kgio_ext.c index ac6f448..3b20064 100644 --- a/ext/kgio/kgio_ext.c +++ b/ext/kgio/kgio_ext.c @@ -15,6 +15,7 @@ #include <assert.h> #include "missing/accept4.h" +#include "missing/ancient_ruby.h" #include "nonblock.h" #include "my_fileno.h" #include "sock_for_fd.h" diff --git a/ext/kgio/missing/ancient_ruby.h b/ext/kgio/missing/ancient_ruby.h new file mode 100644 index 0000000..014e4b8 --- /dev/null +++ b/ext/kgio/missing/ancient_ruby.h @@ -0,0 +1,19 @@ +#ifndef MISSING_ANCIENT_RUBY_H +#define MISSING_ANCIENT_RUBY_H + +#ifndef HAVE_RB_STR_SET_LEN +static void rb_str_set_len(VALUE str, long len) +{ + RSTRING(str)->len = len; + RSTRING(str)->ptr[len] = '\0'; +} +#endif /* ! HAVE_RB_STR_SET_LEN */ + +#ifndef RSTRING_PTR +# define RSTRING_PTR(s) (RSTRING(s)->ptr) +#endif /* !defined(RSTRING_PTR) */ +#ifndef RSTRING_LEN +# define RSTRING_LEN(s) (RSTRING(s)->len) +#endif /* !defined(RSTRING_LEN) */ + +#endif /* MISSING_ANCIENT_RUBY_H */ |