Bug #8669 » io_fread_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 | ||
---|---|---|
static void io_setstrbuf(VALUE *str, long len);
|
||
struct bufread_arg {
|
||
char *str_ptr;
|
||
long len;
|
||
rb_io_t *fptr;
|
||
};
|
||
static VALUE
|
||
bufread_call(VALUE arg)
|
||
{
|
||
struct bufread_arg *p = (struct bufread_arg *)arg;
|
||
p->len = io_bufread(p->str_ptr, p->len, p->fptr);
|
||
return Qundef;
|
||
}
|
||
static long
|
||
io_fread(VALUE str, long offset, long size, rb_io_t *fptr)
|
||
{
|
||
long len;
|
||
struct bufread_arg arg;
|
||
io_setstrbuf(&str, offset + size);
|
||
rb_str_locktmp(str);
|
||
len = io_bufread(RSTRING_PTR(str) + offset, size, fptr);
|
||
rb_str_unlocktmp(str);
|
||
arg.str_ptr = RSTRING_PTR(str) + offset;
|
||
arg.len = size;
|
||
arg.fptr = fptr;
|
||
rb_str_locktmp_ensure(str, bufread_call, (VALUE)&arg);
|
||
len = arg.len;
|
||
if (len < 0) rb_sys_fail_path(fptr->pathv);
|
||
return len;
|
||
}
|
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)
|
||
{
|