From e33b401cb83d6170cd09e4c99a377d834e5cd121 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Thu, 16 Oct 2003 12:43:53 +0000 Subject: [PATCH] [project @ 2003-10-16 12:43:53 by bursa] Buffer css and scan in one piece to fix tokens split across blocks. svn path=/import/netsurf/; revision=365 --- css/css.c | 31 ++++++++++++++++++------------- css/css.h | 2 ++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/css/css.c b/css/css.c index 6fd1960c2..132bfa4bb 100644 --- a/css/css.c +++ b/css/css.c @@ -101,32 +101,37 @@ void css_create(struct content *c) c->data.css.import_url = xcalloc(0, sizeof(*c->data.css.import_url)); c->data.css.import_content = xcalloc(0, sizeof(*c->data.css.import_content)); c->active = 0; + c->data.css.data = xcalloc(0, 1); + c->data.css.length = 0; } void css_process_data(struct content *c, char *data, unsigned long size) +{ + c->data.css.data = xrealloc(c->data.css.data, c->data.css.length + size + 2); + memcpy(c->data.css.data + c->data.css.length, data, size); + c->data.css.length += size; +} + + +int css_convert(struct content *c, unsigned int width, unsigned int height) { int token; YY_BUFFER_STATE buffer; struct parse_params param = {0, c, 0}; - LOG(("content %p, size %lu", c, size)); - - buffer = css__scan_bytes(data, size, c->data.css.css->lexer); + c->data.css.data[c->data.css.length] = + c->data.css.data[c->data.css.length + 1] = 0; + buffer = css__scan_buffer(c->data.css.data, c->data.css.length + 2, + c->data.css.css->lexer); + assert(buffer); while ((token = css_lex(c->data.css.css->lexer))) { css_parser_(c->data.css.css->parser, token, xstrdup(css_get_text(c->data.css.css->lexer)), ¶m); } css__delete_buffer(buffer, c->data.css.css->lexer); -} - - -int css_convert(struct content *c, unsigned int width, unsigned int height) -{ - struct parse_params param = {0, c, 0}; - - LOG(("content %p", c)); + free(c->data.css.data); css_parser_(c->data.css.css->parser, 0, 0, ¶m); @@ -616,7 +621,7 @@ void css_dump_style(const struct css_style * const style) } fprintf(stderr, "; "); fprintf(stderr, "text-align: %s; ", css_text_align_name[style->text_align]); - fprintf(stderr, "visibility: %s", css_visibility_name[style->visibility]); + fprintf(stderr, "visibility: %s; ", css_visibility_name[style->visibility]); fprintf(stderr, "width: "); switch (style->width.width) { case CSS_WIDTH_AUTO: fprintf(stderr, "auto"); break; @@ -635,7 +640,7 @@ void css_dump_stylesheet(const struct css_stylesheet * stylesheet) unsigned int i; struct css_node *r, *n, *m; for (i = 0; i != HASH_SIZE; i++) { - fprintf(stderr, "hash %i:\n", i); + /*fprintf(stderr, "hash %i:\n", i);*/ for (r = stylesheet->rule[i]; r != 0; r = r->next) { for (n = r; n != 0; n = n->right) { if (n->data != 0) diff --git a/css/css.h b/css/css.h index f0a9ce620..a897d4d9b 100644 --- a/css/css.h +++ b/css/css.h @@ -97,6 +97,8 @@ struct content_css_data { unsigned int import_count; char **import_url; struct content **import_content; + char *data; + unsigned int length; };