From 249d8fcee6079aeef5bce1d2cfdc25c6454d1f0a Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 20 Nov 2008 23:30:21 +0000 Subject: Make integer_from_css_string return the number of input bytes processed. svn path=/trunk/libcss/; revision=5758 --- src/parse/css21props.c | 5 ++++- src/utils/utils.h | 7 +++++-- 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; } -- cgit v1.2.1