summaryrefslogtreecommitdiff
path: root/ncurses
diff options
context:
space:
mode:
Diffstat (limited to 'ncurses')
-rw-r--r--ncurses/Makefile.in36
-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
-rw-r--r--ncurses/build.priv.h6
-rw-r--r--ncurses/curses.priv.h331
-rw-r--r--ncurses/llib-lncurses26
-rw-r--r--ncurses/llib-lncursest26
-rw-r--r--ncurses/llib-lncursestw40
-rw-r--r--ncurses/llib-lncursesw40
-rw-r--r--ncurses/llib-ltinfo20
-rw-r--r--ncurses/llib-ltinfot20
-rw-r--r--ncurses/llib-ltinfotw20
-rw-r--r--ncurses/llib-ltinfow20
-rw-r--r--ncurses/modules18
-rw-r--r--ncurses/new_pair.h10
-rw-r--r--ncurses/report_ctype.c104
-rw-r--r--ncurses/report_hashing.c6
-rw-r--r--ncurses/report_offsets.c19
-rw-r--r--ncurses/term.priv.h8
-rw-r--r--ncurses/tinfo/MKcaptab.awk6
-rwxr-xr-xncurses/tinfo/MKcaptab.sh22
-rw-r--r--ncurses/tinfo/MKcodes.awk12
-rwxr-xr-xncurses/tinfo/MKfallback.sh35
-rwxr-xr-xncurses/tinfo/MKkeys_list.sh26
-rw-r--r--ncurses/tinfo/MKnames.awk12
-rwxr-xr-xncurses/tinfo/MKuserdefs.sh10
-rw-r--r--ncurses/tinfo/access.c188
-rw-r--r--ncurses/tinfo/add_tries.c18
-rw-r--r--ncurses/tinfo/alloc_entry.c27
-rw-r--r--ncurses/tinfo/alloc_ttype.c43
-rw-r--r--ncurses/tinfo/captoinfo.c87
-rw-r--r--ncurses/tinfo/comp_error.c16
-rw-r--r--ncurses/tinfo/comp_expand.c22
-rw-r--r--ncurses/tinfo/comp_hash.c14
-rw-r--r--ncurses/tinfo/comp_parse.c59
-rw-r--r--ncurses/tinfo/comp_scan.c68
-rw-r--r--ncurses/tinfo/db_iterator.c66
-rw-r--r--ncurses/tinfo/doalloc.c6
-rw-r--r--ncurses/tinfo/entries.c30
-rw-r--r--ncurses/tinfo/getenv_num.c14
-rw-r--r--ncurses/tinfo/hashed_db.c49
-rw-r--r--ncurses/tinfo/home_terminfo.c12
-rw-r--r--ncurses/tinfo/init_keytry.c10
-rw-r--r--ncurses/tinfo/lib_acs.c24
-rw-r--r--ncurses/tinfo/lib_baudrate.c21
-rw-r--r--ncurses/tinfo/lib_cur_term.c22
-rw-r--r--ncurses/tinfo/lib_data.c44
-rw-r--r--ncurses/tinfo/lib_has_cap.c8
-rw-r--r--ncurses/tinfo/lib_kernel.c18
-rw-r--r--ncurses/tinfo/lib_napms.c10
-rw-r--r--ncurses/tinfo/lib_options.c30
-rw-r--r--ncurses/tinfo/lib_print.c15
-rw-r--r--ncurses/tinfo/lib_raw.c39
-rw-r--r--ncurses/tinfo/lib_setup.c148
-rw-r--r--ncurses/tinfo/lib_termcap.c60
-rw-r--r--ncurses/tinfo/lib_termname.c10
-rw-r--r--ncurses/tinfo/lib_tgoto.c18
-rw-r--r--ncurses/tinfo/lib_ti.c12
-rw-r--r--ncurses/tinfo/lib_tparm.c52
-rw-r--r--ncurses/tinfo/lib_tputs.c32
-rw-r--r--ncurses/tinfo/lib_ttyflags.c46
-rw-r--r--ncurses/tinfo/lib_win32con.c414
-rw-r--r--ncurses/tinfo/lib_win32util.c11
-rw-r--r--ncurses/tinfo/make_hash.c51
-rw-r--r--ncurses/tinfo/make_keys.c25
-rw-r--r--ncurses/tinfo/name_match.c16
-rw-r--r--ncurses/tinfo/obsolete.c14
-rw-r--r--ncurses/tinfo/parse_entry.c56
-rw-r--r--ncurses/tinfo/read_entry.c42
-rw-r--r--ncurses/tinfo/read_termcap.c78
-rw-r--r--ncurses/tinfo/strings.c14
-rw-r--r--ncurses/tinfo/tinfo_driver.c125
-rw-r--r--ncurses/tinfo/trim_sgr0.c98
-rw-r--r--ncurses/tinfo/write_entry.c76
-rw-r--r--ncurses/trace/lib_trace.c22
-rw-r--r--ncurses/trace/lib_traceatr.c35
-rw-r--r--ncurses/trace/lib_tracebits.c22
-rw-r--r--ncurses/trace/lib_tracechr.c10
-rw-r--r--ncurses/trace/lib_tracedmp.c8
-rw-r--r--ncurses/trace/lib_tracemse.c10
-rw-r--r--ncurses/trace/trace_buf.c26
-rw-r--r--ncurses/trace/trace_tries.c10
-rw-r--r--ncurses/trace/varargs.c38
-rw-r--r--ncurses/trace/visbuf.c24
-rwxr-xr-xncurses/tty/MKexpanded.sh11
-rw-r--r--ncurses/tty/hardscroll.c16
-rw-r--r--ncurses/tty/hashmap.c26
-rw-r--r--ncurses/tty/lib_mvcur.c84
-rw-r--r--ncurses/tty/lib_tstp.c16
-rw-r--r--ncurses/tty/lib_twait.c12
-rw-r--r--ncurses/tty/lib_vidattr.c12
-rw-r--r--ncurses/tty/tty_update.c48
-rw-r--r--ncurses/wcwidth.h966
-rw-r--r--ncurses/widechar/charable.c9
-rw-r--r--ncurses/widechar/lib_add_wch.c12
-rw-r--r--ncurses/widechar/lib_box_set.c6
-rw-r--r--ncurses/widechar/lib_cchar.c8
-rw-r--r--ncurses/widechar/lib_get_wch.c10
-rw-r--r--ncurses/widechar/lib_get_wstr.c8
-rw-r--r--ncurses/widechar/lib_hline_set.c6
-rw-r--r--ncurses/widechar/lib_in_wch.c8
-rw-r--r--ncurses/widechar/lib_in_wchnstr.c10
-rw-r--r--ncurses/widechar/lib_ins_wch.c53
-rw-r--r--ncurses/widechar/lib_inwstr.c33
-rw-r--r--ncurses/widechar/lib_key_name.c6
-rw-r--r--ncurses/widechar/lib_pecho_wchar.c6
-rw-r--r--ncurses/widechar/lib_slk_wset.c8
-rw-r--r--ncurses/widechar/lib_unget_wch.c10
-rw-r--r--ncurses/widechar/lib_vid_attr.c26
-rw-r--r--ncurses/widechar/lib_vline_set.c6
-rw-r--r--ncurses/widechar/lib_wacs.c8
-rw-r--r--ncurses/widechar/lib_wunctrl.c13
-rw-r--r--ncurses/widechar/widechars.c12
-rw-r--r--ncurses/win32con/gettimeofday.c9
-rw-r--r--ncurses/win32con/wcwidth.c13
-rw-r--r--ncurses/win32con/win32_driver.c101
-rw-r--r--ncurses/win32con/win_driver.c2282
182 files changed, 3895 insertions, 4872 deletions
diff --git a/ncurses/Makefile.in b/ncurses/Makefile.in
index ae198df675a4..fbe2153baa7e 100644
--- a/ncurses/Makefile.in
+++ b/ncurses/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.184 2024/01/19 12:00:00 tom Exp $
+# $Id: Makefile.in,v 1.194 2025/10/25 17:29:43 tom Exp $
##############################################################################
-# Copyright 2018-2022,2024 Thomas E. Dickey #
+# Copyright 2018-2024,2025 Thomas E. Dickey #
# Copyright 1998-2017,2018 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -50,14 +50,14 @@ SHELL = @SHELL@
VPATH = @srcdir@
THIS = Makefile
-TOP_MFLAGS = @cf_cv_makeflags@ DESTDIR="$(DESTDIR)" RPATH_LIST="$(RPATH_LIST)"
@SET_MAKE@
+@SET_DESTDIR@
+TOP_MFLAGS = DESTDIR="$(DESTDIR)" RPATH_LIST="$(RPATH_LIST)"
x = @EXEEXT@
o = .@OBJEXT@
MODEL = @DFT_LWR_MODEL@
-DESTDIR = @DESTDIR@
top_srcdir = @top_srcdir@
srcdir = @srcdir@
prefix = @prefix@
@@ -69,7 +69,9 @@ datarootdir = @datarootdir@
datadir = @datadir@
includesubdir = @includesubdir@
-INCLUDEDIR = $(DESTDIR)$(includedir)$(includesubdir)
+INCLUDEDIR = $(DESTDIR)$(includedir@MERGE_PREFIX@)$(includesubdir)
+BINDIR = $(DESTDIR)$(bindir@MERGE_PREFIX@)
+LIBDIR = $(DESTDIR)$(libdir@MERGE_PREFIX@)
PACKAGE = @PACKAGE@
@@ -190,7 +192,6 @@ HEADER_DEPS = @INTERNALS_HDR@ \
$(INCDIR)/nc_string.h \
$(INCDIR)/nc_termios.h \
$(INCDIR)/nc_tparm.h \
- $(INCDIR)/nc_win32.h \
$(INCDIR)/term_entry.h \
$(srcdir)/curses.priv.h \
$(srcdir)/new_pair.h \
@@ -206,6 +207,7 @@ TEST_PROGS = \
hashmap$x \
lib_mvcur$x \
link_test$x \
+ report_ctype$x \
report_hashing$x
LOCAL_LIBDIR = @top_builddir@/lib
@@ -235,8 +237,8 @@ all libs :: $(AUTO_SRC) ../lib $(LIBRARIES)
sources: $(AUTO_SRC)
-$(DESTDIR)$(bindir) \
-$(DESTDIR)$(libdir) :
+$(BINDIR) \
+$(LIBDIR) :
mkdir -p $@
../lib : ; mkdir $@
@@ -258,17 +260,23 @@ make_keys$(BUILD_EXEEXT) : \
$(tinfo)/make_keys.c \
./names.c
$(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(tinfo)/make_keys.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
+ @./$@ "-?"
+ @echo "... made $@"
make_hash$(BUILD_EXEEXT) : \
build.priv.h \
$(tinfo)/make_hash.c \
../include/hashsize.h
$(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(tinfo)/make_hash.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
+ @./$@ "-?"
+ @echo "... made $@"
report_offsets$(BUILD_EXEEXT) : \
$(srcdir)/curses.priv.h \
$(srcdir)/report_offsets.c
$(BUILD_CC) -o $@ $(BUILD_CPPFLAGS) $(BUILD_CCFLAGS) $(srcdir)/report_offsets.c $(BUILD_LDFLAGS) $(BUILD_LIBS)
+ @./$@ "-?"
+ @echo "... made $@"
./report_offsets$(BUILD_EXEEXT)
./expanded.c : $(srcdir)/curses.priv.h $(serial)/MKexpanded.sh
@@ -314,6 +322,7 @@ clean :: mostlyclean
-rm -f $(AUTO_SRC)
-rm -f make_keys$(BUILD_EXEEXT)
-rm -f make_hash$(BUILD_EXEEXT)
+ -rm -f report_ctype$(BUILD_EXEEXT)
-rm -f report_offsets$(BUILD_EXEEXT)
-rm -rf .libs *.dSYM *.map
@@ -323,7 +332,9 @@ distclean :: clean
realclean :: distclean
# These rules are used to allow "make -n" to work on a clean directory-tree
+../include/curses.h \
../include/hashsize.h \
+../include/ncurses_def.h \
../include/parametrized.h \
../include/term.h :
( cd ../include && $(MAKE) $(TOP_MFLAGS) )
@@ -355,10 +366,17 @@ link_test$x : ./link_test.c $(TEST_DEPS) \
../@DFT_OBJ_SUBDIR@/dump_entry$o:
( cd ../progs && $(MAKE) ../@DFT_OBJ_SUBDIR@/dump_entry$o )
+report_ctype$x : \
+ $(srcdir)/curses.priv.h \
+ $(srcdir)/report_ctype.c $(TEST_DEPS)
+ @ECHO_LD@ $(CC) -o $@ $(CFLAGS_DEFAULT) $(srcdir)/report_ctype.c $(TEST_LDFLAGS)
+ @echo "... made $@"
+ ./report_ctype$x
+
report_hashing$x : \
$(srcdir)/curses.priv.h \
$(srcdir)/report_hashing.c $(TEST_DEPS)
- @ECHO_LD@ $(CC) -o $@ $(CFLAGS_DEFAULT) report_hashing.c $(TEST_LDFLAGS)
+ @ECHO_LD@ $(CC) -o $@ $(CFLAGS_DEFAULT) $(srcdir)/report_hashing.c $(TEST_LDFLAGS)
# Verify that each header-file can be compiled without including another.
@MAKE_PHONY@.PHONY : check_headers
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);
diff --git a/ncurses/build.priv.h b/ncurses/build.priv.h
index 9014e74abf09..0e2fdeccb4af 100644
--- a/ncurses/build.priv.h
+++ b/ncurses/build.priv.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey *
+ * Copyright 2019-2020,2024 Thomas E. Dickey *
* Copyright 2010,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -32,7 +32,7 @@
****************************************************************************/
/*
- * $Id: build.priv.h,v 1.12 2020/02/02 23:34:34 tom Exp $
+ * $Id: build.priv.h,v 1.13 2024/12/14 22:32:09 tom Exp $
*
* build.priv.h
*
@@ -78,7 +78,7 @@ extern "C" {
#define EXIT_FAILURE 1
#endif
-#define FreeAndNull(p) do { free(p); p = 0; } while (0)
+#define FreeAndNull(p) do { free(p); p = NULL; } while (0)
#define UChar(c) ((unsigned char)(c))
#define SIZEOF(v) (sizeof(v) / sizeof(v[0]))
diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h
index 68cda17e71a3..8999ecdf6e75 100644
--- a/ncurses/curses.priv.h
+++ b/ncurses/curses.priv.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2023,2024 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2017,2018 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -35,7 +35,7 @@
****************************************************************************/
/*
- * $Id: curses.priv.h,v 1.687 2024/04/23 22:28:25 tom Exp $
+ * $Id: curses.priv.h,v 1.741 2025/12/27 21:46:04 tom Exp $
*
* curses.priv.h
*
@@ -59,7 +59,7 @@ extern "C" {
#if USE_RCS_IDS
#define MODULE_ID(id) static const char Ident[] = id;
#else
-#define MODULE_ID(id) /*nothing*/
+#define MODULE_ID(id) /* nothing */
#endif
#include <stddef.h> /* for offsetof */
@@ -88,11 +88,20 @@ extern int errno;
#endif
/* Some Windows related defines */
+
#undef _NC_WINDOWS
-#if (defined(_WIN32) || defined(_WIN64))
+#if (defined(_WIN32) || defined(_WIN64__) || defined(__MSYS__))
#define _NC_WINDOWS
-#else
-#undef EXP_WIN32_DRIVER
+#endif
+
+#undef _NC_CYGWIN
+#if (defined(__MSYS__) || defined(__CYGWIN__))
+#define _NC_CYGWIN
+#endif
+
+#undef _NC_WINDOWS_NATIVE
+#if (defined(_WIN32) || defined(_WIN64))
+#define _NC_WINDOWS_NATIVE
#endif
#undef _NC_MINGW
@@ -197,7 +206,7 @@ extern int errno;
* the path separator in configure doesn't work properly. So, if building
* for MinGW, we enforce the correct Windows PATH separator
*/
-#if defined(_NC_WINDOWS)
+#if defined(_NC_WINDOWS_NATIVE) || defined(__DJGPP__)
# ifdef NCURSES_PATHSEP
# undef NCURSES_PATHSEP
# endif
@@ -223,6 +232,15 @@ extern int errno;
#endif
/*
+ * The stricmp() function is in MSVCRT, and cannot be called or linked from
+ * Cygwin runtime-dependent binaries currently. Use the POSIX strcaseccmp()
+ * function instead which is pretty much the same.
+ */
+#if defined(_NC_CYGWIN)
+#define stricmp(s1, s2) strcasecmp(s1, s2)
+#endif
+
+/*
* Not all platforms have memmove; some have an equivalent bcopy. (Some may
* have neither).
*/
@@ -293,7 +311,7 @@ extern NCURSES_EXPORT(void *) _nc_memmove (void *, const void *, size_t);
/*
* Options for terminal drivers, etc...
*/
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
#define NO_TERMINAL "unknown"
#define USE_SP_RIPOFF 1
#define USE_SP_TERMTYPE 1
@@ -348,6 +366,12 @@ typedef TRIES {
#define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
/*
+ * To make them easier to find, user-defined capabilities used within ncurses
+ * should be tagged with this macro:
+ */
+#define UserCap(name) #name
+
+/*
* Structure for palette tables
*/
@@ -379,6 +403,38 @@ typedef TRIES {
#undef KEY_EVENT /* reduce compiler-warnings with Visual C++ */
#endif
+/*
+ * Macros to make additional parameter to implement wgetch_events()
+ */
+#ifdef NCURSES_WGETCH_EVENTS
+#define EVENTLIST_0th(param) param
+#define EVENTLIST_1st(param) param
+#define EVENTLIST_2nd(param) , param
+#define TWAIT_MASK (TW_ANY | TW_EVENT)
+#else
+#define EVENTLIST_0th(param) void
+#define EVENTLIST_1st(param) /* nothing */
+#define EVENTLIST_2nd(param) /* nothing */
+#define TWAIT_MASK TW_ANY
+#endif
+
+#include <term.priv.h> /* defines TERMIOS via term.h */
+
+#if USE_TERM_DRIVER
+#if defined(TERMIOS)
+#undef USE_NAMED_PIPES
+#define USE_NAMED_PIPES 0
+#undef USE_WIN32CON_DRIVER
+#elif defined(_NC_WINDOWS)
+#include <nc_win32.h>
+#endif /* TERMIOS */
+#endif /* USE_TERM_DRIVER */
+
+#ifndef FixupPathname
+#define FixupPathname(path) /* nothing */
+#define FixupPathname2(path,buffer) /* nothing */
+#endif
+
typedef struct
{
int red, green, blue; /* what color_content() returns */
@@ -422,11 +478,10 @@ typedef union {
#include <nc_panel.h>
-#include <term.priv.h>
#include <nc_termios.h>
-#define IsPreScreen(sp) (((sp) != 0) && sp->_prescreen)
-#define HasTerminal(sp) (((sp) != 0) && (0 != ((sp)->_term)))
+#define IsPreScreen(sp) (((sp) != NULL) && sp->_prescreen)
+#define HasTerminal(sp) (((sp) != NULL) && (NULL != ((sp)->_term)))
#define IsValidScreen(sp) (HasTerminal(sp) && !IsPreScreen(sp))
#if USE_REENTRANT
@@ -790,7 +845,7 @@ typedef enum {
#if USE_SYSMOUSE
,M_SYSMOUSE /* FreeBSD sysmouse on console */
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
,M_TERM_DRIVER /* Win32 console, etc */
#endif
} MouseType;
@@ -877,6 +932,12 @@ typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
#define MAX_DELAY_MSECS 30000
/*
+ * Limit screen dimensions read from environment variables.
+ */
+#define MAX_ENV_LINES 512
+#define MAX_ENV_COLUMNS 512
+
+/*
* When converting from terminfo to termcap, check for cases where we can trim
* octal escapes down to 2-character form. It is useful for terminfo format
* also, but not as important.
@@ -890,13 +951,16 @@ typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
* The filesystem database normally uses a single-letter for the lower level
* of directories. Use a hexadecimal code for filesystems which do not
* preserve mixed-case names.
+ *
+ * The leading "./" is used in _nc_to_dospath() to decide whether to prefix
+ * the converted path with the MinGW32 base directory.
*/
#if MIXEDCASE_FILENAMES
-#define LEAF_FMT "%c"
-#define LEAF_LEN 1
+#define LEAF_FMT "./%c"
+#define LEAF_LEN 3
#else
-#define LEAF_FMT "%02x"
-#define LEAF_LEN 2
+#define LEAF_FMT "./%02x"
+#define LEAF_LEN 4
#endif
/*
@@ -910,7 +974,7 @@ typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
#define TRACEMSE_MAX (80 + (5 * 10) + (32 * 15))
#define TRACEMSE_FMT "id %2d at (%2d, %2d, %2d) state %4lx = {" /* } */
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
struct DriverTCB; /* Terminal Control Block forward declaration */
#define INIT_TERM_DRIVER() _nc_globals.term_driver = _nc_get_driver
#else
@@ -1101,7 +1165,8 @@ typedef struct screen {
MouseFormat _mouse_format; /* type of xterm mouse protocol */
NCURSES_CONST char *_mouse_xtermcap; /* string to enable/disable mouse */
MEVENT _mouse_events[EV_MAX]; /* hold the last mouse event seen */
- MEVENT *_mouse_eventp; /* next free slot in event queue */
+ MEVENT *_mouse_readp; /* read pointer into event queue */
+ MEVENT *_mouse_writep; /* write pointer into event queue */
/*
* These are data that support the proper handling of the panel stack on an
@@ -1187,7 +1252,7 @@ typedef struct screen {
int _sysmouse_new_buttons;
#endif
-#if defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)
+#if USE_TERM_DRIVER || USE_NAMED_PIPES
MEVENT _drv_mouse_fifo[FIFO_SIZE];
int _drv_mouse_head;
int _drv_mouse_tail;
@@ -1265,7 +1330,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
#define WINDOW_EXT(w,m) (((WINDOWLIST *)((void *)((char *)(w) - offsetof(WINDOWLIST, win))))->m)
#ifdef USE_SP_WINDOWLIST
-#define SP_INIT_WINDOWLIST(sp) WindowList(sp) = 0
+#define SP_INIT_WINDOWLIST(sp) WindowList(sp) = NULL
#else
#define SP_INIT_WINDOWLIST(sp) /* nothing */
#endif
@@ -1282,7 +1347,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
sp->_cursor = -1; \
SP_INIT_WINDOWLIST(sp); \
sp->_outch = NCURSES_OUTC_FUNC; \
- sp->jump = 0 \
+ sp->jump = NULL \
/* usually in <limits.h> */
#ifndef UCHAR_MAX
@@ -1376,6 +1441,12 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
#define NulColor /* nothing */
#endif
+#if NCURSES_RGB_COLORS
+#define NulDirect , 0
+#else
+#define NulDirect /* nothing */
+#endif
+
#if CCHARW_MAX > 6
#define NulChar 0,0,0,0,0
#elif CCHARW_MAX > 5
@@ -1397,7 +1468,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
#define RemAttr(c,a) AttrOf(c) &= ~((a) & A_ATTRIBUTES)
#define SetAttr(c,a) AttrOf(c) = ((a) & A_ATTRIBUTES) | WidecExt(c)
-#define NewChar2(c,a) { a, { c, NulChar } NulColor }
+#define NewChar2(c,a) { a, { c, NulChar } NulColor NulDirect }
#define NewChar(ch) NewChar2(ChCharOf(ch), ChAttrOf(ch))
#if CCHARW_MAX > 1
@@ -1427,7 +1498,7 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
#define PUTC(ch) do { if(!isWidecExt(ch)) { \
if (Charable(ch)) { \
TR_PUTC(CharOf(ch)); \
- NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \
+ NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) CharOf(ch)); \
COUNT_OUTCHARS(1); \
} else { \
for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { \
@@ -1440,15 +1511,19 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
if (PUTC_n <= 0) { \
if (PUTC_ch && is8bits(PUTC_ch) && PUTC_i == 0) { \
TR_PUTC(CharOf(ch)); \
- NCURSES_OUTC_FUNC (NCURSES_SP_ARGx CharOf(ch)); \
+ NCURSES_OUTC_FUNC (NCURSES_SP_ARGx (int) CharOf(ch)); \
} \
break; \
- } else { \
+ } else if (PUTC_n > 1 || !is8bits(PUTC_ch)) { \
int PUTC_j; \
for (PUTC_j = 0; PUTC_j < PUTC_n; ++PUTC_j) { \
TR_PUTC(PUTC_buf[PUTC_j]); \
NCURSES_OUTC_FUNC (NCURSES_SP_ARGx PUTC_buf[PUTC_j]); \
} \
+ } else { \
+ PUTC_buf[0] = (char) PUTC_ch; \
+ TR_PUTC(PUTC_buf[0]); \
+ NCURSES_OUTC_FUNC (NCURSES_SP_ARGx PUTC_buf[0]); \
} \
} \
COUNT_OUTCHARS(PUTC_i); \
@@ -1520,10 +1595,12 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
#define CHANGED -1
#define LEGALYX(w, y, x) \
- ((w) != 0 && \
+ ((w) != NULL && \
((x) >= 0 && (x) <= (w)->_maxx && \
(y) >= 0 && (y) <= (w)->_maxy))
+#define OK_DIMENSION(n) ((NCURSES_SIZE_T)(n) == (n) && (n) > 0)
+
#define CHANGED_CELL(line,col) \
if (line->firstchar == _NOCHANGE) \
line->firstchar = line->lastchar = (NCURSES_SIZE_T) (col); \
@@ -1551,12 +1628,12 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch;
#include <nc_alloc.h>
#include <nc_access.h>
-#define FreeIfNeeded(p) if ((p) != 0) free(p)
+#define FreeIfNeeded(p) if ((p) != NULL) free(p)
/* FreeAndNull() is not a comma-separated expression because some compilers
* do not accept a mixture of void with values.
*/
-#define FreeAndNull(p) do { free(p); p = 0; } while (0)
+#define FreeAndNull(p) do { free(p); p = NULL; } while (0)
#ifdef EXP_OOM_TESTING
extern NCURSES_EXPORT(void *) _nc_oom_malloc(size_t size);
@@ -1578,21 +1655,21 @@ extern NCURSES_EXPORT(char *) _nc_oom_strdup(const char *ptr);
#define TYPE_MALLOC(type, size, name) \
do { \
name = typeMalloc(type, size); \
- if (name == 0) \
+ if (name == NULL) \
_nc_err_abort(MSG_NO_MEMORY); \
} while (0)
#define TYPE_CALLOC(type, size, name) \
do { \
name = typeCalloc(type, size); \
- if (name == 0) \
+ if (name == NULL) \
_nc_err_abort(MSG_NO_MEMORY); \
} while (0)
#define TYPE_REALLOC(type, size, name) \
do { \
name = typeRealloc(type, size, name); \
- if (name == 0) \
+ if (name == NULL) \
_nc_err_abort(MSG_NO_MEMORY); \
} while (0)
@@ -1624,8 +1701,8 @@ extern NCURSES_EXPORT(char *) _nc_oom_strdup(const char *ptr);
/*
* Standardize/simplify common loops
*/
-#define each_screen(p) p = _nc_screen_chain; p != 0; p = (p)->_next_screen
-#define each_window(sp,p) p = WindowList(sp); p != 0; p = (p)->next
+#define each_screen(p) p = _nc_screen_chain; p != NULL; p = (p)->_next_screen
+#define each_window(sp,p) p = WindowList(sp); p != NULL; p = (p)->next
#define each_ripoff(p) p = safe_ripoff_stack; (p - safe_ripoff_stack) < N_RIPS; ++p
/*
@@ -1637,8 +1714,8 @@ extern NCURSES_EXPORT(char *) _nc_oom_strdup(const char *ptr);
#define T_CREATE(fmt) "create :" fmt
#define T_RETURN(fmt) "return }" fmt
-#define NonNull(s) ((s) != 0 ? s : "<null>")
-#define NonEmpty(s) ((s) != 0 && *(s) != '\0')
+#define NonNull(s) ((s) != NULL ? s : "<null>")
+#define NonEmpty(s) ((s) != NULL && *(s) != '\0')
#ifdef TRACE
@@ -1705,7 +1782,7 @@ typedef void VoidFunc(void);
#define returnPtrDB(rc) do { TR(TRACE_DATABASE,(T_RETURN("%p"), (rc))); return (rc); } while (0)
#define returnVoidDB do { TR(TRACE_DATABASE,(T_RETURN(""))); return; } while (0)
-extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (int);
+extern NCURSES_EXPORT(bool) _nc_retrace_bool (bool);
extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *);
extern NCURSES_EXPORT(SCREEN *) _nc_retrace_sp (SCREEN *);
extern NCURSES_EXPORT(WINDOW *) _nc_retrace_win (WINDOW *);
@@ -1830,20 +1907,20 @@ extern NCURSES_EXPORT(void) name (void); \
TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
#define DelCharCost(sp,count) \
- ((parm_dch != 0) \
+ ((parm_dch != NULL) \
? sp->_dch_cost \
- : ((delete_character != 0) \
+ : ((delete_character != NULL) \
? (sp->_dch1_cost * count) \
- : INFINITY))
+ : NC_INFINITY))
#define InsCharCost(sp,count) \
- ((parm_ich != 0) \
+ ((parm_ich != NULL) \
? sp->_ich_cost \
: ((enter_insert_mode && exit_insert_mode) \
? sp->_smir_cost + sp->_rmir_cost + (sp->_ip_cost * count) \
- : ((insert_character != 0) \
+ : ((insert_character != NULL) \
? ((sp->_ich1_cost + sp->_ip_cost) * count) \
- : INFINITY)))
+ : NC_INFINITY)))
#if USE_XMC_SUPPORT
#define UpdateAttrs(sp,c) if (!SameAttrOf(SCREEN_ATTRS(sp), c)) { \
@@ -1864,21 +1941,6 @@ extern NCURSES_EXPORT(void) name (void); \
}
#endif
-/*
- * Macros to make additional parameter to implement wgetch_events()
- */
-#ifdef NCURSES_WGETCH_EVENTS
-#define EVENTLIST_0th(param) param
-#define EVENTLIST_1st(param) param
-#define EVENTLIST_2nd(param) , param
-#define TWAIT_MASK (TW_ANY | TW_EVENT)
-#else
-#define EVENTLIST_0th(param) void
-#define EVENTLIST_1st(param) /* nothing */
-#define EVENTLIST_2nd(param) /* nothing */
-#define TWAIT_MASK TW_ANY
-#endif
-
#if NCURSES_EXPANDED && NCURSES_EXT_FUNCS
#undef toggle_attr_on
@@ -1928,7 +1990,7 @@ extern NCURSES_EXPORT(void) _nc_expanded (void);
#endif
#define save_ttytype(termp) \
- if (TerminalType(termp).term_names != 0) { \
+ if (TerminalType(termp).term_names != NULL) { \
_nc_STRNCPY(ttytype, \
TerminalType(termp).term_names, \
NAMESIZE - 1); \
@@ -1936,7 +1998,7 @@ extern NCURSES_EXPORT(void) _nc_expanded (void);
}
#if !NCURSES_WCWIDTH_GRAPHICS
-extern NCURSES_EXPORT(int) _nc_wacs_width(unsigned);
+extern NCURSES_EXPORT(int) _nc_wacs_width(wchar_t);
#else
#define _nc_wacs_width(ch) wcwidth(ch)
#endif
@@ -2006,7 +2068,7 @@ extern NCURSES_EXPORT(void) _nc_reserve_pairs(SCREEN *, int);
extern NCURSES_EXPORT(void) _nc_change_pair(SCREEN *, int);
#define ReservePairs(sp,want) \
- if ((sp->_color_pairs == 0) || (want >= sp->_pair_alloc)) \
+ if ((sp->_color_pairs == NULL) || (want >= sp->_pair_alloc)) \
_nc_reserve_pairs(sp, want)
/* lib_getch.c */
@@ -2015,8 +2077,12 @@ extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, int *, int EVENTLIST_2nd(_nc_eve
/* lib_insch.c */
extern NCURSES_EXPORT(int) _nc_insert_ch(SCREEN *, WINDOW *, chtype);
+/* lib_mouse.c */
+extern NCURSES_EXPORT(bool) _nc_has_mouse (const SCREEN *);
+
/* lib_mvcur.c */
-#define INFINITY 1000000 /* cost: too high to use */
+#define NC_INFINITY 1000000 /* cost: too high to use */
+#define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */
extern NCURSES_EXPORT(int) _nc_mvcur(int yold, int xold, int ynew, int xnew);
@@ -2030,16 +2096,9 @@ extern NCURSES_EXPORT(void) _nc_screen_init (void);
extern NCURSES_EXPORT(void) _nc_screen_resume (void);
extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
-/* lib_mouse.c */
-extern NCURSES_EXPORT(bool) _nc_has_mouse (SCREEN *);
-
-/* lib_mvcur.c */
-#define INFINITY 1000000 /* cost: too high to use */
-#define BAUDBYTE 9 /* 9 = 7 bits + 1 parity + 1 stop */
-
/* lib_setup.c */
extern NCURSES_EXPORT(char *) _nc_get_locale(void);
-extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
+extern NCURSES_EXPORT(bool) _nc_unicode_locale(void);
extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(TERMINAL *);
extern NCURSES_EXPORT(int) _nc_setupterm(const char *, int, int *, int);
extern NCURSES_EXPORT(void) _nc_tinfo_cmdch(TERMINAL *, int);
@@ -2049,7 +2108,7 @@ extern NCURSES_EXPORT(SCREEN *) _nc_find_prescr(void);
extern NCURSES_EXPORT(void) _nc_forget_prescr(void);
#else
#define _nc_find_prescr() _nc_prescreen.allocated
-#define _nc_forget_prescr() _nc_prescreen.allocated = 0
+#define _nc_forget_prescr() _nc_prescreen.allocated = NULL
#endif
/* lib_set_term.c */
@@ -2133,7 +2192,7 @@ extern NCURSES_EXPORT(int) _nc_access (const char *, int);
extern NCURSES_EXPORT(int) _nc_baudrate (int);
extern NCURSES_EXPORT(int) _nc_freewin (WINDOW *);
extern NCURSES_EXPORT(int) _nc_getenv_num (const char *);
-extern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, int);
+extern NCURSES_EXPORT(int) _nc_keypad (SCREEN *, bool);
extern NCURSES_EXPORT(int) _nc_ospeed (int);
extern NCURSES_EXPORT(int) _nc_outch (int);
extern NCURSES_EXPORT(int) _nc_putchar (int);
@@ -2141,13 +2200,13 @@ extern NCURSES_EXPORT(int) _nc_putp(const char *, const char *);
extern NCURSES_EXPORT(int) _nc_putp_flush(const char *, const char *);
extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE2 *const);
extern NCURSES_EXPORT(int) _nc_setup_tinfo(const char *, TERMTYPE2 *);
-extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, int, int);
-extern NCURSES_EXPORT(int) _nc_timed_wait (SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
+extern NCURSES_EXPORT(int) _nc_setupscreen (int, int, FILE *, bool, int);
+extern NCURSES_EXPORT(int) _nc_timed_wait (const SCREEN *, int, int, int * EVENTLIST_2nd(_nc_eventlist *));
extern NCURSES_EXPORT(int) _nc_trans_string (char *, const char *);
extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE2 *const);
extern NCURSES_EXPORT(void) _nc_do_color (int, int, int, NCURSES_OUTC);
extern NCURSES_EXPORT(void) _nc_flush (void);
-extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, TERMTYPE2 *);
+extern NCURSES_EXPORT(void) _nc_free_entry (ENTRY *, const TERMTYPE2 *);
extern NCURSES_EXPORT(void) _nc_freeall (void);
extern NCURSES_EXPORT(void) _nc_hash_map (void);
extern NCURSES_EXPORT(void) _nc_init_keytry (SCREEN *);
@@ -2232,7 +2291,7 @@ extern NCURSES_EXPORT(int) _nc_eventlist_timeout(_nc_eventlist *);
*/
#if USE_WIDEC_SUPPORT
-#if defined(_NC_WINDOWS) && !defined(_NC_MSC) && !defined(EXP_WIN32_DRIVER)
+#if defined(_NC_WINDOWS_NATIVE) && !defined(_NC_MSC) && !USE_NAMED_PIPES
/*
* MinGW has wide-character functions, but they do not work correctly.
*/
@@ -2246,13 +2305,7 @@ extern int __MINGW_NOTHROW _nc_mbtowc(wchar_t *, const char *, size_t);
extern int __MINGW_NOTHROW _nc_mblen(const char *, size_t);
#define mblen(s,n) _nc_mblen(s, n)
-#endif /* _NC_WINDOWS && !_NC_MSC */
-
-#if defined(_NC_WINDOWS) || defined(_NC_MINGW)
-/* see wcwidth.c */
-extern NCURSES_EXPORT(int) mk_wcwidth(wchar_t);
-#define wcwidth(ucs) _nc_wcwidth(ucs)
-#endif
+#endif /* _NC_WINDOWS_NATIVE && !_NC_MSC */
#if HAVE_MBTOWC && HAVE_MBLEN
#define reset_mbytes(state) IGNORE_RC(mblen(NULL, (size_t) 0)), IGNORE_RC(mbtowc(NULL, NULL, (size_t) 0))
@@ -2283,7 +2336,7 @@ extern NCURSES_EXPORT_VAR(int *) _nc_oldnums;
#define USE_SETBUF_0 0
-#define NC_OUTPUT(sp) ((sp != 0 && sp->_ofp != 0) ? sp->_ofp : stdout)
+#define NC_OUTPUT(sp) ((sp != NULL && sp->_ofp != NULL) ? sp->_ofp : stdout)
/*
* On systems with a broken linker, define 'SP' as a function to force the
@@ -2301,7 +2354,7 @@ extern NCURSES_EXPORT(void) _nc_set_screen (SCREEN *);
/* current screen is private data; avoid possible linking conflicts too */
extern NCURSES_EXPORT_VAR(SCREEN *) SP;
#define CURRENT_SCREEN SP
-#define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != 0)
+#define _nc_alloc_screen() ((SP = _nc_alloc_screen_sp()) != NULL)
#define _nc_set_screen(sp) SP = sp
#endif
@@ -2357,14 +2410,14 @@ extern NCURSES_EXPORT(int) _nc_get_tty_mode(TTY *);
#define SetSafeOutcWrapper(outc) \
SCREEN* sp = CURRENT_SCREEN; \
struct screen outc_wrapper; \
- if (sp==0) { \
+ if (sp == NULL) { \
sp = &outc_wrapper; \
memset(sp,0,sizeof(struct screen)); \
sp->_outch = _nc_outc_wrapper; \
}\
sp->jump = outc
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
typedef struct _termInfo
{
@@ -2461,7 +2514,7 @@ extern NCURSES_EXPORT(void) _nc_get_screensize_ex(SCREEN *, TERMINAL *, int
* Entrypoints which are actually provided in the terminal driver, which would
* be an sp-name otherwise.
*/
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
#define TINFO_HAS_KEY _nc_tinfo_has_key
#define TINFO_DOUPDATE _nc_tinfo_doupdate
#define TINFO_MVCUR _nc_tinfo_mvcur
@@ -2474,14 +2527,23 @@ extern NCURSES_EXPORT(int) TINFO_MVCUR(SCREEN*, int, int, int, int);
#define TINFO_MVCUR NCURSES_SP_NAME(_nc_mvcur)
#endif
-#if defined(EXP_WIN32_DRIVER)
-#include <nc_win32.h>
+#ifdef _NC_WINDOWS
+#if USE_WIDEC_SUPPORT
+#include <wchar.h>
+#endif
+#include <tchar.h>
+#include <io.h>
+#elif defined(_NC_WINDOWS_NATIVE)
+#include <tchar.h>
+#include <io.h>
+#elif defined(__EMX__)
+#include <io.h>
#endif
/*
* Entrypoints using an extra parameter with the terminal driver.
*/
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, TERMINAL *, int *, int *);
extern NCURSES_EXPORT(int) _nc_setupterm_ex(TERMINAL **, const char *, int , int *, int);
#define TINFO_GET_SIZE(sp, tp, lp, cp) \
@@ -2500,33 +2562,46 @@ extern NCURSES_EXPORT(void) _nc_get_screensize(SCREEN *, int *, int *);
_nc_setupterm(name, fd, err, reuse)
#endif /* !USE_TERM_DRIVER */
-#ifdef EXP_WIN32_DRIVER
-extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER;
-#else
-#ifdef USE_TERM_DRIVER
-#if defined(USE_WIN32CON_DRIVER)
-#include <nc_mingw.h>
+#if USE_TERM_DRIVER
extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_WIN_DRIVER;
-extern NCURSES_EXPORT(int) _nc_mingw_isatty(int fd);
-extern NCURSES_EXPORT(int) _nc_mingw_isconsole(int fd);
-extern NCURSES_EXPORT(int) _nc_mingw_console_read(
- SCREEN *sp,
- HANDLE fd,
- int *buf);
-extern NCURSES_EXPORT(int) _nc_mingw_testmouse(
- SCREEN * sp,
- HANDLE fd,
- int delay EVENTLIST_2nd(_nc_eventlist*));
-#else
-#endif
extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER;
#endif /* USE_TERM_DRIVER */
-#endif /* EXP_WIN32_DRIVER */
-#if defined(USE_TERM_DRIVER) && defined(EXP_WIN32_DRIVER)
+#ifdef TERMIOS
+#define USE_WINCONMODE 0
+#elif defined(USE_WIN32CON_DRIVER)
+#define USE_WINCONMODE 1
+extern NCURSES_EXPORT(int) _nc_console_setmode(void* handle, const ConsoleMode* arg);
+extern NCURSES_EXPORT(int) _nc_console_getmode(void* handle, ConsoleMode* arg);
+extern NCURSES_EXPORT(bool) _nc_console_checkinit(bool assumeTermInfo);
+extern NCURSES_EXPORT(void*) _nc_console_fd2handle(int fd);
+extern NCURSES_EXPORT(WORD) _nc_console_MapColor(bool fore, int color);
+extern NCURSES_EXPORT(int) _nc_console_flush(void* handle);
+extern NCURSES_EXPORT(bool) _nc_console_get_SBI(void);
+extern NCURSES_EXPORT(HANDLE) _nc_console_handle(int fd);
+extern NCURSES_EXPORT(int) _nc_console_isatty(int fd);
+extern NCURSES_EXPORT(bool) _nc_console_keyExist(int keycode);
+extern NCURSES_EXPORT(int) _nc_console_keyok(int keycode, int flag);
+extern NCURSES_EXPORT(int) _nc_console_read(SCREEN *sp, HANDLE fd, int *buf);
+extern NCURSES_EXPORT(bool) _nc_console_restore(void);
+extern NCURSES_EXPORT(void) _nc_console_selectActiveHandle(void);
+extern NCURSES_EXPORT(void) _nc_console_set_scrollback(bool normal, CONSOLE_SCREEN_BUFFER_INFO * info);
+extern NCURSES_EXPORT(void) _nc_console_size(int *Lines, int *Cols);
+extern NCURSES_EXPORT(int) _nc_console_test(int fd);
+extern NCURSES_EXPORT(int) _nc_console_testmouse(const SCREEN *sp, HANDLE fd, int delay EVENTLIST_2nd(_nc_eventlist*));
+extern NCURSES_EXPORT(int) _nc_console_twait(const SCREEN *sp, HANDLE hdl,int mode,int msec,int *left EVENTLIST_2nd(_nc_eventlist * evl));
+extern NCURSES_EXPORT(int) _nc_console_vt_supported(void);
+
+#ifdef _NC_CHECK_MINTTY
+extern NCURSES_EXPORT(int) _nc_console_checkmintty(int fd, LPHANDLE pMinTTY);
+#endif
+
+#else
+#error unsupported driver configuration
+#endif /* USE_WIN32CON_DRIVER */
+
+#if USE_TERM_DRIVER && defined(USE_WIN32CON_DRIVER)
#define NC_ISATTY(fd) (0 != _nc_console_isatty(fd))
-#elif defined(USE_TERM_DRIVER) && defined(USE_WIN32CON_DRIVER)
-#define NC_ISATTY(fd) _nc_mingw_isatty(fd)
#else
#define NC_ISATTY(fd) isatty(fd)
#endif
@@ -2539,20 +2614,20 @@ extern NCURSES_EXPORT_VAR(TERM_DRIVER) _nc_TINFO_DRIVER;
&& (value = ttyname(fd)) != NULL \
&& strncmp(value, "/dev/pts/", 9))
-#ifdef USE_TERM_DRIVER
-# define IsTermInfo(sp) ((TCBOf(sp) != 0) && ((TCBOf(sp)->drv->isTerminfo)))
-# define HasTInfoTerminal(sp) ((0 != TerminalOf(sp)) && IsTermInfo(sp))
-# if defined(EXP_WIN32_DRIVER)
+#if USE_TERM_DRIVER
+# define IsTermInfo(sp) ((TCBOf(sp) != NULL) && ((TCBOf(sp)->drv != NULL)) && ((TCBOf(sp)->drv->isTerminfo)))
+# define HasTInfoTerminal(sp) ((NULL != TerminalOf(sp)) && IsTermInfo(sp))
+# if USE_NAMED_PIPES
# define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_console_test(TerminalOf(sp)->Filedes))
# elif defined(USE_WIN32CON_DRIVER)
-# define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_mingw_isconsole(TerminalOf(sp)->Filedes))
+# define IsTermInfoOnConsole(sp) (IsTermInfo(sp) && _nc_console_test(TerminalOf(sp)->Filedes))
# else
# define IsTermInfoOnConsole(sp) FALSE
# endif
#else
# define IsTermInfo(sp) TRUE
-# define HasTInfoTerminal(sp) (0 != TerminalOf(sp))
-# if defined(EXP_WIN32_DRIVER)
+# define HasTInfoTerminal(sp) (NULL != TerminalOf(sp))
+# if USE_NAMED_PIPES
# define IsTermInfoOnConsole(sp) _nc_console_test(TerminalOf(sp)->Filedes)
# else
# define IsTermInfoOnConsole(sp) FALSE
@@ -2599,7 +2674,7 @@ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_putp_flush)(SCREEN*, const c
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_ripoffline)(SCREEN*, int, int (*)(WINDOW *,int));
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_scrolln)(SCREEN*, int, int, int, int);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_set_tty_mode)(SCREEN*, TTY*);
-extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, int, int);
+extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_setupscreen)(SCREEN**, int, int, FILE *, bool, int);
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(_nc_tgetent)(SCREEN*,char*,const char *);
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_color)(SCREEN*, int, int, int, NCURSES_SP_OUTC);
extern NCURSES_EXPORT(void) NCURSES_SP_NAME(_nc_do_xmc_glitch)(SCREEN*, attr_t);
@@ -2654,6 +2729,22 @@ extern NCURSES_EXPORT(int) _nc_conv_to_utf8(unsigned char *, unsigned, unsigned)
extern NCURSES_EXPORT(int) _nc_conv_to_utf32(unsigned *, const char *, unsigned);
#endif
+#ifdef _NC_WINDOWS
+#if USE_WIDEC_SUPPORT
+#define write_screen WriteConsoleOutputW
+#define read_screen ReadConsoleOutputW
+#define read_keycode ReadConsoleInputW
+#define KeyEventChar KeyEvent.uChar.UnicodeChar
+#define CharInfoChar Char.UnicodeChar
+#else
+#define write_screen WriteConsoleOutput
+#define read_screen ReadConsoleOutput
+#define read_keycode ReadConsoleInput
+#define KeyEventChar KeyEvent.uChar.AsciiChar
+#define CharInfoChar Char.AsciiChar
+#endif
+#endif /* _NC_WINDOWS */
+
#ifdef __cplusplus
}
#endif
diff --git a/ncurses/llib-lncurses b/ncurses/llib-lncurses
index 5069c22221a1..7c82913e758e 100644
--- a/ncurses/llib-lncurses
+++ b/ncurses/llib-lncurses
@@ -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 *
@@ -1475,7 +1475,7 @@ int mouseinterval(
#undef _nc_has_mouse
NCURSES_BOOL _nc_has_mouse(
- SCREEN *sp)
+ const SCREEN *sp)
{ return(*(NCURSES_BOOL *)0); }
#undef has_mouse_sp
@@ -2032,7 +2032,7 @@ int _nc_setupscreen_sp(
int slines,
int scolumns,
FILE *output,
- int filtered,
+ NCURSES_BOOL filtered,
int slk_format)
{ return(*(int *)0); }
@@ -2041,7 +2041,7 @@ int _nc_setupscreen(
int slines,
int scolumns,
FILE *output,
- int filtered,
+ NCURSES_BOOL filtered,
int slk_format)
{ return(*(int *)0); }
@@ -2801,6 +2801,12 @@ NCURSES_BOOL _nc_is_file_path(
const char *path)
{ return(*(NCURSES_BOOL *)0); }
+#undef _nc_is_path_found
+NCURSES_BOOL _nc_is_path_found(
+ const char *path,
+ struct stat *sb)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_env_access
int _nc_env_access(void)
{ return(*(int *)0); }
@@ -2994,7 +3000,7 @@ ENTRY *_nc_tail;
#undef _nc_free_entry
void _nc_free_entry(
ENTRY *headp,
- TERMTYPE *tterm)
+ const TERMTYPE *tterm)
{ /* void */ }
#undef _nc_free_entries
@@ -3339,7 +3345,7 @@ int _nc_putp_flush_sp(
#undef _nc_keypad
int _nc_keypad(
SCREEN *sp,
- int flag)
+ NCURSES_BOOL flag)
{ return(*(int *)0); }
/* ./tinfo/lib_raw.c */
@@ -3525,8 +3531,8 @@ char *_nc_get_locale(void)
{ return(*(char **)0); }
#undef _nc_unicode_locale
-int _nc_unicode_locale(void)
- { return(*(int *)0); }
+NCURSES_BOOL _nc_unicode_locale(void)
+ { return(*(NCURSES_BOOL *)0); }
#undef _nc_locale_breaks_acs
int _nc_locale_breaks_acs(
@@ -3848,7 +3854,7 @@ void _tracef(
#undef _nc_retrace_bool
NCURSES_BOOL _nc_retrace_bool(
- int code)
+ NCURSES_BOOL code)
{ return(*(NCURSES_BOOL *)0); }
#undef _nc_retrace_char
@@ -4054,7 +4060,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
- SCREEN *sp,
+ const SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
diff --git a/ncurses/llib-lncursest b/ncurses/llib-lncursest
index 7c8bac9c4076..731013d9c3a5 100644
--- a/ncurses/llib-lncursest
+++ b/ncurses/llib-lncursest
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2022,2023 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 2008-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -1484,7 +1484,7 @@ int mouseinterval(
#undef _nc_has_mouse
NCURSES_BOOL _nc_has_mouse(
- SCREEN *sp)
+ const SCREEN *sp)
{ return(*(NCURSES_BOOL *)0); }
#undef has_mouse_sp
@@ -2041,7 +2041,7 @@ int _nc_setupscreen_sp(
int slines,
int scolumns,
FILE *output,
- int filtered,
+ NCURSES_BOOL filtered,
int slk_format)
{ return(*(int *)0); }
@@ -2050,7 +2050,7 @@ int _nc_setupscreen(
int slines,
int scolumns,
FILE *output,
- int filtered,
+ NCURSES_BOOL filtered,
int slk_format)
{ return(*(int *)0); }
@@ -2810,6 +2810,12 @@ NCURSES_BOOL _nc_is_file_path(
const char *path)
{ return(*(NCURSES_BOOL *)0); }
+#undef _nc_is_path_found
+NCURSES_BOOL _nc_is_path_found(
+ const char *path,
+ struct stat *sb)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_env_access
int _nc_env_access(void)
{ return(*(int *)0); }
@@ -3008,7 +3014,7 @@ ENTRY *_nc_tail;
#undef _nc_free_entry
void _nc_free_entry(
ENTRY *headp,
- TERMTYPE *tterm)
+ const TERMTYPE *tterm)
{ /* void */ }
#undef _nc_free_entries
@@ -3394,7 +3400,7 @@ int _nc_putp_flush_sp(
#undef _nc_keypad
int _nc_keypad(
SCREEN *sp,
- int flag)
+ NCURSES_BOOL flag)
{ return(*(int *)0); }
/* ./tinfo/lib_raw.c */
@@ -3602,8 +3608,8 @@ char *_nc_get_locale(void)
{ return(*(char **)0); }
#undef _nc_unicode_locale
-int _nc_unicode_locale(void)
- { return(*(int *)0); }
+NCURSES_BOOL _nc_unicode_locale(void)
+ { return(*(NCURSES_BOOL *)0); }
#undef _nc_locale_breaks_acs
int _nc_locale_breaks_acs(
@@ -3947,7 +3953,7 @@ void _tracef(
#undef _nc_retrace_bool
NCURSES_BOOL _nc_retrace_bool(
- int code)
+ NCURSES_BOOL code)
{ return(*(NCURSES_BOOL *)0); }
#undef _nc_retrace_char
@@ -4164,7 +4170,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
- SCREEN *sp,
+ const SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
diff --git a/ncurses/llib-lncursestw b/ncurses/llib-lncursestw
index 3aa57eee919a..7ecf6e47524f 100644
--- a/ncurses/llib-lncursestw
+++ b/ncurses/llib-lncursestw
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2009-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -1857,6 +1857,12 @@ int wins_wstr(
const wchar_t *z)
{ return(*(int *)0); }
+#undef winwstr
+int winwstr(
+ WINDOW *a1,
+ wchar_t *z)
+ { return(*(int *)0); }
+
#undef mouse_trafo
NCURSES_BOOL mouse_trafo(
int *a1,
@@ -2065,7 +2071,7 @@ int mouseinterval(
#undef _nc_has_mouse
NCURSES_BOOL _nc_has_mouse(
- SCREEN *sp)
+ const SCREEN *sp)
{ return(*(NCURSES_BOOL *)0); }
#undef has_mouse_sp
@@ -2622,7 +2628,7 @@ int _nc_setupscreen_sp(
int slines,
int scolumns,
FILE *output,
- int filtered,
+ NCURSES_BOOL filtered,
int slk_format)
{ return(*(int *)0); }
@@ -2631,7 +2637,7 @@ int _nc_setupscreen(
int slines,
int scolumns,
FILE *output,
- int filtered,
+ NCURSES_BOOL filtered,
int slk_format)
{ return(*(int *)0); }
@@ -3347,12 +3353,6 @@ int winnwstr(
int n)
{ return(*(int *)0); }
-#undef winwstr
-int winwstr(
- WINDOW *win,
- wchar_t *wstr)
- { return(*(int *)0); }
-
/* ./widechar/lib_key_name.c */
#undef key_name
@@ -3581,7 +3581,7 @@ void _nc_free_ordered_pairs(
void _nc_reset_color_pair(
SCREEN *sp,
int pair,
- colorpair_t *next)
+ const colorpair_t *next)
{ /* void */ }
#undef _nc_set_color_pair
@@ -3749,6 +3749,12 @@ NCURSES_BOOL _nc_is_file_path(
const char *path)
{ return(*(NCURSES_BOOL *)0); }
+#undef _nc_is_path_found
+NCURSES_BOOL _nc_is_path_found(
+ const char *path,
+ struct stat *sb)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_env_access
int _nc_env_access(void)
{ return(*(int *)0); }
@@ -3959,7 +3965,7 @@ ENTRY *_nc_tail;
#undef _nc_free_entry
void _nc_free_entry(
ENTRY *headp,
- TERMTYPE2 *tterm)
+ const TERMTYPE2 *tterm)
{ /* void */ }
#undef _nc_free_entries
@@ -4355,7 +4361,7 @@ int _nc_putp_flush_sp(
#undef _nc_keypad
int _nc_keypad(
SCREEN *sp,
- int flag)
+ NCURSES_BOOL flag)
{ return(*(int *)0); }
/* ./tinfo/lib_raw.c */
@@ -4563,8 +4569,8 @@ char *_nc_get_locale(void)
{ return(*(char **)0); }
#undef _nc_unicode_locale
-int _nc_unicode_locale(void)
- { return(*(int *)0); }
+NCURSES_BOOL _nc_unicode_locale(void)
+ { return(*(NCURSES_BOOL *)0); }
#undef _nc_locale_breaks_acs
int _nc_locale_breaks_acs(
@@ -4908,7 +4914,7 @@ void _tracef(
#undef _nc_retrace_bool
NCURSES_BOOL _nc_retrace_bool(
- int code)
+ NCURSES_BOOL code)
{ return(*(NCURSES_BOOL *)0); }
#undef _nc_retrace_char
@@ -5136,7 +5142,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
- SCREEN *sp,
+ const SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
diff --git a/ncurses/llib-lncursesw b/ncurses/llib-lncursesw
index dbf535db4b3f..5ebdfd4c4782 100644
--- a/ncurses/llib-lncursesw
+++ b/ncurses/llib-lncursesw
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2001-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -1854,6 +1854,12 @@ int wins_wstr(
const wchar_t *z)
{ return(*(int *)0); }
+#undef winwstr
+int winwstr(
+ WINDOW *a1,
+ wchar_t *z)
+ { return(*(int *)0); }
+
#undef mouse_trafo
NCURSES_BOOL mouse_trafo(
int *a1,
@@ -2056,7 +2062,7 @@ int mouseinterval(
#undef _nc_has_mouse
NCURSES_BOOL _nc_has_mouse(
- SCREEN *sp)
+ const SCREEN *sp)
{ return(*(NCURSES_BOOL *)0); }
#undef has_mouse_sp
@@ -2613,7 +2619,7 @@ int _nc_setupscreen_sp(
int slines,
int scolumns,
FILE *output,
- int filtered,
+ NCURSES_BOOL filtered,
int slk_format)
{ return(*(int *)0); }
@@ -2622,7 +2628,7 @@ int _nc_setupscreen(
int slines,
int scolumns,
FILE *output,
- int filtered,
+ NCURSES_BOOL filtered,
int slk_format)
{ return(*(int *)0); }
@@ -3338,12 +3344,6 @@ int winnwstr(
int n)
{ return(*(int *)0); }
-#undef winwstr
-int winwstr(
- WINDOW *win,
- wchar_t *wstr)
- { return(*(int *)0); }
-
/* ./widechar/lib_key_name.c */
#undef key_name
@@ -3572,7 +3572,7 @@ void _nc_free_ordered_pairs(
void _nc_reset_color_pair(
SCREEN *sp,
int pair,
- colorpair_t *next)
+ const colorpair_t *next)
{ /* void */ }
#undef _nc_set_color_pair
@@ -3740,6 +3740,12 @@ NCURSES_BOOL _nc_is_file_path(
const char *path)
{ return(*(NCURSES_BOOL *)0); }
+#undef _nc_is_path_found
+NCURSES_BOOL _nc_is_path_found(
+ const char *path,
+ struct stat *sb)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_env_access
int _nc_env_access(void)
{ return(*(int *)0); }
@@ -3945,7 +3951,7 @@ ENTRY *_nc_tail;
#undef _nc_free_entry
void _nc_free_entry(
ENTRY *headp,
- TERMTYPE2 *tterm)
+ const TERMTYPE2 *tterm)
{ /* void */ }
#undef _nc_free_entries
@@ -4300,7 +4306,7 @@ int _nc_putp_flush_sp(
#undef _nc_keypad
int _nc_keypad(
SCREEN *sp,
- int flag)
+ NCURSES_BOOL flag)
{ return(*(int *)0); }
/* ./tinfo/lib_raw.c */
@@ -4486,8 +4492,8 @@ char *_nc_get_locale(void)
{ return(*(char **)0); }
#undef _nc_unicode_locale
-int _nc_unicode_locale(void)
- { return(*(int *)0); }
+NCURSES_BOOL _nc_unicode_locale(void)
+ { return(*(NCURSES_BOOL *)0); }
#undef _nc_locale_breaks_acs
int _nc_locale_breaks_acs(
@@ -4809,7 +4815,7 @@ void _tracef(
#undef _nc_retrace_bool
NCURSES_BOOL _nc_retrace_bool(
- int code)
+ NCURSES_BOOL code)
{ return(*(NCURSES_BOOL *)0); }
#undef _nc_retrace_char
@@ -5026,7 +5032,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
- SCREEN *sp,
+ const SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
diff --git a/ncurses/llib-ltinfo b/ncurses/llib-ltinfo
index 5cfa111a236d..634e02510cc1 100644
--- a/ncurses/llib-ltinfo
+++ b/ncurses/llib-ltinfo
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2022,2023 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 2012-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -72,6 +72,12 @@ NCURSES_BOOL _nc_is_file_path(
const char *path)
{ return(*(NCURSES_BOOL *)0); }
+#undef _nc_is_path_found
+NCURSES_BOOL _nc_is_path_found(
+ const char *path,
+ struct stat *sb)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_env_access
int _nc_env_access(void)
{ return(*(int *)0); }
@@ -265,7 +271,7 @@ ENTRY *_nc_tail;
#undef _nc_free_entry
void _nc_free_entry(
ENTRY *headp,
- TERMTYPE *tterm)
+ const TERMTYPE *tterm)
{ /* void */ }
#undef _nc_free_entries
@@ -610,7 +616,7 @@ int _nc_putp_flush_sp(
#undef _nc_keypad
int _nc_keypad(
SCREEN *sp,
- int flag)
+ NCURSES_BOOL flag)
{ return(*(int *)0); }
/* ./tinfo/lib_raw.c */
@@ -796,8 +802,8 @@ char *_nc_get_locale(void)
{ return(*(char **)0); }
#undef _nc_unicode_locale
-int _nc_unicode_locale(void)
- { return(*(int *)0); }
+NCURSES_BOOL _nc_unicode_locale(void)
+ { return(*(NCURSES_BOOL *)0); }
#undef _nc_locale_breaks_acs
int _nc_locale_breaks_acs(
@@ -1119,7 +1125,7 @@ void _tracef(
#undef _nc_retrace_bool
NCURSES_BOOL _nc_retrace_bool(
- int code)
+ NCURSES_BOOL code)
{ return(*(NCURSES_BOOL *)0); }
#undef _nc_retrace_char
@@ -1325,7 +1331,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
- SCREEN *sp,
+ const SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
diff --git a/ncurses/llib-ltinfot b/ncurses/llib-ltinfot
index 94ca9a7f0272..a0b086940de4 100644
--- a/ncurses/llib-ltinfot
+++ b/ncurses/llib-ltinfot
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2022,2023 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 2013-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -72,6 +72,12 @@ NCURSES_BOOL _nc_is_file_path(
const char *path)
{ return(*(NCURSES_BOOL *)0); }
+#undef _nc_is_path_found
+NCURSES_BOOL _nc_is_path_found(
+ const char *path,
+ struct stat *sb)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_env_access
int _nc_env_access(void)
{ return(*(int *)0); }
@@ -270,7 +276,7 @@ ENTRY *_nc_tail;
#undef _nc_free_entry
void _nc_free_entry(
ENTRY *headp,
- TERMTYPE *tterm)
+ const TERMTYPE *tterm)
{ /* void */ }
#undef _nc_free_entries
@@ -656,7 +662,7 @@ int _nc_putp_flush_sp(
#undef _nc_keypad
int _nc_keypad(
SCREEN *sp,
- int flag)
+ NCURSES_BOOL flag)
{ return(*(int *)0); }
/* ./tinfo/lib_raw.c */
@@ -864,8 +870,8 @@ char *_nc_get_locale(void)
{ return(*(char **)0); }
#undef _nc_unicode_locale
-int _nc_unicode_locale(void)
- { return(*(int *)0); }
+NCURSES_BOOL _nc_unicode_locale(void)
+ { return(*(NCURSES_BOOL *)0); }
#undef _nc_locale_breaks_acs
int _nc_locale_breaks_acs(
@@ -1209,7 +1215,7 @@ void _tracef(
#undef _nc_retrace_bool
NCURSES_BOOL _nc_retrace_bool(
- int code)
+ NCURSES_BOOL code)
{ return(*(NCURSES_BOOL *)0); }
#undef _nc_retrace_char
@@ -1426,7 +1432,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
- SCREEN *sp,
+ const SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
diff --git a/ncurses/llib-ltinfotw b/ncurses/llib-ltinfotw
index 3b21b8765761..cb9d71671f88 100644
--- a/ncurses/llib-ltinfotw
+++ b/ncurses/llib-ltinfotw
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2012-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -72,6 +72,12 @@ NCURSES_BOOL _nc_is_file_path(
const char *path)
{ return(*(NCURSES_BOOL *)0); }
+#undef _nc_is_path_found
+NCURSES_BOOL _nc_is_path_found(
+ const char *path,
+ struct stat *sb)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_env_access
int _nc_env_access(void)
{ return(*(int *)0); }
@@ -282,7 +288,7 @@ ENTRY *_nc_tail;
#undef _nc_free_entry
void _nc_free_entry(
ENTRY *headp,
- TERMTYPE2 *tterm)
+ const TERMTYPE2 *tterm)
{ /* void */ }
#undef _nc_free_entries
@@ -678,7 +684,7 @@ int _nc_putp_flush_sp(
#undef _nc_keypad
int _nc_keypad(
SCREEN *sp,
- int flag)
+ NCURSES_BOOL flag)
{ return(*(int *)0); }
/* ./tinfo/lib_raw.c */
@@ -886,8 +892,8 @@ char *_nc_get_locale(void)
{ return(*(char **)0); }
#undef _nc_unicode_locale
-int _nc_unicode_locale(void)
- { return(*(int *)0); }
+NCURSES_BOOL _nc_unicode_locale(void)
+ { return(*(NCURSES_BOOL *)0); }
#undef _nc_locale_breaks_acs
int _nc_locale_breaks_acs(
@@ -1231,7 +1237,7 @@ void _tracef(
#undef _nc_retrace_bool
NCURSES_BOOL _nc_retrace_bool(
- int code)
+ NCURSES_BOOL code)
{ return(*(NCURSES_BOOL *)0); }
#undef _nc_retrace_char
@@ -1459,7 +1465,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
- SCREEN *sp,
+ const SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
diff --git a/ncurses/llib-ltinfow b/ncurses/llib-ltinfow
index fd308180722a..82d57ad08efb 100644
--- a/ncurses/llib-ltinfow
+++ b/ncurses/llib-ltinfow
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2012-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -72,6 +72,12 @@ NCURSES_BOOL _nc_is_file_path(
const char *path)
{ return(*(NCURSES_BOOL *)0); }
+#undef _nc_is_path_found
+NCURSES_BOOL _nc_is_path_found(
+ const char *path,
+ struct stat *sb)
+ { return(*(NCURSES_BOOL *)0); }
+
#undef _nc_env_access
int _nc_env_access(void)
{ return(*(int *)0); }
@@ -277,7 +283,7 @@ ENTRY *_nc_tail;
#undef _nc_free_entry
void _nc_free_entry(
ENTRY *headp,
- TERMTYPE2 *tterm)
+ const TERMTYPE2 *tterm)
{ /* void */ }
#undef _nc_free_entries
@@ -632,7 +638,7 @@ int _nc_putp_flush_sp(
#undef _nc_keypad
int _nc_keypad(
SCREEN *sp,
- int flag)
+ NCURSES_BOOL flag)
{ return(*(int *)0); }
/* ./tinfo/lib_raw.c */
@@ -818,8 +824,8 @@ char *_nc_get_locale(void)
{ return(*(char **)0); }
#undef _nc_unicode_locale
-int _nc_unicode_locale(void)
- { return(*(int *)0); }
+NCURSES_BOOL _nc_unicode_locale(void)
+ { return(*(NCURSES_BOOL *)0); }
#undef _nc_locale_breaks_acs
int _nc_locale_breaks_acs(
@@ -1141,7 +1147,7 @@ void _tracef(
#undef _nc_retrace_bool
NCURSES_BOOL _nc_retrace_bool(
- int code)
+ NCURSES_BOOL code)
{ return(*(NCURSES_BOOL *)0); }
#undef _nc_retrace_char
@@ -1358,7 +1364,7 @@ int resetty(void)
#undef _nc_timed_wait
int _nc_timed_wait(
- SCREEN *sp,
+ const SCREEN *sp,
int mode,
int milliseconds,
int *timeleft)
diff --git a/ncurses/modules b/ncurses/modules
index e111712e16b0..1b1bb3c0dd53 100644
--- a/ncurses/modules
+++ b/ncurses/modules
@@ -1,6 +1,6 @@
-# $Id: modules,v 1.127 2020/09/12 17:58:12 tom Exp $
+# $Id: modules,v 1.133 2025/12/30 15:13:55 tom Exp $
##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey #
+# Copyright 2019-2020,2025 Thomas E. Dickey #
# Copyright 1998-2013,2017 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -235,13 +235,25 @@ version lib $(base) $(HEADER_DEPS)
@ port_drivers
lib_driver lib $(base) $(HEADER_DEPS)
+# MSYS2, using termios
+@ port_msys2
+gettimeofday lib $(win32con) $(HEADER_DEPS)
+lib_win32util lib $(tinfo) $(HEADER_DEPS)
+wcwidth lib $(win32con) $(HEADER_DEPS)
+widechars lib $(wide) $(HEADER_DEPS)
+
+# MinGW, using Console API
@ port_win32con
gettimeofday lib $(win32con) $(HEADER_DEPS)
+lib_win32con lib $(tinfo) $(HEADER_DEPS)
+lib_win32util lib $(tinfo) $(HEADER_DEPS)
wcwidth lib $(win32con) $(HEADER_DEPS)
widechars lib $(wide) $(HEADER_DEPS)
-win_driver lib $(win32con) $(HEADER_DEPS)
+win32_driver lib $(win32con) $(HEADER_DEPS)
+# MinGW-W64, using Console API and named pipes
@ port_win32
+gettimeofday lib $(win32con) $(HEADER_DEPS)
lib_win32con lib $(tinfo) $(HEADER_DEPS)
lib_win32util lib $(tinfo) $(HEADER_DEPS)
wcwidth lib $(win32con) $(HEADER_DEPS)
diff --git a/ncurses/new_pair.h b/ncurses/new_pair.h
index 49d7e8b8dbdd..82f768cb76b9 100644
--- a/ncurses/new_pair.h
+++ b/ncurses/new_pair.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2018-2021,2024 Thomas E. Dickey *
* Copyright 2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,7 +34,7 @@
/*
* Common type definitions and macros for new_pair.c, lib_color.c
*
- * $Id: new_pair.h,v 1.13 2021/09/24 17:52:01 tom Exp $
+ * $Id: new_pair.h,v 1.16 2024/12/07 17:27:35 tom Exp $
*/
#ifndef NEW_PAIR_H
@@ -111,12 +111,12 @@ colorpair_t;
* that the index is within the limits of the table which we allocated.
*/
#define ValidPair(sp,pair) \
- ((sp != 0) && (pair >= 0) && (pair < sp->_pair_limit) && sp->_coloron)
+ ((sp != NULL) && (pair >= 0) && (pair < sp->_pair_limit) && sp->_coloron)
-#if NCURSES_EXT_COLORS
+#if NCURSES_EXT_FUNCS && NCURSES_EXT_COLORS
extern NCURSES_EXPORT(void) _nc_copy_pairs(SCREEN*, colorpair_t*, colorpair_t*, int);
extern NCURSES_EXPORT(void) _nc_free_ordered_pairs(SCREEN*);
-extern NCURSES_EXPORT(void) _nc_reset_color_pair(SCREEN*, int, colorpair_t*);
+extern NCURSES_EXPORT(void) _nc_reset_color_pair(SCREEN*, int, const colorpair_t*);
extern NCURSES_EXPORT(void) _nc_set_color_pair(SCREEN*, int, int);
#else
#define _nc_free_ordered_pairs(sp) /* nothing */
diff --git a/ncurses/report_ctype.c b/ncurses/report_ctype.c
new file mode 100644
index 000000000000..4ec0a51296ea
--- /dev/null
+++ b/ncurses/report_ctype.c
@@ -0,0 +1,104 @@
+/****************************************************************************
+ * Copyright 2025 Thomas E. Dickey *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: report_ctype.c,v 1.1 2025/10/25 19:21:11 tom Exp $")
+
+#include <ctype.h>
+#include <wctype.h>
+#include <locale.h>
+
+#if HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+
+#define PER_LINE 32
+
+static void
+report(char *locale)
+{
+ int ch;
+ wint_t wch;
+ char *dot;
+ printf("Locale \"%s\"", locale);
+ if (setlocale(LC_CTYPE, locale) != NULL) {
+#if HAVE_LANGINFO_CODESET
+ char *codeset = nl_langinfo(CODESET);
+ if (codeset != NULL) {
+ printf("\nCodeset \"%s\"", codeset);
+ }
+#endif
+ for (ch = 0; ch < 256; ++ch) {
+ int code = '?';
+ wch = ch;
+ if (isprint(ch) && iswprint(wch))
+ code = '=';
+ if (!isprint(ch) && iswprint(wch))
+ code = '+';
+ if (isprint(ch) && !iswprint(wch))
+ code = '-';
+ if ((ch & (PER_LINE - 1)) == 0)
+ printf("\n%02X: ", ch);
+ putchar(code);
+ }
+ putchar('\n');
+ } else {
+ fprintf(stderr, "Cannot set locale\n");
+ }
+ if ((dot = strchr(locale, '.')) != NULL) {
+ *dot = '\0';
+ report(locale);
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ if (argc > 1) {
+ int n;
+ for (n = 1; n < argc; ++n) {
+ report(argv[n]);
+ }
+ } else {
+ static char empty[1];
+ char *locale = getenv("LC_CTYPE");
+ if (locale == NULL)
+ locale = getenv("LC_ALL");
+ if (locale == NULL)
+ locale = getenv("LANG");
+ if (locale == NULL)
+ locale = empty;
+ report(locale);
+ }
+ return EXIT_SUCCESS;
+}
diff --git a/ncurses/report_hashing.c b/ncurses/report_hashing.c
index bed96efbe315..5a091eb0708b 100644
--- a/ncurses/report_hashing.c
+++ b/ncurses/report_hashing.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2025 Thomas E. Dickey *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -33,7 +33,7 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: report_hashing.c,v 1.3 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: report_hashing.c,v 1.4 2025/02/20 01:02:09 tom Exp $")
static void
check_names(const char *name, NCURSES_CONST char *const *table, int termcap)
@@ -46,7 +46,7 @@ check_names(const char *name, NCURSES_CONST char *const *table, int termcap)
printf("%s:\n", name);
for (n = 0; table[n] != NULL; ++n) {
entry_ptr = _nc_find_entry(table[n], hash_table);
- if (entry_ptr == 0) {
+ if (entry_ptr == NULL) {
printf(" %s\n", table[n]);
errs++;
}
diff --git a/ncurses/report_offsets.c b/ncurses/report_offsets.c
index 0f82dcf35db7..9f7e761d5277 100644
--- a/ncurses/report_offsets.c
+++ b/ncurses/report_offsets.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2023,2024 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 *
@@ -34,10 +34,10 @@
#define NEW_PAIR_INTERNAL 1
#include <curses.priv.h>
-MODULE_ID("$Id: report_offsets.c,v 1.28 2024/02/24 15:59:09 tom Exp $")
+MODULE_ID("$Id: report_offsets.c,v 1.32 2025/12/27 12:34:03 tom Exp $")
#define show_size(type) \
- flag = 0; \
+ flag = NULL; \
last = 0; \
printf("%5lu " #type "\n", (unsigned long)sizeof(type))
#define show_name(name) \
@@ -48,7 +48,7 @@ MODULE_ID("$Id: report_offsets.c,v 1.28 2024/02/24 15:59:09 tom Exp $")
printf("?? incorrect order for " #type "." #member "\n"); \
printf("%5lu %c " #type "." #member "\n", next, flag ? *flag : ' '); \
last = next; \
- flag = 0
+ flag = NULL
#if NCURSES_WIDECHAR && NCURSES_EXT_COLORS
#define show_COLORS(type,member) { flag = "c"; show_offset(type,member); }
@@ -56,7 +56,7 @@ MODULE_ID("$Id: report_offsets.c,v 1.28 2024/02/24 15:59:09 tom Exp $")
#define show_COLORS(type,member) /* nothing */
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
#define show_DRIVER(type,member) { flag = "d"; show_offset(type,member); }
#else
#define show_DRIVER(type,member) /* nothing */
@@ -102,11 +102,14 @@ MODULE_ID("$Id: report_offsets.c,v 1.28 2024/02/24 15:59:09 tom Exp $")
#endif
int
-main(void)
+main(int argc, char *argv[])
{
- const char *flag = 0;
+ const char *flag = NULL;
unsigned long last, next;
+ if (argc == 2 && !strcmp(argv[1], "-?"))
+ return EXIT_SUCCESS;
+
printf("Size/offsets of data structures:\n");
show_size(attr_t);
@@ -183,7 +186,9 @@ main(void)
show_REENTR(SCREEN, _ttytype);
show_SPFUNC(SCREEN, use_tioctl);
show_WIDECH(SCREEN, _screen_acs_fix);
+#if NCURSES_EXT_FUNCS && NCURSES_EXT_COLORS
show_COLORS(SCREEN, _ordered_pairs);
+#endif
show_TRACES(SCREEN, tracechr_buf);
printf("\n");
diff --git a/ncurses/term.priv.h b/ncurses/term.priv.h
index 1f436b5f8254..0dd176abb373 100644
--- a/ncurses/term.priv.h
+++ b/ncurses/term.priv.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2021-2023,2024 Thomas E. Dickey *
+ * Copyright 2021-2024,2025 Thomas E. Dickey *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -27,7 +27,7 @@
****************************************************************************/
/*
- * $Id: term.priv.h,v 1.13 2024/03/02 20:43:06 tom Exp $
+ * $Id: term.priv.h,v 1.14 2025/12/27 12:41:23 tom Exp $
*
* term.priv.h
*
@@ -176,7 +176,7 @@ typedef struct {
#include <term_entry.h> /* dbdLAST */
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
struct DriverTCB; /* Terminal Control Block forward declaration */
#endif
@@ -228,7 +228,7 @@ typedef struct {
int count_tparm;
#endif /* HAVE_TSEARCH */
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
int (*term_driver)(struct DriverTCB*, const char*, int*);
#endif
diff --git a/ncurses/tinfo/MKcaptab.awk b/ncurses/tinfo/MKcaptab.awk
index ee4e2e9b8726..cd6730e5b8aa 100644
--- a/ncurses/tinfo/MKcaptab.awk
+++ b/ncurses/tinfo/MKcaptab.awk
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright 2020 Thomas E. Dickey #
+# Copyright 2020,2024 Thomas E. Dickey #
# Copyright 1998-2006,2007 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -26,7 +26,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKcaptab.awk,v 1.21 2020/02/02 23:34:34 tom Exp $
+# $Id: MKcaptab.awk,v 1.22 2024/12/07 20:52:55 tom Exp $
function add_string(text) {
if (text != "IGNORE") {
offsets[num_strings] = offset;
@@ -53,7 +53,7 @@ BEGIN {
printf "/* generated by MKcaptab.awk %s(%d) */\n", tablename, bigstrings;
print ""
if (bigstrings) {
- printf "static struct alias *_nc_%s_table = 0;\n", tablename;
+ printf "static struct alias *_nc_%s_table = NULL;\n", tablename;
print "";
printf "static const char %s_text[] = \"\\\n", tablename;
} else {
diff --git a/ncurses/tinfo/MKcaptab.sh b/ncurses/tinfo/MKcaptab.sh
index 5f4135028f98..a55d48075c1d 100755
--- a/ncurses/tinfo/MKcaptab.sh
+++ b/ncurses/tinfo/MKcaptab.sh
@@ -1,6 +1,6 @@
#!/bin/sh
##############################################################################
-# Copyright 2019-2020,2023 Thomas E. Dickey #
+# Copyright 2019-2023,2024 Thomas E. Dickey #
# Copyright 2007-2010,2011 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -27,13 +27,13 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKcaptab.sh,v 1.20 2023/04/22 15:12:57 tom Exp $
+# $Id: MKcaptab.sh,v 1.22 2024/12/07 21:30:44 tom Exp $
if test $# != 0
then
AWK="$1"; shift 1
else
- AWK=awk
+ AWK="awk"
fi
if test $# != 0
@@ -71,12 +71,12 @@ cat <<'EOF'
/* *INDENT-OFF* */
EOF
-cat "$@" |./make_hash 1 info $OPT1
-cat "$@" |./make_hash 3 cap $OPT1
+cat "$@" |./make_hash 1 info "$OPT1"
+cat "$@" |./make_hash 3 cap "$OPT1"
-cat "$@" |$AWK -f $OPT2 bigstrings=$OPT1 tablename=capalias
+cat "$@" |$AWK -f "$OPT2" bigstrings="$OPT1" tablename=capalias
-cat "$@" |$AWK -f $OPT2 bigstrings=$OPT1 tablename=infoalias
+cat "$@" |$AWK -f "$OPT2" bigstrings="$OPT1" tablename=infoalias
cat <<EOF
/* *INDENT-ON* */
@@ -93,9 +93,9 @@ _nc_build_names(struct name_table_entry **actual,
const name_table_data * source,
const char *strings)
{
- if (*actual == 0) {
+ if (*actual == NULL) {
*actual = typeCalloc(struct name_table_entry, CAPTABSIZE);
- if (*actual != 0) {
+ if (*actual != NULL) {
unsigned n;
unsigned len = 0;
for (n = 0; n < CAPTABSIZE; ++n) {
@@ -121,9 +121,9 @@ _nc_build_alias(struct alias **actual,
const char *strings,
size_t tablesize)
{
- if (*actual == 0) {
+ if (*actual == NULL) {
*actual = typeCalloc(struct alias, tablesize + 1);
- if (*actual != 0) {
+ if (*actual != NULL) {
size_t n;
for (n = 0; n < tablesize; ++n) {
add_alias(from);
diff --git a/ncurses/tinfo/MKcodes.awk b/ncurses/tinfo/MKcodes.awk
index 48f4800b310a..1c7f5a9e69ca 100644
--- a/ncurses/tinfo/MKcodes.awk
+++ b/ncurses/tinfo/MKcodes.awk
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey #
+# Copyright 2019-2020,2024 Thomas E. Dickey #
# Copyright 2007-2009,2010 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -26,7 +26,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKcodes.awk,v 1.11 2020/02/02 23:34:34 tom Exp $
+# $Id: MKcodes.awk,v 1.13 2024/12/14 23:45:36 tom Exp $
function large_item(value) {
result = sprintf("%d,", offset);
offset = offset + length(value) + 1;
@@ -63,7 +63,7 @@ function print_offsets(name,value) {
printf "%s", value
print "};"
print ""
- printf "static NCURSES_CONST char ** ptr_%s = 0;\n", name
+ printf "static NCURSES_CONST char ** ptr_%s = NULL;\n", name
print ""
}
@@ -105,7 +105,7 @@ END {
print "#if BROKEN_LINKER || USE_REENTRANT"
print ""
if (bigstrings) {
- printf "static const char _nc_code_blob[] = \n"
+ printf "static const char _nc_code_blob[] =\n"
printf "%s;\n", bigstr;
print_offsets("boolcodes", large_boolcodes);
print_offsets("numcodes", large_numcodes);
@@ -114,8 +114,8 @@ END {
print "static IT *"
print "alloc_array(NCURSES_CONST char ***value, const short *offsets, unsigned size)"
print "{"
- print " if (*value == 0) {"
- print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {"
+ print " if (*value == NULL) {"
+ print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != NULL) {"
print " unsigned n;"
print " for (n = 0; n < size; ++n) {"
print " (*value)[n] = (NCURSES_CONST char *) _nc_code_blob + offsets[n];"
diff --git a/ncurses/tinfo/MKfallback.sh b/ncurses/tinfo/MKfallback.sh
index 02b36ed739b2..303fcb7a24b5 100755
--- a/ncurses/tinfo/MKfallback.sh
+++ b/ncurses/tinfo/MKfallback.sh
@@ -1,6 +1,6 @@
#!/bin/sh
##############################################################################
-# Copyright 2020,2023 Thomas E. Dickey #
+# Copyright 2020-2023,2025 Thomas E. Dickey #
# Copyright 1998-2019,2020 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -27,7 +27,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKfallback.sh,v 1.26 2023/04/22 15:12:57 tom Exp $
+# $Id: MKfallback.sh,v 1.32 2025/09/20 18:24:34 tom Exp $
#
# MKfallback.sh -- create fallback table for entry reads
#
@@ -44,11 +44,11 @@ terminfo_src=$1
shift
tic_path=$1
-test -z "$tic_path" && tic_path=tic
+[ -z "$tic_path" ] && tic_path=tic
shift
infocmp_path=$1
-test -z "$infocmp_path" && infocmp_path=infocmp
+[ -z "$infocmp_path" ] && infocmp_path=infocmp
shift
case "$tic_path" in #(vi
@@ -59,17 +59,14 @@ case "$tic_path" in #(vi
;;
esac
-if test $# != 0 ; then
- tmp_info=tmp_info
+if [ $# != 0 ]; then
+ tmp_info=`pwd`/tmp_info
echo creating temporary terminfo directory... >&2
- TERMINFO=`pwd`/$tmp_info
- export TERMINFO
+ rm -rf "$tmp_info"
+ mkdir -p "$tmp_info"
- TERMINFO_DIRS=$TERMINFO:$terminfo_dir
- export TERMINFO_DIRS
-
- "$tic_path" -x "$terminfo_src" >&2
+ "$tic_path" -o $tmp_info -x "$terminfo_src" >&2
else
tmp_info=
fi
@@ -87,6 +84,8 @@ EOF
if [ "$*" ]
then
+ opt_info=
+ [ -n "$tmp_info" ] && opt_info="-A $tmp_info"
cat <<EOF
#include <tic.h>
@@ -95,7 +94,7 @@ EOF
for x in "$@"
do
echo "/* $x */"
- "$infocmp_path" -E "$x" | sed -e 's/\<short\>/NCURSES_INT2/g'
+ "$infocmp_path" -x $opt_info -E "$x" | sed -e 's/[ ]short[ ]/ NCURSES_INT2 /g'
done
cat <<EOF
@@ -106,7 +105,7 @@ EOF
for x in "$@"
do
echo "$comma /* $x */"
- "$infocmp_path" -e "$x"
+ "$infocmp_path" -x $opt_info -e "$x"
comma=","
done
@@ -150,8 +149,8 @@ NCURSES_EXPORT(const TERMTYPE *)
_nc_fallback (const char *name)
{
const TERMTYPE2 *tp = _nc_fallback2(name);
- const TERMTYPE *result = 0;
- if (tp != 0) {
+ const TERMTYPE *result = NULL;
+ if (tp != NULL) {
static TERMTYPE temp;
_nc_export_termtype2(&temp, tp);
result = &temp;
@@ -161,7 +160,7 @@ _nc_fallback (const char *name)
#endif
EOF
-if test -n "$tmp_info" ; then
+if [ -n "$tmp_info" ] ; then
echo removing temporary terminfo directory... >&2
- rm -rf $tmp_info
+ rm -rf "$tmp_info"
fi
diff --git a/ncurses/tinfo/MKkeys_list.sh b/ncurses/tinfo/MKkeys_list.sh
index 05ac8cf62578..68eeb62f2564 100755
--- a/ncurses/tinfo/MKkeys_list.sh
+++ b/ncurses/tinfo/MKkeys_list.sh
@@ -1,7 +1,7 @@
#! /bin/sh
-# $Id: MKkeys_list.sh,v 1.9 2024/01/19 12:26:30 tom Exp $
+# $Id: MKkeys_list.sh,v 1.10 2025/06/14 16:03:56 tom Exp $
##############################################################################
-# Copyright 2019-2022,2024 Thomas E. Dickey #
+# Copyright 2019-2024,2025 Thomas E. Dickey #
# Copyright 2001-2003,2017 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -35,27 +35,27 @@
#
# Extract function-key names from the Caps file
#
-: ${AWK-awk}
-: ${USE_SIGWINCH-0}
-if test $# != 0
-then
- DATA="$*"
-else
- DATA=../../include/Caps
-fi
+: "${AWK-awk}"
+: "${USE_SIGWINCH-0}"
data=data$$
+tabs='s/[ ][ ]*/ /g'
trap 'rm -f $data; exit 1' 1 2 3 15
trap 'rm -f $data' 0
-cat $DATA | sed -e 's/[ ][ ]*/ /g' >$data
+if [ $# != 0 ]
+then
+ sed -e "$tabs" "$@" >$data
+else
+ sed -e "$tabs" ../../include/Caps >$data
+fi
cat <<EOF
-# These definitions were generated by $0 $DATA
+# These definitions were generated by $0 $*
KEY_BREAK
KEY_SRESET
KEY_RESET
EOF
-test "$USE_SIGWINCH" = 1 && echo KEY_RESIZE
+[ "$USE_SIGWINCH" = 1 ] && echo KEY_RESIZE
${AWK-awk} <$data '
/^#/ {next;}
diff --git a/ncurses/tinfo/MKnames.awk b/ncurses/tinfo/MKnames.awk
index 4594c728da88..18b97dd77282 100644
--- a/ncurses/tinfo/MKnames.awk
+++ b/ncurses/tinfo/MKnames.awk
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey #
+# Copyright 2019-2020,2024 Thomas E. Dickey #
# Copyright 1998-2008,2009 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -26,7 +26,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKnames.awk,v 1.24 2020/02/02 23:34:34 tom Exp $
+# $Id: MKnames.awk,v 1.26 2024/12/14 23:44:37 tom Exp $
function large_item(value) {
result = sprintf("%d,", offset);
offset = offset + length(value) + 1;
@@ -63,7 +63,7 @@ function print_offsets(name,value) {
printf "%s", value
print "};"
print ""
- printf "static NCURSES_CONST char ** ptr_%s = 0;\n", name
+ printf "static NCURSES_CONST char ** ptr_%s = NULL;\n", name
print ""
}
@@ -111,7 +111,7 @@ END {
print "#if BROKEN_LINKER || USE_REENTRANT"
print ""
if (bigstrings) {
- printf "static const char _nc_name_blob[] = \n"
+ printf "static const char _nc_name_blob[] =\n"
printf "%s;\n", bigstr;
print_offsets("boolfnames", large_boolfnames);
print_offsets("boolnames", large_boolnames);
@@ -123,8 +123,8 @@ END {
print "static IT *"
print "alloc_array(NCURSES_CONST char ***value, const short *offsets, unsigned size)"
print "{"
- print " if (*value == 0) {"
- print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != 0) {"
+ print " if (*value == NULL) {"
+ print " if ((*value = typeCalloc(NCURSES_CONST char *, size + 1)) != NULL) {"
print " unsigned n;"
print " for (n = 0; n < size; ++n) {"
print " (*value)[n] = (NCURSES_CONST char *) _nc_name_blob + offsets[n];"
diff --git a/ncurses/tinfo/MKuserdefs.sh b/ncurses/tinfo/MKuserdefs.sh
index 109dd6445e4d..d4cc020747ed 100755
--- a/ncurses/tinfo/MKuserdefs.sh
+++ b/ncurses/tinfo/MKuserdefs.sh
@@ -1,6 +1,6 @@
#!/bin/sh
##############################################################################
-# Copyright 2019,2020 Thomas E. Dickey #
+# Copyright 2019-2024,2025 Thomas E. Dickey #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@@ -26,7 +26,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
-# $Id: MKuserdefs.sh,v 1.10 2020/02/02 23:34:34 tom Exp $
+# $Id: MKuserdefs.sh,v 1.12 2025/06/14 14:44:56 tom Exp $
AWK=${1-awk}; shift 1
OPT1=${1-0}; shift 1
@@ -51,7 +51,7 @@ cat <<'EOF'
#if NCURSES_XNAMES
EOF
-cat "$@" | ./make_hash 1 user $OPT1
+cat "$@" | ./make_hash 1 user "$OPT1"
cat <<EOF
@@ -69,9 +69,9 @@ _nc_build_names(struct user_table_entry **actual,
const user_table_data *source,
const char *strings)
{
- if (*actual == 0) {
+ if (*actual == NULL) {
*actual = typeCalloc(struct user_table_entry, USERTABSIZE);
- if (*actual != 0) {
+ if (*actual != NULL) {
unsigned n;
unsigned len = 0;
for (n = 0; n < USERTABSIZE; ++n) {
diff --git a/ncurses/tinfo/access.c b/ncurses/tinfo/access.c
index 50a5769c3d63..17c3d24b9b83 100644
--- a/ncurses/tinfo/access.c
+++ b/ncurses/tinfo/access.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2021,2023 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 1998-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,12 +34,15 @@
#include <curses.priv.h>
#include <ctype.h>
+#include <string.h>
#ifndef USE_ROOT_ACCESS
-#if HAVE_SETFSUID
+#if HAVE_SETFSUID && HAVE_SYS_FSUID_H
#include <sys/fsuid.h>
#else
#include <sys/stat.h>
+#undef HAVE_SETFSUID
+#define HAVE_SETFSUID 0 /* workaround for misconfigured system */
#endif
#endif
@@ -52,7 +55,7 @@
#include <tic.h>
-MODULE_ID("$Id: access.c,v 1.37 2023/06/24 21:55:09 tom Exp $")
+MODULE_ID("$Id: access.c,v 1.50 2025/12/27 16:50:06 tom Exp $")
#define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))
@@ -62,6 +65,108 @@ MODULE_ID("$Id: access.c,v 1.37 2023/06/24 21:55:09 tom Exp $")
# define ACCESS access
#endif
+#if USE_DOS_PATHS
+#define IsPathDelim(pp) (*(pp) == '/' || *(pp) == '\\')
+#define UsesDrive(pp) (isalpha(UChar((pp)[0])) && (pp)[1] == ':')
+#define IsRelative(pp) (*(pp) == '.' && ((*(pp+1) == '.' && IsPathDelim(pp+2)) || IsPathDelim(pp+1)))
+
+static char *
+last_delim(const char *path)
+{
+ char *result = NULL;
+ char *check;
+ if ((check = strrchr(path, '\\')) != NULL)
+ result = check;
+ if ((check = strrchr(path, '/')) != NULL) {
+ if ((check - path) > (result - path))
+ result = check;
+ }
+ return result;
+}
+
+/*
+ * MinGW32 uses an environment variable to point to the directory containing
+ * its executables, without a registry setting to help.
+ */
+static const char *
+msystem_base(void)
+{
+ const char *result = NULL;
+ char *env;
+
+ if ((env = getenv("MSYSTEM")) != NULL
+ && !strcmp(env, "MINGW32")
+ && (env = getenv("WD")) != NULL
+ && UsesDrive(env)) {
+ result = env;
+ }
+ return result;
+}
+
+/*
+ * For MinGW32, convert POSIX pathnames to DOS syntax, allowing use of stat()
+ * and access().
+ */
+NCURSES_EXPORT(const char *)
+_nc_to_dospath(const char *path, char *buffer)
+{
+ if (UsesDrive(path) || IsRelative(path)) {
+ if ((strlen(path) < PATH_MAX) && (strpbrk(path, "/") != NULL)) {
+ char ch;
+ char *ptr = buffer;
+ while ((ch = (*ptr++ = *path++)) != '\0') {
+ if (ch == '/')
+ ptr[-1] = '\\';
+ }
+ path = buffer;
+ }
+ } else if (last_delim(path) != NULL) {
+ const char *env;
+ char *ptr;
+ char *last;
+ size_t needed = PATH_MAX - strlen(path) - 3;
+
+ if ((env = msystem_base()) != NULL
+ && strlen(env) < needed
+ && strcpy(buffer, env) != NULL
+ && (last = last_delim(buffer)) != NULL) {
+ char ch;
+
+ *last = '\0';
+
+ /*
+ * If that was a trailing "\", eat more until we actually
+ * trim the last leaf, which corresponds to the directory
+ * containing MSYS executables.
+ */
+ while (last != NULL && last[1] == '\0') {
+ if ((last = last_delim(buffer)) != NULL) {
+ *last = '\0';
+ }
+ }
+ if (last != NULL) {
+ if (!strncmp(path, "/usr", 4))
+ path += 4;
+ if (IsPathDelim(path)) {
+ while ((last = last_delim(buffer)) != NULL && last[1] == '\0')
+ *last = '\0';
+ ptr = buffer + strlen(buffer);
+ } else {
+ ptr = buffer + strlen(buffer);
+ *ptr++ = '\\';
+ }
+ while ((ch = (*ptr++ = *path++)) != '\0') {
+ if (ch == '/')
+ ptr[-1] = '\\';
+ }
+ path = buffer;
+ }
+ }
+ }
+ return path;
+}
+#endif
+
NCURSES_EXPORT(char *)
_nc_rootname(char *path)
{
@@ -70,7 +175,7 @@ _nc_rootname(char *path)
static char *temp;
char *s;
- if ((temp = strdup(result)) != 0)
+ if ((temp = strdup(result)) != NULL)
result = temp;
#if !MIXEDCASE_FILENAMES
for (s = result; *s != '\0'; ++s) {
@@ -78,7 +183,7 @@ _nc_rootname(char *path)
}
#endif
#if defined(PROG_EXT)
- if ((s = strrchr(result, '.')) != 0) {
+ if ((s = strrchr(result, '.')) != NULL) {
if (!strcmp(s, PROG_EXT))
*s = '\0';
}
@@ -94,10 +199,10 @@ NCURSES_EXPORT(bool)
_nc_is_abs_path(const char *path)
{
#if defined(__EMX__) || defined(__DJGPP__)
-#define is_pathname(s) ((((s) != 0) && ((s)[0] == '/')) \
+#define is_pathname(s) ((((s) != NULL) && ((s)[0] == '/')) \
|| (((s)[0] != 0) && ((s)[1] == ':')))
#else
-#define is_pathname(s) ((s) != 0 && (s)[0] == '/')
+#define is_pathname(s) ((s) != NULL && (s)[0] == '/')
#endif
return is_pathname(path);
}
@@ -110,10 +215,10 @@ _nc_pathlast(const char *path)
{
const char *test = strrchr(path, '/');
#ifdef __EMX__
- if (test == 0)
+ if (test == NULL)
test = strrchr(path, '\\');
#endif
- if (test == 0)
+ if (test == NULL)
test = path;
else
test++;
@@ -131,7 +236,10 @@ _nc_access(const char *path, int mode)
{
int result;
- if (path == 0) {
+ FixupPathname(path);
+
+ if (path == NULL) {
+ errno = ENOENT;
result = -1;
} else if (ACCESS(path, mode) < 0) {
if ((mode & W_OK) != 0
@@ -142,7 +250,7 @@ _nc_access(const char *path, int mode)
_nc_STRCPY(head, path, sizeof(head));
leaf = _nc_basename(head);
- if (leaf == 0)
+ if (leaf == NULL)
leaf = head;
*leaf = '\0';
if (head == leaf)
@@ -150,6 +258,7 @@ _nc_access(const char *path, int mode)
result = ACCESS(head, R_OK | W_OK | X_OK);
} else {
+ errno = EPERM;
result = -1;
}
} else {
@@ -164,7 +273,7 @@ _nc_is_dir_path(const char *path)
bool result = FALSE;
struct stat sb;
- if (stat(path, &sb) == 0
+ if (_nc_is_path_found(path, &sb)
&& S_ISDIR(sb.st_mode)) {
result = TRUE;
}
@@ -177,13 +286,26 @@ _nc_is_file_path(const char *path)
bool result = FALSE;
struct stat sb;
- if (stat(path, &sb) == 0
+ if (_nc_is_path_found(path, &sb)
&& S_ISREG(sb.st_mode)) {
result = TRUE;
}
return result;
}
+NCURSES_EXPORT(bool)
+_nc_is_path_found(const char *path, struct stat * sb)
+{
+ bool result = FALSE;
+
+ FixupPathname(path);
+
+ if (stat(path, sb) == 0) {
+ result = TRUE;
+ }
+ return result;
+}
+
#if HAVE_GETEUID && HAVE_GETEGID
#define is_posix_elevated() \
(getuid() != geteuid() \
@@ -247,6 +369,29 @@ _nc_env_access(void)
}
#ifndef USE_ROOT_ACCESS
+static int
+is_a_file(int fd)
+{
+ int result = FALSE;
+ if (fd >= 0) {
+ struct stat sb;
+ if (fstat(fd, &sb) == 0) {
+ switch (sb.st_mode & S_IFMT) {
+ case S_IFBLK:
+ case S_IFCHR:
+ case S_IFDIR:
+ /* disallow devices and directories */
+ break;
+ default:
+ /* allow regular files, fifos and sockets */
+ result = TRUE;
+ break;
+ }
+ }
+ }
+ return result;
+}
+
/*
* Limit privileges if possible; otherwise disallow access for updating files.
*/
@@ -254,15 +399,24 @@ NCURSES_EXPORT(FILE *)
_nc_safe_fopen(const char *path, const char *mode)
{
FILE *result = NULL;
+
#if HAVE_SETFSUID
lower_privileges();
+ FixupPathname(path);
result = fopen(path, mode);
resume_elevation();
#else
+ FixupPathname(path);
if (!is_elevated() || *mode == 'r') {
result = fopen(path, mode);
}
#endif
+ if (result != NULL) {
+ if (!is_a_file(fileno(result))) {
+ fclose(result);
+ result = NULL;
+ }
+ }
return result;
}
@@ -272,13 +426,21 @@ _nc_safe_open3(const char *path, int flags, mode_t mode)
int result = -1;
#if HAVE_SETFSUID
lower_privileges();
+ FixupPathname(path);
result = open(path, flags, mode);
resume_elevation();
#else
+ FixupPathname(path);
if (!is_elevated() || (flags & O_RDONLY)) {
result = open(path, flags, mode);
}
#endif
+ if (result >= 0) {
+ if (!is_a_file(result)) {
+ close(result);
+ result = -1;
+ }
+ }
return result;
}
#endif /* USE_ROOT_ACCESS */
diff --git a/ncurses/tinfo/add_tries.c b/ncurses/tinfo/add_tries.c
index 9d215575fec0..ff41c103da2f 100644
--- a/ncurses/tinfo/add_tries.c
+++ b/ncurses/tinfo/add_tries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2020,2023 Thomas E. Dickey *
+ * Copyright 2019-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: add_tries.c,v 1.13 2023/06/24 15:36:13 tom Exp $")
+MODULE_ID("$Id: add_tries.c,v 1.14 2024/12/07 20:04:23 tom Exp $")
#define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0'
#define CMP_TRY(a,b) ((a)? (a == b) : (b == 128))
@@ -57,14 +57,14 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
if (!VALID_STRING(str) || *txt == '\0' || code == 0)
returnCode(ERR);
- if ((*tree) != 0) {
+ if ((*tree) != NULL) {
ptr = savedptr = (*tree);
for (;;) {
unsigned char cmp = *txt;
while (!CMP_TRY(ptr->ch, cmp)
- && ptr->sibling != 0)
+ && ptr->sibling != NULL)
ptr = ptr->sibling;
if (CMP_TRY(ptr->ch, cmp)) {
@@ -72,12 +72,12 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
ptr->value = (unsigned short) code;
returnCode(OK);
}
- if (ptr->child != 0)
+ if (ptr->child != NULL)
ptr = ptr->child;
else
break;
} else {
- if ((ptr->sibling = typeCalloc(TRIES, 1)) == 0) {
+ if ((ptr->sibling = typeCalloc(TRIES, 1)) == NULL) {
returnCode(ERR);
}
@@ -91,7 +91,7 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
} else { /* (*tree) == 0 :: First sequence to be added */
savedptr = ptr = (*tree) = typeCalloc(TRIES, 1);
- if (ptr == 0) {
+ if (ptr == NULL) {
returnCode(ERR);
}
@@ -106,8 +106,8 @@ _nc_add_to_try(TRIES ** tree, const char *str, unsigned code)
ptr = ptr->child;
- if (ptr == 0) {
- while ((ptr = savedptr) != 0) {
+ if (ptr == NULL) {
+ while ((ptr = savedptr) != NULL) {
savedptr = ptr->child;
free(ptr);
}
diff --git a/ncurses/tinfo/alloc_entry.c b/ncurses/tinfo/alloc_entry.c
index 6280ad4a2b2f..596ec9df5ef8 100644
--- a/ncurses/tinfo/alloc_entry.c
+++ b/ncurses/tinfo/alloc_entry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2013,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -48,7 +48,7 @@
#include <tic.h>
-MODULE_ID("$Id: alloc_entry.c,v 1.79 2023/09/15 08:16:12 tom Exp $")
+MODULE_ID("$Id: alloc_entry.c,v 1.83 2025/02/16 17:57:12 tom Exp $")
#define ABSENT_OFFSET -1
#define CANCELLED_OFFSET -2
@@ -104,7 +104,7 @@ _nc_copy_entry(ENTRY * oldp)
NCURSES_EXPORT(char *)
_nc_save_str(const char *string)
{
- char *result = 0;
+ char *result = NULL;
size_t old_next_free = next_free;
if (stringbuf != NULL) {
@@ -140,7 +140,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
/* copy the string parts to allocated storage, preserving pointers to it */
{
int offsets[MAX_ENTRY_SIZE / sizeof(short)];
- int useoffsets[MAX_USES];
+ int useoffsets[HARD_MAX_USES];
unsigned i, n;
unsigned nuses;
TERMTYPE2 *tp;
@@ -164,7 +164,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
}
for (i = 0; i < nuses; i++) {
- if (ep->uses[i].name == 0) {
+ if (ep->uses[i].name == NULL) {
ep->uses[i].name = _nc_save_str(ep->uses[i].name);
}
}
@@ -187,14 +187,17 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
}
for (i = 0; i < nuses; i++) {
- if (ep->uses[i].name == 0)
+ if (ep->uses[i].name == NULL)
useoffsets[i] = ABSENT_OFFSET;
else
useoffsets[i] = (int) (ep->uses[i].name - stringbuf);
}
TYPE_MALLOC(char, next_free, tp->str_table);
- (void) memcpy(tp->str_table, stringbuf, next_free);
+ if (stringbuf == NULL)
+ (void) memset(tp->str_table, 0, next_free);
+ else
+ (void) memcpy(tp->str_table, stringbuf, next_free);
tp->term_names = tp->str_table + n;
for_each_string(i, &(ep->tterm)) {
@@ -234,7 +237,7 @@ _nc_wrap_entry(ENTRY * const ep, bool copy_strings)
for (i = 0; i < nuses; i++) {
if (useoffsets[i] == ABSENT_OFFSET) {
- ep->uses[i].name = 0;
+ ep->uses[i].name = NULL;
} else {
ep->uses[i].name = strdup(tp->str_table + useoffsets[i]);
}
@@ -255,7 +258,7 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source)
#endif
unsigned i;
- if (source == 0 || from == 0 || target == 0 || to == 0)
+ if (source == NULL || from == NULL || target == NULL || to == NULL)
return;
#if NCURSES_XNAMES
@@ -357,6 +360,8 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source)
}
#endif
for_each_boolean(i, from) {
+ if (i >= NUM_BOOLEANS(to))
+ break;
if (to->Booleans[i] != (NCURSES_SBOOL) CANCELLED_BOOLEAN) {
int mergebool = from->Booleans[i];
@@ -368,6 +373,8 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source)
}
for_each_number(i, from) {
+ if (i >= NUM_NUMBERS(to))
+ break;
if (to->Numbers[i] != CANCELLED_NUMERIC) {
int mergenum = from->Numbers[i];
@@ -384,6 +391,8 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source)
* we ever want to deallocate entries.
*/
for_each_string(i, from) {
+ if (i >= NUM_STRINGS(to))
+ break;
if (to->Strings[i] != CANCELLED_STRING) {
char *mergestring = from->Strings[i];
diff --git a/ncurses/tinfo/alloc_ttype.c b/ncurses/tinfo/alloc_ttype.c
index 304c1b62f4e6..cb711f484277 100644
--- a/ncurses/tinfo/alloc_ttype.c
+++ b/ncurses/tinfo/alloc_ttype.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1999-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,7 +43,7 @@
#include <tic.h>
-MODULE_ID("$Id: alloc_ttype.c,v 1.51 2023/09/09 23:15:53 tom Exp $")
+MODULE_ID("$Id: alloc_ttype.c,v 1.55 2025/02/16 18:31:37 tom Exp $")
#if NCURSES_XNAMES
/*
@@ -181,7 +181,7 @@ realign_data(TERMTYPE2 *to, char **ext_Names,
* Returns the first index in ext_Names[] for the given token-type
*/
static unsigned
-_nc_first_ext_name(TERMTYPE2 *tp, int token_type)
+_nc_first_ext_name(const TERMTYPE2 *tp, int token_type)
{
unsigned first;
@@ -206,7 +206,7 @@ _nc_first_ext_name(TERMTYPE2 *tp, int token_type)
* Returns the last index in ext_Names[] for the given token-type
*/
static unsigned
-_nc_last_ext_name(TERMTYPE2 *tp, int token_type)
+_nc_last_ext_name(const TERMTYPE2 *tp, int token_type)
{
unsigned last;
@@ -229,15 +229,17 @@ _nc_last_ext_name(TERMTYPE2 *tp, int token_type)
* Lookup an entry from extended-names, returning -1 if not found
*/
static int
-_nc_find_ext_name(TERMTYPE2 *tp, char *name, int token_type)
+_nc_find_ext_name(const TERMTYPE2 *tp, const char *name, int token_type)
{
- unsigned j;
- unsigned first = _nc_first_ext_name(tp, token_type);
- unsigned last = _nc_last_ext_name(tp, token_type);
+ if (name != NULL) {
+ unsigned j;
+ unsigned first = _nc_first_ext_name(tp, token_type);
+ unsigned last = _nc_last_ext_name(tp, token_type);
- for (j = first; j < last; j++) {
- if (!strcmp(name, tp->ext_Names[j])) {
- return (int) j;
+ for (j = first; j < last; j++) {
+ if (!strcmp(name, tp->ext_Names[j])) {
+ return (int) j;
+ }
}
}
return -1;
@@ -248,7 +250,7 @@ _nc_find_ext_name(TERMTYPE2 *tp, char *name, int token_type)
* (e.g., Booleans[]).
*/
static int
-_nc_ext_data_index(TERMTYPE2 *tp, int n, int token_type)
+_nc_ext_data_index(const TERMTYPE2 *tp, int n, int token_type)
{
switch (token_type) {
case BOOLEAN:
@@ -271,7 +273,7 @@ _nc_ext_data_index(TERMTYPE2 *tp, int n, int token_type)
* data.
*/
static bool
-_nc_del_ext_name(TERMTYPE2 *tp, char *name, int token_type)
+_nc_del_ext_name(TERMTYPE2 *tp, const char *name, int token_type)
{
int first;
@@ -381,9 +383,12 @@ adjust_cancels(TERMTYPE2 *to, TERMTYPE2 *from)
NonNull(to->term_names),
NonNull(from->term_names)));
for (j = first; j < last;) {
- char *name = to->ext_Names[j];
+ char *name;
int j_str = to->num_Strings - first - to->ext_Strings;
+ if ((j + j_str) > NUM_STRINGS(to))
+ break;
+ name = to->ext_Names[j];
if (to->Strings[j + j_str] == CANCELLED_STRING) {
if (_nc_find_ext_name(from, to->ext_Names[j], BOOLEAN) >= 0) {
if (_nc_del_ext_name(to, name, STRING)
@@ -532,8 +537,8 @@ copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode)
char *new_table;
size_t new_table_size;
#if NCURSES_EXT_NUMBERS
- short *oldptr = 0;
- int *newptr = 0;
+ short *oldptr = NULL;
+ int *newptr = NULL;
#endif
DEBUG(2, (T_CALLED("copy_termtype(dst=%p, src=%p, mode=%d)"), (void *)
@@ -594,7 +599,7 @@ copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode)
TYPE_MALLOC(int, NUM_NUMBERS(dst), newptr);
dst->Numbers = newptr;
}
- if ((mode == srcINT) && (oldptr != 0)) {
+ if ((mode == srcINT) && (oldptr != NULL)) {
DEBUG(2, ("...copy int ->short"));
for (i = 0; i < NUM_NUMBERS(dst); ++i) {
if (src->Numbers[i] > MAX_OF_TYPE(short)) {
@@ -603,7 +608,7 @@ copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode)
oldptr[i] = (short) src->Numbers[i];
}
}
- } else if ((mode == dstINT) && (newptr != 0)) {
+ } else if ((mode == dstINT) && (newptr != NULL)) {
DEBUG(2, ("...copy short ->int"));
for (i = 0; i < NUM_NUMBERS(dst); ++i) {
newptr[i] = ((const short *) (src->Numbers))[i];
@@ -672,7 +677,7 @@ copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode)
}
}
} else {
- dst->ext_Names = 0;
+ dst->ext_Names = NULL;
}
#endif
(void) new_table_size;
diff --git a/ncurses/tinfo/captoinfo.c b/ncurses/tinfo/captoinfo.c
index 7e14731df368..52d085049ead 100644
--- a/ncurses/tinfo/captoinfo.c
+++ b/ncurses/tinfo/captoinfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2021 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 *
@@ -98,7 +98,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: captoinfo.c,v 1.102 2021/09/04 10:29:15 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.109 2025/11/23 20:22:38 tom Exp $")
#if 0
#define DEBUG_THIS(p) DEBUG(9, p)
@@ -124,7 +124,7 @@ static char *
init_string(void)
/* initialize 'my_string', 'my_length' */
{
- if (my_string == 0)
+ if (my_string == NULL)
TYPE_MALLOC(char, my_length = 256, my_string);
*my_string = '\0';
@@ -138,7 +138,7 @@ save_string(char *d, const char *const s)
size_t need = have + strlen(s) + 2;
if (need > my_length) {
my_string = (char *) _nc_doalloc(my_string, my_length = (need + need));
- if (my_string == 0)
+ if (my_string == NULL)
_nc_err_abort(MSG_NO_MEMORY);
d = my_string + have;
}
@@ -247,24 +247,24 @@ cvtchar(register const char *sp)
}
static void
-getparm(int parm, int n)
-/* push n copies of param on the terminfo stack if not already there */
+getparam(int parameter, int n)
+/* push n copies of parameter on the terminfo stack if not already there */
{
int nn;
if (seenr) {
- if (parm == 1)
- parm = 2;
- else if (parm == 2)
- parm = 1;
+ if (parameter == 1)
+ parameter = 2;
+ else if (parameter == 2)
+ parameter = 1;
}
for (nn = 0; nn < n; ++nn) {
dp = save_string(dp, "%p");
- dp = save_char(dp, '0' + parm);
+ dp = save_char(dp, '0' + parameter);
}
- if (onstack == parm) {
+ if (onstack == parameter) {
if (n > 1) {
_nc_warning("string may not be optimal");
dp = save_string(dp, "%Pa");
@@ -277,13 +277,13 @@ getparm(int parm, int n)
if (onstack != 0)
push();
- onstack = parm;
+ onstack = parameter;
- if (seenn && parm < 3) {
+ if (seenn && parameter < 3) {
dp = save_string(dp, "%{96}%^");
}
- if (seenm && parm < 3) {
+ if (seenm && parameter < 3) {
dp = save_string(dp, "%{127}%^");
}
}
@@ -313,8 +313,8 @@ _nc_captoinfo(const char *cap, const char *s, int const parameterized)
dp = init_string();
/* skip the initial padding (if we haven't been told not to) */
- capstart = 0;
- if (s == 0)
+ capstart = NULL;
+ if (s == NULL)
s = "";
if (parameterized >= 0 && isdigit(UChar(*s)))
for (capstart = s; *s != '\0'; s++)
@@ -353,20 +353,20 @@ _nc_captoinfo(const char *cap, const char *s, int const parameterized)
break;
case '6':
case 'B':
- getparm(param, 1);
+ getparam(param, 1);
dp = save_string(dp, "%{10}%/%{16}%*");
- getparm(param, 1);
+ getparam(param, 1);
dp = save_string(dp, "%{10}%m%+");
break;
case '8':
case 'D':
- getparm(param, 2);
+ getparam(param, 2);
dp = save_string(dp, "%{2}%*%-");
break;
case '>':
/* %?%{x}%>%t%{y}%+%; */
if (s[0] && s[1]) {
- getparm(param, 2);
+ getparam(param, 2);
dp = save_string(dp, "%?");
s += cvtchar(s);
dp = save_string(dp, "%>%t");
@@ -385,9 +385,9 @@ _nc_captoinfo(const char *cap, const char *s, int const parameterized)
int l;
l = 2;
if (*s != '=')
- getparm(param, 1);
+ getparam(param, 1);
if (s[1] == 'p') {
- getparm(param + s[2] - '@', 1);
+ getparam(param + s[2] - '@', 1);
if (param != onstack) {
pop();
param--;
@@ -423,12 +423,12 @@ _nc_captoinfo(const char *cap, const char *s, int const parameterized)
s += l;
break;
}
- getparm(param, 1);
+ getparam(param, 1);
s += cvtchar(s);
dp = save_string(dp, "%+");
break;
case '+':
- getparm(param, 1);
+ getparam(param, 1);
s += cvtchar(s);
dp = save_string(dp, "%+%c");
pop();
@@ -436,22 +436,22 @@ _nc_captoinfo(const char *cap, const char *s, int const parameterized)
case 's':
#ifdef WATERLOO
s += cvtchar(s);
- getparm(param, 1);
+ getparam(param, 1);
dp = save_string(dp, "%-");
#else
- getparm(param, 1);
+ getparam(param, 1);
dp = save_string(dp, "%s");
pop();
#endif /* WATERLOO */
break;
case '-':
s += cvtchar(s);
- getparm(param, 1);
+ getparam(param, 1);
dp = save_string(dp, "%-%c");
pop();
break;
case '.':
- getparm(param, 1);
+ getparam(param, 1);
dp = save_string(dp, "%c");
pop();
break;
@@ -467,18 +467,18 @@ _nc_captoinfo(const char *cap, const char *s, int const parameterized)
goto invalid;
case '2':
see02:
- getparm(param, 1);
+ getparam(param, 1);
dp = save_string(dp, "%2d");
pop();
break;
case '3':
see03:
- getparm(param, 1);
+ getparam(param, 1);
dp = save_string(dp, "%3d");
pop();
break;
case 'd':
- getparm(param, 1);
+ getparam(param, 1);
dp = save_string(dp, "%d");
pop();
break;
@@ -535,8 +535,7 @@ _nc_captoinfo(const char *cap, const char *s, int const parameterized)
static int
bcd_expression(const char *str)
{
- /* leave this non-const for HPUX */
- static char fmt[] = "%%p%c%%{10}%%/%%{16}%%*%%p%c%%{10}%%m%%+";
+ static const char fmt[] = "%%p%c%%{10}%%/%%{16}%%*%%p%c%%{10}%%m%%+";
int len = 0;
char ch1, ch2;
@@ -550,7 +549,7 @@ bcd_expression(const char *str)
char buffer[80];
int tst;
_nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) fmt, ch1, ch2);
- tst = strlen(buffer) - 1;
+ tst = (int) strlen(buffer) - 1;
assert(len == tst);
}
#endif
@@ -620,7 +619,7 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
{
int seenone = 0, seentwo = 0, saw_m = 0, saw_n = 0;
const char *padding;
- const char *trimmed = 0;
+ const char *trimmed = NULL;
int in0, in1, in2;
char ch1 = 0, ch2 = 0;
char *bufptr = init_string();
@@ -656,9 +655,9 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
for (; !syntax_error &&
*str &&
- ((trimmed == 0) || (str < trimmed)); str++) {
+ ((trimmed == NULL) || (str < trimmed)); str++) {
int c1, c2;
- char *cp = 0;
+ char *cp = NULL;
if (str[0] == '^') {
if (str[1] == '\0' || (str + 1) == trimmed) {
@@ -744,7 +743,7 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
++myfix;
}
}
- } else if (strchr("E\\nrtbf", xx1) == 0) {
+ } else if (strchr("E\\nrtbf", xx1) == NULL) {
switch (xx1) {
case 'e':
xx1 = 'E';
@@ -815,7 +814,7 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
&& ((in0 == 4 && in1 == 10 && in2 == 48)
|| (in0 == 3 && in1 == 9 && in2 == 38))) {
/* dumb-down an optimized case from xterm-256color for termcap */
- if ((str = strstr(str, ";m")) == 0)
+ if ((str = strstr(str, ";m")) == NULL)
break; /* cannot happen */
++str;
if (in2 == 48) {
@@ -981,8 +980,8 @@ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameteriz
* 'str' always points to the end of what was scanned in this step,
* but that may not be the end of the string.
*/
- assert(str != 0);
- if (str == 0 || *str == '\0')
+ assert(str != NULL);
+ if (str == NULL || *str == '\0')
break;
} /* endwhile (*str) */
@@ -1029,7 +1028,7 @@ main(int argc, char *argv[])
char buf[BUFSIZ];
++curr_line;
- if (fgets(buf, sizeof(buf), stdin) == 0)
+ if (fgets(buf, sizeof(buf), stdin) == NULL)
break;
buf[strlen(buf) - 1] = '\0';
_nc_set_source(buf);
@@ -1051,7 +1050,7 @@ main(int argc, char *argv[])
NCURSES_EXPORT(void)
_nc_captoinfo_leaks(void)
{
- if (my_string != 0) {
+ if (my_string != NULL) {
FreeAndNull(my_string);
}
my_length = 0;
diff --git a/ncurses/tinfo/comp_error.c b/ncurses/tinfo/comp_error.c
index 3e6b4022a74b..d49164e6a5b5 100644
--- a/ncurses/tinfo/comp_error.c
+++ b/ncurses/tinfo/comp_error.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2020,2023 Thomas E. Dickey *
+ * Copyright 2019-2023,2024 Thomas E. Dickey *
* Copyright 1998-2012,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -42,7 +42,7 @@
#include <tic.h>
-MODULE_ID("$Id: comp_error.c,v 1.44 2023/06/15 20:27:02 tom Exp $")
+MODULE_ID("$Id: comp_error.c,v 1.45 2024/12/07 20:04:23 tom Exp $")
NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings = FALSE;
NCURSES_EXPORT_VAR(int) _nc_curr_line = 0; /* current line # in input */
@@ -75,9 +75,9 @@ NCURSES_EXPORT(void)
_nc_set_type(const char *const name)
{
#define MY_SIZE (size_t) MAX_NAME_SIZE
- if (TermType == 0)
+ if (TermType == NULL)
TermType = typeMalloc(char, MY_SIZE + 1);
- if (TermType != 0) {
+ if (TermType != NULL) {
TermType[0] = '\0';
if (name) {
_nc_STRNCAT(TermType, name, MY_SIZE, MY_SIZE);
@@ -89,13 +89,13 @@ NCURSES_EXPORT(void)
_nc_get_type(char *name)
{
#if NO_LEAKS
- if (name == 0 && TermType != 0) {
+ if (name == NULL && TermType != NULL) {
FreeAndNull(TermType);
return;
}
#endif
- if (name != 0)
- _nc_STRCPY(name, TermType != 0 ? TermType : "", MAX_NAME_SIZE);
+ if (name != NULL)
+ _nc_STRCPY(name, TermType != NULL ? TermType : "", MAX_NAME_SIZE);
}
static NCURSES_INLINE void
@@ -106,7 +106,7 @@ where_is_problem(void)
fprintf(stderr, ", line %d", _nc_curr_line);
if (_nc_curr_col > 0)
fprintf(stderr, ", col %d", _nc_curr_col);
- if (TermType != 0 && TermType[0] != '\0')
+ if (TermType != NULL && TermType[0] != '\0')
fprintf(stderr, ", terminal '%s'", TermType);
fputc(':', stderr);
fputc(' ', stderr);
diff --git a/ncurses/tinfo/comp_expand.c b/ncurses/tinfo/comp_expand.c
index e971384f52f2..5ea100e600ea 100644
--- a/ncurses/tinfo/comp_expand.c
+++ b/ncurses/tinfo/comp_expand.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 *
@@ -36,7 +36,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: comp_expand.c,v 1.35 2023/04/28 20:59:06 tom Exp $")
+MODULE_ID("$Id: comp_expand.c,v 1.37 2024/12/07 21:12:53 tom Exp $")
#if 0
#define DEBUG_THIS(p) DEBUG(9, p)
@@ -73,18 +73,18 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
int offset;
} fixups[MAX_TC_FIXUPS];
- if (srcp == 0) {
+ if (srcp == NULL) {
#if NO_LEAKS
- if (buffer != 0) {
+ if (buffer != NULL) {
FreeAndNull(buffer);
length = 0;
}
#endif
- return 0;
+ return NULL;
}
- if (buffer == 0 || need > length) {
- if ((buffer = typeRealloc(char, length = need, buffer)) == 0)
- return 0;
+ if (buffer == NULL || need > length) {
+ if ((buffer = typeRealloc(char, length = need, buffer)) == NULL)
+ return NULL;
}
DEBUG_THIS(("_nc_tic_expand %s:%s:%s",
@@ -124,12 +124,12 @@ _nc_tic_expand(const char *srcp, bool tic_format, int numbers)
case 1:
if (str[0] == L_BRACE
&& isdigit(UChar(str[1]))) {
- char *dst = 0;
+ char *dst = NULL;
long value = strtol(str + 1, &dst, 0);
- if (dst != 0
+ if (dst != NULL
&& *dst == R_BRACE
&& value < 127
- && isprint((int) value)) {
+ && isprint(UChar(value))) {
ch = (int) value;
buffer[bufp++] = S_QUOTE;
if (ch == '\\'
diff --git a/ncurses/tinfo/comp_hash.c b/ncurses/tinfo/comp_hash.c
index 4b081afa2c28..4554b923a1b3 100644
--- a/ncurses/tinfo/comp_hash.c
+++ b/ncurses/tinfo/comp_hash.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2020,2023 Thomas E. Dickey *
+ * Copyright 2019-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 *
@@ -45,7 +45,7 @@
#include <tic.h>
#include <hashsize.h>
-MODULE_ID("$Id: comp_hash.c,v 1.55 2023/06/24 13:29:43 tom Exp $")
+MODULE_ID("$Id: comp_hash.c,v 1.56 2024/12/07 20:05:08 tom Exp $")
/*
* Finds the entry for the given string in the hash table if present.
@@ -58,7 +58,7 @@ _nc_find_entry(const char *string,
bool termcap = (hash_table != _nc_get_hash_table(FALSE));
const HashData *data = _nc_get_hash_info(termcap);
int hashvalue;
- struct name_table_entry const *ptr = 0;
+ struct name_table_entry const *ptr = NULL;
struct name_table_entry const *real_table;
hashvalue = data->hash_of(string);
@@ -71,7 +71,7 @@ _nc_find_entry(const char *string,
ptr = real_table + data->table_data[hashvalue];
while (!data->compare_names(ptr->nte_name, string)) {
if (ptr->nte_link < 0) {
- ptr = 0;
+ ptr = NULL;
break;
}
ptr = real_table + (ptr->nte_link
@@ -108,7 +108,7 @@ _nc_find_type_entry(const char *string,
while (ptr->nte_type != type
|| !data->compare_names(ptr->nte_name, string)) {
if (ptr->nte_link < 0) {
- ptr = 0;
+ ptr = NULL;
break;
}
ptr = table + (ptr->nte_link + data->table_data[data->table_size]);
@@ -125,7 +125,7 @@ _nc_find_user_entry(const char *string)
{
const HashData *data = _nc_get_hash_user();
int hashvalue;
- struct user_table_entry const *ptr = 0;
+ struct user_table_entry const *ptr = NULL;
struct user_table_entry const *real_table;
hashvalue = data->hash_of(string);
@@ -138,7 +138,7 @@ _nc_find_user_entry(const char *string)
ptr = real_table + data->table_data[hashvalue];
while (!data->compare_names(ptr->ute_name, string)) {
if (ptr->ute_link < 0) {
- ptr = 0;
+ ptr = NULL;
break;
}
ptr = real_table + (ptr->ute_link
diff --git a/ncurses/tinfo/comp_parse.c b/ncurses/tinfo/comp_parse.c
index dec4b925625e..8c150f69e920 100644
--- a/ncurses/tinfo/comp_parse.c
+++ b/ncurses/tinfo/comp_parse.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 *
@@ -48,7 +48,7 @@
#include <tic.h>
-MODULE_ID("$Id: comp_parse.c,v 1.134 2024/02/10 15:52:11 tom Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.141 2025/12/27 12:33:34 tom Exp $")
static void sanity_check2(TERMTYPE2 *, bool);
NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2) (TERMTYPE2 *, bool) = sanity_check2;
@@ -64,13 +64,13 @@ enqueue(ENTRY * ep)
DEBUG(2, (T_CALLED("enqueue(ep=%p)"), (void *) ep));
newp = _nc_copy_entry(ep);
- if (newp == 0)
+ if (newp == NULL)
_nc_err_abort(MSG_NO_MEMORY);
newp->last = _nc_tail;
_nc_tail = newp;
- newp->next = 0;
+ newp->next = NULL;
if (newp->last)
newp->last->next = newp;
DEBUG(2, (T_RETURN("")));
@@ -81,7 +81,7 @@ enqueue(ENTRY * ep)
static char *
force_bar(char *dst, char *src)
{
- if (strchr(src, '|') == 0) {
+ if (strchr(src, '|') == NULL) {
size_t len = strlen(src);
if (len > MAX_NAME_SIZE)
len = MAX_NAME_SIZE;
@@ -91,7 +91,7 @@ force_bar(char *dst, char *src)
}
return src;
}
-#define ForceBar(dst, src) ((strchr(src, '|') == 0) ? force_bar(dst, src) : src)
+#define ForceBar(dst, src) ((strchr(src, '|') == NULL) ? force_bar(dst, src) : src)
#if NCURSES_USE_TERMCAP && NCURSES_XNAMES
static char *
@@ -99,7 +99,7 @@ skip_index(char *name)
{
char *bar = strchr(name, '|');
- if (bar != 0 && (bar - name) == 2)
+ if (bar != NULL && (bar - name) == 2)
name = bar + 1;
return name;
@@ -109,7 +109,9 @@ skip_index(char *name)
static bool
check_collisions(char *n1, char *n2, int counter)
{
- char *pstart, *qstart, *pend, *qend;
+ const char *pstart;
+ const char *qstart;
+ char *pend, *qend;
char nc1[NAMEBUFFER_SIZE];
char nc2[NAMEBUFFER_SIZE];
@@ -150,7 +152,7 @@ static char *
name_ending(char *name)
{
if (*name == '\0') {
- name = 0;
+ name = NULL;
} else {
while (*name != '\0' && *name != '|')
++name;
@@ -401,7 +403,7 @@ NCURSES_EXPORT(int)
_nc_resolve_uses2(bool fullresolve, bool literal)
/* try to resolve all use capabilities */
{
- ENTRY *qp, *rp, *lastread = 0;
+ ENTRY *qp, *rp, *lastread = NULL;
bool keepgoing;
unsigned i, j;
int total_unresolved, multiples;
@@ -450,7 +452,7 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
char *lookfor = qp->uses[i].name;
long lookline = qp->uses[i].line;
- if (lookfor == 0)
+ if (lookfor == NULL)
continue;
foundit = FALSE;
@@ -516,7 +518,7 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
_nc_curr_line = (int) lookline;
_nc_warning("resolution of use=%s failed", lookfor);
- qp->uses[i].link = 0;
+ qp->uses[i].link = NULL;
}
}
}
@@ -536,12 +538,18 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
*/
if (fullresolve) {
do {
+ bool attempts;
+ bool progress;
ENTRY merged;
+ attempts = FALSE;
+ progress = FALSE;
keepgoing = FALSE;
for_entry_list(qp) {
if (qp->nuses > 0) {
+ attempts = TRUE;
+
DEBUG(2, ("%s: attempting merge of %d entries",
_nc_first_name(qp->tterm.term_names),
qp->nuses));
@@ -597,16 +605,34 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
#endif
qp->tterm = merged.tterm;
_nc_wrap_entry(qp, TRUE);
+ progress = TRUE;
/*
- * We know every entry is resolvable because name resolution
- * didn't bomb. So go back for another pass.
+ * Every entry should be resolvable because name resolution
+ * did not fail. Continue if we have just made a change,
+ * or another entry may be changeable.
*/
/* FALLTHRU */
incomplete:
keepgoing = TRUE;
}
}
+
+ /*
+ * If we went all the way through the list without making any
+ * changes, while there were remaining use-linkages, something went
+ * wrong. Give up.
+ */
+ if (!progress && attempts) {
+ for_entry_list(qp) {
+ for (i = 0; i < qp->nuses; ++i) {
+ _nc_warning("problem with use=%s", qp->uses[i].name);
+ }
+ }
+ _nc_warning("merge failed, infinite loop");
+ DEBUG(2, (T_RETURN("false")));
+ return FALSE;
+ }
} while
(keepgoing);
@@ -640,6 +666,9 @@ _nc_resolve_uses2(bool fullresolve, bool literal)
TerminalType(&fake_tm) = qp->tterm;
_nc_set_screen(&fake_sp);
set_curterm(&fake_tm);
+#if USE_TERM_DRIVER
+ ((TERMINAL_CONTROL_BLOCK *) (CurTerm))->drv = &_nc_TINFO_DRIVER;
+#endif
_nc_check_termtype2(&qp->tterm, literal);
@@ -756,7 +785,7 @@ _nc_leaks_tic(void)
_nc_names_leaks();
_nc_codes_leaks();
#endif
- _nc_tic_expand(0, FALSE, 0);
+ _nc_tic_expand(NULL, FALSE, 0);
T((T_RETURN("")));
}
diff --git a/ncurses/tinfo/comp_scan.c b/ncurses/tinfo/comp_scan.c
index 3ba0835e2fb8..4a44c797edd2 100644
--- a/ncurses/tinfo/comp_scan.c
+++ b/ncurses/tinfo/comp_scan.c
@@ -1,5 +1,5 @@
/****************************************************************************
-,* Copyright 2020-2022,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 *
@@ -51,7 +51,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: comp_scan.c,v 1.122 2023/05/27 20:13:10 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.126 2024/12/07 21:17:54 tom Exp $")
/*
* Maximum length of string capability we'll accept before raising an error.
@@ -61,7 +61,7 @@ MODULE_ID("$Id: comp_scan.c,v 1.122 2023/05/27 20:13:10 tom Exp $")
#define iswhite(ch) (ch == ' ' || ch == '\t')
-NCURSES_EXPORT_VAR (int) _nc_syntax = 0; /* termcap or terminfo? */
+NCURSES_EXPORT_VAR (int) _nc_syntax = SYN_TERMINFO; /* termcap or terminfo? */
NCURSES_EXPORT_VAR (int) _nc_strict_bsd = 1; /* ncurses extended termcap? */
NCURSES_EXPORT_VAR (long) _nc_curr_file_pos = 0; /* file offset of current line */
NCURSES_EXPORT_VAR (long) _nc_comment_start = 0; /* start of comment range before name */
@@ -70,7 +70,7 @@ NCURSES_EXPORT_VAR (long) _nc_start_line = 0; /* start line of current entry
NCURSES_EXPORT_VAR (struct token) _nc_curr_token =
{
- 0, 0, 0
+ NULL, 0, NULL
};
/*****************************************************************************
@@ -116,12 +116,12 @@ _nc_reset_input(FILE *fp, char *buf)
(T_CALLED("_nc_reset_input(fp=%p, buf=%p)"), (void *) fp, buf));
pushtype = NO_PUSHBACK;
- if (pushname != 0)
+ if (pushname != NULL)
pushname[0] = '\0';
yyin = fp;
bufstart = bufptr = buf;
_nc_curr_file_pos = 0L;
- if (fp != 0)
+ if (fp != NULL)
_nc_curr_line = 0;
_nc_curr_col = 0;
@@ -197,18 +197,18 @@ next_char(void)
int the_char;
if (!yyin) {
- if (result != 0) {
+ if (result != NULL) {
FreeAndNull(result);
FreeAndNull(pushname);
- bufptr = 0;
- bufstart = 0;
+ bufptr = NULL;
+ bufstart = NULL;
allocated = 0;
}
/*
* An string with an embedded null will truncate the input. This is
* intentional (we don't read binary files here).
*/
- if (bufptr == 0 || *bufptr == '\0')
+ if (bufptr == NULL || *bufptr == '\0')
return (EOF);
if (*bufptr == '\n') {
_nc_curr_line++;
@@ -227,12 +227,12 @@ next_char(void)
do {
size_t used = 0;
- bufstart = 0;
+ bufstart = NULL;
do {
if (used + (LEXBUFSIZ / 4) >= allocated) {
allocated += (allocated + LEXBUFSIZ);
result = typeRealloc(char, allocated, result);
- if (result == 0)
+ if (result == NULL)
return (EOF);
if (bufstart)
bufstart = result;
@@ -254,7 +254,7 @@ next_char(void)
if (used != 0)
_nc_STRCAT(result, "\n", allocated);
}
- if ((bufptr = bufstart) != 0) {
+ if ((bufptr = bufstart) != NULL) {
used = strlen(bufptr);
if (used == 0)
return (EOF);
@@ -407,12 +407,12 @@ _nc_get_token(bool silent)
if (pushtype != NO_PUSHBACK) {
int retval = pushtype;
- _nc_set_type(pushname != 0 ? pushname : "");
+ _nc_set_type(pushname != NULL ? pushname : "");
DEBUG(3, ("pushed-back token: `%s', class %d",
_nc_curr_token.tk_name, pushtype));
pushtype = NO_PUSHBACK;
- if (pushname != 0)
+ if (pushname != NULL)
pushname[0] = '\0';
/* currtok wasn't altered by _nc_push_token() */
@@ -421,11 +421,11 @@ _nc_get_token(bool silent)
}
if (end_of_stream()) {
- yyin = 0;
+ yyin = NULL;
(void) next_char(); /* frees its allocated memory */
- if (tok_buf != 0) {
+ if (tok_buf != NULL) {
if (_nc_curr_token.tk_name == tok_buf)
- _nc_curr_token.tk_name = 0;
+ _nc_curr_token.tk_name = NULL;
}
DEBUG(3, (T_RETURN("%d"), EOF));
return (EOF);
@@ -439,7 +439,7 @@ _nc_get_token(bool silent)
}
ch = eat_escaped_newline(ch);
- _nc_curr_token.tk_valstring = 0;
+ _nc_curr_token.tk_valstring = NULL;
#ifdef TRACE
old_line = _nc_curr_line;
@@ -475,7 +475,7 @@ _nc_get_token(bool silent)
#if NCURSES_EXT_FUNCS
&& !(ch == '.' && _nc_disable_period)
#endif
- && ((strchr) (terminfo_punct, (char) ch) == 0)) {
+ && ((strchr) (terminfo_punct, (char) ch) == NULL)) {
if (!silent)
_nc_warning("Illegal character (expected alphanumeric or %s) - '%s'",
terminfo_punct, unctrl(UChar(ch)));
@@ -483,7 +483,7 @@ _nc_get_token(bool silent)
goto start_token;
}
- if (tok_buf == 0)
+ if (tok_buf == NULL)
tok_buf = typeMalloc(char, TOK_BUF_SIZE);
#ifdef TRACE
@@ -499,14 +499,14 @@ _nc_get_token(bool silent)
_nc_start_line = _nc_curr_line;
_nc_syntax = ERR;
- after_name = 0;
- after_list = 0;
+ after_name = NULL;
+ after_list = NULL;
while ((ch = next_char()) != '\n') {
if (ch == EOF) {
_nc_err_abort(MSG_NO_INPUTS);
} else if (ch == '|') {
after_list = tok_ptr;
- if (after_name == 0)
+ if (after_name == NULL)
after_name = tok_ptr;
} else if (ch == ':' && last_char(0) != ',') {
_nc_syntax = SYN_TERMCAP;
@@ -519,7 +519,7 @@ _nc_get_token(bool silent)
* If we did not see a '|', then we found a name with no
* aliases or description.
*/
- if (after_name == 0)
+ if (after_name == NULL)
break;
/*
* We saw a comma, but are not entirely sure this is
@@ -551,7 +551,7 @@ _nc_get_token(bool silent)
;
}
if (islower(UChar(*s))) {
- char *name = s;
+ const char *name = s;
while (isalnum(UChar(*s))) {
++s;
}
@@ -614,7 +614,7 @@ _nc_get_token(bool silent)
* for following warning messages. If there's no '|', then there
* is no description.
*/
- if (after_name != 0) {
+ if (after_name != NULL) {
ch = *after_name;
*after_name = '\0';
_nc_set_type(tok_buf);
@@ -625,11 +625,11 @@ _nc_get_token(bool silent)
* Compute the boundary between the aliases and the description
* field for syntax-checking purposes.
*/
- if (after_list != 0) {
+ if (after_list != NULL) {
if (!silent) {
if (*after_list == '\0' || strchr("|", after_list[1]) != NULL) {
_nc_warning("empty longname field");
- } else if (strchr(after_list, ' ') == 0) {
+ } else if (strchr(after_list, ' ') == NULL) {
_nc_warning("older tic versions may treat the description field as an alias");
}
}
@@ -805,7 +805,7 @@ _nc_get_token(bool silent)
type = _nc_get_token(silent);
DEBUG(3, ("token: `%s', class %d",
- ((_nc_curr_token.tk_name != 0)
+ ((_nc_curr_token.tk_name != NULL)
? _nc_curr_token.tk_name
: "<null>"),
type));
@@ -1023,12 +1023,12 @@ _nc_push_token(int tokclass)
* _nc_get_token() touches.
*/
pushtype = tokclass;
- if (pushname == 0)
+ if (pushname == NULL)
pushname = typeMalloc(char, MAX_NAME_SIZE + 1);
_nc_get_type(pushname);
DEBUG(3, ("pushing token: `%s', class %d",
- ((_nc_curr_token.tk_name != 0)
+ ((_nc_curr_token.tk_name != NULL)
? _nc_curr_token.tk_name
: "<null>"),
pushtype));
@@ -1053,10 +1053,10 @@ _nc_panic_mode(char ch)
NCURSES_EXPORT(void)
_nc_comp_scan_leaks(void)
{
- if (pushname != 0) {
+ if (pushname != NULL) {
FreeAndNull(pushname);
}
- if (tok_buf != 0) {
+ if (tok_buf != NULL) {
FreeAndNull(tok_buf);
}
}
diff --git a/ncurses/tinfo/db_iterator.c b/ncurses/tinfo/db_iterator.c
index db3872e3f90d..f757691a105a 100644
--- a/ncurses/tinfo/db_iterator.c
+++ b/ncurses/tinfo/db_iterator.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2006-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -44,7 +44,7 @@
#include <hashed_db.h>
#endif
-MODULE_ID("$Id: db_iterator.c,v 1.50 2023/06/24 21:52:32 tom Exp $")
+MODULE_ID("$Id: db_iterator.c,v 1.54 2025/12/25 18:19:46 tom Exp $")
#define HaveTicDirectory _nc_globals.have_tic_directory
#define KeepTicDirectory _nc_globals.keep_tic_directory
@@ -75,7 +75,7 @@ check_existence(const char *name, struct stat *sb)
if (quick_prefix(name)) {
result = TRUE;
- } else if (stat(name, sb) == 0
+ } else if (_nc_is_path_found(name, sb)
&& (S_ISDIR(sb->st_mode)
|| (S_ISREG(sb->st_mode) && sb->st_size))) {
result = TRUE;
@@ -84,7 +84,7 @@ check_existence(const char *name, struct stat *sb)
else if (strlen(name) < PATH_MAX - sizeof(DBM_SUFFIX)) {
char temp[PATH_MAX];
_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "%s%s", name, DBM_SUFFIX);
- if (stat(temp, sb) == 0 && S_ISREG(sb->st_mode) && sb->st_size) {
+ if (_nc_is_path_found(temp, sb) && S_ISREG(sb->st_mode) && sb->st_size) {
result = TRUE;
}
}
@@ -124,15 +124,15 @@ update_getenv(const char *name, DBDIRS which)
if (which < dbdLAST) {
char *value;
- char *cached_value = my_vars[which].value;
+ const char *cached_value = my_vars[which].value;
bool same_value;
- if ((value = getenv(name)) != 0) {
+ if ((value = getenv(name)) != NULL) {
value = strdup(value);
}
- same_value = ((value == 0 && cached_value == 0) ||
- (value != 0 &&
- cached_value != 0 &&
+ same_value = ((value == NULL && cached_value == NULL) ||
+ (value != NULL &&
+ cached_value != NULL &&
strcmp(value, cached_value) == 0));
/* Set variable name to enable checks in cache_expired(). */
@@ -153,7 +153,7 @@ update_getenv(const char *name, DBDIRS which)
static char *
cache_getenv(const char *name, DBDIRS which)
{
- char *result = 0;
+ char *result = NULL;
(void) update_getenv(name, which);
if (which < dbdLAST) {
@@ -185,7 +185,7 @@ cache_expired(void)
} else {
DBDIRS n;
for (n = (DBDIRS) 0; n < dbdLAST; ++n) {
- if (my_vars[n].name != 0
+ if (my_vars[n].name != NULL
&& update_getenv(my_vars[n].name, n)) {
result = TRUE;
break;
@@ -225,7 +225,7 @@ _nc_tic_dir(const char *path)
} else if (HaveTicDirectory == 0) {
if (use_terminfo_vars()) {
const char *envp;
- if ((envp = getenv("TERMINFO")) != 0)
+ if ((envp = getenv("TERMINFO")) != NULL)
return _nc_tic_dir(envp);
}
}
@@ -251,7 +251,7 @@ _nc_keep_tic_dir(const char *path)
NCURSES_EXPORT(void)
_nc_last_db(void)
{
- if (my_blob != 0 && cache_expired()) {
+ if (my_blob != NULL && cache_expired()) {
free_cache();
}
}
@@ -268,14 +268,14 @@ _nc_next_db(DBDIRS * state, int *offset)
(void) offset;
if ((int) *state < my_size
- && my_list != 0
- && my_list[*state] != 0) {
+ && my_list != NULL
+ && my_list[*state] != NULL) {
result = my_list[*state];
(*state)++;
} else {
- result = 0;
+ result = NULL;
}
- if (result != 0) {
+ if (result != NULL) {
T(("_nc_next_db %d %s", *state, result));
}
return result;
@@ -293,7 +293,7 @@ _nc_first_db(DBDIRS * state, int *offset)
/* build a blob containing all of the strings we will use for a lookup
* table.
*/
- if (my_blob == 0 || (cache_has_expired = cache_expired())) {
+ if (my_blob == NULL || (cache_has_expired = cache_expired())) {
size_t blobsize = 0;
const char *values[dbdLAST];
struct stat *my_stat;
@@ -303,7 +303,7 @@ _nc_first_db(DBDIRS * state, int *offset)
free_cache();
for (j = 0; j < dbdLAST; ++j)
- values[j] = 0;
+ values[j] = NULL;
/*
* This is the first item in the list, and is used only when tic is
@@ -335,22 +335,22 @@ _nc_first_db(DBDIRS * state, int *offset)
#if NCURSES_USE_TERMCAP
values[dbdEnvOnce2] = cache_getenv("TERMCAP", dbdEnvOnce2);
/* only use $TERMCAP if it is an absolute path */
- if (values[dbdEnvOnce2] != 0
+ if (values[dbdEnvOnce2] != NULL
&& *values[dbdEnvOnce2] != '/') {
- values[dbdEnvOnce2] = 0;
+ values[dbdEnvOnce2] = NULL;
}
values[dbdEnvList2] = cache_getenv("TERMPATH", dbdEnvList2);
#endif /* NCURSES_USE_TERMCAP */
}
for (j = 0; j < dbdLAST; ++j) {
- if (values[j] == 0)
+ if (values[j] == NULL)
values[j] = "";
blobsize += 2 + strlen(values[j]);
}
my_blob = malloc(blobsize);
- if (my_blob != 0) {
+ if (my_blob != NULL) {
*my_blob = '\0';
for (j = 0; j < dbdLAST; ++j) {
add_to_blob(values[j], blobsize);
@@ -366,7 +366,7 @@ _nc_first_db(DBDIRS * state, int *offset)
}
my_list = typeCalloc(char *, blobsize);
my_stat = typeCalloc(struct stat, blobsize);
- if (my_list != 0 && my_stat != 0) {
+ if (my_list != NULL && my_stat != NULL) {
int k = 0;
my_list[k++] = my_blob;
for (j = 0; my_blob[j] != '\0'; ++j) {
@@ -381,11 +381,11 @@ _nc_first_db(DBDIRS * state, int *offset)
/*
* Eliminate duplicates from the list.
*/
- for (j = 0; my_list[j] != 0; ++j) {
+ for (j = 0; my_list[j] != NULL; ++j) {
#ifdef TERMINFO
if (*my_list[j] == '\0') {
char *my_copy = strdup(TERMINFO);
- if (my_copy != 0)
+ if (my_copy != NULL)
my_list[j] = my_copy;
}
#endif
@@ -394,7 +394,7 @@ _nc_first_db(DBDIRS * state, int *offset)
if (!strcmp(my_list[j], my_list[k])) {
T(("duplicate %s", my_list[j]));
k = j - 1;
- while ((my_list[j] = my_list[j + 1]) != 0) {
+ while ((my_list[j] = my_list[j + 1]) != NULL) {
++j;
}
j = k;
@@ -407,7 +407,7 @@ _nc_first_db(DBDIRS * state, int *offset)
* Eliminate non-existent databases, and those that happen to
* be symlinked to another location.
*/
- for (j = 0; my_list[j] != 0; ++j) {
+ for (j = 0; my_list[j] != NULL; ++j) {
bool found = check_existence(my_list[j], &my_stat[j]);
#if HAVE_LINK
if (found) {
@@ -423,7 +423,7 @@ _nc_first_db(DBDIRS * state, int *offset)
if (!found) {
T(("not found %s", my_list[j]));
k = j;
- while ((my_list[k] = my_list[k + 1]) != 0) {
+ while ((my_list[k] = my_list[k + 1]) != NULL) {
++k;
}
--j;
@@ -446,14 +446,14 @@ _nc_db_iterator_leaks(void)
{
DBDIRS which;
- if (my_blob != 0)
+ if (my_blob != NULL)
FreeAndNull(my_blob);
- if (my_list != 0)
+ if (my_list != NULL)
FreeAndNull(my_list);
for (which = 0; (int) which < dbdLAST; ++which) {
- my_vars[which].name = 0;
+ my_vars[which].name = NULL;
FreeIfNeeded(my_vars[which].value);
- my_vars[which].value = 0;
+ my_vars[which].value = NULL;
}
update_tic_dir(NULL);
}
diff --git a/ncurses/tinfo/doalloc.c b/ncurses/tinfo/doalloc.c
index e3b1a2e96c1b..dac28f60f4cd 100644
--- a/ncurses/tinfo/doalloc.c
+++ b/ncurses/tinfo/doalloc.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2021,2024 Thomas E. Dickey *
* Copyright 1998-2002,2012 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: doalloc.c,v 1.14 2021/04/24 23:43:39 tom Exp $")
+MODULE_ID("$Id: doalloc.c,v 1.15 2024/12/07 20:05:08 tom Exp $")
void *
_nc_doalloc(void *oldp, size_t amount)
@@ -51,7 +51,7 @@ _nc_doalloc(void *oldp, size_t amount)
if (amount == 0) {
free(oldp);
newp = NULL;
- } else if ((newp = realloc(oldp, amount)) == 0) {
+ } else if ((newp = realloc(oldp, amount)) == NULL) {
free(oldp);
errno = ENOMEM; /* just in case 'free' reset */
}
diff --git a/ncurses/tinfo/entries.c b/ncurses/tinfo/entries.c
index f47fd3fe9eff..57272a8f626e 100644
--- a/ncurses/tinfo/entries.c
+++ b/ncurses/tinfo/entries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2022,2023 Thomas E. Dickey *
+ * Copyright 2019-2023,2024 Thomas E. Dickey *
* Copyright 2006-2012,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -38,7 +38,7 @@
#include <tic.h>
-MODULE_ID("$Id: entries.c,v 1.35 2023/05/27 20:13:10 tom Exp $")
+MODULE_ID("$Id: entries.c,v 1.39 2024/12/14 23:48:20 tom Exp $")
/****************************************************************************
*
@@ -61,8 +61,8 @@ MODULE_ID("$Id: entries.c,v 1.35 2023/05/27 20:13:10 tom Exp $")
* _nc_head _nc_tail
*/
-NCURSES_EXPORT_VAR(ENTRY *) _nc_head = 0;
-NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = 0;
+NCURSES_EXPORT_VAR(ENTRY *) _nc_head = NULL;
+NCURSES_EXPORT_VAR(ENTRY *) _nc_tail = NULL;
static ENTRY *
_nc_delink_entry(ENTRY * headp, const TERMTYPE2 *const tterm)
@@ -70,12 +70,12 @@ _nc_delink_entry(ENTRY * headp, const TERMTYPE2 *const tterm)
{
ENTRY *ep, *last;
- for (last = 0, ep = headp; ep != 0; last = ep, ep = ep->next) {
+ for (last = NULL, ep = headp; ep != NULL; last = ep, ep = ep->next) {
if (&(ep->tterm) == tterm) {
- if (last != 0) {
+ if (last != NULL) {
last->next = ep->next;
}
- if (ep->next != 0) {
+ if (ep->next != NULL) {
ep->next->last = last;
}
if (ep == _nc_head) {
@@ -91,12 +91,12 @@ _nc_delink_entry(ENTRY * headp, const TERMTYPE2 *const tterm)
}
NCURSES_EXPORT(void)
-_nc_free_entry(ENTRY * headp, TERMTYPE2 *tterm)
+_nc_free_entry(ENTRY * headp, const TERMTYPE2 *tterm)
/* free the allocated storage consumed by the given list entry */
{
ENTRY *ep;
- if ((ep = _nc_delink_entry(headp, tterm)) != 0) {
+ if ((ep = _nc_delink_entry(headp, tterm)) != NULL) {
free(ep);
}
}
@@ -107,7 +107,7 @@ _nc_free_entries(ENTRY * headp)
{
(void) headp; /* unused - _nc_head is altered here! */
- while (_nc_head != 0) {
+ while (_nc_head != NULL) {
_nc_free_termtype2(&(_nc_head->tterm));
}
}
@@ -133,7 +133,7 @@ _nc_leaks_tinfo(void)
{
PRESCREEN_LIST *p;
pthread_t id = GetThreadID();
- for (p = _nc_prescreen.allocated; p != 0; p = p->next) {
+ for (p = _nc_prescreen.allocated; p != NULL; p = p->next) {
if (p->id == id && p->sp != CURRENT_SCREEN) {
FreeAndNull(p->sp);
}
@@ -141,7 +141,7 @@ _nc_leaks_tinfo(void)
}
_nc_unlock_global(screen);
#endif
- if (TerminalOf(CURRENT_SCREEN) != 0) {
+ if (TerminalOf(CURRENT_SCREEN) != NULL) {
del_curterm(TerminalOf(CURRENT_SCREEN));
}
_nc_forget_prescr();
@@ -149,8 +149,8 @@ _nc_leaks_tinfo(void)
_nc_comp_captab_leaks();
_nc_comp_userdefs_leaks();
_nc_free_entries(_nc_head);
- _nc_get_type(0);
- _nc_first_name(0);
+ _nc_get_type(NULL);
+ _nc_first_name(NULL);
_nc_db_iterator_leaks();
_nc_keyname_leaks();
#if BROKEN_LINKER || USE_REENTRANT
@@ -160,7 +160,7 @@ _nc_leaks_tinfo(void)
#endif
_nc_comp_error_leaks();
- if ((s = _nc_home_terminfo()) != 0)
+ if ((s = _nc_home_terminfo()) != NULL)
free(s);
#ifdef TRACE
diff --git a/ncurses/tinfo/getenv_num.c b/ncurses/tinfo/getenv_num.c
index ca179d3343b9..21a250870343 100644
--- a/ncurses/tinfo/getenv_num.c
+++ b/ncurses/tinfo/getenv_num.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018,2020 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 *
@@ -37,16 +37,16 @@
#include <curses.priv.h>
-MODULE_ID("$Id: getenv_num.c,v 1.8 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: getenv_num.c,v 1.11 2025/02/20 01:02:09 tom Exp $")
NCURSES_EXPORT(int)
_nc_getenv_num(const char *name)
{
- char *dst = 0;
- char *src = getenv(name);
+ char *dst = NULL;
+ const char *src = getenv(name);
long value;
- if ((src == 0)
+ if ((src == NULL)
|| (value = strtol(src, &dst, 0)) < 0
|| (dst == src)
|| (*dst != '\0')
@@ -59,7 +59,7 @@ _nc_getenv_num(const char *name)
NCURSES_EXPORT(void)
_nc_setenv_num(const char *name, int value)
{
- if (name != 0 && value >= 0) {
+ if (name != NULL && value >= 0) {
char buffer[128];
#if HAVE_SETENV
_nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) "%d", value);
@@ -67,7 +67,7 @@ _nc_setenv_num(const char *name, int value)
#elif HAVE_PUTENV
char *s;
_nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) "%s=%d", name, value);
- if ((s = strdup(buffer)) != 0)
+ if ((s = strdup(buffer)) != NULL)
putenv(s);
#else
#error expected setenv/putenv functions
diff --git a/ncurses/tinfo/hashed_db.c b/ncurses/tinfo/hashed_db.c
index b78d98f874fe..afd1bda827d4 100644
--- a/ncurses/tinfo/hashed_db.c
+++ b/ncurses/tinfo/hashed_db.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 2006-2011,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -37,7 +37,7 @@
#if USE_HASHED_DB
-MODULE_ID("$Id: hashed_db.c,v 1.19 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: hashed_db.c,v 1.22 2025/01/11 23:52:18 tom Exp $")
#if HASHED_DB_API >= 2
static DBC *cursor;
@@ -55,7 +55,7 @@ static MYCONN *connections;
static void
cleanup(void)
{
- while (connections != 0) {
+ while (connections != NULL) {
_nc_db_close(connections->db);
}
}
@@ -63,10 +63,10 @@ cleanup(void)
static DB *
find_connection(const char *path, bool modify)
{
- DB *result = 0;
+ DB *result = NULL;
MYCONN *p;
- for (p = connections; p != 0; p = p->next) {
+ for (p = connections; p != NULL; p = p->next) {
if (!strcmp(p->path, path) && p->modify == modify) {
result = p->db;
break;
@@ -81,9 +81,9 @@ drop_connection(DB * db)
{
MYCONN *p, *q;
- for (p = connections, q = 0; p != 0; q = p, p = p->next) {
+ for (p = connections, q = NULL; p != NULL; q = p, p = p->next) {
if (p->db == db) {
- if (q != 0)
+ if (q != NULL)
q->next = p->next;
else
connections = p->next;
@@ -94,22 +94,25 @@ drop_connection(DB * db)
}
}
-static void
+static bool
make_connection(DB * db, const char *path, bool modify)
{
+ bool code = FALSE;
MYCONN *p = typeCalloc(MYCONN, 1);
- if (p != 0) {
- p->db = db;
+ if (p != NULL) {
p->path = strdup(path);
- p->modify = modify;
- if (p->path != 0) {
+ if (p->path != NULL) {
+ p->db = db;
+ p->modify = modify;
p->next = connections;
connections = p;
+ code = TRUE;
} else {
free(p);
}
}
+ return code;
}
/*
@@ -118,13 +121,13 @@ make_connection(DB * db, const char *path, bool modify)
NCURSES_EXPORT(DB *)
_nc_db_open(const char *path, bool modify)
{
- DB *result = 0;
+ DB *result = NULL;
int code;
- if (connections == 0)
+ if (connections == NULL)
atexit(cleanup);
- if ((result = find_connection(path, modify)) == 0) {
+ if ((result = find_connection(path, modify)) == NULL) {
#if HASHED_DB_API >= 4
db_create(&result, NULL, 0);
@@ -135,7 +138,7 @@ _nc_db_open(const char *path, bool modify)
DB_HASH,
modify ? DB_CREATE : DB_RDONLY,
0644)) != 0) {
- result = 0;
+ result = NULL;
}
#elif HASHED_DB_API >= 3
db_create(&result, NULL, 0);
@@ -145,7 +148,7 @@ _nc_db_open(const char *path, bool modify)
DB_HASH,
modify ? DB_CREATE : DB_RDONLY,
0644)) != 0) {
- result = 0;
+ result = NULL;
}
#elif HASHED_DB_API >= 2
if ((code = db_open(path,
@@ -155,22 +158,24 @@ _nc_db_open(const char *path, bool modify)
(DB_ENV *) 0,
(DB_INFO *) 0,
&result)) != 0) {
- result = 0;
+ result = NULL;
}
#else
if ((result = dbopen(path,
modify ? (O_CREAT | O_RDWR) : O_RDONLY,
0644,
DB_HASH,
- NULL)) == 0) {
+ NULL)) == NULL) {
code = errno;
+ } else {
+ code = 0;
}
#endif
- if (result != 0) {
- make_connection(result, path, modify);
+ if (result != NULL && make_connection(result, path, modify)) {
T(("opened %s", path));
} else {
- T(("cannot open %s: %s", path, strerror(code)));
+ T(("cannot open %s: (errno %d) %s", path, code, strerror(code)));
+ errno = code;
}
}
return result;
diff --git a/ncurses/tinfo/home_terminfo.c b/ncurses/tinfo/home_terminfo.c
index 7e626dfcaad7..7201de4637aa 100644
--- a/ncurses/tinfo/home_terminfo.c
+++ b/ncurses/tinfo/home_terminfo.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 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 *
@@ -38,7 +38,7 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: home_terminfo.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: home_terminfo.c,v 1.19 2024/12/07 18:14:49 tom Exp $")
/* ncurses extension...fall back on user's private directory */
@@ -47,14 +47,14 @@ MODULE_ID("$Id: home_terminfo.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
NCURSES_EXPORT(char *)
_nc_home_terminfo(void)
{
- char *result = 0;
+ char *result = NULL;
#if USE_HOME_TERMINFO
if (use_terminfo_vars()) {
- if (MyBuffer == 0) {
- char *home;
+ if (MyBuffer == NULL) {
+ const char *home;
- if ((home = getenv("HOME")) != 0) {
+ if ((home = getenv("HOME")) != NULL) {
size_t want = (strlen(home) + sizeof(PRIVATE_INFO));
TYPE_MALLOC(char, want, MyBuffer);
_nc_SPRINTF(MyBuffer, _nc_SLIMIT(want) PRIVATE_INFO, home);
diff --git a/ncurses/tinfo/init_keytry.c b/ncurses/tinfo/init_keytry.c
index ef20dfb1da08..78f8b3e4eb59 100644
--- a/ncurses/tinfo/init_keytry.c
+++ b/ncurses/tinfo/init_keytry.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 1999-2010,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -30,7 +30,7 @@
#include <curses.priv.h>
#include <tic.h> /* struct tinfo_fkeys */
-MODULE_ID("$Id: init_keytry.c,v 1.20 2023/09/16 12:55:01 tom Exp $")
+MODULE_ID("$Id: init_keytry.c,v 1.22 2024/12/07 18:14:49 tom Exp $")
/*
** _nc_init_keytry()
@@ -74,7 +74,7 @@ _nc_init_keytry(SCREEN *sp)
* mouse_activate() (which will call keyok()) are first called.
*/
- if (sp != 0) {
+ if (sp != NULL) {
unsigned n;
for (n = 0; _nc_tinfo_fkeys[n].code; n++) {
@@ -94,8 +94,8 @@ _nc_init_keytry(SCREEN *sp)
TERMTYPE *tp = &(sp->_term->type);
for (n = STRCOUNT; n < NUM_STRINGS(tp); ++n) {
const char *name = ExtStrname(tp, (int) n, strnames);
- char *value = tp->Strings[n];
- if (name != 0
+ const char *value = tp->Strings[n];
+ if (name != NULL
&& *name == 'k'
&& VALID_STRING(value)
&& NCURSES_SP_NAME(key_defined) (NCURSES_SP_ARGx
diff --git a/ncurses/tinfo/lib_acs.c b/ncurses/tinfo/lib_acs.c
index 4ede53f6b995..52d0c5a6aa9a 100644
--- a/ncurses/tinfo/lib_acs.c
+++ b/ncurses/tinfo/lib_acs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2019,2020 Thomas E. Dickey *
+ * Copyright 2018-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 *
@@ -40,14 +40,14 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_acs.c,v 1.50 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_acs.c,v 1.54 2025/12/27 12:33:34 tom Exp $")
#if BROKEN_LINKER || USE_REENTRANT
#define MyBuffer _nc_prescreen.real_acs_map
NCURSES_EXPORT(chtype *)
NCURSES_PUBLIC_VAR(acs_map) (void)
{
- if (MyBuffer == 0)
+ if (MyBuffer == NULL)
MyBuffer = typeCalloc(chtype, ACS_LEN);
return MyBuffer;
}
@@ -59,14 +59,14 @@ NCURSES_EXPORT_VAR (chtype) acs_map[ACS_LEN] =
};
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
NCURSES_EXPORT(chtype)
NCURSES_SP_NAME(_nc_acs_char) (NCURSES_SP_DCLx int c)
{
chtype *map;
if (c < 0 || c >= ACS_LEN)
return (chtype) 0;
- map = (SP_PARM != 0) ? SP_PARM->_acs_map :
+ map = (SP_PARM != NULL) ? SP_PARM->_acs_map :
#if BROKEN_LINKER || USE_REENTRANT
_nc_prescreen.real_acs_map
#else
@@ -81,7 +81,7 @@ NCURSES_EXPORT(void)
NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0)
{
chtype *fake_map = acs_map;
- chtype *real_map = SP_PARM != 0 ? SP_PARM->_acs_map : fake_map;
+ chtype *real_map = SP_PARM != NULL ? SP_PARM->_acs_map : fake_map;
int j;
T(("initializing ACS map"));
@@ -166,7 +166,7 @@ NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0)
real_map['Y'] = '|'; /* vertical line */
real_map['E'] = '+'; /* large plus or crossover */
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver_2(SP_PARM, td_initacs, real_map, fake_map);
#else
if (ena_acs != NULL) {
@@ -183,7 +183,7 @@ NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0)
*
* test/blue.c uses this feature.
*/
-#define PCH_KLUDGE(a,b) (a != 0 && b != 0 && !strcmp(a,b))
+#define PCH_KLUDGE(a,b) (a != NULL && b != NULL && !strcmp(a,b))
if (PCH_KLUDGE(enter_pc_charset_mode, enter_alt_charset_mode) &&
PCH_KLUDGE(exit_pc_charset_mode, exit_alt_charset_mode)) {
size_t i;
@@ -191,7 +191,7 @@ NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0)
if (real_map[i] == 0) {
real_map[i] = (chtype) i;
if (real_map != fake_map) {
- if (SP != 0)
+ if (SP != NULL)
SP->_screen_acs_map[i] = TRUE;
}
}
@@ -210,7 +210,7 @@ NCURSES_SP_NAME(_nc_init_acs) (NCURSES_SP_DCL0)
(int) i,
_tracechar(UChar(acs_chars[i])),
_tracechtype(real_map[UChar(acs_chars[i])])));
- if (SP != 0) {
+ if (SP != NULL) {
SP->_screen_acs_map[UChar(acs_chars[i])] = TRUE;
}
}
@@ -258,7 +258,7 @@ _nc_init_acs(void)
#if !NCURSES_WCWIDTH_GRAPHICS
NCURSES_EXPORT(int)
-_nc_wacs_width(unsigned ch)
+_nc_wacs_width(wchar_t ch)
{
int result;
switch (ch) {
@@ -318,7 +318,7 @@ _nc_wacs_width(unsigned ch)
result = 1;
break;
default:
- result = wcwidth(ch);
+ result = wcwidth((wchar_t) ch);
break;
}
return result;
diff --git a/ncurses/tinfo/lib_baudrate.c b/ncurses/tinfo/lib_baudrate.c
index 311c41ac97fa..3a2537e1af6e 100644
--- a/ncurses/tinfo/lib_baudrate.c
+++ b/ncurses/tinfo/lib_baudrate.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-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 *
@@ -84,7 +84,7 @@
#undef USE_OLD_TTY
#endif /* USE_OLD_TTY */
-MODULE_ID("$Id: lib_baudrate.c,v 1.45 2020/09/05 21:15:32 tom Exp $")
+MODULE_ID("$Id: lib_baudrate.c,v 1.50 2025/12/23 09:21:42 tom Exp $")
/*
* int
@@ -99,7 +99,7 @@ struct speed {
int actual_speed; /* the actual speed */
};
-#if !defined(EXP_WIN32_DRIVER)
+#if !defined(USE_WIN32CON_DRIVER)
#define DATA(number) { B##number, number }
static struct speed const speeds[] =
@@ -189,12 +189,12 @@ static struct speed const speeds[] =
#endif
#endif
};
-#endif /* !EXP_WIN32_DRIVER */
+#endif /* !USE_NAMED_PIPES */
NCURSES_EXPORT(int)
_nc_baudrate(int OSpeed)
{
-#if defined(EXP_WIN32_DRIVER)
+#if defined(USE_WIN32CON_DRIVER)
/* On Windows this is a noop */
(void) OSpeed;
return (OK);
@@ -237,14 +237,14 @@ _nc_baudrate(int OSpeed)
#endif
}
return (result);
-#endif /* !EXP_WIN32_DRIVER */
+#endif /* !USE_NAMED_PIPES */
}
NCURSES_EXPORT(int)
_nc_ospeed(int BaudRate)
{
int result = 1;
-#if defined(EXP_WIN32_DRIVER)
+#if defined(USE_WIN32CON_DRIVER)
(void) BaudRate;
#else
if (BaudRate >= 0) {
@@ -268,7 +268,8 @@ NCURSES_SP_NAME(baudrate) (NCURSES_SP_DCL0)
T((T_CALLED("baudrate(%p)"), (void *) SP_PARM));
-#if defined(EXP_WIN32_DRIVER)
+#if defined(USE_WIN32CON_DRIVER)
+ (void) SP_PARM;
result = OK;
#else
/*
@@ -279,7 +280,7 @@ NCURSES_SP_NAME(baudrate) (NCURSES_SP_DCL0)
#ifdef TRACE
if (IsValidTIScreen(SP_PARM)
&& !NC_ISATTY(fileno((SP_PARM && SP_PARM->_ofp) ? SP_PARM->_ofp : stdout))
- && getenv("BAUDRATE") != 0) {
+ && getenv("BAUDRATE") != NULL) {
int ret;
if ((ret = _nc_getenv_num("BAUDRATE")) <= 0)
ret = 9600;
@@ -304,7 +305,7 @@ NCURSES_SP_NAME(baudrate) (NCURSES_SP_DCL0)
} else {
result = ERR;
}
-#endif /* !EXP_WIN32_DRIVER */
+#endif /* !USE_NAMED_PIPES */
returnCode(result);
}
diff --git a/ncurses/tinfo/lib_cur_term.c b/ncurses/tinfo/lib_cur_term.c
index 1f8db2c1e0c8..23688e732749 100644
--- a/ncurses/tinfo/lib_cur_term.c
+++ b/ncurses/tinfo/lib_cur_term.c
@@ -1,5 +1,5 @@
/****************************************************************************
-,* Copyright 2020-2021,2022 Thomas E. Dickey *
+ * Copyright 2020-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 *
@@ -41,7 +41,7 @@
#include <termcap.h> /* ospeed */
#include <tic.h> /* VALID_STRING */
-MODULE_ID("$Id: lib_cur_term.c,v 1.49 2022/05/28 17:56:55 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.53 2025/12/27 12:41:23 tom Exp $")
#undef CUR
#define CUR TerminalType(termp).
@@ -51,7 +51,7 @@ MODULE_ID("$Id: lib_cur_term.c,v 1.49 2022/05/28 17:56:55 tom Exp $")
NCURSES_EXPORT(TERMINAL *)
NCURSES_SP_NAME(_nc_get_cur_term) (NCURSES_SP_DCL0)
{
- return ((0 != TerminalOf(SP_PARM)) ? TerminalOf(SP_PARM) : CurTerm);
+ return ((NULL != TerminalOf(SP_PARM)) ? TerminalOf(SP_PARM) : CurTerm);
}
#if NCURSES_SP_FUNCS
@@ -74,7 +74,7 @@ NCURSES_PUBLIC_VAR(cur_term) (void)
}
#else
-NCURSES_EXPORT_VAR(TERMINAL *) cur_term = 0;
+NCURSES_EXPORT_VAR(TERMINAL *) cur_term = NULL;
#endif
NCURSES_EXPORT(TERMINAL *)
@@ -93,8 +93,8 @@ NCURSES_SP_NAME(set_curterm) (NCURSES_SP_DCLx TERMINAL *termp)
#else
cur_term = termp;
#endif
- if (termp != 0) {
-#ifdef USE_TERM_DRIVER
+ if (termp != NULL) {
+#if USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) termp;
ospeed = (NCURSES_OSPEED) _nc_ospeed(termp->_baudrate);
if (TCB->drv &&
@@ -134,8 +134,8 @@ NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL *termp)
T((T_CALLED("del_curterm(%p, %p)"), (void *) SP_PARM, (void *) termp));
- if (termp != 0) {
-#ifdef USE_TERM_DRIVER
+ if (termp != NULL) {
+#if USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) termp;
#endif
TERMINAL *cur = (
@@ -155,15 +155,15 @@ NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL *termp)
#endif
_nc_free_termtype2(&TerminalType(termp));
if (termp == cur)
- NCURSES_SP_NAME(set_curterm) (NCURSES_SP_ARGx 0);
+ NCURSES_SP_NAME(set_curterm) (NCURSES_SP_ARGx NULL);
FreeIfNeeded(termp->_termname);
#if USE_HOME_TERMINFO
- if (_nc_globals.home_terminfo != 0) {
+ if (_nc_globals.home_terminfo != NULL) {
FreeAndNull(_nc_globals.home_terminfo);
}
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
if (TCB->drv)
TCB->drv->td_release(TCB);
#endif
diff --git a/ncurses/tinfo/lib_data.c b/ncurses/tinfo/lib_data.c
index b817f49bd78a..44622db62958 100644
--- a/ncurses/tinfo/lib_data.c
+++ b/ncurses/tinfo/lib_data.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,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 *
@@ -43,7 +43,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_data.c,v 1.89 2024/02/24 18:11:38 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.95 2025/12/27 12:33:34 tom Exp $")
/*
* OS/2's native linker complains if we don't initialize public data when
@@ -53,25 +53,25 @@ MODULE_ID("$Id: lib_data.c,v 1.89 2024/02/24 18:11:38 tom Exp $")
NCURSES_EXPORT(WINDOW *)
NCURSES_PUBLIC_VAR(stdscr) (void)
{
- return CURRENT_SCREEN ? StdScreen(CURRENT_SCREEN) : 0;
+ return CURRENT_SCREEN ? StdScreen(CURRENT_SCREEN) : NULL;
}
NCURSES_EXPORT(WINDOW *)
NCURSES_PUBLIC_VAR(curscr) (void)
{
- return CURRENT_SCREEN ? CurScreen(CURRENT_SCREEN) : 0;
+ return CURRENT_SCREEN ? CurScreen(CURRENT_SCREEN) : NULL;
}
NCURSES_EXPORT(WINDOW *)
NCURSES_PUBLIC_VAR(newscr) (void)
{
- return CURRENT_SCREEN ? NewScreen(CURRENT_SCREEN) : 0;
+ return CURRENT_SCREEN ? NewScreen(CURRENT_SCREEN) : NULL;
}
#else
-NCURSES_EXPORT_VAR(WINDOW *) stdscr = 0;
-NCURSES_EXPORT_VAR(WINDOW *) curscr = 0;
-NCURSES_EXPORT_VAR(WINDOW *) newscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) stdscr = NULL;
+NCURSES_EXPORT_VAR(WINDOW *) curscr = NULL;
+NCURSES_EXPORT_VAR(WINDOW *) newscr = NULL;
#endif
-NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = 0;
+NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = NULL;
/*
* The variable 'SP' will be defined as a function on systems that cannot link
@@ -97,7 +97,7 @@ _nc_alloc_screen(void)
{
my_screen = _nc_alloc_screen_sp();
T(("_nc_alloc_screen_sp %p", my_screen));
- return (my_screen != 0);
+ return (my_screen != NULL);
}
NCURSES_EXPORT(void)
@@ -129,7 +129,7 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
FALSE, /* have_tic_directory */
FALSE, /* keep_tic_directory */
- 0, /* tic_directory */
+ NULL, /* tic_directory */
NULL, /* dbi_list */
0, /* dbi_size */
@@ -150,19 +150,19 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
0, /* tgetent_sequence */
0, /* terminal_count */
- 0, /* dbd_blob */
- 0, /* dbd_list */
+ NULL, /* dbd_blob */
+ NULL, /* dbd_list */
0, /* dbd_size */
0, /* dbd_time */
- { { 0, 0 } }, /* dbd_vars */
+ { { NULL, NULL } }, /* dbd_vars */
#if HAVE_TSEARCH
NULL, /* cached_tparm */
0, /* count_tparm */
#endif /* HAVE_TSEARCH */
-#ifdef USE_TERM_DRIVER
- 0, /* term_driver */
+#if USE_TERM_DRIVER
+ NULL, /* term_driver */
#endif
#ifndef USE_SP_WINDOWLIST
@@ -188,7 +188,7 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
0, /* nested_tracef */
0, /* use_pthreads */
#if USE_PTHREADS_EINTR
- 0, /* read_thread */
+ (pthread_t) 0, /* read_thread */
#endif
#endif
#if USE_WIDEC_SUPPORT
@@ -230,7 +230,7 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
#define STACK_FRAME_0s { STACK_FRAME_0 }
#define NUM_VARS_0s { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
-#define RIPOFF_0 { 0,0,0 }
+#define RIPOFF_0 { NULL,0,NULL }
#define RIPOFF_0s { RIPOFF_0 }
NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
@@ -258,7 +258,7 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
},
NULL, /* saved_tty */
FALSE, /* use_tioctl */
- 0, /* _outch */
+ NULL, /* _outch */
#ifndef USE_SP_RIPOFF
RIPOFF_0s, /* ripoff */
NULL, /* rsp */
@@ -272,7 +272,7 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
0, /* COLS */
8, /* TABSIZE */
1000, /* ESCDELAY */
- 0, /* cur_term */
+ NULL, /* cur_term */
#endif
#ifdef TRACE
#if BROKEN_LINKER || USE_REENTRANT
@@ -291,9 +291,9 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
NCURSES_EXPORT(SCREEN *)
_nc_screen_of(WINDOW *win)
{
- SCREEN *sp = 0;
+ SCREEN *sp = NULL;
- if (win != 0) {
+ if (win != NULL) {
sp = WINDOW_EXT(win, screen);
}
return (sp);
diff --git a/ncurses/tinfo/lib_has_cap.c b/ncurses/tinfo/lib_has_cap.c
index cbf68b316508..9f436675f0fc 100644
--- a/ncurses/tinfo/lib_has_cap.c
+++ b/ncurses/tinfo/lib_has_cap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2009,2013 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_has_cap.c,v 1.11 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_has_cap.c,v 1.12 2024/11/23 19:17:15 tom Exp $")
NCURSES_EXPORT(bool)
NCURSES_SP_NAME(has_ic) (NCURSES_SP_DCL0)
@@ -62,7 +62,7 @@ NCURSES_SP_NAME(has_ic) (NCURSES_SP_DCL0)
&& (delete_character || parm_dch)) ? TRUE : FALSE;
}
- returnCode(code);
+ returnBool(code);
}
#if NCURSES_SP_FUNCS
@@ -83,7 +83,7 @@ NCURSES_SP_NAME(has_il) (NCURSES_SP_DCL0)
&& (delete_line || parm_delete_line)) ? TRUE : FALSE;
}
- returnCode(code);
+ returnBool(code);
}
#if NCURSES_SP_FUNCS
diff --git a/ncurses/tinfo/lib_kernel.c b/ncurses/tinfo/lib_kernel.c
index 46f652b0a30a..0bd9630a922a 100644
--- a/ncurses/tinfo/lib_kernel.c
+++ b/ncurses/tinfo/lib_kernel.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2022,2023 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -49,7 +49,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_kernel.c,v 1.36 2023/06/10 13:29:06 tom Exp $")
+MODULE_ID("$Id: lib_kernel.c,v 1.40 2025/12/23 09:09:50 tom Exp $")
#ifdef TERMIOS
static int
@@ -89,12 +89,12 @@ NCURSES_SP_NAME(erasechar) (NCURSES_SP_DCL0)
T((T_CALLED("erasechar(%p)"), (void *) SP_PARM));
- if (termp != 0) {
+ if (termp != NULL) {
#ifdef TERMIOS
result = termp->Ottyb.c_cc[VERASE];
if (result == _nc_vdisable())
result = ERR;
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
result = ERR;
#else
result = termp->Ottyb.sg_erase;
@@ -126,12 +126,12 @@ NCURSES_SP_NAME(killchar) (NCURSES_SP_DCL0)
T((T_CALLED("killchar(%p)"), (void *) SP_PARM));
- if (termp != 0) {
+ if (termp != NULL) {
#ifdef TERMIOS
result = termp->Ottyb.c_cc[VKILL];
if (result == _nc_vdisable())
result = ERR;
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
result = ERR;
#else
result = termp->Ottyb.sg_kill;
@@ -151,12 +151,12 @@ killchar(void)
static void
flush_input(int fd)
{
-#ifdef TERMIOS
+#if defined(TERMIOS)
tcflush(fd, TCIFLUSH);
#else /* !TERMIOS */
errno = 0;
do {
-#if defined(EXP_WIN32_DRIVER)
+#if defined(USE_WIN32CON_DRIVER)
_nc_console_flush(_nc_console_fd2handle(fd));
#else
ioctl(fd, TIOCFLUSH, 0);
@@ -177,7 +177,7 @@ NCURSES_SP_NAME(flushinp) (NCURSES_SP_DCL0)
{
T((T_CALLED("flushinp(%p)"), (void *) SP_PARM));
- if (SP_PARM != 0) {
+ if (SP_PARM != NULL) {
if (NC_ISATTY(SP_PARM->_ifd))
flush_input(SP_PARM->_ifd);
else if (NC_ISATTY(SP_PARM->_ofd))
diff --git a/ncurses/tinfo/lib_napms.c b/ncurses/tinfo/lib_napms.c
index 1b89a54c799b..6fd7f7b8ac8e 100644
--- a/ncurses/tinfo/lib_napms.c
+++ b/ncurses/tinfo/lib_napms.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 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 *
@@ -52,7 +52,7 @@
#endif
#endif
-MODULE_ID("$Id: lib_napms.c,v 1.28 2023/09/16 16:09:33 tom Exp $")
+MODULE_ID("$Id: lib_napms.c,v 1.33 2025/12/27 12:33:34 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms)
@@ -62,7 +62,7 @@ NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms)
if (ms > MAX_DELAY_MSECS)
ms = MAX_DELAY_MSECS;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
CallDriver_1(SP_PARM, td_nap, ms);
#else /* !USE_TERM_DRIVER */
#if NCURSES_SP_FUNCS
@@ -78,10 +78,10 @@ NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms)
request = remaining;
}
}
-#elif defined(_NC_WINDOWS)
+#elif defined(USE_WIN32CON_DRIVER)
Sleep((DWORD) ms);
#else
- _nc_timed_wait(0, 0, ms, (int *) 0 EVENTLIST_2nd(0));
+ _nc_timed_wait(NULL, 0, ms, (int *) 0 EVENTLIST_2nd(NULL));
#endif
#endif /* !USE_TERM_DRIVER */
diff --git a/ncurses/tinfo/lib_options.c b/ncurses/tinfo/lib_options.c
index 6a8bb39489ce..064988d60ab4 100644
--- a/ncurses/tinfo/lib_options.c
+++ b/ncurses/tinfo/lib_options.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2021,2023 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 *
@@ -47,7 +47,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_options.c,v 1.83 2023/04/29 18:56:12 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.86 2025/12/27 12:41:23 tom Exp $")
NCURSES_EXPORT(int)
idlok(WINDOW *win, bool flag)
@@ -57,8 +57,8 @@ idlok(WINDOW *win, bool flag)
if (win) {
SCREEN *sp = _nc_screen_of(win);
- if (sp != 0
-#ifdef USE_TERM_DRIVER
+ if (sp != NULL
+#if USE_TERM_DRIVER
&& IsTermInfo(sp)
#endif
) {
@@ -158,16 +158,16 @@ NCURSES_EXPORT(int)
meta(WINDOW *win GCC_UNUSED, bool flag)
{
int result = ERR;
- SCREEN *sp = (win == 0) ? CURRENT_SCREEN : _nc_screen_of(win);
+ SCREEN *sp = (win == NULL) ? CURRENT_SCREEN : _nc_screen_of(win);
/* Ok, we stay relaxed and don't signal an error if win is NULL */
T((T_CALLED("meta(%p,%d)"), (void *) win, flag));
/* Ok, we stay relaxed and don't signal an error if win is NULL */
- if (sp != 0) {
+ if (sp != NULL) {
sp->_use_meta = flag;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
if (IsTermInfo(sp)) {
if (flag) {
NCURSES_PUTP2("meta_on", meta_on);
@@ -195,12 +195,12 @@ NCURSES_SP_NAME(curs_set) (NCURSES_SP_DCLx int vis)
int code = ERR;
T((T_CALLED("curs_set(%p,%d)"), (void *) SP_PARM, vis));
- if (SP_PARM != 0 && vis >= 0 && vis <= 2) {
+ if (SP_PARM != NULL && vis >= 0 && vis <= 2) {
int cursor = SP_PARM->_cursor;
if (vis == cursor) {
code = cursor;
} else {
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
code = CallDriver_1(SP_PARM, td_cursorSet, vis);
#else
if (IsValidTIScreen(SP_PARM)) {
@@ -269,7 +269,7 @@ typeahead(int fd)
static int
has_key_internal(int keycode, TRIES * tp)
{
- if (tp == 0)
+ if (tp == NULL)
return (FALSE);
else if (tp->value == keycode)
return (TRUE);
@@ -278,7 +278,7 @@ has_key_internal(int keycode, TRIES * tp)
|| has_key_internal(keycode, tp->sibling));
}
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
NCURSES_EXPORT(int)
TINFO_HAS_KEY(SCREEN *sp, int keycode)
{
@@ -290,7 +290,7 @@ NCURSES_EXPORT(int)
NCURSES_SP_NAME(has_key) (NCURSES_SP_DCLx int keycode)
{
T((T_CALLED("has_key(%p,%d)"), (void *) SP_PARM, keycode));
- returnCode(SP != 0 ? has_key_internal(keycode, SP_PARM->_keytry) : FALSE);
+ returnCode(SP != NULL ? has_key_internal(keycode, SP_PARM->_keytry) : FALSE);
}
#if NCURSES_SP_FUNCS
@@ -330,11 +330,11 @@ _nc_putp_flush(const char *name, const char *value)
* the terminal state _before_ switching modes.
*/
NCURSES_EXPORT(int)
-_nc_keypad(SCREEN *sp, int flag)
+_nc_keypad(SCREEN *sp, bool flag)
{
int rc = ERR;
- if (sp != 0) {
+ if (sp != NULL) {
#ifdef USE_PTHREADS
/*
* We might have this situation in a multithreaded application that
@@ -354,7 +354,7 @@ _nc_keypad(SCREEN *sp, int flag)
} else
#endif
{
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
rc = CallDriver_1(sp, td_kpad, flag);
if (rc == OK)
sp->_keypad_on = flag;
diff --git a/ncurses/tinfo/lib_print.c b/ncurses/tinfo/lib_print.c
index e7d8535ef603..d55311330dfb 100644
--- a/ncurses/tinfo/lib_print.c
+++ b/ncurses/tinfo/lib_print.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2021,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,14 +40,15 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_print.c,v 1.31 2023/06/10 12:44:41 tom Exp $")
+MODULE_ID("$Id: lib_print.c,v 1.35 2025/12/27 12:41:23 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)
/* ship binary character data to the printer via mc4/mc5/mc5p */
{
int result;
- char *mybuf = NULL, *switchon;
+ char *mybuf = NULL;
+ const char *switchon;
size_t onsize, offsize;
size_t need;
@@ -71,8 +72,8 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)
need = onsize + (size_t) len + offsize;
- if (switchon == 0
- || (mybuf = typeMalloc(char, need + 1)) == 0) {
+ if (switchon == NULL
+ || (mybuf = typeMalloc(char, need + 1)) == NULL) {
free(mybuf);
errno = ENOMEM;
return (ERR);
@@ -97,14 +98,14 @@ NCURSES_SP_NAME(mcprint) (NCURSES_SP_DCLx char *data, int len)
* kernel will ship the contiguous clist items from the last write
* immediately.
*/
-#ifndef _NC_WINDOWS
+#ifndef _NC_WINDOWS_NATIVE
(void) sleep(0);
#endif
free(mybuf);
return (result);
}
-#if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER)
+#if NCURSES_SP_FUNCS && !USE_TERM_DRIVER
NCURSES_EXPORT(int)
mcprint(char *data, int len)
{
diff --git a/ncurses/tinfo/lib_raw.c b/ncurses/tinfo/lib_raw.c
index fda6deada2a7..81e89ae1044b 100644
--- a/ncurses/tinfo/lib_raw.c
+++ b/ncurses/tinfo/lib_raw.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2023,2024 Thomas E. Dickey *
+ * Copyright 2020-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 *
@@ -50,14 +50,13 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_raw.c,v 1.30 2024/03/30 15:54:17 tom Exp $")
+MODULE_ID("$Id: lib_raw.c,v 1.35 2025/12/23 09:22:35 tom Exp $")
#if HAVE_SYS_TERMIO_H
#include <sys/termio.h> /* needed for ISC */
#endif
#ifdef __EMX__
-#include <io.h>
#define _nc_setmode(mode) setmode(SP_PARM->_ifd, mode)
#else
#define _nc_setmode(mode) /* nothing */
@@ -85,7 +84,7 @@ NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0)
TERMINAL *termp;
T((T_CALLED("raw(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ if ((termp = TerminalOf(SP_PARM)) != NULL) {
TTY buf;
BEFORE("raw");
@@ -97,7 +96,7 @@ NCURSES_SP_NAME(raw) (NCURSES_SP_DCL0)
buf.c_iflag &= (unsigned) ~(COOKED_INPUT);
buf.c_cc[VMIN] = 1;
buf.c_cc[VTIME] = 0;
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
buf.dwFlagIn &= (unsigned long) ~CONMODE_NORAW;
#else
buf.sg_flags |= RAW;
@@ -141,7 +140,7 @@ NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0)
TERMINAL *termp;
T((T_CALLED("cbreak(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ if ((termp = TerminalOf(SP_PARM)) != NULL) {
TTY buf;
BEFORE("cbreak");
@@ -153,7 +152,7 @@ NCURSES_SP_NAME(cbreak) (NCURSES_SP_DCL0)
buf.c_iflag &= (unsigned) ~ICRNL;
buf.c_cc[VMIN] = 1;
buf.c_cc[VTIME] = 0;
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
buf.dwFlagIn |= CONMODE_NORAW;
buf.dwFlagIn &= (unsigned long) ~CONMODE_NOCBREAK;
#else
@@ -179,17 +178,13 @@ cbreak(void)
}
#endif
-/*
- * Note:
- * this implementation may be wrong. See the comment under intrflush().
- */
NCURSES_EXPORT(void)
NCURSES_SP_NAME(qiflush) (NCURSES_SP_DCL0)
{
TERMINAL *termp;
T((T_CALLED("qiflush(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ if ((termp = TerminalOf(SP_PARM)) != NULL) {
TTY buf;
int result;
@@ -224,7 +219,7 @@ NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0)
TERMINAL *termp;
T((T_CALLED("noraw(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ if ((termp = TerminalOf(SP_PARM)) != NULL) {
TTY buf;
BEFORE("noraw");
@@ -235,7 +230,7 @@ NCURSES_SP_NAME(noraw) (NCURSES_SP_DCL0)
buf.c_lflag |= ISIG | ICANON |
(termp->Ottyb.c_lflag & IEXTEN);
buf.c_iflag |= COOKED_INPUT;
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
buf.dwFlagIn |= CONMODE_NORAW;
#else
buf.sg_flags &= ~(RAW | CBREAK);
@@ -279,7 +274,7 @@ NCURSES_SP_NAME(nocbreak) (NCURSES_SP_DCL0)
TERMINAL *termp;
T((T_CALLED("nocbreak(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ if ((termp = TerminalOf(SP_PARM)) != NULL) {
TTY buf;
BEFORE("nocbreak");
@@ -289,7 +284,7 @@ NCURSES_SP_NAME(nocbreak) (NCURSES_SP_DCL0)
#ifdef TERMIOS
buf.c_lflag |= ICANON;
buf.c_iflag |= ICRNL;
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
buf.dwFlagIn |= (CONMODE_NOCBREAK | CONMODE_NORAW);
#else
buf.sg_flags &= ~CBREAK;
@@ -320,7 +315,7 @@ NCURSES_SP_NAME(noqiflush) (NCURSES_SP_DCL0)
TERMINAL *termp;
T((T_CALLED("noqiflush(%p)"), (void *) SP_PARM));
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ if ((termp = TerminalOf(SP_PARM)) != NULL) {
TTY buf;
int result;
@@ -349,11 +344,7 @@ noqiflush(void)
#endif
/*
- * This call does the same thing as the qiflush()/noqiflush() pair. We know
- * for certain that SVr3 intrflush() tweaks the NOFLSH bit; on the other hand,
- * the match (in the SVr4 man pages) between the language describing NOFLSH in
- * termio(7) and the language describing qiflush()/noqiflush() in
- * curs_inopts(3x) is too exact to be coincidence.
+ * This call does the same thing as the qiflush()/noqiflush() pair.
*/
NCURSES_EXPORT(int)
NCURSES_SP_NAME(intrflush) (NCURSES_SP_DCLx WINDOW *win GCC_UNUSED, bool flag)
@@ -362,10 +353,10 @@ NCURSES_SP_NAME(intrflush) (NCURSES_SP_DCLx WINDOW *win GCC_UNUSED, bool flag)
TERMINAL *termp;
T((T_CALLED("intrflush(%p,%d)"), (void *) SP_PARM, flag));
- if (SP_PARM == 0)
+ if (SP_PARM == NULL)
returnCode(ERR);
- if ((termp = TerminalOf(SP_PARM)) != 0) {
+ if ((termp = TerminalOf(SP_PARM)) != NULL) {
TTY buf;
BEFORE("intrflush");
diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c
index 99097f00fc1d..14a6dda0d279 100644
--- a/ncurses/tinfo/lib_setup.c
+++ b/ncurses/tinfo/lib_setup.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 *
@@ -49,7 +49,7 @@
#include <locale.h>
#endif
-MODULE_ID("$Id: lib_setup.c,v 1.240 2024/04/20 17:04:05 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.252 2025/12/27 12:33:34 tom Exp $")
/****************************************************************************
*
@@ -115,12 +115,12 @@ NCURSES_PUBLIC_VAR(ttytype) (void)
#if NCURSES_SP_FUNCS
if (CURRENT_SCREEN) {
TERMINAL *termp = TerminalOf(CURRENT_SCREEN);
- if (termp != 0) {
+ if (termp != NULL) {
result = TerminalType(termp).term_names;
}
}
#else
- if (cur_term != 0) {
+ if (cur_term != NULL) {
result = TerminalType(cur_term).term_names;
}
#endif
@@ -272,7 +272,7 @@ use_tioctl(bool f)
}
#endif
-#if !(defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER))
+#if !(USE_TERM_DRIVER || USE_NAMED_PIPES)
static void
_nc_default_screensize(TERMINAL *termp, int *linep, int *colp)
{
@@ -320,7 +320,7 @@ is_expected(const char *value, const char *expected)
}
static bool
-get_position(TERMINAL *termp, int fd, int *row, int *col)
+get_position(const TERMINAL *termp, int fd, int *row, int *col)
{
bool result = FALSE;
size_t need = strlen(user7);
@@ -334,7 +334,6 @@ get_position(TERMINAL *termp, int fd, int *row, int *col)
char *s;
char cc;
const char *skipped;
- int scanned;
s = memset(buf, '\0', sizeof(buf));
do {
@@ -350,7 +349,7 @@ get_position(TERMINAL *termp, int fd, int *row, int *col)
cc = '\0';
if (skipped != buf
&& *skipped != '\0'
- && (scanned = sscanf(skip_csi(buf), "%d;%d%c", &y, &x, &cc)) == 3
+ && sscanf(skip_csi(buf), "%d;%d%c", &y, &x, &cc) == 3
&& (cc == 'R')) {
*row = y;
*col = x;
@@ -362,10 +361,10 @@ get_position(TERMINAL *termp, int fd, int *row, int *col)
}
static bool
-set_position(NCURSES_SP_DCLx TERMINAL *termp, int row, int col)
+set_position(NCURSES_SP_DCLx const TERMINAL *termp, int row, int col)
{
bool result;
- char *actual = TIPARM_2(cursor_address, row, col);
+ const char *actual = TIPARM_2(cursor_address, row, col);
T((T_CALLED("set_position %d,%d)"), row, col));
#if NCURSES_SP_FUNCS
result = (NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "set_position",
@@ -455,28 +454,28 @@ _nc_check_screensize(SCREEN *sp, TERMINAL *termp, int *linep, int *colp)
#else /* !USE_CHECK_SIZE */
#define _nc_check_screensize(sp, termp, linep, colp) /* nothing */
#endif
-#endif /* !(defined(USE_TERM_DRIVER) || defined(EXP_WIN32_DRIVER)) */
+#endif /* !(USE_TERM_DRIVER || USE_NAMED_PIPES) */
NCURSES_EXPORT(void)
_nc_get_screensize(SCREEN *sp,
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
TERMINAL *termp,
#endif
int *linep, int *colp)
/* Obtain lines/columns values from the environment and/or terminfo entry */
{
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *TCB;
int my_tabsize;
- assert(termp != 0 && linep != 0 && colp != 0);
+ assert(termp != NULL && linep != NULL && colp != NULL);
TCB = (TERMINAL_CONTROL_BLOCK *) termp;
my_tabsize = TCB->info.tabsize;
TCB->drv->td_size(TCB, linep, colp);
#if USE_REENTRANT
- if (sp != 0) {
+ if (sp != NULL) {
sp->_TABSIZE = my_tabsize;
}
#else
@@ -491,7 +490,7 @@ _nc_get_screensize(SCREEN *sp,
bool useTioctl = _nc_prescreen.use_tioctl;
T((T_CALLED("_nc_get_screensize (%p)"), (void *) sp));
-#ifdef EXP_WIN32_DRIVER
+#if USE_NAMED_PIPES
/* If we are here, then Windows console is used in terminfo mode.
We need to figure out the size using the console API
*/
@@ -534,7 +533,7 @@ _nc_get_screensize(SCREEN *sp,
errno = 0;
do {
if (ioctl(cur_term->Filedes, IOCTL_WINSIZE, &size) >= 0) {
- *linep = ((sp != 0 && sp->_filtered)
+ *linep = ((sp != NULL && sp->_filtered)
? 1
: WINSIZE_ROWS(size));
*colp = WINSIZE_COLS(size);
@@ -554,7 +553,8 @@ _nc_get_screensize(SCREEN *sp,
/*
* If environment variables are used, update them.
*/
- if ((sp == 0 || !sp->_filtered) && _nc_getenv_num("LINES") > 0) {
+ if ((sp == NULL || !sp->_filtered) &&
+ _nc_getenv_num("LINES") > 0) {
_nc_setenv_num("LINES", *linep);
}
if (_nc_getenv_num("COLUMNS") > 0) {
@@ -569,11 +569,11 @@ _nc_get_screensize(SCREEN *sp,
* variable.
*/
if ((value = _nc_getenv_num("LINES")) > 0) {
- *linep = value;
+ *linep = Min(value, MAX_ENV_LINES);
T(("screen size: environment LINES = %d", *linep));
}
if ((value = _nc_getenv_num("COLUMNS")) > 0) {
- *colp = value;
+ *colp = Min(value, MAX_ENV_COLUMNS);
T(("screen size: environment COLUMNS = %d", *colp));
}
@@ -606,7 +606,7 @@ _nc_get_screensize(SCREEN *sp,
my_tabsize = 8;
#if USE_REENTRANT
- if (sp != 0)
+ if (sp != NULL)
sp->_TABSIZE = my_tabsize;
#else
TABSIZE = my_tabsize;
@@ -623,11 +623,11 @@ _nc_update_screensize(SCREEN *sp)
int new_lines;
int new_cols;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
int old_lines;
int old_cols;
- assert(sp != 0);
+ assert(sp != NULL);
CallDriver_2(sp, td_getsize, &old_lines, &old_cols);
@@ -637,17 +637,17 @@ _nc_update_screensize(SCREEN *sp)
int old_cols = columns;
#endif
- if (sp != 0) {
+ if (sp != NULL) {
TINFO_GET_SIZE(sp, sp->_term, &new_lines, &new_cols);
/*
* See is_term_resized() and resizeterm().
* We're doing it this way because those functions belong to the upper
* ncurses library, while this resides in the lower terminfo library.
*/
- if (sp->_resize != 0) {
+ if (sp->_resize != NULL) {
if ((new_lines != old_lines) || (new_cols != old_cols)) {
sp->_resize(NCURSES_SP_ARGx new_lines, new_cols);
- } else if (sp->_sig_winch && (sp->_ungetch != 0)) {
+ } else if (sp->_sig_winch && (sp->_ungetch != NULL)) {
sp->_ungetch(SP_PARM, KEY_RESIZE); /* so application can know this */
}
sp->_sig_winch = FALSE;
@@ -709,7 +709,7 @@ _nc_tinfo_cmdch(TERMINAL *termp, int proto)
* since it is fairly common for developers to set the C compiler
* name as an environment variable - using the same symbol.
*/
- if ((tmp = getenv("CC")) != 0 && strlen(tmp) == 1) {
+ if ((tmp = getenv("CC")) != NULL && strlen(tmp) == 1) {
unsigned i;
char CC = *tmp;
@@ -737,7 +737,7 @@ _nc_get_locale(void)
* This is preferable to using getenv() since it ensures that we are using
* the locale which was actually initialized by the application.
*/
- env = setlocale(LC_CTYPE, 0);
+ env = setlocale(LC_CTYPE, NULL);
#else
if (((env = getenv("LANG")) != 0 && *env != '\0')
|| ((env = getenv("LC_CTYPE")) != 0 && *env != '\0')
@@ -752,24 +752,24 @@ _nc_get_locale(void)
/*
* Check if we are running in a UTF-8 locale.
*/
-NCURSES_EXPORT(int)
+NCURSES_EXPORT(bool)
_nc_unicode_locale(void)
{
static bool initialized = FALSE;
- static int result = 0;
+ static bool result = FALSE;
if (!initialized) {
-#if defined(_NC_WINDOWS) && USE_WIDEC_SUPPORT
- result = 1;
+#if defined(_NC_WINDOWS_NATIVE) && USE_WIDEC_SUPPORT
+ result = TRUE;
#elif HAVE_LANGINFO_CODESET
char *env = nl_langinfo(CODESET);
- result = !strcmp(env, "UTF-8");
+ result = !strcmp(env, "UTF-8") ? TRUE : FALSE;
T(("_nc_unicode_locale(%s) ->%d", env, result));
#else
char *env = _nc_get_locale();
- if (env != 0) {
- if (strstr(env, ".UTF-8") != 0) {
- result = 1;
+ if (env != NULL) {
+ if (strstr(env, ".UTF-8") != NULL) {
+ result = TRUE;
T(("_nc_unicode_locale(%s) ->%d", env, result));
}
}
@@ -779,8 +779,8 @@ _nc_unicode_locale(void)
return result;
}
-#define CONTROL_N(s) ((s) != 0 && strstr(s, "\016") != 0)
-#define CONTROL_O(s) ((s) != 0 && strstr(s, "\017") != 0)
+#define CONTROL_N(s) ((s) != NULL && strstr(s, "\016") != NULL)
+#define CONTROL_O(s) ((s) != NULL && strstr(s, "\017") != NULL)
/*
* Check for known broken cases where a UTF-8 locale breaks the alternate
@@ -795,17 +795,17 @@ _nc_locale_breaks_acs(TERMINAL *termp)
int result = 0;
T((T_CALLED("_nc_locale_breaks_acs:%d"), result));
- if (getenv(env_name) != 0) {
+ if (getenv(env_name) != NULL) {
result = _nc_getenv_num(env_name);
- } else if ((value = tigetnum("U8")) >= 0) {
+ } else if ((value = tigetnum(UserCap(U8))) >= 0) {
result = value; /* use extension feature */
- } else if ((env = getenv("TERM")) != 0) {
+ } else if ((env = getenv("TERM")) != NULL) {
if (strstr(env, "linux")) {
result = 1; /* always broken */
- } else if (strstr(env, "screen") != 0
- && ((env = getenv("TERMCAP")) != 0
- && strstr(env, "screen") != 0)
- && strstr(env, "hhII00") != 0) {
+ } else if (strstr(env, "screen") != NULL
+ && ((env = getenv("TERMCAP")) != NULL
+ && strstr(env, "screen") != NULL)
+ && strstr(env, "hhII00") != NULL) {
if (CONTROL_N(enter_alt_charset_mode) ||
CONTROL_O(enter_alt_charset_mode) ||
CONTROL_N(set_attributes) ||
@@ -824,21 +824,21 @@ TINFO_SETUP_TERM(TERMINAL **tp,
int *errret,
int reuse)
{
-#ifdef USE_TERM_DRIVER
- TERMINAL_CONTROL_BLOCK *TCB = 0;
+#if USE_TERM_DRIVER
+ TERMINAL_CONTROL_BLOCK *TCB = NULL;
#endif
TERMINAL *termp;
- SCREEN *sp = 0;
+ SCREEN *sp = NULL;
char *myname;
int code = ERR;
START_TRACE();
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
T((T_CALLED("_nc_setupterm_ex(%p,%s,%d,%p)"),
(void *) tp, _nc_visbuf(tname), Filedes, (void *) errret));
- if (tp == 0) {
+ if (tp == NULL) {
ret_error0(TGETENT_ERR,
"Invalid parameter, internal error.\n");
} else
@@ -848,14 +848,14 @@ TINFO_SETUP_TERM(TERMINAL **tp,
T((T_CALLED("setupterm(%s,%d,%p)"), _nc_visbuf(tname), Filedes, (void *) errret));
#endif
- if (tname == 0) {
+ if (tname == NULL) {
tname = getenv("TERM");
-#if defined(EXP_WIN32_DRIVER)
+#if USE_NAMED_PIPES
if (!VALID_TERM_ENV(tname, NO_TERMINAL)) {
T(("Failure with TERM=%s", NonNull(tname)));
ret_error0(TGETENT_ERR, "TERM environment variable not set.\n");
}
-#elif defined(USE_TERM_DRIVER)
+#elif USE_TERM_DRIVER
if (!NonEmpty(tname))
tname = "unknown";
#else
@@ -881,7 +881,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
*/
if (Filedes == STDOUT_FILENO && !NC_ISATTY(Filedes))
Filedes = STDERR_FILENO;
-#if defined(EXP_WIN32_DRIVER)
+#if USE_NAMED_PIPES
if (Filedes != STDERR_FILENO && NC_ISATTY(Filedes))
_setmode(Filedes, _O_BINARY);
#endif
@@ -903,28 +903,28 @@ TINFO_SETUP_TERM(TERMINAL **tp,
* properly with this feature).
*/
if (reuse
- && (termp != 0)
+ && (termp != NULL)
&& termp->Filedes == Filedes
- && termp->_termname != 0
+ && termp->_termname != NULL
&& !strcmp(termp->_termname, myname)
&& _nc_name_match(TerminalType(termp).term_names, myname, "|")) {
T(("reusing existing terminal information and mode-settings"));
code = OK;
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
TCB = (TERMINAL_CONTROL_BLOCK *) termp;
#endif
} else {
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
TERMINAL_CONTROL_BLOCK *my_tcb;
- termp = 0;
- if ((my_tcb = typeCalloc(TERMINAL_CONTROL_BLOCK, 1)) != 0)
+ termp = NULL;
+ if ((my_tcb = typeCalloc(TERMINAL_CONTROL_BLOCK, 1)) != NULL)
termp = &(my_tcb->term);
#else
int status;
termp = typeCalloc(TERMINAL, 1);
#endif
- if (termp == 0) {
+ if (termp == NULL) {
ret_error1(TGETENT_ERR,
"Not enough memory to create terminal structure.\n",
myname, free(myname));
@@ -948,7 +948,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
#endif /* HAVE_SYSCONF */
T(("using %d for getstr limit", _nc_globals.getstr_limit));
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
INIT_TERM_DRIVER();
/*
* _nc_get_driver() will call td_CanHandle() for each driver, and win_driver
@@ -1027,7 +1027,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
#endif
}
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
*tp = termp;
NCURSES_SP_NAME(set_curterm) (sp, termp);
TCB->drv->td_init(TCB);
@@ -1043,7 +1043,7 @@ TINFO_SETUP_TERM(TERMINAL **tp,
if (errret)
*errret = TGETENT_YES;
-#ifndef USE_TERM_DRIVER
+#if !USE_TERM_DRIVER
if (generic_type) {
/*
* BSD 4.3's termcap contains mis-typed "gn" for wy99. Do a sanity
@@ -1076,10 +1076,10 @@ TINFO_SETUP_TERM(TERMINAL **tp,
NCURSES_EXPORT(SCREEN *)
_nc_find_prescr(void)
{
- SCREEN *result = 0;
+ SCREEN *result = NULL;
PRESCREEN_LIST *p;
pthread_t id = GetThreadID();
- for (p = _nc_prescreen.allocated; p != 0; p = p->next) {
+ for (p = _nc_prescreen.allocated; p != NULL; p = p->next) {
if (p->id == id) {
result = p->sp;
break;
@@ -1099,7 +1099,7 @@ _nc_forget_prescr(void)
PRESCREEN_LIST *p, *q;
pthread_t id = GetThreadID();
_nc_lock_global(screen);
- for (p = _nc_prescreen.allocated, q = 0; p != 0; q = p, p = p->next) {
+ for (p = _nc_prescreen.allocated, q = NULL; p != NULL; q = p, p = p->next) {
if (p->id == id) {
if (q) {
q->next = p->next;
@@ -1130,13 +1130,13 @@ new_prescr(void)
T((T_CALLED("new_prescr()")));
_nc_lock_global(screen);
- if ((sp = _nc_find_prescr()) == 0) {
+ if ((sp = _nc_find_prescr()) == NULL) {
sp = _nc_alloc_screen_sp();
T(("_nc_alloc_screen_sp %p", (void *) sp));
- if (sp != 0) {
+ if (sp != NULL) {
#ifdef USE_PTHREADS
PRESCREEN_LIST *p = typeCalloc(PRESCREEN_LIST, 1);
- if (p != 0) {
+ if (p != NULL) {
p->id = GetThreadID();
p->sp = sp;
p->next = _nc_prescreen.allocated;
@@ -1152,7 +1152,7 @@ new_prescr(void)
sp->_no_padding = _nc_prescreen._no_padding;
#endif
sp->slk_format = 0;
- sp->_slk = 0;
+ sp->_slk = NULL;
sp->_prescreen = TRUE;
SP_PRE_INIT(sp);
#if USE_REENTRANT
@@ -1168,7 +1168,7 @@ new_prescr(void)
}
#endif
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
/*
* This entrypoint is called from tgetent() to allow a special case of reusing
* the same TERMINAL data (see comment).
@@ -1180,14 +1180,14 @@ _nc_setupterm(const char *tname,
int reuse)
{
int rc = ERR;
- TERMINAL *termp = 0;
+ TERMINAL *termp = NULL;
_nc_init_pthreads();
_nc_lock_global(prescreen);
START_TRACE();
if (TINFO_SETUP_TERM(&termp, tname, Filedes, errret, reuse) == OK) {
_nc_forget_prescr();
- if (NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN_PRE, termp) != 0) {
+ if (NCURSES_SP_NAME(set_curterm) (CURRENT_SCREEN_PRE, termp) != NULL) {
rc = OK;
}
}
diff --git a/ncurses/tinfo/lib_termcap.c b/ncurses/tinfo/lib_termcap.c
index 2ece985914e9..331c92999a72 100644
--- a/ncurses/tinfo/lib_termcap.c
+++ b/ncurses/tinfo/lib_termcap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,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,10 +49,10 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_termcap.c,v 1.89 2023/05/27 20:13:10 tom Exp $")
+MODULE_ID("$Id: lib_termcap.c,v 1.96 2025/12/27 12:33:34 tom Exp $")
-NCURSES_EXPORT_VAR(char *) UP = 0;
-NCURSES_EXPORT_VAR(char *) BC = 0;
+NCURSES_EXPORT_VAR(char *) UP = NULL;
+NCURSES_EXPORT_VAR(char *) BC = NULL;
#define MyCache _nc_globals.tgetent_cache
#define CacheInx _nc_globals.tgetent_index
@@ -94,8 +94,8 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
int rc = ERR;
int n;
bool found_cache = FALSE;
-#ifdef USE_TERM_DRIVER
- TERMINAL *termp = 0;
+#if USE_TERM_DRIVER
+ TERMINAL *termp = NULL;
#endif
START_TRACE();
@@ -103,8 +103,8 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
TINFO_SETUP_TERM(&termp, name, STDOUT_FILENO, &rc, TRUE);
-#ifdef USE_TERM_DRIVER
- if (termp == 0 ||
+#if USE_TERM_DRIVER
+ if (termp == NULL ||
!((TERMINAL_CONTROL_BLOCK *) termp)->drv->isTerminfo)
returnCode(rc);
#endif
@@ -125,18 +125,18 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
bool same_result = (MyCache[n].last_used && MyCache[n].last_bufp == bufp);
if (same_result) {
CacheInx = n;
- if (FIX_SGR0 != 0) {
+ if (FIX_SGR0 != NULL) {
FreeAndNull(FIX_SGR0);
}
/*
* Also free the terminfo data that we loaded (much bigger leak).
*/
- if (LAST_TRM != 0 && LAST_TRM != TerminalOf(SP_PARM)) {
- TERMINAL *trm = LAST_TRM;
+ if (LAST_TRM != NULL && LAST_TRM != TerminalOf(SP_PARM)) {
+ const TERMINAL *trm = LAST_TRM;
NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx LAST_TRM);
for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx)
if (LAST_TRM == trm)
- LAST_TRM = 0;
+ LAST_TRM = NULL;
CacheInx = n;
}
found_cache = TRUE;
@@ -157,13 +157,13 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
LAST_TRM = TerminalOf(SP_PARM);
LAST_SEQ = ++CacheSeq;
} else {
- LAST_TRM = 0;
+ LAST_TRM = NULL;
}
PC = 0;
- UP = 0;
- BC = 0;
- FIX_SGR0 = 0; /* don't free it - application may still use */
+ UP = NULL;
+ BC = NULL;
+ FIX_SGR0 = NULL; /* don't free it - application may still use */
if (rc == 1) {
@@ -180,19 +180,19 @@ NCURSES_SP_NAME(tgetent) (NCURSES_SP_DCLx char *bufp, const char *name)
BC = backspace_if_not_bs;
if ((FIX_SGR0 = _nc_trim_sgr0(&TerminalType(TerminalOf(SP_PARM))))
- != 0) {
+ != NULL) {
if (!strcmp(FIX_SGR0, exit_attribute_mode)) {
if (FIX_SGR0 != exit_attribute_mode) {
free(FIX_SGR0);
}
- FIX_SGR0 = 0;
+ FIX_SGR0 = NULL;
}
}
LAST_BUF = bufp;
LAST_USE = TRUE;
SetNoPadding(SP_PARM);
- (void) NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); /* sets ospeed as a side-effect */
+ (void) NCURSES_SP_NAME(baudrate) (NCURSES_SP_ARG); /* sets ospeed as a side effect */
/* LINT_PREPRO
#if 0*/
@@ -246,7 +246,7 @@ NCURSES_SP_NAME(tgetflag) (NCURSES_SP_DCLx const char *id)
int j = -1;
entry_ptr = _nc_find_type_entry(id, BOOLEAN, TRUE);
- if (entry_ptr != 0) {
+ if (entry_ptr != NULL) {
j = entry_ptr->nte_index;
}
#if NCURSES_XNAMES
@@ -292,13 +292,15 @@ NCURSES_SP_NAME(tgetnum) (NCURSES_SP_DCLx const char *id)
int result = ABSENT_NUMERIC;
T((T_CALLED("tgetnum(%p, %s)"), (void *) SP_PARM, id));
+ assert(result < 0);
+
if (HasTInfoTerminal(SP_PARM) && ValidCap(id)) {
TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
struct name_table_entry const *entry_ptr;
int j = -1;
entry_ptr = _nc_find_type_entry(id, NUMBER, TRUE);
- if (entry_ptr != 0) {
+ if (entry_ptr != NULL) {
j = entry_ptr->nte_index;
}
#if NCURSES_XNAMES
@@ -350,7 +352,7 @@ NCURSES_SP_NAME(tgetstr) (NCURSES_SP_DCLx const char *id, char **area)
int j = -1;
entry_ptr = _nc_find_type_entry(id, STRING, TRUE);
- if (entry_ptr != 0) {
+ if (entry_ptr != NULL) {
j = entry_ptr->nte_index;
}
#if NCURSES_XNAMES
@@ -371,12 +373,12 @@ NCURSES_SP_NAME(tgetstr) (NCURSES_SP_DCLx const char *id, char **area)
/* setupterm forces canceled strings to null */
if (VALID_STRING(result)) {
if (result == exit_attribute_mode
- && FIX_SGR0 != 0) {
+ && FIX_SGR0 != NULL) {
result = FIX_SGR0;
TR(TRACE_DATABASE, ("altered to : %s", _nc_visbuf(result)));
}
- if (area != 0
- && *area != 0) {
+ if (area != NULL
+ && *area != NULL) {
_nc_STRCPY(*area, result, 1024);
result = *area;
*area += strlen(*area) + 1;
@@ -401,13 +403,13 @@ tgetstr(const char *id, char **area)
NCURSES_EXPORT(void)
_nc_tgetent_leak(const TERMINAL *const termp)
{
- if (termp != 0) {
+ if (termp != NULL) {
int num;
for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) {
if (LAST_TRM == termp) {
FreeAndNull(FIX_SGR0);
- if (LAST_TRM != 0) {
- LAST_TRM = 0;
+ if (LAST_TRM != NULL) {
+ LAST_TRM = NULL;
}
break;
}
@@ -420,7 +422,7 @@ _nc_tgetent_leaks(void)
{
int num;
for (CacheInx = 0; CacheInx < TGETENT_MAX; ++CacheInx) {
- if (LAST_TRM != 0) {
+ if (LAST_TRM != NULL) {
del_curterm(LAST_TRM);
_nc_tgetent_leak(LAST_TRM);
}
diff --git a/ncurses/tinfo/lib_termname.c b/ncurses/tinfo/lib_termname.c
index 2d80bb349967..a0dca62046c3 100644
--- a/ncurses/tinfo/lib_termname.c
+++ b/ncurses/tinfo/lib_termname.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2003,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -29,21 +29,21 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_termname.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_termname.c,v 1.15 2025/01/12 00:41:56 tom Exp $")
NCURSES_EXPORT(char *)
NCURSES_SP_NAME(termname) (NCURSES_SP_DCL0)
{
- char *name = 0;
+ char *name = NULL;
T((T_CALLED("termname(%p)"), (void *) SP_PARM));
#if NCURSES_SP_FUNCS
- if (TerminalOf(SP_PARM) != 0) {
+ if (TerminalOf(SP_PARM) != NULL) {
name = TerminalOf(SP_PARM)->_termname;
}
#else
- if (cur_term != 0)
+ if (cur_term != NULL)
name = cur_term->_termname;
#endif
diff --git a/ncurses/tinfo/lib_tgoto.c b/ncurses/tinfo/lib_tgoto.c
index 58b561fa7c78..2f7f63f569e1 100644
--- a/ncurses/tinfo/lib_tgoto.c
+++ b/ncurses/tinfo/lib_tgoto.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2023 Thomas E. Dickey *
+ * Copyright 2018-2023,2025 Thomas E. Dickey *
* Copyright 2000-2008,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,7 +36,7 @@
#include <ctype.h>
#include <termcap.h>
-MODULE_ID("$Id: lib_tgoto.c,v 1.23 2023/04/16 17:19:40 tom Exp $")
+MODULE_ID("$Id: lib_tgoto.c,v 1.24 2025/01/12 00:41:56 tom Exp $")
#if !PURE_TERMINFO
static bool
@@ -44,7 +44,7 @@ is_termcap(const char *string)
{
bool result = TRUE;
- if (string == 0 || *string == '\0') {
+ if (string == NULL || *string == '\0') {
result = FALSE; /* tparm() handles empty strings */
} else {
while ((*string != '\0') && result) {
@@ -89,13 +89,13 @@ tgoto_internal(const char *string, int x, int y)
while (*string != 0) {
if ((used + need) > length) {
length += (used + need);
- if ((result = typeRealloc(char, length, result)) == 0) {
+ if ((result = typeRealloc(char, length, result)) == NULL) {
length = 0;
break;
}
}
if (*string == '%') {
- const char *fmt = 0;
+ const char *fmt = NULL;
switch (*++string) {
case '\0':
@@ -122,7 +122,7 @@ tgoto_internal(const char *string, int x, int y)
* and \r, but I don't see that it could work -TD
*/
if (*value == 0) {
- if (BC != 0) {
+ if (BC != NULL) {
*value += 1;
need_BC = TRUE;
} else {
@@ -166,11 +166,11 @@ tgoto_internal(const char *string, int x, int y)
*value -= 2 * (*value % 16);
break;
}
- if (fmt != 0) {
+ if (fmt != NULL) {
_nc_SPRINTF(result + used, _nc_SLIMIT(length - used)
fmt, *value++);
used += strlen(result + used);
- fmt = 0;
+ fmt = NULL;
}
if (value - param > 2) {
value = param + 2;
@@ -181,7 +181,7 @@ tgoto_internal(const char *string, int x, int y)
}
string++;
}
- if (result != 0) {
+ if (result != NULL) {
if (need_BC) {
_nc_STRCPY(result + used, BC, length - used);
used += strlen(BC);
diff --git a/ncurses/tinfo/lib_ti.c b/ncurses/tinfo/lib_ti.c
index 5cb77b850dd7..cb73a51502be 100644
--- a/ncurses/tinfo/lib_ti.c
+++ b/ncurses/tinfo/lib_ti.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018,2020 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 *
@@ -37,7 +37,7 @@
#include <tic.h>
-MODULE_ID("$Id: lib_ti.c,v 1.34 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_ti.c,v 1.36 2025/11/23 18:58:04 tom Exp $")
#if 0
static bool
@@ -56,6 +56,7 @@ NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx const char *str)
int result = ABSENT_BOOLEAN;
T((T_CALLED("tigetflag(%p, %s)"), (void *) SP_PARM, str));
+ assert(result < 0);
if (HasTInfoTerminal(SP_PARM)) {
TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
@@ -63,7 +64,7 @@ NCURSES_SP_NAME(tigetflag) (NCURSES_SP_DCLx const char *str)
int j = -1;
entry_ptr = _nc_find_type_entry(str, BOOLEAN, FALSE);
- if (entry_ptr != 0) {
+ if (entry_ptr != NULL) {
j = entry_ptr->nte_index;
}
#if NCURSES_XNAMES
@@ -101,6 +102,7 @@ NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx const char *str)
int result = CANCELLED_NUMERIC; /* Solaris returns a -1 on error */
T((T_CALLED("tigetnum(%p, %s)"), (void *) SP_PARM, str));
+ assert(result < 0);
if (HasTInfoTerminal(SP_PARM)) {
TERMTYPE2 *tp = &TerminalType(TerminalOf(SP_PARM));
@@ -108,7 +110,7 @@ NCURSES_SP_NAME(tigetnum) (NCURSES_SP_DCLx const char *str)
int j = -1;
entry_ptr = _nc_find_type_entry(str, NUMBER, FALSE);
- if (entry_ptr != 0) {
+ if (entry_ptr != NULL) {
j = entry_ptr->nte_index;
}
#if NCURSES_XNAMES
@@ -155,7 +157,7 @@ NCURSES_SP_NAME(tigetstr) (NCURSES_SP_DCLx const char *str)
int j = -1;
entry_ptr = _nc_find_type_entry(str, STRING, FALSE);
- if (entry_ptr != 0) {
+ if (entry_ptr != NULL) {
j = entry_ptr->nte_index;
}
#if NCURSES_XNAMES
diff --git a/ncurses/tinfo/lib_tparm.c b/ncurses/tinfo/lib_tparm.c
index 5666b27b7e09..22eb7f397a03 100644
--- a/ncurses/tinfo/lib_tparm.c
+++ b/ncurses/tinfo/lib_tparm.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2021,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 *
@@ -53,7 +53,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: lib_tparm.c,v 1.153 2023/11/04 19:28:41 tom Exp $")
+MODULE_ID("$Id: lib_tparm.c,v 1.157 2025/02/15 15:20:16 tom Exp $")
/*
* char *
@@ -87,7 +87,7 @@ MODULE_ID("$Id: lib_tparm.c,v 1.153 2023/11/04 19:28:41 tom Exp $")
* The ':' is used to avoid making %+ or %-
* patterns (see below).
*
- * %p[1-9] push ith parm
+ * %p[1-9] push ith param
* %P[a-z] set dynamic variable [a-z] to pop()
* %g[a-z] get dynamic variable [a-z] and push it
* %P[A-Z] set static variable [A-Z] to pop()
@@ -102,7 +102,7 @@ MODULE_ID("$Id: lib_tparm.c,v 1.153 2023/11/04 19:28:41 tom Exp $")
* %= %> %< logical operations: push(pop() op pop())
* %A %O logical and & or operations for conditionals
* %! %~ unary operations push(op pop())
- * %i add 1 to first two parms (for ANSI terminals)
+ * %i add 1 to first two params (for ANSI terminals)
*
* %? expr %t thenpart %e elsepart %;
* if-then-else, %e elsepart is optional.
@@ -343,7 +343,7 @@ static NCURSES_INLINE int
#define spop(tps) \
((TPS(stack_ptr)-- > 0) \
? ((!TPS(stack)[TPS(stack_ptr)].num_type \
- && TPS(stack)[TPS(stack_ptr)].data.str != 0) \
+ && TPS(stack)[TPS(stack_ptr)].data.str != NULL) \
? TPS(stack)[TPS(stack_ptr)].data.str \
: dummy) \
: (tparm_error(tps, "spop: stack underflow"), \
@@ -361,7 +361,7 @@ static NCURSES_INLINE const char *
parse_format(const char *s, char *format, int *len)
{
*len = 0;
- if (format != 0) {
+ if (format != NULL) {
bool done = FALSE;
bool allowminus = FALSE;
bool dot = FALSE;
@@ -475,13 +475,13 @@ _nc_tparm_analyze(TERMINAL *term, const char *string, char **p_is_s, int *popcou
int level = -1;
const char *cp = string;
- if (cp == 0)
+ if (cp == NULL)
return 0;
if ((len2 = strlen(cp)) + 2 > TPS(fmt_size)) {
TPS(fmt_size) += len2 + 2;
TPS(fmt_buff) = typeRealloc(char, TPS(fmt_size), TPS(fmt_buff));
- if (TPS(fmt_buff) == 0)
+ if (TPS(fmt_buff) == NULL)
return 0;
}
@@ -616,14 +616,14 @@ tparm_setup(TERMINAL *term, const char *string, TPARM_DATA *result)
void *ft;
result->format = string;
- if ((ft = tfind(result, &MyCache, cmp_format)) != 0) {
+ if ((ft = tfind(result, &MyCache, cmp_format)) != NULL) {
size_t len2;
fs = *(TPARM_DATA **) ft;
*result = *fs;
if ((len2 = strlen(string)) + 2 > TPS(fmt_size)) {
TPS(fmt_size) += len2 + 2;
TPS(fmt_buff) = typeRealloc(char, TPS(fmt_size), TPS(fmt_buff));
- if (TPS(fmt_buff) == 0)
+ if (TPS(fmt_buff) == NULL)
return ERR;
}
} else
@@ -637,7 +637,7 @@ tparm_setup(TERMINAL *term, const char *string, TPARM_DATA *result)
result->num_parsed = _nc_tparm_analyze(term, string,
result->p_is_s,
&(result->num_popped));
- if (TPS(fmt_buff) == 0) {
+ if (TPS(fmt_buff) == NULL) {
TR(TRACE_CALLS, ("%s: error in analysis", TPS(tname)));
rc = ERR;
} else {
@@ -654,10 +654,10 @@ tparm_setup(TERMINAL *term, const char *string, TPARM_DATA *result)
result->tparm_type |= (1 << n);
}
#if HAVE_TSEARCH
- if ((fs = typeCalloc(TPARM_DATA, 1)) != 0) {
+ if ((fs = typeCalloc(TPARM_DATA, 1)) != NULL) {
*fs = *result;
- if ((fs->format = strdup(string)) != 0) {
- if (tsearch(fs, &MyCache, cmp_format) != 0) {
+ if ((fs->format = strdup(string)) != NULL) {
+ if (tsearch(fs, &MyCache, cmp_format) != NULL) {
++MyCount;
} else {
free(fs);
@@ -690,9 +690,9 @@ tparm_copy_valist(TPARM_DATA *data, int use_TPARM_ARG, va_list ap)
int i;
for (i = 0; i < data->num_actual; i++) {
- if (data->p_is_s[i] != 0) {
+ if (data->p_is_s[i] != NULL) {
char *value = va_arg(ap, char *);
- if (value == 0)
+ if (value == NULL)
value = dummy;
data->p_is_s[i] = value;
data->param[i] = 0;
@@ -740,7 +740,7 @@ tparm_trace_call(TPARM_STATE *tps, const char *string, TPARM_DATA *data)
if (USE_TRACEF(TRACE_CALLS)) {
int i;
for (i = 0; i < data->num_actual; i++) {
- if (data->p_is_s[i] != 0) {
+ if (data->p_is_s[i] != NULL) {
save_text(tps, ", %s", _nc_visbuf(data->p_is_s[i]), 0);
} else if ((long) data->param[i] > MAX_OF_TYPE(NCURSES_INT2) ||
(long) data->param[i] < 0) {
@@ -1003,12 +1003,12 @@ tparam_internal(TPARM_STATE *tps, const char *string, TPARM_DATA *data)
*/
if (!incremented_two) {
incremented_two = TRUE;
- if (data->p_is_s[0] == 0) {
+ if (data->p_is_s[0] == NULL) {
data->param[0]++;
if (termcap_hack)
TPS(stack)[0].data.num = (int) data->param[0];
}
- if (data->p_is_s[1] == 0) {
+ if (data->p_is_s[1] == NULL) {
data->param[1]++;
if (termcap_hack)
TPS(stack)[1].data.num = (int) data->param[1];
@@ -1099,7 +1099,7 @@ tparam_internal(TPARM_STATE *tps, const char *string, TPARM_DATA *data)
* are parameterized accept only numeric parameters.
*/
static bool
-check_string_caps(TPARM_DATA *data, const char *string)
+check_string_caps(const TPARM_DATA *data, const char *string)
{
bool result = FALSE;
@@ -1126,13 +1126,13 @@ check_string_caps(TPARM_DATA *data, const char *string)
#endif
#if NCURSES_XNAMES
else {
- char *check;
+ const char *check;
- check = tigetstr("Cs");
+ check = tigetstr(UserCap(Cs));
if (CHECK_CAP(check))
want_type = 1; /* style #1 */
- check = tigetstr("Ms");
+ check = tigetstr(UserCap(Ms));
if (CHECK_CAP(check))
want_type = 3; /* storage unit #1, content #2 */
}
@@ -1354,13 +1354,13 @@ _nc_tiparm(int expected, const char *string, ...)
}
#if NCURSES_XNAMES
else {
- char *check;
+ const char *check;
- check = tigetstr("xm");
+ check = tigetstr(UserCap(xm));
if (CHECK_CAP(check)) {
needed = 3;
}
- check = tigetstr("S0");
+ check = tigetstr(UserCap(S0));
if (CHECK_CAP(check)) {
needed = 0; /* used in screen-base */
}
diff --git a/ncurses/tinfo/lib_tputs.c b/ncurses/tinfo/lib_tputs.c
index f834532c9193..92232f6efd70 100644
--- a/ncurses/tinfo/lib_tputs.c
+++ b/ncurses/tinfo/lib_tputs.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 *
@@ -52,7 +52,7 @@
#include <termcap.h> /* ospeed */
#include <tic.h>
-MODULE_ID("$Id: lib_tputs.c,v 1.111 2023/09/16 16:05:15 tom Exp $")
+MODULE_ID("$Id: lib_tputs.c,v 1.116 2025/01/12 00:41:56 tom Exp $")
NCURSES_EXPORT_VAR(char) PC = 0; /* used by termcap library */
NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed = 0; /* used by termcap library */
@@ -63,7 +63,7 @@ NCURSES_EXPORT_VAR(int) _nc_nulls_sent = 0;
NCURSES_EXPORT(void)
_nc_set_no_padding(SCREEN *sp)
{
- bool no_padding = (getenv("NCURSES_NO_PADDING") != 0);
+ bool no_padding = (getenv("NCURSES_NO_PADDING") != NULL);
if (sp)
sp->_no_padding = no_padding;
@@ -124,7 +124,7 @@ NCURSES_EXPORT(void)
NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0)
{
T((T_CALLED("_nc_flush(%p)"), (void *) SP_PARM));
- if (SP_PARM != 0 && SP_PARM->_ofd >= 0) {
+ if (SP_PARM != NULL && SP_PARM->_ofd >= 0) {
TR(TRACE_CHARPUT, ("ofd:%d inuse:%lu buffer:%p",
SP_PARM->_ofd,
(unsigned long) SP_PARM->out_inuse,
@@ -149,15 +149,17 @@ NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_DCL0)
break; /* an error we can not recover from */
}
}
- } else if (SP_PARM->out_buffer == 0) {
- TR(TRACE_CHARPUT, ("flushing stdout"));
+ } else if (SP_PARM->out_buffer == NULL) {
+ TR(TRACE_CHARPUT, ("flushing stdout/stderr"));
fflush(stdout);
+ fflush(stderr);
}
} else {
- TR(TRACE_CHARPUT, ("flushing stdout"));
+ TR(TRACE_CHARPUT, ("flushing stdout/stderr"));
fflush(stdout);
+ fflush(stderr);
}
- if (SP_PARM != 0)
+ if (SP_PARM != NULL)
SP_PARM->out_inuse = 0;
returnVoid;
}
@@ -178,8 +180,8 @@ NCURSES_SP_NAME(_nc_outch) (NCURSES_SP_DCLx int ch)
COUNT_OUTCHARS(1);
if (HasTInfoTerminal(SP_PARM)
- && SP_PARM != 0) {
- if (SP_PARM->out_buffer != 0) {
+ && SP_PARM != NULL) {
+ if (SP_PARM->out_buffer != NULL) {
if (SP_PARM->out_inuse + 1 >= SP_PARM->out_limit)
NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
SP_PARM->out_buffer[SP_PARM->out_inuse++] = (char) ch;
@@ -257,7 +259,7 @@ NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_DCLx
{
int rc = ERR;
- if (string != 0) {
+ if (string != NULL) {
TPUTS_TRACE(name);
rc = NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
string, 1, NCURSES_SP_NAME(_nc_outch));
@@ -312,12 +314,12 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
if (!VALID_STRING(string))
return ERR;
- if (SP_PARM != 0 && HasTInfoTerminal(SP_PARM)) {
+ if (SP_PARM != NULL && HasTInfoTerminal(SP_PARM)) {
if (
#if NCURSES_SP_FUNCS
- (SP_PARM != 0 && SP_PARM->_term == 0)
+ (SP_PARM != NULL && SP_PARM->_term == NULL)
#else
- cur_term == 0
+ cur_term == NULL
#endif
) {
always_delay = FALSE;
@@ -442,7 +444,7 @@ NCURSES_SP_NAME(tputs) (NCURSES_SP_DCLx
NCURSES_EXPORT(int)
_nc_outc_wrapper(SCREEN *sp, int c)
{
- if (0 == sp) {
+ if (NULL == sp) {
return fputc(c, stdout);
} else {
return sp->jump(c);
diff --git a/ncurses/tinfo/lib_ttyflags.c b/ncurses/tinfo/lib_ttyflags.c
index 6363a805be9c..927ab40c85b7 100644
--- a/ncurses/tinfo/lib_ttyflags.c
+++ b/ncurses/tinfo/lib_ttyflags.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-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 *
@@ -42,7 +42,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_ttyflags.c,v 1.36 2020/09/05 22:54:47 tom Exp $")
+MODULE_ID("$Id: lib_ttyflags.c,v 1.40 2025/12/27 12:33:34 tom Exp $")
NCURSES_EXPORT(int)
NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf)
@@ -50,12 +50,12 @@ NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf)
TERMINAL *termp = TerminalOf(SP_PARM);
int result = OK;
- if (buf == 0 || termp == 0) {
+ if (buf == NULL || termp == NULL) {
result = ERR;
} else {
-#ifdef USE_TERM_DRIVER
- if (SP_PARM != 0) {
+#if USE_TERM_DRIVER
+ if (SP_PARM != NULL) {
result = CallDriver_2(SP_PARM, td_sgmode, FALSE, buf);
} else {
result = ERR;
@@ -75,7 +75,7 @@ NCURSES_SP_NAME(_nc_get_tty_mode) (NCURSES_SP_DCLx TTY * buf)
termp ? termp->Filedes : -1,
_nc_trace_ttymode(buf)));
}
- if (result == ERR && buf != 0)
+ if (result == ERR && buf != NULL)
memset(buf, 0, sizeof(*buf));
return (result);
@@ -94,15 +94,15 @@ NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_DCLx TTY * buf)
{
int result = OK;
- if (buf == 0 || SP_PARM == 0) {
+ if (buf == NULL || SP_PARM == NULL) {
result = ERR;
} else {
TERMINAL *termp = TerminalOf(SP_PARM);
- if (0 == termp) {
+ if (NULL == termp) {
result = ERR;
} else {
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
result = CallDriver_2(SP_PARM, td_sgmode, TRUE, buf);
#else
for (;;) {
@@ -113,7 +113,7 @@ NCURSES_SP_NAME(_nc_set_tty_mode) (NCURSES_SP_DCLx TTY * buf)
) {
if (errno == EINTR)
continue;
- if ((errno == ENOTTY) && (SP_PARM != 0))
+ if ((errno == ENOTTY) && (SP_PARM != NULL))
SP_PARM->_notty = TRUE;
result = ERR;
}
@@ -145,8 +145,8 @@ NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_DCL0)
T((T_CALLED("def_shell_mode(%p) ->term %p"),
(void *) SP_PARM, (void *) termp));
- if (termp != 0) {
-#ifdef USE_TERM_DRIVER
+ if (termp != NULL) {
+#if USE_TERM_DRIVER
rc = CallDriver_2(SP_PARM, td_mode, FALSE, TRUE);
#else
/*
@@ -156,7 +156,7 @@ NCURSES_SP_NAME(def_shell_mode) (NCURSES_SP_DCL0)
#ifdef TERMIOS
if (termp->Ottyb.c_oflag & OFLAGS_TABS)
tab = back_tab = NULL;
-#elif defined(EXP_WIN32_DRIVER)
+#elif USE_NAMED_PIPES
/* noop */
#else
if (termp->Ottyb.sg_flags & XTABS)
@@ -185,8 +185,8 @@ NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_DCL0)
T((T_CALLED("def_prog_mode(%p) ->term %p"), (void *) SP_PARM, (void *) termp));
- if (termp != 0) {
-#ifdef USE_TERM_DRIVER
+ if (termp != NULL) {
+#if USE_TERM_DRIVER
rc = CallDriver_2(SP_PARM, td_mode, TRUE, TRUE);
#else
/*
@@ -195,7 +195,7 @@ NCURSES_SP_NAME(def_prog_mode) (NCURSES_SP_DCL0)
if (_nc_get_tty_mode(&termp->Nttyb) == OK) {
#ifdef TERMIOS
termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS);
-#elif defined(EXP_WIN32_DRIVER)
+#elif USE_NAMED_PIPES
/* noop */
#else
termp->Nttyb.sg_flags &= (unsigned) (~XTABS);
@@ -223,8 +223,8 @@ NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_DCL0)
T((T_CALLED("reset_prog_mode(%p) ->term %p"), (void *) SP_PARM, (void *) termp));
- if (termp != 0) {
-#ifdef USE_TERM_DRIVER
+ if (termp != NULL) {
+#if USE_TERM_DRIVER
rc = CallDriver_2(SP_PARM, td_mode, TRUE, FALSE);
#else
if (_nc_set_tty_mode(&termp->Nttyb) == OK) {
@@ -256,8 +256,8 @@ NCURSES_SP_NAME(reset_shell_mode) (NCURSES_SP_DCL0)
T((T_CALLED("reset_shell_mode(%p) ->term %p"),
(void *) SP_PARM, (void *) termp));
- if (termp != 0) {
-#ifdef USE_TERM_DRIVER
+ if (termp != NULL) {
+#if USE_TERM_DRIVER
rc = CallDriver_2(SP_PARM, td_mode, FALSE, FALSE);
#else
if (SP_PARM) {
@@ -281,12 +281,12 @@ reset_shell_mode(void)
static TTY *
saved_tty(NCURSES_SP_DCL0)
{
- TTY *result = 0;
+ TTY *result = NULL;
- if (SP_PARM != 0) {
+ if (SP_PARM != NULL) {
result = (TTY *) & (SP_PARM->_saved_tty);
} else {
- if (_nc_prescreen.saved_tty == 0) {
+ if (_nc_prescreen.saved_tty == NULL) {
_nc_prescreen.saved_tty = typeCalloc(TTY, 1);
}
result = _nc_prescreen.saved_tty;
diff --git a/ncurses/tinfo/lib_win32con.c b/ncurses/tinfo/lib_win32con.c
index 2d6857aeb4a8..e92841a9eb48 100644
--- a/ncurses/tinfo/lib_win32con.c
+++ b/ncurses/tinfo/lib_win32con.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2021,2023 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,70 +36,65 @@
* TODO - GetMousePos(POINT * result) from ntconio.c
*/
+#define TTY int /* FIXME: TTY originalMode */
#include <curses.priv.h>
+#include <nc_win32.h>
-MODULE_ID("$Id: lib_win32con.c,v 1.14 2023/08/05 20:44:38 tom Exp $")
-
-#ifdef _NC_WINDOWS
-
-#ifdef _NC_MINGW
-#include <wchar.h>
-#else
-#include <tchar.h>
+#ifndef _O_BINARY
+#define _O_BINARY 0 /* FIXME: not defined in MSYS2 base */
#endif
-#include <io.h>
+MODULE_ID("$Id: lib_win32con.c,v 1.50 2025/12/27 21:49:45 tom Exp $")
-#if USE_WIDEC_SUPPORT
-#define write_screen WriteConsoleOutputW
-#define read_screen ReadConsoleOutputW
-#else
-#define write_screen WriteConsoleOutput
-#define read_screen ReadConsoleOutput
-#endif
+#if defined(_NC_WINDOWS)
+
+#define CONTROL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
static bool read_screen_data(void);
#define GenMap(vKey,key) MAKELONG(key, vKey)
+/* *INDENT-OFF* */
static const LONG keylist[] =
{
- GenMap(VK_PRIOR, KEY_PPAGE),
- GenMap(VK_NEXT, KEY_NPAGE),
- GenMap(VK_END, KEY_END),
- GenMap(VK_HOME, KEY_HOME),
- GenMap(VK_LEFT, KEY_LEFT),
- GenMap(VK_UP, KEY_UP),
- GenMap(VK_RIGHT, KEY_RIGHT),
- GenMap(VK_DOWN, KEY_DOWN),
+ GenMap(VK_PRIOR, KEY_PPAGE),
+ GenMap(VK_NEXT, KEY_NPAGE),
+ GenMap(VK_END, KEY_END),
+ GenMap(VK_HOME, KEY_HOME),
+ GenMap(VK_LEFT, KEY_LEFT),
+ GenMap(VK_UP, KEY_UP),
+ GenMap(VK_RIGHT, KEY_RIGHT),
+ GenMap(VK_DOWN, KEY_DOWN),
GenMap(VK_DELETE, KEY_DC),
GenMap(VK_INSERT, KEY_IC)
};
static const LONG ansi_keys[] =
{
- GenMap(VK_PRIOR, 'I'),
- GenMap(VK_NEXT, 'Q'),
- GenMap(VK_END, 'O'),
- GenMap(VK_HOME, 'H'),
- GenMap(VK_LEFT, 'K'),
- GenMap(VK_UP, 'H'),
- GenMap(VK_RIGHT, 'M'),
- GenMap(VK_DOWN, 'P'),
+ GenMap(VK_PRIOR, 'I'),
+ GenMap(VK_NEXT, 'Q'),
+ GenMap(VK_END, 'O'),
+ GenMap(VK_HOME, 'H'),
+ GenMap(VK_LEFT, 'K'),
+ GenMap(VK_UP, 'H'),
+ GenMap(VK_RIGHT, 'M'),
+ GenMap(VK_DOWN, 'P'),
GenMap(VK_DELETE, 'S'),
GenMap(VK_INSERT, 'R')
};
+/* *INDENT-ON* */
#define array_length(a) (sizeof(a)/sizeof(a[0]))
#define N_INI ((int)array_length(keylist))
#define FKEYS 24
#define MAPSIZE (FKEYS + N_INI)
+static bool console_initialized = FALSE;
+
/* A process can only have a single console, so it is safe
to maintain all the information about it in a single
static structure.
*/
NCURSES_EXPORT_VAR(ConsoleInfo) _nc_CONSOLE;
-static bool console_initialized = FALSE;
-#define EnsureInit() (void)(console_initialized ? TRUE : _nc_console_checkinit(TRUE, TRUE))
+#define EnsureInit() (void)(console_initialized ? TRUE : _nc_console_checkinit(USE_NAMED_PIPES))
#define REQUIRED_MAX_V (DWORD)10
#define REQUIRED_MIN_V (DWORD)0
@@ -119,10 +114,10 @@ _nc_console_vt_supported(void)
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
- T(("GetVersionEx returnedMajor=%ld, Minor=%ld, Build=%ld",
- osvi.dwMajorVersion,
- osvi.dwMinorVersion,
- osvi.dwBuildNumber));
+ T(("GetVersionEx returnedMajor=%lu, Minor=%lu, Build=%lu",
+ (unsigned long) osvi.dwMajorVersion,
+ (unsigned long) osvi.dwMinorVersion,
+ (unsigned long) osvi.dwBuildNumber));
if (osvi.dwMajorVersion >= REQUIRED_MAX_V) {
if (osvi.dwMajorVersion == REQUIRED_MAX_V) {
if (((osvi.dwMinorVersion == REQUIRED_MIN_V) &&
@@ -222,13 +217,15 @@ _nc_console_fd2handle(int fd)
T(("lib_win32con:validateHandle %d -> WINCONSOLE.hdl", fd));
} else if (hdl == WINCONSOLE.out) {
T(("lib_win32con:validateHandle %d -> WINCONSOLE.out", fd));
+ } else if (hdl == GetStdHandle(STD_INPUT_HANDLE)) {
+ T(("lib_win32con:validateHandle %d -> STD_INPUT_HANDLE", fd));
+ if (!WINCONSOLE.isTermInfoConsole && WINCONSOLE.progMode) {
+ hdl = WINCONSOLE.inp;
+ }
} else {
T(("lib_win32con:validateHandle %d maps to unknown HANDLE", fd));
hdl = INVALID_HANDLE_VALUE;
}
-#if 1
- assert(hdl != INVALID_HANDLE_VALUE);
-#endif
if (hdl != INVALID_HANDLE_VALUE) {
if (hdl != WINCONSOLE.inp && (!WINCONSOLE.isTermInfoConsole && WINCONSOLE.progMode)) {
if (hdl == WINCONSOLE.out && hdl != WINCONSOLE.hdl) {
@@ -240,6 +237,7 @@ _nc_console_fd2handle(int fd)
return hdl;
}
+#if defined(_NC_WINDOWS) && USE_WINCONMODE
NCURSES_EXPORT(int)
_nc_console_setmode(HANDLE hdl, const TTY * arg)
{
@@ -259,36 +257,20 @@ _nc_console_setmode(HANDLE hdl, const TTY * arg)
T(("lib_win32con:_nc_console_setmode %s", _nc_trace_ttymode(arg)));
if (hdl == WINCONSOLE.inp) {
dwFlag = arg->dwFlagIn | ENABLE_MOUSE_INPUT | VT_FLAG_IN;
- if (WINCONSOLE.isTermInfoConsole)
- dwFlag |= (VT_FLAG_IN);
- else
- dwFlag &= (DWORD) ~ (VT_FLAG_IN);
TRCTTYIN(dwFlag);
SetConsoleMode(hdl, dwFlag);
alt = OutHandle();
dwFlag = arg->dwFlagOut;
- if (WINCONSOLE.isTermInfoConsole)
- dwFlag |= (VT_FLAG_OUT);
- else
- dwFlag |= (VT_FLAG_OUT);
TRCTTYOUT(dwFlag);
SetConsoleMode(alt, dwFlag);
} else {
dwFlag = arg->dwFlagOut;
- if (WINCONSOLE.isTermInfoConsole)
- dwFlag |= (VT_FLAG_OUT);
- else
- dwFlag |= (VT_FLAG_OUT);
TRCTTYOUT(dwFlag);
SetConsoleMode(hdl, dwFlag);
alt = WINCONSOLE.inp;
dwFlag = arg->dwFlagIn | ENABLE_MOUSE_INPUT;
- if (WINCONSOLE.isTermInfoConsole)
- dwFlag |= (VT_FLAG_IN);
- else
- dwFlag &= (DWORD) ~ (VT_FLAG_IN);
TRCTTYIN(dwFlag);
SetConsoleMode(alt, dwFlag);
T(("effective mode set %s", _nc_trace_ttymode(&TRCTTY)));
@@ -330,6 +312,7 @@ _nc_console_getmode(HANDLE hdl, TTY * arg)
T(("lib_win32con:_nc_console_getmode %s", _nc_trace_ttymode(arg)));
return (code);
}
+#endif /* defined(_NC_WINDOWS) && USE_WINCONMODE */
NCURSES_EXPORT(int)
_nc_console_flush(HANDLE hdl)
@@ -404,7 +387,7 @@ save_original_screen(void)
return result;
}
-#if 0
+#if defined(_NC_WINDOWS)
static bool
restore_original_screen(void)
{
@@ -426,7 +409,7 @@ restore_original_screen(void)
bufferCoord,
&save_region)) {
result = TRUE;
- mvcur(-1, -1, LINES - 2, 0);
+ SetConsoleCursorPosition(WINCONSOLE.hdl, WINCONSOLE.save_SBI.dwCursorPosition);
T(("... restore original screen contents ok %dx%d (%d,%d - %d,%d)",
WINCONSOLE.save_size.Y,
WINCONSOLE.save_size.X,
@@ -455,11 +438,13 @@ read_screen_data(void)
want = (size_t) (WINCONSOLE.save_size.X * WINCONSOLE.save_size.Y);
- if ((WINCONSOLE.save_screen = malloc(want * sizeof(CHAR_INFO))) != 0) {
- bufferCoord.X = (SHORT) (WINCONSOLE.window_only ?
- WINCONSOLE.SBI.srWindow.Left : 0);
- bufferCoord.Y = (SHORT) (WINCONSOLE.window_only ?
- WINCONSOLE.SBI.srWindow.Top : 0);
+ if ((WINCONSOLE.save_screen = malloc(want * sizeof(CHAR_INFO))) != NULL) {
+ bufferCoord.X = (SHORT) (WINCONSOLE.window_only
+ ? WINCONSOLE.SBI.srWindow.Left
+ : 0);
+ bufferCoord.Y = (SHORT) (WINCONSOLE.window_only
+ ? WINCONSOLE.SBI.srWindow.Top
+ : 0);
T(("... reading console %s %dx%d into %d,%d - %d,%d at %d,%d",
WINCONSOLE.window_only ? "window" : "buffer",
@@ -617,7 +602,7 @@ tdiff(FILETIME fstart, FILETIME fend)
static int
Adjust(int milliseconds, int diff)
{
- if (milliseconds != INFINITY) {
+ if (milliseconds != NC_INFINITY) {
milliseconds -= diff;
if (milliseconds < 0)
milliseconds = 0;
@@ -632,7 +617,7 @@ Adjust(int milliseconds, int diff)
RIGHTMOST_BUTTON_PRESSED)
static mmask_t
-decode_mouse(SCREEN *sp, int mask)
+decode_mouse(const SCREEN *sp, int mask)
{
mmask_t result = 0;
@@ -668,7 +653,9 @@ decode_mouse(SCREEN *sp, int mask)
return result;
}
-#define AdjustY() (WINCONSOLE.buffered ? 0 : (int) WINCONSOLE.SBI.srWindow.Top)
+#define AdjustY() (WINCONSOLE.buffered \
+ ? 0 \
+ : (int) WINCONSOLE.SBI.srWindow.Top)
static bool
handle_mouse(SCREEN *sp, MOUSE_EVENT_RECORD mer)
@@ -828,7 +815,7 @@ _nc_console_keyExist(int keycode)
NCURSES_EXPORT(int)
_nc_console_twait(
- SCREEN *sp,
+ const SCREEN *sp,
HANDLE hdl,
int mode,
int milliseconds,
@@ -837,7 +824,7 @@ _nc_console_twait(
{
INPUT_RECORD inp_rec;
BOOL b;
- DWORD nRead = 0, rc = (DWORD) (-1);
+ DWORD nRead = 0, rc = WAIT_FAILED;
int code = 0;
FILETIME fstart;
FILETIME fend;
@@ -848,9 +835,10 @@ _nc_console_twait(
(void) evl; /* TODO: implement wgetch-events */
#endif
-#define IGNORE_CTRL_KEYS (SHIFT_PRESSED|LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED| \
- LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)
-#define CONSUME() ReadConsoleInput(hdl, &inp_rec, 1, &nRead)
+#define IGNORE_CTRL_KEYS (SHIFT_PRESSED | \
+ LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED | \
+ LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
+#define CONSUME() read_keycode(hdl, &inp_rec, 1, &nRead)
assert(sp);
@@ -858,7 +846,7 @@ _nc_console_twait(
hdl, milliseconds, mode));
if (milliseconds < 0)
- milliseconds = INFINITY;
+ milliseconds = NC_INFINITY;
memset(&inp_rec, 0, sizeof(inp_rec));
@@ -881,14 +869,13 @@ _nc_console_twait(
T(("twait:err GetNumberOfConsoleInputEvents"));
}
if (isNoDelay && b) {
- T(("twait: Events Available: %ld", nRead));
+ T(("twait: Events Available: %lu", (unsigned long) nRead));
if (nRead == 0) {
code = 0;
goto end;
} else {
DWORD n = 0;
- INPUT_RECORD *pInpRec =
- TypeAlloca(INPUT_RECORD, nRead);
+ MakeArray(pInpRec, INPUT_RECORD, nRead);
if (pInpRec != NULL) {
DWORD i;
BOOL f;
@@ -927,13 +914,13 @@ _nc_console_twait(
switch (inp_rec.EventType) {
case KEY_EVENT:
if (mode & TW_INPUT) {
- WORD vk =
- inp_rec.Event.KeyEvent.wVirtualKeyCode;
- char ch =
- inp_rec.Event.KeyEvent.uChar.AsciiChar;
+ WORD vk = inp_rec.Event.KeyEvent.wVirtualKeyCode;
+ WORD ch = inp_rec.Event.KeyEventChar;
+
T(("twait:event KEY_EVENT"));
T(("twait vk=%d, ch=%d, keydown=%d",
vk, ch, inp_rec.Event.KeyEvent.bKeyDown));
+
if (inp_rec.Event.KeyEvent.bKeyDown) {
T(("twait:event KeyDown"));
if (!WINCONSOLE.isTermInfoConsole &&
@@ -964,7 +951,7 @@ _nc_console_twait(
continue;
/* e.g., FOCUS_EVENT */
default:
- T(("twait:event Tyoe %d", inp_rec.EventType));
+ T(("twait:event Type %d", inp_rec.EventType));
CONSUME();
_nc_console_selectActiveHandle();
continue;
@@ -986,7 +973,7 @@ _nc_console_twait(
end:
TR(TRACE_IEVENT, ("end twait: returned %d (%lu), remaining time %d msec",
- code, GetLastError(), milliseconds));
+ code, (unsigned long) GetLastError(), milliseconds));
if (timeleft)
*timeleft = milliseconds;
@@ -996,7 +983,7 @@ _nc_console_twait(
NCURSES_EXPORT(int)
_nc_console_testmouse(
- SCREEN *sp,
+ const SCREEN *sp,
HANDLE hdl,
int delay
EVENTLIST_2nd(_nc_eventlist * evl))
@@ -1037,7 +1024,7 @@ _nc_console_read(
T((T_CALLED("lib_win32con::_nc_console_read(%p)"), sp));
- while ((b = ReadConsoleInput(hdl, &inp_rec, 1, &nRead))) {
+ while ((b = read_keycode(hdl, &inp_rec, 1, &nRead))) {
if (b && nRead > 0) {
if (rc < 0)
rc = 0;
@@ -1045,7 +1032,7 @@ _nc_console_read(
if (inp_rec.EventType == KEY_EVENT) {
if (!inp_rec.Event.KeyEvent.bKeyDown)
continue;
- *buf = (int) inp_rec.Event.KeyEvent.uChar.AsciiChar;
+ *buf = (int) inp_rec.Event.KeyEventChar;
vk = inp_rec.Event.KeyEvent.wVirtualKeyCode;
/*
* There are 24 virtual function-keys, and typically
@@ -1068,6 +1055,16 @@ _nc_console_read(
ungetch('\0');
*buf = AnsiKey(vk);
}
+ } else if (vk == VK_BACK) {
+ if (!(inp_rec.Event.KeyEvent.dwControlKeyState
+ & (SHIFT_PRESSED | CONTROL_PRESSED))) {
+ *buf = KEY_BACKSPACE;
+ }
+ } else if (vk == VK_TAB) {
+ if ((inp_rec.Event.KeyEvent.dwControlKeyState
+ & (SHIFT_PRESSED | CONTROL_PRESSED))) {
+ *buf = KEY_BTAB;
+ }
}
break;
} else if (inp_rec.EventType == MOUSE_EVENT) {
@@ -1083,6 +1080,7 @@ _nc_console_read(
returnCode(rc);
}
+#if USE_TERM_DRIVER && (USE_NAMED_PIPES || defined(USE_WIN32CON_DRIVER))
/* Our replacement for the systems _isatty to include also
a test for mintty. This is called from the NC_ISATTY macro
defined in curses.priv.h
@@ -1098,7 +1096,7 @@ _nc_console_isatty(int fd)
int result = 0;
T((T_CALLED("lib_win32con::_nc_console_isatty(%d"), fd));
- if (_isatty(fd))
+ if (isatty(fd))
result = 1;
#ifdef _NC_CHECK_MINTTY
else {
@@ -1114,137 +1112,155 @@ _nc_console_isatty(int fd)
#endif
returnCode(result);
}
+#endif /* USE_TERM_DRIVER && (USE_NAMED_PIPES || defined(USE_WIN32CON_DRIVER)) */
+#if USE_WINCONMODE
NCURSES_EXPORT(bool)
-_nc_console_checkinit(bool initFlag, bool assumeTermInfo)
+_nc_console_checkinit(bool assumeTermInfo)
{
bool res = FALSE;
- T((T_CALLED("lib_win32con::_nc_console_checkinit(initFlag=%d, assumeTermInfo=%d)"),
- initFlag, assumeTermInfo));
-
- if (!initFlag) {
- res = console_initialized;
- } else {
- /* initialize once, or not at all */
- if (!console_initialized) {
- int i;
- DWORD num_buttons;
- WORD a;
- BOOL buffered = FALSE;
- BOOL b;
-
- START_TRACE();
- WINCONSOLE.isTermInfoConsole = assumeTermInfo;
-
- WINCONSOLE.map = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
- WINCONSOLE.rmap = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
- WINCONSOLE.ansi_map = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
-
- for (i = 0; i < (N_INI + FKEYS); i++) {
- if (i < N_INI) {
- WINCONSOLE.rmap[i] = WINCONSOLE.map[i] =
- (DWORD) keylist[i];
- WINCONSOLE.ansi_map[i] = (DWORD) ansi_keys[i];
- } else {
- WINCONSOLE.rmap[i] = WINCONSOLE.map[i] =
- (DWORD) GenMap((VK_F1 + (i - N_INI)),
- (KEY_F(1) + (i - N_INI)));
- WINCONSOLE.ansi_map[i] =
- (DWORD) GenMap((VK_F1 + (i - N_INI)),
- (';' + (i - N_INI)));
- }
- }
- qsort(WINCONSOLE.ansi_map,
- (size_t) (MAPSIZE),
- sizeof(keylist[0]),
- keycompare);
- qsort(WINCONSOLE.map,
- (size_t) (MAPSIZE),
- sizeof(keylist[0]),
- keycompare);
- qsort(WINCONSOLE.rmap,
- (size_t) (MAPSIZE),
- sizeof(keylist[0]),
- rkeycompare);
-
- if (GetNumberOfConsoleMouseButtons(&num_buttons)) {
- WINCONSOLE.numButtons = (int) num_buttons;
+ T((T_CALLED("lib_win32con::_nc_console_checkinit(assumeTermInfo=%d)"),
+ assumeTermInfo));
+
+ /* initialize once, or not at all */
+ if (!console_initialized) {
+ int i;
+ DWORD num_buttons;
+ WORD a;
+ BOOL buffered = FALSE;
+ BOOL b;
+
+ START_TRACE();
+ WINCONSOLE.isTermInfoConsole = assumeTermInfo;
+
+ WINCONSOLE.map = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
+ WINCONSOLE.rmap = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
+ WINCONSOLE.ansi_map = (LPDWORD) malloc(sizeof(DWORD) * MAPSIZE);
+
+ for (i = 0; i < (N_INI + FKEYS); i++) {
+ if (i < N_INI) {
+ WINCONSOLE.rmap[i] = WINCONSOLE.map[i] =
+ (DWORD) keylist[i];
+ WINCONSOLE.ansi_map[i] = (DWORD) ansi_keys[i];
} else {
- WINCONSOLE.numButtons = 1;
+ WINCONSOLE.rmap[i] = WINCONSOLE.map[i] =
+ (DWORD) GenMap((VK_F1 + (i - N_INI)),
+ (KEY_F(1) + (i - N_INI)));
+ WINCONSOLE.ansi_map[i] =
+ (DWORD) GenMap((VK_F1 + (i - N_INI)),
+ (';' + (i - N_INI)));
}
+ }
+ qsort(WINCONSOLE.ansi_map,
+ (size_t) (MAPSIZE),
+ sizeof(keylist[0]),
+ keycompare);
+ qsort(WINCONSOLE.map,
+ (size_t) (MAPSIZE),
+ sizeof(keylist[0]),
+ keycompare);
+ qsort(WINCONSOLE.rmap,
+ (size_t) (MAPSIZE),
+ sizeof(keylist[0]),
+ rkeycompare);
+
+ if (GetNumberOfConsoleMouseButtons(&num_buttons)) {
+ WINCONSOLE.numButtons = (int) num_buttons;
+ } else {
+ WINCONSOLE.numButtons = 1;
+ }
- a = _nc_console_MapColor(true, COLOR_WHITE) |
- _nc_console_MapColor(false, COLOR_BLACK);
- for (i = 0; i < CON_NUMPAIRS; i++)
- WINCONSOLE.pairs[i] = a;
+ a = _nc_console_MapColor(true, COLOR_WHITE) |
+ _nc_console_MapColor(false, COLOR_BLACK);
+ for (i = 0; i < CON_NUMPAIRS; i++)
+ WINCONSOLE.pairs[i] = a;
#define SaveConsoleMode(handle, value) \
- GetConsoleMode(WINCONSOLE.handle, &WINCONSOLE.originalMode.value)
+ GetConsoleMode(WINCONSOLE.handle, &WINCONSOLE.originalMode.value)
- if (WINCONSOLE.isTermInfoConsole) {
- WINCONSOLE.inp = GetStdHandle(STD_INPUT_HANDLE);
- WINCONSOLE.out = GetStdHandle(STD_OUTPUT_HANDLE);
- WINCONSOLE.hdl = WINCONSOLE.out;
+ if (WINCONSOLE.isTermInfoConsole) {
+ WINCONSOLE.inp = GetStdHandle(STD_INPUT_HANDLE);
+ WINCONSOLE.out = GetStdHandle(STD_OUTPUT_HANDLE);
+ WINCONSOLE.hdl = WINCONSOLE.out;
+
+ SaveConsoleMode(inp, dwFlagIn);
+ SaveConsoleMode(out, dwFlagOut);
- SaveConsoleMode(inp, dwFlagIn);
- SaveConsoleMode(out, dwFlagOut);
+ } else {
+ b = AllocConsole();
+
+ if (!b)
+ b = AttachConsole(ATTACH_PARENT_PROCESS);
+
+ WINCONSOLE.inp = GetDirectHandle("CONIN$", FILE_SHARE_READ);
+ WINCONSOLE.out = GetDirectHandle("CONOUT$", FILE_SHARE_WRITE);
+ SaveConsoleMode(inp, dwFlagIn);
+ SaveConsoleMode(out, dwFlagOut);
+
+ if (getenv("NCGDB") || getenv("NCURSES_CONSOLE2")) {
+ WINCONSOLE.hdl = WINCONSOLE.out;
+ buffered = FALSE;
+ T(("... will not buffer console"));
} else {
- b = AllocConsole();
-
- if (!b)
- b = AttachConsole(ATTACH_PARENT_PROCESS);
-
- WINCONSOLE.inp = GetDirectHandle("CONIN$", FILE_SHARE_READ);
- WINCONSOLE.out = GetDirectHandle("CONOUT$", FILE_SHARE_WRITE);
-
- SaveConsoleMode(inp, dwFlagIn);
- SaveConsoleMode(out, dwFlagOut);
-
- if (getenv("NCGDB") || getenv("NCURSES_CONSOLE2")) {
- WINCONSOLE.hdl = WINCONSOLE.out;
- T(("... will not buffer console"));
- } else {
- T(("... creating console buffer"));
- WINCONSOLE.hdl =
- CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- CONSOLE_TEXTMODE_BUFFER,
- NULL);
- buffered = TRUE;
- }
+ T(("... creating console buffer"));
+ WINCONSOLE.hdl =
+ CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ CONSOLE_TEXTMODE_BUFFER,
+ NULL);
+ buffered = TRUE;
}
+ }
- /* We set binary I/O even when using the console
- driver to cover the situation, that the
- TERM variable is set to #win32con, but actually
- Windows supports virtual terminal processing.
- So if terminfo functions are used in this setup,
- they actually may work.
- */
- _setmode(fileno(stdin), _O_BINARY);
- _setmode(fileno(stdout), _O_BINARY);
-
- if (WINCONSOLE.hdl != INVALID_HANDLE_VALUE) {
- WINCONSOLE.buffered = buffered;
- _nc_console_get_SBI();
- WINCONSOLE.save_SBI = WINCONSOLE.SBI;
- if (!buffered) {
- save_original_screen();
- _nc_console_set_scrollback(FALSE, &WINCONSOLE.SBI);
- }
- GetConsoleCursorInfo(WINCONSOLE.hdl, &WINCONSOLE.save_CI);
- T(("... initial cursor is %svisible, %d%%",
- (WINCONSOLE.save_CI.bVisible ? "" : "not-"),
- (int) WINCONSOLE.save_CI.dwSize));
+ /* We set binary I/O even when using the console
+ driver to cover the situation, that the
+ TERM variable is set to #win32con, but actually
+ Windows supports virtual terminal processing.
+ So if terminfo functions are used in this setup,
+ they actually may work.
+ */
+ _setmode(fileno(stdin), _O_BINARY);
+ _setmode(fileno(stdout), _O_BINARY);
+
+ if (WINCONSOLE.hdl != INVALID_HANDLE_VALUE) {
+ WINCONSOLE.buffered = buffered;
+ _nc_console_get_SBI();
+ WINCONSOLE.save_SBI = WINCONSOLE.SBI;
+ if (!buffered) {
+ save_original_screen();
+ _nc_console_set_scrollback(FALSE, &WINCONSOLE.SBI);
}
+ GetConsoleCursorInfo(WINCONSOLE.hdl, &WINCONSOLE.save_CI);
+ T(("... initial cursor is %svisible, %d%%",
+ (WINCONSOLE.save_CI.bVisible ? "" : "not-"),
+ (int) WINCONSOLE.save_CI.dwSize));
+ }
+
+ WINCONSOLE.initialized = TRUE;
+ console_initialized = TRUE;
+ }
+ res = (WINCONSOLE.hdl != INVALID_HANDLE_VALUE);
+ returnBool(res);
+}
+#endif /* USE_WINCONMODE */
+
+NCURSES_EXPORT(bool)
+_nc_console_restore(void)
+{
+ bool res = FALSE;
- WINCONSOLE.initialized = TRUE;
- console_initialized = TRUE;
+ T((T_CALLED("lib_win32con::_nc_console_restore")));
+ if (WINCONSOLE.hdl != INVALID_HANDLE_VALUE) {
+ res = TRUE;
+ if (!WINCONSOLE.buffered) {
+ _nc_console_set_scrollback(TRUE, &WINCONSOLE.save_SBI);
+ if (!restore_original_screen())
+ res = FALSE;
}
- res = (WINCONSOLE.hdl != INVALID_HANDLE_VALUE);
+ SetConsoleCursorInfo(WINCONSOLE.hdl, &WINCONSOLE.save_CI);
}
returnBool(res);
}
diff --git a/ncurses/tinfo/lib_win32util.c b/ncurses/tinfo/lib_win32util.c
index c67c8ceb9862..f5f3207c0426 100644
--- a/ncurses/tinfo/lib_win32util.c
+++ b/ncurses/tinfo/lib_win32util.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2021,2023 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2009,2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -33,16 +33,15 @@
****************************************************************************/
#include <curses.priv.h>
+#include <tchar.h>
-MODULE_ID("$Id: lib_win32util.c,v 1.4 2023/06/17 17:19:06 tom Exp $")
+MODULE_ID("$Id: lib_win32util.c,v 1.7 2025/06/28 16:58:13 tom Exp $")
-#ifdef _NC_WINDOWS
-#include <io.h>
+#ifdef _NC_WINDOWS_NATIVE
#ifdef _NC_CHECK_MINTTY
#define PSAPI_VERSION 2
#include <psapi.h>
-#include <tchar.h>
#define array_length(a) (sizeof(a)/sizeof(a[0]))
@@ -131,4 +130,4 @@ _nc_gettimeofday(struct timeval *tv, void *tz GCC_UNUSED)
}
#endif // HAVE_GETTIMEOFDAY == 2
-#endif // _NC_WINDOWS
+#endif // _NC_WINDOWS_NATIVE
diff --git a/ncurses/tinfo/make_hash.c b/ncurses/tinfo/make_hash.c
index 78a684cc8bcb..c0fe93043847 100644
--- a/ncurses/tinfo/make_hash.c
+++ b/ncurses/tinfo/make_hash.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2024 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2009-2013,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -44,7 +44,7 @@
#include <ctype.h>
-MODULE_ID("$Id: make_hash.c,v 1.34 2024/03/02 19:35:40 tom Exp $")
+MODULE_ID("$Id: make_hash.c,v 1.37 2025/10/18 15:39:43 tom Exp $")
/*
* _nc_make_hash_table()
@@ -79,7 +79,7 @@ strmalloc(char *s)
{
size_t need = strlen(s) + 1;
char *result = malloc(need);
- if (result == 0)
+ if (result == NULL)
failed("strmalloc");
_nc_STRCPY(result, s, need);
return result;
@@ -153,7 +153,7 @@ static int
count_columns(char **list)
{
int result = 0;
- if (list != 0) {
+ if (list != NULL) {
while (*list++) {
++result;
}
@@ -168,17 +168,17 @@ parse_columns(char *buffer)
int col = 0;
- if (buffer == 0) {
+ if (buffer == NULL) {
free(list);
- list = 0;
- return 0;
+ list = NULL;
+ return NULL;
}
if (*buffer != '#') {
- if (list == 0) {
+ if (list == NULL) {
list = typeCalloc(char *, (MAX_COLUMNS + 1));
- if (list == 0)
- return (0);
+ if (list == NULL)
+ return (NULL);
}
while (*buffer != '\0') {
char *s;
@@ -205,7 +205,7 @@ parse_columns(char *buffer)
break;
}
}
- return col ? list : 0;
+ return col ? list : NULL;
}
#define SetType(n,t) \
@@ -247,9 +247,8 @@ int
main(int argc, char **argv)
{
unsigned tablesize = CAPTABSIZE;
- struct user_table_entry *name_table = typeCalloc(struct
- user_table_entry, tablesize);
- HashValue *hash_table = typeCalloc(HashValue, HASHTABSIZE);
+ struct user_table_entry *name_table;
+ HashValue *hash_table;
const char *root_name;
int column = 0;
int bigstring = 0;
@@ -264,6 +263,12 @@ main(int argc, char **argv)
short NumCount = 0;
short StrCount = 0;
+ if (argc == 2 && !strcmp(argv[1], "-?"))
+ return EXIT_SUCCESS;
+
+ name_table = typeCalloc(struct user_table_entry, tablesize);
+ hash_table = typeCalloc(HashValue, HASHTABSIZE);
+
/* The first argument is the column-number (starting with 0).
* The second is the root name of the tables to generate.
*/
@@ -272,8 +277,8 @@ main(int argc, char **argv)
|| (column >= MAX_COLUMNS)
|| *(root_name = argv[2]) == 0
|| (bigstring = atoi(argv[3])) < 0
- || name_table == 0
- || hash_table == 0) {
+ || name_table == NULL
+ || hash_table == NULL) {
fprintf(stderr, "usage: make_hash column root_name bigstring\n");
exit(EXIT_FAILURE);
}
@@ -291,7 +296,7 @@ main(int argc, char **argv)
else
buffer[sizeof(buffer) - 2] = '\0';
list = parse_columns(buffer);
- if (list == 0) /* blank or comment */
+ if (list == NULL) /* blank or comment */
continue;
if (is_user) {
if (strcmp(list[0], "userdef"))
@@ -382,15 +387,15 @@ main(int argc, char **argv)
printf("\t%d,%d,",
name_table[n].ute_argc,
name_table[n].ute_args);
- printf("\t%3d, %3d %s%c\n",
+ printf("\t%3d, %3d %s%s\n",
name_table[n].ute_index,
name_table[n].ute_link,
R_BRACE,
- n < tablesize - 1 ? ',' : ' ');
+ n < tablesize - 1 ? "," : "");
len += (int) strlen(name_table[n].ute_name) + 1;
}
printf("%s;\n\n", R_BRACE);
- printf("static struct %s_table_entry *_nc_%s_table = 0;\n\n",
+ printf("static struct %s_table_entry *_nc_%s_table = NULL;\n\n",
table_name,
root_name);
} else {
@@ -407,11 +412,11 @@ main(int argc, char **argv)
printf("\t%d,%d,",
name_table[n].ute_argc,
name_table[n].ute_args);
- printf("\t%3d, %3d %s%c\n",
+ printf("\t%3d, %3d %s%s\n",
name_table[n].ute_index,
name_table[n].ute_link,
R_BRACE,
- n < tablesize - 1 ? ',' : ' ');
+ n < tablesize - 1 ? "," : "");
}
printf("%s;\n\n", R_BRACE);
}
@@ -439,7 +444,7 @@ main(int argc, char **argv)
free((void *) name_table[n].ute_name);
}
free(name_table);
- parse_columns(0);
+ parse_columns(NULL);
return EXIT_SUCCESS;
}
diff --git a/ncurses/tinfo/make_keys.c b/ncurses/tinfo/make_keys.c
index b8eb934357a3..fa9e25b3c4a3 100644
--- a/ncurses/tinfo/make_keys.c
+++ b/ncurses/tinfo/make_keys.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2011,2015 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#define USE_TERMLIB 1
#include <build.priv.h>
-MODULE_ID("$Id: make_keys.c,v 1.23 2021/08/18 20:55:25 tom Exp $")
+MODULE_ID("$Id: make_keys.c,v 1.25 2025/10/18 15:41:07 tom Exp $")
#include <names.c>
@@ -51,10 +51,10 @@ unknown(void)
if (result == 0) {
unsigned n;
- for (n = 0; strnames[n] != 0; n++) {
+ for (n = 0; strnames[n] != NULL; n++) {
++result;
}
- for (n = 0; strfnames[n] != 0; n++) {
+ for (n = 0; strfnames[n] != NULL; n++) {
++result;
}
}
@@ -66,14 +66,14 @@ lookup(const char *name)
{
unsigned n;
bool found = FALSE;
- for (n = 0; strnames[n] != 0; n++) {
+ for (n = 0; strnames[n] != NULL; n++) {
if (!strcmp(name, strnames[n])) {
found = TRUE;
break;
}
}
if (!found) {
- for (n = 0; strfnames[n] != 0; n++) {
+ for (n = 0; strfnames[n] != NULL; n++) {
if (!strcmp(name, strfnames[n])) {
found = TRUE;
break;
@@ -93,7 +93,7 @@ make_keys(FILE *ifp, FILE *ofp)
unsigned maxlen = 16;
int scanned;
- while (fgets(buffer, (int) sizeof(buffer), ifp) != 0) {
+ while (fgets(buffer, (int) sizeof(buffer), ifp) != NULL) {
if (*buffer == '#')
continue;
@@ -119,7 +119,7 @@ make_keys(FILE *ifp, FILE *ofp)
static void
write_list(FILE *ofp, const char **list)
{
- while (*list != 0)
+ while (*list != NULL)
fprintf(ofp, "%s\n", *list++);
}
@@ -139,22 +139,25 @@ main(int argc, char *argv[])
"static",
"#endif",
"const struct tinfo_fkeys _nc_tinfo_fkeys[] = {",
- 0
+ NULL
};
static const char *suffix[] =
{
"\t{ 0, 0} };",
"",
"#endif /* _INIT_KEYTRY_H */",
- 0
+ NULL
};
+ if (argc == 2 && !strcmp(argv[1], "-?"))
+ return EXIT_SUCCESS;
+
write_list(stdout, prefix);
if (argc > 1) {
int n;
for (n = 1; n < argc; n++) {
FILE *fp = fopen(argv[n], "r");
- if (fp != 0) {
+ if (fp != NULL) {
make_keys(fp, stdout);
fclose(fp);
}
diff --git a/ncurses/tinfo/name_match.c b/ncurses/tinfo/name_match.c
index 71e584d779ce..8cdaac79db1d 100644
--- a/ncurses/tinfo/name_match.c
+++ b/ncurses/tinfo/name_match.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 1998-2013,2016 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: name_match.c,v 1.25 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: name_match.c,v 1.27 2025/01/12 00:41:56 tom Exp $")
#define FirstName _nc_globals.first_name
@@ -44,7 +44,7 @@ skip_index(const char *name)
{
if ((_nc_syntax == SYN_TERMCAP) && _nc_user_definable) {
const char *bar = strchr(name, '|');
- if (bar != 0 && (bar - name) == 2)
+ if (bar != NULL && (bar - name) == 2)
name = bar + 1;
}
return name;
@@ -60,17 +60,17 @@ NCURSES_EXPORT(char *)
_nc_first_name(const char *const sp)
{
#if NO_LEAKS
- if (sp == 0) {
- if (FirstName != 0) {
+ if (sp == NULL) {
+ if (FirstName != NULL) {
FreeAndNull(FirstName);
}
} else
#endif
{
- if (FirstName == 0)
+ if (FirstName == NULL)
FirstName = typeMalloc(char, MAX_NAME_SIZE + 1);
- if (FirstName != 0) {
+ if (FirstName != NULL) {
unsigned n;
const char *src = sp;
#if NCURSES_USE_TERMCAP && NCURSES_XNAMES
@@ -95,7 +95,7 @@ _nc_name_match(const char *const namelst, const char *const name, const char *co
{
const char *s;
- if ((s = namelst) != 0) {
+ if ((s = namelst) != NULL) {
while (*s != '\0') {
const char *d, *t;
int code, found;
diff --git a/ncurses/tinfo/obsolete.c b/ncurses/tinfo/obsolete.c
index cc62f18cb3f4..79660b0eab4c 100644
--- a/ncurses/tinfo/obsolete.c
+++ b/ncurses/tinfo/obsolete.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 2013-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: obsolete.c,v 1.11 2023/10/21 15:38:47 tom Exp $")
+MODULE_ID("$Id: obsolete.c,v 1.13 2025/02/20 01:12:11 tom Exp $")
/*
* Obsolete entrypoint retained for binary compatibility.
@@ -64,11 +64,11 @@ _nc_set_buffer(FILE *ofp, int buffered)
NCURSES_EXPORT(char *)
_nc_strdup(const char *s)
{
- char *result = 0;
- if (s != 0) {
+ char *result = NULL;
+ if (s != NULL) {
size_t need = strlen(s);
result = malloc(need + 1);
- if (result != 0) {
+ if (result != NULL) {
_nc_STRCPY(result, s, need);
}
}
@@ -126,7 +126,7 @@ _nc_conv_to_utf8(unsigned char *target, unsigned source, unsigned limit)
rc = 0;
}
- if (target != 0) {
+ if (target != NULL) {
switch (rc) {
case 1:
target[0] = CH(0);
@@ -225,7 +225,7 @@ _nc_conv_to_utf32(unsigned *target, const char *source, unsigned limit)
}
}
- if (target != 0) {
+ if (target != NULL) {
int shift = 0;
*target = 0;
for (j = 1; j < rc; j++) {
diff --git a/ncurses/tinfo/parse_entry.c b/ncurses/tinfo/parse_entry.c
index 13fef495aec9..85e95eec6268 100644
--- a/ncurses/tinfo/parse_entry.c
+++ b/ncurses/tinfo/parse_entry.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 *
@@ -48,7 +48,7 @@
#include <ctype.h>
#include <tic.h>
-MODULE_ID("$Id: parse_entry.c,v 1.108 2023/04/24 22:32:33 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.117 2025/11/23 20:25:15 tom Exp $")
#ifdef LINT
static short const parametrized[] =
@@ -204,7 +204,7 @@ expected_type(const char *name, int token_type, bool silent)
{
struct user_table_entry const *entry = _nc_find_user_entry(name);
bool result = TRUE;
- if ((entry != 0) && (token_type != CANCEL)) {
+ if ((entry != NULL) && (token_type != CANCEL)) {
int have_type = (1 << token_type);
if (!(entry->ute_type & have_type)) {
if (!silent)
@@ -332,7 +332,7 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
entryp->tterm.str_table = entryp->tterm.term_names = _nc_save_str(ptr);
- if (entryp->tterm.str_table == 0)
+ if (entryp->tterm.str_table == NULL)
returnDB(ERR);
DEBUG(2, ("Starting '%s'", ptr));
@@ -350,7 +350,7 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
_nc_set_type(name);
/* check for overly-long names and aliases */
- for (base = entryp->tterm.term_names; (ptr = strchr(base, '|')) != 0;
+ for (base = entryp->tterm.term_names; (ptr = strchr(base, '|')) != NULL;
base = ptr + 1) {
if (ptr - base > MAX_ALIAS) {
_nc_warning("%s `%.*s' may be too long",
@@ -379,10 +379,15 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
_nc_warning("invalid name for use-clause \"%s\"",
_nc_curr_token.tk_valstring);
continue;
- } else if (entryp->nuses >= MAX_USES) {
+ } else if (entryp->nuses >= HARD_MAX_USES) {
_nc_warning("too many use-clauses, ignored \"%s\"",
_nc_curr_token.tk_valstring);
continue;
+ } else if (entryp->nuses >= WARN_MAX_USES) {
+ _nc_warning("possibly too many use-clauses (%d vs %d), \"%s\"",
+ entryp->nuses,
+ WARN_MAX_USES,
+ _nc_curr_token.tk_valstring);
}
if ((saved = _nc_save_str(_nc_curr_token.tk_valstring)) != NULL) {
entryp->uses[entryp->nuses].name = saved;
@@ -395,7 +400,7 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
} else {
/* normal token lookup */
entry_ptr = _nc_find_entry(_nc_curr_token.tk_name,
- _nc_get_hash_table(_nc_syntax));
+ _nc_get_hash_table(_nc_syntax == SYN_TERMCAP));
/*
* Our kluge to handle aliasing. The reason it is done
@@ -459,7 +464,7 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
if (expected_type(_nc_curr_token.tk_name, token_type, silent)) {
if ((entry_ptr = _nc_extend_names(entryp,
_nc_curr_token.tk_name,
- token_type)) != 0) {
+ token_type)) != NULL) {
if (_nc_tracing >= DEBUG_LEVEL(1)) {
_nc_warning("extended capability '%s'",
_nc_curr_token.tk_name);
@@ -487,8 +492,8 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
*/
if (!strcmp("ma", _nc_curr_token.tk_name)) {
entry_ptr = _nc_find_type_entry("ma", NUMBER,
- _nc_syntax != 0);
- assert(entry_ptr != 0);
+ _nc_syntax != SYN_TERMINFO);
+ assert(entry_ptr != NULL);
}
} else if (entry_ptr->nte_type != token_type) {
/*
@@ -505,15 +510,15 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
&& !strcmp("ma", _nc_curr_token.tk_name)) {
/* tell max_attributes from arrow_key_map */
entry_ptr = _nc_find_type_entry("ma", NUMBER,
- _nc_syntax != 0);
- assert(entry_ptr != 0);
+ _nc_syntax != SYN_TERMINFO);
+ assert(entry_ptr != NULL);
} else if (token_type == STRING
&& !strcmp("MT", _nc_curr_token.tk_name)) {
/* map terminfo's string MT to MT */
entry_ptr = _nc_find_type_entry("MT", STRING,
- _nc_syntax != 0);
- assert(entry_ptr != 0);
+ _nc_syntax != SYN_TERMINFO);
+ assert(entry_ptr != NULL);
} else if (token_type == BOOLEAN
&& entry_ptr->nte_type == STRING) {
@@ -549,7 +554,8 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
case CANCEL:
switch (entry_ptr->nte_type) {
case BOOLEAN:
- entryp->tterm.Booleans[entry_ptr->nte_index] = CANCELLED_BOOLEAN;
+ entryp->tterm.Booleans[entry_ptr->nte_index] =
+ (NCURSES_SBOOL) CANCELLED_BOOLEAN;
break;
case NUMBER:
@@ -629,7 +635,7 @@ _nc_parse_entry(ENTRY * entryp, int literal, bool silent)
* have picked up defaults via translation.
*/
for (i = 0; i < entryp->nuses; i++) {
- if (entryp->uses[i].name != 0
+ if (entryp->uses[i].name != NULL
&& !strchr(entryp->uses[i].name, '+'))
has_base_entry = TRUE;
}
@@ -695,9 +701,9 @@ _nc_capcmp(const char *s, const char *t)
}
static void
-append_acs0(string_desc * dst, int code, char *src, size_t off)
+append_acs0(string_desc * dst, int code, const char *src, size_t off)
{
- if (src != 0 && off < strlen(src)) {
+ if (src != NULL && off < strlen(src)) {
char temp[3];
temp[0] = (char) code;
temp[1] = src[off];
@@ -707,7 +713,7 @@ append_acs0(string_desc * dst, int code, char *src, size_t off)
}
static void
-append_acs(string_desc * dst, int code, char *src)
+append_acs(string_desc * dst, int code, const char *src)
{
if (VALID_STRING(src) && strlen(src) == 1) {
append_acs0(dst, code, src, 0);
@@ -929,15 +935,15 @@ postprocess_termcap(TERMTYPE2 *tp, bool has_base)
/* we're going to use this for a special case later */
dp = strchr(other_non_function_keys, 'i');
- foundim = (dp != 0) && (dp[1] == 'm');
+ foundim = (dp != NULL) && (dp[1] == 'm');
/* look at each comma-separated capability in the ko string... */
for (base = other_non_function_keys;
- (cp = strchr(base, ',')) != 0;
+ (cp = strchr(base, ',')) != NULL;
base = cp + 1) {
size_t len = (unsigned) (cp - base);
size_t n;
- assoc const *ap = 0;
+ assoc const *ap = NULL;
for (n = 0; n < SIZEOF(ko_xlate); ++n) {
if (len == strlen(ko_xlate[n].from)
@@ -946,7 +952,7 @@ postprocess_termcap(TERMTYPE2 *tp, bool has_base)
break;
}
}
- if (ap == 0) {
+ if (ap == NULL) {
_nc_warning("unknown capability `%.*s' in ko string",
(int) len, base);
continue;
@@ -985,6 +991,8 @@ postprocess_termcap(TERMTYPE2 *tp, bool has_base)
bp = tp->Strings[from_ptr->nte_index];
if (VALID_STRING(bp)) {
for (dp = buf2; *bp; bp++) {
+ if ((size_t) (dp - buf2) >= (sizeof(buf2) - sizeof(TERMTYPE2)))
+ break;
if (bp[0] == '$' && bp[1] == '<') {
while (*bp && *bp != '>') {
++bp;
@@ -1143,7 +1151,7 @@ lookup_fullname(const char *find)
return NOTFOUND;
}
- for (count = 0; names[count] != 0; count++) {
+ for (count = 0; names[count] != NULL; count++) {
if (!strcmp(names[count], find)) {
struct name_table_entry const *entry_ptr = _nc_get_table(FALSE);
while (entry_ptr->nte_type != state
diff --git a/ncurses/tinfo/read_entry.c b/ncurses/tinfo/read_entry.c
index b0f360eca800..fd5f77168aa4 100644
--- a/ncurses/tinfo/read_entry.c
+++ b/ncurses/tinfo/read_entry.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 *
@@ -42,7 +42,7 @@
#include <tic.h>
-MODULE_ID("$Id: read_entry.c,v 1.171 2023/09/16 16:30:34 tom Exp $")
+MODULE_ID("$Id: read_entry.c,v 1.175 2025/01/11 23:52:18 tom Exp $")
#define MyNumber(n) (short) LOW_MSB(n)
@@ -51,7 +51,7 @@ MODULE_ID("$Id: read_entry.c,v 1.171 2023/09/16 16:30:34 tom Exp $")
#if NCURSES_USE_DATABASE
#if NCURSES_EXT_NUMBERS
static size_t
-convert_16bits(char *buf, NCURSES_INT2 *Numbers, int count)
+convert_16bits(const char *buf, NCURSES_INT2 *Numbers, int count)
{
int i;
size_t j;
@@ -77,7 +77,7 @@ convert_16bits(char *buf, NCURSES_INT2 *Numbers, int count)
}
static size_t
-convert_32bits(char *buf, NCURSES_INT2 *Numbers, int count)
+convert_32bits(const char *buf, NCURSES_INT2 *Numbers, int count)
{
int i;
size_t j;
@@ -98,7 +98,7 @@ convert_32bits(char *buf, NCURSES_INT2 *Numbers, int count)
}
#else
static size_t
-convert_32bits(char *buf, NCURSES_INT2 *Numbers, int count)
+convert_32bits(const char *buf, NCURSES_INT2 *Numbers, int count)
{
int i, j;
unsigned char ch;
@@ -122,7 +122,7 @@ convert_32bits(char *buf, NCURSES_INT2 *Numbers, int count)
}
static size_t
-convert_16bits(char *buf, NCURSES_INT2 *Numbers, int count)
+convert_16bits(const char *buf, NCURSES_INT2 *Numbers, int count)
{
int i;
for (i = 0; i < count; i++) {
@@ -195,7 +195,7 @@ convert_strings(char *buf, char **Strings, int count, int size,
}
static int
-fake_read(char *src, int *offset, int limit, char *dst, unsigned want)
+fake_read(const char *src, int *offset, int limit, char *dst, unsigned want)
{
int have = (limit - *offset);
@@ -237,11 +237,11 @@ _nc_init_termtype(TERMTYPE2 *const tp)
tp->ext_Numbers = 0;
tp->ext_Strings = 0;
#endif
- if (tp->Booleans == 0)
+ if (tp->Booleans == NULL)
TYPE_MALLOC(NCURSES_SBOOL, BOOLCOUNT, tp->Booleans);
- if (tp->Numbers == 0)
+ if (tp->Numbers == NULL)
TYPE_MALLOC(NCURSES_INT2, NUMCOUNT, tp->Numbers);
- if (tp->Strings == 0)
+ if (tp->Strings == NULL)
TYPE_MALLOC(char *, STRCOUNT, tp->Strings);
for_each_boolean(i, tp)
@@ -285,7 +285,7 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
char buf[MAX_ENTRY_SIZE + 2];
char *string_table;
unsigned want, have;
- size_t (*convert_numbers) (char *, NCURSES_INT2 *, int);
+ size_t (*convert_numbers) (const char *, NCURSES_INT2 *, int);
int size_of_numbers;
int max_entry_size = MAX_ENTRY_SIZE;
@@ -346,7 +346,7 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
want = (unsigned) (str_size + name_size + 1);
/* try to allocate space for the string table */
if (str_count * SIZEOF_SHORT >= max_entry_size
- || (string_table = typeMalloc(char, want)) == 0) {
+ || (string_table = typeMalloc(char, want)) == NULL) {
returnDB(TGETENT_NO);
}
@@ -483,7 +483,7 @@ _nc_read_termtype(TERMTYPE2 *ptr, char *buffer, int limit)
if (ext_str_limit) {
ptr->ext_str_table = typeMalloc(char, (size_t) ext_str_limit);
- if (ptr->ext_str_table == 0) {
+ if (ptr->ext_str_table == NULL) {
returnDB(TGETENT_NO);
}
if (Read(ptr->ext_str_table, (unsigned) ext_str_limit) != ext_str_limit) {
@@ -582,11 +582,11 @@ NCURSES_EXPORT(int)
_nc_read_file_entry(const char *const filename, TERMTYPE2 *ptr)
/* return 1 if read, 0 if not found or garbled */
{
- FILE *fp = 0;
+ FILE *fp = NULL;
int code;
if (_nc_access(filename, R_OK) < 0
- || (fp = safe_fopen(filename, BIN_R)) == 0) {
+ || (fp = safe_fopen(filename, BIN_R)) == NULL) {
TR(TRACE_DATABASE, ("cannot open terminfo %s (errno=%d)", filename, errno));
code = TGETENT_NO;
} else {
@@ -728,7 +728,7 @@ decode_hex(const char **source)
static int
decode_quickdump(char *target, const char *source)
{
- char *base = target;
+ const char *base = target;
int result = 0;
if (!strncmp(source, "b64:", (size_t) 4)) {
@@ -797,13 +797,13 @@ _nc_read_tic_entry(char *filename,
} else
#if USE_HASHED_DB
if (make_db_filename(filename, limit, path)
- && (capdbp = _nc_db_open(filename, FALSE)) != 0) {
+ && (capdbp = _nc_db_open(filename, FALSE)) != NULL) {
DBT key, data;
int reccnt = 0;
char *save = strdup(name);
- if (save == 0)
+ if (save == NULL)
returnDB(code);
memset(&key, 0, sizeof(key));
@@ -881,7 +881,7 @@ _nc_read_entry2(const char *const name, char *const filename, TERMTYPE2 *const t
{
int code = TGETENT_NO;
- if (name == 0)
+ if (name == NULL)
return _nc_read_entry2("", filename, tp);
_nc_SPRINTF(filename, _nc_SLIMIT(PATH_MAX)
@@ -891,7 +891,7 @@ _nc_read_entry2(const char *const name, char *const filename, TERMTYPE2 *const t
|| strcmp(name, ".") == 0
|| strcmp(name, "..") == 0
|| _nc_pathlast(name) != 0
- || strchr(name, NCURSES_PATHSEP) != 0) {
+ || strchr(name, NCURSES_PATHSEP) != NULL) {
TR(TRACE_DATABASE, ("illegal or missing entry name '%s'", name));
} else {
#if NCURSES_USE_DATABASE
@@ -901,7 +901,7 @@ _nc_read_entry2(const char *const name, char *const filename, TERMTYPE2 *const t
_nc_first_db(&state, &offset);
code = TGETENT_ERR;
- while ((path = _nc_next_db(&state, &offset)) != 0) {
+ while ((path = _nc_next_db(&state, &offset)) != NULL) {
code = _nc_read_tic_entry(filename, PATH_MAX, path, name, tp);
if (code == TGETENT_YES) {
_nc_last_db();
diff --git a/ncurses/tinfo/read_termcap.c b/ncurses/tinfo/read_termcap.c
index 1a294848b827..e9a0faadffcf 100644
--- a/ncurses/tinfo/read_termcap.c
+++ b/ncurses/tinfo/read_termcap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2021,2023 Thomas E. Dickey *
+ * Copyright 2018-2023,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,7 +57,7 @@
#include <sys/types.h>
#include <tic.h>
-MODULE_ID("$Id: read_termcap.c,v 1.104 2023/06/24 21:53:16 tom Exp $")
+MODULE_ID("$Id: read_termcap.c,v 1.107 2025/12/25 18:20:22 tom Exp $")
#if !PURE_TERMINFO
@@ -72,7 +72,7 @@ get_termpath(void)
{
const char *result;
- if (!use_terminfo_vars() || (result = getenv("TERMPATH")) == 0)
+ if (!use_terminfo_vars() || (result = getenv("TERMPATH")) == NULL)
result = TERMPATH;
TR(TRACE_DATABASE, ("TERMPATH is %s", result));
return result;
@@ -275,7 +275,7 @@ _nc_getent(
{
register char *r_end, *rp;
int myfd = FALSE;
- char *record = 0;
+ char *record = NULL;
int tc_not_resolved;
int current;
int lineno;
@@ -291,7 +291,7 @@ _nc_getent(
* Check if we have a top record from cgetset().
*/
if (depth == 0 && toprec != 0 && _nc_cgetmatch(toprec, name) == 0) {
- if ((record = DOALLOC(topreclen + BFRAG)) == 0) {
+ if ((record = DOALLOC(topreclen + BFRAG)) == NULL) {
errno = ENOMEM;
return (TC_SYS_ERR);
}
@@ -305,7 +305,7 @@ _nc_getent(
/*
* Allocate first chunk of memory.
*/
- if ((record = DOALLOC(BFRAG)) == 0) {
+ if ((record = DOALLOC(BFRAG)) == NULL) {
errno = ENOMEM;
return (TC_SYS_ERR);
}
@@ -315,7 +315,7 @@ _nc_getent(
/*
* Loop through database array until finding the record.
*/
- for (current = in_array; db_array[current] != 0; current++) {
+ for (current = in_array; db_array[current] != NULL; current++) {
int eof = FALSE;
/*
@@ -408,7 +408,7 @@ _nc_getent(
pos = (unsigned) (rp - record);
newsize = (size_t) (r_end - record + BFRAG);
record = DOALLOC(newsize);
- if (record == 0) {
+ if (record == NULL) {
if (myfd)
(void) close(fd);
errno = ENOMEM;
@@ -464,7 +464,7 @@ _nc_getent(
register int newilen;
unsigned ilen;
int diff, iret, tclen, oline;
- char *icap = 0, *scan, *tc, *tcstart, *tcend;
+ char *icap = NULL, *scan, *tc, *tcstart, *tcend;
/*
* Loop invariants:
@@ -477,7 +477,7 @@ _nc_getent(
scan = record;
tc_not_resolved = FALSE;
for (;;) {
- if ((tc = _nc_cgetcap(scan, "tc", '=')) == 0) {
+ if ((tc = _nc_cgetcap(scan, "tc", '=')) == NULL) {
break;
}
@@ -548,7 +548,7 @@ _nc_getent(
tcpos = (unsigned) (tcstart - record);
tcposend = (unsigned) (tcend - record);
record = DOALLOC(newsize);
- if (record == 0) {
+ if (record == NULL) {
if (myfd)
(void) close(fd);
free(icap);
@@ -586,7 +586,7 @@ _nc_getent(
(void) close(fd);
*len = (unsigned) (rp - record - 1); /* don't count NUL */
if (r_end > rp) {
- if ((record = DOALLOC((size_t) (rp - record))) == 0) {
+ if ((record = DOALLOC((size_t) (rp - record))) == NULL) {
errno = ENOMEM;
return (TC_SYS_ERR);
}
@@ -720,7 +720,7 @@ get_tc_token(char **srcp, int *endp)
int ch;
bool found = FALSE;
char *s, *base;
- char *tok = 0;
+ char *tok = NULL;
*endp = TRUE;
for (s = base = *srcp; *s != '\0';) {
@@ -749,7 +749,7 @@ get_tc_token(char **srcp, int *endp)
}
/* malformed entry may end without a ':' */
- if (tok == 0 && found) {
+ if (tok == NULL && found) {
tok = base;
}
@@ -768,7 +768,7 @@ copy_tc_token(char *dst, const char *src, size_t len)
continue;
}
if (--len == 0) {
- dst = 0;
+ dst = NULL;
break;
}
*dst++ = (char) ch;
@@ -813,13 +813,13 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
if (cp == NULL) {
_nc_safe_strcpy(&desc, get_termpath());
} else if (!_nc_is_abs_path(cp)) { /* TERMCAP holds an entry */
- if ((termpath = get_termpath()) != 0) {
+ if ((termpath = get_termpath()) != NULL) {
_nc_safe_strcat(&desc, termpath);
} else {
char temp[PBUFSIZ];
temp[0] = 0;
- if ((home = getenv("HOME")) != 0 && *home != '\0'
- && strchr(home, ' ') == 0
+ if ((home = getenv("HOME")) != NULL && *home != '\0'
+ && strchr(home, ' ') == NULL
&& strlen(home) < sizeof(temp) - 10) { /* setup path */
_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
"%s/", home); /* $HOME first */
@@ -850,7 +850,7 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
}
}
}
- *fname = 0; /* mark end of vector */
+ *fname = NULL; /* mark end of vector */
#if !HAVE_BSD_CGETENT
(void) _nc_cgetset(0);
#endif
@@ -875,7 +875,7 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
pd = bp;
ps = dummy;
- while (!endflag && (tok = get_tc_token(&ps, &endflag)) != 0) {
+ while (!endflag && (tok = get_tc_token(&ps, &endflag)) != NULL) {
bool ignore = FALSE;
for (n = 1; n < count; n++) {
@@ -889,7 +889,7 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
if (ignore != TRUE) {
list[count++] = tok;
pd = copy_tc_token(pd, tok, (size_t) (TBUFSIZ - (2 + pd - bp)));
- if (pd == 0) {
+ if (pd == NULL) {
i = -1;
break;
}
@@ -901,7 +901,7 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
FreeIfNeeded(dummy);
FreeIfNeeded(the_source);
- the_source = 0;
+ the_source = NULL;
/* This is not related to the BSD cgetent(), but to fake up a suitable
* filename for ncurses' error reporting. (If we are not using BSD
@@ -917,10 +917,10 @@ _nc_tgetent(char *bp, char **sourcename, int *lineno, const char *name)
if (_nc_access(temp, R_OK) == 0) {
_nc_safe_strcpy(&desc, pathvec[i]);
}
- if ((the_source = strdup(temp)) != 0)
+ if ((the_source = strdup(temp)) != NULL)
*sourcename = the_source;
#else
- if ((the_source = strdup(pathvec[i])) != 0)
+ if ((the_source = strdup(pathvec[i])) != NULL)
*sourcename = the_source;
#endif
}
@@ -941,7 +941,7 @@ static int
add_tc(char *termpaths[], char *path, int count)
{
char *save = strchr(path, NCURSES_PATHSEP);
- if (save != 0)
+ if (save != NULL)
*save = '\0';
if (count < MAXPATHS
&& _nc_access(path, R_OK) == 0) {
@@ -949,7 +949,7 @@ add_tc(char *termpaths[], char *path, int count)
TR(TRACE_DATABASE, ("Adding termpath %s", path));
}
termpaths[count] = 0;
- if (save != 0)
+ if (save != NULL)
*save = NCURSES_PATHSEP;
return count;
}
@@ -966,7 +966,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
#endif
#if USE_GETCAP
char *p, tc[TBUFSIZ];
- char *tc_buf = 0;
+ char *tc_buf = NULL;
#define MY_SIZE sizeof(tc) - 1
int status;
static char *source;
@@ -982,7 +982,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
return TGETENT_NO;
}
- if (use_terminfo_vars() && (p = getenv("TERMCAP")) != 0
+ if (use_terminfo_vars() && (p = getenv("TERMCAP")) != NULL
&& !_nc_is_abs_path(p) && _nc_name_match(p, tn, "|:")) {
/* TERMCAP holds a termcap entry */
tc_buf = strdup(p);
@@ -996,7 +996,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
_nc_set_source(source);
tc_buf = tc;
}
- if (tc_buf == 0)
+ if (tc_buf == NULL)
return (TGETENT_ERR);
_nc_read_entry_source((FILE *) 0, tc_buf, FALSE, TRUE, NULLHOOK);
if (tc_buf != tc)
@@ -1034,20 +1034,20 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
int j, k;
bool use_buffer = FALSE;
bool normal = TRUE;
- char *tc_buf = 0;
+ char *tc_buf = NULL;
char pathbuf[PATH_MAX];
- char *copied = 0;
+ char *copied = NULL;
char *cp;
struct stat test_stat[MAXPATHS];
- termpaths[filecount] = 0;
- if (use_terminfo_vars() && (tc = getenv("TERMCAP")) != 0) {
+ termpaths[filecount] = NULL;
+ if (use_terminfo_vars() && (tc = getenv("TERMCAP")) != NULL) {
if (_nc_is_abs_path(tc)) { /* interpret as a filename */
ADD_TC(tc, 0);
normal = FALSE;
} else if (_nc_name_match(tc, tn, "|:")) { /* treat as a capability file */
tc_buf = strdup(tc);
- use_buffer = (tc_buf != 0);
+ use_buffer = (tc_buf != NULL);
normal = FALSE;
}
}
@@ -1055,7 +1055,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
if (normal) { /* normal case */
char envhome[PATH_MAX], *h;
- if ((copied = strdup(get_termpath())) != 0) {
+ if ((copied = strdup(get_termpath())) != NULL) {
for (cp = copied; *cp; cp++) {
if (*cp == NCURSES_PATHSEP)
*cp = '\0';
@@ -1085,7 +1085,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
#if HAVE_LINK
for (j = 0; j < filecount; j++) {
bool omit = FALSE;
- if (stat(termpaths[j], &test_stat[j]) != 0
+ if (!_nc_is_path_found(termpaths[j], &test_stat[j])
|| !S_ISREG(test_stat[j].st_mode)) {
omit = TRUE;
} else {
@@ -1140,11 +1140,11 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
}
}
}
- if (copied != 0)
+ if (copied != NULL)
free(copied);
#endif /* USE_GETCAP */
- if (_nc_head == 0)
+ if (_nc_head == NULL)
return (TGETENT_ERR);
/* resolve all use references */
@@ -1153,7 +1153,7 @@ _nc_read_termcap_entry(const char *const tn, TERMTYPE2 *const tp)
/* find a terminal matching tn, if we can */
#if USE_GETCAP_CACHE
- if (getcwd(cwd_buf, sizeof(cwd_buf)) != 0) {
+ if (getcwd(cwd_buf, sizeof(cwd_buf)) != NULL) {
_nc_set_writedir((char *) 0); /* note: this does a chdir */
#endif
for_entry_list(ep) {
diff --git a/ncurses/tinfo/strings.c b/ncurses/tinfo/strings.c
index 03f59c24e9ad..7ae15e84cc97 100644
--- a/ncurses/tinfo/strings.c
+++ b/ncurses/tinfo/strings.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 2000-2012,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -38,7 +38,7 @@
#include <curses.priv.h>
#include <tic.h>
-MODULE_ID("$Id: strings.c,v 1.11 2023/05/27 20:13:10 tom Exp $")
+MODULE_ID("$Id: strings.c,v 1.12 2024/12/07 21:24:18 tom Exp $")
/****************************************************************************
* Useful string functions (especially for mvcur)
@@ -71,12 +71,12 @@ _nc_strstr(const char *haystack, const char *needle)
NCURSES_EXPORT(string_desc *)
_nc_str_init(string_desc * dst, char *src, size_t len)
{
- if (dst != 0) {
+ if (dst != NULL) {
dst->s_head = src;
dst->s_tail = src;
dst->s_size = len - 1;
dst->s_init = dst->s_size;
- if (src != 0)
+ if (src != NULL)
*src = 0;
}
return dst;
@@ -88,7 +88,7 @@ _nc_str_init(string_desc * dst, char *src, size_t len)
NCURSES_EXPORT(string_desc *)
_nc_str_null(string_desc * dst, size_t len)
{
- return _nc_str_init(dst, 0, len);
+ return _nc_str_init(dst, NULL, len);
}
/*
@@ -111,7 +111,7 @@ _nc_safe_strcat(string_desc * dst, const char *src)
size_t len = strlen(src);
if (len < dst->s_size) {
- if (dst->s_tail != 0) {
+ if (dst->s_tail != NULL) {
_nc_STRCPY(dst->s_tail, src, dst->s_size);
dst->s_tail += len;
}
@@ -132,7 +132,7 @@ _nc_safe_strcpy(string_desc * dst, const char *src)
size_t len = strlen(src);
if (len < dst->s_size) {
- if (dst->s_head != 0) {
+ if (dst->s_head != NULL) {
_nc_STRCPY(dst->s_head, src, dst->s_size);
dst->s_tail = dst->s_head + len;
}
diff --git a/ncurses/tinfo/tinfo_driver.c b/ncurses/tinfo/tinfo_driver.c
index fd993b820381..ad3fc3f21983 100644
--- a/ncurses/tinfo/tinfo_driver.c
+++ b/ncurses/tinfo/tinfo_driver.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2008-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -52,7 +52,7 @@
# endif
#endif
-MODULE_ID("$Id: tinfo_driver.c,v 1.74 2023/09/16 10:44:33 tom Exp $")
+MODULE_ID("$Id: tinfo_driver.c,v 1.88 2025/12/27 12:33:34 tom Exp $")
/*
* SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS,
@@ -94,8 +94,8 @@ NCURSES_EXPORT_VAR(int) COLORS = 0;
#endif
#define TCBMAGIC NCDRV_MAGIC(NCDRV_TINFO)
-#define AssertTCB() assert(TCB!=0 && TCB->magic==TCBMAGIC)
-#define SetSP() assert(TCB->csp!=0); sp = TCB->csp; (void) sp
+#define AssertTCB() assert(TCB != NULL && TCB->magic == TCBMAGIC)
+#define SetSP() assert(TCB->csp != NULL); sp = TCB->csp; (void) sp
/*
* This routine needs to do all the work to make curscr look
@@ -123,7 +123,7 @@ get_baudrate(TERMINAL *termp)
if (GET_TTY(termp->Filedes, &termp->Nttyb) == OK) {
#ifdef TERMIOS
termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS);
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
/* noop */
#else
termp->Nttyb.sg_flags &= (unsigned) (~XTABS);
@@ -135,7 +135,7 @@ get_baudrate(TERMINAL *termp)
#else /* !USE_OLD_TTY */
#ifdef TERMIOS
my_ospeed = (NCURSES_OSPEED) cfgetospeed(&(termp->Nttyb));
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
/* noop */
my_ospeed = 0;
#else
@@ -161,9 +161,10 @@ drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret)
SCREEN *sp;
START_TRACE();
- T((T_CALLED("tinfo::drv_CanHandle(%p)"), (void *) TCB));
+ T((T_CALLED("tinfo::drv_CanHandle(%p,%s,%p)"),
+ (void *) TCB, NonNull(tname), (void *) errret));
- assert(TCB != 0 && tname != 0);
+ assert(TCB != NULL && tname != NULL);
termp = (TERMINAL *) TCB;
sp = TCB->csp;
TCB->magic = TCBMAGIC;
@@ -215,7 +216,7 @@ drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret)
* _nc_setupscreen(). Do it now anyway, so we can initialize the
* baudrate.
*/
- if (sp == 0 && NC_ISATTY(termp->Filedes)) {
+ if (sp == NULL && NC_ISATTY(termp->Filedes)) {
get_baudrate(termp);
}
#if NCURSES_EXT_NUMBERS
@@ -323,15 +324,15 @@ drv_defaultcolors(TERMINAL_CONTROL_BLOCK * TCB, int fg, int bg)
AssertTCB();
SetSP();
- if (sp != 0 && orig_pair && orig_colors && (initialize_pair != 0)) {
+ if (sp != NULL && orig_pair && orig_colors && (initialize_pair != NULL)) {
#if NCURSES_EXT_FUNCS
sp->_default_color = isDefaultColor(fg) || isDefaultColor(bg);
sp->_has_sgr_39_49 = (NCURSES_SP_NAME(tigetflag) (NCURSES_SP_ARGx
- "AX")
+ UserCap(AX))
== TRUE);
sp->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : fg;
sp->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : bg;
- if (sp->_color_pairs != 0) {
+ if (sp->_color_pairs != NULL) {
bool save = sp->_default_color;
sp->_default_color = TRUE;
NCURSES_SP_NAME(init_pair) (NCURSES_SP_ARGx
@@ -391,7 +392,7 @@ drv_rescol(TERMINAL_CONTROL_BLOCK * TCB)
AssertTCB();
SetSP();
- if (orig_pair != 0) {
+ if (orig_pair != NULL) {
NCURSES_PUTP2("orig_pair", orig_pair);
result = TRUE;
}
@@ -407,7 +408,7 @@ drv_rescolors(TERMINAL_CONTROL_BLOCK * TCB)
AssertTCB();
SetSP();
- if (orig_colors != 0) {
+ if (orig_colors != NULL) {
NCURSES_PUTP2("orig_colors", orig_colors);
result = TRUE;
}
@@ -432,7 +433,7 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp)
useTioctl = _nc_prescreen.use_tioctl;
}
-#ifdef EXP_WIN32_DRIVER
+#ifdef USE_WIN32CON_DRIVER
/* If we are here, then Windows console is used in terminfo mode.
We need to figure out the size using the console API
*/
@@ -470,7 +471,7 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp)
errno = 0;
do {
if (ioctl(termp->Filedes, IOCTL_WINSIZE, &size) >= 0) {
- *linep = ((sp != 0 && sp->_filtered)
+ *linep = ((sp != NULL && sp->_filtered)
? 1
: WINSIZE_ROWS(size));
*colp = WINSIZE_COLS(size);
@@ -489,7 +490,8 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp)
/*
* If environment variables are used, update them.
*/
- if ((sp == 0 || !sp->_filtered) && _nc_getenv_num("LINES") > 0) {
+ if ((sp == NULL || !sp->_filtered)
+ && _nc_getenv_num("LINES") > 0) {
_nc_setenv_num("LINES", *linep);
}
if (_nc_getenv_num("COLUMNS") > 0) {
@@ -504,11 +506,11 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp)
* variable.
*/
if ((value = _nc_getenv_num("LINES")) > 0) {
- *linep = value;
+ *linep = Min(value, MAX_ENV_LINES);
T(("screen size: environment LINES = %d", *linep));
}
if ((value = _nc_getenv_num("COLUMNS")) > 0) {
- *colp = value;
+ *colp = Min(value, MAX_ENV_COLUMNS);
T(("screen size: environment COLUMNS = %d", *colp));
}
}
@@ -545,7 +547,7 @@ static int
drv_getsize(TERMINAL_CONTROL_BLOCK * TCB, int *l, int *c)
{
AssertTCB();
- assert(l != 0 && c != 0);
+ assert(l != NULL && c != NULL);
*l = lines;
*c = columns;
return OK;
@@ -604,6 +606,8 @@ drv_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag)
AssertTCB();
sp = TCB->csp;
+ T((T_CALLED("tinfo:drv_mode(%p,%d,%d)"), (void *) sp, progFlag, defFlag));
+
if (progFlag) /* prog mode */
{
if (defFlag) {
@@ -614,7 +618,7 @@ drv_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag)
if ((drv_sgmode(TCB, FALSE, &(_term->Nttyb)) == OK)) {
#ifdef TERMIOS
_term->Nttyb.c_oflag &= (unsigned) ~OFLAGS_TABS;
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
/* noop */
#else
_term->Nttyb.sg_flags &= (unsigned) ~XTABS;
@@ -628,6 +632,10 @@ drv_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag)
if (sp->_keypad_on)
_nc_keypad(sp, TRUE);
}
+#if defined(USE_WIN32CON_DRIVER)
+ if (!WINCONSOLE.buffered)
+ _nc_console_set_scrollback(FALSE, &WINCONSOLE.SBI);
+#endif
code = OK;
}
}
@@ -641,7 +649,7 @@ drv_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag)
#ifdef TERMIOS
if (_term->Ottyb.c_oflag & OFLAGS_TABS)
tab = back_tab = NULL;
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
/* noop */
#else
if (_term->Ottyb.sg_flags & XTABS)
@@ -656,9 +664,13 @@ drv_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag)
NCURSES_SP_NAME(_nc_flush) (sp);
}
code = drv_sgmode(TCB, TRUE, &(_term->Ottyb));
+#if defined(USE_WIN32CON_DRIVER)
+ if (!_nc_console_restore())
+ code = ERR;
+#endif
}
}
- return (code);
+ returnCode(code);
}
static void
@@ -676,7 +688,7 @@ drv_release(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED)
{
}
-# 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))
static void
drv_screen_init(SCREEN *sp)
@@ -791,7 +803,7 @@ static int
default_fg(SCREEN *sp)
{
#if NCURSES_EXT_FUNCS
- return (sp != 0) ? sp->_default_fg : COLOR_WHITE;
+ return (sp != NULL) ? sp->_default_fg : COLOR_WHITE;
#else
return COLOR_WHITE;
#endif
@@ -801,7 +813,7 @@ static int
default_bg(SCREEN *sp)
{
#if NCURSES_EXT_FUNCS
- return sp != 0 ? sp->_default_bg : COLOR_BLACK;
+ return sp != NULL ? sp->_default_bg : COLOR_BLACK;
#else
return COLOR_BLACK;
#endif
@@ -833,7 +845,7 @@ drv_do_color(TERMINAL_CONTROL_BLOCK * TCB,
int old_fg, old_bg;
AssertTCB();
- if (sp == 0)
+ if (sp == NULL)
return;
if (pair < 0 || pair >= COLOR_PAIRS) {
@@ -844,13 +856,13 @@ drv_do_color(TERMINAL_CONTROL_BLOCK * TCB,
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
TIPARM_1(set_color_pair, pair), 1, outc);
return;
- } else if (sp != 0) {
+ } else if (sp != NULL) {
_nc_pair_content(SP_PARM, pair, &fg, &bg);
}
}
if (old_pair >= 0
- && sp != 0
+ && sp != NULL
&& _nc_pair_content(SP_PARM, old_pair, &old_fg, &old_bg) != ERR) {
if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
|| (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
@@ -907,7 +919,7 @@ static void
init_xterm_mouse(SCREEN *sp)
{
sp->_mouse_type = M_XTERM;
- sp->_mouse_xtermcap = NCURSES_SP_NAME(tigetstr) (NCURSES_SP_ARGx "XM");
+ sp->_mouse_xtermcap = NCURSES_SP_NAME(tigetstr) (NCURSES_SP_ARGx UserCap(XM));
if (!VALID_STRING(sp->_mouse_xtermcap))
sp->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
}
@@ -921,10 +933,10 @@ drv_initmouse(TERMINAL_CONTROL_BLOCK * TCB)
SetSP();
/* we know how to recognize mouse events under "xterm" */
- if (sp != 0) {
+ if (sp != NULL) {
if (NonEmpty(key_mouse)) {
init_xterm_mouse(sp);
- } else if (strstr(SP_TERMTYPE term_names, "xterm") != 0) {
+ } else if (strstr(SP_TERMTYPE term_names, "xterm") != NULL) {
if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK)
init_xterm_mouse(sp);
}
@@ -949,7 +961,7 @@ drv_testmouse(TERMINAL_CONTROL_BLOCK * TCB,
} else
#endif
{
-#ifdef EXP_WIN32_DRIVER
+#if defined(USE_WIN32CON_DRIVER)
rc = _nc_console_testmouse(sp,
_nc_console_handle(sp->_ifd),
delay
@@ -1076,7 +1088,7 @@ drv_initacs(TERMINAL_CONTROL_BLOCK * TCB, chtype *real_map, chtype *fake_map)
SCREEN *sp = TCB->csp;
AssertTCB();
- assert(sp != 0);
+ assert(sp != NULL);
if (ena_acs != NULL) {
NCURSES_PUTP2("ena_acs", ena_acs);
}
@@ -1091,7 +1103,7 @@ drv_initacs(TERMINAL_CONTROL_BLOCK * TCB, chtype *real_map, chtype *fake_map)
*
* test/blue.c uses this feature.
*/
-#define PCH_KLUDGE(a,b) (a != 0 && b != 0 && !strcmp(a,b))
+#define PCH_KLUDGE(a,b) (a != NULL && b != NULL && !strcmp(a,b))
if (PCH_KLUDGE(enter_pc_charset_mode, enter_alt_charset_mode) &&
PCH_KLUDGE(exit_pc_charset_mode, exit_alt_charset_mode)) {
size_t i;
@@ -1099,7 +1111,7 @@ drv_initacs(TERMINAL_CONTROL_BLOCK * TCB, chtype *real_map, chtype *fake_map)
if (real_map[i] == 0) {
real_map[i] = (chtype) i;
if (real_map != fake_map) {
- if (sp != 0)
+ if (sp != NULL)
sp->_screen_acs_map[i] = TRUE;
}
}
@@ -1118,7 +1130,7 @@ drv_initacs(TERMINAL_CONTROL_BLOCK * TCB, chtype *real_map, chtype *fake_map)
(int) i,
_tracechar(UChar(acs_chars[i])),
_tracechtype(real_map[UChar(acs_chars[i])])));
- if (sp != 0) {
+ if (sp != NULL) {
sp->_screen_acs_map[UChar(acs_chars[i])] = TRUE;
}
}
@@ -1163,7 +1175,7 @@ _nc_cookie_init(SCREEN *sp)
bool support_cookies = USE_XMC_SUPPORT;
TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) (sp->_term);
- if (sp == 0 || !ENSURE_TINFO(sp))
+ if (sp == NULL || !ENSURE_TINFO(sp))
return;
#if USE_XMC_SUPPORT
@@ -1172,7 +1184,7 @@ _nc_cookie_init(SCREEN *sp)
* 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;
}
}
@@ -1258,7 +1270,7 @@ drv_twait(TERMINAL_CONTROL_BLOCK * TCB,
AssertTCB();
SetSP();
-#ifdef EXP_WIN32_DRIVER
+#if defined(USE_WIN32CON_DRIVER)
return _nc_console_twait(sp,
_nc_console_handle(sp->_ifd),
mode,
@@ -1274,7 +1286,7 @@ drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
{
SCREEN *sp;
int n;
-#ifndef EXP_WIN32_DRIVER
+#if !defined(USE_WIN32CON_DRIVER)
unsigned char c2 = 0;
#endif
@@ -1283,7 +1295,7 @@ drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
SetSP();
_nc_set_read_thread(TRUE);
-#ifdef EXP_WIN32_DRIVER
+#if defined(USE_WIN32CON_DRIVER)
n = _nc_console_read(sp,
_nc_console_handle(sp->_ifd),
buf);
@@ -1291,7 +1303,7 @@ drv_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
n = (int) read(sp->_ifd, &c2, (size_t) 1);
#endif
_nc_set_read_thread(FALSE);
-#ifndef EXP_WIN32_DRIVER
+#if !defined(USE_WIN32CON_DRIVER)
*buf = (int) c2;
#endif
return n;
@@ -1310,10 +1322,10 @@ drv_nap(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int ms)
request = remaining;
}
}
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
Sleep((DWORD) ms);
#else
- _nc_timed_wait(0, 0, ms, (int *) 0 EVENTLIST_2nd(0));
+ _nc_timed_wait(NULL, 0, ms, (int *) 0 EVENTLIST_2nd(NULL));
#endif
return OK;
}
@@ -1380,7 +1392,7 @@ drv_keyok(TERMINAL_CONTROL_BLOCK * TCB, int c, int flag)
unsigned ch = (unsigned) c;
if (flag) {
while ((s = _nc_expand_try(sp->_key_ok,
- ch, &count, (size_t) 0)) != 0) {
+ ch, &count, (size_t) 0)) != NULL) {
if (_nc_remove_key(&(sp->_key_ok), ch)) {
code = _nc_add_to_try(&(sp->_keytry), s, ch);
free(s);
@@ -1393,7 +1405,7 @@ drv_keyok(TERMINAL_CONTROL_BLOCK * TCB, int c, int flag)
}
} else {
while ((s = _nc_expand_try(sp->_keytry,
- ch, &count, (size_t) 0)) != 0) {
+ ch, &count, (size_t) 0)) != NULL) {
if (_nc_remove_key(&(sp->_keytry), ch)) {
code = _nc_add_to_try(&(sp->_key_ok), s, ch);
free(s);
@@ -1420,7 +1432,7 @@ drv_cursorSet(TERMINAL_CONTROL_BLOCK * TCB, int vis)
T((T_CALLED("tinfo:drv_cursorSet(%p,%d)"), (void *) SP_PARM, vis));
- if (SP_PARM != 0 && IsTermInfo(SP_PARM)) {
+ if (SP_PARM != NULL && IsTermInfo(SP_PARM)) {
switch (vis) {
case 2:
code = NCURSES_PUTP2_FLUSH("cursor_visible", cursor_visible);
@@ -1490,7 +1502,7 @@ NCURSES_EXPORT_VAR (TERM_DRIVER) _nc_TINFO_DRIVER = {
drv_cursorSet /* cursorSet */
};
-#ifdef EXP_WIN32_DRIVER
+#if USE_TERM_DRIVER
/*
* The terminfo driver is mandatory and must always be present.
* So this is the natural place for the driver initialisation
@@ -1504,7 +1516,7 @@ typedef struct DriverEntry {
static DRIVER_ENTRY DriverTable[] =
{
-#ifdef _NC_WINDOWS
+#ifdef USE_WIN32CON_DRIVER
{"win32console", &_nc_WIN_DRIVER},
#endif
{"tinfo", &_nc_TINFO_DRIVER} /* must be last */
@@ -1516,30 +1528,31 @@ _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;
+ TERM_DRIVER *use = NULL;
T((T_CALLED("_nc_get_driver(%p, %s, %p)"),
(void *) TCB, NonNull(name), (void *) errret));
- assert(TCB != 0);
+ assert(TCB != NULL);
for (i = 0; i < SIZEOF(DriverTable); i++) {
res = DriverTable[i].driver;
-#ifdef _NC_WINDOWS
+#if defined(USE_WIN32CON_DRIVER)
if ((i + 1) == SIZEOF(DriverTable)) {
/* For Windows >= 10.0.17763 Windows Console interface implements
virtual Terminal functionality.
If on Windows td_CanHandle returned FALSE although the terminal
name is empty, we default to ms-terminal as tinfo TERM type.
*/
- if (name == 0 || *name == 0 || (strcmp(name, "unknown") == 0)) {
- name = MS_TERMINAL;
+ if (name == NULL || *name == 0 || (strcmp(name, "unknown") == 0)) {
+ name = DEFAULT_TERM_ENV;
T(("Set TERM=%s", name));
}
}
#endif
if (strcmp(DriverTable[i].name, res->td_name(TCB)) == 0) {
if (res->td_CanHandle(TCB, name, errret)) {
+ T(("matched driver %s with TERM=%s", DriverTable[i].name, name));
use = res;
break;
}
@@ -1551,4 +1564,4 @@ _nc_get_driver(TERMINAL_CONTROL_BLOCK * TCB, const char *name, int *errret)
}
returnCode(code);
}
-#endif /* EXP_WIN32_DRIVER */
+#endif /* USE_TERM_DRIVER */
diff --git a/ncurses/tinfo/trim_sgr0.c b/ncurses/tinfo/trim_sgr0.c
index 177dcd87225e..d9c38d87857f 100644
--- a/ncurses/tinfo/trim_sgr0.c
+++ b/ncurses/tinfo/trim_sgr0.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2021,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 2005-2012,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -37,22 +37,91 @@
#include <tic.h>
-MODULE_ID("$Id: trim_sgr0.c,v 1.22 2023/09/23 18:47:56 tom Exp $")
+MODULE_ID("$Id: trim_sgr0.c,v 1.27 2024/12/21 20:15:26 tom Exp $")
#undef CUR
#define CUR tp->
+/*
+ * Skip a padding token, e.g., "<5>", "<5.1>", "<5/>", "<5*>", or "<5/>".
+ * If the pattern does not match, return null.
+ */
static char *
-set_attribute_9(TERMTYPE2 *tp, int flag)
+skip_padding(char *value)
+{
+ char *result = NULL;
+ if (*value++ == '$' && *value++ == '<') {
+ int ch;
+ int state = 0; /* 1=integer, 2=decimal, 3=fraction */
+ while ((ch = UChar(*value++)) != '\0') {
+ if (ch == '*' || ch == '/') {
+ if (!state)
+ break;
+ } else if (ch == '>') {
+ if (state)
+ result = value;
+ break;
+ } else if (ch == '.') {
+ if (state < 2) {
+ state = 2;
+ } else {
+ break; /* a single decimal point is allowed */
+ }
+ } else if (isdigit(ch)) {
+ if (state < 2) {
+ state = 1;
+ } else if (state == 2) {
+ state = 3;
+ } else {
+ break; /* only a single digit after decimal point */
+ }
+ } else {
+ break;
+ }
+ }
+ }
+ return result;
+}
+
+static void
+strip_padding(char *value)
+{
+ char *s = value;
+ char ch;
+
+ while ((ch = *s) != '\0') {
+ if (ch == '\\') {
+ if (*++s == '\0')
+ break;
+ ++s;
+ } else {
+ char *d = NULL;
+ if (ch == '$')
+ d = skip_padding(s);
+ if (d != NULL) {
+ char *t = s;
+ while ((*t++ = *d++) != '\0') ;
+ } else {
+ ++s;
+ }
+ }
+ }
+}
+
+static char *
+set_attribute_9(const TERMTYPE2 *tp, int flag)
{
const char *value;
char *result;
value = TIPARM_9(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, flag);
- if (PRESENT(value))
+ if (PRESENT(value)) {
result = strdup(value);
- else
- result = 0;
+ if (result != NULL)
+ strip_padding(result);
+ } else {
+ result = NULL;
+ }
return result;
}
@@ -60,7 +129,7 @@ static int
is_csi(const char *s)
{
int result = 0;
- if (s != 0) {
+ if (s != NULL) {
if (UChar(s[0]) == CSI_CHR)
result = 1;
else if (s[0] == ESC_CHR && s[1] == L_BLOCK)
@@ -99,9 +168,9 @@ skip_delay(const char *s)
* to the end of the s-string.
*/
static bool
-rewrite_sgr(char *s, char *attr)
+rewrite_sgr(char *s, const char *attr)
{
- if (s != 0) {
+ if (s != NULL) {
if (PRESENT(attr)) {
size_t len_s = strlen(s);
size_t len_a = strlen(attr);
@@ -125,7 +194,7 @@ static bool
similar_sgr(char *a, char *b)
{
bool result = FALSE;
- if (a != 0 && b != 0) {
+ if (a != NULL && b != NULL) {
int csi_a = is_csi(a);
int csi_b = is_csi(b);
size_t len_a;
@@ -237,12 +306,10 @@ _nc_trim_sgr0(TERMTYPE2 *tp)
if (PRESENT(exit_attribute_mode)
&& PRESENT(set_attributes)) {
- bool found = FALSE;
char *on = set_attribute_9(tp, 1);
char *off = set_attribute_9(tp, 0);
char *end = strdup(exit_attribute_mode);
char *tmp;
- size_t i, j, k;
TR(TRACE_DATABASE, ("checking if we can trim sgr0 based on sgr"));
TR(TRACE_DATABASE, ("sgr0 %s", _nc_visbuf(end)));
@@ -255,12 +322,17 @@ _nc_trim_sgr0(TERMTYPE2 *tp)
FreeIfNeeded(off);
} else if (similar_sgr(off, end)
&& !similar_sgr(off, on)) {
+ bool found = FALSE;
+ size_t i, j;
+
TR(TRACE_DATABASE, ("adjusting sgr(9:off) : %s", _nc_visbuf(off)));
result = off;
/*
* If rmacs is a substring of sgr(0), remove that chunk.
*/
if (PRESENT(exit_alt_charset_mode)) {
+ size_t k;
+
TR(TRACE_DATABASE, ("scan for rmacs %s", _nc_visbuf(exit_alt_charset_mode)));
j = strlen(off);
k = strlen(exit_alt_charset_mode);
@@ -297,7 +369,7 @@ _nc_trim_sgr0(TERMTYPE2 *tp)
}
}
if (!found
- && (tmp = strstr(end, off)) != 0
+ && (tmp = strstr(end, off)) != NULL
&& strcmp(end, off) != 0) {
i = (size_t) (tmp - end);
j = strlen(off);
diff --git a/ncurses/tinfo/write_entry.c b/ncurses/tinfo/write_entry.c
index 8ccca9eca6fc..eddae7fbaece 100644
--- a/ncurses/tinfo/write_entry.c
+++ b/ncurses/tinfo/write_entry.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 *
@@ -42,7 +42,7 @@
#include <tic.h>
-MODULE_ID("$Id: write_entry.c,v 1.132 2024/04/20 17:58:51 tom Exp $")
+MODULE_ID("$Id: write_entry.c,v 1.144 2025/12/28 00:33:30 tom Exp $")
#if 1
#define TRACE_OUT(p) DEBUG(2, p)
@@ -71,7 +71,7 @@ static int make_db_root(const char *);
#if !USE_HASHED_DB
static void
-write_file(char *filename, TERMTYPE2 *tp)
+write_file(const char *filename, TERMTYPE2 *tp)
{
char buffer[MAX_ENTRY_SIZE];
unsigned limit = sizeof(buffer);
@@ -82,21 +82,25 @@ write_file(char *filename, TERMTYPE2 *tp)
} else {
FILE *fp = ((_nc_access(filename, W_OK) == 0)
? safe_fopen(filename, BIN_W)
- : 0);
+ : NULL);
size_t actual;
- if (fp == 0) {
- perror(filename);
- _nc_syserr_abort("cannot open %s/%s", _nc_tic_dir(0), filename);
+ if (fp == NULL) {
+ _nc_syserr_abort("cannot open %s/%s: (errno %d) %s",
+ _nc_tic_dir(NULL),
+ filename,
+ errno,
+ strerror(errno));
}
actual = fwrite(buffer, sizeof(char), (size_t) offset, fp);
if (actual != offset) {
int myerr = ferror(fp) ? errno : 0;
if (myerr) {
- _nc_syserr_abort("error writing %s/%s: %s",
+ _nc_syserr_abort("error writing %s/%s: (errno %d) %s",
_nc_tic_dir(NULL),
filename,
+ myerr,
strerror(myerr));
} else {
_nc_syserr_abort("error writing %s/%s: %u bytes vs actual %lu",
@@ -125,15 +129,19 @@ check_writeable(int code)
static const char dirnames[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
static bool verified[sizeof(dirnames)];
- char dir[sizeof(LEAF_FMT)];
- char *s = 0;
+ const char *s = NULL;
- if (code == 0 || (s = (strchr) (dirnames, code)) == 0) {
- _nc_err_abort("Illegal terminfo subdirectory \"" LEAF_FMT "\"", code);
+ if (code == 0 || (s = (strchr) (dirnames, code)) == NULL) {
+ _nc_err_abort("Illegal terminfo subdirectory \"" LEAF_FMT "\"", UChar(code));
} else if (!verified[s - dirnames]) {
- _nc_SPRINTF(dir, _nc_SLIMIT(sizeof(dir)) LEAF_FMT, code);
+ char dir[sizeof(LEAF_FMT)];
+ _nc_SPRINTF(dir, _nc_SLIMIT(sizeof(dir)) LEAF_FMT, UChar(code));
if (make_db_root(dir) < 0) {
- _nc_err_abort("%s/%s: permission denied", _nc_tic_dir(NULL), dir);
+ _nc_err_abort("%s/%s: (errno %d) %s",
+ _nc_tic_dir(NULL),
+ dir,
+ errno,
+ strerror(errno));
} else {
verified[s - dirnames] = TRUE;
}
@@ -153,8 +161,12 @@ make_db_path(char *dst, const char *src, size_t limit)
rc = 0;
}
} else {
- if ((strlen(top) + strlen(src) + 6) <= limit) {
- _nc_SPRINTF(dst, _nc_SLIMIT(limit) "%s/%s", top, src);
+ size_t len_top = strlen(top);
+ size_t len_src = strlen(src);
+ if ((len_top + len_src + 6) <= limit) {
+ _nc_SPRINTF(dst, _nc_SLIMIT(limit) "%.*s/%.*s",
+ (int) len_top, top,
+ (int) len_src, src);
rc = 0;
}
}
@@ -186,6 +198,7 @@ make_db_root(const char *path)
int rc;
char fullpath[PATH_MAX];
+ FixupPathname(path);
if ((rc = make_db_path(fullpath, path, sizeof(fullpath))) == 0) {
#if USE_HASHED_DB
DB *capdbp;
@@ -198,15 +211,17 @@ make_db_root(const char *path)
#else
struct stat statbuf;
- if ((rc = stat(path, &statbuf)) == -1) {
+ rc = 0;
+ if (!_nc_is_path_found(path, &statbuf)) {
rc = mkdir(path
-#ifndef _NC_WINDOWS
+#ifndef _NC_WINDOWS_NATIVE
,0777
#endif
);
} else if (_nc_access(path, R_OK | W_OK | X_OK) < 0) {
rc = -1; /* permission denied */
} else if (!(S_ISDIR(statbuf.st_mode))) {
+ errno = ENOTDIR;
rc = -1; /* not a directory */
}
#endif
@@ -244,8 +259,10 @@ _nc_set_writedir(const char *dir)
}
}
if (!success) {
- _nc_err_abort("%s: permission denied (errno %d)",
- destination, errno);
+ _nc_err_abort("%s: (errno %d) %s",
+ destination,
+ errno,
+ strerror(errno));
}
}
@@ -256,6 +273,7 @@ _nc_set_writedir(const char *dir)
#if USE_HASHED_DB
make_db_path(actual, destination, sizeof(actual));
#else
+ FixupPathname2(destination, actual);
if (chdir(_nc_tic_dir(destination)) < 0
|| getcwd(actual, sizeof(actual)) == NULL)
_nc_err_abort("%s: not a directory", destination);
@@ -431,7 +449,7 @@ _nc_write_entry(TERMTYPE2 *const tp)
* so warn the user.
*/
if (start_time > 0 &&
- stat(filename, &statbuf) >= 0
+ _nc_is_path_found(filename, &statbuf)
&& statbuf.st_mtime >= start_time) {
#if HAVE_LINK && !USE_SYMLINKS
/*
@@ -455,7 +473,7 @@ _nc_write_entry(TERMTYPE2 *const tp)
write_file(filename, tp);
if (start_time == 0) {
- if (stat(filename, &statbuf) == -1
+ if (!_nc_is_path_found(filename, &statbuf)
|| (start_time = statbuf.st_mtime) == 0) {
_nc_syserr_abort("error obtaining time from %s/%s",
_nc_tic_dir(NULL), filename);
@@ -480,14 +498,14 @@ _nc_write_entry(TERMTYPE2 *const tp)
check_writeable(ptr[0]);
_nc_SPRINTF(linkname, _nc_SLIMIT(sizeof(linkname))
- LEAF_FMT "/%.*s", ptr[0],
+ LEAF_FMT "/%.*s", UChar(ptr[0]),
(int) sizeof(linkname) - (2 + LEAF_LEN), ptr);
if (strcmp(filename, linkname) == 0) {
_nc_warning("self-synonym ignored");
}
#if !LINK_TOUCHES
- else if (stat(linkname, &statbuf) >= 0 &&
+ else if (_nc_is_path_found(linkname, &statbuf) &&
statbuf.st_mtime < start_time) {
_nc_warning("alias %s multiply defined.", ptr);
}
@@ -552,7 +570,7 @@ static size_t
fake_write(char *dst,
unsigned *offset,
size_t limit,
- char *src,
+ const char *src,
size_t want,
size_t size)
{
@@ -658,7 +676,7 @@ convert_32bit(unsigned char *buf, NCURSES_INT2 *Numbers, size_t count)
#if NCURSES_XNAMES
static unsigned
-extended_Booleans(TERMTYPE2 *tp)
+extended_Booleans(const TERMTYPE2 *tp)
{
unsigned result = 0;
unsigned i;
@@ -671,7 +689,7 @@ extended_Booleans(TERMTYPE2 *tp)
}
static unsigned
-extended_Numbers(TERMTYPE2 *tp)
+extended_Numbers(const TERMTYPE2 *tp)
{
unsigned result = 0;
unsigned i;
@@ -684,7 +702,7 @@ extended_Numbers(TERMTYPE2 *tp)
}
static unsigned
-extended_Strings(TERMTYPE2 *tp)
+extended_Strings(const TERMTYPE2 *tp)
{
unsigned short result = 0;
unsigned short i;
@@ -701,7 +719,7 @@ extended_Strings(TERMTYPE2 *tp)
* clause - discard the unneeded data.
*/
static bool
-extended_object(TERMTYPE2 *tp)
+extended_object(const TERMTYPE2 *tp)
{
bool result = FALSE;
diff --git a/ncurses/trace/lib_trace.c b/ncurses/trace/lib_trace.c
index 0904c132fee1..a7197b0d371a 100644
--- a/ncurses/trace/lib_trace.c
+++ b/ncurses/trace/lib_trace.c
@@ -48,7 +48,7 @@
#include <ctype.h>
-MODULE_ID("$Id: lib_trace.c,v 1.106 2024/02/24 18:28:19 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.109 2024/12/07 21:02:00 tom Exp $")
NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
@@ -135,7 +135,7 @@ curses_trace(unsigned tracelevel)
Locked(result = _nc_tracing);
- if ((MyFP == 0) && tracelevel) {
+ if ((MyFP == NULL) && tracelevel) {
MyInit = TRUE;
if (MyFD >= 0) {
MyFP = fdopen(MyFD, BIN_W);
@@ -149,7 +149,7 @@ curses_trace(unsigned tracelevel)
#define SAFE_MODE (O_CREAT | O_EXCL | O_RDWR)
if (_nc_access(myFile, W_OK) < 0
|| (MyFD = safe_open3(myFile, SAFE_MODE, 0600)) < 0
- || (MyFP = fdopen(MyFD, BIN_W)) == 0) {
+ || (MyFP = fdopen(MyFD, BIN_W)) == NULL) {
; /* EMPTY */
}
}
@@ -158,7 +158,7 @@ curses_trace(unsigned tracelevel)
* so that the trace-output gets flushed automatically at the
* end of each line. This is useful in case the program dies.
*/
- if (MyFP != 0) {
+ if (MyFP != NULL) {
#if HAVE_SETVBUF /* ANSI */
(void) setvbuf(MyFP, (char *) 0, _IOLBF, (size_t) 0);
#elif HAVE_SETBUF /* POSIX */
@@ -188,10 +188,10 @@ curses_trace(unsigned tracelevel)
_tracef("- DEBUG_LEVEL(%u)", tracelevel >> TRACE_SHIFT);
}
} else if (tracelevel == 0) {
- if (MyFP != 0) {
+ if (MyFP != NULL) {
MyFD = dup(MyFD); /* allow reopen of same file */
fclose(MyFP);
- MyFP = 0;
+ MyFP = NULL;
}
Locked(_nc_tracing = tracelevel);
} else if (_nc_tracing != tracelevel) {
@@ -226,7 +226,7 @@ _nc_va_tracef(const char *fmt, va_list ap)
#ifdef TRACE
/* verbose-trace in the command-line utilities relies on this */
- if (fp == 0 && !MyInit && _nc_tracing >= DEBUG_LEVEL(1))
+ if (fp == NULL && !MyInit && _nc_tracing >= DEBUG_LEVEL(1))
fp = stderr;
#endif
@@ -246,7 +246,7 @@ _nc_va_tracef(const char *fmt, va_list ap)
}
}
- if (doit != 0 && fp != 0) {
+ if (doit != 0 && fp != NULL) {
#ifdef USE_PTHREADS
/*
* TRACE_ICALLS is "really" needed to show normal use with threaded
@@ -261,7 +261,7 @@ _nc_va_tracef(const char *fmt, va_list ap)
if ((pthread_self))
# endif
fprintf(fp, "%#" PRIxPTR ":",
-#ifdef _NC_WINDOWS
+#ifdef _NC_WINDOWS_NATIVE
CASTxPTR(pthread_self().p)
#else
CASTxPTR(pthread_self())
@@ -295,8 +295,8 @@ _tracef(const char *fmt, ...)
}
/* Trace 'bool' return-values */
-NCURSES_EXPORT(NCURSES_BOOL)
-_nc_retrace_bool(int code)
+NCURSES_EXPORT(bool)
+_nc_retrace_bool(bool code)
{
T((T_RETURN("%s"), code ? "TRUE" : "FALSE"));
return code;
diff --git a/ncurses/trace/lib_traceatr.c b/ncurses/trace/lib_traceatr.c
index b36286253d6d..63dc9f22dfe5 100644
--- a/ncurses/trace/lib_traceatr.c
+++ b/ncurses/trace/lib_traceatr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2022,2024 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 1998-2017,2018 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -44,7 +44,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_traceatr.c,v 1.96 2024/02/04 00:11:35 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.101 2025/11/16 16:08:54 tom Exp $")
#define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
@@ -126,7 +126,7 @@ _traceattr2(int bufnum, chtype newmode)
#undef DATA
char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
- if (result != 0) {
+ if (result != NULL) {
size_t n;
unsigned save_nc_tracing = _nc_tracing;
@@ -167,7 +167,7 @@ _traceattr2(int bufnum, chtype newmode)
}
}
if (ChAttrOf(newmode) == A_NORMAL) {
- if (result != 0 && result[1] != '\0')
+ if (result != NULL && result[1] != '\0')
(void) _nc_trace_bufcat(bufnum, "|");
(void) _nc_trace_bufcat(bufnum, "A_NORMAL");
}
@@ -248,14 +248,14 @@ _nc_altcharset_name(attr_t attr, chtype ch)
};
#undef DATA
- const char *result = 0;
+ const char *result = NULL;
#if NCURSES_SP_FUNCS
(void) sp;
#endif
- if (SP_PARM != 0 && (attr & A_ALTCHARSET) && (acs_chars != 0)) {
+ if (SP_PARM != NULL && (attr & A_ALTCHARSET) && (acs_chars != NULL)) {
char *cp;
- char *found = 0;
+ const char *found = NULL;
for (cp = acs_chars; cp[0] && cp[1]; cp += 2) {
if (ChCharOf(UChar(cp[1])) == ChCharOf(ch)) {
@@ -264,7 +264,7 @@ _nc_altcharset_name(attr_t attr, chtype ch)
}
}
- if (found != 0) {
+ if (found != NULL) {
size_t n;
ch = ChCharOf(UChar(*found));
@@ -284,12 +284,12 @@ _tracechtype2(int bufnum, chtype ch)
{
char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
- if (result != 0) {
+ if (result != NULL) {
const char *found;
attr_t attr = ChAttrOf(ch);
_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
- if ((found = _nc_altcharset_name(attr, ch)) != 0) {
+ if ((found = _nc_altcharset_name(attr, ch)) != NULL) {
(void) _nc_trace_bufcat(bufnum, found);
attr &= ~A_ALTCHARSET;
} else
@@ -328,13 +328,13 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
{
char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
- if (result != 0) {
+ if (result != NULL) {
_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
- if (ch != 0) {
+ if (ch != NULL) {
const char *found;
attr_t attr = AttrOfD(ch);
- if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
+ if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != NULL) {
(void) _nc_trace_bufcat(bufnum, found);
attr &= ~A_ALTCHARSET;
} else if (isWidecExt(CHDEREF(ch))) {
@@ -363,7 +363,7 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
UChar(ch->chars[PUTC_i])));
}
break;
- } else if (ch->chars[PUTC_i] > assume_unicode) {
+ } else if ((int) ch->chars[PUTC_i] > assume_unicode) {
char temp[80];
_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
"{%d:\\u%04lx}",
@@ -371,7 +371,7 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
(unsigned long) ch->chars[PUTC_i]);
(void) _nc_trace_bufcat(bufnum, temp);
attr &= ~A_CHARTEXT; /* ignore WidecExt(ch) */
- } else {
+ } else if (PUTC_n > 1 || !is8bits(ch->chars[PUTC_i])) {
for (n = 0; n < PUTC_n; n++) {
if (n)
(void) _nc_trace_bufcat(bufnum, ", ");
@@ -379,6 +379,11 @@ _tracecchar_t2(int bufnum, const cchar_t *ch)
_nc_tracechar(CURRENT_SCREEN,
UChar(PUTC_buf[n])));
}
+ } else {
+ char temp[2];
+ temp[0] = (char) ch->chars[PUTC_i];
+ temp[1] = 0;
+ (void) _nc_trace_bufcat(bufnum, temp);
}
}
(void) _nc_trace_bufcat(bufnum, " }");
diff --git a/ncurses/trace/lib_tracebits.c b/ncurses/trace/lib_tracebits.c
index 4bc50f3b0857..b9f44888896e 100644
--- a/ncurses/trace/lib_tracebits.c
+++ b/ncurses/trace/lib_tracebits.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey *
+ * Copyright 2019-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 *
@@ -35,16 +35,12 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_tracebits.c,v 1.31 2020/11/14 23:38:11 tom Exp $")
+MODULE_ID("$Id: lib_tracebits.c,v 1.37 2025/12/23 09:23:38 tom Exp $")
#if HAVE_SYS_TERMIO_H
#include <sys/termio.h> /* needed for ISC */
#endif
-#ifdef __EMX__
-#include <io.h>
-#endif
-
/* may be undefined if we're using termio.h */
#ifndef TOSTOP
#define TOSTOP 0
@@ -72,21 +68,21 @@ MODULE_ID("$Id: lib_tracebits.c,v 1.31 2020/11/14 23:38:11 tom Exp $")
#ifdef TRACE
-#if defined(EXP_WIN32_DRIVER)
+#if defined(USE_WIN32CON_DRIVER)
#define BITNAMELEN 36
#else
#define BITNAMELEN 8
#endif
typedef struct {
- unsigned int val;
+ unsigned long val;
const char name[BITNAMELEN];
} BITNAMES;
#define TRACE_BUF_SIZE(num) (_nc_globals.tracebuf_ptr[num].size)
static void
-lookup_bits(char *buf, const BITNAMES * table, const char *label, unsigned int val)
+lookup_bits(char *buf, const BITNAMES * table, const char *label, unsigned long val)
{
const BITNAMES *sp;
@@ -172,7 +168,7 @@ _nc_trace_ttymode(const TTY * tty)
8 + sizeof(cflags) +
8 + sizeof(lflags) +
8);
- if (buf != 0) {
+ if (buf != NULL) {
if (tty->c_iflag & ALLIN)
lookup_bits(buf, iflags, "iflags", tty->c_iflag);
@@ -218,7 +214,7 @@ _nc_trace_ttymode(const TTY * tty)
if (tty->c_lflag & ALLLOCAL)
lookup_bits(buf, lflags, "lflags", tty->c_lflag);
}
-#elif defined(EXP_WIN32_DRIVER)
+#elif defined(USE_WIN32CON_DRIVER)
#define DATA(name) { name, { #name } }
static const BITNAMES dwFlagsOut[] =
{
@@ -244,7 +240,7 @@ _nc_trace_ttymode(const TTY * tty)
buf = _nc_trace_buf(0,
8 + sizeof(dwFlagsOut) +
8 + sizeof(dwFlagsIn));
- if (buf != 0) {
+ if (buf != NULL) {
lookup_bits(buf, dwFlagsIn, "dwIn", tty->dwFlagIn);
lookup_bits(buf, dwFlagsOut, "dwOut", tty->dwFlagOut);
}
@@ -284,7 +280,7 @@ _nc_trace_ttymode(const TTY * tty)
buf = _nc_trace_buf(0,
8 + sizeof(cflags));
- if (buf != 0) {
+ if (buf != NULL) {
if (tty->sg_flags & ALLCTRL) {
lookup_bits(buf, cflags, "cflags", tty->sg_flags);
}
diff --git a/ncurses/trace/lib_tracechr.c b/ncurses/trace/lib_tracechr.c
index 9c879dc67397..db3cb530908a 100644
--- a/ncurses/trace/lib_tracechr.c
+++ b/ncurses/trace/lib_tracechr.c
@@ -40,7 +40,7 @@
#include <ctype.h>
-MODULE_ID("$Id: lib_tracechr.c,v 1.24 2024/02/04 00:11:35 tom Exp $")
+MODULE_ID("$Id: lib_tracechr.c,v 1.26 2024/12/07 21:02:00 tom Exp $")
#ifdef TRACE
@@ -50,16 +50,16 @@ NCURSES_EXPORT(char *)
_nc_tracechar(SCREEN *sp, int ch)
{
NCURSES_CONST char *name;
- char *MyBuffer = ((sp != 0)
+ char *MyBuffer = ((sp != NULL)
? sp->tracechr_buf
: _nc_globals.tracechr_buf);
if ((ch > KEY_MIN && !_nc_unicode_locale()) || ch < 0) {
name = safe_keyname(SP_PARM, ch);
- if (name == 0 || *name == '\0')
+ if (name == NULL || *name == '\0')
name = "NULL";
_nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize)
- "'%.30s' = \\x%02x", name, ch);
+ "'%.30s' = \\x%02x", name, UChar(ch));
} else if (!is8bits(ch)
|| (_nc_unicode_locale() && !is7bits(ch))
|| !isprint(UChar(ch))) {
@@ -72,7 +72,7 @@ _nc_tracechar(SCREEN *sp, int ch)
"\\x%02x", ch);
} else {
name = safe_unctrl(SP_PARM, (chtype) ch);
- if (name == 0 || *name == 0)
+ if (name == NULL || *name == 0)
name = "null"; /* shouldn't happen */
_nc_SPRINTF(MyBuffer, _nc_SLIMIT(MyBufSize)
"'%.30s' = \\x%02x", name, ch);
diff --git a/ncurses/trace/lib_tracedmp.c b/ncurses/trace/lib_tracedmp.c
index 529148bb785a..218a15e0f62e 100644
--- a/ncurses/trace/lib_tracedmp.c
+++ b/ncurses/trace/lib_tracedmp.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,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>
#include <ctype.h>
-MODULE_ID("$Id: lib_tracedmp.c,v 1.37 2023/06/24 15:49:45 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.38 2024/12/07 20:06:49 tom Exp $")
#ifdef TRACE
@@ -72,7 +72,7 @@ _tracedump(const char *name, WINDOW *win)
my_length = (unsigned) (2 * (width + 1));
my_buffer = typeRealloc(char, my_length, my_buffer);
}
- if (my_buffer == 0)
+ if (my_buffer == NULL)
return;
for (n = 0; n <= win->_maxy; ++n) {
@@ -177,7 +177,7 @@ _tracedump(const char *name, WINDOW *win)
}
#if NO_LEAKS
free(my_buffer);
- my_buffer = 0;
+ my_buffer = NULL;
my_length = 0;
#endif
}
diff --git a/ncurses/trace/lib_tracemse.c b/ncurses/trace/lib_tracemse.c
index 33d4d3d300d3..bbca18b009dc 100644
--- a/ncurses/trace/lib_tracemse.c
+++ b/ncurses/trace/lib_tracemse.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1998-2012,2014 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_tracemse.c,v 1.23 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_tracemse.c,v 1.24 2024/12/07 20:06:49 tom Exp $")
#ifdef TRACE
@@ -117,9 +117,9 @@ _nc_trace_mmask_t(SCREEN *sp, mmask_t code)
NCURSES_EXPORT(char *)
_nc_tracemouse(SCREEN *sp, MEVENT const *ep)
{
- char *result = 0;
+ char *result = NULL;
- if (sp != 0) {
+ if (sp != NULL) {
_nc_SPRINTF(my_buffer, _nc_SLIMIT(sizeof(my_buffer))
TRACEMSE_FMT,
ep->id,
@@ -138,7 +138,7 @@ _nc_tracemouse(SCREEN *sp, MEVENT const *ep)
NCURSES_EXPORT(mmask_t)
_nc_retrace_mmask_t(SCREEN *sp, mmask_t code)
{
- if (sp != 0) {
+ if (sp != NULL) {
*my_buffer = '\0';
T((T_RETURN("{%s}"), _nc_trace_mmask_t(sp, code)));
} else {
diff --git a/ncurses/trace/trace_buf.c b/ncurses/trace/trace_buf.c
index 91b12e45c248..0ab258d43d9d 100644
--- a/ncurses/trace/trace_buf.c
+++ b/ncurses/trace/trace_buf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 1998-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,7 +36,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: trace_buf.c,v 1.22 2023/06/24 13:37:25 tom Exp $")
+MODULE_ID("$Id: trace_buf.c,v 1.23 2024/12/07 21:24:18 tom Exp $")
#ifdef TRACE
@@ -46,22 +46,22 @@ MODULE_ID("$Id: trace_buf.c,v 1.22 2023/06/24 13:37:25 tom Exp $")
static char *
_nc_trace_alloc(int bufnum, size_t want)
{
- char *result = 0;
+ char *result = NULL;
if (bufnum >= 0) {
if ((size_t) (bufnum + 1) > MySize) {
size_t need = (size_t) (bufnum + 1) * 2;
- if ((MyList = typeRealloc(TRACEBUF, need, MyList)) != 0) {
+ if ((MyList = typeRealloc(TRACEBUF, need, MyList)) != NULL) {
while (need > MySize)
- MyList[MySize++].text = 0;
+ MyList[MySize++].text = NULL;
}
}
- if (MyList != 0) {
- if (MyList[bufnum].text == 0
+ if (MyList != NULL) {
+ if (MyList[bufnum].text == NULL
|| want > MyList[bufnum].size) {
MyList[bufnum].text = typeRealloc(char, want, MyList[bufnum].text);
- if (MyList[bufnum].text != 0)
+ if (MyList[bufnum].text != NULL)
MyList[bufnum].size = want;
}
result = MyList[bufnum].text;
@@ -72,12 +72,12 @@ _nc_trace_alloc(int bufnum, size_t want)
if (MySize) {
if (MyList) {
while (MySize--) {
- if (MyList[MySize].text != 0) {
+ if (MyList[MySize].text != NULL) {
free(MyList[MySize].text);
}
}
free(MyList);
- MyList = 0;
+ MyList = NULL;
}
MySize = 0;
}
@@ -93,7 +93,7 @@ NCURSES_EXPORT(char *)
_nc_trace_buf(int bufnum, size_t want)
{
char *result = _nc_trace_alloc(bufnum, want);
- if (result != 0)
+ if (result != NULL)
*result = '\0';
return result;
}
@@ -109,12 +109,12 @@ _nc_trace_bufcat(int bufnum, const char *value)
if (value == NULL)
value = "";
buffer = _nc_trace_alloc(bufnum, (size_t) 0);
- if (buffer != 0) {
+ if (buffer != NULL) {
size_t have = strlen(buffer);
size_t need = strlen(value) + have;
buffer = _nc_trace_alloc(bufnum, 1 + need);
- if (buffer != 0)
+ if (buffer != NULL)
_nc_STRCPY(buffer + have, value, need);
}
diff --git a/ncurses/trace/trace_tries.c b/ncurses/trace/trace_tries.c
index 14f704b4abb5..8d2592aa7e66 100644
--- a/ncurses/trace/trace_tries.c
+++ b/ncurses/trace/trace_tries.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 1999-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,7 +36,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: trace_tries.c,v 1.18 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: trace_tries.c,v 1.19 2024/12/07 21:24:18 tom Exp $")
#ifdef TRACE
#define my_buffer _nc_globals.tracetry_buf
@@ -50,8 +50,8 @@ recur_tries(TRIES * tree, unsigned level)
my_buffer = (unsigned char *) _nc_doalloc(my_buffer, my_length);
}
- if (my_buffer != 0) {
- while (tree != 0) {
+ if (my_buffer != NULL) {
+ while (tree != NULL) {
if ((my_buffer[level] = tree->ch) == 0)
my_buffer[level] = 128;
my_buffer[level + 1] = 0;
@@ -69,7 +69,7 @@ recur_tries(TRIES * tree, unsigned level)
NCURSES_EXPORT(void)
_nc_trace_tries(TRIES * tree)
{
- if ((my_buffer = typeMalloc(unsigned char, my_length = 80)) != 0) {
+ if ((my_buffer = typeMalloc(unsigned char, my_length = 80)) != NULL) {
_tracef("BEGIN tries %p", (void *) tree);
recur_tries(tree, 0);
_tracef(". . . tries %p", (void *) tree);
diff --git a/ncurses/trace/varargs.c b/ncurses/trace/varargs.c
index 7b9533bd62f4..4fa38da89ad3 100644
--- a/ncurses/trace/varargs.c
+++ b/ncurses/trace/varargs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 2001-2008,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -35,7 +35,7 @@
#include <ctype.h>
-MODULE_ID("$Id: varargs.c,v 1.13 2023/06/24 13:41:46 tom Exp $")
+MODULE_ID("$Id: varargs.c,v 1.16 2025/02/15 15:22:14 tom Exp $")
#ifdef TRACE
@@ -60,35 +60,35 @@ NCURSES_EXPORT(char *)
_nc_varargs(const char *fmt, va_list ap)
{
char buffer[BUFSIZ];
- const char *param;
+ const char *value;
int n;
- if (fmt == 0 || *fmt == '\0')
+ if (fmt == NULL || *fmt == '\0')
return NULL;
if (MyLength == 0)
MyBuffer = typeMalloc(char, MyLength = BUFSIZ);
- if (MyBuffer == 0)
+ if (MyBuffer == NULL)
return NULL;
*MyBuffer = '\0';
while (*fmt != '\0') {
if (*fmt == '%') {
- char *pval = 0; /* avoid const-cast */
+ const char *pval = NULL; /* avoid const-cast */
const char *sval = "";
double fval = 0.0;
int done = FALSE;
int ival = 0;
int type = 0;
- ARGTYPE parm[MAX_PARMS];
- int parms = 0;
+ ARGTYPE param[MAX_PARMS];
+ int params = 0;
ARGTYPE used = atUnknown;
while (*++fmt != '\0' && !done) {
if (*fmt == '*') {
VA_INT(int);
- if (parms < MAX_PARMS)
- parm[parms++] = atInteger;
+ if (params < MAX_PARMS)
+ param[params++] = atInteger;
} else if (isalpha(UChar(*fmt))) {
done = TRUE;
switch (*fmt) {
@@ -141,11 +141,11 @@ _nc_varargs(const char *fmt, va_list ap)
} else if (*fmt == '%') {
done = TRUE;
}
- if (used != atUnknown && parms < MAX_PARMS) {
- parm[parms++] = used;
- for (n = 0; n < parms; ++n) {
- used = parm[n];
- param = buffer;
+ if (used != atUnknown && params < MAX_PARMS) {
+ param[params++] = used;
+ for (n = 0; n < params; ++n) {
+ used = param[n];
+ value = buffer;
switch (used) {
case atInteger:
_nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer))
@@ -160,19 +160,19 @@ _nc_varargs(const char *fmt, va_list ap)
"%p", pval);
break;
case atString:
- param = _nc_visbuf2(1, sval);
+ value = _nc_visbuf2(1, sval);
break;
case atUnknown:
default:
_nc_STRCPY(buffer, "?", sizeof(buffer));
break;
}
- MyLength += strlen(param) + 2;
+ MyLength += strlen(value) + 2;
MyBuffer = typeRealloc(char, MyLength, MyBuffer);
- if (MyBuffer != 0) {
+ if (MyBuffer != NULL) {
_nc_SPRINTF(MyBuffer + strlen(MyBuffer),
_nc_SLIMIT(MyLength - strlen(MyBuffer))
- ", %s", param);
+ ", %s", value);
}
}
}
diff --git a/ncurses/trace/visbuf.c b/ncurses/trace/visbuf.c
index 590e42306f51..2fdd554c5dcb 100644
--- a/ncurses/trace/visbuf.c
+++ b/ncurses/trace/visbuf.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2021,2023 Thomas E. Dickey *
+ * Copyright 2019-2023,2024 Thomas E. Dickey *
* Copyright 2001-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -43,7 +43,7 @@
#include <tic.h>
#include <ctype.h>
-MODULE_ID("$Id: visbuf.c,v 1.54 2023/05/27 20:13:10 tom Exp $")
+MODULE_ID("$Id: visbuf.c,v 1.56 2024/12/07 21:12:53 tom Exp $")
#define NUM_VISBUFS 4
@@ -72,7 +72,7 @@ _nc_vischar(char *tp, unsigned c LIMIT_ARG)
} else if (c == '"' || c == '\\') {
*tp++ = '\\';
*tp++ = (char) c;
- } else if (is7bits((int) c) && (isgraph((int) c) || c == ' ')) {
+ } else if (is7bits(UChar(c)) && (isgraph(UChar(c)) || c == ' ')) {
*tp++ = (char) c;
} else if (c == '\n') {
*tp++ = '\\';
@@ -109,11 +109,11 @@ _nc_vischar(char *tp, unsigned c LIMIT_ARG)
static const char *
_nc_visbuf2n(int bufnum, const char *buf, int len)
{
- const char *vbuf = 0;
+ const char *vbuf = NULL;
char *tp;
int count;
- if (buf == 0)
+ if (buf == NULL)
return ("(null)");
if (buf == CANCELLED_STRING)
return ("(cancelled)");
@@ -140,7 +140,7 @@ _nc_visbuf2n(int bufnum, const char *buf, int len)
}
}
#endif
- if (tp != 0) {
+ if (tp != NULL) {
int c;
*tp++ = D_QUOTE;
@@ -196,7 +196,7 @@ _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
char *tp;
int count;
- if (buf == 0)
+ if (buf == NULL)
return ("(null)");
if (len < 0)
@@ -212,7 +212,7 @@ _nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
vbuf = tp = mybuf[bufnum];
}
#endif
- if (tp != 0) {
+ if (tp != NULL) {
wchar_t c;
*tp++ = D_QUOTE;
@@ -267,12 +267,12 @@ _nc_viswibuf(const wint_t *buf)
}
if (mylen < ++n) {
mylen = n + 80;
- if (mybuf != 0)
+ if (mybuf != NULL)
mybuf = typeRealloc(wchar_t, mylen, mybuf);
else
mybuf = typeMalloc(wchar_t, mylen);
}
- if (mybuf != 0) {
+ if (mybuf != NULL) {
for (n = 0; buf[n] != 0; ++n) {
mybuf[n] = (wchar_t) buf[n];
}
@@ -289,7 +289,7 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T *buf, int len)
{
char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);
- if (result != 0) {
+ if (result != NULL) {
int first = 0;
#if USE_WIDEC_SUPPORT
@@ -317,7 +317,7 @@ _nc_viscbuf2(int bufnum, const NCURSES_CH_T *buf, int len)
for (j = first; j <= last; ++j) {
const char *found = _nc_altcharset_name(attr, (chtype)
CharOf(buf[j]));
- if (found != 0) {
+ if (found != NULL) {
(void) _nc_trace_bufcat(bufnum, found);
attr &= ~A_ALTCHARSET;
} else
diff --git a/ncurses/tty/MKexpanded.sh b/ncurses/tty/MKexpanded.sh
index 0072be2cd35d..576959958020 100755
--- a/ncurses/tty/MKexpanded.sh
+++ b/ncurses/tty/MKexpanded.sh
@@ -1,6 +1,6 @@
#! /bin/sh
##############################################################################
-# Copyright 2019-2020,2021 Thomas E. Dickey #
+# Copyright 2019-2021,2024 Thomas E. Dickey #
# Copyright 1998-2015,2017 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
@@ -30,7 +30,7 @@
#
# Author: Thomas E. Dickey, 1997-on
#
-# $Id: MKexpanded.sh,v 1.24 2022/02/05 17:27:18 tom Exp $
+# $Id: MKexpanded.sh,v 1.25 2024/12/07 20:48:46 tom Exp $
#
# Script to generate 'expanded.c', a dummy source that contains functions
# corresponding to complex macros used in this library. By making functions,
@@ -127,7 +127,12 @@ _nc_UpdateAttrs (CARG_CH_T c)
EOF
$preprocessor $TMP 2>/dev/null | \
- sed -e '1,/^IGNORE$/d' -e 's/^@/#/' -e 's/^#[ ]*if_/#if /' -e "s,$TMP,expanded.c,"
+ sed -e '1,/^IGNORE$/d' \
+ -e 's/^@/#/' \
+ -e 's/^#[ ]*if_/#if /' \
+ -e "s,$TMP,expanded.c," \
+ -e 's/[ ][ ]*$//' \
+ -e '/^#[ ]*[0-9]/d'
cat <<EOF
#else /* ! NCURSES_EXPANDED */
diff --git a/ncurses/tty/hardscroll.c b/ncurses/tty/hardscroll.c
index 2b1f079e4b9e..767b97097db3 100644
--- a/ncurses/tty/hardscroll.c
+++ b/ncurses/tty/hardscroll.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 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 *
@@ -107,7 +107,7 @@ be moved out of order.
THE ALGORITHM
The scrolling is done in two passes. The first pass is from top to bottom
-scroling hunks UP. The second one is from bottom to top scrolling hunks DOWN.
+scrolling hunks UP. The second one is from bottom to top scrolling hunks DOWN.
Obviously enough, no lines to be scrolled will be destroyed. (lav)
HOW TO TEST THIS:
@@ -148,7 +148,7 @@ AUTHOR
#include <curses.priv.h>
-MODULE_ID("$Id: hardscroll.c,v 1.58 2023/09/09 16:04:08 Nicholas.Marriott Exp $")
+MODULE_ID("$Id: hardscroll.c,v 1.61 2025/02/15 15:12:54 tom Exp $")
#if defined(SCROLLDEBUG) || defined(HASHDEBUG)
@@ -169,7 +169,7 @@ extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
if OLDNUM(n) == _NEWINDEX, then the line n in new, not shifted from
somewhere. */
NCURSES_EXPORT_VAR (int *)
- _nc_oldnums = 0; /* obsolete: keep for ABI compat */
+ _nc_oldnums = NULL; /* obsolete: keep for ABI compat */
# if USE_HASHMAP
# define oldnums(sp) (sp)->_oldnum_list
@@ -196,7 +196,7 @@ NCURSES_SP_NAME(_nc_scroll_optimize) (NCURSES_SP_DCL0)
/* get enough storage */
assert(OLDNUM_SIZE(SP_PARM) >= 0);
assert(screen_lines(SP_PARM) > 0);
- if ((oldnums(SP_PARM) == 0)
+ if ((oldnums(SP_PARM) == NULL)
|| (OLDNUM_SIZE(SP_PARM) < screen_lines(SP_PARM))) {
int need_lines = ((OLDNUM_SIZE(SP_PARM) < screen_lines(SP_PARM))
? screen_lines(SP_PARM)
@@ -308,11 +308,11 @@ NCURSES_SP_NAME(_nc_linedump) (NCURSES_SP_DCL0)
/* dump the state of the real and virtual oldnum fields */
{
if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) {
- char *buf = 0;
+ char *buf = NULL;
size_t want = ((size_t) screen_lines(SP_PARM) + 1) * 4;
(void) SP_PARM;
- if ((buf = typeMalloc(char, want)) != 0) {
+ if ((buf = typeMalloc(char, want)) != NULL) {
int n;
*buf = '\0';
@@ -371,7 +371,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
do {
oldnums[n++] = atoi(st);
} while
- ((st = strtok((char *) NULL, " ")) != 0);
+ ((st = strtok((char *) NULL, " ")) != NULL);
/* display it */
(void) fputs("Initial input:\n", stderr);
diff --git a/ncurses/tty/hashmap.c b/ncurses/tty/hashmap.c
index e50b63847b99..1498f5fdee28 100644
--- a/ncurses/tty/hashmap.c
+++ b/ncurses/tty/hashmap.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2020,2023 Thomas E. Dickey *
+ * Copyright 2019-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 *
@@ -74,7 +74,7 @@ AUTHOR
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: hashmap.c,v 1.71 2023/09/16 16:28:53 tom Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.75 2025/07/26 19:48:34 tom Exp $")
#ifdef HASHDEBUG
@@ -120,15 +120,14 @@ static NCURSES_CH_T newtext[MAXLINES][TEXTWIDTH(sp)];
static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);
static NCURSES_INLINE unsigned long
-hash(SCREEN *sp, NCURSES_CH_T *text)
+hash(SCREEN *sp, const NCURSES_CH_T *text)
{
int i;
- NCURSES_CH_T ch;
unsigned long result = 0;
(void) sp;
for (i = TEXTWIDTH(sp); i > 0; i--) {
- ch = *text++;
+ NCURSES_CH_T ch = *text++;
result += (result << 5) + (unsigned long) HASH_VAL(ch);
}
return result;
@@ -312,10 +311,10 @@ NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_DCL0)
}
} else {
/* re-hash all */
- if (oldhash(SP_PARM) == 0)
+ if (oldhash(SP_PARM) == NULL)
oldhash(SP_PARM) = typeCalloc(unsigned long,
(size_t) screen_lines(SP_PARM));
- if (newhash(SP_PARM) == 0)
+ if (newhash(SP_PARM) == NULL)
newhash(SP_PARM) = typeCalloc(unsigned long,
(size_t) screen_lines(SP_PARM));
if (!oldhash(SP_PARM) || !newhash(SP_PARM)) {
@@ -504,7 +503,8 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
for (n = 0; n < screen_lines(sp); n++) {
reallines[n] = n;
oldnums[n] = _NEWINDEX;
- CharOf(oldtext[n][0]) = CharOf(newtext[n][0]) = '.';
+ SetChar(oldtext[n][0], '.', A_NORMAL);
+ SetChar(newtext[n][0], '.', A_NORMAL);
}
if (NC_ISATTY(fileno(stdin)))
@@ -533,27 +533,27 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
do {
oldnums[n++] = atoi(st);
} while
- ((st = strtok((char *) NULL, " ")) != 0);
+ ((st = strtok((char *) NULL, " ")) != NULL);
break;
case 'n': /* use following letters as text of new lines */
for (n = 0; n < screen_lines(sp); n++)
- CharOf(newtext[n][0]) = '.';
+ SetChar(newtext[n][0], '.', A_NORMAL);
for (n = 0; n < screen_lines(sp); n++)
if (line[n + 1] == '\n')
break;
else
- CharOf(newtext[n][0]) = line[n + 1];
+ SetChar(newtext[n][0], line[n + 1], A_NORMAL);
break;
case 'o': /* use following letters as text of old lines */
for (n = 0; n < screen_lines(sp); n++)
- CharOf(oldtext[n][0]) = '.';
+ SetChar(oldtext[n][0], '.', A_NORMAL);
for (n = 0; n < screen_lines(sp); n++)
if (line[n + 1] == '\n')
break;
else
- CharOf(oldtext[n][0]) = line[n + 1];
+ SetChar(oldtext[n][0], line[n + 1], A_NORMAL);
break;
case 'd': /* dump state of test arrays */
diff --git a/ncurses/tty/lib_mvcur.c b/ncurses/tty/lib_mvcur.c
index 8fad93c727ae..bddccc56a4e2 100644
--- a/ncurses/tty/lib_mvcur.c
+++ b/ncurses/tty/lib_mvcur.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 *
@@ -160,7 +160,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_mvcur.c,v 1.161 2023/09/16 16:29:02 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.167 2025/12/27 12:34:03 tom Exp $")
#define WANT_CHAR(sp, y, x) NewScreen(sp)->_line[y].text[x] /* desired state */
@@ -222,8 +222,8 @@ NCURSES_EXPORT(int)
NCURSES_SP_NAME(_nc_msec_cost) (NCURSES_SP_DCLx const char *const cap, int affcnt)
/* compute the cost of a given operation */
{
- if (cap == 0)
- return (INFINITY);
+ if (cap == NULL)
+ return (NC_INFINITY);
else {
const char *cp;
float cum_cost = 0.0;
@@ -287,7 +287,7 @@ normalized_cost(NCURSES_SP_DCLx const char *const cap, int affcnt)
/* compute the effective character-count for an operation (round up) */
{
int cost = NCURSES_SP_NAME(_nc_msec_cost) (NCURSES_SP_ARGx cap, affcnt);
- if (cost != INFINITY)
+ if (cost != NC_INFINITY)
cost = (cost + SP_PARM->_char_padding - 1) / SP_PARM->_char_padding;
return cost;
}
@@ -364,14 +364,14 @@ NCURSES_SP_NAME(_nc_mvcur_init) (NCURSES_SP_DCL0)
SP_PARM->_home_cost = CostOf(cursor_home, 0);
SP_PARM->_ll_cost = CostOf(cursor_to_ll, 0);
#if USE_HARD_TABS
- if (getenv("NCURSES_NO_HARD_TABS") == 0
+ if (getenv("NCURSES_NO_HARD_TABS") == NULL
&& dest_tabs_magic_smso == 0
&& HasHardTabs()) {
SP_PARM->_ht_cost = CostOf(tab, 0);
SP_PARM->_cbt_cost = CostOf(back_tab, 0);
} else {
- SP_PARM->_ht_cost = INFINITY;
- SP_PARM->_cbt_cost = INFINITY;
+ SP_PARM->_ht_cost = NC_INFINITY;
+ SP_PARM->_cbt_cost = NC_INFINITY;
}
#endif /* USE_HARD_TABS */
SP_PARM->_cub1_cost = CostOf(cursor_left, 0);
@@ -461,12 +461,12 @@ NCURSES_SP_NAME(_nc_mvcur_init) (NCURSES_SP_DCL0)
* nested on the various terminals (vt100, xterm, etc.) which use this
* feature.
*/
- if (save_cursor != 0
- && enter_ca_mode != 0
- && strstr(enter_ca_mode, save_cursor) != 0) {
+ if (save_cursor != NULL
+ && enter_ca_mode != NULL
+ && strstr(enter_ca_mode, save_cursor) != NULL) {
T(("...suppressed sc/rc capability due to conflict with smcup/rmcup"));
- save_cursor = 0;
- restore_cursor = 0;
+ save_cursor = NULL;
+ restore_cursor = NULL;
}
/*
@@ -543,12 +543,12 @@ repeated_append(string_desc * target, int total, int num, int repeat, const char
if (_nc_safe_strcat(target, src)) {
total += num;
} else {
- total = INFINITY;
+ total = NC_INFINITY;
break;
}
}
} else {
- total = INFINITY;
+ total = NC_INFINITY;
}
return total;
}
@@ -578,9 +578,9 @@ relative_move(NCURSES_SP_DCLx
(void) _nc_str_copy(&save, target);
if (to_y != from_y) {
- vcost = INFINITY;
+ vcost = NC_INFINITY;
- if (row_address != 0
+ if (row_address != NULL
&& _nc_safe_strcat(target, TIPARM_1(row_address, to_y))) {
vcost = SP_PARM->_vpa_cost;
}
@@ -617,8 +617,8 @@ relative_move(NCURSES_SP_DCLx
}
}
- if (vcost == INFINITY)
- return (INFINITY);
+ if (vcost == NC_INFINITY)
+ return (NC_INFINITY);
}
save = *target;
@@ -627,7 +627,7 @@ relative_move(NCURSES_SP_DCLx
char str[OPT_SIZE];
string_desc check;
- hcost = INFINITY;
+ hcost = NC_INFINITY;
if (column_address
&& _nc_safe_strcat(_nc_str_copy(target, &save),
@@ -658,7 +658,7 @@ relative_move(NCURSES_SP_DCLx
for (fr = from_x; (nxt = NEXTTAB(fr)) <= to_x; fr = nxt) {
lhcost = repeated_append(&check, lhcost,
SP_PARM->_ht_cost, 1, tab);
- if (lhcost == INFINITY)
+ if (lhcost == NC_INFINITY)
break;
}
@@ -751,7 +751,7 @@ relative_move(NCURSES_SP_DCLx
lhcost = repeated_append(&check, lhcost,
SP_PARM->_cbt_cost,
1, back_tab);
- if (lhcost == INFINITY)
+ if (lhcost == NC_INFINITY)
break;
}
@@ -770,8 +770,8 @@ relative_move(NCURSES_SP_DCLx
}
}
- if (hcost == INFINITY)
- return (INFINITY);
+ if (hcost == NC_INFINITY)
+ return (NC_INFINITY);
}
return (vcost + hcost);
@@ -798,7 +798,7 @@ onscreen_mvcur(NCURSES_SP_DCLx
{
string_desc result;
char buffer[OPT_SIZE];
- int tactic = 0, newcost, usecost = INFINITY;
+ int tactic = 0, newcost, usecost = NC_INFINITY;
int t5_cr_cost;
#if defined(MAIN) || defined(NCURSES_TEST)
@@ -846,7 +846,7 @@ onscreen_mvcur(NCURSES_SP_DCLx
&& ((newcost = relative_move(NCURSES_SP_ARGx
NullResult,
yold, xold,
- ynew, xnew, ovw)) != INFINITY)
+ ynew, xnew, ovw)) != NC_INFINITY)
&& newcost < usecost) {
tactic = 1;
usecost = newcost;
@@ -857,7 +857,7 @@ onscreen_mvcur(NCURSES_SP_DCLx
&& ((newcost = relative_move(NCURSES_SP_ARGx
NullResult,
yold, 0,
- ynew, xnew, ovw)) != INFINITY)
+ ynew, xnew, ovw)) != NC_INFINITY)
&& SP_PARM->_cr_cost + newcost < usecost) {
tactic = 2;
usecost = SP_PARM->_cr_cost + newcost;
@@ -868,7 +868,7 @@ onscreen_mvcur(NCURSES_SP_DCLx
&& ((newcost = relative_move(NCURSES_SP_ARGx
NullResult,
0, 0,
- ynew, xnew, ovw)) != INFINITY)
+ ynew, xnew, ovw)) != NC_INFINITY)
&& SP_PARM->_home_cost + newcost < usecost) {
tactic = 3;
usecost = SP_PARM->_home_cost + newcost;
@@ -879,7 +879,7 @@ onscreen_mvcur(NCURSES_SP_DCLx
&& ((newcost = relative_move(NCURSES_SP_ARGx
NullResult,
screen_lines(SP_PARM) - 1, 0,
- ynew, xnew, ovw)) != INFINITY)
+ ynew, xnew, ovw)) != NC_INFINITY)
&& SP_PARM->_ll_cost + newcost < usecost) {
tactic = 4;
usecost = SP_PARM->_ll_cost + newcost;
@@ -895,7 +895,7 @@ onscreen_mvcur(NCURSES_SP_DCLx
&& ((newcost = relative_move(NCURSES_SP_ARGx
NullResult,
yold - 1, screen_columns(SP_PARM) - 1,
- ynew, xnew, ovw)) != INFINITY)
+ ynew, xnew, ovw)) != NC_INFINITY)
&& t5_cr_cost + SP_PARM->_cub1_cost + newcost < usecost) {
tactic = 5;
usecost = t5_cr_cost + SP_PARM->_cub1_cost + newcost;
@@ -948,15 +948,15 @@ onscreen_mvcur(NCURSES_SP_DCLx
nonlocal:
#if defined(MAIN) || defined(NCURSES_TEST)
gettimeofday(&after, NULL);
- diff = after.tv_usec - before.tv_usec
- + (after.tv_sec - before.tv_sec) * 1000000;
+ diff = (float) (after.tv_usec - before.tv_usec
+ + (after.tv_sec - before.tv_sec) * 1000000);
if (!profiling)
(void) fprintf(stderr,
"onscreen: %d microsec, %f 28.8Kbps char-equivalents\n",
(int) diff, diff / 288);
#endif /* MAIN */
- if (usecost != INFINITY) {
+ if (usecost != NC_INFINITY) {
TR(TRACE_MOVE, ("mvcur tactic %d", tactic));
TPUTS_TRACE("mvcur");
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
@@ -984,7 +984,7 @@ _nc_real_mvcur(NCURSES_SP_DCLx
TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("_nc_real_mvcur(%p,%d,%d,%d,%d)"),
(void *) SP_PARM, yold, xold, ynew, xnew));
- if (SP_PARM == 0) {
+ if (SP_PARM == NULL) {
code = ERR;
} else if (yold == ynew && xold == xnew) {
code = OK;
@@ -1079,7 +1079,7 @@ NCURSES_SP_NAME(_nc_mvcur) (NCURSES_SP_DCLx
* external calls. Flush the output if the screen has not been
* initialized, e.g., when used from low-level terminfo programs.
*/
- if ((SP_PARM != 0) && (SP_PARM->_endwin == ewInitial))
+ if ((SP_PARM != NULL) && (SP_PARM->_endwin == ewInitial))
NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
return rc;
}
@@ -1093,7 +1093,7 @@ _nc_mvcur(int yold, int xold,
}
#endif
-#if defined(USE_TERM_DRIVER)
+#if USE_TERM_DRIVER
/*
* The terminal driver does not support the external "mvcur()".
*/
@@ -1106,7 +1106,7 @@ TINFO_MVCUR(NCURSES_SP_DCLx int yold, int xold, int ynew, int xnew)
ynew, xnew,
NCURSES_SP_NAME(_nc_outch),
TRUE);
- if ((SP_PARM != 0) && (SP_PARM->_endwin == ewInitial))
+ if ((SP_PARM != NULL) && (SP_PARM->_endwin == ewInitial))
NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
return rc;
@@ -1227,7 +1227,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
if (fputs("> ", stdout) == EOF)
break;
- if (fgets(buf, sizeof(buf), stdin) == 0)
+ if (fgets(buf, sizeof(buf), stdin) == NULL)
break;
#define PUTS(s) (void) puts(s)
@@ -1307,7 +1307,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
} else if (buf[0] == 'i') {
dump_init(NULL, F_TERMINFO, S_TERMINFO,
FALSE, 70, 0, 0, FALSE, FALSE, 0);
- dump_entry(&TerminalType(cur_term), FALSE, TRUE, 0, 0);
+ dump_entry(&TerminalType(cur_term), FALSE, TRUE, 0, NULL);
putchar('\n');
} else if (buf[0] == 'o') {
if (_nc_optimize_enable & OPTIMIZE_MVCUR) {
@@ -1338,7 +1338,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
* is winning.
*/
else if (sscanf(buf, "t %d", &n) == 1) {
- float cumtime = 0.0, perchar;
+ double cumtime = 0.0, perchar;
int speeds[] =
{2400, 9600, 14400, 19200, 28800, 38400, 0};
@@ -1384,14 +1384,14 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
* transmission both. Transmission time is an estimate
* assuming 9 bits/char, 8 bits + 1 stop bit.
*/
- float totalest = cumtime + xmits * 9 * 1e6 / speeds[i];
+ double totalest = cumtime + (double) xmits * 9 * 1e6 / speeds[i];
/*
* Per-character optimization overhead in character transmits
* at the current speed. Round this to the nearest integer
* to figure COMPUTE_OVERHEAD for the speed.
*/
- float overhead = speeds[i] * perchar / 1e6;
+ double overhead = speeds[i] * perchar / 1e6;
(void)
printf("%6d bps: %3.2f char-xmits overhead; total estimated time %15.2f\n",
diff --git a/ncurses/tty/lib_tstp.c b/ncurses/tty/lib_tstp.c
index dd925c7efd12..3bd872c1dcf1 100644
--- a/ncurses/tty/lib_tstp.c
+++ b/ncurses/tty/lib_tstp.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020-2021,2022 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 *
@@ -43,7 +43,7 @@
#include <SigAction.h>
-MODULE_ID("$Id: lib_tstp.c,v 1.54 2022/12/24 22:22:10 tom Exp $")
+MODULE_ID("$Id: lib_tstp.c,v 1.59 2025/02/15 14:52:13 tom Exp $")
#if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC)
#define USE_SIGTSTP 1
@@ -159,7 +159,7 @@ handle_SIGTSTP(int dummy GCC_UNUSED)
*
* Don't do this if we're not in curses -
*/
- if (sp != 0 && (sp->_endwin == ewRunning))
+ if (sp != NULL && (sp->_endwin == ewRunning))
#if HAVE_TCGETPGRP
if (tcgetpgrp(STDIN_FILENO) == getpgrp())
#endif
@@ -269,7 +269,7 @@ handle_SIGINT(int sig)
{
SCREEN *scan;
for (each_screen(scan)) {
- if (scan->_ofp != 0
+ if (scan->_ofp != NULL
&& NC_ISATTY(fileno(scan->_ofp))) {
scan->_outch = NCURSES_SP_NAME(_nc_outch);
}
@@ -294,7 +294,7 @@ _nc_set_read_thread(bool enable)
# endif
_nc_globals.read_thread = pthread_self();
} else {
- _nc_globals.read_thread = 0;
+ _nc_globals.read_thread = (pthread_t) 0;
}
_nc_unlock_global(curses);
}
@@ -310,7 +310,7 @@ handle_SIGWINCH(int sig GCC_UNUSED)
if (_nc_globals.read_thread) {
if (!pthread_equal(pthread_self(), _nc_globals.read_thread))
pthread_kill(_nc_globals.read_thread, SIGWINCH);
- _nc_globals.read_thread = 0;
+ _nc_globals.read_thread = (pthread_t) 0;
}
# endif
}
@@ -367,8 +367,8 @@ CatchIfDefault(int sig, void (*handler) (int))
result = FALSE;
}
#endif
- T(("CatchIfDefault - will %scatch %s",
- result ? "" : "not ", signal_name(sig)));
+ T(("CatchIfDefault - will%s catch %s",
+ result ? "" : " not", signal_name(sig)));
return result;
}
diff --git a/ncurses/tty/lib_twait.c b/ncurses/tty/lib_twait.c
index 6fa73eedb4ce..8bb7d129977e 100644
--- a/ncurses/tty/lib_twait.c
+++ b/ncurses/tty/lib_twait.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,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 *
@@ -76,7 +76,7 @@
#endif
#undef CUR
-MODULE_ID("$Id: lib_twait.c,v 1.81 2023/09/16 16:30:40 tom Exp $")
+MODULE_ID("$Id: lib_twait.c,v 1.85 2025/03/01 17:07:19 tom Exp $")
/*
* Returns an elapsed time, in milliseconds (if possible).
@@ -120,7 +120,7 @@ _nc_eventlist_timeout(_nc_eventlist * evl)
{
int event_delay = -1;
- if (evl != 0) {
+ if (evl != NULL) {
int n;
for (n = 0; n < evl->count; ++n) {
@@ -168,7 +168,7 @@ _nc_eventlist_timeout(_nc_eventlist * evl)
* descriptors.
*/
NCURSES_EXPORT(int)
-_nc_timed_wait(SCREEN *sp MAYBE_UNUSED,
+_nc_timed_wait(const SCREEN *sp MAYBE_UNUSED,
int mode MAYBE_UNUSED,
int milliseconds,
int *timeleft
@@ -242,7 +242,7 @@ _nc_timed_wait(SCREEN *sp MAYBE_UNUSED,
if ((mode & TW_EVENT) && evl) {
if (fds == fd_list)
fds = typeMalloc(struct pollfd, MIN_FDS + evl->count);
- if (fds == 0)
+ if (fds == NULL)
return TW_NONE;
}
#endif
@@ -273,7 +273,7 @@ _nc_timed_wait(SCREEN *sp MAYBE_UNUSED,
}
#endif
- result = poll(fds, (size_t) count, milliseconds);
+ result = (int) poll(fds, (size_t) count, milliseconds);
#ifdef NCURSES_WGETCH_EVENTS
if ((mode & TW_EVENT) && evl) {
diff --git a/ncurses/tty/lib_vidattr.c b/ncurses/tty/lib_vidattr.c
index 2c7a0b27bd6d..860ef86fd4ef 100644
--- a/ncurses/tty/lib_vidattr.c
+++ b/ncurses/tty/lib_vidattr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2023 Thomas E. Dickey *
+ * Copyright 2018-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 *
@@ -70,7 +70,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_vidattr.c,v 1.79 2023/04/28 20:59:26 tom Exp $")
+MODULE_ID("$Id: lib_vidattr.c,v 1.81 2025/12/27 12:41:23 tom Exp $")
#define doPut(mode) \
TPUTS_TRACE(#mode); \
@@ -114,9 +114,9 @@ NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx
attr_t turn_on, turn_off;
int pair;
bool reverse = FALSE;
- bool can_color = (SP_PARM == 0 || SP_PARM->_coloron);
+ bool can_color = (SP_PARM == NULL || SP_PARM->_coloron);
#if NCURSES_EXT_FUNCS
- bool fix_pair0 = (SP_PARM != 0 && SP_PARM->_coloron && !SP_PARM->_default_color);
+ bool fix_pair0 = (SP_PARM != NULL && SP_PARM->_coloron && !SP_PARM->_default_color);
#else
#define fix_pair0 FALSE
#endif
@@ -134,7 +134,7 @@ NCURSES_SP_NAME(vidputs) (NCURSES_SP_DCLx
TR(TRACE_ATTRS, ("previous attribute was %s", _traceattr(PreviousAttr)));
- if ((SP_PARM != 0)
+ if ((SP_PARM != NULL)
&& (magic_cookie_glitch > 0)) {
#if USE_XMC_SUPPORT
static const chtype table[] =
@@ -380,7 +380,7 @@ NCURSES_SP_NAME(termattrs) (NCURSES_SP_DCL0)
T((T_CALLED("termattrs(%p)"), (void *) SP_PARM));
if (HasTerminal(SP_PARM)) {
-#ifdef USE_TERM_DRIVER
+#if USE_TERM_DRIVER
attrs = CallDriver(SP_PARM, td_conattr);
#else /* ! USE_TERM_DRIVER */
diff --git a/ncurses/tty/tty_update.c b/ncurses/tty/tty_update.c
index 0427024cb084..93dd5971f162 100644
--- a/ncurses/tty/tty_update.c
+++ b/ncurses/tty/tty_update.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 *
@@ -85,7 +85,13 @@
#include <ctype.h>
-MODULE_ID("$Id: tty_update.c,v 1.316 2024/02/04 00:09:34 tom Exp $")
+#if USE_WIDEC_SUPPORT
+#if HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
+#endif
+
+MODULE_ID("$Id: tty_update.c,v 1.323 2025/12/27 12:34:03 tom Exp $")
/*
* This define controls the line-breakout optimization. Every once in a
@@ -211,7 +217,7 @@ GoTo(NCURSES_SP_DCLx int const row, int const col)
}
#if !NCURSES_WCWIDTH_GRAPHICS
-#define is_wacs_value(ch) (_nc_wacs_width(ch) == 1 && wcwidth(ch) > 1)
+#define is_wacs_value(ch) (_nc_wacs_width((wchar_t) ch) == 1 && wcwidth(ch) > 1)
#endif /* !NCURSES_WCWIDTH_GRAPHICS */
static NCURSES_INLINE void
@@ -256,13 +262,15 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
* not checked.
*/
if (is8bits(CharOf(CHDEREF(ch)))
- && (!is7bits(CharOf(CHDEREF(ch))) && _nc_unicode_locale())
&& (isprint(CharOf(CHDEREF(ch)))
+#if USE_WIDEC_SUPPORT
+ || iswprint((wint_t) CharOf(CHDEREF(ch)))
+#endif
|| (SP_PARM->_legacy_coding > 0 && CharOf(CHDEREF(ch)) >= 160)
|| (SP_PARM->_legacy_coding > 1 && CharOf(CHDEREF(ch)) >= 128)
|| (AttrOf(attr) & A_ALTCHARSET
&& ((CharOfD(ch) < ACS_LEN
- && SP_PARM->_acs_map != 0
+ && SP_PARM->_acs_map != NULL
&& SP_PARM->_acs_map[CharOfD(ch)] != 0)
|| (CharOfD(ch) >= 128))))) {
;
@@ -275,7 +283,7 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
#endif
if ((AttrOf(attr) & A_ALTCHARSET)
- && SP_PARM->_acs_map != 0
+ && SP_PARM->_acs_map != NULL
&& ((CharOfD(ch) < ACS_LEN)
#if !NCURSES_WCWIDTH_GRAPHICS
|| is_wacs_value(CharOfD(ch))
@@ -283,7 +291,7 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
)) {
int c8;
my_ch = CHDEREF(ch); /* work around const param */
- c8 = CharOf(my_ch);
+ c8 = (int) CharOf(my_ch);
#if USE_WIDEC_SUPPORT
/*
* This is crude & ugly, but works most of the time. It checks if the
@@ -331,7 +339,7 @@ PutAttrChar(NCURSES_SP_DCLx CARG_CH_T ch)
* drawing flavors are integrated.
*/
if (AttrOf(attr) & A_ALTCHARSET) {
- int j = CharOfD(ch);
+ int j = (int) CharOfD(ch);
chtype temp = UChar(SP_PARM->_acs_map[j]);
if (temp != 0) {
@@ -621,7 +629,7 @@ EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T *ntext, int num)
} else {
return 1; /* cursor stays in the middle */
}
- } else if (repeat_char != 0 &&
+ } else if (repeat_char != NULL &&
#if BSD_TPUTS
!isdigit(UChar(CharOf(ntext0))) &&
#endif
@@ -643,7 +651,7 @@ EmitRange(NCURSES_SP_DCLx const NCURSES_CH_T *ntext, int num)
UpdateAttrs(SP_PARM, ntext0);
temp = ntext0;
if ((AttrOf(temp) & A_ALTCHARSET) &&
- SP_PARM->_acs_map != 0 &&
+ SP_PARM->_acs_map != NULL &&
(SP_PARM->_acs_map[CharOf(temp)] & A_CHARTEXT) != 0) {
SetChar(temp,
(SP_PARM->_acs_map[CharOf(ntext0)] & A_CHARTEXT),
@@ -745,7 +753,7 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0)
_nc_lock_global(update);
- if (SP_PARM == 0) {
+ if (SP_PARM == NULL) {
_nc_unlock_global(update);
returnCode(ERR);
}
@@ -762,7 +770,7 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0)
if (SP_PARM == CURRENT_SCREEN) {
#endif
#define SyncScreens(internal,exported) \
- if (internal == 0) internal = exported; \
+ if (internal == NULL) internal = exported; \
if (internal != exported) exported = internal
SyncScreens(CurScreen(SP_PARM), curscr);
@@ -773,9 +781,9 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0)
#endif
#endif /* !USE_REENTRANT */
- if (CurScreen(SP_PARM) == 0
- || NewScreen(SP_PARM) == 0
- || StdScreen(SP_PARM) == 0) {
+ if (CurScreen(SP_PARM) == NULL
+ || NewScreen(SP_PARM) == NULL
+ || StdScreen(SP_PARM) == NULL) {
_nc_unlock_global(update);
returnCode(ERR);
}
@@ -1091,7 +1099,7 @@ TINFO_DOUPDATE(NCURSES_SP_DCL0)
returnCode(OK);
}
-#if NCURSES_SP_FUNCS && !defined(USE_TERM_DRIVER)
+#if NCURSES_SP_FUNCS && !USE_TERM_DRIVER
NCURSES_EXPORT(int)
doupdate(void)
{
@@ -1132,7 +1140,7 @@ static void
ClrUpdate(NCURSES_SP_DCL0)
{
TR(TRACE_UPDATE, (T_CALLED("ClrUpdate")));
- if (0 != SP_PARM) {
+ if (NULL != SP_PARM) {
int i;
NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM));
int nonempty = Min(screen_lines(SP_PARM),
@@ -1159,7 +1167,7 @@ ClrUpdate(NCURSES_SP_DCL0)
static void
ClrToEOL(NCURSES_SP_DCLx NCURSES_CH_T blank, int needclear)
{
- if (CurScreen(SP_PARM) != 0
+ if (CurScreen(SP_PARM) != NULL
&& SP_PARM->_cursrow >= 0) {
int j;
@@ -2223,7 +2231,7 @@ _nc_screen_init(void)
NCURSES_EXPORT(void)
NCURSES_SP_NAME(_nc_screen_wrap) (NCURSES_SP_DCL0)
{
- if (SP_PARM != 0) {
+ if (SP_PARM != NULL) {
UpdateAttrs(SP_PARM, normal);
#if NCURSES_EXT_FUNCS
@@ -2265,7 +2273,7 @@ _nc_screen_wrap(void)
NCURSES_EXPORT(void)
NCURSES_SP_NAME(_nc_do_xmc_glitch) (NCURSES_SP_DCLx attr_t previous)
{
- if (SP_PARM != 0) {
+ if (SP_PARM != NULL) {
attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP_PARM)));
while (chg != 0) {
diff --git a/ncurses/wcwidth.h b/ncurses/wcwidth.h
index 76673da65845..4cab2d504aea 100644
--- a/ncurses/wcwidth.h
+++ b/ncurses/wcwidth.h
@@ -1,4 +1,57 @@
+/* $Id: wcwidth.h,v 1.10 2025/10/31 23:10:59 tom Exp $ */
+
/*
+ * Copyright 2002-2024,2025 by Thomas E. Dickey
+ *
+ * All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *-----------------------------------------------------------------------------
+ * This is an updated version of Markus Kuhn's implementation of wcwidth.
+ *
+ * Originally added to xterm in 2000 (patch #141), there were a couple of
+ * updates from Kuhn until 2005 (patch #202), renaming entrypoints and applying
+ * data from Unicode.org (e.g., 3.2, 4.0, 4.1.0). The Unicode data is
+ * transformed into tables in this file by a script "uniset" written by Kuhn.
+ *
+ * While Kuhn implemented the original CJK variant, it was unused by xterm
+ * until Jungshik Shin used it in 2002 to implement the -cjk_width command-line
+ * option.
+ *
+ * Kuhn added a check for the vertical forms block (double-width) in 2007;
+ * other updates were derived from the Unicode.org data (release 5.0).
+ *
+ * Since then, additional updates have been made:
+ * + data-type fixes
+ * + new Unicode releases (6.2.0, 9.0.0, etc),
+ * + additional special symbol blocks have been added to the special cases.
+ * + soft-hyphen behavior has been made configurable.
+ * + added table shows when a character is not part of Unicode.
+ *
+ * Kuhn's original header follows giving the design information:
+ *-----------------------------------------------------------------------------
* This is an implementation of wcwidth() and wcswidth() (defined in
* IEEE Std 1002.1-2001) for Unicode.
*
@@ -50,52 +103,73 @@
*
* http://www.unicode.org/unicode/reports/tr11/
*
- * Markus Kuhn -- 2007-05-26 (Unicode 5.0)
+ * Markus Kuhn -- 2007-05-25 (Unicode 5.0)
*
* Permission to use, copy, modify, and distribute this software
* for any purpose and without fee is hereby granted. The author
* disclaims all warranties with regard to this software.
*
* Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
+ *-----------------------------------------------------------------------------
*/
#ifndef _WCWIDTH_H_incl
#define _WCWIDTH_H_incl 1
-#ifdef __cplusplus
-extern "C" {
+#ifdef TEST_DRIVER
+#include <stdio.h>
+#include <stdlib.h> /* EXIT_SUCCESS, etc. */
+#include <unistd.h> /* getopt() */
+#include <string.h> /* strncmp() */
+#include <locale.h> /* setlocale() */
+#include <wctype.h> /* this module */
#endif
#include <ncurses_cfg.h>
#include <ncurses_dll.h>
#include <wchar.h>
+#include <stdint.h>
struct interval {
- int first;
- int last;
+ unsigned long first;
+ unsigned long last;
};
+static int use_latin1 = 1;
+
/* auxiliary function for binary search in interval table */
-static int bisearch(wchar_t ucs, const struct interval *table, int max) {
- int min = 0;
- int mid;
+static int
+bisearch(unsigned long ucs, const struct interval *table, int max)
+{
+
+ if (ucs >= table[0].first && ucs <= table[max].last) {
+ int min = 0;
+
+ while (max >= min) {
+ int mid;
+
+ mid = (min + max) / 2;
+ if (ucs > table[mid].last)
+ min = mid + 1;
+ else if (ucs < table[mid].first)
+ max = mid - 1;
+ else
+ return 1;
+ }
+ }
- if (ucs < table[0].first || ucs > table[max].last)
return 0;
- while (max >= min) {
- mid = (min + max) / 2;
- if (ucs > table[mid].last)
- min = mid + 1;
- else if (ucs < table[mid].first)
- max = mid - 1;
- else
- return 1;
- }
-
- return 0;
}
+/*
+ * Provide a way to change the behavior of soft-hyphen.
+ */
+void
+mk_wcwidth_init(int mode)
+{
+ use_latin1 = (mode == 0);
+}
/* The following two functions define the column width of an ISO 10646
* character as follows:
@@ -109,7 +183,10 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max) {
* category code Mn or Me in the Unicode database) have a
* column width of 0.
*
- * - SOFT HYPHEN (U+00AD) has a column width of 1.
+ * - A few spacing combining marks have a column width of 0.
+ *
+ * - SOFT HYPHEN (U+00AD) has a column width of 1 in Latin-1, 0 in Unicode.
+ * An initialization function is used to switch between the two.
*
* - Other format characters (general category code Cf in the Unicode
* database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
@@ -117,133 +194,606 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max) {
* - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
* have a column width of 0.
*
+ * - Hangul Jamo Extended-B medial vowels and final consonants for old
+ * Korean (U+D7B0-U+D7FF) have a column width of 0.
+ *
* - Spacing characters in the East Asian Wide (W) or East Asian
* Full-width (F) category as defined in Unicode Technical
- * Report #11 have a column width of 2.
+ * Report #11 have a column width of 2. In that report, some codes
+ * were unassigned. Characters in these blocks use a column width of 1:
+ * 4DC0..4DFF; Yijing Hexagram Symbols
+ * A960..A97F; Hangul Jamo Extended-A
*
* - All remaining characters (including all printable
* ISO 8859-1 and WGL4 characters, Unicode control characters,
* etc.) have a column width of 1.
*
+ * - Codes which do not correspond to a Unicode character have a column
+ * width of -1.
+ *
* This implementation assumes that wchar_t characters are encoded
* in ISO 10646.
*/
-NCURSES_EXPORT(int) mk_wcwidth(wchar_t ucs)
+NCURSES_EXPORT(int)
+mk_wcwidth(uint32_t ucs)
{
- /* sorted list of non-overlapping intervals of non-spacing characters */
- /* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */
+ unsigned long cmp = (unsigned long) ucs;
+
+ /* sorted list of non-overlapping intervals of formatting characters */
+ /* generated by
+ * uniset +cat=Cf -00AD -0600-0605 -061C -06DD -070F c
+ */
+ /* *INDENT-OFF* */
+ /* generated by run-uniset_ctl 1.2 */
+ static const struct interval formatting[] = {
+ { 0x0890, 0x0891 }, { 0x08E2, 0x08E2 }, { 0x180E, 0x180E },
+ { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2064 },
+ { 0x2066, 0x206F }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB },
+ { 0x110BD, 0x110BD }, { 0x110CD, 0x110CD }, { 0x13430, 0x1343F },
+ { 0x1BCA0, 0x1BCA3 }, { 0x1D173, 0x1D17A }, { 0xE0001, 0xE0001 },
+ { 0xE0020, 0xE007F }
+ };
+ /* *INDENT-ON* */
+
+ /* sorted list of non-overlapping intervals of non-spacing characters */
+ /* generated by
+ * uniset +cat=Me +cat=Mn +0600-0605 +061C +06DD +070F +1160-11FF +D7B0-D7C6 +D7CB-D7FB c
+ */
+ /* *INDENT-OFF* */
+ /* generated by run-uniset 1.10 */
static const struct interval combining[] = {
- { 0x0300, 0x036F }, { 0x0483, 0x0486 }, { 0x0488, 0x0489 },
- { 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
- { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 },
- { 0x0610, 0x0615 }, { 0x064B, 0x065E }, { 0x0670, 0x0670 },
- { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
- { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
- { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0901, 0x0902 },
- { 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D },
- { 0x0951, 0x0954 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 },
- { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD },
- { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C },
- { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D },
- { 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC },
- { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD },
- { 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C },
- { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D },
- { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 },
- { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 },
- { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBC, 0x0CBC },
- { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
- { 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D },
+ { 0x0300, 0x036F }, { 0x0483, 0x0489 }, { 0x0591, 0x05BD },
+ { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, { 0x05C4, 0x05C5 },
+ { 0x05C7, 0x05C7 }, { 0x0600, 0x0605 }, { 0x0610, 0x061A },
+ { 0x061C, 0x061C }, { 0x064B, 0x065F }, { 0x0670, 0x0670 },
+ { 0x06D6, 0x06DD }, { 0x06DF, 0x06E4 }, { 0x06E7, 0x06E8 },
+ { 0x06EA, 0x06ED }, { 0x070F, 0x070F }, { 0x0711, 0x0711 },
+ { 0x0730, 0x074A }, { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 },
+ { 0x07FD, 0x07FD }, { 0x0816, 0x0819 }, { 0x081B, 0x0823 },
+ { 0x0825, 0x0827 }, { 0x0829, 0x082D }, { 0x0859, 0x085B },
+ { 0x0897, 0x089F }, { 0x08CA, 0x08E1 }, { 0x08E3, 0x0902 },
+ { 0x093A, 0x093A }, { 0x093C, 0x093C }, { 0x0941, 0x0948 },
+ { 0x094D, 0x094D }, { 0x0951, 0x0957 }, { 0x0962, 0x0963 },
+ { 0x0981, 0x0981 }, { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 },
+ { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 }, { 0x09FE, 0x09FE },
+ { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 },
+ { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A51, 0x0A51 },
+ { 0x0A70, 0x0A71 }, { 0x0A75, 0x0A75 }, { 0x0A81, 0x0A82 },
+ { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 },
+ { 0x0ACD, 0x0ACD }, { 0x0AE2, 0x0AE3 }, { 0x0AFA, 0x0AFF },
+ { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F },
+ { 0x0B41, 0x0B44 }, { 0x0B4D, 0x0B4D }, { 0x0B55, 0x0B56 },
+ { 0x0B62, 0x0B63 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 },
+ { 0x0BCD, 0x0BCD }, { 0x0C00, 0x0C00 }, { 0x0C04, 0x0C04 },
+ { 0x0C3C, 0x0C3C }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 },
+ { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0C62, 0x0C63 },
+ { 0x0C81, 0x0C81 }, { 0x0CBC, 0x0CBC }, { 0x0CBF, 0x0CBF },
+ { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, { 0x0CE2, 0x0CE3 },
+ { 0x0D00, 0x0D01 }, { 0x0D3B, 0x0D3C }, { 0x0D41, 0x0D44 },
+ { 0x0D4D, 0x0D4D }, { 0x0D62, 0x0D63 }, { 0x0D81, 0x0D81 },
{ 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 },
{ 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E },
- { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC },
- { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 },
- { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E },
- { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 },
- { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 },
- { 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 },
- { 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x135F, 0x135F },
- { 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 },
- { 0x1772, 0x1773 }, { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD },
- { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD },
- { 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 },
- { 0x1927, 0x1928 }, { 0x1932, 0x1932 }, { 0x1939, 0x193B },
- { 0x1A17, 0x1A18 }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 },
- { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 },
- { 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF },
- { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 },
- { 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F },
- { 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B },
- { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F },
- { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB },
+ { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EBC }, { 0x0EC8, 0x0ECE },
+ { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 },
+ { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 },
+ { 0x0F86, 0x0F87 }, { 0x0F8D, 0x0F97 }, { 0x0F99, 0x0FBC },
+ { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1037 },
+ { 0x1039, 0x103A }, { 0x103D, 0x103E }, { 0x1058, 0x1059 },
+ { 0x105E, 0x1060 }, { 0x1071, 0x1074 }, { 0x1082, 0x1082 },
+ { 0x1085, 0x1086 }, { 0x108D, 0x108D }, { 0x109D, 0x109D },
+ { 0x1160, 0x11FF }, { 0x135D, 0x135F }, { 0x1712, 0x1714 },
+ { 0x1732, 0x1733 }, { 0x1752, 0x1753 }, { 0x1772, 0x1773 },
+ { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 },
+ { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD }, { 0x180B, 0x180D },
+ { 0x180F, 0x180F }, { 0x1885, 0x1886 }, { 0x18A9, 0x18A9 },
+ { 0x1920, 0x1922 }, { 0x1927, 0x1928 }, { 0x1932, 0x1932 },
+ { 0x1939, 0x193B }, { 0x1A17, 0x1A18 }, { 0x1A1B, 0x1A1B },
+ { 0x1A56, 0x1A56 }, { 0x1A58, 0x1A5E }, { 0x1A60, 0x1A60 },
+ { 0x1A62, 0x1A62 }, { 0x1A65, 0x1A6C }, { 0x1A73, 0x1A7C },
+ { 0x1A7F, 0x1A7F }, { 0x1AB0, 0x1ADD }, { 0x1AE0, 0x1AEB },
+ { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 }, { 0x1B36, 0x1B3A },
+ { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 }, { 0x1B6B, 0x1B73 },
+ { 0x1B80, 0x1B81 }, { 0x1BA2, 0x1BA5 }, { 0x1BA8, 0x1BA9 },
+ { 0x1BAB, 0x1BAD }, { 0x1BE6, 0x1BE6 }, { 0x1BE8, 0x1BE9 },
+ { 0x1BED, 0x1BED }, { 0x1BEF, 0x1BF1 }, { 0x1C2C, 0x1C33 },
+ { 0x1C36, 0x1C37 }, { 0x1CD0, 0x1CD2 }, { 0x1CD4, 0x1CE0 },
+ { 0x1CE2, 0x1CE8 }, { 0x1CED, 0x1CED }, { 0x1CF4, 0x1CF4 },
+ { 0x1CF8, 0x1CF9 }, { 0x1DC0, 0x1DFF }, { 0x20D0, 0x20F0 },
+ { 0x2CEF, 0x2CF1 }, { 0x2D7F, 0x2D7F }, { 0x2DE0, 0x2DFF },
+ { 0x302A, 0x302D }, { 0x3099, 0x309A }, { 0xA66F, 0xA672 },
+ { 0xA674, 0xA67D }, { 0xA69E, 0xA69F }, { 0xA6F0, 0xA6F1 },
+ { 0xA802, 0xA802 }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B },
+ { 0xA825, 0xA826 }, { 0xA82C, 0xA82C }, { 0xA8C4, 0xA8C5 },
+ { 0xA8E0, 0xA8F1 }, { 0xA8FF, 0xA8FF }, { 0xA926, 0xA92D },
+ { 0xA947, 0xA951 }, { 0xA980, 0xA982 }, { 0xA9B3, 0xA9B3 },
+ { 0xA9B6, 0xA9B9 }, { 0xA9BC, 0xA9BD }, { 0xA9E5, 0xA9E5 },
+ { 0xAA29, 0xAA2E }, { 0xAA31, 0xAA32 }, { 0xAA35, 0xAA36 },
+ { 0xAA43, 0xAA43 }, { 0xAA4C, 0xAA4C }, { 0xAA7C, 0xAA7C },
+ { 0xAAB0, 0xAAB0 }, { 0xAAB2, 0xAAB4 }, { 0xAAB7, 0xAAB8 },
+ { 0xAABE, 0xAABF }, { 0xAAC1, 0xAAC1 }, { 0xAAEC, 0xAAED },
+ { 0xAAF6, 0xAAF6 }, { 0xABE5, 0xABE5 }, { 0xABE8, 0xABE8 },
+ { 0xABED, 0xABED }, { 0xD7B0, 0xD7C6 }, { 0xD7CB, 0xD7FB },
+ { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F }, { 0xFE20, 0xFE2F },
+ { 0x101FD, 0x101FD }, { 0x102E0, 0x102E0 }, { 0x10376, 0x1037A },
{ 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F },
- { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 },
- { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD },
- { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F },
- { 0xE0100, 0xE01EF }
+ { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x10AE5, 0x10AE6 },
+ { 0x10D24, 0x10D27 }, { 0x10D69, 0x10D6D }, { 0x10EAB, 0x10EAC },
+ { 0x10EFA, 0x10EFF }, { 0x10F46, 0x10F50 }, { 0x10F82, 0x10F85 },
+ { 0x11001, 0x11001 }, { 0x11038, 0x11046 }, { 0x11070, 0x11070 },
+ { 0x11073, 0x11074 }, { 0x1107F, 0x11081 }, { 0x110B3, 0x110B6 },
+ { 0x110B9, 0x110BA }, { 0x110C2, 0x110C2 }, { 0x11100, 0x11102 },
+ { 0x11127, 0x1112B }, { 0x1112D, 0x11134 }, { 0x11173, 0x11173 },
+ { 0x11180, 0x11181 }, { 0x111B6, 0x111BE }, { 0x111C9, 0x111CC },
+ { 0x111CF, 0x111CF }, { 0x1122F, 0x11231 }, { 0x11234, 0x11234 },
+ { 0x11236, 0x11237 }, { 0x1123E, 0x1123E }, { 0x11241, 0x11241 },
+ { 0x112DF, 0x112DF }, { 0x112E3, 0x112EA }, { 0x11300, 0x11301 },
+ { 0x1133B, 0x1133C }, { 0x11340, 0x11340 }, { 0x11366, 0x1136C },
+ { 0x11370, 0x11374 }, { 0x113BB, 0x113C0 }, { 0x113CE, 0x113CE },
+ { 0x113D0, 0x113D0 }, { 0x113D2, 0x113D2 }, { 0x113E1, 0x113E2 },
+ { 0x11438, 0x1143F }, { 0x11442, 0x11444 }, { 0x11446, 0x11446 },
+ { 0x1145E, 0x1145E }, { 0x114B3, 0x114B8 }, { 0x114BA, 0x114BA },
+ { 0x114BF, 0x114C0 }, { 0x114C2, 0x114C3 }, { 0x115B2, 0x115B5 },
+ { 0x115BC, 0x115BD }, { 0x115BF, 0x115C0 }, { 0x115DC, 0x115DD },
+ { 0x11633, 0x1163A }, { 0x1163D, 0x1163D }, { 0x1163F, 0x11640 },
+ { 0x116AB, 0x116AB }, { 0x116AD, 0x116AD }, { 0x116B0, 0x116B5 },
+ { 0x116B7, 0x116B7 }, { 0x1171D, 0x1171D }, { 0x1171F, 0x1171F },
+ { 0x11722, 0x11725 }, { 0x11727, 0x1172B }, { 0x1182F, 0x11837 },
+ { 0x11839, 0x1183A }, { 0x1193B, 0x1193C }, { 0x1193E, 0x1193E },
+ { 0x11943, 0x11943 }, { 0x119D4, 0x119D7 }, { 0x119DA, 0x119DB },
+ { 0x119E0, 0x119E0 }, { 0x11A01, 0x11A0A }, { 0x11A33, 0x11A38 },
+ { 0x11A3B, 0x11A3E }, { 0x11A47, 0x11A47 }, { 0x11A51, 0x11A56 },
+ { 0x11A59, 0x11A5B }, { 0x11A8A, 0x11A96 }, { 0x11A98, 0x11A99 },
+ { 0x11B60, 0x11B60 }, { 0x11B62, 0x11B64 }, { 0x11B66, 0x11B66 },
+ { 0x11C30, 0x11C36 }, { 0x11C38, 0x11C3D }, { 0x11C3F, 0x11C3F },
+ { 0x11C92, 0x11CA7 }, { 0x11CAA, 0x11CB0 }, { 0x11CB2, 0x11CB3 },
+ { 0x11CB5, 0x11CB6 }, { 0x11D31, 0x11D36 }, { 0x11D3A, 0x11D3A },
+ { 0x11D3C, 0x11D3D }, { 0x11D3F, 0x11D45 }, { 0x11D47, 0x11D47 },
+ { 0x11D90, 0x11D91 }, { 0x11D95, 0x11D95 }, { 0x11D97, 0x11D97 },
+ { 0x11EF3, 0x11EF4 }, { 0x11F00, 0x11F01 }, { 0x11F36, 0x11F3A },
+ { 0x11F40, 0x11F40 }, { 0x11F42, 0x11F42 }, { 0x11F5A, 0x11F5A },
+ { 0x13440, 0x13440 }, { 0x13447, 0x13455 }, { 0x1611E, 0x16129 },
+ { 0x1612D, 0x1612F }, { 0x16AF0, 0x16AF4 }, { 0x16B30, 0x16B36 },
+ { 0x16F4F, 0x16F4F }, { 0x16F8F, 0x16F92 }, { 0x16FE4, 0x16FE4 },
+ { 0x1BC9D, 0x1BC9E }, { 0x1CF00, 0x1CF2D }, { 0x1CF30, 0x1CF46 },
+ { 0x1D167, 0x1D169 }, { 0x1D17B, 0x1D182 }, { 0x1D185, 0x1D18B },
+ { 0x1D1AA, 0x1D1AD }, { 0x1D242, 0x1D244 }, { 0x1DA00, 0x1DA36 },
+ { 0x1DA3B, 0x1DA6C }, { 0x1DA75, 0x1DA75 }, { 0x1DA84, 0x1DA84 },
+ { 0x1DA9B, 0x1DA9F }, { 0x1DAA1, 0x1DAAF }, { 0x1E000, 0x1E006 },
+ { 0x1E008, 0x1E018 }, { 0x1E01B, 0x1E021 }, { 0x1E023, 0x1E024 },
+ { 0x1E026, 0x1E02A }, { 0x1E08F, 0x1E08F }, { 0x1E130, 0x1E136 },
+ { 0x1E2AE, 0x1E2AE }, { 0x1E2EC, 0x1E2EF }, { 0x1E4EC, 0x1E4EF },
+ { 0x1E5EE, 0x1E5EF }, { 0x1E6E3, 0x1E6E3 }, { 0x1E6E6, 0x1E6E6 },
+ { 0x1E6EE, 0x1E6EF }, { 0x1E6F5, 0x1E6F5 }, { 0x1E8D0, 0x1E8D6 },
+ { 0x1E944, 0x1E94A }, { 0xE0100, 0xE01EF }
};
+ /* *INDENT-ON* */
- /* test for 8-bit control characters */
- if (ucs == 0)
- return 0;
- if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
- return -1;
+ /* sorted list of non-overlapping intervals of non-characters */
+ /* generated by
+ * uniset +0000..DFFF -4e00..9fd5 +F900..10FFFD unknown +2028..2029 c
+ */
+ /* *INDENT-OFF* */
+ /* generated by run-uniset_unk 1.7 */
+ static const struct interval unknowns[] = {
+ { 0x0378, 0x0379 }, { 0x0380, 0x0383 }, { 0x038B, 0x038B },
+ { 0x038D, 0x038D }, { 0x03A2, 0x03A2 }, { 0x0530, 0x0530 },
+ { 0x0557, 0x0558 }, { 0x058B, 0x058C }, { 0x0590, 0x0590 },
+ { 0x05C8, 0x05CF }, { 0x05EB, 0x05EE }, { 0x05F5, 0x05FF },
+ { 0x070E, 0x070E }, { 0x074B, 0x074C }, { 0x07B2, 0x07BF },
+ { 0x07FB, 0x07FC }, { 0x082E, 0x082F }, { 0x083F, 0x083F },
+ { 0x085C, 0x085D }, { 0x085F, 0x085F }, { 0x086B, 0x086F },
+ { 0x0892, 0x0896 }, { 0x0984, 0x0984 }, { 0x098D, 0x098E },
+ { 0x0991, 0x0992 }, { 0x09A9, 0x09A9 }, { 0x09B1, 0x09B1 },
+ { 0x09B3, 0x09B5 }, { 0x09BA, 0x09BB }, { 0x09C5, 0x09C6 },
+ { 0x09C9, 0x09CA }, { 0x09CF, 0x09D6 }, { 0x09D8, 0x09DB },
+ { 0x09DE, 0x09DE }, { 0x09E4, 0x09E5 }, { 0x09FF, 0x0A00 },
+ { 0x0A04, 0x0A04 }, { 0x0A0B, 0x0A0E }, { 0x0A11, 0x0A12 },
+ { 0x0A29, 0x0A29 }, { 0x0A31, 0x0A31 }, { 0x0A34, 0x0A34 },
+ { 0x0A37, 0x0A37 }, { 0x0A3A, 0x0A3B }, { 0x0A3D, 0x0A3D },
+ { 0x0A43, 0x0A46 }, { 0x0A49, 0x0A4A }, { 0x0A4E, 0x0A50 },
+ { 0x0A52, 0x0A58 }, { 0x0A5D, 0x0A5D }, { 0x0A5F, 0x0A65 },
+ { 0x0A77, 0x0A80 }, { 0x0A84, 0x0A84 }, { 0x0A8E, 0x0A8E },
+ { 0x0A92, 0x0A92 }, { 0x0AA9, 0x0AA9 }, { 0x0AB1, 0x0AB1 },
+ { 0x0AB4, 0x0AB4 }, { 0x0ABA, 0x0ABB }, { 0x0AC6, 0x0AC6 },
+ { 0x0ACA, 0x0ACA }, { 0x0ACE, 0x0ACF }, { 0x0AD1, 0x0ADF },
+ { 0x0AE4, 0x0AE5 }, { 0x0AF2, 0x0AF8 }, { 0x0B00, 0x0B00 },
+ { 0x0B04, 0x0B04 }, { 0x0B0D, 0x0B0E }, { 0x0B11, 0x0B12 },
+ { 0x0B29, 0x0B29 }, { 0x0B31, 0x0B31 }, { 0x0B34, 0x0B34 },
+ { 0x0B3A, 0x0B3B }, { 0x0B45, 0x0B46 }, { 0x0B49, 0x0B4A },
+ { 0x0B4E, 0x0B54 }, { 0x0B58, 0x0B5B }, { 0x0B5E, 0x0B5E },
+ { 0x0B64, 0x0B65 }, { 0x0B78, 0x0B81 }, { 0x0B84, 0x0B84 },
+ { 0x0B8B, 0x0B8D }, { 0x0B91, 0x0B91 }, { 0x0B96, 0x0B98 },
+ { 0x0B9B, 0x0B9B }, { 0x0B9D, 0x0B9D }, { 0x0BA0, 0x0BA2 },
+ { 0x0BA5, 0x0BA7 }, { 0x0BAB, 0x0BAD }, { 0x0BBA, 0x0BBD },
+ { 0x0BC3, 0x0BC5 }, { 0x0BC9, 0x0BC9 }, { 0x0BCE, 0x0BCF },
+ { 0x0BD1, 0x0BD6 }, { 0x0BD8, 0x0BE5 }, { 0x0BFB, 0x0BFF },
+ { 0x0C0D, 0x0C0D }, { 0x0C11, 0x0C11 }, { 0x0C29, 0x0C29 },
+ { 0x0C3A, 0x0C3B }, { 0x0C45, 0x0C45 }, { 0x0C49, 0x0C49 },
+ { 0x0C4E, 0x0C54 }, { 0x0C57, 0x0C57 }, { 0x0C5B, 0x0C5B },
+ { 0x0C5E, 0x0C5F }, { 0x0C64, 0x0C65 }, { 0x0C70, 0x0C76 },
+ { 0x0C8D, 0x0C8D }, { 0x0C91, 0x0C91 }, { 0x0CA9, 0x0CA9 },
+ { 0x0CB4, 0x0CB4 }, { 0x0CBA, 0x0CBB }, { 0x0CC5, 0x0CC5 },
+ { 0x0CC9, 0x0CC9 }, { 0x0CCE, 0x0CD4 }, { 0x0CD7, 0x0CDB },
+ { 0x0CDF, 0x0CDF }, { 0x0CE4, 0x0CE5 }, { 0x0CF0, 0x0CF0 },
+ { 0x0CF4, 0x0CFF }, { 0x0D0D, 0x0D0D }, { 0x0D11, 0x0D11 },
+ { 0x0D45, 0x0D45 }, { 0x0D49, 0x0D49 }, { 0x0D50, 0x0D53 },
+ { 0x0D64, 0x0D65 }, { 0x0D80, 0x0D80 }, { 0x0D84, 0x0D84 },
+ { 0x0D97, 0x0D99 }, { 0x0DB2, 0x0DB2 }, { 0x0DBC, 0x0DBC },
+ { 0x0DBE, 0x0DBF }, { 0x0DC7, 0x0DC9 }, { 0x0DCB, 0x0DCE },
+ { 0x0DD5, 0x0DD5 }, { 0x0DD7, 0x0DD7 }, { 0x0DE0, 0x0DE5 },
+ { 0x0DF0, 0x0DF1 }, { 0x0DF5, 0x0E00 }, { 0x0E3B, 0x0E3E },
+ { 0x0E5C, 0x0E80 }, { 0x0E83, 0x0E83 }, { 0x0E85, 0x0E85 },
+ { 0x0E8B, 0x0E8B }, { 0x0EA4, 0x0EA4 }, { 0x0EA6, 0x0EA6 },
+ { 0x0EBE, 0x0EBF }, { 0x0EC5, 0x0EC5 }, { 0x0EC7, 0x0EC7 },
+ { 0x0ECF, 0x0ECF }, { 0x0EDA, 0x0EDB }, { 0x0EE0, 0x0EFF },
+ { 0x0F48, 0x0F48 }, { 0x0F6D, 0x0F70 }, { 0x0F98, 0x0F98 },
+ { 0x0FBD, 0x0FBD }, { 0x0FCD, 0x0FCD }, { 0x0FDB, 0x0FFF },
+ { 0x10C6, 0x10C6 }, { 0x10C8, 0x10CC }, { 0x10CE, 0x10CF },
+ { 0x1249, 0x1249 }, { 0x124E, 0x124F }, { 0x1257, 0x1257 },
+ { 0x1259, 0x1259 }, { 0x125E, 0x125F }, { 0x1289, 0x1289 },
+ { 0x128E, 0x128F }, { 0x12B1, 0x12B1 }, { 0x12B6, 0x12B7 },
+ { 0x12BF, 0x12BF }, { 0x12C1, 0x12C1 }, { 0x12C6, 0x12C7 },
+ { 0x12D7, 0x12D7 }, { 0x1311, 0x1311 }, { 0x1316, 0x1317 },
+ { 0x135B, 0x135C }, { 0x137D, 0x137F }, { 0x139A, 0x139F },
+ { 0x13F6, 0x13F7 }, { 0x13FE, 0x13FF }, { 0x169D, 0x169F },
+ { 0x16F9, 0x16FF }, { 0x1716, 0x171E }, { 0x1737, 0x173F },
+ { 0x1754, 0x175F }, { 0x176D, 0x176D }, { 0x1771, 0x1771 },
+ { 0x1774, 0x177F }, { 0x17DE, 0x17DF }, { 0x17EA, 0x17EF },
+ { 0x17FA, 0x17FF }, { 0x181A, 0x181F }, { 0x1879, 0x187F },
+ { 0x18AB, 0x18AF }, { 0x18F6, 0x18FF }, { 0x191F, 0x191F },
+ { 0x192C, 0x192F }, { 0x193C, 0x193F }, { 0x1941, 0x1943 },
+ { 0x196E, 0x196F }, { 0x1975, 0x197F }, { 0x19AC, 0x19AF },
+ { 0x19CA, 0x19CF }, { 0x19DB, 0x19DD }, { 0x1A1C, 0x1A1D },
+ { 0x1A5F, 0x1A5F }, { 0x1A7D, 0x1A7E }, { 0x1A8A, 0x1A8F },
+ { 0x1A9A, 0x1A9F }, { 0x1AAE, 0x1AAF }, { 0x1ADE, 0x1ADF },
+ { 0x1AEC, 0x1AFF }, { 0x1B4D, 0x1B4D }, { 0x1BF4, 0x1BFB },
+ { 0x1C38, 0x1C3A }, { 0x1C4A, 0x1C4C }, { 0x1C8B, 0x1C8F },
+ { 0x1CBB, 0x1CBC }, { 0x1CC8, 0x1CCF }, { 0x1CFB, 0x1CFF },
+ { 0x1F16, 0x1F17 }, { 0x1F1E, 0x1F1F }, { 0x1F46, 0x1F47 },
+ { 0x1F4E, 0x1F4F }, { 0x1F58, 0x1F58 }, { 0x1F5A, 0x1F5A },
+ { 0x1F5C, 0x1F5C }, { 0x1F5E, 0x1F5E }, { 0x1F7E, 0x1F7F },
+ { 0x1FB5, 0x1FB5 }, { 0x1FC5, 0x1FC5 }, { 0x1FD4, 0x1FD5 },
+ { 0x1FDC, 0x1FDC }, { 0x1FF0, 0x1FF1 }, { 0x1FF5, 0x1FF5 },
+ { 0x1FFF, 0x1FFF }, { 0x2028, 0x2029 }, { 0x2065, 0x2065 },
+ { 0x2072, 0x2073 }, { 0x208F, 0x208F }, { 0x209D, 0x209F },
+ { 0x20C2, 0x20CF }, { 0x20F1, 0x20FF }, { 0x218C, 0x218F },
+ { 0x242A, 0x243F }, { 0x244B, 0x245F }, { 0x2B74, 0x2B75 },
+ { 0x2CF4, 0x2CF8 }, { 0x2D26, 0x2D26 }, { 0x2D28, 0x2D2C },
+ { 0x2D2E, 0x2D2F }, { 0x2D68, 0x2D6E }, { 0x2D71, 0x2D7E },
+ { 0x2D97, 0x2D9F }, { 0x2DA7, 0x2DA7 }, { 0x2DAF, 0x2DAF },
+ { 0x2DB7, 0x2DB7 }, { 0x2DBF, 0x2DBF }, { 0x2DC7, 0x2DC7 },
+ { 0x2DCF, 0x2DCF }, { 0x2DD7, 0x2DD7 }, { 0x2DDF, 0x2DDF },
+ { 0x2E5E, 0x2E7F }, { 0x2E9A, 0x2E9A }, { 0x2EF4, 0x2EFF },
+ { 0x2FD6, 0x2FEF }, { 0x3040, 0x3040 }, { 0x3097, 0x3098 },
+ { 0x3100, 0x3104 }, { 0x3130, 0x3130 }, { 0x318F, 0x318F },
+ { 0x31E6, 0x31EE }, { 0x321F, 0x321F }, { 0x4DB6, 0x4DBF },
+ { 0x9FD6, 0x9FFF }, { 0xA48D, 0xA48F }, { 0xA4C7, 0xA4CF },
+ { 0xA62C, 0xA63F }, { 0xA6F8, 0xA6FF }, { 0xA7DD, 0xA7F0 },
+ { 0xA82D, 0xA82F }, { 0xA83A, 0xA83F }, { 0xA878, 0xA87F },
+ { 0xA8C6, 0xA8CD }, { 0xA8DA, 0xA8DF }, { 0xA954, 0xA95E },
+ { 0xA97D, 0xA97F }, { 0xA9CE, 0xA9CE }, { 0xA9DA, 0xA9DD },
+ { 0xA9FF, 0xA9FF }, { 0xAA37, 0xAA3F }, { 0xAA4E, 0xAA4F },
+ { 0xAA5A, 0xAA5B }, { 0xAAC3, 0xAADA }, { 0xAAF7, 0xAB00 },
+ { 0xAB07, 0xAB08 }, { 0xAB0F, 0xAB10 }, { 0xAB17, 0xAB1F },
+ { 0xAB27, 0xAB27 }, { 0xAB2F, 0xAB2F }, { 0xAB6C, 0xAB6F },
+ { 0xABEE, 0xABEF }, { 0xABFA, 0xABFF }, { 0xD7A4, 0xD7AF },
+ { 0xD7C7, 0xD7CA }, { 0xD7FC, 0xDFFF }, { 0xFA6E, 0xFA6F },
+ { 0xFADA, 0xFAFF }, { 0xFB07, 0xFB12 }, { 0xFB18, 0xFB1C },
+ { 0xFB37, 0xFB37 }, { 0xFB3D, 0xFB3D }, { 0xFB3F, 0xFB3F },
+ { 0xFB42, 0xFB42 }, { 0xFB45, 0xFB45 }, { 0xFDD0, 0xFDEF },
+ { 0xFE1A, 0xFE1F }, { 0xFE53, 0xFE53 }, { 0xFE67, 0xFE67 },
+ { 0xFE6C, 0xFE6F }, { 0xFE75, 0xFE75 }, { 0xFEFD, 0xFEFE },
+ { 0xFF00, 0xFF00 }, { 0xFFBF, 0xFFC1 }, { 0xFFC8, 0xFFC9 },
+ { 0xFFD0, 0xFFD1 }, { 0xFFD8, 0xFFD9 }, { 0xFFDD, 0xFFDF },
+ { 0xFFE7, 0xFFE7 }, { 0xFFEF, 0xFFF8 }, { 0xFFFE, 0xFFFF },
+ { 0x1000C, 0x1000C }, { 0x10027, 0x10027 }, { 0x1003B, 0x1003B },
+ { 0x1003E, 0x1003E }, { 0x1004E, 0x1004F }, { 0x1005E, 0x1007F },
+ { 0x100FB, 0x100FF }, { 0x10103, 0x10106 }, { 0x10134, 0x10136 },
+ { 0x1018F, 0x1018F }, { 0x1019D, 0x1019F }, { 0x101A1, 0x101CF },
+ { 0x101FE, 0x1027F }, { 0x1029D, 0x1029F }, { 0x102D1, 0x102DF },
+ { 0x102FC, 0x102FF }, { 0x10324, 0x1032C }, { 0x1034B, 0x1034F },
+ { 0x1037B, 0x1037F }, { 0x1039E, 0x1039E }, { 0x103C4, 0x103C7 },
+ { 0x103D6, 0x103FF }, { 0x1049E, 0x1049F }, { 0x104AA, 0x104AF },
+ { 0x104D4, 0x104D7 }, { 0x104FC, 0x104FF }, { 0x10528, 0x1052F },
+ { 0x10564, 0x1056E }, { 0x1057B, 0x1057B }, { 0x1058B, 0x1058B },
+ { 0x10593, 0x10593 }, { 0x10596, 0x10596 }, { 0x105A2, 0x105A2 },
+ { 0x105B2, 0x105B2 }, { 0x105BA, 0x105BA }, { 0x105BD, 0x105BF },
+ { 0x105F4, 0x105FF }, { 0x10737, 0x1073F }, { 0x10756, 0x1075F },
+ { 0x10768, 0x1077F }, { 0x10786, 0x10786 }, { 0x107B1, 0x107B1 },
+ { 0x107BB, 0x107FF }, { 0x10806, 0x10807 }, { 0x10809, 0x10809 },
+ { 0x10836, 0x10836 }, { 0x10839, 0x1083B }, { 0x1083D, 0x1083E },
+ { 0x10856, 0x10856 }, { 0x1089F, 0x108A6 }, { 0x108B0, 0x108DF },
+ { 0x108F3, 0x108F3 }, { 0x108F6, 0x108FA }, { 0x1091C, 0x1091E },
+ { 0x1093A, 0x1093E }, { 0x1095A, 0x1097F }, { 0x109B8, 0x109BB },
+ { 0x109D0, 0x109D1 }, { 0x10A04, 0x10A04 }, { 0x10A07, 0x10A0B },
+ { 0x10A14, 0x10A14 }, { 0x10A18, 0x10A18 }, { 0x10A36, 0x10A37 },
+ { 0x10A3B, 0x10A3E }, { 0x10A49, 0x10A4F }, { 0x10A59, 0x10A5F },
+ { 0x10AA0, 0x10ABF }, { 0x10AE7, 0x10AEA }, { 0x10AF7, 0x10AFF },
+ { 0x10B36, 0x10B38 }, { 0x10B56, 0x10B57 }, { 0x10B73, 0x10B77 },
+ { 0x10B92, 0x10B98 }, { 0x10B9D, 0x10BA8 }, { 0x10BB0, 0x10BFF },
+ { 0x10C49, 0x10C7F }, { 0x10CB3, 0x10CBF }, { 0x10CF3, 0x10CF9 },
+ { 0x10D28, 0x10D2F }, { 0x10D3A, 0x10D3F }, { 0x10D66, 0x10D68 },
+ { 0x10D86, 0x10D8D }, { 0x10D90, 0x10E5F }, { 0x10E7F, 0x10E7F },
+ { 0x10EAA, 0x10EAA }, { 0x10EAE, 0x10EAF }, { 0x10EB2, 0x10EC1 },
+ { 0x10EC8, 0x10ECF }, { 0x10ED9, 0x10EF9 }, { 0x10F28, 0x10F2F },
+ { 0x10F5A, 0x10F6F }, { 0x10F8A, 0x10FAF }, { 0x10FCC, 0x10FDF },
+ { 0x10FF7, 0x10FFF }, { 0x1104E, 0x11051 }, { 0x11076, 0x1107E },
+ { 0x110C3, 0x110CC }, { 0x110CE, 0x110CF }, { 0x110E9, 0x110EF },
+ { 0x110FA, 0x110FF }, { 0x11135, 0x11135 }, { 0x11148, 0x1114F },
+ { 0x11177, 0x1117F }, { 0x111E0, 0x111E0 }, { 0x111F5, 0x111FF },
+ { 0x11212, 0x11212 }, { 0x11242, 0x1127F }, { 0x11287, 0x11287 },
+ { 0x11289, 0x11289 }, { 0x1128E, 0x1128E }, { 0x1129E, 0x1129E },
+ { 0x112AA, 0x112AF }, { 0x112EB, 0x112EF }, { 0x112FA, 0x112FF },
+ { 0x11304, 0x11304 }, { 0x1130D, 0x1130E }, { 0x11311, 0x11312 },
+ { 0x11329, 0x11329 }, { 0x11331, 0x11331 }, { 0x11334, 0x11334 },
+ { 0x1133A, 0x1133A }, { 0x11345, 0x11346 }, { 0x11349, 0x1134A },
+ { 0x1134E, 0x1134F }, { 0x11351, 0x11356 }, { 0x11358, 0x1135C },
+ { 0x11364, 0x11365 }, { 0x1136D, 0x1136F }, { 0x11375, 0x1137F },
+ { 0x1138A, 0x1138A }, { 0x1138C, 0x1138D }, { 0x1138F, 0x1138F },
+ { 0x113B6, 0x113B6 }, { 0x113C1, 0x113C1 }, { 0x113C3, 0x113C4 },
+ { 0x113C6, 0x113C6 }, { 0x113CB, 0x113CB }, { 0x113D6, 0x113D6 },
+ { 0x113D9, 0x113E0 }, { 0x113E3, 0x113FF }, { 0x1145C, 0x1145C },
+ { 0x11462, 0x1147F }, { 0x114C8, 0x114CF }, { 0x114DA, 0x1157F },
+ { 0x115B6, 0x115B7 }, { 0x115DE, 0x115FF }, { 0x11645, 0x1164F },
+ { 0x1165A, 0x1165F }, { 0x1166D, 0x1167F }, { 0x116BA, 0x116BF },
+ { 0x116CA, 0x116CF }, { 0x116E4, 0x116FF }, { 0x1171B, 0x1171C },
+ { 0x1172C, 0x1172F }, { 0x11747, 0x117FF }, { 0x1183C, 0x1189F },
+ { 0x118F3, 0x118FE }, { 0x11907, 0x11908 }, { 0x1190A, 0x1190B },
+ { 0x11914, 0x11914 }, { 0x11917, 0x11917 }, { 0x11936, 0x11936 },
+ { 0x11939, 0x1193A }, { 0x11947, 0x1194F }, { 0x1195A, 0x1199F },
+ { 0x119A8, 0x119A9 }, { 0x119D8, 0x119D9 }, { 0x119E5, 0x119FF },
+ { 0x11A48, 0x11A4F }, { 0x11AA3, 0x11AAF }, { 0x11AF9, 0x11AFF },
+ { 0x11B0A, 0x11B5F }, { 0x11B68, 0x11BBF }, { 0x11BE2, 0x11BEF },
+ { 0x11BFA, 0x11BFF }, { 0x11C09, 0x11C09 }, { 0x11C37, 0x11C37 },
+ { 0x11C46, 0x11C4F }, { 0x11C6D, 0x11C6F }, { 0x11C90, 0x11C91 },
+ { 0x11CA8, 0x11CA8 }, { 0x11CB7, 0x11CFF }, { 0x11D07, 0x11D07 },
+ { 0x11D0A, 0x11D0A }, { 0x11D37, 0x11D39 }, { 0x11D3B, 0x11D3B },
+ { 0x11D3E, 0x11D3E }, { 0x11D48, 0x11D4F }, { 0x11D5A, 0x11D5F },
+ { 0x11D66, 0x11D66 }, { 0x11D69, 0x11D69 }, { 0x11D8F, 0x11D8F },
+ { 0x11D92, 0x11D92 }, { 0x11D99, 0x11D9F }, { 0x11DAA, 0x11DAF },
+ { 0x11DDC, 0x11DDF }, { 0x11DEA, 0x11EDF }, { 0x11EF9, 0x11EFF },
+ { 0x11F11, 0x11F11 }, { 0x11F3B, 0x11F3D }, { 0x11F5B, 0x11FAF },
+ { 0x11FB1, 0x11FBF }, { 0x11FF2, 0x11FFE }, { 0x1239A, 0x123FF },
+ { 0x1246F, 0x1246F }, { 0x12475, 0x1247F }, { 0x12544, 0x12F8F },
+ { 0x12FF3, 0x12FFF }, { 0x13456, 0x1345F }, { 0x143FB, 0x143FF },
+ { 0x14647, 0x160FF }, { 0x1613A, 0x167FF }, { 0x16A39, 0x16A3F },
+ { 0x16A5F, 0x16A5F }, { 0x16A6A, 0x16A6D }, { 0x16ABF, 0x16ABF },
+ { 0x16ACA, 0x16ACF }, { 0x16AEE, 0x16AEF }, { 0x16AF6, 0x16AFF },
+ { 0x16B46, 0x16B4F }, { 0x16B5A, 0x16B5A }, { 0x16B62, 0x16B62 },
+ { 0x16B78, 0x16B7C }, { 0x16B90, 0x16D3F }, { 0x16D7A, 0x16E3F },
+ { 0x16E9B, 0x16E9F }, { 0x16EB9, 0x16EBA }, { 0x16ED4, 0x16EFF },
+ { 0x16F4B, 0x16F4E }, { 0x16F88, 0x16F8E }, { 0x16FA0, 0x16FDF },
+ { 0x16FE5, 0x16FEF }, { 0x16FF7, 0x187FF }, { 0x18CD6, 0x18CFE },
+ { 0x18D00, 0x18D7F }, { 0x18DF3, 0x1AFEF }, { 0x1AFF4, 0x1AFF4 },
+ { 0x1AFFC, 0x1AFFC }, { 0x1AFFF, 0x1AFFF }, { 0x1B123, 0x1B131 },
+ { 0x1B133, 0x1B14F }, { 0x1B153, 0x1B154 }, { 0x1B156, 0x1B163 },
+ { 0x1B168, 0x1B16F }, { 0x1B2FC, 0x1BBFF }, { 0x1BC6B, 0x1BC6F },
+ { 0x1BC7D, 0x1BC7F }, { 0x1BC89, 0x1BC8F }, { 0x1BC9A, 0x1BC9B },
+ { 0x1BCA4, 0x1CBFF }, { 0x1CCFD, 0x1CCFF }, { 0x1CEB4, 0x1CEB9 },
+ { 0x1CED1, 0x1CEDF }, { 0x1CEF1, 0x1CEFF }, { 0x1CF2E, 0x1CF2F },
+ { 0x1CF47, 0x1CF4F }, { 0x1CFC4, 0x1CFFF }, { 0x1D0F6, 0x1D0FF },
+ { 0x1D127, 0x1D128 }, { 0x1D1EB, 0x1D1FF }, { 0x1D246, 0x1D2BF },
+ { 0x1D2D4, 0x1D2DF }, { 0x1D2F4, 0x1D2FF }, { 0x1D357, 0x1D35F },
+ { 0x1D379, 0x1D3FF }, { 0x1D455, 0x1D455 }, { 0x1D49D, 0x1D49D },
+ { 0x1D4A0, 0x1D4A1 }, { 0x1D4A3, 0x1D4A4 }, { 0x1D4A7, 0x1D4A8 },
+ { 0x1D4AD, 0x1D4AD }, { 0x1D4BA, 0x1D4BA }, { 0x1D4BC, 0x1D4BC },
+ { 0x1D4C4, 0x1D4C4 }, { 0x1D506, 0x1D506 }, { 0x1D50B, 0x1D50C },
+ { 0x1D515, 0x1D515 }, { 0x1D51D, 0x1D51D }, { 0x1D53A, 0x1D53A },
+ { 0x1D53F, 0x1D53F }, { 0x1D545, 0x1D545 }, { 0x1D547, 0x1D549 },
+ { 0x1D551, 0x1D551 }, { 0x1D6A6, 0x1D6A7 }, { 0x1D7CC, 0x1D7CD },
+ { 0x1DA8C, 0x1DA9A }, { 0x1DAA0, 0x1DAA0 }, { 0x1DAB0, 0x1DEFF },
+ { 0x1DF1F, 0x1DF24 }, { 0x1DF2B, 0x1DFFF }, { 0x1E007, 0x1E007 },
+ { 0x1E019, 0x1E01A }, { 0x1E022, 0x1E022 }, { 0x1E025, 0x1E025 },
+ { 0x1E02B, 0x1E02F }, { 0x1E06E, 0x1E08E }, { 0x1E090, 0x1E0FF },
+ { 0x1E12D, 0x1E12F }, { 0x1E13E, 0x1E13F }, { 0x1E14A, 0x1E14D },
+ { 0x1E150, 0x1E28F }, { 0x1E2AF, 0x1E2BF }, { 0x1E2FA, 0x1E2FE },
+ { 0x1E300, 0x1E4CF }, { 0x1E4FA, 0x1E5CF }, { 0x1E5FB, 0x1E5FE },
+ { 0x1E600, 0x1E6BF }, { 0x1E6DF, 0x1E6DF }, { 0x1E6F6, 0x1E6FD },
+ { 0x1E700, 0x1E7DF }, { 0x1E7E7, 0x1E7E7 }, { 0x1E7EC, 0x1E7EC },
+ { 0x1E7EF, 0x1E7EF }, { 0x1E7FF, 0x1E7FF }, { 0x1E8C5, 0x1E8C6 },
+ { 0x1E8D7, 0x1E8FF }, { 0x1E94C, 0x1E94F }, { 0x1E95A, 0x1E95D },
+ { 0x1E960, 0x1EC70 }, { 0x1ECB5, 0x1ED00 }, { 0x1ED3E, 0x1EDFF },
+ { 0x1EE04, 0x1EE04 }, { 0x1EE20, 0x1EE20 }, { 0x1EE23, 0x1EE23 },
+ { 0x1EE25, 0x1EE26 }, { 0x1EE28, 0x1EE28 }, { 0x1EE33, 0x1EE33 },
+ { 0x1EE38, 0x1EE38 }, { 0x1EE3A, 0x1EE3A }, { 0x1EE3C, 0x1EE41 },
+ { 0x1EE43, 0x1EE46 }, { 0x1EE48, 0x1EE48 }, { 0x1EE4A, 0x1EE4A },
+ { 0x1EE4C, 0x1EE4C }, { 0x1EE50, 0x1EE50 }, { 0x1EE53, 0x1EE53 },
+ { 0x1EE55, 0x1EE56 }, { 0x1EE58, 0x1EE58 }, { 0x1EE5A, 0x1EE5A },
+ { 0x1EE5C, 0x1EE5C }, { 0x1EE5E, 0x1EE5E }, { 0x1EE60, 0x1EE60 },
+ { 0x1EE63, 0x1EE63 }, { 0x1EE65, 0x1EE66 }, { 0x1EE6B, 0x1EE6B },
+ { 0x1EE73, 0x1EE73 }, { 0x1EE78, 0x1EE78 }, { 0x1EE7D, 0x1EE7D },
+ { 0x1EE7F, 0x1EE7F }, { 0x1EE8A, 0x1EE8A }, { 0x1EE9C, 0x1EEA0 },
+ { 0x1EEA4, 0x1EEA4 }, { 0x1EEAA, 0x1EEAA }, { 0x1EEBC, 0x1EEEF },
+ { 0x1EEF2, 0x1EFFF }, { 0x1F02C, 0x1F02F }, { 0x1F094, 0x1F09F },
+ { 0x1F0AF, 0x1F0B0 }, { 0x1F0C0, 0x1F0C0 }, { 0x1F0D0, 0x1F0D0 },
+ { 0x1F0F6, 0x1F0FF }, { 0x1F1AE, 0x1F1E5 }, { 0x1F203, 0x1F20F },
+ { 0x1F23C, 0x1F23F }, { 0x1F249, 0x1F24F }, { 0x1F252, 0x1F25F },
+ { 0x1F266, 0x1F2FF }, { 0x1F6D9, 0x1F6DB }, { 0x1F6ED, 0x1F6EF },
+ { 0x1F6FD, 0x1F6FF }, { 0x1F7DA, 0x1F7DF }, { 0x1F7EC, 0x1F7EF },
+ { 0x1F7F1, 0x1F7FF }, { 0x1F80C, 0x1F80F }, { 0x1F848, 0x1F84F },
+ { 0x1F85A, 0x1F85F }, { 0x1F888, 0x1F88F }, { 0x1F8AE, 0x1F8AF },
+ { 0x1F8BC, 0x1F8BF }, { 0x1F8C2, 0x1F8CF }, { 0x1F8D9, 0x1F8FF },
+ { 0x1FA58, 0x1FA5F }, { 0x1FA6E, 0x1FA6F }, { 0x1FA7D, 0x1FA7F },
+ { 0x1FA8B, 0x1FA8D }, { 0x1FAC7, 0x1FAC7 }, { 0x1FAC9, 0x1FACC },
+ { 0x1FADD, 0x1FADE }, { 0x1FAEB, 0x1FAEE }, { 0x1FAF9, 0x1FAFF },
+ { 0x1FB93, 0x1FB93 }, { 0x1FBFB, 0x1FFFF }, { 0x2A6D7, 0x2F7FF },
+ { 0x2FA1E, 0xE0000 }, { 0xE0002, 0xE001F }, { 0xE0080, 0xE00FF },
+ { 0xE01F0, 0x10FFFD }
+ };
+ /* *INDENT-ON* */
- /* binary search in table of non-spacing characters */
- if (bisearch(ucs, combining,
- sizeof(combining) / sizeof(struct interval) - 1))
- return 0;
+ /* sorted list of non-overlapping intervals of non-characters */
+ /* generated by
+ * uniset +WIDTH-W +emoji/emoji-data.txt -0000..00ff -cat=Cn -cat=Mn c
+ */
+ /* *INDENT-OFF* */
+ /* generated by run-uniset_dbl 1.4 */
+ static const struct interval doublewidth[] = {
+ { 0x1100, 0x115F }, { 0x200D, 0x200D }, { 0x203C, 0x203C },
+ { 0x2049, 0x2049 }, { 0x20E3, 0x20E3 }, { 0x2122, 0x2122 },
+ { 0x2139, 0x2139 }, { 0x2194, 0x2194 }, { 0x21A9, 0x21A9 },
+ { 0x231A, 0x231B }, { 0x2328, 0x232A }, { 0x23CF, 0x23CF },
+ { 0x23E9, 0x23ED }, { 0x23EF, 0x23F1 }, { 0x23F3, 0x23F3 },
+ { 0x23F8, 0x23F8 }, { 0x24C2, 0x24C2 }, { 0x25AA, 0x25AA },
+ { 0x25B6, 0x25B6 }, { 0x25C0, 0x25C0 }, { 0x25FB, 0x25FB },
+ { 0x25FD, 0x25FE }, { 0x2600, 0x2600 }, { 0x2602, 0x2602 },
+ { 0x2604, 0x2604 }, { 0x260E, 0x260E }, { 0x2611, 0x2611 },
+ { 0x2614, 0x2615 }, { 0x2618, 0x2618 }, { 0x261D, 0x261D },
+ { 0x2620, 0x2620 }, { 0x2622, 0x2622 }, { 0x2626, 0x2626 },
+ { 0x262A, 0x262A }, { 0x262E, 0x2638 }, { 0x263A, 0x263A },
+ { 0x2640, 0x2640 }, { 0x2642, 0x2642 }, { 0x2648, 0x2653 },
+ { 0x265F, 0x2660 }, { 0x2663, 0x2663 }, { 0x2665, 0x2665 },
+ { 0x2668, 0x2668 }, { 0x267B, 0x267B }, { 0x267E, 0x267F },
+ { 0x268A, 0x268F }, { 0x2692, 0x2696 }, { 0x2699, 0x2699 },
+ { 0x269B, 0x269B }, { 0x26A0, 0x26A1 }, { 0x26A7, 0x26A7 },
+ { 0x26AA, 0x26AB }, { 0x26B0, 0x26B0 }, { 0x26BD, 0x26BE },
+ { 0x26C4, 0x26C5 }, { 0x26C8, 0x26C8 }, { 0x26CE, 0x26CF },
+ { 0x26D1, 0x26D1 }, { 0x26D3, 0x26D4 }, { 0x26E9, 0x26EA },
+ { 0x26F0, 0x26F0 }, { 0x26F2, 0x26F5 }, { 0x26F7, 0x26F7 },
+ { 0x26F9, 0x26FA }, { 0x26FD, 0x26FD }, { 0x2702, 0x2702 },
+ { 0x2705, 0x2705 }, { 0x2708, 0x2708 }, { 0x270A, 0x270B },
+ { 0x270D, 0x270D }, { 0x270F, 0x270F }, { 0x2712, 0x2712 },
+ { 0x2714, 0x2714 }, { 0x2716, 0x2716 }, { 0x271D, 0x271D },
+ { 0x2721, 0x2721 }, { 0x2728, 0x2728 }, { 0x2733, 0x2733 },
+ { 0x2744, 0x2744 }, { 0x2747, 0x2747 }, { 0x274C, 0x274C },
+ { 0x274E, 0x274E }, { 0x2753, 0x2755 }, { 0x2757, 0x2757 },
+ { 0x2763, 0x2764 }, { 0x2795, 0x2797 }, { 0x27A1, 0x27A1 },
+ { 0x27B0, 0x27B0 }, { 0x27BF, 0x27BF }, { 0x2934, 0x2934 },
+ { 0x2B05, 0x2B05 }, { 0x2B1B, 0x2B1C }, { 0x2B50, 0x2B50 },
+ { 0x2B55, 0x2B55 }, { 0x2E80, 0x2E99 }, { 0x2E9B, 0x2EF3 },
+ { 0x2F00, 0x2FD5 }, { 0x2FF0, 0x3029 }, { 0x302E, 0x303E },
+ { 0x3041, 0x3096 }, { 0x309B, 0x30FF }, { 0x3105, 0x312F },
+ { 0x3131, 0x318E }, { 0x3190, 0x31E5 }, { 0x31EF, 0x321E },
+ { 0x3220, 0x3247 }, { 0x3250, 0xA48C }, { 0xA490, 0xA4C6 },
+ { 0xA960, 0xA97C }, { 0xAC00, 0xD7A3 }, { 0xF900, 0xFA6D },
+ { 0xFA70, 0xFAD9 }, { 0xFE10, 0xFE19 }, { 0xFE30, 0xFE52 },
+ { 0xFE54, 0xFE66 }, { 0xFE68, 0xFE6B }, { 0xFF01, 0xFF60 },
+ { 0xFFE0, 0xFFE6 }, { 0x16FE0, 0x16FE3 }, { 0x16FF0, 0x16FF6 },
+ { 0x17000, 0x18CD5 }, { 0x18CFF, 0x18D1E }, { 0x18D80, 0x18DF2 },
+ { 0x1AFF0, 0x1AFF3 }, { 0x1AFF5, 0x1AFFB }, { 0x1AFFD, 0x1AFFE },
+ { 0x1B000, 0x1B122 }, { 0x1B132, 0x1B132 }, { 0x1B150, 0x1B152 },
+ { 0x1B155, 0x1B155 }, { 0x1B164, 0x1B167 }, { 0x1B170, 0x1B2FB },
+ { 0x1D300, 0x1D356 }, { 0x1D360, 0x1D376 }, { 0x1F004, 0x1F004 },
+ { 0x1F02C, 0x1F02C }, { 0x1F094, 0x1F094 }, { 0x1F0AF, 0x1F0AF },
+ { 0x1F0C0, 0x1F0C0 }, { 0x1F0CF, 0x1F0D0 }, { 0x1F0F6, 0x1F0F6 },
+ { 0x1F170, 0x1F170 }, { 0x1F17E, 0x1F17E }, { 0x1F18E, 0x1F18E },
+ { 0x1F191, 0x1F19A }, { 0x1F1AE, 0x1F1AE }, { 0x1F1E6, 0x1F1E6 },
+ { 0x1F200, 0x1F203 }, { 0x1F210, 0x1F23C }, { 0x1F240, 0x1F249 },
+ { 0x1F250, 0x1F252 }, { 0x1F260, 0x1F266 }, { 0x1F300, 0x1F321 },
+ { 0x1F324, 0x1F324 }, { 0x1F32D, 0x1F393 }, { 0x1F396, 0x1F396 },
+ { 0x1F399, 0x1F399 }, { 0x1F39E, 0x1F39E }, { 0x1F3A0, 0x1F3CB },
+ { 0x1F3CF, 0x1F3D4 }, { 0x1F3E0, 0x1F3F0 }, { 0x1F3F3, 0x1F3F5 },
+ { 0x1F3F7, 0x1F4FD }, { 0x1F4FF, 0x1F53D }, { 0x1F549, 0x1F549 },
+ { 0x1F54B, 0x1F54E }, { 0x1F550, 0x1F567 }, { 0x1F56F, 0x1F56F },
+ { 0x1F573, 0x1F574 }, { 0x1F57A, 0x1F57A }, { 0x1F587, 0x1F587 },
+ { 0x1F58A, 0x1F58A }, { 0x1F590, 0x1F590 }, { 0x1F595, 0x1F596 },
+ { 0x1F5A4, 0x1F5A5 }, { 0x1F5A8, 0x1F5A8 }, { 0x1F5B1, 0x1F5B1 },
+ { 0x1F5BC, 0x1F5BC }, { 0x1F5C2, 0x1F5C2 }, { 0x1F5D1, 0x1F5D1 },
+ { 0x1F5DC, 0x1F5DC }, { 0x1F5E1, 0x1F5E1 }, { 0x1F5E3, 0x1F5E3 },
+ { 0x1F5E8, 0x1F5E8 }, { 0x1F5EF, 0x1F5EF }, { 0x1F5F3, 0x1F5F3 },
+ { 0x1F5FA, 0x1F64F }, { 0x1F680, 0x1F6C5 }, { 0x1F6CB, 0x1F6CD },
+ { 0x1F6D0, 0x1F6D2 }, { 0x1F6D5, 0x1F6D9 }, { 0x1F6DC, 0x1F6E0 },
+ { 0x1F6E9, 0x1F6E9 }, { 0x1F6EB, 0x1F6ED }, { 0x1F6F0, 0x1F6F0 },
+ { 0x1F6F3, 0x1F6FD }, { 0x1F7DA, 0x1F7DA }, { 0x1F7E0, 0x1F7EC },
+ { 0x1F7F0, 0x1F7F1 }, { 0x1F80C, 0x1F80C }, { 0x1F848, 0x1F848 },
+ { 0x1F85A, 0x1F85A }, { 0x1F888, 0x1F888 }, { 0x1F8AE, 0x1F8AE },
+ { 0x1F8BC, 0x1F8BC }, { 0x1F8C2, 0x1F8C2 }, { 0x1F8D9, 0x1F8D9 },
+ { 0x1F90C, 0x1F93A }, { 0x1F93C, 0x1F945 }, { 0x1F947, 0x1F9FF },
+ { 0x1FA58, 0x1FA58 }, { 0x1FA6E, 0x1FA6E }, { 0x1FA70, 0x1FA7D },
+ { 0x1FA80, 0x1FA8B }, { 0x1FA8E, 0x1FAC9 }, { 0x1FACD, 0x1FADD },
+ { 0x1FADF, 0x1FAEB }, { 0x1FAEF, 0x1FAF9 }, { 0x1FC00, 0x1FC00 },
+ { 0x20000, 0x2A6DF }, { 0x2A700, 0x2B81D }, { 0x2B820, 0x2CEAD },
+ { 0x2CEB0, 0x2EBE0 }, { 0x2EBF0, 0x2EE5D }, { 0x2F800, 0x2FA1D },
+ { 0x30000, 0x3134A }, { 0x31350, 0x33479 }, { 0xE0020, 0xE0020 }
+ };
+ /* *INDENT-ON* */
+
+ int result;
+
+#define Lookup(cmp, table) \
+ bisearch(cmp, table, \
+ (int) (sizeof(table) / sizeof(struct interval) - 1))
+
+ /* test for 8-bit control characters */
+ if (cmp == 0) {
+ result = 0;
+ } else if (cmp < 32 || (cmp >= 0x7f && cmp < 0xa0)) {
+ result = -1;
+ } else if (cmp == 0xad) {
+ result = use_latin1;
+ } else if (Lookup(cmp, formatting)) {
+ /* treat formatting characters like control characters */
+ result = 0;
+ } else if (Lookup(cmp, combining)) {
+ /* binary search in table of non-spacing characters */
+ result = 0;
+ } else {
+ /* if we arrive here, cmp is not a combining or C0/C1 control character */
+ result = 1;
- /* if we arrive here, ucs is not a combining or C0/C1 control character */
-
- return 1 +
- (ucs >= 0x1100 &&
- (ucs <= 0x115f || /* Hangul Jamo init. consonants */
- ucs == 0x2329 || ucs == 0x232a ||
- (ucs >= 0x2e80 && ucs <= 0xa4cf &&
- ucs != 0x303f) /* CJK ... Yi */
- || (ucs >= 0xac00 && ucs <= 0xd7a3) /* Hangul Syllables */
- || (ucs >= 0xf900 && ucs <= 0xfaff) /* CJK Compatibility Ideographs */
- || (ucs >= 0xfe10 && ucs <= 0xfe19) /* Vertical forms */
- || (ucs >= 0xfe30 && ucs <= 0xfe6f) /* CJK Compatibility Forms */
- || (ucs >= 0xff00 && ucs <= 0xff60) /* Fullwidth Forms */
- || (ucs >= 0xffe0 && ucs <= 0xffe6)
-#if !defined(SIZEOF_WCHAR_T) || (SIZEOF_WCHAR_T >= 4)
- || (ucs >= 0x20000 && ucs <= 0x2fffd)
- || (ucs >= 0x30000 && ucs <= 0x3fffd)
+ if (Lookup(cmp, doublewidth)) {
+ result = 2;
+ } else if (cmp >= 0xd800 && cmp <= 0xdfff) {
+#if HAVE_WCWIDTH
+ result = (wcwidth) (ucs);
+#else
+ result = -1;
#endif
- ));
+ } else if (cmp >= unknowns[0].first && Lookup(cmp, unknowns)) {
+ result = -1;
+ }
+ }
+ return result;
}
-
-NCURSES_EXPORT(int) mk_wcswidth(const wchar_t *pwcs, size_t n)
+#ifdef UNUSED
+int
+mk_wcswidth(const wchar_t *pwcs, size_t n)
{
- int w, width = 0;
+ int width = 0;
- for (;*pwcs && n-- > 0; pwcs++)
- if ((w = mk_wcwidth(*pwcs)) < 0)
- return -1;
- else
- width += w;
+ for (; *pwcs && n-- > 0; pwcs++) {
+ int w;
- return width;
-}
+ if ((w = mk_wcwidth(*pwcs)) < 0)
+ return -1;
+ else
+ width += w;
+ }
+ return width;
+}
+#endif /* UNUSED */
/*
* The following functions are the same as mk_wcwidth() and
- * mk_wcswidth(), except that spacing characters in the East Asian
+ * mk_wcwidth_cjk(), except that spacing characters in the East Asian
* Ambiguous (A) category as defined in Unicode Technical Report #11
* have a column width of 2. This variant might be useful for users of
* CJK legacy encodings who want to migrate to UCS without changing
* the traditional terminal character-width behaviour. It is not
* otherwise recommended for general use.
*/
-NCURSES_EXPORT(int) mk_wcwidth_cjk(wchar_t ucs)
+NCURSES_EXPORT(int)
+mk_wcwidth_cjk(uint32_t ucs)
{
- /* sorted list of non-overlapping intervals of East Asian Ambiguous
- * characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
+ /* sorted list of non-overlapping intervals of East Asian Ambiguous
+ * characters, generated by
+ *
+ * uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf \
+ * +E000..F8FF \
+ * +F0000..FFFFD \
+ * +100000..10FFFD c
+ *
+ * "WIDTH-A" is a file extracted from EastAsianWidth.txt by selecting
+ * only those with width "A", and omitting:
+ *
+ * 0xAD
+ * all lines with "COMBINING"
+ */
+ /* *INDENT-OFF* */
+ /* generated by run-uniset_cjk 1.6 */
static const struct interval ambiguous[] = {
{ 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 },
{ 0x00AA, 0x00AA }, { 0x00AE, 0x00AE }, { 0x00B0, 0x00B4 },
@@ -274,55 +824,179 @@ NCURSES_EXPORT(int) mk_wcwidth_cjk(wchar_t ucs)
{ 0x2113, 0x2113 }, { 0x2116, 0x2116 }, { 0x2121, 0x2122 },
{ 0x2126, 0x2126 }, { 0x212B, 0x212B }, { 0x2153, 0x2154 },
{ 0x215B, 0x215E }, { 0x2160, 0x216B }, { 0x2170, 0x2179 },
- { 0x2190, 0x2199 }, { 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 },
- { 0x21D4, 0x21D4 }, { 0x21E7, 0x21E7 }, { 0x2200, 0x2200 },
- { 0x2202, 0x2203 }, { 0x2207, 0x2208 }, { 0x220B, 0x220B },
- { 0x220F, 0x220F }, { 0x2211, 0x2211 }, { 0x2215, 0x2215 },
- { 0x221A, 0x221A }, { 0x221D, 0x2220 }, { 0x2223, 0x2223 },
- { 0x2225, 0x2225 }, { 0x2227, 0x222C }, { 0x222E, 0x222E },
- { 0x2234, 0x2237 }, { 0x223C, 0x223D }, { 0x2248, 0x2248 },
- { 0x224C, 0x224C }, { 0x2252, 0x2252 }, { 0x2260, 0x2261 },
- { 0x2264, 0x2267 }, { 0x226A, 0x226B }, { 0x226E, 0x226F },
- { 0x2282, 0x2283 }, { 0x2286, 0x2287 }, { 0x2295, 0x2295 },
- { 0x2299, 0x2299 }, { 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF },
- { 0x2312, 0x2312 }, { 0x2460, 0x24E9 }, { 0x24EB, 0x254B },
- { 0x2550, 0x2573 }, { 0x2580, 0x258F }, { 0x2592, 0x2595 },
- { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 }, { 0x25B2, 0x25B3 },
- { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD }, { 0x25C0, 0x25C1 },
- { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB }, { 0x25CE, 0x25D1 },
- { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF }, { 0x2605, 0x2606 },
- { 0x2609, 0x2609 }, { 0x260E, 0x260F }, { 0x2614, 0x2615 },
+ { 0x2189, 0x2189 }, { 0x2190, 0x2199 }, { 0x21B8, 0x21B9 },
+ { 0x21D2, 0x21D2 }, { 0x21D4, 0x21D4 }, { 0x21E7, 0x21E7 },
+ { 0x2200, 0x2200 }, { 0x2202, 0x2203 }, { 0x2207, 0x2208 },
+ { 0x220B, 0x220B }, { 0x220F, 0x220F }, { 0x2211, 0x2211 },
+ { 0x2215, 0x2215 }, { 0x221A, 0x221A }, { 0x221D, 0x2220 },
+ { 0x2223, 0x2223 }, { 0x2225, 0x2225 }, { 0x2227, 0x222C },
+ { 0x222E, 0x222E }, { 0x2234, 0x2237 }, { 0x223C, 0x223D },
+ { 0x2248, 0x2248 }, { 0x224C, 0x224C }, { 0x2252, 0x2252 },
+ { 0x2260, 0x2261 }, { 0x2264, 0x2267 }, { 0x226A, 0x226B },
+ { 0x226E, 0x226F }, { 0x2282, 0x2283 }, { 0x2286, 0x2287 },
+ { 0x2295, 0x2295 }, { 0x2299, 0x2299 }, { 0x22A5, 0x22A5 },
+ { 0x22BF, 0x22BF }, { 0x2312, 0x2312 }, { 0x2460, 0x24E9 },
+ { 0x24EB, 0x254B }, { 0x2550, 0x2573 }, { 0x2580, 0x258F },
+ { 0x2592, 0x2595 }, { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 },
+ { 0x25B2, 0x25B3 }, { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD },
+ { 0x25C0, 0x25C1 }, { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB },
+ { 0x25CE, 0x25D1 }, { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF },
+ { 0x2605, 0x2606 }, { 0x2609, 0x2609 }, { 0x260E, 0x260F },
{ 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 },
{ 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 },
{ 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F },
- { 0x273D, 0x273D }, { 0x2776, 0x277F }, { 0xE000, 0xF8FF },
- { 0xFFFD, 0xFFFD }, { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD }
+ { 0x269E, 0x269F }, { 0x26BF, 0x26BF }, { 0x26C6, 0x26CD },
+ { 0x26CF, 0x26D3 }, { 0x26D5, 0x26E1 }, { 0x26E3, 0x26E3 },
+ { 0x26E8, 0x26E9 }, { 0x26EB, 0x26F1 }, { 0x26F4, 0x26F4 },
+ { 0x26F6, 0x26F9 }, { 0x26FB, 0x26FC }, { 0x26FE, 0x26FF },
+ { 0x273D, 0x273D }, { 0x2776, 0x277F }, { 0x2B56, 0x2B59 },
+ { 0x3248, 0x324F }, { 0xE000, 0xF8FF }, { 0xFFFD, 0xFFFD },
+ { 0x1F100, 0x1F10A }, { 0x1F110, 0x1F12D }, { 0x1F130, 0x1F169 },
+ { 0x1F170, 0x1F18D }, { 0x1F18F, 0x1F190 }, { 0x1F19B, 0x1F1AC },
+ { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD }
};
+ /* *INDENT-ON* */
+
+ /* binary search in table of non-spacing characters */
+ if (Lookup((unsigned long) ucs, ambiguous))
+ return 2;
+
+ return mk_wcwidth(ucs);
+}
- /* binary search in table of non-spacing characters */
- if (bisearch(ucs, ambiguous,
- sizeof(ambiguous) / sizeof(struct interval) - 1))
- return 2;
+#ifdef UNUSED
+NCURSES_EXPORT(int)
+mk_wcswidth_cjk(const uint32_t *pwcs, size_t n)
+{
+ int width = 0;
+
+ for (; *pwcs && n-- > 0; pwcs++) {
+ int w;
- return mk_wcwidth(ucs);
+ if ((w = mk_wcwidth_cjk(*pwcs)) < 0)
+ return -1;
+ else
+ width += w;
+ }
+
+ return width;
}
+#endif /* UNUSED */
+#ifdef TEST_DRIVER
+static int opt_all = 0;
+static int opt_quiet = 0;
+static int opt_wider = 0;
+static long total_test = 0;
+static long total_errs = 0;
-NCURSES_EXPORT(int) mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
+static void
+usage(void)
{
- int w, width = 0;
+ static const char *msg[] =
+ {
+ "Usage: test_wcwidth [options] [c1[-c1b] [c2-[c2b] [...]]]",
+ "",
+ "Options:",
+ " -a show all data, rather than just differences",
+ " -s show only summary",
+ " -w use width-characters for ambiguous-width"
+ };
+ size_t n;
+ for (n = 0; n < sizeof(msg) / sizeof(msg[0]); ++n) {
+ fprintf(stderr, "%s\n", msg[n]);
+ }
+ exit(EXIT_FAILURE);
+}
- for (;*pwcs && n-- > 0; pwcs++)
- if ((w = mk_wcwidth_cjk(*pwcs)) < 0)
- return -1;
- else
- width += w;
+static int
+decode_one(const char *source, char **target)
+{
+ int result = -1;
+ long check;
+ int radix = 0;
+ if ((source[0] == 'u' || source[0] == 'U') && source[1] == '+') {
+ source += 2;
+ radix = 16;
+ }
+ check = strtol(source, target, radix);
+ if (*target != NULL && *target != source)
+ result = (int) check;
+ return result;
+}
- return width;
+static int
+decode_range(const char *source, int *lo, int *hi)
+{
+ int result = 0;
+ char *after1;
+ char *after2;
+ if ((*lo = decode_one(source, &after1)) >= 0) {
+ after1 += strspn(after1, ":-.\t ");
+ if ((*hi = decode_one(after1, &after2)) < 0) {
+ *hi = *lo;
+ }
+ result = 1;
+ }
+ return result;
}
-#ifdef __cplusplus
+static void
+do_range(const char *source)
+{
+ int lo, hi;
+ if (decode_range(source, &lo, &hi)) {
+ while (lo <= hi) {
+ wchar_t wlo = (wchar_t) lo;
+ int local_rc = opt_wider ? mk_wcwidth_cjk(wlo) : mk_wcwidth(wlo);
+ int other_rc = wcwidth(wlo);
+ ++total_test;
+ if (opt_all || (local_rc != other_rc)) {
+ if (!opt_quiet)
+ printf("U+%04X\t%d\t%d\n", lo, local_rc, other_rc);
+ }
+ if (local_rc != other_rc) {
+ ++total_errs;
+ }
+ ++lo;
+ }
+ }
}
-#endif
+
+int
+main(int argc, char **argv)
+{
+ int ch;
+
+ setlocale(LC_ALL, "");
+ while ((ch = getopt(argc, argv, "asw")) != -1) {
+ switch (ch) {
+ case 'a':
+ opt_all = 1;
+ break;
+ case 's':
+ opt_quiet = 1;
+ break;
+ case 'w':
+ opt_wider = 1;
+ break;
+ default:
+ usage();
+ }
+ }
+ if (optind >= argc)
+ usage();
+ while (optind < argc) {
+ do_range(argv[optind++]);
+ }
+ if (total_test) {
+ printf("%ld/%ld mismatches (%.0f%%)\n",
+ total_errs,
+ total_test,
+ (100.0 * (double) total_errs) / (double) total_test);
+ }
+ return EXIT_SUCCESS;
+}
+#endif /* TEST_DRIVER 1 */
#endif /* _WCWIDTH_H_incl 1 */
diff --git a/ncurses/widechar/charable.c b/ncurses/widechar/charable.c
index 55d4890c8366..828ceb4a7463 100644
--- a/ncurses/widechar/charable.c
+++ b/ncurses/widechar/charable.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2025 Thomas E. Dickey *
* Copyright 2003-2005,2008 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: charable.c,v 1.8 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: charable.c,v 1.9 2025/09/13 10:55:44 tom Exp $")
NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch)
{
@@ -52,9 +52,8 @@ NCURSES_EXPORT(int) _nc_to_char(wint_t ch)
#if HAVE_WCTOB
result = wctob(ch);
#elif HAVE_WCTOMB
- char temp[MB_LEN_MAX];
- result = wctomb(temp, ch);
- if (strlen(temp) == 1)
+ char temp[MB_LEN_MAX + 1];
+ if (wctomb(temp, ch) == 1)
result = UChar(temp[0]);
else
result = -1;
diff --git a/ncurses/widechar/lib_add_wch.c b/ncurses/widechar/lib_add_wch.c
index be1bbb051ad3..b72c2c8bad1b 100644
--- a/ncurses/widechar/lib_add_wch.c
+++ b/ncurses/widechar/lib_add_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2021,2023 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 2004-2011,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,7 +40,7 @@
#include <wctype.h>
#endif
-MODULE_ID("$Id: lib_add_wch.c,v 1.18 2023/07/15 17:34:12 tom Exp $")
+MODULE_ID("$Id: lib_add_wch.c,v 1.22 2025/01/19 00:51:54 tom Exp $")
/* clone/adapt lib_addch.c */
static const cchar_t blankchar = NewChar(BLANK_TEXT);
@@ -115,7 +115,7 @@ render_char(WINDOW *win, cchar_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;
@@ -307,7 +307,7 @@ wadd_wch_nosync(WINDOW *win, cchar_t ch)
/* the workhorse function -- add a character to the given window */
{
NCURSES_SIZE_T x, y;
- wchar_t *s;
+ const wchar_t *s;
int tabsize = 8;
#if USE_REENTRANT
SCREEN *sp = _nc_screen_of(win);
@@ -384,7 +384,7 @@ wadd_wch_nosync(WINDOW *win, cchar_t ch)
win->_flags &= ~_WRAPPED;
break;
default:
- if ((s = wunctrl(&ch)) != 0) {
+ if ((s = wunctrl(&ch)) != NULL) {
while (*s) {
cchar_t sch;
SetChar(sch, *s++, AttrOf(ch));
@@ -434,7 +434,7 @@ wecho_wchar(WINDOW *win, const cchar_t *wch)
{
int code = ERR;
- TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"),
+ TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wecho_wchar(%p, %s)"),
(void *) win,
_tracecchar_t(wch)));
diff --git a/ncurses/widechar/lib_box_set.c b/ncurses/widechar/lib_box_set.c
index ef2e1a7d1583..9525cd0accc6 100644
--- a/ncurses/widechar/lib_box_set.c
+++ b/ncurses/widechar/lib_box_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2002-2009,2011 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_box_set.c,v 1.7 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_box_set.c,v 1.8 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
wborder_set(WINDOW *win,
@@ -67,7 +67,7 @@ wborder_set(WINDOW *win,
if (!win)
returnCode(ERR);
-#define RENDER_WITH_DEFAULT(ch,def) w ##ch = _nc_render(win, (ch == 0) ? *(const ARG_CH_T)def : *ch)
+#define RENDER_WITH_DEFAULT(ch,def) w ##ch = _nc_render(win, (ch == NULL) ? *(const ARG_CH_T)def : *ch)
RENDER_WITH_DEFAULT(ls, WACS_VLINE);
RENDER_WITH_DEFAULT(rs, WACS_VLINE);
diff --git a/ncurses/widechar/lib_cchar.c b/ncurses/widechar/lib_cchar.c
index 451c5dcb518b..b535946161c5 100644
--- a/ncurses/widechar/lib_cchar.c
+++ b/ncurses/widechar/lib_cchar.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2021,2022 Thomas E. Dickey *
+ * Copyright 2019-2022,2024 Thomas E. Dickey *
* Copyright 2001-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 <wchar.h>
-MODULE_ID("$Id: lib_cchar.c,v 1.38 2022/07/27 08:03:16 tom Exp $")
+MODULE_ID("$Id: lib_cchar.c,v 1.40 2024/12/07 18:07:52 tom Exp $")
/*
* The SuSv2 description leaves some room for interpretation. We'll assume wch
@@ -119,7 +119,7 @@ getcchar(const cchar_t *wcval,
} else
#endif
if (wcval != NULL) {
- wchar_t *wp;
+ const wchar_t *wp;
int len;
#if HAVE_WMEMCHR
@@ -135,7 +135,7 @@ getcchar(const cchar_t *wcval,
* If the value is not a null, return the length plus 1 for null.
*/
code = (len < CCHARW_MAX) ? (len + 1) : CCHARW_MAX;
- } else if (attrs == 0 || pair_arg == 0) {
+ } else if (attrs == NULL || pair_arg == NULL) {
code = ERR;
} else if (len >= 0) {
int color_pair;
diff --git a/ncurses/widechar/lib_get_wch.c b/ncurses/widechar/lib_get_wch.c
index 9f10d3bcf121..f8ae47a6912f 100644
--- a/ncurses/widechar/lib_get_wch.c
+++ b/ncurses/widechar/lib_get_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 2002-2011,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_get_wch.c,v 1.26 2021/04/17 16:12:54 tom Exp $")
+MODULE_ID("$Id: lib_get_wch.c,v 1.28 2025/11/01 20:16:24 tom Exp $")
NCURSES_EXPORT(int)
wget_wch(WINDOW *win, wint_t *result)
@@ -62,7 +62,7 @@ wget_wch(WINDOW *win, wint_t *result)
_nc_lock_global(curses);
sp = _nc_screen_of(win);
- if (sp != 0) {
+ if (sp != NULL) {
size_t count = 0;
for (;;) {
@@ -103,7 +103,7 @@ wget_wch(WINDOW *win, wint_t *result)
code = ERR; /* the two calls should match */
safe_ungetch(SP_PARM, value);
}
- value = wch;
+ value = (int) wch;
break;
}
}
@@ -112,7 +112,7 @@ wget_wch(WINDOW *win, wint_t *result)
code = ERR;
}
- if (result != 0)
+ if (result != NULL)
*result = (wint_t) value;
_nc_unlock_global(curses);
diff --git a/ncurses/widechar/lib_get_wstr.c b/ncurses/widechar/lib_get_wstr.c
index 3b3bd522c2d8..4aa9a0c46d6a 100644
--- a/ncurses/widechar/lib_get_wstr.c
+++ b/ncurses/widechar/lib_get_wstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2021,2023 Thomas E. Dickey *
+ * Copyright 2018-2023,2024 Thomas E. Dickey *
* Copyright 2002-2009,2011 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -40,10 +40,10 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_get_wstr.c,v 1.21 2023/04/29 19:02:03 tom Exp $")
+MODULE_ID("$Id: lib_get_wstr.c,v 1.22 2024/07/27 19:22:23 tom Exp $")
static int
-wadd_wint(WINDOW *win, wint_t *src)
+wadd_wint(WINDOW *win, const wint_t *src)
{
cchar_t tmp;
wchar_t wch[2];
@@ -59,7 +59,7 @@ wadd_wint(WINDOW *win, wint_t *src)
* or other character, and handles reverse wraparound.
*/
static wint_t *
-WipeOut(WINDOW *win, int y, int x, wint_t *first, wint_t *last, int echoed)
+WipeOut(WINDOW *win, int y, int x, const wint_t *first, wint_t *last, int echoed)
{
if (last > first) {
*--last = '\0';
diff --git a/ncurses/widechar/lib_hline_set.c b/ncurses/widechar/lib_hline_set.c
index 8d5e02638a5a..3cb59c260954 100644
--- a/ncurses/widechar/lib_hline_set.c
+++ b/ncurses/widechar/lib_hline_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2002-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_hline_set.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_hline_set.c,v 1.7 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
whline_set(WINDOW *win, const cchar_t *ch, int n)
@@ -60,7 +60,7 @@ whline_set(WINDOW *win, const cchar_t *ch, int n)
CHANGED_RANGE(line, start, end);
- if (ch == 0)
+ if (ch == NULL)
wch = *WACS_HLINE;
else
wch = *ch;
diff --git a/ncurses/widechar/lib_in_wch.c b/ncurses/widechar/lib_in_wch.c
index 1d27332279a7..a401305dc17d 100644
--- a/ncurses/widechar/lib_in_wch.c
+++ b/ncurses/widechar/lib_in_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2002-2009,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_in_wch.c,v 1.7 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_in_wch.c,v 1.8 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
win_wch(WINDOW *win, cchar_t *wcval)
@@ -49,8 +49,8 @@ win_wch(WINDOW *win, cchar_t *wcval)
TR(TRACE_CCALLS, (T_CALLED("win_wch(%p,%p)"), (void *) win, (void *) wcval));
- if (win != 0
- && wcval != 0) {
+ if (win != NULL
+ && wcval != NULL) {
int row, col;
getyx(win, row, col);
diff --git a/ncurses/widechar/lib_in_wchnstr.c b/ncurses/widechar/lib_in_wchnstr.c
index 40a2bb62b419..6f24888ba1d3 100644
--- a/ncurses/widechar/lib_in_wchnstr.c
+++ b/ncurses/widechar/lib_in_wchnstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2002-2007,2009 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_in_wchnstr.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_in_wchnstr.c,v 1.11 2024/12/07 18:03:14 tom Exp $")
NCURSES_EXPORT(int)
win_wchnstr(WINDOW *win, cchar_t *wchstr, int n)
@@ -48,9 +48,9 @@ win_wchnstr(WINDOW *win, cchar_t *wchstr, int n)
int code = OK;
T((T_CALLED("win_wchnstr(%p,%p,%d)"), (void *) win, (void *) wchstr, n));
- if (win != 0
- && wchstr != 0) {
- NCURSES_CH_T *src;
+ if (win != NULL
+ && wchstr != NULL) {
+ const NCURSES_CH_T *src;
int row, col;
int j, k, limit;
diff --git a/ncurses/widechar/lib_ins_wch.c b/ncurses/widechar/lib_ins_wch.c
index ecaabcc9b73e..d880ff14f932 100644
--- a/ncurses/widechar/lib_ins_wch.c
+++ b/ncurses/widechar/lib_ins_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2019-2020,2023 Thomas E. Dickey *
+ * Copyright 2019-2024,2025 Thomas E. Dickey *
* Copyright 2002-2016,2017 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_ins_wch.c,v 1.29 2023/11/21 21:53:28 tom Exp $")
+MODULE_ID("$Id: lib_ins_wch.c,v 1.34 2025/06/21 22:26:21 tom Exp $")
/*
* Insert the given character, updating the current location to simplify
@@ -63,7 +63,7 @@ _nc_insert_wch(WINDOW *win, const cchar_t *wch)
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 - cells;
+ const NCURSES_CH_T *temp2 = temp1 - cells;
CHANGED_TO_EOL(line, win->_curx, win->_maxx);
while (temp1 > end)
@@ -87,7 +87,7 @@ wins_wch(WINDOW *win, const cchar_t *wch)
T((T_CALLED("wins_wch(%p, %s)"), (void *) win, _tracecchar_t(wch)));
- if (win != 0) {
+ if (win != NULL) {
NCURSES_SIZE_T oy = win->_cury;
NCURSES_SIZE_T ox = win->_curx;
@@ -100,6 +100,14 @@ wins_wch(WINDOW *win, const cchar_t *wch)
returnCode(code);
}
+static int
+flush_wchars(WINDOW *win, wchar_t *wchars)
+{
+ cchar_t tmp_cchar;
+ (void) setcchar(&tmp_cchar, wchars, WA_NORMAL, (short) 0, (void *) 0);
+ return _nc_insert_wch(win, &tmp_cchar);
+}
+
NCURSES_EXPORT(int)
wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
{
@@ -108,9 +116,8 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
T((T_CALLED("wins_nwstr(%p,%s,%d)"),
(void *) win, _nc_viswbufn(wstr, n), n));
- if (win != 0
- && wstr != 0
- && n != 0) {
+ if (win != NULL
+ && wstr != NULL) {
if (n < 0) {
n = INT_MAX;
@@ -122,27 +129,37 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
SCREEN *sp = _nc_screen_of(win);
NCURSES_SIZE_T oy = win->_cury;
NCURSES_SIZE_T ox = win->_curx;
+ wchar_t tmp_wchars[1 + CCHARW_MAX];
+ int num_wchars = 0;
for (cp = wstr; ((cp - wstr) < n) && (*cp != L'\0'); cp++) {
int len = _nc_wacs_width(*cp);
- if ((len >= 0 && len != 1) || !is7bits(*cp)) {
- cchar_t tmp_cchar;
- wchar_t tmp_wchar = *cp;
- memset(&tmp_cchar, 0, sizeof(tmp_cchar));
- (void) setcchar(&tmp_cchar,
- &tmp_wchar,
- WA_NORMAL,
- (short) 0,
- (void *) 0);
- code = _nc_insert_wch(win, &tmp_cchar);
- } else {
+ if (is7bits(*cp) && len <= 0) {
+ if (num_wchars) {
+ if ((code = flush_wchars(win, tmp_wchars)) != OK)
+ break;
+ num_wchars = 0;
+ }
/* tabs, other ASCII stuff */
code = _nc_insert_ch(sp, win, (chtype) (*cp));
+ } else {
+ if (num_wchars > 0 && len > 0) {
+ if ((code = flush_wchars(win, tmp_wchars)) != OK)
+ break;
+ num_wchars = 0;
+ }
+ if (num_wchars < CCHARW_MAX) {
+ tmp_wchars[num_wchars++] = *cp;
+ tmp_wchars[num_wchars] = L'\0';
+ }
}
if (code != OK)
break;
}
+ if (code == OK && num_wchars) {
+ code = flush_wchars(win, tmp_wchars);
+ }
win->_curx = ox;
win->_cury = oy;
diff --git a/ncurses/widechar/lib_inwstr.c b/ncurses/widechar/lib_inwstr.c
index b2fdaeac7171..5f82c2eff586 100644
--- a/ncurses/widechar/lib_inwstr.c
+++ b/ncurses/widechar/lib_inwstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-2024,2025 Thomas E. Dickey *
* Copyright 2002-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -34,22 +34,22 @@
/*
** lib_inwstr.c
**
-** The routines winnwstr() and winwstr().
+** The routine winnwstr().
**
*/
#include <curses.priv.h>
-MODULE_ID("$Id: lib_inwstr.c,v 1.9 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_inwstr.c,v 1.14 2025/01/19 00:51:54 tom Exp $")
NCURSES_EXPORT(int)
winnwstr(WINDOW *win, wchar_t *wstr, int n)
{
int count = 0;
- cchar_t *text;
+ const cchar_t *text;
T((T_CALLED("winnwstr(%p,%p,%d)"), (void *) win, (void *) wstr, n));
- if (wstr != 0) {
+ if (wstr != NULL) {
if (win) {
int row, col;
int last = 0;
@@ -57,6 +57,9 @@ winnwstr(WINDOW *win, wchar_t *wstr, int n)
getyx(win, row, col);
+ if (n < 0)
+ n = CCHARW_MAX * (win->_maxx - win->_curx + 1);
+
text = win->_line[row].text;
while (count < n && !done && count != ERR) {
@@ -92,23 +95,3 @@ winnwstr(WINDOW *win, wchar_t *wstr, int n)
}
returnCode(count);
}
-
-/*
- * X/Open says winwstr() returns OK if not ERR. If that is not a blunder, it
- * must have a null termination on the string (see above). Unlike winnstr(),
- * it does not define what happens for a negative count with winnwstr().
- */
-NCURSES_EXPORT(int)
-winwstr(WINDOW *win, wchar_t *wstr)
-{
- int result = OK;
-
- T((T_CALLED("winwstr(%p,%p)"), (void *) win, (void *) wstr));
- if (win == 0) {
- result = ERR;
- } else if (winnwstr(win, wstr,
- CCHARW_MAX * (win->_maxx - win->_curx + 1)) == ERR) {
- result = ERR;
- }
- returnCode(result);
-}
diff --git a/ncurses/widechar/lib_key_name.c b/ncurses/widechar/lib_key_name.c
index 379bdc2d48dd..c85909fe6b88 100644
--- a/ncurses/widechar/lib_key_name.c
+++ b/ncurses/widechar/lib_key_name.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 2007-2008,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,7 +36,7 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_key_name.c,v 1.6 2023/06/03 12:15:34 tom Exp $")
+MODULE_ID("$Id: lib_key_name.c,v 1.7 2024/07/27 19:23:59 tom Exp $")
#define MyData _nc_globals.key_name
@@ -44,7 +44,7 @@ NCURSES_EXPORT(NCURSES_CONST char *)
key_name(wchar_t c)
{
cchar_t my_cchar;
- wchar_t *my_wchars;
+ const wchar_t *my_wchars;
size_t len;
NCURSES_CONST char *result = NULL;
diff --git a/ncurses/widechar/lib_pecho_wchar.c b/ncurses/widechar/lib_pecho_wchar.c
index 502967fd4e4d..617ee3e4b36b 100644
--- a/ncurses/widechar/lib_pecho_wchar.c
+++ b/ncurses/widechar/lib_pecho_wchar.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey *
+ * Copyright 2020-2021,2024 Thomas E. Dickey *
* Copyright 2004,2009 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -33,14 +33,14 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_pecho_wchar.c,v 1.4 2021/10/23 17:07:56 tom Exp $")
+MODULE_ID("$Id: lib_pecho_wchar.c,v 1.5 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
pecho_wchar(WINDOW *pad, const cchar_t *wch)
{
T((T_CALLED("pecho_wchar(%p, %s)"), (void *) pad, _tracech_t(wch)));
- if (pad == 0)
+ if (pad == NULL)
returnCode(ERR);
if (!IS_PAD(pad))
diff --git a/ncurses/widechar/lib_slk_wset.c b/ncurses/widechar/lib_slk_wset.c
index 5aa75ff962f0..eb4c10a1212f 100644
--- a/ncurses/widechar/lib_slk_wset.c
+++ b/ncurses/widechar/lib_slk_wset.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2003-2011,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -41,7 +41,7 @@
#include <wctype.h>
#endif
-MODULE_ID("$Id: lib_slk_wset.c,v 1.15 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_slk_wset.c,v 1.16 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
slk_wset(int i, const wchar_t *astr, int format)
@@ -52,7 +52,7 @@ slk_wset(int i, const wchar_t *astr, int format)
T((T_CALLED("slk_wset(%d, %s, %d)"), i, _nc_viswbuf(astr), format));
- if (astr != 0) {
+ if (astr != NULL) {
size_t arglen;
init_mb(state);
@@ -61,7 +61,7 @@ slk_wset(int i, const wchar_t *astr, int format)
if ((arglen = wcsrtombs(NULL, &str, (size_t) 0, &state)) != (size_t) -1) {
char *mystr;
- if ((mystr = (char *) _nc_doalloc(0, arglen + 1)) != 0) {
+ if ((mystr = (char *) _nc_doalloc(NULL, arglen + 1)) != NULL) {
str = astr;
if (wcsrtombs(mystr, &str, arglen, &state) != (size_t) -1) {
/* glibc documentation claims that the terminating L'\0'
diff --git a/ncurses/widechar/lib_unget_wch.c b/ncurses/widechar/lib_unget_wch.c
index 1a81fecc8705..9f3308bc389b 100644
--- a/ncurses/widechar/lib_unget_wch.c
+++ b/ncurses/widechar/lib_unget_wch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2024 Thomas E. Dickey *
* Copyright 2002-2011,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_unget_wch.c,v 1.18 2023/06/03 12:50:52 tom Exp $")
+MODULE_ID("$Id: lib_unget_wch.c,v 1.19 2024/12/07 20:08:15 tom Exp $")
/*
* Wrapper for wcrtomb() which obtains the length needed for the given
@@ -51,7 +51,7 @@ _nc_wcrtomb(char *target, wchar_t source, mbstate_t * state)
{
int result;
- if (target == 0) {
+ if (target == NULL) {
wchar_t temp[2];
const wchar_t *tempp = temp;
temp[0] = source;
@@ -75,13 +75,13 @@ NCURSES_SP_NAME(unget_wch) (NCURSES_SP_DCLx const wchar_t wch)
T((T_CALLED("unget_wch(%p, %#lx)"), (void *) SP_PARM, (unsigned long) wch));
init_mb(state);
- length = _nc_wcrtomb(0, wch, &state);
+ length = _nc_wcrtomb(NULL, wch, &state);
if (length != (size_t) (-1)
&& length != 0) {
char *string;
- if ((string = (char *) malloc(length)) != 0) {
+ if ((string = (char *) malloc(length)) != NULL) {
int n;
init_mb(state);
diff --git a/ncurses/widechar/lib_vid_attr.c b/ncurses/widechar/lib_vid_attr.c
index f108b307d9a7..864f73e9cb3b 100644
--- a/ncurses/widechar/lib_vid_attr.c
+++ b/ncurses/widechar/lib_vid_attr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2023 Thomas E. Dickey *
+ * Copyright 2018-2023,2024 Thomas E. Dickey *
* Copyright 2002-2014,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -37,7 +37,7 @@
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_vid_attr.c,v 1.31 2023/04/28 20:59:34 tom Exp $")
+MODULE_ID("$Id: lib_vid_attr.c,v 1.32 2024/12/07 20:08:59 tom Exp $")
#define doPut(mode) \
TPUTS_TRACE(#mode); \
@@ -87,9 +87,9 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
attr_t turn_on, turn_off;
bool reverse = FALSE;
- bool can_color = (SP_PARM == 0 || SP_PARM->_coloron);
+ bool can_color = (SP_PARM == NULL || SP_PARM->_coloron);
#if NCURSES_EXT_FUNCS
- bool fix_pair0 = (SP_PARM != 0 && SP_PARM->_coloron && !SP_PARM->_default_color);
+ bool fix_pair0 = (SP_PARM != NULL && SP_PARM->_coloron && !SP_PARM->_default_color);
#else
#define fix_pair0 FALSE
#endif
@@ -193,15 +193,15 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx
TPUTS_TRACE("set_attributes");
NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx
TIPARM_9(set_attributes,
- (newmode & A_STANDOUT) != 0,
- (newmode & A_UNDERLINE) != 0,
- (newmode & A_REVERSE) != 0,
- (newmode & A_BLINK) != 0,
- (newmode & A_DIM) != 0,
- (newmode & A_BOLD) != 0,
- (newmode & A_INVIS) != 0,
- (newmode & A_PROTECT) != 0,
- (newmode & A_ALTCHARSET) != 0),
+ (newmode & A_STANDOUT) != 0,
+ (newmode & A_UNDERLINE) != 0,
+ (newmode & A_REVERSE) != 0,
+ (newmode & A_BLINK) != 0,
+ (newmode & A_DIM) != 0,
+ (newmode & A_BOLD) != 0,
+ (newmode & A_INVIS) != 0,
+ (newmode & A_PROTECT) != 0,
+ (newmode & A_ALTCHARSET) != 0),
1, outc);
previous_attr &= ALL_BUT_COLOR;
previous_pair = 0;
diff --git a/ncurses/widechar/lib_vline_set.c b/ncurses/widechar/lib_vline_set.c
index f7bb5819b6df..e7af3bfefcf2 100644
--- a/ncurses/widechar/lib_vline_set.c
+++ b/ncurses/widechar/lib_vline_set.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2002-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_vline_set.c,v 1.6 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_vline_set.c,v 1.7 2024/12/07 20:08:15 tom Exp $")
NCURSES_EXPORT(int)
wvline_set(WINDOW *win, const cchar_t *ch, int n)
@@ -58,7 +58,7 @@ wvline_set(WINDOW *win, const cchar_t *ch, int n)
if (end > win->_maxy)
end = win->_maxy;
- if (ch == 0)
+ if (ch == NULL)
wch = *WACS_VLINE;
else
wch = *ch;
diff --git a/ncurses/widechar/lib_wacs.c b/ncurses/widechar/lib_wacs.c
index 5b6f6da28936..d88279afd205 100644
--- a/ncurses/widechar/lib_wacs.c
+++ b/ncurses/widechar/lib_wacs.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey *
+ * Copyright 2018-2020,2024 Thomas E. Dickey *
* Copyright 2002-2015,2016 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -33,9 +33,9 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_wacs.c,v 1.20 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_wacs.c,v 1.21 2024/12/07 20:08:32 tom Exp $")
-NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = 0;
+NCURSES_EXPORT_VAR(cchar_t) * _nc_wacs = NULL;
NCURSES_EXPORT(void)
_nc_init_wacs(void)
@@ -119,7 +119,7 @@ _nc_init_wacs(void)
T(("initializing WIDE-ACS map (Unicode is%s active)",
active ? "" : " not"));
- if ((_nc_wacs = typeCalloc(cchar_t, ACS_LEN)) != 0) {
+ if ((_nc_wacs = typeCalloc(cchar_t, ACS_LEN)) != NULL) {
unsigned n;
for (n = 0; n < SIZEOF(table); ++n) {
diff --git a/ncurses/widechar/lib_wunctrl.c b/ncurses/widechar/lib_wunctrl.c
index 155da22926ba..259b68aa217f 100644
--- a/ncurses/widechar/lib_wunctrl.c
+++ b/ncurses/widechar/lib_wunctrl.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2001-2011,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -36,17 +36,18 @@
#include <curses.priv.h>
-MODULE_ID("$Id: lib_wunctrl.c,v 1.17 2020/02/02 23:34:34 tom Exp $")
+MODULE_ID("$Id: lib_wunctrl.c,v 1.19 2024/12/07 18:03:14 tom Exp $")
NCURSES_EXPORT(wchar_t *)
NCURSES_SP_NAME(wunctrl) (NCURSES_SP_DCLx cchar_t *wc)
{
- static wchar_t str[CCHARW_MAX + 1], *wsp;
+ static wchar_t str[CCHARW_MAX + 1];
wchar_t *result;
- if (wc == 0) {
- result = 0;
- } else if (SP_PARM != 0 && Charable(*wc)) {
+ if (wc == NULL) {
+ result = NULL;
+ } else if (SP_PARM != NULL && Charable(*wc)) {
+ wchar_t *wsp;
const char *p =
NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx
(unsigned) _nc_to_char((wint_t)CharOf(*wc)));
diff --git a/ncurses/widechar/widechars.c b/ncurses/widechar/widechars.c
index d05ba98a8265..6ea008ddad65 100644
--- a/ncurses/widechar/widechars.c
+++ b/ncurses/widechar/widechars.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018,2020 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2012,2013 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -31,9 +31,9 @@
#if USE_WIDEC_SUPPORT
-MODULE_ID("$Id: widechars.c,v 1.9 2020/08/29 16:22:03 juergen Exp $")
+MODULE_ID("$Id: widechars.c,v 1.11 2025/02/20 01:02:09 tom Exp $")
-#if (defined(_NC_WINDOWS)) && !defined(_NC_MSC)
+#if defined(_NC_MINGW)
/*
* MinGW has wide-character functions, but they do not work correctly.
*/
@@ -45,7 +45,7 @@ _nc_mbtowc(wchar_t *pwc, const char *s, size_t n)
int count;
int try;
- if (s != 0 && n != 0) {
+ if (s != NULL && n != 0) {
/*
* MultiByteToWideChar() can decide to return more than one
* wide-character. We want only one. Ignore any trailing null, both
@@ -96,7 +96,7 @@ _nc_mblen(const char *s, size_t n)
int count;
wchar_t temp;
- if (s != 0 && n != 0) {
+ if (s != NULL && n != 0) {
count = _nc_mbtowc(&temp, s, n);
if (count == 1) {
int check = WideCharToMultiByte(CP_UTF8,
@@ -148,6 +148,6 @@ _nc_wctomb(char *s, wchar_t wc)
return result;
}
-#endif /* _NC_WINDOWS */
+#endif /* _NC_MINGW */
#endif /* USE_WIDEC_SUPPORT */
diff --git a/ncurses/win32con/gettimeofday.c b/ncurses/win32con/gettimeofday.c
index 603a6f462b78..7b673d46d8ad 100644
--- a/ncurses/win32con/gettimeofday.c
+++ b/ncurses/win32con/gettimeofday.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 2020-2023,2025 Thomas E. Dickey *
* Copyright 2008-2010,2014 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -27,16 +27,11 @@
* authorization. *
****************************************************************************/
-#ifdef WINVER
-# undef WINVER
-#endif
-#define WINVER 0x0501
-
#include <curses.priv.h>
#include <windows.h>
-MODULE_ID("$Id: gettimeofday.c,v 1.7 2023/02/25 20:05:36 tom Exp $")
+MODULE_ID("$Id: gettimeofday.c,v 1.8 2025/08/30 17:59:42 tom Exp $")
#if HAVE_GETTIMEOFDAY == 2
#define JAN1970 116444736000000000LL /* the value for 01/01/1970 00:00 */
diff --git a/ncurses/win32con/wcwidth.c b/ncurses/win32con/wcwidth.c
index 55843662e8aa..1a5401821e7a 100644
--- a/ncurses/win32con/wcwidth.c
+++ b/ncurses/win32con/wcwidth.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2024 Thomas E. Dickey *
* Copyright 2010 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -28,7 +28,7 @@
****************************************************************************/
#include <curses.priv.h>
-MODULE_ID("$Id: wcwidth.c,v 1.4 2020/07/11 21:02:10 tom Exp $")
+MODULE_ID("$Id: wcwidth.c,v 1.5 2024/05/04 18:31:39 tom Exp $")
#if USE_WIDEC_SUPPORT
#define mk_wcwidth(ucs) _nc_wcwidth(ucs)
@@ -36,10 +36,11 @@ MODULE_ID("$Id: wcwidth.c,v 1.4 2020/07/11 21:02:10 tom Exp $")
#define mk_wcwidth_cjk(ucs) _nc_wcwidth_cjk(ucs)
#define mk_wcswidth_cjk(pwcs, n) _nc_wcswidth_cjk(pwcs, n)
-NCURSES_EXPORT(int) mk_wcwidth(wchar_t);
-NCURSES_EXPORT(int) mk_wcswidth(const wchar_t *, size_t);
-NCURSES_EXPORT(int) mk_wcwidth_cjk(wchar_t);
-NCURSES_EXPORT(int) mk_wcswidth_cjk(const wchar_t *, size_t);
+NCURSES_EXPORT(void) mk_wcwidth_init(int);
+NCURSES_EXPORT(int) mk_wcwidth(uint32_t);
+NCURSES_EXPORT(int) mk_wcswidth(const uint32_t *, size_t);
+NCURSES_EXPORT(int) mk_wcwidth_cjk(uint32_t);
+NCURSES_EXPORT(int) mk_wcswidth_cjk(const uint32_t *, size_t);
#include <wcwidth.h>
#else
diff --git a/ncurses/win32con/win32_driver.c b/ncurses/win32con/win32_driver.c
index 0a43588b1714..8e2bba4478d1 100644
--- a/ncurses/win32con/win32_driver.c
+++ b/ncurses/win32con/win32_driver.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2018-2020,2023 Thomas E. Dickey *
+ * Copyright 2018-2024,2025 Thomas E. Dickey *
* Copyright 2008-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -38,41 +38,29 @@
*/
#include <curses.priv.h>
-#ifdef _NC_WINDOWS
-#if (defined(__MINGW32__) || defined(__MINGW64__))
-#include <wchar.h>
-#else
-#include <tchar.h>
-#endif
-#include <io.h>
#define CUR TerminalType(my_term).
-MODULE_ID("$Id: win32_driver.c,v 1.4 2023/09/16 16:29:24 tom Exp $")
+MODULE_ID("$Id: win32_driver.c,v 1.20 2025/12/30 19:34:50 tom Exp $")
#define WINMAGIC NCDRV_MAGIC(NCDRV_WINCONSOLE)
#define EXP_OPTIMIZE 0
-static bool console_initialized = FALSE;
+#define AssertTCB() assert(TCB != NULL && (TCB->magic == WINMAGIC))
+#define validateConsoleHandle() (AssertTCB(), console_initialized || \
+ (console_initialized = \
+ _nc_console_checkinit(USE_NAMED_PIPES)))
+#define SetSP() assert(TCB->csp != NULL); sp = TCB->csp; (void) sp
-#define AssertTCB() assert(TCB != 0 && (TCB->magic == WINMAGIC))
-#define validateConsoleHandle() (AssertTCB() , console_initialized ||\
- (console_initialized=\
- _nc_console_checkinit(TRUE,FALSE)))
-#define SetSP() assert(TCB->csp != 0); sp = TCB->csp; (void) sp
-#define AdjustY() (WINCONSOLE.buffered ?\
- 0 : (int) WINCONSOLE.SBI.srWindow.Top)
-#define RevAttr(attr) (WORD) (((attr) & 0xff00) | \
- ((((attr) & 0x07) << 4) | \
- (((attr) & 0x70) >> 4)))
+#define AdjustY() (WINCONSOLE.buffered \
+ ? 0 \
+ : (int) WINCONSOLE.SBI.srWindow.Top)
-#if USE_WIDEC_SUPPORT
-#define write_screen WriteConsoleOutputW
-#define read_screen ReadConsoleOutputW
-#else
-#define write_screen WriteConsoleOutput
-#define read_screen ReadConsoleOutput
-#endif
+#define RevAttr(attr) (WORD) (((attr) & 0xff00) | \
+ ((((attr) & 0x07) << 4) | \
+ (((attr) & 0x70) >> 4)))
+
+static bool console_initialized = FALSE;
static WORD
MapAttr(WORD res, attr_t ch)
@@ -140,7 +128,7 @@ dump_screen(const char *fn, int ln)
for (i = save_region.Top; i <= save_region.Bottom; ++i) {
for (j = save_region.Left; j <= save_region.Right; ++j) {
- output[k++] = save_screen[ij++].Char.AsciiChar;
+ output[k++] = save_screen[ij++].CharInfoChar;
}
output[k++] = '\n';
}
@@ -171,7 +159,7 @@ con_write16(TERMINAL_CONTROL_BLOCK * TCB,
int y, int x, cchar_t *str, int limit)
{
int actual = 0;
- CHAR_INFO *ci = TypeAlloca(CHAR_INFO, limit);
+ MakeArray(ci, CHAR_INFO, limit);
COORD loc, siz;
SMALL_RECT rec;
int i;
@@ -185,7 +173,7 @@ con_write16(TERMINAL_CONTROL_BLOCK * TCB,
ch = str[i];
if (isWidecExt(ch))
continue;
- ci[actual].Char.UnicodeChar = CharOf(ch);
+ ci[actual].CharInfoChar = CharOf(ch);
ci[actual].Attributes = MapAttr(WINCONSOLE.SBI.wAttributes,
AttrOf(ch));
if (AttrOf(ch) & A_ALTCHARSET) {
@@ -194,9 +182,9 @@ con_write16(TERMINAL_CONTROL_BLOCK * TCB,
if (which > 0
&& which < ACS_LEN
&& CharOf(_nc_wacs[which]) != 0) {
- ci[actual].Char.UnicodeChar = CharOf(_nc_wacs[which]);
+ ci[actual].CharInfoChar = CharOf(_nc_wacs[which]);
} else {
- ci[actual].Char.UnicodeChar = ' ';
+ ci[actual].CharInfoChar = ' ';
}
}
}
@@ -220,7 +208,7 @@ con_write16(TERMINAL_CONTROL_BLOCK * TCB,
static BOOL
con_write8(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n)
{
- CHAR_INFO *ci = TypeAlloca(CHAR_INFO, n);
+ MakeArray(ci, CHAR_INFO, n);
COORD loc, siz;
SMALL_RECT rec;
int i;
@@ -232,13 +220,13 @@ con_write8(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n)
for (i = 0; i < n; i++) {
ch = str[i];
- ci[i].Char.AsciiChar = ChCharOf(ch);
+ ci[i].CharInfoChar = ChCharOf(ch);
ci[i].Attributes = MapAttr(WINCONSOLE.SBI.wAttributes,
ChAttrOf(ch));
if (ChAttrOf(ch) & A_ALTCHARSET) {
if (sp->_acs_map)
- ci[i].Char.AsciiChar =
- ChCharOf(NCURSES_SP_NAME(_nc_acs_char) (sp, ChCharOf(ch)));
+ ci[i].CharInfoChar =
+ ChCharOf(NCURSES_SP_NAME(_nc_acs_char) (sp, ChCharOf(ch)));
}
}
@@ -415,16 +403,16 @@ wcon_doupdate(TERMINAL_CONTROL_BLOCK * TCB)
if ((CurScreen(sp)->_clear || NewScreen(sp)->_clear)) {
int x;
#if USE_WIDEC_SUPPORT
- cchar_t *empty = TypeAlloca(cchar_t, Width);
+ MakeArray(empty, cchar_t, Width);
wchar_t blank[2] =
{
L' ', L'\0'
};
for (x = 0; x < Width; x++)
- setcchar(&empty[x], blank, 0, 0, 0);
+ setcchar(&empty[x], blank, 0, 0, NULL);
#else
- chtype *empty = TypeAlloca(chtype, Width);
+ MakeArray(empty, chtype, Width);
for (x = 0; x < Width; x++)
empty[x] = ' ';
@@ -528,16 +516,17 @@ wcon_CanHandle(TERMINAL_CONTROL_BLOCK * TCB,
{
bool code = FALSE;
- T((T_CALLED("win32con::wcon_CanHandle(%p)"), TCB));
+ T((T_CALLED("win32con::wcon_CanHandle(%p,%s,%p)"),
+ (void *) TCB, NonNull(tname), (void *) errret));
- assert((TCB != 0) && (tname != 0));
+ assert(TCB != NULL);
TCB->magic = WINMAGIC;
- if (tname == 0 || *tname == 0) {
+ if (tname == NULL || *tname == 0) {
if (!_nc_console_vt_supported())
code = TRUE;
- } else if (tname != 0 && *tname == '#') {
+ } else if (tname != NULL && *tname == '#') {
/*
* Use "#" (a character which cannot begin a terminal's name) to
* select specific driver from the table.
@@ -551,9 +540,14 @@ wcon_CanHandle(TERMINAL_CONTROL_BLOCK * TCB,
|| (strncmp(tname + 1, "win32con", n) == 0))) {
code = TRUE;
}
- } else if (tname != 0 && stricmp(tname, "unknown") == 0) {
+ } else if (tname != NULL && stricmp(tname, "unknown") == 0) {
code = TRUE;
}
+#if !USE_NAMED_PIPES
+ else if (_isatty(TCB->term.Filedes)) {
+ code = TRUE;
+ }
+#endif
/*
* This is intentional, to avoid unnecessary breakage of applications
@@ -589,8 +583,8 @@ wcon_dobeepflash(TERMINAL_CONTROL_BLOCK * TCB,
int max_cells = (high * wide);
int i;
- CHAR_INFO *this_screen = TypeAlloca(CHAR_INFO, max_cells);
- CHAR_INFO *that_screen = TypeAlloca(CHAR_INFO, max_cells);
+ MakeArray(this_screen, CHAR_INFO, max_cells);
+ MakeArray(that_screen, CHAR_INFO, max_cells);
COORD this_size;
SMALL_RECT this_region;
COORD bufferCoord;
@@ -752,9 +746,6 @@ wcon_sgmode(TERMINAL_CONTROL_BLOCK * TCB, int setFlag, TTY * buf)
returnCode(result);
}
-#define MIN_WIDE 80
-#define MIN_HIGH 24
-
static int
wcon_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag)
{
@@ -762,12 +753,12 @@ wcon_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag)
TERMINAL *_term = (TERMINAL *) TCB;
int code = ERR;
+ T((T_CALLED("win32con::wcon_mode(%p, progFlag=%d, defFlag=%d)"),
+ TCB, progFlag, defFlag));
+
if (validateConsoleHandle()) {
sp = TCB->csp;
- T((T_CALLED("win32con::wcon_mode(%p, progFlag=%d, defFlag=%d)"),
- TCB, progFlag, defFlag));
-
WINCONSOLE.progMode = progFlag;
WINCONSOLE.lastOut = progFlag ? WINCONSOLE.hdl : WINCONSOLE.out;
SetConsoleActiveScreenBuffer(WINCONSOLE.lastOut);
@@ -847,7 +838,7 @@ wcon_init(TERMINAL_CONTROL_BLOCK * TCB)
AssertTCB();
- if (!(console_initialized = _nc_console_checkinit(TRUE, FALSE))) {
+ if (!(console_initialized = _nc_console_checkinit(USE_NAMED_PIPES))) {
returnVoid;
}
@@ -1059,7 +1050,7 @@ wcon_initacs(TERMINAL_CONTROL_BLOCK * TCB,
for (n = 0; n < SIZEOF(table); ++n) {
real_map[table[n].acs_code] =
(chtype) table[n].use_code | A_ALTCHARSET;
- if (sp != 0)
+ if (sp != NULL)
sp->_screen_acs_map[table[n].acs_code] = TRUE;
}
}
@@ -1221,5 +1212,3 @@ NCURSES_EXPORT_VAR (TERM_DRIVER) _nc_WIN_DRIVER = {
wcon_kyExist, /* kyExist */
wcon_cursorSet /* cursorSet */
};
-
-#endif /* _NC_WINDOWS */
diff --git a/ncurses/win32con/win_driver.c b/ncurses/win32con/win_driver.c
deleted file mode 100644
index 2425b3a44ce6..000000000000
--- a/ncurses/win32con/win_driver.c
+++ /dev/null
@@ -1,2282 +0,0 @@
-/****************************************************************************
- * Copyright 2018-2021,2023 Thomas E. Dickey *
- * Copyright 2008-2016,2017 Free Software Foundation, Inc. *
- * *
- * Permission is hereby granted, free of charge, to any person obtaining a *
- * copy of this software and associated documentation files (the *
- * "Software"), to deal in the Software without restriction, including *
- * without limitation the rights to use, copy, modify, merge, publish, *
- * distribute, distribute with modifications, sublicense, and/or sell *
- * copies of the Software, and to permit persons to whom the Software is *
- * furnished to do so, subject to the following conditions: *
- * *
- * The above copyright notice and this permission notice shall be included *
- * in all copies or substantial portions of the Software. *
- * *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
- * *
- * Except as contained in this notice, the name(s) of the above copyright *
- * holders shall not be used in advertising or otherwise to promote the *
- * sale, use or other dealings in this Software without prior written *
- * authorization. *
- ****************************************************************************/
-
-/****************************************************************************
- * Author: Juergen Pfeifer *
- * and: Thomas E. Dickey *
- ****************************************************************************/
-
-/*
- * TODO - GetMousePos(POINT * result) from ntconio.c
- * TODO - implement nodelay
- * TODO - improve screen-repainting performance, using implied wraparound to reduce write's
- * TODO - make it optional whether screen is restored or not when non-buffered
- */
-
-#include <curses.priv.h>
-
-#ifdef _WIN32
-#include <tchar.h>
-#else
-#include <windows.h>
-#include <wchar.h>
-#endif
-
-#include <io.h>
-
-#define PSAPI_VERSION 2
-#include <psapi.h>
-
-#define CUR TerminalType(my_term).
-
-#define CONTROL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
-
-MODULE_ID("$Id: win_driver.c,v 1.74 2023/09/16 16:27:44 tom Exp $")
-
-#define TypeAlloca(type,count) (type*) _alloca(sizeof(type) * (size_t) (count))
-
-#define WINMAGIC NCDRV_MAGIC(NCDRV_WINCONSOLE)
-
-#define EXP_OPTIMIZE 0
-
-#define array_length(a) (sizeof(a)/sizeof(a[0]))
-
-static bool InitConsole(void);
-static bool okConsoleHandle(TERMINAL_CONTROL_BLOCK *);
-
-#define AssertTCB() assert(TCB != 0 && (TCB->magic == WINMAGIC))
-#define SetSP() assert(TCB->csp != 0); sp = TCB->csp; (void) sp
-
-#define GenMap(vKey,key) MAKELONG(key, vKey)
-
-#define AdjustY() (CON.buffered ? 0 : (int) CON.SBI.srWindow.Top)
-
-#if USE_WIDEC_SUPPORT
-#define write_screen WriteConsoleOutputW
-#define read_screen ReadConsoleOutputW
-#else
-#define write_screen WriteConsoleOutput
-#define read_screen ReadConsoleOutput
-#endif
-/* *INDENT-OFF* */
-static const LONG keylist[] =
-{
- GenMap(VK_PRIOR, KEY_PPAGE),
- GenMap(VK_NEXT, KEY_NPAGE),
- GenMap(VK_END, KEY_END),
- GenMap(VK_HOME, KEY_HOME),
- GenMap(VK_LEFT, KEY_LEFT),
- GenMap(VK_UP, KEY_UP),
- GenMap(VK_RIGHT, KEY_RIGHT),
- GenMap(VK_DOWN, KEY_DOWN),
- GenMap(VK_DELETE, KEY_DC),
- GenMap(VK_INSERT, KEY_IC)
-};
-static const LONG ansi_keys[] =
-{
- GenMap(VK_PRIOR, 'I'),
- GenMap(VK_NEXT, 'Q'),
- GenMap(VK_END, 'O'),
- GenMap(VK_HOME, 'H'),
- GenMap(VK_LEFT, 'K'),
- GenMap(VK_UP, 'H'),
- GenMap(VK_RIGHT, 'M'),
- GenMap(VK_DOWN, 'P'),
- GenMap(VK_DELETE, 'S'),
- GenMap(VK_INSERT, 'R')
-};
-/* *INDENT-ON* */
-#define N_INI ((int)array_length(keylist))
-#define FKEYS 24
-#define MAPSIZE (FKEYS + N_INI)
-#define NUMPAIRS 64
-
-/* A process can only have a single console, so it is safe
- to maintain all the information about it in a single
- static structure.
- */
-static struct {
- BOOL initialized;
- BOOL buffered;
- BOOL window_only;
- BOOL progMode;
- BOOL isTermInfoConsole;
- HANDLE out;
- HANDLE inp;
- HANDLE hdl;
- HANDLE lastOut;
- int numButtons;
- DWORD ansi_map[MAPSIZE];
- DWORD map[MAPSIZE];
- DWORD rmap[MAPSIZE];
- WORD pairs[NUMPAIRS];
- COORD origin;
- CHAR_INFO *save_screen;
- COORD save_size;
- SMALL_RECT save_region;
- CONSOLE_SCREEN_BUFFER_INFO SBI;
- CONSOLE_SCREEN_BUFFER_INFO save_SBI;
- CONSOLE_CURSOR_INFO save_CI;
-} CON;
-
-static BOOL console_initialized = FALSE;
-
-static WORD
-MapColor(bool fore, int color)
-{
- static const int _cmap[] =
- {0, 4, 2, 6, 1, 5, 3, 7};
- int a;
- if (color < 0 || color > 7)
- a = fore ? 7 : 0;
- else
- a = _cmap[color];
- if (!fore)
- a = a << 4;
- return (WORD) a;
-}
-
-#define RevAttr(attr) \
- (WORD) (((attr) & 0xff00) | \
- ((((attr) & 0x07) << 4) | \
- (((attr) & 0x70) >> 4)))
-
-static WORD
-MapAttr(WORD res, attr_t ch)
-{
- if (ch & A_COLOR) {
- int p;
-
- p = PairNumber(ch);
- if (p > 0 && p < NUMPAIRS) {
- WORD a;
- a = CON.pairs[p];
- res = (WORD) ((res & 0xff00) | a);
- }
- }
-
- if (ch & A_REVERSE) {
- res = RevAttr(res);
- }
-
- if (ch & A_STANDOUT) {
- res = RevAttr(res) | BACKGROUND_INTENSITY;
- }
-
- if (ch & A_BOLD)
- res |= FOREGROUND_INTENSITY;
-
- if (ch & A_DIM)
- res |= BACKGROUND_INTENSITY;
-
- return res;
-}
-
-#if 0 /* def TRACE */
-static void
-dump_screen(const char *fn, int ln)
-{
- int max_cells = (CON.SBI.dwSize.Y * (1 + CON.SBI.dwSize.X)) + 1;
- char output[max_cells];
- CHAR_INFO save_screen[max_cells];
- COORD save_size;
- SMALL_RECT save_region;
- COORD bufferCoord;
-
- T(("dump_screen %s@%d", fn, ln));
-
- save_region.Top = CON.SBI.srWindow.Top;
- save_region.Left = CON.SBI.srWindow.Left;
- save_region.Bottom = CON.SBI.srWindow.Bottom;
- save_region.Right = CON.SBI.srWindow.Right;
-
- save_size.X = (SHORT) (save_region.Right - save_region.Left + 1);
- save_size.Y = (SHORT) (save_region.Bottom - save_region.Top + 1);
-
- bufferCoord.X = bufferCoord.Y = 0;
-
- if (read_screen(CON.hdl,
- save_screen,
- save_size,
- bufferCoord,
- &save_region)) {
- int i, j;
- int ij = 0;
- int k = 0;
-
- for (i = save_region.Top; i <= save_region.Bottom; ++i) {
- for (j = save_region.Left; j <= save_region.Right; ++j) {
- output[k++] = save_screen[ij++].Char.AsciiChar;
- }
- output[k++] = '\n';
- }
- output[k] = 0;
-
- T(("DUMP: %d,%d - %d,%d",
- save_region.Top,
- save_region.Left,
- save_region.Bottom,
- save_region.Right));
- T(("%s", output));
- }
-}
-
-#else
-#define dump_screen(fn,ln) /* nothing */
-#endif
-
-#if USE_WIDEC_SUPPORT
-/*
- * TODO: support surrogate pairs
- * TODO: support combining characters
- * TODO: support acsc
- * TODO: _nc_wacs should be part of sp.
- */
-static BOOL
-con_write16(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, cchar_t *str, int limit)
-{
- int actual = 0;
- CHAR_INFO *ci = TypeAlloca(CHAR_INFO, limit);
- COORD loc, siz;
- SMALL_RECT rec;
- int i;
- cchar_t ch;
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
- for (i = actual = 0; i < limit; i++) {
- ch = str[i];
- if (isWidecExt(ch))
- continue;
- ci[actual].Char.UnicodeChar = CharOf(ch);
- ci[actual].Attributes = MapAttr(CON.SBI.wAttributes,
- AttrOf(ch));
- if (AttrOf(ch) & A_ALTCHARSET) {
- if (_nc_wacs) {
- int which = CharOf(ch);
- if (which > 0
- && which < ACS_LEN
- && CharOf(_nc_wacs[which]) != 0) {
- ci[actual].Char.UnicodeChar = CharOf(_nc_wacs[which]);
- } else {
- ci[actual].Char.UnicodeChar = ' ';
- }
- }
- }
- ++actual;
- }
-
- loc.X = (SHORT) 0;
- loc.Y = (SHORT) 0;
- siz.X = (SHORT) actual;
- siz.Y = 1;
-
- rec.Left = (SHORT) x;
- rec.Top = (SHORT) (y + AdjustY());
- rec.Right = (SHORT) (x + limit - 1);
- rec.Bottom = rec.Top;
-
- return write_screen(CON.hdl, ci, siz, loc, &rec);
-}
-#define con_write(tcb, y, x, str, n) con_write16(tcb, y, x, str, n)
-#else
-static BOOL
-con_write8(TERMINAL_CONTROL_BLOCK * TCB, int y, int x, chtype *str, int n)
-{
- CHAR_INFO *ci = TypeAlloca(CHAR_INFO, n);
- COORD loc, siz;
- SMALL_RECT rec;
- int i;
- chtype ch;
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
- for (i = 0; i < n; i++) {
- ch = str[i];
- ci[i].Char.AsciiChar = ChCharOf(ch);
- ci[i].Attributes = MapAttr(CON.SBI.wAttributes,
- ChAttrOf(ch));
- if (ChAttrOf(ch) & A_ALTCHARSET) {
- if (sp->_acs_map)
- ci[i].Char.AsciiChar =
- ChCharOf(NCURSES_SP_NAME(_nc_acs_char) (sp, ChCharOf(ch)));
- }
- }
-
- loc.X = (short) 0;
- loc.Y = (short) 0;
- siz.X = (short) n;
- siz.Y = 1;
-
- rec.Left = (short) x;
- rec.Top = (short) y;
- rec.Right = (short) (x + n - 1);
- rec.Bottom = rec.Top;
-
- return write_screen(CON.hdl, ci, siz, loc, &rec);
-}
-#define con_write(tcb, y, x, str, n) con_write8(tcb, y, x, str, n)
-#endif
-
-#if EXP_OPTIMIZE
-/*
- * Comparing new/current screens, determine the last column-index for a change
- * beginning on the given row,col position. Unlike a serial terminal, there is
- * no cost for "moving" the "cursor" on the line as we update it.
- */
-static int
-find_end_of_change(SCREEN *sp, int row, int col)
-{
- int result = col;
- struct ldat *curdat = CurScreen(sp)->_line + row;
- struct ldat *newdat = NewScreen(sp)->_line + row;
-
- while (col <= newdat->lastchar) {
-#if USE_WIDEC_SUPPORT
- if (isWidecExt(curdat->text[col]) || isWidecExt(newdat->text[col])) {
- result = col;
- } else if (memcmp(&curdat->text[col],
- &newdat->text[col],
- sizeof(curdat->text[0]))) {
- result = col;
- } else {
- break;
- }
-#else
- if (curdat->text[col] != newdat->text[col]) {
- result = col;
- } else {
- break;
- }
-#endif
- ++col;
- }
- return result;
-}
-
-/*
- * Given a row,col position at the end of a change-chunk, look for the
- * beginning of the next change-chunk.
- */
-static int
-find_next_change(SCREEN *sp, int row, int col)
-{
- struct ldat *curdat = CurScreen(sp)->_line + row;
- struct ldat *newdat = NewScreen(sp)->_line + row;
- int result = newdat->lastchar + 1;
-
- while (++col <= newdat->lastchar) {
-#if USE_WIDEC_SUPPORT
- if (isWidecExt(curdat->text[col]) != isWidecExt(newdat->text[col])) {
- result = col;
- break;
- } else if (memcmp(&curdat->text[col],
- &newdat->text[col],
- sizeof(curdat->text[0]))) {
- result = col;
- break;
- }
-#else
- if (curdat->text[col] != newdat->text[col]) {
- result = col;
- break;
- }
-#endif
- }
- return result;
-}
-
-#define EndChange(first) \
- find_end_of_change(sp, y, first)
-#define NextChange(last) \
- find_next_change(sp, y, last)
-
-#endif /* EXP_OPTIMIZE */
-
-#define MARK_NOCHANGE(win,row) \
- win->_line[row].firstchar = _NOCHANGE; \
- win->_line[row].lastchar = _NOCHANGE
-
-static void
-selectActiveHandle(void)
-{
- if (CON.lastOut != CON.hdl) {
- CON.lastOut = CON.hdl;
- SetConsoleActiveScreenBuffer(CON.lastOut);
- }
-}
-
-static bool
-restore_original_screen(void)
-{
- COORD bufferCoord;
- bool result = FALSE;
- SMALL_RECT save_region = CON.save_region;
-
- T(("... restoring %s", CON.window_only ? "window" : "entire buffer"));
-
- bufferCoord.X = (SHORT) (CON.window_only ? CON.SBI.srWindow.Left : 0);
- bufferCoord.Y = (SHORT) (CON.window_only ? CON.SBI.srWindow.Top : 0);
-
- if (write_screen(CON.hdl,
- CON.save_screen,
- CON.save_size,
- bufferCoord,
- &save_region)) {
- result = TRUE;
- mvcur(-1, -1, LINES - 2, 0);
- T(("... restore original screen contents ok %dx%d (%d,%d - %d,%d)",
- CON.save_size.Y,
- CON.save_size.X,
- save_region.Top,
- save_region.Left,
- save_region.Bottom,
- save_region.Right));
- } else {
- T(("... restore original screen contents err"));
- }
- return result;
-}
-
-static const char *
-wcon_name(TERMINAL_CONTROL_BLOCK * TCB)
-{
- (void) TCB;
- return "win32console";
-}
-
-static int
-wcon_doupdate(TERMINAL_CONTROL_BLOCK * TCB)
-{
- int result = ERR;
- int y, nonempty, n, x0, x1, Width, Height;
- SCREEN *sp;
-
- T((T_CALLED("win32con::wcon_doupdate(%p)"), TCB));
- if (okConsoleHandle(TCB)) {
- SetSP();
-
- Width = screen_columns(sp);
- Height = screen_lines(sp);
- nonempty = Min(Height, NewScreen(sp)->_maxy + 1);
-
- T(("... %dx%d clear cur:%d new:%d",
- Height, Width,
- CurScreen(sp)->_clear,
- NewScreen(sp)->_clear));
-
- if (SP_PARM->_endwin == ewSuspend) {
-
- T(("coming back from shell mode"));
- NCURSES_SP_NAME(reset_prog_mode) (NCURSES_SP_ARG);
-
- NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_ARG);
- NCURSES_SP_NAME(_nc_screen_resume) (NCURSES_SP_ARG);
- SP_PARM->_mouse_resume(SP_PARM);
-
- SP_PARM->_endwin = ewRunning;
- }
-
- if ((CurScreen(sp)->_clear || NewScreen(sp)->_clear)) {
- int x;
-#if USE_WIDEC_SUPPORT
- cchar_t *empty = TypeAlloca(cchar_t, Width);
- wchar_t blank[2] =
- {
- L' ', L'\0'
- };
-
- for (x = 0; x < Width; x++)
- setcchar(&empty[x], blank, 0, 0, 0);
-#else
- chtype *empty = TypeAlloca(chtype, Width);
-
- for (x = 0; x < Width; x++)
- empty[x] = ' ';
-#endif
-
- for (y = 0; y < nonempty; y++) {
- con_write(TCB, y, 0, empty, Width);
- memcpy(empty,
- CurScreen(sp)->_line[y].text,
- (size_t) Width * sizeof(empty[0]));
- }
- CurScreen(sp)->_clear = FALSE;
- NewScreen(sp)->_clear = FALSE;
- touchwin(NewScreen(sp));
- T(("... cleared %dx%d lines @%d of screen", nonempty, Width,
- AdjustY()));
- }
-
- for (y = 0; y < nonempty; y++) {
- x0 = NewScreen(sp)->_line[y].firstchar;
- if (x0 != _NOCHANGE) {
-#if EXP_OPTIMIZE
- int x2;
- int limit = NewScreen(sp)->_line[y].lastchar;
- while ((x1 = EndChange(x0)) <= limit) {
- while ((x2 = NextChange(x1)) <= limit && x2 <= (x1 + 2)) {
- x1 = x2;
- }
- n = x1 - x0 + 1;
- memcpy(&CurScreen(sp)->_line[y].text[x0],
- &NewScreen(sp)->_line[y].text[x0],
- n * sizeof(CurScreen(sp)->_line[y].text[x0]));
- con_write(TCB,
- y,
- x0,
- &CurScreen(sp)->_line[y].text[x0], n);
- x0 = NextChange(x1);
- }
-
- /* mark line changed successfully */
- if (y <= NewScreen(sp)->_maxy) {
- MARK_NOCHANGE(NewScreen(sp), y);
- }
- if (y <= CurScreen(sp)->_maxy) {
- MARK_NOCHANGE(CurScreen(sp), y);
- }
-#else
- x1 = NewScreen(sp)->_line[y].lastchar;
- n = x1 - x0 + 1;
- if (n > 0) {
- memcpy(&CurScreen(sp)->_line[y].text[x0],
- &NewScreen(sp)->_line[y].text[x0],
- (size_t) n * sizeof(CurScreen(sp)->_line[y].text[x0]));
- con_write(TCB,
- y,
- x0,
- &CurScreen(sp)->_line[y].text[x0], n);
-
- /* mark line changed successfully */
- if (y <= NewScreen(sp)->_maxy) {
- MARK_NOCHANGE(NewScreen(sp), y);
- }
- if (y <= CurScreen(sp)->_maxy) {
- MARK_NOCHANGE(CurScreen(sp), y);
- }
- }
-#endif
- }
- }
-
- /* put everything back in sync */
- for (y = nonempty; y <= NewScreen(sp)->_maxy; y++) {
- MARK_NOCHANGE(NewScreen(sp), y);
- }
- for (y = nonempty; y <= CurScreen(sp)->_maxy; y++) {
- MARK_NOCHANGE(CurScreen(sp), y);
- }
-
- if (!NewScreen(sp)->_leaveok) {
- CurScreen(sp)->_curx = NewScreen(sp)->_curx;
- CurScreen(sp)->_cury = NewScreen(sp)->_cury;
-
- TCB->drv->td_hwcur(TCB,
- 0, 0,
- CurScreen(sp)->_cury, CurScreen(sp)->_curx);
- }
- selectActiveHandle();
- result = OK;
- }
- returnCode(result);
-}
-
-#ifdef __MING32__
-#define SysISATTY(fd) _isatty(fd)
-#else
-#define SysISATTY(fd) isatty(fd)
-#endif
-
-static bool
-wcon_CanHandle(TERMINAL_CONTROL_BLOCK * TCB,
- const char *tname,
- int *errret GCC_UNUSED)
-{
- bool code = FALSE;
-
- T((T_CALLED("win32con::wcon_CanHandle(%p)"), TCB));
-
- assert((TCB != 0) && (tname != 0));
-
- TCB->magic = WINMAGIC;
-
- if (tname == 0 || *tname == 0)
- code = TRUE;
- else if (tname != 0 && *tname == '#') {
- /*
- * Use "#" (a character which cannot begin a terminal's name) to
- * select specific driver from the table.
- *
- * In principle, we could have more than one non-terminfo driver,
- * e.g., "win32gui".
- */
- size_t n = strlen(tname + 1);
- if (n != 0
- && ((strncmp(tname + 1, "win32console", n) == 0)
- || (strncmp(tname + 1, "win32con", n) == 0))) {
- code = TRUE;
- }
- } else if (tname != 0 && stricmp(tname, "unknown") == 0) {
- code = TRUE;
- } else if (SysISATTY(TCB->term.Filedes)) {
- code = TRUE;
- }
-
- /*
- * This is intentional, to avoid unnecessary breakage of applications
- * using <term.h> symbols.
- */
- if (code && (TerminalType(&TCB->term).Booleans == 0)) {
- _nc_init_termtype(&TerminalType(&TCB->term));
-#if NCURSES_EXT_NUMBERS
- _nc_export_termtype2(&TCB->term.type, &TerminalType(&TCB->term));
-#endif
- }
-
- if (!code) {
- if (_nc_mingw_isconsole(0))
- CON.isTermInfoConsole = TRUE;
- }
- returnBool(code);
-}
-
-static int
-wcon_dobeepflash(TERMINAL_CONTROL_BLOCK * TCB,
- int beepFlag)
-{
- SCREEN *sp;
- int res = ERR;
-
- int high = (CON.SBI.srWindow.Bottom - CON.SBI.srWindow.Top + 1);
- int wide = (CON.SBI.srWindow.Right - CON.SBI.srWindow.Left + 1);
- int max_cells = (high * wide);
- int i;
-
- CHAR_INFO *this_screen = TypeAlloca(CHAR_INFO, max_cells);
- CHAR_INFO *that_screen = TypeAlloca(CHAR_INFO, max_cells);
- COORD this_size;
- SMALL_RECT this_region;
- COORD bufferCoord;
-
- if (okConsoleHandle(TCB)) {
- SetSP();
- this_region.Top = CON.SBI.srWindow.Top;
- this_region.Left = CON.SBI.srWindow.Left;
- this_region.Bottom = CON.SBI.srWindow.Bottom;
- this_region.Right = CON.SBI.srWindow.Right;
-
- this_size.X = (SHORT) wide;
- this_size.Y = (SHORT) high;
-
- bufferCoord.X = this_region.Left;
- bufferCoord.Y = this_region.Top;
-
- if (!beepFlag &&
- read_screen(CON.hdl,
- this_screen,
- this_size,
- bufferCoord,
- &this_region)) {
-
- memcpy(that_screen,
- this_screen,
- sizeof(CHAR_INFO) * (size_t) max_cells);
-
- for (i = 0; i < max_cells; i++) {
- that_screen[i].Attributes = RevAttr(that_screen[i].Attributes);
- }
-
- write_screen(CON.hdl, that_screen, this_size, bufferCoord, &this_region);
- Sleep(200);
- write_screen(CON.hdl, this_screen, this_size, bufferCoord, &this_region);
-
- } else {
- MessageBeep(MB_ICONWARNING); /* MB_OK might be better */
- }
- res = OK;
- }
- return res;
-}
-
-static int
-wcon_print(TERMINAL_CONTROL_BLOCK * TCB,
- char *data GCC_UNUSED,
- int len GCC_UNUSED)
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
- return ERR;
-}
-
-static int
-wcon_defaultcolors(TERMINAL_CONTROL_BLOCK * TCB,
- int fg GCC_UNUSED,
- int bg GCC_UNUSED)
-{
- SCREEN *sp;
- int code = ERR;
-
- AssertTCB();
- SetSP();
-
- return (code);
-}
-
-static bool
-get_SBI(void)
-{
- bool rc = FALSE;
- if (GetConsoleScreenBufferInfo(CON.hdl, &(CON.SBI))) {
- T(("GetConsoleScreenBufferInfo"));
- T(("... buffer(X:%d Y:%d)",
- CON.SBI.dwSize.X,
- CON.SBI.dwSize.Y));
- T(("... window(X:%d Y:%d)",
- CON.SBI.dwMaximumWindowSize.X,
- CON.SBI.dwMaximumWindowSize.Y));
- T(("... cursor(X:%d Y:%d)",
- CON.SBI.dwCursorPosition.X,
- CON.SBI.dwCursorPosition.Y));
- T(("... display(Top:%d Bottom:%d Left:%d Right:%d)",
- CON.SBI.srWindow.Top,
- CON.SBI.srWindow.Bottom,
- CON.SBI.srWindow.Left,
- CON.SBI.srWindow.Right));
- if (CON.buffered) {
- CON.origin.X = 0;
- CON.origin.Y = 0;
- } else {
- CON.origin.X = CON.SBI.srWindow.Left;
- CON.origin.Y = CON.SBI.srWindow.Top;
- }
- rc = TRUE;
- } else {
- T(("GetConsoleScreenBufferInfo ERR"));
- }
- return rc;
-}
-
-static void
-wcon_setcolor(TERMINAL_CONTROL_BLOCK * TCB,
- int fore,
- int color,
- int (*outc) (SCREEN *, int) GCC_UNUSED)
-{
- if (okConsoleHandle(TCB)) {
- WORD a = MapColor(fore, color);
- a |= (WORD) ((CON.SBI.wAttributes) & (fore ? 0xfff8 : 0xff8f));
- SetConsoleTextAttribute(CON.hdl, a);
- get_SBI();
- }
-}
-
-static bool
-wcon_rescol(TERMINAL_CONTROL_BLOCK * TCB)
-{
- bool res = FALSE;
-
- if (okConsoleHandle(TCB)) {
- WORD a = FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN;
- SetConsoleTextAttribute(CON.hdl, a);
- get_SBI();
- res = TRUE;
- }
- return res;
-}
-
-static bool
-wcon_rescolors(TERMINAL_CONTROL_BLOCK * TCB)
-{
- int result = FALSE;
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-
- return result;
-}
-
-static int
-wcon_size(TERMINAL_CONTROL_BLOCK * TCB, int *Lines, int *Cols)
-{
- int result = ERR;
-
- T((T_CALLED("win32con::wcon_size(%p)"), TCB));
-
- if (okConsoleHandle(TCB) &&
- Lines != NULL &&
- Cols != NULL) {
- if (CON.buffered) {
- *Lines = (int) (CON.SBI.dwSize.Y);
- *Cols = (int) (CON.SBI.dwSize.X);
- } else {
- *Lines = (int) (CON.SBI.srWindow.Bottom + 1 -
- CON.SBI.srWindow.Top);
- *Cols = (int) (CON.SBI.srWindow.Right + 1 -
- CON.SBI.srWindow.Left);
- }
- result = OK;
- }
- returnCode(result);
-}
-
-static int
-wcon_setsize(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED,
- int l GCC_UNUSED,
- int c GCC_UNUSED)
-{
- AssertTCB();
- return ERR;
-}
-
-static int
-wcon_sgmode(TERMINAL_CONTROL_BLOCK * TCB, int setFlag, TTY * buf)
-{
- DWORD dwFlag = 0;
- tcflag_t iflag;
- tcflag_t lflag;
- int result = ERR;
-
- if (buf != NULL && okConsoleHandle(TCB)) {
-
- if (setFlag) {
- iflag = buf->c_iflag;
- lflag = buf->c_lflag;
-
- GetConsoleMode(CON.inp, &dwFlag);
-
- if (lflag & ICANON)
- dwFlag |= ENABLE_LINE_INPUT;
- else
- dwFlag &= (DWORD) (~ENABLE_LINE_INPUT);
-
- if (lflag & ECHO)
- dwFlag |= ENABLE_ECHO_INPUT;
- else
- dwFlag &= (DWORD) (~ENABLE_ECHO_INPUT);
-
- if (iflag & BRKINT)
- dwFlag |= ENABLE_PROCESSED_INPUT;
- else
- dwFlag &= (DWORD) (~ENABLE_PROCESSED_INPUT);
-
- dwFlag |= ENABLE_MOUSE_INPUT;
-
- buf->c_iflag = iflag;
- buf->c_lflag = lflag;
- SetConsoleMode(CON.inp, dwFlag);
- TCB->term.Nttyb = *buf;
- } else {
- iflag = TCB->term.Nttyb.c_iflag;
- lflag = TCB->term.Nttyb.c_lflag;
- GetConsoleMode(CON.inp, &dwFlag);
-
- if (dwFlag & ENABLE_LINE_INPUT)
- lflag |= ICANON;
- else
- lflag &= (tcflag_t) (~ICANON);
-
- if (dwFlag & ENABLE_ECHO_INPUT)
- lflag |= ECHO;
- else
- lflag &= (tcflag_t) (~ECHO);
-
- if (dwFlag & ENABLE_PROCESSED_INPUT)
- iflag |= BRKINT;
- else
- iflag &= (tcflag_t) (~BRKINT);
-
- TCB->term.Nttyb.c_iflag = iflag;
- TCB->term.Nttyb.c_lflag = lflag;
-
- *buf = TCB->term.Nttyb;
- }
- result = OK;
- }
- return result;
-}
-
-#define MIN_WIDE 80
-#define MIN_HIGH 24
-
-/*
- * In "normal" mode, reset the buffer- and window-sizes back to their original values.
- */
-static void
-set_scrollback(bool normal, CONSOLE_SCREEN_BUFFER_INFO * info)
-{
- SMALL_RECT rect;
- COORD coord;
- bool changed = FALSE;
-
- T((T_CALLED("win32con::set_scrollback(%s)"),
- (normal
- ? "normal"
- : "application")));
-
- T(("... SBI.srWindow %d,%d .. %d,%d",
- info->srWindow.Top,
- info->srWindow.Left,
- info->srWindow.Bottom,
- info->srWindow.Right));
- T(("... SBI.dwSize %dx%d",
- info->dwSize.Y,
- info->dwSize.X));
-
- if (normal) {
- rect = info->srWindow;
- coord = info->dwSize;
- if (memcmp(info, &CON.SBI, sizeof(*info)) != 0) {
- changed = TRUE;
- CON.SBI = *info;
- }
- } else {
- int high = info->srWindow.Bottom - info->srWindow.Top + 1;
- int wide = info->srWindow.Right - info->srWindow.Left + 1;
-
- if (high < MIN_HIGH) {
- T(("... height %d < %d", high, MIN_HIGH));
- high = MIN_HIGH;
- changed = TRUE;
- }
- if (wide < MIN_WIDE) {
- T(("... width %d < %d", wide, MIN_WIDE));
- wide = MIN_WIDE;
- changed = TRUE;
- }
-
- rect.Left =
- rect.Top = 0;
- rect.Right = (SHORT) (wide - 1);
- rect.Bottom = (SHORT) (high - 1);
-
- coord.X = (SHORT) wide;
- coord.Y = (SHORT) high;
-
- if (info->dwSize.Y != high ||
- info->dwSize.X != wide ||
- info->srWindow.Top != 0 ||
- info->srWindow.Left != 0) {
- changed = TRUE;
- }
-
- }
-
- if (changed) {
- T(("... coord %d,%d", coord.Y, coord.X));
- T(("... rect %d,%d - %d,%d",
- rect.Top, rect.Left,
- rect.Bottom, rect.Right));
- SetConsoleScreenBufferSize(CON.hdl, coord); /* dwSize */
- SetConsoleWindowInfo(CON.hdl, TRUE, &rect); /* srWindow */
- get_SBI();
- }
- returnVoid;
-}
-
-static int
-wcon_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag)
-{
- SCREEN *sp;
- TERMINAL *_term = (TERMINAL *) TCB;
- int code = ERR;
-
- if (okConsoleHandle(TCB)) {
- sp = TCB->csp;
-
- T((T_CALLED("win32con::wcon_mode(%p, prog=%d, def=%d)"),
- TCB, progFlag, defFlag));
-
- CON.progMode = progFlag;
- CON.lastOut = progFlag ? CON.hdl : CON.out;
- SetConsoleActiveScreenBuffer(CON.lastOut);
-
- if (progFlag) /* prog mode */ {
- if (defFlag) {
- if ((wcon_sgmode(TCB, FALSE, &(_term->Nttyb)) == OK)) {
- _term->Nttyb.c_oflag &= (tcflag_t) (~OFLAGS_TABS);
- code = OK;
- }
- } else {
- /* reset_prog_mode */
- if (wcon_sgmode(TCB, TRUE, &(_term->Nttyb)) == OK) {
- if (sp) {
- if (sp->_keypad_on)
- _nc_keypad(sp, TRUE);
- }
- if (!CON.buffered) {
- set_scrollback(FALSE, &CON.SBI);
- }
- code = OK;
- }
- }
- T(("... buffered:%d, clear:%d", CON.buffered, CurScreen(sp)->_clear));
- } else { /* shell mode */
- if (defFlag) {
- /* def_shell_mode */
- if (wcon_sgmode(TCB, FALSE, &(_term->Ottyb)) == OK) {
- code = OK;
- }
- } else {
- /* reset_shell_mode */
- if (sp) {
- _nc_keypad(sp, FALSE);
- NCURSES_SP_NAME(_nc_flush) (sp);
- }
- code = wcon_sgmode(TCB, TRUE, &(_term->Ottyb));
- if (!CON.buffered) {
- set_scrollback(TRUE, &CON.save_SBI);
- if (!restore_original_screen())
- code = ERR;
- }
- SetConsoleCursorInfo(CON.hdl, &CON.save_CI);
- }
- }
-
- }
- returnCode(code);
-}
-
-static void
-wcon_screen_init(SCREEN *sp GCC_UNUSED)
-{
-}
-
-static void
-wcon_wrap(SCREEN *sp GCC_UNUSED)
-{
-}
-
-static int
-rkeycompare(const void *el1, const void *el2)
-{
- WORD key1 = (LOWORD((*((const LONG *) el1)))) & 0x7fff;
- WORD key2 = (LOWORD((*((const LONG *) el2)))) & 0x7fff;
-
- return ((key1 < key2) ? -1 : ((key1 == key2) ? 0 : 1));
-}
-
-static int
-keycompare(const void *el1, const void *el2)
-{
- WORD key1 = HIWORD((*((const LONG *) el1)));
- WORD key2 = HIWORD((*((const LONG *) el2)));
-
- return ((key1 < key2) ? -1 : ((key1 == key2) ? 0 : 1));
-}
-
-static int
-MapKey(WORD vKey)
-{
- WORD nKey = 0;
- void *res;
- LONG key = GenMap(vKey, 0);
- int code = -1;
-
- res = bsearch(&key,
- CON.map,
- (size_t) (N_INI + FKEYS),
- sizeof(keylist[0]),
- keycompare);
- if (res) {
- key = *((LONG *) res);
- nKey = LOWORD(key);
- code = (int) (nKey & 0x7fff);
- if (nKey & 0x8000)
- code = -code;
- }
- return code;
-}
-
-static int
-AnsiKey(WORD vKey)
-{
- WORD nKey = 0;
- void *res;
- LONG key = GenMap(vKey, 0);
- int code = -1;
-
- res = bsearch(&key,
- CON.ansi_map,
- (size_t) (N_INI + FKEYS),
- sizeof(keylist[0]),
- keycompare);
- if (res) {
- key = *((LONG *) res);
- nKey = LOWORD(key);
- code = (int) (nKey & 0x7fff);
- if (nKey & 0x8000)
- code = -code;
- }
- return code;
-}
-
-static void
-wcon_release(TERMINAL_CONTROL_BLOCK * TCB)
-{
- T((T_CALLED("win32con::wcon_release(%p)"), TCB));
-
- AssertTCB();
- if (TCB->prop)
- free(TCB->prop);
-
- returnVoid;
-}
-
-static bool
-read_screen_data(void)
-{
- bool result = FALSE;
- COORD bufferCoord;
- size_t want;
-
- CON.save_size.X = (SHORT) (CON.save_region.Right
- - CON.save_region.Left + 1);
- CON.save_size.Y = (SHORT) (CON.save_region.Bottom
- - CON.save_region.Top + 1);
-
- want = (size_t) (CON.save_size.X * CON.save_size.Y);
-
- if ((CON.save_screen = malloc(want * sizeof(CHAR_INFO))) != 0) {
- bufferCoord.X = (SHORT) (CON.window_only ? CON.SBI.srWindow.Left : 0);
- bufferCoord.Y = (SHORT) (CON.window_only ? CON.SBI.srWindow.Top : 0);
-
- T(("... reading console %s %dx%d into %d,%d - %d,%d at %d,%d",
- CON.window_only ? "window" : "buffer",
- CON.save_size.Y, CON.save_size.X,
- CON.save_region.Top,
- CON.save_region.Left,
- CON.save_region.Bottom,
- CON.save_region.Right,
- bufferCoord.Y,
- bufferCoord.X));
-
- if (read_screen(CON.hdl,
- CON.save_screen,
- CON.save_size,
- bufferCoord,
- &CON.save_region)) {
- result = TRUE;
- } else {
- T((" error %#lx", (unsigned long) GetLastError()));
- FreeAndNull(CON.save_screen);
- }
- }
-
- return result;
-}
-
-/*
- * Attempt to save the screen contents. PDCurses does this if
- * PDC_RESTORE_SCREEN is set, giving the same visual appearance on
- * restoration as if the library had allocated a console buffer. MSDN
- * says that the data which can be read is limited to 64Kb (and may be
- * less).
- */
-static bool
-save_original_screen(void)
-{
- bool result = FALSE;
-
- CON.save_region.Top = 0;
- CON.save_region.Left = 0;
- CON.save_region.Bottom = (SHORT) (CON.SBI.dwSize.Y - 1);
- CON.save_region.Right = (SHORT) (CON.SBI.dwSize.X - 1);
-
- if (read_screen_data()) {
- result = TRUE;
- } else {
-
- CON.save_region.Top = CON.SBI.srWindow.Top;
- CON.save_region.Left = CON.SBI.srWindow.Left;
- CON.save_region.Bottom = CON.SBI.srWindow.Bottom;
- CON.save_region.Right = CON.SBI.srWindow.Right;
-
- CON.window_only = TRUE;
-
- if (read_screen_data()) {
- result = TRUE;
- }
- }
-
- T(("... save original screen contents %s", result ? "ok" : "err"));
- return result;
-}
-
-static void
-wcon_init(TERMINAL_CONTROL_BLOCK * TCB)
-{
- T((T_CALLED("win32con::wcon_init(%p)"), TCB));
-
- AssertTCB();
-
- if (TCB) {
- if (!InitConsole()) {
- returnVoid;
- }
-
- TCB->info.initcolor = TRUE;
- TCB->info.canchange = FALSE;
- TCB->info.hascolor = TRUE;
- TCB->info.caninit = TRUE;
-
- TCB->info.maxpairs = NUMPAIRS;
- TCB->info.maxcolors = 8;
- TCB->info.numlabels = 0;
- TCB->info.labelwidth = 0;
- TCB->info.labelheight = 0;
- TCB->info.nocolorvideo = 1;
- TCB->info.tabsize = 8;
-
- TCB->info.numbuttons = CON.numButtons;
- TCB->info.defaultPalette = _nc_cga_palette;
-
- }
- returnVoid;
-}
-
-static void
-wcon_initpair(TERMINAL_CONTROL_BLOCK * TCB,
- int pair,
- int f,
- int b)
-{
- SCREEN *sp;
-
- if (okConsoleHandle(TCB)) {
- SetSP();
-
- if ((pair > 0) && (pair < NUMPAIRS) && (f >= 0) && (f < 8)
- && (b >= 0) && (b < 8)) {
- CON.pairs[pair] = MapColor(true, f) | MapColor(false, b);
- }
- }
-}
-
-static void
-wcon_initcolor(TERMINAL_CONTROL_BLOCK * TCB,
- int color GCC_UNUSED,
- int r GCC_UNUSED,
- int g GCC_UNUSED,
- int b GCC_UNUSED)
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-}
-
-static void
-wcon_do_color(TERMINAL_CONTROL_BLOCK * TCB,
- int old_pair GCC_UNUSED,
- int pair GCC_UNUSED,
- int reverse GCC_UNUSED,
- int (*outc) (SCREEN *, int) GCC_UNUSED
-)
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-}
-
-static void
-wcon_initmouse(TERMINAL_CONTROL_BLOCK * TCB)
-{
- SCREEN *sp;
-
- if (okConsoleHandle(TCB)) {
- SetSP();
-
- sp->_mouse_type = M_TERM_DRIVER;
- }
-}
-
-static int
-wcon_testmouse(TERMINAL_CONTROL_BLOCK * TCB,
- int delay
- EVENTLIST_2nd(_nc_eventlist * evl))
-{
- int rc = 0;
- SCREEN *sp;
-
- if (okConsoleHandle(TCB)) {
- SetSP();
-
- if (sp->_drv_mouse_head < sp->_drv_mouse_tail) {
- rc = TW_MOUSE;
- } else {
- rc = TCBOf(sp)->drv->td_twait(TCBOf(sp),
- TWAIT_MASK,
- delay,
- (int *) 0
- EVENTLIST_2nd(evl));
- }
- }
-
- return rc;
-}
-
-static int
-wcon_mvcur(TERMINAL_CONTROL_BLOCK * TCB,
- int yold GCC_UNUSED, int xold GCC_UNUSED,
- int y, int x)
-{
- int ret = ERR;
- if (okConsoleHandle(TCB)) {
- COORD loc;
- loc.X = (short) x;
- loc.Y = (short) (y + AdjustY());
- SetConsoleCursorPosition(CON.hdl, loc);
- ret = OK;
- }
- return ret;
-}
-
-static void
-wcon_hwlabel(TERMINAL_CONTROL_BLOCK * TCB,
- int labnum GCC_UNUSED,
- char *text GCC_UNUSED)
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-}
-
-static void
-wcon_hwlabelOnOff(TERMINAL_CONTROL_BLOCK * TCB,
- int OnFlag GCC_UNUSED)
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-}
-
-static chtype
-wcon_conattr(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED)
-{
- chtype res = A_NORMAL;
- res |= (A_BOLD | A_DIM | A_REVERSE | A_STANDOUT | A_COLOR);
- return res;
-}
-
-static void
-wcon_setfilter(TERMINAL_CONTROL_BLOCK * TCB)
-{
- SCREEN *sp;
-
- AssertTCB();
- SetSP();
-}
-
-static void
-wcon_initacs(TERMINAL_CONTROL_BLOCK * TCB,
- chtype *real_map GCC_UNUSED,
- chtype *fake_map GCC_UNUSED)
-{
-#define DATA(a,b) { a, b }
- static struct {
- int acs_code;
- int use_code;
- } table[] = {
- DATA('a', 0xb1), /* ACS_CKBOARD */
- DATA('f', 0xf8), /* ACS_DEGREE */
- DATA('g', 0xf1), /* ACS_PLMINUS */
- DATA('j', 0xd9), /* ACS_LRCORNER */
- DATA('l', 0xda), /* ACS_ULCORNER */
- DATA('k', 0xbf), /* ACS_URCORNER */
- DATA('m', 0xc0), /* ACS_LLCORNER */
- DATA('n', 0xc5), /* ACS_PLUS */
- DATA('q', 0xc4), /* ACS_HLINE */
- DATA('t', 0xc3), /* ACS_LTEE */
- DATA('u', 0xb4), /* ACS_RTEE */
- DATA('v', 0xc1), /* ACS_BTEE */
- DATA('w', 0xc2), /* ACS_TTEE */
- DATA('x', 0xb3), /* ACS_VLINE */
- DATA('y', 0xf3), /* ACS_LEQUAL */
- DATA('z', 0xf2), /* ACS_GEQUAL */
- DATA('0', 0xdb), /* ACS_BLOCK */
- DATA('{', 0xe3), /* ACS_PI */
- DATA('}', 0x9c), /* ACS_STERLING */
- DATA(',', 0xae), /* ACS_LARROW */
- DATA('+', 0xaf), /* ACS_RARROW */
- DATA('~', 0xf9), /* ACS_BULLET */
- };
-#undef DATA
- unsigned n;
-
- SCREEN *sp;
- if (okConsoleHandle(TCB)) {
- SetSP();
-
- for (n = 0; n < SIZEOF(table); ++n) {
- real_map[table[n].acs_code] = (chtype) table[n].use_code | A_ALTCHARSET;
- if (sp != 0)
- sp->_screen_acs_map[table[n].acs_code] = TRUE;
- }
- }
-}
-
-static ULONGLONG
-tdiff(FILETIME fstart, FILETIME fend)
-{
- ULARGE_INTEGER ustart;
- ULARGE_INTEGER uend;
- ULONGLONG diff;
-
- ustart.LowPart = fstart.dwLowDateTime;
- ustart.HighPart = fstart.dwHighDateTime;
- uend.LowPart = fend.dwLowDateTime;
- uend.HighPart = fend.dwHighDateTime;
-
- diff = (uend.QuadPart - ustart.QuadPart) / 10000;
- return diff;
-}
-
-static int
-Adjust(int milliseconds, int diff)
-{
- if (milliseconds != INFINITY) {
- milliseconds -= diff;
- if (milliseconds < 0)
- milliseconds = 0;
- }
- return milliseconds;
-}
-
-#define BUTTON_MASK (FROM_LEFT_1ST_BUTTON_PRESSED | \
- FROM_LEFT_2ND_BUTTON_PRESSED | \
- FROM_LEFT_3RD_BUTTON_PRESSED | \
- FROM_LEFT_4TH_BUTTON_PRESSED | \
- RIGHTMOST_BUTTON_PRESSED)
-
-static mmask_t
-decode_mouse(SCREEN *sp, int mask)
-{
- mmask_t result = 0;
-
- (void) sp;
- assert(sp && console_initialized);
-
- if (mask & FROM_LEFT_1ST_BUTTON_PRESSED)
- result |= BUTTON1_PRESSED;
- if (mask & FROM_LEFT_2ND_BUTTON_PRESSED)
- result |= BUTTON2_PRESSED;
- if (mask & FROM_LEFT_3RD_BUTTON_PRESSED)
- result |= BUTTON3_PRESSED;
- if (mask & FROM_LEFT_4TH_BUTTON_PRESSED)
- result |= BUTTON4_PRESSED;
-
- if (mask & RIGHTMOST_BUTTON_PRESSED) {
- switch (CON.numButtons) {
- case 1:
- result |= BUTTON1_PRESSED;
- break;
- case 2:
- result |= BUTTON2_PRESSED;
- break;
- case 3:
- result |= BUTTON3_PRESSED;
- break;
- case 4:
- result |= BUTTON4_PRESSED;
- break;
- }
- }
-
- return result;
-}
-
-static int
-console_twait(
- SCREEN *sp,
- HANDLE fd,
- int mode,
- int milliseconds,
- int *timeleft
- EVENTLIST_2nd(_nc_eventlist * evl))
-{
- INPUT_RECORD inp_rec;
- BOOL b;
- DWORD nRead = 0, rc = (DWORD) (-1);
- int code = 0;
- FILETIME fstart;
- FILETIME fend;
- int diff;
- bool isImmed = (milliseconds == 0);
-
-#ifdef NCURSES_WGETCH_EVENTS
- (void) evl; /* TODO: implement wgetch-events */
-#endif
-
-#define CONSUME() ReadConsoleInput(fd,&inp_rec,1,&nRead)
-
- assert(sp);
-
- TR(TRACE_IEVENT, ("start twait: %d milliseconds, mode: %d",
- milliseconds, mode));
-
- if (milliseconds < 0)
- milliseconds = INFINITY;
-
- memset(&inp_rec, 0, sizeof(inp_rec));
-
- while (true) {
- GetSystemTimeAsFileTime(&fstart);
- rc = WaitForSingleObject(fd, (DWORD) milliseconds);
- GetSystemTimeAsFileTime(&fend);
- diff = (int) tdiff(fstart, fend);
- milliseconds = Adjust(milliseconds, diff);
-
- if (!isImmed && milliseconds <= 0)
- break;
-
- if (rc == WAIT_OBJECT_0) {
- if (mode) {
- b = GetNumberOfConsoleInputEvents(fd, &nRead);
- if (b && nRead > 0) {
- b = PeekConsoleInput(fd, &inp_rec, 1, &nRead);
- if (b && nRead > 0) {
- switch (inp_rec.EventType) {
- case KEY_EVENT:
- if (mode & TW_INPUT) {
- WORD vk = inp_rec.Event.KeyEvent.wVirtualKeyCode;
- char ch = inp_rec.Event.KeyEvent.uChar.AsciiChar;
-
- if (inp_rec.Event.KeyEvent.bKeyDown) {
- if (0 == ch) {
- int nKey = MapKey(vk);
- if (nKey < 0) {
- CONSUME();
- continue;
- }
- }
- code = TW_INPUT;
- goto end;
- } else {
- CONSUME();
- }
- }
- continue;
- case MOUSE_EVENT:
- if (decode_mouse(sp,
- (inp_rec.Event.MouseEvent.dwButtonState
- & BUTTON_MASK)) == 0) {
- CONSUME();
- } else if (mode & TW_MOUSE) {
- code = TW_MOUSE;
- goto end;
- }
- continue;
- /* e.g., FOCUS_EVENT */
- default:
- CONSUME();
- selectActiveHandle();
- continue;
- }
- }
- }
- }
- continue;
- } else {
- if (rc != WAIT_TIMEOUT) {
- code = -1;
- break;
- } else {
- code = 0;
- break;
- }
- }
- }
- end:
-
- TR(TRACE_IEVENT, ("end twait: returned %d (%d), remaining time %d msec",
- code, errno, milliseconds));
-
- if (timeleft)
- *timeleft = milliseconds;
-
- return code;
-}
-
-static int
-wcon_twait(TERMINAL_CONTROL_BLOCK * TCB,
- int mode,
- int milliseconds,
- int *timeleft
- EVENTLIST_2nd(_nc_eventlist * evl))
-{
- SCREEN *sp;
- int code = 0;
-
- if (okConsoleHandle(TCB)) {
- SetSP();
-
- code = console_twait(sp,
- CON.inp,
- mode,
- milliseconds,
- timeleft EVENTLIST_2nd(evl));
- }
- return code;
-}
-
-static bool
-handle_mouse(SCREEN *sp, MOUSE_EVENT_RECORD mer)
-{
- MEVENT work;
- bool result = FALSE;
-
- assert(sp);
-
- sp->_drv_mouse_old_buttons = sp->_drv_mouse_new_buttons;
- sp->_drv_mouse_new_buttons = mer.dwButtonState & BUTTON_MASK;
-
- /*
- * We're only interested if the button is pressed or released.
- * FIXME: implement continuous event-tracking.
- */
- if (sp->_drv_mouse_new_buttons != sp->_drv_mouse_old_buttons) {
-
- memset(&work, 0, sizeof(work));
-
- if (sp->_drv_mouse_new_buttons) {
-
- work.bstate |= decode_mouse(sp, sp->_drv_mouse_new_buttons);
-
- } else {
-
- /* cf: BUTTON_PRESSED, BUTTON_RELEASED */
- work.bstate |= (decode_mouse(sp,
- sp->_drv_mouse_old_buttons)
- >> 1);
-
- result = TRUE;
- }
-
- work.x = mer.dwMousePosition.X;
- work.y = mer.dwMousePosition.Y - AdjustY();
-
- sp->_drv_mouse_fifo[sp->_drv_mouse_tail] = work;
- sp->_drv_mouse_tail += 1;
- }
-
- return result;
-}
-
-static int
-wcon_read(TERMINAL_CONTROL_BLOCK * TCB, int *buf)
-{
- SCREEN *sp;
- int n = -1;
-
- T((T_CALLED("win32con::wcon_read(%p)"), TCB));
-
- assert(buf);
- if (okConsoleHandle(TCB)) {
- SetSP();
-
- n = _nc_mingw_console_read(sp, CON.inp, buf);
- }
- returnCode(n);
-}
-
-static int
-wcon_nap(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int ms)
-{
- T((T_CALLED("win32con::wcon_nap(%p, %d)"), TCB, ms));
- Sleep((DWORD) ms);
- returnCode(OK);
-}
-
-static int
-wcon_cursorSet(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int mode)
-{
- int res = -1;
-
- T((T_CALLED("win32con:wcon_cursorSet(%d)"), mode));
- if (okConsoleHandle(TCB)) {
- CONSOLE_CURSOR_INFO this_CI = CON.save_CI;
- switch (mode) {
- case 0:
- this_CI.bVisible = FALSE;
- break;
- case 1:
- break;
- case 2:
- this_CI.dwSize = 100;
- break;
- }
- SetConsoleCursorInfo(CON.hdl, &this_CI);
- }
- returnCode(res);
-}
-
-static bool
-wcon_kyExist(TERMINAL_CONTROL_BLOCK * TCB GCC_UNUSED, int keycode)
-{
- WORD nKey;
- void *res;
- bool found = FALSE;
- LONG key = GenMap(0, (WORD) keycode);
-
- T((T_CALLED("win32con::wcon_kyExist(%d)"), keycode));
- res = bsearch(&key,
- CON.rmap,
- (size_t) (N_INI + FKEYS),
- sizeof(keylist[0]),
- rkeycompare);
- if (res) {
- key = *((LONG *) res);
- nKey = LOWORD(key);
- if (!(nKey & 0x8000))
- found = TRUE;
- }
- returnCode(found);
-}
-
-static int
-wcon_kpad(TERMINAL_CONTROL_BLOCK * TCB, int flag GCC_UNUSED)
-{
- SCREEN *sp;
- int code = ERR;
-
- T((T_CALLED("win32con::wcon_kpad(%p, %d)"), TCB, flag));
-
- if (okConsoleHandle(TCB)) {
- SetSP();
-
- if (sp) {
- code = OK;
- }
- }
- returnCode(code);
-}
-
-static int
-wcon_keyok(TERMINAL_CONTROL_BLOCK * TCB,
- int keycode,
- int flag)
-{
- int code = ERR;
- SCREEN *sp;
- WORD nKey;
- WORD vKey;
- void *res;
- LONG key = GenMap(0, (WORD) keycode);
-
- T((T_CALLED("win32con::wcon_keyok(%p, %d, %d)"), TCB, keycode, flag));
-
- if (okConsoleHandle(TCB)) {
- SetSP();
-
- if (sp) {
- res = bsearch(&key,
- CON.rmap,
- (size_t) (N_INI + FKEYS),
- sizeof(keylist[0]),
- rkeycompare);
- if (res) {
- key = *((LONG *) res);
- vKey = HIWORD(key);
- nKey = (LOWORD(key)) & 0x7fff;
- if (!flag)
- nKey |= 0x8000;
- *(LONG *) res = GenMap(vKey, nKey);
- }
- }
- }
- returnCode(code);
-}
-
-NCURSES_EXPORT_VAR (TERM_DRIVER) _nc_WIN_DRIVER = {
- FALSE,
- wcon_name, /* Name */
- wcon_CanHandle, /* CanHandle */
- wcon_init, /* init */
- wcon_release, /* release */
- wcon_size, /* size */
- wcon_sgmode, /* sgmode */
- wcon_conattr, /* conattr */
- wcon_mvcur, /* hwcur */
- wcon_mode, /* mode */
- wcon_rescol, /* rescol */
- wcon_rescolors, /* rescolors */
- wcon_setcolor, /* color */
- wcon_dobeepflash, /* DoBeepFlash */
- wcon_initpair, /* initpair */
- wcon_initcolor, /* initcolor */
- wcon_do_color, /* docolor */
- wcon_initmouse, /* initmouse */
- wcon_testmouse, /* testmouse */
- wcon_setfilter, /* setfilter */
- wcon_hwlabel, /* hwlabel */
- wcon_hwlabelOnOff, /* hwlabelOnOff */
- wcon_doupdate, /* update */
- wcon_defaultcolors, /* defaultcolors */
- wcon_print, /* print */
- wcon_size, /* getsize */
- wcon_setsize, /* setsize */
- wcon_initacs, /* initacs */
- wcon_screen_init, /* scinit */
- wcon_wrap, /* scexit */
- wcon_twait, /* twait */
- wcon_read, /* read */
- wcon_nap, /* nap */
- wcon_kpad, /* kpad */
- wcon_keyok, /* kyOk */
- wcon_kyExist, /* kyExist */
- wcon_cursorSet /* cursorSet */
-};
-
-/* --------------------------------------------------------- */
-
-static HANDLE
-get_handle(int fd)
-{
- intptr_t value = _get_osfhandle(fd);
- return (HANDLE) value;
-}
-
-#if WINVER >= 0x0600
-/* This function tests, whether or not the ncurses application
- is running as a descendant of MSYS2/cygwin mintty terminal
- application. mintty doesn't use Windows Console for its screen
- I/O, so the native Windows _isatty doesn't recognize it as
- character device. But we can discover we are at the end of an
- Pipe and can query to server side of the pipe, looking whether
- or not this is mintty.
- */
-static int
-_ismintty(int fd, LPHANDLE pMinTTY)
-{
- HANDLE handle = get_handle(fd);
- DWORD dw;
- int code = 0;
-
- T((T_CALLED("win32con::_ismintty(%d, %p)"), fd, pMinTTY));
-
- if (handle != INVALID_HANDLE_VALUE) {
- dw = GetFileType(handle);
- if (dw == FILE_TYPE_PIPE) {
- if (GetNamedPipeInfo(handle, 0, 0, 0, 0)) {
- ULONG pPid;
- /* Requires NT6 */
- if (GetNamedPipeServerProcessId(handle, &pPid)) {
- TCHAR buf[MAX_PATH];
- DWORD len = 0;
- /* These security attributes may allow us to
- create a remote thread in mintty to manipulate
- the terminal state remotely */
- HANDLE pHandle = OpenProcess(
- PROCESS_CREATE_THREAD
- | PROCESS_QUERY_INFORMATION
- | PROCESS_VM_OPERATION
- | PROCESS_VM_WRITE
- | PROCESS_VM_READ,
- FALSE,
- pPid);
- if (pMinTTY)
- *pMinTTY = INVALID_HANDLE_VALUE;
- if (pHandle != INVALID_HANDLE_VALUE) {
- if ((len = GetProcessImageFileName(
- pHandle,
- buf,
- (DWORD)
- array_length(buf)))) {
- TCHAR *pos = _tcsrchr(buf, _T('\\'));
- if (pos) {
- pos++;
- if (_tcsnicmp(pos, _TEXT("mintty.exe"), 10)
- == 0) {
- if (pMinTTY)
- *pMinTTY = pHandle;
- code = 1;
- }
- }
- }
- }
- }
- }
- }
- }
- returnCode(code);
-}
-#endif
-
-/* Borrowed from ansicon project.
- Check whether or not an I/O handle is associated with
- a Windows console.
-*/
-static BOOL
-IsConsoleHandle(HANDLE hdl)
-{
- DWORD dwFlag = 0;
- BOOL result;
-
- if (!GetConsoleMode(hdl, &dwFlag)) {
- result = (int) WriteConsoleA(hdl, NULL, 0, &dwFlag, NULL);
- } else {
- result = (int) (dwFlag & ENABLE_PROCESSED_OUTPUT);
- }
- return result;
-}
-
-/* Our replacement for the systems _isatty to include also
- a test for mintty. This is called from the NC_ISATTY macro
- defined in curses.priv.h
- */
-int
-_nc_mingw_isatty(int fd)
-{
- int result = 0;
-
- if (SysISATTY(fd)) {
- result = 1;
- } else {
-#if WINVER >= 0x0600
- result = _ismintty(fd, NULL);
-#endif
- }
- return result;
-}
-
-/* This is used when running in terminfo mode to discover,
- whether or not the "terminal" is actually a Windows
- Console. It is the responsibility of the console to deal
- with the terminal escape sequences that are sent by
- terminfo.
- */
-int
-_nc_mingw_isconsole(int fd)
-{
- HANDLE hdl = get_handle(fd);
- int code = 0;
-
- T((T_CALLED("win32con::_nc_mingw_isconsole(%d)"), fd));
-
- code = (int) IsConsoleHandle(hdl);
-
- returnCode(code);
-}
-
-#define TC_PROLOGUE(fd) \
- SCREEN *sp; \
- TERMINAL *term = 0; \
- int code = ERR; \
- if (_nc_screen_chain == 0) \
- return 0; \
- for (each_screen(sp)) { \
- if (sp->_term && (sp->_term->Filedes == fd)) { \
- term = sp->_term; \
- break; \
- } \
- } \
- assert(term != 0)
-
-int
-_nc_mingw_tcsetattr(
- int fd,
- int optional_action GCC_UNUSED,
- const struct termios *arg)
-{
- TC_PROLOGUE(fd);
-
- if (_nc_mingw_isconsole(fd)) {
- DWORD dwFlag = 0;
- HANDLE ofd = get_handle(fd);
- if (ofd != INVALID_HANDLE_VALUE) {
- if (arg) {
- if (arg->c_lflag & ICANON)
- dwFlag |= ENABLE_LINE_INPUT;
- else
- dwFlag = dwFlag & (DWORD) (~ENABLE_LINE_INPUT);
-
- if (arg->c_lflag & ECHO)
- dwFlag = dwFlag | ENABLE_ECHO_INPUT;
- else
- dwFlag = dwFlag & (DWORD) (~ENABLE_ECHO_INPUT);
-
- if (arg->c_iflag & BRKINT)
- dwFlag |= ENABLE_PROCESSED_INPUT;
- else
- dwFlag = dwFlag & (DWORD) (~ENABLE_PROCESSED_INPUT);
- }
- dwFlag |= ENABLE_MOUSE_INPUT;
- SetConsoleMode(ofd, dwFlag);
- code = OK;
- }
- }
- if (arg)
- term->Nttyb = *arg;
-
- return code;
-}
-
-int
-_nc_mingw_tcgetattr(int fd, struct termios *arg)
-{
- TC_PROLOGUE(fd);
-
- if (_nc_mingw_isconsole(fd)) {
- if (arg)
- *arg = term->Nttyb;
- }
- return code;
-}
-
-int
-_nc_mingw_tcflush(int fd, int queue)
-{
- TC_PROLOGUE(fd);
- (void) term;
-
- if (_nc_mingw_isconsole(fd)) {
- if (queue == TCIFLUSH) {
- BOOL b = FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
- if (!b)
- return (int) GetLastError();
- }
- }
- return code;
-}
-
-int
-_nc_mingw_testmouse(
- SCREEN *sp,
- HANDLE fd,
- int delay
- EVENTLIST_2nd(_nc_eventlist * evl))
-{
- int rc = 0;
-
- assert(sp);
-
- if (sp->_drv_mouse_head < sp->_drv_mouse_tail) {
- rc = TW_MOUSE;
- } else {
- rc = console_twait(sp,
- fd,
- TWAIT_MASK,
- delay,
- (int *) 0
- EVENTLIST_2nd(evl));
- }
- return rc;
-}
-
-int
-_nc_mingw_console_read(
- SCREEN *sp,
- HANDLE fd,
- int *buf)
-{
- int rc = -1;
- INPUT_RECORD inp_rec;
- BOOL b;
- DWORD nRead;
- WORD vk;
-
- assert(sp);
- assert(buf);
-
- memset(&inp_rec, 0, sizeof(inp_rec));
-
- T((T_CALLED("_nc_mingw_console_read(%p)"), sp));
-
- while ((b = ReadConsoleInput(fd, &inp_rec, 1, &nRead))) {
- if (b && nRead > 0) {
- if (rc < 0)
- rc = 0;
- rc = rc + (int) nRead;
- if (inp_rec.EventType == KEY_EVENT) {
- if (!inp_rec.Event.KeyEvent.bKeyDown)
- continue;
- *buf = (int) inp_rec.Event.KeyEvent.uChar.AsciiChar;
- vk = inp_rec.Event.KeyEvent.wVirtualKeyCode;
- /*
- * There are 24 virtual function-keys (defined in winuser.h),
- * and typically 12 function-keys on a keyboard. Use the
- * shift-modifier to provide the remaining keys.
- */
- if (vk >= VK_F1 && vk <= VK_F12) {
- if (inp_rec.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) {
- vk = (WORD) (vk + 12);
- }
- }
- if (*buf == 0) {
- int key = MapKey(vk);
- if (key < 0)
- continue;
- if (sp->_keypad_on) {
- *buf = key;
- } else {
- ungetch('\0');
- *buf = AnsiKey(vk);
- }
- } else if (vk == VK_BACK) {
- if (!(inp_rec.Event.KeyEvent.dwControlKeyState
- & (SHIFT_PRESSED | CONTROL_PRESSED))) {
- *buf = KEY_BACKSPACE;
- }
- }
- break;
- } else if (inp_rec.EventType == MOUSE_EVENT) {
- if (handle_mouse(sp,
- inp_rec.Event.MouseEvent)) {
- *buf = KEY_MOUSE;
- break;
- }
- }
- continue;
- }
- }
- returnCode(rc);
-}
-
-static bool
-InitConsole(void)
-{
- /* initialize once, or not at all */
- if (!console_initialized) {
- int i;
- DWORD num_buttons;
- WORD a;
- BOOL buffered = TRUE;
- BOOL b;
-
- START_TRACE();
-
- for (i = 0; i < (N_INI + FKEYS); i++) {
- if (i < N_INI) {
- CON.rmap[i] = CON.map[i] =
- (DWORD) keylist[i];
- CON.ansi_map[i] = (DWORD) ansi_keys[i];
- } else {
- CON.rmap[i] = CON.map[i] =
- (DWORD) GenMap((VK_F1 + (i - N_INI)),
- (KEY_F(1) + (i - N_INI)));
- CON.ansi_map[i] =
- (DWORD) GenMap((VK_F1 + (i - N_INI)),
- (';' + (i - N_INI)));
- }
- }
- qsort(CON.ansi_map,
- (size_t) (MAPSIZE),
- sizeof(keylist[0]),
- keycompare);
- qsort(CON.map,
- (size_t) (MAPSIZE),
- sizeof(keylist[0]),
- keycompare);
- qsort(CON.rmap,
- (size_t) (MAPSIZE),
- sizeof(keylist[0]),
- rkeycompare);
-
- if (GetNumberOfConsoleMouseButtons(&num_buttons)) {
- CON.numButtons = (int) num_buttons;
- } else {
- CON.numButtons = 1;
- }
-
- a = MapColor(true, COLOR_WHITE) | MapColor(false, COLOR_BLACK);
- for (i = 0; i < NUMPAIRS; i++)
- CON.pairs[i] = a;
-
- b = AllocConsole();
-
- if (!b)
- b = AttachConsole(ATTACH_PARENT_PROCESS);
-
- CON.inp = GetDirectHandle("CONIN$", FILE_SHARE_READ);
- CON.out = GetDirectHandle("CONOUT$", FILE_SHARE_WRITE);
-
- if (getenv("NCGDB") || getenv("NCURSES_CONSOLE2")) {
- T(("... will not buffer console"));
- buffered = FALSE;
- CON.hdl = CON.out;
- } else {
- T(("... creating console buffer"));
- CON.hdl = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- CONSOLE_TEXTMODE_BUFFER,
- NULL);
- }
-
- if (CON.hdl != INVALID_HANDLE_VALUE) {
- CON.buffered = buffered;
- get_SBI();
- CON.save_SBI = CON.SBI;
- if (!buffered) {
- save_original_screen();
- set_scrollback(FALSE, &CON.SBI);
- }
- GetConsoleCursorInfo(CON.hdl, &CON.save_CI);
- T(("... initial cursor is %svisible, %d%%",
- (CON.save_CI.bVisible ? "" : "not-"),
- (int) CON.save_CI.dwSize));
- }
-
- console_initialized = TRUE;
- }
- return (CON.hdl != INVALID_HANDLE_VALUE);
-}
-
-static bool
-okConsoleHandle(TERMINAL_CONTROL_BLOCK * TCB)
-{
- return ((TCB != 0) &&
- (TCB->magic == WINMAGIC) &&
- InitConsole());
-}
-
-/*
- * While a constructor would ensure that this module is initialized, that will
- * interfere with applications that may combine this with GUI interfaces.
- */
-#if 0
-static
-__attribute__((constructor))
- void _enter_console(void)
-{
- (void) InitConsole();
-}
-#endif