* 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
This commit is contained in:
nobu 2005-05-14 02:48:07 +00:00
parent 2cf330ad77
commit 434e8a3796
4 changed files with 209 additions and 14 deletions

16
ruby.c
View file

@ -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);