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
|
@x
\def\?##1]{\hbox to 1in{\hfil##1.\ }}
}
@y
\def\?##1]{\hbox{Changes to \hbox to 1em{\hfil##1}.\ }}
}
\let\maybe=\iftrue
@z
@x
@d banner==luaTeX_banner
@y
@d luaTeXk_banner=='This is luaTeXk, Version ',luatex_version_string
@#
@d banner==luaTeX_banner
@d banner_k==luaTeXk_banner
@z
@x
Actually the heading shown here is not quite normal: The |program| line
does not mention any |output| file, because \ph\ would ask the \TeX\ user
to specify a file name if |output| were specified here.
@^system dependencies@>
@y
@z
@x
program TEX; {all file names are defined dynamically}
label @<Labels in the outer block@>@/
@y
program TEX; {all file names are defined dynamically}
@z
@x
@ Three labels must be declared in the main program, so we give them
symbolic names.
@d start_of_TEX=1 {go here when \TeX's variables are initialized}
@d end_of_TEX=9998 {go here to close files and terminate gracefully}
@d final_end=9999 {this label marks the ending of the program}
@<Labels in the out...@>=
start_of_TEX@t\hskip-2pt@>, end_of_TEX@t\hskip-2pt@>,@,final_end;
{key control points}
@y
@ For Web2c, labels are not declared in the main program, but
we still have to declare the symbolic names.
@d start_of_TEX=1 {go here when \TeX's variables are initialized}
@d final_end=9999 {this label marks the ending of the program}
@z
@x
@d debug==@{ {change this to `$\\{debug}\equiv\null$' when debugging}
@d gubed==@t@>@} {change this to `$\\{gubed}\equiv\null$' when debugging}
@y
@d debug== ifdef('TEXMF_DEBUG')
@d gubed== endif('TEXMF_DEBUG')
@z
@x
@d stat==@{ {change this to `$\\{stat}\equiv\null$' when gathering
usage statistics}
@d tats==@t@>@} {change this to `$\\{tats}\equiv\null$' when gathering
usage statistics}
@y
@d stat==ifdef('STAT')
@d tats==endif('STAT')
@z
@x
the codewords `$|init|\ldots|tini|$'.
@d init== {change this to `$\\{init}\equiv\.{@@\{}$' in the production version}
@d tini== {change this to `$\\{tini}\equiv\.{@@\}}$' in the production version}
@y
the codewords `$|init|\ldots|tini|$' for declarations and by the codewords
`$|Init|\ldots|Tini|$' for executable code. This distinction is helpful for
implementations where a run-time switch differentiates between the two
versions of the program.
@d init==ifdef('INITEX')
@d tini==endif('INITEX')
@d Init==init if ini_version then begin
@d Tini==end;@+tini
@f Init==begin
@f Tini==end
@z
@x
@!init @<Initialize table entries (done by \.{INITEX} only)@>@;@+tini
@y
@!Init @<Initialize table entries (done by \.{INITEX} only)@>@;@+Tini
@z
@x
@<Constants...@>=
@!buf_size=500; {maximum number of characters simultaneously present in
current lines of open files and in control sequences between
\.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|}
@!error_line=72; {width of context lines on terminal error messages}
@!half_error_line=42; {width of first lines of contexts in terminal
error messages; should be between 30 and |error_line-15|}
@!max_print_line=79; {width of longest text lines output; should be at least 60}
@!stack_size=200; {maximum number of simultaneous input sources}
@!max_in_open=6; {maximum number of input files and error insertions that
can be going on simultaneously}
@!param_size=60; {maximum number of simultaneous macro parameters}
@!nest_size=40; {maximum number of semantic levels simultaneously active}
@!max_strings=3000; {maximum number of strings; must not exceed |max_halfword|}
@!string_vacancies=8000; {the minimum number of characters that should be
available for the user's control sequences and font names,
after \TeX's own error messages are stored}
@!pool_size=32000; {maximum number of characters in strings, including all
error messages and help texts, and the names of all fonts and
control sequences; must exceed |string_vacancies| by the total
length of \TeX's own strings, which is currently about 23000}
@!save_size=600; {space for saving values outside of current group; must be
at most |max_halfword|}
@!dvi_buf_size=800; {size of the output buffer; must be a multiple of 8}
@!expand_depth=10000; {limits recursive calls of the |expand| procedure}
@!file_name_size=40; {file names shouldn't be longer than this}
@!pool_name='TeXformats:TEX.POOL ';
{string of length |file_name_size|; tells where the string pool appears}
@y
@d file_name_size == max_halfword-1 { has to be big enough to force namelength into integer }
@d ssup_error_line = 255
@d ssup_max_strings == 262143
{Larger values than 65536 cause the arrays consume much more memory.}
@<Constants...@>=
@!hash_offset=514; {smallest index in hash array, i.e., |hash_base| }
{Use |hash_offset=0| for compilers which cannot decrement pointers.}
@!engine_name='luatex'; {the name of this engine}
@#
@!inf_main_memory = 2000000;
@!sup_main_memory = 32000000;
@!inf_max_strings = 100000;
@!sup_max_strings = ssup_max_strings;
@!inf_strings_free = 100;
@!sup_strings_free = sup_max_strings;
@!inf_buf_size = 500;
@!sup_buf_size = 100000000;
@!inf_nest_size = 40;
@!sup_nest_size = 4000;
@!inf_max_in_open = 6;
@!sup_max_in_open = 127;
@!inf_param_size = 60;
@!sup_param_size = 6000;
@!inf_save_size = 600;
@!sup_save_size = 80000;
@!inf_stack_size = 200;
@!sup_stack_size = 30000;
@!inf_dvi_buf_size = 800;
@!sup_dvi_buf_size = 65536;
@!inf_pool_size = 128000;
@!sup_pool_size = 40000000;
@!inf_pool_free = 1000;
@!sup_pool_free = sup_pool_size;
@!inf_string_vacancies = 8000;
@!sup_string_vacancies = sup_pool_size - 23000;
@!sup_hash_extra = sup_max_strings;
@!inf_hash_extra = 0;
@!sup_ocp_list_size = 1000000;
@!inf_ocp_list_size = 1000;
@!sup_ocp_buf_size = 100000000;
@!inf_ocp_buf_size = 1000;
@!sup_ocp_stack_size = 1000000;
@!inf_ocp_stack_size = 1000;
@!inf_expand_depth = 100;
@!sup_expand_depth = 1000000;
@z
@x
@d font_base=0 {smallest internal font number; must not be less
than |min_quarterword|}
@d hash_size=2100 {maximum number of control sequences; it should be at most
about |(fix_mem_max-fix_mem_min)/10|}
@d hash_prime=1777 {a prime number equal to about 85\pct! of |hash_size|}
@y
@d font_base=0 {smallest internal font number; must not be less
than |min_quarterword|}
@d hash_size=65536 {maximum number of control sequences; it should be at most
about |(mem_max-mem_min)/10|}
@d hash_prime=55711 {a prime number equal to about 85\pct! of |hash_size|}
@z
@x
@d incr(#) == #:=#+1 {increase a variable by unity}
@d decr(#) == #:=#-1 {decrease a variable by unity}
@y
@z
@x
@d text_char == char {the data type of characters in text files}
@y
@d text_char == ASCII_code {the data type of characters in text files}
@z
@x
@!nameoffile:packed array[1..file_name_size] of char;@;@/
{on some systems this may be a \&{record} variable}
@y
@!nameoffile:^packed_ASCII_code;
@z
@x
@ The \ph\ compiler with which the present version of \TeX\ was prepared has
extended the rules of \PASCAL\ in a very convenient way. To open file~|f|,
we can write
$$\vbox{\halign{#\hfil\qquad&#\hfil\cr
|reset(f,@t\\{name}@>,'/O')|&for input;\cr
|rewrite(f,@t\\{name}@>,'/O')|&for output.\cr}}$$
The `\\{name}' parameter, which is of type `{\bf packed array
$[\langle\\{any}\rangle]$ of \\{char}}', stands for the name of
the external file that is being opened for input or output.
Blank spaces that might appear in \\{name} are ignored.
The `\.{/O}' parameter tells the operating system not to issue its own
error messages if something goes wrong. If a file of the specified name
cannot be found, or if such a file cannot be opened for some other reason
(e.g., someone may already be trying to write the same file), we will have
|@!erstat(f)<>0| after an unsuccessful |reset| or |rewrite|. This allows
\TeX\ to undertake appropriate corrective action.
@:PASCAL H}{\ph@>
@^system dependencies@>
\TeX's file-opening procedures return |false| if no file identified by
|nameoffile| could be opened.
@d reset_OK(#)==erstat(#)=0
@d rewrite_OK(#)==erstat(#)=0
@p function a_open_in(var f:alpha_file):boolean;
{open a text file for input}
begin reset(f,nameoffile,'/O'); a_open_in:=reset_OK(f);
end;
@#
function a_open_out(var f:alpha_file):boolean;
{open a text file for output}
begin rewrite(f,nameoffile,'/O'); a_open_out:=rewrite_OK(f);
end;
@#
function b_open_in(var f:byte_file):boolean;
{open a binary file for input}
begin reset(f,nameoffile,'/O'); b_open_in:=reset_OK(f);
end;
@#
function b_open_out(var f:byte_file):boolean;
{open a binary file for output}
begin rewrite(f,nameoffile,'/O'); b_open_out:=rewrite_OK(f);
end;
@#
function w_open_in(var f:word_file):boolean;
{open a word file for input}
begin reset(f,nameoffile,'/O'); w_open_in:=reset_OK(f);
end;
@#
function w_open_out(var f:word_file):boolean;
{open a word file for output}
begin rewrite(f,nameoffile,'/O'); w_open_out:=rewrite_OK(f);
end;
@y
@ All of the file opening functions are defined in C.
@z
@x
@ Files can be closed with the \ph\ routine `|close(f)|', which
@^system dependencies@>
should be used when all input or output with respect to |f| has been completed.
This makes |f| available to be opened again, if desired; and if |f| was used for
output, the |close| operation makes the corresponding external file appear
on the user's area, ready to be read.
These procedures should not generate error messages if a file is
being closed before it has been successfully opened.
@p procedure a_close(var f:alpha_file); {close a text file}
begin close(f);
end;
@#
procedure b_close(var f:byte_file); {close a binary file}
begin close(f);
end;
@#
procedure w_close(var f:word_file); {close a word file}
begin close(f);
end;
@y
@ And all the file closing routines as well.
@z
@x
@!buffer:array[0..buf_size] of packed_ASCII_code; {lines of characters being read}
@y
@!buffer:^packed_ASCII_code; {lines of characters being read}
@z
@x
@p function input_ln(var f:alpha_file;@!bypass_eoln:boolean):boolean;
{inputs the next line or returns |false|}
var last_nonblank:0..buf_size; {|last| with trailing blanks removed}
begin if bypass_eoln then if not eof(f) then get(f);
{input the first character of the line into |f^|}
last:=first; {cf.\ Matthew 19\thinspace:\thinspace30}
if eof(f) then input_ln:=false
else begin last_nonblank:=first;
while not eoln(f) do
begin if last>=max_buf_stack then
begin max_buf_stack:=last+1;
if max_buf_stack=buf_size then
@<Report overflow of the input buffer, and abort@>;
end;
buffer[last]:=f^; get(f); incr(last);
if buffer[last-1]<>" " then last_nonblank:=last;
end;
last:=last_nonblank; input_ln:=true;
end;
end;
@y
We define |input_ln| in C, for efficiency. Nevertheless we quote the module
`Report overflow of the input buffer, and abort' here in order to make
\.{WEAVE} happy, since part of that module is needed by e-TeX.
@p @{ @<Report overflow of the input buffer, and abort@> @}
@z
@x
@<Glob...@>=
@!term_in:alpha_file; {the terminal as an input file}
@!term_out:alpha_file; {the terminal as an output file}
@y
@d term_in==stdin {the terminal as an input file}
@d term_out==stdout {the terminal as an output file}
@<Glob...@>=
@!init
@!ini_version:boolean; {are we \.{INITEX}?}
@!dump_option:boolean; {was the dump name option used?}
@!dump_line:boolean; {was a \.{\%\AM format} line seen?}
tini@/
@#
@!bound_default:integer; {temporary for setup}
@!bound_name:^char; {temporary for setup}
@#
@!error_line:integer; {width of context lines on terminal error messages}
@!half_error_line:integer; {width of first lines of contexts in terminal
error messages; should be between 30 and |error_line-15|}
@!max_print_line:integer;
{width of longest text lines output; should be at least 60}
@!ocp_list_size:integer;
@!ocp_buf_size:integer;
@!ocp_stack_size:integer;
@!max_strings:integer; {maximum number of strings; must not exceed |max_halfword|}
@!strings_free:integer; {strings available after format loaded}
@!string_vacancies:integer; {the minimum number of characters that should be
available for the user's control sequences and font names,
after \TeX's own error messages are stored}
@!pool_size:integer; {maximum number of characters in strings, including all
error messages and help texts, and the names of all fonts and
control sequences; must exceed |string_vacancies| by the total
length of \TeX's own strings, which is currently about 23000}
@!pool_free:integer;{pool space free after format loaded}
@!font_k:integer; {loop variable for initialization}
@!buf_size:integer; {maximum number of characters simultaneously present in
current lines of open files and in control sequences between
\.{\\csname} and \.{\\endcsname}; must not exceed |max_halfword|}
@!stack_size:integer; {maximum number of simultaneous input sources}
@!max_in_open:integer; {maximum number of input files and error insertions that
can be going on simultaneously}
@!param_size:integer; {maximum number of simultaneous macro parameters}
@!nest_size:integer; {maximum number of semantic levels simultaneously active}
@!save_size:integer; {space for saving values outside of current group; must be
at most |max_halfword|}
@!dvi_buf_size:integer; {size of the output buffer; must be a multiple of 8}
@!expand_depth:integer; {limits recursive calls of the |expand| procedure}
@!parsefirstlinep:cinttype; {parse the first line for options}
@!filelineerrorstylep:cinttype; {format messages as file:line:error}
@!haltonerrorp:cinttype; {stop at first error}
@!quoted_filename:boolean; {current filename is quoted}
{Variables for source specials}
@!srcspecialsp : boolean;{Whether |src_specials| are enabled at all}
@!insertsrcspecialauto : boolean;
@!insertsrcspecialeverypar : boolean;
@!insertsrcspecialeveryparend : boolean;
@!insertsrcspecialeverycr : boolean;
@!insertsrcspecialeverymath : boolean;
@!insertsrcspecialeveryhbox : boolean;
@!insertsrcspecialeveryvbox : boolean;
@!insertsrcspecialeverydisplay : boolean;
@z
@x
@ Here is how to open the terminal files
in \ph. The `\.{/I}' switch suppresses the first |get|.
@^system dependencies@>
@d t_open_in==reset(term_in,'TTY:','/O/I') {open the terminal for text input}
@d t_open_out==rewrite(term_out,'TTY:','/O') {open the terminal for text output}
@y
@ Here is how to open the terminal files. |t_open_out| does nothing.
|t_open_in|, on the other hand, does the work of ``rescanning,'' or getting
any command line arguments the user has provided. It's defined in C.
@d t_open_out == {output already open for text output}
@z
@x
these operations can be specified in \ph:
@^system dependencies@>
@d update_terminal == break(term_out) {empty the terminal output buffer}
@d clear_terminal == break_in(term_in,true) {clear the terminal input buffer}
@y
these operations can be specified with {\mc UNIX}. |update_terminal|
does an |fflush|. |clear_terminal| is redefined
to do nothing, since the user should control the terminal.
@^system dependencies@>
@d update_terminal == fflush (term_out)
@d clear_terminal == do_nothing
@z
@x
@<Report overflow of the input buffer, and abort@>=
if format_ident=0 then
begin writeln(term_out,'Buffer size exceeded!'); goto final_end;
@.Buffer size exceeded@>
end
else
check_buffer_overflow(buf_size+10) { need a little bit more}
@y
@<Report overflow of the input buffer, and abort@>=
check_buffer_overflow(buf_size+10) { need a little bit more}
@z
@x
@ The following program does the required initialization
without retrieving a possible command line.
It should be clear how to modify this routine to deal with command lines,
if the system permits them.
@^system dependencies@>
@p function init_terminal:boolean; {gets the terminal input started}
label exit;
begin t_open_in;
@y
@ The following program does the required initialization.
Iff anything has been specified on the command line, then |t_open_in|
will return with |last > first|.
@^system dependencies@>
@p function init_terminal:boolean; {gets the terminal input started}
label exit;
begin t_open_in;
if last > first then
begin loc := first;
while (loc < last) and (buffer[loc]=' ') do incr(loc);
if loc < last then
begin init_terminal := true; goto exit;
end;
end;
@z
@x
write(term_out,'! End of file on the terminal... why?');
@y
writeln(term_out,'! End of file on the terminal... why?');
@z
@x
@!str_pool:packed array[pool_pointer] of packed_ASCII_code; {the characters}
@!str_start : array[str_number] of pool_pointer; {the starting pointers}
@y
@!str_pool: ^packed_ASCII_code; {the characters}
@!str_start : ^pool_pointer; {the starting pointers}
@z
@x
@p @!init function get_strings_started:boolean; {initializes the string pool,
@y
@p @t\4@>@<Declare additional routines for string recycling@>@/
@!init function get_strings_started:boolean; {initializes the string pool,
@z
@x
would like string @'32 to be the single character @'32 instead of the
@y
would like string @'32 to be printed as the single character @'32
instead of the
@z
@x
@!trick_buf:array[0..error_line] of packed_ASCII_code; {circular buffer for
@y
@!trick_buf:array[0..ssup_error_line] of packed_ASCII_code; {circular buffer for
@z
@x
@d error_stop_mode=3 {stops at every opportunity to interact}
@y
@d error_stop_mode=3 {stops at every opportunity to interact}
@d unspecified_mode=4 {extra value for command-line switch}
@z
@x
print_nl("! "); print(#);
@y
if filelineerrorstylep then print_file_line
else print_nl("! ");
print(#);
@z
@x
@!interaction:batch_mode..error_stop_mode; {current level of interaction}
@y
@!interaction:batch_mode..error_stop_mode; {current level of interaction}
@!interactionoption:batch_mode..unspecified_mode; {set from command line}
@z
@x
@ @<Set init...@>=interaction:=error_stop_mode;
@y
@ @<Set init...@>=if interactionoption=unspecified_mode then
interaction:=error_stop_mode
else
interaction:=interactionoption;
@z
@x
@<Error hand...@>=
procedure jump_out;
begin goto end_of_TEX;
end;
@y
@d do_final_end==begin
update_terminal;
ready_already:=0;
if (history <> spotless) and (history <> warning_issued) then
uexit(1)
else
uexit(0);
end
@<Error hand...@>=
procedure jump_out;
begin
close_files_and_terminate;
do_final_end;
end;
@z
@x
show_context;
@y
show_context;
if (haltonerrorp) then begin
history:=fatal_error_stop; jump_out;
end;
@z
@x
line ready to be edited. But such an extension requires some system
wizardry, so the present implementation simply types out the name of the
file that should be
edited and the relevant line number.
@^system dependencies@>
There is a secret `\.D' option available when the debugging routines haven't
been commented~out.
@^debugging@>
@y
line ready to be edited.
We do this by calling the external procedure |calledit| with a pointer to
the filename, its length, and the line number.
However, here we just set up the variables that will be used as arguments,
since we don't want to do the switch-to-editor until after TeX has closed
its files.
@^system dependencies@>
There is a secret `\.D' option available when the debugging routines haven't
been commented~out.
@^debugging@>
@d edit_file==input_stack[base_ptr]
@z
@x
"E": if base_ptr>0 then
begin print_nl("You want to edit file ");
@.You want to edit file x@>
slow_print(input_stack[base_ptr].name_field);
print(" at line "); print_int(line);
interaction:=scroll_mode; jump_out;
@y
"E": if base_ptr>0 then
begin edit_name_start:=str_start_macro(edit_file.name_field);
edit_name_length:=str_start_macro(edit_file.name_field+1) -
str_start_macro(edit_file.name_field);
edit_line:=line;
jump_out;
@z
@x
|remainder|, holds the remainder after a division.
@<Glob...@>=
@y
|remainder|, holds the remainder after a division.
@d remainder==tex_remainder
@<Glob...@>=
@z
@x
@!glue_ratio=real; {one-word representation of a glue expansion factor}
@y
@z
@x
macros are simplified in the obvious way when |min_quarterword=0|.
@^inner loop@>@^system dependencies@>
@d qi(#)==#+min_quarterword
{to put an |eight_bits| item into a quarterword}
@d qo(#)==#-min_quarterword
{to take an |eight_bits| item out of a quarterword}
@d hi(#)==#+min_halfword
{to put a sixteen-bit item into a halfword}
@d ho(#)==#-min_halfword
{to take a sixteen-bit item from a halfword}
@y
macros are simplified in the obvious way when |min_quarterword=0|.
So they have been simplified here in the obvious way.
@^inner loop@>@^system dependencies@>
@d qi(#)==# {to put an |eight_bits| item into a quarterword}
@d qo(#)==# {to take an |eight_bits| item from a quarterword}
@d hi(#)==# {to put a sixteen-bit item into a halfword}
@d ho(#)==# {to take a sixteen-bit item from a halfword}
@z
@x
@!quarterword = min_quarterword..max_quarterword; {1/4 of a word}
@!halfword=min_halfword..max_halfword; {1/2 of a word}
@!two_choices = 1..2; {used when there are two variants in a record}
@!four_choices = 1..4; {used when there are four variants in a record}
@!two_halves = packed record@;@/
@!rh:halfword;
case two_choices of
1: (@!lh:halfword);
2: (@!b0:quarterword; @!b1:quarterword);
end;
@!four_quarters = packed record@;@/
@!b0:quarterword;
@!b1:quarterword;
@!b2:quarterword;
@!b3:quarterword;
end;
@!memory_word = record@;@/
case four_choices of
1: (@!int:integer);
2: (@!gr:glue_ratio);
3: (@!hh:two_halves);
4: (@!qqqq:four_quarters);
end;
@y
@!quarterword = min_quarterword..max_quarterword;
@!halfword = min_halfword..max_halfword;
@!two_choices = 1..2; {used when there are two variants in a record}
@!four_choices = 1..4; {used when there are four variants in a record}
@=#include "texmfmem.h";@>
@z
@x
if abs(vmem(p+glue_offset).int)<@'4000000 then print("?.?")
else if abs(g)>float_constant(20000) then
@y
{ The Unix |pc| folks removed this restriction with a remark that
invalid bit patterns were vanishingly improbable, so we follow
their example without really understanding it.
|if abs(vmem(p+glue_offset).int)<@'4000000 then print('?.?')|
|else| }
if fabs(g)>float_constant(20000) then
@z
@x
begin if m>0 then
case m div (max_command+1) of
0:print("vertical");
1:print("horizontal");
2:print("display math");
end
else if m=0 then print("no")
else case (-m) div (max_command+1) of
0:print("internal vertical");
1:print("restricted horizontal");
2:print("math");
end;
print(" mode");
end;
@y
begin if m>0 then
case m div (max_command+1) of
0:print("vertical mode");
1:print("horizontal mode");
2:print("display math mode");
end
else if m=0 then print("no mode")
else case (-m) div (max_command+1) of
0:print("internal vertical mode");
1:print("restricted horizontal mode");
2:print("math mode");
end;
end;
procedure print_in_mode(@!m:integer); {prints the mode represented by |m|}
begin if m>0 then
case m div (max_command+1) of
0:print("' in vertical mode");
1:print("' in horizontal mode");
2:print("' in display math mode");
end
else if m=0 then print("' in no mode")
else case (-m) div (max_command+1) of
0:print("' in internal vertical mode");
1:print("' in restricted horizontal mode");
2:print("' in math mode");
end;
end;
@z
@x
@!nest:array[0..nest_size] of list_state_record;
@y
@!nest:^list_state_record;
@z
@x
local_par:=null; local_par_bool:=false;
@<Start a new current page@>;
@y
local_par:=null; local_par_bool:=false;
@/{The following piece of code is a copy of module 991:}
page_contents:=empty; page_tail:=page_head; {|link(page_head):=null;|}@/
last_glue:=max_halfword; last_penalty:=0; last_kern:=0;
page_depth:=0; page_max_depth:=0;
@z
@x
print_int(nest[p].pg_field); print(" line");
if nest[p].pg_field<>1 then print_char("s");
@y
print_int(nest[p].pg_field);
if nest[p].pg_field<>1 then print(" lines")
else print(" line");
@z
@x
@d frozen_null_font=frozen_control_sequence+12
{permanent `\.{\\nullfont}'}
@y
@d frozen_special=frozen_control_sequence+12
{permanent `\.{\\special}'}
@d frozen_null_font=frozen_control_sequence+13
{permanent `\.{\\nullfont}'}
@z
@x
for k:=active_base to undefined_control_sequence-1 do
eqtb[k]:=eqtb[undefined_control_sequence];
@y
for k:=active_base to eqtb_top do
eqtb[k]:=eqtb[undefined_control_sequence];
@z
@x
@ The following procedure, which is called just before \TeX\ initializes its
input and output, establishes the initial values of the date and time.
@^system dependencies@>
Since standard \PASCAL\ cannot provide such information, something special
is needed. The program here simply specifies July 4, 1776, at noon; but
users probably want a better approximation to the truth.
@p procedure fix_date_and_time;
begin time:=12*60; {minutes since midnight}
day:=4; {fourth day of the month}
month:=7; {seventh month of the year}
year:=1776; {Anno Domini}
end;
@y
@ The following procedure, which is called just before \TeX\ initializes its
input and output, establishes the initial values of the date and time.
It calls a macro-defined |date_and_time| routine. |date_and_time|
in turn is a C macro, which calls |get_date_and_time|, passing
it the addresses of the day, month, etc., so they can be set by the
routine. |get_date_and_time| also sets up interrupt catching if that
is conditionally compiled in the C code.
@^system dependencies@>
@d fix_date_and_time==dateandtime(time,day,month,year)
@z
@x
else if n<glue_base then @<Show equivalent |n|, in region 1 or 2@>
@y
else if (n<glue_base) or ((n>eqtb_size)and(n<=eqtb_top)) then
@<Show equivalent |n|, in region 1 or 2@>
@z
@x
@!eqtb:array[active_base..eqtb_size] of memory_word;
@y
@!zeqtb:^memory_word;
@z
@x
@!hash: array[hash_base..undefined_control_sequence-1] of two_halves;
{the hash table}
@!hash_used:pointer; {allocation pointer for |hash|}
@y
@!hash: ^two_halves; {the hash table}
@!yhash: ^two_halves; {auxiliary pointer for freeing hash}
@!hash_used:pointer; {allocation pointer for |hash|}
@!hash_extra:pointer; {|hash_extra=hash| above |eqtb_size|}
@!hash_top:pointer; {maximum of the hash array}
@!eqtb_top:pointer; {maximum of the |eqtb|}
@!hash_high:pointer; {pointer to next high hash location}
@z
@x
next(hash_base):=0; text(hash_base):=0;
for k:=hash_base+1 to undefined_control_sequence-1 do hash[k]:=hash[hash_base];
@y
@z
@x
hash_used:=frozen_control_sequence; {nothing is used}
@y
hash_used:=frozen_control_sequence; {nothing is used}
hash_high:=0;
@z
@x
@ @<Insert a new control...@>=
begin if text(p)>0 then
begin repeat if hash_is_full then overflow("hash size",hash_size);
@:TeX capacity exceeded hash size}{\quad hash size@>
decr(hash_used);
until text(hash_used)=0; {search for an empty location in |hash|}
next(p):=hash_used; p:=hash_used;
end;
@y
@ @<Insert a new control...@>=
begin if text(p)>0 then
begin if hash_high<hash_extra then
begin incr(hash_high);
next(p):=hash_high+eqtb_size; p:=hash_high+eqtb_size;
end
else begin
repeat if hash_is_full then overflow("hash size",hash_size+hash_extra);
@:TeX capacity exceeded hash size}{\quad hash size@>
decr(hash_used);
until text(hash_used)=0; {search for an empty location in |hash|}
next(p):=hash_used; p:=hash_used;
end;
end;
@z
@x
else if p>=undefined_control_sequence then print_esc("IMPOSSIBLE.")
@y
else if ((p>=undefined_control_sequence)and(p<=eqtb_size))or(p>eqtb_top) then
print_esc("IMPOSSIBLE.")
@z
@x
else if (text(p)<0)or(text(p)>=str_ptr) then print_esc("NONEXISTENT.")
@y
else if (text(p)>=str_ptr) then print_esc("NONEXISTENT.")
@z
@x
@!save_stack : array[0..save_size] of memory_word;
@y
@!save_stack : ^memory_word;
@z
@x
if p<int_base then
@y
if (p<int_base)or(p>eqtb_size) then
@z
@x
if cs_token_flag+undefined_control_sequence>max_halfword then bad:=21;
@y
if cs_token_flag+eqtb_size+hash_extra>max_halfword then bad:=21;
if (hash_offset<0)or(hash_offset>hash_base) then bad:=42;
@z
@x
@!input_stack : array[0..stack_size] of in_state_record;
@y
@!input_stack : ^in_state_record;
@z
@x
@!input_file : array[1..max_in_open] of alpha_file;
@!line : integer; {current line number in the current source file}
@!line_stack : array[1..max_in_open] of integer;
@y
@!input_file : ^alpha_file;
@!line : integer; {current line number in the current source file}
@!line_stack : ^integer;
@!source_filename_stack : ^str_number;
@!full_source_filename_stack : ^str_number;
@z
@x
begin print_nl("Runaway ");
@.Runaway...@>
case scanner_status of
defining: begin print("definition"); p:=def_ref;
end;
matching: begin print("argument"); p:=temp_token_head;
end;
aligning: begin print("preamble"); p:=hold_token_head;
end;
absorbing: begin print("text"); p:=def_ref;
end;
end; {there are no other cases}
@y
begin
@.Runaway...@>
case scanner_status of
defining: begin print_nl("Runaway definition"); p:=def_ref;
end;
matching: begin print_nl("Runaway argument"); p:=temp_token_head;
end;
aligning: begin print_nl("Runaway preamble"); p:=hold_token_head;
end;
absorbing: begin print_nl("Runaway text"); p:=def_ref;
end;
end; {there are no other cases}
@z
@x
@!param_stack:array [0..param_size] of pointer;
{token list pointers for parameters}
@y
@!param_stack: ^pointer;
{token list pointers for parameters}
@z
@x
incr(in_open); push_input; index:=in_open;
@y
incr(in_open); push_input; index:=in_open;
source_filename_stack[index]:=0;full_source_filename_stack[index]:=0;
@z
@x
begin input_ptr:=0; max_in_stack:=0;
@y
begin input_ptr:=0; max_in_stack:=0;
source_filename_stack[0]:=0;full_source_filename_stack[0]:=0;
@z
@x
if_eof_code: begin scan_four_bit_int; b:=(read_open[cur_val]=closed);
end;
@y
if_eof_code: begin scan_four_bit_int_or_18;
if cur_val=18 then b:=not shellenabledp
else b:=(read_open[cur_val]=closed);
end;
@z
@x
@ The file names we shall deal with for illustrative purposes have the
following structure: If the name contains `\.>' or `\.:', the file area
consists of all characters up to and including the final such character;
otherwise the file area is null. If the remaining file name contains
`\..', the file extension consists of all such characters from the first
remaining `\..' to the end, otherwise the file extension is null.
@y
@ The file names we shall deal with have the
following structure: If the name contains `\./' or `\.:'
(for Amiga only), the file area
consists of all characters up to and including the final such character;
otherwise the file area is null. If the remaining file name contains
`\..', the file extension consists of all such characters from the last
`\..' to the end, otherwise the file extension is null.
@z
@x
@!area_delimiter:pool_pointer; {the most recent `\.>' or `\.:', if any}
@!ext_delimiter:pool_pointer; {the relevant `\..', if any}
@y
@!area_delimiter:pool_pointer; {the most recent `\./', if any}
@!ext_delimiter:pool_pointer; {the most recent `\..', if any}
@z
@x
@d TEX_area=="TeXinputs:"
@.TeXinputs@>
@d TEX_font_area=="TeXfonts:"
@.TeXfonts@>
@y
In C, the default paths are specified separately.
@z
@x
begin area_delimiter:=0; ext_delimiter:=0;
@y
begin area_delimiter:=0; ext_delimiter:=0; quoted_filename:=false;
@z
@x
begin if c=" " then more_name:=false
@y
begin if (c=" ") and stop_at_space and (not quoted_filename) then
more_name:=false
else if c="""" then begin
quoted_filename:=not quoted_filename;
more_name:=true;
end
@z
@x
if (c=">")or(c=":") then
@y
if ISDIRSEP(c) then
@z
@x
else if (c=".")and(ext_delimiter=0) then ext_delimiter:=cur_length;
@y
else if c="." then ext_delimiter:=cur_length;
@z
@x
@ The third.
@^system dependencies@>
@p procedure end_name;
@y
@ The third.
@^system dependencies@>
If a string is already in the string pool, the function
|slow_make_string| does not create a new string but returns this string
number, thus saving string space. Because of this new property of the
returned string number it is not possible to apply |flush_string| to
these strings.
@p procedure end_name;
var temp_str: str_number; {result of file name cache lookups}
@!j,@!s,@!t: pool_pointer; {running indices}
@!must_quote:boolean; {whether we need to quote a string}
@z
@x
@:TeX capacity exceeded number of strings}{\quad number of strings@>
@y
@:TeX capacity exceeded number of strings}{\quad number of strings@>
str_room(6); {Room for quotes, if needed.}
{add quotes if needed}
if area_delimiter<>0 then begin
{maybe quote |cur_area|}
must_quote:=false;
s:=str_start_macro(str_ptr);
t:=str_start_macro(str_ptr)+area_delimiter;
j:=s;
while (not must_quote) and (j<t) do begin
must_quote:=str_pool[j]=" "; incr(j);
end;
if must_quote then begin
for j:=pool_ptr-1 downto t do str_pool[j+2]:=str_pool[j];
str_pool[t+1]:="""";
for j:=t-1 downto s do str_pool[j+1]:=str_pool[j];
str_pool[s]:="""";
if ext_delimiter<>0 then ext_delimiter:=ext_delimiter+2;
area_delimiter:=area_delimiter+2;
pool_ptr:=pool_ptr+2;
end;
end;
{maybe quote |cur_name|}
s:=str_start_macro(str_ptr)+area_delimiter;
if ext_delimiter=0 then t:=pool_ptr else t:=str_start_macro(str_ptr)+ext_delimiter-1;
must_quote:=false;
j:=s;
while (not must_quote) and (j<t) do begin
must_quote:=str_pool[j]=" "; incr(j);
end;
if must_quote then begin
for j:=pool_ptr-1 downto t do str_pool[j+2]:=str_pool[j];
str_pool[t+1]:="""";
for j:=t-1 downto s do str_pool[j+1]:=str_pool[j];
str_pool[s]:="""";
if ext_delimiter<>0 then ext_delimiter:=ext_delimiter+2;
pool_ptr:=pool_ptr+2;
end;
if ext_delimiter<>0 then begin
{maybe quote |cur_ext|}
s:=str_start_macro(str_ptr)+ext_delimiter-1;
t:=pool_ptr;
must_quote:=false;
j:=s;
while (not must_quote) and (j<t) do begin
must_quote:=str_pool[j]=" "; incr(j);
end;
if must_quote then begin
str_pool[t+1]:="""";
for j:=t-1 downto s do str_pool[j+1]:=str_pool[j];
str_pool[s]:="""";
pool_ptr:=pool_ptr+2;
end;
end;
@z
@x
str_start_macro(str_ptr+1):=str_start_macro(str_ptr)+area_delimiter; incr(str_ptr);
end;
if ext_delimiter=0 then
begin cur_ext:=""; cur_name:=make_string;
@y
str_start_macro(str_ptr+1):=str_start_macro(str_ptr)+area_delimiter; incr(str_ptr);
temp_str:=search_string(cur_area);
if temp_str>0 then
begin cur_area:=temp_str;
decr(str_ptr); {no |flush_string|, |pool_ptr| will be wrong!}
for j:=str_start_macro(str_ptr+1) to pool_ptr-1 do
begin str_pool[j-area_delimiter]:=str_pool[j];
end;
pool_ptr:=pool_ptr-area_delimiter; {update |pool_ptr|}
end;
end;
if ext_delimiter=0 then
begin cur_ext:=""; cur_name:=slow_make_string;
@z
@x
else begin cur_name:=str_ptr;
str_start_macro(str_ptr+1):=str_start_macro(str_ptr)+ext_delimiter-area_delimiter-1;
incr(str_ptr); cur_ext:=make_string;
@y
else begin cur_name:=str_ptr;
str_start_macro(str_ptr+1):=str_start_macro(str_ptr)+ext_delimiter-area_delimiter-1;
incr(str_ptr); cur_ext:=make_string;
decr(str_ptr); {undo extension string to look at name part}
temp_str:=search_string(cur_name);
if temp_str>0 then
begin cur_name:=temp_str;
decr(str_ptr); {no |flush_string|, |pool_ptr| will be wrong!}
for j:=str_start_macro(str_ptr+1) to pool_ptr-1 do
begin str_pool[j-ext_delimiter+area_delimiter+1]:=str_pool[j];
end;
pool_ptr:=pool_ptr-ext_delimiter+area_delimiter+1; {update |pool_ptr|}
end;
cur_ext:=slow_make_string; {remake extension string}
@z
@x
begin slow_print(a); slow_print(n); slow_print(e);
@y
var must_quote: boolean; {whether to quote the filename}
@!j:pool_pointer; {index into |str_pool|}
begin
must_quote:=false;
if a<>0 then begin
j:=str_start_macro(a);
while (not must_quote) and (j<str_start_macro(a+1)) do begin
must_quote:=str_pool[j]=" "; incr(j);
end;
end;
if n<>0 then begin
j:=str_start_macro(n);
while (not must_quote) and (j<str_start_macro(n+1)) do begin
must_quote:=str_pool[j]=" "; incr(j);
end;
end;
if e<>0 then begin
j:=str_start_macro(e);
while (not must_quote) and (j<str_start_macro(e+1)) do begin
must_quote:=str_pool[j]=" "; incr(j);
end;
end;
{FIXME: Alternative is to assume that any filename that has to be quoted has
at least one quoted component...if we pick this, a number of insertions
of |print_file_name| should go away.
|must_quote|:=((|a|<>0)and(|str_pool|[|str_start|[|a|]]=""""))or
((|n|<>0)and(|str_pool|[|str_start|[|n|]]=""""))or
((|e|<>0)and(|str_pool|[|str_start|[|e|]]=""""));}
if must_quote then print_char("""");
if a<>0 then
for j:=str_start_macro(a) to str_start_macro(a+1)-1 do
if so(str_pool[j])<>"""" then
print(so(str_pool[j]));
if n<>0 then
for j:=str_start_macro(n) to str_start_macro(n+1)-1 do
if so(str_pool[j])<>"""" then
print(so(str_pool[j]));
if e<>0 then
for j:=str_start_macro(e) to str_start_macro(e+1)-1 do
if so(str_pool[j])<>"""" then
print(so(str_pool[j]));
if must_quote then print_char("""");
@z
@x
@d append_to_name(#)==begin c:=#; incr(k);
if k<=file_name_size then nameoffile[k]:=xchr[c];
end
@y
@d append_to_name(#)==begin c:=#; if not (c="""") then begin incr(k);
if k<=file_name_size then nameoffile[k]:=xchr[c];
end end
@z
@x
for j:=str_start_macro(a) to str_start_macro(a+1)-1 do append_to_name(so(str_pool[j]));
@y
if nameoffile then libcfree (nameoffile);
nameoffile:= xmallocarray (packed_ASCII_code, length(a)+length(n)+length(e)+1);
for j:=str_start_macro(a) to str_start_macro(a+1)-1 do append_to_name(so(str_pool[j]));
@z
@x
for k:=namelength+1 to file_name_size do nameoffile[k]:=' ';
@y
nameoffile[namelength+1]:=0;
@z
@x
@d format_default_length=20 {length of the |TEX_format_default| string}
@d format_area_length=11 {length of its area part}
@d format_ext_length=4 {length of its `\.{.fmt}' part}
@y
Under {\mc UNIX} we don't give the area part, instead depending
on the path searching that will happen during file opening. Also, the
length will be set in the main program.
@d format_area_length=0 {length of its area part}
@d format_ext_length=4 {length of its `\.{.fmt}' part}
@z
@x
@!TEX_format_default:packed array[1..format_default_length] of char;
@ @<Set init...@>=
TEX_format_default:='TeXformats:plain.fmt';
@y
@!format_default_length: integer;
@!TEX_format_default: ^char;
@ We set the name of the default format file and the length of that name
in C, instead of Pascal, since we want them to depend on the name of the
program.
@z
@x
for j:=1 to n do append_to_name(TEX_format_default[j]);
@y
if nameoffile then libcfree (nameoffile);
nameoffile := xmallocarray (packed_ASCII_code, n+(b-a+1)+format_ext_length+1);
for j:=1 to n do append_to_name(TEX_format_default[j]);
@z
@x
for k:=namelength+1 to file_name_size do nameoffile[k]:=' ';
@y
nameoffile[namelength+1]:=0;
@z
@x
pack_buffered_name(0,loc,j-1); {try first without the system file area}
if w_open_in(fmt_file) then goto found;
pack_buffered_name(format_area_length,loc,j-1);
{now try the system format file area}
if w_open_in(fmt_file) then goto found;
@y
pack_buffered_name(0,loc,j-1); {Kpathsea does everything}
if w_open_in(fmt_file) then goto found;
@z
@x
wterm_ln('Sorry, I can''t find that format;',' will try PLAIN.');
@y
wterm ('Sorry, I can''t find the format `');
fputs (stringcast(nameoffile + 1), stdout);
wterm ('''; will try `');
fputs (TEX_format_default + 1, stdout);
wterm_ln ('''.');
@z
@x
wterm_ln('I can''t find the PLAIN format file!');
@.I can't find PLAIN...@>
@y
wterm ('I can''t find the format file `');
fputs (TEX_format_default + 1, stdout);
wterm_ln ('''!');
@.I can't find the format...@>
@z
@x
@p function make_name_string:str_number;
var k:1..file_name_size; {index into |nameoffile|}
begin if (pool_ptr+namelength>pool_size)or(str_ptr=max_strings)or
(cur_length>0) then
make_name_string:="?"
else begin for k:=1 to namelength do append_char(nameoffile[k]);
make_name_string:=make_string;
end;
@y
@p function make_name_string:str_number;
var k:1..file_name_size; {index into |nameoffile|}
save_area_delimiter, save_ext_delimiter: pool_pointer;
save_name_in_progress, save_stop_at_space: boolean;
begin if (pool_ptr+namelength>pool_size)or(str_ptr=max_strings)or
(cur_length>0) then
make_name_string:="?"
else begin for k:=1 to namelength do append_char(nameoffile[k]);
make_name_string:=make_string;
{At this point we also set |cur_name|, |cur_ext|, and |cur_area| to
match the contents of |nameoffile|.}
save_area_delimiter:=area_delimiter;
save_ext_delimiter:=ext_delimiter;
save_name_in_progress:=name_in_progress;
save_stop_at_space:=stop_at_space;
name_in_progress:=true;
begin_name;
stop_at_space:=false;
k:=1;
while (k<=namelength)and(more_name(nameoffile[k])) do
incr(k);
stop_at_space:=save_stop_at_space;
end_name;
name_in_progress:=save_name_in_progress;
area_delimiter:=save_area_delimiter;
ext_delimiter:=save_ext_delimiter;
end;
@z
@x
if not more_name(cur_chr) then goto done;
@y
{If |cur_chr| is a space and we're not scanning a token list, check
whether we're at the end of the buffer. Otherwise we end up adding
spurious spaces to file names in some cases.}
if (cur_chr=" ") and (state<>token_list) and (loc>limit) then goto done;
if not more_name(cur_chr) then goto done;
@z
@x
var k:0..buf_size; {index into |buffer|}
@y
var k:0..buf_size; {index into |buffer|}
@!saved_cur_name:str_number; {to catch empty terminal input}
@z
@x
if e=".tex" then show_context;
@y
if (e=".tex") or (e="") then show_context;
@z
@x
clear_terminal; prompt_input(": "); @<Scan file name in the buffer@>;
if cur_ext="" then cur_ext:=e;
@y
saved_cur_name:=cur_name;
clear_terminal; prompt_input(": "); @<Scan file name in the buffer@>;
if cur_ext="" then cur_ext:=e;
if length(cur_name)=0 then cur_name:=saved_cur_name;
@z
@x
@d ensure_dvi_open==if output_file_name=0 then
@y
@d log_name == texmf_log_name
@d ensure_dvi_open==if output_file_name=0 then
@z
@x
@!months:packed array [1..36] of char; {abbreviations of month names}
@y
@!months:^char;
@z
@x
if job_name=0 then job_name:="texput";
@.texput@>
@y
if job_name=0 then job_name:=getjobname("texput");
@.texput@>
pack_job_name(".fls");
recorder_change_filename(stringcast(nameoffile+1));
@z
@x
begin wlog(banner);
@y
begin if srcspecialsp or filelineerrorstylep or parsefirstlinep
then
wlog(banner_k)
else
wlog(banner);
@z
@x
slow_print(format_ident); print(" ");
@y
wlog(versionstring);
slow_print(format_ident); print(" ");
@z
@x
months:='JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC';
@y
months := ' JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC';
@z
@x
end
@y
if shellenabledp then begin
wlog_cr;
wlog(' ');
if restrictedshell then begin
wlog('restricted ');
end;
wlog('\write18 enabled.')
end;
if srcspecialsp then begin
wlog_cr;
wlog(' Source specials enabled.')
end;
if filelineerrorstylep then begin
wlog_cr;
wlog(' file:line:error style messages enabled.')
end;
if parsefirstlinep then begin
wlog_cr;
wlog(' %&-line parsing enabled.');
end;
end
@z
@x
prompt_file_name("input file name",".tex");
@y
prompt_file_name("input file name","");
@z
@x
name:=a_make_name_string(cur_file);
@y
name:=a_make_name_string(cur_file);
source_filename_stack[in_open]:=name;
full_source_filename_stack[in_open]:=makefullnamestring;
if name=str_ptr-1 then {we can try to conserve string pool space now}
begin temp_str:=search_string(name);
if temp_str>0 then
begin name:=temp_str; flush_string;
end;
end;
@z
@x
begin job_name:=cur_name; open_log_file;
@y
begin job_name:=getjobname(cur_name); open_log_file;
@z
@x
if name=str_ptr-1 then {we can conserve string pool space now}
begin flush_string; name:=cur_name;
end;
@y
@z
@x
@!ocp_list_info:array[ocp_list_index] of memory_word;
{the big collection of ocp list data}
@!ocp_listmem_ptr:ocp_list_index; {first unused word of |ocp_list_info|}
@!ocp_listmem_run_ptr:ocp_list_index; {temp unused word of |ocp_list_info|}
@!ocp_lstack_info:array[ocp_lstack_index] of memory_word;
{the big collection of ocp lstack data}
@!ocp_lstackmem_ptr:ocp_lstack_index; {first unused word of |ocp_lstack_info|}
@!ocp_lstackmem_run_ptr:ocp_lstack_index; {temp unused word of |ocp_lstack_info|}
@!ocp_list_ptr:internal_ocp_list_number; {largest internal ocp list number in use}
@!ocp_list_list:array[internal_ocp_list_number] of ocp_list_index;
@y
@!ocp_list_info:^memory_word;
{the big collection of ocp list data}
@!ocp_listmem_ptr:ocp_list_index; {first unused word of |ocp_list_info|}
@!ocp_listmem_run_ptr:ocp_list_index; {temp unused word of |ocp_list_info|}
@!ocp_lstack_info:^memory_word;
{the big collection of ocp lstack data}
@!ocp_lstackmem_ptr:ocp_lstack_index; {first unused word of |ocp_lstack_info|}
@!ocp_lstackmem_run_ptr:ocp_lstack_index; {temp unused word of |ocp_lstack_info|}
@!ocp_list_ptr:internal_ocp_list_number; {largest internal ocp list number in use}
@!ocp_list_list:^ocp_list_index;
@z
@x
@!dvi_buf:array[dvi_index] of real_eight_bits; {buffer for \.{DVI} output}
@!half_buf:dvi_index; {half of |dvi_buf_size|}
@!dvi_limit:dvi_index; {end of the current half buffer}
@!dvi_ptr:dvi_index; {the next available buffer address}
@y
@!dvi_buf:^real_eight_bits; {buffer for \.{DVI} output}
@!half_buf:integer; {half of |dvi_buf_size|}
@!dvi_limit:integer; {end of the current half buffer}
@!dvi_ptr:integer; {the next available buffer address}
@z
@x
@p procedure write_dvi(@!a,@!b:dvi_index);
var k:dvi_index;
begin for k:=a to b do write(dvi_file,dvi_buf[k]);
end;
@y
In C, we use a macro to call |fwrite| or |write| directly, writing all
the bytes in one shot. Much better even than writing four
bytes at a time.
@z
@x
old_setting:=selector; selector:=new_string;
@y
if output_comment then
begin l:=strlen(output_comment); dvi_out(l);
for s:=0 to l-1 do dvi_out(output_comment[s]);
end
else begin {the default code is unchanged}
old_setting:=selector; selector:=new_string;
@z
@x
pool_ptr:=str_start_macro(str_ptr); {flush the current string}
@y
pool_ptr:=str_start_macro(str_ptr); {flush the current string}
end;
@z
@x
dvi_out(eop); incr(total_pages); cur_s:=-1;
@y
dvi_out(eop); incr(total_pages); cur_s:=-1;
ifdef ('IPC')
if ipcon>0 then
begin if dvi_limit=half_buf then
begin write_dvi(half_buf, dvi_buf_size-1);
flush_dvi;
dvi_gone:=dvi_gone+half_buf;
end;
if dvi_ptr>0 then
begin write_dvi(0, dvi_ptr-1);
flush_dvi;
dvi_offset:=dvi_offset+dvi_ptr; dvi_gone:=dvi_gone+dvi_ptr;
end;
dvi_ptr:=0; dvi_limit:=dvi_buf_size;
ipcpage(dvi_gone);
end;
endif ('IPC');
@z
@x
k:=4+((dvi_buf_size-dvi_ptr) mod 4); {the number of 223's}
@y
ifdef ('IPC')
k:=7-((3+dvi_offset+dvi_ptr) mod 4); {the number of 223's}
endif ('IPC')
ifndef ('IPC')
k:=4+((dvi_buf_size-dvi_ptr) mod 4); {the number of 223's}
endifn ('IPC')
@z
@x
print_nl("Output written on "); slow_print(output_file_name);
@y
print_nl("Output written on "); print_file_name(0, output_file_name, 0);
@z
@x
print(" ("); print_int(total_pages); print(" page");
if total_pages<>1 then print_char("s");
@y
print(" ("); print_int(total_pages);
if total_pages<>1 then print(" pages")
else print(" page");
@z
@x
@<Append character |cur_chr|...@>=
continue: adjust_space_factor;@/
@y
@<Append character |cur_chr|...@>=
if ((head=tail) and (mode>0)) then begin
if (insertsrcspecialauto) then append_src_special;
end;
continue: adjust_space_factor;@/
@z
@x
print("' in "); print_mode(mode);
@y
print_in_mode(mode);
@z
@x
if indented then begin
p:=new_null_box; box_dir(p):=par_direction;
width(p):=par_indent;@+
tail_append(p);
@y
if indented then begin
p:=new_null_box; box_dir(p):=par_direction;
width(p):=par_indent;@+
tail_append(p);
if (insertsrcspecialeverypar) then insert_src_special;@+
@z
@x
begin print_err("Extra "); print_esc("endcsname");
@.Extra \\endcsname@>
help1("I'm ignoring this, since I wasn't doing a \csname.");
@y
begin
if cur_chr = 10 then
begin
print_err("Extra "); print_esc("endmubyte");
@.Extra \\endmubyte@>
help1("I'm ignoring this, since I wasn't doing a \mubyte.");
end else begin
print_err("Extra "); print_esc("endcsname");
@.Extra \\endcsname@>
help1("I'm ignoring this, since I wasn't doing a \csname.");
end;
@z
@x
if every_math<>null then begin_token_list(every_math,every_math_text);
@y
if (insertsrcspecialeverymath) then insert_src_special;
if every_math<>null then begin_token_list(every_math,every_math_text);
@z
@x
if every_vbox<>null then begin_token_list(every_vbox,every_vbox_text);
@y
if (insertsrcspecialeveryvbox) then insert_src_special;
if every_vbox<>null then begin_token_list(every_vbox,every_vbox_text);
@z
@x
if (cur_cs=0)or(cur_cs>frozen_control_sequence) then
@y
if (cur_cs=0)or(cur_cs>eqtb_top)or
((cur_cs>frozen_control_sequence)and(cur_cs<=eqtb_size)) then
@z
@x
@!flushable_string:str_number; {string not yet referenced}
@y
@z
@x
interaction:=cur_chr;
@y
interaction:=cur_chr;
if interaction = batch_mode
then kpsemaketexdiscarderrors := 1
else kpsemaketexdiscarderrors := 0;
@z
@x
slow_print(s); update_terminal;
@y
print(s); update_terminal;
@z
@x
begin print_err(""); slow_print(s);
@y
begin print_err(""); print(s);
@z
@x
format_ident:=" (INITEX)";
@y
if ini_version then format_ident:=" (INITEX)";
@z
@x
@!w: four_quarters; {four ASCII codes}
@y
@!format_engine: ^packed_ASCII_code;
@z
@x
@!w: four_quarters; {four ASCII codes}
@y
@!format_engine: ^packed_ASCII_code;
@z
@x
@d dump_wd(#)==begin fmt_file^:=#; put(fmt_file);@+end
@d dump_int(#)==begin fmt_file^.int:=#; put(fmt_file);@+end
@d dump_hh(#)==begin fmt_file^.hh:=#; put(fmt_file);@+end
@d dump_qqqq(#)==begin fmt_file^.qqqq:=#; put(fmt_file);@+end
@y
@z
@x
@d undump_wd(#)==begin get(fmt_file); #:=fmt_file^;@+end
@d undump_int(#)==begin get(fmt_file); #:=fmt_file^.int;@+end
@d undump_hh(#)==begin get(fmt_file); #:=fmt_file^.hh;@+end
@d undump_qqqq(#)==begin get(fmt_file); #:=fmt_file^.qqqq;@+end
@y
@z
@x
@d undump_size_end_end(#)==too_small(#)@+else undump_end_end
@y
@d format_debug_end(#)==
writeln (stderr, ' = ', #);
end;
@d format_debug(#)==
if debug_format_file then begin
write (stderr, 'fmtdebug:', #);
format_debug_end
@d undump_size_end_end(#)==
too_small(#)@+else format_debug (#)(x); undump_end_end
@z
@x
dump_int(@$);@/
@y
dump_int(@"57325458); {Web2C \TeX's magic constant: "W2TX"}
{Align engine to 4 bytes with one or more trailing NUL}
x:=strlen(engine_name);
format_engine:=xmallocarray(packed_ASCII_code,x+4);
strcpy(stringcast(format_engine), stringcast(engine_name));
for k:=x to x+3 do format_engine[k]:=0;
x:=x+4-(x mod 4);
dump_int(x);dump_things(format_engine[0], x);
libcfree(format_engine);@/
dump_int(@$);@/
dump_int(max_halfword);@/
dump_int(hash_high);
@z
@x
x:=fmt_file^.int;
if x<>@$ then goto bad_fmt; {check that strings are the same}
@y
@+Init
libcfree(str_pool); libcfree(str_start);
libcfree(yhash); libcfree(zeqtb); libcfree(fixmem); libcfree(varmem);
@+Tini
undump_int(x);
format_debug('format magic number')(x);
if x<>@"57325458 then goto bad_fmt; {not a format file}
undump_int(x);
format_debug('engine name size')(x);
if (x<0) or (x>256) then goto bad_fmt; {corrupted format file}
format_engine:=xmallocarray(packed_ASCII_code, x);
undump_things(format_engine[0], x);
format_engine[x-1]:=0; {force string termination, just in case}
if strcmp(stringcast(engine_name), stringcast(format_engine)) then
begin wake_up_terminal;
wterm_ln('---! ', stringcast(nameoffile+1), ' was written by ', format_engine);
libcfree(format_engine);
goto bad_fmt;
end;
libcfree(format_engine);
undump_int(x);
format_debug('string pool checksum')(x);
if x<>@$ then begin {check that strings are the same}
wake_up_terminal;
wterm_ln('---! ', stringcast(nameoffile+1), ' was written by an older version');
goto bad_fmt;
end;
undump_int(x);
if x<>max_halfword then goto bad_fmt; {check |max_halfword|}
undump_int(hash_high);
if (hash_high<0)or(hash_high>sup_hash_extra) then goto bad_fmt;
if hash_extra<hash_high then hash_extra:=hash_high;
eqtb_top:=eqtb_size+hash_extra;
if hash_extra=0 then hash_top:=undefined_control_sequence else
hash_top:=eqtb_top;
yhash:=xmallocarray(two_halves,1+hash_top-hash_offset);
hash:=yhash - hash_offset;
next(hash_base):=0; text(hash_base):=0;
for x:=hash_base+1 to hash_top do hash[x]:=hash[hash_base];
zeqtb:=xmallocarray (memory_word,eqtb_top+1);
eqtb:=zeqtb;
eq_type(undefined_control_sequence):=undefined_cs;
equiv(undefined_control_sequence):=null;
eq_level(undefined_control_sequence):=level_zero;
for x:=eqtb_size+1 to eqtb_top do
eqtb[x]:=eqtb[undefined_control_sequence];
@z
@x
dump_int(str_ptr);
for k:=string_offset to str_ptr do dump_int(str_start_macro(k));
k:=0;
while k+4<pool_ptr do
begin dump_four_ASCII; k:=k+4;
end;
k:=pool_ptr-4; dump_four_ASCII;
@y
dump_int((str_ptr-string_offset));
dump_things(str_start[0], (str_ptr-string_offset)+1);
dump_things(str_pool[0], pool_ptr);
@z
@x
undump_size(0)(pool_size)('string pool size')(pool_ptr);
undump_size(0)(max_strings)('max strings')(str_ptr);
for k:=string_offset to str_ptr do undump(0)(pool_ptr)(str_start_macro(k));
k:=0;
while k+4<pool_ptr do
begin undump_four_ASCII; k:=k+4;
end;
k:=pool_ptr-4; undump_four_ASCII;
@y
undump_size(0)(sup_pool_size-pool_free)('string pool size')(pool_ptr);
if pool_size<pool_ptr+pool_free then
pool_size:=pool_ptr+pool_free;
undump_size(0)(sup_max_strings-strings_free)('sup strings')(str_ptr);@/
if max_strings<str_ptr+strings_free then
max_strings:=str_ptr+strings_free;
str_start:=xmallocarray(pool_pointer, max_strings);
str_ptr:=str_ptr + string_offset;
undump_checked_things(0, pool_ptr, str_start[0], (str_ptr-string_offset)+1);@/
str_pool:=xmallocarray(packed_ASCII_code, pool_size);
undump_things(str_pool[0], pool_ptr);
@z
@x
for k:=fix_mem_min to fix_mem_end do dump_wd(mem(k));
@y
dump_things(mem(fix_mem_min), fix_mem_end-fix_mem_min+1);
@z
@x
for k:=fix_mem_min to fix_mem_end do undump_wd(mem(k));
@y
undump_things (mem(fix_mem_min), fix_mem_end-fix_mem_min+1);
@z
@x
undump(hash_base)(frozen_control_sequence)(par_loc);
par_token:=cs_token_flag+par_loc;@/
undump(hash_base)(frozen_control_sequence)(write_loc);@/
@y
undump(hash_base)(hash_top)(par_loc);
par_token:=cs_token_flag+par_loc;@/
undump(hash_base)(hash_top)(write_loc);@/
@z
@x
while k<l do
begin dump_wd(eqtb[k]); incr(k);
end;
@y
dump_things(eqtb[k], l-k);
@z
@x
while k<l do
begin dump_wd(eqtb[k]); incr(k);
end;
@y
dump_things(eqtb[k], l-k);
@z
@x
k:=j+1; dump_int(k-l);
until k>eqtb_size
@y
k:=j+1; dump_int(k-l);
until k>eqtb_size;
if hash_high>0 then dump_things(eqtb[eqtb_size+1],hash_high);
{dump |hash_extra| part}
@z
@x
for j:=k to k+x-1 do undump_wd(eqtb[j]);
@y
undump_things(eqtb[k], x);
@z
@x
until k>eqtb_size
@y
until k>eqtb_size;
if hash_high>0 then undump_things(eqtb[eqtb_size+1],hash_high);
{undump |hash_extra| part}
@z
@x
dump_int(hash_used); cs_count:=frozen_control_sequence-1-hash_used;
@y
dump_int(hash_used); cs_count:=frozen_control_sequence-1-hash_used+hash_high;
@z
@x
for p:=hash_used+1 to undefined_control_sequence-1 do dump_hh(hash[p]);
@y
dump_things(hash[hash_used+1], undefined_control_sequence-1-hash_used);
if hash_high>0 then dump_things(hash[eqtb_size+1], hash_high);
@z
@x
for p:=hash_used+1 to undefined_control_sequence-1 do undump_hh(hash[p]);
@y
undump_things (hash[hash_used+1], undefined_control_sequence-1-hash_used);
if debug_format_file then begin
print_csnames (hash_base, undefined_control_sequence - 1);
end;
if hash_high > 0 then begin
undump_things (hash[eqtb_size+1], hash_high);
if debug_format_file then begin
print_csnames (eqtb_size + 1, hash_high - (eqtb_size + 1));
end;
end;
@z
@x
@ @<Undump the array info for internal font number |k|@>=
begin undump_font(k);@/
end
@y
@ @<Undump the array info for internal font number |k|@>=
begin undump_font(k);@/
end;
make_pdftex_banner
@z
@x
for k:=0 to active_max_ptr-1 do dump_wd(active_info[k]);
if active_max_ptr>0 then begin
print_ln; print_int(active_max_ptr); print(" words of active ocps");
end;
@ @<Undump the active ocp information@>=
undump_size(0)(active_mem_size)('active start point')(active_min_ptr);
undump_size(0)(active_mem_size)('active mem size')(active_max_ptr);
for k:=0 to active_max_ptr-1 do undump_wd(active_info[k]);
@y
if active_max_ptr>0 then
dump_things(active_info[0], active_max_ptr);
if active_max_ptr>0 then begin
print_ln; print_int(active_max_ptr); print(" words of active ocps");
end;
@ @<Undump the active ocp information@>=
undump_size(0)(active_mem_size)('active start point')(active_min_ptr);
undump_size(0)(active_mem_size)('active mem size')(active_max_ptr);
if active_max_ptr>0 then
undump_things(active_info[0], active_max_ptr);
@z
@x
@ @<Dump the ocp list information@>=
dump_int(ocp_listmem_ptr);
for k:=0 to ocp_listmem_ptr-1 do dump_wd(ocp_list_info[k]);
dump_int(ocp_list_ptr);
for k:=null_ocp_list to ocp_list_ptr do begin
dump_int(ocp_list_list[k]);
if null_ocp_list<>ocp_list_ptr then begin
print_nl("\ocplist");
print_esc(ocp_list_id_text(k));
print_char("=");
print_ocp_list(ocp_list_list[k]);
end;
end;
dump_int(ocp_lstackmem_ptr);
for k:=0 to ocp_lstackmem_ptr-1 do dump_wd(ocp_lstack_info[k])
@y
@ @<Dump the ocp list information@>=
dump_int(ocp_listmem_ptr);
dump_things(ocp_list_info[0], ocp_listmem_ptr);
dump_int(ocp_list_ptr);
dump_things(ocp_list_list[null_ocp_list], ocp_list_ptr+1-null_ocp_list);
for k:=null_ocp_list to ocp_list_ptr do begin
if null_ocp_list<>ocp_list_ptr then begin
print_nl("\ocplist");
print_esc(ocp_list_id_text(k));
print_char("=");
print_ocp_list(ocp_list_list[k]);
end;
end;
dump_int(ocp_lstackmem_ptr);
dump_things(ocp_lstack_info[0], ocp_lstackmem_ptr)
@z
@x
@ @<Undump the ocp list information@>=
undump_size(1)(1000000)('ocp list mem size')(ocp_listmem_ptr);
for k:=0 to ocp_listmem_ptr-1 do undump_wd(ocp_list_info[k]);
undump_size(ocp_list_base)(ocp_list_biggest)('ocp list max')(ocp_list_ptr);
for k:=null_ocp_list to ocp_list_ptr do
undump_int(ocp_list_list[k]);
undump_size(1)(1000000)('ocp lstack mem size')(ocp_lstackmem_ptr);
for k:=0 to ocp_lstackmem_ptr-1 do undump_wd(ocp_lstack_info[k])
@y
@ @<Undump the ocp list information@>=
undump_size(1)(1000000)('ocp list mem size')(ocp_listmem_ptr);
undump_things(ocp_list_info[0], ocp_listmem_ptr);
undump_size(0)(1000000)('ocp list max')(ocp_list_ptr);
undump_things(ocp_list_list[null_ocp_list], ocp_list_ptr+1-null_ocp_list);
undump_size(0)(1000000)('ocp lstack mem size')(ocp_lstackmem_ptr);
undump_things(ocp_lstack_info[0], ocp_lstackmem_ptr)
@z
@x
undump(batch_mode)(error_stop_mode)(interaction);
@y
undump(batch_mode)(error_stop_mode)(interaction);
if interactionoption<>unspecified_mode then interaction:=interactionoption;
@z
@x
if (x<>69069)or eof(fmt_file) then goto bad_fmt
@y
if x<>69069 then goto bad_fmt
@z
@x
print(" (preloaded format="); print(job_name); print_char(" ");
@y
print(" (format="); print(job_name); print_char(" ");
@z
@x
@p begin @!{|start_here|}
@y
@d const_chk(#)==begin if # < inf_@&# then # := inf_@&# else
if # > sup_@&# then # := sup_@&# end
{|setup_bound_var| stuff duplicated in \.{mf.ch}.}
@d setup_bound_var(#)==bound_default:=#; setup_bound_var_end
@d setup_bound_var_end(#)==bound_name:=#; setup_bound_var_end_end
@d setup_bound_var_end_end(#)==if luainit>0 then begin
get_lua_number('texconfig',bound_name,addressof(#));
if #=0 then #:=bound_default;
end
else
setupboundvariable(addressof(#), bound_name, bound_default);
@p procedure main_body;
begin @!{|start_here|}
{Bounds that may be set from the configuration file. We want the user to
be able to specify the names with underscores, but \.{TANGLE} removes
underscores, so we're stuck giving the names twice, once as a string,
once as the identifier. How ugly.}
setup_bound_var (100000)('pool_size')(pool_size);
setup_bound_var (75000)('string_vacancies')(string_vacancies);
setup_bound_var (5000)('pool_free')(pool_free); {min pool avail after fmt}
setup_bound_var (15000)('max_strings')(max_strings);
setup_bound_var (100)('strings_free')(strings_free);
setup_bound_var (3000)('buf_size')(buf_size);
setup_bound_var (50)('nest_size')(nest_size);
setup_bound_var (15)('max_in_open')(max_in_open);
setup_bound_var (60)('param_size')(param_size);
setup_bound_var (4000)('save_size')(save_size);
setup_bound_var (300)('stack_size')(stack_size);
setup_bound_var (16384)('dvi_buf_size')(dvi_buf_size);
setup_bound_var (79)('error_line')(error_line);
setup_bound_var (50)('half_error_line')(half_error_line);
setup_bound_var (79)('max_print_line')(max_print_line);
setup_bound_var(1000)('ocp_list_size')(ocp_list_size);
setup_bound_var(1000)('ocp_buf_size')(ocp_buf_size);
setup_bound_var(1000)('ocp_stack_size')(ocp_stack_size);
setup_bound_var (0)('hash_extra')(hash_extra);
setup_bound_var (72)('pk_dpi')(pk_dpi);
setup_bound_var (10000)('expand_depth')(expand_depth);
{Check other constants against their sup and inf.}
const_chk (buf_size);
const_chk (nest_size);
const_chk (max_in_open);
const_chk (param_size);
const_chk (save_size);
const_chk (stack_size);
const_chk (dvi_buf_size);
const_chk (pool_size);
const_chk (string_vacancies);
const_chk (pool_free);
const_chk (max_strings);
const_chk (strings_free);
const_chk (hash_extra);
const_chk (obj_tab_size);
const_chk (pdf_mem_size);
const_chk (dest_names_size);
const_chk (pk_dpi);
if error_line > ssup_error_line then error_line := ssup_error_line;
{array memory allocation}
buffer:=xmallocarray (packed_ASCII_code, buf_size);
nest:=xmallocarray (list_state_record, nest_size);
save_stack:=xmallocarray (memory_word, save_size);
input_stack:=xmallocarray (in_state_record, stack_size);
input_file:=xmallocarray (alpha_file, max_in_open);
input_file_callback_id:=xmallocarray (integer, max_in_open);
line_stack:=xmallocarray (integer, max_in_open);
eof_seen:=xmallocarray (boolean, max_in_open);
grp_stack:=xmallocarray (save_pointer, max_in_open);
if_stack:=xmallocarray (pointer, max_in_open);
source_filename_stack:=xmallocarray (str_number, max_in_open);
full_source_filename_stack:=xmallocarray (str_number, max_in_open);
param_stack:=xmallocarray (halfword, param_size);
dvi_buf:=xmallocarray (real_eight_bits, dvi_buf_size);
ocp_list_info:=xmallocarray (memory_word, ocp_list_size);
memset(ocp_list_info,0,sizeof(memory_word)* ocp_list_size);
ocp_lstack_info:=xmallocarray (memory_word, ocp_list_size);
memset(ocp_lstack_info,0,sizeof(memory_word)* ocp_list_size);
ocp_list_list:=xmallocarray (ocp_list_index, ocp_list_size);
otp_init_input_buf:=xmallocarray (quarterword, ocp_buf_size);
otp_input_buf:=xmallocarray (quarterword, ocp_buf_size);
otp_output_buf:=xmallocarray (quarterword, ocp_buf_size);
otp_stack_buf:=xmallocarray (quarterword, ocp_stack_size);
otp_calcs:=xmallocarray (halfword, ocp_stack_size);
otp_states:=xmallocarray (halfword, ocp_stack_size);
obj_tab:=xmallocarray (obj_entry, inf_obj_tab_size); {will grow dynamically}
obj_offset(0):=0;
pdf_mem:=xmallocarray (integer, inf_pdf_mem_size); {will grow dynamically}
dest_names:=xmallocarray (dest_name_entry, inf_dest_names_size); {will grow dynamically}
pdf_op_buf:=xmallocarray (real_eight_bits, pdf_op_buf_size);
pdf_os_buf:=xmallocarray (real_eight_bits, inf_pdf_os_buf_size); {will grow dynamically}
pdf_os_objnum:=xmallocarray (integer, pdf_os_max_objs);
pdf_os_objoff:=xmallocarray (integer, pdf_os_max_objs);
@+Init
fixmem:=xmallocarray (smemory_word, fix_mem_init+1);
memset (voidcast(fixmem), 0, (fix_mem_init+1)*sizeof(smemory_word));
fix_mem_min:=0;
fix_mem_max:=fix_mem_init;
eqtb_top := eqtb_size+hash_extra;
if hash_extra=0 then hash_top:=undefined_control_sequence else
hash_top:=eqtb_top;
yhash:=xmallocarray (two_halves,1+hash_top-hash_offset);
hash:=yhash - hash_offset; {Some compilers require |hash_offset=0|}
next(hash_base):=0; text(hash_base):=0;
for hash_used:=hash_base+1 to hash_top do hash[hash_used]:=hash[hash_base];
zeqtb:=xmallocarray (memory_word, eqtb_top);
eqtb:=zeqtb;
str_start:=xmallocarray (pool_pointer, max_strings);
str_pool:=xmallocarray (packed_ASCII_code, pool_size);
@+Tini
@z
@x
@!init if not get_strings_started then goto final_end;
init_prim; {call |primitive| for each primitive}
init_str_ptr:=str_ptr; init_pool_ptr:=pool_ptr; fix_date_and_time;
tini@/
@y
@!Init if not get_strings_started then goto final_end;
init_prim; {call |primitive| for each primitive}
init_str_ptr:=str_ptr; init_pool_ptr:=pool_ptr; fix_date_and_time;
Tini@/
@z
@x
end_of_TEX: close_files_and_terminate;
final_end: ready_already:=0;
end.
@y
close_files_and_terminate;
final_end: do_final_end;
end {|main_body|};
@z
@x
wterm(banner);
@y
if srcspecialsp or filelineerrorstylep or parsefirstlinep then
wterm(banner_k)
else
wterm(banner);
@z
@x
if format_ident=0 then wterm_ln(' (no format preloaded)')
else begin slow_print(format_ident); print_ln;
end;
@y
wterm(versionstring);
if format_ident>0 then slow_print(format_ident);
print_ln;
if shellenabledp then begin
wterm(' ');
if restrictedshell then begin
wterm('restricted ');
end;
wterm_ln('\write18 enabled.');
end;
if srcspecialsp then begin
wterm_ln(' Source specials enabled.')
end;
if filelineerrorstylep then begin
wterm_ln(' file:line:error style messages enabled.')
end;
if parsefirstlinep then begin
wterm_ln(' %&-line parsing enabled.')
end;
@z
@x
slow_print(log_name); print_char(".");
@y
print_file_name(0, log_name, 0); print_char(".");
@z
@x
end;
@y
end;
print_ln;
if (edit_name_start<>0) and (interaction>batch_mode) then
calledit(str_pool,edit_name_start,edit_name_length,edit_line);
@z
@x
wlog_ln(' ',cs_count:1,' multiletter control sequences out of ',
hash_size:1);@/
@y
wlog_ln(' ',cs_count:1,' multiletter control sequences out of ',
hash_size:1, '+', hash_extra:1);@/
@z
@x
begin @!init for i:=0 to biggest_used_mark do begin
@y
begin @!Init for i:=0 to biggest_used_mark do begin
@z
@x
store_fmt_file; return;@+tini@/
@y
store_fmt_file; return;@+Tini@/
@z
@x
if (format_ident=0)or(buffer[loc]="&") then
@y
if (format_ident=0)or(buffer[loc]="&")or dump_line then
@z
@x
w_close(fmt_file);
@y
w_close(fmt_file);
eqtb:=zeqtb;
@z
@x
fix_date_and_time;@/
@y
fix_date_and_time;@/
@!init
make_pdftex_banner;
tini@/
@z
@x
begin goto breakpoint;@\ {go to every label at least once}
breakpoint: m:=0; @{'BREAKPOINT'@}@\
end
@y
abort {do something to cause a core dump}
@z
@x
primitive("special",extension,special_node);@/
@y
primitive("special",extension,special_node);@/
text(frozen_special):="special"; eqtb[frozen_special]:=eqtb[cur_val];@/
@z
@x
else if cur_val>15 then cur_val:=16;
@y
else if (cur_val>15) and (cur_val <> 18) then cur_val:=16;
@z
@x
begin @<Expand macros in the token list
@y
@!d:integer; {number of characters in incomplete current string}
@!clobbered:boolean; {system string is ok?}
@!runsystem_ret:integer; {return value from |runsystem|}
begin @<Expand macros in the token list
@z
@x
if write_open[j] then selector:=j
@y
if j=18 then selector := new_string
else if write_open[j] then selector:=j
@z
@x
flush_list(def_ref); selector:=old_setting;
@y
flush_list(def_ref);
if j=18 then
begin if (tracing_online<=0) then
selector:=log_only {Show what we're doing in the log file.}
else selector:=term_and_log; {Show what we're doing.}
{If the log file isn't open yet, we can only send output to the terminal.
Calling |open_log_file| from here seems to result in bad data in the log.}
if not log_opened then selector:=term_only;
print_nl("runsystem(");
for d:=0 to cur_length-1 do
begin {|print| gives up if passed |str_ptr|, so do it by hand.}
print(so(str_pool[str_start_macro(str_ptr)+d])); {N.B.: not |print_char|}
end;
print(")...");
if shellenabledp then begin
str_room(1); append_char(0); {Append a null byte to the expansion.}
clobbered:=false;
for d:=0 to cur_length-1 do {Convert to external character set.}
begin
str_pool[str_start_macro(str_ptr)+d]:=xchr[str_pool[str_start_macro(str_ptr)+d]];
if (str_pool[str_start_macro(str_ptr)+d]=null_code)
and (d<cur_length-1) then clobbered:=true;
{minimal checking: NUL not allowed in argument string of |system|()}
end;
if clobbered then print("clobbered")
else begin {We have the command. See if we're allowed to execute it,
and report in the log. We don't check the actual exit status of
the command, or do anything with the output.}
runsystem_ret := runsystem(stringcast(addressof(
str_pool[str_start_macro(str_ptr)])));
if runsystem_ret = -1 then print("quotation error in system command")
else if runsystem_ret = 0 then print("disabled (restricted)")
else if runsystem_ret = 1 then print("executed")
else if runsystem_ret = 2 then print("executed (allowed)")
end;
end else begin
print("disabled"); {|shellenabledp| false}
end;
print_char("."); print_nl(""); print_ln;
pool_ptr:=str_start_macro(str_ptr); {erase the string}
end;
selector:=old_setting;
@z
@x
@!eof_seen : array[1..max_in_open] of boolean; {has eof been seen?}
@y
@!eof_seen : ^boolean; {has eof been seen?}
@z
@x
@!grp_stack : array[0..max_in_open] of save_pointer; {initial |cur_boundary|}
@!if_stack : array[0..max_in_open] of pointer; {initial |cond_ptr|}
@y
@!grp_stack : ^save_pointer; {initial |cur_boundary|}
@!if_stack : ^pointer; {initial |cond_ptr|}
@z
@x
@!otp_init_input_buf:array[0..20000] of quarterword;
@!otp_input_start:halfword;
@!otp_input_last:halfword;
@!otp_input_end:halfword;
@!otp_input_buf:array[0..20000] of quarterword;
@!otp_output_end:halfword;
@!otp_output_buf:array[0..20000] of quarterword;
@!otp_stack_used:halfword;
@!otp_stack_last:halfword;
@!otp_stack_new:halfword;
@!otp_stack_buf:array[0..1000] of quarterword;
@!otp_pc:halfword;
@!otp_calc_ptr:halfword;
@!otp_calcs:array[0..1000] of halfword;
@!otp_state_ptr:halfword;
@!otp_states:array[0..1000] of halfword;
@y
@!otp_init_input_buf:^quarterword;
@!otp_input_start:halfword;
@!otp_input_last:halfword;
@!otp_input_end:halfword;
@!otp_input_buf:^quarterword;
@!otp_output_end:halfword;
@!otp_output_buf:^quarterword;
@!otp_stack_used:halfword;
@!otp_stack_last:halfword;
@!otp_stack_new:halfword;
@!otp_stack_buf:^quarterword;
@!otp_pc:halfword;
@!otp_calc_ptr:halfword;
@!otp_calcs:^halfword;
@!otp_state_ptr:halfword;
@!otp_states:^halfword;
@z
@x
@* \[54] System-dependent changes.
@y
@* \[54/web2c] System-dependent changes for Web2c.
Here are extra variables for Web2c. (This numbering of the
system-dependent section allows easy integration of Web2c and e-\TeX, etc.)
@^<system dependencies@>
@<Glob...@>=
@!edit_name_start: pool_pointer; {where the filename to switch to starts}
@!edit_name_length,@!edit_line: integer; {what line to start editing at}
@!ipcon: cinttype; {level of IPC action, 0 for none [default]}
@!stop_at_space: boolean; {whether |more_name| returns false for space}
@ The |edit_name_start| will be set to point into |str_pool| somewhere after
its beginning if \TeX\ is supposed to switch to an editor on exit.
@<Set init...@>=
edit_name_start:=0;
stop_at_space:=true;
@ These are used when we regenerate the representation of the first 256
strings.
@<Global...@> =
@!save_str_ptr: str_number;
@!save_pool_ptr: pool_pointer;
@!shellenabledp: cinttype;
@!restrictedshell: cinttype;
@!output_comment: ^char;
@!k,l: 0..255; {used by `Make the first 256 strings', etc.}
@ When debugging a macro package, it can be useful to see the exact
control sequence names in the format file. For example, if ten new
csnames appear, it's nice to know what they are, to help pinpoint where
they came from. (This isn't a truly ``basic'' printing procedure, but
that's a convenient module in which to put it.)
@<Basic printing procedures@> =
procedure print_csnames (hstart:integer; hfinish:integer);
var c,h:integer;
begin
writeln(stderr, 'fmtdebug:csnames from ', hstart, ' to ', hfinish, ':');
for h := hstart to hfinish do begin
if text(h) > 0 then begin {if have anything at this position}
for c := str_start_macro(text(h)) to str_start_macro(text(h) + 1) - 1
do begin
putbyte(str_pool[c], stderr); {print the characters}
end;
writeln(stderr, '|');
end;
end;
end;
@ Are we printing extra info as we read the format file?
@<Glob...@> =
@!debug_format_file: boolean;
@ A helper for printing file:line:error style messages. Look for a
filename in |full_source_filename_stack|, and if we fail to find
one fall back on the non-file:line:error style.
@<Basic print...@>=
procedure print_file_line;
var level: 0..max_in_open;
begin
level:=in_open;
while (level>0) and (full_source_filename_stack[level]=0) do
decr(level);
if level=0 then
print_nl("! ")
else begin
print_nl (""); print (full_source_filename_stack[level]); print (":");
if level=in_open then print_int (line)
else print_int (line_stack[index+1-(in_open-level)]);
print (": ");
end;
end;
@ To be able to determine whether \.{\\write18} is enabled from within
\TeX\ we also implement \.{\\eof18}. We sort of cheat by having an
additional route |scan_four_bit_int_or_18| which is the same as
|scan_four_bit_int| except it also accepts the value 18.
@<Declare procedures that scan restricted classes of integers@>=
procedure scan_four_bit_int_or_18;
begin scan_int;
if (cur_val<0)or((cur_val>15)and(cur_val<>18)) then
begin print_err("Bad number");
@.Bad number@>
help2("Since I expected to read a number between 0 and 15,")@/
("I changed this one to zero."); int_error(cur_val); cur_val:=0;
end;
end;
@* \[54/web2c-string] The string recycling routines. \TeX{} uses 2
upto 4 {\it new\/} strings when scanning a filename in an \.{\\input},
\.{\\openin}, or \.{\\openout} operation. These strings are normally
lost because the reference to them are not saved after finishing the
operation. |search_string| searches through the string pool for the
given string and returns either 0 or the found string number.
@<Declare additional routines for string recycling@>=
function search_string(@!search:str_number):str_number;
label found;
var result: str_number;
@!s: str_number; {running index}
@!len: integer; {length of searched string}
begin result:=0; len:=length(search);
if len=0 then {trivial case}
begin result:=""; goto found;
end
else begin s:=search-1; {start search with newest string below |s|; |search>1|!}
while s>=string_offset do {first |string_offset| strings depend on implementation!!}
begin if length(s)=len then
if str_eq_str(s,search) then
begin result:=s; goto found;
end;
decr(s);
end;
end;
found:search_string:=result;
end;
@ The following routine is a variant of |make_string|. It searches
the whole string pool for a string equal to the string currently built
and returns a found string. Otherwise a new string is created and
returned. Be cautious, you can not apply |flush_string| to a replaced
string!
@<Declare additional routines for string recycling@>=
function slow_make_string : str_number;
label exit;
var s: str_number; {result of |search_string|}
@!t: str_number; {new string}
begin t:=make_string; s:=search_string(t);
if s>0 then
begin flush_string; slow_make_string:=s; return;
end;
slow_make_string:=t;
exit:end;
@* \[54] System-dependent changes.
@z
@x
@* \[55] Index.
@y
@ @<Declare action procedures for use by |main_control|@>=
procedure insert_src_special;
var toklist, p, q,r : pointer;
begin
if (source_filename_stack[in_open] > 0 and isnewsource (source_filename_stack[in_open]
, line)) then begin
toklist := get_avail;
p := toklist;
info(p) := cs_token_flag+frozen_special;
r := get_avail; link(p):=r; p := link(p);
info(p) := left_brace_token+"{";
q := str_toks (makesrcspecial (source_filename_stack[in_open], line));
link(p) := link(temp_token_head);
p := q;
r := get_avail; link(p):=r; p := link(p);
info(p) := right_brace_token+"}";
ins_list (toklist);
remembersourceinfo (source_filename_stack[in_open], line);
end;
end;
procedure append_src_special;
var q : pointer;
begin
if (source_filename_stack[in_open] > 0 and isnewsource (source_filename_stack[in_open]
, line)) then begin
new_whatsit (special_node);
write_stream(tail) := 0;
q:=get_avail; def_ref := q;
token_ref_count(def_ref) := null;
q := str_toks (makesrcspecial (source_filename_stack[in_open], line));
link(def_ref) := link(temp_head);
write_tokens(tail) := def_ref;
remembersourceinfo (source_filename_stack[in_open], line);
end;
end;
@ This function used to be in pdftex, but is useful in tex too.
@p function get_nullstr: str_number;
begin
get_nullstr := "";
end;
@* \[55] Index.
@z
|