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.
23 lines
491 B
C++
23 lines
491 B
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <cstdlib>
|
|
#include <climits>
|
|
|
|
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
|