From db11b6452f24c9b58e410aeaaa62854a4ef8c189 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 9 Jan 2006 01:20:03 +0100 Subject: [PATCH 01/31] Fix a typo and a ref:[] --- src/dom/sgml/parser.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dom/sgml/parser.h b/src/dom/sgml/parser.h index dd354263..03225966 100644 --- a/src/dom/sgml/parser.h +++ b/src/dom/sgml/parser.h @@ -89,7 +89,8 @@ typedef enum sgml_parser_code * * This struct hold info used while parsing SGML data. * - * NOTE: The only variable the user should set is ref:[error_func]. */ + * NOTE: The only variable the user should set is ref:[sgml_parser.error_func]. + */ struct sgml_parser { enum sgml_parser_type type; /*:: Stream or tree */ enum sgml_parser_flag flags; /*:: Flags that control the behaviour */ @@ -149,7 +150,7 @@ parse_sgml(struct sgml_parser *parser, struct dom_string *buffer, int complete); * Returns what line number the parser is currently at or zero if there has * been no parsing yet. * - * NOTE: Line numbers are recoderded in the scanner tokens. + * NOTE: Line numbers are recorded in the scanner tokens. */ unsigned int get_sgml_parser_line_number(struct sgml_parser *parser); From 5808b4ae0c25630476dce17c496cc6bfd93fd197 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 9 Jan 2006 01:22:33 +0100 Subject: [PATCH 02/31] Make html_top have a pointer type; use it to declare format and par_format --- src/document/html/internal.h | 6 +++--- src/document/html/parser.c | 34 +++++++++++++++--------------- src/document/html/parser/forms.c | 10 ++++----- src/document/html/parser/general.c | 30 +++++++++++++------------- src/document/html/parser/link.c | 22 +++++++++---------- src/document/html/parser/parse.c | 34 +++++++++++++++--------------- src/document/html/parser/stack.c | 4 ++-- 7 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/document/html/internal.h b/src/document/html/internal.h index 968b208e..b85a8727 100644 --- a/src/document/html/internal.h +++ b/src/document/html/internal.h @@ -114,9 +114,9 @@ struct html_context { void *(*special_f)(struct html_context *, enum html_special_type, ...); }; -#define format (((struct html_element *) html_context->stack.next)->attr) -#define par_format (((struct html_element *) html_context->stack.next)->parattr) -#define html_top (*(struct html_element *) html_context->stack.next) +#define html_top ((struct html_element *) html_context->stack.next) +#define format (html_top->attr) +#define par_format (html_top->parattr) #define html_is_preformatted() (format.style.attr & AT_PREFORMATTED) diff --git a/src/document/html/parser.c b/src/document/html/parser.c index c4ed0d2e..34900370 100644 --- a/src/document/html/parser.c +++ b/src/document/html/parser.c @@ -93,7 +93,7 @@ get_target(struct document_options *options, unsigned char *a) void ln_break(struct html_context *html_context, int n) { - if (!n || html_top.invisible) return; + if (!n || html_top->invisible) return; while (n > html_context->line_breax) { html_context->line_breax++; html_context->line_break_f(html_context); @@ -108,7 +108,7 @@ put_chrs(struct html_context *html_context, unsigned char *start, int len) if (html_is_preformatted()) html_context->putsp = HTML_SPACE_NORMAL; - if (!len || html_top.invisible) + if (!len || html_top->invisible) return; switch (html_context->putsp) { @@ -258,8 +258,8 @@ html_focusable(struct html_context *html_context, unsigned char *a) void html_skip(struct html_context *html_context, unsigned char *a) { - html_top.invisible = 1; - html_top.type = ELEMENT_DONT_KILL; + html_top->invisible = 1; + html_top->type = ELEMENT_DONT_KILL; } void @@ -666,7 +666,7 @@ init_html_parser_state(struct html_context *html_context, struct html_element *element; html_stack_dup(html_context, type); - element = &html_top; + element = html_top; par_format.align = align; @@ -677,7 +677,7 @@ init_html_parser_state(struct html_context *html_context, par_format.list_level = 0; par_format.list_number = 0; par_format.dd_margin = 0; - html_top.namelen = 0; + html_top->namelen = 0; } return element; @@ -691,20 +691,20 @@ done_html_parser_state(struct html_context *html_context, { html_context->line_breax = 1; - while (&html_top != element) { - kill_html_stack_item(html_context, &html_top); + while (html_top != element) { + kill_html_stack_item(html_context, html_top); #if 0 /* I've preserved this bit to show an example of the Old Code * of the Mikulas days (I _HOPE_ it's by Mikulas, at least ;-). * I think this assert() can never fail, for one. --pasky */ - assertm(&html_top && (void *) &html_top != (void *) &html_stack, + assertm(html_top && (void *) html_top != (void *) &html_stack, "html stack trashed"); if_assert_failed break; #endif } - html_top.type = ELEMENT_KILLABLE; - kill_html_stack_item(html_context, &html_top); + html_top->type = ELEMENT_KILLABLE; + kill_html_stack_item(html_context, html_top); } @@ -777,12 +777,12 @@ init_html_parser(struct uri *uri, struct document_options *options, par_format.bgcolor = options->default_bg; - html_top.invisible = 0; - html_top.name = NULL; - html_top.namelen = 0; - html_top.options = NULL; - html_top.linebreak = 1; - html_top.type = ELEMENT_DONT_KILL; + html_top->invisible = 0; + html_top->name = NULL; + html_top->namelen = 0; + html_top->options = NULL; + html_top->linebreak = 1; + html_top->type = ELEMENT_DONT_KILL; html_context->has_link_lines = 0; html_context->table_level = 0; diff --git a/src/document/html/parser/forms.c b/src/document/html/parser/forms.c index bc3922ee..a0431bf3 100644 --- a/src/document/html/parser/forms.c +++ b/src/document/html/parser/forms.c @@ -254,7 +254,7 @@ html_input_format(struct html_context *html_context, unsigned char *a, case FC_HIDDEN: INTERNAL("bad control type"); } - kill_html_stack_item(html_context, &html_top); + kill_html_stack_item(html_context, html_top); put_chrs(html_context, " ", 1); } @@ -498,7 +498,7 @@ end_parse: for (i = 0; i < max_width; i++) put_chrs(html_context, "_", 1); - kill_html_stack_item(html_context, &html_top); + kill_html_stack_item(html_context, html_top); put_chrs(html_context, "]", 1); html_context->special_f(html_context, SP_CONTROL, fc); } @@ -513,7 +513,7 @@ do_html_select_multiple(struct html_context *html_context, unsigned char *a, if (!al) return; html_focusable(html_context, a); - html_top.type = ELEMENT_DONT_KILL; + html_top->type = ELEMENT_DONT_KILL; mem_free_set(&format.select, al); format.select_disabled = has_attr(a, "disabled", html_context->options) ? FORM_MODE_DISABLED @@ -603,7 +603,7 @@ end_parse: format.form = fc; format.style.attr |= AT_BOLD; put_chrs(html_context, "[ ]", 3); - kill_html_stack_item(html_context, &html_top); + kill_html_stack_item(html_context, html_top); put_chrs(html_context, " ", 1); html_context->special_f(html_context, SP_CONTROL, fc); } @@ -709,7 +709,7 @@ pp: ln_break(html_context, 1); } - kill_html_stack_item(html_context, &html_top); + kill_html_stack_item(html_context, html_top); if (rows > 1) ln_break(html_context, 1); else diff --git a/src/document/html/parser/general.c b/src/document/html/parser/general.c index f84e4e95..622e5d1f 100644 --- a/src/document/html/parser/general.c +++ b/src/document/html/parser/general.c @@ -141,7 +141,7 @@ html_apply_canvas_bgcolor(struct html_context *html_context) /* If there are any CSS twaks regarding bgcolor, make sure we will get * it _and_ prefer it over bgcolor attribute. */ if (html_context->options->css_enable) - css_apply(html_context, &html_top, &html_context->css_styles, + css_apply(html_context, html_top, &html_context->css_styles, &html_context->stack); #endif @@ -195,7 +195,7 @@ html_script(struct html_context *html_context, unsigned char *a, mem_free(type); not_processed: /* Permit nested scripts and retreat. */ - html_top.invisible++; + html_top->invisible++; return; } @@ -403,8 +403,8 @@ void html_title(struct html_context *html_context, unsigned char *a, unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5) { - html_top.invisible = 1; - html_top.type = ELEMENT_WEAK; + html_top->invisible = 1; + html_top->type = ELEMENT_WEAK; } void @@ -586,7 +586,7 @@ html_hr(struct html_context *html_context, unsigned char *a, } html_context->special_f(html_context, SP_NOWRAP, 0); ln_break(html_context, 2); - kill_html_stack_item(html_context, &html_top); + kill_html_stack_item(html_context, html_top); } void @@ -690,7 +690,7 @@ html_ul(struct html_context *html_context, unsigned char *a, int_upper_bound(&par_format.leftmargin, par_format.width / 2); par_format.align = ALIGN_LEFT; - html_top.type = ELEMENT_DONT_KILL; + html_top->type = ELEMENT_DONT_KILL; } void @@ -725,7 +725,7 @@ html_ol(struct html_context *html_context, unsigned char *a, int_upper_bound(&par_format.leftmargin, par_format.width / 2); par_format.align = ALIGN_LEFT; - html_top.type = ELEMENT_DONT_KILL; + html_top->type = ELEMENT_DONT_KILL; } static struct { @@ -873,10 +873,10 @@ html_dl(struct html_context *html_context, unsigned char *a, par_format.list_number = 0; par_format.align = ALIGN_LEFT; par_format.dd_margin = par_format.leftmargin; - html_top.type = ELEMENT_DONT_KILL; + html_top->type = ELEMENT_DONT_KILL; if (!(par_format.flags & P_COMPACT)) { ln_break(html_context, 2); - html_top.linebreak = 2; + html_top->linebreak = 2; } } @@ -948,14 +948,14 @@ html_frame(struct html_context *html_context, unsigned char *a, } if (!name) return; - if (!html_context->options->frames || !html_top.frameset) { + if (!html_context->options->frames || !html_top->frameset) { html_focusable(html_context, a); put_link_line("Frame: ", name, url, "", html_context); } else { if (html_context->special_f(html_context, SP_USED, NULL)) { html_context->special_f(html_context, SP_FRAME, - html_top.frameset, name, url); + html_top->frameset, name, url); } } @@ -997,12 +997,12 @@ html_frameset(struct html_context *html_context, unsigned char *a, } } - if (!html_top.frameset) { + if (!html_top->frameset) { width = html_context->options->box.width; height = html_context->options->box.height; html_context->options->needs_height = 1; } else { - struct frameset_desc *frameset_desc = html_top.frameset; + struct frameset_desc *frameset_desc = html_top->frameset; int offset; if (frameset_desc->box.y >= frameset_desc->box.height) @@ -1020,9 +1020,9 @@ html_frameset(struct html_context *html_context, unsigned char *a, parse_frame_widths(rows, height, HTML_FRAME_CHAR_HEIGHT, &fp.height, &fp.y); - fp.parent = html_top.frameset; + fp.parent = html_top->frameset; if (fp.x && fp.y) { - html_top.frameset = html_context->special_f(html_context, SP_FRAMESET, &fp); + html_top->frameset = html_context->special_f(html_context, SP_FRAMESET, &fp); } mem_free_if(fp.width); mem_free_if(fp.height); diff --git a/src/document/html/parser/link.c b/src/document/html/parser/link.c index 7d8031e8..2a40251c 100644 --- a/src/document/html/parser/link.c +++ b/src/document/html/parser/link.c @@ -67,20 +67,20 @@ html_a(struct html_context *html_context, unsigned char *a, #ifdef CONFIG_GLOBHIST } else if (get_global_history_item(format.link)) { format.style.fg = format.vlink; - html_top.pseudo_class &= ~ELEMENT_LINK; - html_top.pseudo_class |= ELEMENT_VISITED; + html_top->pseudo_class &= ~ELEMENT_LINK; + html_top->pseudo_class |= ELEMENT_VISITED; #endif #ifdef CONFIG_BOOKMARKS } else if (get_bookmark(format.link)) { format.style.fg = format.bookmark_link; - html_top.pseudo_class &= ~ELEMENT_VISITED; + html_top->pseudo_class &= ~ELEMENT_VISITED; /* XXX: Really set ELEMENT_LINK? --pasky */ - html_top.pseudo_class |= ELEMENT_LINK; + html_top->pseudo_class |= ELEMENT_LINK; #endif } else { format.style.fg = format.clink; - html_top.pseudo_class &= ~ELEMENT_VISITED; - html_top.pseudo_class |= ELEMENT_LINK; + html_top->pseudo_class &= ~ELEMENT_VISITED; + html_top->pseudo_class |= ELEMENT_LINK; } mem_free_set(&format.title, @@ -89,7 +89,7 @@ html_a(struct html_context *html_context, unsigned char *a, html_focusable(html_context, a); } else { - kill_html_stack_item(html_context, &html_top); + kill_html_stack_item(html_context, html_top); } set_fragment_identifier(html_context, a, "name"); @@ -269,7 +269,7 @@ html_img_do(unsigned char *a, unsigned char *object_src, * If not, just exit now. */ if (!options->images && !format.link) { mem_free_if(src); - if (usemap) kill_html_stack_item(html_context, &html_top); + if (usemap) kill_html_stack_item(html_context, html_top); return; } @@ -332,7 +332,7 @@ html_img_do(unsigned char *a, unsigned char *object_src, put_image_label(a, label, html_context); - if (ismap) kill_html_stack_item(html_context, &html_top); + if (ismap) kill_html_stack_item(html_context, html_top); mem_free_set(&format.image, NULL); mem_free_set(&format.title, NULL); } @@ -341,7 +341,7 @@ html_img_do(unsigned char *a, unsigned char *object_src, } mem_free_if(src); - if (usemap) kill_html_stack_item(html_context, &html_top); + if (usemap) kill_html_stack_item(html_context, html_top); } void @@ -369,7 +369,7 @@ put_link_line(unsigned char *prefix, unsigned char *linkname, format.style.fg = format.clink; put_chrs(html_context, linkname, strlen(linkname)); ln_break(html_context, 1); - kill_html_stack_item(html_context, &html_top); + kill_html_stack_item(html_context, html_top); } diff --git a/src/document/html/parser/parse.c b/src/document/html/parser/parse.c index 0eba68fd..eb107524 100644 --- a/src/document/html/parser/parse.c +++ b/src/document/html/parser/parse.c @@ -714,7 +714,7 @@ next_break: element: endingtag = *name == '/'; name += endingtag; namelen -= endingtag; - if (!endingtag && html_context->putsp == HTML_SPACE_ADD && !html_top.invisible) + if (!endingtag && html_context->putsp == HTML_SPACE_ADD && !html_top->invisible) put_chrs(html_context, " ", 1); put_chrs(html_context, base_pos, html - base_pos); if (!html_is_preformatted() && !endingtag && html_context->putsp == HTML_SPACE_NORMAL) { @@ -766,14 +766,14 @@ start_element(struct element_info *ei, struct css_selector *selector = NULL; #endif - if (html_top.type == ELEMENT_WEAK) { - kill_html_stack_item(html_context, &html_top); + if (html_top->type == ELEMENT_WEAK) { + kill_html_stack_item(html_context, html_top); } /* We try to process nested