summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-14 02:48:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-14 02:48:07 +0000
commit434e8a379656337f97cff9108c5a4b5b7c220fed (patch)
tree837e95dcfe4bdbf5cd36c93bbe67568d53b8383a /ruby.c
parent2cf330ad771450f9285cb0f0c88d6a1dc17a64d2 (diff)
downloadruby-434e8a379656337f97cff9108c5a4b5b7c220fed.tar.gz
* intern.h (ruby_pragma): prototype. [ruby-core:04881]
* parse.y (parser_pragma): parse Emacsen hack. * parse.y (parser_prepare): deal with specific syntax at the top. * ruby.c (load_file): read the first line iff it started with shebang. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/ruby.c b/ruby.c
index dd2a3612a2..736f585f27 100644
--- a/ruby.c
+++ b/ruby.c
@@ -917,11 +917,11 @@ load_file(fname, script)
c = rb_io_getc(f);
if (c == INT2FIX('#')) {
- line = rb_io_gets(f);
- if (NIL_P(line)) return;
- line_start++;
+ c = rb_io_getc(f);
+ if (c == INT2FIX('!')) {
+ line = rb_io_gets(f);
+ if (NIL_P(line)) return;
- if (RSTRING(line)->len > 2 && RSTRING(line)->ptr[0] == '!') {
if ((p = strstr(RSTRING(line)->ptr, "ruby")) == 0) {
/* not ruby script, kick the program */
char **argv;
@@ -965,7 +965,15 @@ load_file(fname, script)
p = moreswitches(p+1);
}
}
+
+ /* push back shebang for pragma may exist in next line */
+ rb_io_ungetc(f, INT2FIX('\n'));
+ rb_io_ungetc(f, INT2FIX('!'));
+ }
+ else if (!NIL_P(c)) {
+ rb_io_ungetc(f, c);
}
+ rb_io_ungetc(f, INT2FIX('#'));
}
else if (!NIL_P(c)) {
rb_io_ungetc(f, c);