Changeset 3930
- Timestamp:
- Oct 26, 2014, 5:18:37 AM (11 years ago)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/libc-0.6/src/emx/src/lib/sys/__spawnve.c
r3903 r3930 509 509 510 510 /* 511 * Squeeze the interpreter arguments + the program name into 512 * the argument buffer after argv[0]. 513 * ASSUME that the arguments and program name require no escaping. 514 */ 515 size_t cchPgmName = strlen(pszPgmName); 516 int cchInterpreterArgs = pszInterpreterArgs ? strlen(pszInterpreterArgs) : -1; 517 BOOL fQuote = strpbrk(pszPgmName, " \t") != NULL; 518 cch = cchPgmName + cchInterpreterArgs + 2 + 2 * fQuote; 519 520 /* grow and shift the argument buffer. */ 511 * The original argv0 is replaced by the "program name". 512 * The interpreter and its optional arguments are then inserted in front of that. 513 * 514 * ASSUMES that the arguments and program name require no escaping. 515 * ASSUMES that enmMethod != args_unix, which is true at the time of writing. 516 */ 517 size_t offOldArg1 = strlen(pszArgsBuf) + 1; 518 size_t cchPgmName = strlen(pszPgmName); 519 size_t cchInterpreter = strlen(pszInterpreter); 520 BOOL fQuote = strpbrk(pszPgmName, " \t") != NULL; 521 int cchInterpreterArgs = pszInterpreterArgs ? strlen(pszInterpreterArgs) : -1; 522 cch = cchInterpreter + 1 + cchInterpreterArgs + 1 + cchPgmName + 2*fQuote + 1 - offOldArg1; 523 524 /* Grow and shift the argument buffer. */ 521 525 size_t cbToMove = cbArgs; /* (ADD modifies cbArgs) */ 522 526 ADD(cch); 523 psz = pszArgsBuf + strlen(pszArgsBuf) + 1; 524 memmove(psz + cch, psz, cbToMove); 525 526 /* add arguments */ 527 memmove(pszArgsBuf + cch + offOldArg1, pszArgsBuf + offOldArg1, cbToMove - offOldArg1); 528 529 /* New argv[0] = Interpreter name. */ 530 psz = pszArgsBuf; 531 memcpy(psz, pszInterpreter, cchInterpreter); 532 psz += cchInterpreter; 533 *psz++ = '\0'; 534 535 /* Add arguments after that (if present). */ 527 536 if (pszInterpreterArgs) 528 537 { … … 532 541 } 533 542 534 /* script name*/543 /* Finally add the script name (previous szNativePath actually). */ 535 544 if (fQuote) 536 545 *psz++ = '"'; … … 565 574 /* 566 575 * Try execute it. 576 * Note! pszPgmName = &szNativePath[0], so we're good here and if this loops. 567 577 */ 568 578 LIBCLOG_MSG("Calling DosExecPgm pgm: %s args: %s\\0%s\\0\\0\n", pszPgmName, pszArgsBuf, pszArgsBuf + strlen(pszArgsBuf) + 1); -
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.