summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-13 04:38:01 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-07-13 04:38:01 +0000
commit35c6e6af5ba2c405a91dc6b9e4af833d0979ed22 (patch)
tree7f54dda0bcda0a58eb5229def03ce3015c98a2b5 /marshal.c
parent71d408a6c3298b229c0f1d2ff7159ca410a4c612 (diff)
str2cstr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/marshal.c b/marshal.c
index 4234c98981..095db75cd7 100644
--- a/marshal.c
+++ b/marshal.c
@@ -812,21 +812,21 @@ marshal_load(argc, argv)
struct load_arg arg;
rb_scan_args(argc, argv, "11", &port, &proc);
- if (TYPE(port) == T_STRING) {
+ if (obj_is_kind_of(port, cIO)) {
+ io_binmode(port);
+ GetOpenFile(port, fptr);
+ io_readable(fptr);
+ arg.fp = fptr->f;
+ }
+ else if (rb_respond_to(port, rb_intern("to_str"))) {
+ int len;
+
arg.fp = 0;
- arg.ptr = RSTRING(port)->ptr;
+ arg.ptr = str2cstr(port, &len);
arg.end = arg.ptr + RSTRING(port)->len;
}
else {
- if (obj_is_kind_of(port, cIO)) {
- io_binmode(port);
- GetOpenFile(port, fptr);
- io_readable(fptr);
- arg.fp = fptr->f;
- }
- else {
- TypeError("instance of IO needed");
- }
+ TypeError("instance of IO needed");
}
major = r_byte(&arg);