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

Unified Diff: base/strings/string_number_conversions.cc

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 months 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 | « base/strings/pattern_unittest.cc ('k') | base/strings/string_piece.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/string_number_conversions.cc
diff --git a/base/strings/string_number_conversions.cc b/base/strings/string_number_conversions.cc
index 642d24e9ada11ad61444fcadd81a0accddb0df65..b6b65d2a3bf8ce53dc1fd463006ce1bc88877377 100644
--- a/base/strings/string_number_conversions.cc
+++ b/base/strings/string_number_conversions.cc
@@ -42,7 +42,12 @@ struct IntToStringT {
template <typename INT2, typename UINT2>
struct ToUnsignedT<INT2, UINT2, true> {
static UINT2 ToUnsigned(INT2 value) {
- return static_cast<UINT2>(value < 0 ? -value : value);
+ if (value >= 0) {
+ return value;
+ } else {
+ // Avoid integer overflow when negating INT_MIN.
+ return static_cast<UINT2>(-(value + 1)) + 1;
+ }
}
};
@@ -131,10 +136,10 @@ template<int BASE, typename CHAR> bool CharToDigit(CHAR c, uint8* digit) {
return BaseCharToDigit<CHAR, BASE, BASE <= 10>::Convert(c, digit);
}
-// There is an IsWhitespace for wchars defined in string_util.h, but it is
-// locale independent, whereas the functions we are replacing were
-// locale-dependent. TBD what is desired, but for the moment let's not introduce
-// a change in behaviour.
+// There is an IsUnicodeWhitespace for wchars defined in string_util.h, but it
+// is locale independent, whereas the functions we are replacing were
+// locale-dependent. TBD what is desired, but for the moment let's not
+// introduce a change in behaviour.
template<typename CHAR> class WhitespaceHelper {
};
« no previous file with comments | « base/strings/pattern_unittest.cc ('k') | base/strings/string_piece.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698