Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 // Read a string of digits as an unsigned number (cap just below kMaxInt). | 80 // Read a string of digits as an unsigned number (cap just below kMaxInt). |
| 81 int ReadUnsignedNumber() { | 81 int ReadUnsignedNumber() { |
| 82 has_read_number_ = true; | 82 has_read_number_ = true; |
| 83 int n; | 83 int n; |
| 84 for (n = 0; IsAsciiDigit() && n < kMaxInt / 10 - 1; Next()) { | 84 for (n = 0; IsAsciiDigit() && n < kMaxInt / 10 - 1; Next()) { |
| 85 n = n * 10 + ch_ - '0'; | 85 n = n * 10 + ch_ - '0'; |
| 86 } | 86 } |
| 87 return n; | 87 return n; |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Read a string of up to three digits as an unsigned number of milliseconds | |
| 91 int ReadMilliseconds() { | |
| 92 has_read_number_ = true; | |
| 93 int n = 0; | |
| 94 int i; | |
| 95 for (i = 0; IsAsciiDigit(); Next(), i++) { | |
| 96 if (i < 3) n = n + pow(10, 2 - i) * (ch_ - '0'); | |
|
Lasse Reichstein
2010/11/25 12:56:05
I'm somewhat opposed to using the standard pow(dou
Florian Loitsch
2010/11/25 13:55:54
Isn't this simply:
for (int i = 0; IsAsciiDigit();
Lasse Reichstein
2010/11/25 14:10:36
Not if there are fewer than three digits. We need
| |
| 97 } | |
| 98 return n; | |
| 99 } | |
| 100 | |
| 90 // Read a word (sequence of chars. >= 'A'), fill the given buffer with a | 101 // Read a word (sequence of chars. >= 'A'), fill the given buffer with a |
| 91 // lower-case prefix, and pad any remainder of the buffer with zeroes. | 102 // lower-case prefix, and pad any remainder of the buffer with zeroes. |
| 92 // Return word length. | 103 // Return word length. |
| 93 int ReadWord(uint32_t* prefix, int prefix_size) { | 104 int ReadWord(uint32_t* prefix, int prefix_size) { |
| 94 int len; | 105 int len; |
| 95 for (len = 0; IsAsciiAlphaOrAbove(); Next(), len++) { | 106 for (len = 0; IsAsciiAlphaOrAbove(); Next(), len++) { |
| 96 if (len < prefix_size) prefix[len] = AsciiAlphaToLower(ch_); | 107 if (len < prefix_size) prefix[len] = AsciiAlphaToLower(ch_); |
| 97 } | 108 } |
| 98 for (int i = len; i < prefix_size; i++) prefix[i] = 0; | 109 for (int i = len; i < prefix_size; i++) prefix[i] = 0; |
| 99 return len; | 110 return len; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 int comp_[kSize]; | 253 int comp_[kSize]; |
| 243 int index_; | 254 int index_; |
| 244 int named_month_; | 255 int named_month_; |
| 245 }; | 256 }; |
| 246 }; | 257 }; |
| 247 | 258 |
| 248 | 259 |
| 249 } } // namespace v8::internal | 260 } } // namespace v8::internal |
| 250 | 261 |
| 251 #endif // V8_DATEPARSER_H_ | 262 #endif // V8_DATEPARSER_H_ |
| OLD | NEW |