Changeset 102004 in vbox for trunk/src/libs/xpcom18a4
- Timestamp:
- Nov 8, 2023 7:07:08 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/nsprpub/pr/src/io/prscanf.c
r102000 r102004 337 337 } 338 338 339 static PRStatus340 GetFloat(ScanfState *state)341 {342 char buf[FMAX + 1], *p;343 int ch;344 PRBool seenDigit = PR_FALSE;345 346 if (state->width == 0 || state->width > FMAX) {347 state->width = FMAX;348 }349 p = buf;350 GET_IF_WITHIN_WIDTH(state, ch);351 if (WITHIN_WIDTH(state) && (ch == '+' || ch == '-')) {352 *p++ = ch;353 GET_IF_WITHIN_WIDTH(state, ch);354 }355 while (WITHIN_WIDTH(state) && isdigit(ch)) {356 *p++ = ch;357 GET_IF_WITHIN_WIDTH(state, ch);358 seenDigit = PR_TRUE;359 }360 if (WITHIN_WIDTH(state) && ch == DECIMAL_POINT) {361 *p++ = ch;362 GET_IF_WITHIN_WIDTH(state, ch);363 while (WITHIN_WIDTH(state) && isdigit(ch)) {364 *p++ = ch;365 GET_IF_WITHIN_WIDTH(state, ch);366 seenDigit = PR_TRUE;367 }368 }369 370 /*371 * This is not robust. For example, "1.2e+" would confuse372 * the code below to read 'e' and '+', only to realize that373 * it should have stopped at "1.2". But we can't push back374 * more than one character, so there is nothing I can do.375 */376 377 /* Parse exponent */378 if (WITHIN_WIDTH(state) && (ch == 'e' || ch == 'E') && seenDigit) {379 *p++ = ch;380 GET_IF_WITHIN_WIDTH(state, ch);381 if (WITHIN_WIDTH(state) && (ch == '+' || ch == '-')) {382 *p++ = ch;383 GET_IF_WITHIN_WIDTH(state, ch);384 }385 while (WITHIN_WIDTH(state) && isdigit(ch)) {386 *p++ = ch;387 GET_IF_WITHIN_WIDTH(state, ch);388 }389 }390 if (WITHIN_WIDTH(state)) {391 UNGET(state, ch);392 }393 if (!seenDigit) {394 return PR_FAILURE;395 }396 *p = '\0';397 if (state->assign) {398 PRFloat64 dval = PR_strtod(buf, NULL);399 400 state->converted = PR_TRUE;401 if (state->sizeSpec == _PR_size_l) {402 *va_arg(state->ap, PRFloat64 *) = dval;403 } else if (state->sizeSpec == _PR_size_L) {404 #if defined(OSF1) || defined(IRIX)405 *va_arg(state->ap, double *) = dval;406 #else407 *va_arg(state->ap, long double *) = dval;408 #endif409 } else {410 *va_arg(state->ap, float *) = (float) dval;411 }412 }413 return PR_SUCCESS;414 }415 416 339 /* 417 340 * Convert, and return the end of the conversion spec. … … 463 386 case 'e': case 'E': case 'f': 464 387 case 'g': case 'G': 465 if (GetFloat(state) == PR_FAILURE) { 466 return NULL; 467 } 388 /** @todo r=aeichner 389 * PR_sscanf is only called in one point by now and it doesn't parse any floats, 390 * and it will hopefully go away soon anyway. 391 */ 392 AssertReleaseFailed(); 393 return NULL; 468 394 break; 469 395 case 'n':
Note:
See TracChangeset
for help on using the changeset viewer.