src: Rename isAlpha, isDigit, and isHexDigit as is_...

This commit is contained in:
Tatsuhiro Tsujikawa 2015-11-28 00:41:39 +09:00
parent d867fe64e3
commit ba9e912cf6
5 changed files with 14 additions and 13 deletions

View File

@ -340,7 +340,8 @@ std::string normalize_path(InputIt first, InputIt last) {
} else {
for (; first < last - 2;) {
if (*first == '%') {
if (util::isHexDigit(*(first + 1)) && util::isHexDigit(*(first + 2))) {
if (util::is_hex_digit(*(first + 1)) &&
util::is_hex_digit(*(first + 2))) {
auto c = (util::hex_to_uint(*(first + 1)) << 4) +
util::hex_to_uint(*(first + 2));
if (util::in_rfc3986_unreserved_chars(c)) {

View File

@ -859,13 +859,13 @@ ssize_t parse_proxy_line_port(const uint8_t *first, const uint8_t *last) {
}
if (*p == '0') {
if (p + 1 != last && util::isDigit(*(p + 1))) {
if (p + 1 != last && util::is_digit(*(p + 1))) {
return -1;
}
return 1;
}
for (; p != last && util::isDigit(*p); ++p) {
for (; p != last && util::is_digit(*p); ++p) {
port *= 10;
port += *p - '0';

View File

@ -471,7 +471,7 @@ LogFragmentType log_var_lookup_token(const char *name, size_t namelen) {
namespace {
bool var_token(char c) {
return util::isAlpha(c) || util::isDigit(c) || c == '_';
return util::is_alpha(c) || util::is_digit(c) || c == '_';
}
} // namespace

View File

@ -67,7 +67,7 @@ const char UPPER_XDIGITS[] = "0123456789ABCDEF";
bool in_rfc3986_unreserved_chars(const char c) {
static constexpr const char unreserved[] = {'-', '.', '_', '~'};
return isAlpha(c) || isDigit(c) ||
return is_alpha(c) || is_digit(c) ||
std::find(std::begin(unreserved), std::end(unreserved), c) !=
std::end(unreserved);
}
@ -120,7 +120,7 @@ bool in_token(char c) {
static constexpr const char extra[] = {'!', '#', '$', '%', '&',
'\'', '*', '+', '-', '.',
'^', '_', '`', '|', '~'};
return isAlpha(c) || isDigit(c) ||
return is_alpha(c) || is_digit(c) ||
std::find(std::begin(extra), std::end(extra), c) != std::end(extra);
}

View File

@ -64,14 +64,14 @@ constexpr const char NGHTTP2_H1_1[] = "http/1.1";
namespace util {
inline bool isAlpha(const char c) {
inline bool is_alpha(const char c) {
return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
}
inline bool isDigit(const char c) { return '0' <= c && c <= '9'; }
inline bool is_digit(const char c) { return '0' <= c && c <= '9'; }
inline bool isHexDigit(const char c) {
return isDigit(c) || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f');
inline bool is_hex_digit(const char c) {
return is_digit(c) || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f');
}
bool in_rfc3986_unreserved_chars(const char c);
@ -84,7 +84,7 @@ bool in_token(char c);
bool in_attr_char(char c);
// Returns integer corresponding to hex notation |c|. It is undefined
// if isHexDigit(c) is false.
// if is_hex_digit(c) is false.
uint32_t hex_to_uint(char c);
std::string percent_encode(const unsigned char *target, size_t len);
@ -99,8 +99,8 @@ std::string percent_decode(InputIt first, InputIt last) {
std::string result;
for (; first != last; ++first) {
if (*first == '%') {
if (first + 1 != last && first + 2 != last && isHexDigit(*(first + 1)) &&
isHexDigit(*(first + 2))) {
if (first + 1 != last && first + 2 != last &&
is_hex_digit(*(first + 1)) && is_hex_digit(*(first + 2))) {
result += (hex_to_uint(*(first + 1)) << 4) + hex_to_uint(*(first + 2));
first += 2;
continue;