Ruby 2.0.0p247(2013-06-27revision41674)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Typedefs | Functions | Variables
transcode.c File Reference
`#include "ruby/ruby.h"`
`#include "ruby/encoding.h"`
`#include "internal.h"`
`#include "transcode_data.h"`
`#include <ctype.h>`
Include dependency graph for transcode.c:

Go to the source code of this file.

## Data Structures
struct | rb_transcoding
union | rb_transcoding::rb_transcoding_state_t
struct | rb_econv_elem_t
struct | rb_econv_t
struct | transcoder_entry_t
struct | search_path_queue_tag
struct | search_path_bfs_t
struct | trans_open_t
struct | asciicompat_encoding_t
struct | rb_econv_init_by_convpath_t

## Macros
#define | ENABLE_ECONV_NEWLINE_OPTION 1
#define | TRANSCODING_READBUF(tc)
#define | TRANSCODING_WRITEBUF(tc)
#define | TRANSCODING_WRITEBUF_SIZE(tc)
#define | TRANSCODING_STATE_EMBED_MAX ((int)sizeof(union rb_transcoding_state_t))
#define | TRANSCODING_STATE(tc)
#define | DECORATOR_P(sname, dname) (*(sname) == '\0')
#define | encoding_equal(enc1, enc2) (STRCASECMP((enc1), (enc2)) == 0)
#define | SUSPEND(ret, num)
#define | SUSPEND_OBUF(num)
#define | SUSPEND_AFTER_OUTPUT(num)
#define | next_table (tc->next_table)
#define | next_info (tc->next_info)
#define | next_byte (tc->next_byte)
#define | writebuf_len (tc->writebuf_len)
#define | writebuf_off (tc->writebuf_off)
#define | BYTE_ADDR(index) (tr->byte_array + (index))
#define | WORD_ADDR(index) (tr->word_array + INFO2WORDINDEX(index))
#define | BL_BASE BYTE_ADDR(BYTE_LOOKUP_BASE(WORD_ADDR(next_table)))
#define | BL_INFO WORD_ADDR(BYTE_LOOKUP_INFO(WORD_ADDR(next_table)))
#define | BL_MIN_BYTE (BL_BASE[0])
#define | BL_MAX_BYTE (BL_BASE[1])
#define | BL_OFFSET(byte) (BL_BASE[2+(byte)-BL_MIN_BYTE])
#define | BL_ACTION(byte) (BL_INFO[BL_OFFSET((byte))])
#define | MAX_ECFLAGS_DECORATORS 32
#define | hash_fallback rb_hash_aref

## Typedefs
typedef struct rb_transcoding | rb_transcoding
typedef struct search_path_queue_tag | search_path_queue_t

## Functions
static unsigned char * | allocate_converted_string (const char *sname, const char *dname, const unsigned char *str, size_t len, unsigned char *caller_dst_buf, size_t caller_dst_bufsize, size_t *dst_len_ptr)
static transcoder_entry_t * | make_transcoder_entry (const char *sname, const char *dname)
static transcoder_entry_t * | get_transcoder_entry (const char *sname, const char *dname)
void | rb_register_transcoder (const rb_transcoder *tr)
static void | declare_transcoder (const char *sname, const char *dname, const char *lib)
void | rb_declare_transcoder (const char *enc1, const char *enc2, const char *lib)
static int | transcode_search_path_i (st_data_t key, st_data_t val, st_data_t arg)
static int | transcode_search_path (const char *sname, const char *dname, void(*callback)(const char *sname, const char *dname, int depth, void *arg), void *arg)
static const rb_transcoder * | load_transcoder_entry (transcoder_entry_t *entry)
static const char * | get_replacement_character (const char *encname, size_t *len_ret, const char **repl_encname_ptr)
static const unsigned char * | transcode_char_start (rb_transcoding *tc, const unsigned char *in_start, const unsigned char *inchar_start, const unsigned char *in_p, size_t *char_len_ptr)
static rb_econv_result_t | transcode_restartable0 (const unsigned char **in_pos, unsigned char **out_pos, const unsigned char *in_stop, unsigned char *out_stop, rb_transcoding *tc, const int opt)
static rb_econv_result_t | transcode_restartable (const unsigned char **in_pos, unsigned char **out_pos, const unsigned char *in_stop, unsigned char *out_stop, rb_transcoding *tc, const int opt)
static rb_transcoding * | rb_transcoding_open_by_transcoder (const rb_transcoder *tr, int flags)
static rb_econv_result_t | rb_transcoding_convert (rb_transcoding *tc, const unsigned char **input_ptr, const unsigned char *input_stop, unsigned char **output_ptr, unsigned char *output_stop, int flags)
static void | rb_transcoding_close (rb_transcoding *tc)
static size_t | rb_transcoding_memsize (rb_transcoding *tc)
static rb_econv_t * | rb_econv_alloc (int n_hint)
static int | rb_econv_add_transcoder_at (rb_econv_t *ec, const rb_transcoder *tr, int i)
static rb_econv_t * | rb_econv_open_by_transcoder_entries (int n, transcoder_entry_t **entries)
static void | trans_open_i (const char *sname, const char *dname, int depth, void *arg)
static rb_econv_t * | rb_econv_open0 (const char *sname, const char *dname, int ecflags)
static int | decorator_names (int ecflags, const char **decorators_ret)
rb_econv_t * | rb_econv_open (const char *sname, const char *dname, int ecflags)
static int | trans_sweep (rb_econv_t *ec, const unsigned char **input_ptr, const unsigned char *input_stop, unsigned char **output_ptr, unsigned char *output_stop, int flags, int start)
static rb_econv_result_t | rb_trans_conv (rb_econv_t *ec, const unsigned char **input_ptr, const unsigned char *input_stop, unsigned char **output_ptr, unsigned char *output_stop, int flags, int *result_position_ptr)
static rb_econv_result_t | rb_econv_convert0 (rb_econv_t *ec, const unsigned char **input_ptr, const unsigned char *input_stop, unsigned char **output_ptr, unsigned char *output_stop, int flags)
static int | output_replacement_character (rb_econv_t *ec)
static int | output_hex_charref (rb_econv_t *ec)
rb_econv_result_t | rb_econv_convert (rb_econv_t *ec, const unsigned char **input_ptr, const unsigned char *input_stop, unsigned char **output_ptr, unsigned char *output_stop, int flags)
const char * | rb_econv_encoding_to_insert_output (rb_econv_t *ec)
int | rb_econv_insert_output (rb_econv_t *ec, const unsigned char *str, size_t len, const char *str_encoding)
void | rb_econv_close (rb_econv_t *ec)
size_t | rb_econv_memsize (rb_econv_t *ec)
int | rb_econv_putbackable (rb_econv_t *ec)
void | rb_econv_putback (rb_econv_t *ec, unsigned char *p, int n)
static int | asciicompat_encoding_i (st_data_t key, st_data_t val, st_data_t arg)
const char * | rb_econv_asciicompat_encoding (const char *ascii_incompat_name)
VALUE | rb_econv_substr_append (rb_econv_t *ec, VALUE src, long off, long len, VALUE dst, int flags)
VALUE | rb_econv_str_append (rb_econv_t *ec, VALUE src, VALUE dst, int flags)
VALUE | rb_econv_substr_convert (rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags)
VALUE | rb_econv_str_convert (rb_econv_t *ec, VALUE src, int flags)
static int | rb_econv_add_converter (rb_econv_t *ec, const char *sname, const char *dname, int n)
static int | rb_econv_decorate_at (rb_econv_t *ec, const char *decorator_name, int n)
int | rb_econv_decorate_at_first (rb_econv_t *ec, const char *decorator_name)
int | rb_econv_decorate_at_last (rb_econv_t *ec, const char *decorator_name)
void | rb_econv_binmode (rb_econv_t *ec)
static VALUE | econv_description (const char *sname, const char *dname, int ecflags, VALUE mesg)
VALUE | rb_econv_open_exc (const char *sname, const char *dname, int ecflags)
static VALUE | make_econv_exception (rb_econv_t *ec)
static void | more_output_buffer (VALUE destination, unsigned char *(*resize_destination)(VALUE, size_t, size_t), int max_output, unsigned char **out_start_ptr, unsigned char **out_pos, unsigned char **out_stop_ptr)
static int | make_replacement (rb_econv_t *ec)
int | rb_econv_set_replacement (rb_econv_t *ec, const unsigned char *str, size_t len, const char *encname)
static VALUE | proc_fallback (VALUE fallback, VALUE c)
static VALUE | method_fallback (VALUE fallback, VALUE c)
static VALUE | aref_fallback (VALUE fallback, VALUE c)
static void | transcode_loop (const unsigned char **in_pos, unsigned char **out_pos, const unsigned char *in_stop, unsigned char *out_stop, VALUE destination, unsigned char *(*resize_destination)(VALUE, size_t, size_t), const char *src_encoding, const char *dst_encoding, int ecflags, VALUE ecopts)
static unsigned char * | str_transcoding_resize (VALUE destination, size_t len, size_t new_len)
static int | econv_opts (VALUE opt, int ecflags)
int | rb_econv_prepare_options (VALUE opthash, VALUE *opts, int ecflags)
int | rb_econv_prepare_opts (VALUE opthash, VALUE *opts)
rb_econv_t * | rb_econv_open_opts (const char *source_encoding, const char *destination_encoding, int ecflags, VALUE opthash)
static int | enc_arg (volatile VALUE *arg, const char **name_p, rb_encoding **enc_p)
static int | str_transcode_enc_args (VALUE str, volatile VALUE *arg1, volatile VALUE *arg2, const char **sname_p, rb_encoding **senc_p, const char **dname_p, rb_encoding **denc_p)
static int | str_transcode0 (int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
static int | str_transcode (int argc, VALUE *argv, VALUE *self)
static VALUE | str_encode_associate (VALUE str, int encidx)
static VALUE | str_encode_bang (int argc, VALUE *argv, VALUE str)
static VALUE | encoded_dup (VALUE newstr, VALUE str, int encidx)
static VALUE | str_encode (int argc, VALUE *argv, VALUE str)
VALUE | rb_str_encode (VALUE str, VALUE to, int ecflags, VALUE ecopts)
static void | econv_free (void *ptr)
static size_t | econv_memsize (const void *ptr)
static VALUE | econv_s_allocate (VALUE klass)
static rb_encoding * | make_dummy_encoding (const char *name)
static rb_encoding * | make_encoding (const char *name)
static VALUE | make_encobj (const char *name)
static VALUE | econv_s_asciicompat_encoding (VALUE klass, VALUE arg)
static void | econv_args (int argc, VALUE *argv, volatile VALUE *snamev_p, volatile VALUE *dnamev_p, const char **sname_p, const char **dname_p, rb_encoding **senc_p, rb_encoding **denc_p, int *ecflags_p, VALUE *ecopts_p)
static int | decorate_convpath (VALUE convpath, int ecflags)
static void | search_convpath_i (const char *sname, const char *dname, int depth, void *arg)
static VALUE | econv_s_search_convpath (int argc, VALUE *argv, VALUE klass)
int | rb_econv_has_convpath_p (const char *from_encoding, const char *to_encoding)
static void | rb_econv_init_by_convpath_i (const char *sname, const char *dname, int depth, void *arg)
static rb_econv_t * | rb_econv_init_by_convpath (VALUE self, VALUE convpath, const char **sname_p, const char **dname_p, rb_encoding **senc_p, rb_encoding **denc_p)
static VALUE | econv_init (int argc, VALUE *argv, VALUE self)
static VALUE | econv_inspect (VALUE self)
static rb_econv_t * | check_econv (VALUE self)
static VALUE | econv_source_encoding (VALUE self)
static VALUE | econv_destination_encoding (VALUE self)
static VALUE | econv_convpath (VALUE self)
static VALUE | econv_equal (VALUE self, VALUE other)
static VALUE | econv_result_to_symbol (rb_econv_result_t res)
static VALUE | econv_primitive_convert (int argc, VALUE *argv, VALUE self)
static VALUE | econv_convert (VALUE self, VALUE source_string)
static VALUE | econv_finish (VALUE self)
static VALUE | econv_primitive_errinfo (VALUE self)
static VALUE | econv_insert_output (VALUE self, VALUE string)
static VALUE | econv_putback (int argc, VALUE *argv, VALUE self)
static VALUE | econv_last_error (VALUE self)
static VALUE | econv_get_replacement (VALUE self)
static VALUE | econv_set_replacement (VALUE self, VALUE arg)
VALUE | rb_econv_make_exception (rb_econv_t *ec)
void | rb_econv_check_error (rb_econv_t *ec)
static VALUE | ecerr_source_encoding_name (VALUE self)
static VALUE | ecerr_source_encoding (VALUE self)
static VALUE | ecerr_destination_encoding_name (VALUE self)
static VALUE | ecerr_destination_encoding (VALUE self)
static VALUE | ecerr_error_char (VALUE self)
static VALUE | ecerr_error_bytes (VALUE self)
static VALUE | ecerr_readagain_bytes (VALUE self)
static VALUE | ecerr_incomplete_input (VALUE self)
void | Init_transcode (void)

## Variables
VALUE | rb_eUndefinedConversionError
VALUE | rb_eInvalidByteSequenceError
VALUE | rb_eConverterNotFoundError
VALUE | rb_cEncodingConverter
static VALUE | sym_invalid
static VALUE | sym_undef
static VALUE | sym_replace
static VALUE | sym_fallback
static VALUE | sym_aref
static VALUE | sym_xml
static VALUE | sym_text
static VALUE | sym_attr
static VALUE | sym_universal_newline
static VALUE | sym_crlf_newline
static VALUE | sym_cr_newline
static VALUE | sym_newline
static VALUE | sym_universal
static VALUE | sym_crlf
static VALUE | sym_cr
static VALUE | sym_lf
static VALUE | sym_partial_input
static VALUE | sym_invalid_byte_sequence
static VALUE | sym_undefined_conversion
static VALUE | sym_destination_buffer_full
static VALUE | sym_source_buffer_empty
static VALUE | sym_finished
static VALUE | sym_after_output
static VALUE | sym_incomplete_input
static st_table * | transcoder_table
static const char | transcoder_lib_prefix [] = "enc/trans/"
static const rb_data_type_t | econv_data_type

## Macro Definition Documentation

#define BL_ACTION | ( |  | byte) |  | (BL_INFO[BL_OFFSET((byte))])

Referenced by transcode_restartable0().

#define BL_BASE BYTE_ADDR(BYTE_LOOKUP_BASE(WORD_ADDR(next_table)))

#define BL_INFO WORD_ADDR(BYTE_LOOKUP_INFO(WORD_ADDR(next_table)))

#define BL_MAX_BYTE (BL_BASE[1])

Referenced by transcode_restartable0().

#define BL_MIN_BYTE (BL_BASE[0])

Referenced by transcode_restartable0().

#define BL_OFFSET | ( |  | byte) |  | (BL_BASE[2+(byte)-BL_MIN_BYTE])

#define BYTE_ADDR | ( |  | index) |  | (tr->byte_array + (index))

Referenced by transcode_restartable0().

#define DECORATOR_P | ( |  | sname,
|  |  | dname
| ) |  | (*(sname) == '\0')

Definition at line 154 of file transcode.c.

Referenced by asciicompat_encoding_i(), decorate_convpath(), econv_convpath(), econv_init(), make_econv_exception(), rb_econv_add_transcoder_at(), rb_econv_decorate_at_first(), rb_econv_decorate_at_last(), rb_econv_init_by_convpath(), and search_convpath_i().

#define ENABLE_ECONV_NEWLINE_OPTION 1

Definition at line 18 of file transcode.c.

#define encoding_equal | ( |  | enc1,
|  |  | enc2
| ) |  | (STRCASECMP((enc1), (enc2)) == 0)

Definition at line 241 of file transcode.c.

Referenced by get_replacement_character(), output_hex_charref(), rb_econv_insert_output(), rb_econv_set_replacement(), str_transcode0(), and transcode_search_path().

#define hash_fallback rb_hash_aref

Definition at line 2237 of file transcode.c.

Referenced by transcode_loop().

#define MAX_ECFLAGS_DECORATORS 32

Definition at line 1026 of file transcode.c.

Referenced by decorate_convpath(), and rb_econv_open().

#define next_byte (tc->next_byte)

Referenced by transcode_restartable0().

#define next_info (tc->next_info)

Referenced by transcode_restartable0().

#define next_table (tc->next_table)

Referenced by transcode_restartable0().

#define SUSPEND | ( |  | ret,
|  |  | num
| ) |  |

Value:
do { \
tc->resume_position = (num); \
if (0 < in_p - inchar_start) \
MEMMOVE(TRANSCODING_READBUF(tc)+tc->recognized_len, \
inchar_start, unsigned char, in_p - inchar_start); \
*in_pos = in_p; \
*out_pos = out_p; \
tc->recognized_len += in_p - inchar_start; \
if (readagain_len) { \
tc->recognized_len -= readagain_len; \
tc->readagain_len = readagain_len; \
} \
return (ret); \
resume_label ## num:; \
} while (0)

Referenced by transcode_restartable0().

#define SUSPEND_AFTER_OUTPUT | ( |  | num) |  |

Value:
if ((opt & ECONV_AFTER_OUTPUT) && *out_pos != out_p) { \
SUSPEND(econv_after_output, num); \
}

Referenced by transcode_restartable0().

#define SUSPEND_OBUF | ( |  | num) |  |

Value:
do { \
while (out_stop - out_p < 1) { SUSPEND(econv_destination_buffer_full, num); } \
} while (0)

Referenced by transcode_restartable0().

#define TRANSCODING_READBUF | ( |  | tc) |  |

Value:
((tc)->transcoder->max_input <= (int)sizeof((tc)->readbuf.ary) ? \
(tc)->readbuf.ary : \
(tc)->readbuf.ptr)

Definition at line 84 of file transcode.c.

Referenced by rb_econv_convert0(), rb_econv_insert_output(), rb_econv_putback(), transcode_char_start(), and transcode_restartable().

#define TRANSCODING_STATE | ( |  | tc) |  |

Value:
((tc)->transcoder->state_size <= (int)sizeof((tc)->state) ? \
(tc)->state.ary : \
(tc)->state.ptr)

Definition at line 97 of file transcode.c.

Referenced by rb_transcoding_close(), rb_transcoding_open_by_transcoder(), and transcode_restartable0().

#define TRANSCODING_STATE_EMBED_MAX ((int)sizeof(union rb_transcoding_state_t))

Definition at line 96 of file transcode.c.

#define TRANSCODING_WRITEBUF | ( |  | tc) |  |

Value:
((tc)->transcoder->max_output <= (int)sizeof((tc)->writebuf.ary) ? \
(tc)->writebuf.ary : \
(tc)->writebuf.ptr)

Definition at line 88 of file transcode.c.

Referenced by transcode_restartable0().

#define TRANSCODING_WRITEBUF_SIZE | ( |  | tc) |  |

Value:
((tc)->transcoder->max_output <= (int)sizeof((tc)->writebuf.ary) ? \
sizeof((tc)->writebuf.ary) : \
(size_t)(tc)->transcoder->max_output)

Definition at line 92 of file transcode.c.

Referenced by transcode_restartable0().

#define WORD_ADDR | ( |  | index) |  | (tr->word_array + INFO2WORDINDEX(index))

#define writebuf_len (tc->writebuf_len)

Referenced by transcode_restartable0().

#define writebuf_off (tc->writebuf_off)

Referenced by transcode_restartable0().

## Typedef Documentation

typedef struct rb_transcoding rb_transcoding

typedef struct search_path_queue_tag search_path_queue_t

## Function Documentation

static unsigned char * allocate_converted_string | ( | const char * | sname,
|  | const char * | dname,
|  | const unsigned char * | str,
|  | size_t | len,
|  | unsigned char * | caller_dst_buf,
|  | size_t | caller_dst_bufsize,
|  | size_t * | dst_len_ptr
| ) |  |
| static

Definition at line 1519 of file transcode.c.

References dp, econv_destination_buffer_full, econv_finished, fail, NULL, rb_econv_close(), rb_econv_convert(), rb_econv_open(), SIZE_MAX, xfree, xmalloc, and xrealloc.

Referenced by output_hex_charref(), rb_econv_insert_output(), and rb_econv_set_replacement().

static VALUE aref_fallback | ( | VALUE | fallback,
|  | VALUE | c
| ) |  |
| static

Definition at line 2252 of file transcode.c.

References rb_funcall3(), and sym_aref.

Referenced by transcode_loop().

static int asciicompat_encoding_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | st_data_t | arg
| ) |  |
| static

Definition at line 1769 of file transcode.c.

References asciicompat_encoding_t::ascii_compat_name, asciicompat_decoder, rb_transcoder::asciicompat_type, DECORATOR_P, transcoder_entry_t::dname, rb_transcoder::dst_encoding, load_transcoder_entry(), transcoder_entry_t::sname, ST_CONTINUE, and ST_STOP.

Referenced by rb_econv_asciicompat_encoding().

static rb_econv_t* check_econv | ( | VALUE | self) |  |
| static

Definition at line 3428 of file transcode.c.

References rb_econv_init_by_convpath_t::ec, rb_eTypeError, rb_raise(), and TypedData_Get_Struct.

Referenced by econv_convert(), econv_convpath(), econv_destination_encoding(), econv_equal(), econv_finish(), econv_get_replacement(), econv_insert_output(), econv_last_error(), econv_primitive_convert(), econv_primitive_errinfo(), econv_putback(), econv_set_replacement(), and econv_source_encoding().

static void declare_transcoder | ( | const char * | sname,
|  | const char * | dname,
|  | const char * | lib
| ) |  |
| static

Definition at line 222 of file transcode.c.

References transcoder_entry_t::lib, and make_transcoder_entry().

Referenced by rb_declare_transcoder().

static int decorate_convpath | ( | VALUE | convpath,
|  | int | ecflags
| ) |  |
| static

Definition at line 3038 of file transcode.c.

References asciicompat_encoder, rb_transcoder::asciicompat_type, decorator_names(), DECORATOR_P, rb_transcoder::dst_encoding, get_transcoder_entry(), i, load_transcoder_entry(), MAX_ECFLAGS_DECORATORS, RARRAY_LENINT, RARRAY_PTR, rb_ary_store(), rb_enc_name, rb_str_new_cstr(), rb_to_encoding(), RB_TYPE_P, rb_transcoder::src_encoding, and T_ARRAY.

Referenced by econv_s_search_convpath().

static int decorator_names | ( | int | ecflags,
|  | const char ** | decorators_ret
| ) |  |
| static

Definition at line 1029 of file transcode.c.

References ECONV_CR_NEWLINE_DECORATOR, ECONV_CRLF_NEWLINE_DECORATOR, ECONV_NEWLINE_DECORATOR_MASK, ECONV_UNIVERSAL_NEWLINE_DECORATOR, ECONV_XML_ATTR_CONTENT_DECORATOR, ECONV_XML_ATTR_QUOTE_DECORATOR, and ECONV_XML_TEXT_DECORATOR.

Referenced by decorate_convpath(), and rb_econv_open().

static VALUE ecerr_destination_encoding | ( | VALUE | self) |  |
| static

Definition at line 4261 of file transcode.c.

References rb_attr_get(), and rb_intern.

Referenced by Init_transcode().

static VALUE ecerr_destination_encoding_name | ( | VALUE | self) |  |
| static

Definition at line 4249 of file transcode.c.

References rb_attr_get(), and rb_intern.

Referenced by Init_transcode().

static VALUE ecerr_error_bytes | ( | VALUE | self) |  |
| static

Definition at line 4303 of file transcode.c.

References rb_attr_get(), and rb_intern.

Referenced by Init_transcode().

static VALUE ecerr_error_char | ( | VALUE | self) |  |
| static

Definition at line 4282 of file transcode.c.

References rb_attr_get(), and rb_intern.

Referenced by Init_transcode().

static VALUE ecerr_incomplete_input | ( | VALUE | self) |  |
| static

Definition at line 4345 of file transcode.c.

References rb_attr_get(), and rb_intern.

Referenced by Init_transcode().

static VALUE ecerr_readagain_bytes | ( | VALUE | self) |  |
| static

Definition at line 4315 of file transcode.c.

References rb_attr_get(), and rb_intern.

Referenced by Init_transcode().

static VALUE ecerr_source_encoding | ( | VALUE | self) |  |
| static

Definition at line 4237 of file transcode.c.

References rb_attr_get(), and rb_intern.

Referenced by Init_transcode().

static VALUE ecerr_source_encoding_name | ( | VALUE | self) |  |
| static

Definition at line 4211 of file transcode.c.

References rb_attr_get(), and rb_intern.

Referenced by Init_transcode().

static void econv_args | ( | int | argc,
|  | VALUE * | argv,
|  | volatile VALUE * | snamev_p,
|  | volatile VALUE * | dnamev_p,
|  | const char ** | sname_p,
|  | const char ** | dname_p,
|  | rb_encoding ** | senc_p,
|  | rb_encoding ** | denc_p,
|  | int * | ecflags_p,
|  | VALUE * | ecopts_p
| ) |  |
| static

Definition at line 2978 of file transcode.c.

References NIL_P, NULL, NUM2INT, Qnil, rb_econv_prepare_opts(), rb_enc_from_index(), rb_enc_name, rb_error_arity(), rb_scan_args(), rb_to_encoding_index(), rb_to_int(), StringValue, and StringValueCStr.

Referenced by econv_init(), and econv_s_search_convpath().

static VALUE econv_convert | ( | VALUE | self,
|  | VALUE | source_string
| ) |  |
| static

Definition at line 3804 of file transcode.c.

References check_econv(), ECONV_PARTIAL_INPUT, econv_primitive_convert(), INT2NUM, make_econv_exception(), NULL, Qnil, rb_bug(), rb_eArgError, rb_exc_raise(), rb_raise(), rb_str_dup(), rb_str_new(), rb_econv_init_by_convpath_t::ret, StringValue, sym_finished, sym_incomplete_input, sym_invalid_byte_sequence, sym_source_buffer_empty, and sym_undefined_conversion.

Referenced by Init_transcode().

static VALUE econv_convpath | ( | VALUE | self) |  |
| static

Definition at line 3492 of file transcode.c.

References check_econv(), DECORATOR_P, rb_transcoder::dst_encoding, rb_econv_t::elems, i, make_encobj(), rb_econv_t::num_trans, rb_ary_new(), rb_ary_push(), rb_assoc_new(), rb_str_new_cstr(), result, rb_transcoder::src_encoding, rb_econv_elem_t::tc, rb_transcoding::transcoder, and v.

Referenced by Init_transcode().

static VALUE econv_description | ( | const char * | sname,
|  | const char * | dname,
|  | int | ecflags,
|  | VALUE | mesg
| ) |  |
| static

Definition at line 1970 of file transcode.c.

References ECONV_CR_NEWLINE_DECORATOR, ECONV_CRLF_NEWLINE_DECORATOR, ECONV_NEWLINE_DECORATOR_MASK, ECONV_UNIVERSAL_NEWLINE_DECORATOR, ECONV_XML_ATTR_CONTENT_DECORATOR, ECONV_XML_ATTR_QUOTE_DECORATOR, ECONV_XML_TEXT_DECORATOR, NIL_P, NULL, rb_str_cat2(), rb_str_catf(), and rb_str_new().

Referenced by econv_inspect(), and rb_econv_open_exc().

static VALUE econv_destination_encoding | ( | VALUE | self) |  |
| static

Definition at line 3461 of file transcode.c.

References check_econv(), rb_econv_t::destination_encoding, Qnil, and rb_enc_from_encoding().

Referenced by Init_transcode().

static VALUE econv_equal | ( | VALUE | self,
|  | VALUE | other
| ) |  |
| static

Definition at line 3516 of file transcode.c.

References check_econv(), DATA_PTR, rb_econv_t::destination_encoding_name, rb_econv_t::elems, rb_econv_t::flags, i, memcmp(), rb_econv_t::num_trans, Qfalse, Qnil, Qtrue, rb_typeddata_is_kind_of(), rb_econv_t::replacement_enc, rb_econv_t::replacement_len, rb_econv_t::replacement_str, rb_econv_t::source_encoding_name, rb_econv_elem_t::tc, and rb_transcoding::transcoder.

Referenced by Init_transcode().

static VALUE econv_finish | ( | VALUE | self) |  |
| static

Definition at line 3854 of file transcode.c.

References check_econv(), econv_primitive_convert(), INT2NUM, make_econv_exception(), NULL, Qnil, rb_bug(), rb_exc_raise(), rb_str_new(), rb_econv_init_by_convpath_t::ret, sym_finished, sym_incomplete_input, sym_invalid_byte_sequence, and sym_undefined_conversion.

Referenced by Init_transcode().

static void econv_free | ( | void * | ptr) |  |
| static

Definition at line 2892 of file transcode.c.

References rb_econv_close().

static VALUE econv_get_replacement | ( | VALUE | self) |  |
| static

Definition at line 4138 of file transcode.c.

References check_econv(), make_replacement(), rb_enc_find(), rb_enc_str_new(), rb_eUndefinedConversionError, rb_raise(), rb_econv_t::replacement_enc, rb_econv_t::replacement_len, rb_econv_t::replacement_str, and rb_econv_init_by_convpath_t::ret.

Referenced by Init_transcode().

static VALUE econv_init | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 3354 of file transcode.c.

References DATA_PTR, DECORATOR_P, rb_econv_t::destination_encoding, rb_econv_init_by_convpath_t::ec, econv_args(), make_dummy_encoding(), NIL_P, Qnil, rb_check_array_type(), rb_check_typeddata(), rb_econv_init_by_convpath(), rb_econv_open_exc(), rb_econv_open_opts(), rb_eTypeError, rb_exc_raise(), rb_raise(), and rb_econv_t::source_encoding.

Referenced by Init_transcode().

static VALUE econv_insert_output | ( | VALUE | self,
|  | VALUE | string
| ) |  |
| static

Definition at line 4020 of file transcode.c.

References check_econv(), Qnil, rb_eArgError, rb_econv_encoding_to_insert_output(), rb_econv_insert_output(), rb_enc_find(), rb_enc_from_encoding(), rb_raise(), rb_str_encode(), rb_econv_init_by_convpath_t::ret, RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by Init_transcode().

static VALUE econv_inspect | ( | VALUE | self) |  |
| static

Definition at line 3408 of file transcode.c.

References rb_econv_t::destination_encoding_name, rb_econv_init_by_convpath_t::ec, econv_description(), rb_econv_t::flags, rb_obj_classname(), rb_sprintf(), rb_str_cat2(), rb_econv_t::source_encoding_name, and TypedData_Get_Struct.

Referenced by Init_transcode().

static VALUE econv_last_error | ( | VALUE | self) |  |
| static

Definition at line 4114 of file transcode.c.

References check_econv(), make_econv_exception(), NIL_P, and Qnil.

Referenced by Init_transcode().

static size_t econv_memsize | ( | const void * | ptr) |  |
| static

Definition at line 2899 of file transcode.c.

static int econv_opts | ( | VALUE | opt,
|  | int | ecflags
| ) |  |
| static

Definition at line 2420 of file transcode.c.

References ECONV_CR_NEWLINE_DECORATOR, ECONV_CRLF_NEWLINE_DECORATOR, ECONV_INVALID_REPLACE, ECONV_NEWLINE_DECORATOR_MASK, ECONV_UNDEF_HEX_CHARREF, ECONV_UNDEF_REPLACE, ECONV_UNIVERSAL_NEWLINE_DECORATOR, ECONV_XML_ATTR_CONTENT_DECORATOR, ECONV_XML_ATTR_QUOTE_DECORATOR, ECONV_XML_TEXT_DECORATOR, NIL_P, rb_eArgError, rb_hash_aref(), rb_id2name(), rb_raise(), RB_TYPE_P, RTEST, SYM2ID, sym_attr, sym_cr, sym_cr_newline, sym_crlf, sym_crlf_newline, sym_invalid, sym_lf, sym_newline, sym_replace, sym_text, sym_undef, sym_universal, sym_universal_newline, sym_xml, SYMBOL_P, T_SYMBOL, and v.

Referenced by rb_econv_prepare_options().

static VALUE econv_primitive_convert | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 3660 of file transcode.c.

References check_econv(), rb_econv_t::destination_encoding, ECONV_AFTER_OUTPUT, econv_destination_buffer_full, ECONV_PARTIAL_INPUT, econv_result_to_symbol(), input, LONG_MAX, NIL_P, NULL, NUM2INT, NUM2LONG, output, Qnil, rb_eArgError, rb_econv_convert(), rb_enc_associate(), rb_error_arity(), rb_hash_aref(), rb_raise(), rb_scan_args(), rb_str_capacity(), rb_str_drop_bytes(), rb_str_modify(), rb_str_resize(), rb_str_set_len(), rb_to_int(), RSTRING_EMBED_LEN_MAX, RSTRING_LEN, RSTRING_PTR, RTEST, StringValue, sym_after_output, sym_partial_input, and v.

Referenced by econv_convert(), econv_finish(), and Init_transcode().

static VALUE econv_primitive_errinfo | ( | VALUE | self) |  |
| static

Definition at line 3962 of file transcode.c.

References check_econv(), rb_econv_t::destination_encoding, econv_result_to_symbol(), rb_econv_t::error_bytes_len, rb_econv_t::error_bytes_start, rb_econv_t::last_error, Qnil, rb_ary_new2(), rb_ary_store(), rb_str_new(), rb_str_new2, rb_econv_t::readagain_len, rb_econv_t::result, and rb_econv_t::source_encoding.

Referenced by Init_transcode().

static VALUE econv_putback | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | self
| ) |  |
| static

Definition at line 4065 of file transcode.c.

References check_econv(), max(), NIL_P, NULL, NUM2INT, rb_econv_putback(), rb_econv_putbackable(), rb_enc_associate(), rb_scan_args(), rb_str_new(), RSTRING_PTR, and rb_econv_t::source_encoding.

Referenced by Init_transcode().

static VALUE econv_result_to_symbol | ( | rb_econv_result_t | res) |  |
| static

Definition at line 3551 of file transcode.c.

References econv_after_output, econv_destination_buffer_full, econv_finished, econv_incomplete_input, econv_invalid_byte_sequence, econv_source_buffer_empty, econv_undefined_conversion, INT2NUM, sym_after_output, sym_destination_buffer_full, sym_finished, sym_incomplete_input, sym_invalid_byte_sequence, sym_source_buffer_empty, and sym_undefined_conversion.

Referenced by econv_primitive_convert(), and econv_primitive_errinfo().

static VALUE econv_s_allocate | ( | VALUE | klass) |  |
| static

Definition at line 2910 of file transcode.c.

References NULL, and TypedData_Wrap_Struct.

Referenced by Init_transcode().

static VALUE econv_s_asciicompat_encoding | ( | VALUE | klass,
|  | VALUE | arg
| ) |  |
| static

Definition at line 2960 of file transcode.c.

References enc_arg(), make_encoding(), NULL, Qnil, rb_econv_asciicompat_encoding(), and rb_enc_from_encoding().

Referenced by Init_transcode().

static VALUE econv_s_search_convpath | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  |
| static

Definition at line 3121 of file transcode.c.

References decorate_convpath(), econv_args(), NIL_P, Qnil, rb_econv_open_exc(), rb_exc_raise(), search_convpath_i(), and transcode_search_path().

Referenced by Init_transcode().

static VALUE econv_set_replacement | ( | VALUE | self,
|  | VALUE | arg
| ) |  |
| static

Definition at line 4164 of file transcode.c.

References arg, check_econv(), rb_econv_set_replacement(), rb_enc_get(), rb_enc_name, rb_eUndefinedConversionError, rb_raise(), rb_econv_init_by_convpath_t::ret, RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by Init_transcode().

static VALUE econv_source_encoding | ( | VALUE | self) |  |
| static

Definition at line 3446 of file transcode.c.

References check_econv(), Qnil, rb_enc_from_encoding(), and rb_econv_t::source_encoding.

Referenced by Init_transcode().

static int enc_arg | ( | volatile VALUE * | arg,
|  | const char ** | name_p,
|  | rb_encoding ** | enc_p
| ) |  |
| static

Definition at line 2605 of file transcode.c.

References NULL, rb_enc_from_index(), rb_enc_name, rb_to_encoding_index(), and StringValueCStr.

Referenced by econv_s_asciicompat_encoding(), encoding_table_get_name_core(), rb_econv_init_by_convpath(), and str_transcode_enc_args().

static VALUE encoded_dup | ( | VALUE | newstr,
|  | VALUE | str,
|  | int | encidx
| ) |  |
| static

Definition at line 2877 of file transcode.c.

References rb_enc_associate_index(), rb_obj_class(), rb_str_dup(), RBASIC, and str_encode_associate().

Referenced by rb_str_encode(), and str_encode().

static const char* get_replacement_character | ( | const char * | encname,
|  | size_t * | len_ret,
|  | const char ** | repl_encname_ptr
| ) |  |
| static

Definition at line 393 of file transcode.c.

References encoding_equal.

Referenced by make_replacement().

static transcoder_entry_t* get_transcoder_entry | ( | const char * | sname,
|  | const char * | dname
| ) |  |
| static

Definition at line 189 of file transcode.c.

References NULL, st_lookup(), and val.

Referenced by decorate_convpath(), rb_econv_add_converter(), rb_econv_binmode(), and trans_open_i().

void Init_transcode | ( | void | ) |  |

Definition at line 4373 of file transcode.c.

References ecerr_destination_encoding(), ecerr_destination_encoding_name(), ecerr_error_bytes(), ecerr_error_char(), ecerr_incomplete_input(), ecerr_readagain_bytes(), ecerr_source_encoding(), ecerr_source_encoding_name(), ECONV_AFTER_OUTPUT, econv_convert(), econv_convpath(), ECONV_CR_NEWLINE_DECORATOR, ECONV_CRLF_NEWLINE_DECORATOR, econv_destination_encoding(), econv_equal(), econv_finish(), econv_get_replacement(), econv_init(), econv_insert_output(), econv_inspect(), ECONV_INVALID_MASK, ECONV_INVALID_REPLACE, econv_last_error(), ECONV_PARTIAL_INPUT, econv_primitive_convert(), econv_primitive_errinfo(), econv_putback(), econv_s_allocate(), econv_s_asciicompat_encoding(), econv_s_search_convpath(), econv_set_replacement(), econv_source_encoding(), ECONV_UNDEF_HEX_CHARREF, ECONV_UNDEF_MASK, ECONV_UNDEF_REPLACE, ECONV_UNIVERSAL_NEWLINE_DECORATOR, ECONV_XML_ATTR_CONTENT_DECORATOR, ECONV_XML_ATTR_QUOTE_DECORATOR, ECONV_XML_TEXT_DECORATOR, ID2SYM, Init_newline(), INT2FIX, rb_cData, rb_cEncoding, rb_cEncodingConverter, rb_cString, rb_define_alloc_func(), rb_define_class_under(), rb_define_const(), rb_define_method(), rb_define_singleton_method(), rb_eConverterNotFoundError, rb_eEncodingError, rb_eInvalidByteSequenceError, rb_eUndefinedConversionError, rb_intern, st_init_strcasetable(), str_encode(), str_encode_bang(), sym_after_output, sym_aref, sym_attr, sym_cr, sym_cr_newline, sym_crlf, sym_crlf_newline, sym_destination_buffer_full, sym_fallback, sym_finished, sym_incomplete_input, sym_invalid, sym_invalid_byte_sequence, sym_lf, sym_newline, sym_partial_input, sym_replace, sym_source_buffer_empty, sym_text, sym_undef, sym_undefined_conversion, sym_universal, sym_universal_newline, and sym_xml.

static const rb_transcoder* load_transcoder_entry | ( | transcoder_entry_t * | entry) |  |
| static

Definition at line 362 of file transcode.c.

References FL_TAINT, FL_UNSET, FL_UNTRUSTED, transcoder_entry_t::lib, NULL, OBJ_FREEZE, rb_require_safe(), rb_safe_level, rb_str_new(), rb_str_set_len(), RSTRING_PTR, strlen(), transcoder_entry_t::transcoder, and transcoder_lib_prefix.

Referenced by asciicompat_encoding_i(), decorate_convpath(), rb_econv_add_converter(), and rb_econv_open_by_transcoder_entries().

static rb_encoding* make_dummy_encoding | ( | const char * | name) |  |
| static

Definition at line 2916 of file transcode.c.

References rb_define_dummy_encoding(), and rb_enc_from_index().

Referenced by econv_init(), and make_encoding().

static VALUE make_econv_exception | ( | rb_econv_t * | ec) |  |
| static

Definition at line 2039 of file transcode.c.

References DECORATOR_P, rb_econv_t::destination_encoding, rb_econv_t::destination_encoding_name, rb_transcoder::dst_encoding, econv_incomplete_input, econv_invalid_byte_sequence, econv_undefined_conversion, rb_econv_t::elems, err, rb_econv_t::error_bytes_len, rb_econv_t::error_bytes_start, i, rb_econv_t::last_error, MBCLEN_CHARFOUND_LEN, MBCLEN_CHARFOUND_P, rb_econv_t::num_trans, Qfalse, Qnil, Qtrue, rb_eInvalidByteSequenceError, rb_enc_associate_index(), rb_enc_find_index(), rb_enc_from_encoding(), rb_enc_from_index(), rb_enc_mbc_to_codepoint, rb_enc_precise_mbclen(), rb_eUndefinedConversionError, rb_exc_new3(), rb_intern, rb_ivar_set(), rb_sprintf(), rb_str_catf(), rb_str_dump(), rb_str_new(), rb_str_new2, rb_utf8_encoding(), rb_econv_t::readagain_len, rb_econv_t::result, rb_econv_t::source_encoding, rb_econv_t::source_encoding_name, rb_transcoder::src_encoding, StringValueCStr, rb_econv_elem_t::tc, and rb_transcoding::transcoder.

Referenced by econv_convert(), econv_finish(), econv_last_error(), rb_econv_check_error(), rb_econv_make_exception(), and transcode_loop().

static VALUE make_encobj | ( | const char * | name) |  |
| static

Definition at line 2936 of file transcode.c.

References make_encoding(), and rb_enc_from_encoding().

Referenced by econv_convpath(), and search_convpath_i().

static rb_encoding* make_encoding | ( | const char * | name) |  |
| static

Definition at line 2926 of file transcode.c.

References make_dummy_encoding(), and rb_enc_find().

Referenced by econv_s_asciicompat_encoding(), and make_encobj().

static int make_replacement | ( | rb_econv_t * | ec) |  |
| static

Definition at line 2156 of file transcode.c.

References rb_transcoder::dst_encoding, get_replacement_character(), rb_econv_t::last_tc, rb_econv_encoding_to_insert_output(), rb_enc_find(), rb_econv_t::replacement_allocated, rb_econv_t::replacement_enc, rb_econv_t::replacement_len, rb_econv_t::replacement_str, and rb_transcoding::transcoder.

Referenced by econv_get_replacement(), and output_replacement_character().

static transcoder_entry_t* make_transcoder_entry | ( | const char * | sname,
|  | const char * | dname
| ) |  |
| static

Definition at line 166 of file transcode.c.

References ALLOC, transcoder_entry_t::dname, transcoder_entry_t::lib, NULL, transcoder_entry_t::sname, st_add_direct(), st_init_strcasetable(), st_lookup(), transcoder_entry_t::transcoder, and val.

Referenced by declare_transcoder(), and rb_register_transcoder().

static VALUE method_fallback | ( | VALUE | fallback,
|  | VALUE | c
| ) |  |
| static

Definition at line 2246 of file transcode.c.

References rb_method_call().

Referenced by transcode_loop().

static void more_output_buffer | ( | VALUE | destination,
|  | unsigned char *(*)(VALUE, size_t, size_t) | resize_destination,
|  | int | max_output,
|  | unsigned char ** | out_start_ptr,
|  | unsigned char ** | out_pos,
|  | unsigned char ** | out_stop_ptr
| ) |  |
| static

Definition at line 2140 of file transcode.c.

Referenced by transcode_loop().

static int output_hex_charref | ( | rb_econv_t * | ec) |  |
| static

Definition at line 1390 of file transcode.c.

References allocate_converted_string(), encoding_equal, rb_econv_t::error_bytes_len, rb_econv_t::error_bytes_start, fail, rb_econv_t::last_error, p, rb_econv_insert_output(), snprintf, rb_econv_t::source_encoding, strlen(), and xfree.

Referenced by rb_econv_convert().

static int output_replacement_character | ( | rb_econv_t * | ec) |  |
| static

Definition at line 2222 of file transcode.c.

References make_replacement(), rb_econv_insert_output(), rb_econv_t::replacement_enc, rb_econv_t::replacement_len, and rb_econv_t::replacement_str.

Referenced by rb_econv_convert().

static VALUE proc_fallback | ( | VALUE | fallback,
|  | VALUE | c
| ) |  |
| static

Definition at line 2240 of file transcode.c.

References rb_ary_new4(), and rb_proc_call().

Referenced by transcode_loop().

void rb_declare_transcoder | ( | const char * | enc1,
|  | const char * | enc2,
|  | const char * | lib
| ) |  |

Definition at line 233 of file transcode.c.

References declare_transcoder(), rb_eArgError, and rb_raise().

static int rb_econv_add_converter | ( | rb_econv_t * | ec,
|  | const char * | sname,
|  | const char * | dname,
|  | int | n
| ) |  |
| static

Definition at line 1875 of file transcode.c.

References get_transcoder_entry(), load_transcoder_entry(), rb_econv_add_transcoder_at(), and rb_econv_t::started.

Referenced by rb_econv_decorate_at(), rb_econv_init_by_convpath(), and rb_econv_init_by_convpath_i().

static int rb_econv_add_transcoder_at | ( | rb_econv_t * | ec,
|  | const rb_transcoder * | tr,
|  | int | i
| ) |  |
| static

Definition at line 894 of file transcode.c.

References DECORATOR_P, rb_transcoder::dst_encoding, econv_source_buffer_empty, rb_econv_t::elems, i, rb_econv_elem_t::last_result, rb_econv_t::last_tc, MEMMOVE, rb_econv_t::num_allocated, rb_econv_t::num_trans, rb_econv_elem_t::out_buf_end, rb_econv_elem_t::out_buf_start, rb_econv_elem_t::out_data_end, rb_econv_elem_t::out_data_start, p, rb_transcoding_open_by_transcoder(), REALLOC_N, rb_transcoder::src_encoding, rb_econv_elem_t::tc, rb_transcoding::transcoder, and xmalloc.

Referenced by rb_econv_add_converter(), and rb_econv_open_by_transcoder_entries().

static rb_econv_t* rb_econv_alloc | ( | int | n_hint) |  |
| static

Definition at line 856 of file transcode.c.

References ALLOC, ALLOC_N, rb_econv_t::destination_encoding, rb_econv_t::destination_encoding_name, econv_source_buffer_empty, rb_econv_t::elems, rb_econv_t::error_bytes_len, rb_econv_t::error_bytes_start, rb_econv_t::error_tc, rb_econv_t::flags, rb_econv_t::in_buf_end, rb_econv_t::in_buf_start, rb_econv_t::in_data_end, rb_econv_t::in_data_start, rb_econv_t::last_error, rb_econv_t::last_tc, NULL, rb_econv_t::num_allocated, rb_econv_t::num_finished, rb_econv_t::num_trans, rb_econv_t::readagain_len, rb_econv_t::replacement_allocated, rb_econv_t::replacement_enc, rb_econv_t::replacement_len, rb_econv_t::replacement_str, rb_econv_t::result, rb_econv_t::source_encoding, rb_econv_t::source_encoding_name, and rb_econv_t::started.

Referenced by rb_econv_init_by_convpath(), and rb_econv_open_by_transcoder_entries().

const char* rb_econv_asciicompat_encoding | ( | const char * | ascii_incompat_name) |  |

Definition at line 1786 of file transcode.c.

References asciicompat_encoding_t::ascii_compat_name, asciicompat_encoding_t::ascii_incompat_name, asciicompat_encoding_i(), NULL, st_table::num_entries, st_foreach(), st_lookup(), and v.

Referenced by econv_s_asciicompat_encoding(), and make_writeconv().

void rb_econv_binmode | ( | rb_econv_t * | ec) |  |

Definition at line 1934 of file transcode.c.

References ECONV_CR_NEWLINE_DECORATOR, ECONV_CRLF_NEWLINE_DECORATOR, ECONV_NEWLINE_DECORATOR_MASK, ECONV_UNIVERSAL_NEWLINE_DECORATOR, rb_econv_t::elems, rb_econv_t::flags, get_transcoder_entry(), i, rb_econv_t::num_trans, rb_econv_elem_t::out_buf_start, rb_transcoding_close(), rb_econv_elem_t::tc, rb_transcoding::transcoder, transcoder_entry_t::transcoder, and xfree.

Referenced by rb_io_binmode().

void rb_econv_check_error | ( | rb_econv_t * | ec) |  |

Definition at line 4194 of file transcode.c.

References make_econv_exception(), NIL_P, and rb_exc_raise().

Referenced by fill_cbuf(), gzfile_getc(), and rb_econv_substr_append().

void rb_econv_close | ( | rb_econv_t * | ec) |  |

Definition at line 1702 of file transcode.c.

References rb_econv_t::elems, i, rb_econv_t::in_buf_start, rb_econv_t::num_trans, rb_econv_elem_t::out_buf_start, rb_transcoding_close(), rb_econv_t::replacement_allocated, rb_econv_t::replacement_str, rb_econv_elem_t::tc, and xfree.

Referenced by allocate_converted_string(), clear_readconv(), clear_writeconv(), econv_free(), gzfile_reset(), rb_econv_open(), rb_econv_open_by_transcoder_entries(), rb_econv_open_opts(), rb_io_ascii8bit_binmode(), RUBY_ALIAS_FUNCTION(), and transcode_loop().

rb_econv_result_t rb_econv_convert | ( | rb_econv_t * | ec,
|  | const unsigned char ** | input_ptr,
|  | const unsigned char * | input_stop,
|  | unsigned char ** | output_ptr,
|  | unsigned char * | output_stop,
|  | int | flags
| ) |  |

Definition at line 1446 of file transcode.c.

References econv_incomplete_input, econv_invalid_byte_sequence, ECONV_INVALID_MASK, ECONV_INVALID_REPLACE, ECONV_UNDEF_HEX_CHARREF, ECONV_UNDEF_MASK, ECONV_UNDEF_REPLACE, econv_undefined_conversion, rb_econv_t::flags, output_hex_charref(), output_replacement_character(), rb_econv_convert0(), and rb_econv_t::started.

Referenced by allocate_converted_string(), econv_primitive_convert(), fill_cbuf(), finish_writeconv(), gzfile_getc(), rb_econv_substr_append(), RUBY_ALIAS_FUNCTION(), and transcode_loop().

static rb_econv_result_t rb_econv_convert0 | ( | rb_econv_t * | ec,
|  | const unsigned char ** | input_ptr,
|  | const unsigned char * | input_stop,
|  | unsigned char ** | output_ptr,
|  | unsigned char * | output_stop,
|  | int | flags
| ) |  |
| static

Definition at line 1266 of file transcode.c.

References rb_econv_t::destination_encoding, rb_transcoder::dst_encoding, econv_after_output, ECONV_AFTER_OUTPUT, econv_destination_buffer_full, econv_finished, econv_incomplete_input, econv_invalid_byte_sequence, ECONV_PARTIAL_INPUT, econv_source_buffer_empty, econv_undefined_conversion, rb_econv_t::elems, rb_econv_t::error_bytes_len, rb_econv_t::error_bytes_start, rb_econv_t::error_tc, rb_econv_t::in_buf_start, rb_econv_t::in_data_end, rb_econv_t::in_data_start, rb_econv_t::last_error, rb_econv_t::num_trans, rb_econv_elem_t::out_buf_start, rb_econv_elem_t::out_data_end, rb_econv_elem_t::out_data_start, rb_trans_conv(), rb_transcoding::readagain_len, rb_econv_t::readagain_len, rb_transcoding::recognized_len, rb_econv_t::result, rb_econv_t::source_encoding, rb_transcoder::src_encoding, rb_econv_elem_t::tc, rb_transcoding::transcoder, and TRANSCODING_READBUF.

Referenced by rb_econv_convert().

static int rb_econv_decorate_at | ( | rb_econv_t * | ec,
|  | const char * | decorator_name,
|  | int | n
| ) |  |
| static

Definition at line 1894 of file transcode.c.

References rb_econv_add_converter().

Referenced by rb_econv_decorate_at_first(), and rb_econv_decorate_at_last().

int rb_econv_decorate_at_first | ( | rb_econv_t * | ec,
|  | const char * | decorator_name
| ) |  |

Definition at line 1900 of file transcode.c.

References asciicompat_decoder, rb_transcoder::asciicompat_type, DECORATOR_P, rb_transcoder::dst_encoding, rb_econv_t::elems, rb_econv_t::num_trans, rb_econv_decorate_at(), rb_transcoder::src_encoding, rb_econv_elem_t::tc, and rb_transcoding::transcoder.

int rb_econv_decorate_at_last | ( | rb_econv_t * | ec,
|  | const char * | decorator_name
| ) |  |

Definition at line 1917 of file transcode.c.

References asciicompat_encoder, rb_transcoder::asciicompat_type, DECORATOR_P, rb_transcoder::dst_encoding, rb_econv_t::elems, rb_econv_t::num_trans, rb_econv_decorate_at(), rb_transcoder::src_encoding, rb_econv_elem_t::tc, and rb_transcoding::transcoder.

Referenced by rb_econv_open().

const char* rb_econv_encoding_to_insert_output | ( | rb_econv_t * | ec) |  |

Definition at line 1503 of file transcode.c.

References asciicompat_encoder, rb_transcoder::asciicompat_type, rb_transcoder::dst_encoding, rb_econv_t::last_tc, NULL, rb_transcoder::src_encoding, and rb_transcoding::transcoder.

Referenced by econv_insert_output(), make_replacement(), rb_econv_insert_output(), and rb_econv_set_replacement().

int rb_econv_has_convpath_p | ( | const char * | from_encoding,
|  | const char * | to_encoding
| ) |  |

Definition at line 3150 of file transcode.c.

References Qnil, RTEST, search_convpath_i(), and transcode_search_path().

Referenced by rb_w32_write_console().

static rb_econv_t* rb_econv_init_by_convpath | ( | VALUE | self,
|  | VALUE | convpath,
|  | const char ** | sname_p,
|  | const char ** | dname_p,
|  | rb_encoding ** | senc_p,
|  | rb_encoding ** | denc_p
| ) |  |
| static

Definition at line 3180 of file transcode.c.

References DATA_PTR, DECORATOR_P, rb_econv_t::destination_encoding_name, rb_transcoder::dst_encoding, rb_econv_init_by_convpath_t::ec, rb_econv_t::elems, enc_arg(), i, rb_econv_init_by_convpath_t::index, NIL_P, NULL, rb_econv_t::num_trans, RARRAY_LEN, RARRAY_LENINT, rb_ary_entry(), rb_check_array_type(), rb_eArgError, rb_econv_add_converter(), rb_econv_alloc(), rb_econv_init_by_convpath_i(), rb_raise(), rb_econv_init_by_convpath_t::ret, rb_econv_t::source_encoding_name, rb_transcoder::src_encoding, StringValueCStr, rb_econv_elem_t::tc, transcode_search_path(), and rb_transcoding::transcoder.

Referenced by econv_init().

static void rb_econv_init_by_convpath_i | ( | const char * | sname,
|  | const char * | dname,
|  | int | depth,
|  | void * | arg
| ) |  |
| static

Definition at line 3165 of file transcode.c.

References rb_econv_init_by_convpath_t::ec, rb_econv_init_by_convpath_t::index, rb_econv_add_converter(), and rb_econv_init_by_convpath_t::ret.

Referenced by rb_econv_init_by_convpath().

int rb_econv_insert_output | ( | rb_econv_t * | ec,
|  | const unsigned char * | str,
|  | size_t | len,
|  | const char * | str_encoding
| ) |  |

Definition at line 1587 of file transcode.c.

References allocate_converted_string(), asciicompat_encoder, rb_transcoder::asciicompat_type, buf, rb_econv_t::elems, encoding_equal, fail, rb_econv_t::in_buf_end, rb_econv_t::in_buf_start, rb_econv_t::in_data_end, rb_econv_t::in_data_start, MEMMOVE, NULL, rb_econv_t::num_trans, rb_econv_elem_t::out_buf_end, rb_econv_elem_t::out_buf_start, rb_econv_elem_t::out_data_end, rb_econv_elem_t::out_data_start, rb_econv_encoding_to_insert_output(), rb_transcoding::readagain_len, rb_transcoding::recognized_len, rb_econv_t::started, rb_econv_elem_t::tc, rb_transcoding::transcoder, TRANSCODING_READBUF, xfree, xmalloc, and xrealloc.

Referenced by econv_insert_output(), output_hex_charref(), output_replacement_character(), and transcode_loop().

VALUE rb_econv_make_exception | ( | rb_econv_t * | ec) |  |

Definition at line 4188 of file transcode.c.

References make_econv_exception().

Referenced by fill_cbuf(), and finish_writeconv().

size_t rb_econv_memsize | ( | rb_econv_t * | ec) |  |

Definition at line 1720 of file transcode.c.

References rb_econv_t::elems, i, rb_econv_t::in_buf_end, rb_econv_t::in_buf_start, rb_econv_t::num_allocated, rb_econv_t::num_trans, rb_econv_elem_t::out_buf_end, rb_econv_elem_t::out_buf_start, rb_transcoding_memsize(), rb_econv_t::replacement_allocated, rb_econv_t::replacement_len, size, and rb_econv_elem_t::tc.

Referenced by rb_io_memsize().

rb_econv_t* rb_econv_open | ( | const char * | sname,
|  | const char * | dname,
|  | int | ecflags
| ) |  |

Definition at line 1067 of file transcode.c.

References decorator_names(), ECONV_ERROR_HANDLER_MASK, rb_econv_t::flags, i, MAX_ECFLAGS_DECORATORS, NULL, rb_econv_close(), rb_econv_decorate_at_last(), and rb_econv_open0().

Referenced by allocate_converted_string(), and rb_econv_open_opts().

static rb_econv_t* rb_econv_open0 | ( | const char * | sname,
|  | const char * | dname,
|  | int | ecflags
| ) |  |
| static

Definition at line 976 of file transcode.c.

References rb_econv_t::destination_encoding_name, trans_open_t::entries, rb_econv_t::flags, NULL, trans_open_t::num_additional, rb_econv_open_by_transcoder_entries(), rb_enc_find_index(), rb_enc_from_index(), rb_econv_t::source_encoding_name, trans_open_i(), transcode_search_path(), and xfree.

Referenced by rb_econv_open().

static rb_econv_t* rb_econv_open_by_transcoder_entries | ( | int | n,
|  | transcoder_entry_t ** | entries
| ) |  |
| static

Definition at line 933 of file transcode.c.

References i, load_transcoder_entry(), NULL, rb_econv_t::num_trans, rb_econv_add_transcoder_at(), rb_econv_alloc(), and rb_econv_close().

Referenced by rb_econv_open0().

VALUE rb_econv_open_exc | ( | const char * | sname,
|  | const char * | dname,
|  | int | ecflags
| ) |  |

Definition at line 2028 of file transcode.c.

References econv_description(), rb_eConverterNotFoundError, rb_exc_new3(), rb_str_cat2(), and rb_str_new_cstr().

Referenced by econv_init(), econv_s_search_convpath(), make_readconv(), make_writeconv(), and transcode_loop().

rb_econv_t* rb_econv_open_opts | ( | const char * | source_encoding,
|  | const char * | destination_encoding,
|  | int | ecflags,
|  | VALUE | opthash
| ) |  |

Definition at line 2570 of file transcode.c.

References NIL_P, NULL, OBJ_FROZEN, Qnil, rb_bug(), rb_econv_close(), rb_econv_open(), rb_econv_set_replacement(), rb_enc_get(), rb_enc_name, rb_hash_aref(), RB_TYPE_P, RSTRING_LEN, RSTRING_PTR, sym_replace, and T_HASH.

Referenced by econv_init(), gzfile_reset(), make_readconv(), make_writeconv(), rb_gzfile_ecopts(), RUBY_ALIAS_FUNCTION(), and transcode_loop().

int rb_econv_prepare_options | ( | VALUE | opthash,
|  | VALUE * | opts,
|  | int | ecflags
| ) |  |

Definition at line 2519 of file transcode.c.

References econv_opts(), ENC_CODERANGE_BROKEN, NIL_P, Qnil, rb_check_hash_type(), rb_eArgError, rb_enc_get(), rb_enc_name, rb_enc_str_coderange(), rb_hash_aref(), rb_hash_aset(), rb_hash_freeze(), rb_hash_new(), rb_obj_is_method(), rb_obj_is_proc(), rb_raise(), rb_respond_to(), rb_str_dump(), rb_str_new_frozen(), StringValue, StringValueCStr, sym_aref, sym_fallback, sym_replace, and v.

Referenced by io_encoding_set(), rb_econv_prepare_opts(), and rb_io_extract_modeenc().

int rb_econv_prepare_opts | ( | VALUE | opthash,
|  | VALUE * | opts
| ) |  |

Definition at line 2564 of file transcode.c.

References rb_econv_prepare_options().

Referenced by econv_args(), rb_gzfile_ecopts(), and str_transcode().

void rb_econv_putback | ( | rb_econv_t * | ec,
|  | unsigned char * | p,
|  | int | n
| ) |  |

Definition at line 1753 of file transcode.c.

References rb_econv_t::elems, rb_econv_t::num_trans, rb_transcoding::readagain_len, rb_transcoding::recognized_len, rb_econv_elem_t::tc, and TRANSCODING_READBUF.

Referenced by econv_putback(), and fill_cbuf().

int rb_econv_putbackable | ( | rb_econv_t * | ec) |  |

Definition at line 1742 of file transcode.c.

References rb_econv_t::elems, rb_econv_t::num_trans, rb_transcoding::readagain_len, and rb_econv_elem_t::tc.

Referenced by econv_putback(), and fill_cbuf().

int rb_econv_set_replacement | ( | rb_econv_t * | ec,
|  | const unsigned char * | str,
|  | size_t | len,
|  | const char * | encname
| ) |  |

Definition at line 2190 of file transcode.c.

References allocate_converted_string(), encoding_equal, MEMCPY, NULL, rb_econv_encoding_to_insert_output(), rb_econv_t::replacement_allocated, rb_econv_t::replacement_enc, rb_econv_t::replacement_len, rb_econv_t::replacement_str, xfree, and xmalloc.

Referenced by econv_set_replacement(), and rb_econv_open_opts().

VALUE rb_econv_str_append | ( | rb_econv_t * | ec,
|  | VALUE | src,
|  | VALUE | dst,
|  | int | flags
| ) |  |

Definition at line 1857 of file transcode.c.

References rb_econv_substr_append(), and RSTRING_LEN.

VALUE rb_econv_str_convert | ( | rb_econv_t * | ec,
|  | VALUE | src,
|  | int | flags
| ) |  |

Definition at line 1869 of file transcode.c.

References Qnil, rb_econv_substr_append(), and RSTRING_LEN.

Referenced by do_writeconv(), and gzfile_newstr().

VALUE rb_econv_substr_append | ( | rb_econv_t * | ec,
|  | VALUE | src,
|  | long | off,
|  | long | len,
|  | VALUE | dst,
|  | int | flags
| ) |  |

Definition at line 1813 of file transcode.c.

References rb_econv_t::destination_encoding, dp, econv_destination_buffer_full, rb_econv_t::last_tc, LONG_MAX, rb_transcoder::max_output, NIL_P, rb_eArgError, rb_econv_check_error(), rb_econv_convert(), rb_enc_associate(), rb_raise(), rb_str_buf_new(), rb_str_capacity(), rb_str_resize(), rb_str_set_len(), RSTRING_LEN, RSTRING_PTR, and rb_transcoding::transcoder.

Referenced by rb_econv_str_append(), rb_econv_str_convert(), and rb_econv_substr_convert().

VALUE rb_econv_substr_convert | ( | rb_econv_t * | ec,
|  | VALUE | src,
|  | long | byteoff,
|  | long | bytesize,
|  | int | flags
| ) |  |

Definition at line 1863 of file transcode.c.

References Qnil, and rb_econv_substr_append().

void rb_register_transcoder | ( | const rb_transcoder * | tr) |  |

Definition at line 205 of file transcode.c.

References rb_transcoder::dst_encoding, make_transcoder_entry(), rb_eArgError, rb_raise(), rb_transcoder::src_encoding, and transcoder_entry_t::transcoder.

Referenced by Init_newline().

VALUE rb_str_encode | ( | VALUE | str,
|  | VALUE | to,
|  | int | ecflags,
|  | VALUE | ecopts
| ) |  |

Definition at line 2867 of file transcode.c.

References argc, argv, encoded_dup(), and str_transcode0().

Referenced by do_writeconv(), econv_insert_output(), fix_string_encoding(), get_user_from_path(), rb_file_expand_path_internal(), rb_io_getline_1(), rb_str_ellipsize(), rb_str_encode_ospath(), rb_w32_conv_from_wchar(), and rb_w32_write_console().

static rb_econv_result_t rb_trans_conv | ( | rb_econv_t * | ec,
|  | const unsigned char ** | input_ptr,
|  | const unsigned char * | input_stop,
|  | unsigned char ** | output_ptr,
|  | unsigned char * | output_stop,
|  | int | flags,
|  | int * | result_position_ptr
| ) |  |
| static

Definition at line 1175 of file transcode.c.

References econv_after_output, ECONV_AFTER_OUTPUT, econv_destination_buffer_full, econv_finished, econv_incomplete_input, econv_invalid_byte_sequence, ECONV_PARTIAL_INPUT, econv_source_buffer_empty, econv_undefined_conversion, rb_econv_t::elems, i, rb_econv_elem_t::last_result, NULL, rb_econv_t::num_trans, rb_bug(), and trans_sweep().

Referenced by rb_econv_convert0().

static void rb_transcoding_close | ( | rb_transcoding * | tc) |  |
| static

Definition at line 822 of file transcode.c.

References rb_transcoding::ary, rb_transcoder::max_input, rb_transcoder::max_output, rb_transcoding::ptr, rb_transcoding::rb_transcoding_state_t::ptr, rb_transcoding::readbuf, rb_transcoding::state, rb_transcoder::state_fini_func, rb_transcoding::transcoder, TRANSCODING_STATE, rb_transcoding::writebuf, and xfree.

Referenced by rb_econv_binmode(), and rb_econv_close().

static rb_econv_result_t rb_transcoding_convert | ( | rb_transcoding * | tc,
|  | const unsigned char ** | input_ptr,
|  | const unsigned char * | input_stop,
|  | unsigned char ** | output_ptr,
|  | unsigned char * | output_stop,
|  | int | flags
| ) |  |
| static

Definition at line 810 of file transcode.c.

References transcode_restartable().

Referenced by trans_sweep().

static size_t rb_transcoding_memsize | ( | rb_transcoding * | tc) |  |
| static

Definition at line 838 of file transcode.c.

References rb_transcoding::ary, rb_transcoder::max_input, rb_transcoder::max_output, rb_transcoding::readbuf, size, rb_transcoder::state_size, rb_transcoding::transcoder, and rb_transcoding::writebuf.

Referenced by rb_econv_memsize().

static rb_transcoding* rb_transcoding_open_by_transcoder | ( | const rb_transcoder * | tr,
|  | int | flags
| ) |  |
| static

Definition at line 783 of file transcode.c.

References ALLOC, rb_transcoding::ary, rb_transcoding::flags, rb_transcoder::max_input, rb_transcoder::max_output, rb_transcoding::ptr, rb_transcoding::rb_transcoding_state_t::ptr, rb_transcoding::readagain_len, rb_transcoding::readbuf, rb_transcoding::recognized_len, rb_transcoding::resume_position, rb_transcoding::state, rb_transcoder::state_init_func, rb_transcoder::state_size, rb_transcoding::transcoder, TRANSCODING_STATE, rb_transcoding::writebuf, rb_transcoding::writebuf_len, rb_transcoding::writebuf_off, and xmalloc.

Referenced by rb_econv_add_transcoder_at().

static void search_convpath_i | ( | const char * | sname,
|  | const char * | dname,
|  | int | depth,
|  | void * | arg
| ) |  |
| static

Definition at line 3077 of file transcode.c.

References arg, DECORATOR_P, make_encobj(), Qnil, rb_ary_new(), rb_ary_store(), rb_assoc_new(), rb_str_new_cstr(), and v.

Referenced by econv_s_search_convpath(), and rb_econv_has_convpath_p().

static VALUE str_encode | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | str
| ) |  |
| static

Definition at line 2859 of file transcode.c.

References encoded_dup(), and str_transcode().

Referenced by Init_transcode().

static VALUE str_encode_associate | ( | VALUE | str,
|  | int | encidx
| ) |  |
| inline static

Definition at line 2745 of file transcode.c.

References ENC_CODERANGE_SET, ENC_CODERANGE_VALID, rb_enc_asciicompat, rb_enc_associate_index(), rb_enc_from_index(), rb_str_coderange_scan_restartable(), RSTRING_END, and RSTRING_PTR.

Referenced by encoded_dup(), and str_encode_bang().

static VALUE str_encode_bang | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | str
| ) |  |
| static

Definition at line 2777 of file transcode.c.

References rb_check_frozen, rb_enc_associate_index(), rb_str_shared_replace(), str_encode_associate(), and str_transcode().

Referenced by Init_transcode().

static int str_transcode | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE * | self
| ) |  |
| static

Definition at line 2731 of file transcode.c.

References NIL_P, NULL, Qnil, rb_econv_prepare_opts(), rb_scan_args(), and str_transcode0().

Referenced by str_encode(), and str_encode_bang().

static int str_transcode0 | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE * | self,
|  | int | ecflags,
|  | VALUE | ecopts
| ) |  |
| static

Definition at line 2656 of file transcode.c.

References bp, buf, ECONV_INVALID_REPLACE, ECONV_NEWLINE_DECORATOR_MASK, ECONV_UNDEF_REPLACE, ECONV_XML_ATTR_CONTENT_DECORATOR, ECONV_XML_ATTR_QUOTE_DECORATOR, ECONV_XML_TEXT_DECORATOR, ENC_CODERANGE_7BIT, encoding_equal, NIL_P, PRIdPTRDIFF, Qnil, rb_check_arity, rb_define_dummy_encoding(), rb_eArgError, rb_enc_asciicompat, rb_enc_default_internal(), rb_enc_str_coderange(), rb_obj_encoding(), rb_raise(), rb_str_set_len(), rb_str_tmp_new(), RSTRING_LEN, RSTRING_PTR, str_transcode_enc_args(), str_transcoding_resize(), and transcode_loop().

Referenced by rb_str_encode(), and str_transcode().

static int str_transcode_enc_args | ( | VALUE | str,
|  | volatile VALUE * | arg1,
|  | volatile VALUE * | arg2,
|  | const char ** | sname_p,
|  | rb_encoding ** | senc_p,
|  | const char ** | dname_p,
|  | rb_encoding ** | denc_p
| ) |  |
| static

Definition at line 2629 of file transcode.c.

References enc_arg(), NIL_P, rb_enc_from_index(), rb_enc_get_index(), and rb_enc_name.

Referenced by str_transcode0().

static unsigned char* str_transcoding_resize | ( | VALUE | destination,
|  | size_t | len,
|  | size_t | new_len
| ) |  |
| static

Definition at line 2413 of file transcode.c.

References rb_str_resize(), and RSTRING_PTR.

Referenced by str_transcode0().

static void trans_open_i | ( | const char * | sname,
|  | const char * | dname,
|  | int | depth,
|  | void * | arg
| ) |  |
| static

Definition at line 965 of file transcode.c.

References ALLOC_N, arg, trans_open_t::entries, get_transcoder_entry(), and trans_open_t::num_additional.

Referenced by rb_econv_open0().

static int trans_sweep | ( | rb_econv_t * | ec,
|  | const unsigned char ** | input_ptr,
|  | const unsigned char * | input_stop,
|  | unsigned char ** | output_ptr,
|  | unsigned char * | output_stop,
|  | int | flags,
|  | int | start
| ) |  |
| static

Definition at line 1094 of file transcode.c.

References econv_after_output, ECONV_AFTER_OUTPUT, econv_destination_buffer_full, econv_finished, econv_incomplete_input, econv_invalid_byte_sequence, ECONV_PARTIAL_INPUT, econv_source_buffer_empty, econv_undefined_conversion, rb_econv_t::elems, f, i, rb_econv_elem_t::last_result, MEMMOVE, rb_econv_t::num_finished, rb_econv_t::num_trans, rb_econv_elem_t::out_buf_end, rb_econv_elem_t::out_buf_start, rb_econv_elem_t::out_data_end, rb_econv_elem_t::out_data_start, rb_transcoding_convert(), and rb_econv_elem_t::tc.

Referenced by rb_trans_conv().

static const unsigned char* transcode_char_start | ( | rb_transcoding * | tc,
|  | const unsigned char * | in_start,
|  | const unsigned char * | inchar_start,
|  | const unsigned char * | in_p,
|  | size_t * | char_len_ptr
| ) |  |
| static

Definition at line 412 of file transcode.c.

References MEMCPY, rb_transcoding::recognized_len, and TRANSCODING_READBUF.

Referenced by transcode_restartable0().

static void transcode_loop | ( | const unsigned char ** | in_pos,
|  | unsigned char ** | out_pos,
|  | const unsigned char * | in_stop,
|  | unsigned char * | out_stop,
|  | VALUE | destination,
|  | unsigned char *(*)(VALUE, size_t, size_t) | resize_destination,
|  | const char * | src_encoding,
|  | const char * | dst_encoding,
|  | int | ecflags,
|  | VALUE | ecopts
| ) |  |
| static

Definition at line 2258 of file transcode.c.

References aref_fallback(), econv_destination_buffer_full, econv_incomplete_input, econv_invalid_byte_sequence, econv_undefined_conversion, rb_econv_t::error_bytes_len, rb_econv_t::error_bytes_start, hash_fallback, rb_econv_t::last_error, rb_econv_t::last_tc, make_econv_exception(), rb_transcoder::max_output, method_fallback(), more_output_buffer(), NIL_P, proc_fallback(), Qnil, Qundef, rb_eArgError, rb_econv_close(), rb_econv_convert(), rb_econv_insert_output(), rb_econv_open_exc(), rb_econv_open_opts(), rb_enc_find(), rb_enc_get(), rb_enc_name, rb_enc_str_new(), rb_exc_raise(), rb_hash_aref(), rb_obj_is_method(), rb_obj_is_proc(), rb_raise(), RB_TYPE_P, RSTRING_LEN, RSTRING_PTR, rb_econv_t::source_encoding, StringValue, sym_fallback, T_HASH, and rb_transcoding::transcoder.

Referenced by str_transcode0().

static rb_econv_result_t transcode_restartable | ( | const unsigned char ** | in_pos,
|  | unsigned char ** | out_pos,
|  | const unsigned char * | in_stop,
|  | unsigned char * | out_stop,
|  | rb_transcoding * | tc,
|  | const int | opt
| ) |  |
| static

Definition at line 757 of file transcode.c.

References ALLOCA_N, ECONV_PARTIAL_INPUT, econv_source_buffer_empty, MEMCPY, rb_transcoding::readagain_len, rb_transcoding::recognized_len, transcode_restartable0(), and TRANSCODING_READBUF.

Referenced by rb_transcoding_convert().

static rb_econv_result_t transcode_restartable0 | ( | const unsigned char ** | in_pos,
|  | unsigned char ** | out_pos,
|  | const unsigned char * | in_stop,
|  | unsigned char * | out_stop,
|  | rb_transcoding * | tc,
|  | const int | opt
| ) |  |
| static

Definition at line 432 of file transcode.c.

References BL_ACTION, BL_MAX_BYTE, BL_MIN_BYTE, BYTE_ADDR, rb_transcoder::conv_tree_start, econv_finished, econv_incomplete_input, econv_invalid_byte_sequence, ECONV_PARTIAL_INPUT, econv_source_buffer_empty, econv_undefined_conversion, rb_transcoder::finish_func, FOURbt, rb_transcoder::func_ii, rb_transcoder::func_io, rb_transcoder::func_si, rb_transcoder::func_sio, rb_transcoder::func_so, FUNii, FUNio, FUNsi, FUNsio, FUNso, GB4bt, getBT0, getBT1, getBT2, getBT3, getGB4bt0, getGB4bt1, getGB4bt2, getGB4bt3, rb_transcoder::input_unit_length, INVALID, rb_transcoder::max_output, next_byte, next_info, next_table, NOMAP, ONEbt, rb_transcoding::output_index, p, rb_eRuntimeError, rb_raise(), rb_transcoding::recognized_len, rb_transcoding::resume_position, STR1, STR1_BYTEINDEX, STR1_LENGTH, SUSPEND, SUSPEND_AFTER_OUTPUT, SUSPEND_OBUF, THREEbt, transcode_char_start(), rb_transcoding::transcoder, TRANSCODING_STATE, TRANSCODING_WRITEBUF, TRANSCODING_WRITEBUF_SIZE, TWObt, UNDEF, writebuf_len, writebuf_off, and ZERObt.

Referenced by transcode_restartable().

static int transcode_search_path | ( | const char * | sname,
|  | const char * | dname,
|  | void(*)(const char *sname, const char *dname, int depth, void *arg) | callback,
|  | void * | arg
| ) |  |
| static

Definition at line 277 of file transcode.c.

References ALLOC, search_path_bfs_t::base_enc, callback(), search_path_queue_tag::enc, encoding_equal, search_path_queue_tag::next, NULL, search_path_bfs_t::queue, search_path_bfs_t::queue_last_ptr, st_add_direct(), st_foreach(), st_free_table(), st_init_strcasetable(), st_lookup(), transcode_search_path_i(), val, search_path_bfs_t::visited, and xfree.

Referenced by econv_s_search_convpath(), rb_econv_has_convpath_p(), rb_econv_init_by_convpath(), and rb_econv_open0().

static int transcode_search_path_i | ( | st_data_t | key,
|  | st_data_t | val,
|  | st_data_t | arg
| ) |  |
| static

Definition at line 256 of file transcode.c.

References ALLOC, search_path_bfs_t::base_enc, search_path_queue_tag::enc, search_path_queue_tag::next, NULL, search_path_bfs_t::queue_last_ptr, st_add_direct(), ST_CONTINUE, st_lookup(), and search_path_bfs_t::visited.

Referenced by transcode_search_path().

## Variable Documentation

const rb_data_type_t econv_data_type
| static

Initial value:
= {
"econv",
{NULL, econv_free, econv_memsize,},
}

Definition at line 2904 of file transcode.c.

VALUE rb_cEncodingConverter

Definition at line 25 of file transcode.c.

Referenced by Init_transcode(), and RUBY_ALIAS_FUNCTION().

VALUE rb_eConverterNotFoundError

Definition at line 23 of file transcode.c.

Referenced by Init_transcode(), and rb_econv_open_exc().

VALUE rb_eInvalidByteSequenceError

Definition at line 22 of file transcode.c.

Referenced by Init_transcode(), and make_econv_exception().

VALUE rb_eUndefinedConversionError

Definition at line 21 of file transcode.c.

Referenced by econv_get_replacement(), econv_set_replacement(), Init_transcode(), and make_econv_exception().

VALUE sym_after_output
| static

Definition at line 42 of file transcode.c.

Referenced by econv_primitive_convert(), econv_result_to_symbol(), and Init_transcode().

VALUE sym_aref
| static

Definition at line 27 of file transcode.c.

Referenced by aref_fallback(), Init_transcode(), and rb_econv_prepare_options().

VALUE sym_attr
| static

Definition at line 28 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_cr
| static

Definition at line 33 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_cr_newline
| static

Definition at line 31 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_crlf
| static

Definition at line 33 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_crlf_newline
| static

Definition at line 30 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_destination_buffer_full
| static

Definition at line 39 of file transcode.c.

Referenced by econv_result_to_symbol(), and Init_transcode().

VALUE sym_fallback
| static

Definition at line 27 of file transcode.c.

Referenced by Init_transcode(), rb_econv_prepare_options(), and transcode_loop().

VALUE sym_finished
| static

Definition at line 41 of file transcode.c.

Referenced by econv_convert(), econv_finish(), econv_result_to_symbol(), and Init_transcode().

VALUE sym_incomplete_input
| static

Definition at line 43 of file transcode.c.

Referenced by econv_convert(), econv_finish(), econv_result_to_symbol(), and Init_transcode().

VALUE sym_invalid
| static

Definition at line 27 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_invalid_byte_sequence
| static

Definition at line 37 of file transcode.c.

Referenced by econv_convert(), econv_finish(), econv_result_to_symbol(), and Init_transcode().

VALUE sym_lf
| static

Definition at line 33 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_newline
| static

Definition at line 33 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_partial_input
| static

Definition at line 35 of file transcode.c.

Referenced by econv_primitive_convert(), and Init_transcode().

VALUE sym_replace
| static

Definition at line 27 of file transcode.c.

Referenced by econv_opts(), Init_transcode(), rb_econv_open_opts(), and rb_econv_prepare_options().

VALUE sym_source_buffer_empty
| static

Definition at line 40 of file transcode.c.

Referenced by econv_convert(), econv_result_to_symbol(), and Init_transcode().

VALUE sym_text
| static

Definition at line 28 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_undef
| static

Definition at line 27 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_undefined_conversion
| static

Definition at line 38 of file transcode.c.

Referenced by econv_convert(), econv_finish(), econv_result_to_symbol(), and Init_transcode().

VALUE sym_universal
| static

Definition at line 33 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_universal_newline
| static

Definition at line 29 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_xml
| static

Definition at line 28 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

const char transcoder_lib_prefix[] = "enc/trans/"
| static

Definition at line 230 of file transcode.c.

Referenced by load_transcoder_entry().

st_table* transcoder_table
| static

Definition at line 163 of file transcode.c.