| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2008, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2008, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 typedef LChar NumberToLStringBuffer[NumberToStringBufferLength]; | 44 typedef LChar NumberToLStringBuffer[NumberToStringBufferLength]; |
| 45 | 45 |
| 46 WTF_EXPORT const char* numberToString(double, NumberToStringBuffer); | 46 WTF_EXPORT const char* numberToString(double, NumberToStringBuffer); |
| 47 WTF_EXPORT const char* numberToFixedPrecisionString(double, unsigned significant
Figures, NumberToStringBuffer, bool truncateTrailingZeros = false); | 47 WTF_EXPORT const char* numberToFixedPrecisionString(double, unsigned significant
Figures, NumberToStringBuffer, bool truncateTrailingZeros = false); |
| 48 WTF_EXPORT const char* numberToFixedWidthString(double, unsigned decimalPlaces,
NumberToStringBuffer); | 48 WTF_EXPORT const char* numberToFixedWidthString(double, unsigned decimalPlaces,
NumberToStringBuffer); |
| 49 | 49 |
| 50 WTF_EXPORT double parseDouble(const LChar* string, size_t length, size_t& parsed
Length); | 50 WTF_EXPORT double parseDouble(const LChar* string, size_t length, size_t& parsed
Length); |
| 51 WTF_EXPORT double parseDouble(const UChar* string, size_t length, size_t& parsed
Length); | 51 WTF_EXPORT double parseDouble(const UChar* string, size_t length, size_t& parsed
Length); |
| 52 | 52 |
| 53 namespace Internal { | 53 namespace Internal { |
| 54 double parseDoubleFromLongString(const UChar* string, size_t length, size_t&
parsedLength); | 54 double parseDoubleFromLongString(const UChar* string, size_t length, size_t& par
sedLength); |
| 55 } | 55 } |
| 56 | 56 |
| 57 inline double parseDouble(const LChar* string, size_t length, size_t& parsedLeng
th) | 57 inline double parseDouble(const LChar* string, size_t length, size_t& parsedLeng
th) { |
| 58 { | 58 return double_conversion::StringToDoubleConverter::StringToDouble(reinterpret_
cast<const char*>(string), length, &parsedLength); |
| 59 return double_conversion::StringToDoubleConverter::StringToDouble(reinterpre
t_cast<const char*>(string), length, &parsedLength); | |
| 60 } | 59 } |
| 61 | 60 |
| 62 inline double parseDouble(const UChar* string, size_t length, size_t& parsedLeng
th) | 61 inline double parseDouble(const UChar* string, size_t length, size_t& parsedLeng
th) { |
| 63 { | 62 const size_t conversionBufferSize = 64; |
| 64 const size_t conversionBufferSize = 64; | 63 if (length > conversionBufferSize) |
| 65 if (length > conversionBufferSize) | 64 return Internal::parseDoubleFromLongString(string, length, parsedLength); |
| 66 return Internal::parseDoubleFromLongString(string, length, parsedLength)
; | 65 LChar conversionBuffer[conversionBufferSize]; |
| 67 LChar conversionBuffer[conversionBufferSize]; | 66 for (size_t i = 0; i < length; ++i) |
| 68 for (size_t i = 0; i < length; ++i) | 67 conversionBuffer[i] = isASCII(string[i]) ? static_cast<LChar>(string[i]) : 0
; |
| 69 conversionBuffer[i] = isASCII(string[i]) ? static_cast<LChar>(string[i])
: 0; | 68 return parseDouble(conversionBuffer, length, parsedLength); |
| 70 return parseDouble(conversionBuffer, length, parsedLength); | |
| 71 } | 69 } |
| 72 | 70 |
| 73 } // namespace WTF | 71 } // namespace WTF |
| 74 | 72 |
| 75 using WTF::NumberToStringBuffer; | 73 using WTF::NumberToStringBuffer; |
| 76 using WTF::NumberToLStringBuffer; | 74 using WTF::NumberToLStringBuffer; |
| 77 using WTF::numberToString; | 75 using WTF::numberToString; |
| 78 using WTF::numberToFixedPrecisionString; | 76 using WTF::numberToFixedPrecisionString; |
| 79 using WTF::numberToFixedWidthString; | 77 using WTF::numberToFixedWidthString; |
| 80 using WTF::parseDouble; | 78 using WTF::parseDouble; |
| 81 | 79 |
| 82 #endif // WTF_dtoa_h | 80 #endif // WTF_dtoa_h |
| OLD | NEW |