示例#1
0
/*****************************************************************************
	ExeEY()
	This function executes an EY command.
*****************************************************************************/
#include "zport.h"		/* define portability identifiers */
#include "tecoc.h"		/* define general identifiers */
#include "defext.h"		/* define external global variables */
DEFAULT ExeEY()			/* execute an EY command */
{
	BOOLEAN	ColonMod;
	DBGFEN(1,"ExeEY",NULL);
	ColonMod = (CmdMod & COLON);		/* is it :EY ? */
	CmdMod &= ~COLON;			/* clear modifiers flags */
	GapBeg = EBfBeg;			/* clear the...   */
	GapEnd = EBfEnd;			/*   ...edit buffer */
	if (IsEofI[CurInp]) {			/* if at end-of-file */
		if (ColonMod) {			/* if it's :EY */
			DBGFEX(1,DbgFNm,"PushEx(0)");
			return PushEx(0L, OPERAND);
		} else {
			EStTop = EStBot;	/* clear expression stack */
			DBGFEX(1,DbgFNm,"SUCCESS");
			return SUCCESS;
		}
	}
	if (RdPage() == FAILURE) {		/* read a page */
		DBGFEX(1,DbgFNm,"FAILURE");
		return FAILURE;
	}
	if (ColonMod) {				/* if it's :EY */
		DBGFEX(1,DbgFNm,"PushEx(-1)");
		return PushEx(-1L, OPERAND);
	}
	EStTop = EStBot;			/* clear expression stack */
	DBGFEX(1,DbgFNm,"SUCCESS");
	return SUCCESS;
}
示例#2
0
文件: exef.c 项目: rmblair/tecoc
static DEFAULT ExeFS()			/* execute an FS command */
{
	DBGFEN(1,"ExeFS",NULL);

/*
 * The command m,nFS is illegal: the user should use m,nFC
 */

	if (CmdMod & MARGIS) {			/* if it's m,nFS */
		ErrStr(ERR_ILL, "m,nFS");	/* illegal command "m,nFS" */
		DBGFEX(1,DbgFNm,"FAILURE");
		return FAILURE;
	}

/*
 * If it's ::FStext$,  it's a compare,  not a search.  The text argument is
 * compared to the characters immediately following the character pointer.
 * It returns -1 if the strings match, else 0.  A ::FStext$ command is
 * equivalent to a .,.+1:FCtext$ command, so that's the way it's implemented.
 */

	if (CmdMod & DCOLON) {			/* if it's ::FS */
		if (CmdMod & MARGIS) {		/* if it's m,n::FS */
			ErrStr(ERR_ILL, "m,n::FS");
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
		if (EStTop > EStBot) {		/* if it's n::FS */
			ErrStr(ERR_ILL, "n::FS");
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
		if (GapEnd == EBfEnd) {		/* if nothing to search */
			CmdMod = '\0';		/* clear modifiers flags */
			DBGFEX(1,DbgFNm,"PushEx(0)");
			return PushEx(0L,OPERAND);
		}
		CmdMod &= ~DCOLON;		/* clear double-colon bit */
		CmdMod |= COLON;		/* set colon bit */
		CmdMod |= MARGIS;		/* set m defined bit */
		MArgmt = GapBeg - EBfBeg;	/* set m */
		if (PushEx((LONG)((GapBeg-EBfBeg)+1),OPERAND) == FAILURE) {
			DBGFEX(1,DbgFNm,"FAILURE, PushEx() failed");
			return FAILURE;
		}
		DBGFEX(1,DbgFNm,"ExeFC()");
		return ExeFC();			/* execute FC command */
	}

	SrcTyp = S_SEARCH;
	if (Replac() == FAILURE) {
		DBGFEX(1,DbgFNm,"FAILURE, Replac() failed");
		return FAILURE;
	}

	CmdMod = '\0';				/* clear modifiers flags */

	DBGFEX(1,DbgFNm,"SUCCESS");
	return SUCCESS;
}
示例#3
0
integer ExeU()					/* execute U command */
{
	DBGFEN(1,"ExeU",NULL);
	if (EStTop == EStBot) {			/* if no numeric argument */
		ErrMsg(ERR_NAU);
		DBGFEX(1,DbgFNm,"FAILURE, no arg before U");
		return FAILURE;
	}

	if (GetNmA() == FAILURE) {		/* get numeric argument */
		DBGFEX(1,DbgFNm,"FAILURE, GetNmA() failed");
		return FAILURE;
	}
	if (IncCBP() == FAILURE) {		/* increment to Q-reg name */
		DBGFEX(1,DbgFNm,"FAILURE, IncCBp() failed.");
		return FAILURE;
	}
	if (FindQR() == FAILURE) {
		DBGFEX(1,DbgFNm,"FAILURE, FindQR() failed");
		return FAILURE;
	}

	QR->Number = NArgmt;
	if (CmdMod & MARGIS) {			/* if m,nUq */
		DBGFEX(1,DbgFNm,"PushEx()");
		return PushEx(MArgmt, OPERAND);
	}

	CmdMod = '\0';				/* clear modifiers flags */

	DBGFEX(1,DbgFNm,"SUCCESS");
	return SUCCESS;
}
示例#4
0
integer
DoCJR(long HowFar)                /* do C, J or R stuff */
/* long HowFar;                         positive or negative displacement */
{
    long    InRange;
    bool ColonMod;

#if DEBUGGING
    static char *DbgFNm = "DoCJR";
    sprintf(DbgSBf,"HowFar = %ld", HowFar);
    DbgFEn(2,DbgFNm,DbgSBf);
#endif

    ColonMod = (CmdMod & COLON);                /* is it :C, :J, or :R? */
    CmdMod &= ~COLON;                        /* clear : flag */

    InRange = -1;                                /* -1 means SUCCESS in TECO */
    if (HowFar > 0)
    {
        if ((GapEnd + HowFar) > EBfEnd)
            InRange = 0;                /* 0 means FAILURE in TECO */
        else
        {
            MEMMOVE(GapBeg, GapEnd + 1, HowFar);
            GapBeg += HowFar;
            GapEnd += HowFar;
        }
    }
    else
    {
        if ((GapBeg + HowFar) < EBfBeg)
            InRange = 0;                /* 0 means FAILURE in TECO */
        else
        {
            GapBeg += HowFar;
            GapEnd += HowFar;
            MEMMOVE(GapEnd+1, GapBeg, -(HowFar));
        }
    }

    if (ColonMod)                      /* if colon modifier */
    {
        DBGFEX(2,DbgFNm,"PushEx");
        return PushEx(InRange, OPERAND);
    }
    else if (InRange == 0)              /* if out-of-bounds */
    {
        ErrChr(ERR_POP, *CBfPtr);
        DBGFEX(2, DbgFNm, "FAILURE");
        return FAILURE;
    }

    CmdMod = '\0';                                /* clear modifiers flags */
    EStTop = EStBot;                        /* clear expression stack */

    DBGFEX(2,DbgFNm,"SUCCESS");

    return SUCCESS;
}
示例#5
0
/*****************************************************************************
	ExeDot()
	This function executes a . (dot) command.
	.	Equivalent to the number of characters between the
		beginning of the buffer and the current position of the
		pointer. Thus "." represents the current position of
		the pointer.
*****************************************************************************/
#include "zport.h"		/* define portability identifiers */
#include "tecoc.h"		/* define general identifiers */
#include "defext.h"		/* define external global variables */
DEFAULT ExeDot()		/* execute a . (dot) command */
{
#if DEBUGGING
	DBGFEN(1,"ExeDot",NULL);
	sprintf(DbgSBf,"PushEx(%ld)", (LONG)(GapBeg-EBfBeg));
	DbgFEx(1,DbgFNm,DbgSBf);
#endif
	return PushEx((LONG)(GapBeg-EBfBeg), OPERAND);
}
示例#6
0
integer ExeCCC()		/* execute a control-^ command */
{
	DBGFEN(1,"ExeCCC",NULL);

	if (IncCBP() == FAILURE) {
		DBGFEX(1,DbgFNm,"FAILURE");
		return FAILURE;
	}

	DBGFEX(1,DbgFNm,"PushEx()");
	return PushEx((long)*CBfPtr, OPERAND);
}
示例#7
0
/*****************************************************************************
	ExeRtP()
	This function executes a ) command.
*****************************************************************************/
#include "zport.h"		/* define portability identifiers */
#include "tecoc.h"		/* define general identifiers */
#include "defext.h"		/* define external global variables */
#include "deferr.h"		/* define identifiers for error messages */
DEFAULT ExeRtP()		/* execute right parenthesis command */
{
	DBGFEN(1,"ExeRtP",NULL);
/*
 * if no numeric arg.  or not a number
 */
	if ((EStTop == EStBot) || (EStack[EStTop].ElType != OPERAND)) {
		ErrMsg(ERR_NAP);		/* no argument before ) */
		DBGFEX(1,DbgFNm,"FAILURE");
		return FAILURE;
	}
	DBGFEX(1,DbgFNm,"PushEx(')')");
	return PushEx((LONG)')', OPERATOR);
}
示例#8
0
文件: exew.c 项目: rmblair/tecoc
static DEFAULT VGetW()		/* execute an n:W command */
{
    DBGFEN(1,"VGetW",NULL);
    DBGFEX(1,DbgFNm,"PushEx()");
    return PushEx(	NArgmt==0 ? CrType :
			NArgmt==1 ? HtSize :
			NArgmt==2 ? VtSize :
			NArgmt==3 ? SeeAll :
			NArgmt==4 ? MrkFlg :
			NArgmt==5 ? HldFlg :
			NArgmt==6 ? TopDot :
			NArgmt==7 ? ScroLn :
#if CURSES
		        NArgmt==8 ? SpcMrk :
		        NArgmt==9 ? KeyPad :
#endif
		                             0 , OPERAND);
}
示例#9
0
/*****************************************************************************
	ExeCtR()
	This function executes a ^R (control-R or caret-R) command.  The
control-R command sets TECO's radix,  which controls how ASCII strings are
converted to/from their binary representations.  The current radix is used
by the backslash command and whenever TECO encounters a string of digits in
a command string.
*****************************************************************************/
#include "zport.h"		/* define portability identifiers */
#include "tecoc.h"		/* define general identifiers */
#include "defext.h"		/* define external global variables */
#include "deferr.h"		/* define identifiers for error messages */
DEFAULT ExeCtR()		/* execute a ^R (control-R) command */
{
	DBGFEN(1,"ExeCtR",NULL);
	if ((EStTop == EStBot) ||		    /* if no numeric arg or */
	    (EStack[EStTop].ElType != OPERAND)) {     /* partial expression */
		DBGFEX(1,DbgFNm,"PushEx");
		return PushEx((LONG)Radix, OPERAND);
	}
	if (GetNmA() == FAILURE) {
		DBGFEX(1,DbgFNm,"FAILURE, GetNmA() failed");
		return FAILURE;
	}
	if ((NArgmt != 8) && (NArgmt != 10) && (NArgmt != 16)) {
		ErrMsg(ERR_IRA);	/* illegal radix with ^R */
		DBGFEX(1,DbgFNm,"FAILURE, illegal radix");
		return FAILURE;
	}
	Radix = (DEFAULT)NArgmt;
	DBGFEX(1,DbgFNm,"SUCCESS");
	return SUCCESS;
}
示例#10
0
/*****************************************************************************
	PopMac()
	This function "pops" the current macro environment,  which was
established by an earlier call to the PshMac function.  Part of this job
is de-allocating memory consumed by local q-registers.
*****************************************************************************/
#include "zport.h"		/* define portability identifiers */
#include "tecoc.h"		/* define general identifiers */
#include "defext.h"		/* define external global variables */
DEFAULT PopMac()		/* restore environment after macro exit */
{
    WORD	i;
    MSptr	MSp;		/* pointer into the macro stack */
    QRptr	QRp;		/* pointer into local Q-register table */
    BOOLEAN	RetVal;		/* TRUE if macro is returning a value */
    DBGFEN(1,"PopMac",NULL);
    RetVal = (EStTop > EStBot);
    if (RetVal) {		/* if macro is returning a value */
        if (GetNmA() == FAILURE) {
	    DBGFEX(1,DbgFNm,"FAILURE, GetNmA() failed");
	    return FAILURE;
	}
    }
/*
 * restore old environment
 */
    MSp = &MStack[MStTop];
    CStBeg = MSp->CStBeg;		/* restore old command string start */
    CBfPtr = MSp->CBfPtr;		/* restore old command string ptr */
    CStEnd = MSp->CStEnd;		/* restore old command string end */
    EStBot = MSp->EStBot;		/* restore expression stack bottom */
    EStTop = MSp->EStTop;		/* restore expression stack top */
    LStBot = MSp->LStBot;		/* restore loop stack bottom */
    LStTop = MSp->LStTop;		/* restore loop stack top */
    if (MSp->QRgstr != NULL) {		/* local q-registers allocated? */
        for (QRp = MSp->QRgstr, i = 0; i < 36; ++i, ++QRp) {
	    if (QRp->Start != NULL) {
		ZFree((voidptr)QRp->Start);
	    }
	}
	ZFree(MSp->QRgstr);
    }
    --MStTop;
#if DEBUGGING
    sprintf(DbgSBf,"%s", (RetVal) ? "PushEx(NArgmt)" : "SUCCESS");
    DbgFEx(1,DbgFNm,DbgSBf);
#endif
    return ((RetVal) ? PushEx(NArgmt, OPERAND) : SUCCESS);
}
示例#11
0
integer ExeRBr()                /* execute ] command */
{
	QRptr		TmpQRp;
	ptrdiff_t	TmpSiz;
	bool		ColonMod;

#if DEBUGGING
	static char *DbgFNm = "ExeRBr";
	sprintf(DbgSBf, "QStTop = %d", QStTop);
	DbgFEn(1,DbgFNm,DbgSBf);
#endif

	ColonMod = (CmdMod & COLON);		/* is it :] ? */
	CmdMod &= ~COLON;			/* clear colon flag */

	if (IncCBP() == FAILURE) {
		return FAILURE;
	}

	if (FindQR() == FAILURE) {
		DBGFEX(1,DbgFNm,"FAILURE");
		return FAILURE;
	}

	if (QStTop < 0)	{			/* if q-reg stack is empty */
		if (ColonMod) {			/* if it's :] */
			DBGFEX(1,DbgFNm,"PushEx(0)");
			return PushEx(0L, OPERAND);
		} else {
			ErrMsg(ERR_PES);	/* can't pop empty stack */
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
	}

/*
 * Copy QStack Q-register to QR
 */
	TmpQRp = &QStack[QStTop];
	TmpSiz = TmpQRp->End_P1 - TmpQRp->Start;
	if (TmpSiz == 0) {			/* if it should be empty */
		if (QR->Start != NULL) {	    /* but it isn't empty */
			ZFree((voidptr)QR->Start);	/* then empty it */
			QR->Start = QR->End_P1 = NULL;
		}
	} else {
		if (MakRom((size_t)TmpSiz) == FAILURE) { /* adjust QR space */
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
		MEMMOVE(QR->Start, TmpQRp->Start, (size_t)TmpSiz);
		QR->End_P1 = QR->Start + TmpSiz;
	}
	QR->Number = TmpQRp->Number;

/*
 * clear QStack Q-register
 */
	if (TmpQRp->Start != NULL) {
		ZFree((voidptr)TmpQRp->Start);
		TmpQRp->Start = TmpQRp->End_P1 = NULL;
	}
	TmpQRp->Number = 0;

	--QStTop;

	DBGFEX(1,DbgFNm,(ColonMod) ? "PushEx(-1)" : "SUCCESS");
	return (ColonMod) ? PushEx(-1L, OPERAND) : SUCCESS;
}
示例#12
0
文件: exea.c 项目: rmblair/tecoc
DEFAULT ExeA()			/* execute an A command */
{
    BOOLEAN		EBfFul;
    unsigned char	TmpChr;
    BOOLEAN		ColonMod;

    DBGFEN(1,"ExeA",NULL);

    ColonMod = (CmdMod & COLON);		/* is it :A or n:A */
    CmdMod &= ~COLON;				/* clear : flag */

/*
 * if we have a numeric argument, it's nA or n:A
 */

    if (EStTop > EStBot) {			/* if numeric argument */
        UMinus();				/* if it's -A, make it -1A */
	if (GetNmA() == FAILURE) {		/* get numeric argument */
	    DBGFEX(1,DbgFNm,"FAILURE, GetNmA() failed");
	    return FAILURE;
	}

	if (ColonMod) {				/* if it's n:A */
	    if (NArgmt < 1) {
	        ErrMsg(ERR_IPA);
		DBGFEX(1,DbgFNm,"FAILURE, n:A, n < 1");
		return FAILURE;
	    }
	    while (NArgmt-- > 0) {
	        EBfFul = FALSE;
		if (RdLine(&EBfFul) == FAILURE) {
		    DBGFEX(1,DbgFNm,"FAILURE, RdLine() failed");
		    return FAILURE;
		}
		if (EBfFul) {
		    break;
		}
		if (IsEofI[CurInp]) {		/* if end-of-file */
		    DBGFEX(1,DbgFNm,"PushEx(0)");
		    return PushEx(0L, OPERAND);
		}
	    }
	    DBGFEX(1,DbgFNm,"PushEx(-1)");
	    return PushEx(-1L, OPERAND);
	}

/*
 * it's nA
 */
	if (NArgmt < 0) {
	    if ((GapBeg+NArgmt) < EBfBeg) {
	        DBGFEX(1,DbgFNm,"PushEx(-1)");
		return PushEx(-1L, OPERAND);
	    }
	    TmpChr = *(GapBeg+NArgmt);
	} else {
	    if ((GapEnd+NArgmt+1) > EBfEnd) {
	        DBGFEX(1,DbgFNm,"PushEx(-1)");
		return PushEx(-1L, OPERAND);
	    }
	    TmpChr = *(GapEnd+NArgmt+1);
	}
#if DEBUGGING
	sprintf(DbgSBf,"PushEx(%d)", TmpChr);
	DbgFEx(1,DbgFNm,DbgSBf);
#endif
	return PushEx((LONG)TmpChr, OPERAND);
    }

/*
 * if there is no numeric argument, must be A or :A
 */

    if (IsEofI[CurInp]) {			/* if already at end-of-file */
        DBGFEX(1,DbgFNm,(ColonMod) ? "PushEx(0)" : "SUCCESS");
	return ((ColonMod) ? PushEx(0L,OPERAND) : SUCCESS);
    }

    if (RdPage() == FAILURE) {			/* read a page */
        DBGFEX(1,DbgFNm,"FAILURE, RdPage() failed");
	return FAILURE;
    }

    DBGFEX(1,DbgFNm,(ColonMod) ? "PushEx(-1)" : "SUCCESS");
    return (ColonMod) ? PushEx(-1L, OPERAND) : SUCCESS;
}
示例#13
0
/*****************************************************************************
	ExeCtN()
	This function executes a ^N (control-N or caret-N) command.
	^N	<CTRL/N> (caret/N) is the end of file flag.  It is
		equivalent to -1 if the file open on the currently
		selected input stream is at end of file, and zero
		otherwise.
*****************************************************************************/
#include "zport.h"		/* define portability identifiers */
#include "tecoc.h"		/* define general identifiers */
#include "defext.h"		/* define external global variables */
DEFAULT ExeCtN()		/* execute a ^N (control-N) command */
{
	DBGFEN(1,"ExeCtN",NULL);
	DBGFEX(1,DbgFNm,"PushEx()");
	return PushEx((IsEofI[CurInp] ? -1L : 0L), OPERAND);
}
示例#14
0
integer ExeB()			/* execute a B command */
{
	DBGFEN(1,"ExeB",NULL);
	DBGFEX(1,DbgFNm,"PushEx(0)");
	return PushEx(0L, OPERAND);
}
示例#15
0
文件: exew.c 项目: rmblair/tecoc
static DEFAULT VSetW()		/* execute an m,n:W command */
{
    DBGFEN(1,"VSetW",NULL);

/*
 * Use an if here instead of a "default" case because doing a switch will
 * cast the variable to an "int",  causing Turbo-C to warn about types.
 */

    if ((NArgmt < 0) || (NArgmt > 9)) {
	return ExeNYI();
    }

    switch ((int)NArgmt) {
	case 0:
	    if ((MArgmt < 0) || (MArgmt > 13) || (MArgmt == 3) ||
						 (MArgmt == 5) ||
						 (MArgmt == 7) ||
						 (MArgmt == 9)) {
		ZDspBf("Illegal terminal type.", 22);
		ZDspBf("  Terminal types are:\r\n", 23);
		ZDspBf("\t0\t= VT52\r\n", 11);
		ZDspBf("\t1\t= VT61\r\n", 11);
		ZDspBf("\t2\t= VT100 in VT52 mode\r\n", 25);
		ZDspBf("\t4\t= VT100 in VT100 mode\r\n", 26);
		ZDspBf("\t6\t= VT05\r\n", 11);
		ZDspBf("\t8\t= VT102\r\n", 12);
		ZDspBf("\t10\t= VK100\r\n", 13);
		ZDspBf("\t11\t= VT200 in VT200 mode\r\n", 27);
		ZDspBf("\t12\t= VT200 in ANSI (VT100) mode\r\n", 34);
		ZDspBf("\t13\t= VT200 in VT52 mode\r\n", 26);
		CrType = (DEFAULT)MArgmt;
		return FAILURE;
	    }
	    CrType = (DEFAULT)MArgmt;
	    break;
	case 1:
	    if (MArgmt < 1) {
		ErrMsg(ERR_ARG);
		return FAILURE;
	    }
	    if (ZSetTT(TTWIDTH, (DEFAULT)MArgmt) == FAILURE)
		return FAILURE;
	    HtSize = (DEFAULT)MArgmt;
	    break;
	case 2:
	    if (MArgmt < 1) {
		ErrMsg(ERR_ARG);
		return FAILURE;
	    }
	    if (ZSetTT(TTHEIGHT, (DEFAULT)MArgmt) == FAILURE)
		return FAILURE;
	    VtSize = (DEFAULT)MArgmt;
	    break;
	case 3:
	    SeeAll = (DEFAULT)MArgmt;
	    break;
	case 4:
	    MrkFlg = (DEFAULT)MArgmt;
	    break;
	case 5:
	    HldFlg = (DEFAULT)MArgmt;
	    break;
	case 6:
#if CURSES
	    scope_start = (int)MArgmt;
	    p_scope_start = (scope_start > GapBeg - EBfBeg)
				? (scope_start - (GapBeg - EBfBeg)) + GapEnd
				: EBfBeg + scope_start;
#else
	    TopDot = (DEFAULT)MArgmt;
#endif
	    break;
	case 7:
	    ScroLn = (DEFAULT)MArgmt;
#if CURSES
	    Scope(ScroLn);
#endif
	    break;
#if CURSES
	case 8:
	    SpcMrk = (DEFAULT)MArgmt;
	    break;
	case 9:
	    KeyPad = (DEFAULT)MArgmt;
	    break;
#endif
    } /* end of switch */

    DBGFEX(1,DbgFNm,"SUCCESS");
    return (PushEx(MArgmt, OPERAND));
}