зеркало из https://github.com/github/ruby.git
* encoding.c (Init_Encoding): moved initialization from encdb.h.
* enc/make_encdb.rb (enc_name_list): constified. * enc/make_encdb.rb (enc_init_db): moved some functions to encoding.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e26e05c4ab
Коммит
bb8ddbe847
|
@ -1,3 +1,11 @@
|
|||
Sun Jan 13 18:41:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* encoding.c (Init_Encoding): moved initialization from encdb.h.
|
||||
|
||||
* enc/make_encdb.rb (enc_name_list): constified.
|
||||
|
||||
* enc/make_encdb.rb (enc_init_db): moved some functions to encoding.c.
|
||||
|
||||
Sun Jan 13 13:53:00 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ruby.c (load_file): local variable was not initialized when -x flag
|
||||
|
|
|
@ -35,26 +35,16 @@ Dir.open(encdir) {|d| d.grep(/.+\.c\z/)}.each do |fn|
|
|||
end
|
||||
p aliases
|
||||
open('encdb.h', 'wb') do |f|
|
||||
f.puts 'static const char *enc_name_list[] = {'
|
||||
f.puts 'static const char *const enc_name_list[] = {'
|
||||
encodings.each {|name| f.puts' "%s",' % name}
|
||||
replicas.each_key {|name| f.puts' "%s",' % name}
|
||||
aliases.each_key {|name| f.puts' "%s",' % name}
|
||||
f.puts(<<"_TEXT_")
|
||||
};
|
||||
#define enc_name_list_size (sizeof(enc_name_list)/sizeof(enc_name_list[0]))
|
||||
|
||||
static void enc_init_db(void)
|
||||
{
|
||||
if (!enc_table.replica_name) {
|
||||
enc_table.replica_name = st_init_strcasetable();
|
||||
}
|
||||
if (!enc_table.alias_name) {
|
||||
enc_table.alias_name = st_init_strcasetable();
|
||||
}
|
||||
_TEXT_
|
||||
f.puts('};', '', 'static void', 'enc_init_db(void)', '{')
|
||||
replicas.each_pair {|name, orig|
|
||||
f.puts' st_insert(enc_table.replica_name, (st_data_t)"%s", (st_data_t)"%s");' % [name, orig]}
|
||||
f.puts ' ENC_REPLICATE("%s", "%s");' % [name, orig]
|
||||
}
|
||||
aliases.each_pair {|name, orig|
|
||||
f.puts' st_insert(enc_table.alias_name, (st_data_t)"%s", (st_data_t)"%s");' % [name, orig]}
|
||||
f.puts ' ENC_ALIAS("%s", "%s");' % [name, orig]
|
||||
}
|
||||
f.puts '}'
|
||||
end
|
||||
|
|
|
@ -34,6 +34,12 @@ static struct {
|
|||
st_table *alias_name;
|
||||
} enc_table;
|
||||
|
||||
#undef ENC_REPLICATE
|
||||
#undef ENC_ALIAS
|
||||
#define ENC_REPLICATE(name, orig) st_insert(enc_table.replica_name, (st_data_t)(name), (st_data_t)(orig))
|
||||
#define ENC_ALIAS(name, orig) st_insert(enc_table.alias_name, (st_data_t)(name), (st_data_t)(orig))
|
||||
#define enc_name_list_size (sizeof(enc_name_list)/sizeof(enc_name_list[0]))
|
||||
|
||||
#include "encdb.h"
|
||||
|
||||
#define ENC_UNINITIALIZED (&rb_cEncoding)
|
||||
|
@ -1033,6 +1039,9 @@ Init_Encoding(void)
|
|||
{
|
||||
id_base_encoding = rb_intern("#base_encoding");
|
||||
|
||||
enc_table.replica_name = st_init_strcasetable();
|
||||
enc_table.alias_name = st_init_strcasetable();
|
||||
|
||||
rb_cEncoding = rb_define_class("Encoding", rb_cObject);
|
||||
rb_undef_alloc_func(rb_cEncoding);
|
||||
rb_define_method(rb_cEncoding, "to_s", enc_name, 0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче