[w3m-dev 04402] Re: "normal" bugs from bugs.debian.org

Hiroyuki Ito <[email protected]> Mon, 16 Aug 2010 19:39:03 +0900 (JST)
Newsgroups gmane.comp.web.w3m.devel
Message-ID <[email protected]>
伊東です。

>> not suitable for use in BROWSER
>> http://bugs.debian.org/568923
>> 
>> TERM が設定されていないときは 0 以外で値で終了してほしい。
> 
> こんな感じで大丈夫でしょうか?

SIGHUP 等で終了したときも 1 を返すようになると思いますが問題ないでしょうか。

下記の patch では signal を受けて終了した時の動作は変わらないはずです。




Index: terms.c
===================================================================
RCS file: /cvsroot/w3m/w3m/terms.c,v
retrieving revision 1.62
diff -u -r1.62 terms.c
--- terms.c	4 Aug 2010 14:06:36 -0000	1.62
+++ terms.c	16 Aug 2010 10:34:09 -0000
@@ -256,7 +256,7 @@
 #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 @@
 	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 @@
 	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 @@
 	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,19 +637,31 @@
     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)
 {
     mySignal(SIGIOT, SIG_DFL);
@@ -708,14 +720,14 @@
     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 @@
     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;
 }