summaryrefslogtreecommitdiff
path: root/test/test.priv.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/test.priv.h')
-rw-r--r--test/test.priv.h105
1 files changed, 80 insertions, 25 deletions
diff --git a/test/test.priv.h b/test/test.priv.h
index a901185b8df0..3c0c2d36979d 100644
--- a/test/test.priv.h
+++ b/test/test.priv.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2023,2024 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2017,2018 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -30,7 +30,7 @@
/****************************************************************************
* Author: Thomas E. Dickey 1996-on *
****************************************************************************/
-/* $Id: test.priv.h,v 1.218 2024/02/10 14:40:03 tom Exp $ */
+/* $Id: test.priv.h,v 1.229 2025/12/06 21:21:06 tom Exp $ */
#ifndef __TEST_PRIV_H
#define __TEST_PRIV_H 1
@@ -183,6 +183,30 @@
#define HAVE_MATH_H 0
#endif
+#ifndef HAVE_MBLEN
+#define HAVE_MBLEN 0
+#endif
+
+#ifndef HAVE_MBRLEN
+#define HAVE_MBRLEN 0
+#endif
+
+#ifndef HAVE_MBRTOWC
+#define HAVE_MBRTOWC 0
+#endif
+
+#ifndef HAVE_MBSRTOWCS
+#define HAVE_MBSRTOWCS 0
+#endif
+
+#ifndef HAVE_MBSTOWCS
+#define HAVE_MBSTOWCS 0
+#endif
+
+#ifndef HAVE_MBTOWC
+#define HAVE_MBTOWC 0
+#endif
+
#ifndef HAVE_MENU_H
#define HAVE_MENU_H 0
#endif
@@ -275,6 +299,10 @@
#define HAVE_SYS_SELECT_H 0
#endif
+#ifndef HAVE_SYS_TIME_SELECT
+#define HAVE_SYS_TIME_SELECT 0
+#endif
+
#ifndef HAVE_TERMATTRS
#define HAVE_TERMATTRS 0
#endif
@@ -363,6 +391,18 @@
#define HAVE_VID_PUTS 0
#endif
+#ifndef HAVE_WCSRTOMBS
+#define HAVE_WCSRTOMBS 0
+#endif
+
+#ifndef HAVE_WCSTOMBS
+#define HAVE_WCSTOMBS 0
+#endif
+
+#ifndef HAVE_WCWIDTH
+#define HAVE_WCWIDTH 0
+#endif
+
#ifndef HAVE_WINSDELLN
#define HAVE_WINSDELLN 0
#endif
@@ -743,16 +783,28 @@ extern int optind;
#define HELP_KEY_2 KEY_F(1)
/* our "standard" options for getopt, needed for help2man */
+#define OPTS_COMMAND 'c'
+#define OPTS_LOGGING 'l'
#define OPTS_USAGE 'h'
#define OPTS_VERSION 'V'
-#define OPTS_COMMON "hV"
+#define OPTS_COMMON "c:l:hV"
#define USAGE_COMMON \
"Common options:"\
," -h show this message"\
," -V show version of curses"
+/* reserve -c/-l for command/logging */
+#define CASE_COMMON \
+ case OPTS_COMMAND: \
+ case OPTS_LOGGING: \
+ usage(ch == OPTS_USAGE); \
+ ExitProgram(EXIT_FAILURE); \
+ case OPTS_VERSION: \
+ show_version(argv); \
+ ExitProgram(EXIT_SUCCESS)
+
#if HAVE_CURSES_VERSION
-#define format_version(buffer, size) strcpy(buffer, curses_version())
+#define format_version(buffer, size) _nc_STRCPY(buffer, curses_version(), size)
#elif defined(NCURSES_VERSION_MAJOR) && defined(NCURSES_VERSION_MINOR) && defined(NCURSES_VERSION_PATCH)
#define format_version(buffer, size) \
_nc_SPRINTF(buffer, _nc_SLIMIT(size) "ncurses %d.%d.%d", \
@@ -760,13 +812,13 @@ extern int optind;
NCURSES_VERSION_MINOR, \
NCURSES_VERSION_PATCH)
#else
-#define format_version(buffer, size) strcpy(buffer, "ncurses-examples")
+#define format_version(buffer, size) _nc_STRCPY(buffer, "ncurses-examples", size)
#endif
#define VERSION_COMMON() \
static char *version_common(char **argv) { \
- char *base = argv[0]; \
- char *part = strrchr(base, '/'); \
+ const char *base = argv[0]; \
+ const char *part = strrchr(base, '/'); \
size_t need = strlen(base) + 80; \
char *result = malloc(need); \
if (result != NULL) { \
@@ -853,6 +905,12 @@ extern "C" {
#endif
/*
+ * To make them easier to find, user-defined capabilities used within ncurses
+ * should be tagged with this macro:
+ */
+#define UserCap(name) #name
+
+/*
* X/Open Curses does not define the arrays of terminfo/termcap names as SVr4
* curses did, and some implementations provide them anyway, but undeclared.
*/
@@ -916,8 +974,8 @@ extern int TABSIZE;
* Workaround in case getcchar() returns a positive value when the source
* string produces only a L'\0'.
*/
-#define TEST_CCHAR(s, count, then_stmt, else_stmt) \
- if ((count = getcchar(s, NULL, NULL, NULL, NULL)) > 0) { \
+#define TEST_CCHAR(s, then_stmt, else_stmt) \
+ if (getcchar(s, NULL, NULL, NULL, NULL) > 0) { \
wchar_t test_wch[CCHARW_MAX + 2]; \
attr_t test_attrs; \
NCURSES_PAIRS_T test_pair; \
@@ -1047,12 +1105,12 @@ extern int TABSIZE;
#define EXIT_FAILURE 1
#endif
-#undef _NC_WINDOWS
+#undef _NC_WINDOWS_NATIVE
#if (defined(_WIN32) || defined(_WIN64))
-#define _NC_WINDOWS 1
+#define _NC_WINDOWS_NATIVE 1
#endif
-#if defined(_NC_WINDOWS) || defined(USE_WIN32CON_DRIVER)
+#if defined(_NC_WINDOWS_NATIVE) || defined(USE_WIN32CON_DRIVER)
#if defined(PDCURSES)
#ifdef WINVER
@@ -1066,11 +1124,8 @@ extern int TABSIZE;
#include <sys/time.h> /* for struct timeval */
#undef sleep
#define sleep(n) Sleep((n) * 1000)
-#define SIGHUP 1
-#define SIGKILL 9
-#define getlogin() "username"
-#elif defined(EXP_WIN32_DRIVER)
+#else /* !PDCURSES */
#if defined(HAVE_NCURSESW_NCURSES_H)
#include <ncursesw/nc_win32.h>
@@ -1080,23 +1135,23 @@ extern int TABSIZE;
#include <nc_win32.h>
#endif
-#else
+#endif /* PDCURSES */
-#if defined(HAVE_NCURSESW_NCURSES_H)
-#include <ncursesw/nc_mingw.h>
-#elif defined(HAVE_NCURSES_NCURSES_H)
-#include <ncurses/nc_mingw.h>
-#else
-#include <nc_mingw.h>
+#define getlogin() "username"
+
+#ifndef SIGHUP
+#define SIGHUP 1
#endif
+#ifndef SIGKILL
+#define SIGKILL 9
#endif
/* conflicts in test/firstlast.c */
#undef large
#undef small
-#endif
+#endif /* WIN32... */
#ifdef NEED_TIME_H
#if TIME_WITH_SYS_TIME
@@ -1184,7 +1239,7 @@ extern char *_nc_strstr(const char *, const char *);
#define InitAndCatch(init,handler) do { init; CATCHALL(handler); } while (0)
#endif
-#if defined(_NC_WINDOWS) || defined(USE_WIN32CON_DRIVER)
+#if defined(_NC_WINDOWS_NATIVE) || defined(USE_WIN32CON_DRIVER)
#define SetupAlarm(opt) (void)opt
#else
#define SetupAlarm(opt) if (opt) alarm((unsigned)opt)