Workaround for Coverity CID#1: the Prevent parser didn't recognise there
were multiple possible values for c inside the code. Rewrite code in question to use if instead of switch; optimise while here.
This commit is contained in:
33
lex.c
33
lex.c
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.30 2007/05/10 19:22:11 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.31 2007/05/13 18:07:22 tg Exp $");
|
||||||
|
|
||||||
/* Structure to keep track of the lexing state and the various pieces of info
|
/* Structure to keep track of the lexing state and the various pieces of info
|
||||||
* needed for each particular state. */
|
* needed for each particular state. */
|
||||||
@@ -654,41 +654,28 @@ yylex(int cf)
|
|||||||
if (wp == dp && state == SBASE) {
|
if (wp == dp && state == SBASE) {
|
||||||
Xfree(ws, wp); /* free word */
|
Xfree(ws, wp); /* free word */
|
||||||
/* no word, process LEX1 character */
|
/* no word, process LEX1 character */
|
||||||
switch (c) {
|
if ((c == '|') || (c == '&') || (c == ';') || (c == '('/*)*/)) {
|
||||||
default:
|
|
||||||
return c;
|
|
||||||
|
|
||||||
case '|':
|
|
||||||
case '&':
|
|
||||||
case ';':
|
|
||||||
if ((c2 = getsc()) == c)
|
if ((c2 = getsc()) == c)
|
||||||
c = (c == ';') ? BREAK :
|
c = (c == ';') ? BREAK :
|
||||||
(c == '|') ? LOGOR :
|
(c == '|') ? LOGOR :
|
||||||
(c == '&') ? LOGAND :
|
(c == '&') ? LOGAND :
|
||||||
|
/*
|
||||||
|
* this is the place where
|
||||||
|
* ((...); (...))
|
||||||
|
* and similar is broken
|
||||||
|
*/
|
||||||
|
(c == '(' /*)*/ ) ? MDPAREN :
|
||||||
YYERRCODE;
|
YYERRCODE;
|
||||||
else if (c == '|' && c2 == '&')
|
else if (c == '|' && c2 == '&')
|
||||||
c = COPROC;
|
c = COPROC;
|
||||||
else
|
else
|
||||||
ungetsc(c2);
|
ungetsc(c2);
|
||||||
return c;
|
} else if (c == '\n') {
|
||||||
|
|
||||||
case '\n':
|
|
||||||
gethere();
|
gethere();
|
||||||
if (cf & CONTIN)
|
if (cf & CONTIN)
|
||||||
goto Again;
|
goto Again;
|
||||||
return c;
|
|
||||||
|
|
||||||
case '(': /*)*/
|
|
||||||
if ((c2 = getsc()) == '(') /*)*/
|
|
||||||
/* XXX need to handle ((...); (...)) */
|
|
||||||
c = MDPAREN;
|
|
||||||
else
|
|
||||||
ungetsc(c2);
|
|
||||||
return c;
|
|
||||||
/*(*/
|
|
||||||
case ')':
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
*wp++ = EOS; /* terminate word */
|
*wp++ = EOS; /* terminate word */
|
||||||
|
Reference in New Issue
Block a user