| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } else if (*current == '-') { | 261 } else if (*current == '-') { |
| 262 ++current; | 262 ++current; |
| 263 if (current == end) { | 263 if (current == end) { |
| 264 return JunkStringValue(); | 264 return JunkStringValue(); |
| 265 } | 265 } |
| 266 negative = true; | 266 negative = true; |
| 267 } | 267 } |
| 268 | 268 |
| 269 if (radix == 0) { | 269 if (radix == 0) { |
| 270 // Radix detection. | 270 // Radix detection. |
| 271 radix = 10; |
| 271 if (*current == '0') { | 272 if (*current == '0') { |
| 272 ++current; | 273 ++current; |
| 273 if (current == end) return SignedZero(negative); | 274 if (current == end) return SignedZero(negative); |
| 274 if (*current == 'x' || *current == 'X') { | 275 if (*current == 'x' || *current == 'X') { |
| 275 radix = 16; | 276 radix = 16; |
| 276 ++current; | 277 ++current; |
| 277 if (current == end) return JunkStringValue(); | 278 if (current == end) return JunkStringValue(); |
| 278 } else { | 279 } else { |
| 279 radix = 8; | |
| 280 leading_zero = true; | 280 leading_zero = true; |
| 281 } | 281 } |
| 282 } else { | |
| 283 radix = 10; | |
| 284 } | 282 } |
| 285 } else if (radix == 16) { | 283 } else if (radix == 16) { |
| 286 if (*current == '0') { | 284 if (*current == '0') { |
| 287 // Allow "0x" prefix. | 285 // Allow "0x" prefix. |
| 288 ++current; | 286 ++current; |
| 289 if (current == end) return SignedZero(negative); | 287 if (current == end) return SignedZero(negative); |
| 290 if (*current == 'x' || *current == 'X') { | 288 if (*current == 'x' || *current == 'X') { |
| 291 ++current; | 289 ++current; |
| 292 if (current == end) return JunkStringValue(); | 290 if (current == end) return JunkStringValue(); |
| 293 } else { | 291 } else { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 ASSERT(buffer_pos < kBufferSize); | 669 ASSERT(buffer_pos < kBufferSize); |
| 672 buffer[buffer_pos] = '\0'; | 670 buffer[buffer_pos] = '\0'; |
| 673 | 671 |
| 674 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); | 672 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); |
| 675 return (sign == NEGATIVE) ? -converted : converted; | 673 return (sign == NEGATIVE) ? -converted : converted; |
| 676 } | 674 } |
| 677 | 675 |
| 678 } } // namespace v8::internal | 676 } } // namespace v8::internal |
| 679 | 677 |
| 680 #endif // V8_CONVERSIONS_INL_H_ | 678 #endif // V8_CONVERSIONS_INL_H_ |
| OLD | NEW |