don't try to switch a char and have a case of EOF - use an int.

This commit is contained in:
mrg 2006-05-18 18:42:59 +00:00
parent 747c268e1c
commit 06b50ed8b9
2 changed files with 13 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: io.c,v 1.19 2006/03/21 17:14:15 christos Exp $ */ /* $NetBSD: io.c,v 1.20 2006/05/18 18:42:59 mrg Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -39,7 +39,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
#else #else
__RCSID("$NetBSD: io.c,v 1.19 2006/03/21 17:14:15 christos Exp $"); __RCSID("$NetBSD: io.c,v 1.20 2006/05/18 18:42:59 mrg Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -60,16 +60,17 @@ getin(char **wrd1, char **wrd2)
{ {
char *s; char *s;
static char wd1buf[MAXSTR], wd2buf[MAXSTR]; static char wd1buf[MAXSTR], wd2buf[MAXSTR];
int first, numch; int first, numch, c;
*wrd1 = wd1buf; /* return ptr to internal str */ *wrd1 = wd1buf; /* return ptr to internal str */
*wrd2 = wd2buf; *wrd2 = wd2buf;
wd2buf[0] = 0; /* in case it isn't set here */ wd2buf[0] = 0; /* in case it isn't set here */
for (s = wd1buf, first = 1, numch = 0;;) { for (s = wd1buf, first = 1, numch = 0;;) {
if ((*s = getchar()) >= 'A' && *s <= 'Z') c = getchar();
if ((*s = (char)c) >= 'A' && *s <= 'Z')
*s = *s - ('A' - 'a'); *s = *s - ('A' - 'a');
/* convert to upper case */ /* convert to upper case */
switch (*s) { /* start reading from user */ switch (c) { /* start reading from user */
case '\n': case '\n':
*s = 0; *s = 0;
return; return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sync.c,v 1.23 2004/09/07 13:20:39 jrf Exp $ */ /* $NetBSD: sync.c,v 1.24 2006/05/18 18:42:59 mrg Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -34,7 +34,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)sync.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)sync.c 8.2 (Berkeley) 4/28/95";
#else #else
__RCSID("$NetBSD: sync.c,v 1.23 2004/09/07 13:20:39 jrf Exp $"); __RCSID("$NetBSD: sync.c,v 1.24 2006/05/18 18:42:59 mrg Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -251,9 +251,13 @@ Sync(void)
if (isstr != 0 && isstr != 1) if (isstr != 0 && isstr != 1)
goto bad; goto bad;
if (isstr) { if (isstr) {
int c;
char *p; char *p;
for (p = buf;;) { for (p = buf;;) {
switch (*p++ = getc(sync_fp)) { c = getc(sync_fp);
*p++ = (char)c;
switch (c) {
case '\n': case '\n':
p--; p--;
case EOF: case EOF: