From 0c7d399300204a2f102bcd0bd9812c0e057d05ef Mon Sep 17 00:00:00 2001 From: Patrick Winnertz Date: Wed, 4 Feb 2009 20:37:00 +0100 Subject: [PATCH 1/2] Reverted Enricos backport from master which removes accidentially slang1.x support Enrico has accidentially removed the slang1.x support in mc-4.6 branch as this is a structural change which clearly doesn't belong into mc-4.6. Signed-off-by: Patrick Winnertz --- ChangeLog | 3 --- acinclude.m4 | 39 ++++++++++++++++++++++++++++++++ src/slint.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 101 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b48e12124..9bdc617ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,9 +9,6 @@ 2009-02-01 Enrico Weigelt, metux ITS - * acinclude.m4: removed MC_SLANG_PRIVATE macro - * src/slint.c: removed HAVE_SLANG_PRIVATE conditional and - replaced SLang_getkey2(), SLang_input_pending2() * src/util.c: fixed name_trunc() on NULL or empty parameters * src/achown.c: fixed unitialized var in init_chown_advanced() (patch from andrew_b) diff --git a/acinclude.m4 b/acinclude.m4 index aa2c6faef..f4c0e3bc5 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -298,6 +298,44 @@ AC_DEFUN([MC_USE_TERMCAP], [ ]) +dnl +dnl Check if private functions are available for linking +dnl +AC_DEFUN([MC_SLANG_PRIVATE], [ + AC_CACHE_CHECK([if S-Lang exports private functions], + [mc_cv_slang_private], [ + ac_save_LIBS="$LIBS" + LIBS="$LIBS -lslang" + AC_TRY_LINK([ + #ifdef HAVE_SLANG_SLANG_H + #include + #else + #include + #endif + #if SLANG_VERSION >= 10000 + extern unsigned int SLsys_getkey (void); + #else + extern unsigned int _SLsys_getkey (void); + #endif + ], [ + #if SLANG_VERSION >= 10000 + _SLsys_getkey (); + #else + SLsys_getkey (); + #endif + ], + [mc_cv_slang_private=yes], + [mc_cv_slang_private=no]) + LIBS="$ac_save_LIBS" + ]) + + if test x$mc_cv_slang_private = xyes; then + AC_DEFINE(HAVE_SLANG_PRIVATE, 1, + [Define if private S-Lang functions are available]) + fi +]) + + dnl dnl Check if the installed S-Lang library uses termcap dnl @@ -373,6 +411,7 @@ it's not fully supported yet]) if test x$with_screen = xslang; then AC_DEFINE(HAVE_SYSTEM_SLANG, 1, [Define to use S-Lang library installed on the system]) + MC_SLANG_PRIVATE screen_type=slang screen_msg="S-Lang library (installed on the system)" else diff --git a/src/slint.c b/src/slint.c index cf8732204..c30fac1b1 100644 --- a/src/slint.c +++ b/src/slint.c @@ -77,6 +77,66 @@ static int no_slang_delay; /* Forward declarations */ static void load_terminfo_keys (void); +#ifndef HAVE_SLANG_PRIVATE +/* Private interfaces have been stripped, so we cannot use them */ +#define SLang_getkey2() SLang_getkey() +#define SLang_input_pending2(s) SLang_input_pending(s) +#else +/* Copied from ../slang/slgetkey.c, removed the DEC_8Bit_HACK. */ +extern unsigned char SLang_Input_Buffer []; +#if SLANG_VERSION >= 10000 +extern unsigned int _SLsys_getkey (void); +extern int _SLsys_input_pending (int); +#else +extern unsigned int SLsys_getkey (void); +extern int SLsys_input_pending (int); +#endif + +static unsigned int SLang_getkey2 (void) +{ + unsigned int imax; + unsigned int ch; + + if (SLang_Input_Buffer_Len) + { + ch = (unsigned int) *SLang_Input_Buffer; + SLang_Input_Buffer_Len--; + imax = SLang_Input_Buffer_Len; + + memmove ((char *) SLang_Input_Buffer, + (char *) (SLang_Input_Buffer + 1), imax); + return(ch); + } +#if SLANG_VERSION >= 10000 + else return(_SLsys_getkey ()); +#else + else return(SLsys_getkey()); +#endif +} + +static int SLang_input_pending2 (int tsecs) +{ + 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); +#else + n = SLsys_input_pending (tsecs); +#endif + if (n <= 0) return 0; + + 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; +} +#endif /* HAVE_SLANG_PRIVATE */ + /* Only done the first time */ void slang_init (void) @@ -405,10 +465,10 @@ getch (void) { int c; if (no_slang_delay) - if (SLang_input_pending (0) == 0) + if (SLang_input_pending2 (0) == 0) return -1; - c = SLang_getkey (); + c = SLang_getkey2 (); if (c == SLANG_GETKEY_ERROR) { fprintf (stderr, "SLang_getkey returned SLANG_GETKEY_ERROR\n" From 161dc235a618c33bda49dbd84295406d5273fb70 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT service" Date: Wed, 4 Feb 2009 22:39:27 +0100 Subject: [PATCH 2/2] lib/mc.sh.in: fixes for non-bash shells (fixing #196) --- ChangeLog | 4 ++++ lib/mc.sh.in | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9bdc617ca..74b6e0f9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-02-04 Enrico Weigelt, metux ITS + + * lib/mc.sh.in: fixes for non-bash shells (fixing #196) + 2009-02-04 Enrico Weigelt, metux ITS * mhl/types.h, mhl/escape.h: replaced bool type by stdbool.h (fixing #240) diff --git a/lib/mc.sh.in b/lib/mc.sh.in index e3dc1fc9a..a829bf010 100644 --- a/lib/mc.sh.in +++ b/lib/mc.sh.in @@ -1 +1,3 @@ +# Don't define aliases in plain Bourne shell +[ -n "${BASH_VERSION}${KSH_VERSION}${ZSH_VERSION}" ] || return 0 alias mc='. @suppbindir@/mc-wrapper.sh'