Add functions and macros for second encoding definitions.
* encoding.c (rb_enc_set_base): Add for setting base encoding with their names. this is internal function. * template/encdb.h.tmpl: specify ENC_SET_BASE for second encodings in each encoding files. * enc/encdb.c (rb_enc_set_base): add a declaration. (ENC_SET_BASE): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e00b83ceb9
commit
b3d7273dc1
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Tue Aug 4 09:33:54 2009 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* encoding.c (rb_enc_set_base): Add for setting base encoding
|
||||||
|
with their names. this is internal function.
|
||||||
|
|
||||||
|
* template/encdb.h.tmpl: specify ENC_SET_BASE for second encodings in
|
||||||
|
each encoding files.
|
||||||
|
|
||||||
|
* enc/encdb.c (rb_enc_set_base): add a declaration.
|
||||||
|
(ENC_SET_BASE): ditto.
|
||||||
|
|
||||||
Tue Aug 4 06:30:01 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue Aug 4 06:30:01 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* hash.c (rb_hash_replace): should copy compare_by_identity status as well.
|
* hash.c (rb_hash_replace): should copy compare_by_identity status as well.
|
||||||
|
@ -13,10 +13,12 @@ int rb_encdb_replicate(const char *alias, const char *orig);
|
|||||||
int rb_encdb_alias(const char *alias, const char *orig);
|
int rb_encdb_alias(const char *alias, const char *orig);
|
||||||
int rb_encdb_dummy(const char *name);
|
int rb_encdb_dummy(const char *name);
|
||||||
void rb_encdb_declare(const char *name);
|
void rb_encdb_declare(const char *name);
|
||||||
|
void rb_enc_set_base(const char *name, const char *orig);
|
||||||
#define ENC_REPLICATE(name, orig) rb_encdb_replicate(name, orig)
|
#define ENC_REPLICATE(name, orig) rb_encdb_replicate(name, orig)
|
||||||
#define ENC_ALIAS(name, orig) rb_encdb_alias(name, orig)
|
#define ENC_ALIAS(name, orig) rb_encdb_alias(name, orig)
|
||||||
#define ENC_DUMMY(name) rb_encdb_dummy(name)
|
#define ENC_DUMMY(name) rb_encdb_dummy(name)
|
||||||
#define ENC_DEFINE(name) rb_encdb_declare(name)
|
#define ENC_DEFINE(name) rb_encdb_declare(name)
|
||||||
|
#define ENC_SET_BASE(name) rb_enc_set_base(name)
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_encdb(void)
|
Init_encdb(void)
|
||||||
|
12
encoding.c
12
encoding.c
@ -275,6 +275,18 @@ set_base_encoding(int index, rb_encoding *base)
|
|||||||
return enc;
|
return enc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* for encdb.h
|
||||||
|
* Set base encoding for encodings which are not replicas
|
||||||
|
* but not in their own files.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
rb_enc_set_base(const char *name, const char *orig)
|
||||||
|
{
|
||||||
|
int idx = rb_enc_registered(name);
|
||||||
|
int origidx = rb_enc_registered(orig);
|
||||||
|
set_base_encoding(idx, rb_enc_from_index(origidx));
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rb_enc_replicate(const char *name, rb_encoding *encoding)
|
rb_enc_replicate(const char *name, rb_encoding *encoding)
|
||||||
{
|
{
|
||||||
|
@ -34,11 +34,15 @@ encdirs.each do |encdir|
|
|||||||
next if files[fn]
|
next if files[fn]
|
||||||
files[fn] = true
|
files[fn] = true
|
||||||
open(File.join(encdir,fn)) do |f|
|
open(File.join(encdir,fn)) do |f|
|
||||||
orig = nil
|
|
||||||
name = nil
|
name = nil
|
||||||
f.each_line do |line|
|
f.each_line do |line|
|
||||||
if (/^OnigEncodingDefine/ =~ line)..(/"(.*?)"/ =~ line)
|
if (/^OnigEncodingDefine/ =~ line)..(/"(.*?)"/ =~ line)
|
||||||
if $1
|
if $1
|
||||||
|
if name
|
||||||
|
lines << %[ENC_SET_BASE("#$1", "#{name}");]
|
||||||
|
else
|
||||||
|
name = $1
|
||||||
|
end
|
||||||
check_duplication(defs, $1, fn, $.)
|
check_duplication(defs, $1, fn, $.)
|
||||||
encodings << $1
|
encodings << $1
|
||||||
count += 1
|
count += 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user