aboutsummaryrefslogtreecommitdiffstats
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
commit6dbe235a605c0c2f9a28aafb033ae7e983c82678 (patch)
tree19943a60bbfa40973f77ed9fb571b520a5bba552 /launcher.c
parent2dd7ed9ccf64f5136c0e6fc8f9bd8216fde53cf2 (diff)
downloadexternal_python_setuptools-6dbe235a605c0c2f9a28aafb033ae7e983c82678.tar.gz
external_python_setuptools-6dbe235a605c0c2f9a28aafb033ae7e983c82678.tar.bz2
external_python_setuptools-6dbe235a605c0c2f9a28aafb033ae7e983c82678.zip
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) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4053548
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*/