Refactoring function r_str_isnumber

This commit is contained in:
Alexis Ehret 2021-01-16 13:55:47 +01:00 committed by pancake
parent a3f05a9b1a
commit 4827f58ea6

View File

@ -3354,16 +3354,17 @@ R_API size_t *r_str_split_lines(char *str, size_t *count) {
}
R_API bool r_str_isnumber(const char *str) {
if (!str || !*str) {
if (!str || (!IS_DIGIT (*str) && *str != '-')) {
return false;
}
bool isnum = IS_DIGIT (*str) || *str == '-';
while (isnum && *++str) {
while (*++str) {
if (!IS_DIGIT (*str)) {
isnum = false;
return false;
}
}
return isnum;
return true;
}
/* TODO: optimize to start searching by the end of the string */