mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
Refactor is_positive_num() to use C-strings
This makes the future move to C easier, as well as just shows that it's plain unnecessary to use an std::string here.
This commit is contained in:
parent
825dbac228
commit
89bddf98b6
3 changed files with 4 additions and 4 deletions
|
@ -284,9 +284,9 @@ static bool VVV_isxdigit(const unsigned char digit)
|
||||||
|| SDL_isdigit(digit);
|
|| SDL_isdigit(digit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_positive_num(const std::string& str, const bool hex)
|
bool is_positive_num(const char* str, const bool hex)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < str.length(); i++)
|
for (size_t i = 0; str[i] != '\0'; ++i)
|
||||||
{
|
{
|
||||||
if (hex)
|
if (hex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@ bool next_split_s(
|
||||||
|
|
||||||
bool is_number(const char* str);
|
bool is_number(const char* str);
|
||||||
|
|
||||||
bool is_positive_num(const std::string& str, const bool hex);
|
bool is_positive_num(const char* str, const bool hex);
|
||||||
|
|
||||||
bool endsWith(const std::string& str, const std::string& suffix);
|
bool endsWith(const std::string& str, const std::string& suffix);
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ std::string find_tag(const std::string& buf, const std::string& start, const std
|
||||||
size_t real_start = start_pos + 2 + ((int) hex);
|
size_t real_start = start_pos + 2 + ((int) hex);
|
||||||
std::string number(value.substr(real_start, end - real_start));
|
std::string number(value.substr(real_start, end - real_start));
|
||||||
|
|
||||||
if (!is_positive_num(number, hex))
|
if (!is_positive_num(number.c_str(), hex))
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue