summaryrefslogtreecommitdiffstats
path: root/libass/ass_strtod.c
Commit message (Collapse)AuthorAgeFilesLines
* ass_strtod: correctly convert large negative exponentsOleg Oshmyan2016-11-211-4/+43
| | | | | | | | | | | | Avoid overflow in dblExp that prevents subnormal numbers from being generated (or small normal numbers if `double` supports many more negative exponents than positive): if `10**abs(exp)` would overflow and we actually want a negative exponent, switch to using precomputed negative powers of 10 rather than positive. Also avoid underflow for numbers with a large negative exponent where the exponent alone underflows but the significand has enough digits to cancel this out, e. g. in `10e-324` with IEEE 754 double.
* ass_strtod: don't cast away constOleg Oshmyan2016-11-211-2/+3
|
* ass_strtod: handle overflowing exponentsOleg Oshmyan2016-11-211-7/+37
| | | | | | | | | | | | The exponent may overflow an integer, e. g. in `14e888888888888888888888888888880000000000000000000000000000` on a 32-bit platform. Correctly handle this, including the case when the exponent overflows but the whole string still describes a valid floating-point number, e. g. in `1[4294967200 zeros]e-4294967300`. This fixes libass#244. Buffer overflow was fixed in 67f647e, and this ensures that the string is converted to the correct number.
* ass_strtod: skip leading zeros in mantissaOleg Oshmyan2016-11-211-3/+14
| | | | | | | | ass_strtod reads at most 18 leading digits of the mantissa. This previously included zeros, even though they are not significant digits, e. g. 0.000000000000000001e18 was converted to 0.0. After this commit, leading zeros before and after the decimal point will be skipped, so the above number will be correctly converted to 1.0.
* ass_strtod: don't report overflow for 0.0e[huge exponent]Oleg Oshmyan2016-11-211-1/+3
|
* ass_strtod: use size_t for substring lengthsOleg Oshmyan2016-11-211-18/+19
| | | | | This fixes overflow on extremely long input strings. See libass#244.
* Fully fix compilation with MSVC/ICLOleg Oshmyan2015-09-171-0/+1
| | | | | | | | | As before, this does not add any build system support: a config.h file and a project must still be manually created (or the compiler can be run manually instead of using a project). Signed-off-by: Grigori Goronzy <greg@kinoho.net> Signed-off-by: Oleg Oshmyan <chortos@inbox.lv>
* Include config.h in all source files and in no headersOleg Oshmyan2015-09-171-0/+2
| | | | | | | | | This way, #include "config.h" is consistently the very first thing the compiler sees when compiling any file. Some source files currently don't use anything defined in config.h, but it's easier and less error-prone to include it now to anticipate possible future changes in those files, config.h or other headers.
* NIH: add locale-independent string functionsGrigori Goronzy2015-09-111-4/+4
| | | | | | | | OS or platform-specific locale independent functions are painful to use and/or not available, so roll our own. Not great but the least painful and least intrusive. v2: fix indexing, use static inline
* ass_strtod: use modern Cwm42014-01-241-7/+8
|
* Fix a warning due to added constnessGrigori Goronzy2010-01-121-1/+1
|
* Constify table in ass_strtodYuriy M. Kaminskiy2010-01-121-0/+2
|
* Replace strtod with locale-independent strtodGrigori Goronzy2010-01-051-0/+247
strtod respects the locale and in some locales, the decimal separator is not a point, leading to parsing errors in tags like \pos(23.4,5), which are perfectly valid. As there isn't a really portable way to use a particular locale just for one call to strtod, reimplement it. The implementation was taken from the 1.8 branch of Ruby.