[net.unix-wizards] Problem with curses ``getstr

mcooper@oberon.UUCP (Michael Cooper) (10/17/85)

Ahh, yes.  Another curses problem.  Or at least it is a problem 
that curses is having with me!  I am trying to get a string from a window
with wgetstr(win, buf).  Now I checked both in the documentation and
getstr.c and both say that getstr reads up to a newline ('\n') or EOF.
When I put this into practice, though, it just plain doesn't work.  It
keeps reading everything in.  This includes newlines, SIGINTR, SIGKILL,
SIGSUSP.  The only way to get out of it is to use another terminal and kill
the program's process.

Would somebody care to point out something that I missed?  Or is it 
just another bug from the braindamaged Berzerkeley?  If so, anybody want to
volunteer a fix?


-- 
					Michael Cooper

+----------------------------------------------------------------------------+
| University of Southern California - University Computing Services	     |
|============================================================================|
|	Usenet: ...!{uscvax, sdcrdcf, engvax, scgvaxd, smeagol,	             |
|		    cit-vax, brand, dworkin, tyger, omnilax}!oberon!mcooper  |
|	Bitnet: mcooper@uscvaxq, mcooper@jaxom 				     |
|	  ARPA:	mcooper@usc-oberon.arpa	  OR   mcooper@usc-eclc.arpa  	     |
+----------------------------------------------------------------------------+

laman@ncr-sd.UUCP (Mike Laman) (10/23/85)

In article <137@oberon.UUCP> mcooper@oberon.UUCP (Michael Cooper) writes:
>Ahh, yes.  Another curses problem.  Or at least it is a problem 
>that curses is having with me!  I am trying to get a string from a window
>with wgetstr(win, buf).  Now I checked both in the documentation and
>getstr.c and both say that getstr reads up to a newline ('\n') or EOF.
>When I put this into practice, though, it just plain doesn't work.  It
>keeps reading everything in.  This includes newlines, SIGINTR, SIGKILL,
>SIGSUSP.  The only way to get out of it is to use another terminal and kill
>the program's process.
>
>Would somebody care to point out something that I missed?  Or is it 
>just another bug from the braindamaged Berzerkeley?  If so, anybody want to
>volunteer a fix?
>

    Sure, I'll volunteer a fix.  This is an amazingly simple one.  Don't
ask me how it got through, but one would suspect the wgetstr (or getstr)
aren't used much :-).

    In wgetstr() you will see the loop:

							Opps
							   |
							   |
							   V
	while ((*str = wgetch(win)) != ERR && *str != '\n');
		str++;
	if (*str == ERR) {
		:
		:

    Yep.  Remove the semicolon and have fun.  Maybe I should post
my list of bug fixes for the 4.2 BSD curses library again
(to net.bugs.4bsd)? If anyone thinks so, then let me know by mail.  If I
get a few requests, I'll post my file of bug fixes again.  It has
been a while.

		Mike Laman, NCR @ Rancho Bernardo
		UUCP: {ucbvax,philabs,sdcsla}!sdcsvax!ncr-sd!laman

freed@aum.UUCP (Erik Freed) (10/25/85)

> In article <137@oberon.UUCP> mcooper@oberon.UUCP (Michael Cooper) writes:
> >Ahh, yes.  Another curses problem.  Or at least it is a problem 
> >that curses is having with me!  I am trying to get a string from a window
> >with wgetstr(win, buf).  Now I checked both in the documentation and
> >getstr.c and both say that getstr reads up to a newline ('\n') or EOF.
> >When I put this into practice, though, it just plain doesn't work.  It
> >keeps reading everything in.  This includes newlines, SIGINTR, SIGKILL,
> >SIGSUSP.  The only way to get out of it is to use another terminal and kill
> >the program's process.

I can suggest one possible problem; If you don't set to crmode specifically
I think that getstr() sets the terminal to RAW mode. Try calling cbreak or
crmode. 
-- 
-------------------------------------------------------------------------------
                           Erik James Freed
			   Aurora Systems
			   San Francisco, CA
			   {dual,ptsfa}!aum!freed