mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-09 12:01:15 +00:00
Change all str_to_int 'base' args from int to unsigned
This commit is contained in:
parent
459c5a2303
commit
ad8d02827b
14
str.c
14
str.c
@ -645,7 +645,7 @@ char *str_str(char *haystack, const char *needle, size_t haystack_len)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int str_to_int32(const char *str, int base, int32_t *result, const char **afterp)
|
||||
int str_to_int32(const char *str, unsigned base, int32_t *result, const char **afterp)
|
||||
{
|
||||
if (isspace(*str))
|
||||
return 0;
|
||||
@ -661,7 +661,7 @@ int str_to_int32(const char *str, int base, int32_t *result, const char **afterp
|
||||
return 1;
|
||||
}
|
||||
|
||||
int str_to_uint32(const char *str, int base, uint32_t *result, const char **afterp)
|
||||
int str_to_uint32(const char *str, unsigned base, uint32_t *result, const char **afterp)
|
||||
{
|
||||
if (isspace(*str))
|
||||
return 0;
|
||||
@ -677,7 +677,7 @@ int str_to_uint32(const char *str, int base, uint32_t *result, const char **afte
|
||||
return 1;
|
||||
}
|
||||
|
||||
int str_to_int64(const char *str, int base, int64_t *result, const char **afterp)
|
||||
int str_to_int64(const char *str, unsigned base, int64_t *result, const char **afterp)
|
||||
{
|
||||
if (isspace(*str))
|
||||
return 0;
|
||||
@ -693,7 +693,7 @@ int str_to_int64(const char *str, int base, int64_t *result, const char **afterp
|
||||
return 1;
|
||||
}
|
||||
|
||||
int str_to_uint64(const char *str, int base, uint64_t *result, const char **afterp)
|
||||
int str_to_uint64(const char *str, unsigned base, uint64_t *result, const char **afterp)
|
||||
{
|
||||
if (isspace(*str))
|
||||
return 0;
|
||||
@ -739,7 +739,7 @@ uint64_t scale_factor(const char *str, const char **afterp)
|
||||
return factor;
|
||||
}
|
||||
|
||||
int str_to_int64_scaled(const char *str, int base, int64_t *result, const char **afterp)
|
||||
int str_to_int64_scaled(const char *str, unsigned base, int64_t *result, const char **afterp)
|
||||
{
|
||||
int64_t value;
|
||||
const char *end = str;
|
||||
@ -758,7 +758,7 @@ int str_to_int64_scaled(const char *str, int base, int64_t *result, const char *
|
||||
return 1;
|
||||
}
|
||||
|
||||
int str_to_uint32_scaled(const char *str, int base, uint32_t *result, const char **afterp)
|
||||
int str_to_uint32_scaled(const char *str, unsigned base, uint32_t *result, const char **afterp)
|
||||
{
|
||||
uint32_t value;
|
||||
const char *end = str;
|
||||
@ -794,7 +794,7 @@ int uint32_scaled_to_str(char *str, size_t len, uint32_t value)
|
||||
return strbuf_overrun(b) ? 0 : 1;
|
||||
}
|
||||
|
||||
int str_to_uint64_scaled(const char *str, int base, uint64_t *result, const char **afterp)
|
||||
int str_to_uint64_scaled(const char *str, unsigned base, uint64_t *result, const char **afterp)
|
||||
{
|
||||
uint64_t value;
|
||||
const char *end = str;
|
||||
|
20
str.h
20
str.h
@ -380,8 +380,8 @@ int strn_str_casecmp(const char *str1, size_t len1, const char *str2);
|
||||
*/
|
||||
char *str_str(char *haystack, const char *needle, size_t haystack_len);
|
||||
|
||||
/* Parse a string as an integer in ASCII radix notation in the given 'base' (eg, base=10 means
|
||||
* decimal).
|
||||
/* Parse a NUL-terminated string as an integer in ASCII radix notation in the given 'base' (eg,
|
||||
* base=10 means decimal).
|
||||
*
|
||||
* Returns 1 if a valid integer is parsed, storing the value in *result (unless result is NULL) and
|
||||
* storing a pointer to the immediately succeeding character in *afterp. If afterp is NULL then
|
||||
@ -391,10 +391,10 @@ char *str_str(char *haystack, const char *needle, size_t haystack_len);
|
||||
*
|
||||
* @author Andrew Bettison <andrew@servalproject.com>
|
||||
*/
|
||||
int str_to_int32(const char *str, int base, int32_t *result, const char **afterp);
|
||||
int str_to_uint32(const char *str, int base, uint32_t *result, const char **afterp);
|
||||
int str_to_int64(const char *str, int base, int64_t *result, const char **afterp);
|
||||
int str_to_uint64(const char *str, int base, uint64_t *result, const char **afterp);
|
||||
int str_to_int32(const char *str, unsigned base, int32_t *result, const char **afterp);
|
||||
int str_to_uint32(const char *str, unsigned base, uint32_t *result, const char **afterp);
|
||||
int str_to_int64(const char *str, unsigned base, int64_t *result, const char **afterp);
|
||||
int str_to_uint64(const char *str, unsigned base, uint64_t *result, const char **afterp);
|
||||
|
||||
/* Parse a string as an integer in ASCII radix notation in the given 'base' (eg, base=10 means
|
||||
* decimal) and scale the result by a factor given by an optional suffix "scaling" character in the
|
||||
@ -410,10 +410,10 @@ int str_to_uint64(const char *str, int base, uint64_t *result, const char **afte
|
||||
*
|
||||
* @author Andrew Bettison <andrew@servalproject.com>
|
||||
*/
|
||||
int str_to_int32_scaled(const char *str, int base, int32_t *result, const char **afterp);
|
||||
int str_to_uint32_scaled(const char *str, int base, uint32_t *result, const char **afterp);
|
||||
int str_to_int64_scaled(const char *str, int base, int64_t *result, const char **afterp);
|
||||
int str_to_uint64_scaled(const char *str, int base, uint64_t *result, const char **afterp);
|
||||
int str_to_int32_scaled(const char *str, unsigned base, int32_t *result, const char **afterp);
|
||||
int str_to_uint32_scaled(const char *str, unsigned base, uint32_t *result, const char **afterp);
|
||||
int str_to_int64_scaled(const char *str, unsigned base, int64_t *result, const char **afterp);
|
||||
int str_to_uint64_scaled(const char *str, unsigned base, uint64_t *result, const char **afterp);
|
||||
uint64_t scale_factor(const char *str, const char **afterp);
|
||||
|
||||
/* Format a string as a decimal integer in ASCII radix notation with a scale suffix character in the
|
||||
|
Loading…
x
Reference in New Issue
Block a user