summaryrefslogtreecommitdiff
path: root/src/utils/utils.h
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-24 00:56:48 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-11-24 00:56:48 +0000
commitd8b5dd586db230db3f09bedba9bfc0bdb254fe57 (patch)
treecc03414893089bec421e755efb949a76d470fe6e /src/utils/utils.h
parentf235d82dccb499f1af06e7ef3e1d7b9b57c12014 (diff)
downloadlibcss-d8b5dd586db230db3f09bedba9bfc0bdb254fe57.tar.gz
libcss-d8b5dd586db230db3f09bedba9bfc0bdb254fe57.tar.bz2
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
Diffstat (limited to 'src/utils/utils.h')
-rw-r--r--src/utils/utils.h5
1 files changed, 3 insertions, 2 deletions
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