Bug#1931: less" doesn'
On 7 Dec 1995, Mark Nudelman wrote:
> Thanks for sending the info on the two fixes you made in less-290.
> I don't quite understand the purpose of the first one. You said:
> >In screen.c, it's presumed that dumb terminals have termcap
> >capabilities. This isn't necessarily true. I added the
> >#ifdef DEBIAN block below to stop a segfault.
> Your change causes less to exit immediately when it finds an unknown
> type of terminal, rather than trying to run using minimal ("dumb")
> capabilities. I'm not sure what you mean by "it's presumed that dumb
> terminals have termcap capabilities." The ability to handle the termcap
> functions (tgetflag, etc.) is a feature of the system, not of the terminal.
> It may be that your system's implementation of termcap is failing because
> I'm simulating a tgetent() call by simply strcpy'ing a string into termbuf.
> This would be unfortunate. I guess a better solution, if this is the case, is
> to not call any termcap functions if tgetent fails, and simply hardcode
> some default capabilities. I will look into this.
Here's what happens with the change not compiled in.
Script started on Thu Dec 7 20:03:52 1995
# gdb ./less
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.14 (i486-debian-linux), Copyright 1995 Free Software Foundation, Inc...
(gdb) break get_term
Breakpoint 1 at 0x21cc: file screen.c, line 688.
(gdb) r screen.c
Starting program: /home/A/debian/packages/work/less-290/less-290/./less screen.c
Breakpoint 1, get_term () at screen.c:688
688 if ((term = getenv("TERM")) == NULL)
690 if (tgetent(termbuf, term) <= 0)
698 strcpy(termbuf, "dumb:hc:");
701 hard = tgetflag("hc");
Program received signal SIGSEGV, Segmentation fault.
0x600532ed in end ()
(gdb) The program is running. Quit anyway (and kill it)? (y or n) y
Script done on Thu Dec 7 20:04:56 1995
I'm not a curses jock, but it appears to me that tgetent() sets
up termbuf as a local variable which termcap doesn't know about,
and then tgetflag() is looking for "hc" in the entry for TERM=crap.
I'm not sure what the required operation for tgetent() is when
it's asked to get a capability for a terminal which isn't present
in /etc/termcap. Perhaps this is a bug in GNU libtermcap. A segfault
in the library call seems a bit harsh, but I don't know if it's
allowed. My man page for ncurses (not GNU curses) says that tgetflag
returns ERR on failure.