Avoid iswhite(EOF) - fixes coverty CIDs 365 and 1196
I'm not at all sure EOF handling is correct anyway - but it probably only affects the last line of a file (and maybe last lines without \n). In particular I suspect that 'ungetc(EOF, file)' doesn't do the expected thing, and that fseek() needs to be preceeded by clearerr(). But life it short.
This commit is contained in:
parent
435a7d0d03
commit
4fe310d596
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: C.c,v 1.13 2005/07/20 17:22:45 ross Exp $ */
|
/* $NetBSD: C.c,v 1.14 2006/04/05 20:03:14 dsl Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1987, 1993, 1994
|
* Copyright (c) 1987, 1993, 1994
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)C.c 8.4 (Berkeley) 4/2/94";
|
static char sccsid[] = "@(#)C.c 8.4 (Berkeley) 4/2/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: C.c,v 1.13 2005/07/20 17:22:45 ross Exp $");
|
__RCSID("$NetBSD: C.c,v 1.14 2006/04/05 20:03:14 dsl Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -150,10 +150,11 @@ c_entries(void)
|
|||||||
*/
|
*/
|
||||||
case '(':
|
case '(':
|
||||||
do c = getc(inf);
|
do c = getc(inf);
|
||||||
while(iswhite(c));
|
while (c != EOF && iswhite(c));
|
||||||
if (c == '*')
|
if (c == '*')
|
||||||
break;
|
break;
|
||||||
else ungetc(c, inf);
|
if (c != EOF)
|
||||||
|
ungetc(c, inf);
|
||||||
if (!level && token) {
|
if (!level && token) {
|
||||||
int curline;
|
int curline;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: yacc.c,v 1.10 2005/02/17 17:29:58 xtraeme Exp $ */
|
/* $NetBSD: yacc.c,v 1.11 2006/04/05 20:03:14 dsl Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1987, 1993, 1994
|
* Copyright (c) 1987, 1993, 1994
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)yacc.c 8.3 (Berkeley) 4/2/94";
|
static char sccsid[] = "@(#)yacc.c 8.3 (Berkeley) 4/2/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: yacc.c,v 1.10 2005/02/17 17:29:58 xtraeme Exp $");
|
__RCSID("$NetBSD: yacc.c,v 1.11 2006/04/05 20:03:14 dsl Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -106,6 +106,8 @@ y_entries(void)
|
|||||||
*sp++ = c;
|
*sp++ = c;
|
||||||
*sp = EOS;
|
*sp = EOS;
|
||||||
getline(); /* may change before ':' */
|
getline(); /* may change before ':' */
|
||||||
|
if (c == EOF)
|
||||||
|
return;
|
||||||
while (iswhite(c)) {
|
while (iswhite(c)) {
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
SETLINE;
|
SETLINE;
|
||||||
|
Loading…
Reference in New Issue
Block a user