MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / setargv

Function setargv

SRC/tcl/winMain.cpp:343–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341 * Memory allocated.
342 *
343 *--------------------------------------------------------------------------
344 */
345
346static void
347setargv(int *argcPtr, char ***argvPtr)
348{
349 char *cmdLine, *p, *arg, *argSpace;
350 char **argv;
351 int argc, size, inquote, copy, slashes;
352
353 cmdLine = GetCommandLine(); /* INTL: BUG */
354
355 /*
356 * Precompute an overly pessimistic guess at the number of arguments
357 * in the command line by counting non-space spans.
358 */
359
360 size = 2;
361 for (p = cmdLine; *p != '\0'; p++) {
362 if ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
363 size++;
364 while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
365 p++;
366 }
367 if (*p == '\0') {
368 break;
369 }
370 }
371 }
372 argSpace = (char *) Tcl_Alloc(
373 (unsigned) (size * sizeof(char *) + strlen(cmdLine) + 1));
374 argv = (char **) argSpace;
375 argSpace += size * sizeof(char *);
376 size--;
377
378 p = cmdLine;
379 for (argc = 0; argc < size; argc++) {
380 argv[argc] = arg = argSpace;
381 while ((*p == ' ') || (*p == '\t')) { /* INTL: ISO space. */
382 p++;
383 }
384 if (*p == '\0') {
385 break;
386 }
387
388 inquote = 0;
389 slashes = 0;
390 while (1) {
391 copy = 1;
392 while (*p == '\\') {
393 slashes++;
394 p++;
395 }
396 if (*p == '"') {
397 if ((slashes & 1) == 0) {
398 copy = 0;
399 if ((inquote) && (p[1] == '"')) {
400 p++;

Callers 1

WinMainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected