w3m

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

commit ffc94960c6a53736d2f0b5e984e261c5570352b0
parent 9e5b4c72d2c9b849f9dd2b9fa8c5bfba3bb198af
Author: ukai <ukai>
Date:   Wed, 29 Jan 2003 17:10:17 +0000

[w3m-dev 03708] Re: Don't stop loading image when moving to next page.
* config.h.dist (lstat): define ifndef HAVE_LSTAT
* configure (config.h) ditto
* display.c (fmTerm): new loadImage
	(save_current_buf): only ifdef USE_BUFINFO
	(displayBuffer): new loadImage
* etc.c (setup_child): TrapSignal
* file.c (loadGeneralFile): TRAP_OFF, TRAP_ON
	(loadHTMLstream): ditto
	(loadGopherDir): ditto
	(loadBuffer): ditto
	(loadImageBuffer): ditto
	(getNextPage): ditto
	(save2tmp): ditto
* fm.h (TrapSignal): added
	(TRAP_ON): added
	(TRAP_OFF): added
* form.c (HAVE_LSTAT): deleted
* frame.c (createFrameFile): TRAP_OFF, TRAP_ON
* image.c (image_buffer): added
	(deleteImage): new loadImage
	(getAllImage): initialize image_buffer
	(loadImage): rewrite
* main.c (main): new loadImage
	(checkDownloadList): remove ifdef HAVE_LSTAT
* news.c (loadNwesgroup): TRAP_ON, TRAP_OFF
* proto.h (loadImage): add buf arg
* url.c (openSocket): TRAP_ON, TRAP_OFF
	(check_no_proxy): TRAP_ON, TRAP_OFF
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 36++++++++++++++++++++++++++++++++++--
Mconfig.h.dist | 4++++
Mconfigure | 4++++
Mdisplay.c | 16++++------------
Metc.c | 1+
Mfile.c | 130++++++++++++++++++++-----------------------------------------------------------
Mfm.h | 12++++++++++++
Mform.c | 7-------
Mframe.c | 13+++----------
Mimage.c | 122++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mmain.c | 10+---------
Mnews.c | 10+++-------
Mproto.h | 2+-
Murl.c | 25+++++++------------------
14 files changed, 169 insertions(+), 223 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,11 +1,43 @@ -2003-01-29 NAKAJIMA Mikio <minakaji@osaka.email.ne.jp> +2003-01-30 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 03708] Re: Don't stop loading image when moving to next page. + * config.h.dist (lstat): define ifndef HAVE_LSTAT + * configure (config.h) ditto + * display.c (fmTerm): new loadImage + (save_current_buf): only ifdef USE_BUFINFO + (displayBuffer): new loadImage + * etc.c (setup_child): TrapSignal + * file.c (loadGeneralFile): TRAP_OFF, TRAP_ON + (loadHTMLstream): ditto + (loadGopherDir): ditto + (loadBuffer): ditto + (loadImageBuffer): ditto + (getNextPage): ditto + (save2tmp): ditto + * fm.h (TrapSignal): added + (TRAP_ON): added + (TRAP_OFF): added + * form.c (HAVE_LSTAT): deleted + * frame.c (createFrameFile): TRAP_OFF, TRAP_ON + * image.c (image_buffer): added + (deleteImage): new loadImage + (getAllImage): initialize image_buffer + (loadImage): rewrite + * main.c (main): new loadImage + (checkDownloadList): remove ifdef HAVE_LSTAT + * news.c (loadNwesgroup): TRAP_ON, TRAP_OFF + * proto.h (loadImage): add buf arg + * url.c (openSocket): TRAP_ON, TRAP_OFF + (check_no_proxy): TRAP_ON, TRAP_OFF + +2003-01-29 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * [w3m-dev 03707] Don't stop loading image when moving to next page. * display.c (save_current_buf): required when defined USE_IMAGE (displayBuffer): stop only buffer changed * image.c (loadImage): IMG_FLAG_START load from maxLoadImage -2003-01-29 NAKAJIMA Mikio <minakaji@osaka.email.ne.jp> +2003-01-29 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * [w3m-dev 03706] X-Image-URL: support, bug fix of reshapeBuffer() * buffer.c (reshapeBuffer): rewrite diff --git a/config.h.dist b/config.h.dist @@ -238,6 +238,10 @@ typedef void MySignalHandler; #endif /* HAVE_SRANDOM */ #endif +#ifndef HAVE_LSTAT +#define lstat stat +#endif + #if defined( __CYGWIN32__ ) && !defined( __CYGWIN__ ) #define __CYGWIN__ #endif diff --git a/configure b/configure @@ -2504,6 +2504,10 @@ $def_ipv6_ss_family #endif /* HAVE_SRANDOM */ #endif +#ifndef HAVE_LSTAT +#define lstat stat +#endif + #if defined( __CYGWIN32__ ) && !defined( __CYGWIN__ ) #define __CYGWIN__ #endif diff --git a/display.c b/display.c @@ -164,7 +164,7 @@ fmTerm(void) refresh(); #ifdef USE_IMAGE if (activeImage) - loadImage(IMG_FLAG_STOP); + loadImage(NULL, IMG_FLAG_STOP); #endif #ifdef USE_MOUSE if (use_mouse) @@ -210,7 +210,7 @@ static int graph_mode = 0; static Linecolor color_mode = 0; #endif -#if defined(USE_BUFINFO) || defined(USE_IMAGE) +#ifdef USE_BUFINFO static Buffer *save_current_buf = NULL; #endif @@ -431,10 +431,7 @@ displayBuffer(Buffer *buf, int mode) if (draw_image_flag) clear(); clearImage(); - if (buf != save_current_buf) - loadImage(IMG_FLAG_STOP); - else - loadImage(IMG_FLAG_START); + loadImage(buf, IMG_FLAG_STOP); image_touch++; draw_image_flag = FALSE; } @@ -472,17 +469,12 @@ displayBuffer(Buffer *buf, int mode) refresh(); #ifdef USE_IMAGE if (activeImage && displayImage && buf->img) { - /* - * loadImage(IMG_FLAG_START); - */ drawImage(); } #endif -#if defined(USE_BUFINFO) || defined(USE_IMAGE) - if (buf != save_current_buf) { #ifdef USE_BUFINFO + if (buf != save_current_buf) { saveBufferInfo(); -#endif save_current_buf = buf; } #endif diff --git a/etc.c b/etc.c @@ -1367,6 +1367,7 @@ setup_child(int child, int i, int f) close_all_fds_except(i, f); QuietMessage = TRUE; fmInitialized = FALSE; + TrapSignal = FALSE; } pid_t diff --git a/file.c b/file.c @@ -1583,10 +1583,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, checkRedirection(NULL); load_doc: - if (fmInitialized) - term_raw(); - if (prevtrap) - signal(SIGINT, prevtrap); + TRAP_OFF; url_option.referer = referer; url_option.flag = flag; f = openURL(tpath, &pu, current, &url_option, request, extra_header, of, @@ -1654,10 +1651,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, } if (status == HTST_MISSING) { - if (fmInitialized) - term_raw(); - if (prevtrap) - signal(SIGINT, prevtrap); + TRAP_OFF; UFclose(&f); return NULL; } @@ -1665,9 +1659,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, /* openURL() succeeded */ if (SETJMP(AbortLoading) != 0) { /* transfer interrupted */ - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; if (b) discardBuffer(b); UFclose(&f); @@ -1682,9 +1674,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, } if (header_string) header_string = NULL; - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; if (pu.scheme == SCM_HTTP || #ifdef USE_SSL pu.scheme == SCM_HTTPS || @@ -1754,9 +1744,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, if (ss == NULL) { /* abort */ UFclose(&f); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return NULL; } UFclose(&f); @@ -1778,9 +1766,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, if (ss == NULL) { /* abort */ UFclose(&f); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return NULL; } UFclose(&f); @@ -1818,9 +1804,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, case 'm': page = loadGopherDir(&f, &pu, &code); t = "gopher:directory"; - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; goto page_loaded; case 's': t = "audio/basic"; @@ -1865,9 +1849,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, UFclose(&f); else { UFclose(&f); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; doFileMove(tmpf, guess_save_name(t_buf, pu.file)); } return NO_BUFFER; @@ -1971,9 +1953,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, if (do_download) { /* download only */ char *file; - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; if (DecodeCTE && IStype(f.stream) != IST_ENCODED) f.stream = newEncodedStream(f.stream, f.encoding); if (pu.scheme == SCM_LOCAL) { @@ -2016,9 +1996,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, b->real_type = t; } UFclose(&f); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return b; } #endif @@ -2044,15 +2022,11 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, copyParsedURL(&b->currentURL, &pu); } UFclose(&f); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return b; } else { - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; if (pu.scheme == SCM_LOCAL) { UFclose(&f); _doFileCopy(pu.real_file, @@ -2140,9 +2114,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, reAnchorNewsheader(b); #endif preFormUpdateBuffer(b); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return b; } @@ -6572,9 +6544,7 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) HTMLlineproc1("<br>Transfer Interrupted!<br>", &htmlenv1); goto phase2; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; #ifdef JP_CHARSET if (newBuf != NULL && newBuf->document_code != '\0') @@ -6645,25 +6615,19 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) if (htmlenv1.title) newBuf->buffername = htmlenv1.title; if (w3m_halfdump) { - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; print_internal_information(&htmlenv1); return; } if (w3m_backend) { - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; print_internal_information(&htmlenv1); backend_halfdump_buf = htmlenv1.buf; return; } phase2: newBuf->trbyte = trbyte + linelen; - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; #ifdef JP_CHARSET newBuf->document_code = code; content_charset = '\0'; @@ -6686,22 +6650,16 @@ loadHTMLString(Str page) newBuf = newBuffer(INIT_BUFFER_WIDTH); if (SETJMP(AbortLoading) != 0) { - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; discardBuffer(newBuf); return NULL; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; init_stream(&f, SCM_LOCAL, newStrStream(page)); loadHTMLstream(&f, newBuf, NULL, TRUE); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; newBuf->topLine = newBuf->firstLine; newBuf->lastLine = newBuf->currentLine; newBuf->currentLine = newBuf->firstLine; @@ -6740,9 +6698,7 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, char *code) if (SETJMP(AbortLoading) != 0) goto gopher_end; - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; #ifdef JP_CHARSET *code = DocumentCode; @@ -6804,9 +6760,7 @@ loadGopherDir(URLFile *uf, ParsedURL *pu, char *code) } gopher_end: - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; Strcat_charp(tmp, "</table>\n</body>\n</html>\n"); return tmp; @@ -6839,9 +6793,7 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf) if (SETJMP(AbortLoading) != 0) { goto _end; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; if (newBuf->sourcefile == NULL && (uf->scheme != SCM_LOCAL || newBuf->mailcap)) { @@ -6906,9 +6858,7 @@ loadBuffer(URLFile *uf, Buffer *volatile newBuf) lineBuf2->length, FOLD_BUFFER_WIDTH, nlines); } _end: - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; newBuf->topLine = newBuf->firstLine; newBuf->lastLine = newBuf->currentLine; newBuf->currentLine = newBuf->firstLine; @@ -6931,10 +6881,10 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf) Str tmp, tmpf; FILE *src = NULL; URLFile f; - MySignalHandler(*prevtrap) (); + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; struct stat st; - loadImage(IMG_FLAG_STOP); + loadImage(newBuf, IMG_FLAG_STOP); image.url = uf->url; image.ext = uf->ext; image.width = -1; @@ -6945,22 +6895,16 @@ loadImageBuffer(URLFile *uf, Buffer *newBuf) !stat(cache->file, &st)) goto image_buffer; - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; if (IStype(uf->stream) != IST_ENCODED) uf->stream = newEncodedStream(uf->stream, uf->encoding); if (save2tmp(*uf, cache->file) < 0) { UFclose(uf); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return NULL; } UFclose(uf); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; cache->loaded = IMG_FLAG_LOADED; cache->index = 0; @@ -7242,9 +7186,7 @@ getNextPage(Buffer *buf, int plen) if (SETJMP(AbortLoading) != 0) { goto pager_end; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; init_stream(&uf, SCM_UNKNOWN, NULL); for (i = 0; i < plen; i++) { @@ -7307,9 +7249,7 @@ getNextPage(Buffer *buf, int plen) } } pager_end: - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; buf->trbyte = trbyte + linelen; #ifdef JP_CHARSET @@ -7342,9 +7282,7 @@ save2tmp(URLFile uf, char *tmpf) if (SETJMP(AbortLoading) != 0) { goto _end; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; check = 0; #ifdef USE_NNTP if (uf.scheme == SCM_NEWS) { @@ -7379,9 +7317,7 @@ save2tmp(URLFile uf, char *tmpf) } _end: bcopy(env_bak, AbortLoading, sizeof(JMP_BUF)); - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; fclose(ff); current_content_length = 0; return 0; diff --git a/fm.h b/fm.h @@ -778,6 +778,18 @@ global char MetaRefresh init(FALSE); global char fmInitialized init(FALSE); global char QuietMessage init(FALSE); +global char TrapSignal init(TRUE); +#define TRAP_ON if (TrapSignal) { \ + prevtrap = signal(SIGINT, KeyAbort); \ + if (fmInitialized) \ + term_cbreak(); \ +} +#define TRAP_OFF if (TrapSignal) { \ + if (fmInitialized) \ + term_raw(); \ + if (prevtrap) \ + signal(SIGINT, prevtrap); \ +} extern unsigned char GlobalKeymap[]; extern unsigned char EscKeymap[]; diff --git a/form.c b/form.c @@ -9,13 +9,6 @@ #include "local.h" #include "regex.h" -#ifndef HAVE_LSTAT -/* lstat is identical to stat, only the link itself is statted, not the file - * that is obtained by tracing the links. But on OS/2 systems, there is no - * differences. */ -#define lstat stat -#endif /* not HAVE_LSTAT */ - extern Str *textarea_str; #ifdef MENU_SELECT extern FormSelectOption *select_option; diff --git a/frame.c b/frame.c @@ -424,15 +424,10 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, if (level == 0) { if (SETJMP(AbortLoading) != 0) { - if (fmInitialized) - term_raw(); - signal(SIGINT, prevtrap); + TRAP_OFF; return -1; } - prevtrap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); - + TRAP_ON; f->name = "_top"; } @@ -852,9 +847,7 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer *current, int level, fputs("</table>\n", f1); if (level == 0) { fputs("</body></html>\n", f1); - signal(SIGINT, prevtrap); - if (fmInitialized) - term_raw(); + TRAP_OFF; } return 0; } diff --git a/image.c b/image.c @@ -243,6 +243,7 @@ static Hash_sv *image_hash = NULL; static Hash_sv *image_file = NULL; static GeneralList *image_list = NULL; static ImageCache **image_cache = NULL; +static Buffer *image_buffer = NULL; void deleteImage(Buffer *buf) @@ -263,7 +264,7 @@ deleteImage(Buffer *buf) a->image->cache->index < 0) unlink(a->image->cache->file); } - loadImage(IMG_FLAG_STOP); + loadImage(NULL, IMG_FLAG_STOP); } void @@ -274,6 +275,7 @@ getAllImage(Buffer *buf) ParsedURL *current; int i; + image_buffer = buf; if (!buf) return; buf->image_loaded = TRUE; @@ -318,11 +320,11 @@ showImageProgress(Buffer *buf) } void -loadImage(int flag) +loadImage(Buffer *buf, int flag) { ImageCache *cache; struct stat st; - int wait_st, i; + int wait_st, i, draw = FALSE; if (maxLoadImage > MAX_LOAD_IMAGE) maxLoadImage = MAX_LOAD_IMAGE; @@ -334,74 +336,71 @@ loadImage(int flag) image_cache = New_N(ImageCache *, MAX_LOAD_IMAGE); bzero(image_cache, sizeof(ImageCache *) * MAX_LOAD_IMAGE); } - - if (flag == IMG_FLAG_STOP || flag == IMG_FLAG_START) { - if (flag == IMG_FLAG_STOP) - i = 0; - else - i = maxLoadImage; - for ( ; i < n_load_image; i++) { - cache = image_cache[i]; - if (!cache) - continue; - if (cache->pid) { - kill(cache->pid, SIGKILL); + for (i = 0; i < n_load_image; i++) { + cache = image_cache[i]; + if (!cache) + continue; + if (lstat(cache->touch, &st)) + continue; + if (cache->pid) { + kill(cache->pid, SIGKILL); +/* #ifdef HAVE_WAITPID - waitpid(cache->pid, &wait_st, 0); + waitpid(cache->pid, &wait_st, 0); #else - wait(&wait_st); + wait(&wait_st); #endif - cache->pid = 0; +*/ + cache->pid = 0; + } + if (!stat(cache->file, &st)) { + cache->loaded = IMG_FLAG_LOADED; + if (getImageSize(cache)) { + if (image_buffer) + image_buffer->need_reshape = TRUE; } - unlink(cache->touch); - image_cache[i] = NULL; + draw = TRUE; } - image_list = NULL; - image_file = NULL; - n_load_image = maxLoadImage; - return; + else + cache->loaded = IMG_FLAG_ERROR; + unlink(cache->touch); + image_cache[i] = NULL; } - { - int draw = FALSE; - for (i = 0; i < n_load_image; i++) { - cache = image_cache[i]; - if (!cache) - continue; -#ifdef HAVE_LSTAT - if (lstat(cache->touch, &st)) -#else - if (stat(cache->touch, &st)) -#endif - continue; - if (cache->pid) { - kill(cache->pid, SIGKILL); + for (i = (buf != image_buffer) ? 0 : maxLoadImage; i < n_load_image; i++) { + cache = image_cache[i]; + if (!cache) + continue; + if (cache->pid) { + kill(cache->pid, SIGKILL); +/* #ifdef HAVE_WAITPID - waitpid(cache->pid, &wait_st, 0); + waitpid(cache->pid, &wait_st, 0); #else - wait(&wait_st); + wait(&wait_st); #endif - cache->pid = 0; - } - if (!stat(cache->file, &st)) { - cache->loaded = IMG_FLAG_LOADED; - if (getImageSize(cache)) { - if (CurrentTab && Currentbuf) - Currentbuf->need_reshape = TRUE; - } - draw = TRUE; - } - else - cache->loaded = IMG_FLAG_ERROR; - unlink(cache->touch); - image_cache[i] = NULL; - } - if (draw && CurrentTab && Currentbuf) { - drawImage(); - showImageProgress(Currentbuf); +*/ + cache->pid = 0; } + unlink(cache->touch); + image_cache[i] = NULL; } + if (flag == IMG_FLAG_STOP) { + image_list = NULL; + image_file = NULL; + n_load_image = maxLoadImage; + image_buffer = NULL; + return; + } + + if (draw && image_buffer) { + drawImage(); + showImageProgress(image_buffer); + } + + image_buffer = buf; + if (!image_list) return; for (i = 0; i < n_load_image; i++) { @@ -416,8 +415,8 @@ loadImage(int flag) } image_list = NULL; image_file = NULL; - if (CurrentTab && Currentbuf) - displayBuffer(Currentbuf, B_NORMAL); + if (image_buffer) + displayBuffer(image_buffer, B_NORMAL); return; } if (cache->loaded == IMG_FLAG_UNLOADED) @@ -428,7 +427,10 @@ loadImage(int flag) flush_tty(); if ((cache->pid = fork()) == 0) { Buffer *b; +/* setup_child(TRUE, 0, -1); +*/ + setup_child(FALSE, 0, -1); image_source = cache->file; b = loadGeneralFile(cache->url, cache->current, NULL, 0, NULL); if (!b || !b->real_type || strncasecmp(b->real_type, "image/", 6)) diff --git a/main.c b/main.c @@ -1039,7 +1039,7 @@ main(int argc, char **argv, char **envp) if (activeImage && displayImage && Currentbuf->img && !Currentbuf->image_loaded) { do { - loadImage(IMG_FLAG_NEXT); + loadImage(Currentbuf, IMG_FLAG_NEXT); } while (sleep_till_anykey(1, 0) <= 0); } #endif @@ -6089,11 +6089,7 @@ checkDownloadList(void) if (!FirstDL) return FALSE; for (d = FirstDL; d != NULL; d = d->next) { -#ifdef HAVE_LSTAT if (!d->ok && !lstat(d->lock, &st)) -#else - if (!d->ok && !stat(d->lock, &st)) -#endif return TRUE; } return FALSE; @@ -6131,11 +6127,7 @@ DownloadListBuffer(void) DOWNLOAD_LIST_TITLE "</h1>\n" "<form method=internal action=download><hr>\n"); for (d = LastDL; d != NULL; d = d->prev) { -#ifdef HAVE_LSTAT if (lstat(d->lock, &st)) -#else - if (stat(d->lock, &st)) -#endif d->ok = TRUE; Strcat_charp(src, "<pre>\n"); Strcat(src, Sprintf("%s\n --&gt; %s\n ", html_quote(d->url), diff --git a/news.c b/news.c @@ -314,7 +314,7 @@ loadNewsgroup(ParsedURL *pu, char *code) char *volatile scheme, *volatile group, *volatile list; int status, i, first, last; volatile int flag = 0, start = 0, end = 0; - MySignalHandler(*volatile trap) (SIGNAL_ARG) = NULL; + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; if (current_news.host == NULL || !pu->file || *pu->file == '\0') return NULL; @@ -346,9 +346,7 @@ loadNewsgroup(ParsedURL *pu, char *code) Strcat_charp(page, "</table>\n<p>Transfer Interrupted!\n"); goto news_end; } - trap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; tmp = news_command(&current_news, "GROUP", group, &status); if (status != 211) @@ -489,9 +487,7 @@ loadNewsgroup(ParsedURL *pu, char *code) news_end: Strcat_charp(page, "</body>\n</html>\n"); - if (fmInitialized) - term_raw(); - signal(SIGINT, trap); + TRAP_OFF; return page; } diff --git a/proto.h b/proto.h @@ -184,7 +184,7 @@ extern void restore_fonteffect(struct html_feed_environ *h_env, #ifdef USE_IMAGE extern void deleteImage(Buffer *buf); extern void getAllImage(Buffer *buf); -extern void loadImage(int flag); +extern void loadImage(Buffer *buf, int flag); extern ImageCache *getImage(Image * image, ParsedURL *current, int flag); extern int getImageSize(ImageCache * cache); #endif diff --git a/url.c b/url.c @@ -457,7 +457,7 @@ openSocket(char *const hostname, int a1, a2, a3, a4; unsigned long adr; #endif /* not INET6 */ - MySignalHandler(*volatile trap) (SIGNAL_ARG) = NULL; + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; if (fmInitialized) { message(Sprintf("Opening socket...")->ptr, 0, 0); @@ -471,9 +471,7 @@ openSocket(char *const hostname, close(sock); goto error; } - trap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; if (hostname == NULL) { #ifdef SOCK_DEBUG sock_log("openSocket() failed. reason: Bad hostname \"%s\"\n", @@ -618,15 +616,10 @@ openSocket(char *const hostname, } #endif /* not INET6 */ - if (fmInitialized) - term_raw(); - signal(SIGINT, trap); + TRAP_OFF; return sock; error: - if (fmInitialized) - term_raw(); - signal(SIGINT, trap); - + TRAP_OFF; return -1; } @@ -1955,7 +1948,7 @@ check_no_proxy(char *domain) { TextListItem *tl; volatile int ret = 0; - MySignalHandler(*volatile trap) (SIGNAL_ARG) = NULL; + MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; if (NO_proxy_domains == NULL || NO_proxy_domains->nitem == 0 || domain == NULL) @@ -1974,9 +1967,7 @@ check_no_proxy(char *domain) ret = 0; goto end; } - trap = signal(SIGINT, KeyAbort); - if (fmInitialized) - term_cbreak(); + TRAP_ON; { #ifndef INET6 struct hostent *he; @@ -2053,9 +2044,7 @@ check_no_proxy(char *domain) #endif /* INET6 */ } end: - if (fmInitialized) - term_raw(); - signal(SIGINT, trap); + TRAP_OFF; return ret; }