mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* parse.y (parser_initialize): set default encoding. [ruby-dev:31787]
* ruby.c (load_file): make new parse instance after processing shebang line options. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
26adfc185f
commit
fd7e89ddc2
3 changed files with 18 additions and 8 deletions
|
@ -1,3 +1,10 @@
|
|||
Sat Sep 15 17:32:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (parser_initialize): set default encoding. [ruby-dev:31787]
|
||||
|
||||
* ruby.c (load_file): make new parse instance after processing shebang
|
||||
line options.
|
||||
|
||||
Sat Sep 15 17:04:08 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* encoding.c (rb_enc_associate_index, rb_enc_get_index): check if
|
||||
|
|
2
parse.y
2
parse.y
|
@ -8686,7 +8686,7 @@ parser_initialize(struct parser_params *parser)
|
|||
#ifdef YYMALLOC
|
||||
parser->heap = NULL;
|
||||
#endif
|
||||
parser->enc = rb_enc_from_index(0);
|
||||
parser->enc = onigenc_get_default_encoding();
|
||||
}
|
||||
|
||||
extern void rb_mark_source_filename(char *);
|
||||
|
|
17
ruby.c
17
ruby.c
|
@ -64,7 +64,7 @@ extern int ruby_yydebug;
|
|||
|
||||
char *ruby_inplace_mode = 0;
|
||||
|
||||
static NODE *load_file(VALUE, const char *, int);
|
||||
static NODE *load_file(VALUE *, const char *, int);
|
||||
static void forbid_setid(const char *);
|
||||
|
||||
static VALUE do_loop = Qfalse, do_print = Qfalse;
|
||||
|
@ -880,16 +880,16 @@ proc_options(int argc, char **argv)
|
|||
process_sflag();
|
||||
|
||||
ruby_init_loadpath();
|
||||
parser = rb_parser_new();
|
||||
if (e_script) {
|
||||
require_libraries();
|
||||
parser = rb_parser_new();
|
||||
tree = rb_parser_compile_string(parser, script, e_script, 1);
|
||||
}
|
||||
else {
|
||||
if (script[0] == '-' && !script[1]) {
|
||||
forbid_setid("program input from stdin");
|
||||
}
|
||||
tree = load_file(parser, script, 1);
|
||||
tree = load_file(&parser, script, 1);
|
||||
}
|
||||
|
||||
process_sflag();
|
||||
|
@ -911,7 +911,7 @@ proc_options(int argc, char **argv)
|
|||
}
|
||||
|
||||
static NODE *
|
||||
load_file(VALUE parser, const char *fname, int script)
|
||||
load_file(VALUE *parser, const char *fname, int script)
|
||||
{
|
||||
extern VALUE rb_stdin;
|
||||
VALUE f;
|
||||
|
@ -1027,8 +1027,9 @@ load_file(VALUE parser, const char *fname, int script)
|
|||
}
|
||||
require_libraries(); /* Why here? unnatural */
|
||||
}
|
||||
tree = (NODE *)rb_parser_compile_file(parser, fname, f, line_start);
|
||||
if (script && rb_parser_end_seen_p(parser)) {
|
||||
*parser = rb_parser_new();
|
||||
tree = (NODE *)rb_parser_compile_file(*parser, fname, f, line_start);
|
||||
if (script && rb_parser_end_seen_p(*parser)) {
|
||||
rb_define_global_const("DATA", f);
|
||||
}
|
||||
else if (f != rb_stdin) {
|
||||
|
@ -1040,7 +1041,9 @@ load_file(VALUE parser, const char *fname, int script)
|
|||
void *
|
||||
rb_load_file(const char *fname)
|
||||
{
|
||||
return load_file(rb_parser_new(), fname, 0);
|
||||
VALUE parser;
|
||||
|
||||
return load_file(&parser, fname, 0);
|
||||
}
|
||||
|
||||
VALUE rb_progname;
|
||||
|
|
Loading…
Reference in a new issue