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
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
|
/*-
******************************************************************************
******************************************************************************
**
** MODULE
**
** $RCSfile: bibtex-1.c,v $
** $Revision: 3.71 $
** $Date: 1996/08/18 20:47:30 $
**
** DESCRIPTION
**
** A 32-bit implementation of BibTeX v0.99c for MS-DOS, OS/2 2.x,
** Unix and VMS. This C language implementation is based on the
** original WEB source but it has been enhanced to support 8-bit input
** characters and a very large processing capacity.
**
** For documentation describing how to use and build this program,
** see the 00README.TXT file that accompanies this distribution.
**
** MODULE CONTENTS
**
** This is the first of 4 source modules for BibTeX. The source has
** been split into 4 parts so that some of the more primitive editors
** can cope. This code mimics the BibTeX WEB source as closely as
** possible and there should be NO system dependent code in any of the
** bibtex-#.c modules.
**
** The functions defined in this module are:
**
** aux_err_stuff_after_right_brace
** aux_err_white_space_in_argument
** aux_input_command
** bad_argument_token
** bad_cross_reference_print
** bib_cmd_confusion
** bib_equals_sign_print
** bib_err_print
** bib_field_too_long_print
** bib_id_print
** bib_ln_num_print
** bib_one_of_two_print
** bib_unbalanced_braces_print
** bib_warn_print
** brace_lvl_one_letters_complaint
** braces_unbalanced_complaint
** bst_1print_string_size_exceeded
** bst_2print_string_size_exceeded
** bst_cant_mess_with_entries_prin
** bst_entry_command
** bst_err_print_and_look_for_blan
** bst_execute_command
** bst_ex_warn_print
** bst_function_command
** bst_id_print
** bst_integers_command
** build_in
** case_conversion_confusion
** check_brace_level
** check_cite_overflow
** check_command_execution
** check_field_overflow
** cite_key_disappeared_confusion
** compress_bib_white
** decr_brace_level
** eat_bib_print
** eat_bib_white_space
** eat_bst_print
** eat_bst_white_space
** enough_text_chars
**
** AUTHORS
**
** Original WEB translation to C, conversion to "big" (32-bit) capacity,
** addition of run-time selectable capacity and 8-bit support extensions
** by:
**
** Niel Kempson
** Snowy Owl Systems Limited, Cheltenham, England
** E-mail: kempson@snowyowl.co.uk
**
** 8-bit support extensions also by:
**
** Alejandro Aguilar-Sierra
** Centro de Ciencias de la Atm\'osfera,
** Universidad Nacional Aut\'onoma de M\'exico, M\'exico
** E-mail: asierra@servidor.unam.mx
**
** COPYRIGHT
**
** This implementation copyright (c) 1991-1995 by Niel Kempson
** and copyright (c) 1995 by Alejandro Aguilar-Sierra.
**
** 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 1, 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, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
** In other words, you are welcome to use, share and improve this
** program. You are forbidden to forbid anyone else to use, share
** and improve what you give them. Help stamp out software-hoarding!
**
** ACKNOWLEDGEMENT
**
** The original BibTeX was written by Oren Patashnik using Donald
** Knuth's WEB system. This format produces a PASCAL program for
** execution and a TeX documented version of the source code. This
** program started as a (manual) translation of the WEB source into C.
**
** CHANGE LOG
**
** $Log: bibtex-1.c,v $
** Revision 3.71 1996/08/18 20:47:30 kempson
** Official release 3.71 (see HISTORY file for details).
**
** Revision 3.70 1996/04/08 10:08:40 kempson
** Final documentation & cosmetic changes for official release 3.70.
**
** Revision 3.5 1995/09/24 20:44:37 kempson
** Many changes for final beta test version.
**
** Revision 3.4 1995/04/09 22:15:38 kempson
** Placed under RCS control
**
******************************************************************************
******************************************************************************
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "sysdep.h"
#include "bibtex.h"
#include "datatype.h"
#include "gblprocs.h"
#include "gblvars.h"
#include "utils.h"
#include "version.h"
/***************************************************************************
* WEB section number: 61
* ~~~~~~~~~~~~~~~~~~~
* This procedure copies the default logical area name |area| into the
* array |name_of_file| starting at position 1, after shifting up the rest
* of the filename. It also sets the global variable |name_length| to the
* appropriate value.
*
* NOTE: because C arrays start at index 0, not 1, the subscripts of array
* |name_of_file| are generally 1 less than those in the WEB source.
***************************************************************************/
void add_area (StrNumber_T area)
BEGIN
PoolPointer_T p_ptr;
if ((name_length + LENGTH (area)) > FILE_NAME_SIZE)
BEGIN
PRINT ("File=");
PRINT_POOL_STR (area);
PRINT2 ("%s,", name_of_file);
file_nm_size_overflow ();
END
name_ptr = name_length - 1;
while (name_ptr >= 0)
BEGIN
name_of_file[name_ptr + LENGTH (area)] = name_of_file[name_ptr];
DECR (name_ptr);
END
name_ptr = 0;
p_ptr = str_start[area];
while (p_ptr < str_start[area + 1])
BEGIN
name_of_file[name_ptr] = CHR (str_pool[p_ptr]);
INCR (name_ptr);
INCR (p_ptr);
END
name_length = name_length + LENGTH (area);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 61 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 320
* ~~~~~~~~~~~~~~~~~~~
* This procedure adds to the execution buffer the given string in
* |str_pool| if it will fit. It assumes the global variable
* |ex_buf_length| gives the length of the current string in |ex_buf|, and
* thus also gives the location of the next character.
***************************************************************************/
void add_buf_pool (StrNumber_T p_str)
BEGIN
p_ptr1 = str_start[p_str];
p_ptr2 = str_start[p_str + 1];
if ((ex_buf_length + (p_ptr2 - p_ptr1)) > BUF_SIZE)
BEGIN
buffer_overflow ();
END
ex_buf_ptr = ex_buf_length;
while (p_ptr1 < p_ptr2)
BEGIN
APPEND_EX_BUF_CHAR(str_pool[p_ptr1]);
INCR (p_ptr1);
END
ex_buf_length = ex_buf_ptr;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 320 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 265
* ~~~~~~~~~~~~~~~~~~~
* This procedure adds (or restores) to |cite_list| a cite key; it is
* called only when |all_entries| is |true| or when adding
* cross references, and it assumes that |cite_loc| and |lc_cite_loc| are
* set. It also INCRs its argument.
***************************************************************************/
void add_database_cite (CiteNumber_T *new_cite)
BEGIN
check_cite_overflow (*new_cite);
check_field_overflow (num_fields * (*new_cite));
cite_list[*new_cite] = hash_text[cite_loc];
ilk_info[cite_loc] = *new_cite;
ilk_info[lc_cite_loc] = cite_loc;
INCR (*new_cite);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 265 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 60
* ~~~~~~~~~~~~~~~~~~~
* This procedure copies file extension |ext| into the array
* |name_of_file| starting at position |name_length+1|. It also sets the
* global variable |name_length| to the appropriate value.
*
* NOTE: because C arrays start at index 0, not 1, the subscripts of array
* |name_of_file| are generally 1 less than those in the WEB source.
***************************************************************************/
void add_extension (StrNumber_T ext)
BEGIN
PoolPointer_T p_ptr;
if ((name_length + LENGTH (ext)) > FILE_NAME_SIZE)
BEGIN
PRINT2 ("File=%s, extension=", name_of_file);
PRINT_POOL_STR (ext);
PRINT_LN (",");
file_nm_size_overflow ();
END
name_ptr = name_length;
p_ptr = str_start[ext];
while (p_ptr < str_start[ext + 1])
BEGIN
name_of_file[name_ptr] = CHR (str_pool[p_ptr]);
INCR (name_ptr);
INCR (p_ptr);
END
name_length = name_length + LENGTH (ext);
name_ptr = name_length;
while (name_ptr < FILE_NAME_SIZE)
BEGIN
name_of_file[name_ptr] = ' ';
INCR (name_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 60 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 322
* ~~~~~~~~~~~~~~~~~~~
* This procedure adds to the output buffer the given string in
* |str_pool|. It assumes the global variable |out_buf_length| gives the
* length of the current string in |out_buf|, and thus also gives the
* location for the next character. If there are enough characters
* present in the output buffer, it writes one or more lines out to the
* .bbl file. It may break a line at any |white_space| character it
* likes, but if it does, it will add two |space|s to the next output
* line.
***************************************************************************/
void add_out_pool (StrNumber_T p_str)
BEGIN
BufPointer_T break_ptr;
BufPointer_T end_ptr;
p_ptr1 = str_start[p_str];
p_ptr2 = str_start[p_str + 1];
if ((out_buf_length + (p_ptr2 - p_ptr1)) > BUF_SIZE)
BEGIN
BIBTEX_OVERFLOW ("output buffer size ", BUF_SIZE);
END
out_buf_ptr = out_buf_length;
while (p_ptr1 < p_ptr2)
BEGIN
out_buf[out_buf_ptr] = str_pool[p_ptr1];
INCR (p_ptr1);
INCR (out_buf_ptr);
END
out_buf_length = out_buf_ptr;
while (out_buf_length > MAX_PRINT_LINE)
/***************************************************************************
* WEB section number: 323
* ~~~~~~~~~~~~~~~~~~~
* Here we break the line by looking for a |white_space| character,
* backwards from |out_buf[max_print_line]| until
* |out_buf[min_print_line]|; we break at the |white_space| and indent
* the next line two |space|s. The next module handles things when
* there's no |white_space| character to break at.
***************************************************************************/
BEGIN
end_ptr = out_buf_length;
out_buf_ptr = MAX_PRINT_LINE;
while ((lex_class[out_buf[out_buf_ptr]] != WHITE_SPACE)
&& (out_buf_ptr >= MIN_PRINT_LINE))
BEGIN
DECR (out_buf_ptr);
END
if (out_buf_ptr == (MIN_PRINT_LINE - 1))
/***************************************************************************
* WEB section number: 324
* ~~~~~~~~~~~~~~~~~~~
* If there's no |white_space| character to break the line at, we break
* it at |out_buf[max_print_line-1]|, append a |comment| character, and
* don't indent the next line.
***************************************************************************/
BEGIN
out_buf[end_ptr] = out_buf[MAX_PRINT_LINE - 1];
out_buf[MAX_PRINT_LINE - 1] = COMMENT;
out_buf_length = MAX_PRINT_LINE;
break_ptr = out_buf_length - 1;
output_bbl_line ();
out_buf[MAX_PRINT_LINE - 1] = out_buf[end_ptr];
out_buf_ptr = 0;
tmp_ptr = break_ptr;
while (tmp_ptr < end_ptr)
BEGIN
out_buf[out_buf_ptr] = out_buf[tmp_ptr];
INCR (out_buf_ptr);
INCR (tmp_ptr);
END
out_buf_length = end_ptr - break_ptr;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 324 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
else
BEGIN
out_buf_length = out_buf_ptr;
break_ptr = out_buf_length + 1;
output_bbl_line ();
out_buf[0] = SPACE;
out_buf[1] = SPACE;
out_buf_ptr = 2;
tmp_ptr = break_ptr;
while (tmp_ptr < end_ptr)
BEGIN
out_buf[out_buf_ptr] = out_buf[tmp_ptr];
INCR (out_buf_ptr);
INCR (tmp_ptr);
END
out_buf_length = end_ptr - break_ptr + 2;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 323 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 322 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 318
* ~~~~~~~~~~~~~~~~~~~
* This procedure adds to |str_pool| the string from |ex_buf[0]| through
* |ex_buf[ex_buf_length-1]| if it will fit. It assumes the global
* variable |ex_buf_length| gives the length of the current string in
* |ex_buf|. It then pushes this string onto the literal stack.
***************************************************************************/
void add_pool_buf_and_push (void)
BEGIN
STR_ROOM (ex_buf_length);
ex_buf_ptr = 0;
while (ex_buf_ptr < ex_buf_length)
BEGIN
APPEND_CHAR (ex_buf[ex_buf_ptr]);
INCR (ex_buf_ptr);
END
push_lit_stk (make_string (), STK_STR);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 318 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 169
* ~~~~~~~~~~~~~~~~~~~
* This macro complains if we've already encountered a function to be
* inserted into the hash table.
***************************************************************************/
void already_seen_function_print (HashLoc_T seen_fn_loc)
BEGIN
PRINT_POOL_STR (hash_text[seen_fn_loc]);
PRINT (" is already a type \"");
print_fn_class (seen_fn_loc);
PRINT_LN ("\" function name");
BST_ERR_PRINT_AND_LOOK_FOR_BLAN;
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 169 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 120
* ~~~~~~~~~~~~~~~~~~~
* A \bibdata command will have its arguments between braces and
* separated by commas. There must be exactly one such command in the
* .aux file(s). All upper-case letters are converted to lower case.
***************************************************************************/
void aux_bib_data_command (void)
BEGIN
if (bib_seen)
BEGIN
AUX_ERR_ILLEGAL_ANOTHER (N_AUX_BIBDATA);
END
bib_seen = TRUE;
while (SCAN_CHAR != RIGHT_BRACE)
BEGIN
INCR (buf_ptr2);
if ( ! scan2_white (RIGHT_BRACE, COMMA))
BEGIN
AUX_ERR_NO_RIGHT_BRACE;
END
if (lex_class[SCAN_CHAR] == WHITE_SPACE)
BEGIN
AUX_ERR_WHITE_SPACE_IN_ARGUMENT;
END
if ((last > (buf_ptr2 + 1)) && (SCAN_CHAR == RIGHT_BRACE))
BEGIN
AUX_ERR_STUFF_AFTER_RIGHT_BRACE;
END
/***************************************************************************
* WEB section number: 123
* ~~~~~~~~~~~~~~~~~~~
* Now we add the just-found argument to |bib_list| if it hasn't already
* been encountered as a \bibdata argument and if, after appending
* the |s_bib_extension| string, the resulting file name can be opened.
***************************************************************************/
BEGIN
if (bib_ptr == MAX_BIB_FILES)
BEGIN
BIBTEX_OVERFLOW ("number of database files ", MAX_BIB_FILES);
END
CUR_BIB_STR = hash_text[str_lookup (buffer, buf_ptr1, TOKEN_LEN,
BIB_FILE_ILK, DO_INSERT)];
if (hash_found)
BEGIN
OPEN_BIBDATA_AUX_ERR ("This database file appears more than once: ");
END
start_name (CUR_BIB_STR);
add_extension (s_bib_extension);
if ( ! a_open_in (&CUR_BIB_FILE, BIB_FILE_SEARCH_PATH))
BEGIN
add_area (s_bib_area);
if ( ! a_open_in (&CUR_BIB_FILE, BIB_FILE_SEARCH_PATH))
BEGIN
OPEN_BIBDATA_AUX_ERR ("I couldn't open database file ");
perror ("\nReason");
END
END
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_POOL_STR (CUR_BIB_STR);
TRACE_PR_POOL_STR (s_bib_extension);
TRACE_PR_LN (" is a bibdata file");
}
#endif /* TRACE */
INCR (bib_ptr);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 123 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 120 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 126
* ~~~~~~~~~~~~~~~~~~~
* A \bibstyle command will have exactly one argument, and it will be
* between braces. There must be exactly one such command in the .aux
* file(s). All upper-case letters are converted to lower case.
***************************************************************************/
void aux_bib_style_command (void)
BEGIN
if (bst_seen)
BEGIN
AUX_ERR_ILLEGAL_ANOTHER (N_AUX_BIBSTYLE);
END
bst_seen = TRUE;
INCR (buf_ptr2);
if ( ! scan1_white (RIGHT_BRACE))
BEGIN
AUX_ERR_NO_RIGHT_BRACE;
END
if (lex_class[SCAN_CHAR] == WHITE_SPACE)
BEGIN
AUX_ERR_WHITE_SPACE_IN_ARGUMENT;
END
if (last > (buf_ptr2 + 1))
BEGIN
AUX_ERR_STUFF_AFTER_RIGHT_BRACE;
END
/***************************************************************************
* WEB section number: 127
* ~~~~~~~~~~~~~~~~~~~
* Now we open the file whose name is the just-found argument appended
* with the |s_bst_extension| string, if possible.
***************************************************************************/
BEGIN
bst_str = hash_text[str_lookup (buffer, buf_ptr1, TOKEN_LEN,
BST_FILE_ILK, DO_INSERT)];
if (hash_found)
BEGIN
#ifdef TRACE
if (Flag_trace)
print_bst_name ();
#endif /* TRACE */
CONFUSION ("Already encountered style file");
END
start_name (bst_str);
add_extension (s_bst_extension);
if ( ! a_open_in (&bst_file, BST_FILE_SEARCH_PATH))
BEGIN
add_area (s_bst_area);
if ( ! a_open_in (&bst_file, BST_FILE_SEARCH_PATH))
BEGIN
PRINT ("I couldn't open style file ");
print_bst_name ();
perror ("\nReason");
bst_str = 0;
AUX_ERR_RETURN;
END
END
PRINT ("The style file: ");
print_bst_name ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 127 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 126 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 132
* ~~~~~~~~~~~~~~~~~~~
* A \citation command will have its arguments between braces and
* separated by commas. Upper/lower cases are considered to be different
* for \citation arguments, which is the same as the rest of \LaTeX\
* but different from the rest of \BibTeX. A cite key needn't exactly
* case-match its corresponding database key to work, although two cite
* keys that are case-mismatched will produce an error message. (A BEGIN\sl
* case mismatch\/END is a mismatch, but only because of a case difference.)
*
* A \citation command having * as an argument indicates that the
* entire database will be included (almost as if a \nocite command
* that listed every cite key in the database, in order, had been given at
* the corresponding spot in the .tex file).
***************************************************************************/
void aux_citation_command (void)
BEGIN
citation_seen = TRUE;
while (SCAN_CHAR != RIGHT_BRACE)
BEGIN
INCR (buf_ptr2);
if ( ! scan2_white (RIGHT_BRACE, COMMA))
BEGIN
AUX_ERR_NO_RIGHT_BRACE;
END
if (lex_class[SCAN_CHAR] == WHITE_SPACE)
BEGIN
AUX_ERR_WHITE_SPACE_IN_ARGUMENT;
END
if ((last > (buf_ptr2 + 1)) && (SCAN_CHAR == RIGHT_BRACE))
BEGIN
AUX_ERR_STUFF_AFTER_RIGHT_BRACE;
END
/***************************************************************************
* WEB section number: 133
* ~~~~~~~~~~~~~~~~~~~
* We must check if (the lower-case version of) this cite key has been
* previously encountered, and proceed accordingly. The alias kludge
* helps make the stack space not overflow on some machines.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR (" cite key encountered");
}
#endif /* TRACE */
/***************************************************************************
* WEB section number: 134
* ~~~~~~~~~~~~~~~~~~~
* Here we check for a \citation command having * as an
* argument, indicating that the entire database will be included.
***************************************************************************/
BEGIN
if (TOKEN_LEN == 1)
BEGIN
if (buffer[buf_ptr1] == STAR)
BEGIN
#ifdef TRACE
if (Flag_trace)
TRACE_PR_LN ("---entire database to be included");
#endif /* TRACE */
if (all_entries)
BEGIN
PRINT_LN ("Multiple inclusions of entire database");
AUX_ERR_RETURN;
END
else
BEGIN
all_entries = TRUE;
all_marker = cite_ptr;
goto Next_Cite_Label;
END
END
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 134 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
tmp_ptr = buf_ptr1;
while (tmp_ptr < buf_ptr2)
BEGIN
ex_buf[tmp_ptr] = buffer[tmp_ptr];
INCR (tmp_ptr);
END
lower_case (ex_buf, buf_ptr1, TOKEN_LEN);
lc_cite_loc = str_lookup (ex_buf, buf_ptr1, TOKEN_LEN, LC_CITE_ILK,
DO_INSERT);
if (hash_found)
/***************************************************************************
* WEB section number: 135
* ~~~~~~~~~~~~~~~~~~~
* We've previously encountered the lower-case version, so we check that
* the actual version exactly matches the actual version of the
* previously-encountered cite key(s).
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace)
TRACE_PR_LN (" previously");
#endif /* TRACE */
dummy_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, CITE_ILK,
DONT_INSERT);
if ( ! hash_found)
BEGIN
PRINT ("Case mismatch error between cite keys ");
PRINT_TOKEN;
PRINT (" and ");
PRINT_POOL_STR (cite_list[ilk_info[ilk_info[lc_cite_loc]]]);
PRINT_NEWLINE;
AUX_ERR_RETURN;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 135 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
else
/***************************************************************************
* WEB section number: 136
* ~~~~~~~~~~~~~~~~~~~
* Now we add the just-found argument to |cite_list| if there isn't
* anything funny happening.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace)
TRACE_PR_NEWLINE;
#endif /* TRACE */
cite_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, CITE_ILK,
DO_INSERT);
if (hash_found)
BEGIN
hash_cite_confusion ();
END
check_cite_overflow (cite_ptr);
CUR_CITE_STR = hash_text[cite_loc];
ilk_info[cite_loc] = cite_ptr;
ilk_info[lc_cite_loc] = cite_loc;
INCR (cite_ptr);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 136 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 133 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Next_Cite_Label: DO_NOTHING
END
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 132 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 144
* ~~~~~~~~~~~~~~~~~~~
* We must complain if anything's amiss.
***************************************************************************/
void aux_end1_err_print (void)
BEGIN
PRINT ("I found no ");
END
void aux_end2_err_print (void)
BEGIN
PRINT ("---while reading file ");
print_aux_name ();
mark_error ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 144 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 112
* ~~~~~~~~~~~~~~~~~~~
* Here are a bunch of macros whose print statements are used at least
* twice. Thus we save space by making the statements procedures. This
* macro complains when there's a repeated command that's to be used just
* once.
***************************************************************************/
void aux_err_illegal_another_print (Integer_T cmd_num)
BEGIN
PRINT ("Illegal, another \\bib");
switch (cmd_num)
BEGIN
case N_AUX_BIBDATA:
PRINT ("data");
break;
case N_AUX_BIBSTYLE:
PRINT ("style");
break;
default:
CONFUSION ("Illegal auxiliary-file command");
END
PRINT (" command");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 112 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 113
* ~~~~~~~~~~~~~~~~~~~
* This one complains when a command is missing its |right_brace|.
***************************************************************************/
void aux_err_no_right_brace_print (void)
BEGIN
PRINT2 ("No \"%c\"", xchr[RIGHT_BRACE]);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 113 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 111
* ~~~~~~~~~~~~~~~~~~~
* When we find a bug, we print a message and flush the rest of the line.
* This macro must be called from within a procedure that has an |exit|
* label.
***************************************************************************/
void aux_err_print (void)
BEGIN
PRINT2 ("---line %ld of file ", (long) CUR_AUX_LINE);
print_aux_name ();
print_bad_input_line ();
print_skipping_whatever_remains ();
PRINT_LN ("command");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 111 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 114
* ~~~~~~~~~~~~~~~~~~~
* This one complains when a command has stuff after its |right_brace|.
***************************************************************************/
void aux_err_stuff_after_right_brace (void)
BEGIN
PRINT2 ("Stuff after \"%c\"", xchr[RIGHT_BRACE]);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 114 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 115
* ~~~~~~~~~~~~~~~~~~~
* And this one complains when a command has |white_space| in its
* argument.
***************************************************************************/
void aux_err_white_space_in_argument (void)
BEGIN
PRINT ("White space in argument");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 115 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 139
* ~~~~~~~~~~~~~~~~~~~
* An \@input command will have exactly one argument, it will be
* between braces, and it must have the |s_aux_extension|. All upper-case
* letters are converted to lower case.
***************************************************************************/
void aux_input_command (void)
BEGIN
Boolean_T aux_extension_ok;
INCR (buf_ptr2);
if ( ! scan1_white (RIGHT_BRACE))
BEGIN
AUX_ERR_NO_RIGHT_BRACE;
END
if (lex_class[SCAN_CHAR] == WHITE_SPACE)
BEGIN
AUX_ERR_WHITE_SPACE_IN_ARGUMENT;
END
if (last > (buf_ptr2 + 1))
BEGIN
AUX_ERR_STUFF_AFTER_RIGHT_BRACE;
END
/***************************************************************************
* WEB section number: 140
* ~~~~~~~~~~~~~~~~~~~
* We must check that this potential .aux file won't overflow the
* stack, that it has the correct extension, that we haven't encountered
* it before (to prevent, among other things, an infinite loop).
***************************************************************************/
BEGIN
INCR (aux_ptr);
if (aux_ptr == AUX_STACK_SIZE)
BEGIN
PRINT_TOKEN;
PRINT (": ");
BIBTEX_OVERFLOW ("auxiliary file depth ", AUX_STACK_SIZE);
END
aux_extension_ok = TRUE;
if (TOKEN_LEN < LENGTH (s_aux_extension))
BEGIN
aux_extension_ok = FALSE;
END
else if ( ! str_eq_buf (s_aux_extension, buffer,
(buf_ptr2 - LENGTH (s_aux_extension)),
LENGTH (s_aux_extension)))
BEGIN
aux_extension_ok = FALSE;
END
if ( ! aux_extension_ok)
BEGIN
PRINT_TOKEN;
PRINT (" has a wrong extension");
DECR (aux_ptr);
AUX_ERR_RETURN;
END
CUR_AUX_STR = hash_text[str_lookup (buffer, buf_ptr1, TOKEN_LEN,
AUX_FILE_ILK, DO_INSERT)];
if (hash_found)
BEGIN
PRINT ("Already encountered file ");
print_aux_name ();
DECR (aux_ptr);
AUX_ERR_RETURN;
END
/***************************************************************************
* WEB section number: 141
* ~~~~~~~~~~~~~~~~~~~
* We check that this .aux file can actually be opened, and then open it.
*
* NOTE: because C arrays start at index 0, not 1, the subscripts of array
* |name_of_file| are generally 1 less than those in the WEB source.
***************************************************************************/
BEGIN
start_name (CUR_AUX_STR);
name_ptr = name_length;
while (name_ptr < FILE_NAME_SIZE)
BEGIN
name_of_file[name_ptr] = ' ';
INCR (name_ptr);
END
if ( ! a_open_in (&CUR_AUX_FILE, AUX_FILE_SEARCH_PATH))
BEGIN
PRINT ("I couldn't open auxiliary file ");
print_aux_name ();
perror ("\nReason");
DECR (aux_ptr);
AUX_ERR_RETURN;
END
PRINT2 ("A level-%ld auxilliary file: ", (long) aux_ptr);
print_aux_name ();
CUR_AUX_LINE = 0;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 141 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 140 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 139 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 177
* ~~~~~~~~~~~~~~~~~~~
* A legal argument for an execute, iterate, or reverse
* command must exist and be |built_in| or |wiz_defined|. Here's where we
* check, returning |true| if the argument is illegal.
***************************************************************************/
Boolean_T bad_argument_token (void)
BEGIN
Boolean_T bad_argument_token;
bad_argument_token= TRUE;
lower_case (buffer, buf_ptr1, TOKEN_LEN);
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, BST_FN_ILK, DONT_INSERT);
if ( ! hash_found)
BEGIN
PRINT_TOKEN;
BST_ERR (" is an unknown function");
END
else if ((fn_type[fn_loc] != BUILT_IN) && (fn_type[fn_loc] != WIZ_DEFINED))
BEGIN
PRINT_TOKEN;
PRINT (" has bad function type ");
print_fn_class (fn_loc);
BST_ERR_PRINT_AND_LOOK_FOR_BLAN;
END
bad_argument_token= FALSE;
Exit_Label:
return (bad_argument_token);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 177 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 280
* ~~~~~~~~~~~~~~~~~~~
* This procedure exists to save space, since it's used twice---once for
* each of the two succeeding modules.
***************************************************************************/
void bad_cross_reference_print (StrNumber_T s)
BEGIN
PRINT ("--entry \"");
PRINT_POOL_STR (CUR_CITE_STR);
PRINT_LN ("\"");
PRINT ("refers to entry \"");
PRINT_POOL_STR (s);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 280 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 240
* ~~~~~~~~~~~~~~~~~~~
* Here's another bug.
***************************************************************************/
void bib_cmd_confusion (void)
BEGIN
CONFUSION ("Unknown database-file command");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 240 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 231
* ~~~~~~~~~~~~~~~~~~~
* This one's for an expected |equals_sign|.
***************************************************************************/
void bib_equals_sign_print (void)
BEGIN
BIB_ERR2 ("I was expecting an \"%c\"", xchr[EQUALS_SIGN]);
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 231 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 221
* ~~~~~~~~~~~~~~~~~~~
* When there's a serious error parsing a .bib file, we flush
* everything up to the beginning of the next entry.
***************************************************************************/
void bib_err_print (void)
BEGIN
PRINT ("-");
bib_ln_num_print ();
print_bad_input_line ();
print_skipping_whatever_remains ();
if (at_bib_command)
BEGIN
PRINT_LN ("command");
END
else
BEGIN
PRINT_LN ("entry");
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 221 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 233
* ~~~~~~~~~~~~~~~~~~~
* And this one about an overly exuberant field.
***************************************************************************/
void bib_field_too_long_print (void)
BEGIN
BIB_ERR2 ("Your field is more than %ld characters", (long) BUF_SIZE);
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 233 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 235
* ~~~~~~~~~~~~~~~~~~~
* This macro is used to scan all .bib identifiers. The argument
* tells what was happening at the time. The associated procedure simply
* prints an error message.
***************************************************************************/
void bib_id_print (void)
BEGIN
if (scan_result == ID_NULL)
BEGIN
PRINT ("You're missing ");
END
else if (scan_result == OTHER_CHAR_ADJACENT)
BEGIN
PRINT2 ("\"%c\" immediately follows ", xchr[SCAN_CHAR]);
END
else
BEGIN
id_scanning_confusion ();
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 235 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 220
* ~~~~~~~~~~~~~~~~~~~
* This little procedure exists because it's used by at least two other
* procedures and thus saves some space.
***************************************************************************/
void bib_ln_num_print (void)
BEGIN
PRINT2 ("--line %ld of file ", (long) bib_line_num);
print_bib_name ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 220 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 230
* ~~~~~~~~~~~~~~~~~~~
* And here are a bunch of error-message macros, each called more than
* once, that thus save space as implemented. This one is for when one of
* two possible characters is expected while scanning.
***************************************************************************/
void bib_one_of_two_print (ASCIICode_T char1, ASCIICode_T char2)
BEGIN
BIB_ERR3 ("I was expecting a `%c' or a `%c'", xchr[char1], xchr[char2]);
Exit_Label: DO_NOTHING
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 230 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 232
* ~~~~~~~~~~~~~~~~~~~
* This complains about unbalanced braces.
***************************************************************************/
void bib_unbalanced_braces_print (void)
BEGIN
BIB_ERR ("Unbalanced braces");
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 232 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 222
* ~~~~~~~~~~~~~~~~~~~
* When there's a harmless error parsing a .bib file, we just give a
* warning message. This is always called after other stuff has been
* printed out.
***************************************************************************/
void bib_warn_print (void)
BEGIN
bib_ln_num_print ();
mark_warning ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 222 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 406
* ~~~~~~~~~~~~~~~~~~~
* At most one of the important letters, perhaps doubled, may appear at
* |sp_brace_level = 1|.
***************************************************************************/
void brace_lvl_one_letters_complaint (void)
BEGIN
PRINT ("The format string \"");
PRINT_POOL_STR (pop_lit1);
BST_EX_WARN ("\" has an illegal brace-level-1 letter");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 406 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 368
* ~~~~~~~~~~~~~~~~~~~
* This complaint often arises because the style designer has to type lots
* of braces.
***************************************************************************/
void braces_unbalanced_complaint (StrNumber_T pop_lit_var)
BEGIN
PRINT ("Warning--\"");
PRINT_POOL_STR (pop_lit_var);
BST_MILD_EX_WARN ("\" isn't a brace-balanced string");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 368 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 356
* ~~~~~~~~~~~~~~~~~~~
* It's time for a complaint if either of the two (entry or global) string
* lengths is exceeded.
***************************************************************************/
void bst_1print_string_size_exceeded (void)
BEGIN
PRINT ("Warning--you've exceeded ");
END
void bst_2print_string_size_exceeded (void)
BEGIN
PRINT ("-string-size,");
bst_mild_ex_warn_print ();
PRINT_LN ("*Please notify the bibstyle designer*");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 356 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 295
* ~~~~~~~~~~~~~~~~~~~
* It's illegal to mess with the entry information at certain times;
* here's a complaint for these times.
***************************************************************************/
void bst_cant_mess_with_entries_prin (void)
BEGIN
BST_EX_WARN ("You can't mess with entries here");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 295 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 170
* ~~~~~~~~~~~~~~~~~~~
* An entry command has three arguments, each a (possibly empty) list
* of function names between braces (the names are separated by one or
* more |white_space| characters). All function names in this and other
* commands must be legal .bst identifiers. Upper/lower cases are
* considered to be the same for function names in these lists---all
* upper-case letters are converted to lower case. These arguments give
* lists of |field|s, |int_entry_var|s, and |str_entry_var|s.
***************************************************************************/
void bst_entry_command (void)
BEGIN
if (entry_seen)
BEGIN
BST_ERR ("Illegal, another entry command");
END
entry_seen = TRUE;
EAT_BST_WHITE_AND_EOF_CHECK ("entry");
/***************************************************************************
* WEB section number: 171
* ~~~~~~~~~~~~~~~~~~~
* This module reads a |left_brace|, the list of |field|s, and a
* |right_brace|. The |field|s are those like `author' and `title.'
***************************************************************************/
BEGIN
BST_GET_AND_CHECK_LEFT_BRACE ("entry");
EAT_BST_WHITE_AND_EOF_CHECK ("entry");
while (SCAN_CHAR != RIGHT_BRACE)
BEGIN
BST_IDENTIFIER_SCAN ("entry");
/***************************************************************************
* WEB section number: 172
* ~~~~~~~~~~~~~~~~~~~
* Here we insert the just found field name into the hash table, record
* it as a |field|, and assign it a number to be used in indexing into
* the |field_info| array.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR_LN (" is a field");
}
#endif /* TRACE */
lower_case (buffer, buf_ptr1, TOKEN_LEN);
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN,
BST_FN_ILK, DO_INSERT);
CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc);
fn_type[fn_loc] = FIELD;
ilk_info[fn_loc] = num_fields;
INCR (num_fields);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 172 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("entry");
END
INCR (buf_ptr2);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 171 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("entry");
if (num_fields == num_pre_defined_fields)
BEGIN
BST_WARN ("Warning--I didn't find any fields");
END
/***************************************************************************
* WEB section number: 173
* ~~~~~~~~~~~~~~~~~~~
* This module reads a |left_brace|, the list of |int_entry_var|s,
* and a |right_brace|.
***************************************************************************/
BEGIN
BST_GET_AND_CHECK_LEFT_BRACE ("entry");
EAT_BST_WHITE_AND_EOF_CHECK ("entry");
while (SCAN_CHAR != RIGHT_BRACE)
BEGIN
BST_IDENTIFIER_SCAN ("entry");
/***************************************************************************
* WEB section number: 174
* ~~~~~~~~~~~~~~~~~~~
* Here we insert the just found |int_entry_var| name into the hash table
* and record it as an |int_entry_var|. An |int_entry_var| is one that
* the style designer wants a separate copy of for each entry.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR_LN (" is an integer entry-variable");
}
#endif /* TRACE */
lower_case (buffer, buf_ptr1, TOKEN_LEN);
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN,
BST_FN_ILK, DO_INSERT);
CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc);
fn_type[fn_loc] = INT_ENTRY_VAR;
FN_INFO[fn_loc] = num_ent_ints;
INCR (num_ent_ints);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 174 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("entry");
END
INCR (buf_ptr2);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 173 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("entry");
/***************************************************************************
* WEB section number: 175
* ~~~~~~~~~~~~~~~~~~~
* This module reads a |left_brace|, the list of |str_entry_var|s, and a
* |right_brace|. A |str_entry_var| is one that the style designer wants
* a separate copy of for each entry.
***************************************************************************/
BEGIN
BST_GET_AND_CHECK_LEFT_BRACE ("entry");
EAT_BST_WHITE_AND_EOF_CHECK ("entry");
while (SCAN_CHAR != RIGHT_BRACE)
BEGIN
BST_IDENTIFIER_SCAN ("entry");
/***************************************************************************
* WEB section number: 176
* ~~~~~~~~~~~~~~~~~~~
* Here we insert the just found |str_entry_var| name into the hash
* table, record it as a |str_entry_var|, and set its pointer into
* |entry_strs|.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR_LN (" is a string entry-variable");
}
#endif /* TRACE */
lower_case (buffer, buf_ptr1, TOKEN_LEN);
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN,
BST_FN_ILK, DO_INSERT);
CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc);
fn_type[fn_loc] = STR_ENTRY_VAR;
FN_INFO[fn_loc] = num_ent_strs;
INCR (num_ent_strs);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 176 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("entry");
END
INCR (buf_ptr2);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 175 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 170 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 149
* ~~~~~~~~~~~~~~~~~~~
* When there's a serious error parsing the .bst file, we flush the
* rest of the current command; a blank line is assumed to mark the end of
* a command (but for the purposes of error recovery only). Thus, error
* recovery will be better if style designers leave blank lines between
* .bst commands. This macro must be called from within a procedure
* that has an |exit| label.
***************************************************************************/
void bst_err_print_and_look_for_blan (void)
BEGIN
PRINT ("-");
bst_ln_num_print ();
print_bad_input_line ();
while (last != 0)
if ( ! input_ln (bst_file))
BEGIN
longjmp (Bst_Done_Flag, 1);
END
else
BEGIN
INCR (bst_line_num);
END
buf_ptr2 = last;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 149 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 178
* ~~~~~~~~~~~~~~~~~~~
* An execute command has one argument, a single |built_in| or
* |wiz_defined| function name between braces. Upper/lower cases are
* considered to be the same---all upper-case letters are converted to
* lower case. Also, we must make sure we've already seen a read
* command.
*
* This module reads a |left_brace|, a single function to be executed, and
* a |right_brace|.
***************************************************************************/
void bst_execute_command (void)
BEGIN
if ( ! read_seen)
BEGIN
BST_ERR ("Illegal, execute command before read command");
END
EAT_BST_WHITE_AND_EOF_CHECK ("execute");
BST_GET_AND_CHECK_LEFT_BRACE ("execute");
EAT_BST_WHITE_AND_EOF_CHECK ("execute");
BST_IDENTIFIER_SCAN ("execute");
/***************************************************************************
* WEB section number: 179
* ~~~~~~~~~~~~~~~~~~~
* Before executing the function, we must make sure it's a legal one. It
* must exist and be |built_in| or |wiz_defined|.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR_LN (" is a to be executed function");
}
#endif /* TRACE */
if (bad_argument_token ())
BEGIN
goto Exit_Label;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 179 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("execute");
BST_GET_AND_CHECK_RIGHT_BRACE ("execute");
/***************************************************************************
* WEB section number: 296
* ~~~~~~~~~~~~~~~~~~~
* This module executes a single specified function once. It can't do
* anything with the entries.
***************************************************************************/
BEGIN
init_command_execution ();
mess_with_entries = FALSE;
execute_fn (fn_loc);
check_command_execution ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 296 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 178 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 293
* ~~~~~~~~~~~~~~~~~~~
* When there's an error while executing .bst functions, what we do
* depends on whether the function is messing with the entries.
* Furthermore this error is serious enough to classify as an
* |error_message| instead of a |warning_message|. These messages (that
* is, from |bst_ex_warn|) are meant both for the user and for the style
* designer while debugging.
***************************************************************************/
void bst_ex_warn_print (void)
BEGIN
if (mess_with_entries)
BEGIN
PRINT (" for entry ");
PRINT_POOL_STR (CUR_CITE_STR);
END
PRINT_NEWLINE;
PRINT ("while executing-");
bst_ln_num_print ();
mark_error ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 293 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 180
* ~~~~~~~~~~~~~~~~~~~
* A function command has two arguments; the first is a |wiz_defined|
* function name between braces. Upper/lower cases are considered to be
* the same---all upper-case letters are converted to lower case. The
* second argument defines this function. It consists of a sequence of
* functions, between braces, separated by |white_space| characters.
* Upper/lower cases are considered to be the same for function names but
* not for |str_literal|s.
***************************************************************************/
void bst_function_command (void)
BEGIN
EAT_BST_WHITE_AND_EOF_CHECK ("function");
/***************************************************************************
* WEB section number: 181
* ~~~~~~~~~~~~~~~~~~~
* This module reads a |left_brace|, a |wiz_defined| function name, and
* a |right_brace|.
***************************************************************************/
BEGIN
BST_GET_AND_CHECK_LEFT_BRACE ("function");
EAT_BST_WHITE_AND_EOF_CHECK ("function");
BST_IDENTIFIER_SCAN ("function");
/***************************************************************************
* WEB section number: 182
* ~~~~~~~~~~~~~~~~~~~
* The function name must exist and be a new one; we mark it as
* |wiz_defined|. Also, see if it's the default entry-type function.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR_LN (" is a wizard-defined function");
}
#endif /* TRACE */
lower_case (buffer, buf_ptr1, TOKEN_LEN);
wiz_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, BST_FN_ILK,
DO_INSERT);
CHECK_FOR_ALREADY_SEEN_FUNCTION (wiz_loc);
fn_type[wiz_loc] = WIZ_DEFINED;
if (hash_text[wiz_loc] == s_default)
BEGIN
b_default = wiz_loc;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 182 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("function");
BST_GET_AND_CHECK_RIGHT_BRACE ("function");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 181 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("function");
BST_GET_AND_CHECK_LEFT_BRACE ("function");
scan_fn_def (wiz_loc);
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 180 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 166
* ~~~~~~~~~~~~~~~~~~~
* This macro is used to scan all .bst identifiers. The argument
* supplies the .bst command name. The associated procedure simply
* prints an error message.
***************************************************************************/
void bst_id_print (void)
BEGIN
if (scan_result == ID_NULL)
BEGIN
PRINT2 ("\"%c\" begins identifier, command: ", xchr[SCAN_CHAR]);
END
else if (scan_result == OTHER_CHAR_ADJACENT)
BEGIN
PRINT2 ("\"%c\" immediately follows identifier, command: ",
xchr[SCAN_CHAR]);
END
else
BEGIN
id_scanning_confusion ();
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 166 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 201
* ~~~~~~~~~~~~~~~~~~~
* An integers command has one argument, a list of function names
* between braces (the names are separated by one or more |white_space|
* characters). Upper/lower cases are considered to be the same for
* function names in these lists---all upper-case letters are converted to
* lower case. Each name in this list specifies an |int_global_var|.
* There may be several integers commands in the .bst file.
*
* This module reads a |left_brace|, a list of |int_global_var|s, and a
* |right_brace|.
***************************************************************************/
void bst_integers_command (void)
BEGIN
EAT_BST_WHITE_AND_EOF_CHECK ("integers");
BST_GET_AND_CHECK_LEFT_BRACE ("integers");
EAT_BST_WHITE_AND_EOF_CHECK ("integers");
while (SCAN_CHAR != RIGHT_BRACE)
BEGIN
BST_IDENTIFIER_SCAN ("integers");
/***************************************************************************
* WEB section number: 202
* ~~~~~~~~~~~~~~~~~~~
* Here we insert the just found |int_global_var| name into the hash
* table and record it as an |int_global_var|. Also, we initialize it by
* setting |FN_INFO[fn_loc]| to 0.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR_LN (" is an integer global-variable");
}
#endif /* TRACE */
lower_case (buffer, buf_ptr1, TOKEN_LEN);
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN,
BST_FN_ILK, DO_INSERT);
CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc);
fn_type[fn_loc] = INT_GLOBAL_VAR;
FN_INFO[fn_loc] = 0;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 202 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("integers");
END
INCR (buf_ptr2);
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 201 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 203
* ~~~~~~~~~~~~~~~~~~~
* An iterate command has one argument, a single |built_in| or
* |wiz_defined| function name between braces. Upper/lower cases are
* considered to be the same---all upper-case letters are converted to
* lower case. Also, we must make sure we've already seen a read
* command.
*
* This module reads a |left_brace|, a single function to be iterated, and
* a |right_brace|.
***************************************************************************/
void bst_iterate_command (void)
BEGIN
if ( ! read_seen)
BEGIN
BST_ERR ("Illegal, iterate command before read command");
END
EAT_BST_WHITE_AND_EOF_CHECK ("iterate");
BST_GET_AND_CHECK_LEFT_BRACE ("iterate");
EAT_BST_WHITE_AND_EOF_CHECK ("iterate");
BST_IDENTIFIER_SCAN ("iterate");
/***************************************************************************
* WEB section number: 204
* ~~~~~~~~~~~~~~~~~~~
* Before iterating the function, we must make sure it's a legal one. It
* must exist and be |built_in| or |wiz_defined|.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR_LN (" is a to be iterated function");
}
#endif /* TRACE */
if (bad_argument_token ())
BEGIN
goto Exit_Label;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 204 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("iterate");
BST_GET_AND_CHECK_RIGHT_BRACE ("iterate");
/***************************************************************************
* WEB section number: 297
* ~~~~~~~~~~~~~~~~~~~
* This module iterates a single specified function for all entries
* specified by |cite_list|.
***************************************************************************/
BEGIN
init_command_execution ();
mess_with_entries = TRUE;
sort_cite_ptr = 0;
while (sort_cite_ptr < num_cites)
BEGIN
cite_ptr = SORTED_CITES[sort_cite_ptr];
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_POOL_STR (hash_text[fn_loc]);
TRACE_PR (" to be iterated on ");
TRACE_PR_POOL_STR (CUR_CITE_STR);
TRACE_PR_NEWLINE;
}
#endif /* TRACE */
execute_fn (fn_loc);
check_command_execution ();
INCR (sort_cite_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 297 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 203 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 167
* ~~~~~~~~~~~~~~~~~~~
* This macro just makes sure we're at a |left_brace|.
***************************************************************************/
void bst_left_brace_print (void)
BEGIN
PRINT2 ("\"%c\" is missing in command: ", xchr[LEFT_BRACE]);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 167 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 148
* ~~~~~~~~~~~~~~~~~~~
* This little procedure exists because it's used by at least two other
* procedures and thus saves some space.
***************************************************************************/
void bst_ln_num_print (void)
BEGIN
PRINT2 ("--line %ld of file ", (long) bst_line_num);
print_bst_name ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 148 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 205
* ~~~~~~~~~~~~~~~~~~~
* A macro command, like a function command, has two arguments;
* the first is a macro name between braces. The name must be a legal
* .bst identifier. Upper/lower cases are considered to be the
* same---all upper-case letters are converted to lower case. The second
* argument defines this macro. It consists of a |double_quote|-delimited
* string (which must be on a single line) between braces, with optional
* |white_space| characters between the braces and the |double_quote|s.
* This |double_quote|-delimited string is parsed exactly as a
* |str_literal| is for the function command.
***************************************************************************/
void bst_macro_command (void)
BEGIN
if (read_seen)
BEGIN
BST_ERR ("Illegal, macro command after read command");
END
EAT_BST_WHITE_AND_EOF_CHECK ("macro");
/***************************************************************************
* WEB section number: 206
* ~~~~~~~~~~~~~~~~~~~
* This module reads a |left_brace|, a macro name, and a |right_brace|.
***************************************************************************/
BEGIN
BST_GET_AND_CHECK_LEFT_BRACE ("macro");
EAT_BST_WHITE_AND_EOF_CHECK ("macro");
BST_IDENTIFIER_SCAN ("macro");
/***************************************************************************
* WEB section number: 207
* ~~~~~~~~~~~~~~~~~~~
* The macro name must be a new one; we mark it as |macro_ilk|.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR_LN (" is a macro");
}
#endif /* TRACE */
lower_case (buffer, buf_ptr1, TOKEN_LEN);
macro_name_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, MACRO_ILK,
DO_INSERT);
if (hash_found)
BEGIN
PRINT_TOKEN;
BST_ERR (" is already defined as a macro");
END
ilk_info[macro_name_loc] = hash_text[macro_name_loc];
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 207 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("macro");
BST_GET_AND_CHECK_RIGHT_BRACE ("macro");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 206 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("macro");
/***************************************************************************
* WEB section number: 208
* ~~~~~~~~~~~~~~~~~~~
* This module reads a |left_brace|, the |double_quote|-delimited string
* that defines this macro, and a |right_brace|.
***************************************************************************/
BEGIN
BST_GET_AND_CHECK_LEFT_BRACE ("macro");
EAT_BST_WHITE_AND_EOF_CHECK ("macro");
if (SCAN_CHAR != DOUBLE_QUOTE)
BEGIN
BST_ERR2 ("A macro definition must be %c-delimited",
xchr[DOUBLE_QUOTE]);
END
/***************************************************************************
* WEB section number: 209
* ~~~~~~~~~~~~~~~~~~~
* A macro definition-string is preceded by a |double_quote| and consists
* of all characters on this line up to the next |double_quote|. The
* array |ilk_info| contains a pointer to this string for the macro name.
***************************************************************************/
BEGIN
INCR (buf_ptr2);
if ( ! scan1 (DOUBLE_QUOTE))
BEGIN
BST_ERR2 ("There's no `%c' to end macro definition",
xchr[DOUBLE_QUOTE]);
END
#ifdef TRACE
if (Flag_trace) {
TRACE_PR ("\"");
TRACE_PR_TOKEN;
TRACE_PR ("\"");
TRACE_PR_LN (" is a macro string");
}
#endif /* TRACE */
macro_def_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, TEXT_ILK,
DO_INSERT);
fn_type[macro_def_loc] = STR_LITERAL;
ilk_info[macro_name_loc] = hash_text[macro_def_loc];
INCR (buf_ptr2);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 209 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("macro");
BST_GET_AND_CHECK_RIGHT_BRACE ("macro");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 208 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 205 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 294
* ~~~~~~~~~~~~~~~~~~~
* When an error is so harmless, we print a |warning_message| instead of
* an |error_message|.
***************************************************************************/
void bst_mild_ex_warn_print (void)
BEGIN
if (mess_with_entries)
BEGIN
PRINT (" for entry ");
PRINT_POOL_STR (CUR_CITE_STR);
END
PRINT_NEWLINE;
BST_WARN ("while executing");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 294 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 211
* ~~~~~~~~~~~~~~~~~~~
* The read command has no arguments so there's no more parsing to do.
* We must make sure we haven't seen a read command before and we've
* already seen an entry command.
***************************************************************************/
void bst_read_command (void)
BEGIN
if (read_seen)
BEGIN
BST_ERR ("Illegal, another read command");
END
read_seen = TRUE;
if ( ! entry_seen)
BEGIN
BST_ERR ("Illegal, read command before entry command");
END
sv_ptr1 = buf_ptr2;
sv_ptr2 = last;
tmp_ptr = sv_ptr1;
while (tmp_ptr < sv_ptr2)
BEGIN
sv_buffer[tmp_ptr] = buffer[tmp_ptr];
INCR (tmp_ptr);
END
/***************************************************************************
* WEB section number: 223
* ~~~~~~~~~~~~~~~~~~~
* For all |num_bib_files| database files, we keep reading and processing
* .bib entries until none left.
***************************************************************************/
BEGIN
/***************************************************************************
* WEB section number: 224
* ~~~~~~~~~~~~~~~~~~~
* We need to initialize the |field_info| array, and also various things
* associated with the |cite_list| array (but not |cite_list| itself).
***************************************************************************/
BEGIN
/***************************************************************************
* WEB section number: 225
* ~~~~~~~~~~~~~~~~~~~
* This module initializes all fields of all entries to |missing|, the
* value to which all fields are initialized.
***************************************************************************/
BEGIN
check_field_overflow (num_fields * num_cites);
field_ptr = 0;
while (field_ptr < Max_Fields)
BEGIN
field_info[field_ptr] = MISSING;
INCR (field_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 225 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 227
* ~~~~~~~~~~~~~~~~~~~
* We must initialize the |type_list| array so that we can detect
* duplicate (or missing) entries for cite keys on |cite_list|. Also,
* when we're to include the entire database, we use the array
* |entry_exists| to detect those missing entries whose |cite_list| info
* will (or to be more precise, might) be overwritten; and we use the
* array |cite_info| to save the part of |cite_list| that will (might) be
* overwritten. We also use |cite_info| for counting cross~references
* when it's appropriate---when an entry isn't otherwise to be included
* on |cite_list| (that is, the entry isn't \cited or
* \nocited). Such an entry is included on the final |cite_list| if
* it's cross~referenced at least |min_crossrefs| times.
***************************************************************************/
BEGIN
cite_ptr = 0;
while (cite_ptr < Max_Cites)
BEGIN
type_list[cite_ptr] = EMPTY;
cite_info[cite_ptr] = ANY_VALUE;
INCR (cite_ptr);
END
old_num_cites = num_cites;
if (all_entries)
BEGIN
cite_ptr = all_marker;
while (cite_ptr < old_num_cites)
BEGIN
cite_info[cite_ptr] = cite_list[cite_ptr];
entry_exists[cite_ptr] = FALSE;
INCR (cite_ptr);
END
cite_ptr = all_marker;
END
else
BEGIN
cite_ptr = num_cites;
all_marker = ANY_VALUE;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 227 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 224 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
read_performed = TRUE;
bib_ptr = 0;
while (bib_ptr < num_bib_files)
BEGIN
PRINT2 ("Database file #%ld: ", (long) bib_ptr + 1);
print_bib_name ();
bib_line_num = 0;
buf_ptr2 = last;
while ( ! feof (CUR_BIB_FILE))
BEGIN
get_bib_command_or_entry_and_pr ();
END
a_close (CUR_BIB_FILE);
INCR (bib_ptr);
END
reading_completed = TRUE;
#ifdef TRACE
if (Flag_trace)
TRACE_PR_LN ("Finished reading the database file(s)");
#endif /* TRACE */
/***************************************************************************
* WEB section number: 276
* ~~~~~~~~~~~~~~~~~~~
* This gets things ready for further .bst processing.
***************************************************************************/
BEGIN
num_cites = cite_ptr;
num_preamble_strings = preamble_ptr;
/***************************************************************************
* WEB section number: 277
* ~~~~~~~~~~~~~~~~~~~
* Now we update any entry (here called a child entry) that
* cross referenced another (here called a parent entry); this
* cross referencing occurs when the child's crossref field (value)
* consists of the parent's database key. To do the update, we replace
* the child's |missing| fields by the corresponding fields of the
* parent. Also, we make sure the crossref field contains the
* case-correct version. Finally, although it is technically illegal to
* nest cross references, and although we give a warning (a few modules
* hence) when someone tries, we do what we can to accommodate the
* attempt.
***************************************************************************/
BEGIN
cite_ptr = 0;
while (cite_ptr < num_cites)
BEGIN
field_ptr = (cite_ptr * num_fields) + crossref_num;
if (field_info[field_ptr] != MISSING)
BEGIN
if (find_cite_locs_for_this_cite_ke (field_info[field_ptr]))
BEGIN
cite_loc = ilk_info[lc_cite_loc];
field_info[field_ptr] = hash_text[cite_loc];
cite_parent_ptr = ilk_info[cite_loc];
field_ptr = (cite_ptr * num_fields) + num_pre_defined_fields;
field_end_ptr = field_ptr - num_pre_defined_fields + num_fields;
field_parent_ptr = (cite_parent_ptr * num_fields)
+ num_pre_defined_fields;
while (field_ptr < field_end_ptr)
BEGIN
if (field_info[field_ptr] == MISSING)
BEGIN
field_info[field_ptr] = field_info[field_parent_ptr];
END
INCR (field_ptr);
INCR (field_parent_ptr);
END
END
END
INCR (cite_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 277 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 279
* ~~~~~~~~~~~~~~~~~~~
* Here we remove the crossref field value for each child whose
* parent was cross referenced too few times. We also issue any
* necessary warnings arising from a bad cross reference.
***************************************************************************/
BEGIN
cite_ptr = 0;
while (cite_ptr < num_cites)
BEGIN
field_ptr = (cite_ptr * num_fields) + crossref_num;
if (field_info[field_ptr] != MISSING)
BEGIN
if ( ! find_cite_locs_for_this_cite_ke (field_info[field_ptr]))
BEGIN
if (cite_hash_found)
BEGIN
hash_cite_confusion ();
END
non_existent_cross_reference_er ();
field_info[field_ptr] = MISSING;
END
else
BEGIN
if (cite_loc != ilk_info[lc_cite_loc])
BEGIN
hash_cite_confusion ();
END
cite_parent_ptr = ilk_info[cite_loc];
if (type_list[cite_parent_ptr] == EMPTY)
BEGIN
non_existent_cross_reference_er ();
field_info[field_ptr] = MISSING;
END
else
BEGIN
field_parent_ptr = (cite_parent_ptr * num_fields)
+ crossref_num;
if (field_info[field_parent_ptr] != MISSING)
/***************************************************************************
* WEB section number: 282
* ~~~~~~~~~~~~~~~~~~~
* We also complain when an entry being cross referenced has a
* non|missing| crossref field itself, but this one is just a
* warning, not a full-blown error.
***************************************************************************/
BEGIN
PRINT ("Warning--you've nested cross references");
bad_cross_reference_print (cite_list[cite_parent_ptr]);
PRINT_LN ("\", which also refers to something");
mark_warning ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 282 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
if (( ! all_entries) && (cite_parent_ptr >= old_num_cites)
&& (cite_info[cite_parent_ptr] < Min_Crossrefs))
BEGIN
field_info[field_ptr] = MISSING;
END
END
END
END
INCR (cite_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 279 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 283
* ~~~~~~~~~~~~~~~~~~~
* We remove (and give a warning for) each cite key on the original
* |cite_list| without a corresponding database entry. And we remove any
* entry that was included on |cite_list| only because it was
* cross~referenced, yet was cross~referenced fewer than |min_crossrefs|
* times. Throughout this module, |cite_ptr| points to the next cite key
* to be checked and |cite_xptr| points to the next permanent spot on
* |cite_list|.
***************************************************************************/
BEGIN
cite_ptr = 0;
while (cite_ptr < num_cites)
BEGIN
if (type_list[cite_ptr] == EMPTY)
BEGIN
print_missing_entry (CUR_CITE_STR);
END
else if ((all_entries) || (cite_ptr < old_num_cites)
|| (cite_info[cite_ptr] >= Min_Crossrefs))
BEGIN
if (cite_ptr > cite_xptr)
/***************************************************************************
* WEB section number: 285
* ~~~~~~~~~~~~~~~~~~~
* We have to move to its final resting place all the entry information
* associated with the exact location in |cite_list| of this cite key.
***************************************************************************/
BEGIN
cite_list[cite_xptr] = cite_list[cite_ptr];
type_list[cite_xptr] = type_list[cite_ptr];
if ( ! find_cite_locs_for_this_cite_ke (cite_list[cite_ptr]))
BEGIN
cite_key_disappeared_confusion ();
END
if (( ! cite_hash_found) || (cite_loc != ilk_info[lc_cite_loc]))
BEGIN
hash_cite_confusion ();
END
ilk_info[cite_loc] = cite_xptr;
field_ptr = cite_xptr * num_fields;
field_end_ptr = field_ptr + num_fields;
tmp_ptr = cite_ptr * num_fields;
while (field_ptr < field_end_ptr)
BEGIN
field_info[field_ptr] = field_info[tmp_ptr];
INCR (field_ptr);
INCR (tmp_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 285 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
INCR (cite_xptr);
END
INCR (cite_ptr);
END
num_cites = cite_xptr;
if (all_entries)
/***************************************************************************
* WEB section number: 286
* ~~~~~~~~~~~~~~~~~~~
* We need this module only when we're including the whole database.
* It's for missing entries whose cite key originally resided in
* |cite_list| at a spot that another cite key (might have) claimed.
***************************************************************************/
BEGIN
cite_ptr = all_marker;
while (cite_ptr < old_num_cites)
BEGIN
if ( ! entry_exists[cite_ptr])
BEGIN
print_missing_entry (cite_info[cite_ptr]);
END
INCR (cite_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 286 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 283 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 287
* ~~~~~~~~~~~~~~~~~~~
* This module initializes all |int_entry_var|s of all entries to 0, the
* value to which all integers are initialized.
***************************************************************************/
BEGIN
if ((num_ent_ints * num_cites) > Max_Ent_Ints)
BEGIN
PRINT2 ("%ld: ", (long) (num_ent_ints * num_cites));
BIBTEX_OVERFLOW ("total number of integer entry-variables ", Max_Ent_Ints);
END
int_ent_ptr = 0;
while (int_ent_ptr < (num_ent_ints * num_cites))
BEGIN
entry_ints[int_ent_ptr] = 0;
INCR (int_ent_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 287 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 288
* ~~~~~~~~~~~~~~~~~~~
* This module initializes all |str_entry_var|s of all entries to the
* null string, the value to which all strings are initialized.
***************************************************************************/
BEGIN
if ((num_ent_strs * num_cites) > Max_Ent_Strs)
BEGIN
PRINT2 ("%ld: ", (long) (num_ent_strs * num_cites));
BIBTEX_OVERFLOW ("total number of string entry-variables ", Max_Ent_Strs);
END
str_ent_ptr = 0;
while (str_ent_ptr < (num_ent_strs * num_cites))
BEGIN
ENTRY_STRS(str_ent_ptr,0) = END_OF_STRING;
INCR (str_ent_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 288 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 289
* ~~~~~~~~~~~~~~~~~~~
* The array |sorted_cites| initially specifies that the entries are to
* be processed in order of cite-key occurrence. The sort command
* may change this to whatever it likes (which, we hope, is whatever the
* style-designer instructs it to like). We make |sorted_cites| an alias
* to save space; this works fine because we're done with |cite_info|.
***************************************************************************/
BEGIN
cite_ptr = 0;
while (cite_ptr < num_cites)
BEGIN
SORTED_CITES[cite_ptr] = cite_ptr;
INCR (cite_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 289 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 276 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
read_completed = TRUE;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 223 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
buf_ptr2 = sv_ptr1;
last = sv_ptr2;
tmp_ptr = buf_ptr2;
while (tmp_ptr < last)
BEGIN
buffer[tmp_ptr] = sv_buffer[tmp_ptr];
INCR (tmp_ptr);
END
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 211 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 212
* ~~~~~~~~~~~~~~~~~~~
* A reverse command has one argument, a single |built_in| or
* |wiz_defined| function name between braces. Upper/lower cases are
* considered to be the same---all upper-case letters are converted to
* lower case. Also, we must make sure we've already seen a read
* command.
*
* This module reads a |left_brace|, a single function to be iterated in
* reverse, and a |right_brace|.
***************************************************************************/
void bst_reverse_command (void)
BEGIN
if ( ! read_seen)
BEGIN
BST_ERR ("Illegal, reverse command before read command");
END
EAT_BST_WHITE_AND_EOF_CHECK ("reverse");
BST_GET_AND_CHECK_LEFT_BRACE ("reverse");
EAT_BST_WHITE_AND_EOF_CHECK ("reverse");
BST_IDENTIFIER_SCAN ("reverse");
/***************************************************************************
* WEB section number: 213
* ~~~~~~~~~~~~~~~~~~~
* Before iterating the function, we must make sure it's a legal one. It
* must exist and be |built_in| or |wiz_defined|.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR_LN (" is a to be iterated in reverse function");
}
#endif /* TRACE */
if (bad_argument_token ())
BEGIN
goto Exit_Label;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 213 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("reverse");
BST_GET_AND_CHECK_RIGHT_BRACE ("reverse");
/***************************************************************************
* WEB section number: 298
* ~~~~~~~~~~~~~~~~~~~
* This module iterates a single specified function for all entries
* specified by |cite_list|, but does it in reverse order.
***************************************************************************/
BEGIN
init_command_execution ();
mess_with_entries = TRUE;
if (num_cites > 0)
BEGIN
sort_cite_ptr = num_cites;
REPEAT
BEGIN
DECR (sort_cite_ptr);
cite_ptr = SORTED_CITES[sort_cite_ptr];
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_POOL_STR (hash_text[fn_loc]);
TRACE_PR (" to be iterated in reverse on ");
TRACE_PR_POOL_STR (CUR_CITE_STR);
TRACE_PR_NEWLINE;
}
#endif /* TRACE */
execute_fn (fn_loc);
check_command_execution ();
END UNTIL (sort_cite_ptr == 0);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 298 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 212 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 168
* ~~~~~~~~~~~~~~~~~~~
* And this one, a |right_brace|.
***************************************************************************/
void bst_right_brace_print (void)
BEGIN
PRINT2 ("\"%c\" is missing in command: ", xchr[RIGHT_BRACE]);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 168 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 214
* ~~~~~~~~~~~~~~~~~~~
* The sort command has no arguments so there's no more parsing to do,
* but we must make sure we've already seen a read command.
***************************************************************************/
void bst_sort_command (void)
BEGIN
if ( ! read_seen)
BEGIN
BST_ERR ("Illegal, sort command before read command");
END
/***************************************************************************
* WEB section number: 299
* ~~~~~~~~~~~~~~~~~~~
* This module sorts the entries based on sort.key$; it is a stable
* sort.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace)
TRACE_PR_LN ("Sorting the entries");
#endif /* TRACE */
if (num_cites > 1)
BEGIN
quick_sort (0, num_cites - 1);
END
#ifdef TRACE
if (Flag_trace)
TRACE_PR_LN ("Done sorting");
#endif /* TRACE */
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 299 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 214 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 215
* ~~~~~~~~~~~~~~~~~~~
* A strings command has one argument, a list of function names
* between braces (the names are separated by one or more |white_space|
* characters). Upper/lower cases are considered to be the same for
* function names in these lists---all upper-case letters are converted to
* lower case. Each name in this list specifies a |str_global_var|.
* There may be several strings commands in the .bst file.
*
* This module reads a |left_brace|, a list of |str_global_var|s, and a
* |right_brace|.
***************************************************************************/
void bst_strings_command (void)
BEGIN
EAT_BST_WHITE_AND_EOF_CHECK ("strings");
BST_GET_AND_CHECK_LEFT_BRACE ("strings");
EAT_BST_WHITE_AND_EOF_CHECK ("strings");
while (SCAN_CHAR != RIGHT_BRACE)
BEGIN
BST_IDENTIFIER_SCAN ("strings");
/***************************************************************************
* WEB section number: 216
* ~~~~~~~~~~~~~~~~~~~
* Here we insert the just found |str_global_var| name into the hash
* table, record it as a |str_global_var|, set its pointer into
* |global_strs|, and initialize its value there to the null string.
***************************************************************************/
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR_LN (" is a string global-variable");
}
#endif /* TRACE */
lower_case (buffer, buf_ptr1, TOKEN_LEN);
fn_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, BST_FN_ILK,
DO_INSERT);
CHECK_FOR_ALREADY_SEEN_FUNCTION (fn_loc);
fn_type[fn_loc] = STR_GLOBAL_VAR;
FN_INFO[fn_loc] = num_glb_strs;
if (num_glb_strs == MAX_GLOB_STRS)
BEGIN
BIBTEX_OVERFLOW ("number of string global-variables %ld", MAX_GLOB_STRS);
END
INCR (num_glb_strs);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 216 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
EAT_BST_WHITE_AND_EOF_CHECK ("strings");
END
INCR (buf_ptr2);
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 215 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 150
* ~~~~~~~~~~~~~~~~~~~
* When there's a harmless error parsing the .bst file (harmless
* syntactically, at least) we give just a |warning_message|.
***************************************************************************/
void bst_warn_print (void)
BEGIN
bst_ln_num_print ();
mark_warning ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 150 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 46
* ~~~~~~~~~~~~~~~~~~~
* When a buffer overflows, it's time to complain (and then quit).
***************************************************************************/
void buffer_overflow (void)
BEGIN
BIBTEX_OVERFLOW ("buffer size ", BUF_SIZE);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 46 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 335
* ~~~~~~~~~~~~~~~~~~~
* This procedure inserts a |built_in| function into the hash table and
* initializes the corresponding pre-defined string (of length at most
* |longest_pds|). The array |FN_INFO| contains a number from 0 through
* the number of |built_in| functions minus 1 (i.e., |num_blt_in_fns - 1|
* if we're keeping statistics); this number is used by a |case| statement
* to execute this function and is used for keeping execution counts when
* keeping statistics.
***************************************************************************/
void build_in (PdsType_T pds, PdsLen_T len,
HashLoc_T *fn_hash_loc, BltInRange_T blt_in_num)
BEGIN
pre_define (pds, len, BST_FN_ILK);
*fn_hash_loc = pre_def_loc;
fn_type[*fn_hash_loc] = BUILT_IN;
FN_INFO[*fn_hash_loc] = blt_in_num;
#ifdef STAT
if (Flag_stats) {
blt_in_loc[blt_in_num] = *fn_hash_loc;
execution_count[blt_in_num] = 0;
}
#endif /* STAT */
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 335 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 373
* ~~~~~~~~~~~~~~~~~~~
* Another bug complaint.
***************************************************************************/
void case_conversion_confusion (void)
BEGIN
CONFUSION ("Unknown type of case conversion");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 373 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 369
* ~~~~~~~~~~~~~~~~~~~
* This one makes sure that |brace_level=0| (it's called at a point in a
* string where braces must be balanced).
***************************************************************************/
void check_brace_level (StrNumber_T pop_lit_var)
BEGIN
if (brace_level > 0)
BEGIN
braces_unbalanced_complaint (pop_lit_var);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 369 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 138
* ~~~~~~~~~~~~~~~~~~~
* Complain if somebody's got a cite fetish. This procedure is called
* when were about to add another cite key to |cite_list|. It assumes
* that |cite_loc| gives the potential cite key's hash table location.
***************************************************************************/
void check_cite_overflow (CiteNumber_T last_cite)
BEGIN
if (last_cite == Max_Cites)
BEGIN
PRINT_POOL_STR (hash_text[cite_loc]);
PRINT_LN (" is the key:");
BIBTEX_OVERFLOW ("number of cite keys ", Max_Cites);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 138 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 317
* ~~~~~~~~~~~~~~~~~~~
* At the end of a .bst command-execution we check that the stack and
* |str_pool| are still in good shape.
***************************************************************************/
void check_command_execution (void)
BEGIN
if (lit_stk_ptr != 0)
BEGIN
PRINT_LN2 ("ptr=%ld, stack=", (long) lit_stk_ptr);
pop_whole_stack ();
PRINT ("---the literal stack isn't empty");
bst_ex_warn_print ();
END
if (cmd_str_ptr != str_ptr)
BEGIN
#ifdef TRACE
if (Flag_trace)
TRACE_PR_LN3 ("Pointer is %ld but should be %ld", (long) str_ptr,
(long) cmd_str_ptr);
#endif /* TRACE */
CONFUSION ("Nonempty empty string stack");
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 317 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 226
* ~~~~~~~~~~~~~~~~~~~
* Complain if somebody's got a field fetish.
***************************************************************************/
void check_field_overflow (Integer_T total_fields)
BEGIN
if (total_fields > Max_Fields)
BEGIN
PRINT_LN2 ("%ld fields:", (long) total_fields);
BIBTEX_OVERFLOW ("total number of fields ", Max_Fields);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 226 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 271
* ~~~~~~~~~~~~~~~~~~~
* Here's another bug complaint.
***************************************************************************/
void cite_key_disappeared_confusion (void)
BEGIN
CONFUSION ("A cite key disappeared");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 271 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 252
* ~~~~~~~~~~~~~~~~~~~
* The .bib-specific scanning function |compress_bib_white| skips over
* |white_space| characters within a string until hitting a nonwhite
* character; in fact, it does everything |eat_bib_white_space| does, but
* it also adds a |space| to |field_vl_str|. This function is never
* called if there are no |white_space| characters (or ends-of-line) to be
* scanned (though the associated macro might be). The function returns
* |false| if there is a serious syntax error.
***************************************************************************/
Boolean_T compress_bib_white (void)
BEGIN
Boolean_T compress_bib_white;
compress_bib_white = FALSE;
COPY_CHAR (SPACE);
while ( ! scan_white_space ())
BEGIN
if ( ! input_ln (CUR_BIB_FILE))
BEGIN
eat_bib_print ();
goto Exit_Label;
END
INCR (bib_line_num);
buf_ptr2 = 0;
END
compress_bib_white = TRUE;
Exit_Label: DO_NOTHING;
return (compress_bib_white);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 252 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 367
* ~~~~~~~~~~~~~~~~~~~
* This procedure complains if the just-encountered |right_brace| would
* make |brace_level| negative.
***************************************************************************/
void decr_brace_level (StrNumber_T pop_lit_var)
BEGIN
if (brace_level == 0)
BEGIN
braces_unbalanced_complaint (pop_lit_var);
END
else
BEGIN
DECR (brace_level);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 367 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 229
* ~~~~~~~~~~~~~~~~~~~
* It's often illegal to end a .bib command in certain places, and
* this is where we come to check.
***************************************************************************/
void eat_bib_print (void)
BEGIN
BIB_ERR (" Illegal end of database file");
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 229 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 228
* ~~~~~~~~~~~~~~~~~~~
* Before we actually start the code for reading a database file, we must
* define this .bib-specific scanning function. It skips over
* |white_space| characters until hitting a nonwhite character or the end
* of the file, respectively returning |true| or |false|. It also updates
* |bib_line_num|, the line counter.
***************************************************************************/
Boolean_T eat_bib_white_space (void)
BEGIN
Boolean_T eat_bib_white_space;
while ( ! scan_white_space ())
BEGIN
if ( ! input_ln (CUR_BIB_FILE))
BEGIN
eat_bib_white_space = FALSE;
goto Exit_Label;
END
INCR (bib_line_num);
buf_ptr2 = 0;
END
eat_bib_white_space = TRUE;
Exit_Label:
return (eat_bib_white_space);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 228 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 153
* ~~~~~~~~~~~~~~~~~~~
* It's often illegal to end a .bst command in certain places, and
* this is where we come to check.
***************************************************************************/
void eat_bst_print (void)
BEGIN
PRINT ("Illegal end of style file in command: ");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 153 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 152
* ~~~~~~~~~~~~~~~~~~~
* This .bst-specific scanning function skips over |white_space|
* characters (and comments) until hitting a nonwhite character or the end
* of the file, respectively returning |true| or |false|. It also updates
* |bst_line_num|, the line counter.
***************************************************************************/
Boolean_T eat_bst_white_space (void)
BEGIN
Boolean_T eat_bst_white_space;
LOOP
BEGIN
if (scan_white_space ())
BEGIN
if (SCAN_CHAR != COMMENT)
BEGIN
eat_bst_white_space = TRUE;
goto Exit_Label;
END
END
if ( ! input_ln (bst_file))
BEGIN
eat_bst_white_space = FALSE;
goto Exit_Label;
END
INCR (bst_line_num);
buf_ptr2 = 0;
END
Exit_Label:
return (eat_bst_white_space);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 152 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 418
* ~~~~~~~~~~~~~~~~~~~
* This function looks at the string in |ex_buf|, starting at
* |ex_buf_xptr| and ending just before |ex_buf_ptr|, and it returns
* |true| if there are |enough_chars|, where a special character (even if
* it's missing its matching |right_brace|) counts as a single charcter.
* This procedure is called only for strings that don't have too many
* |right_brace|s.
***************************************************************************/
Boolean_T enough_text_chars (BufPointer_T enough_chars)
BEGIN
Boolean_T enough_text_chars;
num_text_chars = 0;
ex_buf_yptr = ex_buf_xptr;
while ((ex_buf_yptr < ex_buf_ptr) && (num_text_chars < enough_chars))
BEGIN
INCR (ex_buf_yptr);
if (ex_buf[ex_buf_yptr - 1] == LEFT_BRACE)
BEGIN
INCR (brace_level);
if ((brace_level == 1) && (ex_buf_yptr < ex_buf_ptr))
BEGIN
if (ex_buf[ex_buf_yptr] == BACKSLASH)
BEGIN
INCR (ex_buf_yptr);
while ((ex_buf_yptr < ex_buf_ptr) && (brace_level > 0))
BEGIN
if (ex_buf[ex_buf_yptr] == RIGHT_BRACE)
BEGIN
DECR (brace_level);
END
else if (ex_buf[ex_buf_yptr] == LEFT_BRACE)
BEGIN
INCR (brace_level);
END
INCR (ex_buf_yptr);
END
END
END
END
else if (ex_buf[ex_buf_yptr - 1] == RIGHT_BRACE)
BEGIN
DECR (brace_level);
END
INCR (num_text_chars);
END
if (num_text_chars < enough_chars)
BEGIN
enough_text_chars = FALSE;
END
else
BEGIN
enough_text_chars = TRUE;
END
return (enough_text_chars);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 418 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
|