After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 306823 - Misparses some non-integer numbers [PATCH]
Misparses some non-integer numbers [PATCH]
Status: RESOLVED FIXED
Product: libcroco
Classification: Core
Component: General
0.6
Other All
: High normal
: ---
Assigned To: libcroco maintainers
libcroco maintainers
: 403758 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-06-07 22:23 UTC by Peter Moulder
Modified: 2007-02-14 20:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch to fix the described problems (4.76 KB, patch)
2005-06-07 23:05 UTC, Peter Moulder
none Details | Review

Description Peter Moulder 2005-06-07 22:23:41 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:
Comment 1 Peter Moulder 2005-06-07 23:05:16 UTC
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.)
Comment 2 Dominic Lachowicz 2006-04-27 22:25:48 UTC
I think that I fixed this a while ago, and the fix is in 0.61
Comment 3 Dominic Lachowicz 2006-04-29 13:08:21 UTC
This patch is better than mine in 333057, so I've reverted mine and committed yours instead. Thanks Peter.
Comment 4 Dominic Lachowicz 2007-02-14 20:28:16 UTC
*** Bug 403758 has been marked as a duplicate of this bug. ***