Subject: lib/12565: curses scanw function does not work in telnet session
To: None <gnats-bugs@gnats.netbsd.org>
From: Christian Groessler <cpg@aladdin.de>
List: netbsd-bugs
Date: 04/06/2001 23:24:56
>Number:         12565
>Category:       lib
>Synopsis:       curses scanw function does not work in telnet session
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 06 14:30:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Christian Groessler
>Release:        NetBSD-current Apr-2001
>Organization:
	
>Environment:
	
System: NetBSD power.cnet.aladdin.de 1.5T NetBSD 1.5T (POWER) #6: Mon Apr 2 22:43:44 CEST 2001 chris@power.cnet.aladdin.de:/net/swamp/zeug/netbsd-chkout/sys/arch/macppc/compile/POWER macppc
Architecture: powerpc
Machine: macppc

I tried it on different NetBSD versions / platforms (i386, macppc,
alpha, vax, 1.3.3, 1.5, -current). All sow the same behaviour.
>Description:
	the libcurses scanw() function (probably others) don't work
correctly in a telnet session.

The <return> key does not end the input, it looks like a CR char is
printed, as the next input key is displayed at the start of the line.

I tried the appended test program on different systems (Linux /
Solaris) and there it works. Also when using pkgsrc/lib/ncurses
instead of NetBSD curses it works.

>How-To-Repeat:
	Here is my test program:

-----------
#include <stdio.h>

#ifdef USE_NCURSES
#  include <ncurses.h>
#else
#  include <curses.h>
#endif

void putsat( int x, int y, char *s )
/* Show a string at x,y, also erasing to end of line */
{
    move( y, x );
    clrtoeol();
    addstr( s );
}

int main( int argc, char **argv )
{
  int val1, val2;

  initscr();

  putsat(10,2, "Test Program");
  putsat(9,3, "--------------");

  putsat( 1, 5, "Value 1: " );
  refresh();

  scanw( "%d", &val1 );
  if( !val1 )              /* enter 0 to exit... */
    goto raus;

  putsat( 1, 6, "Value 2: " );
  refresh();

  scanw( "%d", &val2 );
  if( !val2 )              /* enter 0 to exit... */
    goto raus;

  endwin();
  printf("\n\n\tVal1: %d, Val2: %d\n",val1, val2);
  return(0);

 raus:
  endwin();
  return(0);
}
-----------

Compile it with "cc prog.c -o prog -lcurses" and run it in e.g. xterm
or any other terminal except telnet.
You will be able to enter 2 numbers and then the program terminates.

Then try it in a telnet session (e.g. telnet localhost). See that you
cannot end the input of scanw() with return/enter.  (Ctrl-J works).

>Fix:
	n/a
>Release-Note:
>Audit-Trail:
>Unformatted: