From f807b916005b1c03735bf9c566600a863a3122f4 Mon Sep 17 00:00:00 2001 From: Norbert Warmuth Date: Tue, 13 Apr 1999 19:21:03 +0000 Subject: [PATCH] Tue Apr 13 07:07:36 1999 Norbert Warmuth * slang/slutty.c (SLsys_getkey): handle EOF on stdin (return SLANG_GETKEY_ERROR on EOF instead of returning garbage) * slang/Makefile.in (clean): remove the symbolic link slang.h on the distclean target and not on the clean target. Tue Apr 13 07:14:10 1999 Norbert Warmuth * src/slint.c (getch): Quit MC when SLang_getkey returns an error. Looking at the code that's only the case when we read EOF from stdin. This fixes the problem where MC consumes a lot of cpu time while reading EOF from stdin in a tight loop. This situation arises when the terminal line/connection drops without MC being sent SIGHUP. Tue Apr 13 06:07:05 1999 Norbert Warmuth * configure.in: Some AC_ARG_WITH macros haven't checked $withval, i.e. --with-PACKAGE and --without-PACKAGE gave the same results. --- ChangeLog | 5 +++++ configure.in | 27 ++++++++++++++++----------- slang/ChangeLog | 8 ++++++++ slang/Makefile.in | 4 ++-- slang/slutty.c | 6 +++++- src/ChangeLog | 14 ++++++++++++++ src/slint.c | 17 ++++++++++++++--- 7 files changed, 64 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index cdd842ee4..40c8fdc30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Apr 13 06:07:05 1999 Norbert Warmuth + + * configure.in: Some AC_ARG_WITH macros havn't checked $withval, i.e. + --with-PACKAGE and --without-PACKAGE gave the same results. + 1999-04-09 Federico Mena Quintero * configure.in (VERSION): Bumped version number to 4.5.30. diff --git a/configure.in b/configure.in index 56329fc7a..54438288b 100644 --- a/configure.in +++ b/configure.in @@ -795,25 +795,28 @@ AC_CHECK_LIB(slang,SLang_init_tty, AC_ARG_WITH(terminfo, [--with-terminfo SLANG: Force usage of terminfo],[ - AC_USE_TERMINFO - slang_check_lib=false - slang_use_system_installed_lib=false - ] + if test x$withval = xyes; then + AC_USE_TERMINFO + slang_check_lib=false + slang_use_system_installed_lib=false + fi] ) AC_ARG_WITH(termcap, [--with-termcap SLANG: Force usage of termcap],[ - AC_USE_TERMCAP - slang_check_lib=false - slang_use_system_installed_lib=false - ] + if test x$withval = xyes; then + AC_USE_TERMCAP + slang_check_lib=false + slang_use_system_installed_lib=false + fi] ) AC_ARG_WITH(included-slang, [--with-included-slang SLANG: use the SLang library included here],[ + if test x$withval = xyes; then slang_use_system_installed_lib=false slang_check_lib=true - ] + fi] ) AC_DEFUN(AC_WITH_SLANG, @@ -917,8 +920,10 @@ AC_SUBST(LEDIT) AC_ARG_WITH(netrc, [--with-netrc Compile with ftp .netrc support],[ - AC_DEFINE(USE_NETRC) - AC_MSG_RESULT(ftpfs will have .netrc parsing code) + if test x$withval = xyes; then + AC_DEFINE(USE_NETRC) + AC_MSG_RESULT(ftpfs will have .netrc parsing code) + fi ]) undelfs_o="" diff --git a/slang/ChangeLog b/slang/ChangeLog index 7b9841eae..66c1f52b5 100644 --- a/slang/ChangeLog +++ b/slang/ChangeLog @@ -1,3 +1,11 @@ +Tue Apr 13 07:07:36 1999 Norbert Warmuth + + * slutty.c (SLsys_getkey): handle EOF on stdin (return + SLANG_GETKEY_ERROR on EOF instead of returning garbage) + + * Makefile.in (clean): remove the symbolic link slang.h on the + distclean target and not on the clean target. + Sun Feb 14 01:05:42 1999 Norbert Warmuth * sldisply.c (SLtt_get_terminfo): use g_snprintf instead of diff --git a/slang/Makefile.in b/slang/Makefile.in index fda8cf63b..d52cc3e32 100644 --- a/slang/Makefile.in +++ b/slang/Makefile.in @@ -51,10 +51,10 @@ TAGS: $(SLANGSRCS) etags $(SLANGSRCS) clean: - $(RMF) *.o core a.out libmcslang.a slang.h + $(RMF) *.o core a.out libmcslang.a realclean: clean - $(RMF) .depend + $(RMF) .depend slang.h $(RMF) TAGS $(RMF) *~ diff --git a/slang/slutty.c b/slang/slutty.c index ed2ee8c05..5c6f47392 100644 --- a/slang/slutty.c +++ b/slang/slutty.c @@ -462,6 +462,7 @@ static int handle_interrupt (void) unsigned int SLsys_getkey (void) { unsigned char c; + unsigned int i; if (TTY_Inited == 0) { @@ -497,7 +498,7 @@ unsigned int SLsys_getkey (void) break; /* let read handle it */ } - while (-1 == read(SLang_TT_Read_FD, (char *) &c, 1)) + while (-1 == (i = read(SLang_TT_Read_FD, (char *) &c, 1))) { if (errno == EINTR) { @@ -532,6 +533,9 @@ unsigned int SLsys_getkey (void) return SLANG_GETKEY_ERROR; } + if (i == 0) + return SLANG_GETKEY_ERROR; + return((unsigned int) c); } diff --git a/src/ChangeLog b/src/ChangeLog index a88f30aae..e3300b79f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +Tue Apr 13 07:14:10 1999 Norbert Warmuth + + * slint.c (getch): Quit MC when SLang_getkey returns an error. Looking + at the code that's only the case when we read EOF from stdin. + + This fixes the problem where MC consumes a lot of cpu time while + reading EOF from stdin in a tight loop. This situation arises when the + terminal line/connection drops without MC being sent SIGHUP. + +Tue Apr 13 07:13:10 1999 Norbert Warmuth + + * slint.c (SLang_input_pending2): don't store SLANG_GETKEY_ERROR (int) + in the input buffer (char). + 1999-04-12 Andrew T. Veliath * main.c (_do_panel_cd): If we are using GNOME, and the panel is a diff --git a/src/slint.c b/src/slint.c index ee46fb751..edde6d8b0 100644 --- a/src/slint.c +++ b/src/slint.c @@ -105,8 +105,9 @@ static unsigned int SLang_getkey2 (void) static int SLang_input_pending2 (int tsecs) { - int n; + int n, i; unsigned char c; + if (SLang_Input_Buffer_Len) return (int) SLang_Input_Buffer_Len; #if SLANG_VERSION >= 10000 n = _SLsys_input_pending (tsecs); @@ -115,7 +116,10 @@ static int SLang_input_pending2 (int tsecs) #endif if (n <= 0) return 0; - c = (unsigned char) SLang_getkey2 (); + i = SLang_getkey2 (); + if (i == SLANG_GETKEY_ERROR) + return 0; /* don't put crippled error codes into the input buffer */ + c = (unsigned char)i; SLang_ungetkey_string (&c, 1); return n; @@ -571,11 +575,18 @@ load_terminfo_keys () int getch () { + int c; if (no_slang_delay) if (SLang_input_pending2 (0) == 0) return -1; - return (SLang_getkey2 ()); + c = SLang_getkey2 (); + if (c == SLANG_GETKEY_ERROR) { + fprintf (stderr, "SLang_getkey returned SLANG_GETKEY_ERROR\n" + "Assuming EOF on stdin and exiting\n"); + quiet_quit_cmd (); + } + return (c); } extern int slow_terminal;