MCPcopy Index your code
hub / github.com/GJDuck/e9patch / parseBoolOptArg

Function parseBoolOptArg

src/e9patch/e9patch.cpp:218–228  ·  view source on GitHub ↗

* Parse a Boolean from an optarg. */

Source from the content-addressed store, hash-verified

216 * Parse a Boolean from an optarg.
217 */
218static bool parseBoolOptArg(const char *option, const char *optarg)
219{
220 if (optarg == nullptr)
221 return true;
222 if (strcmp(optarg, "true") == 0 || strcmp(optarg, "1") == 0)
223 return true;
224 else if (strcmp(optarg, "false") == 0 || strcmp(optarg, "0") == 0)
225 return false;
226 error("failed to parse argument \"%s\" for the `%s' option; "
227 "expected a Boolean [true, false]", option, optarg);
228}
229
230/*
231 * Usage.

Callers 1

parseOptionsFunction · 0.85

Calls 2

strcmpFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected