Ruby
2.7.1p83(2020-03-31revisiona0c7c23c9cec0d0ffcba012279cd652d28ad5bf3)
|
#include "ruby/encoding.h"
#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 |
Typedefs | |
typedef OnigEncodingType | rb_raw_encoding |
Variables | |
VALUE | rb_cEncoding |
#define ENC_ASSERT | ( | expr | ) | RUBY_ASSERT_WHEN(ENC_DEBUG, expr) |
Definition at line 23 of file encoding.c.
#define enc_autoload_p | ( | enc | ) | (!rb_enc_mbmaxlen(enc)) |
Definition at line 75 of file encoding.c.
#define ENC_DEBUG 0 |
Definition at line 21 of file encoding.c.
#define ENC_DUMMY_FLAG (1<<24) |
Definition at line 62 of file encoding.c.
#define ENC_DUMMY_P | ( | enc | ) | ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG) |
Definition at line 66 of file encoding.c.
#define ENC_INDEX_MASK (~(~0U<<24)) |
Definition at line 63 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 67 of file encoding.c.
#define ENC_TO_ENCINDEX | ( | enc | ) | (int)((enc)->ruby_encoding_index & ENC_INDEX_MASK) |
Definition at line 65 of file encoding.c.
#define ENCODING_COUNT ENCINDEX_BUILTIN_MAX |
Definition at line 69 of file encoding.c.
#define ENCODING_NAMELEN_MAX 63 |
Definition at line 72 of file encoding.c.
#define is_data_encoding | ( | obj | ) | (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj) == &encoding_data_type) |
Definition at line 85 of file encoding.c.
Definition at line 86 of file encoding.c.
Definition at line 24 of file encoding.c.
#define rb_intern | ( | str | ) | rb_intern_const(str) |
#define UNSPECIFIED_ENCODING INT_MAX |
Definition at line 70 of file encoding.c.
#define valid_encoding_name_p | ( | name | ) | ((name) && strlen(name) <= ENCODING_NAMELEN_MAX) |
Definition at line 73 of file encoding.c.
typedef OnigEncodingType rb_raw_encoding |
Definition at line 30 of file encoding.c.
Definition at line 1919 of file encoding.c.
References i, list, rb_cEncoding, rb_cObject, rb_define_alloc_func(), and rb_define_class().
Definition at line 1964 of file encoding.c.
References rb_enc_init().
NORETURN | ( | static void | not_encodingVALUE enc | ) |
Definition at line 1322 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 1316 of file encoding.c.
Referenced by rb_define_dummy_encoding(), rb_glob(), rb_str_conv_enc_opts(), rb_symname_p(), ruby_brace_glob(), and ruby_init_loadpath().
Definition at line 89 of file encoding.c.
References is_data_encoding, and obj.
rb_encoding* rb_default_external_encoding | ( | void | ) |
Definition at line 1427 of file encoding.c.
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 1512 of file encoding.c.
Referenced by rb_enc_default_internal(), rb_external_str_with_enc(), rb_inspect(), rb_str_quote_unprintable(), rb_str_symname_p(), and rsock_raise_socket_error().
Definition at line 462 of file encoding.c.
References rb_encoding_entry::enc, index, name, rb_ascii8bit_encoding(), rb_enc_replicate(), and rb_encoding.
Definition at line 553 of file encoding.c.
Definition at line 1044 of file encoding.c.
References char, rb_encoding_entry::enc, ISASCII, len, 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 866 of file encoding.c.
References rb_encoding_entry::enc, obj, rb_enc_associate_index(), and rb_enc_to_index().
Referenced by rb_econv_append(), rb_reg_quote(), rb_str_conv_enc_opts(), rb_str_ellipsize(), and rb_str_initialize().
Definition at line 838 of file encoding.c.
References rb_encoding_entry::enc, obj, rb_check_frozen, rb_eArgError, rb_enc_get_index(), rb_encoding, 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().
Definition at line 753 of file encoding.c.
rb_encoding* rb_enc_check | ( | VALUE | str1, |
VALUE | str2 | ||
) |
Definition at line 891 of file encoding.c.
References rb_encoding_entry::enc, rb_eEncCompatError, rb_enc_compatible(), rb_enc_get(), rb_enc_name, rb_encoding, and rb_raise().
rb_encoding* rb_enc_check_str | ( | VALUE | str1, |
VALUE | str2 | ||
) |
Definition at line 880 of file encoding.c.
References rb_encoding_entry::enc, and rb_encoding.
Referenced by rb_str_plus().
int rb_enc_code_to_mbclen | ( | int | code, |
rb_encoding * | enc | ||
) |
Definition at line 1100 of file encoding.c.
References rb_encoding_entry::enc, and ONIGENC_CODE_TO_MBCLEN.
int rb_enc_codelen | ( | int | c, |
rb_encoding * | enc | ||
) |
Definition at line 1089 of file encoding.c.
References rb_encoding_entry::enc, n, 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().
Definition at line 1083 of file encoding.c.
References rb_encoding_entry::enc, and 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 1068 of file encoding.c.
References rb_encoding_entry::enc, 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 974 of file encoding.c.
References rb_enc_from_index(), and rb_enc_get_index().
Referenced by rb_enc_check().
Definition at line 990 of file encoding.c.
References obj2, rb_enc_associate_index(), and rb_enc_get_index().
Referenced by rb_reg_quote(), and rb_str_concat_literals().
Definition at line 1441 of file encoding.c.
References rb_default_external_encoding(), and rb_enc_from_encoding().
Definition at line 1521 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 131 of file encoding.c.
References rb_encoding_entry::enc, and ENC_DUMMY_P.
Referenced by rb_enc_str_coderange().
Definition at line 1014 of file encoding.c.
References rb_encoding_entry::enc, ONIGENC_MBC_ENC_LEN, and UChar.
rb_encoding* rb_enc_find | ( | const char * | name | ) |
Definition at line 728 of file encoding.c.
References name, rb_enc_find_index(), and rb_enc_from_index().
Definition at line 693 of file encoding.c.
References rb_encoding_entry::enc, i, name, rb_enc_registered(), and rb_encoding.
Referenced by Init_enc_set_filesystem_encoding(), rb_enc_find(), rb_enc_find_index2(), and rb_nkf_enc_get().
Definition at line 717 of file encoding.c.
References buf, ENCODING_NAMELEN_MAX, len, memcpy(), name, and rb_enc_find_index().
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 1972 of file encoding.c.
References st_foreach().
VALUE rb_enc_from_encoding | ( | rb_encoding * | encoding | ) |
Definition at line 116 of file encoding.c.
References ENC_TO_ENCINDEX, and Qnil.
Referenced by rb_enc_default_external(), rb_enc_default_internal(), and rb_str_ellipsize().
rb_encoding* rb_enc_from_index | ( | int | index | ) |
Definition at line 609 of file encoding.c.
References index, and UNLIKELY.
Referenced by 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 872 of file encoding.c.
References obj, rb_enc_from_index(), and rb_enc_get_index().
Referenced by rb_enc_check(), rb_file_dirname(), 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 618 of file encoding.c.
Definition at line 779 of file encoding.c.
References i, obj, SPECIAL_CONST_P, and SYMBOL_P.
Referenced by rb_enc_associate_index(), rb_enc_compatible(), rb_enc_copy(), rb_enc_get(), rb_obj_encoding(), rb_str_dump(), and rb_str_opt_plus().
Definition at line 582 of file encoding.c.
Referenced by Init_encodings().
Definition at line 1020 of file encoding.c.
References rb_encoding_entry::enc, int, MBCLEN_CHARFOUND_LEN, MBCLEN_CHARFOUND_P, n, ONIGENC_PRECISE_MBC_ENC_LEN, rb_enc_mbminlen, and UChar.
Definition at line 1032 of file encoding.c.
References rb_encoding_entry::enc, n, ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE, ONIGENC_PRECISE_MBC_ENC_LEN, and UChar.
Referenced by rb_enc_ascget(), rb_enc_codepoint_len(), rb_enc_uint_chr(), and rb_str_concat().
int rb_enc_register | ( | const char * | name, |
rb_encoding * | encoding | ||
) |
Definition at line 326 of file encoding.c.
References index, name, rb_enc_from_index(), rb_enc_name, rb_enc_registered(), rb_encoding, and STRCASECMP.
Definition at line 624 of file encoding.c.
References name.
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 402 of file encoding.c.
Referenced by rb_define_dummy_encoding().
Definition at line 382 of file encoding.c.
References name, and rb_enc_registered().
Definition at line 1479 of file encoding.c.
References NIL_P, rb_eArgError, and rb_raise().
Definition at line 1563 of file encoding.c.
Definition at line 393 of file encoding.c.
References rb_encoding_entry::enc, and rb_encoding.
Definition at line 830 of file encoding.c.
References obj, and rb_check_frozen.
Referenced by rb_str_concat_literals().
int rb_enc_to_index | ( | rb_encoding * | enc | ) |
Definition at line 125 of file encoding.c.
References rb_encoding_entry::enc, and 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 1112 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 1106 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 521 of file encoding.c.
References rb_encoding_entry::enc, and ONIGENC_IS_UNICODE.
Definition at line 565 of file encoding.c.
References rb_enc_registered().
Referenced by Init_enc().
Definition at line 350 of file encoding.c.
References name, and rb_enc_registered().
Referenced by Init_enc().
Definition at line 472 of file encoding.c.
References index.
Definition at line 450 of file encoding.c.
References name, and rb_enc_registered().
Definition at line 576 of file encoding.c.
References index, ONIGENC_FLAG_UNICODE, and rb_enc_from_index().
Definition at line 1378 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 1387 of file encoding.c.
References rb_enc_from_index(), and rb_filesystem_encindex().
Referenced by rb_dir_getwd(), rb_filesystem_str_new(), and rb_filesystem_str_new_cstr().
rb_encoding* rb_find_encoding | ( | VALUE | enc | ) |
Definition at line 252 of file encoding.c.
Definition at line 759 of file encoding.c.
References CONST_ID.
Definition at line 109 of file localeinit.c.
References ENCINDEX_US_ASCII.
Referenced by rb_locale_encindex().
Definition at line 1354 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 1372 of file encoding.c.
References rb_enc_from_index(), and rb_locale_encindex().
Referenced by rb_loaderror(), rb_loaderror_with_path(), rb_locale_str_new(), rb_locale_str_new_cstr(), and rb_str_export_locale().
Definition at line 1004 of file encoding.c.
References obj, rb_enc_get_index(), rb_eTypeError, and rb_raise().
rb_encoding* rb_to_encoding | ( | VALUE | enc | ) |
Definition at line 245 of file encoding.c.
Definition at line 197 of file encoding.c.
Definition at line 1346 of file encoding.c.
References ENCINDEX_US_ASCII.
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 1340 of file encoding.c.
Referenced by rb_intern2(), rb_iv_get(), rb_reg_quote(), and rb_sym_intern_ascii().
Definition at line 1334 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 1328 of file encoding.c.
Referenced by rb_str_encode_ospath().
int count |
Definition at line 57 of file encoding.c.
Referenced by asn1time_to_time(), EVENTSINK_Invoke(), ffi_closure_SYSV(), ffi_prep_args(), ffi_prep_cif_machdep(), rb_ivar_count(), rb_vm_bugreport(), and ruby_malloc_size_overflow().
struct rb_encoding_entry* list |
Definition at line 56 of file encoding.c.
Referenced by Init_Encoding(), onig_node_list_add(), rb_hook_list_remove_tracepoint(), rb_objspace_free(), and rb_set_end_proc().
st_table* names |
Definition at line 59 of file encoding.c.
VALUE rb_cEncoding |
Definition at line 46 of file encoding.c.
Referenced by Init_Encoding().
int size |
Definition at line 58 of file encoding.c.
Referenced by ffi_call(), ffi_closure_call_SYSV(), ffi_closure_helper_DARWIN(), ffi_closure_helper_SYSV(), ffi_closure_osf_inner(), ffi_closure_sparc_inner_v8(), ffi_closure_sparc_inner_v9(), ffi_closure_SYSV_inner(), ffi_prep_args(), ffi_prep_cif_machdep(), onig_bbuf_init(), onig_memsize(), onig_region_memsize(), rb_aligned_malloc(), rb_ast_memsize(), rb_ec_initialize_vm_stack(), rb_ec_set_vm_stack(), rb_econv_memsize(), rb_hash_new_with_size(), rb_io_memsize(), rb_iseq_insns_info_decode_positions(), rb_iseq_insns_info_encode_positions(), rb_iseq_mark_insn_storage(), rb_iseq_memsize(), rb_load_with_builtin_functions(), rb_mem_clear(), rb_parser_calloc(), rb_parser_malloc(), rb_parser_realloc(), rb_struct_new(), rb_vm_bugreport(), rb_w32_read(), rb_w32_reparse_symlink_p(), rb_w32_write(), reg_get_val(), RUBY_ALIAS_FUNCTION(), ruby_getcwd(), ruby_mimmalloc(), ruby_xcalloc(), ruby_xmalloc(), ruby_xmalloc2(), ruby_xmalloc_body(), ruby_xrealloc2_body(), and st_init_numtable_with_size().