aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-04-21 19:59:50 +0100
committerRon Yorston <rmy@pobox.com>2012-04-21 19:59:50 +0100
commit073257d2d34097e4ace7daa5882b090c07d528cc (patch)
treecc065bc385ec0ca70167037c60b10bbef6c72370
parent728bb21b191ebf577498589f7162e71b8df5ea65 (diff)
downloadbusybox-w32-073257d2d34097e4ace7daa5882b090c07d528cc.tar.gz
busybox-w32-073257d2d34097e4ace7daa5882b090c07d528cc.tar.bz2
busybox-w32-073257d2d34097e4ace7daa5882b090c07d528cc.zip
Some fixes to #! parsing
-rw-r--r--win32/process.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/win32/process.c b/win32/process.c
index 7c94da6e3..b95e173e1 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -35,8 +35,8 @@ next_path_sep(const char *path)
35static const char * 35static const char *
36parse_interpreter(const char *cmd, char ***opts, int *nopts) 36parse_interpreter(const char *cmd, char ***opts, int *nopts)
37{ 37{
38 static char buf[100]; 38 static char buf[100], *opt[MAX_OPT];
39 char *p, *s, *t, *opt[MAX_OPT]; 39 char *p, *s, *t;
40 int n, fd; 40 int n, fd;
41 41
42 *nopts = 0; 42 *nopts = 0;
@@ -70,11 +70,8 @@ parse_interpreter(const char *cmd, char ***opts, int *nopts)
70 *p = '\0'; 70 *p = '\0';
71 } 71 }
72 72
73 if (!(p = strrchr(buf+2, '/')) && !(p = strrchr(buf+2, '\\'))) 73 /* move to end of interpreter path (which may not contain spaces) */
74 return NULL; 74 for ( s=buf+2; *s && !isspace(*s); ++s ) {
75
76 /* move to end of interpreter name */
77 for ( s=p; *s && !isspace(*s); ++s ) {
78 } 75 }
79 76
80 n = 0; 77 n = 0;
@@ -88,6 +85,10 @@ parse_interpreter(const char *cmd, char ***opts, int *nopts)
88 } 85 }
89 } 86 }
90 87
88 /* find interpreter name */
89 if (!(p = strrchr(buf+2, '/')))
90 return NULL;
91
91 *nopts = n; 92 *nopts = n;
92 *opts = opt; 93 *opts = opt;
93 94