Skip to content

Commit

Permalink
fixed ripper parsing
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@3904 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
lrz committed Apr 4, 2010
1 parent d300a9e commit 2585f28
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions parse.y
Expand Up @@ -9924,18 +9924,29 @@ ripper_initialize(VALUE self, SEL sel, int argc, VALUE *argv)

Data_Get_Struct(self, struct parser_params, parser);
rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
#if 0 // TODO
if (rb_obj_respond_to(src, ripper_id_gets, 0)) {
parser->parser_lex_gets = ripper_lex_get_generic;
}
else
#endif
{
StringValue(src);
parser->parser_lex_gets = lex_get_str;

UChar *chars = NULL;
long chars_len = 0;
bool need_free = false;
rb_str_get_uchars(src, &chars, &chars_len, &need_free);

if (need_free) {
UChar *tmp = (UChar *)xmalloc(sizeof(UChar) * chars_len);
memcpy(tmp, chars, sizeof(UChar) * chars_len);
free(chars);
chars = tmp;
}
GC_WB(&parser->parser_lex_input, src);

struct lex_get_str_context *ctx = (struct lex_get_str_context *)
xmalloc(sizeof(struct lex_get_str_context));
GC_WB(&ctx->str, src);
ctx->chars = chars;
ctx->chars_len = chars_len;

parser->parser_lex_gets = lex_get_str;
GC_WB(&parser->parser_lex_input, ctx);
parser->eofp = Qfalse;

if (NIL_P(fname)) {
fname = STR_NEW2("(ripper)");
}
Expand Down

0 comments on commit 2585f28

Please sign in to comment.