From 569d535b29255d860e7c3755069d60265a5e9085 Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Tue, 3 Dec 2002 15:35:09 +0000 Subject: [w3m-dev 03509] HTML parser * file.c (close_textarea): delete (HTMLtagproc1): rewrite delete HTML_EOL move HTML_LISTING, HTML_N_LISTING add HTML_PRE_PLAIN, HTML_N_PRE_PLAIN add HTML_PLAINTEXT end_tag (HTMLlineproc0): s/str/line/ rewrite (completeHTMLstream): if necessary * fm.h (struct readbuffer): delete ignore_tag add end_tag (RB_XMPMODE): deleted (RB_LSTMODE): deleted (RB_SCRIPT): added (RB_STYLE): added (RB_*): renumber (R_ST_EOL): added (R_ST_*): renumber (ST_IS_TAG): check R_ST_EOL * form.c (form_fputs_decode): remove handling * frame.c (newFrame): remove_space() (CASE_TABLE_TAG): added (createFrameFile): rewrite * html.c (TagMAP): delete eol add pre_plain, /pre_plain * html.h (HTML_EOL): deleted (HTML_PRE_PLAIN): added (HTML_N_PRE_PLAIN): added * table.c (visible_length): rewrite (visible_length_plain): added (maximum_visible_length_plain): added (do_refill): R_ST_EOL (table_close_select): end_tag (table_close_textarea): end_tag (TAG_ACTION_PLAIN): added (feed_table_tag): rewrite (feed_table): rewrite * table.h (TBLM_*) reassign (struct table_mode): delete ignore_tag add end_tag * tagtable.tab (eol): deleted (pre_plain): added (/pre_plain): added From: Hironori SAKAMOTO --- frame.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 132 insertions(+), 28 deletions(-) (limited to 'frame.c') diff --git a/frame.c b/frame.c index ef0faec..343dc02 100644 --- a/frame.c +++ b/frame.c @@ -1,4 +1,4 @@ -/* $Id: frame.c,v 1.22 2002/11/28 16:00:34 ukai Exp $ */ +/* $Id: frame.c,v 1.23 2002/12/03 15:35:10 ukai Exp $ */ #include "fm.h" #include "parsetagx.h" #include "myctype.h" @@ -97,7 +97,7 @@ newFrame(struct parsed_tag *tag, Buffer *buf) body->baseURL = baseURL(buf); if (tag) { if (parsedtag_get_value(tag, ATTR_SRC, &p)) - body->url = url_quote_conv(p, buf->document_code); + body->url = url_quote_conv(remove_space(p), buf->document_code); if (parsedtag_get_value(tag, ATTR_NAME, &p) && *p != '_') body->name = url_quote_conv(p, buf->document_code); } @@ -412,6 +412,23 @@ frame_download_source(struct frame_body *b, ParsedURL *currentURL, return ret_frameset; } +#define CASE_TABLE_TAG \ + case HTML_TR:\ + case HTML_N_TR:\ + case HTML_TD:\ + case HTML_N_TD:\ + case HTML_TH:\ + case HTML_N_TH:\ + case HTML_THEAD:\ + case HTML_N_THEAD:\ + case HTML_TBODY:\ + case HTML_N_TBODY:\ + case HTML_TFOOT:\ + case HTML_N_TFOOT:\ + case HTML_COLGROUP:\ + case HTML_N_COLGROUP:\ + case HTML_COL + static int createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, int force_reload) @@ -467,8 +484,10 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, struct frameset *f_frameset; int i = c + r * f->col; char *p = ""; + int status = R_ST_NORMAL; Str tok = Strnew(); - int status; + int pre_mode = 0; + int end_tag = 0; frame = f->frame[i]; @@ -557,12 +576,13 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, break; } do { - status = R_ST_NORMAL; + int is_tag = FALSE; + char *q; + struct parsed_tag *tag; + do { if (*p == '\0') { Str tmp = StrmyUFgets(&f2); - if (tmp->length == 0 && status != R_ST_NORMAL) - tmp = correct_irrtag(status); if (tmp->length == 0) break; #ifdef JP_CHARSET @@ -573,21 +593,67 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, cleanup_line(tmp, HTML_MODE); p = tmp->ptr; } - if (status == R_ST_NORMAL) - read_token(tok, &p, &status, 1, 0); - else if (ST_IS_COMMENT(status)) - read_token(tok, &p, &status, 0, 0); - else - read_token(tok, &p, &status, 1, 1); + read_token(tok, &p, &status, 1, status != R_ST_NORMAL); } while (status != R_ST_NORMAL); if (tok->length == 0) continue; if (tok->ptr[0] == '<') { + is_tag = TRUE; + if (pre_mode & (RB_PLAIN | RB_INTXTA | RB_SCRIPT | + RB_STYLE)) { + q = tok->ptr; + if ((tag = parse_tag(&q, FALSE)) && + tag->tagid == end_tag) { + if (pre_mode & RB_PLAIN) { + fputs("", f1); + pre_mode = 0; + end_tag = 0; + goto token_end; + } + pre_mode = 0; + end_tag = 0; + goto proc_normal; + } + if (strncmp(tok->ptr, "