]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/test.priv.h
ncurses 6.2 - patch 20210424
[ncurses.git] / test / test.priv.h
index f820a33d255d458e4934bf02c0f6654bf4ff7a7c..58f79e00125cb778df48eecf099b4f847c783bb1 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc.              *
+ * Copyright 2018-2020,2021 Thomas E. Dickey                                *
+ * Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,7 +30,7 @@
 /****************************************************************************
  *  Author: Thomas E. Dickey                    1996-on                     *
  ****************************************************************************/
-/* $Id: test.priv.h,v 1.177 2019/02/02 19:57:53 tom Exp $ */
+/* $Id: test.priv.h,v 1.197 2021/04/25 00:00:24 tom Exp $ */
 
 #ifndef __TEST_PRIV_H
 #define __TEST_PRIV_H 1
 #define HAVE_STDINT_H 0
 #endif
 
+#ifndef HAVE_STDNORETURN_H
+#define HAVE_STDNORETURN_H 0
+#endif
+
+#ifndef HAVE_STRSTR
+#define HAVE_STRSTR 0
+#endif
+
 #ifndef HAVE_SYS_IOCTL_H
 #define HAVE_SYS_IOCTL_H 0
 #endif
 #include <curses.h>
 #endif
 
+#if HAVE_STDNORETURN_H && !defined(NCURSES_VERSION)
+#include <stdnoreturn.h>
+#undef GCC_NORETURN
+#define GCC_NORETURN _Noreturn
+#endif
+
+#if !(defined(NCURSES_WGETCH_EVENTS) && defined(NEED_KEY_EVENT))
+#undef KEY_EVENT               /* reduce compiler-warnings with Visual C++ */
+#endif
+
 #if defined(HAVE_XCURSES) || defined(PDCURSES)
 /* no other headers */
 #undef  HAVE_SETUPTERM         /* nonfunctional */
@@ -432,6 +451,13 @@ extern int optind;
 #include <assert.h>
 #include <ctype.h>
 
+#if defined(_MSC_VER)
+#undef popen
+#define popen(s,n) _popen(s,n)
+#undef pclose
+#define pclose(s) _pclose(s)
+#endif
+
 #ifndef GCC_NORETURN
 #define GCC_NORETURN           /* nothing */
 #endif
@@ -469,6 +495,18 @@ extern int optind;
 #define slk_clear()            /* nothing */
 #endif
 
+#ifndef HAVE_CURSES_DATA_TABSIZE
+#define HAVE_CURSES_DATA_TABSIZE 0
+#endif
+
+#if !NCURSES_EXT_FUNCS
+#if HAVE_CURSES_DATA_TABSIZE
+#define set_tabsize(n) TABSIZE = (n)
+#else
+#define set_tabsize(n)         /* nothing */
+#endif
+#endif
+
 #if HAVE_TPUTS_SP
 #define USE_SP_FUNCS 1
 #else
@@ -710,19 +748,44 @@ extern "C" {
 #endif
 
 #if USE_STRING_HACKS && HAVE_SNPRINTF
-#define _nc_SPRINTF             NCURSES_VOID snprintf
+#define _nc_SPRINTF             NCURSES_VOID (snprintf)
 #define _nc_SLIMIT(n)           NCURSES_CAST(size_t,n),
 #else
-#define _nc_SPRINTF             NCURSES_VOID sprintf
+#define _nc_SPRINTF             NCURSES_VOID (sprintf)
 #define _nc_SLIMIT(n)          /* nothing */
 #endif
 
+/*
+ * X/Open Curses does not define the arrays of terminfo/termcap names as SVr4
+ * curses did, and some implementations provide them anyway, but undeclared.
+ */
 #ifdef DECL_CURSES_DATA_BOOLNAMES
 extern char *boolnames[], *boolcodes[], *boolfnames[];
 extern char *numnames[], *numcodes[], *numfnames[];
 extern char *strnames[], *strcodes[], *strfnames[];
 #endif
 
+/*
+ * Again, an SVr4 curses feature latent in the libraries but not in headers.
+ */
+#ifndef DECL_CURSES_DATA_TABSIZE
+#define DECL_CURSES_DATA_TABSIZE 0
+#endif
+
+#if DECL_CURSES_DATA_TABSIZE
+extern int TABSIZE;
+#undef  HAVE_CURSES_DATA_TABSIZE
+#define HAVE_CURSES_DATA_TABSIZE 1
+#endif
+
+#ifndef HAVE_CURSES_DATA_TABSIZE
+#define HAVE_CURSES_DATA_TABSIZE 0
+#endif
+
+/*
+ * X/Open Curses provides termname(), whose return value is analogous to the
+ * SVr4 curses variable ttytype[].
+ */
 #ifndef HAVE_CURSES_DATA_TTYTYPE
 #define HAVE_CURSES_DATA_TTYTYPE 0
 #endif
@@ -844,9 +907,9 @@ extern char *strnames[], *strcodes[], *strfnames[];
  * ncurses restores the cursor in endwin().  Other libraries may not.
  */
 #ifdef NCURSES_VERSION
-#define exit_curses() endwin()
+#define stop_curses() endwin()
 #else
-#define exit_curses() do { endwin(); curs_set(1); } while (0)
+#define stop_curses() do { endwin(); curs_set(1); } while (0)
 #endif
 
 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
@@ -861,11 +924,14 @@ extern char *strnames[], *strcodes[], *strfnames[];
 
 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
 #include <nc_alloc.h>
-#if HAVE_NC_FREEALL && defined(USE_TINFO)
+#if HAVE_EXIT_TERMINFO && (defined(USE_TERMINFO) || defined(USE_TINFO))
+#undef ExitProgram
+#define ExitProgram(code) exit_terminfo(code)
+#elif HAVE_EXIT_CURSES
 #undef ExitProgram
-#define ExitProgram(code) _nc_free_tinfo(code)
+#define ExitProgram(code) exit_curses(code)
 #endif
-#else
+#else /* not ncurses-tree */
 #define typeMalloc(type,n) (type *) malloc((size_t)(n) * sizeof(type))
 #define typeCalloc(type,elts) (type *) calloc((size_t)(elts), sizeof(type))
 #define typeRealloc(type,n,p) (type *) realloc(p, (size_t)(n) * sizeof(type))
@@ -882,7 +948,12 @@ extern char *strnames[], *strcodes[], *strfnames[];
 #define EXIT_FAILURE 1
 #endif
 
-#if defined(_WIN32) || defined(USE_WIN32CON_DRIVER)
+#undef _NC_WINDOWS
+#if (defined(_WIN32) || defined(_WIN64))
+#define _NC_WINDOWS 1
+#endif
+
+#if defined(_NC_WINDOWS) || defined(USE_WIN32CON_DRIVER)
 
 #if defined(PDCURSES)
 #ifdef WINVER
@@ -900,7 +971,19 @@ extern char *strnames[], *strcodes[], *strfnames[];
 #define SIGKILL 9
 #define getlogin() "username"
 
-#elif defined(HAVE_NCURSESW_NCURSES_H)
+#elif defined(EXP_WIN32_DRIVER)
+
+#if defined(HAVE_NCURSESW_NCURSES_H)
+#include <ncursesw/nc_win32.h>
+#elif defined(HAVE_NCURSES_NCURSES_H)
+#include <ncurses/nc_win32.h>
+#else
+#include <nc_win32.h>
+#endif
+
+#else
+
+#if defined(HAVE_NCURSESW_NCURSES_H)
 #include <ncursesw/nc_mingw.h>
 #elif defined(HAVE_NCURSES_NCURSES_H)
 #include <ncurses/nc_mingw.h>
@@ -908,6 +991,8 @@ extern char *strnames[], *strcodes[], *strfnames[];
 #include <nc_mingw.h>
 #endif
 
+#endif
+
 /* conflicts in test/firstlast.c */
 #undef large
 #undef small
@@ -927,6 +1012,18 @@ extern char *strnames[], *strcodes[], *strfnames[];
 #endif
 #endif
 
+/*
+ * Ultrix 3.1
+ */
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+#if !HAVE_STRSTR
+extern char *_nc_strstr(const char *, const char *);
+#define strstr(a,b) _nc_strstr((a),(b))
+#endif /* !HAVE_STRSTR */
+
 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
  * curses which doesn't have const parameters declared (so far) in the places
  * that XSI shows.
@@ -968,6 +1065,12 @@ extern char *strnames[], *strcodes[], *strfnames[];
 #define InitAndCatch(init,handler) do { init; CATCHALL(handler); } while (0)
 #endif
 
+#if defined(_NC_WINDOWS) || defined(USE_WIN32CON_DRIVER)
+#define SetupAlarm(opt)        (void)opt
+#else
+#define SetupAlarm(opt)        if (opt) alarm((unsigned)opt)
+#endif
+
 /*
  * Workaround for clean(er) compile with Solaris's legacy curses.
  * The same would be needed for HPUX 10.20
@@ -1076,7 +1179,7 @@ extern char *tgoto(char *, int, int);     /* available, but not prototyped */
        if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
            int t = _nc_getenv_num("NCURSES_TRACE"); \
            if (t >= 0) \
-               trace((unsigned) t); \
+               curses_trace((unsigned) t); \
        }
 extern unsigned _nc_tracing;
 extern int _nc_getenv_num(const char *);