Bug in ULTRIX terminfo/curses?

Phil Blanchfield DGBT/DIP phil at dgbt.uucp
Thu Mar 1 13:18:52 AEST 1990


Fellow ULTRIX folk:

I was trying to get a PD package to work with VT100 arrows (function keys)
and I think I discovered a bug in the ULTRIX terminfo/curses stuff.

The included program demonstrates the bug. 

Both the ULTRIX an SUNOS man pages for getch() say:

"     If keypad is TRUE, and a function key is pressed, the token	"
      for that function key is returned instead of the raw charac-
      ters.

This is also spoken of in "Guide to Curses Screen-Handling".

The included program shows that getch() returns token's only if
you don't "fopen()" a file!!! Actually, the call to fopen here
is never even reached.  It works fine on SUNOS both ways.

I am running ULTRIX V3.1 on a VAX-750.

Has anyone else seen this bug?
Does this happen on a RISC?
Is there a work around?


/*
 *	Test program for terminfo under ULTRIX 3.1
 *	
 *	This program demonstrates a bug that I found in the ULTRIX
 *	terminfo/curses library. With "keypad TRUE", when a function key
 *	is hit, getch() should return a function key code (int > 401)
 *	instead of the multi-character string which is actually sent
 *	by the terminal.
 *
 *	To compile on ULTRIX:
 *
 *	cc prog.c -o prog -lcursesX
 *
 *	To compile on SUNOS:
 *
 *	/usr/5bin/cc prog.c -o prog -lcurses
 *
 *	Notes:
 *		The only way out is with a control-C and the you will
 *		have to type: reset without any echo.
 */

#include <stdio.h>
#ifdef sun
#include <curses.h>
#else /* assume ULTRIX */
#include <cursesX.h>
#endif

main()
{
    int chr;
    char string[30];
    FILE *fopen();

    initscr();
    keypad(stdscr,TRUE);
    crmode();
    noecho();

    for(;;)
    {
	chr = getch();

	sprintf(string,"%d = %o\n",chr,chr);
	addstr(string);
	refresh();
    }
	fopen("vtst.c","r");	/* comment out this line and it works!! */
}
-- 
Phil Blanchfield    phil at dgbt.crc.dnd.ca  | The Communications Research Centre
UUCP: ...utzoo!lsuc!nrcaer!dgbt!phil  | 3701 Carling Avenue, Ottawa CANADA



More information about the Comp.unix.ultrix mailing list