예제 #1
0
파일: exeu.c 프로젝트: shinmai-rookie/tecoc
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;
}
예제 #2
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);
}
예제 #3
0
파일: exef.c 프로젝트: rmblair/tecoc
DEFAULT ExeF()				/* execute one of the F commands */
{
	if (IncCBP() == FAILURE) {
		return FAILURE;
	}

	switch (To_Upper(*CBfPtr)) {
          case 'S':  return ExeFS();
	  case 'N':  return ExeFN();
	  case 'D':  return ExeFD();
	  case 'R':  return ExeFR();
	  case 'B':  return ExeFB();
	  case 'C':  return ExeFC();
	  case 'K':  return ExeFK();
	  case '_':  return ExeFUn();
	  case '>':  return ExeFGt();
	  case '<':  return ExeFLs();
	  case '\'': return ExeFSQ();
	  case '|':  return ExeFBr();
	  default:   ErrChr(ERR_IFC, *CBfPtr);
		     return FAILURE;
	}
}
예제 #4
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;
}
예제 #5
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;
}
예제 #6
0
파일: findqr.c 프로젝트: rmblair/tecoc
DEFAULT FindQR()		/* find q-register index */
{
    WORD	i;
    BOOLEAN	LocalQ;
    WORD	QIndex;
    unsigned char QName;

/*
 * If it's a local q-register name (starts with a dot), remember and move on.
 */
    DBGFEN(3,"FindQR",NULL);
    LocalQ = (*CBfPtr == '.');			/* if local q-register */
    if (LocalQ) {				/* if local q-register name */
        if (IncCBP() == FAILURE) {		/* move to next character */
	    DBGFEX(3,DbgFNm,"FAILURE, IncCBP() failed");
	    return FAILURE;
	}
    }

/*
 * Get the index into the QRgstr array into i.
 */
    QName = *CBfPtr;
    if (Is_Upper(QName)) {
        i = 'A' - 10;				/* QRgStr[10..35] */
    } else if (Is_Lower(QName)) {
	i = 'a' - 10;				/* QRgstr[10..35] */
    } else if (Is_Digit(QName)) {
	i = '0';				/* QRgstr[0..9] */
    } else {
        ErrChr(ERR_IQN, QName);
	DBGFEX(3,DbgFNm,"FAILURE, illegal Q-register name");
	return FAILURE;
    }

/*
 * Get a pointer to the structure into QR.
 */
    QIndex = QName - i;				/* index into QRgstr[] */
    if (LocalQ) {				/* if local q-register */
        if (MStTop < 0) {			/* if not in a macro */
	    QR = &QRgstr[QIndex+36];		/* use QRgstr[36..71] */
	} else {				/* else (we're in a macro) */
	    WORD TMIndx;
	    QRptr QRp;
	    for (TMIndx=MStTop; TMIndx>0; TMIndx--) {
		if (MStack[TMIndx].QRgstr != NULL) {
		    QRp = MStack[TMIndx].QRgstr;
		    break;
		}
	    }
	    QR = (TMIndx != 0) ?		/* if we found one */
		    &QRp[QIndex]:		/* use the one we found */ 
		    (QRptr) &QRgstr[QIndex+36];	/* else use main level ones */
	}
    } else {
        QR = &QRgstr[QIndex];
    }

#if DEBUGGING
    sprintf(DbgSBf,"SUCCESS, %sQIndex = %d (QName = '%c')",
	    (LocalQ) ? "local " : "", QIndex, QName);
    DBGFEX(3,DbgFNm,DbgSBf);
#endif
    return SUCCESS;
}
예제 #7
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;
}
예제 #8
0
파일: exei.c 프로젝트: shinmai-rookie/tecoc
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;
}
예제 #9
0
파일: exex.c 프로젝트: shinmai-rookie/tecoc
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;
}