summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_debug.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2016-09-14 20:37:11 +0200
committerSamuel Pitoiset <[email protected]>2016-09-26 19:39:04 +0200
commitbe0535b8c7a84659e2829c8d0bfd7f2847e71825 (patch)
treefcddb029b13d3179dfbc0a97f11072c6934f6e2c /src/gallium/auxiliary/util/u_debug.c
parent5da24242b3a54f31da153d67d55cd0f8547582f9 (diff)
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 <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Tested-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util/u_debug.c')
-rw-r--r--src/gallium/auxiliary/util/u_debug.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index 4619526094c..dd3e16791d6 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -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 {
- sign = 1;
- }
- result = 0;
- while ('0' <= c && c <= '9') {
- result = result*10 + (c - '0');
- c = *str++;
+ } else {
+ char *endptr;
+
+ result = strtol(str, &endptr, 0);
+ if (str == endptr) {
+ /* Restore the default value when no digits were found. */
+ result = dfault;
}
- result *= sign;
}
if (debug_get_option_should_print())