diff options
author | mongo <mongo@iomega> | 2017-01-23 11:56:20 -0300 |
---|---|---|
committer | mongo <mongo@iomega> | 2017-01-23 11:56:20 -0300 |
commit | 41f54cd3cc8c8d4504f2a049ccd8b609244b9318 (patch) | |
tree | a01c374ca3f12c9fced6f606878e718aef716179 /src/utils | |
parent | 71fde2d4b49ae15a8b2b60eb1ad1398bedfb8d7b (diff) |
Fix # 113
Diffstat (limited to 'src/utils')
-rwxr-xr-x | src/utils/string.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/utils/string.c b/src/utils/string.c index eebb186..753f37f 100755 --- a/src/utils/string.c +++ b/src/utils/string.c @@ -229,22 +229,35 @@ int isnumeric(char * string) { int res = true; bool has_dot = false; bool has_dash = false; + bool has_digit = false; for (i=0; i<len; i++) { + if ( string[i] == '.' && ! has_dot ) { has_dot = true; continue; } - if ( string[i] == '-' && ! has_dash ) { - has_dash = true; + + if ( string[i] == '-' ) { + if (has_digit) { + res = false; + break; + } + if (! has_dash) { + has_dash = true; + } else { + res = false; + break; + } continue; } + if ( isdigit(string[i]) ) { + has_digit = true; continue; } - else { - res = false; - break; - } + + res = false; + break; } return res; } |