RESOLVED FIXED 10820
Add StringImpl::toDouble() and remove uses of .deprecatedString().toDouble()
https://bugs.webkit.org/show_bug.cgi?id=10820
Summary Add StringImpl::toDouble() and remove uses of .deprecatedString().toDouble()
Eric Seidel (no email)
Reported 2006-09-11 23:28:21 PDT
Attached is my (broken) patch to do this. Don't know why it fails, but it does. I'll come back to it eventually. Posting now for posterity (in case I forget, or someone else wishes to give it a go).
Attachments
Broken patch (breaks layout tests for svg gradients) (18.82 KB, patch)
2006-09-11 23:29 PDT, Eric Seidel (no email)
no flags
Non-broken patch (18.08 KB, patch)
2006-09-26 00:25 PDT, Anders Carlsson
mjs: review+
Eric Seidel (no email)
Comment 1 2006-09-11 23:29:08 PDT
Created attachment 10509 [details] Broken patch (breaks layout tests for svg gradients)
Alexey Proskuryakov
Comment 2 2006-09-12 02:29:51 PDT
Perhaps String/StringImpl need a clear division between locale-sensitive and insensitive routines (number parsing can obviously be either). Not something for this bug, although a little comment in the header could be useful.
Anders Carlsson
Comment 3 2006-09-26 00:25:56 PDT
Created attachment 10778 [details] Non-broken patch I found two problems with the toDouble implementation: +double StringImpl::toDouble(bool* ok) const +{ + if (empty()) { this should be isEmpty(). empty() returns the special empty string singleton so this is always true. + if (ok) + *ok = false; + return 0; + } + char *end; + double val = kjs_strtod(Latin1Encoding().encode(characters(), length()).data(), &end); + if (ok) + *ok = end == 0 || *end == '\0'; TextEncoding::encode returns a CString which is destroyed after calling kjs_strtod. This makes the end pointer dangling so *end could potentially crash. + return val; +} I've uploaded a patch that doesn't break any layout tests.
Maciej Stachowiak
Comment 4 2006-09-26 00:28:02 PDT
Comment on attachment 10778 [details] Non-broken patch r=me
Anders Carlsson
Comment 5 2006-09-26 00:43:50 PDT
Committed revision 16568.
Dave Hyatt
Comment 6 2006-09-26 04:13:17 PDT
Please remember in the future that this kind of header include: #include <JavaScriptCore/dtoa.h> is Mac-specific. I fixed it to be #include <kjs/dtoa.h> instead to fix Win32.
Note You need to log in before you can comment on or make changes to this bug.