- struct do_if_trns *t;
-
- /* Check that we're in a pleasing situation. */
- if (!ctl_stack || ctl_stack->type != CST_DO_IF)
- {
- msg (SE, _("There is no DO IF to match with this ELSE."));
- return CMD_FAILURE;
- }
-
- if (((struct do_if_trns *) ctl_stack->trns)->has_else)
- {
- msg (SE, _("There may be at most one ELSE clause in each DO IF "
- "structure. It must be the last clause."));
- return CMD_FAILURE;
- }
-
- /* Note that the ELSE transformation is *not* added to the list of
- transformations. That's because it doesn't need to do anything.
- Its goto transformation *is* added, because that's necessary.
- The main DO IF do_if_trns is the destructor for this ELSE
- do_if_trns. */
- t = xmalloc (sizeof *t);
- t->next = NULL;
- t->brk = xmalloc (sizeof *t->brk);
- t->brk->h.proc = goto_trns_proc;
- t->brk->h.free = NULL;
- t->cond = NULL;
- add_transformation ((struct trns_header *) t->brk);
- t->h.index = t->brk->h.index + 1;
-
- /* Add to string of ELSE IFs. */
- add_ELSE_IF (t);
-
+ struct do_if_trns *do_if = ctl_stack_top (&do_if_class);
+ if (do_if == NULL || !must_not_have_else (do_if))
+ return CMD_FAILURE;
+ add_else (do_if);