示例#1
0
integer ExeV()			/* execute an V command */
{
	long firstarg;

	DBGFEN(1,"ExeV",NULL);
	if (EStTop == EStBot) {			/* if no numeric argument */
		NArgmt = 1;			/* default is 1V */
	} else {
		UMinus();			/* if it's -V, make it -1V */
		if (GetNmA() == FAILURE) {	/* get numeric argument */
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
	}

	firstarg = 1 - ((CmdMod & MARGIS) ? MArgmt : NArgmt);
	if (firstarg <= 0) {
		TypBuf(GapBeg+Ln2Chr(firstarg), GapBeg);
	} else {
		TypBuf(GapEnd+1, GapEnd+Ln2Chr(firstarg)+1);
	}

	if (NArgmt <= 0) {
		TypBuf(GapBeg+Ln2Chr(NArgmt), GapBeg);
	} else {
		TypBuf(GapEnd+1, GapEnd+Ln2Chr(NArgmt)+1);
	}

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

	DBGFEX(1,DbgFNm,"SUCCESS");
	return SUCCESS;
}
示例#2
0
/*****************************************************************************
	ExeLst()
	This function executes a less-than-sign (<) command.
	n<	Iterate n times
*****************************************************************************/
#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 ExeLst()				/* execute a  < command */
{
	DBGFEN(1,"ExeLst",NULL);
	if (++LStTop >= LPS_SIZE) {		/* if loop stack is full */
		ErrMsg(ERR_PDO);		/* push-down list overflow */
		DBGFEX(1,DbgFNm,"FAILURE");
		return FAILURE;
	}
	if (EStTop == EStBot) {			/* if no numeric argument */
		NArgmt = INFINITE;		/* make it an infinite loop */
	} else {
		if (GetNmA() == FAILURE) {	/* get numeric argmument */
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
		if (NArgmt <= 0) {		/* if null loop */
			if (FlowEL()== FAILURE) { /* flow to end of loop */
				DBGFEX(1,DbgFNm,"FAILURE");
				return FAILURE;
			}
			CmdMod = '\0';		/* clear modifiers flags */
			DBGFEX(1,DbgFNm,"SUCCESS");
			return SUCCESS;
		}
	}
	LStack[LStTop].LIndex = NArgmt;		/* store loop index */
	LStack[LStTop].LAddr = CBfPtr;		/* store loop start */
	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
文件: exej.c 项目: rmblair/tecoc
DEFAULT ExeJ()			/* execute J command */
{
	DBGFEN(1,"ExeJ",NULL);

	if (EStTop == EStBot) {			/* if no numeric argument */
		NArgmt = 0;			/* default is 0J */
	} else {
		if (GetNmA() == FAILURE) {	/* get numeric argument */
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
	}
	DBGFEX(1,DbgFNm,"DoCJR()");
	return DoCJR(EBfBeg-GapBeg+NArgmt);
}
示例#5
0
/*****************************************************************************
	ExeCom()
	This function executes a , (comma argument separator) 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 ExeCom()		/* execute a , (comma) command */
{
	DBGFEN(1,"ExeCom",NULL);
	if (EStTop == EStBot) {			/* if no numeric argument */
		ErrMsg(ERR_NAC);		/* no arg before , */
		DBGFEX(1,DbgFNm,"FAILURE");
		return FAILURE;
	}
	if (GetNmA() == FAILURE) {
		DBGFEX(1,DbgFNm,"FAILURE");
		return FAILURE;
	}
	MArgmt = NArgmt;
	CmdMod |= MARGIS;
	DBGFEX(1,DbgFNm,"SUCCESS");
	return SUCCESS;
}
示例#6
0
文件: exer.c 项目: rmblair/tecoc
DEFAULT ExeR()			/* execute a R command */
{
	DBGFEN(1,"ExeR",NULL);

	if (EStTop == EStBot) {			/* if no numeric argument */
		NArgmt = 1;			/* default is 1R */
	} else {
		UMinus();			/* if it's -R, make it -1R */
		if (GetNmA() == FAILURE) {
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
	}

	DBGFEX(1,DbgFNm,"DoCJR()");
	return DoCJR(-NArgmt);
}
示例#7
0
integer ExeC()			/* execute a C command */
{
	DBGFEN(1,"ExeC",NULL);

	if (EStTop == EStBot) {			/* if no numeric argument */
		NArgmt = 1;			/* default is 1C */
	} else {
		UMinus();			/* if it's -C, make it -1C */
		if (GetNmA() == FAILURE) {
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
	}

	DBGFEX(1,DbgFNm,"DoCJR");
	return DoCJR(NArgmt);
}
示例#8
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;
}
示例#9
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);
}
示例#10
0
integer ExeCtW()		/* execute a ^W (control-W) command */
{
	DBGFEN(1,"ExeCtW",NULL);

	if (EStTop == EStBot) {			/* if no numeric argument */
		IniSrM = UPPER;
	} else {
		if (GetNmA() == FAILURE) {	/* get numeric argument */
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
		if (NArgmt) {			/* if it wasn't 0^W */
			ErrMsg(ERR_ARG);	/* improper arguments */
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
		IniSrM = NONE;
	}

	CmdMod = '\0';				/* clear modifiers flags */
	DBGFEX(1,DbgFNm,"SUCCESS");
	return SUCCESS;
}
示例#11
0
文件: exedqu.c 项目: rmblair/tecoc
DEFAULT ExeDQu()		/* execute a " (double quote) command */
{
	unsigned char RelExp;			/* relational expression */

	DBGFEN(1,"ExeDQu",NULL);
	if (EStTop == EStBot) {			/* if no numeric argument */
		ErrMsg(ERR_NAQ);		/* no argument before " */
		DBGFEX(1,DbgFNm,"FAILURE");
		return FAILURE;
	}

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

	if (IncCBP() == FAILURE) {
		DBGFEX(1,DbgFNm,"FAILURE, IncCBP() failed");
		return FAILURE;
	}
	CmdMod = '\0';
	RelExp = (unsigned char)NArgmt;

	switch (To_Upper(*CBfPtr)) {
	case 'A':	/* test for alphabetic */
		if (Is_Alpha(RelExp)) {
			DBGFEX(1,DbgFNm,"SUCCESS, Is_Alpha");
			return SUCCESS;
		}
		break;

	case 'C':	/* test for symbol constituent */
		if (Is_SyCon(RelExp)) {
			DBGFEX(1,DbgFNm,"SUCCESS, Is_SyCon");
			return SUCCESS;
		}
		break;

	case 'D':	/* test for numeric */
		if (Is_Digit(RelExp)) {
			DBGFEX(1,DbgFNm,"SUCCESS, Is_Digit");
			return SUCCESS;
		}
		break;

	case 'E':	/* test for equal to zero */
	case 'F':	/* test for false */
	case 'U':	/* test for unsuccessful */
	case '=':	/* test for equal to zero */
		if (NArgmt == 0) {
			DBGFEX(1,DbgFNm,"SUCCESS, equal to zero");
			return SUCCESS;
		}
		break;

	case 'G':	/* test for greater than zero */
	case '>':	/* test for greater than zero */
		if (NArgmt > 0) {
			DBGFEX(1,DbgFNm,"SUCCESS, greater than zero");
			return SUCCESS;
		}
		break;

	case 'L':	/* test for less than zero */
	case 'S':	/* test for successful */
	case 'T':	/* test for TRUE */
	case '<':	/* test for less than zero */
		if (NArgmt < 0) {
			DBGFEX(1,DbgFNm,"SUCCESS, less than zero");
			return SUCCESS;
		}
		break;

	case 'N':	/* test for not equal to zero */
		if (NArgmt != 0) {
			DBGFEX(1,DbgFNm,"SUCCESS, not equal to zero");
			return SUCCESS;
		}
		break;

	case 'R':	/* test for alphanumeric */
		if (Is_Alnum(RelExp)) {
			DBGFEX(1,DbgFNm,"SUCCESS, Is_Alnum");
			return SUCCESS;
		}
		break;

	case 'V':	/* test for lowercase */
		if (Is_Lower(RelExp)) {
			DBGFEX(1,DbgFNm,"SUCCESS, Is_Lower");
			return SUCCESS;
		}
		break;

	case 'W':	/* test for uppercase */
		if (Is_Upper(RelExp)) {
			DBGFEX(1,DbgFNm,"SUCCESS, Is_Upper");
			return SUCCESS;
		}
		break;

	default:
		ErrMsg(ERR_IQC);		/* ill. char. after " */
		DBGFEX(1,DbgFNm,"FAILURE");
		return FAILURE;
	}

	if (FlowEE() == FAILURE) {		/* flow to | or ' */
		DBGFEX(1,DbgFNm,"FAILURE, FlowEE() failed");
		return FAILURE;
	}

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

	DBGFEX(1,DbgFNm,"SUCCESS, test failed");
	return SUCCESS;
}
示例#12
0
integer ExeCtU()		/* execute a ^U (control-U) command */
{
    ptrdiff_t TmpSiz;

    DBGFEN(1,"ExeCtU",NULL);

    /*
     * increment CBfPtr past ^U
     */
    if (IncCBP() == FAILURE) {
        DBGFEX(1,DbgFNm,"FAILURE, IncCBP() failed");
        return FAILURE;
    }

    /*
     * try to find Q-register name after ^U
     */
    if (FindQR() == FAILURE) {
        DBGFEX(1,DbgFNm,"FAILURE, FindQR() failed");
        return FAILURE;
    }

    /*
     * If there is a colon modifier, we are appending to the Q-register text.
     * If there isn't a colon modifier, we are replacing the text currently
     * in the Q-register.  If there is any text currently in the Q-register,
     * we have to zap it first.
     */
    if (!(CmdMod & COLON)) {		/* if no colon modifier */
        if (QR->Start != NULL) {	/* if not empty */
            ZFree((voidptr)QR->Start);	/* free the memory */
            QR->Start = QR->End_P1 = NULL;
        }
    }


    /*
     * If there is a numeric argument n, we are dealing with a character to
     * place into or append to the Q-register.
     */
    if (EStTop > EStBot) {			/* if numeric argument */
        if (GetNmA() == FAILURE) {	/* get numeric argument */
            DBGFEX(1,DbgFNm,"FAILURE, GetNmA() failed");
            return FAILURE;
        }
        if (CmdMod & ATSIGN) {		/* it's @^U// */

            /*
             * increment CBfPtr to 1st delimiter
             */
            if (IncCBP() == FAILURE) {
                DBGFEX(1,DbgFNm,"FAILURE, IncCBP() failed");
                return FAILURE;
            }

            /*
             * increment CBfPtr to 2nd delimiter
             */
            if (IncCBP() == FAILURE) {
                DBGFEX(1,DbgFNm,"FAILURE, IncCBP() failed");
                return FAILURE;
            }

            /*
             * the two delimiters should be the same
             */
            if (*CBfPtr != *(CBfPtr-1)) {
                ErrMsg(ERR_IIA);
                DBGFEX(1,DbgFNm,"FAILURE, ERR_IIA");
                return FAILURE;
            }
        }

        /*
         * Increase the size of the text area by 1 character
         */
        if (MakRom((size_t) 1) == FAILURE) {
            DBGFEX(1,DbgFNm,"FAILURE, MakRom() failed");
            return FAILURE;
        }

        /*
         * Append the character to the Q-register
         */
        *(QR->End_P1) = (char) NArgmt;
        QR->End_P1++;
    } else {				/* else no numeric argument */
        /*
         * We must be dealing with a string, find the end of the string.
         */
        if (FindES(ESCAPE) == FAILURE) {
            DBGFEX(1,DbgFNm,"FAILURE, FindES() failed");
            return FAILURE;
        }

        TmpSiz = CBfPtr - ArgPtr;
        if (TmpSiz > 0) {

            /*
             * make room for the string
             */
            if (MakRom((size_t)TmpSiz) == FAILURE) {
                DBGFEX(1,DbgFNm,"FAILURE, MakRom() failed");
                return FAILURE;
            }

            /*
             * Append the string to the Q-register text
             */
            MEMMOVE(QR->End_P1, ArgPtr, (size_t)TmpSiz);
            QR->End_P1 += TmpSiz;
        }
    }

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

    DBGFEX(1,DbgFNm,"SUCCESS");
    return SUCCESS;
}
示例#13
0
integer ExeI()			/* execute an I command */
{
	unsigned char InChar;

	DBGFEN(1,"ExeI",NULL);
	if (EStTop > EStBot) {			/* if numeric argument */
		if (GetNmA() == FAILURE) {	/* get numeric argument */
			DBGFEX(1,DbgFNm,"FAILURE, GetNmA() failed");
			return FAILURE;
		}

		if (CmdMod & ATSIGN) {		/* if it's n@I// */
			if (IncCBP() == FAILURE) {
				DBGFEX(1,DbgFNm,"FAILURE, 1st IncCBP() failed");
				return FAILURE;
			}
			if (IncCBP() == FAILURE) {
				DBGFEX(1,DbgFNm,"FAILURE, 2nd IncCBP() failed");
				return FAILURE;
			}
			if (*CBfPtr != *(CBfPtr-1)) {
				ErrMsg(ERR_IIA);     /* illegal insert arg */
				DBGFEX(1,DbgFNm,"FAILURE, illegal insert arg");
				return FAILURE;
			}
		} else {				/* else must be nI$ */
			if ((CBfPtr+1) == CStEnd) {
				if (MStTop < 0) {
					ErrUTC();
					DBGFEX(1,DbgFNm,"FAILURE, unterminated command");
					return FAILURE;
				} else {
					DBGFEX(1,DbgFNm,"SUCCESS");
					return SUCCESS;
				}
			}
			if (*(CBfPtr+1) != ESCAPE) {
				ErrMsg(ERR_IIA);     /* illegal insert arg */
				DBGFEX(1,DbgFNm,"FAILURE, illegal insert arg");
				return FAILURE;
			}
		}
		InChar = (char)NArgmt;
		if (InsStr(&InChar, (ptrdiff_t)1) == FAILURE) {
			DBGFEX(1,DbgFNm,"FAILURE, InsStr() failed");
			return FAILURE;
		}
	} else {				/* else no numeric argument */
		if (FindES(ESCAPE) == FAILURE) {
			DBGFEX(1,DbgFNm,"FAILURE, FindES() failed");
			return FAILURE;
		}
		if (InsStr(ArgPtr, CBfPtr-ArgPtr) == FAILURE) {
			DBGFEX(1,DbgFNm,"FAILURE, InsStr() failed");
			return FAILURE;
		}
	}

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

	DBGFEX(1,DbgFNm,"SUCCESS");
	return SUCCESS;
}
示例#14
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;
}
示例#15
0
文件: exew.c 项目: rmblair/tecoc
DEFAULT ExeW()			/* execute an W command */
{
	DBGFEN(1,"ExeW",NULL);

/*
 * If the terminal is not a scope,  don't do anything.  Don't return
 * FAILURE,  because that'll terminate the current macro.
 */
	if (!(EtFlag & ET_WAT_SCOPE)) {		/* if scope not available */
		CmdMod = '\0';
		DBGFEX(1,DbgFNm,"SUCCESS");
		return SUCCESS;
	}

#if VIDEO

	if (EStTop == EStBot) {			/* if no numeric argument */
		NArgmt = (CmdMod & COLON) ? 0 : 16;
	} else {
		if (GetNmA() == FAILURE) {	/* get the numeric argument */
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
	}

	if (CmdMod & COLON) {			/* if it's :W */
		if (NArgmt < 0) {		/* insert processing? */
			CmdMod = '\0';
			return ExeNYI();
		} else {
			if (CmdMod & MARGIS) {	/* if it's m,n:W */
				CmdMod = '\0';
				if (VSetW() == FAILURE) {
					DBGFEX(1,DbgFNm,"FAILURE");
					return FAILURE;
				}
			} else {		/* else (must be n:W) */
				CmdMod = '\0';
				if (VGetW() == FAILURE) {
					DBGFEX(1,DbgFNm,"FAILURE");
					return FAILURE;
				}
			}
		}
	} else {				/* else there's no colon */
		CmdMod = '\0';
		if (VDoW() == FAILURE) {
			DBGFEX(1,DbgFNm,"FAILURE");
			return FAILURE;
		}
		EStTop = EStBot;		/* clear expression stack */
		CmdMod &= ~COLON;		/* clear colon modifier */
	}

	DBGFEX(1,DbgFNm,"SUCCESS");
	CmdMod = '\0';
	return SUCCESS;

#else /* not VIDEO */

	CmdMod = '\0';
	DBGFEX(1,DbgFNm,"ExeNYI()");
	return ExeNYI();

#endif /* VIDEO */
}
示例#16
0
integer ExeX()			/* execute an X command */
{
	ptrdiff_t TmpSiz;

	DBGFEN(1,"ExeX",NULL);
	if (EStTop == EStBot) {			/* if no numeric argument */
		NArgmt = 1;			/* default is 1X */
	} else {
		UMinus();			/* if it's -X, make it -1X */
		if (GetNmA() == FAILURE) {	/* get numeric argument */
			DBGFEX(1,DbgFNm,"FAILURE, GetNmA() failed");
			return FAILURE;
		}
	}


	if (IncCBP() == FAILURE) {		/* move to char after X */
		DBGFEX(1,DbgFNm,"FAILURE, IncCBP() failed");
		return FAILURE;
	}

	if (FindQR() == FAILURE) {		/* find q-register values */
		DBGFEX(1,DbgFNm,"FAILURE, FindQR() failed");
		return FAILURE;
	}

	if (!(CmdMod & COLON)) {		/* if no colon modifier */
		if (QR->Start != NULL) {	/* if text area not empty */
			ZFree((voidptr)QR->Start);/* free allocated memory */
			QR->Start = QR->End_P1 = NULL;
		}
	}

	if ((CmdMod & MARGIS) == '\0') {	/* if it's nXq (not m,nXq) */
		NArgmt = Ln2Chr(NArgmt);
		if (NArgmt > 0) {
			if (MakRom((size_t)NArgmt) == FAILURE) {
				DBGFEX(1,DbgFNm,"FAILURE, MakRom() failed");
				return FAILURE;
			}
			MEMMOVE(QR->End_P1, GapEnd+1, (size_t)NArgmt);
			QR->End_P1 += NArgmt;
		} else if (NArgmt < 0) {
			if (MakRom((size_t)-NArgmt) == FAILURE) {
				DBGFEX(1,DbgFNm,"FAILURE, MakRom() failed");
				return FAILURE;
			}
			MEMMOVE(QR->End_P1, GapBeg+NArgmt, (size_t)-NArgmt);
			QR->End_P1 -= NArgmt;
		}
	} else if (NArgmt != MArgmt) {		/* else (it's m,nXq) */
		MEMMOVE(ErrTxt, "m,nX", 5);
		if (GetAra() == FAILURE) {
			DBGFEX(1,DbgFNm,"FAILURE, GetAra() failed");
			return FAILURE;
		}
		if ((AraBeg < GapBeg) && (AraEnd > GapEnd)) {
			TmpSiz = (GapBeg-AraBeg) + (AraEnd-GapEnd);
			if (TmpSiz > 0) {
				if (MakRom((size_t)TmpSiz) == FAILURE) {
					DBGFEX(1,DbgFNm,"FAILURE, MakRom() failed");
					return FAILURE;
				}
				MEMMOVE(QR->End_P1,
					AraBeg,
					(size_t)(GapBeg - AraBeg));
				QR->End_P1 += GapBeg-AraBeg;
				MEMMOVE(QR->End_P1,
					GapEnd+1,
					(size_t)(AraEnd - GapEnd));
				QR->End_P1 += AraEnd-GapEnd;
			}
		} else {			/* else area is contiguous */
			TmpSiz = (AraEnd - AraBeg) + 1;
			if (TmpSiz > 0) {
				if (MakRom((size_t)TmpSiz) == FAILURE) {
					DBGFEX(1,DbgFNm,"FAILURE, MakRom() failed");
					return FAILURE;
				}
				MEMMOVE(QR->End_P1, AraBeg, (size_t)TmpSiz);
				QR->End_P1 += TmpSiz;
			}
		}
	}

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

	DBGFEX(1,DbgFNm,"SUCCESS");
	return SUCCESS;
}