Ruby  2.0.0p648(2015-12-16revision53162)
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_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 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_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 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_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_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_tabletranscoder_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_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')
#define ENABLE_ECONV_NEWLINE_OPTION   1

Definition at line 18 of file transcode.c.

#define encoding_equal (   enc1,
  enc2 
)    (STRCASECMP((enc1), (enc2)) == 0)
#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)
#define next_info   (tc->next_info)

Referenced by transcode_restartable0().

#define next_table   (tc->next_table)
#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)
if(dispIdMember==DISPID_VALUE)
Definition: win32ole.c:791
#define TRANSCODING_READBUF(tc)
Definition: transcode.c:84
#define MEMMOVE(p1, p2, type, n)
Definition: ruby.h:1243

Referenced by transcode_restartable0().

#define SUSPEND_AFTER_OUTPUT (   num)
Value:
if ((opt & ECONV_AFTER_OUTPUT) && *out_pos != out_p) { \
}
#define SUSPEND(ret, num)
#define ECONV_AFTER_OUTPUT
Definition: encoding.h:340

Referenced by transcode_restartable0().

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

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)
#define sizeof(x)
Definition: zlib.c:58

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)
#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 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
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 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
static int decorator_names ( int  ecflags,
const char **  decorators_ret 
)
static
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
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 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
static VALUE econv_finish ( VALUE  self)
static
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
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 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
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 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
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 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
static VALUE encoded_dup ( VALUE  newstr,
VALUE  str,
int  encidx 
)
static
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
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
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
static transcoder_entry_t* make_transcoder_entry ( const char *  sname,
const char *  dname 
)
static
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
static int output_replacement_character ( rb_econv_t ec)
static
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
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 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)
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 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 
)
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 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
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 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)
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_options ( VALUE  opthash,
VALUE opts,
int  ecflags 
)
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 
)
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 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 
)
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)
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 810 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 2859 of file transcode.c.

References encoded_dup(), and str_transcode().

Referenced by Init_transcode().

static VALUE str_encode_associate ( VALUE  str,
int  encidx 
)
inlinestatic
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 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
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
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 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
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

const rb_data_type_t econv_data_type
static
Initial value:
= {
"econv",
}
static void econv_free(void *ptr)
Definition: transcode.c:2892
static size_t econv_memsize(const void *ptr)
Definition: transcode.c:2899
#define NULL
Definition: _sdbm.c:102

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
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
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.