[macruby-changes] [2513] MacRuby/trunk/marshal.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Sep 8 11:44:27 PDT 2009
Revision: 2513
http://trac.macosforge.org/projects/ruby/changeset/2513
Author: lsansonetti at apple.com
Date: 2009-09-08 11:44:27 -0700 (Tue, 08 Sep 2009)
Log Message:
-----------
fixed a bunch of Marshal bugs
Modified Paths:
--------------
MacRuby/trunk/marshal.c
Modified: MacRuby/trunk/marshal.c
===================================================================
--- MacRuby/trunk/marshal.c 2009-09-08 18:42:37 UTC (rev 2512)
+++ MacRuby/trunk/marshal.c 2009-09-08 18:44:27 UTC (rev 2513)
@@ -971,7 +971,7 @@
type_error:
rb_raise(rb_eTypeError, "instance of IO needed");
}
- GC_WB(&arg->str, rb_str_buf_new(0));
+ GC_WB(&arg->str, rb_bytestring_new());
GC_WB(&arg->dest, port);
if (rb_obj_respond_to(port, s_binmode, Qtrue)) {
rb_funcall2(port, s_binmode, 0, 0);
@@ -982,9 +982,6 @@
GC_WB(&arg->str, port);
}
- // TODO should create ByteString
- //RSTRING_BYTEPTR(arg->str); /* force bytestring creation */
-
GC_WB(&arg->symbols, st_init_numtable());
GC_WB(&arg->data, st_init_numtable());
arg->taint = Qfalse;
@@ -1043,9 +1040,12 @@
VALUE src = arg->src;
VALUE v = rb_funcall2(src, s_getbyte, 0, 0);
check_load_arg(arg);
- if (NIL_P(v)) rb_eof_error();
+ if (NIL_P(v)) {
+ rb_eof_error();
+ }
c = (unsigned char)NUM2CHR(v);
}
+
return c;
}
@@ -1115,6 +1115,7 @@
UInt8 *data = rb_bytestring_byte_pointer(str);
memcpy(data, (UInt8 *)RSTRING_PTR(arg->src) + arg->offset, len);
data[len] = '\0';
+ arg->offset += len;
}
else {
too_short:
@@ -1424,6 +1425,7 @@
RBIGNUM_SET_SIGN(big, (r_byte(arg) == '+'));
len = r_long(arg);
data = r_bytes0(len * 2, arg);
+ // TODO: this doesn't work at all
#if SIZEOF_BDIGITS == SIZEOF_SHORT
rb_big_resize((VALUE)big, len);
#else
@@ -1431,7 +1433,7 @@
#endif
digits = RBIGNUM_DIGITS(big);
MEMCPY(digits, RSTRING_PTR(data), char, len * 2);
-#if SIZEOF_BDIGITS > SIZEOF_SHORT
+#if 0//SIZEOF_BDIGITS > SIZEOF_SHORT
MEMZERO((char *)digits + len * 2, char,
RBIGNUM_LEN(big) * sizeof(BDIGIT) - len * 2);
#endif
@@ -1467,8 +1469,9 @@
case TYPE_REGEXP:
{
volatile VALUE str = r_bytes(arg);
- int options = r_byte(arg);
- v = r_entry(rb_reg_new_str(str, options), arg);
+ const char *cstr = RSTRING_PTR(str);
+ const int options = r_byte(arg);
+ v = r_entry(rb_reg_new(cstr, strlen(cstr), options), arg);
v = r_leave(v, arg);
}
break;
@@ -1555,7 +1558,7 @@
rb_raise(rb_eTypeError, "class %s needs to have method `_load'",
rb_class2name(klass));
}
- data = r_string(arg);
+ data = r_bytes(arg);
if (ivp) {
r_ivar(data, arg);
*ivp = Qfalse;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090908/b587a442/attachment.html>
More information about the macruby-changes
mailing list