summaryrefslogtreecommitdiff
path: root/launcher.c
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2007-01-24 21:00:55 +0000
committerPJ Eby <distutils-sig@python.org>2007-01-24 21:00:55 +0000
commit7636744224d5c47326379eaac30b9eedef1ba98a (patch)
tree19943a60bbfa40973f77ed9fb571b520a5bba552 /launcher.c
parentf39b602c6b0b5e91fea5e38dddf171a889fc3b24 (diff)
downloadpython-setuptools-bitbucket-7636744224d5c47326379eaac30b9eedef1ba98a.tar.gz
Fix ``#!`` parsing problems in Windows ``.exe`` script wrappers, when there
was whitespace inside a quoted argument or at the end of the ``#!`` line (backport from trunk)
Diffstat (limited to 'launcher.c')
-rwxr-xr-xlauncher.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/launcher.c b/launcher.c
index b1da7725..09e2bafb 100755
--- a/launcher.c
+++ b/launcher.c
@@ -129,6 +129,7 @@ char **parse_argv(char *cmdline, int *argc)
char *output = cmdline;
char c;
int nb = 0;
+ int iq = 0;
*argc = 0;
result[0] = output;
@@ -136,19 +137,20 @@ char **parse_argv(char *cmdline, int *argc)
do {
c = *cmdline++;
- if (!c || isspace(c)) {
+ if (!c || (isspace(c) && !iq)) {
while (nb) {*output++ = '\\'; nb--; }
*output++ = 0;
result[++*argc] = output;
if (!c) return result;
while (isspace(*cmdline)) cmdline++; /* skip leading spaces */
+ if (!*cmdline) return result; /* avoid empty arg if trailing ws */
continue;
}
if (c == '\\')
++nb; /* count \'s */
else {
if (c == '"') {
- if (!(nb & 1)) c = 0; /* skip " unless odd # of \ */
+ if (!(nb & 1)) { iq = !iq; c = 0; } /* skip " unless odd # of \ */
nb = nb >> 1; /* cut \'s in half */
}
while (nb) {*output++ = '\\'; nb--; }
@@ -160,8 +162,6 @@ char **parse_argv(char *cmdline, int *argc)
-
-
int run(int argc, char **argv, int is_gui) {
char python[256]; /* python executable's filename*/