From d8b5dd586db230db3f09bedba9bfc0bdb254fe57 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 24 Nov 2008 00:56:48 +0000 Subject: Fix number parsing and make test code automatically determine correctness. More test data, which covers everything. Fix includes in libcss/types.h svn path=/trunk/libcss/; revision=5764 --- src/utils/utils.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/utils/utils.h') diff --git a/src/utils/utils.h b/src/utils/utils.h index eead21d..f1ab6d7 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -106,6 +106,7 @@ static inline fixed number_from_css_string(const css_string *string, len--; } fracpart = ((1 << 10) * fracpart + pwr/2) / pwr; + /* Extra paranoid clamp to maximum fractional part */ if (fracpart >= (1 << 10)) fracpart = (1 << 10) - 1; } @@ -113,13 +114,13 @@ static inline fixed number_from_css_string(const css_string *string, /* If the intpart is larger than we can represent, * then clamp to the maximum value we can store. */ if (intpart >= (1 << 21)) { - intpart = (sign == -1) ? (1 << 21) : (1 << 21) - 1; fracpart = (1 << 10) - 1; + intpart = (1 << 21) - 1; } *consumed = ptr - string->ptr; - return FMULI((intpart << 10) | fracpart, sign); + return FMULI(((intpart << 10) | fracpart), sign); } #endif -- cgit v1.2.3