1730 |
1730 |
return rb_funcallv(io, id_write, 1, &str);
|
1731 |
1731 |
}
|
1732 |
1732 |
|
|
1733 |
VALUE
|
|
1734 |
rb_io_writev(VALUE io, int argc, VALUE *argv)
|
|
1735 |
{
|
|
1736 |
return rb_funcallv(io, id_write, argc, argv);
|
|
1737 |
}
|
|
1738 |
|
1733 |
1739 |
/*
|
1734 |
1740 |
* call-seq:
|
1735 |
1741 |
* ios << obj -> ios
|
... | ... | |
7586 |
7592 |
return Qtrue;
|
7587 |
7593 |
}
|
7588 |
7594 |
|
|
7595 |
void
|
|
7596 |
io_puts_string(VALUE out, VALUE str)
|
|
7597 |
{
|
|
7598 |
if (RSTRING_LEN(str) == 0 || !rb_str_end_with_asciichar(str, '\n')) {
|
|
7599 |
#ifdef HAVE_WRITEV
|
|
7600 |
VALUE args[2];
|
|
7601 |
args[0] = str;
|
|
7602 |
args[1] = rb_default_rs;
|
|
7603 |
rb_io_writev(out, 2, args);
|
|
7604 |
#else
|
|
7605 |
rb_io_write(out, str);
|
|
7606 |
rb_io_write(out, rb_default_rs);
|
|
7607 |
#endif
|
|
7608 |
}
|
|
7609 |
else {
|
|
7610 |
rb_io_write(out, str);
|
|
7611 |
}
|
|
7612 |
}
|
|
7613 |
|
7589 |
7614 |
/*
|
7590 |
7615 |
* call-seq:
|
7591 |
7616 |
* ios.puts(obj, ...) -> nil
|
... | ... | |
7617 |
7642 |
rb_io_puts(int argc, const VALUE *argv, VALUE out)
|
7618 |
7643 |
{
|
7619 |
7644 |
int i;
|
7620 |
|
VALUE line;
|
7621 |
7645 |
|
7622 |
7646 |
/* if no argument given, print newline. */
|
7623 |
7647 |
if (argc == 0) {
|
7624 |
|
rb_io_write(out, rb_default_rs);
|
7625 |
|
return Qnil;
|
|
7648 |
rb_io_write(out, rb_default_rs);
|
|
7649 |
return Qnil;
|
7626 |
7650 |
}
|
7627 |
7651 |
for (i=0; i<argc; i++) {
|
7628 |
|
if (RB_TYPE_P(argv[i], T_STRING)) {
|
7629 |
|
line = argv[i];
|
7630 |
|
goto string;
|
7631 |
|
}
|
7632 |
|
if (rb_exec_recursive(io_puts_ary, argv[i], out)) {
|
7633 |
|
continue;
|
7634 |
|
}
|
7635 |
|
line = rb_obj_as_string(argv[i]);
|
7636 |
|
string:
|
7637 |
|
rb_io_write(out, line);
|
7638 |
|
if (RSTRING_LEN(line) == 0 ||
|
7639 |
|
!rb_str_end_with_asciichar(line, '\n')) {
|
7640 |
|
rb_io_write(out, rb_default_rs);
|
7641 |
|
}
|
|
7652 |
if (RB_TYPE_P(argv[i], T_STRING)) {
|
|
7653 |
io_puts_string(out, argv[i]);
|
|
7654 |
continue;
|
|
7655 |
}
|
|
7656 |
|
|
7657 |
if (rb_exec_recursive(io_puts_ary, argv[i], out)) {
|
|
7658 |
continue;
|
|
7659 |
}
|
|
7660 |
|
|
7661 |
io_puts_string(out, rb_obj_as_string(argv[i]));
|
7642 |
7662 |
}
|
7643 |
7663 |
|
7644 |
7664 |
return Qnil;
|