summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2002-07-17 01:45:57 +0000
committerwtc%netscape.com <devnull@localhost>2002-07-17 01:45:57 +0000
commitb7ae86fc3e84fb110ecf4fafb23ad8e16b5855bd (patch)
tree8e9e91183bd526d11e9dc9f9ceef78acf59e4d07
parent9b1463427443ea0832e5bbf4e5cb0a706700913d (diff)
downloadnspr-hg-b7ae86fc3e84fb110ecf4fafb23ad8e16b5855bd.tar.gz
Bug 157347: deleted the code that tried to escape the quotes around
command-line arguments. The patch was contributed by Michael Kaply <mkaply@us.ibm.com>. r=wtc.
-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;
}