diff --git a/re2/fuzzing/re2_fuzzer.cc b/re2/fuzzing/re2_fuzzer.cc index d0e5ba0ca..9a7af08a7 100644 --- a/re2/fuzzing/re2_fuzzer.cc +++ b/re2/fuzzing/re2_fuzzer.cc @@ -105,7 +105,7 @@ void TestOneInput(absl::string_view pattern, const RE2::Options& options, // counted repetition is involved - whereas the marginal benefit is zero. // Crudely limit the use of 'k', 'K', 's' and 'S' too because they become // three-element character classes when case-insensitive and using UTF-8. - // TODO(junyer): Handle [:isalnum:] et al. when they start to cause pain. + // TODO(junyer): Handle [[:alnum:]] et al. when they start to cause pain. int char_class = 0; int backslash_p = 0; // very expensive, so handle specially for (size_t i = 0; i < pattern.size(); i++) { diff --git a/re2/parse.cc b/re2/parse.cc index 7b1510dda..655cb9a27 100644 --- a/re2/parse.cc +++ b/re2/parse.cc @@ -26,6 +26,7 @@ #include #include "absl/base/macros.h" +#include "absl/strings/ascii.h" #include "util/logging.h" #include "util/utf.h" #include "re2/pod_array.h" @@ -1322,14 +1323,14 @@ bool Regexp::ParseState::MaybeConcatString(int r, ParseFlags flags) { // Parses a decimal integer, storing it in *np. // Sets *s to span the remainder of the string. static bool ParseInteger(absl::string_view* s, int* np) { - if (s->empty() || !isdigit((*s)[0] & 0xFF)) + if (s->empty() || !absl::ascii_isdigit((*s)[0] & 0xFF)) return false; // Disallow leading zeros. - if (s->size() >= 2 && (*s)[0] == '0' && isdigit((*s)[1] & 0xFF)) + if (s->size() >= 2 && (*s)[0] == '0' && absl::ascii_isdigit((*s)[1] & 0xFF)) return false; int n = 0; int c; - while (!s->empty() && isdigit(c = (*s)[0] & 0xFF)) { + while (!s->empty() && absl::ascii_isdigit(c = (*s)[0] & 0xFF)) { // Avoid overflow. if (n >= 100000000) return false; @@ -1468,7 +1469,7 @@ static bool ParseEscape(absl::string_view* s, Rune* rp, int code; switch (c) { default: - if (c < Runeself && !isalpha(c) && !isdigit(c)) { + if (c < Runeself && !absl::ascii_isalnum(c)) { // Escaped non-word characters are always themselves. // PCRE is not quite so rigorous: it accepts things like // \q, but we don't. We once rejected \_, but too many diff --git a/re2/re2.cc b/re2/re2.cc index a0fa6ce63..bc713cf64 100644 --- a/re2/re2.cc +++ b/re2/re2.cc @@ -27,6 +27,7 @@ #include "absl/base/macros.h" #include "absl/container/fixed_array.h" +#include "absl/strings/ascii.h" #include "absl/strings/str_format.h" #include "util/logging.h" #include "util/strutil.h" @@ -975,7 +976,7 @@ bool RE2::CheckRewriteString(absl::string_view rewrite, if (c == '\\') { continue; } - if (!isdigit(c)) { + if (!absl::ascii_isdigit(c)) { *error = "Rewrite schema error: " "'\\' must be followed by a digit or '\\'."; return false; @@ -1005,7 +1006,7 @@ int RE2::MaxSubmatch(absl::string_view rewrite) { if (*s == '\\') { s++; int c = (s < end) ? *s : -1; - if (isdigit(c)) { + if (absl::ascii_isdigit(c)) { int n = (c - '0'); if (n > max) max = n; @@ -1029,7 +1030,7 @@ bool RE2::Rewrite(std::string* out, } s++; int c = (s < end) ? *s : -1; - if (isdigit(c)) { + if (absl::ascii_isdigit(c)) { int n = (c - '0'); if (n >= veclen) { if (options_.log_errors()) { @@ -1110,13 +1111,13 @@ static const char* TerminateNumber(char* buf, size_t nbuf, const char* str, size_t* np, bool accept_spaces) { size_t n = *np; if (n == 0) return ""; - if (n > 0 && isspace(*str)) { + if (n > 0 && absl::ascii_isspace(*str)) { // We are less forgiving than the strtoxxx() routines and do not // allow leading spaces. We do allow leading spaces for floats. if (!accept_spaces) { return ""; } - while (n > 0 && isspace(*str)) { + while (n > 0 && absl::ascii_isspace(*str)) { n--; str++; }