summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-30 12:54:15 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-30 12:54:15 +0000
commita2339bc02147505ae459293c9fece5ae17b5f285 (patch)
tree3f653f580e0222000c44f24f76112a67252968bc
parent4de39cd34edf69376af707071f0a6fbeed90e091 (diff)
merges r25526,r25527,r25528,r25529,r25530 and r25555 from trunk into ruby_1_9_1.
-- * encoding.c (get_filesystem_encoding): add Encoding.filesystem_encoding [ruby-dev:39546] also see [ruby-core:25959] -- * gem_prelude.rb (Gem.set_home): force_encoding(Encoding.filesystem_encoding) [ruby-dev:39546] * gem_prelude.rb (Gem.set_paths): ditto. -- Previous commit is for [ruby-core:25959] -- * encoding.c (get_filesystem_encoding): removed. * encoding.c (rb_locale_encindex): added. * encoding.c (rb_filesystem_encindex): added. * encoding.c (rb_filesystem_encindex): add an alias 'filesystem'. [ruby-dev:39574] * encoding.c (enc_find): add rdoc about special aliases. * gem_prelude.rb (Gem.set_home): use Encoding.find('filesystem'). * gem_prelude.rb (Gem.set_paths): ditto. -- * encoding.c (enc_find): fixed rdoc formatting. -- * ruby.c (process_options): call rb_filesystem_encoding(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@26510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog35
-rw-r--r--encoding.c48
-rw-r--r--gem_prelude.rb3
-rw-r--r--ruby.c1
-rw-r--r--test/ruby/test_encoding.rb2
-rw-r--r--version.h2
6 files changed, 77 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index c192df9f54..3244299b93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+Thu Oct 29 04:41:44 2009 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ruby.c (process_options): call rb_filesystem_encoding().
+
+Wed Oct 28 16:32:49 2009 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * encoding.c (get_filesystem_encoding): removed.
+
+ * encoding.c (rb_locale_encindex): added.
+
+ * encoding.c (rb_filesystem_encindex): added.
+
+ * encoding.c (rb_filesystem_encindex): add an alias 'filesystem'.
+ [ruby-dev:39574]
+
+ * encoding.c (enc_find): add rdoc about special aliases.
+
+ * gem_prelude.rb (Gem.set_home): use Encoding.find('filesystem').
+
+ * gem_prelude.rb (Gem.set_paths): ditto.
+
+Wed Oct 28 15:02:31 2009 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * gem_prelude.rb (Gem.set_home):
+ force_encoding(Encoding.filesystem_encoding)
+ [ruby-core:25959]
+
+ * gem_prelude.rb (Gem.set_paths): ditto.
+
+Wed Oct 28 14:24:45 2009 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * encoding.c (get_filesystem_encoding):
+ add Encoding.filesystem_encoding [ruby-dev:39546]
+ also see [ruby-core:25959]
+
Tue Oct 27 15:44:48 2009 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/ftp.rb (getbinaryfile, list): call to_s to convert
diff --git a/encoding.c b/encoding.c
index bc960c26a7..104d472eb6 100644
--- a/encoding.c
+++ b/encoding.c
@@ -921,9 +921,18 @@ enc_list(VALUE klass)
* Encoding.find("US-ASCII") => #<Encoding:US-ASCII>
* Encoding.find(:Shift_JIS) => #<Encoding:Shift_JIS>
*
+ * Names which this method accept are encoding names and aliases
+ * including following special aliases
+ *
+ * "external":: default external encoding
+ * "internal":: default internal encoding
+ * "locale":: locale encoding
+ * "filesystem":: filesystem encoding
+ *
* An ArgumentError is raised when no encoding with <i>name</i>.
- * Only +Encoding.find("internal")+ however returns nil when no encoding named "internal",
- * in other words, when Ruby has no default internal encoding.
+ * Only <code>Encoding.find("internal")</code> 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)
@@ -1021,8 +1030,8 @@ rb_usascii_encindex(void)
return ENCINDEX_US_ASCII;
}
-rb_encoding *
-rb_locale_encoding(void)
+static int
+rb_locale_encindex(void)
{
VALUE charmap = rb_locale_charmap(rb_cEncoding);
int idx;
@@ -1034,25 +1043,40 @@ rb_locale_encoding(void)
if (rb_enc_registered("locale") < 0) enc_alias_internal("locale", idx);
- return rb_enc_from_index(idx);
+ return idx;
}
rb_encoding *
-rb_filesystem_encoding(void)
+rb_locale_encoding(void)
{
- rb_encoding *enc;
+ return rb_enc_from_index(rb_locale_encindex());
+}
+
+static int
+rb_filesystem_encindex(void)
+{
+ int idx;
#if defined NO_LOCALE_CHARMAP
- enc = rb_default_external_encoding();
+ idx = rb_enc_to_index(rb_default_external_encoding());
#elif defined _WIN32 || defined __CYGWIN__
char cp[sizeof(int) * 8 / 3 + 4];
snprintf(cp, sizeof cp, "CP%d", AreFileApisANSI() ? GetACP() : GetOEMCP());
- enc = rb_enc_find(cp);
+ idx = rb_enc_find_index(cp);
#elif defined __APPLE__
- enc = rb_enc_find("UTF8-MAC");
+ idx = rb_enc_to_index(rb_enc_find("UTF8-MAC"));
#else
- enc = rb_default_external_encoding();
+ idx = rb_enc_to_index(rb_default_external_encoding());
#endif
- return enc;
+
+ if (rb_enc_registered("filesystem") < 0) enc_alias_internal("filesystem", idx);
+
+ return idx;
+}
+
+rb_encoding *
+rb_filesystem_encoding(void)
+{
+ return rb_enc_from_index(rb_filesystem_encindex());
}
struct default_encoding {
diff --git a/gem_prelude.rb b/gem_prelude.rb
index b5da35e186..1562d23a30 100644
--- a/gem_prelude.rb
+++ b/gem_prelude.rb
@@ -66,7 +66,7 @@ if defined?(Gem) then
end
def self.set_home(home)
- @gem_home = home
+ @gem_home = home.force_encoding(Encoding.find('filesystem'))
ensure_gem_subdirectories(@gem_home)
end
@@ -78,6 +78,7 @@ if defined?(Gem) then
@gem_path = [Gem.dir]
end
@gem_path.uniq!
+ @gem_path.map!{|x|x.force_encoding(Encoding.find('filesystem'))}
@gem_path.each do |gp| ensure_gem_subdirectories(gp) end
end
diff --git a/ruby.c b/ruby.c
index b50ee45079..2612fac7b4 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1278,6 +1278,7 @@ process_options(VALUE arg)
ruby_init_loadpath_safe(opt->safe_level);
rb_enc_find_index("encdb");
lenc = rb_locale_encoding();
+ (void)rb_filesystem_encoding();
rb_enc_associate(rb_progname, lenc);
parser = rb_parser_new();
if (opt->yydebug) rb_parser_set_yydebug(parser, Qtrue);
diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb
index 9f48d30d1d..132c3e23f3 100644
--- a/test/ruby/test_encoding.rb
+++ b/test/ruby/test_encoding.rb
@@ -37,6 +37,8 @@ class TestEncoding < Test::Unit::TestCase
def test_find
assert_raise(ArgumentError) { Encoding.find("foobarbazqux") }
+ assert_nothing_raised{Encoding.find("locale")}
+ assert_nothing_raised{Encoding.find("filesystem")}
end
def test_dummy_p
diff --git a/version.h b/version.h
index 160c160d62..1475584929 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.1"
-#define RUBY_PATCHLEVEL 415
+#define RUBY_PATCHLEVEL 416
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1