Changeset 108001 in webkit for trunk/Source/JavaScriptCore/wtf
- Timestamp:
- Feb 16, 2012, 4:54:37 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore/wtf/text
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wtf/text/WTFString.cpp
r107625 r108001 1037 1037 } 1038 1038 1039 template <typename CharType >1039 template <typename CharType, WTF::AllowTrailingJunkTag allowTrailingJunk> 1040 1040 static inline double toDoubleType(const CharType* data, size_t length, bool* ok, bool* didReadNumber) 1041 1041 { … … 1054 1054 char* start = bytes.data(); 1055 1055 char* end; 1056 double val = WTF::strtod< WTF::DisallowTrailingJunk>(start, &end);1056 double val = WTF::strtod<allowTrailingJunk>(start, &end); 1057 1057 if (ok) 1058 1058 *ok = (end == 0 || *end == '\0') && !isnan(val); … … 1064 1064 double charactersToDouble(const LChar* data, size_t length, bool* ok, bool* didReadNumber) 1065 1065 { 1066 return toDoubleType<LChar >(data, length, ok, didReadNumber);1066 return toDoubleType<LChar, WTF::DisallowTrailingJunk>(data, length, ok, didReadNumber); 1067 1067 } 1068 1068 1069 1069 double charactersToDouble(const UChar* data, size_t length, bool* ok, bool* didReadNumber) 1070 1070 { 1071 return toDoubleType<UChar >(data, length, ok, didReadNumber);1071 return toDoubleType<UChar, WTF::DisallowTrailingJunk>(data, length, ok, didReadNumber); 1072 1072 } 1073 1073 … … 1075 1075 { 1076 1076 // FIXME: This will return ok even when the string fits into a double but not a float. 1077 return static_cast<float>(toDoubleType<LChar >(data, length, ok, didReadNumber));1077 return static_cast<float>(toDoubleType<LChar, WTF::DisallowTrailingJunk>(data, length, ok, didReadNumber)); 1078 1078 } 1079 1079 … … 1081 1081 { 1082 1082 // FIXME: This will return ok even when the string fits into a double but not a float. 1083 return static_cast<float>(toDoubleType<UChar>(data, length, ok, didReadNumber)); 1083 return static_cast<float>(toDoubleType<UChar, WTF::DisallowTrailingJunk>(data, length, ok, didReadNumber)); 1084 } 1085 1086 float charactersToFloatIgnoringJunk(const LChar* data, size_t length, bool* ok, bool* didReadNumber) 1087 { 1088 // FIXME: This will return ok even when the string fits into a double but not a float. 1089 return static_cast<float>(toDoubleType<LChar, WTF::AllowTrailingJunk>(data, length, ok, didReadNumber)); 1090 } 1091 1092 float charactersToFloatIgnoringJunk(const UChar* data, size_t length, bool* ok, bool* didReadNumber) 1093 { 1094 // FIXME: This will return ok even when the string fits into a double but not a float. 1095 return static_cast<float>(toDoubleType<UChar, WTF::AllowTrailingJunk>(data, length, ok, didReadNumber)); 1084 1096 } 1085 1097 -
trunk/Source/JavaScriptCore/wtf/text/WTFString.h
r106433 r108001 88 88 WTF_EXPORT_PRIVATE double charactersToDouble(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0); 89 89 float charactersToFloat(const LChar*, size_t, bool* ok = 0, bool* didReadNumber = 0); 90 WTF_EXPORT_PRIVATE float charactersToFloatIgnoringJunk(const LChar*, size_t, bool* ok = 0, bool* didReadNumber = 0); 90 91 WTF_EXPORT_PRIVATE float charactersToFloat(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0); 92 WTF_EXPORT_PRIVATE float charactersToFloatIgnoringJunk(const UChar*, size_t, bool* ok = 0, bool* didReadNumber = 0); 91 93 92 94 enum FloatConversionFlags {
Note:
See TracChangeset
for help on using the changeset viewer.