/*****************************************************************************

	FlowEE()

	This function moves the command string pointer to the next matching
' or | character in the command string.  It is called when a conditional
command (e.g. "E) is encountered and the condition fails, or when an F|
command is encountered.

*****************************************************************************/

#include "ZPort.h"		/* define portability identifiers */
#include "DefError.h"		/* define identifiers for error messages */
#include "DefTeco.h"		/* define general identifiers */

extern	VOID	EchoIt();	/* echo a character to the terminal */
extern	VOID	ErrMsg();	/* display an error message */
extern	DEFAULT	SkpCmd();	/* skip a single command */

EXTERN	char	*CBfPtr;	/* pointer into command string */
EXTERN	char	*CStEnd;	/* pointer to last char of command string */
EXTERN	BOOLEAN	TraceM;		/* trace mode flag */


DEFAULT FlowEE()		/* flow to else or end (| or ') */
{
	LOCAL WORD TmpNst;

	TmpNst = 1;
	do
		{
		if (CBfPtr == CStEnd)
			{
			ErrMsg(ERR_UTC);
			return(FAILURE);
			}
		++CBfPtr;
		if ((*CBfPtr == '|') &&
		    (TmpNst == 1))
			break;
		if (*CBfPtr == '"')
			++TmpNst;
		else if (*CBfPtr == '\'')
			--TmpNst;
		if (SkpCmd() == FAILURE)
			return(FAILURE);
		}
	while (TmpNst > 0);

	if (TraceM)
		EchoIt(*CBfPtr);

	return(SUCCESS);
}
