Data Structures | Defines | Typedefs | Functions | Variables

transcode.c File Reference

#include "ruby/ruby.h"
#include "ruby/encoding.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

Defines

#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 MAX_TRANSCODER_LIBNAME_LEN   64
#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

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_tmake_transcoder_entry (const char *sname, const char *dname)
static transcoder_entry_tget_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_transcoderload_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_transcodingrb_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_trb_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_trb_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_trb_econv_open0 (const char *sname, const char *dname, int ecflags)
static int decorator_names (int ecflags, const char **decorators_ret)
rb_econv_trb_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 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 rb_econv_prepare_opts (VALUE opthash, VALUE *opts)
rb_econv_trb_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 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_encodingmake_dummy_encoding (const char *name)
static rb_encodingmake_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_trb_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_tcheck_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_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_newline (void)
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_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_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_tabletranscoder_table
static const char transcoder_lib_prefix [] = "enc/trans/"
static const rb_data_type_t econv_data_type

Define Documentation

#define BL_ACTION (   byte  )     (BL_INFO[BL_OFFSET((byte))])
#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])
#define BL_MIN_BYTE   (BL_BASE[0])
#define BL_OFFSET (   byte  )     (BL_BASE[2+(byte)-BL_MIN_BYTE])
#define BYTE_ADDR (   index  )     (tr->byte_array + (index))
#define DECORATOR_P (   sname,
  dname 
)    (*(sname) == '\0')
#define encoding_equal (   enc1,
  enc2 
)    (STRCASECMP(enc1, enc2) == 0)
#define MAX_ECFLAGS_DECORATORS   32

Definition at line 1021 of file transcode.c.

#define MAX_TRANSCODER_LIBNAME_LEN   64

Definition at line 224 of file transcode.c.

Referenced by load_transcoder_entry(), and rb_declare_transcoder().

#define next_byte   (tc->next_byte)

Referenced by get_info(), and transcode_restartable0().

#define next_info   (tc->next_info)
#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 78 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 91 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 90 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 82 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 86 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


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]
static int asciicompat_encoding_i ( st_data_t  key,
st_data_t  val,
st_data_t  arg 
) [static]
static rb_econv_t* check_econv ( VALUE  self  )  [static]
static void declare_transcoder ( const char *  sname,
const char *  dname,
const char *  lib 
) [static]

Definition at line 216 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]
static int decorator_names ( int  ecflags,
const char **  decorators_ret 
) [static]
static VALUE ecerr_destination_encoding ( VALUE  self  )  [static]

Definition at line 4134 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 4122 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 4176 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 4155 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 4218 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 4188 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 4110 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 4084 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]
static VALUE econv_convert ( VALUE  self,
VALUE  source_string 
) [static]
static VALUE econv_convpath ( VALUE  self  )  [static]
static VALUE econv_description ( const char *  sname,
const char *  dname,
int  ecflags,
VALUE  mesg 
) [static]
static VALUE econv_destination_encoding ( VALUE  self  )  [static]

Definition at line 3378 of file transcode.c.

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

Referenced by Init_transcode().

static VALUE econv_finish ( VALUE  self  )  [static]
static void econv_free ( void *  ptr  )  [static]

Definition at line 2818 of file transcode.c.

References rb_econv_close().

static VALUE econv_get_replacement ( VALUE  self  )  [static]
static VALUE econv_init ( int  argc,
VALUE argv,
VALUE  self 
) [static]
static VALUE econv_insert_output ( VALUE  self,
VALUE  string 
) [static]
static VALUE econv_inspect ( VALUE  self  )  [static]
static VALUE econv_last_error ( VALUE  self  )  [static]

Definition at line 3987 of file transcode.c.

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

Referenced by Init_transcode().

static size_t econv_memsize ( const void *  ptr  )  [static]

Definition at line 2825 of file transcode.c.

static int econv_opts ( VALUE  opt  )  [static]
static VALUE econv_primitive_convert ( int  argc,
VALUE argv,
VALUE  self 
) [static]
static VALUE econv_primitive_errinfo ( VALUE  self  )  [static]
static VALUE econv_putback ( int  argc,
VALUE argv,
VALUE  self 
) [static]
static VALUE econv_result_to_symbol ( rb_econv_result_t  res  )  [static]
static VALUE econv_s_allocate ( VALUE  klass  )  [static]

Definition at line 2836 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]
static VALUE econv_s_search_convpath ( int  argc,
VALUE argv,
VALUE  klass 
) [static]
static VALUE econv_set_replacement ( VALUE  self,
VALUE  arg 
) [static]
static VALUE econv_source_encoding ( VALUE  self  )  [static]

Definition at line 3363 of file transcode.c.

References check_econv(), 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]
static const char* get_replacement_character ( const char *  encname,
size_t *  len_ret,
const char **  repl_encname_ptr 
) [static]

Definition at line 385 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 183 of file transcode.c.

References st_lookup().

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

void Init_newline ( void   ) 

Definition at line 183 of file newline.c.

References rb_cr_newline, rb_crlf_newline, rb_register_transcoder(), and rb_universal_newline.

Referenced by Init_transcode().

void Init_transcode ( void   ) 

Definition at line 4248 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_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_attr, sym_cr_newline, sym_crlf_newline, sym_destination_buffer_full, sym_fallback, sym_finished, sym_incomplete_input, sym_invalid, sym_invalid_byte_sequence, sym_partial_input, sym_replace, sym_source_buffer_empty, sym_text, sym_undef, sym_undefined_conversion, sym_universal_newline, and sym_xml.

static const rb_transcoder* load_transcoder_entry ( transcoder_entry_t entry  )  [static]
static rb_encoding* make_dummy_encoding ( const char *  name  )  [static]

Definition at line 2842 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]
static VALUE make_encobj ( const char *  name  )  [static]

Definition at line 2862 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 2852 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]
static transcoder_entry_t* make_transcoder_entry ( const char *  sname,
const char *  dname 
) [static]
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 2145 of file transcode.c.

References len.

Referenced by transcode_loop().

static int output_hex_charref ( rb_econv_t ec  )  [static]
static int output_replacement_character ( rb_econv_t ec  )  [static]
void rb_declare_transcoder ( const char *  enc1,
const char *  enc2,
const char *  lib 
)
static int rb_econv_add_converter ( rb_econv_t ec,
const char *  sname,
const char *  dname,
int  n 
) [static]
static int rb_econv_add_transcoder_at ( rb_econv_t ec,
const rb_transcoder tr,
int  i 
) [static]
static rb_econv_t* rb_econv_alloc ( int  n_hint  )  [static]
const char* rb_econv_asciicompat_encoding ( const char *  ascii_incompat_name  ) 
void rb_econv_binmode ( rb_econv_t ec  ) 
void rb_econv_check_error ( rb_econv_t ec  ) 

Definition at line 4067 of file transcode.c.

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

Referenced by fill_cbuf(), and rb_econv_substr_append().

void rb_econv_close ( 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 
)
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]
static int rb_econv_decorate_at ( rb_econv_t ec,
const char *  decorator_name,
int  n 
) [static]

Definition at line 1886 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 
)
int rb_econv_decorate_at_last ( rb_econv_t ec,
const char *  decorator_name 
)
const char* rb_econv_encoding_to_insert_output ( rb_econv_t ec  ) 
int rb_econv_has_convpath_p ( const char *  from_encoding,
const char *  to_encoding 
)

Definition at line 3070 of file transcode.c.

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

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]
static void rb_econv_init_by_convpath_i ( const char *  sname,
const char *  dname,
int  depth,
void *  arg 
) [static]
int rb_econv_insert_output ( rb_econv_t ec,
const unsigned char *  str,
size_t  len,
const char *  str_encoding 
)
VALUE rb_econv_make_exception ( rb_econv_t ec  ) 

Definition at line 4061 of file transcode.c.

References make_econv_exception().

Referenced by fill_cbuf(), and finish_writeconv().

size_t rb_econv_memsize ( rb_econv_t ec  ) 
rb_econv_t* rb_econv_open ( const char *  sname,
const char *  dname,
int  ecflags 
)
static rb_econv_t* rb_econv_open0 ( const char *  sname,
const char *  dname,
int  ecflags 
) [static]
static rb_econv_t* rb_econv_open_by_transcoder_entries ( int  n,
transcoder_entry_t **  entries 
) [static]
VALUE rb_econv_open_exc ( const char *  sname,
const char *  dname,
int  ecflags 
)
rb_econv_t* rb_econv_open_opts ( const char *  source_encoding,
const char *  destination_encoding,
int  ecflags,
VALUE  opthash 
)
int rb_econv_prepare_opts ( VALUE  opthash,
VALUE opts 
)
void rb_econv_putback ( rb_econv_t ec,
unsigned char *  p,
int  n 
)
int rb_econv_putbackable ( rb_econv_t ec  ) 
int rb_econv_set_replacement ( rb_econv_t ec,
const unsigned char *  str,
size_t  len,
const char *  encname 
)
VALUE rb_econv_str_append ( rb_econv_t ec,
VALUE  src,
VALUE  dst,
int  flags 
)

Definition at line 1850 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 1862 of file transcode.c.

References Qnil, rb_econv_substr_append(), and RSTRING_LEN.

Referenced by do_writeconv().

VALUE rb_econv_substr_append ( rb_econv_t ec,
VALUE  src,
long  off,
long  len,
VALUE  dst,
int  flags 
)
VALUE rb_econv_substr_convert ( rb_econv_t ec,
VALUE  src,
long  byteoff,
long  bytesize,
int  flags 
)

Definition at line 1856 of file transcode.c.

References Qnil, and rb_econv_substr_append().

void rb_register_transcoder ( const rb_transcoder tr  ) 
VALUE rb_str_encode ( VALUE  str,
VALUE  to,
int  ecflags,
VALUE  ecopts 
)
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]
static void rb_transcoding_close ( rb_transcoding tc  )  [static]
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 802 of file transcode.c.

References transcode_restartable().

Referenced by trans_sweep().

static size_t rb_transcoding_memsize ( rb_transcoding tc  )  [static]
static rb_transcoding* rb_transcoding_open_by_transcoder ( const rb_transcoder tr,
int  flags 
) [static]
static void search_convpath_i ( const char *  sname,
const char *  dname,
int  depth,
void *  arg 
) [static]
static VALUE str_encode ( int  argc,
VALUE argv,
VALUE  str 
) [static]

Definition at line 2784 of file transcode.c.

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

Referenced by Init_transcode().

static VALUE str_encode_associate ( VALUE  str,
int  encidx 
) [inline, static]
static VALUE str_encode_bang ( int  argc,
VALUE argv,
VALUE  str 
) [static]
static int str_transcode ( int  argc,
VALUE argv,
VALUE self 
) [static]

Definition at line 2663 of file transcode.c.

References NIL_P, rb_check_convert_type(), rb_econv_prepare_opts(), str_transcode0(), and T_HASH.

Referenced by str_encode(), and str_encode_bang().

static int str_transcode0 ( int  argc,
VALUE argv,
VALUE self,
int  ecflags,
VALUE  ecopts 
) [static]
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 2557 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 2385 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]
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]
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 404 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]
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]
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]
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]
static int transcode_search_path_i ( st_data_t  key,
st_data_t  val,
st_data_t  arg 
) [static]

Variable Documentation

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

Definition at line 2830 of file transcode.c.

Definition at line 22 of file transcode.c.

Referenced by Init_transcode().

Definition at line 20 of file transcode.c.

Referenced by Init_transcode(), and rb_econv_open_exc().

Definition at line 19 of file transcode.c.

Referenced by Init_transcode(), and make_econv_exception().

Definition at line 36 of file transcode.c.

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

VALUE sym_attr [static]

Definition at line 25 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

Definition at line 28 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

Definition at line 27 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

Definition at line 33 of file transcode.c.

Referenced by econv_result_to_symbol(), and Init_transcode().

VALUE sym_fallback [static]

Definition at line 24 of file transcode.c.

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

VALUE sym_finished [static]

Definition at line 35 of file transcode.c.

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

Definition at line 37 of file transcode.c.

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

VALUE sym_invalid [static]

Definition at line 24 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

Definition at line 31 of file transcode.c.

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

Definition at line 29 of file transcode.c.

Referenced by econv_primitive_convert(), and Init_transcode().

VALUE sym_replace [static]

Definition at line 24 of file transcode.c.

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

Definition at line 34 of file transcode.c.

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

VALUE sym_text [static]

Definition at line 25 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_undef [static]

Definition at line 24 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

Definition at line 32 of file transcode.c.

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

Definition at line 26 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

VALUE sym_xml [static]

Definition at line 25 of file transcode.c.

Referenced by econv_opts(), and Init_transcode().

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

Definition at line 225 of file transcode.c.

Definition at line 157 of file transcode.c.