From 073257d2d34097e4ace7daa5882b090c07d528cc Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sat, 21 Apr 2012 19:59:50 +0100 Subject: Some fixes to #! parsing --- win32/process.c | 15 ++++++++------- 1 file 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) static const char * parse_interpreter(const char *cmd, char ***opts, int *nopts) { - static char buf[100]; - char *p, *s, *t, *opt[MAX_OPT]; + static char buf[100], *opt[MAX_OPT]; + char *p, *s, *t; int n, fd; *nopts = 0; @@ -70,11 +70,8 @@ parse_interpreter(const char *cmd, char ***opts, int *nopts) *p = '\0'; } - if (!(p = strrchr(buf+2, '/')) && !(p = strrchr(buf+2, '\\'))) - return NULL; - - /* move to end of interpreter name */ - for ( s=p; *s && !isspace(*s); ++s ) { + /* move to end of interpreter path (which may not contain spaces) */ + for ( s=buf+2; *s && !isspace(*s); ++s ) { } n = 0; @@ -88,6 +85,10 @@ parse_interpreter(const char *cmd, char ***opts, int *nopts) } } + /* find interpreter name */ + if (!(p = strrchr(buf+2, '/'))) + return NULL; + *nopts = n; *opts = opt; -- cgit v1.2.3-55-g6feb