Ticket #4463: 0001-configure-fix-duplication-of-ncurses-in-MCLIBS.patch

File 0001-configure-fix-duplication-of-ncurses-in-MCLIBS.patch, 3.2 KB (added by karlson2k, 18 months ago)
  • m4.include/mc-with-screen-ncurses.m4

    From 97a61921e379924bd81fa07424cf4de48d0d1b72 Mon Sep 17 00:00:00 2001
    From: Evgeny Grin <k2k@narod.ru>
    Date: Fri, 19 May 2023 20:27:04 +0300
    Subject: [PATCH] configure: fix duplication of ncurses in MCLIBS
    
    AC_SEARCH_LIBS macro adds required library to 'LIBS' variable.
    Currently 'LIBS' could be appended to 'MCLIBS' several times leading to
    duplication of found values.
    Also fixed duplication for 'stdscr' function detection.
    Additionally fixed potential problematic situation when 'addwstr' or
    'has_colors' detected in one ncurses library (for example 'ncurses'),
    while 'stdscr' detected in other ncurses library (for example 'curses').
    Such combination leads to problems.
    
    Signed-off-by: Karlson2k (Evgeny Grin) <k2k@narod.ru>
    ---
     m4.include/mc-with-screen-ncurses.m4 | 27 ++++++++++++++-------------
     1 file changed, 14 insertions(+), 13 deletions(-)
    
    diff --git a/m4.include/mc-with-screen-ncurses.m4 b/m4.include/mc-with-screen-ncurses.m4
    index 80d8478c9..d4b4ada43 100644
    a b AC_DEFUN([mc_WITH_NCURSES], [ 
    9898        dnl check the user supplied location 
    9999        mc_CHECK_NCURSES_BY_PATH([$ac_ncurses_inc_path],[$ac_ncurses_lib_path]) 
    100100 
    101         LIBS= 
    102         AC_SEARCH_LIBS([has_colors], [ncurses], [MCLIBS="$MCLIBS $LIBS"],  
     101        LIBS="$MCLIBS" 
     102        AC_SEARCH_LIBS([has_colors], [ncurses], [],  
    103103                       [AC_MSG_ERROR([Cannot find ncurses library])]) 
    104         AC_SEARCH_LIBS([stdscr], [tinfo ncurses], [MCLIBS="$MCLIBS $LIBS"], 
     104        AC_SEARCH_LIBS([stdscr], [tinfo], [], 
    105105                       [AC_MSG_ERROR([Cannot find a library providing stdscr])]) 
    106  
     106        MCLIBS="$LIBS" 
    107107 
    108108        screen_type=ncurses 
    109109        screen_msg="NCurses" 
    110110        AC_DEFINE(USE_NCURSES, 1,  
    111111                  [Define to use ncurses for screen management]) 
    112112    else 
    113         LIBS= 
    114         AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes], 
     113        LIBS="$MCLIBS" 
     114        AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [ncursesw_found=yes], 
    115115                       [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])]) 
    116  
    117         AC_SEARCH_LIBS([stdscr], [tinfow tinfo ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS"], 
    118                        [AC_MSG_ERROR([Cannot find a library providing stdscr])]) 
     116        MCLIBS="$LIBS" 
    119117 
    120118        if test x"$ncursesw_found" = "x"; then 
    121             LIBS= 
    122             AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"],  
     119            LIBS="$MCLIBS" 
     120            AC_SEARCH_LIBS([has_colors], [ncurses curses], [],  
    123121                           [AC_MSG_ERROR([Cannot find ncurses library])]) 
    124             AC_SEARCH_LIBS([stdscr], [tinfo ncurses curses], [MCLIBS="$MCLIBS $LIBS"], 
    125                            [AC_MSG_ERROR([Cannot find a library providing stdscr])]) 
     122            MCLIBS="$LIBS" 
    126123        fi 
     124        LIBS="$MCLIBS" 
     125        AC_SEARCH_LIBS([stdscr], [tinfow tinfo], [MCLIBS="$MCLIBS $LIBS"], 
     126                       [AC_MSG_ERROR([Cannot find a library providing stdscr])]) 
     127        MCLIBS="$LIBS" 
    127128 
    128129        dnl Check the header 
    129130        ncurses_h_found=