summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormkaply%us.ibm.com <devnull@localhost>2002-07-17 05:51:07 +0000
committermkaply%us.ibm.com <devnull@localhost>2002-07-17 05:51:07 +0000
commit54a4974b42d720e6fa8b6e3f890c151cd7399722 (patch)
tree1a48cd3d403305722215bc1dc532b0fbc2884dcf
parentbc14a71fa1e4dca6fdeed0dba5abc5898ea30d75 (diff)
downloadnspr-hg-54a4974b42d720e6fa8b6e3f890c151cd7399722.tar.gz
#157347
r=wtc, sr=blizzard, a=chofmann OS/2 only - don't try to escape quotation marks when using DosStartSession
-rw-r--r--pr/src/md/os2/os2misc.c75
1 files changed, 9 insertions, 66 deletions
diff --git a/pr/src/md/os2/os2misc.c b/pr/src/md/os2/os2misc.c
index 7acaa830..c27b0614 100644
--- a/pr/src/md/os2/os2misc.c
+++ b/pr/src/md/os2/os2misc.c
@@ -118,85 +118,28 @@ PR_Now(void)
static int assembleCmdLine(char *const *argv, char **cmdLine)
{
char *const *arg;
- char *p, *q;
int cmdLineSize;
- int numBackslashes;
- int i;
/*
* Find out how large the command line buffer should be.
*/
cmdLineSize = 0;
for (arg = argv+1; *arg; arg++) {
- /*
- * \ and " need to be escaped by a \. In the worst case,
- * every character is a \ or ", so the string of length
- * may double. If we quote an argument, that needs two ".
- * Finally, we need a space between arguments, a null between
- * the EXE name and the arguments, and 2 nulls at the end
- * of command line.
- */
- cmdLineSize += 2 * strlen(*arg) /* \ and " need to be escaped */
- + 4; /* space in between, or final nulls */
- }
- p = *cmdLine = PR_MALLOC(cmdLineSize);
- if (p == NULL) {
+ cmdLineSize += strlen(*arg) + 1; /* space in between, or final null */
+ }
+ *cmdLine = PR_MALLOC(cmdLineSize);
+ if (*cmdLine == NULL) {
return -1;
}
- for (arg = argv+1; *arg; arg++) {
- /* Add a space to separates the arguments */
- if (arg > argv + 1) {
- *p++ = ' ';
- }
- q = *arg;
- numBackslashes = 0;
-
- while (*q) {
- if (*q == '\\') {
- numBackslashes++;
- q++;
- } else if (*q == '"') {
- if (numBackslashes) {
- /*
- * Double the backslashes since they are followed
- * by a quote
- */
- for (i = 0; i < 2 * numBackslashes; i++) {
- *p++ = '\\';
- }
- numBackslashes = 0;
- }
- /* To escape the quote */
- *p++ = '\\';
- *p++ = *q++;
- } else {
- if (numBackslashes) {
- /*
- * Backslashes are not followed by a quote, so
- * don't need to double the backslashes.
- */
- for (i = 0; i < numBackslashes; i++) {
- *p++ = '\\';
- }
- numBackslashes = 0;
- }
- *p++ = *q++;
- }
- }
+ (*cmdLine)[0] = '\0';
- /* Now we are at the end of this argument */
- if (numBackslashes) {
- for (i = 0; i < numBackslashes; i++) {
- *p++ = '\\';
- }
+ for (arg = argv+1; *arg; arg++) {
+ if (arg > argv +1) {
+ strcat(*cmdLine, " ");
}
- if(arg == argv)
- *p++ = ' ';
+ strcat(*cmdLine, *arg);
}
-
- /* Add a null at the end */
- *p = '\0';
return 0;
}