Factor out a single parseNumber utility function (#1839)

This commit is contained in:
Rangi
2025-09-22 15:15:24 -04:00
committed by GitHub
parent c8d22d8744
commit 634fd853d1
18 changed files with 304 additions and 337 deletions

View File

@@ -2,9 +2,11 @@
#include "backtrace.hpp"
#include <stdlib.h> // strtoul
#include <optional>
#include <stdint.h>
#include "platform.hpp" // strcasecmp
#include "util.hpp" // parseWholeNumber
Tracing tracing;
@@ -22,8 +24,10 @@ bool trace_ParseTraceDepth(char const *arg) {
tracing.loud = false;
return true;
} else {
char *endptr;
tracing.depth = strtoul(arg, &endptr, 0);
return arg[0] != '\0' && *endptr == '\0';
std::optional<uint64_t> depth = parseWholeNumber(arg);
if (depth) {
tracing.depth = *depth;
}
return depth.has_value();
}
}