8000 merges r25526,r25527,r25528,r25529,r25530 and r25555 from trunk into … · documenting-ruby/ruby@a2339bc · GitHub
[go: up one dir, main page]

Skip to content

Commit a2339bc

Browse files
committed
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
1 parent 4de39cd commit a2339bc

File tree

6 files changed

+77
-14
lines changed

6 files changed

+77
-14
lines changed

ChangeLog

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
Thu Oct 29 04:41:44 2009 NARUSE, Yui <naruse@ruby-lang.org>
2+
3+
* ruby.c (process_options): call rb_filesystem_encoding().
4+
5+
Wed Oct 28 16:32:49 2009 NARUSE, Yui <naruse@ruby-lang.org>
6+
7+
* encoding.c (get_filesystem_encoding): removed.
8+
9+
* encoding.c (rb_locale_encindex): added.
10+
11+
* encoding.c (rb_filesystem_encindex): added.
12+
13+
* encoding.c (rb_filesystem_encindex): add an alias 'filesystem'.
14+
[ruby-dev:39574]
15+
16+
* encoding.c (enc_find): add rdoc about special aliases.
17+
18+
* gem_prelude.rb (Gem.set_home): use Encoding.find('filesystem').
19+
20+
* gem_prelude.rb (Gem.set_paths): ditto.
21+
22+
Wed Oct 28 15:02:31 2009 NARUSE, Yui <naruse@ruby-lang.org>
23+
24+
* gem_prelude.rb (Gem.set_home):
25+
force_encoding(Encoding.filesystem_encoding)
26+
[ruby-core:25959]
27+
28+
* gem_prelude.rb (Gem.set_paths): ditto.
29+
30+
Wed Oct 28 14:24:45 2009 NARUSE, Yui <naruse@ruby-lang.org>
31+
32+
* encoding.c (get_filesystem_encoding):
33+
add Encoding.filesystem_encoding [ruby-dev:39546]
34+
also see [ruby-core:25959]
35+
136
Tue Oct 27 15:44:48 2009 Shugo Maeda <shugo@ruby-lang.org>
237

338
* lib/net/ftp.rb (getbinaryfile, list): call to_s to convert

encoding.c

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -921,9 +921,18 @@ enc_list(VALUE klass)
921921
* Encoding.find("US-ASCII") => #<Encoding:US-ASCII>
922922
* Encoding.find(:Shift_JIS) => #<Encoding:Shift_JIS>
923923
*
924+
* Names which this method accept are encoding names and aliases
925+
* including following special aliases
926+
*
927+
* "external":: default external encoding
928+
* "internal":: default internal encoding
929+
* "locale":: locale encoding
930+
* "filesystem":: filesystem encoding
931+
*
924932
* An ArgumentError is raised when no encoding with <i>name</i>.
925-
* Only +Encoding.find("internal")+ however returns nil when no encoding named "internal",
926-
* in other words, when Ruby has no default internal encoding.
933+
* Only <code>Encoding.find("internal")</code> however returns nil
934+
* when no encoding named "internal", in other words, when Ruby has no
935+
* default internal encoding.
927936
*/
928937
static VALUE
929938
enc_find(VALUE klass, VALUE enc)
@@ -1021,8 +1030,8 @@ rb_usascii_encindex(void)
10211030
return ENCINDEX_US_ASCII;
10221031
}
10231032

1024-
rb_encoding *
1025-
rb_locale_encoding(void)
1033+
static int
1034+
rb_locale_encindex(void)
10261035
{
10271036
VALUE charmap = rb_locale_charmap(rb_cEncoding);
10281037
int idx;
@@ -1034,25 +1043,40 @@ rb_locale_encoding(void)
10341043

10351044
if (rb_enc_registered("locale") < 0) enc_alias_internal("locale", idx);
10361045

1037-
return rb_enc_from_index(idx);
1046+
return idx;
10381047
}
10391048

10401049
rb_encoding *
1041-
rb_filesystem_encoding(void)
1050+
rb_locale_encoding(void)
10421051
{
1043-
rb_encoding *enc;
1052+
return rb_enc_from_index(rb_locale_encindex());
1053+
}
1054+
1055+
static int
1056+
rb_filesystem_encindex(void)
1057+
{
1058+
int idx;
10441059
#if defined NO_LOCALE_CHARMAP
1045-
enc = rb_default_external_encoding();
1060+
idx = rb_enc_to_index(rb_default_external_encoding());
10461061
#elif defined _WIN32 || defined __CYGWIN__
10471062
char cp[sizeof(int) * 8 / 3 + 4];
10481063
snprintf(cp, sizeof cp, "CP%d", AreFileApisANSI() ? GetACP() : GetOEMCP());
1049-
enc = rb_enc_find(cp);
1064+
idx = rb_enc_find_index(cp);
10501065
#elif defined __APPLE__
1051-
enc = rb_enc_find("UTF8-MAC");
1066+
idx = rb_enc_to_index(rb_enc_find("UTF8-MAC"));
10521067
#else
1053-
enc = rb_default_external_encoding();
1068+
idx = rb_enc_to_index(rb_default_external_encoding());
10541069
#endif
1055-
return enc;
1070+
1071+
if (rb_enc_registered("filesystem") < 0) enc_alias_internal("filesystem", idx);
1072+
1073+
return idx;
1074+
}
1075+
1076+
rb_encoding *
1077+
rb_filesystem_encoding(void)
1078+
{
1079+
return rb_enc_from_index(rb_filesystem_encindex());
10561080
}
10571081

10581082
struct default_encoding {

gem_prelude.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def self.pre_uninstall(&hook)
6666
end
6767

6868
def self.set_home(home)
69-
@gem_home = home
69+
@gem_home = home.force_encoding(Encoding.find('filesystem'))
7070
ensure_gem_subdirectories(@gem_home)
7171
end
7272

@@ -78,6 +78,7 @@ def self.set_paths(gpaths)
7878
@gem_path = [Gem.dir]
7979
end
8080
@gem_path.uniq!
81+
@gem_path.map!{|x|x.force_encoding(Encoding.find('filesystem'))}
8182
@gem_path.each do |gp| ensure_gem_subdirectories(gp) end
8283
end
8384

ruby.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,7 @@ process_options(VALUE arg)
12781278
ruby_init_loadpath_safe(opt->safe_level);
12791279
rb_enc_find_index("encdb");
12801280
lenc = rb_locale_encoding();
1281+
(void)rb_filesystem_encoding();
12811282
rb_enc_associate(rb_progname, lenc);
12821283
parser = rb_parser_new();
12831284
if (opt->yydebug) rb_parser_set_yydebug(parser, Qtrue);

test/ruby/test_encoding.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def test_singleton
3737

3838
def test_find
3939
assert_raise(ArgumentError) { Encoding.find("foobarbazqux") }
40+
assert_nothing_raised{Encoding.find("locale")}
41+
assert_nothing_raised{Encoding.find("filesystem")}
4042
end
4143

4244
def test_dummy_p

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define RUBY_VERSION "1.9.1"
2-
#define RUBY_PATCHLEVEL 415
2+
#define RUBY_PATCHLEVEL 416
33
#define RUBY_VERSION_MAJOR 1
44
#define RUBY_VERSION_MINOR 9
55
#define RUBY_VERSION_TEENY 1

0 commit comments

Comments
 (0)
0