Codechange: Use std::strto* variants everywhere (#10720)

This commit is contained in:
Charles Pigott
2023-04-26 12:56:14 +01:00
committed by GitHub
parent 997c936893
commit 80bd5ad727
14 changed files with 24 additions and 25 deletions

View File

@@ -174,7 +174,7 @@ const uint16 INIFILE_VERSION = (IniFileVersion)(IFV_MAX_VERSION - 1); ///< Curre
size_t OneOfManySettingDesc::ParseSingleValue(const char *str, size_t len, const std::vector<std::string> &many)
{
/* check if it's an integer */
if (isdigit(*str)) return strtoul(str, nullptr, 0);
if (isdigit(*str)) return std::strtoul(str, nullptr, 0);
size_t idx = 0;
for (auto one : many) {
@@ -245,7 +245,7 @@ static int ParseIntList(const char *p, T *items, int maxitems)
default: {
if (n == maxitems) return -1; // we don't accept that many numbers
char *end;
unsigned long v = strtoul(p, &end, 0);
unsigned long v = std::strtoul(p, &end, 0);
if (p == end) return -1; // invalid character (not a number)
if (sizeof(T) < sizeof(v)) v = Clamp<unsigned long>(v, std::numeric_limits<T>::min(), std::numeric_limits<T>::max());
items[n++] = v;
@@ -377,7 +377,7 @@ void ManyOfManySettingDesc::FormatValue(char *buf, const char *last, const void
size_t IntSettingDesc::ParseValue(const char *str) const
{
char *end;
size_t val = strtoul(str, &end, 0);
size_t val = std::strtoul(str, &end, 0);
if (end == str) {
ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_VALUE);
msg.SetDParamStr(0, str);