mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-10 06:01:52 +00:00
Stratosphere: use isxdigit to check if char is hex.
This commit is contained in:
parent
c70420d996
commit
cb4089e49c
3 changed files with 13 additions and 18 deletions
|
@ -13,13 +13,11 @@ 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')) {
|
||||
str++;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (isxdigit(*str)) {
|
||||
str++;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <switch.h>
|
||||
#include "ldr_patcher.hpp"
|
||||
|
@ -28,11 +29,9 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Read build id from name. */
|
||||
|
|
|
@ -12,13 +12,11 @@
|
|||
|
||||
static bool IsHexadecimal(const char *str) {
|
||||
while (*str) {
|
||||
if (('0' <= *str && *str <= '9') ||
|
||||
('a' <= *str && *str <= 'f') ||
|
||||
('A' <= *str && *str <= 'F')) {
|
||||
str++;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (isxdigit(*str)) {
|
||||
str++;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue