Bug 910814 - SpiderMonkey: Document that js_strtod_harder doesn't actually report overflow errors, and clean up its callers accordingly. r=waldo

This commit is contained in:
Dan Gohman 2013-09-04 10:11:22 -07:00
parent eda03c54d2
commit 08213aaf2a
3 changed files with 4 additions and 9 deletions

View File

@ -48,6 +48,7 @@ inline void* dtoa_malloc(size_t size) { return js_malloc(size); }
inline void dtoa_free(void* p) { return js_free(p); }
#define NO_GLOBAL_STATE
#define NO_ERRNO
#define MALLOC dtoa_malloc
#define FREE dtoa_free
#include "dtoa.c"

View File

@ -31,10 +31,10 @@ js_DestroyDtoaState(DtoaState *state);
* scan. If no number can be formed, *se receives a pointer to the first
* unparseable character in s00, and zero is returned.
*
* *err is set to zero on success; it's set to JS_DTOA_ERANGE on range
* errors and JS_DTOA_ENOMEM on memory failure.
* On overflow, this function returns infinity and does not indicate an error.
*
* *err is set to zero on success; it's set to JS_DTOA_ENOMEM on memory failure.
*/
#define JS_DTOA_ERANGE 1
#define JS_DTOA_ENOMEM 2
double
js_strtod_harder(DtoaState *state, const char *s00, char **se, int *err);

View File

@ -79,8 +79,6 @@ ComputeAccurateDecimalInteger(ThreadSafeContext *cx,
js_free(cstr);
return false;
}
if (err == JS_DTOA_ERANGE && *dp == HUGE_VAL)
*dp = js_PositiveInfinity;
js_free(cstr);
return true;
}
@ -1718,10 +1716,6 @@ js_strtod(ThreadSafeContext *cx, const jschar *s, const jschar *send,
} else {
int err;
d = js_strtod_harder(cx->dtoaState(), cstr, &estr, &err);
if (d == HUGE_VAL)
d = js_PositiveInfinity;
else if (d == -HUGE_VAL)
d = js_NegativeInfinity;
}
i = estr - cstr;