From d650a434b27a35cf217bb8b20f4092c4876a489d Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Tue, 11 Sep 2007 09:30:26 +0200 Subject: [PATCH 1/8] Extend Use of LWS() macro to parse_old_meta_refresh(). --- src/document/html/parser.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/document/html/parser.c b/src/document/html/parser.c index cdc8745c3..8a3dded58 100644 --- a/src/document/html/parser.c +++ b/src/document/html/parser.c @@ -270,6 +270,8 @@ html_skip(struct html_context *html_context, unsigned char *a) html_top->type = ELEMENT_DONT_KILL; } +#define LWS(c) ((c) == ' ' || (c) == ASCII_TAB) + /* Parse meta refresh without URL= in it: * * @@ -285,18 +287,18 @@ parse_old_meta_refresh(unsigned char *str, unsigned char **ret) if_assert_failed return; *ret = NULL; - while (*p && (*p == ' ' || *p == ASCII_TAB)) p++; + while (*p && LWS(*p)) p++; if (!*p) return; while (*p && *p >= '0' && *p <= '9') p++; if (!*p) return; - while (*p && (*p == ' ' || *p == ASCII_TAB)) p++; + while (*p && LWS(*p)) p++; if (!*p) return; if (*p == ';' || *p == ',') p++; else return; - while (*p && (*p == ' ' || *p == ASCII_TAB)) p++; + while (*p && LWS(*p)) p++; if (!*p) return; len = strlen(p); - while (len && (p[len] == ' ' || p[len] == ASCII_TAB)) len--; + while (len && LWS(p[len])) len--; if (len) *ret = memacpy(p, len); } @@ -321,7 +323,6 @@ parse_old_meta_refresh(unsigned char *str, unsigned char **ret) static enum parse_header_param search_for_url_param(unsigned char *str, unsigned char **ret) { -#define LWS(c) ((c) == ' ' || (c) == ASCII_TAB) unsigned char *p; int plen = 0; @@ -372,9 +373,10 @@ search_for_url_param(unsigned char *str, unsigned char **ret) return HEADER_PARAM_OUT_OF_MEMORY; } return HEADER_PARAM_FOUND; -#undef LWS } +#undef LWS + static void check_head_for_refresh(struct html_context *html_context, unsigned char *head) { From 75d47ef9576d8b2999388ef5f0ffc23e2afcbfb4 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Fri, 14 Sep 2007 09:26:39 +0200 Subject: [PATCH 2/8] Drop useless goto/label. --- src/document/html/renderer.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 5cb61d6cc..06c55fd1a 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -2176,30 +2176,27 @@ ret: /* Clear memory to prevent bad key comparaison due to alignment * of key fields. */ struct table_cache_entry *tce = mem_calloc(1, sizeof(*tce)); - /* A goto is used here to prevent a test or code - * redundancy. */ - if (!tce) goto end; - tce->key.start = start; - tce->key.end = end; - tce->key.align = align; - tce->key.margin = margin; - tce->key.width = width; - tce->key.x = x; - tce->key.link_num = link_num; - copy_struct(&tce->part, part); + if (tce) { + tce->key.start = start; + tce->key.end = end; + tce->key.align = align; + tce->key.margin = margin; + tce->key.width = width; + tce->key.x = x; + tce->key.link_num = link_num; + copy_struct(&tce->part, part); - if (!add_hash_item(table_cache, - (unsigned char *) &tce->key, - sizeof(tce->key), tce)) { - mem_free(tce); - } else { - table_cache_entries++; + if (!add_hash_item(table_cache, + (unsigned char *) &tce->key, + sizeof(tce->key), tce)) { + mem_free(tce); + } else { + table_cache_entries++; + } } } -end: - return part; } From e914ca85fe5df735f42d933388270c7cc259228c Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Fri, 14 Sep 2007 09:55:43 +0200 Subject: [PATCH 3/8] Use explicit names for variables in format_html_part(). llm -> saved_last_link_to_move ltm -> saved_last_tag_to_move ef -> saved_empty_format lm -> saved_margin --- src/document/html/renderer.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 06c55fd1a..3a6798792 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -2064,10 +2064,10 @@ format_html_part(struct html_context *html_context, { struct part *part; void *html_state; - int llm = renderer_context.last_link_to_move; - struct tag *ltm = renderer_context.last_tag_to_move; - int ef = renderer_context.empty_format; - int lm = html_context->margin; + int saved_last_link_to_move = renderer_context.last_link_to_move; + struct tag *saved_last_tag_to_move = renderer_context.last_tag_to_move; + int saved_empty_format = renderer_context.empty_format; + int saved_margin = html_context->margin; /* Hash creation if needed. */ if (!table_cache) { @@ -2163,11 +2163,11 @@ format_html_part(struct html_context *html_context, } ret: - renderer_context.last_link_to_move = llm; - renderer_context.last_tag_to_move = ltm; - renderer_context.empty_format = ef; + renderer_context.last_link_to_move = saved_last_link_to_move; + renderer_context.last_tag_to_move = saved_last_tag_to_move; + renderer_context.empty_format = saved_empty_format; - html_context->margin = lm; + html_context->margin = saved_margin; if (html_context->table_level > 1 && !document && table_cache From 60913ba9f9a3daa3e44b439c6350c9af99402f81 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Fri, 14 Sep 2007 09:59:34 +0200 Subject: [PATCH 4/8] format_html_part(): save and restore renderer_context.last_tag_for_newline too. --- src/document/html/renderer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 3a6798792..f8872ba0d 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -2066,6 +2066,7 @@ format_html_part(struct html_context *html_context, void *html_state; int saved_last_link_to_move = renderer_context.last_link_to_move; struct tag *saved_last_tag_to_move = renderer_context.last_tag_to_move; + struct tag *saved_last_tag_for_newline = renderer_context.last_tag_for_newline; int saved_empty_format = renderer_context.empty_format; int saved_margin = html_context->margin; @@ -2166,6 +2167,7 @@ ret: renderer_context.last_link_to_move = saved_last_link_to_move; renderer_context.last_tag_to_move = saved_last_tag_to_move; renderer_context.empty_format = saved_empty_format; + renderer_context.last_tag_for_newline = saved_last_tag_for_newline; html_context->margin = saved_margin; From d6bb586a0081b8f5d03a7ed5f090f9199f2cd0a7 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Fri, 14 Sep 2007 10:07:32 +0200 Subject: [PATCH 5/8] format_html_part(): group int variables declarations --- src/document/html/renderer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index f8872ba0d..39b00ae4f 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -2064,11 +2064,11 @@ format_html_part(struct html_context *html_context, { struct part *part; void *html_state; - int saved_last_link_to_move = renderer_context.last_link_to_move; struct tag *saved_last_tag_to_move = renderer_context.last_tag_to_move; struct tag *saved_last_tag_for_newline = renderer_context.last_tag_for_newline; int saved_empty_format = renderer_context.empty_format; int saved_margin = html_context->margin; + int saved_last_link_to_move = renderer_context.last_link_to_move; /* Hash creation if needed. */ if (!table_cache) { From 6c6e75a71d8d976eaef8d7e16c31f79a3c36e551 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Fri, 14 Sep 2007 15:14:34 +0200 Subject: [PATCH 6/8] Trim trailing whitespaces. --- contrib/proxy/gen.c | 2 +- src/config/conf.c | 2 +- src/scripting/smjs/cache_object.c | 2 +- src/terminal/draw.h | 2 +- src/util/profile.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/proxy/gen.c b/contrib/proxy/gen.c index 59d1b2b1f..6e7807aba 100644 --- a/contrib/proxy/gen.c +++ b/contrib/proxy/gen.c @@ -95,7 +95,7 @@ parse(void) space = strchr(current, ' '); if (!space) return; - + host = find(space + 1, "Host: "); if (!host) return; diff --git a/src/config/conf.c b/src/config/conf.c index 4c9f3fa14..c08c04dd3 100644 --- a/src/config/conf.c +++ b/src/config/conf.c @@ -142,7 +142,7 @@ parse_set_common(struct option *opt_tree, unsigned char **file, int *line, if (want_domain && *domain_name) { struct option *domain_tree; - + domain_tree = get_domain_tree(domain_name); if (!domain_tree) { mem_free(domain_name); diff --git a/src/scripting/smjs/cache_object.c b/src/scripting/smjs/cache_object.c index 393f664a9..8d2a44d90 100644 --- a/src/scripting/smjs/cache_object.c +++ b/src/scripting/smjs/cache_object.c @@ -49,7 +49,7 @@ cache_entry_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp) if (!JS_InstanceOf(ctx, obj, (JSClass *) &cache_entry_class, NULL)) return JS_FALSE; - cached = JS_GetInstancePrivate(ctx, obj, + cached = JS_GetInstancePrivate(ctx, obj, (JSClass *) &cache_entry_class, NULL); if (!cache_entry_is_valid(cached)) return JS_FALSE; diff --git a/src/terminal/draw.h b/src/terminal/draw.h index 91e4a03a3..6dcd31afa 100644 --- a/src/terminal/draw.h +++ b/src/terminal/draw.h @@ -54,7 +54,7 @@ struct screen_char { unsigned char color[SCREEN_COLOR_SIZE]; }; -/** @relates screen_char */ +/** @relates screen_char */ #define copy_screen_chars(to, from, amount) \ do { memcpy(to, from, (amount) * sizeof(struct screen_char)); } while (0) diff --git a/src/util/profile.h b/src/util/profile.h index 6568c6e2b..4570e9b04 100644 --- a/src/util/profile.h +++ b/src/util/profile.h @@ -1,4 +1,4 @@ -/** Process' CPU time utilities +/** Process' CPU time utilities * @file*/ #ifndef EL__UTIL_PROFILE_H From fec10a1846ec7129636b3245c907edbb331b9c2c Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Wed, 19 Sep 2007 09:22:44 +0200 Subject: [PATCH 7/8] Revert "format_html_part(): save and restore renderer_context.last_tag_for_newline too." This reverts commit 60913ba9f9a3daa3e44b439c6350c9af99402f81. This was a bad move, anchors ceased to function correctly. Reported by Witekfl. --- src/document/html/renderer.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 39b00ae4f..486607c6b 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -2065,7 +2065,6 @@ format_html_part(struct html_context *html_context, struct part *part; void *html_state; struct tag *saved_last_tag_to_move = renderer_context.last_tag_to_move; - struct tag *saved_last_tag_for_newline = renderer_context.last_tag_for_newline; int saved_empty_format = renderer_context.empty_format; int saved_margin = html_context->margin; int saved_last_link_to_move = renderer_context.last_link_to_move; @@ -2167,7 +2166,6 @@ ret: renderer_context.last_link_to_move = saved_last_link_to_move; renderer_context.last_tag_to_move = saved_last_tag_to_move; renderer_context.empty_format = saved_empty_format; - renderer_context.last_tag_for_newline = saved_last_tag_for_newline; html_context->margin = saved_margin; From 05fc8f516978c50261d46778633fd74240d20326 Mon Sep 17 00:00:00 2001 From: Laurent MONIN Date: Fri, 21 Sep 2007 11:05:40 +0200 Subject: [PATCH 8/8] Fix compilation with --disable-css. Compilation failed due to missing DEBUG_CSS test. This was introduced in commit 98260f7970bcd940f2d2146ac7b5a980a7586082 --- src/document/html/parser/stack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/document/html/parser/stack.c b/src/document/html/parser/stack.c index 914388054..d5c43b78c 100644 --- a/src/document/html/parser/stack.c +++ b/src/document/html/parser/stack.c @@ -151,8 +151,9 @@ html_stack_dup(struct html_context *html_context, enum html_element_mortality_ty if (ep->attr.title) e->attr.title = stracpy(ep->attr.title); if (ep->attr.select) e->attr.select = stracpy(ep->attr.select); +#ifdef CONFIG_CSS e->attr.id = e->attr.class = NULL; - +#endif /* We don't want to propagate these. */ /* XXX: For sure? --pasky */ e->attr.onclick = e->attr.ondblclick = e->attr.onmouseover = e->attr.onhover