зеркало из https://github.com/github/ruby.git
* iseq.c (rb_iseq_compile_with_option): Instead of testing
respond_to, just check if the argument is actually a file, because by calling user-defined gets something weired can happen. Patch by Glass_saga. [ruby-dev:40202] [Bug #2861] * parse.y (ripper_initialize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
197e7b812c
Коммит
d090f17f21
|
@ -1,3 +1,12 @@
|
||||||
|
Sat Oct 27 10:12:13 2012 URABE Shyouhei <shyouhei@ruby-lang.org>
|
||||||
|
|
||||||
|
* iseq.c (rb_iseq_compile_with_option): Instead of testing
|
||||||
|
respond_to, just check if the argument is actually a file,
|
||||||
|
because by calling user-defined gets something weired can
|
||||||
|
happen. Patch by Glass_saga. [ruby-dev:40202] [Bug #2861]
|
||||||
|
|
||||||
|
* parse.y (ripper_initialize): ditto.
|
||||||
|
|
||||||
Sat Oct 27 10:07:57 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Oct 27 10:07:57 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* parse.y (enum lex_state_e): [EXPERIMENTAL] lex_state as bit field /
|
* parse.y (enum lex_state_e): [EXPERIMENTAL] lex_state as bit field /
|
||||||
|
|
7
iseq.c
7
iseq.c
|
@ -590,11 +590,16 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE absolute_path, VALUE li
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
int ln = NUM2INT(line);
|
int ln = NUM2INT(line);
|
||||||
const char *fn = StringValueCStr(file);
|
const char *fn = StringValueCStr(file);
|
||||||
NODE *node = parse_string(StringValue(src), fn, ln);
|
NODE *node;
|
||||||
rb_compile_option_t option;
|
rb_compile_option_t option;
|
||||||
|
|
||||||
make_compile_option(&option, opt);
|
make_compile_option(&option, opt);
|
||||||
|
|
||||||
|
if (RB_TYPE_P((src), T_FILE))
|
||||||
|
node = rb_compile_file(fn, src, ln);
|
||||||
|
else
|
||||||
|
node = parse_string(StringValue(src), fn, ln);
|
||||||
|
|
||||||
if (base_block && base_block->iseq) {
|
if (base_block && base_block->iseq) {
|
||||||
iseqval = rb_iseq_new_with_opt(node, base_block->iseq->location.label,
|
iseqval = rb_iseq_new_with_opt(node, base_block->iseq->location.label,
|
||||||
file, absolute_path, line, base_block->iseq->self,
|
file, absolute_path, line, base_block->iseq->self,
|
||||||
|
|
6
parse.y
6
parse.y
|
@ -541,7 +541,6 @@ static int lvar_defined_gen(struct parser_params*, ID);
|
||||||
|
|
||||||
#include "eventids1.c"
|
#include "eventids1.c"
|
||||||
#include "eventids2.c"
|
#include "eventids2.c"
|
||||||
static ID ripper_id_gets;
|
|
||||||
|
|
||||||
static VALUE ripper_dispatch0(struct parser_params*,ID);
|
static VALUE ripper_dispatch0(struct parser_params*,ID);
|
||||||
static VALUE ripper_dispatch1(struct parser_params*,ID,VALUE);
|
static VALUE ripper_dispatch1(struct parser_params*,ID,VALUE);
|
||||||
|
@ -11083,7 +11082,7 @@ ripper_warningS(struct parser_params *parser, const char *fmt, const char *str)
|
||||||
static VALUE
|
static VALUE
|
||||||
ripper_lex_get_generic(struct parser_params *parser, VALUE src)
|
ripper_lex_get_generic(struct parser_params *parser, VALUE src)
|
||||||
{
|
{
|
||||||
return rb_funcall(src, ripper_id_gets, 0);
|
return rb_io_gets(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -11119,7 +11118,7 @@ ripper_initialize(int argc, VALUE *argv, VALUE self)
|
||||||
|
|
||||||
TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
|
TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
|
||||||
rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
|
rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
|
||||||
if (rb_obj_respond_to(src, ripper_id_gets, 0)) {
|
if (RB_TYPE_P(src, T_FILE)) {
|
||||||
parser->parser_lex_gets = ripper_lex_get_generic;
|
parser->parser_lex_gets = ripper_lex_get_generic;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -11283,7 +11282,6 @@ Init_ripper(void)
|
||||||
{
|
{
|
||||||
parser_data_type.parent = RTYPEDDATA_TYPE(rb_parser_new());
|
parser_data_type.parent = RTYPEDDATA_TYPE(rb_parser_new());
|
||||||
|
|
||||||
ripper_id_gets = rb_intern("gets");
|
|
||||||
ripper_init_eventids1();
|
ripper_init_eventids1();
|
||||||
ripper_init_eventids2();
|
ripper_init_eventids2();
|
||||||
/* ensure existing in symbol table */
|
/* ensure existing in symbol table */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче