void rb_enc_init(void) { enc_table_expand(ENCODING_COUNT + 1); if (!enc_table.names) { enc_table.names = st_init_strcasetable(); } #define ENC_REGISTER(enc) enc_register_at(ENCINDEX_##enc, rb_enc_name(&OnigEncoding##enc), &OnigEncoding##enc) ENC_REGISTER(ASCII); ENC_REGISTER(UTF_8); ENC_REGISTER(US_ASCII); #undef ENC_REGISTER #define ENCDB_REGISTER(name, enc) enc_register_at(ENCINDEX_##enc, name, NULL) ENCDB_REGISTER("UTF-16BE", UTF_16BE); ENCDB_REGISTER("UTF-16LE", UTF_16LE); ENCDB_REGISTER("UTF-32BE", UTF_32BE); ENCDB_REGISTER("UTF-32LE", UTF_32LE); ENCDB_REGISTER("UTF-16", UTF_16); ENCDB_REGISTER("UTF-32", UTF_32); ENCDB_REGISTER("UTF8-MAC", UTF8_MAC); ENCDB_REGISTER("EUC-JP", EUC_JP); ENCDB_REGISTER("Windows-31J", Windows_31J); #undef ENCDB_REGISTER enc_table.count = ENCINDEX_BUILTIN_MAX; }
static int enc_register(const char *name, rb_encoding *encoding) { int index = enc_table.count; if ((index = enc_table_expand(index + 1)) < 0) return -1; enc_table.count = index; return enc_register_at(index - 1, name, encoding); }
void rb_enc_init(void) { enc_table_expand(ENCODING_COUNT + 1); if (!enc_table.names) { enc_table.names = st_init_strcasetable(); } #define ENC_REGISTER(enc) enc_register_at(ENCINDEX_##enc, rb_enc_name(&OnigEncoding##enc), &OnigEncoding##enc) ENC_REGISTER(ASCII); ENC_REGISTER(UTF_8); ENC_REGISTER(US_ASCII); #undef ENC_REGISTER enc_table.count = ENCINDEX_BUILTIN_MAX; }