MCPcopy Create free account
hub / github.com/apache/nuttx / parse_args

Function parse_args

tools/mkdeps.c:383–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381#endif
382
383static void parse_args(int argc, char **argv)
384{
385 char *args = NULL;
386 int argidx;
387 int group = 0;
388
389 /* Always look in the current directory */
390
391 g_altpath = strdup(".");
392
393 /* Ensure dep target obj path has a default value */
394
395 g_objpath = strdup(".");
396
397 /* Accumulate CFLAGS up to "--" */
398
399 for (argidx = 1; argidx < argc; argidx++)
400 {
401 if (strcmp(argv[argidx], "--") == 0)
402 {
403 g_cc = g_cflags;
404 g_cflags = args;
405 args = NULL;
406 group++;
407 }
408 else if (strcmp(argv[argidx], "--dep-debug") == 0)
409 {
410 g_debug++;
411 }
412 else if (strcmp(argv[argidx], "--dep-path") == 0)
413 {
414 argidx++;
415 if (argidx >= argc)
416 {
417 show_usage(argv[0], "ERROR: Missing argument to --dep-path",
418 EXIT_FAILURE);
419 }
420
421 if (args)
422 {
423 append(&args, argv[argidx]);
424 }
425 else
426 {
427 append(&g_altpath, argv[argidx]);
428 }
429 }
430 else if (strcmp(argv[argidx], "--obj-path") == 0)
431 {
432 argidx++;
433 if (argidx >= argc)
434 {
435 show_usage(argv[0], "ERROR: Missing argument to --obj-path",
436 EXIT_FAILURE);
437 }
438
439 g_objpath = argv[argidx];
440 }

Callers 1

mainFunction · 0.70

Calls 5

strdupFunction · 0.85
do_shquoteFunction · 0.85
show_usageFunction · 0.70
appendFunction · 0.70
strcmpFunction · 0.50

Tested by

no test coverage detected