Skip to content

Instantly share code, notes, and snippets.

@emasaka
Created January 15, 2011 11:11
Show Gist options
  • Select an option

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

Select an option

Save emasaka/780846 to your computer and use it in GitHub Desktop.
--- ruby-1.9.2-p136/ruby.c 2010-12-23 19:49:13.000000000 +0900
+++ ruby-1.9.2-p136.filter/ruby.c 2011-01-15 19:18:26.878913570 +0900
@@ -1618,7 +1618,16 @@
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_respond_to(rb_mKernel, source_filter)) {
+ 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