Bug#1057935: ncurses-hexedit: FTBFS: invalid use of incomplete typedef ‘WINDOW’ {aka ‘struct _win_st’}

2023-12-17 Thread Sven Joachim
Control: tags -1 + patch

On 2023-12-10 20:18 +0100, Santiago Vila wrote:

> Package: src:ncurses-hexedit
> Version: 0.9.7+orig-7.2
> Severity: serious
> Tags: ftbfs
>
> Dear maintainer:
>
> During a rebuild of all packages in unstable, your package failed to build:
>
> 
> [...]
> gcc -DHAVE_CONFIG_H -I. -I..  -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2
> -ffile-prefix-map=/<>=. -fstack-protector-strong
> -fstack-clash-protection -Wformat -Werror=format-security
> -fcf-protection -Wall -c -o file.o file.c
> file.c: In function ‘printPage’:
> file.c:647:34: error: invalid use of incomplete typedef ‘WINDOW’ {aka ‘struct 
> _win_st’}
>   647 |   for (result = Globals.wmain->_curx; result < COLS; result++)
>   |  ^~

There are quite a few more instances of such errors across the source
code, the attached patch should fix all of them.  The package builds and
from a cursory look appears to work, but it would be good if a potential
NMU'er reviews and tests the patch before uploading.

Cheers,
   Sven

From 676299deb4fa83c7f100011da2948c49ba97499c Mon Sep 17 00:00:00 2001
From: Sven Joachim 
Date: Sun, 17 Dec 2023 16:15:43 +0100
Subject: [PATCH] Avoid accessing internal ncurses structures

Since ncurses patchlevel 20231021 the WINDOW structure is opaque, its
members cannot be addressed directly.  Use the functions ncurses
provides for this purpose instead.
---
 src/file.c|  2 +-
 src/misc.c|  6 ++
 src/print.c   | 16 
 src/widgets.c | 24 
 4 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/src/file.c b/src/file.c
index 14a2475..ba7c147 100644
--- a/src/file.c
+++ b/src/file.c
@@ -644,7 +644,7 @@ printPage (const struct FileNames *fp)
   wprintw (Globals.wmain, "%s", trunc_file);
   fp = fp->p;

-  for (result = Globals.wmain->_curx; result < COLS; result++)
+  for (result = getcurx(Globals.wmain); result < COLS; result++)
  wprintw (Globals.wmain, " ");
}

diff --git a/src/misc.c b/src/misc.c
index 24068b4..8b0fb4b 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -641,10 +641,8 @@ handleSigwinch (int i)
if (!newlines)
   die_horribly (NOT_ENOUGH_MEMORY, NULL);

-   Globals.wmain->_cury = cursor_y - 1;
-   Globals.wmain->_curx = cursor_x;
-   stdscr->_cury = cursor_y;
-   stdscr->_curx = cursor_x;
+   wmove(Globals.wmain, cursor_y - 1, cursor_x);
+   move(cursor_y, cursor_x);
if (cursor_y >= BOTTOM_LINE)
   cursor_y = BOTTOM_LINE;
if (Globals.mode == FILE_MODE)
diff --git a/src/print.c b/src/print.c
index 57b291e..59b0ca1 100644
--- a/src/print.c
+++ b/src/print.c
@@ -196,16 +196,16 @@ drawAsciiDump (unsigned long off, unsigned long *offs)
   if (*offs > Globals.filesize)
  break;
 #ifdef __NCURSES_H /* i don't know why this works */
-  if (Globals.wmain->_cury == MAIN_BOTTOM_LINE)
+  if (getcury(Globals.wmain) == MAIN_BOTTOM_LINE)
 #else
-  if (Globals.wmain->_cury == MAIN_HEIGHT)
+  if (getcury(Globals.wmain) == MAIN_HEIGHT)
 #endif
  break;
-  if (Globals.wmain->_curx == COLS - 2)
+  if (getcurx(Globals.wmain) == COLS - 2)
   {
  move = 1;
   }
-  if (Globals.wmain->_curx == 0)
+  if (getcurx(Globals.wmain) == 0)
  *(newlines + i++) = *offs;
   bold = hash_lookup (*offs, NULL);
   if (!bold)
@@ -215,8 +215,8 @@ drawAsciiDump (unsigned long off, unsigned long *offs)
   {
  if (filebuffer (*offs) == '\n')
  {
-int cury = Globals.wmain->_cury;
-int i = Globals.wmain->_curx;
+int cury = getcury(Globals.wmain);
+int i = getcurx(Globals.wmain);
 for (; i < COLS - 2; i++)
wprintw (Globals.wmain, " ");
 wprintw (Globals.wmain, ".");
@@ -235,7 +235,7 @@ drawAsciiDump (unsigned long off, unsigned long *offs)
   {
  if (filebuffer (*offs) == EBCDIC['\n'])
  {
-int cury = Globals.wmain->_cury;
+int cury = getcury(Globals.wmain);
 wprintw (Globals.wmain, ".");
 wmove (Globals.wmain, cury + 1, 0);
  }
@@ -257,7 +257,7 @@ drawAsciiDump (unsigned long off, unsigned long *offs)
   (*offs)++;
   if (move)
   {
- wmove (Globals.wmain, Globals.wmain->_cury + 1, 0);
+ wmove (Globals.wmain, getcury(Globals.wmain) + 1, 0);
  move = 0;
  continue;
   }
diff --git a/src/widgets.c b/src/widgets.c
index eb627ad..38183f8 100644
--- a/src/widgets.c
+++ b/src/widgets.c
@@ -99,11 +99,11 @@ stringBox (WINDOW *win, int y, int x, int len, int max, char *sample)
  case KEY_LEFT:
 if (i > 0)
 {
-   if (win->_curx > x)
+   if (getcurx(win) > x)
/* not at left hand side */
{
   i--;
-  wmove 

Bug#1057935: ncurses-hexedit: FTBFS: invalid use of incomplete typedef ‘WINDOW’ {aka ‘struct _win_st’}

2023-12-10 Thread Santiago Vila

Package: src:ncurses-hexedit
Version: 0.9.7+orig-7.2
Severity: serious
Tags: ftbfs

Dear maintainer:

During a rebuild of all packages in unstable, your package failed to build:


[...]
 debian/rules binary
dh binary
   debian/rules override_dh_update_autotools_config
make[1]: Entering directory '/<>'
dh_update_autotools_config
test -f debian/backup.tar || \
tar cpf debian/backup.tar -T debian/mutable
make[1]: Leaving directory '/<>'
   dh_autoreconf
find ! -ipath "./debian/*" -a ! \( -path '*/.git/*' -o -path '*/.hg/*' -o 
-path '*/.bzr/*' -o -path '*/.svn/*' -o -path '*/CVS/*' \) -a  -type f -exec md5sum {} + -o 
-type l -printf "symlink  %p
" > debian/autoreconf.before
grep -q ^XDT_ configure.ac
autoreconf -f -i
configure.ac:11: warning: 'AM_CONFIG_HEADER': this macro is obsolete.
configure.ac:11: You should use the 'AC_CONFIG_HEADERS' macro instead.
./lib/autoconf/general.m4:2434: AC_DIAGNOSE is expanded from...
aclocal.m4:745: AM_CONFIG_HEADER is expanded from...
configure.ac:11: the top level
configure.ac:22: warning: The macro `AC_HEADER_STDC' is obsolete.
configure.ac:22: You should run autoupdate.
./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from...
configure.ac:22: the top level
configure.ac:109: warning: AC_OUTPUT should be used without arguments.
configure.ac:109: You should run autoupdate.
configure.ac:13: installing './compile'
src/Makefile.am: installing './depcomp'
find ! -ipath "./debian/*" -a ! \( -path '*/.git/*' -o -path '*/.hg/*' -o 
-path '*/.bzr/*' -o -path '*/.svn/*' -o -path '*/CVS/*' \) -a  -type f -exec md5sum {} + -o 
-type l -printf "symlink  %p
" > debian/autoreconf.after
   dh_auto_configure
./configure --build=x86_64-linux-gnu --prefix=/usr 
--includedir=\${prefix}/include --mandir=\${prefix}/share/man 
--infodir=\${prefix}/share/info --sysconfdir=/etc --localstatedir=/var 
--disable-option-checking --disable-silent-rules 
--libdir=\${prefix}/lib/x86_64-linux-gnu --runstatedir=/run 
--disable-maintainer-mode --disable-dependency-tracking
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... none
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking how to run the C preprocessor... gcc -E
checking whether gcc needs -traditional... no
checking for ncurses.h... yes
checking for fcntl.h... yes
checking for getopt.h... yes
checking for limits.h... yes
checking for sys/ioctl.h... yes
checking for unistd.h... (cached) yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking for an ANSI C-conforming const... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for snprintf... yes
checking for isprint... yes
checking for getopt_long... yes
checking for TIOCGWINSZ... yes, found in termio.h
checking for newwin in -lncurses... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating docs/Makefile
config.status: creating gnu/Makefile
config.status: creating src/Makefile
config.status: creating config.h
config.status: executing depfiles commands
rm -f debian/ncurses-hexedit.debhelper.log
   debian/rules override_dh_auto_build
make[1]: Entering directory '/<>'
dh_auto_build -- \

make -j2
make[2]: Entering directory '/<>'
make  all-recursive
make[3]: Entering directory '/<>'
Making all in docs
make[4]: Entering directory '/<>/docs'
restore=: && backupdir=".am$$" && \
am__cwd=`pwd` && CDPATH="${ZSH_VERSION+.}:" && cd . && \
rm -rf $backupdir && mkdir $backupdir && \
if (/bin/bash '/<>/missing' makeinfo --version) >/dev/null 2>&1; 
then \
  for f in hexeditor.info hexeditor.info-[0-9]