Subject: bin/8091: [PATCH] Atc getAChar() cleanup
To: None <gnats-bugs@gnats.netbsd.org>
From: Joseph Myers <jsm28@cam.ac.uk>
List: netbsd-bugs
Date: 07/27/1999 11:14:36
>Number:         8091
>Category:       bin
>Synopsis:       [PATCH] Atc getAChar() cleanup
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 27 10:20:00 1999
>Last-Modified:
>Originator:     Joseph S. Myers
>Organization:
Trinity College, University of Cambridge, UK
>Release:        NetBSD anoncvs of 1999-07-26
>Environment:
[
System: Linux decomino 2.2.10 #1 Mon Jun 14 07:48:53 UTC 1999 i686 unknown
Architecture: i686
]
>Description:

In atc(6), the function getAChar() has BSD and SYSV variants to deal
with variations in EINTR behaviour, but the optimisation of using the
BSD version where the SYSV version isn't needed is insignificant.
This patch therefore simplifies the code by making there be just one
version, a more paranoid (about EOF when errno is already EINTR)
version of the SYSV code.  Since the BSD/SYSV defines are mainly used
to control whether BSD timers are used, this helps where BSD timers
but SYSV EINTR handling are wanted.

>How-To-Repeat:

>Fix:

diff -ruN atc/graphics.c atc+/graphics.c
--- atc/graphics.c	Sun Jul 25 10:57:43 1999
+++ atc+/graphics.c	Tue Jul 27 12:09:23 1999
@@ -69,15 +69,14 @@
 int
 getAChar()
 {
-#ifdef BSD
-	return (getchar());
-#endif
-#ifdef SYSV
 	int c;
 
-	while ((c = getchar()) == -1 && errno == EINTR) ;
+	errno = 0;
+	while ((c = getchar()) == -1 && errno == EINTR) {
+		errno = 0;
+		clearerr(stdin);
+	}
 	return(c);
-#endif
 }
 
 void
>Audit-Trail:
>Unformatted: