THRIFT-374. rb: ruby 1.9 compatibility
This patch updates the thrift_native package to use 1.9 compatible macros and fixes the pure ruby stuff to behave equally well in ruby1.8.6-ruby1.9.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@758435 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/ext/memory_buffer.c b/lib/rb/ext/memory_buffer.c
index e37c787..e90de75 100644
--- a/lib/rb/ext/memory_buffer.c
+++ b/lib/rb/ext/memory_buffer.c
@@ -31,7 +31,7 @@
VALUE rb_thrift_memory_buffer_write(VALUE self, VALUE str) {
VALUE buf = GET_BUF(self);
- rb_str_buf_cat(buf, RSTRING(str)->ptr, RSTRING(str)->len);
+ rb_str_buf_cat(buf, RSTRING_PTR(str), RSTRING_LEN(str));
return Qnil;
}
@@ -45,11 +45,11 @@
VALUE data = rb_funcall(buf, slice_method_id, 2, index_value, length_value);
index += length;
- if (index > RSTRING(buf)->len) {
- index = RSTRING(buf)->len;
+ if (index > RSTRING_LEN(buf)) {
+ index = RSTRING_LEN(buf);
}
if (index >= GARBAGE_BUFFER_SIZE) {
- rb_ivar_set(self, buf_ivar_id, rb_funcall(buf, slice_method_id, 2, INT2FIX(index), INT2FIX(RSTRING(buf)->len - 1)));
+ rb_ivar_set(self, buf_ivar_id, rb_funcall(buf, slice_method_id, 2, INT2FIX(index), INT2FIX(RSTRING_LEN(buf) - 1)));
index = 0;
}