You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
413 B
C++
21 lines
413 B
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <climits>
|
|
#include <cstdlib>
|
|
|
|
namespace Util {
|
|
bool strtol(const char* nptr, long& n) {
|
|
if (!nptr || *nptr == '\0')
|
|
return false;
|
|
char* endptr = nullptr;
|
|
long tmp = std::strtol(nptr, &endptr, 10);
|
|
if (*endptr != '\0')
|
|
return false;
|
|
if (tmp == LONG_MAX || tmp == LONG_MIN)
|
|
return false;
|
|
n = tmp;
|
|
return true;
|
|
}
|
|
|
|
} // namespace Util
|