Fix edge case where "0x" would be considered a complete hexadecimal
number for purposes of str_end. Now the hexadecimal prefix needs a valid
digit after it, else just the 0 will be counted as the number.
Details
Details
- Reviewers
sivachandra - Commits
- rG37ce7349f7e9: [libc] fix strtointeger hex prefix parsing
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
While it is OK for this patch, I would suggest that the tests be templatized.
libc/src/__support/str_conv_utils.h | ||
---|---|---|
82 | I think the logic here and on line 41/42 can be moved to a single function say, is_hex_start(...). Then, we can use it like this: else if (base == 16 && is_hex_start(src)) { ... } infer_base will have to be modified to something like this: if (is_hex_start(*src)) { (*src) += 2; return 16; } else if (**src == '0') { ++(*src); return 8; } else { return 10; } |
I think the logic here and on line 41/42 can be moved to a single function say, is_hex_start(...). Then, we can use it like this:
infer_base will have to be modified to something like this: