w3m

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

commit b4958dc1796f3ce94b074b2424ce167aaf0571fd
parent b3c484eb56467659d9c1cb8f937b8562b3fa0550
Author: ukai <ukai>
Date:   Thu, 27 Dec 2001 17:50:56 +0000

[w3m-dev 02765] backend
From: Hironori Sakamoto <h-saka@lsi.nec.co.jp>

Diffstat:
MChangeLog | 9+++++++++
Mbackend.c | 21+++++++++++++++------
Mfile.c | 15+++++----------
Mfm.h | 2+-
4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,12 @@ +2001-12-28 Hironori Sakamoto <h-saka@lsi.nec.co.jp> + + * [w3m-dev 02765] backend + * backend.c (internal_get): cleanups + * file.c (flushline): remove w3m_backend checks + * file.c (loadHTMLstream): add w3m_backend check + * fm.h (backend_halfdump_str): deleted + * fm.h (backend_halfdump_buf): added + 2001-12-28 Kiyokazu SUTO <suto@ks-and-ks.ne.jp> * [w3m-dev 02761] diff --git a/backend.c b/backend.c @@ -136,15 +136,21 @@ internal_get(char *url, int flag, FormList *request) { Buffer *buf; - backend_halfdump_str = Strnew_charp("<pre>\n"); + backend_halfdump_buf = NULL; do_download = flag; buf = loadGeneralFile(url, NULL, NO_REFERER, 0, request); do_download = FALSE; if (buf != NULL && buf != NO_BUFFER) { - if (!strcasecmp(buf->type, "text/html")) { - Strcat(backend_halfdump_str, - Sprintf("</pre><title>%s</title>\n", buf->buffername)); - print_headers(buf, backend_halfdump_str->length); + if (!strcasecmp(buf->type, "text/html") && backend_halfdump_buf) { + TextLineListItem *p; + Str first, last; + int len = 0; + for (p = backend_halfdump_buf->first; p; p = p->next) + len += p->ptr->line->length + 1; + first = Strnew_charp("<pre>\n"); + last = Strnew_m_charp("</pre><title>", html_quote(buf->buffername), + "</title>\n", NULL); + print_headers(buf, len + first->length + last->length); if (buf->formlist) { FormList *fp; int fid = 0; @@ -154,7 +160,10 @@ internal_get(char *url, int flag, FormList *request) print_formlist(--fid, fp); } printf("\n"); - Strfputs(backend_halfdump_str, stdout); + printf("%s", first->ptr); + for (p = backend_halfdump_buf->first; p; p = p->next) + printf("%s\n", p->ptr->line->ptr); + printf("%s", last->ptr); } else { if (!strcasecmp(buf->type, "text/plain")) { diff --git a/file.c b/file.c @@ -2025,13 +2025,8 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent, #endif if (lbuf->pos > h_env->maxlimit) h_env->maxlimit = lbuf->pos; - if (buf) { + if (buf) pushTextLine(buf, lbuf); - if (w3m_backend) { - Strcat(backend_halfdump_str, lbuf->line); - Strcat_char(backend_halfdump_str, '\n'); - } - } else { Strfputs(lbuf->line, f); fputc('\n', f); @@ -2046,11 +2041,9 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent, Str tmp = Strnew(), tmp2 = Strnew(); #define APPEND(str) \ - if (buf) { \ + if (buf) \ appendTextLine(buf,(str),0); \ - if (w3m_backend) \ - Strcat(backend_halfdump_str, (str)); \ - } else \ + else \ Strfputs((str),f) while (*p) { @@ -5074,6 +5067,8 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) newBuf->document_code = code; content_charset = '\0'; #endif /* JP_CHARSET */ + if (w3m_backend) + backend_halfdump_buf = htmlenv1.buf; HTMLlineproc2(newBuf, htmlenv1.buf); } diff --git a/fm.h b/fm.h @@ -881,7 +881,7 @@ global int use_lessopen init(FALSE); global int FollowRedirection init(10); global int w3m_backend init(FALSE); -global Str backend_halfdump_str; +global TextLineList *backend_halfdump_buf; global TextList *backend_batch_commands init(NULL); int backend(void); extern void deleteFiles(void);