OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |