w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit ecf1a6f65deed420565d84a7ed030de01589608d
parent 053ed33c489dd35a2fc52af180b14e29364a6f98
Author: htrb <htrb>
Date:   Sun, 18 Jul 2010 14:10:09 +0000

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=242599#21
* file.c
(is_html_type): added.
(examineFile, loadGeneralFile, _saveBuffer)
(openGeneralPagerBuffer, reloadBuffer): use is_html_type() instead of strcasecmp().
(loadGeneralFile): set f.guess_tupe
* display.c
(displayBuffer): use is_html_type() instead of strcasecmp().
* buffer.c
(reshapeBuffer): use is_html_type() instead of strcasecmp().
* backend.c
(internal_get): use is_html_type() instead of strcasecmp().

Diffstat:
MChangeLog | 13+++++++++++++
Mbackend.c | 2+-
Mbuffer.c | 4++--
Mdisplay.c | 2+-
Mfile.c | 26+++++++++++++++++++-------
Mmain.c | 12++++++------
Mproto.h | 1+
Murl.c | 1+
8 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,16 @@ +2010-07-18 d+w3m@vdr.jp + + * [w3m-dev 04319] Re: w3m's bugs from bugs.debian.org + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=242599#21 + * file.c (is_html_type): added. + (examineFile, loadGeneralFile, _saveBuffer) + (openGeneralPagerBuffer, reloadBuffer): use is_html_type() instead + of strcasecmp(). + (loadGeneralFile): set f.guess_tupe + * display.c (displayBuffer): use is_html_type() instead of strcasecmp(). + * buffer.c (reshapeBuffer): use is_html_type() instead of strcasecmp(). + * backend.c (internal_get): use is_html_type() instead of strcasecmp(). + 2010-07-18 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * [w3m-dev 04286] Re: break textform when buffer back diff --git a/backend.c b/backend.c @@ -95,7 +95,7 @@ internal_get(char *url, int flag, FormList *request) buf = loadGeneralFile(url, NULL, NO_REFERER, 0, request); do_download = FALSE; if (buf != NULL && buf != NO_BUFFER) { - if (!strcasecmp(buf->type, "text/html") && backend_halfdump_buf) { + if (is_html_type(buf->type) && backend_halfdump_buf) { TextLineListItem *p; Str first, last; int len = 0; diff --git a/buffer.c b/buffer.c @@ -558,7 +558,7 @@ reshapeBuffer(Buffer *buf) WcOption.auto_detect = WC_OPT_DETECT_OFF; UseContentCharset = FALSE; #endif - if (!strcasecmp(buf->type, "text/html")) + if (is_html_type(buf->type)) loadHTMLBuffer(&f, buf); else loadBuffer(&f, buf); @@ -590,7 +590,7 @@ reshapeBuffer(Buffer *buf) gotoLine(buf, cur->linenumber); } buf->pos -= buf->currentLine->bpos; - if (FoldLine && strcasecmp(buf->type, "text/html")) + if (FoldLine && !is_html_type(buf->type)) buf->currentColumn = 0; else buf->currentColumn = sbuf.currentColumn; diff --git a/display.c b/display.c @@ -380,7 +380,7 @@ displayBuffer(Buffer *buf, int mode) if (buf->height == 0) buf->height = LASTLINE + 1; if ((buf->width != INIT_BUFFER_WIDTH && - ((buf->type && !strcmp(buf->type, "text/html")) || FoldLine)) + (is_html_type(buf->type) || FoldLine)) || buf->need_reshape) { buf->need_reshape = TRUE; reshapeBuffer(buf); diff --git a/file.c b/file.c @@ -272,6 +272,13 @@ is_plain_text_type(char *type) (is_text_type(type) && !is_dump_text_type(type))); } +int +is_html_type(char *type) +{ + return (type && (strcasecmp(type, "text/html") == 0 || + strcasecmp(type, "application/xhtml+xml") == 0)); +} + static void check_compression(char *path, URLFile *uf) { @@ -373,7 +380,7 @@ examineFile(char *path, URLFile *uf) uf->guess_type = guessContentType(path); if (uf->guess_type == NULL) uf->guess_type = "text/plain"; - if (strcasecmp(uf->guess_type, "text/html") == 0) + if (is_html_type(uf->guess_type)) return; if ((fp = lessopen_stream(path))) { UFclose(uf); @@ -2055,6 +2062,10 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, t = f.guess_type; } + /* XXX: can we use guess_type to give the type to loadHTMLstream + * to support default utf8 encoding for XHTML here? */ + f.guess_type = t; + page_loaded: if (page) { FILE *src; @@ -2166,7 +2177,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, } #endif - if (!strcasecmp(t, "text/html")) + if (is_html_type(t)) proc = loadHTMLBuffer; else if (is_plain_text_type(t)) proc = loadBuffer; @@ -2230,7 +2241,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, b->real_type = real_type; if (b->currentURL.host == NULL && b->currentURL.file == NULL) copyParsedURL(&b->currentURL, &pu); - if (!strcasecmp(t, "text/html")) + if (is_html_type(t)) b->type = "text/html"; else if (w3m_backend) { Str s = Strnew_charp(t); @@ -6949,6 +6960,8 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) } if (content_charset && UseContentCharset) doc_charset = content_charset; + else if (f->guess_type && !strcasecmp(f->guess_type, "application/xhtml+xml")) + doc_charset = WC_CES_UTF_8; meta_charset = 0; #endif #if 0 @@ -7383,8 +7396,7 @@ _saveBuffer(Buffer *buf, Line *l, FILE * f, int cont) wc_ces charset = DisplayCharset ? DisplayCharset : WC_CES_US_ASCII; #endif - if (buf->type && !strcasecmp(buf->type, "text/html")) - is_html = TRUE; + is_html = is_html_type(buf->type); pager_next: for (; l != NULL; l = l->next) { @@ -7541,7 +7553,7 @@ openGeneralPagerBuffer(InputStream stream) t = DefaultType; DefaultType = NULL; } - if (!strcasecmp(t, "text/html")) { + if (is_html_type(t)) { buf = loadHTMLBuffer(&uf, t_buf); buf->type = "text/html"; } @@ -8351,7 +8363,7 @@ reloadBuffer(Buffer *buf) buf->hmarklist->nmark = 0; if (buf->imarklist) buf->imarklist->nmark = 0; - if (!strcasecmp(buf->type, "text/html")) + if (is_html_type(buf->type)) loadHTMLBuffer(&uf, buf); else loadBuffer(&uf, buf); diff --git a/main.c b/main.c @@ -4616,10 +4616,10 @@ DEFUN(vwSrc, SOURCE VIEW, "View HTML source") buf = newBuffer(INIT_BUFFER_WIDTH); - if (!strcasecmp(Currentbuf->type, "text/html")) { + if (is_html_type(Currentbuf->type)) { buf->type = "text/plain"; if (Currentbuf->real_type && - !strcasecmp(Currentbuf->real_type, "text/html")) + is_html_type(Currentbuf->real_type)) buf->real_type = "text/plain"; else buf->real_type = Currentbuf->real_type; @@ -4769,8 +4769,8 @@ DEFUN(reload, RELOAD, "Reload buffer") repBuffer(Currentbuf, buf); if ((buf->type != NULL) && (sbuf.type != NULL) && ((!strcasecmp(buf->type, "text/plain") && - !strcasecmp(sbuf.type, "text/html")) || - (!strcasecmp(buf->type, "text/html") && + is_html_type(sbuf.type)) || + (is_html_type(buf->type) && !strcasecmp(sbuf.type, "text/plain")))) { vwSrc(); if (Currentbuf != buf) @@ -5092,7 +5092,7 @@ DEFUN(dispI, DISPLAY_IMAGE, "Restart loading and drawing of images") return; displayImage = TRUE; /* - * if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html"))) + * if (!(Currentbuf->type && is_html_type(Currentbuf->type))) * return; */ Currentbuf->image_flag = IMG_FLAG_AUTO; @@ -5105,7 +5105,7 @@ DEFUN(stopI, STOP_IMAGE, "Stop loading and drawing of images") if (!activeImage) return; /* - * if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html"))) + * if (!(Currentbuf->type && is_html_type(Currentbuf->type))) * return; */ Currentbuf->image_flag = IMG_FLAG_SKIP; diff --git a/proto.h b/proto.h @@ -165,6 +165,7 @@ extern ParsedURL *schemeToProxy(int scheme); extern void examineFile(char *path, URLFile *uf); extern char *acceptableEncoding(); extern int dir_exist(char *path); +extern int is_html_type(char *type); #ifdef USE_M17N extern char **get_symbol(wc_ces charset, int *width); extern char **set_symbol(int width); diff --git a/url.c b/url.c @@ -101,6 +101,7 @@ static struct table2 DefaultGuess[] = { {"html", "text/html"}, {"htm", "text/html"}, {"shtml", "text/html"}, + {"xhtml", "application/xhtml+xml"}, {"gif", "image/gif"}, {"jpeg", "image/jpeg"}, {"jpg", "image/jpeg"},