summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-03-11 07:33:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-03-11 07:33:08 +0000
commit58649234258a476f7cd69db41f89405e117d4b32 (patch)
tree99136677122b7d904432408099b9d008ea8cfb6a /ruby.c
parente8fea3f8dda47198a78d8957a07e8b304664e0a1 (diff)
gets speed up patch
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/ruby.c b/ruby.c
index 7c94820..965027d 100644
--- a/ruby.c
+++ b/ruby.c
@@ -422,6 +422,7 @@ proc_options(argcp, argvp)
else {
rb_gvar_set2(argv[0], TRUE);
}
+ argv[0][0] = '-';
}
*argcp = argc; *argvp = argv;
}
@@ -448,6 +449,7 @@ load_file(fname, script)
VALUE c;
VALUE line;
VALUE rs = RS;
+ char *p;
RS = RS_default;
if (xflag) {
@@ -458,7 +460,7 @@ load_file(fname, script)
if (RSTRING(line)->len > 2
&& RSTRING(line)->ptr[0] == '#'
&& RSTRING(line)->ptr[1] == '!') {
- if (strstr(RSTRING(line)->ptr, "ruby")) {
+ if (p = strstr(RSTRING(line)->ptr, "ruby")) {
goto start_read;
}
}
@@ -475,8 +477,6 @@ load_file(fname, script)
if (RSTRING(line)->len > 2
&& RSTRING(line)->ptr[0] == '!') {
- char *p;
-
if ((p = strstr(RSTRING(line)->ptr, "ruby")) == 0) {
/* not ruby script, kick the program */
char **argv;
@@ -509,19 +509,25 @@ load_file(fname, script)
}
start_read:
- if (p = strstr(RSTRING(line)->ptr, "ruby -")) {
+ p += 4;
+ RSTRING(line)->ptr[RSTRING(line)->len-1] = '\0';
+ if (RSTRING(line)->ptr[RSTRING(line)->len-2] == '\r')
+ RSTRING(line)->ptr[RSTRING(line)->len-2] = '\0';
+ if (p = strstr(p, " -")) {
int argc; char *argv[2]; char **argvp = argv;
- UCHAR *s;
-
- s = RSTRING(line)->ptr;
- while (isspace(*s))
- s++;
- *s = '\0';
- RSTRING(line)->ptr[RSTRING(line)->len-1] = '\0';
- if (RSTRING(line)->ptr[RSTRING(line)->len-2] == '\r')
- RSTRING(line)->ptr[RSTRING(line)->len-2] = '\0';
- argc = 2; argv[0] = 0; argv[1] = p + 5;
- proc_options(&argc, &argvp);
+ UCHAR *s = ++p;
+
+ argc = 2; argv[0] = 0;
+ while (*p == '-') {
+ while (*s && !isspace(*s))
+ s++;
+ *s = '\0';
+ argv[1] = p;
+ proc_options(&argc, &argvp);
+ p = ++s;
+ while (*p && isspace(*p))
+ p++;
+ }
}
}
}