MCPcopy Create free account
hub / github.com/Kitware/CMake / GetIndexArg

Function GetIndexArg

Source/cmListCommand.cxx:31–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace {
30
31bool GetIndexArg(std::string const& arg, int* idx, cmMakefile& mf)
32{
33 long value;
34 if (!cmStrToLong(arg, &value)) {
35 switch (mf.GetPolicyStatus(cmPolicies::CMP0121)) {
36 case cmPolicies::WARN: {
37 // Default is to warn and use old behavior OLD behavior is to allow
38 // compatibility, so issue a warning and use the previous behavior.
39 std::string warn =
40 cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0121),
41 " Invalid list index \"", arg, "\".");
42 mf.IssueMessage(MessageType::AUTHOR_WARNING, warn);
43 CM_FALLTHROUGH;
44 }
45 case cmPolicies::OLD:
46 // OLD behavior is to allow compatibility, so just ignore the
47 // situation.
48 break;
49 case cmPolicies::NEW:
50 return false;
51 }
52 }
53
54 // Truncation is happening here, but it had always been happening here.
55 *idx = static_cast<int>(value);
56
57 return true;
58}
59
60bool GetListString(std::string& listString, std::string const& var,
61 cmMakefile const& makefile)

Callers 4

HandleGetCommandFunction · 0.85
HandleInsertCommandFunction · 0.85
HandleSublistCommandFunction · 0.85
HandleRemoveAtCommandFunction · 0.85

Calls 4

cmStrToLongFunction · 0.85
cmStrCatFunction · 0.70
GetPolicyStatusMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…