refactor: the long goodbye

long is 32 bits on windows, while it is 64 bits on other architectures.
This makes the type suboptimal for a codebase meant to be
cross-platform. Replace it with more appropriate integer types.
This commit is contained in:
dundargoc
2023-09-29 14:58:48 +02:00
committed by dundargoc
parent c513cbf361
commit acc646ad8f
57 changed files with 362 additions and 367 deletions

View File

@@ -1167,14 +1167,14 @@ long getdigits_long(char **pp, bool strict, long def)
/// Gets a int32_t number from a string.
///
/// @see getdigits
int32_t getdigits_int32(char **pp, bool strict, long def)
int32_t getdigits_int32(char **pp, bool strict, int32_t def)
{
intmax_t number = getdigits(pp, strict, def);
#if SIZEOF_INTMAX_T > 4
if (strict) {
assert(number >= INT32_MIN && number <= INT32_MAX);
} else if (!(number >= INT32_MIN && number <= INT32_MAX)) {
return (int32_t)def;
return def;
}
#endif
return (int32_t)number;