summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-09-27 05:12:09 +0000
committerChristopher Faylor <me@cgf.cx>2000-09-27 05:12:09 +0000
commite564846577d119c0684ccd3afa8d0103f22160e6 (patch)
tree6b990beb20010ab2de2893d5e4073f284f3afc3a
parent03de9775c4a0b867ee6095f462fad959213a0ea7 (diff)
downloadcygnal-e564846577d119c0684ccd3afa8d0103f22160e6.tar.gz
cygnal-e564846577d119c0684ccd3afa8d0103f22160e6.tar.bz2
cygnal-e564846577d119c0684ccd3afa8d0103f22160e6.zip
* spawn.cc (spawn_guts): Attempt to accomodate archaic windows quoting
mechanism when dealing with '\' and '"'.
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/cygheap.cc10
-rw-r--r--winsup/cygwin/cygheap.h9
-rw-r--r--winsup/cygwin/spawn.cc18
4 files changed, 31 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index cc99e87b4..1fc2354f9 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+Wed Sep 27 01:10:07 2000 Christopher Faylor <cgf@cygnus.com>
+
+ * spawn.cc (spawn_guts): Attempt to accomodate archaic windows quoting
+ mechanism when dealing with '\' and '"'.
+
Mon Sep 25 20:47:04 2000 Christopher Faylor <cgf@cygnus.com>
* dcrt0.cc (quoted): Fix problem where ' quoted strings were skipped.
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index d8e13331b..132b230c2 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -235,3 +235,13 @@ cstrdup (const char *s)
strcpy (p, s);
return p;
}
+
+extern "C" char *__stdcall
+cstrdup1 (const char *s)
+{
+ char *p = (char *) cmalloc (HEAP_1_STR, strlen (s) + 1);
+ if (!p)
+ return NULL;
+ strcpy (p, s);
+ return p;
+}
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 6eaeee240..47493ce48 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -15,8 +15,12 @@ enum cygheap_types
HEAP_FHANDLER,
HEAP_STR,
HEAP_ARGV,
- HEAP_EXEC,
- HEAP_BUF
+ HEAP_BUF,
+ HEAP_1_START,
+ HEAP_1_STR,
+ HEAP_1_ARGV,
+ HEAP_1_BUF,
+ HEAP_1_EXEC
};
#define CYGHEAPSIZE ((1000 * sizeof (fhandler_union)) + (2 * 65536))
@@ -34,4 +38,5 @@ void *__stdcall cmalloc (cygheap_types, DWORD);
void *__stdcall crealloc (void *, DWORD);
void *__stdcall ccalloc (cygheap_types, DWORD, DWORD);
char *__stdcall cstrdup (const char *);
+char *__stdcall cstrdup1 (const char *);
}
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 09a1b8cef..a1646e970 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -252,7 +252,7 @@ public:
int argc;
av (int ac, const char * const *av) : calloced (0), argc (ac)
{
- argv = (char **) cmalloc (HEAP_ARGV, (argc + 1) * sizeof (char *));
+ argv = (char **) cmalloc (HEAP_1_ARGV, (argc + 1) * sizeof (char *));
memcpy (argv, av, (argc + 1) * sizeof (char *));
}
~av ()
@@ -269,19 +269,19 @@ public:
/* Note: Assumes that argv array has not yet been "unshifted" */
if (!calloced)
{
- argv[0] = cstrdup (arg0);
+ argv[0] = cstrdup1 (arg0);
calloced = 1;
}
}
void dup_maybe (int i)
{
if (i >= calloced)
- argv[i] = cstrdup (argv[i]);
+ argv[i] = cstrdup1 (argv[i]);
}
void dup_all ()
{
for (int i = calloced; i < argc; i++)
- argv[i] = cstrdup (argv[i]);
+ argv[i] = cstrdup1 (argv[i]);
}
};
@@ -304,7 +304,7 @@ av::unshift (const char *what, int conv)
*p = '\0';
what = buf;
}
- *argv = cstrdup (what);
+ *argv = cstrdup1 (what);
argc++;
calloced++;
return 1;
@@ -367,7 +367,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
return -1;
}
- ciresrv.moreinfo = (cygheap_exec_info *) ccalloc (HEAP_EXEC, 1, sizeof (cygheap_exec_info));
+ ciresrv.moreinfo = (cygheap_exec_info *) ccalloc (HEAP_1_EXEC, 1, sizeof (cygheap_exec_info));
ciresrv.moreinfo->old_title = old_title ? cstrdup (old_title) : NULL;
ciresrv.moreinfo->fds = fdtab;
ciresrv.moreinfo->nfds = fdtab.size;
@@ -506,7 +506,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
for (; (p = strpbrk (a, "\"\\")); a = ++p)
{
one_line.add (a, p - a);
- if (*p == '\\' || *p == '"')
+ if ((*p == '\\' && p[1] == '"') || *p == '"')
one_line.add ("\\", 1);
one_line.add (p, 1);
}
@@ -534,11 +534,11 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
cygcwd.copy (ciresrv.moreinfo->cwd_posix, ciresrv.moreinfo->cwd_win32,
ciresrv.moreinfo->cwd_hash);
- ciresrv.moreinfo->environ = (char **) cmalloc (HEAP_ARGV, envsize (envp, 1));
+ ciresrv.moreinfo->environ = (char **) cmalloc (HEAP_1_ARGV, envsize (envp, 1));
char **c;
const char * const *e;
for (c = ciresrv.moreinfo->environ, e = envp; *e;)
- *c++ = cstrdup (*e++);
+ *c++ = cstrdup1 (*e++);
*c = NULL;
if (mode != _P_OVERLAY ||
!DuplicateHandle (hMainProc, myself.shared_handle (), hMainProc, &ciresrv.moreinfo->myself_pinfo, 0,