From 299d49aebf2362dc74e05087fce23c009f85d692 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 12 Jun 2023 14:03:39 -0400 Subject: [PATCH] another follow-up for curses_putmixed We received a report from someone whose build was failing because of the use of cchar_t and setcchar(). They were getting errors even though they were using an up-to-date curses library. Apparently, ncurses requires that _XOPEN_SOURCE_EXTENDED must be defined before the curses header files in order for those features to be available. We had already updated our .370 series of hints and hints/include files with -D_XOPEN_SOURCE_EXTENDED=1 but this person must have been building in some other way. Instead of failing to build in that situation, allow the fallback to the older, less-functional genl_putmixed() function, but also try not to do so silently and display a message that functionality is reduced. The difference between the use of genl_putmixed() and curses_putmixed() or tty_putmixed(), is that when doing '/' farlook operations, curses_putmixed() and tty_putmixed() try to display a character in the message window that looks exactly the same as the one on the map, even if a symbol from a symset is being used on the map, or when using ENHANCED_SYMBOLS. Related note: curses_putmixed() matches the symbol and the color, whereas tty_putmixed() (at present) does not attempt to match the color. --- include/tradstdc.h | 4 ++++ win/curses/cursmain.c | 9 +++++++-- win/curses/cursmesg.c | 9 ++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/tradstdc.h b/include/tradstdc.h index bff09c3a7..ccbb6d839 100644 --- a/include/tradstdc.h +++ b/include/tradstdc.h @@ -362,6 +362,8 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ #endif #if __GNUC__ >= 5 #define NONNULL __attribute__((returns_nonnull)) +/* #pragma message is available */ +#define NH_PRAGMA_MESSAGE 1 #endif #endif @@ -369,6 +371,8 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */ #ifndef ATTRNORETURN #define ATTRNORETURN __declspec(noreturn) #endif +/* #pragma message is available */ +#define NH_PRAGMA_MESSAGE 1 #endif #ifndef PRINTF_F diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index d5d21c678..f042adef8 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -24,11 +24,16 @@ extern long curs_mesg_suppress_seq; /* from cursmesg.c */ extern boolean curs_mesg_no_suppress; /* ditto */ extern int mesg_mixed; extern glyph_info mesg_gi; + #ifndef CURSES_GENL_PUTMIXED -#if !defined(PDCURSES) || defined(PDC_WIDE) +#if defined(PDC_WIDE) || defined(NCURSES_WIDECHAR) #define USE_CURSES_PUTMIXED +#else /* WIDE */ +#ifdef NH_PRAGMA_MESSAGE +#pragma message "Curses wide support not defined so NetHack curses message window functionality reduced" #endif -#endif +#endif /* WIDE */ +#endif /* CURSES_GENL_PUTMIXED */ /* stubs for curses_procs{} */ #ifdef POSITIONBAR diff --git a/win/curses/cursmesg.c b/win/curses/cursmesg.c index 60d37c085..14db90fbb 100644 --- a/win/curses/cursmesg.c +++ b/win/curses/cursmesg.c @@ -31,11 +31,14 @@ int mesg_mixed = 0; glyph_info mesg_gi; #ifndef CURSES_GENL_PUTMIXED -#if !defined(PDCURSES) || defined(PDC_WIDE) +#if defined(PDC_WIDE) || defined(NCURSES_WIDECHAR) #define USE_CURSES_PUTMIXED +#else /* WIDE */ +#ifdef NH_PRAGMA_MESSAGE +#pragma message "Curses wide support not defined so NetHack curses message window functionality reduced" #endif -#endif - +#endif /* WIDE */ +#endif /* CURSES_GENL_PUTMIXED */ /* Message window routines for curses interface */