Replace long with int64_t in exiv2app.hpp
This commit is contained in:
+11
-4
@@ -1,19 +1,26 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "app_utils.hpp"
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <limits>
|
||||
|
||||
namespace Util {
|
||||
bool strtol(const char* nptr, long& n) {
|
||||
bool strtol(const char* nptr, int64_t& n) {
|
||||
if (!nptr || *nptr == '\0')
|
||||
return false;
|
||||
char* endptr = nullptr;
|
||||
long tmp = std::strtol(nptr, &endptr, 10);
|
||||
long long tmp = std::strtoll(nptr, &endptr, 10);
|
||||
if (*endptr != '\0')
|
||||
return false;
|
||||
if (tmp == LONG_MAX || tmp == LONG_MIN)
|
||||
// strtoll returns LLONG_MAX or LLONG_MIN if an overflow occurs.
|
||||
if (tmp == LLONG_MAX || tmp == LLONG_MIN)
|
||||
return false;
|
||||
n = tmp;
|
||||
if (tmp < std::numeric_limits<int64_t>::min())
|
||||
return false;
|
||||
if (tmp > std::numeric_limits<int64_t>::max())
|
||||
return false;
|
||||
n = static_cast<int64_t>(tmp);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user