Bug #8669 » read_internal_callback.diff
internal.h | ||
---|---|---|
#define QUOTE(str) rb_str_quote_unprintable(str)
|
||
#define QUOTE_ID(id) rb_id_quote_unprintable(id)
|
||
void rb_str_fill_terminator(VALUE str, const int termlen);
|
||
VALUE rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg);
|
||
/* struct.c */
|
||
VALUE rb_struct_init_copy(VALUE copy, VALUE s);
|
io.c | ||
---|---|---|
void
|
||
rb_readwrite_sys_fail(int writable, const char *mesg);
|
||
struct read_internal_arg {
|
||
int fd;
|
||
char *str_ptr;
|
||
long len;
|
||
};
|
||
static VALUE
|
||
read_internal_call(VALUE arg)
|
||
{
|
||
struct read_internal_arg *p = (struct read_internal_arg *)arg;
|
||
p->len = rb_read_internal(p->fd, p->str_ptr, p->len);
|
||
return Qundef;
|
||
}
|
||
static VALUE
|
||
io_getpartial(int argc, VALUE *argv, VALUE io, int nonblock)
|
||
{
|
||
rb_io_t *fptr;
|
||
VALUE length, str;
|
||
long n, len;
|
||
struct read_internal_arg arg;
|
||
rb_scan_args(argc, argv, "11", &length, &str);
|
||
... | ... | |
rb_io_set_nonblock(fptr);
|
||
}
|
||
io_setstrbuf(&str, len);
|
||
rb_str_locktmp(str);
|
||
n = rb_read_internal(fptr->fd, RSTRING_PTR(str), len);
|
||
rb_str_unlocktmp(str);
|
||
arg.fd = fptr->fd;
|
||
arg.str_ptr = RSTRING_PTR(str);
|
||
arg.len = len;
|
||
rb_str_locktmp_ensure(str, read_internal_call, (VALUE)&arg);
|
||
n = arg.len;
|
||
if (n < 0) {
|
||
if (!nonblock && rb_io_wait_readable(fptr->fd))
|
||
goto again;
|
||
... | ... | |
VALUE len, str;
|
||
rb_io_t *fptr;
|
||
long n, ilen;
|
||
struct read_internal_arg arg;
|
||
rb_scan_args(argc, argv, "11", &len, &str);
|
||
ilen = NUM2LONG(len);
|
||
... | ... | |
io_setstrbuf(&str, ilen);
|
||
rb_str_locktmp(str);
|
||
n = rb_read_internal(fptr->fd, RSTRING_PTR(str), ilen);
|
||
rb_str_unlocktmp(str);
|
||
arg.fd = fptr->fd;
|
||
arg.str_ptr = RSTRING_PTR(str);
|
||
arg.len = ilen;
|
||
rb_ensure(read_internal_call, (VALUE)&arg, rb_str_unlocktmp, str);
|
||
n = arg.len;
|
||
if (n == -1) {
|
||
rb_sys_fail_path(fptr->pathv);
|
string.c | ||
---|---|---|
return str;
|
||
}
|
||
VALUE
|
||
rb_str_locktmp_ensure(VALUE str, VALUE (*func)(VALUE), VALUE arg)
|
||
{
|
||
rb_str_locktmp(str);
|
||
return rb_ensure(func, arg, rb_str_unlocktmp, str);
|
||
}
|
||
void
|
||
rb_str_set_len(VALUE str, long len)
|
||
{
|
- « Previous
- 1
- 2
- 3
- 4
- Next »