1 /*****************************************************************************
2
3 ExeG()
4
5 This function executes a G command.
6 Gq Get string from Q-register q into buffer
7 G* Get last filespec string into buffer
8 G_ Get last search string into buffer
9 :Gq Type Q-register q on terminal
10
11 *****************************************************************************/
12
13 #include "zport.h" /* define portability identifiers */
14 #include "tecoc.h" /* define general identifiers */
15 #include "defext.h" /* define external global variables */
16 #include "deferr.h" /* define identifiers for error messages */
17
ExeG()18 DEFAULT ExeG() /* execute a G command */
19 {
20 charptr TxtBeg; /* beginning of a text area */
21 charptr TxtEnd; /* end of a text area */
22
23 DBGFEN(1,"ExeG",NULL);
24 if (IncCBP() == FAILURE) { /* move to char after G */
25 DBGFEX(1,DbgFNm,"FAILURE");
26 return FAILURE;
27 }
28
29 if (*CBfPtr == '*') { /* if it's G* */
30 TxtBeg = FBfBeg;
31 TxtEnd = FBfPtr;
32 } else if (*CBfPtr == '_') { /* else if it's G_ */
33 TxtBeg = SBfBeg;
34 TxtEnd = SBfPtr;
35 } else { /* else it's Gq */
36 if (FindQR() == FAILURE) {
37 return FAILURE;
38 }
39 if (QR->Start == NULL) { /* if empty */
40 RefLen = 0;
41 CmdMod = '\0'; /* clear modifiers flags */
42 EStTop = EStBot; /* clear expression stack */
43 DBGFEX(1,DbgFNm,"SUCCESS, Q-register empty");
44 return SUCCESS;
45 }
46 TxtBeg = QR->Start;
47 TxtEnd = QR->End_P1;
48 }
49
50 if (CmdMod & COLON) { /* if it's :G */
51 TypBuf(TxtBeg, TxtEnd);
52 } else { /* else (no : modifier) */
53 if (InsStr(TxtBeg, TxtEnd-TxtBeg) == FAILURE) {
54 DBGFEX(1,DbgFNm,"FAILURE");
55 return FAILURE;
56 }
57 }
58 CmdMod = '\0'; /* clear modifiers flags */
59 EStTop = EStBot; /* clear expression stack */
60
61 DBGFEX(1,DbgFNm,"SUCCESS");
62 return SUCCESS;
63 }
64