summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-20 23:30:21 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-11-20 23:30:21 +0000
commit249d8fcee6079aeef5bce1d2cfdc25c6454d1f0a (patch)
tree926aa2d0ede06e8f4edfc789bae8e4b237cb7613
parentdd27ee6e83d9490112356f55ec69a29fe48b4aa4 (diff)
downloadlibcss-249d8fcee6079aeef5bce1d2cfdc25c6454d1f0a.tar.gz
libcss-249d8fcee6079aeef5bce1d2cfdc25c6454d1f0a.tar.bz2
Make integer_from_css_string return the number of input bytes processed.
svn path=/trunk/libcss/; revision=5758
-rw-r--r--src/parse/css21props.c5
-rw-r--r--src/utils/utils.h7
2 files changed, 9 insertions, 3 deletions
diff --git a/src/parse/css21props.c b/src/parse/css21props.c
index f69c067..811dbe3 100644
--- a/src/parse/css21props.c
+++ b/src/parse/css21props.c
@@ -1683,7 +1683,10 @@ css_error parse_font_weight(css_css21 *c,
if (token->lower.ptr == c->strings[INHERIT]) {
flags |= FLAG_INHERIT;
} else if (token->type == CSS_TOKEN_NUMBER) {
- int32_t num = integer_from_css_string(&token->lower);
+ size_t consumed = 0;
+ int32_t num = integer_from_css_string(&token->lower, &consumed);
+ if (consumed != token->lower.len)
+ return CSS_INVALID;
switch (num) {
case 100: value = FONT_WEIGHT_100; break;
case 200: value = FONT_WEIGHT_200; break;
diff --git a/src/utils/utils.h b/src/utils/utils.h
index d31278d..b165059 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -27,14 +27,15 @@
#define UNUSED(x) ((x)=(x))
#endif
-static inline int32_t integer_from_css_string(const css_string *string)
+static inline int32_t integer_from_css_string(const css_string *string,
+ size_t *consumed)
{
size_t len;
const uint8_t *ptr;
int sign = 1;
int32_t val = 0;
- if (string == NULL || string->len == 0)
+ if (string == NULL || string->len == 0 || consumed == NULL)
return 0;
len = string->len;
@@ -64,6 +65,8 @@ static inline int32_t integer_from_css_string(const css_string *string)
len--;
}
+ *consumed = ptr - string->ptr;
+
return val * sign;
}