To ensure that I made a correct fix, I test-compiled le-1.16.3 and ran it. Doing that, I noticed some additional issues (partly because I did not override the makefile's C++ variables, but that was just as well, since it prompted me to do the extra fixes):
a) renamed the private symbol find_pair to find_or_init_pair b) include unistd.h to get prototype for write() c) add a cast to fix a signed/unsigned compiler warning d) add (to help with running valgrind) the ExitProgram macro e) fix a different fail-to-build with the opaque TERMTYPE Having done that, in a quick check the menus came up, and valgrind had only reported an issue with linux_process_key() which I suppose Alexander is familiar with. There are still more than a hundred compiler warnings. -- Thomas E. Dickey <dic...@invisible-island.net> http://invisible-island.net ftp://invisible-island.net
# patch by Thomas E. Dickey <dic...@invisible-island.net> # created Sat Jul 22 14:39:46 UTC 2017 # ------------------------------------------------------------------------------ # color.cc | 6 +++--- # edit.cc | 26 ++++++++++++++++++-------- # keynames.cc | 2 +- # regex.c | 8 ++++++-- # 4 files changed, 28 insertions(+), 14 deletions(-) # ------------------------------------------------------------------------------ Index: src/color.cc --- le-1.16.3/src/color.cc 2013-03-18 13:44:31.000000000 +0000 +++ le-1.16.3-fix/src/color.cc 2017-07-22 12:42:26.382956801 +0000 @@ -33,7 +33,7 @@ int can_use_default_colors; int next_pair; -static int find_pair(int fg,int bg) +static int find_or_init_pair(int fg,int bg) { if(!can_use_default_colors) { @@ -67,7 +67,7 @@ attr_table[an].n_attr=0; if(pal[i].fg!=NO_COLOR || pal[i].bg!=NO_COLOR) { - pair=find_pair(pal[i].fg,pal[i].bg); + pair=find_or_init_pair(pal[i].fg,pal[i].bg); attr_table[an].n_attr|=COLOR_PAIR(pair); } attr_table[an].n_attr|=pal[i].attr; @@ -94,7 +94,7 @@ else { attr_table[i].so_attr=(attr_table[i].n_attr|hl->attr)&~A_COLOR; - pair=find_pair(hl->fg,pal[p].bg); + pair=find_or_init_pair(hl->fg,pal[p].bg); attr_table[i].so_attr|=COLOR_PAIR(pair); } } Index: src/edit.cc --- le-1.16.3/src/edit.cc 2015-12-03 07:15:40.000000000 +0000 +++ le-1.16.3-fix/src/edit.cc 2017-07-22 13:15:35.326113146 +0000 @@ -53,6 +53,15 @@ # define fcntl(x,y,z) (0) #endif +#ifdef HAVE__NC_FREE_AND_EXIT +extern "C" { +extern void _nc_free_and_exit(int); +#define ExitProgram(code) _nc_free_and_exit(code) +}; +#else +#define ExitProgram(code) exit(code) +#endif + #include <alloca.h> #include "localcharset.h" @@ -385,7 +394,7 @@ if(le_scr==NULL) { fprintf(stderr,"le: newterm() failed. Check your $TERM variable.\n"); - exit(1); + ExitProgram(1); } #endif @@ -529,7 +538,7 @@ TermCurses(); - exit(0); + ExitProgram(0); } void PrintUsage(int arg) @@ -557,7 +566,7 @@ "\n" "The last file will be loaded. If no files specified, last readable file\n" "from history will be loaded if the path is relative or it is the last.\n"); - exit(1); + ExitProgram(1); } #if USE_MULTIBYTE_CHARS @@ -680,19 +689,19 @@ break; case('?'): fprintf(stderr,"%s: Try `%s --help' for more information\n",Program,argv[0]); - exit(1); + ExitProgram(1); case(DUMP_KEYMAP): WriteActionMap(stdout); - exit(0); + ExitProgram(0); case(DUMP_COLORS): DumpDefaultColors(stdout); - exit(0); + ExitProgram(0); case(PRINT_HELP): PrintUsage(0); - exit(0); + ExitProgram(0); case(PRINT_VERSION): PrintVersion(); - exit(0); + ExitProgram(0); case(USE_MMAP): opt_use_mmap=1; if(optView==-1) @@ -793,5 +802,6 @@ } Edit(); Terminate(); + ExitProgram(0); return 0; } Index: src/keynames.cc --- le-1.16.3/src/keynames.cc 2013-03-18 13:44:31.000000000 +0000 +++ le-1.16.3-fix/src/keynames.cc 2017-07-22 14:37:00.829660294 +0000 @@ -353,7 +353,7 @@ if(!cur_term) return; - TERMTYPE *tp = &cur_term->type; + TERMTYPE *tp = (TERMTYPE *)(&cur_term); if(!tp) return; if(NUM_STRINGS(tp)<=STRCOUNT) Index: src/regex.c --- le-1.16.3/src/regex.c 2013-03-18 13:44:31.000000000 +0000 +++ le-1.16.3-fix/src/regex.c 2017-07-22 12:52:29.475732342 +0000 @@ -202,6 +202,10 @@ char *realloc (); # endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + /* When used in Emacs's lib-src, we need xmalloc and xrealloc. */ void * @@ -2152,7 +2156,7 @@ re_wctype (str) re_char *str; { - const char *string = str; + const char *string = (const char *)str; if (STREQ (string, "alnum")) return RECC_ALNUM; else if (STREQ (string, "alpha")) return RECC_ALPHA; else if (STREQ (string, "word")) return RECC_WORD; @@ -2742,7 +2746,7 @@ main_pend = pend; main_pattern = pattern; p = pattern = whitespace_regexp; - pend = p + strlen (p); + pend = p + strlen ((const char *) p); break; }
signature.asc
Description: Digital signature