Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Unified Diff: net/spdy/spdy_alt_svc_wire_format.cc

Issue 2558643002: Remove some uses of isdigit in net/, as it can be locale depedent. (Closed)
Patch Set: Response Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/quic_spdy_stream_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_alt_svc_wire_format.cc
diff --git a/net/spdy/spdy_alt_svc_wire_format.cc b/net/spdy/spdy_alt_svc_wire_format.cc
index e94b4fa719569e1bebd5d8a29fe21a2b2849fbd6..df4e84dded564bde7619100d5f514455e51992b5 100644
--- a/net/spdy/spdy_alt_svc_wire_format.cc
+++ b/net/spdy/spdy_alt_svc_wire_format.cc
@@ -9,6 +9,7 @@
#include <string>
#include "base/logging.h"
+#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
namespace net {
@@ -22,7 +23,8 @@ bool ParsePositiveIntegerImpl(StringPiece::const_iterator c,
StringPiece::const_iterator end,
T* value) {
*value = 0;
- for (; c != end && isdigit(*c); ++c) {
+ // TODO(mmenke): This really should be using methods in parse_number.h.
+ for (; c != end && '0' <= *c && *c <= '9'; ++c) {
if (*value > std::numeric_limits<T>::max() / 10) {
return false;
}
@@ -277,22 +279,20 @@ bool SpdyAltSvcWireFormat::PercentDecode(StringPiece::const_iterator c,
}
DCHECK_EQ('%', *c);
++c;
- if (c == end || !isxdigit(*c)) {
+ if (c == end || !base::IsHexDigit(*c)) {
return false;
}
- char decoded = tolower(*c);
- // '0' is 0, 'a' is 10.
- decoded += isdigit(*c) ? (0 - '0') : (10 - 'a');
// Network byte order is big-endian.
- decoded <<= 4;
+ int decoded = base::HexDigitToInt(*c) << 4;
+
++c;
- if (c == end || !isxdigit(*c)) {
+ if (c == end || !base::IsHexDigit(*c)) {
return false;
}
- decoded += tolower(*c);
- // '0' is 0, 'a' is 10.
- decoded += isdigit(*c) ? (0 - '0') : (10 - 'a');
- output->push_back(decoded);
+ // Network byte order is big-endian.
+ decoded += base::HexDigitToInt(*c);
+
+ output->push_back(static_cast<char>(decoded));
}
return true;
}
« no previous file with comments | « net/quic/core/quic_spdy_stream_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698