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

	SkpCrt()

	This function is called by SkpCmd to skip a command which starts
with a caret character (^).

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

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

extern	DEFAULT	ExeNul();	/* execute a null command */
extern	DEFAULT	SkpCtA();	/* skip a control-A (^A) command */
extern	DEFAULT	SkpCtU();	/* skip a control-U (^U) command */
extern	DEFAULT	SkpArg();	/* skip a command with a text argument */
extern	DEFAULT	SkpOne();	/* skip one character */
extern	DEFAULT	SkpSkp();	/* skip nothing */

EXTERN	char	*CBfPtr;	/* pointer into command string */
EXTERN	char	*CStEnd;	/* pointer to last char of command string */
EXTERN	WORD	MStTop;		/* top of macro stack */


DEFAULT SkpCrt()		/* skip a ^ (caret) command */
{
	static DEFAULT (*FCAray[])() = {
/* ^A*/ SkpCtA,   /* ^B*/ SkpSkp,   /* ^C*/ SkpSkp,   /* ^D*/ SkpSkp,
/* ^E*/ SkpSkp,   /* ^F*/ SkpSkp,   /* ^G*/ SkpSkp,   /* ^H*/ SkpSkp,
/*TAB*/ SkpArg,   /* LF*/ ExeNul,   /* VT*/ SkpSkp,   /* FF*/ SkpSkp,
/* CR*/ ExeNul,   /* ^N*/ SkpSkp,   /* ^O*/ SkpSkp,   /* ^P*/ SkpSkp,
/* ^Q*/ SkpSkp,   /* ^R*/ SkpSkp,   /* ^S*/ SkpSkp,   /* ^T*/ SkpSkp,
/* ^U*/ SkpCtU,   /* ^V*/ SkpSkp,   /* ^W*/ SkpSkp,   /* ^X*/ SkpSkp,
/* ^Y*/ SkpSkp,   /* ^Z*/ SkpSkp,   /* ^[*/ SkpSkp,   /* ^\*/ SkpSkp,
/* ^]*/ SkpSkp,   /* ^^*/ SkpOne,   /* ^_*/ SkpSkp
	};
	LOCAL WORD CDummy;

	if (CBfPtr == CStEnd)			/* if end of command string */
		if (MStTop < 0)			/* if macro stack empty */
			{
			ErrMsg(ERR_UTC);	/* unterminated command */
			return(FAILURE);
			}
		else
			return(SUCCESS);
	++CBfPtr;
	if ((*CBfPtr >= 'A') && (*CBfPtr <= '_'))
		CDummy = *CBfPtr - 'A';
	else if (Is_Lower(*CBfPtr))
		CDummy = *CBfPtr - 'a';		/* convert to upper case */
	else
		{
		ErrMsg(ERR_IUC);		/* illegal char after ^ */
		return(FAILURE);
		}
	return(Execut(FCAray[CDummy]));
}
