Subject: lib/3966: update to lib/3962 patch
To: None <gnats-bugs@gnats.netbsd.org>
From: Brett Lymn (Master of the Siren) <blymn@baea.com.au>
List: netbsd-bugs
Date: 08/11/1997 23:07:13
>Number:         3966
>Category:       lib
>Synopsis:       There is an endian bug in the orignal patch I sent
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 11 06:50:01 1997
>Last-Modified:
>Originator:     Brett Lymn (Master of the Siren)
>Organization:
Brett Lymn
>Release:        2nd August 1997
>Environment:
	
System: NetBSD siren 1.2G NetBSD 1.2G (SIREN) #0: Sat Aug 9 17:10:14 CST 1997 toor@siren:/usr/src/sys/arch/i386/compile/SIREN i386


>Description:
	The original patch supplied in lib/3962 has a bug in big
endian machines.  The patch below applied after 3962 will fix the 
problem.

>How-To-Repeat:
	n/a
>Fix:

Index: getch.c
===================================================================
RCS file: /home/siren/src/src/lib/libcurses/getch.c,v
retrieving revision 1.6
diff -r1.6 getch.c
298c298,299
<   int k;
---
>   int k, nchar;
>   char c;
306,308c307,309
<       k = 0;
<       if (read(STDIN_FILENO, &k, sizeof(char)) < 0) return ERR;
<       if (k <= 0) return ERR; /* just in case we are nodelay mode */
---
>       if ((nchar = read(STDIN_FILENO, &c, sizeof(char))) < 0) return ERR;
>       k = (unsigned int) c;
>       if (nchar == 0) return ERR; /* just in case we are nodelay mode */
328,329c329
<       k = 0;
<       if (read(STDIN_FILENO, &k, sizeof(char)) < 0) return ERR;
---
>       if ((nchar = read(STDIN_FILENO, &c, sizeof(char))) < 0) return ERR;
332c332,333
<       if (k <= 0) /* inter-char timeout, start backing out */
---
>       k = (unsigned int) c;
>       if (nchar == 0) /* inter-char timeout, start backing out */
406c407,408
<         int inp = 0;
---
>         int inp;
>         char c;
432c434,441
<           read(STDIN_FILENO, &inp, sizeof(char));
---
>           if (read(STDIN_FILENO, &c, sizeof(char)) < 0)
>           {
>             inp = ERR;
>           }
>           else
>           {
>             inp = (unsigned int) c;
>           }
>Audit-Trail:
>Unformatted: