Stratosphere: use isxdigit to check if char is hex.

This commit is contained in:
Michael Scire 2018-07-29 17:27:30 -07:00
parent c70420d996
commit cb4089e49c
3 changed files with 13 additions and 18 deletions

View file

@ -13,9 +13,7 @@ static std::atomic_bool g_has_initialized = false;
static bool IsHexadecimal(const char *str) {
while (*str) {
if (('0' <= *str && *str <= '9') ||
('a' <= *str && *str <= 'f') ||
('A' <= *str && *str <= 'F')) {
if (isxdigit(*str)) {
str++;
} else {
return false;

View file

@ -3,6 +3,7 @@
#include <cstdio>
#include <cstring>
#include <dirent.h>
#include <ctype.h>
#include <switch.h>
#include "ldr_patcher.hpp"
@ -28,9 +29,7 @@ static inline u8 HexNybbleToU8(const char nybble) {
static bool MatchesBuildId(const char *name, size_t name_len, const u8 *build_id) {
/* Validate name is hex build id. */
for (unsigned int i = 0; i < name_len - 4; i++) {
if (!(('0' <= name[i] && name[i] <= '9') ||
('a' <= name[i] && name[i] <= 'f') ||
('A' <= name[i] && name[i] <= 'F'))) {
if (isxdigit(name[i]) == 0) {
return false;
}
}

View file

@ -12,9 +12,7 @@
static bool IsHexadecimal(const char *str) {
while (*str) {
if (('0' <= *str && *str <= '9') ||
('a' <= *str && *str <= 'f') ||
('A' <= *str && *str <= 'F')) {
if (isxdigit(*str)) {
str++;
} else {
return false;