Index: etc.c =================================================================== RCS file: /home/okabe/CVS_DB/w3m/etc.c,v retrieving revision 1.8.2.27 diff -u -r1.8.2.27 etc.c --- etc.c 2000/12/20 20:55:58 1.8.2.27 +++ etc.c 2000/12/21 14:46:18 @@ -779,6 +779,46 @@ return 1; } +Str +correct_irrtag(int status) +{ + char c; + Str tmp = Strnew(); + + while (status != R_ST_NORMAL) { + switch (status) { + case R_ST_CMNT: /* required "-->" */ + case R_ST_NCMNT1: /* required "->" */ + c = '-'; + break; + case R_ST_NCMNT2: + case R_ST_NCMNT3: + case R_ST_IRRTAG: + case R_ST_CMNT1: + case R_ST_CMNT2: + case R_ST_TAG: + case R_ST_TAG0: + case R_ST_EQL: /* required ">" */ + c = '>'; + break; + case R_ST_QUOTE: + c = '\''; + break; + case R_ST_DQUOTE: + c = '"'; + break; + case R_ST_AMP: + c = ';'; + break; + default: + return tmp; + } + next_status(c, &status); + Strcat_char(tmp, c); + } + return tmp; +} + /* authentication */ struct auth_cookie * find_auth(char *host, char *realm) Index: file.c =================================================================== RCS file: /home/okabe/CVS_DB/w3m/file.c,v retrieving revision 1.22.2.62 diff -u -r1.22.2.62 file.c --- file.c 2000/12/21 06:16:09 1.22.2.62 +++ file.c 2000/12/21 17:08:18 @@ -1961,6 +1961,17 @@ } } +static void +close_anchor(struct html_feed_environ *h_env, struct readbuffer *obuf) +{ + if (obuf->anchor) { + close_anchor0(h_env, obuf); + push_tag(obuf, "", HTML_N_A); + obuf->anchor = NULL; + } + obuf->anchor_target = NULL; +} + void save_fonteffect(struct html_feed_environ *h_env, struct readbuffer *obuf) { @@ -2694,20 +2705,10 @@ } #endif /* ID_EXT */ -#define CLOSE_ANCHOR { \ - close_anchor0(h_env, obuf); \ - if (obuf->anchor) { \ - push_tag(obuf, "", HTML_N_A); \ - hseq = 0; \ - obuf->anchor = NULL; \ - } \ - obuf->anchor_target = NULL; \ -} - #define CLOSE_P if (obuf->flag & RB_P) { \ flushline(h_env, obuf, envs[h_env->envc].indent,0,h_env->limit);\ RB_RESTORE_FLAG(obuf);\ - CLOSE_ANCHOR;\ + close_anchor(h_env, obuf);\ obuf->flag &= ~RB_P;\ } @@ -2844,7 +2845,7 @@ } do_blankline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); RB_RESTORE_FLAG(obuf); - CLOSE_ANCHOR; + close_anchor(h_env, obuf); obuf->flag |= RB_IGNORE_P; return 1; case HTML_UL: @@ -2893,7 +2894,7 @@ obuf->flag |= RB_IGNORE_P; } } - CLOSE_ANCHOR; + close_anchor(h_env, obuf); return 1; case HTML_DL: CLOSE_P; @@ -3094,7 +3095,7 @@ } flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); obuf->prevchar = ' '; - CLOSE_ANCHOR; + close_anchor(h_env, obuf); return 1; case HTML_PRE: if (!parsedtag_exists(tag, ATTR_FOR_TABLE)) @@ -3109,8 +3110,8 @@ case HTML_N_PRE: flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); obuf->flag &= ~RB_PRE; - CLOSE_ANCHOR - return 1; + close_anchor(h_env, obuf); + return 1; case HTML_PRE_INT: i = obuf->line->length; append_tags(obuf); @@ -3179,10 +3180,9 @@ /* istr = str; */ return 1; case HTML_A: - if (obuf->anchor) { - CLOSE_ANCHOR - } - obuf->anchor = NULL; + if (obuf->anchor) + close_anchor(h_env, obuf); + hseq = 0; if (parsedtag_get_value(tag, ATTR_HREF, &p)) @@ -3200,8 +3200,8 @@ } return 0; case HTML_N_A: - CLOSE_ANCHOR - return 1; + close_anchor(h_env, obuf); + return 1; case HTML_IMG: tmp = process_img(tag); HTMLlineproc1(tmp->ptr, h_env); @@ -4546,6 +4546,34 @@ h_env->blank_lines = 0; } +void +completeHTMLstream(struct html_feed_environ *h_env, struct readbuffer *obuf) +{ + close_anchor(h_env, obuf); + if (obuf->img_alt) { + push_tag(obuf, "", HTML_N_IMG_ALT); + obuf->img_alt = NULL; + } + if (obuf->in_bold) { + push_tag(obuf, "", HTML_N_B); + obuf->in_bold = 0; + } + if (obuf->in_under) { + push_tag(obuf, "", HTML_N_U); + obuf->in_under = 0; + } + /* for unbalanced select tag */ + if (obuf->flag & RB_INSELECT) + HTMLlineproc1("", h_env); + + /* for unbalanced table tag */ + while (obuf->table_level >= 0) { + table_mode[obuf->table_level].pre_mode + &= ~(TBLM_IGNORE | TBLM_XMP | TBLM_LST); + HTMLlineproc1("", h_env); + } +} + void loadHTMLstream(URLFile * f, Buffer * newBuf, FILE * src, int internal) { @@ -4642,21 +4670,10 @@ #endif /* USE_NNTP */ HTMLlineproc0(lineBuf2->ptr, &htmlenv1, internal); } - if (obuf.status == R_ST_CMNT) - HTMLlineproc1("-->", &htmlenv1); - else if (obuf.status == R_ST_TAG) - HTMLlineproc1(">", &htmlenv1); + if (obuf.status != R_ST_NORMAL) + HTMLlineproc1(correct_irrtag(obuf.status)->ptr, &htmlenv1); obuf.status = R_ST_NORMAL; - /* for unbalanced select tag */ - if (obuf.flag & RB_INSELECT) - HTMLlineproc1("", &htmlenv1); - /* for unbalanced table tag */ - while (obuf.table_level >= 0) { - table_mode[obuf.table_level].pre_mode - &= ~(TBLM_IGNORE | TBLM_XMP | TBLM_LST); - HTMLlineproc1("", &htmlenv1); - } - + completeHTMLstream(&htmlenv1, &obuf); flushline(&htmlenv1, &obuf, 0, 2, htmlenv1.limit); if (htmlenv1.title) newBuf->buffername = htmlenv1.title; Index: frame.c =================================================================== RCS file: /home/okabe/CVS_DB/w3m/frame.c,v retrieving revision 1.4.2.13 diff -u -r1.4.2.13 frame.c --- frame.c 2000/12/16 19:39:34 1.4.2.13 +++ frame.c 2000/12/21 17:27:12 @@ -423,9 +423,8 @@ static int createFrameFile(struct frameset *f, FILE * f1, Buffer * current, int level, int force_reload) { - int r, c, status, t_stack; + int r, c, t_stack; InputStream f2; - Str tmp, tok; #ifdef JP_CHARSET char code, ic, charset[2]; #endif /* JP_CHARSET */ @@ -465,8 +464,6 @@ fputs("