#include "ruby.h"
#include "ruby/io.h"
#include "ruby/encoding.h"
Include dependency graph for stringio.c:
Go to the source code of this file.
Data Structures | |
struct | StringIO |
Defines | |
#define | IS_STRIO(obj) (rb_typeddata_is_kind_of(obj, &strio_data_type)) |
#define | error_inval(msg) (errno = EINVAL, rb_sys_fail(msg)) |
#define | check_strio(self) ((struct StringIO*)rb_check_typeddata(self, &strio_data_type)) |
#define | StringIO(obj) get_strio(obj) |
#define | CLOSED(ptr) (!((ptr)->flags & FMODE_READWRITE)) |
#define | READABLE(ptr) ((ptr)->flags & FMODE_READABLE) |
#define | WRITABLE(ptr) ((ptr)->flags & FMODE_WRITABLE) |
#define | strio_binmode strio_self |
#define | strio_fcntl strio_unimpl |
#define | strio_flush strio_self |
#define | strio_fsync strio_0 |
#define | strio_set_sync strio_first |
#define | strio_tell strio_get_pos |
#define | strio_addstr rb_io_addstr |
#define | strio_print rb_io_print |
#define | strio_printf rb_io_printf |
#define | strio_puts rb_io_puts |
#define | strio_syswrite strio_write |
#define | strio_isatty strio_false |
#define | strio_pid strio_nil |
#define | strio_fileno strio_nil |
Functions | |
static void | strio_init (int, VALUE *, struct StringIO *) |
static struct StringIO * | strio_alloc (void) |
static void | strio_mark (void *p) |
static void | strio_free (void *p) |
static size_t | strio_memsize (const void *p) |
static struct StringIO * | get_strio (VALUE self) |
static VALUE | strio_substr (struct StringIO *ptr, long pos, long len) |
static struct StringIO * | readable (struct StringIO *ptr) |
static struct StringIO * | writable (struct StringIO *ptr) |
static void | check_modifiable (struct StringIO *ptr) |
static VALUE | strio_s_allocate (VALUE klass) |
static VALUE | strio_initialize (int argc, VALUE *argv, VALUE self) |
static VALUE | strio_finalize (VALUE self) |
static VALUE | strio_s_open (int argc, VALUE *argv, VALUE klass) |
static VALUE | strio_false (VALUE self) |
static VALUE | strio_nil (VALUE self) |
static VALUE | strio_self (VALUE self) |
static VALUE | strio_0 (VALUE self) |
static VALUE | strio_first (VALUE self, VALUE arg) |
static VALUE | strio_unimpl (int argc, VALUE *argv, VALUE self) |
static VALUE | strio_get_string (VALUE self) |
static VALUE | strio_set_string (VALUE self, VALUE string) |
static VALUE | strio_close (VALUE self) |
static VALUE | strio_close_read (VALUE self) |
static VALUE | strio_close_write (VALUE self) |
static VALUE | strio_closed (VALUE self) |
static VALUE | strio_closed_read (VALUE self) |
static VALUE | strio_closed_write (VALUE self) |
static VALUE | strio_eof (VALUE self) |
static VALUE | strio_copy (VALUE copy, VALUE orig) |
static VALUE | strio_get_lineno (VALUE self) |
static VALUE | strio_set_lineno (VALUE self, VALUE lineno) |
static VALUE | strio_reopen (int argc, VALUE *argv, VALUE self) |
static VALUE | strio_get_pos (VALUE self) |
static VALUE | strio_set_pos (VALUE self, VALUE pos) |
static VALUE | strio_rewind (VALUE self) |
static VALUE | strio_seek (int argc, VALUE *argv, VALUE self) |
static VALUE | strio_get_sync (VALUE self) |
static VALUE | strio_each_byte (VALUE self) |
static VALUE | strio_getc (VALUE self) |
static VALUE | strio_getbyte (VALUE self) |
static void | strio_extend (struct StringIO *ptr, long pos, long len) |
static VALUE | strio_ungetc (VALUE self, VALUE c) |
static VALUE | strio_ungetbyte (VALUE self, VALUE c) |
static VALUE | strio_readchar (VALUE self) |
static VALUE | strio_readbyte (VALUE self) |
static VALUE | strio_each_char (VALUE self) |
static VALUE | strio_each_codepoint (VALUE self) |
static void | bm_init_skip (long *skip, const char *pat, long m) |
static long | bm_search (const char *little, long llen, const char *big, long blen, const long *skip) |
static VALUE | strio_getline (int argc, VALUE *argv, struct StringIO *ptr) |
static VALUE | strio_gets (int argc, VALUE *argv, VALUE self) |
static VALUE | strio_readline (int argc, VALUE *argv, VALUE self) |
static VALUE | strio_each (int argc, VALUE *argv, VALUE self) |
static VALUE | strio_readlines (int argc, VALUE *argv, VALUE self) |
static VALUE | strio_write (VALUE self, VALUE str) |
static VALUE | strio_putc (VALUE self, VALUE ch) |
static VALUE | strio_read (int argc, VALUE *argv, VALUE self) |
static VALUE | strio_sysread (int argc, VALUE *argv, VALUE self) |
static VALUE | strio_size (VALUE self) |
static VALUE | strio_truncate (VALUE self, VALUE len) |
static VALUE | strio_external_encoding (VALUE self) |
static VALUE | strio_internal_encoding (VALUE self) |
static VALUE | strio_set_encoding (VALUE self, VALUE ext_enc) |
void | Init_stringio () |
Variables | |
static const rb_data_type_t | strio_data_type |
#define check_strio | ( | self | ) | ((struct StringIO*)rb_check_typeddata(self, &strio_data_type)) |
Definition at line 81 of file stringio.c.
Referenced by get_strio(), strio_copy(), and strio_initialize().
#define CLOSED | ( | ptr | ) | (!((ptr)->flags & FMODE_READWRITE)) |
Definition at line 108 of file stringio.c.
Referenced by strio_close(), strio_closed(), and strio_seek().
Definition at line 34 of file stringio.c.
Referenced by strio_seek(), strio_set_pos(), and strio_truncate().
#define IS_STRIO | ( | obj | ) | (rb_typeddata_is_kind_of(obj, &strio_data_type)) |
Definition at line 33 of file stringio.c.
#define READABLE | ( | ptr | ) | ((ptr)->flags & FMODE_READABLE) |
Definition at line 109 of file stringio.c.
Referenced by readable(), strio_close_read(), and strio_closed_read().
#define StringIO | ( | obj | ) | get_strio(obj) |
Definition at line 106 of file stringio.c.
Referenced by strio_0(), strio_close(), strio_close_read(), strio_close_write(), strio_closed(), strio_closed_read(), strio_closed_write(), strio_copy(), strio_each(), strio_each_byte(), strio_each_codepoint(), strio_eof(), strio_external_encoding(), strio_false(), strio_finalize(), strio_first(), strio_get_lineno(), strio_get_pos(), strio_get_string(), strio_get_sync(), strio_getbyte(), strio_getc(), strio_gets(), strio_nil(), strio_putc(), strio_read(), strio_readlines(), strio_reopen(), strio_rewind(), strio_seek(), strio_self(), strio_set_encoding(), strio_set_lineno(), strio_set_pos(), strio_set_string(), strio_size(), strio_truncate(), strio_ungetbyte(), strio_ungetc(), strio_unimpl(), and strio_write().
#define strio_addstr rb_io_addstr |
#define strio_binmode strio_self |
#define strio_fcntl strio_unimpl |
#define strio_fileno strio_nil |
#define strio_flush strio_self |
#define strio_fsync strio_0 |
#define strio_isatty strio_false |
#define strio_pid strio_nil |
#define strio_print rb_io_print |
#define strio_printf rb_io_printf |
#define strio_puts rb_io_puts |
#define strio_set_sync strio_first |
#define strio_syswrite strio_write |
#define strio_tell strio_get_pos |
#define WRITABLE | ( | ptr | ) | ((ptr)->flags & FMODE_WRITABLE) |
Definition at line 110 of file stringio.c.
Referenced by strio_close_write(), strio_closed_write(), and writable().
static void bm_init_skip | ( | long * | skip, | |
const char * | pat, | |||
long | m | |||
) | [static] |
static long bm_search | ( | const char * | little, | |
long | llen, | |||
const char * | big, | |||
long | blen, | |||
const long * | skip | |||
) | [static] |
Definition at line 899 of file stringio.c.
Referenced by forward_search_range(), and strio_getline().
static void check_modifiable | ( | struct StringIO * | ptr | ) | [static] |
Definition at line 134 of file stringio.c.
References OBJ_FROZEN, rb_eIOError, rb_raise(), and StringIO::string.
Referenced by strio_extend(), strio_putc(), and strio_write().
Definition at line 84 of file stringio.c.
References check_strio, rb_eIOError, rb_io_taint_check(), and rb_raise().
void Init_stringio | ( | ) |
Definition at line 1385 of file stringio.c.
References rb_cData, rb_define_alloc_func(), rb_define_class(), rb_define_method(), rb_define_singleton_method(), rb_include_module(), rb_mEnumerable, strio_addstr, strio_binmode, strio_close(), strio_close_read(), strio_close_write(), strio_closed(), strio_closed_read(), strio_closed_write(), strio_copy(), strio_each(), strio_each_byte(), strio_each_char(), strio_each_codepoint(), strio_eof(), strio_external_encoding(), strio_fcntl, strio_fileno, strio_flush, strio_fsync, strio_get_lineno(), strio_get_pos(), strio_get_string(), strio_get_sync(), strio_getbyte(), strio_getc(), strio_gets(), strio_initialize(), strio_internal_encoding(), strio_isatty, strio_pid, strio_print, strio_printf, strio_putc(), strio_puts, strio_read(), strio_readbyte(), strio_readchar(), strio_readline(), strio_readlines(), strio_reopen(), strio_rewind(), strio_s_allocate(), strio_s_open(), strio_seek(), strio_set_encoding(), strio_set_lineno(), strio_set_pos(), strio_set_string(), strio_set_sync, strio_size(), strio_sysread(), strio_syswrite, strio_tell, strio_truncate(), strio_ungetbyte(), strio_ungetc(), and strio_write().
Definition at line 113 of file stringio.c.
References rb_eIOError, rb_raise(), and READABLE.
Referenced by strio_each(), strio_each_byte(), strio_each_codepoint(), strio_eof(), strio_getbyte(), strio_getc(), strio_gets(), strio_read(), strio_readlines(), strio_ungetbyte(), and strio_ungetc().
static struct StringIO* strio_alloc | ( | void | ) | [static] |
Definition at line 37 of file stringio.c.
References ALLOC, StringIO::count, StringIO::flags, StringIO::lineno, StringIO::pos, Qnil, and StringIO::string.
Referenced by strio_initialize().
Definition at line 330 of file stringio.c.
References CLOSED, StringIO::flags, FMODE_READWRITE, Qnil, rb_eIOError, rb_raise(), and StringIO.
Referenced by Init_stringio().
Definition at line 348 of file stringio.c.
References StringIO::flags, FMODE_READABLE, Qnil, rb_eIOError, rb_raise(), READABLE, and StringIO.
Referenced by Init_stringio().
Definition at line 366 of file stringio.c.
References StringIO::flags, FMODE_WRITABLE, Qnil, rb_eIOError, rb_raise(), StringIO, and WRITABLE.
Referenced by Init_stringio().
Definition at line 383 of file stringio.c.
References CLOSED, Qfalse, Qtrue, and StringIO.
Referenced by Init_stringio().
Definition at line 397 of file stringio.c.
References Qfalse, Qtrue, READABLE, and StringIO.
Referenced by Init_stringio().
Definition at line 411 of file stringio.c.
References Qfalse, Qtrue, StringIO, and WRITABLE.
Referenced by Init_stringio().
Definition at line 436 of file stringio.c.
References check_strio, StringIO::count, DATA_PTR, OBJ_INFECT, rb_convert_type(), StringIO, strio_free(), and T_DATA.
Referenced by Init_stringio(), and strio_reopen().
Definition at line 1061 of file stringio.c.
References NIL_P, rb_yield(), readable(), RETURN_ENUMERATOR, StringIO, and strio_getline().
Referenced by Init_stringio().
Definition at line 627 of file stringio.c.
References CHR2FIX, StringIO::pos, rb_yield(), readable(), RETURN_ENUMERATOR, RSTRING_LEN, RSTRING_PTR, StringIO::string, and StringIO.
Referenced by Init_stringio().
Definition at line 837 of file stringio.c.
References NIL_P, rb_yield(), RETURN_ENUMERATOR, and strio_getc().
Referenced by Init_stringio().
Definition at line 860 of file stringio.c.
References StringIO::pos, rb_enc_codepoint_len(), rb_enc_get(), rb_yield(), readable(), RETURN_ENUMERATOR, RSTRING_END, RSTRING_LEN, RSTRING_PTR, StringIO::string, StringIO, and UINT2NUM().
Referenced by Init_stringio().
Definition at line 427 of file stringio.c.
References StringIO::pos, Qfalse, Qtrue, readable(), RSTRING_LEN, StringIO::string, and StringIO.
Referenced by Init_stringio().
static void strio_extend | ( | struct StringIO * | ptr, | |
long | pos, | |||
long | len | |||
) | [static] |
Definition at line 682 of file stringio.c.
References check_modifiable(), MEMZERO, rb_str_modify(), rb_str_resize(), RSTRING_LEN, RSTRING_PTR, and StringIO::string.
Referenced by strio_putc(), and strio_write().
Definition at line 1345 of file stringio.c.
References rb_enc_from_encoding(), rb_enc_get(), StringIO::string, and StringIO.
Referenced by Init_stringio().
Definition at line 207 of file stringio.c.
References StringIO::flags, FMODE_READWRITE, Qnil, StringIO::string, and StringIO.
Referenced by strio_s_open().
static void strio_free | ( | void * | p | ) | [static] |
Definition at line 58 of file stringio.c.
References StringIO::count, and xfree.
Referenced by strio_copy().
Definition at line 463 of file stringio.c.
References StringIO::lineno, LONG2NUM, and StringIO.
Referenced by Init_stringio().
Definition at line 521 of file stringio.c.
References LONG2NUM, StringIO::pos, and StringIO.
Referenced by Init_stringio().
Definition at line 605 of file stringio.c.
References Qtrue, and StringIO.
Referenced by Init_stringio().
Definition at line 670 of file stringio.c.
References CHR2FIX, StringIO::pos, Qnil, readable(), RSTRING_LEN, RSTRING_PTR, StringIO::string, and StringIO.
Referenced by Init_stringio(), and strio_readbyte().
Definition at line 647 of file stringio.c.
References len, StringIO::pos, Qnil, rb_enc_get(), rb_enc_mbclen(), rb_enc_str_new(), readable(), RSTRING_END, RSTRING_LEN, RSTRING_PTR, StringIO::string, and StringIO.
Referenced by Init_stringio(), strio_each_char(), and strio_readchar().
Definition at line 918 of file stringio.c.
References bm_init_skip(), bm_search(), CHAR_BIT, StringIO::lineno, MEMCMP, NIL_P, NUM2LONG(), StringIO::pos, Qnil, rb_check_string_type(), rb_enc_get(), rb_enc_right_char_head, rb_rs, rb_scan_args(), rb_str_new(), RSTRING_LEN, RSTRING_PTR, StringIO::string, StringValue, strio_substr(), T_STRING, and TYPE.
Referenced by strio_each(), strio_gets(), and strio_readlines().
Definition at line 1017 of file stringio.c.
References rb_lastline_set(), readable(), StringIO, and strio_getline().
Referenced by Init_stringio(), and strio_readline().
Definition at line 166 of file stringio.c.
References errno, FIX2INT, FIXNUM_P, StringIO::flags, FMODE_READABLE, FMODE_READWRITE, FMODE_WRITABLE, StringIO::lineno, OBJ_FROZEN, StringIO::pos, rb_default_external_encoding(), rb_enc_str_new(), rb_io_mode_flags, rb_io_modenum_flags, rb_scan_args(), rb_str_resize(), rb_sys_fail, StringIO::string, StringValue, and StringValueCStr.
Referenced by strio_initialize(), and strio_reopen().
Definition at line 153 of file stringio.c.
References check_strio, DATA_PTR, rb_call_super(), strio_alloc(), and strio_init().
Referenced by Init_stringio().
static void strio_mark | ( | void * | p | ) | [static] |
static size_t strio_memsize | ( | const void * | p | ) | [static] |
Definition at line 67 of file stringio.c.
Definition at line 1170 of file stringio.c.
References check_modifiable(), StringIO::flags, FMODE_APPEND, NUM2CHR(), OBJ_INFECT, StringIO::pos, RSTRING_LEN, RSTRING_PTR, StringIO::string, StringIO, strio_extend(), and writable().
Referenced by Init_stringio().
Definition at line 1202 of file stringio.c.
References len, MEMCPY, NIL_P, NUM2LONG(), StringIO::pos, Qnil, rb_ascii8bit_encoding(), rb_eArgError, rb_enc_associate(), rb_raise(), rb_str_modify(), rb_str_new(), rb_str_resize(), readable(), RSTRING_LEN, RSTRING_PTR, StringIO::string, StringIO, StringValue, and strio_substr().
Referenced by Init_stringio(), and strio_sysread().
Definition at line 819 of file stringio.c.
References NIL_P, rb_eof_error(), and strio_getbyte().
Referenced by Init_stringio().
Definition at line 805 of file stringio.c.
References NIL_P, rb_eof_error(), and strio_getc().
Referenced by Init_stringio().
Definition at line 1034 of file stringio.c.
References NIL_P, rb_eof_error(), and strio_gets().
Referenced by Init_stringio().
Definition at line 1083 of file stringio.c.
References NIL_P, rb_ary_new(), rb_ary_push(), readable(), StringIO, and strio_getline().
Referenced by Init_stringio().
Definition at line 503 of file stringio.c.
References rb_io_taint_check(), StringIO, strio_copy(), strio_init(), T_STRING, and TYPE.
Referenced by Init_stringio().
Definition at line 552 of file stringio.c.
References INT2FIX, StringIO::lineno, StringIO::pos, and StringIO.
Referenced by Init_stringio().
Definition at line 142 of file stringio.c.
References strio_data_type, and TypedData_Wrap_Struct.
Referenced by Init_stringio().
Definition at line 223 of file stringio.c.
References rb_block_given_p(), rb_class_new_instance(), rb_ensure(), rb_yield(), and strio_finalize().
Referenced by Init_stringio().
Definition at line 568 of file stringio.c.
References CLOSED, error_inval, INT2FIX, NIL_P, NULL, NUM2LONG(), StringIO::pos, rb_eIOError, rb_raise(), rb_scan_args(), RSTRING_LEN, StringIO::string, and StringIO.
Referenced by Init_stringio().
Definition at line 1372 of file stringio.c.
References rb_enc_associate(), rb_to_encoding(), and StringIO.
Referenced by Init_stringio().
Definition at line 476 of file stringio.c.
References NUM2LONG(), and StringIO.
Referenced by Init_stringio().
Definition at line 533 of file stringio.c.
References error_inval, NUM2LONG(), StringIO::pos, and StringIO.
Referenced by Init_stringio().
Definition at line 309 of file stringio.c.
References StringIO::flags, FMODE_READABLE, FMODE_READWRITE, StringIO::lineno, OBJ_FROZEN, StringIO::pos, rb_io_taint_check(), StringIO::string, StringIO, and StringValue.
Referenced by Init_stringio().
Definition at line 1304 of file stringio.c.
References NIL_P, rb_eIOError, rb_raise(), RSTRING_LEN, StringIO::string, StringIO, and ULONG2NUM().
Referenced by Init_stringio().
Definition at line 95 of file stringio.c.
References rb_enc_get(), rb_enc_str_new(), RSTRING_LEN, RSTRING_PTR, and StringIO::string.
Referenced by strio_getline(), and strio_read().
Definition at line 1272 of file stringio.c.
References NIL_P, rb_eof_error(), and strio_read().
Referenced by Init_stringio().
Definition at line 1321 of file stringio.c.
References error_inval, MEMZERO, NUM2LONG(), rb_str_resize(), RSTRING_LEN, RSTRING_PTR, StringIO::string, StringIO, and writable().
Referenced by Init_stringio().
Definition at line 763 of file stringio.c.
References buf, FIX2INT, FIXNUM_P, memmove(), NIL_P, StringIO::pos, Qnil, RB_GC_GUARD, rb_str_modify(), rb_str_resize(), readable(), RSTRING_LEN, RSTRING_PTR, SafeStringValue, StringIO::string, and StringIO.
Referenced by Init_stringio().
Definition at line 708 of file stringio.c.
References buf, FIX2INT, FIXNUM_P, len, NIL_P, StringIO::pos, Qnil, rb_ascii8bit_encoding(), rb_enc_codelen(), rb_enc_get(), rb_enc_mbclen(), rb_enc_mbcput, rb_enc_str_new(), rb_str_concat(), rb_str_conv_enc(), rb_str_resize(), rb_str_update(), readable(), RSTRING_LEN, RSTRING_PTR, SafeStringValue, StringIO::string, and StringIO.
Referenced by Init_stringio().
Definition at line 1104 of file stringio.c.
References check_modifiable(), StringIO::flags, FMODE_APPEND, INT2FIX, len, LONG2NUM, memmove(), OBJ_INFECT, StringIO::pos, rb_ascii8bit_encoding(), rb_enc_get(), RB_GC_GUARD, rb_obj_as_string(), rb_str_cat(), rb_str_conv_enc(), RSTRING_LEN, RSTRING_PTR, StringIO::string, StringIO, strio_extend(), T_STRING, TYPE, and writable().
Referenced by Init_stringio().
Definition at line 122 of file stringio.c.
References OBJ_TAINTED, rb_eIOError, rb_raise(), rb_secure(), StringIO::string, and WRITABLE.
Referenced by strio_putc(), strio_truncate(), and strio_write().
const rb_data_type_t strio_data_type [static] |
Initial value:
{ "strio", strio_mark, strio_free, strio_memsize, }
Definition at line 74 of file stringio.c.
Referenced by strio_s_allocate().