| 29 | namespace { |
| 30 | |
| 31 | bool 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 | |
| 60 | bool GetListString(std::string& listString, std::string const& var, |
| 61 | cmMakefile const& makefile) |
no test coverage detected
searching dependent graphs…