libluna: Allow passing a base to scan_(un)signed_integer()

This commit is contained in:
apio 2023-06-19 00:58:02 +02:00
parent 8c2348c425
commit a2c081f219
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 6 additions and 6 deletions

View File

@ -2,10 +2,10 @@
#include <luna/Types.h> #include <luna/Types.h>
// Parse an unsigned integer and advance *str to point to the first non-digit character after the number. // Parse an unsigned integer and advance *str to point to the first non-digit character after the number.
usize scan_unsigned_integer(const char** str); usize scan_unsigned_integer(const char** str, int base = 10);
// Parse a signed integer and advance *str to point to the first non-digit character after the number. // Parse a signed integer and advance *str to point to the first non-digit character after the number.
isize scan_signed_integer(const char** str); isize scan_signed_integer(const char** str, int base = 10);
// Parse an unsigned integer, similar to strtoull(). // Parse an unsigned integer, similar to strtoull().
usize parse_unsigned_integer(const char* str, const char** endptr, int base); usize parse_unsigned_integer(const char* str, const char** endptr, int base);

View File

@ -89,12 +89,12 @@ isize parse_signed_integer(const char* str, const char** endptr, int base)
return negative ? -(isize)rc : (isize)rc; return negative ? -(isize)rc : (isize)rc;
} }
usize scan_unsigned_integer(const char** str) usize scan_unsigned_integer(const char** str, int base)
{ {
return parse_unsigned_integer(*str, str, 10); return parse_unsigned_integer(*str, str, base);
} }
isize scan_signed_integer(const char** str) isize scan_signed_integer(const char** str, int base)
{ {
return parse_signed_integer(*str, str, 10); return parse_signed_integer(*str, str, base);
} }