A
Army1987
I can see no problem [1] with the loop below, and gcc compiles it
without complaining no matter how many warnings I enable, but
splint has a parse error on line 103 (marked below), column 22. Is
it seriously broken, or am I missing something?
while (!done) { /* line 76 */
switch (getans("Hit, Stand, suRrender, or Double down? ",
"hsrd")) {
case 'r':
credit -= wager / 2;
goto restart;
case 'd':
if (credit < 2 * wager) {
puts("You don't have enough money.");
break;
} else {
wager *= 2;
done = 1;
}
/* fall through */
case 'h':
card = drawcard(&deck);
printf("You got: %s of %s. ",
cardnames[card.rank], suitnames[card.suit]);
add_to_hand(card, &plhand);
printf("Your score is %u.\n", plhand.score);
if (plhand.bust) {
puts("You busted.");
/* fall through */
case 's':
done = 1;
}
break; /* line 103; column 22 is the semicolon. */
default:
fputs("End-of-file encountered or read error.\n", stderr);
exit(EXIT_FAILURE);
}
if (plhand.score == 21)
done = 1;
}
[1] I know that goto is evil, but I had to jump out of a switch
statement and two while statements at once, without jumping out of
the outermost of the three while statements...
without complaining no matter how many warnings I enable, but
splint has a parse error on line 103 (marked below), column 22. Is
it seriously broken, or am I missing something?
while (!done) { /* line 76 */
switch (getans("Hit, Stand, suRrender, or Double down? ",
"hsrd")) {
case 'r':
credit -= wager / 2;
goto restart;
case 'd':
if (credit < 2 * wager) {
puts("You don't have enough money.");
break;
} else {
wager *= 2;
done = 1;
}
/* fall through */
case 'h':
card = drawcard(&deck);
printf("You got: %s of %s. ",
cardnames[card.rank], suitnames[card.suit]);
add_to_hand(card, &plhand);
printf("Your score is %u.\n", plhand.score);
if (plhand.bust) {
puts("You busted.");
/* fall through */
case 's':
done = 1;
}
break; /* line 103; column 22 is the semicolon. */
default:
fputs("End-of-file encountered or read error.\n", stderr);
exit(EXIT_FAILURE);
}
if (plhand.score == 21)
done = 1;
}
[1] I know that goto is evil, but I had to jump out of a switch
statement and two while statements at once, without jumping out of
the outermost of the three while statements...