Ticket #152: remove-ncurses.patch

File remove-ncurses.patch, 5.5 KB (added by josephpiche, 4 years ago)

potential fix

  • utils/gg_utils.h

    old new  
    5252#include <io.h> 
    5353#endif 
    5454 
    55 void gg_init_color(void); 
    5655void write_color_char(int c, int x); 
    5756void write_color_string(int c, const char *str); 
    5857 
  • utils/gg_utils.c

    old new  
    3535/* Avoid compiler warnings with unused parameters */ 
    3636#define UNUSED(x)  (void)x 
    3737 
    38 /* Define TERMINFO or ANSI_COLOR to enable coloring of pieces. 
     38/* Define ANSI_COLOR to enable coloring of pieces. 
    3939 * This is normally done in config.h. 
    4040 */ 
    4141 
     
    5252 *  7=white 
    5353 */ 
    5454 
    55 #ifdef TERMINFO 
    56  
    57 #ifdef _AIX 
    58 #define _TPARM_COMPAT 
    59 #endif 
    60  
    61 #if HAVE_CURSES_H 
    62 #include <curses.h> 
    63 #elif HAVE_NCURSES_CURSES_H 
    64 #include <ncurses/curses.h> 
    65 #else 
    66 #endif 
    67  
    68 #if HAVE_TERM_H 
    69 #include <term.h> 
    70 #elif HAVE_NCURSES_TERM_H 
    71 #include <ncurses/term.h> 
    72 #else 
    73 #endif 
    74  
    75  
    76 /* terminfo attributes */ 
    77 static char *setaf;             /* terminfo string to set color */ 
    78 static int max_color;           /* terminfo max colour */ 
    79  
    80 static int init = 0; 
    81  
    82 #endif /* TERMINFO */ 
    83  
    8455/* for gg_cputime */ 
    8556 
    8657#ifdef HAVE_UNISTD_H 
     
    9263#include <windows.h> 
    9364#endif 
    9465 
    95 void 
    96 gg_init_color() 
    97 { 
    98 #ifdef TERMINFO 
    99  
    100 /* compiler is set to make string literals  const char * 
    101  * But system header files dont prototype things correctly. 
    102  * These are equivalent to a non-const string literals 
    103  */ 
    104  
    105   static char setaf_literal[] = "setaf"; 
    106   static char colors_literal[] = "colors"; 
    107   static char empty_literal[] = ""; 
    108  
    109   if (init) 
    110     return; 
    111    
    112   init = 1; 
    113  
    114   setupterm(NULL, 2, NULL); 
    115   setaf = tigetstr(setaf_literal); 
    116   if (!setaf) 
    117     setaf = empty_literal; 
    118   max_color = tigetnum(colors_literal) - 1; 
    119   if (max_color < 1) 
    120     max_color = 1; 
    121   else if (max_color > 30) 
    122     max_color = 30; 
    123    
    124 #endif /* TERMINFO */ 
    125 } 
    126  
    127  
    12866 
    12967#ifdef WIN32 
    13068#ifdef VC 
     
    15492void  
    15593write_color_char_no_space(int c, int x) 
    15694{ 
    157 #ifdef TERMINFO 
    158  
    159   fprintf(stderr, "%s%c", tparm(setaf, c, 0, 0, 0, 0, 0, 0, 0, 0), x); 
    160   fputs(tparm(setaf, max_color, 0, 0, 0, 0, 0, 0, 0, 0), stderr); 
    161  
    162 #elif defined(ANSI_COLOR) 
     95#ifdef ANSI_COLOR 
    16396 
    16497  fprintf(stderr, "\033[%dm%c\033[0m", 30+c, x); 
    16598 
  • engine/showbord.c

    old new  
    100100void 
    101101start_draw_board() 
    102102{ 
    103   gg_init_color(); 
    104103  draw_letter_coordinates(stderr); 
    105104} 
    106105 
     
    266265showboard(int xo) 
    267266{ 
    268267  int i, j, ii; 
    269   gg_init_color(); 
    270268 
    271269  /* Set all dragon numbers to 0. */ 
    272270  memset(dragon_num, 0, sizeof(dragon_num)); 
  • configure.in

    old new  
    2929 
    3030AM_MAINTAINER_MODE 
    3131 
    32 dnl See if user has expressed a preference for use of curses and/or color 
    33 dnl These set variables $enable_color and $with_curses to "no" if disabled 
     32dnl See if user has expressed a preference for use of color 
     33dnl These set variables $enable_color to "no" if disabled 
    3434dnl "yes" if enabled, or undefined if not specified 
    3535 
    3636AC_ARG_WITH(readline, 
    3737 [  --with-readline     try to use GNU Readline for command reading 
    3838  --without-readline  do not use GNU Readline (default)]) 
    3939 
    40 AC_ARG_WITH(curses, 
    41  [  --with-curses       try to use curses for colored debugging output (default) 
    42   --without-curses    do not use curses for colored debugging output]) 
    43  
    4440AC_ARG_ENABLE(color, 
    45  [  --enable-color              use curses or ansi escape sequences for colored 
     41 [  --enable-color              use ansi escape sequences for colored 
    4642                                   debug output 
    4743  --disable-color             do not try to generated colored debug output]) 
    4844 
     
    160156AC_C_CONST 
    161157 
    162158AC_CHECK_HEADERS(unistd.h sys/time.h sys/times.h) 
    163 AC_CHECK_HEADERS(curses.h term.h ncurses/curses.h ncurses/term.h) 
    164  
    165 if test "$ac_cv_header_curses_h" = "yes";then 
    166    curses_header="curses.h" 
    167 elif test "$ac_cv_header_ncurses_curses_h" = "yes";then 
    168    curses_header="ncurses/curses.h" 
    169 else 
    170    curses_header="no" 
    171 fi 
    172  
    173 if test "$ac_cv_header_term_h" = "yes";then 
    174    term_header="term.h" 
    175 elif test "$ac_cv_header_ncurses_term_h" = "yes";then 
    176    term_header="ncurses/term.h" 
    177 else 
    178    term_header="no" 
    179 fi 
    180159 
    181160AC_CHECK_SIZEOF(long,,[#include <stdio.h>]) 
    182161 
     
    250229 
    251230dnl -------- color debugging support ----------- 
    252231 
    253 AH_TEMPLATE([TERMINFO], 
    254 [Define to 1 if termcap/terminfo is available.]) 
    255  
    256232AH_TEMPLATE([ANSI_COLOR], 
    257233[Define to use ansi escape sequences for color debugging]) 
    258234 
    259235tmp_color_result="none" 
    260236 
    261 if test "$with_curses" != no -a "$enable_color" != no ; then 
    262   tmp_color_result="none (curses failed)" 
    263  
    264   dnl Do a separate test for curses and termcap 
    265   dnl DJGPP does have pdcurses, but not termcap 
    266  
    267   dnl make sure that both curses.h and term.h are available 
    268   dnl FIXME: better to actually figure out here what headers 
    269   dnl are really required 
    270   if test "$term_header" != "no" -a "$curses_header" != "no" ; then 
    271  
    272     dnl check for a working termcap library 
    273     AC_SEARCH_LIBS(tparm,ncurses curses pdcurses termcap terminfo termlib) 
    274  
    275     if test "$ac_cv_search_tparm" != "no" ; then 
    276       AC_DEFINE(TERMINFO) 
    277     tmp_color_result="curses" 
    278     fi 
    279   fi 
    280 fi 
    281  
    282 if test "$with_curses" = no -a "$enable_color" != no ; then 
    283   dnl we asked for color, but there is no termcap 
     237if test "$enable_color" != no ; then 
    284238  AC_DEFINE(ANSI_COLOR) 
    285239  tmp_color_result="ANSI color" 
    286240