From 970d17ca4c52b32186910059bca87f8e6424050b Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Wed, 16 Jan 2002 19:02:12 +0000 Subject: [w3m-dev 02862] SIGPIPE for migemo support * main.c (SigPipe): added * main.c (MAIN): signal(SIGPIPE, ) * search.c: #include * search.c (migemostr): check fflush() error * search.c (migemostr): check result string (empty is err) * search.c (migemostr): if error occured, disable use_migemo From: Fumitoshi UKAI --- ChangeLog | 12 +++++++++++- main.c | 21 ++++++++++++++++++++- search.c | 18 ++++++++++++++++-- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a621e5..1b96ebe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2002-01-17 Fumitoshi UKAI + + * [w3m-dev 02862] SIGPIPE for migemo support + * main.c (SigPipe): added + * main.c (MAIN): signal(SIGPIPE, ) + * search.c: #include + * search.c (migemostr): check fflush() error + * search.c (migemostr): check result string (empty is err) + * search.c (migemostr): if error occured, disable use_migemo + 2002-01-17 Fumitoshi UKAI * [w3m-dev 02861] IPv6 configuration check @@ -2064,4 +2074,4 @@ * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.233 2002/01/16 17:22:49 ukai Exp $ +$Id: ChangeLog,v 1.234 2002/01/16 19:02:12 ukai Exp $ diff --git a/main.c b/main.c index c660faa..1115e35 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.62 2002/01/16 16:49:54 ukai Exp $ */ +/* $Id: main.c,v 1.63 2002/01/16 19:02:15 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include @@ -54,6 +54,10 @@ static MySignalHandler resize_handler(SIGNAL_ARG); static void resize_screen(void); #endif +#ifdef SIGPIPE +static MySignalHandler SigPipe(SIGNAL_ARG); +#endif + #ifdef USE_MARK static char *MarkString = NULL; #endif @@ -708,6 +712,9 @@ MAIN(int argc, char **argv, char **envp) #ifdef SIGCHLD signal(SIGCHLD, sig_chld); #endif +#ifdef SIGPIPE + signal(SIGPIPE, SigPipe); +#endif orig_GC_warn_proc = GC_set_warn_proc(wrap_GC_warn_proc); err_msg = Strnew(); @@ -1206,6 +1213,18 @@ resize_screen(void) } #endif /* SIGWINCH */ +#ifdef SIGPIPE +static MySignalHandler +SigPipe(SIGNAL_ARG) +{ +#ifdef USE_MIGEMO + init_migemo(); +#endif + signal(SIGPIPE, SigPipe); + SIGNAL_RETURN; +} +#endif + /* * Command functions: These functions are called with a keystroke. */ diff --git a/search.c b/search.c index 1c47ff1..d77701b 100644 --- a/search.c +++ b/search.c @@ -1,6 +1,7 @@ -/* $Id: search.c,v 1.9 2002/01/16 16:49:55 ukai Exp $ */ +/* $Id: search.c,v 1.10 2002/01/16 19:02:16 ukai Exp $ */ #include "fm.h" #include "regex.h" +#include static void set_mark(Line *l, int pos, int epos) @@ -71,10 +72,23 @@ migemostr(char *str) if (open_migemo(migemo_command) == 0) return str; fprintf(migemow, "%s\n", str); - fflush(migemow); +again: + if (fflush(migemow) != 0) { + switch (errno) { + case EINTR: goto again; + default: goto err; + } + } tmp = Strfgets(migemor); Strchop(tmp); + if (tmp->length == 0) + goto err; return tmp->ptr; +err: + /* XXX: backend migemo is not working? */ + init_migemo(); + use_migemo = 0; + return str; } #endif /* USE_MIGEMO */ -- cgit v1.2.3