| 1114 | } |
| 1115 | |
| 1116 | bool Library::isIntArgValid(const Token *ftok, int argnr, const MathLib::bigint argvalue, const Settings& settings) const |
| 1117 | { |
| 1118 | const ArgumentChecks *ac = getarg(ftok, argnr); |
| 1119 | if (!ac || ac->valid.empty()) |
| 1120 | return true; |
| 1121 | if (ac->valid.find('.') != std::string::npos) |
| 1122 | return isFloatArgValid(ftok, argnr, static_cast<double>(argvalue), settings); |
| 1123 | TokenList tokenList(settings, ftok->isCpp() ? Standards::Language::CPP : Standards::Language::C); |
| 1124 | gettokenlistfromvalid(ac->valid, tokenList); |
| 1125 | for (const Token *tok = tokenList.front(); tok; tok = tok->next()) { |
| 1126 | if (tok->isNumber() && argvalue == MathLib::toBigNumber(tok)) |
| 1127 | return true; |
| 1128 | if (Token::Match(tok, "%num% : %num%") && argvalue >= MathLib::toBigNumber(tok) && argvalue <= MathLib::toBigNumber(tok->tokAt(2))) |
| 1129 | return true; |
| 1130 | if (Token::Match(tok, "%num% : ,") && argvalue >= MathLib::toBigNumber(tok)) |
| 1131 | return true; |
| 1132 | if ((!tok->previous() || tok->strAt(-1) == ",") && Token::Match(tok,": %num%") && argvalue <= MathLib::toBigNumber(tok->tokAt(1))) |
| 1133 | return true; |
| 1134 | } |
| 1135 | return false; |
| 1136 | } |
| 1137 | |
| 1138 | bool Library::isFloatArgValid(const Token *ftok, int argnr, double argvalue, const Settings& settings) const |
| 1139 | { |