[前][次][番号順一覧][スレッド一覧]

ruby-changes:14661

From: yugui <ko1@a...>
Date: Sat, 30 Jan 2010 22:22:30 +0900 (JST)
Subject: [ruby-changes:14661] Ruby:r26510 (ruby_1_9_1): merges r25526,r25527,r25528,r25529,r25530 and r25555 from trunk into ruby_1_9_1.

yugui	2010-01-30 21:54:15 +0900 (Sat, 30 Jan 2010)

  New Revision: 26510

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26510

  Log:
    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().

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/encoding.c
    branches/ruby_1_9_1/gem_prelude.rb
    branches/ruby_1_9_1/ruby.c
    branches/ruby_1_9_1/test/ruby/test_encoding.rb
    branches/ruby_1_9_1/version.h

Index: ruby_1_9_1/encoding.c
===================================================================
--- ruby_1_9_1/encoding.c	(revision 26509)
+++ ruby_1_9_1/encoding.c	(revision 26510)
@@ -921,9 +921,18 @@
  *   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 @@
     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,27 +1043,42 @@
 
     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 {
     int index;			/* -2 => not yet set, -1 => nil */
     rb_encoding *enc;
Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 26509)
+++ ruby_1_9_1/ChangeLog	(revision 26510)
@@ -1,3 +1,38 @@
+Thu Oct 29 04:41:44 2009  NARUSE, Yui  <naruse@r...>
+
+	* ruby.c (process_options): call rb_filesystem_encoding().
+
+Wed Oct 28 16:32:49 2009  NARUSE, Yui  <naruse@r...>
+
+	* 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@r...>
+
+	* 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@r...>
+
+	* 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@r...>
 
 	* lib/net/ftp.rb (getbinaryfile, list): call to_s to convert
Index: ruby_1_9_1/gem_prelude.rb
===================================================================
--- ruby_1_9_1/gem_prelude.rb	(revision 26509)
+++ ruby_1_9_1/gem_prelude.rb	(revision 26510)
@@ -66,7 +66,7 @@
     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 @@
         @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
 
Index: ruby_1_9_1/version.h
===================================================================
--- ruby_1_9_1/version.h	(revision 26509)
+++ ruby_1_9_1/version.h	(revision 26510)
@@ -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
Index: ruby_1_9_1/ruby.c
===================================================================
--- ruby_1_9_1/ruby.c	(revision 26509)
+++ ruby_1_9_1/ruby.c	(revision 26510)
@@ -1278,6 +1278,7 @@
     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);
Index: ruby_1_9_1/test/ruby/test_encoding.rb
===================================================================
--- ruby_1_9_1/test/ruby/test_encoding.rb	(revision 26509)
+++ ruby_1_9_1/test/ruby/test_encoding.rb	(revision 26510)
@@ -37,6 +37,8 @@
 
   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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]