Ruby
2.5.0dev(2017-10-22revision60238)
|
#include "internal.h"
#include "encindex.h"
#include "regenc.h"
#include <ctype.h>
#include "ruby/util.h"
#include "ruby_assert.h"
Go to the source code of this file.
Data Structures | |
struct | rb_encoding_entry |
struct | default_encoding |
Macros | |
#define | ENC_DEBUG 0 |
#define | ENC_ASSERT (!ENC_DEBUG)?(void)0:assert |
#define | MUST_STRING(str) (ENC_ASSERT(RB_TYPE_P(str, T_STRING)), str) |
#define | ENC_DUMMY_FLAG (1<<24) |
#define | ENC_INDEX_MASK (~(~0U<<24)) |
#define | ENC_TO_ENCINDEX(enc) (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK) |
#define | ENC_DUMMY_P(enc) ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG) |
#define | ENC_SET_DUMMY(enc) ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG) |
#define | ENCODING_COUNT ENCINDEX_BUILTIN_MAX |
#define | UNSPECIFIED_ENCODING INT_MAX |
#define | ENCODING_NAMELEN_MAX 63 |
#define | valid_encoding_name_p(name) ((name) && strlen(name) <= ENCODING_NAMELEN_MAX) |
#define | enc_autoload_p(enc) (!rb_enc_mbmaxlen(enc)) |
#define | is_data_encoding(obj) (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj) == &encoding_data_type) |
#define | is_obj_encoding(obj) (RB_TYPE_P((obj), T_DATA) && is_data_encoding(obj)) |
#define | ENC_REGISTER(enc) enc_register_at(ENCINDEX_##enc, rb_enc_name(&OnigEncoding##enc), &OnigEncoding##enc) |
#define | ENCDB_REGISTER(name, enc) enc_register_at(ENCINDEX_##enc, name, NULL) |
#define | rb_intern(str) rb_intern_const(str) |
Typedefs | |
typedef OnigEncodingType | rb_raw_encoding |
Variables | |
VALUE | rb_cEncoding |
Definition at line 22 of file encoding.c.
#define enc_autoload_p | ( | enc | ) | (!rb_enc_mbmaxlen(enc)) |
Definition at line 76 of file encoding.c.
#define ENC_DEBUG 0 |
Definition at line 20 of file encoding.c.
#define ENC_DUMMY_FLAG (1<<24) |
Definition at line 61 of file encoding.c.
#define ENC_DUMMY_P | ( | enc | ) | ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG) |
Definition at line 65 of file encoding.c.
Referenced by rb_enc_dummy_p().
#define ENC_INDEX_MASK (~(~0U<<24)) |
Definition at line 62 of file encoding.c.
#define ENC_REGISTER | ( | enc | ) | enc_register_at(ENCINDEX_##enc, rb_enc_name(&OnigEncoding##enc), &OnigEncoding##enc) |
#define ENC_SET_DUMMY | ( | enc | ) | ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG) |
Definition at line 66 of file encoding.c.
#define ENC_TO_ENCINDEX | ( | enc | ) | (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK) |
Definition at line 64 of file encoding.c.
Referenced by rb_enc_from_encoding(), and rb_enc_to_index().
#define ENCODING_COUNT ENCINDEX_BUILTIN_MAX |
Definition at line 70 of file encoding.c.
#define ENCODING_NAMELEN_MAX 63 |
Definition at line 73 of file encoding.c.
#define is_data_encoding | ( | obj | ) | (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj) == &encoding_data_type) |
Definition at line 86 of file encoding.c.
Referenced by rb_data_is_encoding().
#define is_obj_encoding | ( | obj | ) | (RB_TYPE_P((obj), T_DATA) && is_data_encoding(obj)) |
Definition at line 87 of file encoding.c.
#define MUST_STRING | ( | str | ) | (ENC_ASSERT(RB_TYPE_P(str, T_STRING)), str) |
Definition at line 23 of file encoding.c.
#define rb_intern | ( | str | ) | rb_intern_const(str) |
#define UNSPECIFIED_ENCODING INT_MAX |
Definition at line 71 of file encoding.c.
#define valid_encoding_name_p | ( | name | ) | ((name) && strlen(name) <= ENCODING_NAMELEN_MAX) |
Definition at line 74 of file encoding.c.
typedef OnigEncodingType rb_raw_encoding |
Definition at line 29 of file encoding.c.
void Init_Encoding | ( | void | ) |
Definition at line 1917 of file encoding.c.
References list, rb_cEncoding, rb_cObject, rb_define_alloc_func(), and rb_define_class().
NORETURN | ( | static void | not_encodingVALUE enc | ) |
int rb_ascii8bit_encindex | ( | void | ) |
Definition at line 1314 of file encoding.c.
References ENCINDEX_ASCII.
Referenced by rb_char_to_option_kcode(), rb_external_str_new_with_enc(), rb_external_str_with_enc(), and rb_str_coderange_scan_restartable().
rb_encoding* rb_ascii8bit_encoding | ( | void | ) |
Definition at line 1305 of file encoding.c.
Referenced by rb_define_dummy_encoding(), rb_glob(), rb_reg_fragment_setenc(), rb_str_conv_enc_opts(), rb_symname_p(), and ruby_brace_glob().
int rb_data_is_encoding | ( | VALUE | obj | ) |
Definition at line 90 of file encoding.c.
References is_data_encoding.
rb_encoding* rb_default_external_encoding | ( | void | ) |
Definition at line 1425 of file encoding.c.
References default_encoding::enc, default_encoding::index, rb_enc_from_index(), and rb_locale_encoding().
Referenced by Init_enc_set_filesystem_encoding(), rb_enc_default_external(), rb_external_str_new(), rb_external_str_new_cstr(), rb_inspect(), rb_str_export(), rb_str_quote_unprintable(), and rb_str_symname_p().
rb_encoding* rb_default_internal_encoding | ( | void | ) |
Definition at line 1510 of file encoding.c.
References default_encoding::enc, default_encoding::index, and rb_enc_from_index().
Referenced by rb_enc_default_internal(), rb_external_str_with_enc(), rb_inspect(), rb_str_quote_unprintable(), and rb_str_symname_p().
int rb_define_dummy_encoding | ( | const char * | name | ) |
Definition at line 466 of file encoding.c.
References rb_ascii8bit_encoding(), and rb_enc_replicate().
Definition at line 557 of file encoding.c.
int rb_enc_ascget | ( | const char * | p, |
const char * | e, | ||
int * | len, | ||
rb_encoding * | enc | ||
) |
Definition at line 1032 of file encoding.c.
References ISASCII, MBCLEN_CHARFOUND_P, rb_enc_asciicompat, rb_enc_isascii, rb_enc_mbc_to_codepoint, and rb_enc_precise_mbclen().
Referenced by rb_reg_quote(), and rb_str_end_with_asciichar().
VALUE rb_enc_associate | ( | VALUE | obj, |
rb_encoding * | enc | ||
) |
Definition at line 854 of file encoding.c.
References rb_enc_associate_index(), and rb_enc_to_index().
Referenced by rb_econv_append(), rb_file_expand_path_internal(), rb_reg_fragment_setenc(), rb_reg_quote(), rb_str_conv_enc_opts(), rb_str_ellipsize(), rb_str_encode_ospath(), and rb_str_initialize().
Definition at line 826 of file encoding.c.
References rb_encoding_entry::enc, rb_check_frozen, rb_eArgError, rb_enc_get_index(), rb_raise(), and SPECIAL_CONST_P.
Referenced by rb_dir_getwd(), rb_enc_associate(), rb_enc_copy(), rb_external_str_with_enc(), rb_str_concat(), and rb_utf8_str_new_cstr().
rb_encoding* rb_enc_check | ( | VALUE | str1, |
VALUE | str2 | ||
) |
Definition at line 879 of file encoding.c.
References rb_encoding_entry::enc, rb_eEncCompatError, rb_enc_compatible(), rb_enc_get(), rb_enc_name, and rb_raise().
rb_encoding* rb_enc_check_str | ( | VALUE | str1, |
VALUE | str2 | ||
) |
Definition at line 868 of file encoding.c.
Referenced by rb_str_plus().
int rb_enc_code_to_mbclen | ( | int | code, |
rb_encoding * | enc | ||
) |
Definition at line 1088 of file encoding.c.
References ONIGENC_CODE_TO_MBCLEN.
int rb_enc_codelen | ( | int | c, |
rb_encoding * | enc | ||
) |
Definition at line 1077 of file encoding.c.
References ONIGENC_CODE_TO_MBCLEN, rb_eArgError, rb_enc_name, and rb_raise().
Referenced by rb_enc_uint_chr(), rb_str_buf_cat_ascii(), and rb_str_concat().
unsigned int rb_enc_codepoint | ( | const char * | p, |
const char * | e, | ||
rb_encoding * | enc | ||
) |
Definition at line 1071 of file encoding.c.
References rb_enc_codepoint_len().
unsigned int rb_enc_codepoint_len | ( | const char * | p, |
const char * | e, | ||
int * | len_p, | ||
rb_encoding * | enc | ||
) |
Definition at line 1056 of file encoding.c.
References MBCLEN_CHARFOUND_LEN, MBCLEN_CHARFOUND_P, rb_eArgError, rb_enc_mbc_to_codepoint, rb_enc_name, rb_enc_precise_mbclen(), and rb_raise().
Referenced by rb_enc_codepoint().
rb_encoding* rb_enc_compatible | ( | VALUE | str1, |
VALUE | str2 | ||
) |
Definition at line 962 of file encoding.c.
References rb_enc_from_index(), and rb_enc_get_index().
Referenced by rb_enc_check().
Definition at line 978 of file encoding.c.
References rb_enc_associate_index(), and rb_enc_get_index().
Referenced by rb_file_expand_path_internal(), rb_reg_quote(), and rb_str_concat_literals().
VALUE rb_enc_default_external | ( | void | ) |
Definition at line 1439 of file encoding.c.
References rb_default_external_encoding(), and rb_enc_from_encoding().
VALUE rb_enc_default_internal | ( | void | ) |
Definition at line 1519 of file encoding.c.
References rb_default_internal_encoding(), and rb_enc_from_encoding().
int rb_enc_dummy_p | ( | rb_encoding * | enc | ) |
Definition at line 132 of file encoding.c.
References ENC_DUMMY_P.
Referenced by rb_enc_str_coderange().
int rb_enc_fast_mbclen | ( | const char * | p, |
const char * | e, | ||
rb_encoding * | enc | ||
) |
Definition at line 1002 of file encoding.c.
References ONIGENC_MBC_ENC_LEN, and UChar.
rb_encoding* rb_enc_find | ( | const char * | name | ) |
Definition at line 728 of file encoding.c.
References rb_enc_find_index(), and rb_enc_from_index().
int rb_enc_find_index | ( | const char * | name | ) |
Definition at line 704 of file encoding.c.
References rb_encoding_entry::enc, and rb_enc_registered().
Referenced by Init_enc_set_filesystem_encoding(), rb_enc_find(), rb_locale_charmap(), and rb_nkf_enc_get().
void rb_enc_foreach_name | ( | int(*)(st_data_t name, st_data_t idx, st_data_t arg) | func, |
st_data_t | arg | ||
) |
Definition at line 1964 of file encoding.c.
References st_foreach.
VALUE rb_enc_from_encoding | ( | rb_encoding * | encoding | ) |
Definition at line 117 of file encoding.c.
References ENC_TO_ENCINDEX, and Qnil.
Referenced by rb_enc_default_external(), rb_enc_default_internal(), rb_parser_encoding(), and rb_str_ellipsize().
rb_encoding* rb_enc_from_index | ( | int | index | ) |
Definition at line 616 of file encoding.c.
Referenced by rb_default_external_encoding(), rb_default_internal_encoding(), rb_enc_compatible(), rb_enc_find(), rb_enc_get(), rb_enc_register(), rb_enc_str_coderange(), rb_encdb_set_unicode(), rb_filesystem_encoding(), rb_locale_encoding(), rb_str_buf_cat_ascii(), rb_str_comparable(), rb_str_dump(), rb_str_encode_ospath(), rb_str_end_with_asciichar(), rb_str_escape(), rb_str_inspect(), and rb_w32_conv_from_wchar().
rb_encoding* rb_enc_get | ( | VALUE | obj | ) |
Definition at line 860 of file encoding.c.
References rb_enc_from_index(), and rb_enc_get_index().
Referenced by rb_enc_check(), rb_file_dirname(), rb_file_expand_path_internal(), rb_inspect(), rb_must_asciicompat(), rb_path_to_class(), rb_readlink(), rb_reg_check_preprocess(), rb_reg_quote(), rb_reg_regsub(), rb_str_conv_enc_opts(), and rb_str_ellipsize().
rb_encoding* rb_enc_get_from_index | ( | int | index | ) |
Definition at line 628 of file encoding.c.
int rb_enc_get_index | ( | VALUE | obj | ) |
Definition at line 773 of file encoding.c.
References BUILTIN_TYPE, rb_sym2str, SPECIAL_CONST_P, SYMBOL_P, T_REGEXP, and T_STRING.
Referenced by rb_enc_associate_index(), rb_enc_compatible(), rb_enc_copy(), rb_enc_get(), rb_obj_encoding(), and rb_str_dump().
void rb_enc_init | ( | void | ) |
Definition at line 589 of file encoding.c.
int rb_enc_mbclen | ( | const char * | p, |
const char * | e, | ||
rb_encoding * | enc | ||
) |
Definition at line 1008 of file encoding.c.
References MBCLEN_CHARFOUND_LEN, MBCLEN_CHARFOUND_P, ONIGENC_PRECISE_MBC_ENC_LEN, rb_enc_mbminlen, and UChar.
int rb_enc_precise_mbclen | ( | const char * | p, |
const char * | e, | ||
rb_encoding * | enc | ||
) |
Definition at line 1020 of file encoding.c.
References ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE, ONIGENC_PRECISE_MBC_ENC_LEN, and UChar.
Referenced by rb_enc_ascget(), rb_enc_codepoint_len(), rb_enc_uint_chr(), rb_str_concat(), and rb_str_encode_ospath().
int rb_enc_register | ( | const char * | name, |
rb_encoding * | encoding | ||
) |
Definition at line 333 of file encoding.c.
References rb_enc_from_index(), rb_enc_name, rb_enc_registered(), and STRCASECMP.
int rb_enc_registered | ( | const char * | name | ) |
Definition at line 634 of file encoding.c.
References st_data_t.
Referenced by rb_enc_find_index(), rb_enc_register(), rb_enc_set_base(), rb_encdb_alias(), rb_encdb_declare(), rb_encdb_replicate(), rb_filesystem_encindex(), and rb_locale_encindex().
int rb_enc_replicate | ( | const char * | name, |
rb_encoding * | encoding | ||
) |
Definition at line 409 of file encoding.c.
Referenced by rb_define_dummy_encoding().
Definition at line 389 of file encoding.c.
References rb_enc_registered().
void rb_enc_set_default_external | ( | VALUE | encoding | ) |
Definition at line 1477 of file encoding.c.
References NIL_P, rb_eArgError, and rb_raise().
void rb_enc_set_default_internal | ( | VALUE | encoding | ) |
Definition at line 1561 of file encoding.c.
int rb_enc_set_dummy | ( | int | index | ) |
Definition at line 400 of file encoding.c.
void rb_enc_set_index | ( | VALUE | obj, |
int | idx | ||
) |
Definition at line 818 of file encoding.c.
References rb_check_frozen.
Referenced by rb_str_concat_literals().
int rb_enc_to_index | ( | rb_encoding * | enc | ) |
Definition at line 126 of file encoding.c.
References ENC_TO_ENCINDEX.
Referenced by Init_enc_set_filesystem_encoding(), rb_dir_getwd(), rb_enc_associate(), rb_enc_str_buf_cat(), rb_external_str_new_with_enc(), rb_external_str_with_enc(), rb_str_coderange_scan_restartable(), rb_str_concat(), rb_w32_conv_from_wchar(), and rb_w32_readdir().
int rb_enc_tolower | ( | int | c, |
rb_encoding * | enc | ||
) |
Definition at line 1100 of file encoding.c.
References ONIGENC_ASCII_CODE_TO_LOWER_CASE, and ONIGENC_IS_ASCII_CODE.
int rb_enc_toupper | ( | int | c, |
rb_encoding * | enc | ||
) |
Definition at line 1094 of file encoding.c.
References ONIGENC_ASCII_CODE_TO_UPPER_CASE, and ONIGENC_IS_ASCII_CODE.
int rb_enc_unicode_p | ( | rb_encoding * | enc | ) |
Definition at line 525 of file encoding.c.
References ONIGENC_IS_UNICODE, and st_data_t.
Definition at line 572 of file encoding.c.
References rb_enc_registered().
Referenced by Init_enc(), and Init_enc_set_filesystem_encoding().
void rb_encdb_declare | ( | const char * | name | ) |
Definition at line 357 of file encoding.c.
References rb_enc_registered().
Referenced by Init_enc(), and Init_enc_set_filesystem_encoding().
int rb_encdb_dummy | ( | const char * | name | ) |
Definition at line 476 of file encoding.c.
Definition at line 454 of file encoding.c.
References rb_enc_registered().
void rb_encdb_set_unicode | ( | int | index | ) |
Definition at line 583 of file encoding.c.
References ONIGENC_FLAG_UNICODE, and rb_enc_from_index().
int rb_filesystem_encindex | ( | void | ) |
Definition at line 1376 of file encoding.c.
References ENCINDEX_ASCII, and rb_enc_registered().
Referenced by rb_filesystem_encoding(), and rb_str_encode_ospath().
rb_encoding* rb_filesystem_encoding | ( | void | ) |
Definition at line 1385 of file encoding.c.
References rb_enc_from_index(), and rb_filesystem_encindex().
Referenced by rb_dir_getwd(), rb_file_expand_path_internal(), rb_filesystem_str_new(), and rb_filesystem_str_new_cstr().
rb_encoding* rb_find_encoding | ( | VALUE | enc | ) |
Definition at line 253 of file encoding.c.
void rb_gc_mark_encodings | ( | void | ) |
Definition at line 263 of file encoding.c.
ID rb_id_encoding | ( | void | ) |
Definition at line 753 of file encoding.c.
References CONST_ID.
int rb_locale_charmap_index | ( | void | ) |
Definition at line 108 of file localeinit.c.
References ENCINDEX_US_ASCII.
Referenced by rb_locale_encindex(), and rb_usascii_encindex().
int rb_locale_encindex | ( | void | ) |
Definition at line 1352 of file encoding.c.
References ENCINDEX_ASCII, Init_w32_codepage(), rb_enc_registered(), and rb_locale_charmap_index().
Referenced by rb_locale_encoding().
rb_encoding* rb_locale_encoding | ( | void | ) |
Definition at line 1370 of file encoding.c.
References rb_enc_from_index(), and rb_locale_encindex().
Referenced by rb_default_external_encoding(), rb_loaderror(), rb_loaderror_with_path(), rb_locale_str_new(), rb_locale_str_new_cstr(), and rb_str_export_locale().
Definition at line 992 of file encoding.c.
References rb_enc_get_index(), rb_eTypeError, and rb_raise().
rb_encoding* rb_to_encoding | ( | VALUE | enc | ) |
Definition at line 246 of file encoding.c.
int rb_to_encoding_index | ( | VALUE | enc | ) |
Definition at line 198 of file encoding.c.
int rb_usascii_encindex | ( | void | ) |
Definition at line 1344 of file encoding.c.
References ENCINDEX_US_ASCII, and rb_locale_charmap_index().
Referenced by rb_external_str_new_with_enc(), rb_external_str_with_enc(), rb_usascii_str_new(), and rb_usascii_str_new_cstr().
rb_encoding* rb_usascii_encoding | ( | void | ) |
Definition at line 1335 of file encoding.c.
Referenced by rb_intern2(), rb_reg_fragment_setenc(), rb_reg_quote(), and rb_sym_intern_ascii().
int rb_utf8_encindex | ( | void | ) |
Definition at line 1329 of file encoding.c.
References ENCINDEX_UTF_8.
Referenced by rb_char_to_option_kcode(), and rb_utf8_str_new_cstr().
rb_encoding* rb_utf8_encoding | ( | void | ) |
Definition at line 1320 of file encoding.c.
Referenced by rb_str_encode_ospath().
int count |
Definition at line 56 of file encoding.c.
Referenced by asn1time_to_time(), clock_gettime(), EVENTSINK_Invoke(), and rb_ivar_count().
struct rb_encoding_entry* list |
Definition at line 55 of file encoding.c.
Referenced by Init_Encoding(), onigenc_with_ascii_strnicmp(), rb_objspace_free(), and rb_set_end_proc().
st_table* names |
Definition at line 58 of file encoding.c.
VALUE rb_cEncoding |
Definition at line 45 of file encoding.c.
Referenced by Init_Encoding(), and InitVM_transcode().
int size |
Definition at line 57 of file encoding.c.
Referenced by onig_memsize(), onig_region_memsize(), onigenc_with_ascii_strnicmp(), rb_econv_memsize(), rb_hash_keys(), rb_hash_values(), rb_io_memsize(), rb_iseq_disasm(), rb_node_memsize(), rb_struct_new(), rb_w32_reparse_symlink_p(), rb_w32_write(), reg_get_val(), and ruby_getcwd().