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>
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().])
+ ])
])
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
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;