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

Side by Side Diff: Source/platform/DateComponents.cpp

Issue 141273002: Code problems detected by cppcheck (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 6 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 unified diff | Download patch
« no previous file with comments | « Source/core/xml/XPathFunctions.cpp ('k') | Source/platform/Decimal.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 for (; index < src.length(); ++index) { 93 for (; index < src.length(); ++index) {
94 if (!isASCIIDigit(src[index])) 94 if (!isASCIIDigit(src[index]))
95 break; 95 break;
96 } 96 }
97 return index - start; 97 return index - start;
98 } 98 }
99 99
100 // Very strict integer parser. Do not allow leading or trailing whitespace unlik e charactersToIntStrict(). 100 // Very strict integer parser. Do not allow leading or trailing whitespace unlik e charactersToIntStrict().
101 static bool toInt(const String& src, unsigned parseStart, unsigned parseLength, int& out) 101 static bool toInt(const String& src, unsigned parseStart, unsigned parseLength, int& out)
102 { 102 {
103 if (parseStart + parseLength > src.length() || parseLength <= 0) 103 if (parseStart + parseLength > src.length() || !parseLength)
104 return false; 104 return false;
105 int value = 0; 105 int value = 0;
106 unsigned current = parseStart; 106 unsigned current = parseStart;
107 unsigned end = current + parseLength; 107 unsigned end = current + parseLength;
108 108
109 // We don't need to handle negative numbers for ISO 8601. 109 // We don't need to handle negative numbers for ISO 8601.
110 for (; current < end; ++current) { 110 for (; current < end; ++current) {
111 if (!isASCIIDigit(src[current])) 111 if (!isASCIIDigit(src[current]))
112 return false; 112 return false;
113 int digit = src[current] - '0'; 113 int digit = src[current] - '0';
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 case Week: 703 case Week:
704 return String::format("%04d-W%02d", m_year, m_week); 704 return String::format("%04d-W%02d", m_year, m_week);
705 case Invalid: 705 case Invalid:
706 break; 706 break;
707 } 707 }
708 ASSERT_NOT_REACHED(); 708 ASSERT_NOT_REACHED();
709 return String("(Invalid DateComponents)"); 709 return String("(Invalid DateComponents)");
710 } 710 }
711 711
712 } // namespace WebCore 712 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/xml/XPathFunctions.cpp ('k') | Source/platform/Decimal.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698