diff options
-rw-r--r-- | ext/kgio/extconf.rb | 1 | ||||
-rw-r--r-- | ext/kgio/read_write.c | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/ext/kgio/extconf.rb b/ext/kgio/extconf.rb index fb680f7..f6bd0cc 100644 --- a/ext/kgio/extconf.rb +++ b/ext/kgio/extconf.rb @@ -49,5 +49,6 @@ have_func('rb_thread_io_blocking_region') have_func('rb_str_set_len') have_func('rb_time_interval') have_func('rb_wait_for_single_fd') +have_func('rb_str_subseq') create_makefile('kgio_ext') diff --git a/ext/kgio/read_write.c b/ext/kgio/read_write.c index 51d2d16..9924743 100644 --- a/ext/kgio/read_write.c +++ b/ext/kgio/read_write.c @@ -4,6 +4,9 @@ static VALUE sym_wait_readable, sym_wait_writable; static VALUE eErrno_EPIPE, eErrno_ECONNRESET; static ID id_set_backtrace; +#ifndef HAVE_RB_STR_SUBSEQ +#define rb_str_subseq rb_str_substr +#endif /* * we know MSG_DONTWAIT works properly on all stream sockets under Linux @@ -338,7 +341,7 @@ done: a->ptr = RSTRING_PTR(a->buf) + written; return -1; } else if (written > 0) { - a->buf = rb_str_new(a->ptr, a->len); + a->buf = rb_str_subseq(a->buf, written, a->len); } else { a->buf = sym_wait_writable; } |