Skip to content

Instantly share code, notes, and snippets.

@emasaka
Created October 29, 2011 12:24
Show Gist options
  • Select an option

  • Save emasaka/1324383 to your computer and use it in GitHub Desktop.

Select an option

Save emasaka/1324383 to your computer and use it in GitHub Desktop.
diff -up ruby-1.9.2-p290/ruby.c filter-ruby-1.9.2-p290/ruby.c
--- ruby-1.9.2-p290/ruby.c 2010-12-23 19:49:13.000000000 +0900
+++ filter-ruby-1.9.2-p290/ruby.c 2011-10-28 21:50:44.452623054 +0900
@@ -1618,7 +1618,16 @@ load_file_internal(VALUE arg)
return (VALUE)rb_parser_compile_string(parser, fname, f, line_start);
}
rb_funcall(f, set_encoding, 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-"));
- tree = rb_parser_compile_file(parser, fname, f, line_start);
+ {
+ VALUE source_filter = rb_intern("source_filter");
+ if (rb_obj_respond_to(rb_cObject, source_filter, 1)) {
+ VALUE s1 = rb_funcall(f, rb_intern("read"), 0);
+ VALUE s2 = rb_funcall(rb_mKernel, source_filter, 1, s1);
+ tree = rb_parser_compile_string(parser, fname, s2, line_start);
+ } else {
+ tree = rb_parser_compile_file(parser, fname, f, line_start);
+ }
+ }
rb_funcall(f, set_encoding, 1, rb_parser_encoding(parser));
if (script && tree && rb_parser_end_seen_p(parser)) {
rb_define_global_const("DATA", f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment