]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
irqtop: add vw_printw() fallback for slang builds
authorKarel Zak <kzak@redhat.com>
Thu, 9 Apr 2026 08:16:30 +0000 (10:16 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 9 Apr 2026 08:20:07 +0000 (10:20 +0200)
The vw_printw() function and OK macro are ncurses-specific and not
available in slang's curses compatibility layer. This causes build
failures when configuring with --with-slang.

Add configure/meson checks for vw_printw() availability and provide
a portable fallback implementation using vsnprintf() and waddstr()
when the function is not available.

Addresses: https://github.com/util-linux/util-linux/issues/4177
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
meson.build
sys-utils/irqtop.c

index 4c824eb12416253860107cd3d61adae419acb35e..93f4f8afe0017b1d5b3d39c8d526a3ce1b40f11b 100644 (file)
@@ -1223,6 +1223,10 @@ AS_IF([test "x$have_slang" = xyes || test "x$have_ncursesw" = xyes || test "x$ha
                     AC_DEFINE(HAVE_RESIZETERM, 1,
                               [Define if curses library has the resizeterm().])
        ])
+       AC_CHECK_LIB([$CURSES_LIB_NAME], vw_printw, [
+                    AC_DEFINE(HAVE_VW_PRINTW, 1,
+                              [Define if curses library has the vw_printw().])
+       ])
 ])
 
 
index 88c6bdf5f6f64f9bb4421db0358c8612e3e91d52..19f7f02b04de62c312a39aa3930f3f34e130898c 100644 (file)
@@ -320,6 +320,8 @@ foreach curses_libs : [lib_slang, lib_ncursesw, lib_ncurses]
     conf.set('HAVE_USE_DEFAULT_COLORS', have ? 1 : false)
     have = cc.has_function('resizeterm', dependencies : curses_libs)
     conf.set('HAVE_RESIZETERM', have ? 1 : false)
+    have = cc.has_function('vw_printw', dependencies : curses_libs)
+    conf.set('HAVE_VW_PRINTW', have ? 1 : false)
     break
   endif
 endforeach
index d0b331119130f927d7e7920ef9daf7df4988cb1d..c017053e7e32dd7c1020e63d209aecc63cd9707b 100644 (file)
@@ -86,6 +86,21 @@ struct irqtop_ctl {
                softirq;
 };
 
+#ifndef OK
+# define OK 0
+#endif
+
+#ifndef HAVE_VW_PRINTW
+static inline int vw_printw(WINDOW *win, const char *fmt, va_list args)
+{
+       char buf[BUFSIZ];
+
+       if (vsnprintf(buf, sizeof(buf), fmt, args) < 0)
+               return ERR;
+       return waddstr(win, buf);
+}
+#endif
+
 static inline int irqtop_printf(struct irqtop_ctl *ctl, const char *fmt, ...)
 {
        int ret = 0;