summaryrefslogtreecommitdiffstats
path: root/encoding.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-04 00:50:59 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-04 00:50:59 +0000
commit6050298ffd0c9e8b7fe3c483bcf825d56a22d96a (patch)
treedc22ba0d8d5d8f40e161cbb68f297bc6a50427a3 /encoding.c
parent9315bc11674a764db4f54c56c3ac5155d4edd1a3 (diff)
downloadruby-6050298ffd0c9e8b7fe3c483bcf825d56a22d96a.tar.gz
ruby-6050298ffd0c9e8b7fe3c483bcf825d56a22d96a.tar.xz
ruby-6050298ffd0c9e8b7fe3c483bcf825d56a22d96a.zip
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: http://svn.ruby-lang.org/repos/ruby/trunk@24383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/encoding.c b/encoding.c
index 5e54ce721..49326b662 100644
--- a/encoding.c
+++ b/encoding.c
@@ -275,6 +275,18 @@ set_base_encoding(int index, rb_encoding *base)
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
rb_enc_replicate(const char *name, rb_encoding *encoding)
{