MCPcopy Create free account
hub / github.com/crawl/crawl / parse_args

Function parse_args

crawl-ref/source/initfile.cc:5661–6243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5659}
5660
5661bool parse_args(int argc, char **argv, bool rc_only)
5662{
5663 COMPILE_CHECK(ARRAYSZ(cmd_ops) == CLO_NOPS);
5664
5665#ifndef DEBUG_STATISTICS
5666 const char *dbg_stat_err = "mapstat and objstat are available only in "
5667 "DEBUG_STATISTICS builds.\n";
5668#endif
5669
5670 if (crawl_state.command_line_arguments.empty())
5671 {
5672 crawl_state.command_line_arguments.insert(
5673 crawl_state.command_line_arguments.end(),
5674 argv, argv + argc);
5675 }
5676
5677 string exe_path = _find_executable_path();
5678
5679 if (!exe_path.empty())
5680 set_crawl_base_dir(exe_path.c_str());
5681 else
5682 set_crawl_base_dir(argv[0]);
5683
5684 SysEnv.crawl_exe = get_base_filename(argv[0]);
5685
5686 SysEnv.rcdirs.clear();
5687 SysEnv.map_gen_iters = 0;
5688
5689 if (argc < 2) // no args!
5690 return true;
5691
5692 char *arg, *next_arg;
5693 int current = 1;
5694 bool nextUsed = false;
5695 int ecount;
5696
5697 // initialise
5698 for (int i = 0; i < num_cmd_ops; i++)
5699 _arg_seen(static_cast<commandline_option_type>(i)) = false;
5700
5701 if (SysEnv.cmd_args.empty())
5702 {
5703 for (int i = 1; i < argc; ++i)
5704 SysEnv.cmd_args.emplace_back(argv[i]);
5705 }
5706
5707 bool seen_headless_ok = false;
5708
5709 while (current < argc)
5710 {
5711 // get argument
5712 arg = argv[current];
5713
5714 // next argument (if there is one)
5715 if (current+1 < argc)
5716 next_arg = argv[current+1];
5717 else
5718 next_arg = nullptr;

Callers 1

mainFunction · 0.85

Calls 15

_find_executable_pathFunction · 0.85
set_crawl_base_dirFunction · 0.85
get_base_filenameFunction · 0.85
endFunction · 0.85
isadigitFunction · 0.85
playable_metadata_jsonFunction · 0.85
branch_data_jsonFunction · 0.85
split_stringFunction · 0.85
_str_to_speciesFunction · 0.85
str_to_jobFunction · 0.85
_set_crawl_dirFunction · 0.85
_print_save_versionFunction · 0.85

Tested by

no test coverage detected