]> diplodocus.org Git - nmh/blob - m4/tputs.m4
Fix invalid pointer arithmetic.
[nmh] / m4 / tputs.m4
1 dnl
2 dnl Some systems have different arguments to the tputs callback; it can
3 dnl be int (*)(int), or int (*)(char). Try to probe to see which one it
4 dnl actually is, so our callback can match the prototype.
5 dnl
6 dnl The first argument to tputs sometimes is char *, other times is
7 dnl const char *, so we have to include that in the test as well, but
8 dnl we don't provide any definitions for it (since it's not necessary)
9 dnl
10
11 AC_DEFUN([NMH_TPUTS_PUTC_ARG],
12 [AC_CACHE_CHECK([the argument of the tputs() callback],
13 [nmh_cv_tputs_putc_arg],
14 [for tputs_arg1 in 'const char *' 'char *'; do
15 for tputs_putc_arg in 'int' 'char'; do
16 AC_COMPILE_IFELSE(
17 [AC_LANG_PROGRAM(
18 [AC_INCLUDES_DEFAULT
19 #include <curses.h>
20 #include <term.h>
21 ],
22 [extern int tputs($tputs_arg1, int, int (*)($tputs_putc_arg));])],
23 [nmh_cv_tputs_putc_arg="$tputs_putc_arg"; break 2])
24 done
25 done
26 AS_IF([test "X$nmh_cv_tputs_putc_arg" = X],
27 [AC_MSG_FAILURE([cannot determine tputs callback argument])])])
28 AC_DEFINE_UNQUOTED([TPUTS_PUTC_ARG], [$nmh_cv_tputs_putc_arg],
29 [The type of the argument of the tputs() callback])
30 ])