1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
|
char *tecexec_c_version = "tecexec.c: $Revision: 1.3 $";
/*
* $Date: 2007/12/26 13:28:30 $
* $Source: /cvsroot/videoteco/videoteco/tecexec.c,v $
* $Revision: 1.3 $
* $Locker: $
*/
/* tecexec.c
* The SWITCH/CASE statements which implement execution stage of the parser
*
*
* Copyright (C) 1985-2007 BY Paul Cantrell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "teco.h"
#include "tecparse.h"
extern struct cmd_token *jump_to_token;
extern struct cmd_token *last_token_executed;
extern struct cmd_token *last_cmd_list;
extern struct search_buff search_string;
extern char user_message[PARSER_STRING_MAX];
extern char exit_flag;
extern struct window *window_list;
extern struct buff_header *curbuf,*buffer_headers;
extern struct buff_header *qregister_push_down_list;
extern int last_search_pos1,last_search_pos2;
extern int last_search_status;
extern int remembered_dot;
extern char intr_flag;
extern char immediate_execute_flag;
extern struct window *curwin;
int find_conditional_else(struct cmd_token *);
int find_conditional_end(struct cmd_token *);
int compare_label(struct cmd_token *,struct cmd_token *);
void extract_label(struct cmd_token *,char *);
struct wildcard_expansion *expand_filename( char *wildcard_string );
/* EXECUTE_A_STATE - Do the runtime execution part of a command
*
* Function:
*
* This routine is called to execute the runtime part of a command token.
* This could be during immediate execution mode, directly after a token
* gets parsed, or it could be during final stages when we are either
* running commands which cannot be undone (like ex), or simply complex
* things like an iteration. The execute_state which we dispatch on was
* set by the parse state during syntax analysis.
*/
int
execute_a_state( struct cmd_token *ct, struct cmd_token *uct )
{
register struct undo_token *ut;
char tmp_buffer[LINE_BUFFER_SIZE],tmp_message[LINE_BUFFER_SIZE];
PREAMBLE();
last_token_executed = ct;
switch(ct->execute_state){
/*
* Here to return the numeric value of a q-register. This has to be done
* at run time because the value of the q-register might be modified during
* the course of the command. Note that we return an error if the q-register
* has never been loaded. Otherwise, we return the value in tmpval so that
* it can be the input to further arithmetic expressions.
*/
case EXEC_C_QVALUE:
{/* Local Block */
register struct buff_header *hbp;
if(ct->q_register == '*'){
ct->ctx.tmpval = curbuf->buffer_number;
return(SUCCESS);
}/* End IF */
hbp = buff_qfind(ct->q_register,0);
if(hbp == NULL){
sprintf(tmp_message,"?Q-register %c empty",ct->q_register);
error_message(tmp_message);
return(FAIL);
}/* End IF */
ct->ctx.tmpval = hbp->ivalue;
return(SUCCESS);
}/* End Local Block */
/*
* Here to return the numeric value of a q-register and also increment it's
* value. Other than the incrementing, this is exactly like the QVALUE state.
*/
case EXEC_C_PERCENT_VALUE:
{/* Local Block */
register struct buff_header *hbp;
hbp = buff_qfind(ct->q_register,0);
if(hbp == NULL){
sprintf(tmp_message,"?Q-register %c empty",ct->q_register);
error_message(tmp_message);
return(FAIL);
}/* End IF */
/*
* Set up an undo block so that we can put the previous value back into
* the q-register if this command gets undone.
*/
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_UQREGISTER;
ut->iarg1 = ct->q_register;
ut->iarg2 = hbp->ivalue;
hbp->ivalue += ct->ctx.tmpval;
ct->ctx.tmpval = hbp->ivalue;
return(SUCCESS);
}/* End Local Block */
/*
* Here to read a file into a q-register. We also set up undo tokens to
* restore the previous contents of the q-register if he undoes this.
*/
case EXEC_C_EQQREGISTER:
{/* Local Block */
register struct buff_header *qbp;
struct wildcard_expansion *name_list,*np;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEBUFF;
ut->iarg1 = curbuf->buffer_number;
qbp = buff_qfind(ct->ctx.tmpval,1);
if(ct->ctx.tmpval == '*'){
if(ct->ctx.carg){
rename_edit_buffer(curbuf,ct->ctx.carg,uct);
}/* End IF */
else {
load_qname_register();
buff_switch(qbp,1);
}/* End Else */
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = SUCCESS;
}/* End IF */
return(SUCCESS);
}/* End IF */
if(ct->ctx.carg == NULL || ct->ctx.carg[0] == '\0'){
buff_switch(qbp,1);
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = SUCCESS;
}/* End IF */
return(SUCCESS);
}/* End IF */
/*
* Delete the previous contents of the q-register, but allow it to be
* reconstructed if this gets undone. Note that we don't have to do
* this if there was nothing there. Also, if the colon modifier was
* specified, then we append to the buffer instead of replacing it.
*/
if((ct->ctx.flags & CTOK_M_COLON_SEEN) == 0 && qbp->zee){
buff_delete_with_undo(uct,qbp,0,qbp->zee);
}/* End IF */
/*
* Set up an undo argument to delete any characters which get inserted as
* part of the buff_read we do to load the q-register.
*/
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_DELETE;
ut->carg1 = (char *)qbp;
ut->iarg1 = qbp->dot;
ut->iarg2 = qbp->zee;
np = expand_filename(ct->ctx.carg);
if(np == NULL){
sprintf(tmp_message,"EQ No such file <%s>",ct->ctx.carg);
error_message(tmp_message);
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
return(FAIL);
}/* End IF */
while(np){
buff_read(qbp,np->we_name);
name_list = np;
np = np->we_next;
tec_release(TYPE_C_WILD,(char *)name_list);
}/* End While */
ut->iarg2 = qbp->zee - ut->iarg2;
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = SUCCESS;
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to load a q-register with a numeric value. Note that not only do we
* have to put the new number into it, we also have to set up the undo token
* so that if this command is backed out of we can restore the previous value
* to the q-register.
*/
case EXEC_C_UQREGISTER:
{/* Local Block */
register struct buff_header *hbp;
/*
* Find the q-register. If it does not exist yet, create it.
*/
hbp = buff_qfind(ct->q_register,1);
if(hbp == NULL){
return(FAIL);
}/* End IF */
/*
* Insure that we have an argument to store
*/
if(ct->ctx.iarg1_flag == NO){
error_message("?Argument required for U command");
return(FAIL);
}/* End IF */
/*
* Set up an undo block so that we can put the previous value back into
* the q-register if this command gets undone.
*/
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_UQREGISTER;
ut->iarg1 = ct->q_register;
ut->iarg2 = hbp->ivalue;
hbp->ivalue = ct->ctx.iarg1;
return(SUCCESS);
}/* End Local Block */
/*
* Here to load the text contents of the specified q-register into the
* edit buffer at the current location.
*/
case EXEC_C_GQREGISTER:
{/* Local Block */
register struct buff_header *hbp;
register struct buff_header *qbp;
hbp = curbuf;
/*
* If this is the buffer name q-register, we have to do some special
* stuff.
*/
if(ct->q_register == '*') load_qname_register();
/*
* Get a pointer to the q-register buffer structure. If it doesn't
* exist, declare an error.
*/
qbp = buff_qfind(ct->q_register,0);
if(qbp == NULL){
sprintf(tmp_message,"?Q-register <%c> does not exist",
ct->q_register);
error_message(tmp_message);
return(FAIL);
}/* End IF */
/*
* Test if the q-register is empty, and declare an error if it is
*/
if(qbp->zee == 0){
sprintf(tmp_message,"?Q-register <%c> is empty",
ct->q_register);
error_message(tmp_message);
return(FAIL);
}/* End IF */
/*
* Make sure the Q register and the edit buffer are not the same buffer
*/
if(qbp == hbp){
strcpy(tmp_message,
"?Cannot use G to copy from a Q-register to itself");
error_message(tmp_message);
return(FAIL);
}/* End IF */
/*
* Now copy the text out of the q-register and insert it into the edit buffer
*/
buff_insert_from_buffer_with_undo(uct,hbp,hbp->dot,qbp,0,qbp->zee);
return(SUCCESS);
}/* End Local Block */
/*
* Here to execute the macro in the specified Q register
*/
case EXEC_C_MQREGISTER:
{/* Local Block */
register struct buff_header *qbp;
/*
* Get a pointer to the q-register buffer structure. If it doesn't
* exist, declare an error.
*/
qbp = buff_qfind(ct->q_register,0);
if(qbp == NULL){
sprintf(tmp_message,"?Q-register <%c> does not exist",
ct->q_register);
error_message(tmp_message);
return(FAIL);
}/* End IF */
/*
* It's an error if the q-register is empty
*/
if(qbp->zee == 0){
sprintf(tmp_message,"?Q-register <%c> is empty",
ct->q_register);
error_message(tmp_message);
return(FAIL);
}/* End IF */
/*
* Set up the undo block, and pass its address to the tecmacro routine so
* that the tecmacro can chain the command list off of it.
*/
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_MACRO;
ut->carg1 = NULL;
return(tecmacro(qbp,ct,(struct cmd_token **)&ut->carg1));
}/* End Local Block */
/*
* Here to load text into a q-register in response to the X command.
* This clears any existing text from the q-register, and then copies
* the specified text into it.
*/
case EXEC_C_XQREGISTER:
{/* Local Block */
register struct buff_header *hbp;
register struct buff_header *qbp;
register struct buff_line *lbp;
register int i,j;
int pos1,pos2;
hbp = curbuf;
/*
* Get a pointer to the q-register buffer structure. If it doesn't
* exist, create it.
*/
qbp = buff_qfind(ct->q_register,1);
if(qbp == NULL){
return(FAIL);
}/* End IF */
/*
* Make sure the Q register and the edit buffer are not the same buffer
*/
if(qbp == hbp){
strcpy(tmp_message,
"?Cannot use X to copy from a Q-register to itself");
error_message(tmp_message);
return(FAIL);
}/* End IF */
/*
* If two arguments were specified, then he has specified an a,b range to
* be copied.
*/
if(ct->ctx.iarg1_flag == YES && ct->ctx.iarg2_flag == YES){
pos1 = ct->ctx.iarg1;
pos2 = ct->ctx.iarg2;
if(parse_illegal_buffer_position(pos1,pos2,"X")){
return(FAIL);
}/* End IF */
if(pos2 < pos1){
pos2 = ct->ctx.iarg1;
pos1 = ct->ctx.iarg2;
}/* End IF */
}/* End IF */
/*
* Else, if it was a single command, it is a relative copy which affects a
* portion of the buffer in a similar way as if it was an L command. Our job
* now is to turn it into a a,b range.
*/
else {
lbp = buff_find_line(hbp,hbp->dot);
if(lbp == NULL) return(FAIL);
/*
* Start by pretending it was a 0L command, and get to the begining of
* the line. That allows us to not worry about offset onto current line.
*/
j = 0 - buff_find_offset(hbp,lbp,hbp->dot);
i = ct->ctx.iarg1;
if(ct->ctx.iarg1_flag == NO) i = 1;
/*
* If argument is positive, movement is forward
*/
if(i > 0){
while(i-- && lbp){
j += lbp->byte_count;
lbp = lbp->next_line;
}/* End WHILE */
if(lbp == NULL){
error_message("?Attempt to Move Pointer Off Page with X");
return(FAIL);
}/* End IF */
pos1 = hbp->dot;
pos2 = hbp->dot + j;
}/* End IF */
/*
* Else, it is backwards
*/
else {
while(i++ && lbp){
lbp = lbp->prev_line;
if(lbp == NULL){
error_message("?Attempt to Move Pointer Off Page with X");
return(FAIL);
}/* End IF */
j -= lbp->byte_count;
}/* End WHILE */
pos1 = hbp->dot + j;
pos2 = hbp->dot;
}/* End Else */
}/* End Else */
/*
* Now that we have calculated the buffer positions to be used by the command,
* we can actually do the work.
*/
j = pos2 - pos1;
/*
* Delete the previous contents of the q-register, but allow it to be
* reconstructed if this gets undone. Note that we don't have to do
* this if there was nothing there. Also, if the colon modifier was
* specified, then we append to the buffer instead of replacing it.
*/
if((ct->ctx.flags & CTOK_M_COLON_SEEN) == 0 && qbp->zee){
buff_delete_with_undo(uct,qbp,0,qbp->zee);
}/* End IF */
/*
* Now copy the new text from the edit buffer into the q-register
*/
buff_insert_from_buffer_with_undo(uct,qbp,qbp->zee,hbp,pos1,j);
/*
* If the q-register specified is '*', then the actual result is to rename
* the current buffer.
*/
if(ct->q_register == '*'){
rename_edit_buffer(hbp,qbp->name,uct);
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to load text into a q-register in response to the * command.
* This clears any existing text from the q-register, and then copies
* the previous command string into it.
*/
case EXEC_C_SAVECOMMAND:
{/* Local Block */
register struct buff_header *qbp;
register struct cmd_token *oct;
register int i;
/*
* Get a pointer to the q-register buffer structure. If it doesn't
* exist, create it.
*/
qbp = buff_qfind(ct->q_register,1);
if(qbp == NULL){
return(FAIL);
}/* End IF */
/*
* Delete the previous contents of the q-register, but allow it to be
* reconstructed if this gets undone. Note that we don't have to do
* this if there was nothing there.
*/
if(qbp->zee) buff_delete_with_undo(uct,qbp,0,qbp->zee);
/*
* Set up an undo token to delete the contents of the q-register that we
* are about to load.
*/
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_DELETE;
ut->carg1 = (char *)qbp;
ut->iarg1 = 0;
ut->iarg2 = 0;
/*
* Now we go through the last command list and anytime we see an input
* byte, we copy it into the q-register.
*/
oct = last_cmd_list;
i = 0;
while(oct){
if(oct->flags & TOK_M_EAT_TOKEN){
buff_insert_char(qbp,i++,oct->input_byte);
ut->iarg2 += 1;
}/* End IF */
oct = oct->next_token;
}/* End While */
return(SUCCESS);
}/* End Local Block */
/*
* Here to push the specified q-register onto the q-register stack
*/
case EXEC_C_PUSH_QREGISTER:
if(ct->q_register == '*') load_qname_register();
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
if(push_qregister(ct->q_register) != SUCCESS) return(FAIL);
ut->opcode = UNDO_C_POP;
return(SUCCESS);
/*
* Here to pop a Q register off of the stack and replace a Q register
* with it. Since this destroys the Q register we pop onto, we first
* must save the entire Q register.
*/
case EXEC_C_POP_QREGISTER:
{/* Local Block */
register struct buff_header *pbp;
register struct buff_header *qbp;
/*
* Get a pointer to the pushed buffer structure. If there are none on
* the stack, then he has tried to pop too many, and this is an error.
*/
pbp = qregister_push_down_list;
if(pbp == NULL){
error_message("?Q-register push down list is empty");
return(FAIL);
}/* End IF */
/*
* Get a pointer to the q-register buffer structure. If it doesn't
* exist, create it.
*/
qbp = buff_qfind(ct->q_register,1);
if(qbp == NULL){
return(FAIL);
}/* End IF */
/*
* Arrange to restore the numeric contents of the Q register if this
* should be undone.
*/
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_UQREGISTER;
ut->iarg1 = ct->q_register;
ut->iarg2 = qbp->ivalue;
qbp->ivalue = pbp->ivalue;
/*
* Delete the previous contents of the q-register, but allow it to be
* reconstructed if this gets undone. Note that we don't have to do
* this if there was nothing there.
*/
if(qbp->zee){
if(buff_delete_with_undo(uct,qbp,0,qbp->zee) == FAIL){
return(FAIL);
}/* End IF */
}/* End IF */
/*
* Arrange for it to be deleted if this gets undone.
*/
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_DELETE;
ut->carg1 = (char *)qbp;
ut->iarg1 = 0;
ut->iarg2 = pbp->zee;
/*
* Transfer the contents of the pushed register into the actual Q register
*/
buff_bulk_insert(qbp,0,pbp->zee,pbp->first_line);
pbp->first_line = NULL;
qbp->pos_cache.lbp = NULL;
qbp->pos_cache.base = 0;
/*
* Arrange that the push be re-done if the pop is undone.
*/
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_PUSH;
ut->iarg1 = ct->q_register;
/*
* Place it on the main buffer list so that buff_destroy can find it
*/
qregister_push_down_list = pbp->next_header;
pbp->next_header = buffer_headers;
buffer_headers = pbp;
buff_destroy(pbp);
/*
* If the q-register specified is '*', then the actual result is to rename
* the current buffer.
*/
if(ct->q_register == '*'){
rename_edit_buffer(curbuf,qbp->name,uct);
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to return the current position of 'dot'
*/
case EXEC_C_DOTVALUE:
ct->ctx.tmpval = curbuf->dot;
return(SUCCESS);
/*
* Here to return the number of bytes in the edit buffer
*/
case EXEC_C_ZEEVALUE:
ct->ctx.tmpval = curbuf->zee;
return(SUCCESS);
/*
* Here to return the value 0,Z which H is shorthand for
*/
case EXEC_C_HVALUE:
ct->ctx.iarg1 = 0;
ct->ctx.iarg2 = curbuf->zee;
return(SUCCESS);
/*
* Print out the numeric value of an expression
*/
case EXEC_C_EQUALS:
if(ct->ctx.iarg1_flag == NO){
error_message("?Argument required for = command");
return(FAIL);
}/* End IF */
sprintf(tmp_buffer,"value = %d",ct->ctx.iarg1);
screen_message(tmp_buffer);
return(SUCCESS);
case EXEC_C_TWO_EQUALS:
sprintf(tmp_buffer,"value = 0%o",ct->ctx.iarg1);
screen_message(tmp_buffer);
return(SUCCESS);
case EXEC_C_THREE_EQUALS:
sprintf(tmp_buffer,"value = 0x%X",ct->ctx.iarg1);
screen_message(tmp_buffer);
return(SUCCESS);
/*
* Here to insert the value of the expression into the edit buffer as a
* decimal representation.
*/
case EXEC_C_BACKSLASH:
{/* Local Block */
register int i,j;
char *cp;
int length = 0;
if(ct->ctx.iarg2 < 2 || ct->ctx.iarg2 > 36) ct->ctx.iarg2 = 10;
j = ct->ctx.iarg1;
cp = tmp_buffer + sizeof(tmp_buffer);
do {
i = j % ct->ctx.iarg2;
j = (j - i) / ct->ctx.iarg2;
if(i > 9) i += ('A' - 10);
else i += '0';
*(--cp) = i;
length += 1;
} while(j);
buff_insert_with_undo(uct,curbuf,curbuf->dot,cp,length);
return(SUCCESS);
}/* End Local Block */
/*
* Here to interpret the ascii digits following 'dot' in the edit buffer
* as a decimal number, and return this number as the value of this expression,
* leaving 'dot' positioned after the digits.
*/
case EXEC_C_BACKSLASHARG:
{/* Local Block */
register int i;
register int radix;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
radix = ct->ctx.tmpval;
ct->ctx.tmpval = 0;
for(;;){
i = buff_contents(curbuf,curbuf->dot);
if(i >= '0' && i <= '9') i -= '0';
else if(i >= 'a' && i <= 'z') i -= ('a' - 10);
else if(i >= 'A' && i <= 'Z') i -= ('A' - 10);
else break;
if(i < 0 || i >= radix) break;
ct->ctx.tmpval = ct->ctx.tmpval * radix + i;
if(curbuf->dot == curbuf->zee) break;
curbuf->dot++;
}/* End FOR */
return(SUCCESS);
}/* End Local Block */
/*
* The poor bastard wants to leave...
*/
case EXEC_C_EXITCOMMAND:
{/* Local Block */
register struct buff_header *hbp;
if(ct->ctx.iarg1_flag == NO || ct->ctx.iarg1 != -1){
for(hbp = buffer_headers; hbp != NULL; hbp = hbp->next_header){
if(hbp->buffer_number <= 0) continue;
if(hbp->ismodified != 0 && hbp->isreadonly == 0){
error_message("?Modified buffers exist");
return(FAIL);
}/* End IF */
}/* End FOR */
}/* End IF */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_SET_EXIT_FLAG;
exit_flag = YES;
return(SUCCESS);
}/* End Local Block */
/*
* Here to jump to an absolute position in the buffer
*/
case EXEC_C_JUMP:
if(ct->ctx.iarg1_flag == YES && ct->ctx.iarg1 < 0){
error_message("?Negative Argument to J");
return(FAIL);
}/* End IF */
if(ct->ctx.iarg1_flag == NO) ct->ctx.iarg1 = 0;
if(parse_illegal_buffer_position(ct->ctx.iarg1,0,"J")){
return(FAIL);
}/* End IF */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
if(ct->ctx.iarg1_flag == NO) curbuf->dot = 0;
else curbuf->dot = ct->ctx.iarg1;
return(SUCCESS);
/*
* Here to move dot by a relative number of buffer positions
*/
case EXEC_C_CHAR:
{/* Local Block */
register int i;
i = curbuf->dot + 1;
if(ct->ctx.iarg1_flag == YES){
i = curbuf->dot + ct->ctx.iarg1;
}/* End IF */
if(parse_illegal_buffer_position(i,0,"C")) return(FAIL);
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
curbuf->dot = i;
return(SUCCESS);
}/* End Local Block */
/*
* Here to move dot by a relative number of buffer positions, just like
* the "C" command, except that the direction is by default backwards.
*/
case EXEC_C_RCHAR:
{/* Local Block */
register int i;
i = curbuf->dot - 1;
if(ct->ctx.iarg1_flag == YES){
i = curbuf->dot - ct->ctx.iarg1;
}/* End IF */
if(parse_illegal_buffer_position(i,0,"R")) return(FAIL);
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
curbuf->dot = i;
return(SUCCESS);
}/* End Local Block */
/*
* Here to delete the specified number of characters following 'dot'.
* A negative value indicates we should delete characters BEFORE 'dot'.
*/
case EXEC_C_DELETE:
{/* Local Block */
register int i;
i = 1;
if(ct->ctx.iarg1_flag == YES) i = ct->ctx.iarg1;
if(parse_illegal_buffer_position(curbuf->dot+i,0,"D")){
return(FAIL);
}/* End IF */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
if(i < 0){
i = 0 - i;
curbuf->dot -= i;
}/* End IF */
/*
* Call the standard routine which deletes the specified buffer positions
* and constructs the undo list so that it can be rebuilt if necessary.
*/
if(i) buff_delete_with_undo(uct,curbuf,curbuf->dot,i);
return(SUCCESS);
}/* End Local Block */
/*
* Here to move 'dot' by the specified number of words. Note that words
* can have a pretty nebulous definition, depending on what you are doing.
* This should probably have a q-register which contains all of the delimeters.
*/
case EXEC_C_WORD:
{/* Local Block */
register int count;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
count = ct->ctx.iarg1;
if(ct->ctx.iarg1_flag == NO) count = 1;
cmd_wordmove(count);
return(SUCCESS);
}/* End Local Block */
/*
* Here to delete the specified number of words. Note that words
* can have a pretty nebulous definition, depending on what you are doing.
* This should probably have a q-register which contains all of the delimeters.
*/
case EXEC_C_DELWORD:
{/* Local Block */
register int count;
int original_position;
int pos;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = original_position = curbuf->dot;
count = ct->ctx.iarg1;
if(ct->ctx.iarg1_flag == NO) count = 1;
cmd_wordmove(count);
pos = original_position;
count = curbuf->dot - original_position;
if(count < 0){
count = 0 - count;
pos = curbuf->dot;
}/* End IF */
if(count) buff_delete_with_undo(uct,curbuf,pos,count);
return(SUCCESS);
}/* End Local Block */
/*
* Here to delete backward the specified number of words. Note that
* words can have a pretty nebulous definition, depending on what you are
* doing. This should probably have a q-register which contains all of the
* delimeters.
*/
case EXEC_C_RDELWORD:
{/* Local Block */
register int count;
int original_position;
int pos;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = original_position = curbuf->dot;
count = 0 - ct->ctx.iarg1;
if(ct->ctx.iarg1_flag == NO) count = -1;
cmd_wordmove(count);
pos = original_position;
count = curbuf->dot - original_position;
if(count < 0){
count = 0 - count;
pos = curbuf->dot;
}/* End IF */
if(count) buff_delete_with_undo(uct,curbuf,pos,count);
return(SUCCESS);
}/* End Local Block */
/*
* Here to move the 'dot' by the specified number of lines.
*/
case EXEC_C_LINE:
{/* Local Block */
register struct buff_header *hbp;
register struct buff_line *lbp;
register int i,j;
hbp = curbuf;
lbp = buff_find_line(hbp,hbp->dot);
/*
* Start by pretending it was a 0L command, and get to the begining of
* the line. That allows us to not worry about offset onto current line.
*/
j = 0 - buff_find_offset(hbp,lbp,hbp->dot);
i = ct->ctx.iarg1;
if(ct->ctx.iarg1_flag == NO) i = 1;
/*
* If argument is positive, movement is forward
*/
if(i > 0){
while(i-- && lbp){
j += lbp->byte_count;
lbp = lbp->next_line;
}/* End WHILE */
if(lbp == NULL){
error_message("?Attempt to Move Pointer Off Page with L");
return(FAIL);
}/* End IF */
}/* End IF */
else {
while(i++ && lbp){
lbp = lbp->prev_line;
if(lbp == NULL){
error_message("?Attempt to Move Pointer Off Page with L");
return(FAIL);
}/* End IF */
j -= lbp->byte_count;
}/* End WHILE */
}/* End Else */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = hbp->dot;
hbp->dot += j;
return(SUCCESS);
}/* End Local Block */
/*
* Here to move the 'dot' backward by the specified number of lines.
*/
case EXEC_C_RLINE:
{/* Local Block */
register struct buff_header *hbp;
register struct buff_line *lbp;
register int i,j;
hbp = curbuf;
lbp = buff_find_line(hbp,hbp->dot);
/*
* Start by pretending it was a 0L command, and get to the begining of
* the line. That allows us to not worry about offset onto current line.
*/
j = 0 - buff_find_offset(hbp,lbp,hbp->dot);
i = 0 - ct->ctx.iarg1;
if(ct->ctx.iarg1_flag == NO) i = -1;
/*
* If argument is positive, movement is forward
*/
if(i > 0){
while(i-- && lbp){
j += lbp->byte_count;
lbp = lbp->next_line;
}/* End WHILE */
if(lbp == NULL){
error_message("?Attempt to Move Pointer Off Page with B");
return(FAIL);
}/* End IF */
}/* End IF */
else {
while(i++ && lbp){
lbp = lbp->prev_line;
if(lbp == NULL){
error_message("?Attempt to Move Pointer Off Page with B");
return(FAIL);
}/* End IF */
j -= lbp->byte_count;
}/* End WHILE */
}/* End Else */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = hbp->dot;
hbp->dot += j;
return(SUCCESS);
}/* End Local Block */
/*
* Here to kill the specified number of lines.
*/
case EXEC_C_KILL:
{/* Local Block */
register struct buff_header *hbp;
register struct buff_line *lbp;
register int i,j;
int pos1,pos2;
hbp = curbuf;
/*
* If two arguments were specified, then he has specified an a,b range to
* be killed.
*/
if(ct->ctx.iarg1_flag == YES && ct->ctx.iarg2_flag == YES){
pos1 = ct->ctx.iarg1;
pos2 = ct->ctx.iarg2;
if(parse_illegal_buffer_position(pos1,pos2,"K")){
return(FAIL);
}/* End IF */
if(pos2 < pos1){
pos2 = ct->ctx.iarg1;
pos1 = ct->ctx.iarg2;
}/* End IF */
}/* End IF */
/*
* Else, if it was a single command, it is a relative kill which affects a
* portion of the buffer in a similar way as if it was an L command. Our job
* now is to turn it into a a,b range.
*/
else {
lbp = buff_find_line(hbp,hbp->dot);
/*
* Start by pretending it was a 0L command, and get to the begining of
* the line. That allows us to not worry about offset onto current line.
*/
j = 0 - buff_find_offset(hbp,lbp,hbp->dot);
i = ct->ctx.iarg1;
if(ct->ctx.iarg1_flag == NO) i = 1;
/*
* If argument is positive, movement is forward
*/
if(i > 0){
while(i-- && lbp){
j += lbp->byte_count;
lbp = lbp->next_line;
}/* End WHILE */
if(lbp == NULL){
error_message("?Attempt to Move Pointer Off Page with K");
return(FAIL);
}/* End IF */
pos1 = hbp->dot;
pos2 = hbp->dot + j;
}/* End IF */
else {
while(i++ && lbp){
lbp = lbp->prev_line;
if(lbp == NULL){
error_message("?Attempt to Move Pointer Off Page with K");
return(FAIL);
}/* End IF */
j -= lbp->byte_count;
}/* End WHILE */
pos1 = hbp->dot + j;
pos2 = hbp->dot;
}/* End Else */
}/* End Else */
j = pos2 - pos1;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = hbp->dot;
/*
* Call the standard routine which deletes the specified buffer positions
* and constructs the undo list so that it can be rebuilt if necessary.
*/
if(j) buff_delete_with_undo(uct,hbp,pos1,j);
return(SUCCESS);
}/* End Local Block */
/*
* Here to insert a character as part of an insert command
*/
case EXEC_C_INSERT:
buff_insert_char_with_undo(
uct,
curbuf,
curbuf->dot,
ct->ctx.iarg1_flag ? ct->ctx.iarg1 : ct->input_byte
);
return(SUCCESS);
/*
* This state is used when a subroutine state is trying to return a
* value to the calling state. It gets specially noticed by the parser,
* so it really doesn't do much except act as a flag.
*/
case EXEC_C_STOREVAL:
return(SUCCESS);
/*
* Store the current expression value as the first argument to a command
*/
case EXEC_C_STORE1:
ct->ctx.iarg1 = ct->ctx.tmpval;
return(SUCCESS);
/*
* Store the current expression value as the second argument to a command
*/
case EXEC_C_STORE2:
ct->ctx.iarg2 = ct->ctx.tmpval;
return(SUCCESS);
/*
* Here when we have a leading minus sign in an expression such as -3+4
*/
case EXEC_C_UMINUS:
ct->ctx.tmpval = 0 - ct->ctx.tmpval;
return(SUCCESS);
/*
* Here to add the two parts of the expression to produce a new temporary
* value.
*/
case EXEC_C_PLUS:
ct->ctx.tmpval = ct->ctx.iarg2 + ct->ctx.tmpval;
return(SUCCESS);
/*
* Here to subtract the two parts of the expression to produce a new temporary
* value.
*/
case EXEC_C_MINUS:
ct->ctx.tmpval = ct->ctx.iarg2 - ct->ctx.tmpval;
return(SUCCESS);
/*
* Here to multiply the two parts of the expression to produce a new temporary
* value.
*/
case EXEC_C_TIMES:
ct->ctx.tmpval = ct->ctx.iarg1 * ct->ctx.tmpval;
return(SUCCESS);
/*
* Here to divide the two parts of the expression to produce a new temporary
* value.
*/
case EXEC_C_DIVIDE:
if(ct->ctx.tmpval == 0){
error_message("?Attempt to Divide by Zero");
return(FAIL);
}/* End IF */
ct->ctx.tmpval = ct->ctx.iarg1 / ct->ctx.tmpval;
return(SUCCESS);
/*
* Here in response to the "A" command which returns as a value the ASCII
* value of the character at 'dot' + offset.
*/
case EXEC_C_ACOMMAND:
{/* Local Block */
register int i;
i = curbuf->dot + ct->ctx.tmpval;
if(parse_illegal_buffer_position(i,i+1,"A")){
return(FAIL);
}/* End IF */
ct->ctx.tmpval = buff_contents(curbuf,i);
return(SUCCESS);
}/* End Local Block */
/*
* Here to cause a repaint of the screen incase it got messed up by
* something
*/
case EXEC_C_REDRAW_SCREEN:
screen_redraw();
return(SUCCESS);
/*
* Here to search for a given string. This gets used not only in the
* "S" command, but as a substate in any command which requires searching
* for a string (such as FD, FK, FS, FR, etc.)
*/
case EXEC_C_SEARCH:
{/* Local Block */
int arg1,arg2;
#if 0
struct buff_header *qbp;
#endif
if(set_search_string_with_undo(ct->ctx.carg,uct) == FAIL){
return(FAIL);
}/* End IF */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
arg1 = 1;
arg2 = -1;
if(ct->ctx.iarg1_flag) arg1 = ct->ctx.iarg1;
if(ct->ctx.iarg2_flag) arg2 = ct->ctx.iarg2;
/*
* If there are two arguments, then it is a constrained search and we must
* insure that the two positions specified are valid buffer positions.
*/
if(ct->ctx.iarg1_flag && ct->ctx.iarg2_flag){
if(arg1 < 0 || arg1 > curbuf->zee){
sprintf(tmp_message,
"?Illegal buffer position %d in search command",arg1);
error_message(tmp_message);
return(FAIL);
}/* End IF */
if(arg2 < 0 || arg2 > curbuf->zee){
sprintf(tmp_message,
"?Illegal buffer position %d in search command",arg2);
error_message(tmp_message);
return(FAIL);
}/* End IF */
}/* End IF */
/*
* That done, we call the search command to perform the search
*/
if(cmd_search(arg1,arg2,&search_string) == FAIL){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
if(!ct->ctx.inest && search_string.error_message_given == NO){
sprintf(tmp_message,
"?Cannot find '%.40s'",search_string.input);
error_message(tmp_message);
}/* End IF */
return(SUCCESS);
}/* End IF */
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = -1;
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to implement the FR command. The FR command is similar to the FS
* command (Find-Substitute), except that if the second string argument is
* null, rather than simply deleting the first string argument, it is replaced
* by the default replace string.
*/
case EXEC_C_FRREPLACE:
{/* Local Block */
register struct buff_header *qbp;
register int j;
if(last_search_status == 0){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
if(ct->ctx.inest != 0) return(SUCCESS);
return(FAIL);
}/* End IF */
j = last_search_pos2 - last_search_pos1;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
/*
* Call the standard routine which deletes the specified buffer positions
* and constructs the undo list so that it can be rebuilt if necessary.
*/
if(j) buff_delete_with_undo(uct,curbuf,last_search_pos1,j);
qbp = buff_qfind('-',1);
if(qbp == NULL){
return(FAIL);
}/* End IF */
buff_insert_from_buffer_with_undo(
uct,
curbuf, /* destination is current edit buf */
last_search_pos1, /* at the search position */
qbp, /* source is replacement q-register*/
0, /* from position 0 to the end */
qbp->zee
);
if(ct->ctx.iarg1_flag == YES){
if( ct->ctx.iarg1 < 0){
curbuf->dot = last_search_pos1;
}/* End IF */
else if(ct->ctx.iarg2_flag == YES){
if(ct->ctx.iarg2 < ct->ctx.iarg1){
curbuf->dot = last_search_pos1;
}/* End IF */
}/* End Else */
}/* End IF */
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = -1;
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to implement the FS (Find-Substitute) command which searches for
* the first string argument and replaces it with the second.
*/
case EXEC_C_FSREPLACE1:
{/* Local Block */
register int j;
register struct buff_header *qbp;
ct->ctx.tmpval = 0;
if(last_search_status == 0){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
if(ct->ctx.inest != 0) return(SUCCESS);
return(FAIL);
}/* End IF */
#ifdef INTERACTIVE_FS
j = last_search_pos2 - last_search_pos1;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
if(j) buff_delete_with_undo(uct,curbuf,last_search_pos1,j);
#endif /* INTERACTIVE_FS */
return(SUCCESS);
case EXEC_C_FSREPLACE2:
if(last_search_status == 0){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
if(ct->ctx.inest != 0) return(SUCCESS);
return(FAIL);
}/* End IF */
qbp = buff_qfind('-',1);
if(qbp == NULL){
return(FAIL);
}/* End IF */
#ifdef INTERACTIVE_FS
buff_insert_char_with_undo(uct,curbuf,curbuf->dot,ct->input_byte);
#endif /* INTERACTIVE_FS */
/*
* What this does is hope that the replacement string is the same as the
* previous one. Only if we get a miscompare do we delete the contents of
* the replacement q-register, and insert the new string.
*/
if(qbp->zee > ct->ctx.tmpval){
if(ct->input_byte == buff_contents(qbp,ct->ctx.tmpval)){
ct->ctx.tmpval += 1;
return(SUCCESS);
}
buff_delete_with_undo(uct,qbp,ct->ctx.tmpval,
qbp->zee-ct->ctx.tmpval);
}
buff_insert_char_with_undo(uct,qbp,ct->ctx.tmpval,ct->input_byte);
ct->ctx.tmpval += 1;
return(SUCCESS);
case EXEC_C_FSREPLACE3:
qbp = buff_qfind('-',1);
if(qbp == NULL){
return(FAIL);
}/* End IF */
if(qbp->zee > ct->ctx.tmpval){
buff_delete_with_undo(uct,qbp,ct->ctx.tmpval,
qbp->zee-ct->ctx.tmpval);
}
#ifndef INTERACTIVE_FS
j = last_search_pos2 - last_search_pos1;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
if(j) buff_delete_with_undo(uct,curbuf,last_search_pos1,j);
buff_insert_from_buffer_with_undo(uct,
curbuf,
curbuf->dot,
qbp,
0,
qbp->zee
);
#endif /* !INTERACTIVE_FS */
if(ct->ctx.iarg1_flag == YES){
if( ct->ctx.iarg1 < 0){
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
curbuf->dot = last_search_pos1;
}/* End IF */
else if(ct->ctx.iarg2_flag == YES){
if(ct->ctx.iarg2 < ct->ctx.iarg1){
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
curbuf->dot = last_search_pos1;
}/* End IF */
}/* End Else */
}/* End IF */
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = last_search_status;
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to execute the FT (tags) command. Since this is a fairly complicated
* command, we call a subroutine to perform the actions.
*/
case EXEC_C_FTAGS:
{/* Local Block */
register int arg_count = 0;
register int status;
if(ct->ctx.iarg1_flag == YES) arg_count = 1;
if(ct->ctx.iarg2_flag == YES) arg_count = 2;
status = cmd_tags(
uct,
arg_count,
ct->ctx.iarg1,
ct->ctx.iarg2,
ct->ctx.carg
);
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = status;
return(SUCCESS);
}/* End IF */
return(status);
}/* End Local Block */
/*
* Here to execute the FD command which searches for a string and deletes
* it. It is like FS but saves you from typing the second escape.
*/
case EXEC_C_FDCOMMAND:
{/* Local Block */
register int j;
if(last_search_status == 0){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
if(ct->ctx.inest != 0) return(SUCCESS);
return(FAIL);
}/* End IF */
j = last_search_pos2 - last_search_pos1;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
/*
* Call the standard routine which deletes the specified buffer positions
* and constructs the undo list so that it can be rebuilt if necessary.
*/
if(j) buff_delete_with_undo(uct,curbuf,last_search_pos1,j);
curbuf->dot = last_search_pos1;
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = -1;
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to implement the FK command. The FK command remembers the current
* position in the buffer and searches for the specified string. It then
* deletes the characters from the old current position up to but not
* including the search string.
*/
case EXEC_C_FKCOMMAND:
{/* Local Block */
register int j;
if(last_search_status == 0){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
if(ct->ctx.inest != 0) return(SUCCESS);
return(FAIL);
}/* End IF */
if(remembered_dot <= last_search_pos1){
last_search_pos2 = last_search_pos1;
last_search_pos1 = remembered_dot;
}/* End IF */
else {
last_search_pos1 = last_search_pos2;
last_search_pos2 = remembered_dot;
curbuf->dot = last_search_pos1;
}/* End IF */
j = last_search_pos2 - last_search_pos1;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = curbuf->dot;
/*
* Call the standard routine which deletes the specified buffer positions
* and constructs the undo list so that it can be rebuilt if necessary.
*/
if(j) buff_delete_with_undo(uct,curbuf,last_search_pos1,j);
curbuf->dot = last_search_pos1;
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = -1;
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* This state is used by the FK command to remember the current dot
* position before it is changed by the search command.
*/
case EXEC_C_REMEMBER_DOT:
remembered_dot = curbuf->dot;
return(SUCCESS);
/*
* Here to implement the N search which searches across edit buffers for
* the given string.
*/
case EXEC_C_NSEARCH:
{/* Local Block */
int count;
struct buff_header *original_buffer;
int original_dot;
int saved_dot,saved_top,saved_bottom;
int first_buffer;
int last_buffer = 0;
char back_in_original_buffer;
/*
* We set the search string, just like all the other search commands
*/
if(set_search_string_with_undo(ct->ctx.carg,uct) == FAIL){
return(FAIL);
}/* End IF */
/*
* Remember the buffer that we started in, and be ready to change back to
* it if we undo.
*/
original_buffer = curbuf;
original_dot = curbuf->dot;
count = 1;
if(ct->ctx.iarg1_flag) count = ct->ctx.iarg1;
/*
* If he says 1,5n<string>$ then we search for the string in buffers 1
* through 5. We check that both buffers exist before we begin the search.
*/
if(ct->ctx.iarg2_flag){
count = 1;
first_buffer = ct->ctx.iarg1;
last_buffer = ct->ctx.iarg2;
if(first_buffer != curbuf->buffer_number){
if(buff_openbuffer(NULL,last_buffer,0) != SUCCESS){
return(FAIL);
}/* End IF */
if(buff_openbuffer(NULL,first_buffer,0) != SUCCESS){
return(FAIL);
}/* End IF */
curbuf->dot = 0;
}/* End IF */
}/* End IF */
/*
* In the starting buffer, we want to search from 'dot' to the end. Then
* we would search all the other buffers, and then the original one again,
* but from the top to 'dot'. The saved_dot stuff is necessary because
* the cmd_search routine has the side effect of changing 'dot' in the
* buffer being searched. However, we only want to affect 'dot' in the
* final buffer that the final occurance of the search string is found in.
*/
saved_dot = curbuf->dot;
saved_top = curbuf->dot;
saved_bottom = curbuf->zee;
back_in_original_buffer = 0;
while(count > 0){
if(cmd_search(saved_top,saved_bottom,&search_string) != FAIL){
saved_top = curbuf->dot;
count -= 1;
continue;
}/* End IF */
/*
* Here if the search failed. We want to switch over to the next buffer and
* try again, until we exhaust all the buffers. If we reach the final buffer
* without finding the string, we return an error to the user, leaving him
* back in his original buffer.
*/
if(ct->ctx.iarg2_flag && curbuf->buffer_number == last_buffer){
if(buff_openbuffer(NULL,original_buffer->buffer_number,0) != SUCCESS){
error_message("Boom! lost original buffer");
return(FAIL);
}/* End IF */
back_in_original_buffer = 1;
}/* End IF */
if(back_in_original_buffer){
curbuf->dot = saved_dot;
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
sprintf(tmp_message,
"?Cannot find '%.40s'",search_string.input);
if(!ct->ctx.inest && !intr_flag &&
search_string.error_message_given == NO){
error_message(tmp_message);
}/* End IF */
return(SUCCESS);
}/* End IF */
/*
* We havn't tried all the buffers yet, switch to the next one.
*/
curbuf->dot = saved_dot;
while(1){
curbuf = curbuf->next_header;
if(curbuf == NULL) curbuf = buffer_headers;
if(curbuf->buffer_number == -1) break;
if(curbuf->buffer_number > 0) break;
if(ct->ctx.iarg2_flag) continue;
if(curbuf == original_buffer) break;
}/* End While */
saved_dot = curbuf->dot;
saved_top = 0;
saved_bottom = curbuf->zee;
if(ct->ctx.iarg2_flag == NO){
if(curbuf->buffer_number == original_buffer->buffer_number){
back_in_original_buffer = 1;
saved_bottom = original_dot;
}/* End IF */
}/* End IF */
}/* End While */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEBUFF;
ut->iarg1 = original_buffer->buffer_number;
buff_switch(curbuf,1);
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEDOT;
ut->iarg1 = saved_dot;
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = -1;
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to begin an iteration < ... >
*/
case EXEC_C_ITERATION_BEGIN:
{/* Local Block */
register struct cmd_token *oct;
if(ct->ctx.iarg1_flag == YES){
if(ct->ctx.iarg1 <= 0){
oct = ct;
while((oct = oct->next_token)){
if(oct->opcode != TOK_C_ITERATION_END) continue;
if(oct->ctx.inest != (ct->ctx.inest-1)) continue;
jump_to_token = oct;
return(SUCCESS);
}/* End While */
ct->ctx.go_flag = NO;
return(SUCCESS);
}/* End IF */
ct->ctx.iarg1 -= 1;
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to provide the execution code for the end of an iteration.
* This must search backwards in the parse tokens to find the begining
* of the iteration, and set up to jump to that token
*/
case EXEC_C_ITERATION_END:
{/* Local Block */
register struct cmd_token *oct;
/*
* The parser left us a pointer to the begining of the iteration so we can
* find it without having to search.
*/
oct = ct->ctx.caller_token;
if(oct->ctx.iarg1_flag == YES){
if(oct->ctx.iarg1 <= 0){
return(SUCCESS);
}/* End IF */
}/* End IF */
/*
* The following line grabs the old iteration value so that when the
* begining of iteration code grabs the "previous" iarg1, this will
* be it. Think of it this way: the code has to do something different
* the first time into the iteration (it has to load the results of the
* STORE1, then the subsequent times it has to decrement what's already
* there. That's why this seems a little kludgy.
*/
ct->ctx.iarg1 = oct->ctx.iarg1;
jump_to_token = oct;
return(SUCCESS);
}/* End Local Block */
/*
* Here to implement the semicolon command which is used to jump out
* of an iteration if the argument is >= 0.
*/
case EXEC_C_SEMICOLON:
{/* Local Block */
register struct cmd_token *oct;
int value;
value = last_search_status;
if(ct->ctx.iarg1_flag == YES) value = ct->ctx.iarg1;
if(value < 0) return(SUCCESS);
oct = ct;
while((oct = oct->next_token)){
if(oct->opcode != TOK_C_ITERATION_END) continue;
if(oct->ctx.inest != (ct->ctx.inest-1)) continue;
if(oct->next_token){
jump_to_token = oct->next_token;
return(SUCCESS);
}/* End IF */
}/* End While */
ct->ctx.go_flag = NO;
return(BLOCKED);
}/* End Local Block */
/*
* Here to implement the various conditional operators
*/
case EXEC_C_COND_GT:
if(ct->ctx.iarg1 <= 0){
return(find_conditional_else(ct));
}/* End IF */
return(SUCCESS);
case EXEC_C_COND_LT:
if(ct->ctx.iarg1 >= 0){
return(find_conditional_else(ct));
}/* End IF */
return(SUCCESS);
case EXEC_C_COND_EQ:
if(ct->ctx.iarg1 != 0){
return(find_conditional_else(ct));
}/* End IF */
return(SUCCESS);
case EXEC_C_COND_NE:
if(ct->ctx.iarg1 == 0){
return(find_conditional_else(ct));
}/* End IF */
return(SUCCESS);
case EXEC_C_COND_DIGIT:
if(!isdigit(ct->ctx.iarg1)){
return(find_conditional_else(ct));
}/* End IF */
return(SUCCESS);
case EXEC_C_COND_ALPHA:
if(!isalpha(ct->ctx.iarg1)){
return(find_conditional_else(ct));
}/* End IF */
return(SUCCESS);
case EXEC_C_COND_LOWER:
if(!islower(ct->ctx.iarg1)){
return(find_conditional_else(ct));
}/* End IF */
return(SUCCESS);
case EXEC_C_COND_UPPER:
if(!isupper(ct->ctx.iarg1)){
return(find_conditional_else(ct));
}/* End IF */
return(SUCCESS);
case EXEC_C_COND_SYMBOL:
if(!isalnum(ct->ctx.iarg1) && ct->ctx.iarg1 != '_'){
return(find_conditional_else(ct));
}/* End IF */
return(SUCCESS);
case EXEC_C_SKIP_ELSE:
return(find_conditional_end(ct));
/*
* Here to implement the GOTO command OLABEL$
*/
case EXEC_C_GOTO:
{/* Local Block */
struct cmd_token *goto_ptr;
struct cmd_token *test_ptr;
/*
* First step is to find the begining of this goto string
*/
goto_ptr = ct;
while((goto_ptr = goto_ptr->prev_token)){
if(goto_ptr->opcode != TOK_C_GOTO_BEGIN) continue;
break;
}/* End While */
/*
* Now try to find the label. First search backwards for it
*/
test_ptr = goto_ptr;
while((test_ptr = test_ptr->prev_token)){
if(test_ptr->opcode != TOK_C_LABEL_BEGIN) continue;
if(compare_label(goto_ptr,test_ptr) == YES){
ct->ctx.go_flag = NO;
jump_to_token = test_ptr;
return(SUCCESS);
}/* End IF */
}/* End While */
/*
* The label is not in front of us, look for it afterwards
*/
test_ptr = goto_ptr;
while((test_ptr = test_ptr->next_token)){
if(test_ptr->opcode == TOK_C_FINALTOKEN){
char string1[PARSER_STRING_MAX];
extract_label(goto_ptr,string1);
(void) sprintf(tmp_message,"?Can't find label <%s>",
string1);
error_message(tmp_message);
return(FAIL);
}/* End IF */
if(test_ptr->opcode != TOK_C_LABEL_BEGIN) continue;
if(compare_label(goto_ptr,test_ptr) == YES){
jump_to_token = test_ptr;
return(SUCCESS);
}/* End IF */
}/* End While */
ct->ctx.go_flag = NO;
return(BLOCKED);
}/* End Local Block */
/*
* Here to write out the buffer. If the filename is specified, write it
* to that name, otherwise write it to the default name of the buffer.
*/
case EXEC_C_WRITEFILE:
{/* Local Block */
int status;
struct wildcard_expansion *name_list,*np;
char *filename;
if(curbuf->isreadonly){
error_message("?File is Readonly");
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
return(FAIL);
}/* End IF */
if(ct->ctx.carg) filename = ct->ctx.carg;
else filename = curbuf->name;
np = expand_filename(filename);
if(np == NULL){
sprintf(tmp_message,"EW No such file <%s>",filename);
error_message(tmp_message);
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
return(FAIL);
}/* End IF */
if(np->we_next){
sprintf(tmp_message,"EW: Non-unique filename <%s>",filename);
error_message(tmp_message);
while(np){
name_list = np;
np = np->we_next;
tec_release(TYPE_C_WILD,(char *)name_list);
}/* End While */
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
return(FAIL);
}/* End IF */
status = cmd_write(curbuf,np->we_name);
tec_release(TYPE_C_WILD,(char *)np);
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = status;
return(SUCCESS);
}/* End IF */
return(status);
}/* End Local Block */
/*
* Read in the named file to the current position in the edit buffer
*/
case EXEC_C_READFILE:
{/* Local Block */
struct wildcard_expansion *name_list,*np;
if(ct->ctx.carg == NULL || ct->ctx.carg[0] == '\0'){
error_message("?ER Requires a filename");
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
return(FAIL);
}/* End IF */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_DELETE;
ut->carg1 = (char *)curbuf;
ut->iarg1 = curbuf->dot;
ut->iarg2 = curbuf->zee;
np = expand_filename(ct->ctx.carg);
if(np == NULL){
sprintf(tmp_message,"ER No such file <%s>",ct->ctx.carg);
error_message(tmp_message);
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
return(FAIL);
}/* End IF */
while(np){
buff_read(curbuf,np->we_name);
name_list = np;
np = np->we_next;
tec_release(TYPE_C_WILD,(char *)name_list);
}/* End While */
ut->iarg2 = curbuf->zee - ut->iarg2;
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = SUCCESS;
return(SUCCESS);
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to change the current edit buffer. If a numeric argument is
* supplied, change to that buffer, otherwise a string should have been
* specified, and this is the name of the file/buffer to be loaded.
*/
case EXEC_C_EDITBUF:
{/* Local Block */
struct buff_header *hbp,*old_buffer,*first_buffer;
struct wildcard_expansion *name_list,*np;
/*
* Here if there is no string argument. It better be a numeric buffer
* number argument. If so, switch to that buffer, and set the undo to
* switch back to the old one if this gets undone.
*/
if(ct->ctx.carg == NULL || ct->ctx.carg[0] == '\0'){
if(ct->ctx.iarg1_flag == NO){
error_message("?EB Requires a filename or argument");
return(FAIL);
}/* End IF */
old_buffer = curbuf;
if(buff_openbuffer(0,ct->ctx.iarg1,0) == FAIL){
return(FAIL);
}/* End IF */
if(curbuf->buffer_number != ct->ctx.iarg1){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}
return(FAIL);
}/* End IF */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEBUFF;
ut->iarg1 = old_buffer->buffer_number;
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = SUCCESS;
}
return(SUCCESS);
}/* End IF */
old_buffer = curbuf;
first_buffer = NULL;
np = expand_filename(ct->ctx.carg);
if(np == NULL){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}
sprintf(tmp_message,"EB No such file <%s>",ct->ctx.carg);
error_message(tmp_message);
return(FAIL);
}/* End IF */
while(np){
/*
* The following hack detects whether a new buffer was created so that
* we know whether or not to set up an undo to un-create it.
*/
hbp = buff_find(np->we_name);
if(buff_openbuffer(np->we_name,0,0) == SUCCESS){
if(hbp == NULL){
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CLOSEBUFF;
ut->carg1 = (char *)curbuf;
}/* End IF */
if(first_buffer == NULL) first_buffer = curbuf;
}/* End IF */
name_list = np;
np = np->we_next;
tec_release(TYPE_C_WILD,(char *)name_list);
}/* End While */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEBUFF;
ut->iarg1 = old_buffer->buffer_number;
buff_openbuffer(0,first_buffer->buffer_number,0);
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = SUCCESS;
return(SUCCESS);
}
return(SUCCESS);
}/* End Local Block */
/*
* Here to implement the EF command which removes an edit buffer.
*/
case EXEC_C_CLOSEBUF:
{/* Local Block */
register struct buff_header *hbp,*bp;
register int i;
hbp = curbuf;
if(curbuf->buffer_number == 0){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
error_message("?EF Not allowed on special buffers");
return(FAIL);
}/* End IF */
if(hbp->ismodified && !hbp->isreadonly){
if(ct->ctx.iarg1_flag == NO ||
ct->ctx.iarg1 != -1){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}/* End IF */
sprintf(tmp_message,"?EF Buffer %s is modified",
curbuf->name);
error_message(tmp_message);
return(FAIL);
}/* End IF */
}/* End IF */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEBUFF;
ut->iarg1 = hbp->buffer_number;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_REOPENBUFF;
ut->iarg1 = hbp->buffer_number;
ut->carg1 = (char *)hbp;
/*
* Unlink this buffer header from the header list. Check to see if it is
* at the head of the list. If not at the head of the list, we have to
* search the list till we find it's father. Then we make it's father's
* child be it's child.
*/
i = 0;
bp = buffer_headers;
if(bp == hbp) buffer_headers = bp->next_header;
else {
while(bp){
if(bp->next_header == hbp) break;
bp = bp->next_header;
}/* End While */
bp->next_header = hbp->next_header;
curbuf = NULL;
if(bp->buffer_number > 0 && hbp->buffer_number > 0){
i = bp->buffer_number;
}/* End IF */
else if(bp->buffer_number < 0 && hbp->buffer_number < 0){
i = bp->buffer_number;
}/* End Else */
else if(hbp->buffer_number > 0 && hbp->next_header){
i = hbp->next_header->buffer_number;
}/* End Else */
else i = -1;
}/* End Else */
/*
* Pick a different buffer to be the current buffer
*/
if(i){
if(buff_openbuffer(NULL,i,0) == FAIL) i = 0;
}/* End IF */
if(!i){
if(buff_openbuffer(NULL,-1,0) == FAIL){
buff_openbuffer(NULL,0,0);
}/* End IF */
}/* End IF */
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = SUCCESS;
}/* End IF */
return(SUCCESS);
}/* End Local Block */
/*
* Here to implement the EV command which is identical to the EB command
* except that if the buffer does not exist, when it is created it is created
* as a read only buffer.
*/
case EXEC_C_VIEWBUF:
{/* Local Block */
struct buff_header *hbp,*old_buffer,*first_buffer;
struct wildcard_expansion *name_list,*np;
/*
* Here if there is no string argument. It better be a numeric buffer
* number argument. If so, switch to that buffer, and set the undo to
* switch back to the old one if this gets undone.
*/
if(ct->ctx.carg == NULL || ct->ctx.carg[0] == '\0'){
if(ct->ctx.iarg1_flag == NO){
error_message("?EV Requires a filename or argument");
return(FAIL);
}/* End IF */
old_buffer = curbuf;
buff_openbuffer(0,ct->ctx.iarg1,1);
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEBUFF;
ut->iarg1 = old_buffer->buffer_number;
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = SUCCESS;
}
return(SUCCESS);
}/* End IF */
old_buffer = curbuf;
first_buffer = NULL;
np = expand_filename(ct->ctx.carg);
if(np == NULL){
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = FAIL;
return(SUCCESS);
}
sprintf(tmp_message,"EV No such file <%s>",ct->ctx.carg);
error_message(tmp_message);
return(FAIL);
}/* End IF */
while(np){
/*
* The following hack detects whether a new buffer was created so that
* we know whether or not to set up an undo to un-create it.
*/
hbp = buff_find(np->we_name);
if(buff_openbuffer(np->we_name,0,1) == SUCCESS){
if(hbp == NULL){
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CLOSEBUFF;
ut->carg1 = (char *)curbuf;
}/* End IF */
if(first_buffer == NULL) first_buffer = curbuf;
}/* End IF */
name_list = np;
np = np->we_next;
tec_release(TYPE_C_WILD,(char *)name_list);
}/* End While */
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEBUFF;
ut->iarg1 = old_buffer->buffer_number;
buff_openbuffer(0,first_buffer->buffer_number,1);
if(ct->ctx.flags & CTOK_M_COLON_SEEN){
ct->ctx.tmpval = SUCCESS;
return(SUCCESS);
}
return(SUCCESS);
}/* End Local Block */
/*
* Here to scroll the screen the specified number of lines
*/
case EXEC_C_SCROLL:
if(ct->ctx.iarg1_flag == NO) ct->ctx.iarg1 = 1;
screen_scroll(ct->ctx.iarg1);
return(SUCCESS);
/*
* Here to cause the screen to update
*/
case EXEC_C_UPDATE_SCREEN:
screen_format_windows();
screen_refresh();
return(SUCCESS);
/*
* Here to either split or combine windows
*/
case EXEC_C_WINDOW_CONTROL:
{/* Local Block */
struct window *old_wptr;
struct window *new_wptr;
if(ct->ctx.iarg1_flag == NO) screen_delete_window(curwin);
if(ct->ctx.iarg1_flag == YES && ct->ctx.iarg2_flag == YES){
old_wptr = curwin;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
new_wptr =
screen_split_window(
curwin,
ct->ctx.iarg1,
ct->ctx.iarg2
);
if(new_wptr == NULL) return(FAIL);
ut->opcode = UNDO_C_WINDOW_SPLIT;
ut->iarg1 = old_wptr->win_window_number;
ut->carg1 = (char *)new_wptr;
}/* End Else */
return(SUCCESS);
}/* End Local Block */
/*
* Here to select the next window as active
*/
case EXEC_C_NEXT_WINDOW:
{/* Local Block */
int status;
int new_window;
new_window = ct->ctx.iarg1_flag == YES ? ct->ctx.iarg1 : 0;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_WINDOW_SWITCH;
ut->iarg1 = curwin->win_window_number;
status = window_switch(new_window);
return(status);
}/* End Local Block */
/*
* Here to reset a ^A message to NULL
*/
case EXEC_C_RESET_MESSAGE:
user_message[0] = '\0';
return(SUCCESS);
/*
* Here to add a byte to the length of the current user message string
*/
case EXEC_C_MESSAGE:
{/* Local Block */
register int i;
if(strlen(user_message) > (sizeof(user_message) - 1)){
error_message("?^A message length exceeded");
return(FAIL);
}/* End IF */
i = strlen(user_message);
user_message[i] = ct->input_byte;
user_message[i+1] = '\0';
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_SHORTEN_MESSAGE;
return(SUCCESS);
}/* End Local Block */
/*
* Here to print the current user message to the status line of the screen
*/
case EXEC_C_OUTPUT_MESSAGE:
screen_message(user_message);
screen_refresh();
return(SUCCESS);
/*
* Here to execute the specified operating system command, and insert the
* generated output into the edit buffer.
*/
case EXEC_C_ECCOMMAND:
{/* Local Block */
int status;
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_DELETE;
ut->carg1 = (char *)curbuf;
ut->iarg1 = curbuf->dot;
ut->iarg2 = 0;
status = cmd_oscmd(ct);
ut->iarg2 = curbuf->dot - ut->iarg1;
return(status);
}/* End Local Block */
case EXEC_C_SET_IMMEDIATE_MODE:
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_SET_IMMEDIATE_MODE;
ut->iarg1 = immediate_execute_flag;
immediate_execute_flag = YES;
if(ct->ctx.iarg1 == 0){
ct->ctx.go_flag = NO;
immediate_execute_flag = NO;
}/* End IF */
return(SUCCESS);
case EXEC_C_OPENBRACE:
{/* Local Block */
register struct buff_header *qbp;
/*
* Get a pointer to the q-register buffer structure. If it doesn't
* exist, create it.
*/
qbp = buff_qfind('$',1);
if(qbp == NULL){
return(FAIL);
}/* End IF */
/*
* Set up the undo token to remember the current edit buffer, and then switch
* to the Q-register.
*/
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_CHANGEBUFF;
ut->iarg1 = curbuf->buffer_number;
buff_switch(qbp,1);
/*
* Delete the previous contents of the q-register, but allow it to be
* reconstructed if this gets undone. Note that we don't have to do
* this if there was nothing there.
*/
if(qbp->zee) buff_delete_with_undo(uct,qbp,0,qbp->zee);
/*
* Arrange for it to be deleted if this gets undone.
*/
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
/*
* Copy the parser command line into the Q-register
*/
parser_dump_command_line(qbp);
ut->opcode = UNDO_C_DELETE;
ut->carg1 = (char *)qbp;
ut->iarg1 = 0;
ut->iarg2 = qbp->zee;
return(SUCCESS);
}/* End Local Block */
case EXEC_C_CLOSEBRACE:
{/* Local Block */
register struct buff_header *qbp;
/*
* Get a pointer to the q-register buffer structure. If it doesn't
* exist, that is an error
*/
qbp = buff_qfind('$',0);
if(qbp == NULL){
return(FAIL);
}/* End IF */
/*
* Replace the command line with the contents of the Q-register
*/
parser_replace_command_line(qbp);
return(INVALIDATE);
}/* End Local Block */
/*
* Here to skip a label (this occurs when we run into a label)
*/
case EXEC_C_SKIPLABEL:
while(ct){
if(ct->opcode == TOK_C_LABEL_END){
jump_to_token = ct;
return(SUCCESS);
}/* End IF */
ct = ct->next_token;
}/* End While */
return(SUCCESS);
/*
* Here if he wants to set some options up
*/
case EXEC_C_SETOPTIONS:
ut = allocate_undo_token(uct);
if(ut == NULL) return(FAIL);
ut->opcode = UNDO_C_SETOPTIONS;
return(cmd_setoptions(ct->ctx.iarg1,ct->ctx.iarg2,ut));
default:
sprintf(tmp_message,"?TECEXEC: unknown state %d dispatched",
ct->execute_state);
error_message(tmp_message);
return(FAIL);
}/* End Switch */
}/* End Routine */
/* PUSH_QREGISTER - Push a Q register onto the stack
*
* Function:
*
* This routine is called to make a copy of a Q register and place it
* on the Q register stack.
*/
int
push_qregister( char letter )
{
register struct buff_header *hbp;
register struct buff_header *qbp;
PREAMBLE();
/*
* Get a pointer to the q-register buffer structure. If it doesn't
* exist, create it.
*/
qbp = buff_qfind(letter,1);
if(qbp == NULL){
return(FAIL);
}/* End IF */
hbp = buff_duplicate(qbp);
hbp->next_header = qregister_push_down_list;
qregister_push_down_list = hbp;
return(SUCCESS);
}/* End Routine */
/* EXTRACT_LABEL - Build a string with the contents of the label in it
*
* Function:
*
* This routine is called to build a string with the label name
* in it. The current use is for error messages.
*/
void
extract_label( struct cmd_token *label_ptr, char *string1 )
{
register char *cp1;
cp1 = string1;
*cp1 = '\0';
while(label_ptr){
if(cp1 >= &string1[PARSER_STRING_MAX-1]) break;
if(label_ptr->opcode == TOK_C_INPUTCHAR){
if(label_ptr->input_byte == '!') break;
*cp1++ = label_ptr->input_byte;
*cp1 = '\0';
}/* End IF */
if(label_ptr->opcode == TOK_C_LABEL_END) break;
label_ptr = label_ptr->next_token;
}/* End While */
}/* End Routine */
/* COMPARE_LABEL - Test if this is our label
*
* Function:
*
* This routine is called by the GOTO function to compare labels
* to see if they match.
*/
int
compare_label( struct cmd_token *goto_ptr, struct cmd_token *label_ptr )
{
char string1[PARSER_STRING_MAX],string2[PARSER_STRING_MAX];
char *cp1;
PREAMBLE();
cp1 = string1;
*cp1 = '\0';
while(goto_ptr){
if(cp1 >= &string1[PARSER_STRING_MAX-1]) break;
if(goto_ptr->opcode == TOK_C_INPUTCHAR){
if(goto_ptr->input_byte == ESCAPE) break;
*cp1++ = goto_ptr->input_byte;
*cp1 = '\0';
}/* End IF */
if(goto_ptr->opcode == TOK_C_GOTO_END) break;
goto_ptr = goto_ptr->next_token;
}/* End While */
cp1 = string2;
*cp1 = '\0';
while(label_ptr){
if(cp1 >= &string2[PARSER_STRING_MAX-1]) break;
if(label_ptr->opcode == TOK_C_INPUTCHAR){
if(label_ptr->input_byte == '!') break;
*cp1++ = label_ptr->input_byte;
*cp1 = '\0';
}/* End IF */
if(label_ptr->opcode == TOK_C_LABEL_END) break;
label_ptr = label_ptr->next_token;
}/* End While */
if(strcmp(string1,string2) == 0) return(YES);
return(NO);
}/* End Routine */
/* FIND_CONDITIONAL_ELSE - Routine to find the else of a conditional
*
* Function:
*
* This routine is called by the conditional expressions when the
* specified condition has not been met and we want to execute the
* else clause of the conditional. The routine searches until it
* finds either the else, or the end of the conditional.
*/
int
find_conditional_else( struct cmd_token *ct )
{
register struct cmd_token *oct;
PREAMBLE();
oct = ct;
while((oct = oct->next_token)){
if(oct->opcode == TOK_C_CONDITIONAL_ELSE){
if(oct->ctx.cnest == ct->ctx.cnest){
jump_to_token = oct;
return(SUCCESS);
}/* End IF */
}/* End IF */
if(oct->opcode == TOK_C_CONDITIONAL_END){
if(oct->ctx.cnest == (ct->ctx.cnest-1)){
jump_to_token = oct;
return(SUCCESS);
}/* End IF */
}/* End IF */
}/* End While */
ct->ctx.go_flag = NO;
return(BLOCKED);
}/* End Routine */
/* FIND_CONDITIONAL_END - Routine to find the close of a conditional
*
* Function:
*
* This routine is called to skip over the else clause and find the
* end of the conditional.
*/
int
find_conditional_end( struct cmd_token *ct )
{
register struct cmd_token *oct;
PREAMBLE();
oct = ct;
while((oct = oct->next_token)){
if(oct->opcode != TOK_C_CONDITIONAL_END) continue;
if(oct->ctx.cnest != (ct->ctx.cnest-1)) continue;
jump_to_token = oct;
return(SUCCESS);
}/* End While */
ct->ctx.go_flag = NO;
return(BLOCKED);
}/* End Routine */
/* EXEC_DOQ0 - Execute Q register zero as a macro
*
* Function:
*
* This routine is called to execute Q register zero as a macro on
* startup. This allows the user to initialize things from his teco.ini
* before teco reaches command level.
*/
int
exec_doq0()
{
register struct buff_header *qbp;
register struct undo_token *ut;
struct cmd_token *ct;
PREAMBLE();
/*
* Get a pointer to the q-register buffer structure. If it doesn't
* exist, declare an error.
*/
qbp = buff_qfind('0',0);
if(qbp == NULL){
error_message("?Internal Error! Q register 0 disappeared during init");
return(FAIL);
}/* End IF */
/*
* If the Q register is empty, just return with no error.
*/
if(qbp->zee == 0){
return(SUCCESS);
}/* End IF */
/*
* Set up a fake command token and undo token structure for the parser to
* chain undo blocks off of. We don't ever undo this stuff, but the routine
* expects it to be there.
*/
ct = allocate_cmd_token((struct cmd_token *)NULL);
if(ct == NULL) return(FAIL);
ut = allocate_undo_token(ct);
if(ut == NULL){
free_cmd_token(ct);
return(FAIL);
}/* End IF */
ut->opcode = UNDO_C_MACRO;
ut->carg1 = NULL;
tecmacro(qbp,ct,(struct cmd_token **)&ut->carg1);
parser_cleanup_ctlist(ct);
return(SUCCESS);
}/* End Routine */
|