Ruby
2.7.2p137(2020-10-01revision5445e0435260b449decf2ac16f9d09bae3cafe72)
|
#include "ruby/encoding.h"
#include "internal.h"
#include "transcode_data.h"
#include <ctype.h>
#include "id.h"
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 |
Variables | |
VALUE | rb_cEncodingConverter |
#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 DECORATOR_P | ( | sname, | |
dname | |||
) | (*(sname) == '\0') |
Definition at line 154 of file transcode.c.
#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.
#define hash_fallback rb_hash_aref |
Definition at line 2228 of file transcode.c.
#define MAX_ECFLAGS_DECORATORS 32 |
Definition at line 1011 of file transcode.c.
#define next_byte (tc->next_byte) |
#define next_info (tc->next_info) |
#define next_table (tc->next_table) |
#define SUSPEND | ( | ret, | |
num | |||
) |
#define SUSPEND_AFTER_OUTPUT | ( | num | ) |
#define SUSPEND_OBUF | ( | num | ) |
#define TRANSCODING_READBUF | ( | tc | ) |
Definition at line 84 of file transcode.c.
#define TRANSCODING_STATE | ( | tc | ) |
Definition at line 97 of file transcode.c.
#define TRANSCODING_STATE_EMBED_MAX ((int)sizeof(union rb_transcoding_state_t)) |
Definition at line 96 of file transcode.c.
#define TRANSCODING_WRITEBUF | ( | tc | ) |
Definition at line 88 of file transcode.c.
#define TRANSCODING_WRITEBUF_SIZE | ( | tc | ) |
Definition at line 92 of file transcode.c.
#define WORD_ADDR | ( | index | ) | (tr->word_array + INFO2WORDINDEX(index)) |
#define writebuf_len (tc->writebuf_len) |
#define writebuf_off (tc->writebuf_off) |
typedef struct rb_transcoding rb_transcoding |
typedef struct search_path_queue_tag search_path_queue_t |
Definition at line 4404 of file transcode.c.
Definition at line 4440 of file transcode.c.
Definition at line 233 of file transcode.c.
References rb_eArgError, and rb_raise().
Definition at line 1796 of file transcode.c.
References rb_econv_t::destination_encoding, dp, econv_destination_buffer_full, rb_econv_t::last_tc, len, long, 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_substr_append().
Definition at line 1769 of file transcode.c.
References st_lookup(), and v.
void rb_econv_binmode | ( | rb_econv_t * | ec | ) |
Definition at line 1925 of file transcode.c.
References ECONV_CR_NEWLINE_DECORATOR, ECONV_CRLF_NEWLINE_DECORATOR, ECONV_NEWLINE_DECORATOR_MASK, ECONV_UNIVERSAL_NEWLINE_DECORATOR, and rb_econv_t::flags.
Referenced by rb_io_binmode().
void rb_econv_check_error | ( | rb_econv_t * | ec | ) |
void rb_econv_close | ( | rb_econv_t * | ec | ) |
Definition at line 1685 of file transcode.c.
References i, rb_econv_t::num_trans, rb_econv_t::replacement_allocated, rb_econv_t::replacement_str, and xfree.
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 1429 of file transcode.c.
References rb_econv_t::started.
Referenced by rb_econv_append().
int rb_econv_decorate_at_first | ( | rb_econv_t * | ec, |
const char * | decorator_name | ||
) |
Definition at line 1891 of file transcode.c.
References rb_econv_t::num_trans.
int rb_econv_decorate_at_last | ( | rb_econv_t * | ec, |
const char * | decorator_name | ||
) |
Definition at line 1908 of file transcode.c.
References rb_econv_t::num_trans.
const char* rb_econv_encoding_to_insert_output | ( | rb_econv_t * | ec | ) |
Definition at line 1486 of file transcode.c.
References asciicompat_encoder, rb_econv_t::last_tc, NULL, and rb_transcoding::transcoder.
Referenced by rb_econv_insert_output(), and rb_econv_set_replacement().
Definition at line 3167 of file transcode.c.
References Qnil.
int rb_econv_insert_output | ( | rb_econv_t * | ec, |
const unsigned char * | str, | ||
size_t | len, | ||
const char * | str_encoding | ||
) |
Definition at line 1570 of file transcode.c.
References encoding_equal, len, NULL, rb_econv_encoding_to_insert_output(), rb_econv_t::started, and str.
VALUE rb_econv_make_exception | ( | rb_econv_t * | ec | ) |
Definition at line 4218 of file transcode.c.
size_t rb_econv_memsize | ( | rb_econv_t * | ec | ) |
Definition at line 1703 of file transcode.c.
References i, rb_econv_t::num_trans, rb_econv_t::replacement_allocated, rb_econv_t::replacement_len, and size.
Referenced by rb_io_memsize().
Definition at line 1052 of file transcode.c.
References i, and MAX_ECFLAGS_DECORATORS.
Definition at line 2019 of file transcode.c.
References exc, and rb_str_new_cstr.
rb_econv_t* rb_econv_open_opts | ( | const char * | source_encoding, |
const char * | destination_encoding, | ||
int | ecflags, | ||
VALUE | opthash | ||
) |
Definition at line 2561 of file transcode.c.
References NIL_P, OBJ_FROZEN, Qnil, rb_bug(), rb_hash_aref(), RB_TYPE_P, and T_HASH.
Definition at line 2510 of file transcode.c.
References NIL_P, Qnil, and v.
Referenced by rb_econv_prepare_opts().
Definition at line 2555 of file transcode.c.
References rb_econv_prepare_options().
void rb_econv_putback | ( | rb_econv_t * | ec, |
unsigned char * | p, | ||
int | n | ||
) |
Definition at line 1736 of file transcode.c.
References rb_econv_t::elems, memcpy(), n, rb_econv_t::num_trans, rb_transcoding::readagain_len, rb_transcoding::recognized_len, rb_econv_elem_t::tc, and TRANSCODING_READBUF.
int rb_econv_putbackable | ( | rb_econv_t * | ec | ) |
Definition at line 1725 of file transcode.c.
References rb_econv_t::elems, INT_MAX, rb_econv_t::num_trans, rb_transcoding::readagain_len, and rb_econv_elem_t::tc.
int rb_econv_set_replacement | ( | rb_econv_t * | ec, |
const unsigned char * | str, | ||
size_t | len, | ||
const char * | encname | ||
) |
Definition at line 2181 of file transcode.c.
References encoding_equal, len, MEMCPY, rb_econv_encoding_to_insert_output(), str, and xmalloc.
VALUE rb_econv_str_append | ( | rb_econv_t * | ec, |
VALUE | src, | ||
VALUE | dst, | ||
int | flags | ||
) |
Definition at line 1848 of file transcode.c.
References rb_econv_substr_append(), RSTRING_LEN, and src.
VALUE rb_econv_str_convert | ( | rb_econv_t * | ec, |
VALUE | src, | ||
int | flags | ||
) |
Definition at line 1860 of file transcode.c.
References Qnil, rb_econv_substr_append(), RSTRING_LEN, and src.
VALUE rb_econv_substr_append | ( | rb_econv_t * | ec, |
VALUE | src, | ||
long | off, | ||
long | len, | ||
VALUE | dst, | ||
int | flags | ||
) |
Definition at line 1839 of file transcode.c.
References len, rb_econv_append(), RB_GC_GUARD, rb_str_new_frozen(), RSTRING_PTR, and src.
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 1854 of file transcode.c.
References Qnil, rb_econv_substr_append(), and src.
void rb_register_transcoder | ( | const rb_transcoder * | tr | ) |
Definition at line 205 of file transcode.c.
Definition at line 2870 of file transcode.c.
References argc, argv, and str.
Referenced by rb_str_ellipsize().
VALUE rb_cEncodingConverter |
Definition at line 25 of file transcode.c.