438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
# File 'ext/libbin/data_types.c', line 438
static VALUE cStr_convert(int argc, VALUE* argv, VALUE self) {
(void)self;
VALUE input;
VALUE output;
VALUE length;
rb_scan_args(argc, argv, "25", &input, &output, NULL, NULL, NULL, NULL, &length);
VALUE str;
if (NIL_P(length))
str = rb_funcall(input, rb_intern("readline"), 1, rb_str_new_static("", 1));
else {
str = rb_funcall(input, id_read, 1, length);
if (NIL_P(str) || RSTRING_LEN(str) < NUM2LONG(length))
rb_raise(rb_eRuntimeError,
"could not read enough data: got %ld needed %zu", RSTRING_LEN(str), NUM2LONG(length));
}
rb_funcall(output, id_write, 1, str);
return str;
}
|