Derive maximum base from number of digits instead of hardcoding
This commit is contained in:
parent
fd87faddeb
commit
341f08d704
|
@ -9,7 +9,7 @@ static const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||||
bool baseconv(char outbuf[], size_t bufsize, unsigned base, uintmax_t num) {
|
bool baseconv(char outbuf[], size_t bufsize, unsigned base, uintmax_t num) {
|
||||||
// Supported bases are 2 to 36 inclusive (though it could be higher
|
// Supported bases are 2 to 36 inclusive (though it could be higher
|
||||||
// if our digits string was longer
|
// if our digits string was longer
|
||||||
if (base < 2 || base > 36)
|
if (base < 2 || base > sizeof(digits))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Longest possible converted string is base-2, where we produce one
|
// Longest possible converted string is base-2, where we produce one
|
||||||
|
|
Loading…
Reference in New Issue