aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-25 18:49:28 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-25 18:49:28 +0000
commit2160c40fb2ef40e8a7ad593239fac3558e2639f1 (patch)
tree83f32a2e5213b0fc5e9217b137c1a0bbfef44725
parent13b5b22ae63cb35adc7e73f8f3d248a6ffd46ad1 (diff)
downloadruby-2160c40fb2ef40e8a7ad593239fac3558e2639f1.tar.gz
* parse.y (parser_initialize): set default script encoding as US-ASCII.
* ruby.c (load_file): ditto. * ruby.c (process_options): set script encoding of -e from locale except when -K is specified. * ruby.c (load_file): set script encoding of stdin from locale except when -K is specified. [ruby-dev:33375] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog12
-rw-r--r--parse.y2
-rw-r--r--ruby.c31
3 files changed, 20 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index b5d8aa1524..6b1711f675 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Sat Jan 26 03:41:53 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * parse.y (parser_initialize): set default script encoding as US-ASCII.
+
+ * ruby.c (load_file): ditto.
+
+ * ruby.c (process_options): set script encoding of -e from locale
+ except when -K is specified.
+
+ * ruby.c (load_file): set script encoding of stdin from locale except
+ when -K is specified. [ruby-dev:33375]
+
Sat Jan 26 02:51:06 2008 Koichi Sasada <ko1@atdot.net>
* compile.c, compile.h: fix stack pointer issues.
diff --git a/parse.y b/parse.y
index 140e320fea..b6dbcd7c2b 100644
--- a/parse.y
+++ b/parse.y
@@ -9222,7 +9222,7 @@ parser_initialize(struct parser_params *parser)
#ifdef YYMALLOC
parser->heap = NULL;
#endif
- parser->enc = rb_ascii8bit_encoding();
+ parser->enc = rb_usascii_encoding();
}
extern void rb_mark_source_filename(char *);
diff --git a/ruby.c b/ruby.c
index 2de86c9170..1467fdfb23 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1008,33 +1008,21 @@ process_options(VALUE arg)
enc = rb_enc_from_index(opt->ext.enc.index);
}
else {
- enc = 0;
+ enc = rb_locale_encoding();
}
if (opt->e_script) {
- rb_encoding *eenc = rb_locale_encoding();
- if (!enc) {
- enc = eenc;
- }
- else if (!rb_enc_asciicompat(enc)) {
- rb_warning("%s is not ASCII compatible, ignored for -e",
- rb_enc_name(enc));
- }
- else if (eenc != enc &&
- (rb_enc_str_coderange(opt->e_script) != ENC_CODERANGE_7BIT)) {
- rb_warning("-e conatains non ASCII string, encoding %s is not used",
- rb_enc_name(enc));
+ rb_encoding *eenc;
+ if (opt->src.enc.index >= 0) {
+ eenc = rb_enc_from_index(opt->src.enc.index);
}
else {
- eenc = enc;
+ eenc = rb_locale_encoding();
}
rb_enc_associate(opt->e_script, eenc);
require_libraries();
tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1);
}
else {
- if (!enc) {
- enc = rb_locale_encoding();
- }
if (opt->script[0] == '-' && !opt->script[1]) {
forbid_setid("program input from stdin");
}
@@ -1199,15 +1187,10 @@ load_file(VALUE parser, const char *fname, int script, struct cmdline_options *o
enc = rb_enc_from_index(opt->src.enc.index);
}
else if (f == rb_stdin) {
- if (opt->ext.enc.index >= 0) {
- enc = rb_enc_from_index(opt->ext.enc.index);
- }
- else {
- enc = rb_locale_encoding();
- }
+ enc = rb_locale_encoding();
}
else {
- enc = rb_ascii8bit_encoding();
+ enc = rb_usascii_encoding();
}
rb_funcall(f, rb_intern("set_encoding"), 1, rb_enc_from_encoding(enc));
tree = (NODE *)rb_parser_compile_file(parser, fname, f, line_start);