- Timestamp:
- Oct 26, 2014, 5:18:37 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/src/kNIX/os2/__spawnve.c
r3904 r3930 523 523 524 524 /* 525 * Squeeze the interpreter arguments + the program name into 526 * the argument buffer after argv[0]. 527 * ASSUME that the arguments and program name require no escaping. 528 */ 525 * The original argv0 is replaced by the "program name". 526 * The interpreter and its optional arguments are then inserted in front of that. 527 * 528 * ASSUMES that the arguments and program name require no escaping. 529 * ASSUMES that enmMethod != args_unix, which is true at the time of writing. 530 */ 531 size_t offOldArg1 = strlen(pszArgsBuf) + 1; 529 532 size_t cchPgmName = strlen(pszPgmName); 530 int cchInterpreterArgs = pszInterpreterArgs ? strlen(pszInterpreterArgs) : -1;533 size_t cchInterpreter = strlen(pszInterpreter); 531 534 BOOL fQuote = strpbrk(pszPgmName, " \t") != NULL; 532 cch = cchPgmName + cchInterpreterArgs + 2 + 2 * fQuote; 533 534 /* grow and shift the argument buffer. */ 535 int cchInterpreterArgs = pszInterpreterArgs ? strlen(pszInterpreterArgs) : -1; 536 cch = cchInterpreter + 1 + cchInterpreterArgs + 1 + cchPgmName + 2 * fQuote + 1 - offOldArg1; 537 538 /* Grow and shift the argument buffer. */ 535 539 size_t cbToMove = cbArgs; /* (ADD modifies cbArgs) */ 536 540 ADD(cch); 537 psz = pszArgsBuf + strlen(pszArgsBuf) + 1; 538 memmove(psz + cch, psz, cbToMove); 539 540 /* add arguments */ 541 memmove(pszArgsBuf + cch + offOldArg1, pszArgsBuf + offOldArg1, cbToMove - offOldArg1); 542 543 /* New argv[0] = Interpreter name. */ 544 psz = pszArgsBuf; 545 memcpy(psz, pszInterpreter, cchInterpreter); 546 psz += cchInterpreter; 547 *psz++ = '\0'; 548 549 /* Add arguments after that (if present). */ 541 550 if (pszInterpreterArgs) 542 551 { … … 546 555 } 547 556 548 /* script name*/557 /* Finally add the script name (previous szNativePath actually). */ 549 558 if (fQuote) 550 559 *psz++ = '"'; … … 579 588 /* 580 589 * Try execute it. 590 * Note! pszPgmName = &szNativePath[0], so we're good here and if this loops. 581 591 */ 582 592 LIBCLOG_MSG("Calling DosExecPgm pgm: %s args: %s\\0%s\\0\\0\n", pszPgmName, pszArgsBuf, pszArgsBuf + strlen(pszArgsBuf) + 1);
Note:
See TracChangeset
for help on using the changeset viewer.