X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fcurses.priv.h;h=ade33c79f8ee2821b8899ab9cdc7d0bc3e110061;hp=fdc8c4a99a03c31f0cc86444d60cefd6393adefc;hb=44963481f15221316cbf9f7289a710f54cab2c84;hpb=2017ab0e60ca857accae38a01252e0cbdf5f1efe diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index fdc8c4a9..ade33c79 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -34,7 +34,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.597 2018/03/04 01:06:04 tom Exp $ + * $Id: curses.priv.h,v 1.607 2018/11/24 17:27:36 tom Exp $ * * curses.priv.h * @@ -71,7 +71,7 @@ extern "C" { #include #endif -#if HAVE_SYS_BSDTYPES_H +#if HAVE_SYS_BSDTYPES_H && !(defined(_WIN32) || defined(_WIN64)) #include /* needed for ISC */ #endif @@ -184,7 +184,7 @@ extern int errno; * the path separator in configure doesn't work properly. So, if building * for MinGW, we enforce the correct Windows PATH separator */ -#ifdef __MINGW32__ +#ifdef _WIN32 # ifdef NCURSES_PATHSEP # undef NCURSES_PATHSEP # endif @@ -916,6 +916,8 @@ typedef struct { int slk_format; + int getstr_limit; /* getstr_limit based on POSIX LINE_MAX */ + char *safeprint_buf; size_t safeprint_used; @@ -1003,6 +1005,15 @@ extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals; #define N_RIPS 5 +/* The limit reserves one byte for a terminating NUL */ +#define my_getstr_limit (_nc_globals.getstr_limit - 1) +#define _nc_getstr_limit(n) \ + (((n) < 0) \ + ? my_getstr_limit \ + : (((n) > my_getstr_limit) \ + ? my_getstr_limit \ + : (n))) + #ifdef USE_PTHREADS typedef struct _prescreen_list { struct _prescreen_list *next; @@ -1658,7 +1669,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; /* FreeAndNull() is not a comma-separated expression because some compilers * do not accept a mixture of void with values. */ -#define FreeAndNull(p) free(p); p = 0 +#define FreeAndNull(p) do { free(p); p = 0; } while (0) #include @@ -1667,14 +1678,18 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; * tries to limp along after a failure. */ #define TYPE_MALLOC(type, size, name) \ - name = typeMalloc(type, size); \ - if (name == 0) \ - _nc_err_abort(MSG_NO_MEMORY) + do { \ + name = typeMalloc(type, size); \ + if (name == 0) \ + _nc_err_abort(MSG_NO_MEMORY); \ + } while (0) #define TYPE_REALLOC(type, size, name) \ - name = typeRealloc(type, size, name); \ - if (name == 0) \ - _nc_err_abort(MSG_NO_MEMORY) + do { \ + name = typeRealloc(type, size, name); \ + if (name == 0) \ + _nc_err_abort(MSG_NO_MEMORY); \ + } while (0) /* * TTY bit definition for converting tabs to spaces. @@ -1747,7 +1762,8 @@ extern NCURSES_EXPORT(void) _nc_locked_tracef (const char *, ...) GCC_PRINTFLIKE typedef void VoidFunc(void); #define TR_FUNC(value) ((const char*) (value)) -#define NonNull(s) ((s) != 0 ? s : "") +#define NonNull(s) ((s) != 0 ? s : "") +#define NonEmpty(s) ((s) != 0 && *(s) != '\0') #define returnAttr(code) TRACE_RETURN(code,attr_t) #define returnBits(code) TRACE_RETURN(code,unsigned) @@ -2078,7 +2094,7 @@ extern NCURSES_EXPORT(bool) _nc_has_mouse (SCREEN *); extern NCURSES_EXPORT(char *) _nc_get_locale(void); extern NCURSES_EXPORT(int) _nc_unicode_locale(void); extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *); -extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int, int *, int); +extern NCURSES_EXPORT(int) _nc_setupterm(const char *, int, int *, int); extern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, int); #ifdef USE_PTHREADS @@ -2209,11 +2225,9 @@ extern NCURSES_EXPORT(const TERMTYPE2 *) _nc_fallback2 (const char *); #if NCURSES_EXT_NUMBERS extern NCURSES_EXPORT(void) _nc_copy_termtype2 (TERMTYPE2 *, const TERMTYPE2 *); extern NCURSES_EXPORT(void) _nc_export_termtype2(TERMTYPE *, const TERMTYPE2 *); -extern NCURSES_EXPORT(void) _nc_import_termtype2(TERMTYPE2 *, const TERMTYPE *); #else #define _nc_copy_termtype2(dst,src) _nc_copy_termtype((dst),(src)) #define _nc_export_termtype2(dst,src) /* nothing */ -#define _nc_import_termtype2(dst,src) /* nothing */ #define _nc_free_termtype2(t) _nc_free_termtype(t) /* also... */ #define _nc_read_entry2 _nc_read_entry @@ -2269,7 +2283,7 @@ extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *); */ #if USE_WIDEC_SUPPORT -#if defined(__MINGW32__) +#if defined(_WIN32) /* * MinGW has wide-character functions, but they do not work correctly. */ @@ -2284,7 +2298,7 @@ extern int __MINGW_NOTHROW _nc_mbtowc(wchar_t *, const char *, size_t); extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t); #define mblen(s,n) _nc_mblen(s, n) -#endif /* __MINGW32__ */ +#endif /* _WIN32 */ #if HAVE_MBTOWC && HAVE_MBLEN #define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0)) @@ -2511,7 +2525,7 @@ extern NCURSES_EXPORT(int) TINFO_MVCUR(SCREEN*, int, int, int, int); */ #ifdef USE_TERM_DRIVER extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, TERMINAL *, int *, int *); -extern NCURSES_EXPORT(int) _nc_setupterm_ex(TERMINAL **, NCURSES_CONST char *, int , int *, int); +extern NCURSES_EXPORT(int) _nc_setupterm_ex(TERMINAL **, const char *, int , int *, int); #define TINFO_GET_SIZE(sp, tp, lp, cp) \ _nc_get_screensize(sp, tp, lp, cp) #define TINFO_SET_CURTERM(sp, tp) \