From looking through the code ( without trying to actually do it ), it appears there are two places where things would need to be changed, and there are two different ways I can think of to do it, the hard way ( add the handling for 'elseif' in it's combined form in both mprog_do_command and mprog_driver ), or the hacked way - which I actually like better since it would still be fully functional but not nearly as much work - which is just to force the driver to process the else and if separately.
The hacking way:
The mprog_do_command function
Add an if statement checking for elseif, returning FOUNDELSEIF ( you'll need to declare it at the top of the file, too ).
The mprog_driver function:
Add a case in the switch statement for FOUNDELSEIF just before FOUNDELSE. The lines processed in this case statement remove the 'else' part of the elseif from the variable 'cmnd' and stop the while statement from advancing to the next line. I would add another boolean named 'noadvance' or a prettier name and check for it before processing the code that advances the line, which is this code at the beginning of the while loop:
/* With these two lines, cmnd becomes the current line from the prog,
and command_list becomes everything after that line. */
cmnd = command_list;
command_list = mprog_next_command( command_list );
/* Are we at the end? */
if ( cmnd == '\0' )
if ( ifstate[iflevel][IN_IF] || ifstate[iflevel][IN_ELSE] )
progbug( "Missing endif", mob );
Lastly, don't put a break at the end of the FOUNDELSEIF statement, so it goes right into the FOUNDELSE statement.
This would remove the 'else' from the 'elseif (statement)' check for the standard errors for 'else' and leave 'if (statement)' to be processed the next run through the while statement.
Wouldn't this work? It's possible I'm missing something major, of course, but it looks like that should do it.