예제 #1
0
파일: skpcmd.c 프로젝트: rmblair/tecoc
static DEFAULT SkpOne()		/* skip one command character */
{
#if DEBUGGING
	static char *DbgFNm = "SkpOne";
	sprintf(DbgSBf,"*CBfPtr = '%c'", *CBfPtr);
	DbgFEn(3,DbgFNm,DbgSBf);
#endif
	if (CBfPtr == CStEnd) {
		if (MStTop < 0) {		/* if not in a macro */
			ErrUTC();		/* unterminated command */
			DBGFEX(3,DbgFNm,"FAILURE");
			return FAILURE;
		} else {
			DBGFEX(3,DbgFNm,"SUCCESS");
			return SUCCESS;
		}
	}

	++CBfPtr;

#if DEBUGGING
	sprintf(DbgSBf,"*CBfPtr = '%c'", *CBfPtr);
	DbgFEx(3,DbgFNm,DbgSBf);
#endif
	return SUCCESS;
}
예제 #2
0
파일: exedot.c 프로젝트: blakemcbride/TECOC
/*****************************************************************************
	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);
}
예제 #3
0
파일: getara.c 프로젝트: rmblair/tecoc
DEFAULT GetAra()		/* get m,n addresses */
{
	LONG	TmpLng;

#if DEBUGGING
	static char *DbgFNm = "GetAra";
	sprintf(DbgSBf,"MArgmt = %ld, NArgmt = %ld", MArgmt, NArgmt);
	DbgFEn(4,DbgFNm,DbgSBf);
#endif

	if (MArgmt < 0) {			/* if negative m */
		ErrMsg(ERR_NCA);		/* negative argument to , */
		DBGFEX(4,DbgFNm,"FAILURE, negative m");
		return FAILURE;
	}

	if (NArgmt < 0)	{			/* if negative n */
		ErrStr(ERR_POP, ErrTxt);	/* POP = pointer off page */
		DBGFEX(4,DbgFNm,"FAILURE, negative n");
		return FAILURE;
	}

	if (MArgmt > NArgmt) {			/* if wrong order */
		TmpLng = NArgmt;
		NArgmt = MArgmt;
		MArgmt = TmpLng;
	}

	AraBeg = EBfBeg + MArgmt;		/* compute area beginning */
	if (AraBeg > GapBeg-1) {		/* if past start of gap */
		AraBeg += (GapEnd-GapBeg) + 1;	/* correct for gap */
	}

	AraEnd = (EBfBeg + NArgmt) - 1;		/* compute area end */
	if (AraEnd > GapBeg-1) {		/* if before end of gap */
		AraEnd += (GapEnd-GapBeg) + 1;	/* correct for gap */
	}

	if ((AraBeg > EBfEnd) ||		/* if m or n too large */
	    (AraEnd > EBfEnd)) {
		ErrStr(ERR_POP, ErrTxt);	/* POP = pointer off page */
		DBGFEX(4,DbgFNm,"FAILURE");
		return FAILURE;
	}

#if DEBUGGING
	sprintf(DbgSBf,"SUCCESS, AraBeg = %ld, AraEnd = %ld",
		Zcp2ul(AraBeg), Zcp2ul(AraEnd));
	DbgFEx(4,DbgFNm,DbgSBf);
#endif
	return SUCCESS;
}
예제 #4
0
파일: popmac.c 프로젝트: blakemcbride/TECOC
/*****************************************************************************
	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);
}
예제 #5
0
파일: getnma.c 프로젝트: rmblair/tecoc
DEFAULT GetNmA()		/* get numeric argument */
{
    DBGFEN(2,"GetNmA",NULL);

    if (EStack[EStTop].ElType == OPERAND) {	/* it's an operand */
	NArgmt = EStack[EStTop].Elemnt;
	--EStTop;
#if DEBUGGING
	sprintf(DbgSBf,"SUCCESS, NArgmt = %ld",NArgmt);
	DbgFEx(2,DbgFNm,DbgSBf);
#endif
	return SUCCESS;
    }

#if DEBUGGING
    sprintf(DbgSBf,"dying with IFE, EstBot = %ld, stack =",(LONG)EStBot);
    DbgFMs(2,DbgFNm,DbgSBf);
    while (EStTop > 0) {
	printf("EStack[%ld].ElType = ", (LONG)EStTop);
	if (EStack[EStTop].ElType == OPERATOR) {
	    printf("OPERATOR, EStack[%ld].Elemnt = '%c'\r\n",
	    (LONG)EStTop, (char)EStack[EStTop].Elemnt);
	} else {
	    printf("OPERAND, EStack[%ld].Elemnt = %ld\r\n",
	    (LONG)EStTop, (LONG)EStack[EStTop].Elemnt);
	}
	EStTop--;
    }
#endif

    ErrMsg(ERR_IFE);			/* ill-formed numeric expression */

    DBGFEX(2,DbgFNm,"FAILURE, unterminated command");

    return FAILURE;
}
예제 #6
0
파일: skpcmd.c 프로젝트: blakemcbride/TECOC
/*****************************************************************************
	SkpCmd()
	This function "skips" TECO commands. It is used when TECO needs to
skip forward under one of these conditions:
	1. flow to the end of a conditional
	2. flow to the else clause of a conditional
	3. flow to the end of a loop
	4. flow while searching for a tag
	When this function is called, CBfPtr points to a command.  When this
function returns, CBfPtr is left pointing to the last character of the
command. In the case of a command like T, CBfPtr is not changed.  In the
case of a command like Stext<ESC>, CBfPtr is left pointing to the <ESC>.
*****************************************************************************/
DEFAULT SkpCmd()		/* skip a "command" */
{
	static DEFAULT (*FSAray[])(VVOID) = {
/*NUL*/ ExeNul,   /* ^A*/ SkpCtA,   /* ^B*/ SkpSkp,   /* ^C*/ SkpSkp,
/* ^D*/ SkpSkp,   /* ^E*/ SkpSkp,   /* ^F*/ SkpSkp,   /* ^G*/ SkpSkp,
/* BS*/ 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,   /*ESC*/ SkpSkp,
/* ^\*/ SkpSkp,   /* ^]*/ SkpSkp,   /* ^^*/ SkpOne,   /* ^_*/ SkpSkp,
/* SP*/ ExeNul,   /* ! */ SkpExc,   /* " */ SkpDqu,   /* # */ SkpSkp,
/* $ */ SkpSkp,   /* % */ SkpOne,   /* & */ SkpSkp,   /* ' */ SkpSkp,
/* ( */ SkpSkp,   /* ) */ SkpSkp,   /* * */ SkpSkp,   /* + */ SkpSkp,
/* , */ SkpSkp,   /* - */ SkpSkp,   /* . */ SkpSkp,   /* / */ SkpSkp,
/* 0 */ SkpSkp,   /* 1 */ SkpSkp,   /* 2 */ SkpSkp,   /* 3 */ SkpSkp,
/* 4 */ SkpSkp,   /* 5 */ SkpSkp,   /* 6 */ SkpSkp,   /* 7 */ SkpSkp,
/* 8 */ SkpSkp,   /* 9 */ SkpSkp,   /* : */ SkpSkp,   /* ; */ SkpSkp,
/* < */ SkpSkp,   /* = */ SkpSkp,   /* > */ SkpSkp,   /* ? */ SkpSkp,
/* @ */ ExeAtS,   /* A */ SkpSkp,   /* B */ SkpSkp,   /* C */ SkpSkp,
/* D */ SkpSkp,   /* E */ SkpE,     /* F */ SkpF,     /* G */ SkpOne,
/* H */ SkpSkp,   /* I */ SkpArg,   /* J */ SkpSkp,   /* K */ SkpSkp,
/* L */ SkpSkp,   /* M */ SkpOne,   /* N */ SkpArg,   /* O */ SkpArg,
/* P */ SkpSkp,   /* Q */ SkpOne,   /* R */ SkpSkp,   /* S */ SkpArg,
/* T */ SkpSkp,   /* U */ SkpOne,   /* V */ SkpSkp,   /* W */ SkpSkp,
/* X */ SkpOne,   /* Y */ SkpSkp,   /* Z */ SkpSkp,   /* [ */ SkpOne,
/* \ */ SkpSkp,   /* ] */ SkpOne,   /* ^ */ SkpCrt,   /* _ */ SkpArg,
/* ` */ SkpSkp,   /* a */ SkpSkp,   /* b */ SkpSkp,   /* c */ SkpSkp,
/* d */ SkpSkp,   /* e */ SkpE,     /* f */ SkpF,     /* g */ SkpOne,
/* h */ SkpSkp,   /* i */ SkpArg,   /* j */ SkpSkp,   /* k */ SkpSkp,
/* l */ SkpSkp,   /* m */ SkpOne,   /* n */ SkpArg,   /* o */ SkpArg,
/* p */ SkpSkp,   /* q */ SkpOne,   /* r */ SkpSkp,   /* s */ SkpArg,
/* t */ SkpSkp,   /* u */ SkpOne,   /* v */ SkpSkp,   /* w */ SkpSkp,
/* x */ SkpOne,   /* y */ SkpSkp,   /* z */ SkpSkp,   /* { */ SkpSkp,
/* | */ SkpSkp,   /* } */ SkpSkp,   /* ~ */ SkpSkp,   /*DEL*/ SkpSkp,
/*129*/ SkpSkp,   /*130*/ SkpSkp,   /*131*/ SkpSkp,   /*132*/ SkpSkp,
/*133*/ SkpSkp,   /*134*/ SkpSkp,   /*135*/ SkpSkp,   /*136*/ SkpSkp,
/*137*/ SkpSkp,   /*138*/ SkpSkp,   /*139*/ SkpSkp,   /*140*/ SkpSkp,
/*141*/ SkpSkp,   /*142*/ SkpSkp,   /*143*/ SkpSkp,   /*144*/ SkpSkp,
/*145*/ SkpSkp,   /*146*/ SkpSkp,   /*147*/ SkpSkp,   /*148*/ SkpSkp,
/*149*/ SkpSkp,   /*150*/ SkpSkp,   /*151*/ SkpSkp,   /*152*/ SkpSkp,
/*153*/ SkpSkp,   /*154*/ SkpSkp,   /*155*/ SkpSkp,   /*156*/ SkpSkp,
/*157*/ SkpSkp,   /*158*/ SkpSkp,   /*159*/ SkpSkp,   /*160*/ SkpSkp,
/*161*/ SkpSkp,   /*162*/ SkpSkp,   /*163*/ SkpSkp,   /*164*/ SkpSkp,
/*165*/ SkpSkp,   /*166*/ SkpSkp,   /*167*/ SkpSkp,   /*168*/ SkpSkp,
/*169*/ SkpSkp,   /*170*/ SkpSkp,   /*171*/ SkpSkp,   /*172*/ SkpSkp,
/*173*/ SkpSkp,   /*174*/ SkpSkp,   /*175*/ SkpSkp,   /*176*/ SkpSkp,
/*177*/ SkpSkp,   /*178*/ SkpSkp,   /*179*/ SkpSkp,   /*180*/ SkpSkp,
/*181*/ SkpSkp,   /*182*/ SkpSkp,   /*183*/ SkpSkp,   /*184*/ SkpSkp,
/*185*/ SkpSkp,   /*186*/ SkpSkp,   /*187*/ SkpSkp,   /*188*/ SkpSkp,
/*189*/ SkpSkp,   /*190*/ SkpSkp,   /*191*/ SkpSkp,   /*192*/ SkpSkp,
/*193*/ SkpSkp,   /*194*/ SkpSkp,   /*195*/ SkpSkp,   /*196*/ SkpSkp,
/*197*/ SkpSkp,   /*198*/ SkpSkp,   /*199*/ SkpSkp,   /*200*/ SkpSkp,
/*201*/ SkpSkp,   /*202*/ SkpSkp,   /*203*/ SkpSkp,   /*204*/ SkpSkp,
/*205*/ SkpSkp,   /*206*/ SkpSkp,   /*207*/ SkpSkp,   /*208*/ SkpSkp,
/*209*/ SkpSkp,   /*210*/ SkpSkp,   /*211*/ SkpSkp,   /*212*/ SkpSkp,
/*213*/ SkpSkp,   /*214*/ SkpSkp,   /*215*/ SkpSkp,   /*216*/ SkpSkp,
/*217*/ SkpSkp,   /*218*/ SkpSkp,   /*219*/ SkpSkp,   /*220*/ SkpSkp,
/*221*/ SkpSkp,   /*222*/ SkpSkp,   /*223*/ SkpSkp,   /*224*/ SkpSkp,
/*225*/ SkpSkp,   /*226*/ SkpSkp,   /*227*/ SkpSkp,   /*228*/ SkpSkp,
/*229*/ SkpSkp,   /*230*/ SkpSkp,   /*231*/ SkpSkp,   /*232*/ SkpSkp,
/*233*/ SkpSkp,   /*234*/ SkpSkp,   /*235*/ SkpSkp,   /*236*/ SkpSkp,
/*237*/ SkpSkp,   /*238*/ SkpSkp,   /*239*/ SkpSkp,   /*240*/ SkpSkp,
/*241*/ SkpSkp,   /*242*/ SkpSkp,   /*243*/ SkpSkp,   /*244*/ SkpSkp,
/*245*/ SkpSkp,   /*246*/ SkpSkp,   /*247*/ SkpSkp,   /*248*/ SkpSkp,
/*249*/ SkpSkp,   /*250*/ SkpSkp,   /*251*/ SkpSkp,   /*252*/ SkpSkp,
/*253*/ SkpSkp,   /*254*/ SkpSkp,   /*255*/ SkpSkp,   /*256*/ SkpSkp
	};
	DEFAULT Status;
#if DEBUGGING
	static char *DbgFNm = "SkpCmd";
	sprintf(DbgSBf,"*CBfPtr = '%c', at_sign is %s",
		*CBfPtr, (CmdMod & ATSIGN) ? "TRUE" : "FALSE");
	DbgFEn(3,DbgFNm,DbgSBf);
#endif
	Status = (*FSAray[*CBfPtr])();
#if DEBUGGING
	sprintf(DbgSBf,"*CBfPtr = '%c'", *CBfPtr);
	DbgFEx(3,DbgFNm,DbgSBf);
#endif
	return Status;
}
예제 #7
0
int
BldStr(charptr XBfBeg, charptr XBfEnd, charptr* XBfPtr)                /* build a string */
/* charptr XBfBeg;                 beginning of build-string buffer */
/* charptr XBfEnd;                 end of build-string buffer */
/* charptr (*XBfPtr);                 pointer into build-string buffer */
{
    charptr       EndArg;                /* end of input string, plus 1 */
    unsigned char TmpChr;        /* temporary character */

    DBGFEN(2,"BldStr",NULL);

    if (FindES(ESCAPE) == FAILURE)         /* move CBfPtr to end of argument */
    {
        DBGFEX(2,DbgFNm,"FAILURE, FindES(ESCAPE) failed");
        return FAILURE;
    }

    CaseCv = IniSrM;                /* initialize internal search mode */
    BBfPtr = XBfBeg;                /* initialize ptr into build-string buffer */
    EndArg = CBfPtr;                /* save pointer to end of argument */
    CBfPtr = ArgPtr;                /* reset to beginning of argument */

    while (CBfPtr < EndArg)
    {
        if ((*CBfPtr == '^') && ((EdFlag & ED_CARET_OK) == 0))
        {
            if (++CBfPtr == EndArg)
            {
                ErrMsg(ERR_ISS);
                DBGFEX(2,DbgFNm,"FAILURE, no char after ^");
                return FAILURE;
            }
            TmpChr = To_Upper(*CBfPtr);
            if ((TmpChr < '@') || (TmpChr > '_'))
            {
                ErrChr(ERR_IUC, *CBfPtr);
                DBGFEX(2,DbgFNm,"FAILURE, bad char after ^");
                return FAILURE;
            }
            TmpChr &= '\077';
        }
        else
            TmpChr = *CBfPtr;

        switch (TmpChr)
        {
            case CTRL_R:
            case CTRL_Q:
                if (++CBfPtr == EndArg)
                {
                    ErrMsg(ERR_ISS);
                    DBGFEX(2, DbgFNm, "FAILURE");
                    return FAILURE;
                }
                *BBfPtr++ = *CBfPtr;
                break;

            case CTRL_V:
            case CTRL_W:
                if (DoCtVW(EndArg, TmpChr) == FAILURE)
                {
                    DBGFEX(2, DbgFNm, "FAILURE, DoCtVW failed");
                    return FAILURE;
                }
                break;

            case CTRL_E:
                if (DoCtE(EndArg, XBfEnd) == FAILURE)
                {
                    DBGFEX(2, DbgFNm, "FAILURE, DoCtE failed");
                    return FAILURE;
                }
                break;

            default:
                if (CaseCv == LOWER)
                    TmpChr = To_Lower(TmpChr);
                else if (CaseCv == UPPER)
                    TmpChr = To_Upper(TmpChr);
                *BBfPtr++ = TmpChr;
        } /* switch(TmpChr) */

        if (BBfPtr > XBfEnd)
        {
            ErrMsg(ERR_STL);        /* string too long */
            DBGFEX(2, DbgFNm, "FAILURE, string too long");
            return FAILURE;
        }
        ++CBfPtr;
    }
    *XBfPtr = BBfPtr;

#if DEBUGGING
    sprintf(DbgSBf, "string = \"%.*s\"", (int)(BBfPtr-XBfBeg), XBfBeg);
    DbgFEx(2, DbgFNm, DbgSBf);
#endif

    return SUCCESS;
}
예제 #8
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;
}