Changeset 65588 in webkit for trunk/JavaScriptCore/wtf/dtoa.cpp
- Timestamp:
- Aug 18, 2010, 12:41:22 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/dtoa.cpp
r64706 r65588 89 89 * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, 90 90 * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. 91 * #define INFNAN_CHECK on IEEE systems to cause strtod to check for92 * Infinity and NaN (case insensitively). On some systems (e.g.,93 * some HP systems), it may be necessary to #define NAN_WORD094 * appropriately -- to the most significant word of a quiet NaN.95 * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)96 * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,97 * strtod also accepts (case insensitively) strings of the form98 * NaN(x), where x is a string of hexadecimal digits and spaces;99 * if there is only one string of hexadecimal digits, it is taken100 * for the 52 fraction bits of the resulting NaN; if there are two101 * or more strings of hex digits, the first is for the high 20 bits,102 * the second and subsequent for the low 32 bits, with intervening103 * white space ignored; but if this results in none of the 52104 * fraction bits being on (an IEEE Infinity symbol), then NAN_WORD0105 * and NAN_WORD1 are used instead.106 91 * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that 107 92 * avoids underflows on inputs whose result does not underflow. … … 167 152 #endif 168 153 169 #define INFNAN_CHECK170 #define No_Hex_NaN171 172 154 #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(IEEE_ARM) != 1 173 155 Exactly one of IEEE_8087, IEEE_ARM or IEEE_MC68k should be defined. … … 1041 1023 #define n_bigtens 5 1042 1024 1043 #if defined(INFNAN_CHECK)1044 1045 #ifndef NAN_WORD01046 #define NAN_WORD0 0x7ff800001047 #endif1048 1049 #ifndef NAN_WORD11050 #define NAN_WORD1 01051 #endif1052 1053 static int match(const char** sp, const char* t)1054 {1055 int c, d;1056 const char* s = *sp;1057 1058 while ((d = *t++)) {1059 if ((c = *++s) >= 'A' && c <= 'Z')1060 c += 'a' - 'A';1061 if (c != d)1062 return 0;1063 }1064 *sp = s + 1;1065 return 1;1066 }1067 1068 #ifndef No_Hex_NaN1069 static void hexnan(U* rvp, const char** sp)1070 {1071 uint32_t c, x[2];1072 const char* s;1073 int havedig, udx0, xshift;1074 1075 x[0] = x[1] = 0;1076 havedig = xshift = 0;1077 udx0 = 1;1078 s = *sp;1079 while ((c = *(const unsigned char*)++s)) {1080 if (c >= '0' && c <= '9')1081 c -= '0';1082 else if (c >= 'a' && c <= 'f')1083 c += 10 - 'a';1084 else if (c >= 'A' && c <= 'F')1085 c += 10 - 'A';1086 else if (c <= ' ') {1087 if (udx0 && havedig) {1088 udx0 = 0;1089 xshift = 1;1090 }1091 continue;1092 } else if (/*(*/ c == ')' && havedig) {1093 *sp = s + 1;1094 break;1095 } else1096 return; /* invalid form: don't change *sp */1097 havedig = 1;1098 if (xshift) {1099 xshift = 0;1100 x[0] = x[1];1101 x[1] = 0;1102 }1103 if (udx0)1104 x[0] = (x[0] << 4) | (x[1] >> 28);1105 x[1] = (x[1] << 4) | c;1106 }1107 if ((x[0] &= 0xfffff) || x[1]) {1108 word0(rvp) = Exp_mask | x[0];1109 word1(rvp) = x[1];1110 }1111 }1112 #endif /*No_Hex_NaN*/1113 #endif /* INFNAN_CHECK */1114 1115 1025 double strtod(const char* s00, char** se) 1116 1026 { … … 1237 1147 if (!nd) { 1238 1148 if (!nz && !nz0) { 1239 #ifdef INFNAN_CHECK1240 /* Check for Nan and Infinity */1241 switch (c) {1242 case 'i':1243 case 'I':1244 if (match(&s, "nf")) {1245 --s;1246 if (!match(&s, "inity"))1247 ++s;1248 word0(&rv) = 0x7ff00000;1249 word1(&rv) = 0;1250 goto ret;1251 }1252 break;1253 case 'n':1254 case 'N':1255 if (match(&s, "an")) {1256 word0(&rv) = NAN_WORD0;1257 word1(&rv) = NAN_WORD1;1258 #ifndef No_Hex_NaN1259 if (*s == '(') /*)*/1260 hexnan(&rv, &s);1261 #endif1262 goto ret;1263 }1264 }1265 #endif /* INFNAN_CHECK */1266 1149 ret0: 1267 1150 s = s00;
Note:
See TracChangeset
for help on using the changeset viewer.