aboutsummaryrefslogtreecommitdiff
path: root/ncurses/base
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2026-01-14 12:37:49 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2026-01-14 12:37:49 +0000
commitc5a1e08b52b2f6c05e0116d46277904b711b6bdb (patch)
treea6ad7350d1b1100356ca59616d22c51dd29743eb /ncurses/base
parent24fa7a5107c5b75d1c197accf0305be64bc72882 (diff)
Vendor import ncurses 6.6vendor/ncurses/6.6vendor/ncurses
Diffstat (limited to 'ncurses/base')
-rw-r--r--ncurses/base/MKkeyname.awk30
-rwxr-xr-xncurses/base/MKlib_gen.sh77
-rw-r--r--ncurses/base/MKunctrl.awk10
-rw-r--r--ncurses/base/define_key.c12
-rw-r--r--ncurses/base/key_defined.c10
-rw-r--r--ncurses/base/keybound.c8
-rw-r--r--ncurses/base/keyok.c10
-rw-r--r--ncurses/base/legacy_coding.c6
-rw-r--r--ncurses/base/lib_addch.c12
-rw-r--r--ncurses/base/lib_addstr.c14
-rw-r--r--ncurses/base/lib_beep.c10
-rw-r--r--ncurses/base/lib_bkgd.c6
-rw-r--r--ncurses/base/lib_chgat.c7
-rw-r--r--ncurses/base/lib_color.c84
-rw-r--r--ncurses/base/lib_colorset.c6
-rw-r--r--ncurses/base/lib_delch.c8
-rw-r--r--ncurses/base/lib_delwin.c29
-rw-r--r--ncurses/base/lib_dft_fgbg.c12
-rw-r--r--ncurses/base/lib_driver.c50
-rw-r--r--ncurses/base/lib_echo.c8
-rw-r--r--ncurses/base/lib_endwin.c6
-rw-r--r--ncurses/base/lib_erase.c6
-rw-r--r--ncurses/base/lib_flash.c8
-rw-r--r--ncurses/base/lib_freeall.c18
-rw-r--r--ncurses/base/lib_getch.c51
-rw-r--r--ncurses/base/lib_getstr.c12
-rw-r--r--ncurses/base/lib_initscr.c12
-rw-r--r--ncurses/base/lib_insch.c10
-rw-r--r--ncurses/base/lib_insnstr.c8
-rw-r--r--ncurses/base/lib_instr.c16
-rw-r--r--ncurses/base/lib_mouse.c170
-rw-r--r--ncurses/base/lib_mvwin.c6
-rw-r--r--ncurses/base/lib_newterm.c47
-rw-r--r--ncurses/base/lib_newwin.c80
-rw-r--r--ncurses/base/lib_nl.c12
-rw-r--r--ncurses/base/lib_overlay.c10
-rw-r--r--ncurses/base/lib_pad.c22
-rw-r--r--ncurses/base/lib_printw.c12
-rw-r--r--ncurses/base/lib_redrawln.c6
-rw-r--r--ncurses/base/lib_refresh.c8
-rw-r--r--ncurses/base/lib_restart.c12
-rw-r--r--ncurses/base/lib_screen.c104
-rw-r--r--ncurses/base/lib_set_term.c128
-rw-r--r--ncurses/base/lib_slk.c22
-rw-r--r--ncurses/base/lib_slkatr_set.c8
-rw-r--r--ncurses/base/lib_slkatrof.c6
-rw-r--r--ncurses/base/lib_slkatron.c6
-rw-r--r--ncurses/base/lib_slkatrset.c6
-rw-r--r--ncurses/base/lib_slkattr.c6
-rw-r--r--ncurses/base/lib_slkclear.c6
-rw-r--r--ncurses/base/lib_slkcolor.c8
-rw-r--r--ncurses/base/lib_slklab.c8
-rw-r--r--ncurses/base/lib_slkrefr.c18
-rw-r--r--ncurses/base/lib_slkset.c16
-rw-r--r--ncurses/base/lib_slktouch.c6
-rw-r--r--ncurses/base/lib_touch.c12
-rw-r--r--ncurses/base/lib_ungetch.c6
-rw-r--r--ncurses/base/lib_wattron.c6
-rw-r--r--ncurses/base/lib_winch.c6
-rw-r--r--ncurses/base/lib_window.c14
-rw-r--r--ncurses/base/nc_panel.c6
-rw-r--r--ncurses/base/new_pair.c22
-rw-r--r--ncurses/base/resizeterm.c47
-rw-r--r--ncurses/base/safe_sprintf.c19
-rw-r--r--ncurses/base/tries.c20
-rw-r--r--ncurses/base/vsscanf.c8
-rw-r--r--ncurses/base/wresize.c22
67 files changed, 745 insertions, 732 deletions
diff --git a/ncurses/base/MKkeyname.awk b/ncurses/base/MKkeyname.awk
index b3d04ee77f53..545661f7e4c2 100644
--- a/ncurses/base/MKkeyname.awk
+++ b/ncurses/base/MKkeyname.awk
@@ -1,6 +1,6 @@
-# $Id: MKkeyname.awk,v 1.51 2020/02/02 23:34:34 tom Exp $
+# $Id: MKkeyname.awk,v 1.53 2024/12/07 21:09:39 tom Exp $
##############################################################################
-# Copyright 2020 Thomas E. Dickey #
+# Copyright 2020,2024 Thomas E. Dickey #
# Copyright 1998-2016,2017 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -59,7 +59,7 @@ END {
if (bigstrings) {
printf "\t{ -1, 0 }};\n"
print ""
- print "static const char key_names[] = "names";"
+ print "static const char key_names[] ="names";"
} else {
printf "\t{ 0, 0 }};\n"
}
@@ -72,7 +72,7 @@ END {
print "safe_keyname (SCREEN *sp, int c)"
print "{"
print " char name[20];"
- print " NCURSES_CONST char *result = 0;"
+ print " NCURSES_CONST char *result = NULL;"
print ""
print " if (c == -1) {"
print " result = \"-1\";"
@@ -86,7 +86,7 @@ END {
print " }"
print " }"
} else {
- print " for (i = 0; _nc_key_names[i].name != 0; i++) {"
+ print " for (i = 0; _nc_key_names[i].name != NULL; i++) {"
print " if (_nc_key_names[i].code == c) {"
print " result = (NCURSES_CONST char *)_nc_key_names[i].name;"
print " break;"
@@ -94,12 +94,12 @@ END {
print " }"
}
print ""
- print " if (result == 0 && (c >= 0 && c < SIZEOF_TABLE)) {"
- print " if (MyTable == 0)"
+ print " if (result == NULL && (c >= 0 && c < SIZEOF_TABLE)) {"
+ print " if (MyTable == NULL)"
print " MyTable = typeCalloc(char *, SIZEOF_TABLE);"
print ""
- print " if (MyTable != 0) {"
- print " int m_prefix = (sp == 0 || sp->_use_meta);"
+ print " if (MyTable != NULL) {"
+ print " int m_prefix = (sp == NULL || sp->_use_meta);"
print ""
print " /* if sense of meta() changed, discard cached data */"
print " if (MyInit != (m_prefix + 1)) {"
@@ -112,7 +112,7 @@ END {
print " }"
print ""
print " /* create and cache result as needed */"
- print " if (MyTable[c] == 0) {"
+ print " if (MyTable[c] == NULL) {"
print " int cc = c;"
print " char *p = name;"
print "#define P_LIMIT (sizeof(name) - (size_t) (p - name))"
@@ -132,22 +132,22 @@ END {
print " result = MyTable[c];"
print " }"
print "#if NCURSES_EXT_FUNCS && NCURSES_XNAMES"
- print " } else if (result == 0 && HasTerminal(sp)) {"
+ print " } else if (result == NULL && HasTerminal(sp)) {"
print " int j, k;"
print " char * bound;"
print " TERMTYPE2 *tp = &TerminalType(TerminalOf(sp));"
print " unsigned save_trace = _nc_tracing;"
print ""
print " _nc_tracing = 0; /* prevent recursion via keybound() */"
- print " for (j = 0; (bound = NCURSES_SP_NAME(keybound)(NCURSES_SP_ARGx c, j)) != 0; ++j) {"
+ print " for (j = 0; (bound = NCURSES_SP_NAME(keybound)(NCURSES_SP_ARGx c, j)) != NULL; ++j) {"
print " for(k = STRCOUNT; k < (int) NUM_STRINGS(tp); k++) {"
- print " if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) {"
+ print " if (tp->Strings[k] != NULL && !strcmp(bound, tp->Strings[k])) {"
print " result = ExtStrname(tp, k, strnames);"
print " break;"
print " }"
print " }"
print " free(bound);"
- print " if (result != 0)"
+ print " if (result != NULL)"
print " break;"
print " }"
print " _nc_tracing = save_trace;"
@@ -166,7 +166,7 @@ END {
print "#if NO_LEAKS"
print "void _nc_keyname_leaks(void)"
print "{"
- print " if (MyTable != 0) {"
+ print " if (MyTable != NULL) {"
print " int j;"
print " for (j = 0; j < SIZEOF_TABLE; ++j) {"
print " FreeIfNeeded(MyTable[j]);"
diff --git a/ncurses/base/MKlib_gen.sh b/ncurses/base/MKlib_gen.sh
index f0ac0452e8ef..fbaf3f2d68fc 100755
--- a/ncurses/base/MKlib_gen.sh
+++ b/ncurses/base/MKlib_gen.sh
@@ -2,10 +2,10 @@
#
# MKlib_gen.sh -- generate sources from curses.h macro definitions
#
-# ($Id: MKlib_gen.sh,v 1.73 2022/10/01 13:14:20 tom Exp $)
+# ($Id: MKlib_gen.sh,v 1.79 2025/02/23 01:55:06 tom Exp $)
#
##############################################################################
-# Copyright 2018-2021,2022 Thomas E. Dickey #
+# Copyright 2018-2024,2025 Thomas E. Dickey #
# Copyright 1998-2016,2017 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -188,6 +188,10 @@ if test "$USE" = generated ; then
cat >$ED4 <<EOF
s/^\(.*\) \(.*\) (\(.*\))\$/NCURSES_EXPORT(\1) \2 (\3)/
/attr_[sg]et.* z)/s,z),z GCC_UNUSED),
+ s/\(((\)0[L]*\([ ]*!=[ ]*(const void\)/\1NULL\2/g
+ /returnCode(wborder_set/s,0[L]*,NULL,g
+ /returnWin/s,0[L]*,NULL,
+ /_parent/s,0[L]*,NULL,
EOF
else
cat >$ED4 <<EOF
@@ -199,6 +203,8 @@ cat >$ED4 <<EOF
s/^\(.*\) \(.*\) (\(.*\))\$/\1 call_\2 (\3)/
}
s/\([^_]\)NCURSES_SP_NAME___\([a-zA-Z][a-zA-Z_]*\)/\1NCURSES_SP_NAME(\2)/g
+/call_NCURSES_SP_NAME/s,(0,(NULL,
+/call\(_NCURSES_SP_NAME\)\?_*\(delscreen\|ripoffline\|set_term\|vidputs\|vid_puts\)/s,0),NULL),
EOF
fi
@@ -440,6 +446,10 @@ BEGIN {
print "#define NCURSES_ATTR_T int"
print "#include <ncurses_cfg.h>"
print ""
+ print "#if USE_STDBOOL_H"
+ print "#include <stdbool.h>"
+ print "#endif"
+ print ""
print "#undef NCURSES_NOMACROS /* _this_ file uses macros */"
print "#define NCURSES_NOMACROS 1"
print ""
@@ -464,8 +474,11 @@ BEGIN {
}
END {
if ( "$USE" != "generated" ) {
- print "int main(void)"
- print "{"
+ print "static int link_test(int code)"
+ print "{"
+ print " switch(code)"
+ print " {"
+ casenum = 1;
for (n = 1; n < start; ++n) {
value = calls[n];
if ( value !~ /P_POUNDC/ ) {
@@ -473,20 +486,37 @@ END {
sub(/^[0-9a-zA-Z_]+ /,"",value);
sub(/^[*][ \t]*/,"",value);
gsub("struct[ \t]*[0-9a-zA-Z_]+[ \t]*[*]","",value);
+ arg_l = index(value, "(");
+ arg_r = index(value, ")");
+ if ( arg_l > 0 && arg_r > arg_l + 1 ) {
+ args = substr(value, arg_l + 1, arg_r - arg_l - 1);
+ gsub(/[0-9a-zA-Z_]+[ \t]*[*][ \t]*[0-9a-zA-Z_]+/,"NULL",args);
+ gsub(/ (bool|int|short|attr_t|chtype|wchar_t|NCURSES_BOOL|NCURSES_OUTC|NCURSES_OUTC_sp|va_list) /," ",args);
+ value = substr(value,0,arg_l) args substr(value,arg_r);
+ }
gsub(/[0-9a-zA-Z_]+[ \t]*[*][ \t]*/,"",value);
gsub(/ (const) /," ",value);
- gsub(/ (int|short|attr_t|chtype|wchar_t|NCURSES_BOOL|NCURSES_OUTC|NCURSES_OUTC_sp|va_list) /," ",value);
+ gsub(/ (bool|int|short|attr_t|chtype|wchar_t|NCURSES_BOOL|NCURSES_OUTC|NCURSES_OUTC_sp|va_list) /," ",value);
gsub(/ void /,"",value);
sub(/^/,"call_",value);
gsub(/ (a[0-9]|z) /, " 0 ", value);
gsub(/ int[ \t]*[(][^)]+[)][(][^)]+[)]/, "0", value);
- printf "\t%s;\n", value;
+ if ( index(value, "call_NCURSES_SP_NAME") > 0 ) {
+ sub("0","NULL", value);
+ }
+ printf " case %d: %s; break;\n", casenum++, value;
} else {
+ if ( index(value, "call_NCURSES_SP_NAME") > 0 ) {
+ printf "/* FIXME %s */\n", value;
+ sub("0","NULL", value);
+ }
print value;
}
}
- print " return 0;"
- print "}"
+ print " default: return 0; /* case did not exist */"
+ print " }"
+ print " return 1; /* case exists */"
+ print "}"
}
}
EOF1
@@ -527,3 +557,34 @@ $preprocessor $TMP 2>/dev/null \
-e '/#ident/d' \
-e '/#line/d' \
| sed -f $ED4
+
+# a simple test-driver checks one or all of the linkages
+if test "$USE" = "implemented"
+then
+cat <<"EOF"
+int main(int argc, char *argv[])
+{
+ int n;
+ int rc;
+ if (argc > 1)
+ {
+ rc = !link_test(atoi(argv[1]));
+ }
+ else
+ {
+ rc = 0;
+ for (n = 1; ; ++n)
+ {
+ printf("TEST %d\n", n);
+ fflush(stdout);
+ if (!link_test(n))
+ {
+ rc = 1;
+ break;
+ }
+ }
+ }
+ return rc;
+}
+EOF
+fi
diff --git a/ncurses/base/MKunctrl.awk b/ncurses/base/MKunctrl.awk
index e5362bd60d15..c8f669661cee 100644
--- a/ncurses/base/MKunctrl.awk
+++ b/ncurses/base/MKunctrl.awk
@@ -1,4 +1,4 @@
-# $Id: MKunctrl.awk,v 1.30 2024/02/03 21:09:14 tom Exp $
+# $Id: MKunctrl.awk,v 1.31 2024/12/07 21:06:39 tom Exp $
##############################################################################
# Copyright 2020,2024 Thomas E. Dickey #
# Copyright 1998-2012,2017 Free Software Foundation, Inc. #
@@ -135,7 +135,7 @@ END {
print ""
if (bigstrings) {
- print "static const char unctrl_blob[] = "blob";"
+ print "static const char unctrl_blob[] ="blob";"
print ""
stringname = "unctrl_blob + unctrl"
} else {
@@ -147,7 +147,7 @@ END {
print "\t(void) sp;"
print "\tif (check >= 0 && check < (int)SIZEOF(unctrl_table)) {"
print "#if NCURSES_EXT_FUNCS"
- print "\t\tif ((sp != 0)"
+ print "\t\tif ((sp != NULL)"
print "\t\t && (sp->_legacy_coding > 1)"
print "\t\t && (check >= 128)"
print "\t\t && (check < 160))"
@@ -156,7 +156,7 @@ END {
print "\t\tif ((check >= 160)"
print "\t\t && (check < 256)"
print "\t\t && !_nc_unicode_locale()"
- print "\t\t && ((sp != 0)"
+ print "\t\t && ((sp != NULL)"
print "\t\t && ((sp->_legacy_coding > 0)"
print "\t\t || (sp->_legacy_coding == 0"
print "\t\t && isprint(check)))))"
@@ -165,7 +165,7 @@ END {
print "#endif /* NCURSES_EXT_FUNCS */"
printf "\t\t\tresult = %s_table[check];\n", stringname;
print "\t} else {"
- print "\t\tresult = 0;"
+ print "\t\tresult = NULL;"
print "\t}"
print "\treturn (NCURSES_CONST char *)result;"
print "}"
diff --git a/ncurses/base/define_key.c b/ncurses/base/define_key.c
index fb9ae36be877..1b7db4cba5b3 100644
--- a/ncurses/base/define_key.c
+++ b/ncurses/base/define_key.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2009,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,7 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: define_key.c,v 1.22 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: define_key.c,v 1.24 2025/12/27 12:41:23 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(define_key) (NCURSES_SP_DCLx const char *str, int keycode)
@@ -42,24 +42,24 @@ NCURSES_SP_NAME(define_key) (NCURSES_SP_DCLx const char *str, int keycode)
int code = ERR;
T((T_CALLED("define_key(%p, %s,%d)"), (void *) SP_PARM, _nc_visbuf(str), keycode));
- if (SP_PARM == 0 || !HasTInfoTerminal(SP_PARM)) {
+ if (SP_PARM == NULL || !HasTInfoTerminal(SP_PARM)) {
code = ERR;
} else if (keycode > 0) {
unsigned ukey = (unsigned) keycode;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
#define CallHasKey(keycode) CallDriver_1(SP_PARM, td_kyExist, keycode)
#else
#define CallHasKey(keycode) NCURSES_SP_NAME(has_key)(NCURSES_SP_ARGx keycode)
#endif
- if (str != 0) {
+ if (str != NULL) {
NCURSES_SP_NAME(define_key) (NCURSES_SP_ARGx str, 0);
} else if (CallHasKey(keycode)) {
while (_nc_remove_key(&(SP_PARM->_keytry), ukey))
code = OK;
}
- if (str != 0) {
+ if (str != NULL) {
if (NCURSES_SP_NAME(key_defined) (NCURSES_SP_ARGx str) == 0) {
if (_nc_add_to_try(&(SP_PARM->_keytry), str, ukey) == OK) {
code = OK;
diff --git a/ncurses/base/key_defined.c b/ncurses/base/key_defined.c
index 147e5fe2db93..28939edeb48d 100644
--- a/ncurses/base/key_defined.c
+++ b/ncurses/base/key_defined.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 2003-2006,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,7 +34,7 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: key_defined.c,v 1.11 2023/06/24 15:36:32 tom Exp $")
+MODULE_ID("$Id: key_defined.c,v 1.12 2024/12/07 21:24:18 tom Exp $")
static int
find_definition(TRIES * tree, const char *str)
@@ -43,9 +43,9 @@ find_definition(TRIES * tree, const char *str)
int result = OK;
if (VALID_STRING(str) && *str != '\0') {
- for (ptr = tree; ptr != 0; ptr = ptr->sibling) {
+ for (ptr = tree; ptr != NULL; ptr = ptr->sibling) {
if (UChar(*str) == UChar(ptr->ch)) {
- if (str[1] == '\0' && ptr->child != 0) {
+ if (str[1] == '\0' && ptr->child != NULL) {
result = ERR;
} else if ((result = find_definition(ptr->child, str + 1))
== OK) {
@@ -72,7 +72,7 @@ NCURSES_SP_NAME(key_defined) (NCURSES_SP_DCLx const char *str)
int code = ERR;
T((T_CALLED("key_defined(%p, %s)"), (void *) SP_PARM, _nc_visbuf(str)));
- if (SP_PARM != 0 && str != 0) {
+ if (SP_PARM != NULL && str != NULL) {
code = find_definition(SP_PARM->_keytry, str);
}
diff --git a/ncurses/base/keybound.c b/ncurses/base/keybound.c
index bbd912a0d858..9dc404670eda 100644
--- a/ncurses/base/keybound.c
+++ b/ncurses/base/keybound.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1999-2009,2011 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,7 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: keybound.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: keybound.c,v 1.13 2024/12/07 21:24:18 tom Exp $")
/*
* Returns the count'th string definition which is associated with the
@@ -43,10 +43,10 @@ MODULE_ID("$Id: keybound.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
NCURSES_EXPORT(char *)
NCURSES_SP_NAME(keybound) (NCURSES_SP_DCLx int code, int count)
{
- char *result = 0;
+ char *result = NULL;
T((T_CALLED("keybound(%p, %d,%d)"), (void *) SP_PARM, code, count));
- if (SP_PARM != 0 && code >= 0) {
+ if (SP_PARM != NULL && code >= 0) {
result = _nc_expand_try(SP_PARM->_keytry,
(unsigned) code,
&count,
diff --git a/ncurses/base/keyok.c b/ncurses/base/keyok.c
index 945228aa8035..564b3f10a606 100644
--- a/ncurses/base/keyok.c
+++ b/ncurses/base/keyok.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2020,2021 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,7 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: keyok.c,v 1.17 2021/06/17 21:26:02 tom Exp $")
+MODULE_ID("$Id: keyok.c,v 1.19 2025/12/27 12:41:23 tom Exp $")
/*
* Enable (or disable) ncurses' interpretation of a keycode by adding (or
@@ -53,7 +53,7 @@ NCURSES_SP_NAME(keyok) (NCURSES_SP_DCLx int c, bool flag)
if (HasTerminal(SP_PARM)) {
T((T_CALLED("keyok(%p, %d,%d)"), (void *) SP_PARM, c, flag));
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
code = CallDriver_2(sp, td_kyOk, c, flag);
#else
if (c >= 0) {
@@ -63,7 +63,7 @@ NCURSES_SP_NAME(keyok) (NCURSES_SP_DCLx int c, bool flag)
if (flag) {
while ((s = _nc_expand_try(SP_PARM->_key_ok,
- ch, &count, (size_t) 0)) != 0) {
+ ch, &count, (size_t) 0)) != NULL) {
if (_nc_remove_key(&(SP_PARM->_key_ok), ch)) {
code = _nc_add_to_try(&(SP_PARM->_keytry), s, ch);
free(s);
@@ -76,7 +76,7 @@ NCURSES_SP_NAME(keyok) (NCURSES_SP_DCLx int c, bool flag)
}
} else {
while ((s = _nc_expand_try(SP_PARM->_keytry,
- ch, &count, (size_t) 0)) != 0) {
+ ch, &count, (size_t) 0)) != NULL) {
if (_nc_remove_key(&(SP_PARM->_keytry), ch)) {
code = _nc_add_to_try(&(SP_PARM->_key_ok), s, ch);
free(s);
diff --git a/ncurses/base/legacy_coding.c b/ncurses/base/legacy_coding.c
index a71aee014e7e..3da1414d8512 100644
--- a/ncurses/base/legacy_coding.c
+++ b/ncurses/base/legacy_coding.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2005,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,7 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: legacy_coding.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: legacy_coding.c,v 1.7 2024/12/07 20:00:48 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(use_legacy_coding) (NCURSES_SP_DCLx int level)
@@ -42,7 +42,7 @@ NCURSES_SP_NAME(use_legacy_coding) (NCURSES_SP_DCLx int level)
int result = ERR;
T((T_CALLED("use_legacy_coding(%p,%d)"), (void *) SP_PARM, level));
- if (level >= 0 && level <= 2 && SP_PARM != 0) {
+ if (level >= 0 && level <= 2 && SP_PARM != NULL) {
result = SP_PARM->_legacy_coding;
SP_PARM->_legacy_coding = level;
}
diff --git a/ncurses/base/lib_addch.c b/ncurses/base/lib_addch.c
index a14bfd3b0e05..634714a623fb 100644
--- a/ncurses/base/lib_addch.c
+++ b/ncurses/base/lib_addch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2021,2022 Thomas E. Dickey *
+ * Copyright 2019-2022,2024 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -37,7 +37,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_addch.c,v 1.141 2022/06/12 15:16:41 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.144 2024/12/07 17:18:07 tom Exp $")
static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
@@ -118,7 +118,7 @@ _nc_render(WINDOW *win, NCURSES_CH_T ch)
#endif
static bool
-newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T *ypos)
+newline_forces_scroll(const WINDOW *win, NCURSES_SIZE_T *ypos)
{
bool result = FALSE;
@@ -451,14 +451,14 @@ waddch_nosync(WINDOW *win, const NCURSES_CH_T ch)
if ((AttrOf(ch) & A_ALTCHARSET)
|| (
#if USE_WIDEC_SUPPORT
- (sp != 0 && sp->_legacy_coding) &&
+ (sp != NULL && sp->_legacy_coding) &&
#endif
s[1] == 0
)
|| (
- (isprint((int) t) && !iscntrl((int) t))
+ (isprint(UChar(t)) && !iscntrl(UChar(t)))
#if USE_WIDEC_SUPPORT
- || ((sp == 0 || !sp->_legacy_coding) &&
+ || ((sp == NULL || !sp->_legacy_coding) &&
(WINDOW_EXT(win, addch_used)
|| !_nc_is_charable(CharOf(ch))))
#endif
diff --git a/ncurses/base/lib_addstr.c b/ncurses/base/lib_addstr.c
index a3753af0d53e..5bea4187f199 100644
--- a/ncurses/base/lib_addstr.c
+++ b/ncurses/base/lib_addstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2022,2023 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -45,7 +45,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_addstr.c,v 1.62 2023/11/21 21:47:23 tom Exp $")
+MODULE_ID("$Id: lib_addstr.c,v 1.65 2025/02/20 08:53:36 tom Exp $")
NCURSES_EXPORT(int)
waddnstr(WINDOW *win, const char *astr, int n)
@@ -55,8 +55,8 @@ waddnstr(WINDOW *win, const char *astr, int n)
T((T_CALLED("waddnstr(%p,%s,%d)"), (void *) win, _nc_visbufn(astr, n), n));
- if (win && (str != 0) && (n != 0)) {
- bool explicit = (n > 0);
+ if (win != NULL && str != NULL) {
+ bool explicit = (n >= 0);
TR(TRACE_VIRTPUT | TRACE_ATTRS,
("... current %s", _traceattr(WINDOW_ATTRS(win))));
@@ -123,7 +123,7 @@ NCURSES_EXPORT(int)
_nc_wchstrlen(const cchar_t *s)
{
int result = 0;
- if (s != 0) {
+ if (s != NULL) {
while (CharOf(s[result]) != L'\0') {
result++;
}
@@ -230,8 +230,8 @@ waddnwstr(WINDOW *win, const wchar_t *str, int n)
T((T_CALLED("waddnwstr(%p,%s,%d)"), (void *) win, _nc_viswbufn(str, n), n));
- if (win && (str != 0) && (n != 0)) {
- bool explicit = (n > 0);
+ if (win != NULL && str != NULL) {
+ bool explicit = (n >= 0);
TR(TRACE_VIRTPUT | TRACE_ATTRS,
("... current %s", _traceattr(WINDOW_ATTRS(win))));
diff --git a/ncurses/base/lib_beep.c b/ncurses/base/lib_beep.c
index b1a60b923ef6..5708c33e9698 100644
--- a/ncurses/base/lib_beep.c
+++ b/ncurses/base/lib_beep.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2013,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -47,7 +47,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_beep.c,v 1.18 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_beep.c,v 1.21 2025/12/27 12:41:23 tom Exp $")
/*
* beep()
@@ -64,12 +64,12 @@ NCURSES_SP_NAME(beep) (NCURSES_SP_DCL0)
T((T_CALLED("beep(%p)"), (void *) SP_PARM));
-#ifdef USE_TERM_DRIVER
- if (SP_PARM != 0)
+#if USE_TERM_DRIVER
+ if (SP_PARM != NULL)
res = CallDriver_1(SP_PARM, td_doBeepOrFlash, TRUE);
#else
/* FIXME: should make sure that we are not in altchar mode */
- if (cur_term == 0) {
+ if (cur_term == NULL) {
res = ERR;
} else if (bell) {
res = NCURSES_PUTP2_FLUSH("bell", bell);
diff --git a/ncurses/base/lib_bkgd.c b/ncurses/base/lib_bkgd.c
index 4f99080835e8..0358f4a2d40e 100644
--- a/ncurses/base/lib_bkgd.c
+++ b/ncurses/base/lib_bkgd.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2018-2021,2024 Thomas E. Dickey *
* Copyright 1998-2014,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -37,7 +37,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_bkgd.c,v 1.63 2021/05/08 14:58:12 tom Exp $")
+MODULE_ID("$Id: lib_bkgd.c,v 1.64 2024/12/07 20:00:48 tom Exp $")
static const NCURSES_CH_T blank = NewChar(BLANK_TEXT);
@@ -136,7 +136,7 @@ _nc_background(WINDOW *win, const ARG_CH_T ch, bool narrow)
#define TraceChar(c) _tracechar(CharOf(c))
#endif
- if (SP == 0) {
+ if (SP == NULL) {
;
} else if (win) {
NCURSES_CH_T new_bkgd = CHDEREF(ch);
diff --git a/ncurses/base/lib_chgat.c b/ncurses/base/lib_chgat.c
index 74c4f75b44d9..e78c76a69098 100644
--- a/ncurses/base/lib_chgat.c
+++ b/ncurses/base/lib_chgat.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-2015,2025 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,7 +43,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_chgat.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_chgat.c,v 1.15 2025/02/15 20:53:36 tom Exp $")
NCURSES_EXPORT(int)
wchgat(WINDOW *win,
@@ -62,7 +62,8 @@ wchgat(WINDOW *win,
color_pair));
set_extended_pair(opts, color_pair);
- if (win) {
+ if (win != NULL
+ && color_pair >= 0) {
struct ldat *line = &(win->_line[win->_cury]);
int i;
diff --git a/ncurses/base/lib_color.c b/ncurses/base/lib_color.c
index f001b22413fe..5472419c159a 100644
--- a/ncurses/base/lib_color.c
+++ b/ncurses/base/lib_color.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -49,9 +49,9 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_color.c,v 1.150 2023/09/16 16:39:15 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.157 2025/12/27 12:31:03 tom Exp $")
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
#define CanChange InfoOf(SP_PARM).canchange
#define DefaultPalette InfoOf(SP_PARM).defaultPalette
#define HasColor InfoOf(SP_PARM).hascolor
@@ -69,7 +69,7 @@ MODULE_ID("$Id: lib_color.c,v 1.150 2023/09/16 16:39:15 tom Exp $")
#define UseHlsPalette (hue_lightness_saturation)
#endif
-#ifndef USE_TERM_DRIVER
+#if !USE_TERM_DRIVER
/*
* These should be screen structure members. They need to be globals for
* historical reasons. So we assign them in start_color() and also in
@@ -132,7 +132,7 @@ static const color_t hls_palette[] =
DATA( 0, 50, 100), /* COLOR_WHITE */
};
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
NCURSES_EXPORT_VAR(const color_t*) _nc_cga_palette = cga_palette;
NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette = hls_palette;
#endif
@@ -146,20 +146,20 @@ NCURSES_EXPORT_VAR(const color_t*) _nc_hls_palette = hls_palette;
static int
default_fg(NCURSES_SP_DCL0)
{
- return (SP_PARM != 0) ? SP_PARM->_default_fg : COLOR_WHITE;
+ return (SP_PARM != NULL) ? SP_PARM->_default_fg : COLOR_WHITE;
}
static int
default_bg(NCURSES_SP_DCL0)
{
- return SP_PARM != 0 ? SP_PARM->_default_bg : COLOR_BLACK;
+ return SP_PARM != NULL ? SP_PARM->_default_bg : COLOR_BLACK;
}
#else
#define default_fg(sp) COLOR_WHITE
#define default_bg(sp) COLOR_BLACK
#endif
-#ifndef USE_TERM_DRIVER
+#if !USE_TERM_DRIVER
/*
* SVr4 curses is known to interchange color codes (1,4) and (3,6), possibly
* to maintain compatibility with a pre-ANSI scheme. The same scheme is
@@ -181,7 +181,7 @@ toggled_colors(int c)
static void
set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc)
{
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver_3(SP_PARM, td_color, FALSE, bg, outc);
#else
if (set_a_background) {
@@ -201,7 +201,7 @@ set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc)
static void
set_foreground_color(NCURSES_SP_DCLx int fg, NCURSES_SP_OUTC outc)
{
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver_3(SP_PARM, td_color, TRUE, fg, outc);
#else
if (set_a_foreground) {
@@ -248,7 +248,7 @@ init_color_table(NCURSES_SP_DCL0)
static bool
init_direct_colors(NCURSES_SP_DCL0)
{
- static NCURSES_CONST char name[] = "RGB";
+ static NCURSES_CONST char name[] = UserCap(RGB);
rgb_bits_t *result = &(SP_PARM->_direct_color);
@@ -273,7 +273,7 @@ init_direct_colors(NCURSES_SP_DCL0)
result->bits.red = UChar(n);
result->bits.green = UChar(n);
result->bits.blue = UChar(n);
- } else if ((s = tigetstr(name)) != 0 && VALID_STRING(s)) {
+ } else if ((s = tigetstr(name)) != NULL && VALID_STRING(s)) {
int red = n;
int green = n;
int blue = width - (2 * n);
@@ -306,13 +306,13 @@ init_direct_colors(NCURSES_SP_DCL0)
static bool
reset_color_pair(NCURSES_SP_DCL0)
{
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
return CallDriver(SP_PARM, td_rescol);
#else
bool result = FALSE;
(void) SP_PARM;
- if (orig_pair != 0) {
+ if (orig_pair != NULL) {
(void) NCURSES_PUTP2("orig_pair", orig_pair);
result = TRUE;
}
@@ -336,10 +336,10 @@ NCURSES_SP_NAME(_nc_reset_colors) (NCURSES_SP_DCL0)
if (reset_color_pair(NCURSES_SP_ARG))
result = TRUE;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
result = CallDriver(SP_PARM, td_rescolors);
#else
- if (orig_colors != 0) {
+ if (orig_colors != NULL) {
NCURSES_PUTP2("orig_colors", orig_colors);
result = TRUE;
}
@@ -362,7 +362,7 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
T((T_CALLED("start_color(%p)"), (void *) SP_PARM));
- if (SP_PARM == 0) {
+ if (SP_PARM == NULL) {
result = ERR;
} else if (SP_PARM->_coloron) {
result = OK;
@@ -393,7 +393,9 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
* If using default colors, allocate extra space in table to
* allow for default-color as a component of a color-pair.
*/
- SP_PARM->_pair_limit += (1 + (2 * maxcolors));
+ if (maxcolors < maxpairs) {
+ SP_PARM->_pair_limit += (1 + (2 * maxcolors));
+ }
#if !NCURSES_EXT_COLORS
SP_PARM->_pair_limit = limit_PAIRS(SP_PARM->_pair_limit);
#endif
@@ -406,12 +408,12 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
#endif
ReservePairs(SP_PARM, 16);
- if (SP_PARM->_color_pairs != 0) {
+ if (SP_PARM->_color_pairs != NULL) {
if (init_direct_colors(NCURSES_SP_ARG)) {
result = OK;
} else {
TYPE_CALLOC(color_t, maxcolors, SP_PARM->_color_table);
- if (SP_PARM->_color_table != 0) {
+ if (SP_PARM->_color_table != NULL) {
MakeColorPair(SP_PARM->_color_pairs[0],
default_fg(NCURSES_SP_ARG),
default_bg(NCURSES_SP_ARG));
@@ -425,7 +427,7 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
COLORS, COLOR_PAIRS));
SP_PARM->_coloron = 1;
- } else if (SP_PARM->_color_pairs != 0) {
+ } else if (SP_PARM->_color_pairs != NULL) {
FreeAndNull(SP_PARM->_color_pairs);
}
}
@@ -526,13 +528,13 @@ _nc_reserve_pairs(SCREEN *sp, int want)
if (have > sp->_pair_limit)
have = sp->_pair_limit;
- if (sp->_color_pairs == 0) {
+ if (sp->_color_pairs == NULL) {
TYPE_CALLOC(colorpair_t, have, sp->_color_pairs);
} else if (have > sp->_pair_alloc) {
-#if NCURSES_EXT_COLORS
+#if NCURSES_EXT_COLORS && NCURSES_EXT_FUNCS
colorpair_t *next;
- if ((next = typeCalloc(colorpair_t, have)) == 0)
+ if ((next = typeCalloc(colorpair_t, have)) == NULL)
_nc_err_abort(MSG_NO_MEMORY);
memcpy(next, sp->_color_pairs, (size_t) sp->_pair_alloc * sizeof(*next));
_nc_copy_pairs(sp, next, sp->_color_pairs, sp->_pair_alloc);
@@ -540,13 +542,13 @@ _nc_reserve_pairs(SCREEN *sp, int want)
sp->_color_pairs = next;
#else
TYPE_REALLOC(colorpair_t, have, sp->_color_pairs);
- if (sp->_color_pairs != 0) {
+ if (sp->_color_pairs != NULL) {
memset(sp->_color_pairs + sp->_pair_alloc, 0,
sizeof(colorpair_t) * (size_t) (have - sp->_pair_alloc));
}
#endif
}
- if (sp->_color_pairs != 0) {
+ if (sp->_color_pairs != NULL) {
sp->_pair_alloc = have;
}
}
@@ -656,7 +658,7 @@ _nc_init_pair(SCREEN *sp, int pair, int f, int b)
if (GET_SCREEN_PAIR(sp) == pair)
SET_SCREEN_PAIR(sp, (int) (~0)); /* force attribute update */
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver_3(sp, td_initpair, pair, f, b);
#else
if (initialize_pair && InPalette(f) && InPalette(b)) {
@@ -713,7 +715,7 @@ _nc_init_color(SCREEN *sp, int color, int r, int g, int b)
color,
r, g, b));
- if (sp == 0 || sp->_direct_color.value)
+ if (sp == NULL || sp->_direct_color.value)
returnCode(result);
maxcolors = MaxColors;
@@ -739,7 +741,7 @@ _nc_init_color(SCREEN *sp, int color, int r, int g, int b)
sp->_color_table[color].blue = b;
}
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver_4(sp, td_initcolor, color, r, g, b);
#else
NCURSES_PUTP2("initialize_color",
@@ -776,7 +778,7 @@ init_color(NCURSES_COLOR_T color,
NCURSES_EXPORT(bool)
NCURSES_SP_NAME(can_change_color) (NCURSES_SP_DCL)
{
- int result = FALSE;
+ bool result = FALSE;
T((T_CALLED("can_change_color(%p)"), (void *) SP_PARM));
@@ -784,7 +786,7 @@ NCURSES_SP_NAME(can_change_color) (NCURSES_SP_DCL)
result = TRUE;
}
- returnCode(result);
+ returnBool(result);
}
#if NCURSES_SP_FUNCS
@@ -798,12 +800,12 @@ can_change_color(void)
NCURSES_EXPORT(bool)
NCURSES_SP_NAME(has_colors) (NCURSES_SP_DCL0)
{
- int code = FALSE;
+ bool code = FALSE;
(void) SP_PARM;
T((T_CALLED("has_colors(%p)"), (void *) SP_PARM));
if (HasTerminal(SP_PARM)) {
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
code = HasColor;
#else
code = ((VALID_NUMERIC(max_colors) && VALID_NUMERIC(max_pairs)
@@ -814,7 +816,7 @@ NCURSES_SP_NAME(has_colors) (NCURSES_SP_DCL0)
|| set_color_pair)) ? TRUE : FALSE);
#endif
}
- returnCode(code);
+ returnBool(code);
}
#if NCURSES_SP_FUNCS
@@ -837,7 +839,7 @@ _nc_color_content(SCREEN *sp, int color, int *r, int *g, int *b)
(void *) g,
(void *) b));
- if (sp != 0) {
+ if (sp != NULL) {
int maxcolors = MaxColors;
if (color >= 0 && OkColorHi(color) && sp->_coloron) {
@@ -991,7 +993,7 @@ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx
int reverse,
NCURSES_SP_OUTC outc)
{
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver_4(SP_PARM, td_docolor, old_pair, pair, reverse, outc);
#else
int fg = COLOR_DEFAULT;
@@ -1008,14 +1010,14 @@ NCURSES_SP_NAME(_nc_do_color) (NCURSES_SP_DCLx
TIPARM_1(set_color_pair, pair),
1, outc);
return;
- } else if (SP_PARM != 0) {
+ } else if (SP_PARM != NULL) {
if (_nc_pair_content(SP_PARM, pair, &fg, &bg) == ERR)
return;
}
}
if (old_pair >= 0
- && SP_PARM != 0
+ && SP_PARM != NULL
&& _nc_pair_content(SP_PARM, old_pair, &old_fg, &old_bg) != ERR) {
if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
|| (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
@@ -1081,7 +1083,7 @@ _nc_do_color(int old_pair, int pair, int reverse, NCURSES_OUTC outc)
}
#endif
-#if NCURSES_EXT_COLORS
+#if NCURSES_EXT_COLORS && NCURSES_EXT_FUNCS
NCURSES_EXPORT(int)
NCURSES_SP_NAME(init_extended_pair) (NCURSES_SP_DCLx int pair, int f, int b)
{
@@ -1115,11 +1117,11 @@ NCURSES_SP_NAME(extended_pair_content) (NCURSES_SP_DCLx
NCURSES_EXPORT(void)
NCURSES_SP_NAME(reset_color_pairs) (NCURSES_SP_DCL0)
{
- if (SP_PARM != 0) {
+ if (SP_PARM != NULL) {
if (SP_PARM->_color_pairs) {
_nc_free_ordered_pairs(SP_PARM);
free(SP_PARM->_color_pairs);
- SP_PARM->_color_pairs = 0;
+ SP_PARM->_color_pairs = NULL;
SP_PARM->_pair_alloc = 0;
ReservePairs(SP_PARM, 16);
clearok(CurScreen(SP_PARM), TRUE);
diff --git a/ncurses/base/lib_colorset.c b/ncurses/base/lib_colorset.c
index 387edef61b23..d200b9f095a5 100644
--- a/ncurses/base/lib_colorset.c
+++ b/ncurses/base/lib_colorset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2014,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_colorset.c,v 1.16 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_colorset.c,v 1.17 2024/12/07 20:00:48 tom Exp $")
NCURSES_EXPORT(int)
wcolor_set(WINDOW *win, NCURSES_PAIRS_T pair_arg, void *opts)
@@ -53,7 +53,7 @@ wcolor_set(WINDOW *win, NCURSES_PAIRS_T pair_arg, void *opts)
T((T_CALLED("wcolor_set(%p,%d)"), (void *) win, color_pair));
set_extended_pair(opts, color_pair);
if (win
- && (SP != 0)
+ && (SP != NULL)
&& (color_pair >= 0)
&& (color_pair < SP->_pair_limit)) {
TR(TRACE_ATTRS, ("... current %ld", (long) GET_WINDOW_PAIR(win)));
diff --git a/ncurses/base/lib_delch.c b/ncurses/base/lib_delch.c
index d39a8ebae619..a24cb677a184 100644
--- a/ncurses/base/lib_delch.c
+++ b/ncurses/base/lib_delch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2001,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_delch.c,v 1.14 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_delch.c,v 1.16 2024/10/19 21:20:46 tom Exp $")
NCURSES_EXPORT(int)
wdelch(WINDOW *win)
@@ -54,8 +54,8 @@ wdelch(WINDOW *win)
NCURSES_CH_T blank = win->_nc_bkgd;
struct ldat *line = &(win->_line[win->_cury]);
NCURSES_CH_T *end = &(line->text[win->_maxx]);
- NCURSES_CH_T *temp2 = &(line->text[win->_curx + 1]);
- NCURSES_CH_T *temp1 = temp2 - 1;
+ NCURSES_CH_T *temp1 = &(line->text[win->_curx]);
+ const NCURSES_CH_T *temp2 = temp1 + 1;
CHANGED_TO_EOL(line, win->_curx, win->_maxx);
while (temp1 < end)
diff --git a/ncurses/base/lib_delwin.c b/ncurses/base/lib_delwin.c
index c96e417a9a48..855671ca7b51 100644
--- a/ncurses/base/lib_delwin.c
+++ b/ncurses/base/lib_delwin.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2021,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 1998-2008,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,30 +43,31 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_delwin.c,v 1.25 2023/10/21 11:12:44 tom Exp $")
+MODULE_ID("$Id: lib_delwin.c,v 1.29 2024/12/07 17:28:13 tom Exp $")
static bool
-cannot_delete(WINDOW *win)
+cannot_delete(const WINDOW *win)
{
bool result = TRUE;
+ bool found = FALSE;
+ SCREEN *scan;
+ WINDOWLIST *p;
- if (IS_PAD(win)) {
- result = FALSE;
- } else {
- WINDOWLIST *p;
-#if NCURSES_SP_FUNCS && defined(USE_SP_WINDOWLIST)
- SCREEN *sp = _nc_screen_of(win);
-#endif
-
- for (each_window(SP_PARM, p)) {
+ for (each_screen(scan)) {
+ for (each_window(scan, p)) {
if (&(p->win) == win) {
result = FALSE;
+ found = TRUE;
+ break;
} else if (IS_SUBWIN(&(p->win))
&& p->win._parent == win) {
result = TRUE;
+ found = TRUE;
break;
}
}
+ if (found)
+ break;
}
return result;
}
@@ -79,7 +80,7 @@ delwin(WINDOW *win)
T((T_CALLED("delwin(%p)"), (void *) win));
if (_nc_try_global(curses) == 0) {
- if (win == 0
+ if (win == NULL
|| cannot_delete(win)) {
result = ERR;
} else if (IS_PAD(win)) {
@@ -91,7 +92,7 @@ delwin(WINDOW *win)
#endif
if (IS_SUBWIN(win)) {
touchwin(win->_parent);
- } else if (CurScreen(SP_PARM) != 0) {
+ } else if (CurScreen(SP_PARM) != NULL) {
touchwin(CurScreen(SP_PARM));
}
result = _nc_freewin(win);
diff --git a/ncurses/base/lib_dft_fgbg.c b/ncurses/base/lib_dft_fgbg.c
index 4dd43bb1bbd0..78d4c568bf62 100644
--- a/ncurses/base/lib_dft_fgbg.c
+++ b/ncurses/base/lib_dft_fgbg.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2014,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -38,7 +38,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_dft_fgbg.c,v 1.31 2021/04/03 22:27:18 tom Exp $")
+MODULE_ID("$Id: lib_dft_fgbg.c,v 1.34 2025/12/27 12:28:45 tom Exp $")
/*
* Modify the behavior of color-pair 0 so that the library doesn't assume that
@@ -69,17 +69,17 @@ NCURSES_SP_NAME(assume_default_colors) (NCURSES_SP_DCLx int fg, int bg)
int code = ERR;
T((T_CALLED("assume_default_colors(%p,%d,%d)"), (void *) SP_PARM, fg, bg));
- if (SP_PARM != 0) {
-#ifdef USE_TERM_DRIVER
+ if (SP_PARM != NULL) {
+#if USE_TERM_DRIVER
code = CallDriver_2(SP_PARM, td_defaultcolors, fg, bg);
#else
if ((orig_pair || orig_colors) && !initialize_pair) {
SP_PARM->_default_color = isDefaultColor(fg) || isDefaultColor(bg);
- SP_PARM->_has_sgr_39_49 = (tigetflag("AX") == TRUE);
+ SP_PARM->_has_sgr_39_49 = (tigetflag(UserCap(AX)) == TRUE);
SP_PARM->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : fg;
SP_PARM->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : bg;
- if (SP_PARM->_color_pairs != 0) {
+ if (SP_PARM->_color_pairs != NULL) {
bool save = SP_PARM->_default_color;
SP_PARM->_assumed_color = TRUE;
SP_PARM->_default_color = TRUE;
diff --git a/ncurses/base/lib_driver.c b/ncurses/base/lib_driver.c
index c53802f3732a..1a4b6a89355b 100644
--- a/ncurses/base/lib_driver.c
+++ b/ncurses/base/lib_driver.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2009-2012,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,51 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_driver.c,v 1.9 2020/08/29 19:53:35 tom Exp $")
-
-#ifndef EXP_WIN32_DRIVER
-typedef struct DriverEntry {
- const char *name;
- TERM_DRIVER *driver;
-} DRIVER_ENTRY;
-
-static DRIVER_ENTRY DriverTable[] =
-{
-#ifdef _WIN32
- {"win32console", &_nc_WIN_DRIVER},
-#endif
- {"tinfo", &_nc_TINFO_DRIVER} /* must be last */
-};
-
-NCURSES_EXPORT(int)
-_nc_get_driver(TERMINAL_CONTROL_BLOCK * TCB, const char *name, int *errret)
-{
- int code = ERR;
- size_t i;
- TERM_DRIVER *res = (TERM_DRIVER *) 0;
- TERM_DRIVER *use = 0;
-
- T((T_CALLED("_nc_get_driver(%p, %s, %p)"),
- (void *) TCB, NonNull(name), (void *) errret));
-
- assert(TCB != 0);
-
- for (i = 0; i < SIZEOF(DriverTable); i++) {
- res = DriverTable[i].driver;
- if (strcmp(DriverTable[i].name, res->td_name(TCB)) == 0) {
- if (res->td_CanHandle(TCB, name, errret)) {
- use = res;
- break;
- }
- }
- }
- if (use != 0) {
- TCB->drv = use;
- code = OK;
- }
- returnCode(code);
-}
-#endif /* !EXP_WIN32_DRIVER */
+MODULE_ID("$Id: lib_driver.c,v 1.12 2025/10/18 19:20:33 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(has_key) (SCREEN *sp, int keycode)
@@ -98,7 +54,7 @@ NCURSES_SP_NAME(_nc_mcprint) (SCREEN *sp, char *data, int len)
{
int code = ERR;
- if (0 != TerminalOf(sp))
+ if (NULL != TerminalOf(sp))
code = CallDriver_2(sp, td_print, data, len);
return (code);
}
diff --git a/ncurses/base/lib_echo.c b/ncurses/base/lib_echo.c
index de7832f4afc1..381f51fbedd6 100644
--- a/ncurses/base/lib_echo.c
+++ b/ncurses/base/lib_echo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 1998-2000,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -45,13 +45,13 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_echo.c,v 1.10 2023/04/29 18:57:12 tom Exp $")
+MODULE_ID("$Id: lib_echo.c,v 1.11 2024/12/07 20:00:48 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(echo) (NCURSES_SP_DCL0)
{
T((T_CALLED("echo(%p)"), (void *) SP_PARM));
- if (0 == SP_PARM)
+ if (NULL == SP_PARM)
returnCode(ERR);
IsEcho(SP_PARM) = TRUE;
returnCode(OK);
@@ -69,7 +69,7 @@ NCURSES_EXPORT(int)
NCURSES_SP_NAME(noecho) (NCURSES_SP_DCL0)
{
T((T_CALLED("noecho(%p)"), (void *) SP_PARM));
- if (0 == SP_PARM)
+ if (NULL == SP_PARM)
returnCode(ERR);
IsEcho(SP_PARM) = FALSE;
returnCode(OK);
diff --git a/ncurses/base/lib_endwin.c b/ncurses/base/lib_endwin.c
index 85d2bdbaac05..4cff0e7051b9 100644
--- a/ncurses/base/lib_endwin.c
+++ b/ncurses/base/lib_endwin.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2025 Thomas E. Dickey *
* Copyright 1998-2014,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,7 +43,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_endwin.c,v 1.28 2023/11/11 21:27:32 tom Exp $")
+MODULE_ID("$Id: lib_endwin.c,v 1.29 2025/12/27 12:41:23 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(endwin) (NCURSES_SP_DCL0)
@@ -54,7 +54,7 @@ NCURSES_SP_NAME(endwin) (NCURSES_SP_DCL0)
if (SP_PARM != NULL) {
if (SP_PARM->_endwin != ewSuspend) {
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *TCB = TCBOf(SP_PARM);
SP_PARM->_endwin = ewSuspend;
diff --git a/ncurses/base/lib_erase.c b/ncurses/base/lib_erase.c
index aa9437a19ef1..461acddaf39b 100644
--- a/ncurses/base/lib_erase.c
+++ b/ncurses/base/lib_erase.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2022 Thomas E. Dickey *
+ * Copyright 2020-2022,2024 Thomas E. Dickey *
* Copyright 1998-2009,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_erase.c,v 1.20 2022/09/03 21:40:27 tom Exp $")
+MODULE_ID("$Id: lib_erase.c,v 1.21 2024/12/07 20:00:48 tom Exp $")
NCURSES_EXPORT(int)
werase(WINDOW *win)
@@ -71,7 +71,7 @@ werase(WINDOW *win)
*/
if_WIDEC({
if (isWidecExt(start[0])) {
- int x = (win->_parent != 0) ? (win->_begx) : 0;
+ int x = (win->_parent != NULL) ? (win->_begx) : 0;
while (x-- > 0) {
if (isWidecBase(start[-1])) {
--start;
diff --git a/ncurses/base/lib_flash.c b/ncurses/base/lib_flash.c
index 975d5f5678f8..2bbfc5231b2c 100644
--- a/ncurses/base/lib_flash.c
+++ b/ncurses/base/lib_flash.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2013,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -47,7 +47,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_flash.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_flash.c,v 1.17 2025/12/27 12:41:23 tom Exp $")
/*
* flash()
@@ -63,8 +63,8 @@ NCURSES_SP_NAME(flash) (NCURSES_SP_DCL0)
int res = ERR;
T((T_CALLED("flash(%p)"), (void *) SP_PARM));
-#ifdef USE_TERM_DRIVER
- if (SP_PARM != 0)
+#if USE_TERM_DRIVER
+ if (SP_PARM != NULL)
res = CallDriver_1(SP_PARM, td_doBeepOrFlash, FALSE);
#else
if (HasTerminal(SP_PARM)) {
diff --git a/ncurses/base/lib_freeall.c b/ncurses/base/lib_freeall.c
index 75bbe77e3409..304ef8f6a9f3 100644
--- a/ncurses/base/lib_freeall.c
+++ b/ncurses/base/lib_freeall.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2018-2021,2024 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
extern int malloc_errfd; /* FIXME */
#endif
-MODULE_ID("$Id: lib_freeall.c,v 1.76 2021/11/06 21:52:49 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.78 2024/12/07 18:00:11 tom Exp $")
/*
* Free all ncurses data. This is used for testing only (there's no practical
@@ -54,11 +54,11 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
T((T_CALLED("_nc_freeall()")));
#if NO_LEAKS
_nc_globals.leak_checking = TRUE;
- if (SP_PARM != 0) {
- if (SP_PARM->_oldnum_list != 0) {
+ if (SP_PARM != NULL) {
+ if (SP_PARM->_oldnum_list != NULL) {
FreeAndNull(SP_PARM->_oldnum_list);
}
- if (SP_PARM->_panelHook.destroy != 0) {
+ if (SP_PARM->_panelHook.destroy != NULL) {
SP_PARM->_panelHook.destroy(SP_PARM->_panelHook.stdscr_pseudo_panel);
}
#if NCURSES_EXT_COLORS
@@ -66,10 +66,10 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
#endif
}
#endif
- if (SP_PARM != 0) {
+ if (SP_PARM != NULL) {
_nc_lock_global(curses);
- while (WindowList(SP_PARM) != 0) {
+ while (WindowList(SP_PARM) != NULL) {
WINDOWLIST *p, *q;
bool deleted = FALSE;
@@ -87,7 +87,7 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
#endif
for (each_window(SP_PARM, q)) {
- WINDOW *q_win = &(q->win);
+ const WINDOW *q_win = &(q->win);
#ifndef USE_SP_WINDOWLIST
if (q->screen != SP_PARM)
@@ -119,7 +119,7 @@ NCURSES_SP_NAME(_nc_freeall) (NCURSES_SP_DCL0)
_nc_unlock_global(curses);
}
- (void) _nc_printf_string(0, empty_va);
+ (void) _nc_printf_string(NULL, empty_va);
#ifdef TRACE
(void) _nc_trace_buf(-1, (size_t) 0);
#endif
diff --git a/ncurses/base/lib_getch.c b/ncurses/base/lib_getch.c
index 8e4767918bdd..e5f6c0041cc2 100644
--- a/ncurses/base/lib_getch.c
+++ b/ncurses/base/lib_getch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2015,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -44,7 +44,7 @@
#define NEED_KEY_EVENT
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getch.c,v 1.146 2023/04/29 18:57:12 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.154 2025/12/27 12:28:45 tom Exp $")
#include <fifo_defs.h>
@@ -134,17 +134,6 @@ _nc_use_meta(WINDOW *win)
return (sp ? sp->_use_meta : 0);
}
-#ifdef USE_TERM_DRIVER
-# if defined(_NC_WINDOWS) && !defined(EXP_WIN32_DRIVER)
-static HANDLE
-_nc_get_handle(int fd)
-{
- intptr_t value = _get_osfhandle(fd);
- return (HANDLE) value;
-}
-# endif
-#endif
-
/*
* Check for mouse activity, returning nonzero if we find any.
*/
@@ -153,22 +142,16 @@ check_mouse_activity(SCREEN *sp, int delay EVENTLIST_2nd(_nc_eventlist * evl))
{
int rc;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *TCB = TCBOf(sp);
rc = TCBOf(sp)->drv->td_testmouse(TCBOf(sp), delay EVENTLIST_2nd(evl));
-# if defined(EXP_WIN32_DRIVER)
+# if USE_NAMED_PIPES || defined(_NC_WINDOWS_NATIVE)
/* if we emulate terminfo on console, we have to use the console routine */
if (IsTermInfoOnConsole(sp)) {
rc = _nc_console_testmouse(sp,
_nc_console_handle(sp->_ifd),
delay EVENTLIST_2nd(evl));
} else
-# elif defined(_NC_WINDOWS)
- /* if we emulate terminfo on console, we have to use the console routine */
- if (IsTermInfoOnConsole(sp)) {
- HANDLE fd = _nc_get_handle(sp->_ifd);
- rc = _nc_mingw_testmouse(sp, fd, delay EVENTLIST_2nd(evl));
- } else
# endif
rc = TCB->drv->td_testmouse(TCB, delay EVENTLIST_2nd(evl));
#else /* !USE_TERM_DRIVER */
@@ -179,7 +162,7 @@ check_mouse_activity(SCREEN *sp, int delay EVENTLIST_2nd(_nc_eventlist * evl))
} else
# endif
{
-# if defined(EXP_WIN32_DRIVER)
+# if USE_NAMED_PIPES
rc = _nc_console_testmouse(sp,
_nc_console_handle(sp->_ifd),
delay
@@ -289,7 +272,7 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
n = 1;
} else
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
if ((sp->_mouse_type == M_TERM_DRIVER)
&& (sp->_drv_mouse_head < sp->_drv_mouse_tail)) {
sp->_mouse_event(sp);
@@ -305,9 +288,9 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
} else
#endif
{ /* Can block... */
-#if defined(USE_TERM_DRIVER)
+#if USE_TERM_DRIVER
int buf;
-# if defined(EXP_WIN32_DRIVER)
+# if USE_NAMED_PIPES || defined(_NC_WINDOWS_NATIVE)
if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && IsCbreak(sp)) {
_nc_set_read_thread(TRUE);
n = _nc_console_read(sp,
@@ -315,23 +298,17 @@ fifo_push(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
&buf);
_nc_set_read_thread(FALSE);
} else
-# elif defined(_NC_WINDOWS)
- if (NC_ISATTY(sp->_ifd) && IsTermInfoOnConsole(sp) && IsCbreak(sp))
- n = _nc_mingw_console_read(sp,
- _nc_get_handle(sp->_ifd),
- &buf);
- else
-# endif /* EXP_WIN32_DRIVER */
+# endif /* USE_NAMED_PIPES */
n = CallDriver_1(sp, td_read, &buf);
ch = buf;
#else /* !USE_TERM_DRIVER */
-#if defined(EXP_WIN32_DRIVER)
+#if USE_NAMED_PIPES
int buf;
#endif
unsigned char c2 = 0;
_nc_set_read_thread(TRUE);
-#if defined(EXP_WIN32_DRIVER)
+#if USE_NAMED_PIPES
n = _nc_console_read(sp,
_nc_console_handle(sp->_ifd),
&buf);
@@ -414,7 +391,7 @@ recur_wgetnstr(WINDOW *win, char *buf)
SCREEN *sp = _nc_screen_of(win);
int rc;
- if (sp != 0) {
+ if (sp != NULL) {
#ifdef USE_PTHREADS
if (_nc_use_pthreads && sp != CURRENT_SCREEN) {
SCREEN *save_SP;
@@ -457,7 +434,7 @@ _nc_wgetch(WINDOW *win,
*result = 0;
sp = _nc_screen_of(win);
- if (win == 0 || sp == 0) {
+ if (win == NULL || sp == NULL) {
returnCode(ERR);
}
@@ -513,7 +490,7 @@ _nc_wgetch(WINDOW *win,
recur_wrefresh(win);
- if (win->_notimeout || (win->_delay >= 0) || (IsCbreak(sp) > 1)) {
+ if ((win->_delay >= 0) || (IsCbreak(sp) > 1)) {
if (head == -1) { /* fifo is empty */
int delay;
diff --git a/ncurses/base/lib_getstr.c b/ncurses/base/lib_getstr.c
index cac21fc85bd9..8e7d6dc05f5a 100644
--- a/ncurses/base/lib_getstr.c
+++ b/ncurses/base/lib_getstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2021,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2011,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -42,14 +42,14 @@
#define NEED_KEY_EVENT
#include <curses.priv.h>
-MODULE_ID("$Id: lib_getstr.c,v 1.39 2023/04/29 19:00:17 tom Exp $")
+MODULE_ID("$Id: lib_getstr.c,v 1.42 2025/01/19 00:51:54 tom Exp $")
/*
* This wipes out the last character, no matter whether it was a tab, control
* or other character, and handles reverse wraparound.
*/
static char *
-WipeOut(WINDOW *win, int y, int x, char *first, char *last, int echoed)
+WipeOut(WINDOW *win, int y, int x, const char *first, char *last, int echoed)
{
if (last > first) {
*--last = '\0';
@@ -81,11 +81,11 @@ wgetnstr_events(WINDOW *win,
TTY_FLAGS save_flags;
char erasec;
char killc;
- char *oldstr;
+ const char *oldstr;
int ch;
int y, x;
- T((T_CALLED("wgetnstr(%p,%p,%d)"), (void *) win, (void *) str, maxlen));
+ T((T_CALLED("wgetnstr_events(%p,%p,%d)"), (void *) win, (void *) str, maxlen));
if (!win || !str)
returnCode(ERR);
@@ -195,7 +195,7 @@ wgetnstr_events(WINDOW *win,
if (ch == ERR)
returnCode(ch);
- T(("wgetnstr returns %s", _nc_visbuf(oldstr)));
+ T(("wgetnstr_events returns %s", _nc_visbuf(oldstr)));
#ifdef KEY_EVENT
if (ch == KEY_EVENT)
diff --git a/ncurses/base/lib_initscr.c b/ncurses/base/lib_initscr.c
index 6b9149135501..782e0659cac1 100644
--- a/ncurses/base/lib_initscr.c
+++ b/ncurses/base/lib_initscr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -46,7 +46,7 @@
#include <sys/termio.h> /* needed for ISC */
#endif
-MODULE_ID("$Id: lib_initscr.c,v 1.48 2020/09/07 14:26:48 tom Exp $")
+MODULE_ID("$Id: lib_initscr.c,v 1.52 2025/03/09 00:49:14 tom Exp $")
NCURSES_EXPORT(WINDOW *)
initscr(void)
@@ -70,7 +70,8 @@ initscr(void)
(void) VALID_TERM_ENV(env, "unknown");
if ((name = strdup(env)) == NULL) {
- fprintf(stderr, "Error opening allocating $TERM.\n");
+ fprintf(stderr, "ncurses: cannot allocate %d bytes of"
+ "memory for $TERM; exiting\n", (int) strlen(env));
ExitProgram(EXIT_FAILURE);
}
#ifdef __CYGWIN__
@@ -90,8 +91,9 @@ initscr(void)
}
}
#endif
- if (newterm(name, stdout, stdin) == 0) {
- fprintf(stderr, "Error opening terminal: %s.\n", name);
+ if (newterm(name, stdout, stdin) == NULL) {
+ fprintf(stderr, "ncurses: cannot initialize terminal type"
+ " ($TERM=\"%s\"); exiting\n", name);
ExitProgram(EXIT_FAILURE);
}
diff --git a/ncurses/base/lib_insch.c b/ncurses/base/lib_insch.c
index 894605ccfa98..430bcf210e8d 100644
--- a/ncurses/base/lib_insch.c
+++ b/ncurses/base/lib_insch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2013,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -44,7 +44,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_insch.c,v 1.37 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_insch.c,v 1.39 2024/12/07 17:40:33 tom Exp $")
/*
* Insert the given character, updating the current location to simplify
@@ -85,12 +85,12 @@ _nc_insert_ch(SCREEN *sp, WINDOW *win, chtype ch)
#endif
(isprint(ch8) ||
(ChAttrOf(ch) & A_ALTCHARSET) ||
- (sp != 0 && sp->_legacy_coding && !iscntrl(ch8)))) {
+ (sp != NULL && sp->_legacy_coding && !iscntrl(ch8)))) {
if (win->_curx <= win->_maxx) {
struct ldat *line = &(win->_line[win->_cury]);
NCURSES_CH_T *end = &(line->text[win->_curx]);
NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
- NCURSES_CH_T *temp2 = temp1 - 1;
+ const NCURSES_CH_T *temp2 = temp1 - 1;
SetChar2(wch, ch);
@@ -151,7 +151,7 @@ winsch(WINDOW *win, chtype c)
T((T_CALLED("winsch(%p, %s)"), (void *) win, _tracechtype(c)));
- if (win != 0) {
+ if (win != NULL) {
NCURSES_SIZE_T oy = win->_cury;
NCURSES_SIZE_T ox = win->_curx;
diff --git a/ncurses/base/lib_insnstr.c b/ncurses/base/lib_insnstr.c
index caec48e8eb70..b3eb216b93ff 100644
--- a/ncurses/base/lib_insnstr.c
+++ b/ncurses/base/lib_insnstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2023,2024 Thomas E. Dickey *
* Copyright 2004-2009,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_insnstr.c,v 1.10 2023/11/21 21:58:03 tom Exp $")
+MODULE_ID("$Id: lib_insnstr.c,v 1.11 2024/12/07 20:00:48 tom Exp $")
NCURSES_EXPORT(int)
winsnstr(WINDOW *win, const char *s, int n)
@@ -51,7 +51,7 @@ winsnstr(WINDOW *win, const char *s, int n)
T((T_CALLED("winsnstr(%p,%s,%d)"), (void *) win, _nc_visbufn(s, n), n));
- if (win != 0 && str != 0 && n != 0) {
+ if (win != NULL && str != NULL && n != 0) {
SCREEN *sp = _nc_screen_of(win);
#if USE_WIDEC_SUPPORT
/*
@@ -64,7 +64,7 @@ winsnstr(WINDOW *win, const char *s, int n)
if (sp->_screen_unicode) {
size_t nn = (n > 0) ? (size_t) n : strlen(s);
wchar_t *buffer = typeMalloc(wchar_t, nn + 1);
- if (buffer != 0) {
+ if (buffer != NULL) {
mbstate_t state;
size_t n3;
init_mb(state);
diff --git a/ncurses/base/lib_instr.c b/ncurses/base/lib_instr.c
index 221ebd290400..c9016b659a6f 100644
--- a/ncurses/base/lib_instr.c
+++ b/ncurses/base/lib_instr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2021,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_instr.c,v 1.26 2023/06/03 12:37:04 tom Exp $")
+MODULE_ID("$Id: lib_instr.c,v 1.28 2024/12/07 17:53:39 tom Exp $")
NCURSES_EXPORT(int)
winnstr(WINDOW *win, char *str, int n)
@@ -63,7 +63,7 @@ winnstr(WINDOW *win, char *str, int n)
for (; i < n;) {
#if USE_WIDEC_SUPPORT
- cchar_t *cell = &(text[col]);
+ const cchar_t *cell = &(text[col]);
attr_t attrs;
NCURSES_PAIRS_T pair;
char *tmp;
@@ -72,17 +72,17 @@ winnstr(WINDOW *win, char *str, int n)
wchar_t *wch;
int n2;
- n2 = getcchar(cell, 0, 0, 0, 0);
+ n2 = getcchar(cell, NULL, NULL, NULL, NULL);
if (n2 > 0
- && (wch = typeCalloc(wchar_t, (unsigned) n2 + 1)) != 0) {
+ && (wch = typeCalloc(wchar_t, (unsigned) n2 + 1)) != NULL) {
bool done = FALSE;
- if (getcchar(cell, wch, &attrs, &pair, 0) == OK) {
+ if (getcchar(cell, wch, &attrs, &pair, NULL) == OK) {
mbstate_t state;
size_t n3;
init_mb(state);
- n3 = wcstombs(0, wch, (size_t) 0);
+ n3 = wcstombs(NULL, wch, (size_t) 0);
if (!isEILSEQ(n3) && (n3 != 0) && (n3 <= MB_LEN_MAX)) {
size_t need = n3 + 10 + (size_t) i;
int have = (int) n3 + i;
@@ -90,7 +90,7 @@ winnstr(WINDOW *win, char *str, int n)
/* check for loop-done as well as overflow */
if (have > n || (int) need <= 0) {
done = TRUE;
- } else if ((tmp = typeCalloc(char, need)) == 0) {
+ } else if ((tmp = typeCalloc(char, need)) == NULL) {
done = TRUE;
} else {
size_t i3;
diff --git a/ncurses/base/lib_mouse.c b/ncurses/base/lib_mouse.c
index a03d8b8e1ab0..eb36ad2da817 100644
--- a/ncurses/base/lib_mouse.c
+++ b/ncurses/base/lib_mouse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2023,2024 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -44,7 +44,7 @@
* sysmouse (FreeBSD)
* special-purpose mouse interface for OS/2 EMX.
*
- * Notes for implementors of new mouse-interface methods:
+ * Notes for implementers of new mouse-interface methods:
*
* The code is logically split into a lower level that accepts event reports
* in a device-dependent format and an upper level that parses mouse gestures
@@ -70,7 +70,6 @@
*/
#ifdef __EMX__
-# include <io.h>
# define INCL_DOS
# define INCL_VIO
# define INCL_KBD
@@ -85,7 +84,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_mouse.c,v 1.200 2024/02/17 21:13:01 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.219 2025/12/30 17:23:24 tom Exp $")
#include <tic.h>
@@ -380,7 +379,7 @@ handle_sysmouse(int sig GCC_UNUSED)
}
#endif /* USE_SYSMOUSE */
-#if !defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)
+#if !defined(_NC_WINDOWS_NATIVE) || USE_NAMED_PIPES
#define xterm_kmous "\033[M"
static void
@@ -388,10 +387,10 @@ init_xterm_mouse(SCREEN *sp)
{
sp->_mouse_type = M_XTERM;
sp->_mouse_format = MF_X10;
- sp->_mouse_xtermcap = tigetstr("XM");
+ sp->_mouse_xtermcap = tigetstr(UserCap(XM));
if (VALID_STRING(sp->_mouse_xtermcap)) {
char *code = strstr(sp->_mouse_xtermcap, "[?");
- if (code != 0) {
+ if (code != NULL) {
code += 2;
while ((*code >= '0') && (*code <= '9')) {
char *next = code;
@@ -417,7 +416,7 @@ init_xterm_mouse(SCREEN *sp)
}
}
} else {
- int code = tigetnum("XM");
+ int code = tigetnum(UserCap(XM));
switch (code) {
#ifdef EXP_XTERM_1005
case 1005:
@@ -440,7 +439,7 @@ init_xterm_mouse(SCREEN *sp)
#endif
static void
-enable_xterm_mouse(SCREEN *sp, int enable)
+enable_xterm_mouse(SCREEN *sp, bool enable)
{
TPUTS_TRACE(enable
? "xterm mouse initialization"
@@ -453,11 +452,11 @@ enable_xterm_mouse(SCREEN *sp, int enable)
sp->_mouse_active = enable;
}
-#if defined(USE_TERM_DRIVER)
+#if USE_TERM_DRIVER
static void
-enable_win32_mouse(SCREEN *sp, int enable)
+enable_win32_mouse(SCREEN *sp, bool enable)
{
-#if defined(EXP_WIN32_DRIVER)
+#if USE_NAMED_PIPES
enable_xterm_mouse(sp, enable);
#else
sp->_mouse_active = enable;
@@ -483,9 +482,9 @@ allow_gpm_mouse(SCREEN *sp GCC_UNUSED)
if (NC_ISATTY(fileno(stdout))) {
const char *list = getenv("NCURSES_GPM_TERMS");
const char *env = getenv("TERM");
- if (list != 0) {
- if (env != 0) {
- result = _nc_name_match(list, env, "|:");
+ if (list != NULL) {
+ if (env != NULL) {
+ result = _nc_name_match(list, env, "|:") ? TRUE : FALSE;
}
} else {
/* GPM checks the beginning of the $TERM variable to decide if it
@@ -495,7 +494,7 @@ allow_gpm_mouse(SCREEN *sp GCC_UNUSED)
* capability. Perhaps that works for someone. If so, they can
* set the environment variable (above).
*/
- if (env != 0 && strstr(env, "linux") != 0) {
+ if (env != NULL && strstr(env, "linux") != NULL) {
result = TRUE;
}
}
@@ -507,7 +506,7 @@ allow_gpm_mouse(SCREEN *sp GCC_UNUSED)
static void
unload_gpm_library(SCREEN *sp)
{
- if (sp->_dlopen_gpm != 0) {
+ if (sp->_dlopen_gpm != NULL) {
T(("unload GPM library"));
sp->_mouse_gpm_loaded = FALSE;
sp->_mouse_fd = -1;
@@ -522,25 +521,25 @@ load_gpm_library(SCREEN *sp)
/*
* If we already had a successful dlopen, reuse it.
*/
- if (sp->_dlopen_gpm != 0) {
+ if (sp->_dlopen_gpm != NULL) {
sp->_mouse_gpm_found = TRUE;
sp->_mouse_gpm_loaded = TRUE;
- } else if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != 0) {
+ } else if ((sp->_dlopen_gpm = dlopen(LIBGPM_SONAME, my_RTLD)) != NULL) {
#if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
- if (GET_DLSYM(gpm_fd) == 0 ||
- GET_DLSYM(Gpm_Open) == 0 ||
- GET_DLSYM(Gpm_Close) == 0 ||
- GET_DLSYM(Gpm_GetEvent) == 0) {
+ if (GET_DLSYM(gpm_fd) == NULL ||
+ GET_DLSYM(Gpm_Open) == NULL ||
+ GET_DLSYM(Gpm_Close) == NULL ||
+ GET_DLSYM(Gpm_GetEvent) == NULL) {
#if (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
T(("GPM initialization failed: %s", dlerror()));
unload_gpm_library(sp);
dlclose(sp->_dlopen_gpm);
- sp->_dlopen_gpm = 0;
+ sp->_dlopen_gpm = NULL;
} else {
sp->_mouse_gpm_found = TRUE;
sp->_mouse_gpm_loaded = TRUE;
@@ -754,14 +753,15 @@ initialize_mousetype(SCREEN *sp)
}
#endif /* USE_SYSMOUSE */
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver(sp, td_initmouse);
#endif
-#if !defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)
+#if !defined(_NC_WINDOWS_NATIVE) || USE_NAMED_PIPES
/* we know how to recognize mouse events under "xterm" */
if (NonEmpty(key_mouse)) {
init_xterm_mouse(sp);
- } else if (strstr(SP_TERMTYPE term_names, "xterm") != 0) {
+ } else if (SP_TERMTYPE term_names != NULL
+ && strstr(SP_TERMTYPE term_names, "xterm") != NULL) {
if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK)
init_xterm_mouse(sp);
}
@@ -778,7 +778,7 @@ _nc_mouse_init(SCREEN *sp)
T((T_CALLED("_nc_mouse_init(%p)"), (void *) sp));
- if (sp != 0) {
+ if (sp != NULL) {
if (!sp->_mouse_initialized) {
int i;
@@ -786,7 +786,7 @@ _nc_mouse_init(SCREEN *sp)
TR(MY_TRACE, ("set _mouse_initialized"));
- sp->_mouse_eventp = FirstEV(sp);
+ sp->_mouse_readp = sp->_mouse_writep = FirstEV(sp);
for (i = 0; i < EV_MAX; i++)
Invalidate(sp->_mouse_events + i);
@@ -796,7 +796,7 @@ _nc_mouse_init(SCREEN *sp)
}
result = sp->_mouse_initialized;
}
- returnCode(result);
+ returnBool(result);
}
/*
@@ -806,7 +806,7 @@ _nc_mouse_init(SCREEN *sp)
static bool
_nc_mouse_event(SCREEN *sp)
{
- MEVENT *eventp = sp->_mouse_eventp;
+ MEVENT *eventp = sp->_mouse_writep;
bool result = FALSE;
(void) eventp;
@@ -874,7 +874,7 @@ _nc_mouse_event(SCREEN *sp)
eventp->z = 0;
/* bump the next-free pointer into the circular list */
- sp->_mouse_eventp = NEXT(eventp);
+ sp->_mouse_writep = NEXT(eventp);
result = TRUE;
break;
}
@@ -899,13 +899,13 @@ _nc_mouse_event(SCREEN *sp)
}
/* bump the next-free pointer into the circular list */
- sp->_mouse_eventp = eventp = NEXT(eventp);
+ sp->_mouse_writep = eventp = NEXT(eventp);
result = TRUE;
}
break;
#endif /* USE_SYSMOUSE */
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
case M_TERM_DRIVER:
while (sp->_drv_mouse_head < sp->_drv_mouse_tail) {
*eventp = sp->_drv_mouse_fifo[sp->_drv_mouse_head];
@@ -921,7 +921,7 @@ _nc_mouse_event(SCREEN *sp)
}
/* bump the next-free pointer into the circular list */
- sp->_mouse_eventp = eventp = NEXT(eventp);
+ sp->_mouse_writep = eventp = NEXT(eventp);
result = TRUE;
}
break;
@@ -984,7 +984,12 @@ handle_wheel(SCREEN *sp, MEVENT * eventp, int button, int wheel)
}
break;
case 2:
- PRESS_POSITION(3);
+ if (wheel) {
+ /* Ignore this event as it is not a true press of the button */
+ eventp->bstate = REPORT_MOUSE_POSITION;
+ } else {
+ PRESS_POSITION(3);
+ }
break;
default:
/*
@@ -1114,7 +1119,7 @@ decode_xterm_X10(SCREEN *sp, MEVENT * eventp)
sp->_ifd,
#endif
kbuf + grabbed, (size_t) (MAX_KBUF - (int) grabbed));
- if (res == -1)
+ if (res < 0)
break;
}
_nc_set_read_thread(FALSE);
@@ -1162,7 +1167,7 @@ decode_xterm_1005(SCREEN *sp, MEVENT * eventp)
sp->_ifd,
#endif
(kbuf + grabbed), (size_t) 1);
- if (res == -1)
+ if (res < 0)
break;
grabbed += (size_t) res;
if (grabbed > 1) {
@@ -1219,7 +1224,7 @@ typedef struct {
} SGR_DATA;
static bool
-read_SGR(SCREEN *sp, SGR_DATA * result)
+read_SGR(const SCREEN *sp, SGR_DATA * result)
{
char kbuf[80]; /* bigger than any possible mouse response */
int grabbed = 0;
@@ -1240,7 +1245,7 @@ read_SGR(SCREEN *sp, SGR_DATA * result)
sp->_ifd,
#endif
(kbuf + grabbed), (size_t) 1);
- if (res == -1)
+ if (res < 0)
break;
if ((grabbed + MAX_KBUF) >= (int) sizeof(kbuf)) {
result->nerror++;
@@ -1355,9 +1360,9 @@ _nc_mouse_inline(SCREEN *sp)
/* mouse report received in the keyboard stream -- parse its info */
{
bool result = FALSE;
- MEVENT *eventp = sp->_mouse_eventp;
+ MEVENT *eventp = sp->_mouse_writep;
- TR(MY_TRACE, ("_nc_mouse_inline() called"));
+ TR(MY_TRACE, (T_CALLED("_nc_mouse_inline(%p)"), (void *) sp));
if (sp->_mouse_type == M_XTERM) {
switch (sp->_mouse_format) {
@@ -1380,7 +1385,7 @@ _nc_mouse_inline(SCREEN *sp)
(long) IndexEV(sp, eventp)));
/* bump the next-free pointer into the circular list */
- sp->_mouse_eventp = NEXT(eventp);
+ sp->_mouse_writep = NEXT(eventp);
if (!result) {
/* If this event is from a wheel-mouse, treat it like position
@@ -1400,11 +1405,11 @@ _nc_mouse_inline(SCREEN *sp)
}
}
- return (result);
+ returnCode(result);
}
static void
-mouse_activate(SCREEN *sp, int on)
+mouse_activate(SCREEN *sp, bool on)
{
T((T_CALLED("mouse_activate(%p,%s)"),
(void *) SP_PARM, on ? "on" : "off"));
@@ -1422,7 +1427,7 @@ mouse_activate(SCREEN *sp, int on)
#if NCURSES_EXT_FUNCS
NCURSES_SP_NAME(keyok) (NCURSES_SP_ARGx KEY_MOUSE, on);
#endif
- enable_xterm_mouse(sp, 1);
+ enable_xterm_mouse(sp, TRUE);
break;
#if USE_GPM_SUPPORT
case M_GPM:
@@ -1438,7 +1443,7 @@ mouse_activate(SCREEN *sp, int on)
sp->_mouse_active = TRUE;
break;
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
case M_TERM_DRIVER:
enable_win32_mouse(sp, TRUE);
break;
@@ -1462,7 +1467,7 @@ mouse_activate(SCREEN *sp, int on)
switch (sp->_mouse_type) {
case M_XTERM:
- enable_xterm_mouse(sp, 0);
+ enable_xterm_mouse(sp, FALSE);
break;
#if USE_GPM_SUPPORT
case M_GPM:
@@ -1475,7 +1480,7 @@ mouse_activate(SCREEN *sp, int on)
sp->_mouse_active = FALSE;
break;
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
case M_TERM_DRIVER:
enable_win32_mouse(sp, FALSE);
break;
@@ -1501,7 +1506,7 @@ static bool
_nc_mouse_parse(SCREEN *sp, int runcount)
/* parse a run of atomic mouse events into a gesture */
{
- MEVENT *eventp = sp->_mouse_eventp;
+ MEVENT *eventp = sp->_mouse_writep;
MEVENT *next, *ep;
MEVENT *first_valid = NULL;
MEVENT *first_invalid = NULL;
@@ -1510,7 +1515,14 @@ _nc_mouse_parse(SCREEN *sp, int runcount)
bool merge;
bool endLoop;
- TR(MY_TRACE, ("_nc_mouse_parse(%d) called", runcount));
+ TR(MY_TRACE, (T_CALLED("_nc_mouse_parse(%d)"), runcount));
+
+ if (!sp->_maxclick
+ && sp->_mouse_readp != NULL
+ && ValidEvent(sp->_mouse_readp)
+ && ((sp->_mouse_readp->bstate & sp->_mouse_mask) != 0)) {
+ returnCode(1);
+ }
/*
* When we enter this routine, the event list next-free pointer
@@ -1723,7 +1735,7 @@ _nc_mouse_parse(SCREEN *sp, int runcount)
if (first_invalid == NULL) {
first_invalid = eventp;
}
- sp->_mouse_eventp = first_invalid;
+ sp->_mouse_writep = first_invalid;
#ifdef TRACE
if (first_valid != NULL) {
@@ -1746,7 +1758,7 @@ _nc_mouse_parse(SCREEN *sp, int runcount)
/* after all this, do we have a valid event? */
ep = PREV(first_invalid);
- return ValidEvent(ep) && ((ep->bstate & sp->_mouse_mask) != 0);
+ returnCode(ValidEvent(ep) && ((ep->bstate & sp->_mouse_mask) != 0));
}
static void
@@ -1772,7 +1784,7 @@ _nc_mouse_wrap(SCREEN *sp)
mouse_activate(sp, FALSE);
break;
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
case M_TERM_DRIVER:
mouse_activate(sp, FALSE);
break;
@@ -1809,7 +1821,7 @@ _nc_mouse_resume(SCREEN *sp)
break;
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
case M_TERM_DRIVER:
mouse_activate(sp, TRUE);
break;
@@ -1830,36 +1842,34 @@ NCURSES_EXPORT(int)
NCURSES_SP_NAME(getmouse) (NCURSES_SP_DCLx MEVENT * aevent)
{
int result = ERR;
- MEVENT *eventp;
+ MEVENT *readp;
T((T_CALLED("getmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent));
- if ((aevent != 0) &&
- (SP_PARM != 0) &&
+ if ((aevent != NULL) &&
+ (SP_PARM != NULL) &&
(SP_PARM->_mouse_type != M_NONE) &&
- (eventp = SP_PARM->_mouse_eventp) != 0) {
- /* compute the current-event pointer */
- MEVENT *prev = PREV(eventp);
-
+ (readp = SP_PARM->_mouse_readp) != NULL) {
/*
* Discard events not matching mask (there could be still some if
* _nc_mouse_parse was not called, e.g., when _nc_mouse_inline returns
* false).
*/
- while (ValidEvent(prev) && (!(prev->bstate & SP_PARM->_mouse_mask2))) {
- Invalidate(prev);
- prev = PREV(prev);
+ while (readp != SP_PARM->_mouse_writep &&
+ (!ValidEvent(readp) || !(readp->bstate & SP_PARM->_mouse_mask2))) {
+ Invalidate(readp);
+ readp = NEXT(readp);
}
- if (ValidEvent(prev)) {
+ if (readp != SP_PARM->_mouse_writep && ValidEvent(readp)) {
/* copy the event we find there */
- *aevent = *prev;
+ *aevent = *readp;
TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
- _nc_tracemouse(SP_PARM, prev),
- (long) IndexEV(SP_PARM, prev)));
+ _nc_tracemouse(SP_PARM, readp),
+ (long) IndexEV(SP_PARM, readp)));
- Invalidate(prev); /* so the queue slot becomes free */
- SP_PARM->_mouse_eventp = prev;
+ Invalidate(readp); /* so the queue slot becomes free */
+ SP_PARM->_mouse_readp = NEXT(readp);
result = OK;
} else {
/* Reset the provided event */
@@ -1890,15 +1900,15 @@ NCURSES_SP_NAME(ungetmouse) (NCURSES_SP_DCLx MEVENT * aevent)
T((T_CALLED("ungetmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent));
- if (aevent != 0 &&
- SP_PARM != 0 &&
- (eventp = SP_PARM->_mouse_eventp) != 0) {
+ if (aevent != NULL &&
+ SP_PARM != NULL &&
+ (eventp = SP_PARM->_mouse_writep) != NULL) {
/* stick the given event in the next-free slot */
*eventp = *aevent;
/* bump the next-free pointer into the circular list */
- SP_PARM->_mouse_eventp = NEXT(eventp);
+ SP_PARM->_mouse_writep = NEXT(eventp);
/* push back the notification event on the keyboard queue */
result = NCURSES_SP_NAME(ungetch) (NCURSES_SP_ARGx KEY_MOUSE);
@@ -1926,7 +1936,7 @@ NCURSES_SP_NAME(mousemask) (NCURSES_SP_DCLx mmask_t newmask, mmask_t * oldmask)
(unsigned long) newmask,
(void *) oldmask));
- if (SP_PARM != 0) {
+ if (SP_PARM != NULL) {
if (oldmask)
*oldmask = SP_PARM->_mouse_mask;
@@ -1988,7 +1998,7 @@ wenclose(const WINDOW *win, int y, int x)
T((T_CALLED("wenclose(%p,%d,%d)"), (const void *) win, y, x));
- if (win != 0) {
+ if (win != NULL) {
y -= win->_yoffset;
if (IS_PAD(win)) {
if (win->_pad._pad_y >= 0 &&
@@ -2020,7 +2030,7 @@ NCURSES_SP_NAME(mouseinterval) (NCURSES_SP_DCLx int maxclick)
T((T_CALLED("mouseinterval(%p,%d)"), (void *) SP_PARM, maxclick));
- if (SP_PARM != 0) {
+ if (SP_PARM != NULL) {
oldval = SP_PARM->_maxclick;
if (maxclick >= 0)
SP_PARM->_maxclick = maxclick;
@@ -2042,9 +2052,9 @@ mouseinterval(int maxclick)
/* This may be used by other routines to ask for the existence of mouse
support */
NCURSES_EXPORT(bool)
-_nc_has_mouse(SCREEN *sp)
+_nc_has_mouse(const SCREEN *sp)
{
- return (((0 == sp) || (sp->_mouse_type == M_NONE)) ? FALSE : TRUE);
+ return (((NULL == sp) || (sp->_mouse_type == M_NONE)) ? FALSE : TRUE);
}
NCURSES_EXPORT(bool)
diff --git a/ncurses/base/lib_mvwin.c b/ncurses/base/lib_mvwin.c
index fca014efeb9a..66421971a7dd 100644
--- a/ncurses/base/lib_mvwin.c
+++ b/ncurses/base/lib_mvwin.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2021,2024 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,13 +43,13 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_mvwin.c,v 1.20 2021/10/23 18:57:41 tom Exp $")
+MODULE_ID("$Id: lib_mvwin.c,v 1.21 2024/07/27 19:23:59 tom Exp $")
NCURSES_EXPORT(int)
mvwin(WINDOW *win, int by, int bx)
{
#if NCURSES_SP_FUNCS
- SCREEN *sp = _nc_screen_of(win);
+ const SCREEN *sp = _nc_screen_of(win);
#endif
T((T_CALLED("mvwin(%p,%d,%d)"), (void *) win, by, bx));
diff --git a/ncurses/base/lib_newterm.c b/ncurses/base/lib_newterm.c
index 15d05a31b583..91f67c2ff98e 100644
--- a/ncurses/base/lib_newterm.c
+++ b/ncurses/base/lib_newterm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2022 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -49,9 +49,9 @@
#include <tic.h>
-MODULE_ID("$Id: lib_newterm.c,v 1.104 2022/07/09 18:58:58 tom Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.110 2025/12/27 12:28:45 tom Exp $")
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
#define NumLabels InfoOf(SP_PARM).numlabels
#else
#define NumLabels num_labels
@@ -88,7 +88,7 @@ _nc_initscr(NCURSES_SP_DCL0)
buf.c_oflag &= (unsigned) ~(ONLCR);
#elif HAVE_SGTTY_H
buf.sg_flags &= ~(ECHO | CRMOD);
-#elif defined(EXP_WIN32_DRIVER)
+#elif USE_NAMED_PIPES
buf.dwFlagIn = CONMODE_IN_DEFAULT;
buf.dwFlagOut = CONMODE_OUT_DEFAULT | VT_FLAG_OUT;
if (WINCONSOLE.isTermInfoConsole) {
@@ -175,12 +175,12 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
FILE *ifp)
{
int errret;
- SCREEN *result = 0;
+ SCREEN *result = NULL;
SCREEN *current;
TERMINAL *its_term;
FILE *_ofp = ofp ? ofp : stdout;
FILE *_ifp = ifp ? ifp : stdin;
- TERMINAL *new_term = 0;
+ TERMINAL *new_term = NULL;
START_TRACE();
T((T_CALLED("newterm(%p, \"%s\", %p,%p)"),
@@ -190,8 +190,8 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
(void *) ifp));
#if NCURSES_SP_FUNCS
- assert(SP_PARM != 0);
- if (SP_PARM == 0)
+ assert(SP_PARM != NULL);
+ if (SP_PARM == NULL)
returnSP(SP_PARM);
#endif
@@ -199,9 +199,9 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
_nc_lock_global(curses);
current = CURRENT_SCREEN;
- its_term = (current ? current->_term : 0);
+ its_term = (current ? current->_term : NULL);
-#if defined(EXP_WIN32_DRIVER)
+#if USE_NAMED_PIPES
_setmode(fileno(_ifp), _O_BINARY);
_setmode(fileno(_ofp), _O_BINARY);
#endif
@@ -212,11 +212,11 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
TINFO_SETUP_TERM(&new_term, name,
fileno(_ofp), &errret, FALSE) != ERR) {
int slk_format;
- int filter_mode;
+ bool filter_mode;
- _nc_set_screen(0);
-#ifdef USE_TERM_DRIVER
- assert(new_term != 0);
+ _nc_set_screen(NULL);
+#if USE_TERM_DRIVER
+ assert(new_term != NULL);
#endif
#if NCURSES_SP_FUNCS
@@ -241,19 +241,19 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
filter_mode,
slk_format) == ERR) {
_nc_set_screen(current);
- result = 0;
+ result = NULL;
} else {
int value;
int cols;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *TCB;
#elif !NCURSES_SP_FUNCS
_nc_set_screen(CURRENT_SCREEN);
#endif
- assert(SP_PARM != 0);
+ assert(SP_PARM != NULL);
cols = *(ptrCols(SP_PARM));
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
_nc_set_screen(SP_PARM);
TCB = (TERMINAL_CONTROL_BLOCK *) new_term;
TCB->csp = SP_PARM;
@@ -271,7 +271,7 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
if (current)
current->_term = its_term;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
SP_PARM->_term = new_term;
#else
new_term = SP_PARM->_term;
@@ -279,6 +279,7 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
/* allow user to set maximum escape delay from the environment */
if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
+ value = Min(value, MAX_DELAY_MSECS);
#if NCURSES_EXT_FUNCS
NCURSES_SP_NAME(set_escdelay) (NCURSES_SP_ARGx value);
#else
@@ -300,7 +301,7 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
SP_PARM->_use_meta = FALSE;
#endif
SP_PARM->_endwin = ewInitial;
-#ifndef USE_TERM_DRIVER
+#if !USE_TERM_DRIVER
/*
* Check whether we can optimize scrolling under dumb terminals in
* case we do not have any of these capabilities, scrolling
@@ -317,10 +318,10 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); /* sets a field in the screen structure */
- SP_PARM->_keytry = 0;
+ SP_PARM->_keytry = NULL;
/* compute movement costs so we can do better move optimization */
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
TCBOf(SP_PARM)->drv->td_scinit(SP_PARM);
#else /* ! USE_TERM_DRIVER */
/*
@@ -332,7 +333,7 @@ NCURSES_SP_NAME(newterm) (NCURSES_SP_DCLx
* properly if we remove rmso or rmul. Curses applications
* shouldn't be looking at this detail.
*/
-#define SGR0_TEST(mode) (mode != 0) && (exit_attribute_mode == 0 || strcmp(mode, exit_attribute_mode))
+#define SGR0_TEST(mode) (mode != NULL) && (exit_attribute_mode == NULL || strcmp(mode, exit_attribute_mode))
SP_PARM->_use_rmso = SGR0_TEST(exit_standout_mode);
SP_PARM->_use_rmul = SGR0_TEST(exit_underline_mode);
#if USE_ITALIC
diff --git a/ncurses/base/lib_newwin.c b/ncurses/base/lib_newwin.c
index a6723197c093..3085453d9a50 100644
--- a/ncurses/base/lib_newwin.c
+++ b/ncurses/base/lib_newwin.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2021,2024 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -44,18 +44,18 @@
#include <curses.priv.h>
#include <stddef.h>
-MODULE_ID("$Id: lib_newwin.c,v 1.76 2021/10/23 18:53:38 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.79 2024/12/14 23:50:18 tom Exp $")
#define window_is(name) ((sp)->_##name == win)
#if USE_REENTRANT
#define remove_window(name) \
- sp->_##name = 0
+ sp->_##name = NULL
#else
#define remove_window(name) \
- sp->_##name = 0; \
+ sp->_##name = NULL; \
if (win == name) \
- name = 0
+ name = NULL
#endif
static void
@@ -64,7 +64,7 @@ remove_window_from_screen(WINDOW *win)
SCREEN *sp;
#ifdef USE_SP_WINDOWLIST
- if ((sp = _nc_screen_of(win)) != 0) {
+ if ((sp = _nc_screen_of(win)) != NULL) {
if (window_is(curscr)) {
remove_window(curscr);
} else if (window_is(stdscr)) {
@@ -99,17 +99,17 @@ _nc_freewin(WINDOW *win)
T((T_CALLED("_nc_freewin(%p)"), (void *) win));
- if (win != 0) {
+ if (win != NULL) {
if (_nc_nonsp_try_global(curses) == 0) {
WINDOWLIST *p, *q;
- q = 0;
+ q = NULL;
for (each_window(sp, p)) {
if (&(p->win) == win) {
remove_window_from_screen(win);
- if (q == 0)
+ if (q == NULL)
WindowList(sp) = p->next;
else
q->next = p->next;
@@ -150,8 +150,8 @@ NCURSES_SP_NAME(newwin) (NCURSES_SP_DCLx
|| begx < 0
|| num_lines < 0
|| num_columns < 0
- || SP_PARM == 0)
- returnWin(0);
+ || SP_PARM == NULL)
+ returnWin(NULL);
if (num_lines == 0)
num_lines = SP_PARM->_lines_avail - begy;
@@ -160,14 +160,14 @@ NCURSES_SP_NAME(newwin) (NCURSES_SP_DCLx
win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx
num_lines, num_columns, begy, begx, 0);
- if (win == 0)
- returnWin(0);
+ if (win == NULL)
+ returnWin(NULL);
for (i = 0; i < num_lines; i++) {
win->_line[i].text = typeCalloc(NCURSES_CH_T, (unsigned) num_columns);
- if (win->_line[i].text == 0) {
+ if (win->_line[i].text == NULL) {
(void) _nc_freewin(win);
- returnWin(0);
+ returnWin(NULL);
}
for (ptr = win->_line[i].text;
ptr < win->_line[i].text + num_columns;
@@ -207,11 +207,14 @@ derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
/*
* make sure window fits inside the original one
*/
- if (begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0)
- returnWin(0);
- if (begy + num_lines > orig->_maxy + 1
+ if (begy < 0
+ || begx < 0
+ || orig == NULL
+ || num_lines < 0
+ || num_columns < 0
+ || begy + num_lines > orig->_maxy + 1
|| begx + num_columns > orig->_maxx + 1)
- returnWin(0);
+ returnWin(NULL);
if (num_lines == 0)
num_lines = orig->_maxy + 1 - begy;
@@ -225,8 +228,8 @@ derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx num_lines, num_columns,
orig->_begy + begy,
orig->_begx + begx, flags);
- if (win == 0)
- returnWin(0);
+ if (win == NULL)
+ returnWin(NULL);
win->_pary = begy;
win->_parx = begx;
@@ -244,10 +247,10 @@ derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
NCURSES_EXPORT(WINDOW *)
subwin(WINDOW *w, int l, int c, int y, int x)
{
- WINDOW *result = 0;
+ WINDOW *result = NULL;
T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), (void *) w, l, c, y, x));
- if (w != 0) {
+ if (w != NULL) {
T(("parent has begy = %ld, begx = %ld", (long) w->_begy, (long) w->_begx));
result = derwin(w, l, c, y - w->_begy, x - w->_begx);
@@ -255,13 +258,6 @@ subwin(WINDOW *w, int l, int c, int y, int x)
returnWin(result);
}
-static bool
-dimension_limit(int value)
-{
- NCURSES_SIZE_T test = (NCURSES_SIZE_T) value;
- return (test == value && value > 0);
-}
-
NCURSES_EXPORT(WINDOW *)
NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_DCLx
int num_lines,
@@ -278,20 +274,20 @@ NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_DCLx
T((T_CALLED("_nc_makenew(%p,%d,%d,%d,%d)"),
(void *) SP_PARM, num_lines, num_columns, begy, begx));
- if (SP_PARM == 0)
- returnWin(0);
+ if (SP_PARM == NULL)
+ returnWin(NULL);
- if (!dimension_limit(num_lines) || !dimension_limit(num_columns))
- returnWin(0);
+ if (!OK_DIMENSION(num_lines) || !OK_DIMENSION(num_columns))
+ returnWin(NULL);
- if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
- returnWin(0);
+ if ((wp = typeCalloc(WINDOWLIST, 1)) == NULL)
+ returnWin(NULL);
win = &(wp->win);
- if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == 0) {
+ if ((win->_line = typeCalloc(struct ldat, ((unsigned) num_lines))) == NULL) {
free(wp);
- returnWin(0);
+ returnWin(NULL);
}
_nc_nonsp_lock_global(curses);
@@ -322,7 +318,7 @@ NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_DCLx
win->_sync = 0;
win->_parx = -1;
win->_pary = -1;
- win->_parent = 0;
+ win->_parent = NULL;
win->_regtop = 0;
win->_regbottom = (NCURSES_SIZE_T) (num_lines - 1);
@@ -389,18 +385,18 @@ NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_DCLx
NCURSES_EXPORT(WINDOW *)
_nc_curscr_of(SCREEN *sp)
{
- return (sp == 0) ? NULL : CurScreen(sp);
+ return (sp == NULL) ? NULL : CurScreen(sp);
}
NCURSES_EXPORT(WINDOW *)
_nc_newscr_of(SCREEN *sp)
{
- return (sp == 0) ? NULL : NewScreen(sp);
+ return (sp == NULL) ? NULL : NewScreen(sp);
}
NCURSES_EXPORT(WINDOW *)
_nc_stdscr_of(SCREEN *sp)
{
- return (sp == 0) ? NULL : StdScreen(sp);
+ return (sp == NULL) ? NULL : StdScreen(sp);
}
#endif
diff --git a/ncurses/base/lib_nl.c b/ncurses/base/lib_nl.c
index 417b257d0399..f02d3f1baac9 100644
--- a/ncurses/base/lib_nl.c
+++ b/ncurses/base/lib_nl.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2000,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -45,17 +45,13 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_nl.c,v 1.14 2023/04/29 18:51:49 tom Exp $")
-
-#ifdef __EMX__
-#include <io.h>
-#endif
+MODULE_ID("$Id: lib_nl.c,v 1.16 2025/06/21 14:27:02 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(nl) (NCURSES_SP_DCL0)
{
T((T_CALLED("nl(%p)"), (void *) SP_PARM));
- if (0 == SP_PARM)
+ if (NULL == SP_PARM)
returnCode(ERR);
IsNl(SP_PARM) = TRUE;
#ifdef __EMX__
@@ -77,7 +73,7 @@ NCURSES_EXPORT(int)
NCURSES_SP_NAME(nonl) (NCURSES_SP_DCL0)
{
T((T_CALLED("nonl(%p)"), (void *) SP_PARM));
- if (0 == SP_PARM)
+ if (NULL == SP_PARM)
returnCode(ERR);
IsNl(SP_PARM) = FALSE;
#ifdef __EMX__
diff --git a/ncurses/base/lib_overlay.c b/ncurses/base/lib_overlay.c
index 6d21c7617047..6ab8cf059f92 100644
--- a/ncurses/base/lib_overlay.c
+++ b/ncurses/base/lib_overlay.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 1998-2013,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_overlay.c,v 1.34 2023/09/16 16:39:07 tom Exp $")
+MODULE_ID("$Id: lib_overlay.c,v 1.35 2024/12/07 20:03:37 tom Exp $")
static int
overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
@@ -50,7 +50,7 @@ overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
T((T_CALLED("overlap(%p,%p,%d)"), (const void *) src, (void *) dst, flag));
- if (src != 0 && dst != 0) {
+ if (src != NULL && dst != NULL) {
int sx1, sy1, sx2, sy2;
int dx1, dy1, dx2, dy2;
@@ -146,8 +146,8 @@ copywin(const WINDOW *src, WINDOW *dst,
dminrow, dmincol,
dmaxrow, dmaxcol, over));
- if (src != 0
- && dst != 0
+ if (src != NULL
+ && dst != NULL
&& dmaxrow >= dminrow
&& dmaxcol >= dmincol) {
attr_t bk;
diff --git a/ncurses/base/lib_pad.c b/ncurses/base/lib_pad.c
index d4bd7f111bef..c5bfd6053a50 100644
--- a/ncurses/base/lib_pad.c
+++ b/ncurses/base/lib_pad.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2021,2024 Thomas E. Dickey *
* Copyright 1998-2010,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,7 +43,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_pad.c,v 1.50 2021/10/23 22:57:27 tom Exp $")
+MODULE_ID("$Id: lib_pad.c,v 1.52 2024/12/07 17:44:59 tom Exp $")
NCURSES_EXPORT(WINDOW *)
NCURSES_SP_NAME(newpad) (NCURSES_SP_DCLx int l, int c)
@@ -55,17 +55,17 @@ NCURSES_SP_NAME(newpad) (NCURSES_SP_DCLx int l, int c)
T((T_CALLED("newpad(%p,%d, %d)"), (void *) SP_PARM, l, c));
if (l <= 0 || c <= 0)
- returnWin(0);
+ returnWin(NULL);
win = NCURSES_SP_NAME(_nc_makenew) (NCURSES_SP_ARGx l, c, 0, 0, _ISPAD);
if (win == NULL)
- returnWin(0);
+ returnWin(NULL);
for (i = 0; i < l; i++) {
if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX);
- if ((win->_line[i].text = typeCalloc(NCURSES_CH_T, ((size_t) c))) == 0) {
+ if ((win->_line[i].text = typeCalloc(NCURSES_CH_T, ((size_t) c))) == NULL) {
(void) _nc_freewin(win);
- returnWin(0);
+ returnWin(NULL);
}
for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; ptr++)
SetChar(*ptr, BLANK_TEXT, BLANK_ATTR);
@@ -92,7 +92,7 @@ subpad(WINDOW *orig, int l, int c, int begy, int begx)
if (orig) {
if (!IS_PAD(orig)
|| ((win = derwin(orig, l, c, begy, begx)) == NULL))
- returnWin(0);
+ returnWin(NULL);
}
returnWin(win);
}
@@ -143,7 +143,7 @@ pnoutrefresh(WINDOW *win,
T((T_CALLED("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)"),
(void *) win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));
- if (win == 0)
+ if (win == NULL)
returnCode(ERR);
if (!IS_PAD(win))
@@ -197,8 +197,8 @@ pnoutrefresh(WINDOW *win,
#endif /* TRACE */
#if USE_SCROLL_HINTS
if (win->_pad._pad_y >= 0) {
- displaced = pminrow - win->_pad._pad_y
- - (sminrow - win->_pad._pad_top);
+ displaced = ((pminrow - win->_pad._pad_y) -
+ (sminrow - win->_pad._pad_top));
T(("pad being shifted by %d line(s)", displaced));
} else
displaced = 0;
@@ -331,7 +331,7 @@ pechochar(WINDOW *pad, const chtype ch)
{
T((T_CALLED("pechochar(%p, %s)"), (void *) pad, _tracechtype(ch)));
- if (pad == 0)
+ if (pad == NULL)
returnCode(ERR);
if (!IS_PAD(pad))
diff --git a/ncurses/base/lib_printw.c b/ncurses/base/lib_printw.c
index d901b727a91c..fa1a153b3981 100644
--- a/ncurses/base/lib_printw.c
+++ b/ncurses/base/lib_printw.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2024 Thomas E. Dickey *
* Copyright 1998-2012,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_printw.c,v 1.28 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_printw.c,v 1.30 2024/12/07 17:44:59 tom Exp $")
NCURSES_EXPORT(int)
printw(const char *fmt, ...)
@@ -133,7 +133,7 @@ mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
NCURSES_EXPORT(int)
vwprintw(WINDOW *win, const char *fmt, va_list argp)
{
- char *buf;
+ const char *buf;
int code = ERR;
#if NCURSES_SP_FUNCS
SCREEN *sp = _nc_screen_of(win);
@@ -142,7 +142,7 @@ vwprintw(WINDOW *win, const char *fmt, va_list argp)
T((T_CALLED("vwprintw(%p,%s,va_list)"), (void *) win, _nc_visbuf(fmt)));
buf = NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_ARGx fmt, argp);
- if (buf != 0) {
+ if (buf != NULL) {
code = waddstr(win, buf);
}
returnCode(code);
@@ -151,7 +151,7 @@ vwprintw(WINDOW *win, const char *fmt, va_list argp)
NCURSES_EXPORT(int)
vw_printw(WINDOW *win, const char *fmt, va_list argp)
{
- char *buf;
+ const char *buf;
int code = ERR;
#if NCURSES_SP_FUNCS
SCREEN *sp = _nc_screen_of(win);
@@ -160,7 +160,7 @@ vw_printw(WINDOW *win, const char *fmt, va_list argp)
T((T_CALLED("vw_printw(%p,%s,va_list)"), (void *) win, _nc_visbuf(fmt)));
buf = NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_ARGx fmt, argp);
- if (buf != 0) {
+ if (buf != NULL) {
code = waddstr(win, buf);
}
returnCode(code);
diff --git a/ncurses/base/lib_redrawln.c b/ncurses/base/lib_redrawln.c
index c99d6992a2a9..99c02490d775 100644
--- a/ncurses/base/lib_redrawln.c
+++ b/ncurses/base/lib_redrawln.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_redrawln.c,v 1.18 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_redrawln.c,v 1.19 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(int)
wredrawln(WINDOW *win, int beg, int num)
@@ -52,7 +52,7 @@ wredrawln(WINDOW *win, int beg, int num)
T((T_CALLED("wredrawln(%p,%d,%d)"), (void *) win, beg, num));
- if (win == 0)
+ if (win == NULL)
returnCode(ERR);
sp = _nc_screen_of(win);
diff --git a/ncurses/base/lib_refresh.c b/ncurses/base/lib_refresh.c
index bcaa4624b8a9..e43e28d6bda9 100644
--- a/ncurses/base/lib_refresh.c
+++ b/ncurses/base/lib_refresh.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2021,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 1998-2010,2011 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,7 +43,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_refresh.c,v 1.48 2023/05/27 20:13:10 tom Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.49 2024/09/22 20:17:40 tom Exp $")
NCURSES_EXPORT(int)
wrefresh(WINDOW *win)
@@ -55,7 +55,7 @@ wrefresh(WINDOW *win)
T((T_CALLED("wrefresh(%p)"), (void *) win));
- if (win == 0) {
+ if (SP_PARM == NULL || win == NULL) {
code = ERR;
} else if (win == CurScreen(SP_PARM)) {
CurScreen(SP_PARM)->_clear = TRUE;
@@ -92,7 +92,7 @@ wnoutrefresh(WINDOW *win)
T((T_CALLED("wnoutrefresh(%p)"), (void *) win));
- if (win == NULL)
+ if (SP_PARM == NULL || win == NULL)
returnCode(ERR);
/*
diff --git a/ncurses/base/lib_restart.c b/ncurses/base/lib_restart.c
index 0c61cb7ea667..4d5b0c127dbd 100644
--- a/ncurses/base/lib_restart.c
+++ b/ncurses/base/lib_restart.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2012,2015 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -42,7 +42,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_restart.c,v 1.18 2023/04/29 19:01:25 tom Exp $")
+MODULE_ID("$Id: lib_restart.c,v 1.21 2025/12/27 12:41:23 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx
@@ -51,8 +51,8 @@ NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx
int *errret)
{
int result;
-#ifdef USE_TERM_DRIVER
- TERMINAL *new_term = 0;
+#if USE_TERM_DRIVER
+ TERMINAL *new_term = NULL;
#endif
START_TRACE();
@@ -64,10 +64,10 @@ NCURSES_SP_NAME(restartterm) (NCURSES_SP_DCLx
if (TINFO_SETUP_TERM(&new_term, termp, filenum, errret, FALSE) != OK) {
result = ERR;
- } else if (SP_PARM != 0) {
+ } else if (SP_PARM != NULL) {
TTY_FLAGS save_flags = SP_PARM->_tty_flags;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
SP_PARM->_term = new_term;
#endif
if (save_flags._echo) {
diff --git a/ncurses/base/lib_screen.c b/ncurses/base/lib_screen.c
index e2647b54e2eb..26708eb59c0b 100644
--- a/ncurses/base/lib_screen.c
+++ b/ncurses/base/lib_screen.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2021,2023 Thomas E. Dickey *
+ * Copyright 2019-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 *
@@ -42,7 +42,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_screen.c,v 1.105 2023/04/28 20:58:54 tom Exp $")
+MODULE_ID("$Id: lib_screen.c,v 1.113 2025/12/27 12:28:45 tom Exp $")
#define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */
@@ -58,7 +58,7 @@ MODULE_ID("$Id: lib_screen.c,v 1.105 2023/04/28 20:58:54 tom Exp $")
#define ARG_SLIMIT(name) /* nothing */
#endif
-#define CUR_SLIMIT _nc_SLIMIT(limit - (size_t) (target - base))
+#define CUR_SLIMIT _nc_SLIMIT(limit - (size_t) (target + 1 - base))
#define TOP_SLIMIT _nc_SLIMIT(sizeof(buffer))
/*
@@ -172,7 +172,7 @@ read_txt(FILE *fp)
char *result = malloc(limit);
char *buffer;
- if (result != 0) {
+ if (result != NULL) {
int ch = 0;
size_t used = 0;
@@ -182,9 +182,9 @@ read_txt(FILE *fp)
if (used + 2 >= limit) {
limit += 1024;
buffer = realloc(result, limit);
- if (buffer == 0) {
+ if (buffer == NULL) {
free(result);
- result = 0;
+ result = NULL;
break;
}
result = buffer;
@@ -201,7 +201,7 @@ read_txt(FILE *fp)
TR(TRACE_IEVENT, ("READ:%s", result));
} else if (used == 0) {
free(result);
- result = 0;
+ result = NULL;
}
}
return result;
@@ -222,7 +222,6 @@ decode_attr(char *source, attr_t *target, int *color)
source++;
found = FALSE;
} else if (found) {
- size_t n;
char *next = source;
if (source[0] == GUTTER) {
@@ -241,6 +240,8 @@ decode_attr(char *source, attr_t *target, int *color)
*target |= pair;
*color = value;
} else {
+ size_t n;
+
while (isalnum(UChar(*next))) {
++next;
}
@@ -304,8 +305,8 @@ decode_char(char *source, int *target)
if (limit) {
*target = 0;
while (limit-- > 0) {
- char *find = strchr(digits, *source++);
- int ch = (find != 0) ? (int) (find - digits) : -1;
+ const char *find = strchr(digits, *source++);
+ int ch = (find != NULL) ? (int) (find - digits) : -1;
*target *= base;
if (ch >= 0 && ch < base) {
*target += ch;
@@ -337,7 +338,7 @@ decode_chtype(char *source, chtype fillin, chtype *target)
#if NCURSES_WIDECHAR
static char *
-decode_cchar(char *source, cchar_t *fillin, cchar_t *target)
+decode_cchar(char *source, const cchar_t *fillin, cchar_t *target)
{
int color;
attr_t attr = fillin->attr;
@@ -382,18 +383,18 @@ read_win(WINDOW *win, FILE *fp)
memset(win, 0, sizeof(WINDOW));
for (;;) {
- char *name;
+ const char *name;
char *value;
char *txt = read_txt(fp);
- if (txt == 0)
+ if (txt == NULL)
break;
if (!strcmp(txt, "rows:")) {
free(txt);
code = OK;
break;
}
- if ((value = strchr(txt, '=')) == 0) {
+ if ((value = strchr(txt, '=')) == NULL) {
free(txt);
continue;
}
@@ -505,8 +506,8 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
T((T_CALLED("getwin(%p)"), (void *) filep));
- if (filep == 0) {
- returnWin(0);
+ if (filep == NULL) {
+ returnWin(NULL);
}
/*
@@ -514,7 +515,7 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
* screen-dump, or new-format.
*/
if (read_block(&tmp, (size_t) 4, filep) < 0) {
- returnWin(0);
+ returnWin(NULL);
}
/*
* If this is a new-format file, and we do not support it, give up.
@@ -523,9 +524,9 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
#if NCURSES_EXT_PUTWIN
if (read_win(&tmp, filep) < 0)
#endif
- returnWin(0);
+ returnWin(NULL);
} else if (read_block(((char *) &tmp) + 4, sizeof(WINDOW) - 4, filep) < 0) {
- returnWin(0);
+ returnWin(NULL);
} else {
old_format = TRUE;
}
@@ -537,7 +538,7 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
tmp._maxy > MAX_SIZE ||
tmp._maxx == 0 ||
tmp._maxx > MAX_SIZE) {
- returnWin(0);
+ returnWin(NULL);
}
if (IS_PAD(&tmp)) {
@@ -555,7 +556,7 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
* fields, because the window hierarchy within which they
* made sense is probably gone.
*/
- if (nwin != 0) {
+ if (nwin != NULL) {
int n;
size_t linesize = sizeof(NCURSES_CH_T) * (size_t) (tmp._maxx + 1);
@@ -593,13 +594,13 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
for (n = 0; n <= nwin->_maxy; n++) {
if (read_block(nwin->_line[n].text, linesize, filep) < 0) {
delwin(nwin);
- returnWin(0);
+ returnWin(NULL);
}
}
}
#if NCURSES_EXT_PUTWIN
else {
- char *txt = 0;
+ char *txt = NULL;
bool success = TRUE;
NCURSES_CH_T prior = blank;
@@ -608,7 +609,7 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
long row;
char *next;
- if ((txt = read_txt(filep)) == 0) {
+ if ((txt = read_txt(filep)) == NULL) {
T(("...failed to read string for row %d", n + 1));
success = FALSE;
break;
@@ -627,13 +628,13 @@ NCURSES_SP_NAME(getwin) (NCURSES_SP_DCLx FILE *filep)
break;
}
free(txt);
- txt = 0;
+ txt = NULL;
}
if (!success) {
free(txt);
delwin(nwin);
- returnWin(0);
+ returnWin(NULL);
}
}
#endif
@@ -797,7 +798,7 @@ putwin(WINDOW *win, FILE *filep)
T((T_CALLED("putwin(%p,%p)"), (void *) win, (void *) filep));
#if NCURSES_EXT_PUTWIN
- if (win != 0) {
+ if (win != NULL) {
const char *version = curses_version();
char buffer[1024];
NCURSES_CH_T last_cell;
@@ -916,7 +917,7 @@ putwin(WINDOW *win, FILE *filep)
* ncurses is compiled with wide-character support, and also may depend
* on the version of ncurses, e.g., if the WINDOW structure is extended.
*/
- if (win != 0) {
+ if (win != NULL) {
size_t len = (size_t) (win->_maxx + 1);
int y;
@@ -942,7 +943,7 @@ putwin(WINDOW *win, FILE *filep)
* Replace a window covering the whole screen, i.e., newscr or curscr.
*/
static WINDOW *
-replace_window(WINDOW *target, FILE *source)
+replace_window(const WINDOW *target, FILE *source)
{
WINDOW *result = getwin(source);
#if NCURSES_EXT_FUNCS
@@ -959,26 +960,28 @@ replace_window(WINDOW *target, FILE *source)
}
}
#endif
- delwin(target);
return result;
}
NCURSES_EXPORT(int)
NCURSES_SP_NAME(scr_restore) (NCURSES_SP_DCLx const char *file)
{
- FILE *fp = 0;
+ FILE *fp = NULL;
int code = ERR;
T((T_CALLED("scr_restore(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
- if (_nc_access(file, R_OK) >= 0
- && (fp = safe_fopen(file, BIN_R)) != 0) {
- NewScreen(SP_PARM) = replace_window(NewScreen(SP_PARM), fp);
+ if (SP_PARM != NULL
+ && _nc_access(file, R_OK) >= 0
+ && (fp = safe_fopen(file, BIN_R)) != NULL) {
+ WINDOW *my_newscr = replace_window(NewScreen(SP_PARM), fp);
+ (void) fclose(fp);
+ if (my_newscr != NULL) {
+ delwin(NewScreen(SP_PARM));
+ NewScreen(SP_PARM) = my_newscr;
#if !USE_REENTRANT
- newscr = NewScreen(SP_PARM);
+ newscr = my_newscr;
#endif
- (void) fclose(fp);
- if (NewScreen(SP_PARM) != 0) {
code = OK;
}
}
@@ -997,12 +1000,12 @@ NCURSES_EXPORT(int)
scr_dump(const char *file)
{
int result;
- FILE *fp = 0;
+ FILE *fp = NULL;
T((T_CALLED("scr_dump(%s)"), _nc_visbuf(file)));
if (_nc_access(file, W_OK) < 0
- || (fp = safe_fopen(file, BIN_W)) == 0) {
+ || (fp = safe_fopen(file, BIN_W)) == NULL) {
result = ERR;
} else {
(void) putwin(newscr, fp);
@@ -1019,23 +1022,25 @@ NCURSES_SP_NAME(scr_init) (NCURSES_SP_DCLx const char *file)
T((T_CALLED("scr_init(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
- if (SP_PARM != 0 &&
-#ifdef USE_TERM_DRIVER
+ if (SP_PARM != NULL &&
+#if USE_TERM_DRIVER
InfoOf(SP_PARM).caninit
#else
!(exit_ca_mode && non_rev_rmcup)
#endif
) {
- FILE *fp = 0;
+ FILE *fp = NULL;
if (_nc_access(file, R_OK) >= 0
- && (fp = safe_fopen(file, BIN_R)) != 0) {
- CurScreen(SP_PARM) = replace_window(CurScreen(SP_PARM), fp);
+ && (fp = safe_fopen(file, BIN_R)) != NULL) {
+ WINDOW *my_curscr = replace_window(CurScreen(SP_PARM), fp);
+ (void) fclose(fp);
+ if (my_curscr != NULL) {
+ delwin(CurScreen(SP_PARM));
+ CurScreen(SP_PARM) = my_curscr;
#if !USE_REENTRANT
- curscr = CurScreen(SP_PARM);
+ curscr = my_curscr;
#endif
- (void) fclose(fp);
- if (CurScreen(SP_PARM) != 0) {
code = OK;
}
}
@@ -1058,13 +1063,14 @@ NCURSES_SP_NAME(scr_set) (NCURSES_SP_DCLx const char *file)
T((T_CALLED("scr_set(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));
- if (NCURSES_SP_NAME(scr_init) (NCURSES_SP_ARGx file) == OK) {
+ if (SP_PARM != NULL
+ && NCURSES_SP_NAME(scr_init) (NCURSES_SP_ARGx file) == OK) {
delwin(NewScreen(SP_PARM));
NewScreen(SP_PARM) = dupwin(curscr);
#if !USE_REENTRANT
newscr = NewScreen(SP_PARM);
#endif
- if (NewScreen(SP_PARM) != 0) {
+ if (NewScreen(SP_PARM) != NULL) {
code = OK;
}
}
diff --git a/ncurses/base/lib_set_term.c b/ncurses/base/lib_set_term.c
index 78de859208b6..b6f9e57f5568 100644
--- a/ncurses/base/lib_set_term.c
+++ b/ncurses/base/lib_set_term.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2021,2022 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -57,9 +57,9 @@
#undef CUR
#define CUR SP_TERMTYPE
-MODULE_ID("$Id: lib_set_term.c,v 1.184 2022/12/10 21:34:12 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.199 2025/12/27 12:28:45 tom Exp $")
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
#define MaxColors InfoOf(sp).maxcolors
#define NumLabels InfoOf(sp).numlabels
#else
@@ -81,7 +81,7 @@ set_term(SCREEN *screenp)
_nc_set_screen(screenp);
newSP = screenp;
- if (newSP != 0) {
+ if (newSP != NULL) {
TINFO_SET_CURTERM(newSP, newSP->_term);
#if !USE_REENTRANT
curscr = CurScreen(newSP);
@@ -91,11 +91,11 @@ set_term(SCREEN *screenp)
COLOR_PAIRS = newSP->_pair_count;
#endif
} else {
- TINFO_SET_CURTERM(oldSP, 0);
+ TINFO_SET_CURTERM(oldSP, NULL);
#if !USE_REENTRANT
- curscr = 0;
- newscr = 0;
- stdscr = 0;
+ curscr = NULL;
+ newscr = NULL;
+ stdscr = NULL;
COLORS = 0;
COLOR_PAIRS = 0;
#endif
@@ -110,7 +110,7 @@ set_term(SCREEN *screenp)
static void
_nc_free_keytry(TRIES * kt)
{
- if (kt != 0) {
+ if (kt != NULL) {
_nc_free_keytry(kt->child);
_nc_free_keytry(kt->sibling);
free(kt);
@@ -120,7 +120,7 @@ _nc_free_keytry(TRIES * kt)
static bool
delink_screen(SCREEN *sp)
{
- SCREEN *last = 0;
+ SCREEN *last = NULL;
SCREEN *temp;
bool result = FALSE;
@@ -160,7 +160,7 @@ delscreen(SCREEN *sp)
rop++) {
if (rop->win) {
(void) delwin(rop->win);
- rop->win = 0;
+ rop->win = NULL;
}
}
}
@@ -174,9 +174,9 @@ delscreen(SCREEN *sp)
}
}
- if (sp->_slk != 0) {
+ if (sp->_slk != NULL) {
- if (sp->_slk->ent != 0) {
+ if (sp->_slk->ent != NULL) {
int i;
for (i = 0; i < sp->_slk->labcnt; ++i) {
@@ -186,14 +186,14 @@ delscreen(SCREEN *sp)
free(sp->_slk->ent);
}
free(sp->_slk);
- sp->_slk = 0;
+ sp->_slk = NULL;
}
_nc_free_keytry(sp->_keytry);
- sp->_keytry = 0;
+ sp->_keytry = NULL;
_nc_free_keytry(sp->_key_ok);
- sp->_key_ok = 0;
+ sp->_key_ok = NULL;
FreeIfNeeded(sp->_current_attr);
@@ -217,9 +217,9 @@ delscreen(SCREEN *sp)
}
#if USE_GPM_SUPPORT
#ifdef HAVE_LIBDL
- if (sp->_dlopen_gpm != 0) {
+ if (sp->_dlopen_gpm != NULL) {
dlclose(sp->_dlopen_gpm);
- sp->_dlopen_gpm = 0;
+ sp->_dlopen_gpm = NULL;
}
#endif
#endif /* USE_GPM_SUPPORT */
@@ -232,17 +232,17 @@ delscreen(SCREEN *sp)
*/
if (is_current) {
#if !USE_REENTRANT
- curscr = 0;
- newscr = 0;
- stdscr = 0;
+ curscr = NULL;
+ newscr = NULL;
+ stdscr = NULL;
COLORS = 0;
COLOR_PAIRS = 0;
#endif
- _nc_set_screen(0);
+ _nc_set_screen(NULL);
#if USE_WIDEC_SUPPORT
- if (SP == 0) {
+ if (SP == NULL) {
FreeIfNeeded(_nc_wacs);
- _nc_wacs = 0;
+ _nc_wacs = NULL;
}
#endif
} else {
@@ -303,7 +303,7 @@ extract_fgbg(const char *src, int *result)
}
#endif
-#define ReturnScreenError() do { _nc_set_screen(0); \
+#define ReturnScreenError() do { _nc_set_screen(NULL); \
returnCode(ERR); } while (0)
/* OS-independent screen initializations */
@@ -315,26 +315,29 @@ NCURSES_SP_NAME(_nc_setupscreen) (
int slines,
int scolumns,
FILE *output,
- int filtered,
+ bool filtered,
int slk_format)
{
-#ifndef USE_TERM_DRIVER
+#if !USE_TERM_DRIVER
static const TTY null_TTY; /* all zeros iff uninitialized */
#endif
char *env;
int bottom_stolen = 0;
SCREEN *sp;
-#ifndef USE_TERM_DRIVER
+#if !USE_TERM_DRIVER
bool support_cookies = USE_XMC_SUPPORT;
#endif
T((T_CALLED("_nc_setupscreen(%d, %d, %p, %d, %d)"),
slines, scolumns, (void *) output, filtered, slk_format));
- assert(CURRENT_SCREEN == 0); /* has been reset in newterm() ! */
+ /* CURRENT_SCREEN is reset in newterm() */
+ if (CURRENT_SCREEN)
+ returnCode(ERR);
#if NCURSES_SP_FUNCS
- assert(spp != 0);
+ if (spp == NULL)
+ returnCode(ERR);
sp = *spp;
if (!sp) {
@@ -357,13 +360,13 @@ NCURSES_SP_NAME(_nc_setupscreen) (
sp->_next_screen = _nc_screen_chain;
_nc_screen_chain = sp;
- if ((sp->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0) {
+ if ((sp->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == NULL) {
ReturnScreenError();
}
#else
if (!_nc_alloc_screen()
- || ((SP->_acs_map = typeCalloc(chtype, ACS_LEN)) == 0)
- || ((SP->_screen_acs_map = typeCalloc(bool, ACS_LEN)) == 0)) {
+ || ((SP->_acs_map = typeCalloc(chtype, ACS_LEN)) == NULL)
+ || ((SP->_screen_acs_map = typeCalloc(bool, ACS_LEN)) == NULL)) {
returnCode(ERR);
}
@@ -373,7 +376,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
sp->_next_screen = _nc_screen_chain;
_nc_screen_chain = sp;
- if ((sp->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0) {
+ if ((sp->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == NULL) {
returnCode(ERR);
}
#endif
@@ -383,12 +386,16 @@ NCURSES_SP_NAME(_nc_setupscreen) (
*/
_nc_set_screen(sp);
sp->_term = cur_term;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
TCBOf(sp)->csp = sp;
_nc_get_screensize(sp, sp->_term, &slines, &scolumns);
#else
_nc_get_screensize(sp, &slines, &scolumns);
#endif
+ if (scolumns < 0)
+ scolumns = 0;
+ if (slines < 0)
+ slines = 0;
SET_LINES(slines);
SET_COLS(scolumns);
@@ -401,7 +408,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
if (filtered) {
slines = 1;
SET_LINES(slines);
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver(sp, td_setfilter);
#else
/* *INDENT-EQLS* */
@@ -420,12 +427,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
#endif
T(("filter screensize %dx%d", slines, scolumns));
}
-#ifdef __DJGPP__
- T(("setting output mode to binary"));
- fflush(output);
- setmode(output, O_BINARY);
-#endif
-#if defined(EXP_WIN32_DRIVER)
+#if USE_NAMED_PIPES
T(("setting output mode to binary"));
fflush(output);
_setmode(fileno(output), _O_BINARY);
@@ -437,12 +439,12 @@ NCURSES_SP_NAME(_nc_setupscreen) (
fflush(output);
sp->_ofd = output ? fileno(output) : -1;
sp->_ofp = output;
-#if defined(EXP_WIN32_DRIVER)
+#if USE_NAMED_PIPES
if (output)
_setmode(fileno(output), _O_BINARY);
#endif
sp->out_limit = (size_t) ((2 + slines) * (6 + scolumns));
- if ((sp->out_buffer = malloc(sp->out_limit)) == 0)
+ if ((sp->out_buffer = malloc(sp->out_limit)) == NULL)
sp->out_limit = 0;
sp->out_inuse = 0;
@@ -455,7 +457,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
/*
* Set our assumption of the terminal's default foreground and background
- * colors. The curs_color man-page states that we can assume that the
+ * colors. The curs_color man page states that we can assume that the
* background is black. The origin of this assumption appears to be
* terminals that displayed colored text, but no colored backgrounds, e.g.,
* the first colored terminals around 1980. More recent ones with better
@@ -484,7 +486,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
* Allow those assumed/default color assumptions to be overridden at
* runtime:
*/
- if ((env = getenv("NCURSES_ASSUMED_COLORS")) != 0) {
+ if ((env = getenv("NCURSES_ASSUMED_COLORS")) != NULL) {
int fg, bg;
char sep1, sep2;
int count = sscanf(env, "%d%c%d%c", &fg, &sep1, &bg, &sep2);
@@ -551,7 +553,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
if (NCURSES_SP_NAME(has_colors) (NCURSES_SP_ARG)) {
sp->_ok_attributes |= A_COLOR;
}
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
_nc_cookie_init(sp);
#else
#if USE_XMC_SUPPORT
@@ -560,7 +562,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
* in the environment, reset the support-flag.
*/
if (magic_cookie_glitch >= 0) {
- if (getenv("NCURSES_NO_MAGIC_COOKIE") != 0) {
+ if (getenv("NCURSES_NO_MAGIC_COOKIE") != NULL) {
support_cookies = FALSE;
}
}
@@ -638,10 +640,10 @@ NCURSES_SP_NAME(_nc_setupscreen) (
NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_ARG);
#if USE_WIDEC_SUPPORT
sp->_screen_unicode = _nc_unicode_locale();
- if (_nc_wacs == 0) {
+ if (_nc_wacs == NULL) {
_nc_init_wacs();
}
- if (_nc_wacs == 0) {
+ if (_nc_wacs == NULL) {
ReturnScreenError();
}
@@ -649,7 +651,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
&& _nc_locale_breaks_acs(sp->_term));
#endif
env = _nc_get_locale();
- sp->_legacy_coding = ((env == 0)
+ sp->_legacy_coding = ((env == NULL)
|| !strcmp(env, "C")
|| !strcmp(env, "POSIX"));
T(("legacy-coding %d", sp->_legacy_coding));
@@ -657,19 +659,19 @@ NCURSES_SP_NAME(_nc_setupscreen) (
sp->_nc_sp_idcok = TRUE;
sp->_nc_sp_idlok = FALSE;
- sp->oldhash = 0;
- sp->newhash = 0;
+ sp->oldhash = NULL;
+ sp->newhash = NULL;
T(("creating newscr"));
NewScreen(sp) = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx slines, scolumns,
0, 0);
- if (NewScreen(sp) == 0) {
+ if (NewScreen(sp) == NULL) {
ReturnScreenError();
}
T(("creating curscr"));
CurScreen(sp) = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx slines, scolumns,
0, 0);
- if (CurScreen(sp) == 0) {
+ if (CurScreen(sp) == NULL) {
ReturnScreenError();
}
#if !USE_REENTRANT
@@ -688,8 +690,8 @@ NCURSES_SP_NAME(_nc_setupscreen) (
* Get the current tty-modes. setupterm() may already have done this,
* unless we use the term-driver.
*/
-#ifndef USE_TERM_DRIVER
- if (cur_term != 0 &&
+#if !USE_TERM_DRIVER
+ if (cur_term != NULL &&
!memcmp(&cur_term->Ottyb, &null_TTY, sizeof(TTY)))
#endif
{
@@ -755,7 +757,7 @@ NCURSES_SP_NAME(_nc_setupscreen) (
assert((sp->_lines_avail + sp->_topstolen + bottom_stolen) == slines);
if ((StdScreen(sp) = NCURSES_SP_NAME(newwin) (NCURSES_SP_ARGx
sp->_lines_avail,
- scolumns, 0, 0)) == 0) {
+ scolumns, 0, 0)) == NULL) {
ReturnScreenError();
}
SET_LINES(sp->_lines_avail);
@@ -771,10 +773,10 @@ NCURSES_EXPORT(int)
_nc_setupscreen(int slines GCC_UNUSED,
int scolumns GCC_UNUSED,
FILE *output,
- int filtered,
+ bool filtered,
int slk_format)
{
- SCREEN *sp = 0;
+ SCREEN *sp = NULL;
int rc = NCURSES_SP_NAME(_nc_setupscreen) (&sp,
slines,
scolumns,
@@ -782,7 +784,7 @@ _nc_setupscreen(int slines GCC_UNUSED,
filtered,
slk_format);
if (rc != OK)
- _nc_set_screen(0);
+ _nc_set_screen(NULL);
return rc;
}
#endif
@@ -805,13 +807,13 @@ NCURSES_SP_NAME(_nc_ripoffline) (NCURSES_SP_DCLx
TR_FUNC_ARG(0, init)));
#if NCURSES_SP_FUNCS
- if (SP_PARM != 0 && SP_PARM->_prescreen)
+ if (SP_PARM != NULL && SP_PARM->_prescreen)
#endif
{
if (line == 0) {
code = OK;
} else {
- if (safe_ripoff_sp == 0) {
+ if (safe_ripoff_sp == NULL) {
safe_ripoff_sp = safe_ripoff_stack;
}
if (safe_ripoff_sp < safe_ripoff_stack + N_RIPS) {
diff --git a/ncurses/base/lib_slk.c b/ncurses/base/lib_slk.c
index 47e57e0bc5bd..3ddc98161ba9 100644
--- a/ncurses/base/lib_slk.c
+++ b/ncurses/base/lib_slk.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2022 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2010,2011 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -48,9 +48,9 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_slk.c,v 1.50 2022/08/20 18:29:22 tom Exp $")
+MODULE_ID("$Id: lib_slk.c,v 1.52 2025/12/27 12:41:23 tom Exp $")
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
#define NumLabels InfoOf(SP_PARM).numlabels
#define NoColorVideo InfoOf(SP_PARM).nocolorvideo
#define LabelWidth InfoOf(SP_PARM).labelwidth
@@ -68,7 +68,7 @@ MODULE_ID("$Id: lib_slk.c,v 1.50 2022/08/20 18:29:22 tom Exp $")
static int
slk_failed(NCURSES_SP_DCL0)
{
- if ((0 != SP_PARM) && SP_PARM->_slk) {
+ if ((NULL != SP_PARM) && SP_PARM->_slk) {
FreeIfNeeded(SP_PARM->_slk->ent);
free(SP_PARM->_slk);
SP_PARM->_slk = (SLK *) 0;
@@ -148,7 +148,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
assert(stwin);
sp = _nc_screen_of(stwin);
- if (0 == sp)
+ if (NULL == sp)
returnCode(ERR);
assert(TerminalOf(SP_PARM));
@@ -157,7 +157,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
if (SP_PARM->_slk) { /* we did this already, so simply return */
returnCode(OK);
- } else if ((SP_PARM->_slk = typeCalloc(SLK, 1)) == 0)
+ } else if ((SP_PARM->_slk = typeCalloc(SLK, 1)) == NULL)
returnCode(ERR);
if (!SP_PARM->slk_format)
@@ -196,13 +196,13 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
for (i = 0; i < SP_PARM->_slk->labcnt; i++) {
size_t used = max_length + 1;
- SP_PARM->_slk->ent[i].ent_text = (char *) _nc_doalloc(0, used);
- if (SP_PARM->_slk->ent[i].ent_text == 0)
+ SP_PARM->_slk->ent[i].ent_text = (char *) _nc_doalloc(NULL, used);
+ if (SP_PARM->_slk->ent[i].ent_text == NULL)
returnCode(slk_failed(NCURSES_SP_ARG));
memset(SP_PARM->_slk->ent[i].ent_text, 0, used);
- SP_PARM->_slk->ent[i].form_text = (char *) _nc_doalloc(0, used);
- if (SP_PARM->_slk->ent[i].form_text == 0)
+ SP_PARM->_slk->ent[i].form_text = (char *) _nc_doalloc(NULL, used);
+ if (SP_PARM->_slk->ent[i].form_text == NULL)
returnCode(slk_failed(NCURSES_SP_ARG));
if (used > 1) {
@@ -235,7 +235,7 @@ NCURSES_SP_NAME(slk_restore) (NCURSES_SP_DCL0)
{
T((T_CALLED("slk_restore(%p)"), (void *) SP_PARM));
- if (0 == SP_PARM)
+ if (NULL == SP_PARM)
returnCode(ERR);
if (SP_PARM->_slk == NULL)
returnCode(ERR);
diff --git a/ncurses/base/lib_slkatr_set.c b/ncurses/base/lib_slkatr_set.c
index 7c5a23acdb1f..4c2c362232ab 100644
--- a/ncurses/base/lib_slkatr_set.c
+++ b/ncurses/base/lib_slkatr_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2014,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -39,7 +39,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkatr_set.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slkatr_set.c,v 1.18 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(slk_attr_set) (NCURSES_SP_DCLx
@@ -56,8 +56,8 @@ NCURSES_SP_NAME(slk_attr_set) (NCURSES_SP_DCLx
color_pair));
set_extended_pair(opts, color_pair);
- if (SP_PARM != 0
- && SP_PARM->_slk != 0
+ if (SP_PARM != NULL
+ && SP_PARM->_slk != NULL
&& color_pair >= 0
&& color_pair < SP_PARM->_pair_limit) {
TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
diff --git a/ncurses/base/lib_slkatrof.c b/ncurses/base/lib_slkatrof.c
index 2d53ab2066ce..03c09cf1786e 100644
--- a/ncurses/base/lib_slkatrof.c
+++ b/ncurses/base/lib_slkatrof.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2005,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -39,14 +39,14 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkatrof.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slkatrof.c,v 1.13 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(slk_attroff) (NCURSES_SP_DCLx const chtype attr)
{
T((T_CALLED("slk_attroff(%p,%s)"), (void *) SP_PARM, _traceattr(attr)));
- if (SP_PARM != 0 && SP_PARM->_slk != 0) {
+ if (SP_PARM != NULL && SP_PARM->_slk != NULL) {
TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
RemAttr(SP_PARM->_slk->attr, attr);
if ((attr & A_COLOR) != 0) {
diff --git a/ncurses/base/lib_slkatron.c b/ncurses/base/lib_slkatron.c
index accc2f2ace6b..0e714eddf599 100644
--- a/ncurses/base/lib_slkatron.c
+++ b/ncurses/base/lib_slkatron.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -39,14 +39,14 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkatron.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slkatron.c,v 1.14 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(slk_attron) (NCURSES_SP_DCLx const chtype attr)
{
T((T_CALLED("slk_attron(%p,%s)"), (void *) SP_PARM, _traceattr(attr)));
- if (SP_PARM != 0 && SP_PARM->_slk != 0) {
+ if (SP_PARM != NULL && SP_PARM->_slk != NULL) {
TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr))));
AddAttr(SP_PARM->_slk->attr, attr);
if ((attr & A_COLOR) != 0) {
diff --git a/ncurses/base/lib_slkatrset.c b/ncurses/base/lib_slkatrset.c
index 11fa7e6f96de..2d410be532b2 100644
--- a/ncurses/base/lib_slkatrset.c
+++ b/ncurses/base/lib_slkatrset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2005,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -39,14 +39,14 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkatrset.c,v 1.11 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slkatrset.c,v 1.12 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(slk_attrset) (NCURSES_SP_DCLx const chtype attr)
{
T((T_CALLED("slk_attrset(%p,%s)"), (void *) SP_PARM, _traceattr(attr)));
- if (SP_PARM != 0 && SP_PARM->_slk != 0) {
+ if (SP_PARM != NULL && SP_PARM->_slk != NULL) {
SetAttr(SP_PARM->_slk->attr, attr);
returnCode(OK);
} else
diff --git a/ncurses/base/lib_slkattr.c b/ncurses/base/lib_slkattr.c
index af49f3bb7c05..9a6339137b42 100644
--- a/ncurses/base/lib_slkattr.c
+++ b/ncurses/base/lib_slkattr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -39,14 +39,14 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkattr.c,v 1.12 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slkattr.c,v 1.13 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(attr_t)
NCURSES_SP_NAME(slk_attr) (NCURSES_SP_DCL0)
{
T((T_CALLED("slk_attr(%p)"), (void *) SP_PARM));
- if (SP_PARM != 0 && SP_PARM->_slk != 0) {
+ if (SP_PARM != NULL && SP_PARM->_slk != NULL) {
attr_t result = AttrOf(SP_PARM->_slk->attr) & ALL_BUT_COLOR;
int pair = GetPair(SP_PARM->_slk->attr);
diff --git a/ncurses/base/lib_slkclear.c b/ncurses/base/lib_slkclear.c
index 10531e4df8a6..5d54623f11f4 100644
--- a/ncurses/base/lib_slkclear.c
+++ b/ncurses/base/lib_slkclear.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2007,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -41,7 +41,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkclear.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slkclear.c,v 1.16 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(slk_clear) (NCURSES_SP_DCL0)
@@ -50,7 +50,7 @@ NCURSES_SP_NAME(slk_clear) (NCURSES_SP_DCL0)
T((T_CALLED("slk_clear(%p)"), (void *) SP_PARM));
- if (SP_PARM != 0 && SP_PARM->_slk != 0) {
+ if (SP_PARM != NULL && SP_PARM->_slk != NULL) {
SP_PARM->_slk->hidden = TRUE;
/* For simulated SLK's it looks much more natural to
inherit those attributes from the standard screen */
diff --git a/ncurses/base/lib_slkcolor.c b/ncurses/base/lib_slkcolor.c
index 00d1eaa050da..1801364ce5d8 100644
--- a/ncurses/base/lib_slkcolor.c
+++ b/ncurses/base/lib_slkcolor.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2024 Thomas E. Dickey *
* Copyright 1998-2014,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -39,7 +39,7 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slkcolor.c,v 1.20 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slkcolor.c,v 1.21 2024/12/07 20:03:37 tom Exp $")
static int
_nc_slk_color(SCREEN *sp, int pair_arg)
@@ -48,8 +48,8 @@ _nc_slk_color(SCREEN *sp, int pair_arg)
T((T_CALLED("slk_color(%p,%d)"), (void *) sp, pair_arg));
- if (sp != 0
- && sp->_slk != 0
+ if (sp != NULL
+ && sp->_slk != NULL
&& pair_arg >= 0
&& pair_arg < sp->_pair_limit) {
TR(TRACE_ATTRS, ("... current is %s", _tracech_t(CHREF(sp->_slk->attr))));
diff --git a/ncurses/base/lib_slklab.c b/ncurses/base/lib_slklab.c
index 894ff26dbd30..23555039888f 100644
--- a/ncurses/base/lib_slklab.c
+++ b/ncurses/base/lib_slklab.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2003,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -41,15 +41,15 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slklab.c,v 1.11 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slklab.c,v 1.12 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(char *)
NCURSES_SP_NAME(slk_label) (NCURSES_SP_DCLx int n)
{
T((T_CALLED("slk_label(%p,%d)"), (void *) SP_PARM, n));
- if (SP_PARM == 0 || SP_PARM->_slk == 0 || n < 1 || n > SP_PARM->_slk->labcnt)
- returnPtr(0);
+ if (SP_PARM == NULL || SP_PARM->_slk == NULL || n < 1 || n > SP_PARM->_slk->labcnt)
+ returnPtr(NULL);
returnPtr(SP_PARM->_slk->ent[n - 1].ent_text);
}
diff --git a/ncurses/base/lib_slkrefr.c b/ncurses/base/lib_slkrefr.c
index 7a40624b1276..6717b6c7a20d 100644
--- a/ncurses/base/lib_slkrefr.c
+++ b/ncurses/base/lib_slkrefr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2013,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -44,9 +44,9 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_slkrefr.c,v 1.32 2021/09/04 10:54:35 tom Exp $")
+MODULE_ID("$Id: lib_slkrefr.c,v 1.35 2025/12/27 12:41:23 tom Exp $")
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
#define NumLabels InfoOf(SP_PARM).numlabels
#else
#define NumLabels num_labels
@@ -58,7 +58,7 @@ MODULE_ID("$Id: lib_slkrefr.c,v 1.32 2021/09/04 10:54:35 tom Exp $")
static void
slk_paint_info(WINDOW *win)
{
- SCREEN *sp = _nc_screen_of(win);
+ const SCREEN *sp = _nc_screen_of(win);
if (win && sp && (sp->slk_format == 4)) {
int i;
@@ -83,7 +83,7 @@ slk_intern_refresh(SCREEN *sp)
SLK *slk;
int numlab;
- if (sp == 0)
+ if (sp == NULL)
return;
slk = sp->_slk;
@@ -97,7 +97,7 @@ slk_intern_refresh(SCREEN *sp)
if (slk->dirty || slk->ent[i].dirty) {
if (slk->ent[i].visible) {
if (numlab > 0 && SLK_STDFMT(fmt)) {
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver_2(sp, td_hwlabel, i + 1, slk->ent[i].form_text);
#else
if (i < num_labels) {
@@ -125,7 +125,7 @@ slk_intern_refresh(SCREEN *sp)
slk->dirty = FALSE;
if (numlab > 0) {
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver_1(sp, td_hwlabelOnOff, slk->hidden ? FALSE : TRUE);
#else
if (slk->hidden) {
@@ -145,7 +145,7 @@ NCURSES_SP_NAME(slk_noutrefresh) (NCURSES_SP_DCL0)
{
T((T_CALLED("slk_noutrefresh(%p)"), (void *) SP_PARM));
- if (SP_PARM == 0 || SP_PARM->_slk == 0)
+ if (SP_PARM == NULL || SP_PARM->_slk == NULL)
returnCode(ERR);
if (SP_PARM->_slk->hidden)
returnCode(OK);
@@ -170,7 +170,7 @@ NCURSES_SP_NAME(slk_refresh) (NCURSES_SP_DCL0)
{
T((T_CALLED("slk_refresh(%p)"), (void *) SP_PARM));
- if (SP_PARM == 0 || SP_PARM->_slk == 0)
+ if (SP_PARM == NULL || SP_PARM->_slk == NULL)
returnCode(ERR);
if (SP_PARM->_slk->hidden)
returnCode(OK);
diff --git a/ncurses/base/lib_slkset.c b/ncurses/base/lib_slkset.c
index 3e777f14651c..5476c5a6e70d 100644
--- a/ncurses/base/lib_slkset.c
+++ b/ncurses/base/lib_slkset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey *
+ * Copyright 2019-2020,2024 Thomas E. Dickey *
* Copyright 1998-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -45,7 +45,7 @@
#endif
#endif
-MODULE_ID("$Id: lib_slkset.c,v 1.26 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slkset.c,v 1.27 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format)
@@ -60,14 +60,14 @@ NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format)
T((T_CALLED("slk_set(%p, %d, \"%s\", %d)"), (void *) SP_PARM, i, str, format));
- if (SP_PARM == 0
- || (slk = SP_PARM->_slk) == 0
+ if (SP_PARM == NULL
+ || (slk = SP_PARM->_slk) == NULL
|| i < 1
|| i > slk->labcnt
|| format < 0
|| format > 2)
returnCode(ERR);
- if (str == 0)
+ if (str == NULL)
str = "";
--i; /* Adjust numbering of labels */
@@ -84,7 +84,7 @@ NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format)
size_t need;
init_mb(state);
- need = mbrtowc(0, p, strlen(p), &state);
+ need = mbrtowc(NULL, p, strlen(p), &state);
if (need == (size_t) -1)
break;
mbrtowc(&wc, p, need, &state);
@@ -107,14 +107,14 @@ NCURSES_SP_NAME(slk_set) (NCURSES_SP_DCLx int i, const char *astr, int format)
#endif
FreeIfNeeded(slk->ent[i].ent_text);
- if ((slk->ent[i].ent_text = strdup(str)) == 0)
+ if ((slk->ent[i].ent_text = strdup(str)) == NULL)
returnCode(ERR);
slk->ent[i].ent_text[numchrs] = '\0';
if ((slk->ent[i].form_text = (char *) _nc_doalloc(slk->ent[i].form_text,
(size_t) (limit +
numchrs + 1))
- ) == 0)
+ ) == NULL)
returnCode(ERR);
switch (format) {
diff --git a/ncurses/base/lib_slktouch.c b/ncurses/base/lib_slktouch.c
index 6696a25f4020..f269b91371f0 100644
--- a/ncurses/base/lib_slktouch.c
+++ b/ncurses/base/lib_slktouch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2000,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -39,14 +39,14 @@
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_slktouch.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slktouch.c,v 1.10 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(slk_touch) (NCURSES_SP_DCL0)
{
T((T_CALLED("slk_touch(%p)"), (void *) SP_PARM));
- if (SP_PARM == 0 || SP_PARM->_slk == 0)
+ if (SP_PARM == NULL || SP_PARM->_slk == NULL)
returnCode(ERR);
SP_PARM->_slk->dirty = TRUE;
diff --git a/ncurses/base/lib_touch.c b/ncurses/base/lib_touch.c
index d8d59e138c2e..130a76d6a57e 100644
--- a/ncurses/base/lib_touch.c
+++ b/ncurses/base/lib_touch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -44,7 +44,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_touch.c,v 1.16 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_touch.c,v 1.17 2024/11/23 19:17:05 tom Exp $")
#undef is_linetouched
@@ -55,10 +55,10 @@ is_linetouched(WINDOW *win, int line)
/* XSI doesn't define any error, and gcc ultimately made it impossible */
if (!win || (line > win->_maxy) || (line < 0)) {
- returnCode(FALSE);
+ returnBool(FALSE);
}
- returnCode(win->_line[line].firstchar != _NOCHANGE ? TRUE : FALSE);
+ returnBool(win->_line[line].firstchar != _NOCHANGE ? TRUE : FALSE);
}
NCURSES_EXPORT(bool)
@@ -71,9 +71,9 @@ is_wintouched(WINDOW *win)
for (i = 0; i <= win->_maxy; i++)
if (win->_line[i].firstchar != _NOCHANGE)
- returnCode(TRUE);
+ returnBool(TRUE);
}
- returnCode(FALSE);
+ returnBool(FALSE);
}
NCURSES_EXPORT(int)
diff --git a/ncurses/base/lib_ungetch.c b/ncurses/base/lib_ungetch.c
index fcbe6f4a90c1..8729f1fdf308 100644
--- a/ncurses/base/lib_ungetch.c
+++ b/ncurses/base/lib_ungetch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,7 +43,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_ungetch.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_ungetch.c,v 1.18 2024/12/07 20:03:37 tom Exp $")
#include <fifo_defs.h>
@@ -65,7 +65,7 @@ safe_ungetch(SCREEN *sp, int ch)
T((T_CALLED("ungetch(%p,%s)"), (void *) sp, _nc_tracechar(sp, ch)));
- if (sp != 0 && tail >= 0) {
+ if (sp != NULL && tail >= 0) {
if (head < 0) {
head = 0;
t_inc();
diff --git a/ncurses/base/lib_wattron.c b/ncurses/base/lib_wattron.c
index 906021d3b4cf..f15f3a4f97b5 100644
--- a/ncurses/base/lib_wattron.c
+++ b/ncurses/base/lib_wattron.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2022 Thomas E. Dickey *
+ * Copyright 2020-2022,2024 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,13 +43,13 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: lib_wattron.c,v 1.13 2022/04/15 22:34:38 tom Exp $")
+MODULE_ID("$Id: lib_wattron.c,v 1.14 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(int)
wattr_on(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
{
T((T_CALLED("wattr_on(%p,%s)"), (void *) win, _traceattr(at)));
- if (win != 0) {
+ if (win != NULL) {
T(("... current %s (%d)",
_traceattr(WINDOW_ATTRS(win)),
GET_WINDOW_PAIR(win)));
diff --git a/ncurses/base/lib_winch.c b/ncurses/base/lib_winch.c
index 91253d106471..2fb4f1c4281f 100644
--- a/ncurses/base/lib_winch.c
+++ b/ncurses/base/lib_winch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,13 +40,13 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_winch.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_winch.c,v 1.10 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(chtype)
winch(WINDOW *win)
{
T((T_CALLED("winch(%p)"), (void *) win));
- if (win != 0) {
+ if (win != NULL) {
returnChtype((chtype) CharOf(win->_line[win->_cury].text[win->_curx])
| AttrOf(win->_line[win->_cury].text[win->_curx]));
} else {
diff --git a/ncurses/base/lib_window.c b/ncurses/base/lib_window.c
index 5323fbf0348e..d69b22b2e476 100644
--- a/ncurses/base/lib_window.c
+++ b/ncurses/base/lib_window.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2021,2024 Thomas E. Dickey *
* Copyright 1998-2010,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_window.c,v 1.32 2021/10/23 23:06:24 tom Exp $")
+MODULE_ID("$Id: lib_window.c,v 1.33 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(void)
_nc_synchook(WINDOW *win)
@@ -61,8 +61,8 @@ mvderwin(WINDOW *win, int y, int x)
T((T_CALLED("mvderwin(%p,%d,%d)"), (void *) win, y, x));
- if (win != 0
- && (orig = win->_parent) != 0
+ if (win != NULL
+ && (orig = win->_parent) != NULL
&& (x >= 0 && y >= 0)
&& (x + getmaxx(win) <= getmaxx(orig))
&& (y + getmaxy(win) <= getmaxy(orig))) {
@@ -178,11 +178,11 @@ NCURSES_EXPORT(WINDOW *)
dupwin(WINDOW *win)
/* make an exact duplicate of the given window */
{
- WINDOW *nwin = 0;
+ WINDOW *nwin = NULL;
T((T_CALLED("dupwin(%p)"), (void *) win));
- if (win != 0) {
+ if (win != NULL) {
#if NCURSES_SP_FUNCS
SCREEN *sp = _nc_screen_of(win);
#endif
@@ -199,7 +199,7 @@ dupwin(WINDOW *win)
win->_begx);
}
- if (nwin != 0) {
+ if (nwin != NULL) {
int i;
size_t linesize;
diff --git a/ncurses/base/nc_panel.c b/ncurses/base/nc_panel.c
index 002f118efc99..b6e0642f781c 100644
--- a/ncurses/base/nc_panel.c
+++ b/ncurses/base/nc_panel.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2000,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -33,7 +33,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: nc_panel.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: nc_panel.c,v 1.7 2024/12/07 20:03:37 tom Exp $")
NCURSES_EXPORT(struct panelhook *)
NCURSES_SP_NAME(_nc_panelhook) (NCURSES_SP_DCL0)
@@ -42,7 +42,7 @@ NCURSES_SP_NAME(_nc_panelhook) (NCURSES_SP_DCL0)
? &(SP_PARM->_panelHook)
: (CURRENT_SCREEN
? &(CURRENT_SCREEN->_panelHook)
- : 0));
+ : NULL));
}
#if NCURSES_SP_FUNCS
diff --git a/ncurses/base/new_pair.c b/ncurses/base/new_pair.c
index 70866c636812..f28b25a1696f 100644
--- a/ncurses/base/new_pair.c
+++ b/ncurses/base/new_pair.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,7 +43,7 @@
#define CUR SP_TERMTYPE
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
#define MaxColors InfoOf(SP_PARM).maxcolors
#else
#define MaxColors max_colors
@@ -61,7 +61,7 @@
#endif
-MODULE_ID("$Id: new_pair.c,v 1.23 2021/08/16 22:11:26 tom Exp $")
+MODULE_ID("$Id: new_pair.c,v 1.27 2025/12/27 12:41:23 tom Exp $")
#if NCURSES_EXT_COLORS
@@ -148,10 +148,10 @@ _nc_find_color_pair(SCREEN *sp, int fg, int bg)
find.fg = fg;
find.bg = bg;
- if (sp != 0) {
+ if (sp != NULL) {
void *pp;
- if ((pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != 0) {
- colorpair_t *temp = *(colorpair_t **) pp;
+ if ((pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != NULL) {
+ const colorpair_t *temp = *(colorpair_t **) pp;
result = (int) (temp - sp->_color_pairs);
}
}
@@ -193,7 +193,7 @@ _nc_free_ordered_pairs(SCREEN *sp)
* pair table.
*/
NCURSES_EXPORT(void)
-_nc_reset_color_pair(SCREEN *sp, int pair, colorpair_t * next)
+_nc_reset_color_pair(SCREEN *sp, int pair, const colorpair_t * next)
{
colorpair_t *last;
@@ -252,8 +252,8 @@ _nc_copy_pairs(SCREEN *sp, colorpair_t * target, colorpair_t * source, int lengt
{
int n;
for (n = 0; n < length; ++n) {
- void *find = tfind(source + n, &sp->_ordered_pairs, compare_data);
- if (find != 0) {
+ const void *find = tfind(source + n, &sp->_ordered_pairs, compare_data);
+ if (find != NULL) {
tdelete(source + n, &sp->_ordered_pairs, compare_data);
tsearch(target + n, &sp->_ordered_pairs, compare_data);
}
@@ -266,7 +266,7 @@ NCURSES_SP_NAME(alloc_pair) (NCURSES_SP_DCLx int fg, int bg)
int pair;
T((T_CALLED("alloc_pair(%d,%d)"), fg, bg));
- if (SP_PARM == 0) {
+ if (SP_PARM == NULL) {
pair = -1;
} else if ((pair = _nc_find_color_pair(SP_PARM, fg, bg)) < 0) {
/*
@@ -291,7 +291,7 @@ NCURSES_SP_NAME(alloc_pair) (NCURSES_SP_DCLx int fg, int bg)
if (!found && (SP_PARM->_pair_alloc < SP_PARM->_pair_limit)) {
pair = SP_PARM->_pair_alloc;
ReservePairs(SP_PARM, pair);
- if (SP_PARM->_color_pairs == 0) {
+ if (SP_PARM->_color_pairs == NULL) {
pair = -1;
} else {
found = TRUE;
diff --git a/ncurses/base/resizeterm.c b/ncurses/base/resizeterm.c
index 1a2ddb365a58..55a1801ed35d 100644
--- a/ncurses/base/resizeterm.c
+++ b/ncurses/base/resizeterm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2021,2024 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2015,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -46,7 +46,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: resizeterm.c,v 1.53 2024/04/20 21:54:14 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.61 2025/12/27 12:28:45 tom Exp $")
/*
* If we're trying to be reentrant, do not want any local statics.
@@ -103,8 +103,9 @@ NCURSES_EXPORT(bool)
NCURSES_SP_NAME(is_term_resized) (NCURSES_SP_DCLx int ToLines, int ToCols)
{
T((T_CALLED("is_term_resized(%p, %d, %d)"), (void *) SP_PARM, ToLines, ToCols));
- returnCode(ToLines > 0
+ returnBool(ToLines > 0
&& ToCols > 0
+ && SP_PARM != NULL
&& (ToLines != screen_lines(SP_PARM)
|| ToCols != screen_columns(SP_PARM)));
}
@@ -122,10 +123,10 @@ is_term_resized(int ToLines, int ToCols)
static ripoff_t *
ripped_window(WINDOW *win)
{
- ripoff_t *result = 0;
+ ripoff_t *result = NULL;
ripoff_t *rop;
- if (win != 0) {
+ if (win != NULL) {
#ifdef USE_SP_RIPOFF
SCREEN *sp = _nc_screen_of(win);
#endif
@@ -148,7 +149,7 @@ ripped_bottom(WINDOW *win)
{
int result = 0;
- if (win != 0) {
+ if (win != NULL) {
ripoff_t *rop;
#ifdef USE_SP_RIPOFF
@@ -174,7 +175,7 @@ child_depth(WINDOW *cmp)
{
int depth = 0;
- if (cmp != 0) {
+ if (cmp != NULL) {
#ifdef USE_SP_WINDOWLIST
SCREEN *sp = _nc_screen_of(cmp);
#endif
@@ -199,9 +200,9 @@ parent_depth(WINDOW *cmp)
{
int depth = 0;
- if (cmp != 0) {
+ if (cmp != NULL) {
WINDOW *tst;
- while ((tst = cmp->_parent) != 0) {
+ while ((tst = cmp->_parent) != NULL) {
++depth;
cmp = tst;
}
@@ -219,17 +220,17 @@ adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS)
int bottom = CurLines + _nc_screen_of(win)->_topstolen - stolen;
int myLines = win->_maxy + 1;
int myCols = win->_maxx + 1;
- ripoff_t *rop = ripped_window(win);
+ const ripoff_t *rop = ripped_window(win);
T((T_CALLED("adjust_window(%p,%d,%d)%s depth %d/%d currently %ldx%ld at %ld,%ld"),
(void *) win, ToLines, ToCols,
- (rop != 0) ? " (rip)" : "",
+ (rop != NULL) ? " (rip)" : "",
parent_depth(win),
child_depth(win),
(long) getmaxy(win), (long) getmaxx(win),
(long) getbegy(win) + win->_yoffset, (long) getbegx(win)));
- if (rop != 0 && rop->line < 0) {
+ if (rop != NULL && rop->line < 0) {
/*
* If it is a ripped-off window at the bottom of the screen, simply
* move it to the same relative position.
@@ -343,7 +344,7 @@ increase_size(NCURSES_SP_DCLx int ToLines, int ToCols, int stolen EXTRA_DCLS)
}
/*
- * This function reallocates NCURSES window structures, with no side-effects
+ * This function reallocates NCURSES window structures, with no side effects
* such as ungetch().
*/
NCURSES_EXPORT(int)
@@ -354,10 +355,10 @@ NCURSES_SP_NAME(resize_term) (NCURSES_SP_DCLx int ToLines, int ToCols)
T((T_CALLED("resize_term(%p,%d,%d) old(%d,%d)"),
(void *) SP_PARM, ToLines, ToCols,
- (SP_PARM == 0) ? -1 : screen_lines(SP_PARM),
- (SP_PARM == 0) ? -1 : screen_columns(SP_PARM)));
+ (SP_PARM == NULL) ? -1 : screen_lines(SP_PARM),
+ (SP_PARM == NULL) ? -1 : screen_columns(SP_PARM)));
- if (SP_PARM == 0 || ToLines <= 0 || ToCols <= 0) {
+ if (SP_PARM == NULL || ToLines <= 0 || ToCols <= 0) {
returnCode(ERR);
}
@@ -406,7 +407,7 @@ NCURSES_SP_NAME(resize_term) (NCURSES_SP_DCLx int ToLines, int ToCols)
screen_lines(SP_PARM) = (NCURSES_SIZE_T) ToLines;
screen_columns(SP_PARM) = (NCURSES_SIZE_T) ToCols;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver_2(SP_PARM, td_setsize, ToLines, ToCols);
#else
lines = (NCURSES_INT2) ToLines;
@@ -473,18 +474,18 @@ NCURSES_SP_NAME(resizeterm) (NCURSES_SP_DCLx int ToLines, int ToCols)
T((T_CALLED("resizeterm(%p, %d,%d) old(%d,%d)"),
(void *) SP_PARM, ToLines, ToCols,
- (SP_PARM == 0) ? -1 : screen_lines(SP_PARM),
- (SP_PARM == 0) ? -1 : screen_columns(SP_PARM)));
+ (SP_PARM == NULL) ? -1 : screen_lines(SP_PARM),
+ (SP_PARM == NULL) ? -1 : screen_columns(SP_PARM)));
- if (SP_PARM != 0 && ToLines > 0 && ToCols > 0) {
+ if (SP_PARM != NULL && ToLines > 0 && ToCols > 0) {
result = OK;
SP_PARM->_sig_winch = FALSE;
if (NCURSES_SP_NAME(is_term_resized) (NCURSES_SP_ARGx ToLines, ToCols)) {
#if USE_SIGWINCH
ripoff_t *rop;
- bool slk_visible = (SP_PARM != 0
- && SP_PARM->_slk != 0
+ bool slk_visible = (SP_PARM != NULL
+ && SP_PARM->_slk != NULL
&& !(SP_PARM->_slk->hidden));
if (slk_visible) {
@@ -505,7 +506,7 @@ NCURSES_SP_NAME(resizeterm) (NCURSES_SP_DCLx int ToLines, int ToCols)
*/
for (each_ripoff(rop)) {
if (rop->win != StdScreen(SP_PARM)
- && rop->win != 0
+ && rop->win != NULL
&& rop->line < 0) {
if (rop->hook != _nc_slk_initialize) {
diff --git a/ncurses/base/safe_sprintf.c b/ncurses/base/safe_sprintf.c
index 8816e58c2ca8..219b60691346 100644
--- a/ncurses/base/safe_sprintf.c
+++ b/ncurses/base/safe_sprintf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2021,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2012,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,7 +34,7 @@
#include <curses.priv.h>
#include <ctype.h>
-MODULE_ID("$Id: safe_sprintf.c,v 1.37 2023/09/30 10:42:42 tom Exp $")
+MODULE_ID("$Id: safe_sprintf.c,v 1.39 2025/02/20 01:07:05 tom Exp $")
#if USE_SAFE_SPRINTF
@@ -60,12 +60,12 @@ _nc_printf_length(const char *fmt, va_list ap)
size_t fmt_len;
char fmt_arg[BUFSIZ];
- if (fmt == 0 || *fmt == '\0')
+ if (fmt == NULL || *fmt == '\0')
return 0;
fmt_len = strlen(fmt) + 1;
- if ((format = typeMalloc(char, fmt_len)) == 0)
+ if ((format = typeMalloc(char, fmt_len)) == NULL)
return -1;
- if ((buffer = typeMalloc(char, length)) == 0) {
+ if ((buffer = typeMalloc(char, length)) == NULL) {
free(format);
return -1;
}
@@ -114,7 +114,7 @@ _nc_printf_length(const char *fmt, va_list ap)
_nc_SLIMIT(sizeof(fmt_arg))
"%d", ival);
fmt_len += strlen(fmt_arg);
- if ((format = _nc_doalloc(format, fmt_len)) == 0) {
+ if ((format = _nc_doalloc(format, fmt_len)) == NULL) {
free(buffer);
return -1;
}
@@ -162,7 +162,7 @@ _nc_printf_length(const char *fmt, va_list ap)
if (prec > (int) length) {
length = length + (size_t) prec;
buffer = typeRealloc(char, length, buffer);
- if (buffer == 0) {
+ if (buffer == NULL) {
free(format);
return -1;
}
@@ -262,10 +262,9 @@ NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_DCLx
if (my_buffer != NULL) {
# if HAVE_VSNPRINTF
- /* SUSv2, 1997 */
- int used;
-
do {
+ /* SUSv2, 1997 */
+ int used;
va_list ap2;
begin_va_copy(ap2, ap);
diff --git a/ncurses/base/tries.c b/ncurses/base/tries.c
index 0f8c0516e88f..2f080d5eb13b 100644
--- a/ncurses/base/tries.c
+++ b/ncurses/base/tries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -41,7 +41,7 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: tries.c,v 1.32 2023/06/24 15:36:23 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.33 2024/12/07 21:24:18 tom Exp $")
/*
* Expand a keycode into the string that it corresponds to, returning null if
@@ -51,12 +51,12 @@ NCURSES_EXPORT(char *)
_nc_expand_try(TRIES * tree, unsigned code, int *count, size_t len)
{
TRIES *ptr = tree;
- char *result = 0;
+ char *result = NULL;
if (code != 0) {
- while (ptr != 0) {
+ while (ptr != NULL) {
if ((result = _nc_expand_try(ptr->child, code, count, len + 1))
- != 0) {
+ != NULL) {
break;
}
if (ptr->value == code) {
@@ -69,8 +69,8 @@ _nc_expand_try(TRIES * tree, unsigned code, int *count, size_t len)
ptr = ptr->sibling;
}
}
- if (result != 0) {
- if (ptr != 0 && (result[len] = (char) ptr->ch) == 0)
+ if (result != NULL) {
+ if (ptr != NULL && (result[len] = (char) ptr->ch) == 0)
*((unsigned char *) (result + len)) = 128;
#ifdef TRACE
if (len == 0 && USE_TRACEF(TRACE_MAXIMUM)) {
@@ -96,7 +96,7 @@ _nc_remove_key(TRIES ** tree, unsigned code)
if (code == 0)
returnCode(FALSE);
- while (*tree != 0) {
+ while (*tree != NULL) {
if (_nc_remove_key(&(*tree)->child, code)) {
returnCode(TRUE);
}
@@ -128,11 +128,11 @@ _nc_remove_string(TRIES ** tree, const char *string)
if (!VALID_STRING(string) || *string == 0)
returnCode(FALSE);
- while (*tree != 0) {
+ while (*tree != NULL) {
if (UChar((*tree)->ch) == UChar(*string)) {
if (string[1] != 0)
returnCode(_nc_remove_string(&(*tree)->child, string + 1));
- if ((*tree)->child == 0) {
+ if ((*tree)->child == NULL) {
TRIES *to_free = *tree;
*tree = (*tree)->sibling;
free(to_free);
diff --git a/ncurses/base/vsscanf.c b/ncurses/base/vsscanf.c
index 40ee8bb1d876..022365f078f4 100644
--- a/ncurses/base/vsscanf.c
+++ b/ncurses/base/vsscanf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2025 Thomas E. Dickey *
* Copyright 1998-2004,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -39,7 +39,7 @@
#if !HAVE_VSSCANF
-MODULE_ID("$Id: vsscanf.c,v 1.22 2023/09/23 18:48:57 tom Exp $")
+MODULE_ID("$Id: vsscanf.c,v 1.23 2025/02/20 01:08:11 tom Exp $")
#if !(HAVE_VFSCANF || HAVE__DOSCAN)
@@ -215,7 +215,7 @@ vsscanf(const char *str, const char *format, va_list ap)
int eaten;
void *pointer;
- if (my_fmt != 0) {
+ if (my_fmt != NULL) {
/*
* Split the original format into chunks, adding a "%n" to the end
* of each (except of course if it used %n), and use that
@@ -229,7 +229,7 @@ vsscanf(const char *str, const char *format, va_list ap)
state = sUnknown;
chunk = cUnknown;
other = oUnknown;
- pointer = 0;
+ pointer = NULL;
for (n = 0; format[n] != 0 && state != sFinal; ++n) {
my_fmt[n] = format[n];
switch (state) {
diff --git a/ncurses/base/wresize.c b/ncurses/base/wresize.c
index 6d5589e2794e..957a5035b2be 100644
--- a/ncurses/base/wresize.c
+++ b/ncurses/base/wresize.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2021,2023 Thomas E. Dickey *
+ * Copyright 2019-2023,2024 Thomas E. Dickey *
* Copyright 1998-2010,2011 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,7 +34,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: wresize.c,v 1.43 2023/10/21 11:13:03 tom Exp $")
+MODULE_ID("$Id: wresize.c,v 1.45 2024/12/07 18:08:56 tom Exp $")
static int
cleanup_lines(struct ldat *data, int length)
@@ -109,7 +109,7 @@ wresize(WINDOW *win, int ToLines, int ToCols)
{
int col, row, size_x, size_y;
struct ldat *pline;
- struct ldat *new_lines = 0;
+ struct ldat *new_lines = NULL;
#ifdef TRACE
T((T_CALLED("wresize(%p,%d,%d)"), (void *) win, ToLines, ToCols));
@@ -125,9 +125,11 @@ wresize(WINDOW *win, int ToLines, int ToCols)
}
#endif
- if (!win || --ToLines < 0 || --ToCols < 0)
+ if (!win || !OK_DIMENSION(ToLines) || !OK_DIMENSION(ToCols))
returnCode(ERR);
+ ToLines--;
+ ToCols--;
size_x = win->_maxx;
size_y = win->_maxy;
@@ -147,7 +149,7 @@ wresize(WINDOW *win, int ToLines, int ToCols)
}
pline = win->_parent->_line;
} else {
- pline = 0;
+ pline = NULL;
}
/*
@@ -156,7 +158,7 @@ wresize(WINDOW *win, int ToLines, int ToCols)
* (at least temporarily) the array pointing to the individual lines.
*/
new_lines = typeCalloc(struct ldat, (unsigned) (ToLines + 1));
- if (new_lines == 0)
+ if (new_lines == NULL)
returnCode(ERR);
/*
@@ -173,7 +175,7 @@ wresize(WINDOW *win, int ToLines, int ToCols)
if (row <= size_y) {
if (ToCols != size_x) {
s = typeMalloc(NCURSES_CH_T, (unsigned) ToCols + 1);
- if (s == 0)
+ if (s == NULL)
returnCode(cleanup_lines(new_lines, row));
for (col = 0; col <= ToCols; ++col) {
bool valid = (col <= size_x);
@@ -193,15 +195,15 @@ wresize(WINDOW *win, int ToLines, int ToCols)
}
} else {
s = typeMalloc(NCURSES_CH_T, (unsigned) ToCols + 1);
- if (s == 0)
+ if (s == NULL)
returnCode(cleanup_lines(new_lines, row));
for (col = 0; col <= ToCols; ++col)
s[col] = win->_nc_bkgd;
}
- } else if (pline != 0 && pline[win->_pary + row].text != 0) {
+ } else if (pline != NULL && pline[win->_pary + row].text != NULL) {
s = &pline[win->_pary + row].text[win->_parx];
} else {
- s = 0;
+ s = NULL;
}
if_USE_SCROLL_HINTS(new_lines[row].oldindex = row);