Skip to content

Commit

Permalink
cleanup compile-checks for mousemask
Browse files Browse the repository at this point in the history
configure.ac: check for mousemask and mmask_t
replace use of NCURSES_MOUSE_VERSION by HAVE_MOUSEMASK
  • Loading branch information
sf-mensch committed Jul 28, 2023
1 parent bf7f203 commit 52b350d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 24 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

2023-07-28 Simon Sobisch <[email protected]>

* configure.ac: check for mousemask and mmask_t

2023-07-24 Simon Sobisch <[email protected]>

* configure.ac: fix for resolving COBCRUN_NAME
Expand Down
10 changes: 10 additions & 0 deletions build_windows/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@
/* #undef HAVE_ATTRIBUTE_CONSTRUCTOR - using DllMain */
#endif

/* Has __attribute__((pure)) */
/* #undef HAVE_ATTRIBUTE_PURE */

/* Define to 1 if you have the `canonicalize_file_name' function. */
#if defined(__ORANGEC__)
#define HAVE_CANONICALIZE_FILE_NAME 1
Expand Down Expand Up @@ -596,6 +599,13 @@
/* #undef HAVE_MOUSEINTERVAL */
#endif

/* curses has mousemask function and mmask_t definition */
#if CONFIGURED_CURSES != NOCURSES
#define HAVE_MOUSEMASK 1
#else
/* #undef HAVE_MOUSEMASK */
#endif

/* Define to 1 if you have the <mpir.h> header file. */
#if USED_MATHLIB == MATHLIB_MPIR
#define HAVE_MPIR_H 1
Expand Down
23 changes: 23 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ AH_TEMPLATE([HAVE_RESIZE_TERM], [curses has resize_term function])
AH_TEMPLATE([HAVE_DEFINE_KEY], [curses has define_key function])
AH_TEMPLATE([HAVE_MOUSEINTERVAL], [curses has mouseinterval function])
AH_TEMPLATE([HAVE_HAS_MOUSE], [curses has has_mouse function])
AH_TEMPLATE([HAVE_MOUSEMASK], [curses has mousemask function and mmask_t definition])
AH_TEMPLATE([HAVE_CURSES_FREEALL], [curses provides function to free all memory])
AH_TEMPLATE([HAVE_USE_LEGACY_CODING], [ncurses has use_legacy_coding function])
AH_TEMPLATE([HAVE_DESIGNATED_INITS], [Has designated initializers])
Expand Down Expand Up @@ -1529,6 +1530,28 @@ if test "$USE_CURSES" != no -a "$USE_CURSES" != "not_found"; then
[AC_DEFINE([HAVE_HAS_MOUSE], [1]) AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])],
[])

AC_MSG_CHECKING([for curses mousemask function and mmask_t])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h>
#elif defined (HAVE_NCURSESW_CURSES_H)
#include <ncursesw/curses.h>
#elif defined (HAVE_NCURSES_H)
#include <ncurses.h>
#elif defined (HAVE_NCURSES_NCURSES_H)
#include <ncurses/ncurses.h>
#elif defined (HAVE_PDCURSES_H)
#include <pdcurses.h>
#elif defined (HAVE_CURSES_H)
#include <curses.h>
#endif]], [[
mmask_t dummy = { 0 };
mousemask (dummy, NULL);
]])],
[AC_DEFINE([HAVE_MOUSEMASK], [1]) AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])],
[])
fi
LIBS="$curr_libs $LIBCOB_LIBS"

Expand Down
5 changes: 5 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

2023-07-28 Simon Sobisch <[email protected]>

* screenio.c, common.c: replace use of NCURSES_MOUSE_VERSION by
HAVE_MOUSEMASK

2023-07-27 Chuck Haatvedt <[email protected]>

* move.c (cob_move_display_to_packed): fix data corruption caused
Expand Down
12 changes: 9 additions & 3 deletions libcob/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@
#include <ncurses/ncurses.h>
#define COB_GEN_SCREENIO
#elif defined (HAVE_PDCURSES_H)
/* will internally define NCURSES_MOUSE_VERSION with
a recent version (for older version define manually): */
#define PDC_NCMOUSE /* use ncurses compatible mouse API */
#include <pdcurses.h>
#define COB_GEN_SCREENIO
Expand All @@ -129,6 +127,12 @@
#endif
#endif

#if defined (__PDCURSES__)
/* Note: PDC will internally define NCURSES_MOUSE_VERSION with
a recent version when PDC_NCMOUSE was defined;
for older version define manually! */
#endif

#if defined (WITH_XML2)
#include <libxml/xmlversion.h>
#include <libxml/xmlwriter.h>
Expand Down Expand Up @@ -9219,8 +9223,10 @@ get_screenio_and_mouse_info (char *version_buffer, size_t size, const int verbos
mouse_support = _("no");
}
}
#elif defined (NCURSES_MOUSE_VERSION)
#elif defined (HAVE_MOUSEMASK)
#if defined (__PDCURSES__)
/* CHECKME: that looks wrong - can't we test as above?
Double check with older PDCurses! */
mouse_support = _("yes");
#endif
#else
Expand Down
40 changes: 19 additions & 21 deletions libcob/screenio.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,18 @@
#include <ncurses/ncurses.h>
#define WITH_EXTENDED_SCREENIO
#elif defined (HAVE_PDCURSES_H)
/* will internally define NCURSES_MOUSE_VERSION with
a recent version (for older version define manually): */
#define PDC_NCMOUSE /* use ncurses compatible mouse API */
#include <pdcurses.h>
#define WITH_EXTENDED_SCREENIO
#elif defined (HAVE_PDCURSES_CURSES_H)
/* will internally define NCURSES_MOUSE_VERSION with
a recent version (for older version define manually): */
#define PDC_NCMOUSE /* use ncurses compatible mouse API */
#include <pdcurses/curses.h>
#define WITH_EXTENDED_SCREENIO
#elif defined (HAVE_XCURSES_H)
/* will internally define NCURSES_MOUSE_VERSION with
a recent version (for older version define manually): */
#define PDC_NCMOUSE /* use ncurses compatible mouse API */
#include <xcurses.h>
#define WITH_EXTENDED_SCREENIO
#elif defined (HAVE_XCURSES_CURSES_H)
/* will internally define NCURSES_MOUSE_VERSION with
a recent version (for older version define manually): */
#define PDC_NCMOUSE /* use ncurses compatible mouse API */
#include <xcurses/curses.h>
#define WITH_EXTENDED_SCREENIO
Expand All @@ -87,6 +79,12 @@
#define WITH_EXTENDED_SCREENIO
#endif

#if defined (__PDCURSES__)
/* Note: PDC will internally define NCURSES_MOUSE_VERSION with
a recent version when PDC_NCMOUSE was defined;
for older version define manually! */
#endif

/* work around broken system headers or compile flags defining
NCURSES_WIDECHAR / PDC_WIDE but not including the actual definitions */
#if defined (NCURSES_WIDECHAR) && !defined (WACS_HLINE)
Expand All @@ -106,7 +104,7 @@
#ifdef HAVE_CURSES_FREEALL
extern void _nc_freeall (void);
#endif
#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
static mmask_t cob_mask_accept; /* mask that is returned to COBOL ACCEPT */
static mmask_t cob_mask_routine; /* mask that is returned to COBOL routines (reserved) */
#if defined BUTTON5_PRESSED /* added in NCURSES_MOUSE_VERSION 2 */
Expand Down Expand Up @@ -164,7 +162,7 @@ static int accept_cursor_x;
static int pending_accept;
static int got_sys_char;
static unsigned int curr_setting_insert_mode = INT_MAX;
#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
static unsigned int curr_setting_mouse_flags = UINT_MAX;
#endif
#endif
Expand Down Expand Up @@ -2147,7 +2145,7 @@ find_field_by_pos (const int initial_curs, const int line, const int column) {
return -1;
}

#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
static int
mouse_to_exception_code (mmask_t mask) {
int fret = -1;
Expand Down Expand Up @@ -2397,7 +2395,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout)
int integer_part_end;
char sign;
int fix_position = 0;
#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
MEVENT mevent;
#endif

Expand Down Expand Up @@ -2429,7 +2427,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout)
}
}

#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
/* prevent warnings about not intialized structure */
memset (&mevent, 0, sizeof (MEVENT));
#endif
Expand Down Expand Up @@ -2458,7 +2456,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout)
goto screen_return;
}

#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
/* get mouse event here, handle later */
if (keyp == KEY_MOUSE) {
getmouse (&mevent);
Expand Down Expand Up @@ -2722,7 +2720,7 @@ cob_screen_get_all (const int initial_curs, const int accept_timeout)
/* Enter sign */
break;

#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
case KEY_MOUSE:
{
int mline = mevent.y;
Expand Down Expand Up @@ -3401,7 +3399,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum
int status;
chtype prompt_char; /* prompt character */
chtype default_prompt_char;
#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
MEVENT mevent;
#endif

Expand All @@ -3421,7 +3419,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum

origin_y = 0;
origin_x = 0;
#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
/* prevent warnings about not intialized structure */
memset (&mevent, 0, sizeof (MEVENT));
#endif
Expand Down Expand Up @@ -3636,7 +3634,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum
continue;
}

#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
/* get mouse event here, handle later */
if (keyp == KEY_MOUSE) {
getmouse (&mevent);
Expand Down Expand Up @@ -3722,7 +3720,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum
/* End key. */
fret = 2015;
goto field_return;
#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
case KEY_MOUSE:
{
int mline = mevent.y;
Expand Down Expand Up @@ -3949,7 +3947,7 @@ field_accept (cob_field *f, cob_flags_t fattr, const int sline, const int scolum
cob_move_cursor (cline, ccolumn);
continue;

#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
case KEY_MOUSE:
{
int mline = mevent.y;
Expand Down Expand Up @@ -4965,7 +4963,7 @@ cob_settings_screenio (void)
#ifdef HAVE_MOUSEINTERVAL
mouseinterval (COB_MOUSE_INTERVAL);
#endif
#ifdef NCURSES_MOUSE_VERSION
#ifdef HAVE_MOUSEMASK
if (curr_setting_mouse_flags != COB_MOUSE_FLAGS) {
mmask_t mask_applied = cob_mask_routine;
if (COB_MOUSE_FLAGS) {
Expand Down

0 comments on commit 52b350d

Please sign in to comment.