summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2019-02-18 00:35:31 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2019-03-10 13:42:03 +0000
commit861681b2717ed605f26af326d82d9b2009714c2e (patch)
tree70fc59fe5bcc47b34b69153c7eac274c9d3afd28
parentdb3834aa96dc06f4be51d936246e2a297e02fecf (diff)
downloadlibcss-861681b2717ed605f26af326d82d9b2009714c2e.tar.gz
libcss-861681b2717ed605f26af326d82d9b2009714c2e.tar.bz2
Parse: maintain stack of brackets in parseAny
-rw-r--r--src/parse/parse.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/parse/parse.c b/src/parse/parse.c
index 91bcff5..afc6d72 100644
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -99,8 +99,6 @@ struct css_parser
bool parseError; /**< A parse error has occurred */
parserutils_stack *open_items; /**< Stack of open brackets */
- uint8_t match_char; /**< Close bracket type for parseAny */
-
bool last_was_ws; /**< Last token was whitespace */
css_parser_event_handler event; /**< Client's event handler */
@@ -478,7 +476,6 @@ css_error css__parser_create_internal(const char *charset,
p->quirks = false;
p->pushback = NULL;
p->parseError = false;
- p->match_char = 0;
p->event = NULL;
p->last_was_ws = false;
p->event_pw = NULL;
@@ -2044,14 +2041,15 @@ css_error parseAny(css_parser *parser)
}
if (token->type == CSS_TOKEN_FUNCTION) {
- parser->match_char = ')';
+ parserutils_stack_push(parser->open_items, &")"[0]);
state->substate = WS;
} else if (token->type == CSS_TOKEN_CHAR &&
lwc_string_length(token->idata) == 1 &&
(lwc_string_data(token->idata)[0] == '(' ||
lwc_string_data(token->idata)[0] == '[')) {
- parser->match_char = lwc_string_data(
- token->idata)[0] == '(' ? ')' : ']';
+ parserutils_stack_push(parser->open_items,
+ &(lwc_string_data(
+ token->idata)[0] == '(' ? ")" : "]")[0]);
state->substate = WS;
} else {
state->substate = WS2;
@@ -2086,7 +2084,9 @@ css_error parseAny(css_parser *parser)
if (token->type == CSS_TOKEN_CHAR &&
lwc_string_length(token->idata) == 1 &&
lwc_string_data(token->idata)[0] ==
- parser->match_char) {
+ ((uint8_t *) parserutils_stack_get_current(
+ parser->open_items))[0]) {
+ parserutils_stack_pop(parser->open_items, NULL);
state->substate = WS2;
goto ws2;
}