From 3c2121d4e00edf4e13fc8f0ae03663b5fb6bfdc8 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Tue, 16 Oct 2018 18:03:21 -0600 Subject: [PATCH] Do not require prefix for hex --- src/header/stdlib/mod.rs | 2 +- tests/expected/stdlib/strtol.stdout | 1 + tests/stdlib/strtol.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index 0644dfb8..6925a2a9 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -756,7 +756,7 @@ pub unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> { { convert_integer(s.offset(2), 16).map(|(val, idx, overflow)| (val, idx + 2, overflow)) } else { - None + convert_integer(s, 16).map(|(val, idx, overflow)| (val, idx, overflow)) } } diff --git a/tests/expected/stdlib/strtol.stdout b/tests/expected/stdlib/strtol.stdout index 6f53efcf..5ac06ec2 100644 --- a/tests/expected/stdlib/strtol.stdout +++ b/tests/expected/stdlib/strtol.stdout @@ -6,6 +6,7 @@ 1234567890 38acf abcdef12 +cafebeef 731 731 0 diff --git a/tests/stdlib/strtol.c b/tests/stdlib/strtol.c index 7d09883c..c088e144 100644 --- a/tests/stdlib/strtol.c +++ b/tests/stdlib/strtol.c @@ -13,6 +13,7 @@ int main(int argc, char* argv[]) { printf("%lx\n", strtol(" 0x38Acfg", NULL, 0)); printf("%lx\n", strtol("0Xabcdef12", NULL, 16)); + printf("%lx\n", strtol("cafebeef", NULL, 16)); printf("%lo\n", strtol(" 073189", NULL, 0)); printf("%lo\n", strtol(" 073189", NULL, 8)); -- GitLab