Now it can generate chars until UINT_MAX

This commit is contained in:
Daniel Cortés
2019-10-13 18:59:52 -03:00
parent 810965a9fb
commit 1f4c244044
5 changed files with 24 additions and 17 deletions

View File

@@ -18,7 +18,7 @@ enum strtoui_error strtoui(unsigned int *out, char *s, int base) {
if(s[0] == '\0' || isspace(s[0]))
return STRTOUI_INCONVERTIBLE;
long l = strtol(s, &end, base);
if(l > INT_MAX || (errno == ERANGE && l == LONG_MAX))
if(l > UINT_MAX || (errno == ERANGE && l == LONG_MAX))
return STRTOUI_OVERFLOW;
if(l < 0|| (errno == ERANGE && l == LONG_MIN))
return STRTOUI_UNDERFLOW;