From 58740ef8816557481c752889392b4ee148fe94aa Mon Sep 17 00:00:00 2001 From: yugui Date: Fri, 12 Dec 2008 10:35:39 +0000 Subject: [PATCH] * encoding.c (rb_enc_set_default_external): default_internal can be nil, but default_external cannot. * encoding.c (rb_set_default_internal): adds rdoc. * encoding.c (enc_find): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ encoding.c | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3725f09b57..197a4f8020 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Dec 12 19:29:07 2008 Yuki Sonoda (Yugui) + + * encoding.c (rb_enc_set_default_external): default_internal can be + nil, but default_external cannot. + + * encoding.c (rb_set_default_internal): adds rdoc. + + * encoding.c (enc_find): ditto. + Fri Dec 12 19:24:47 2008 Yuki Sonoda (Yugui) * common.mk (run, runruby, parse, gdb, gdb-ruby): you can also run diff --git a/encoding.c b/encoding.c index 910768d56a..f802850f3b 100644 --- a/encoding.c +++ b/encoding.c @@ -905,6 +905,9 @@ enc_list(VALUE klass) * Encoding.find("US-ASCII") => # * Encoding.find(:Shift_JIS) => # * + * An ArgumentError is raised when no encoding with name. + * Only +Encoding.find("internal")+ however returns nil when no encoding named "internal", + * in other words, when Ruby has no default internal encoding. */ static VALUE enc_find(VALUE klass, VALUE enc) @@ -1102,6 +1105,9 @@ get_default_external(VALUE klass) void rb_enc_set_default_external(VALUE encoding) { + if (NIL_P(encoding)) { + rb_raise(rb_eArgError, "default external can not be nil"); + } enc_set_default_encoding(&default_external, encoding, "external", ENCINDEX_US_ASCII); } @@ -1161,9 +1167,10 @@ rb_enc_set_default_internal(VALUE encoding) /* * call-seq: - * Encoding.default_internal = enc + * Encoding.default_internal = enc or nil * * Sets default internal encoding. + * Or removes default internal encoding when passed nil. */ static VALUE set_default_internal(VALUE klass, VALUE encoding)