Just something hilarious I stumbled across.
enum {
NO_CLEANUP,
CLEANUP1,
CLEANUP2,
CLEANUP3
} cleanup_mode = NO_CLEANUP;
bool done = false;
while (!done) {
switch (cleanup_mode) {
case NO_CLEANUP:
// Build Step One
…
if (failure_condition_one) {
cleanup_mode = CLEANUP1;
continue;
}
// Build Step Two
…
if (failure_condition_two) {
cleanup_mode = CLEANUP2;
continue;
}
// Build Step Three
…
if (failure_condition_three) {
cleanup_mode = CLEANUP3;
continue;
}
break;
case CLEANUP3:
…
case CLEANUP2:
…
case CLEANUP1:
…
done = true;
}
}
(and if anyone can tell me how to make the formatting work, it’ll look nicer, too)