Updating CPPFunction in old readline consumers

One of my favourite open source utilities is tdl, a command-line to-do list manager. I was recently updating a SmartOS VM for development work, and noticed that I lacked a working tdl binary. An attempt to build it resulted in a failure like

gcc -O2 -Wall -DUSE_DOTLOCK=1 -DUSE_READLINE=1 -DBARE_READLINE_H=0 -DUSE_RL_COMPLETION_MATCHES=1  -c inter.c
inter.c: In function 'interactive_text_readline':
inter.c:559:3: error: unknown type name 'Function'
inter.c:562:25: warning: assignment from incompatible pointer type [enabled by default]
inter.c:568:21: warning: assignment from incompatible pointer type [enabled by default]
inter.c: In function 'interactive_text':
inter.c:636:41: error: 'CPPFunction' undeclared (first use in this function)
inter.c:636:41: note: each undeclared identifier is reported only once for each function it appears in
inter.c:636:54: error: expected expression before ')' token
inter.c:638:54: error: expected expression before ')' token
inter.c: In function 'interactive':
inter.c:656:41: error: 'CPPFunction' undeclared (first use in this function)
inter.c:656:54: error: expected expression before ')' token
inter.c: At top level:
inter.c:320:15: warning: 'tdl_completion' defined but not used [-Wunused-function]
inter.c:343:15: warning: 'null_tdl_completion' defined but not used [-Wunused-function]
inter.c: In function 'get_line_stdio':
inter.c:605:1: warning: control reaches end of non-void function [-Wreturn-type]
Makefile:61: recipe for target 'inter.o' failed
make: *** [inter.o] Error 1

Version 1.5.2 of tdl was released on 02004-02-03. The contemporary version of GNU readline would have been 4.3; today, pkgsrc on SmartOS delivers readline 6.3, which was released 02014-02-26. I know I’ve built tdl much more recently than 02004, so I decided to spend some time to determine what’s changed between these two components.

With 6.3, the compatibility type definitions for Function, CPFunction, CPPFunction, and VFunction were finally removed. Each of these “old style” readline function types can typically be replaced with the “new style” types as follows

  • Function becomes rl_hook_func_t in hook assignments. Function may map to other function types in rltypedefs.h if a non-void argument list is given.

  • VFunction becomes rl_voidfunc_t.

  • VCPFunction becomes rl_vcpfunc_t.

  • CPFunction becomes rl_compentry_func_t.

  • CPPFunction becomes rl_completion_func_t.

The patch for tdl-1.5.2:inter.c resolves all but the final warning above, and should lead to happy task tracking with tdl.

(If you are on MacOS X (and potentially on other systems that deliver editline), then the editline include files that provide readline.h declarations still provide the old style definitions.)