Subject: lib/34062: rl_deprep_term_function is NULL in libedit.
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <akr@fsij.org>
List: netbsd-bugs
Date: 07/23/2006 16:05:01
>Number:         34062
>Category:       lib
>Synopsis:       rl_deprep_term_function is NULL in libedit.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 23 16:05:00 +0000 2006
>Originator:     Tanaka Akira
>Release:        NetBSD 3.0
>Organization:
FSIJ
>Environment:
NetBSD netbsd30.home 3.0 NetBSD 3.0 (XENU) #0: Mon Dec 19 01:30:48 UTC 2005  builds@works.netbsd.org:/home/builds/ab/netbsd-3-0-RELEASE/i386/200512182024Z-obj/home/builds/ab/netbsd-3-0-RELEASE/src/sys/arch/i386/compile/XENU i386

>Description:
rl_deprep_term_function is NULL in libedit.

It should be rl_deprep_terminal by default,
according to readline info:

 -- Variable: rl_voidfunc_t * rl_deprep_term_function
     If non-zero, Readline will call indirectly through this pointer to
     reset the terminal.  This function should undo the effects of
     `rl_prep_term_function'.  By default, this is set to
     `rl_deprep_terminal' (*note Terminal Management::).

I found this problem by segfault of Ruby.

>How-To-Repeat:
rl_deprep_term_function is NULL in libedit.

% cat tst.c 
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>

int main(int argc, char **argv)
{
  printf("%p\n", rl_deprep_term_function);
  printf("%p\n", rl_deprep_terminal);
  return 0;
}
% gcc tst.c -ledit -ltermcap
% ./a.out 
0x0
0x804852c

rl_deprep_term_function is rl_deprep_terminal in libreadline.

% gcc -I/usr/pkg/include tst.c -{L,R}/usr/pkg/lib -lreadline -ltermcap
% ./a.out 
0x804853c
0x804853c

>Fix:
I think libedit/readline.c should initialize rl_deprep_term_function
as rl_deprep_terminal, instead of NULL.

(not tested)