mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 19:20:08 +01:00
gallium/util: make use of strtol() in debug_get_num_option()
This allows to use hexadecimal numbers which are automatically detected by strtol() when the base is 0. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Tested-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
5da24242b3
commit
be0535b8c7
1 changed files with 8 additions and 17 deletions
|
|
@ -203,25 +203,16 @@ debug_get_num_option(const char *name, long dfault)
|
|||
const char *str;
|
||||
|
||||
str = os_get_option(name);
|
||||
if (!str)
|
||||
if (!str) {
|
||||
result = dfault;
|
||||
else {
|
||||
long sign;
|
||||
char c;
|
||||
c = *str++;
|
||||
if (c == '-') {
|
||||
sign = -1;
|
||||
c = *str++;
|
||||
} else {
|
||||
char *endptr;
|
||||
|
||||
result = strtol(str, &endptr, 0);
|
||||
if (str == endptr) {
|
||||
/* Restore the default value when no digits were found. */
|
||||
result = dfault;
|
||||
}
|
||||
else {
|
||||
sign = 1;
|
||||
}
|
||||
result = 0;
|
||||
while ('0' <= c && c <= '9') {
|
||||
result = result*10 + (c - '0');
|
||||
c = *str++;
|
||||
}
|
||||
result *= sign;
|
||||
}
|
||||
|
||||
if (debug_get_option_should_print())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue