static DEFAULT SkpCtU() /* skip control-U command */ { BOOLEAN TTrace; /* temp: holds trace flag */ if (CBfPtr == CStEnd) if (MStTop < 0) /* if not in a macro */ { ErrUTC(); /* unterminated command */ return FAILURE; } else return SUCCESS; ++CBfPtr; TTrace = TraceM; /* save trace mode flag */ TraceM = FALSE; /* keep FindES from tracing */ if (FindES(ESCAPE) == FAILURE) /* find end of string */ { TraceM = TTrace; /* restore trace mode flag */ return FAILURE; } TraceM = TTrace; /* restore trace mode flag */ CmdMod = '\0'; /* clear modifiers flags */ return SUCCESS; }
/***************************************************************************** SkpDAr() *****************************************************************************/ static DEFAULT SkpDAr() /* skip "double text argument" command */ { BOOLEAN TTrace; /* saves TraceM temporarily */ TTrace = TraceM; /* save trace mode flag */ TraceM = FALSE; /* keep FindES from tracing */ if (FindES(ESCAPE) == FAILURE) { TraceM = TTrace; /* restore trace mode flag */ return FAILURE; } if (CmdMod & ATSIGN) /* if at-sign modified */ --CBfPtr; if (FindES(ESCAPE) == FAILURE) { TraceM = TTrace; /* restore trace mode flag */ return FAILURE; } TraceM = TTrace; /* restore trace mode flag */ return SUCCESS; }
/***************************************************************************** SkpCtA() *****************************************************************************/ static DEFAULT SkpCtA() /* skip control-A command */ { BOOLEAN TTrace; /* temp: holds trace flag */ TTrace = TraceM; /* save trace mode flag */ TraceM = FALSE; /* keep FindES from tracing */ if (FindES(CTRL_A) == FAILURE) /* find end of string */ { TraceM = TTrace; /* restore trace mode flag */ return FAILURE; } TraceM = TTrace; /* restore trace mode flag */ CmdMod = '\0'; /* clear modifiers flags */ return SUCCESS; }
/***************************************************************************** SkpArg() *****************************************************************************/ static DEFAULT SkpArg() /* skip command with text argument */ { BOOLEAN TTrace; /* temp: holds trace flag */ TTrace = TraceM; /* save trace mode flag */ TraceM = FALSE; /* keep FindES from tracing */ if (FindES(ESCAPE) == FAILURE) /* find end of string */ { TraceM = TTrace; /* restore trace mode flag */ return FAILURE; } TraceM = TTrace; /* restore trace mode flag */ CmdMod = '\0'; /* clear modifiers flags */ return SUCCESS; }
integer ExeExc() /* execute a ! (exclamation mark) command */ { DBGFEN(1,"ExeExc",NULL); if (FindES('!') == FAILURE) { /* simply skip to next '!' */ DBGFEX(1,DbgFNm,"FAILURE"); return FAILURE; } CmdMod = '\0'; /* clear modifiers flags */ EStTop = EStBot; /* clear expression stack */ DBGFEX(1,DbgFNm,"SUCCESS"); return SUCCESS; }
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; }
integer ExeS() /* execute an S command */ { DBGFEN(1, "ExeS", NULL); /* * The command m,nS is illegal: the user should use m,nFB */ if (CmdMod & MARGIS) { /* if it's m,nS */ ErrStr(ERR_ILL, "m,nS"); /* illegal command "m,nS" */ DBGFEX(1,DbgFNm,"FAILURE"); return FAILURE; } /* * If it's ::Stext$, 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 ::Stext$ command is * equivalent to a .,.+1:FBtext$ command, so that's the way it's implemented. */ if (CmdMod & DCOLON) { /* if it's ::S */ if (CmdMod & MARGIS) { /* if it's m,n::S */ ErrStr(ERR_ILL, "m,n::S"); DBGFEX(1,DbgFNm,"FAILURE"); return FAILURE; } if (EStTop > EStBot) { /* if it's n::S */ ErrStr(ERR_ILL, "n::S"); DBGFEX(1,DbgFNm,"FAILURE"); return FAILURE; } if (GapEnd == EBfEnd) { /* if nothing to search */ if (FindES(ESCAPE) == FAILURE) { DBGFEX(1,DbgFNm,"FAILURE"); return FAILURE; } 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"); return FAILURE; } DBGFEX(1,DbgFNm,"ExeFB()"); return ExeFB(); /* execute FB command */ } SrcTyp = S_SEARCH; if (Search(false) == FAILURE) { DBGFEX(1,DbgFNm,"FAILURE"); return FAILURE; } CmdMod = '\0'; /* clear modifiers flags */ DBGFEX(1,DbgFNm,"SUCCESS"); return SUCCESS; }
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; }
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; }