Thomas, would you welcome further work along these lines? I'm thinking mainly of migration of further man page migrations to ".in" files, but I'd also appreciate hearing of any places that `int`s should be made `bool`s.
Regards, Branden
commit 9f013e72b477700f9de1ec404e74f15fd623b1c3 Author: G. Branden Robinson <[email protected]> Date: Sun Aug 31 04:53:58 2025 -0500 Make `use_extended_names()` return `bool` for ABI 7. * aclocal.m4: Introduce new `cf_dft_int_or_bool` configuration variable for this purpose, and any other `int` data type that should be a `bool` but hasn't been. (I'm not aware of any others at this point.) Default it to `int`, but make it `bool` if ABI >= 7 is selected. * configure.in: Couple Autoconf variable `NCURSES_INT_OR_BOOL` to new configuration variable. `AC_SUBST()` it (when surrounded by at signs) in configure-generated files. * include/curses.h.in: Define C preprocessor macro `NCURSES_INT_OR_BOOL` coupled to Autoconf variable `NCURSES_INT_OR_BOOL`. Declare its value as `use_extended_names()`'s return type. * ncurses/tinfo/free_ttype.c: Use `NCURSES_INT_OR_BOOL`'s value as the return type in `use_extended_names()`'s definition. The foregoing raised the question of how to correctly document the return type in the function's man page, which prompted a file rename and a change to the build system (one I have been hoping to undertake for a while).[1] * man/curs_extend.3x: Rename this... * man/curs_extend.3x.in: ...to this. * configure.in: Add "man/curs_extend.3x" to `AC_OUTPUT()`-ted files. * aclocal.m4: When generating "edit_man.sh", ignore files with ".in" suffix as we already do ".orig" and ".rej". * man/Makefile.in: Clean the man pages listed in AC_OUTPUT() in "configure.in". * man/curs_extend.3x.in (SYNOPSIS) <use_extended_names>: Interpolate correct return type at configuration time. As a bonus, the Autoconf substvars `NCURSES_MAJOR`, `NCURSES_MINOR`, and `TIC` are populated by this procedure, and do not require sed-driven editing at installation time. Any other man pages we migrate to this ".in" scheme will enjoy the same benefit for any `AC_SUBST()` variables they use. [1] See "I may end up piloting some patches along these lines" in <https://lists.gnu.org/archive/html/bug-ncurses/2023-10/msg00015.html>. diff --git a/aclocal.m4 b/aclocal.m4 index 909982c33..0e7113c21 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -92,6 +92,7 @@ cf_dft_signed_char=no cf_dft_tparm_arg=long cf_dft_widec=no cf_dft_with_lp64=no +cf_dft_int_or_bool=int # ABI 6 default differences from ABI 5: case x$cf_cv_abi_default in @@ -121,6 +122,7 @@ case x$cf_cv_abi_default in cf_dft_ordinate_type=int cf_dft_rgb_color=yes cf_dft_signed_char=yes + cf_dft_int_or_bool=bool # also: remove the wgetch-events feature in ABI 7 ;; esac @@ -6089,7 +6091,7 @@ fi # process the list of source-files for i in "\[$]@" ; do case \$i in -(*.orig|*.rej) ;; +(*.orig|*.rej|*.in) ;; (*.[[0-9]]*) section=\`expr "\$i" : '.*\\.\\([[0-9]]\\)[[xm]]*'\`; if test "\$verb" = installing ; then diff --git a/configure.in b/configure.in index 7eb3cd7e3..20e6167cf 100644 --- a/configure.in +++ b/configure.in @@ -1042,6 +1042,9 @@ if test "$cf_cv_enable_lp64" = 1 ; then test -n "$with_mmask_t" && test "$NCURSES_MMASK_T" != unsigned && AC_MSG_WARN(option --enable-lp64 overrides --with-mmask-t) fi +NCURSES_INT_OR_BOOL=$cf_dft_int_or_bool +AC_SUBST(NCURSES_INT_OR_BOOL) + ### use option --with-ccharw-max to override CCHARW_MAX size AC_MSG_CHECKING(for size CCHARW_MAX) AC_ARG_WITH(ccharw-max, @@ -2523,6 +2526,8 @@ AC_SUBST(PRIVATE_LIBS) # This is used for the *-config script and *.pc data files. CF_LD_SEARCHPATH +# Man pages listed here should be removed in man/Makefile.in's +# "distclean" target. AC_OUTPUT( \ include/MKterm.h.awk \ include/curses.head:include/curses.h.in \ @@ -2530,6 +2535,7 @@ AC_OUTPUT( \ include/nc_win32.h \ include/termcap.h \ include/unctrl.h \ + man/curs_extend.3x \ man/man_db.renames \ $SUB_MAKEFILES \ Makefile,[ diff --git a/include/curses.h.in b/include/curses.h.in index 0541e35a7..891d679ac 100644 --- a/include/curses.h.in +++ b/include/curses.h.in @@ -976,10 +976,13 @@ extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *); extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *); extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int); +/* the API has sometimes used `int` where `bool` was more appropriate */ +#define NCURSES_INT_OR_BOOL @NCURSES_INT_OR_BOOL@ + #if @NCURSES_XNAMES@ /* NCURSES_XNAMES */ #undef NCURSES_XNAMES #define NCURSES_XNAMES @NCURSES_XNAMES@ /* NCURSES_XNAMES */ -extern NCURSES_EXPORT(int) use_extended_names (bool); +extern NCURSES_EXPORT(NCURSES_INT_OR_BOOL) use_extended_names (bool); #endif /* diff --git a/man/Makefile.in b/man/Makefile.in index 877068945..4623ed18f 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -103,5 +103,8 @@ clean: mostlyclean ../edit_man.sed : make_sed.sh $(SHELL) $(srcdir)/make_sed.sh @MANPAGE_RENAMES@ >../edit_man.sed +# Clean the man pages listed in AC_OUTPUT() in "configure.in". distclean realclean: clean - -rm -f Makefile *-config.1 ../edit_man.* ../man_alias.* man_db.renames + -rm -f Makefile *-config.1 ../edit_man.* \ + ../man_alias.* man_db.renames \ + curs_extend.3x diff --git a/man/curs_extend.3x b/man/curs_extend.3x.in similarity index 98% rename from man/curs_extend.3x rename to man/curs_extend.3x.in index a92ff7fcc..2d595f0fb 100644 --- a/man/curs_extend.3x +++ b/man/curs_extend.3x.in @@ -50,7 +50,7 @@ .SH SYNOPSIS \fB#include <curses.h> .PP \fBconst char * curses_version(void); -\fBint use_extended_names(bool \fIbf\fP); +\fB@NCURSES_INT_OR_BOOL@ use_extended_names(bool \fIbf\fP); .fi .SH DESCRIPTION These diff --git a/ncurses/tinfo/free_ttype.c b/ncurses/tinfo/free_ttype.c index 7935152a7..144cac4ac 100644 --- a/ncurses/tinfo/free_ttype.c +++ b/ncurses/tinfo/free_ttype.c @@ -92,7 +92,7 @@ _nc_free_termtype2(TERMTYPE2 *ptr) #if NCURSES_XNAMES NCURSES_EXPORT_VAR(bool) _nc_user_definable = TRUE; -NCURSES_EXPORT(int) +NCURSES_EXPORT(NCURSES_INT_OR_BOOL) use_extended_names(bool flag) { int oldflag = _nc_user_definable;
signature.asc
Description: PGP signature
