Remove goto L12 - take two

On't know if you let me near this code again but here is a second
stab at removing "goto L12"

Previous attempt failed because of trying to continue the outer
do{}while(false)
Adding an extra for(;;) loop where the only repeat is the former
"goto L12" is replaced by continue. All other exits are returns
and a break;
This commit is contained in:
Peje Nilsson 2017-06-19 10:24:48 +02:00 committed by Eric S. Raymond
parent c2df849dad
commit 2fe36df4e2

14
main.c
View file

@ -623,6 +623,7 @@ static bool playermove(token_t verb, int motion)
* block travel and then redo it once the blocking condition has been
* removed.
*/
for (;;) { /* L12 loop */
for (;;) {
game.newloc = scratchloc / 1000;
motion = MOD(game.newloc, 100);
@ -637,7 +638,6 @@ static bool playermove(token_t verb, int motion)
/* else fall through */
} else if (game.prop[motion] != game.newloc / 100 - 3)
break;
L12:
do {
if (TRAVEL[kk] < 0)
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
@ -672,7 +672,15 @@ L12:
* plover-passage to get it out. Having dropped it, go back and
* pretend he wasn't carrying it after all. */
DROP(EMERALD, game.loc);
goto L12;
do {
if (TRAVEL[kk] < 0)
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
++kk;
game.newloc = labs(TRAVEL[kk]) / 1000;
} while
(game.newloc == scratchloc);
scratchloc = game.newloc;
continue; /* goto L12 */
case 3:
/* Travel 303. Troll bridge. Must be done only as special
* motion so that dwarves won't wander across and encounter
@ -707,6 +715,8 @@ L12:
}
BUG(SPECIAL_TRAVEL_500_GT_L_GT_300_EXCEEDS_GOTO_LIST);
}
break; /* Leave L12 loop */
}
} while
(false);
/* FIXME: Arithmetic on location number, becoming a message number */