* encoding.c (enc_get_default_encoding): removed.
Generalizing rb_default_{external,internal}_encoding seems to be difficult. default_external cannot be NULL even before detected. [ruby-dev:37390] * encoding.c (rb_default_external_encoding): has its own implementation again. * encoding.c (rb_default_internal_encoding): ditto. * gem_prelude.rb: added notice. * ruby.c (rubylib_mangled_path, rubylib_mangled_path2): uses locale encoding but not ASCII-8BIT. * ruby.c (process_options): refers less to default_external. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d7f67b4970
commit
aa06e69000
19
ChangeLog
19
ChangeLog
@ -1,3 +1,22 @@
|
|||||||
|
Fri Dec 12 14:09:55 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||||
|
|
||||||
|
* encoding.c (enc_get_default_encoding): removed.
|
||||||
|
Generalizing rb_default_{external,internal}_encoding seems to be
|
||||||
|
difficult.
|
||||||
|
default_external cannot be NULL even before detected. [ruby-dev:37390]
|
||||||
|
|
||||||
|
* encoding.c (rb_default_external_encoding): has its own
|
||||||
|
implementation again.
|
||||||
|
|
||||||
|
* encoding.c (rb_default_internal_encoding): ditto.
|
||||||
|
|
||||||
|
* gem_prelude.rb: added notice.
|
||||||
|
|
||||||
|
* ruby.c (rubylib_mangled_path, rubylib_mangled_path2): uses locale
|
||||||
|
encoding but not ASCII-8BIT.
|
||||||
|
|
||||||
|
* ruby.c (process_options): refers less to default_external.
|
||||||
|
|
||||||
Fri Dec 12 11:00:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Dec 12 11:00:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* load.c (rb_feature_p): load path must be expanded.
|
* load.c (rb_feature_p): load path must be expanded.
|
||||||
|
24
encoding.c
24
encoding.c
@ -1037,15 +1037,6 @@ struct default_encoding {
|
|||||||
rb_encoding *enc;
|
rb_encoding *enc;
|
||||||
};
|
};
|
||||||
|
|
||||||
static rb_encoding *
|
|
||||||
enc_get_default_encoding(struct default_encoding *def)
|
|
||||||
{
|
|
||||||
if (!def->enc && def->index >= 0) {
|
|
||||||
def->enc = rb_enc_from_index(def->index);
|
|
||||||
}
|
|
||||||
return def->enc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
enc_set_default_encoding(struct default_encoding *def, VALUE encoding,
|
enc_set_default_encoding(struct default_encoding *def, VALUE encoding,
|
||||||
const char *name, int defindex)
|
const char *name, int defindex)
|
||||||
@ -1077,7 +1068,15 @@ static struct default_encoding default_external = {-2};
|
|||||||
rb_encoding *
|
rb_encoding *
|
||||||
rb_default_external_encoding(void)
|
rb_default_external_encoding(void)
|
||||||
{
|
{
|
||||||
return enc_get_default_encoding(&default_external);
|
if (default_external.enc) return default_external.enc;
|
||||||
|
|
||||||
|
if (default_external.index >= 0) {
|
||||||
|
default_external.enc = rb_enc_from_index(default_external.index);
|
||||||
|
return default_external.enc;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return rb_locale_encoding();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -1126,7 +1125,10 @@ static struct default_encoding default_internal = {-2};
|
|||||||
rb_encoding *
|
rb_encoding *
|
||||||
rb_default_internal_encoding(void)
|
rb_default_internal_encoding(void)
|
||||||
{
|
{
|
||||||
return enc_get_default_encoding(&default_internal);
|
if (!default_internal.enc && default_internal.index >= 0) {
|
||||||
|
default_internal.enc = rb_enc_from_index(default_internal.index);
|
||||||
|
}
|
||||||
|
return default_internal.enc; /* can be NULL */
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
# vim: filetype=ruby
|
# vim: filetype=ruby
|
||||||
# THIS FILE WAS AUTOGENERATED, DO NOT EDIT
|
# THIS FILE WAS AUTOGENERATED, DO NOT EDIT
|
||||||
|
|
||||||
|
# NOTICE: Ruby is during initialization here.
|
||||||
|
# * Encoding.default_external does not reflects -E.
|
||||||
|
# * Should not expect Encoding.default_internal.
|
||||||
|
# * Locale encoding is available.
|
||||||
if defined?(Gem) then
|
if defined?(Gem) then
|
||||||
|
|
||||||
module Kernel
|
module Kernel
|
||||||
|
12
ruby.c
12
ruby.c
@ -213,9 +213,9 @@ rubylib_mangled_path(const char *s, unsigned int l)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!newp || l < oldl || STRNCASECMP(oldp, s, oldl) != 0) {
|
if (!newp || l < oldl || STRNCASECMP(oldp, s, oldl) != 0) {
|
||||||
return rb_str_new(s, l);
|
return rb_locale_str_new(s, l);
|
||||||
}
|
}
|
||||||
ret = rb_str_new(0, l + newl - oldl);
|
ret = rb_locale_str_new(0, l + newl - oldl);
|
||||||
ptr = RSTRING_PTR(ret);
|
ptr = RSTRING_PTR(ret);
|
||||||
memcpy(ptr, newp, newl);
|
memcpy(ptr, newp, newl);
|
||||||
memcpy(ptr + newl, s + oldl, l - oldl);
|
memcpy(ptr + newl, s + oldl, l - oldl);
|
||||||
@ -229,8 +229,8 @@ rubylib_mangled_path2(const char *s)
|
|||||||
return rubylib_mangled_path(s, strlen(s));
|
return rubylib_mangled_path(s, strlen(s));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define rubylib_mangled_path rb_str_new
|
#define rubylib_mangled_path rb_locale_str_new
|
||||||
#define rubylib_mangled_path2 rb_str_new2
|
#define rubylib_mangled_path2 rb_locale_str_new_cstr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1178,7 +1178,7 @@ process_options(VALUE arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ruby_script(opt->script);
|
rb_progname = rb_obj_freeze(rb_str_new_cstr(opt->script));
|
||||||
#if defined DOSISH || defined __CYGWIN__
|
#if defined DOSISH || defined __CYGWIN__
|
||||||
translate_char(RSTRING_PTR(rb_progname), '\\', '/');
|
translate_char(RSTRING_PTR(rb_progname), '\\', '/');
|
||||||
#endif
|
#endif
|
||||||
@ -1670,7 +1670,7 @@ ruby_process_options(int argc, char **argv)
|
|||||||
struct cmdline_options opt;
|
struct cmdline_options opt;
|
||||||
NODE *tree;
|
NODE *tree;
|
||||||
|
|
||||||
ruby_script(argv[0]); /* for the time being */
|
ruby_script(argv[0]); /* for the time being */
|
||||||
rb_argv0 = rb_str_new4(rb_progname);
|
rb_argv0 = rb_str_new4(rb_progname);
|
||||||
rb_gc_register_mark_object(rb_argv0);
|
rb_gc_register_mark_object(rb_argv0);
|
||||||
args.argc = argc;
|
args.argc = argc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user