GNOME Bugzilla – Bug 306823
Misparses some non-integer numbers [PATCH]
Last modified: 2007-02-14 20:28:16 UTC
Please describe the problem: libcroco misparses non-integer numbers whose first decimal place is zero (e.g. 2.05). Also, I believe it fails to reject `3.' as a number; though I haven't tested this. (Numbers in CSS must match `[0-9]+|[0-9]*\.[0-9]+'.) Steps to reproduce: stylesheet such as: .myclass { myprop: 2.05; otherprop: 3. } Actual results: the application is told that myprop has value 2.5 and that otherprop has a valid declaration with numeric value 3.0. Expected results: the application is told that myprop has value 2.05, and behaviour indicating that `otherprop: 3.' isn't a valid CSS2 declaration. Does this happen every time? yes Other information:
Created attachment 47406 [details] [review] patch to fix the described problems Switching from int_part,dec_part to numerator,denominator has additional minor benefit of more closely matching the range of double, e.g. it can represent numbers of magnitude >= 2**32 or < 10**-9. I believe the multiple divisions by 10 occurring in cr_utils_n_to_0_dot_n introduce more rounding error on average than a single division by an integral non-negative power of 10 [or nearby double, if 5**nplaces > 2**53] as used in the patch. The patch removes the cr_utils_n_to_0_dot_n function from cr-utils.h, as it is no longer used (and unlikely to be used in future). N.B. The patch doesn't add appropriate test cases. The only testing it has received is that inkscape now does the correct thing for two versions of a document where one has stroke-width: 40 and the other stroke-width: 40.02. I haven't tested the `3. is not a css number' part of the patch. I suggest waiting until we've addressed libcroco's parse error behaviour for non-CSS2 decls first. (Credit for original inkscape bug report & test cases: nicolas jacquey of svg2ps group.)
I think that I fixed this a while ago, and the fix is in 0.61
This patch is better than mine in 333057, so I've reverted mine and committed yours instead. Thanks Peter.
*** Bug 403758 has been marked as a duplicate of this bug. ***