mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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:
parent
e26e05c4ab
commit
bb8ddbe847
3 changed files with 23 additions and 16 deletions
|
@ -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>
|
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
|
* 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
|
end
|
||||||
p aliases
|
p aliases
|
||||||
open('encdb.h', 'wb') do |f|
|
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}
|
encodings.each {|name| f.puts' "%s",' % name}
|
||||||
replicas.each_key {|name| f.puts' "%s",' % name}
|
replicas.each_key {|name| f.puts' "%s",' % name}
|
||||||
aliases.each_key {|name| f.puts' "%s",' % name}
|
aliases.each_key {|name| f.puts' "%s",' % name}
|
||||||
f.puts(<<"_TEXT_")
|
f.puts('};', '', 'static void', 'enc_init_db(void)', '{')
|
||||||
};
|
|
||||||
#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_
|
|
||||||
replicas.each_pair {|name, orig|
|
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|
|
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 '}'
|
f.puts '}'
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,6 +34,12 @@ static struct {
|
||||||
st_table *alias_name;
|
st_table *alias_name;
|
||||||
} enc_table;
|
} 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"
|
#include "encdb.h"
|
||||||
|
|
||||||
#define ENC_UNINITIALIZED (&rb_cEncoding)
|
#define ENC_UNINITIALIZED (&rb_cEncoding)
|
||||||
|
@ -1033,6 +1039,9 @@ Init_Encoding(void)
|
||||||
{
|
{
|
||||||
id_base_encoding = rb_intern("#base_encoding");
|
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_cEncoding = rb_define_class("Encoding", rb_cObject);
|
||||||
rb_undef_alloc_func(rb_cEncoding);
|
rb_undef_alloc_func(rb_cEncoding);
|
||||||
rb_define_method(rb_cEncoding, "to_s", enc_name, 0);
|
rb_define_method(rb_cEncoding, "to_s", enc_name, 0);
|
||||||
|
|
Loading…
Reference in a new issue