From 572ac48fd7ac7e5b2c1874a7198842d32f2bf0b7 Mon Sep 17 00:00:00 2001 From: Ito Hiroyuki Date: Fri, 20 Aug 2010 09:34:47 +0000 Subject: exit code is 1 when an error is occured --- ChangeLog | 10 +++++++++- terms.c | 34 +++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index d0ddc74..7904837 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-08-20 Ito Hiroyuki + + * [w3m-dev 04402] Re: "normal" bugs from bugs.debian.org + * terms.c (reset_exit_with_value, reset_error_exit): added + (reset_exit): use reset_exit_with_value() + (ttymode_set, ttymode_reset, set_cc, getTCstr) + (sleep_till_anykey): use reset_error_exit() instead of reset_exit() + 2010-08-14 "Adam C. Emerson" * [w3m-dev 04390] @@ -9155,4 +9163,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.1035 2010/08/14 01:29:40 htrb Exp $ +$Id: ChangeLog,v 1.1036 2010/08/20 09:34:47 htrb Exp $ diff --git a/terms.c b/terms.c index e031586..7a3c987 100644 --- a/terms.c +++ b/terms.c @@ -1,4 +1,4 @@ -/* $Id: terms.c,v 1.62 2010/08/04 14:06:36 htrb Exp $ */ +/* $Id: terms.c,v 1.63 2010/08/20 09:34:47 htrb Exp $ */ /* * An original curses library for EUC-kanji by Akinori ITO, December 1989 * revised by Akinori ITO, January 1995 @@ -256,7 +256,7 @@ check_cygwin_console(void) #endif /* __CYGWIN__ */ char *getenv(const char *); -MySignalHandler reset_exit(SIGNAL_ARG), error_dump(SIGNAL_ARG); +MySignalHandler reset_exit(SIGNAL_ARG), reset_error_exit(SIGNAL_ARG), error_dump(SIGNAL_ARG); void setlinescols(void); void flush_tty(); @@ -564,7 +564,7 @@ ttymode_set(int mode, int imode) if (errno == EINTR || errno == EAGAIN) continue; printf("Error occured while set %x: errno=%d\n", mode, errno); - reset_exit(SIGNAL_ARGLIST); + reset_error_exit(SIGNAL_ARGLIST); } #endif } @@ -585,7 +585,7 @@ ttymode_reset(int mode, int imode) if (errno == EINTR || errno == EAGAIN) continue; printf("Error occured while reset %x: errno=%d\n", mode, errno); - reset_exit(SIGNAL_ARGLIST); + reset_error_exit(SIGNAL_ARGLIST); } #endif /* __MINGW32_VERSION */ } @@ -602,7 +602,7 @@ set_cc(int spec, int val) if (errno == EINTR || errno == EAGAIN) continue; printf("Error occured: errno=%d\n", errno); - reset_exit(SIGNAL_ARGLIST); + reset_error_exit(SIGNAL_ARGLIST); } } #endif /* not HAVE_SGTTY_H */ @@ -637,18 +637,30 @@ reset_tty(void) close_tty(); } -MySignalHandler -reset_exit(SIGNAL_ARG) +static MySignalHandler +reset_exit_with_value(SIGNAL_ARG, int rval) { #ifdef USE_MOUSE if (mouseActive) mouse_end(); #endif /* USE_MOUSE */ reset_tty(); - w3m_exit(0); + w3m_exit(rval); SIGNAL_RETURN; } +MySignalHandler +reset_error_exit(SIGNAL_ARG) +{ + reset_exit_with_value(SIGNAL_ARGLIST, 1); +} + +MySignalHandler +reset_exit(SIGNAL_ARG) +{ + reset_exit_with_value(SIGNAL_ARGLIST, 0); +} + MySignalHandler error_dump(SIGNAL_ARG) { @@ -708,14 +720,14 @@ getTCstr(void) ent = getenv("TERM") ? getenv("TERM") : DEFAULT_TERM; if (ent == NULL) { fprintf(stderr, "TERM is not set\n"); - reset_exit(SIGNAL_ARGLIST); + reset_error_exit(SIGNAL_ARGLIST); } r = tgetent(bp, ent); if (r != 1) { /* Can't find termcap entry */ fprintf(stderr, "Can't find termcap entry %s\n", ent); - reset_exit(SIGNAL_ARGLIST); + reset_error_exit(SIGNAL_ARGLIST); } GETSTR(T_ce, "ce"); /* clear to the end of line */ @@ -2008,7 +2020,7 @@ sleep_till_anykey(int sec, int purge) er = TerminalSet(tty, &ioval); if (er == -1) { printf("Error occured: errno=%d\n", errno); - reset_exit(SIGNAL_ARGLIST); + reset_error_exit(SIGNAL_ARGLIST); } return ret; } -- cgit v1.2.3