From 90e05332d329663b9616bae2792b7cb36d03e13f Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 15 Feb 2009 01:59:58 +0000 Subject: Quirks mode parsing svn path=/trunk/libcss/; revision=6519 --- test/css21.c | 11 +++++----- test/parse-auto.c | 25 +++++++++++++--------- test/parse2-auto.c | 2 +- test/select-auto.c | 62 +++++++++++++++++++++++++++++++----------------------- 4 files changed, 58 insertions(+), 42 deletions(-) (limited to 'test') diff --git a/test/css21.c b/test/css21.c index 93200f5..b19fc2e 100644 --- a/test/css21.c +++ b/test/css21.c @@ -43,8 +43,8 @@ int main(int argc, char **argv) for (int count = 0; count < ITERATIONS; count++) { assert(css_stylesheet_create(CSS_LEVEL_21, "UTF-8", argv[2], - NULL, CSS_ORIGIN_AUTHOR, CSS_MEDIA_ALL, ctx, - myrealloc, NULL, &sheet) == CSS_OK); + NULL, CSS_ORIGIN_AUTHOR, CSS_MEDIA_ALL, false, + ctx, myrealloc, NULL, &sheet) == CSS_OK); fp = fopen(argv[2], "rb"); if (fp == NULL) { @@ -92,13 +92,14 @@ int main(int argc, char **argv) css_stylesheet *import; char buf[lwc_string_length(url) + 1]; - memcpy(buf, lwc_string_data(url), lwc_string_length(url)); + memcpy(buf, lwc_string_data(url), + lwc_string_length(url)); buf[lwc_string_length(url)] = '\0'; assert(css_stylesheet_create(CSS_LEVEL_21, "UTF-8", buf, NULL, CSS_ORIGIN_AUTHOR, - media, ctx, myrealloc, NULL, &import) == - CSS_OK); + media, false, ctx, myrealloc, NULL, + &import) == CSS_OK); assert(css_stylesheet_data_done(import) == CSS_OK); diff --git a/test/parse-auto.c b/test/parse-auto.c index 5ed0f55..1bb868b 100644 --- a/test/parse-auto.c +++ b/test/parse-auto.c @@ -312,7 +312,7 @@ void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen) lwc_context_ref(ctx); assert(css_stylesheet_create(CSS_LEVEL_21, "UTF-8", "foo", NULL, - CSS_ORIGIN_AUTHOR, CSS_MEDIA_ALL, ctx, + CSS_ORIGIN_AUTHOR, CSS_MEDIA_ALL, false, ctx, myrealloc, NULL, &sheet) == CSS_OK); error = css_stylesheet_append_data(sheet, data, len); @@ -336,12 +336,13 @@ void run_test(const uint8_t *data, size_t len, exp_entry *exp, size_t explen) css_stylesheet *import; char buf[lwc_string_length(url) + 1]; - memcpy(buf, lwc_string_data(url), lwc_string_length(url)); + memcpy(buf, lwc_string_data(url), + lwc_string_length(url)); buf[lwc_string_length(url)] = '\0'; assert(css_stylesheet_create(CSS_LEVEL_21, "UTF-8", buf, NULL, CSS_ORIGIN_AUTHOR, - media, ctx, myrealloc, NULL, &import) == + media, false, ctx, myrealloc, NULL, &import) == CSS_OK); assert(css_stylesheet_register_import(sheet, @@ -443,8 +444,7 @@ void validate_rule_selector(css_rule_selector *s, exp_entry *e, int testnum) } if (j != e->stused) { - lwc_string **p = - (void *) ((uint8_t *) + lwc_string **p = (void *) ((uint8_t *) s->style->bytecode + i); if (lwc_string_length(*p) != @@ -452,8 +452,10 @@ void validate_rule_selector(css_rule_selector *s, exp_entry *e, int testnum) memcmp(lwc_string_data(*p), e->stringtab[j].string, lwc_string_length(*p)) != 0) { - printf("%d: Got string '%.*s'. Expected '%s'\n", - testnum, (int) lwc_string_length(*p), + printf("%d: Got string '%.*s'. " + "Expected '%s'\n", + testnum, + (int) lwc_string_length(*p), lwc_string_data(*p), e->stringtab[j].string); assert(0 && "Strings differ"); @@ -496,7 +498,8 @@ void validate_rule_import(css_rule_import *s, exp_entry *e, int testnum) if (strncmp(lwc_string_data(s->url), e->name, lwc_string_length(s->url)) != 0) { printf("%d: Got URL '%.*s'. Expected '%s'\n", - testnum, (int) lwc_string_length(s->url), lwc_string_data(s->url), + testnum, (int) lwc_string_length(s->url), + lwc_string_data(s->url), e->name); assert(0 && "Mismatched URLs"); } @@ -547,7 +550,8 @@ void dump_selector_detail(css_selector_detail *detail, char **ptr) { switch (detail->type) { case CSS_SELECTOR_ELEMENT: - if (lwc_string_length(detail->name) == 1 && lwc_string_data(detail->name)[0] == '*' && + if (lwc_string_length(detail->name) == 1 && + lwc_string_data(detail->name)[0] == '*' && detail->next == 0) { dump_string(detail->name, ptr); } else if (lwc_string_length(detail->name) != 1 || @@ -628,6 +632,7 @@ void dump_selector_detail(css_selector_detail *detail, char **ptr) void dump_string(lwc_string *string, char **ptr) { - *ptr += sprintf(*ptr, "%.*s", (int) lwc_string_length(string), lwc_string_data(string)); + *ptr += sprintf(*ptr, "%.*s", (int) lwc_string_length(string), + lwc_string_data(string)); } diff --git a/test/parse2-auto.c b/test/parse2-auto.c index aedc46b..dd3c529 100644 --- a/test/parse2-auto.c +++ b/test/parse2-auto.c @@ -176,7 +176,7 @@ void run_test(const uint8_t *data, size_t len, const char *exp, size_t explen) lwc_context_ref(ctx); assert(css_stylesheet_create(CSS_LEVEL_21, "UTF-8", "foo", NULL, - CSS_ORIGIN_AUTHOR, CSS_MEDIA_ALL, ctx, + CSS_ORIGIN_AUTHOR, CSS_MEDIA_ALL, false, ctx, myrealloc, NULL, &sheet) == CSS_OK); error = css_stylesheet_append_data(sheet, data, len); diff --git a/test/select-auto.c b/test/select-auto.c index a0f0966..a4e6158 100644 --- a/test/select-auto.c +++ b/test/select-auto.c @@ -441,7 +441,8 @@ void parse_sheet(line_ctx *ctx, const char *data, size_t len) /** \todo How are we going to handle @import? */ assert(css_stylesheet_create(CSS_LEVEL_21, "UTF-8", "foo", "foo", - origin, media, ctx->dict, myrealloc, NULL, &sheet) == CSS_OK); + origin, media, false, ctx->dict, myrealloc, NULL, + &sheet) == CSS_OK); /* Extend array of sheets and append new sheet to it */ temp = realloc(ctx->sheets, @@ -697,7 +698,7 @@ css_error named_ancestor_node(void *pw, void *n, for (node = node->parent; node != NULL; node = node->parent) { bool match; assert(lwc_context_string_caseless_isequal(ctx->dict, - name, node->name, &match) == lwc_error_ok); + name, node->name, &match) == lwc_error_ok); if (match == true) break; } @@ -718,8 +719,8 @@ css_error named_parent_node(void *pw, void *n, if (node->parent != NULL) { bool match; assert(lwc_context_string_caseless_isequal(ctx->dict, - name, node->parent->name, - &match) == lwc_error_ok); + name, node->parent->name, &match) == + lwc_error_ok); if (match == true) *parent = (void *) node->parent; } @@ -738,8 +739,8 @@ css_error named_sibling_node(void *pw, void *n, if (node->prev != NULL) { bool match; assert(lwc_context_string_caseless_isequal(ctx->dict, - name, node->prev->name, - &match) == lwc_error_ok); + name, node->prev->name, &match) == + lwc_error_ok); if (match == true) *sibling = (void *) node->prev; } @@ -779,8 +780,9 @@ css_error node_has_class(void *pw, void *n, for (i = 0; i < node->n_attrs; i++) { bool amatch; - assert(lwc_context_string_caseless_isequal(ctx->dict, node->attrs[i].name, - ctx->attr_class, &amatch) == lwc_error_ok); + assert(lwc_context_string_caseless_isequal(ctx->dict, + node->attrs[i].name, ctx->attr_class, + &amatch) == lwc_error_ok); if (amatch == true) break; } @@ -804,8 +806,9 @@ css_error node_has_id(void *pw, void *n, for (i = 0; i < node->n_attrs; i++) { bool amatch; - assert(lwc_context_string_caseless_isequal(ctx->dict, node->attrs[i].name, - ctx->attr_id, &amatch) == lwc_error_ok); + assert(lwc_context_string_caseless_isequal(ctx->dict, + node->attrs[i].name, ctx->attr_id, &amatch) == + lwc_error_ok); if (amatch == true) break; } @@ -829,8 +832,9 @@ css_error node_has_attribute(void *pw, void *n, *match = false; for (i = 0; i < node->n_attrs; i++) { - assert(lwc_context_string_caseless_isequal(ctx->dict, node->attrs[i].name, - name, match) == lwc_error_ok); + assert(lwc_context_string_caseless_isequal(ctx->dict, + node->attrs[i].name, name, match) == + lwc_error_ok); if (*match == true) break; } @@ -850,15 +854,17 @@ css_error node_has_attribute_equal(void *pw, void *n, *match = false; for (i = 0; i < node->n_attrs; i++) { - assert(lwc_context_string_caseless_isequal(ctx->dict, node->attrs[i].name, - name, match) == lwc_error_ok); + assert(lwc_context_string_caseless_isequal(ctx->dict, + node->attrs[i].name, name, match) == + lwc_error_ok); if (*match == true) break; } if (*match == true) { - assert(lwc_context_string_caseless_isequal(ctx->dict, node->attrs[i].name, - value, match) == lwc_error_ok); + assert(lwc_context_string_caseless_isequal(ctx->dict, + node->attrs[i].name, value, match) == + lwc_error_ok); } return CSS_OK; @@ -877,8 +883,9 @@ css_error node_has_attribute_includes(void *pw, void *n, *match = false; for (i = 0; i < node->n_attrs; i++) { - assert(lwc_context_string_caseless_isequal(ctx->dict, node->attrs[i].name, - name, match) == lwc_error_ok); + assert(lwc_context_string_caseless_isequal(ctx->dict, + node->attrs[i].name, name, match) == + lwc_error_ok); if (*match == true) break; } @@ -886,7 +893,8 @@ css_error node_has_attribute_includes(void *pw, void *n, if (*match == true) { const char *p; const char *start = lwc_string_data(node->attrs[i].value); - const char *end = start + lwc_string_length(node->attrs[i].value); + const char *end = start + + lwc_string_length(node->attrs[i].value); *match = false; @@ -894,8 +902,8 @@ css_error node_has_attribute_includes(void *pw, void *n, if (*p == ' ') { if ((size_t) (p - start) == vlen && strncasecmp(start, - lwc_string_data(value), - vlen) == 0) { + lwc_string_data(value), + vlen) == 0) { *match = true; break; } @@ -921,8 +929,9 @@ css_error node_has_attribute_dashmatch(void *pw, void *n, *match = false; for (i = 0; i < node->n_attrs; i++) { - assert(lwc_context_string_caseless_isequal(ctx->dict, node->attrs[i].name, - name, match) == lwc_error_ok); + assert(lwc_context_string_caseless_isequal(ctx->dict, + node->attrs[i].name, name, match) == + lwc_error_ok); if (*match == true) break; } @@ -930,7 +939,8 @@ css_error node_has_attribute_dashmatch(void *pw, void *n, if (*match == true) { const char *p; const char *start = lwc_string_data(node->attrs[i].value); - const char *end = start + lwc_string_length(node->attrs[i].value); + const char *end = start + + lwc_string_length(node->attrs[i].value); *match = false; @@ -938,8 +948,8 @@ css_error node_has_attribute_dashmatch(void *pw, void *n, if (*p == '-') { if ((size_t) (p - start) == vlen && strncasecmp(start, - lwc_string_data(value), - vlen) == 0) { + lwc_string_data(value), + vlen) == 0) { *match = true; break; } -- cgit v1.2.3