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
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
|
/*-
******************************************************************************
******************************************************************************
**
** MODULE
**
** file: bibtex-3.c
**
** 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 third 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:
**
** pre_def_certain_strings
** pre_define
** print_lit
** print_missing_entry
** print_overflow
** print_recursion_illegal
** print_skipping_whatever_remains
** print_stk_lit
** print_wrong_stk_lit
** push_lit_stk
** quick_sort
** sam_too_long_file_name_print
** sam_wrong_file_name_print
** scan1
** scan1_white
** scan2
** scan2_white
** scan3
** scan_a_field_token_and_eat_whit
** scan_alpha
** scan_and_store_the_field_value
** scan_balanced_braces
** str_eq_buf
** str_eq_str
** str_lookup
** swap
** trace_and_stat_printing
** trace_pr_fn_class
** unknwn_function_class_confusion
** unknwn_literal_confusion
** upper_case
** von_name_ends_and_last_name_sta
** von_token_found
** x_add_period
**
** 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-3.c,v $
** Revision 3.71 1996/08/18 20:37:06 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.6 1995/10/21 22:19:33 kempson
** Removed previous WEB-imposed limit on the maximum value of Hash_Prime.
**
** 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:40 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: 336
* ~~~~~~~~~~~~~~~~~~~
* This is a procedure so that |initialize| is smaller.
***************************************************************************/
void pre_def_certain_strings (void)
BEGIN
/***************************************************************************
* WEB section number: 75
* ~~~~~~~~~~~~~~~~~~~
* It's time to insert some of the pre-defined strings into |str_pool|
* (and thus the hash table). These system-dependent strings should
* contain no upper-case letters, and they must all be exactly
* |longest_pds| characters long (even if fewer characters are actually
* stored). The |pre_define| routine appears shortly.
*
* Important notes: These pre-definitions must not have any glitches or
* the program may bomb because the |log_file| hasn't been opened yet,
* and |text_ilk|s should be pre-defined later, for
* .bst-function-execution purposes.
***************************************************************************/
pre_define (".aux ", 4, FILE_EXT_ILK);
s_aux_extension = hash_text[pre_def_loc];
pre_define (".bbl ", 4, FILE_EXT_ILK);
s_bbl_extension = hash_text[pre_def_loc];
pre_define (".blg ", 4, FILE_EXT_ILK);
s_log_extension = hash_text[pre_def_loc];
pre_define (".bst ", 4, FILE_EXT_ILK);
s_bst_extension = hash_text[pre_def_loc];
pre_define (".bib ", 4, FILE_EXT_ILK);
s_bib_extension = hash_text[pre_def_loc];
/***************************************************************************
* WEB section number: 79
* ~~~~~~~~~~~~~~~~~~~
* Now we pre-define the command strings; they must all be exactly
* |longest_pds| characters long.
*
* Important note: These pre-definitions must not have any glitches or
* the program may bomb because the |log_file| hasn't been opened yet.
***************************************************************************/
pre_define ("\\citation ", 9, AUX_COMMAND_ILK);
ilk_info[pre_def_loc] = N_AUX_CITATION;
pre_define ("\\bibdata ", 8, AUX_COMMAND_ILK);
ilk_info[pre_def_loc] = N_AUX_BIBDATA;
pre_define ("\\bibstyle ", 9, AUX_COMMAND_ILK);
ilk_info[pre_def_loc] = N_AUX_BIBSTYLE;
pre_define ("\\@input ", 7, AUX_COMMAND_ILK);
ilk_info[pre_def_loc] = N_AUX_INPUT;
pre_define ("entry ", 5, BST_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BST_ENTRY;
pre_define ("execute ", 7, BST_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BST_EXECUTE;
pre_define ("function ", 8, BST_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BST_FUNCTION;
pre_define ("integers ", 8, BST_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BST_INTEGERS;
pre_define ("iterate ", 7, BST_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BST_ITERATE;
pre_define ("macro ", 5, BST_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BST_MACRO;
pre_define ("read ", 4, BST_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BST_READ;
pre_define ("reverse ", 7, BST_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BST_REVERSE;
pre_define ("sort ", 4, BST_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BST_SORT;
pre_define ("strings ", 7, BST_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BST_STRINGS;
pre_define ("comment ", 7, BIB_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BIB_COMMENT;
pre_define ("preamble ", 8, BIB_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BIB_PREAMBLE;
pre_define ("string ", 6, BIB_COMMAND_ILK);
ilk_info[pre_def_loc] = N_BIB_STRING;
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 79 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 334
* ~~~~~~~~~~~~~~~~~~~
* It's time for us to insert more pre-defined strings into |str_pool|
* (and thus the hash table) and to insert the |built_in| functions into
* the hash table. The strings corresponding to these functions should
* contain no upper-case letters, and they must all be exactly
* |longest_pds| characters long. The |build_in| routine (to appear
* shortly) does the work.
*
* Important note: These pre-definitions must not have any glitches or the
* program may bomb because the |log_file| hasn't been opened yet.
***************************************************************************/
build_in ("= ", 1, &b_equals, N_EQUALS);
build_in ("> ", 1, &b_greater_than, N_GREATER_THAN);
build_in ("< ", 1, &b_less_than, N_LESS_THAN);
build_in ("+ ", 1, &b_plus, N_PLUS);
build_in ("- ", 1, &b_minus, N_MINUS);
build_in ("& ", 1, &b_bit_and, N_BIT_AND);
build_in ("| ", 1, &b_bit_or, N_BIT_OR);
build_in ("* ", 1, &b_concatenate, N_CONCATENATE);
build_in (":= ", 2, &b_gets, N_GETS);
build_in ("add.period$ ", 11, &b_add_period, N_ADD_PERIOD);
build_in ("call.type$ ", 10, &b_call_type, N_CALL_TYPE);
build_in ("change.case$", 12, &b_change_case, N_CHANGE_CASE);
build_in ("chr.to.int$ ", 11, &b_chr_to_int, N_CHR_TO_INT);
build_in ("cite$ ", 5, &b_cite, N_CITE);
build_in ("duplicate$ ", 10, &b_duplicate, N_DUPLICATE);
build_in ("empty$ ", 6, &b_empty, N_EMPTY);
build_in ("format.name$", 12, &b_format_name, N_FORMAT_NAME);
build_in ("if$ ", 3, &b_if, N_IF);
build_in ("int.to.chr$ ", 11, &b_int_to_chr, N_INT_TO_CHR);
build_in ("int.to.str$ ", 11, &b_int_to_str, N_INT_TO_STR);
build_in ("missing$ ", 8, &b_missing, N_MISSING);
build_in ("newline$ ", 8, &b_newline, N_NEWLINE);
build_in ("num.names$ ", 10, &b_num_names, N_NUM_NAMES);
build_in ("pop$ ", 4, &b_pop, N_POP);
build_in ("preamble$ ", 9, &b_preamble, N_PREAMBLE);
build_in ("purify$ ", 7, &b_purify, N_PURIFY);
build_in ("quote$ ", 6, &b_quote, N_QUOTE);
build_in ("skip$ ", 5, &b_skip, N_SKIP);
build_in ("stack$ ", 6, &b_stack, N_STACK);
build_in ("substring$ ", 10, &b_substring, N_SUBSTRING);
build_in ("swap$ ", 5, &b_swap, N_SWAP);
build_in ("text.length$", 12, &b_text_length, N_TEXT_LENGTH);
build_in ("text.prefix$", 12, &b_text_prefix, N_TEXT_PREFIX);
build_in ("top$ ", 4, &b_top_stack, N_TOP_STACK);
build_in ("type$ ", 5, &b_type, N_TYPE);
build_in ("warning$ ", 8, &b_warning, N_WARNING);
build_in ("width$ ", 6, &b_width, N_WIDTH);
build_in ("while$ ", 6, &b_while, N_WHILE);
build_in ("write$ ", 6, &b_write, N_WRITE);
#ifdef UTF_8
build_in ("is.cjk.str$ ", 11, &b_cjk_string, N_IS_CJK_STRING);
build_in ("is.kanji.str$", 13, &b_cjk_string, N_IS_CJK_STRING);
#endif
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 334 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 339
* ~~~~~~~~~~~~~~~~~~~
* Here we pre-define a few strings used in executing the .bst file:
* the null string, which is sometimes pushed onto the stack; a string
* used for default entry types; and some control sequences used to spot
* foreign characters. We also initialize the |s_preamble| array to
* empty. These pre-defined strings must all be exactly |longest_pds|
* characters long.
*
* Important note: These pre-definitions must not have any glitches or
* the program may bomb because the |log_file| hasn't been opened yet,
* and |text_ilk|s should be pre-defined here, not earlier, for
* .bst-function-execution purposes.
***************************************************************************/
pre_define (" ", 0, TEXT_ILK);
s_null = hash_text[pre_def_loc];
fn_type[pre_def_loc] = STR_LITERAL;
pre_define ("default.type", 12, TEXT_ILK);
s_default = hash_text[pre_def_loc];
fn_type[pre_def_loc] = STR_LITERAL;
b_default = b_skip;
preamble_ptr = 0;
pre_define ("i ", 1, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_I;
pre_define ("j ", 1, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_J;
pre_define ("oe ", 2, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_OE;
pre_define ("OE ", 2, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_OE_UPPER;
pre_define ("ae ", 2, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_AE;
pre_define ("AE ", 2, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_AE_UPPER;
pre_define ("aa ", 2, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_AA;
pre_define ("AA ", 2, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_AA_UPPER;
pre_define ("o ", 1, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_O;
pre_define ("O ", 1, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_O_UPPER;
pre_define ("l ", 1, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_L;
pre_define ("L ", 1, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_L_UPPER;
pre_define ("ss ", 2, CONTROL_SEQ_ILK);
ilk_info[pre_def_loc] = N_SS;
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 339 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 340
* ~~~~~~~~~~~~~~~~~~~
* Now we pre-define any built-in |field|s, |str_entry_var|s, and
* |int_global_var|s; these strings must all be exactly |longest_pds|
* characters long. Note that although these are built-in functions, we
* classify them (in the |fn_type| array) otherwise.
*
* Important note: These pre-definitions must not have any glitches or
* the program may bomb because the |log_file| hasn't been opened yet.
***************************************************************************/
pre_define ("crossref ", 8, BST_FN_ILK);
fn_type[pre_def_loc] = FIELD;
FN_INFO[pre_def_loc] = num_fields;
crossref_num = num_fields;
INCR (num_fields);
num_pre_defined_fields = num_fields;
pre_define ("sort.key$ ", 9, BST_FN_ILK);
fn_type[pre_def_loc] = STR_ENTRY_VAR;
FN_INFO[pre_def_loc] = num_ent_strs;
sort_key_num = num_ent_strs;
INCR (num_ent_strs);
pre_define ("entry.max$ ", 10, BST_FN_ILK);
fn_type[pre_def_loc] = INT_GLOBAL_VAR;
FN_INFO[pre_def_loc] = Ent_Str_Size;
pre_define ("global.max$ ", 11, BST_FN_ILK);
fn_type[pre_def_loc] = INT_GLOBAL_VAR;
FN_INFO[pre_def_loc] = Glob_Str_Size;
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 340 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 336 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 77
* ~~~~~~~~~~~~~~~~~~~
* This procedure initializes a pre-defined string of length at most
* |longest_pds|.
***************************************************************************/
void pre_define (PdsType_T pds, PdsLen_T len, StrIlk_T ilk)
BEGIN
PdsLen_T i;
for (i=1; i<=len; i++)
BEGIN
/*----------------------------------------------------------------------
* Unlike the WEB, the string in `pds' will occupy the positions
* pds[0] ... pds[len-1], rather than pds[1] ... pds[len].
*----------------------------------------------------------------------*/
buffer[i] = xord[(UChar_T)pds[i-1]];
END
pre_def_loc = str_lookup (buffer, 1, len, ilk, DO_INSERT);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 77 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 3
* ~~~~~~~~~~~~~~~~~~~
***************************************************************************/
void print_a_newline (void)
BEGIN
if (log_file != NULL)
FPUTC ('\n', log_file);
FPUTC ('\n', TERM_OUT);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 51
* ~~~~~~~~~~~~~~~~~~~
* And here are the associated procedures. Note the |term_out| file is
* system dependent.
***************************************************************************/
void print_a_pool_str (StrNumber_T s)
BEGIN
out_pool_str (TERM_OUT, s);
out_pool_str (log_file, s);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 51 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 82
* ~~~~~~~~~~~~~~~~~~~
* And here are the associated procedures. Note the |term_out| file is
* system dependent.
***************************************************************************/
void print_a_token (void)
BEGIN
out_token (TERM_OUT);
out_token (log_file);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 82 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 108
* ~~~~~~~~~~~~~~~~~~~
* Print the name of the current .aux file, followed by a |newline|.
***************************************************************************/
void print_aux_name (void)
BEGIN
PRINT_POOL_STR (CUR_AUX_STR);
PRINT_NEWLINE;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 108 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 95
* ~~~~~~~~~~~~~~~~~~~
* The |print_bad_input_line| procedure prints the current input line,
* splitting it at the character being scanned: It prints |buffer[0]|,
* |buffer[1]|, \dots, |buffer[buf_ptr2-1]| on one line and
* |SCAN_CHAR|, \dots, |buffer[last-1]| on the next (and both
* lines start with a colon between two |space|s). Each |white_space|
* character is printed as a |space|.
***************************************************************************/
void print_bad_input_line (void)
BEGIN
BufPointer_T bf_ptr;
PRINT (" : ");
bf_ptr = 0;
while (bf_ptr < buf_ptr2)
BEGIN
if (lex_class[buffer[bf_ptr]] == WHITE_SPACE)
BEGIN
PRINT2 ("%c", xchr[SPACE]);
END
else
BEGIN
PRINT2 ("%c", xchr[buffer[bf_ptr]]);
END
INCR (bf_ptr);
END
PRINT_NEWLINE;
PRINT (" : ");
bf_ptr = 0;
while (bf_ptr < buf_ptr2)
BEGIN
PRINT2 ("%c", xchr[SPACE]);
INCR (bf_ptr);
END
bf_ptr = buf_ptr2;
while (bf_ptr < last)
BEGIN
if (lex_class[buffer[bf_ptr]] == WHITE_SPACE)
BEGIN
PRINT2 ("%c", xchr[SPACE]);
END
else
BEGIN
PRINT2 ("%c", xchr[buffer[bf_ptr]]);
END
INCR (bf_ptr);
END
PRINT_NEWLINE;
bf_ptr = 0;
while ((bf_ptr < buf_ptr2) && (lex_class[buffer[bf_ptr]] == WHITE_SPACE))
BEGIN
INCR (bf_ptr);
END
if (bf_ptr == buf_ptr2)
BEGIN
PRINT_LN ("(Error may have been on previous line)");
END
mark_error ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 95 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 121
* ~~~~~~~~~~~~~~~~~~~
* Here's a procedure we'll need shortly. It prints the name of the
* current .bib file, followed by a |newline|.
***************************************************************************/
void print_bib_name (void)
BEGIN
PRINT_POOL_STR (CUR_BIB_STR);
PRINT_POOL_STR (s_bib_extension);
PRINT_NEWLINE;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 121 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 128
* ~~~~~~~~~~~~~~~~~~~
* Print the name of the .bst file, followed by a |newline|.
***************************************************************************/
void print_bst_name (void)
BEGIN
PRINT_POOL_STR (bst_str);
PRINT_POOL_STR (s_bst_extension);
PRINT_NEWLINE;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 128 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 45
* ~~~~~~~~~~~~~~~~~~~
* When something happens that the program thinks is impossible,
* call the maintainer.
***************************************************************************/
void print_confusion (void)
BEGIN
PRINT_LN ("---this can't happen");
PRINT_LN ("*Please notify the BibTeX maintainer*");
mark_fatal ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 45 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 158
* ~~~~~~~~~~~~~~~~~~~
* Occasionally we'll want to |print| the name of one of these function
* classes.
***************************************************************************/
void print_fn_class (HashLoc_T fn_loc)
BEGIN
switch (fn_type[fn_loc])
BEGIN
case BUILT_IN:
PRINT ("built-in");
break;
case WIZ_DEFINED:
PRINT ("wizard-defined");
break;
case INT_LITERAL:
PRINT ("integer-literal");
break;
case STR_LITERAL:
PRINT ("string-literal");
break;
case FIELD:
PRINT ("field");
break;
case INT_ENTRY_VAR:
PRINT ("integer-entry-variable");
break;
case STR_ENTRY_VAR:
PRINT ("string-entry-variable");
break;
case INT_GLOBAL_VAR:
PRINT ("integer-global-variable");
break;
case STR_GLOBAL_VAR:
PRINT ("string-global-variable");
break;
default:
unknwn_function_class_confusion ();
break;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 158 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 313
* ~~~~~~~~~~~~~~~~~~~
* This is similar to |print_stk_lit|, but here we don't give the
* literal's type, and here we end with a new line. This procedure
* should never be called after popping an empty stack.
***************************************************************************/
void print_lit (Integer_T stk_lt, StkType_T stk_tp)
BEGIN
switch (stk_tp)
BEGIN
case STK_INT:
PRINT_LN2 ("%ld", (long) stk_lt);
break;
case STK_STR:
PRINT_POOL_STR (stk_lt);
PRINT_NEWLINE;
break;
case STK_FN:
PRINT_POOL_STR (hash_text[stk_lt]);
PRINT_NEWLINE;
break;
case STK_FIELD_MISSING:
PRINT_POOL_STR (stk_lt);
PRINT_NEWLINE;
break;
case STK_EMPTY:
illegl_literal_confusion ();
break;
default:
unknwn_literal_confusion ();
break;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 313 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/**************************************************************************
* WEB section number: 284
* ~~~~~~~~~~~~~~~~~~~
* When a cite key on the original |cite_list| (or added to |cite_list|
* because of cross~referencing) didn't appear in the database, complain.
***************************************************************************/
void print_missing_entry (StrNumber_T s)
BEGIN
PRINT ("Warning--I didn't find a database entry for \"");
PRINT_POOL_STR (s);
PRINT_LN ("\"");
mark_warning ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 284 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 44
* ~~~~~~~~~~~~~~~~~~~
* When something in the program wants to be bigger or something out
* there wants to be smaller, it's time to call it a run. Here's the
* first of several macros that have associated procedures so that they
* produce less inline code.
***************************************************************************/
void print_overflow (void)
BEGIN
PRINT ("Sorry---you've exceeded BibTeX's ");
mark_fatal ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 44 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 184
* ~~~~~~~~~~~~~~~~~~~
* This macro is similar to the last one but is specifically for
* recursion in a |wiz_defined| function, which is illegal; it helps save
* space.
***************************************************************************/
void print_recursion_illegal (void)
BEGIN
#ifdef TRACE
if (Flag_trace)
TRACE_PR_NEWLINE;
#endif /* TRACE */
PRINT_LN ("Curse you, wizard, before you recurse me:");
PRINT ("function ");
PRINT_TOKEN;
PRINT_LN (" is illegal in its own definition");
/*------------------------------------------------------------------------
* print_recursion_illegal();
*----------------------------------------------------------------------*/
skip_token_print ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 184 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 96
* ~~~~~~~~~~~~~~~~~~~
* This little procedure exists because it's used by at least two other
* procedures and thus saves some space.
***************************************************************************/
void print_skipping_whatever_remains (void)
BEGIN
PRINT ("I'm skipping whatever remains of this ");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 96 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 311
* ~~~~~~~~~~~~~~~~~~~
* Occasionally we'll want to know what's on the literal stack. Here we
* print out a stack literal, giving its type. This procedure should
* never be called after popping an empty stack.
***************************************************************************/
void print_stk_lit (Integer_T stk_lt, StkType_T stk_tp)
BEGIN
switch (stk_tp)
BEGIN
case STK_INT:
PRINT2 ("%ld is an integer literal", (long) stk_lt);
break;
case STK_STR:
PRINT ("\"");
PRINT_POOL_STR (stk_lt);
PRINT ("\" is a string literal");
break;
case STK_FN:
PRINT ("`");
PRINT_POOL_STR (hash_text[stk_lt]);
PRINT ("' is a function literal");
break;
case STK_FIELD_MISSING:
PRINT ("`");
PRINT_POOL_STR (stk_lt);
PRINT ("' is a missing field");
break;
case STK_EMPTY:
illegl_literal_confusion ();
break;
default:
unknwn_literal_confusion ();
break;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 311 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 312
* ~~~~~~~~~~~~~~~~~~~
* This procedure appropriately chastises the style designer; however, if
* the wrong literal came from popping an empty stack, the procedure
* |pop_lit_stack| will have already done the chastising (because this
* procedure is called only after popping the stack) so there's no need
* for more.
***************************************************************************/
void print_wrong_stk_lit (Integer_T stk_lt, StkType_T stk_tp1,
StkType_T stk_tp2)
BEGIN
if (stk_tp1 != STK_EMPTY)
BEGIN
print_stk_lit (stk_lt, stk_tp1);
switch (stk_tp2)
BEGIN
case STK_INT:
PRINT (", not an integer,");
break;
case STK_STR:
PRINT (", not a string,");
break;
case STK_FN:
PRINT (", not a function,");
break;
case STK_FIELD_MISSING:
case STK_EMPTY:
illegl_literal_confusion ();
break;
default:
unknwn_literal_confusion ();
break;
END
bst_ex_warn_print ();
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 312 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 307
* ~~~~~~~~~~~~~~~~~~~
* Ok, that's it for sorting; now we'll play with the literal stack.
* This procedure pushes a literal onto the stack, checking for stack
* overflow.
***************************************************************************/
void push_lit_stk (Integer_T push_lt, StkType_T push_type)
BEGIN
#ifdef TRACE
LitStkLoc_T dum_ptr;
#endif /* TRACE */
lit_stack[lit_stk_ptr] = push_lt;
lit_stk_type[lit_stk_ptr] = push_type;
#ifdef TRACE
if (Flag_trace) {
for (dum_ptr=0; dum_ptr <= lit_stk_ptr; dum_ptr++)
BEGIN
TRACE_PR (" ");
END
TRACE_PR ("Pushing ");
switch (lit_stk_type[lit_stk_ptr])
BEGIN
case STK_INT:
TRACE_PR_LN2 ("%ld", (long) lit_stack[lit_stk_ptr]);
break;
case STK_STR:
TRACE_PR ("\"");
TRACE_PR_POOL_STR (lit_stack[lit_stk_ptr]);
TRACE_PR_LN ("\"");
break;
case STK_FN:
TRACE_PR ("`");
TRACE_PR_POOL_STR (hash_text[lit_stack[lit_stk_ptr]]);
TRACE_PR_LN ("'");
break;
case STK_FIELD_MISSING:
TRACE_PR ("missing field `");
out_pool_str (log_file, lit_stack[lit_stk_ptr]);
TRACE_PR_LN ("'");
break;
case STK_EMPTY:
TRACE_PR_LN ("a bad literal--popped from an empty stack");
break;
default:
unknwn_literal_confusion ();
break;
END
} /* end if (Flag_trace) */
#endif /* TRACE */
if (lit_stk_ptr == Lit_Stk_Size)
BEGIN
BIB_XRETALLOC_NOSET ("lit_stack", lit_stack, Integer_T,
Lit_Stk_Size, Lit_Stk_Size + LIT_STK_SIZE);
BIB_XRETALLOC ("lit_stk_type", lit_stk_type, StkType_T,
Lit_Stk_Size, Lit_Stk_Size + LIT_STK_SIZE);
END
INCR (lit_stk_ptr);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 307 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 303
* ~~~~~~~~~~~~~~~~~~~
* These next two procedures (actually, one procedures and one function,
* but who's counting) are subroutines for |quick_sort|, which follows.
* The |swap| procedure exchanges the two elements its arguments point
* to.
***************************************************************************/
void quick_sort (CiteNumber_T left_end, CiteNumber_T right_end)
BEGIN
CiteNumber_T left,
right;
CiteNumber_T insert_ptr;
CiteNumber_T middle;
CiteNumber_T partition;
#ifdef TRACE
if (Flag_trace)
TRACE_PR_LN3 ("Sorting %ld through %ld", (long) left_end,
(long) right_end);
#endif /* TRACE */
if ((right_end - left_end) < SHORT_LIST)
BEGIN
/***************************************************************************
* WEB section number: 304
* ~~~~~~~~~~~~~~~~~~~
* This code sorts the entries between |left_end| and |right_end| when
* the difference is less than |short_list|. Each iteration of the outer
* loop inserts the element indicated by |insert_ptr| into its proper
* place among the (sorted) elements from |left_end| through
* |insert_ptr-1|.
***************************************************************************/
for (insert_ptr=(left_end+1); insert_ptr<=right_end; insert_ptr++)
BEGIN
for (right=insert_ptr; right >= (left_end+1); right--)
BEGIN
if (less_than (SORTED_CITES[right-1], SORTED_CITES[right]))
BEGIN
goto Next_Insert_Label;
END
swap (right - 1, right);
END
Next_Insert_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 304 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
else
BEGIN
/***************************************************************************
* WEB section number: 305
* ~~~~~~~~~~~~~~~~~~~
* Now we find the median of the three sort.key$s to which the three
* elements |sorted_cites[left_end+end_offset]|,
* |sorted_cites[right_end]-end_offset|, and
* |sorted_cites[(left_end+right_end) div 2]| point (a nonzero
* |end_offset| avoids using as the leftmost of the three elements the
* one that was swapped there when the old partition element was swapped
* into its final spot; this turns out to avoid $n^2$ behavior when the
* list is nearly sorted to start with). This code determines which of
* the six possible permutations we're dealing with and moves the median
* element to |left_end|. The comments next to the |swap| actions give
* the known orderings of the corresponding elements of |sorted_cites|
* before the action.
***************************************************************************/
left = left_end + END_OFFSET;
middle = (left_end + right_end) / 2;
right = right_end - END_OFFSET;
if (less_than (SORTED_CITES[left], SORTED_CITES[middle]))
BEGIN
if (less_than (SORTED_CITES[middle], SORTED_CITES[right]))
BEGIN
swap (left_end, middle);
END
else if (less_than (SORTED_CITES[left], SORTED_CITES[right]))
BEGIN
swap (left_end, right);
END
else
BEGIN
swap (left_end, left);
END
END
else if (less_than (SORTED_CITES[right], SORTED_CITES[middle]))
BEGIN
swap (left_end, middle);
END
else if (less_than (SORTED_CITES[right], SORTED_CITES[left]))
BEGIN
swap (left_end, right);
END
else
BEGIN
swap (left_end, left);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 305 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 306
* ~~~~~~~~~~~~~~~~~~~
* This module uses the median-of-three computed above to partition the
* elements into those less than and those greater than the median.
* Equal sort.key$s are sorted by order of occurrence (in
* |cite_list|).
***************************************************************************/
partition = SORTED_CITES[left_end];
left = left_end + 1;
right = right_end;
do
BEGIN
while (less_than (SORTED_CITES[left], partition))
BEGIN
INCR (left);
END
while (less_than (partition, SORTED_CITES[right]))
BEGIN
DECR (right);
END
if (left < right)
BEGIN
swap (left, right);
INCR (left);
DECR (right);
END
END while ( ! (left == (right + 1)));
swap (left_end, right);
quick_sort (left_end, right - 1);
quick_sort (left, right_end);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 306 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 303 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 98
* ~~~~~~~~~~~~~~~~~~~
* I mean, this is truly disgraceful. A user has to type something in to
* the terminal just once during the entire run. And it's not some
* complicated string where you have to get every last punctuation mark
* just right, and it's not some fancy list where you get nervous because
* if you forget one item you have to type the whole thing again; it's
* just a simple, ordinary, file name. Now you'd think a five-year-old
* could do it; you'd think it's so simple a user should be able to do it
* in his sleep. But noooooooooo. He had to sit there droning on and on
* about who knows what until he exceeded the bounds of common sense, and
* he probably didn't even realize it. Just pitiful. What's this world
* coming to? We should probably just delete all his files and be done
* with him. Note: The |TERM_OUT| file is system dependent.
*
* 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 sam_too_long_file_name_print (void)
BEGIN
FPRINTF (TERM_OUT, "File name `");
name_ptr = 0;
while (name_ptr < aux_name_length)
BEGIN
FPUTC (name_of_file[name_ptr], TERM_OUT);
INCR (name_ptr);
END
FPRINTF (TERM_OUT, "' is too long\n");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 98 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 99
* ~~~~~~~~~~~~~~~~~~~
* We've abused the user enough for one section; suffice it to
* say here that most of what we said last module still applies.
* Note: The |TERM_OUT| file is system dependent.
*
* 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 sam_wrong_file_name_print (void)
BEGIN
FPRINTF (TERM_OUT, "I couldn't open file name `");
FPUTS (name_of_file, TERM_OUT);
FPRINTF (TERM_OUT, "'\n");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 99 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 83
* ~~~~~~~~~~~~~~~~~~~
* This function scans the |buffer| for the next token, starting at the
* global variable |buf_ptr2| and ending just before either the single
* specified stop-character or the end of the current line, whichever
* comes first, respectively returning |true| or |false|; afterward,
* |scan_char| is the first character following this token.
***************************************************************************/
Boolean_T scan1 (ASCIICode_T char1)
BEGIN
Boolean_T scan1;
buf_ptr1 = buf_ptr2;
while ((SCAN_CHAR != char1) && (buf_ptr2 < last))
BEGIN
INCR (buf_ptr2);
END
if (buf_ptr2 < last)
BEGIN
scan1 = TRUE;
END
else
BEGIN
scan1 = FALSE;
END
return (scan1);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 83 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 84
* ~~~~~~~~~~~~~~~~~~~
* This function is the same but stops at |white_space| characters as well.
***************************************************************************/
Boolean_T scan1_white (ASCIICode_T char1)
BEGIN
Boolean_T scan1_white;
buf_ptr1 = buf_ptr2;
while ((lex_class[SCAN_CHAR] != WHITE_SPACE)
&& (SCAN_CHAR != char1) && (buf_ptr2 < last))
BEGIN
INCR (buf_ptr2);
END
if (buf_ptr2 < last)
BEGIN
scan1_white = TRUE;
END
else
BEGIN
scan1_white = FALSE;
END
return (scan1_white);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 84 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 85
* ~~~~~~~~~~~~~~~~~~~
* This function is similar to |scan1|, but stops at either of two
* stop-characters as well as the end of the current line.
***************************************************************************/
Boolean_T scan2 (ASCIICode_T char1, ASCIICode_T char2)
BEGIN
Boolean_T scan2;
buf_ptr1 = buf_ptr2;
while ((SCAN_CHAR != char1) && (SCAN_CHAR != char2)
&& (buf_ptr2 < last))
BEGIN
INCR (buf_ptr2);
END
if (buf_ptr2 < last)
BEGIN
scan2 = TRUE;
END
else
BEGIN
scan2 = FALSE;
END
return (scan2);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 85 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 86
* ~~~~~~~~~~~~~~~~~~~
* This function is the same but stops at |white_space| characters as well.
***************************************************************************/
Boolean_T scan2_white (ASCIICode_T char1, ASCIICode_T char2)
BEGIN
Boolean_T scan2_white;
buf_ptr1 = buf_ptr2;
while ((SCAN_CHAR != char1) && (SCAN_CHAR != char2)
&& (lex_class[SCAN_CHAR] != WHITE_SPACE) && (buf_ptr2 < last))
BEGIN
INCR (buf_ptr2);
END
if (buf_ptr2 < last)
BEGIN
scan2_white = TRUE;
END
else
BEGIN
scan2_white = FALSE;
END
return (scan2_white);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 86 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 87
* ~~~~~~~~~~~~~~~~~~~
* This function is similar to |scan2|, but stops at either of three
* stop-characters as well as the end of the current line.
***************************************************************************/
Boolean_T scan3 (ASCIICode_T char1, ASCIICode_T char2,
ASCIICode_T char3)
BEGIN
Boolean_T scan3;
buf_ptr1 = buf_ptr2;
while ((SCAN_CHAR != char1) && (SCAN_CHAR != char2)
&& (SCAN_CHAR != char3) && (buf_ptr2 < last))
BEGIN
INCR (buf_ptr2);
END
if (buf_ptr2 < last)
BEGIN
scan3 = TRUE;
END
else
BEGIN
scan3 = FALSE;
END
return (scan3);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 87 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 250
* ~~~~~~~~~~~~~~~~~~~
* Each field token is either a nonnegative number, a macro name (like
* `jan'), or a brace-balanced string delimited by either |double_quote|s
* or braces. Thus there are four possibilities for the first character
* of the field token: If it's a |left_brace| or a |double_quote|, the
* token (with balanced braces, up to the matching |right_str_delim|) is
* a string; if it's |numeric|, the token is a number; if it's anything
* else, the token is a macro name (and should thus have been defined by
* either the .bst-file's macro command or the .bib-file's
* string command). This function returns |false| if there was a
* serious syntax error.
***************************************************************************/
Boolean_T scan_a_field_token_and_eat_whit (void)
BEGIN
Boolean_T scan_a_field_token_And_eat_whit;
scan_a_field_token_And_eat_whit = FALSE;
switch (SCAN_CHAR)
BEGIN
case LEFT_BRACE:
right_str_delim = RIGHT_BRACE;
if ( ! scan_balanced_braces ())
goto Exit_Label;
break;
case DOUBLE_QUOTE:
right_str_delim = DOUBLE_QUOTE;
if ( ! scan_balanced_braces ())
goto Exit_Label;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/***************************************************************************
* WEB section number: 258
* ~~~~~~~~~~~~~~~~~~~
* This module scans a nonnegative number and copies it to |field_vl_str|
* if it's to store the field.
***************************************************************************/
if ( ! scan_nonneg_integer ())
BEGIN
CONFUSION ("A digit disappeared");
END
if (store_field)
BEGIN
tmp_ptr = buf_ptr1;
while (tmp_ptr < buf_ptr2)
BEGIN
COPY_CHAR (buffer[tmp_ptr]);
INCR (tmp_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 258 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
break;
default:
/***************************************************************************
* WEB section number: 259
* ~~~~~~~~~~~~~~~~~~~
* This module scans a macro name and copies its string to |field_vl_str|
* if it's to store the field, complaining if the macro is recursive or
* undefined.
***************************************************************************/
scan_identifier (COMMA, right_outer_delim, CONCAT_CHAR);
BIB_IDENTIFIER_SCAN_CHECK ("a field part");
if (store_field)
BEGIN
lower_case (buffer, buf_ptr1, TOKEN_LEN);
macro_name_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, MACRO_ILK,
DONT_INSERT);
store_token = TRUE;
if (at_bib_command)
BEGIN
if (command_num == N_BIB_STRING)
BEGIN
if (macro_name_loc == cur_macro_loc)
BEGIN
store_token = FALSE;
MACRO_NAME_WARNING ("used in its own definition");
END
END
END
if ( ! hash_found)
BEGIN
store_token = FALSE;
MACRO_NAME_WARNING ("undefined");
END
if (store_token)
BEGIN
/***************************************************************************
* WEB section number: 260
* ~~~~~~~~~~~~~~~~~~~
* The macro definition may have |white_space| that needs compressing,
* because it may have been defined in the .bst file.
***************************************************************************/
tmp_ptr = str_start[ilk_info[macro_name_loc]];
tmp_end_ptr = str_start[ilk_info[macro_name_loc] + 1];
if (FIELD_END == 0)
BEGIN
if ((lex_class[str_pool[tmp_ptr]] == WHITE_SPACE)
&& (tmp_ptr < tmp_end_ptr))
BEGIN
COPY_CHAR (SPACE);
INCR (tmp_ptr);
while ((lex_class[str_pool[tmp_ptr]] == WHITE_SPACE)
&& (tmp_ptr < tmp_end_ptr))
BEGIN
INCR (tmp_ptr);
END
END
END
while (tmp_ptr < tmp_end_ptr)
BEGIN
if (lex_class[str_pool[tmp_ptr]] != WHITE_SPACE)
BEGIN
COPY_CHAR (str_pool[tmp_ptr]);
END
else if (FIELD_VL_STR[FIELD_END - 1] != SPACE)
BEGIN
COPY_CHAR (SPACE);
END
INCR (tmp_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 260 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 259 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
break;
END
EAT_BIB_WHITE_AND_EOF_CHECK;
scan_a_field_token_And_eat_whit = TRUE;
Exit_Label: DO_NOTHING;
return (scan_a_field_token_And_eat_whit);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 250 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 88
* ~~~~~~~~~~~~~~~~~~~
* This function scans for letters, stopping at the first nonletter; it
* returns |true| if there is at least one letter.
***************************************************************************/
Boolean_T scan_alpha (void)
BEGIN
Boolean_T scan_alpha;
buf_ptr1 = buf_ptr2;
while ((lex_class[SCAN_CHAR] == ALPHA) && (buf_ptr2 < last))
BEGIN
INCR (buf_ptr2);
END
if (TOKEN_LEN == 0)
BEGIN
scan_alpha = FALSE;
END
else
BEGIN
scan_alpha = TRUE;
END
return (scan_alpha);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 88 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 249
* ~~~~~~~~~~~~~~~~~~~
* This function scans the list of field tokens that define the field
* value string. If |store_field| is |true| it accumulates (indirectly)
* in |field_vl_str| the concatenation of all the field tokens,
* compressing nonnull |white_space| to a single |space| and, if the
* field value is for a field (rather than a string definition), removing
* any leading or trailing |white_space|; when it's finished it puts the
* string into the hash table. It returns |false| if there was a serious
* syntax error.
***************************************************************************/
Boolean_T scan_and_store_the_field_value (void)
BEGIN
Boolean_T scan_and_store_the_field_value;
scan_and_store_the_field_value = FALSE;
FIELD_END = 0;
if ( ! scan_a_field_token_and_eat_whit ())
BEGIN
goto Exit_Label;
END
while (SCAN_CHAR == CONCAT_CHAR)
BEGIN
INCR (buf_ptr2);
EAT_BIB_WHITE_AND_EOF_CHECK;
if ( ! scan_a_field_token_and_eat_whit ())
BEGIN
goto Exit_Label;
END
END
if (store_field)
BEGIN
/***************************************************************************
* WEB section number: 261
* ~~~~~~~~~~~~~~~~~~~
* Now it's time to store the field value in the hash table, and store an
* appropriate pointer to it (depending on whether it's for a database
* entry or command). But first, if necessary, we remove a trailing
* |space| and a leading |space| if these exist. (Hey, if we had some
* ham we could make ham-and-eggs if we had some eggs.)
***************************************************************************/
if ( ! at_bib_command)
BEGIN
if (FIELD_END > 0)
BEGIN
if (FIELD_VL_STR[FIELD_END - 1] == SPACE)
BEGIN
DECR (FIELD_END);
END
END
END
if (( ! at_bib_command) && (FIELD_VL_STR[0] == SPACE) && (FIELD_END > 0))
BEGIN
FIELD_START = 1;
END
else
BEGIN
FIELD_START = 0;
END
field_val_loc = str_lookup (FIELD_VL_STR, FIELD_START,
FIELD_END - FIELD_START, TEXT_ILK,
DO_INSERT);
fn_type[field_val_loc] = STR_LITERAL;
#ifdef TRACE
if (Flag_trace) {
TRACE_PR ("\"");
TRACE_PR_POOL_STR (hash_text[field_val_loc]);
TRACE_PR_LN ("\" is a field value");
}
#endif /* TRACE */
if (at_bib_command)
BEGIN
/***************************************************************************
* WEB section number: 262
* ~~~~~~~~~~~~~~~~~~~
* Here's where we store the goods when we're dealing with a command
* rather than an entry.
***************************************************************************/
switch (command_num)
BEGIN
case N_BIB_PREAMBLE:
s_preamble[preamble_ptr] = hash_text[field_val_loc];
INCR (preamble_ptr);
break;
case N_BIB_STRING:
ilk_info[cur_macro_loc] = hash_text[field_val_loc];
break;
default:
bib_cmd_confusion ();
break;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 262 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
else
BEGIN
/***************************************************************************
* WEB section number: 263
* ~~~~~~~~~~~~~~~~~~~
* And here, an entry.
***************************************************************************/
field_ptr = (entry_cite_ptr * num_fields) + FN_INFO[field_name_loc];
if (field_info[field_ptr] != MISSING)
BEGIN
PRINT ("Warning--I'm ignoring ");
PRINT_POOL_STR (cite_list[entry_cite_ptr]);
PRINT ("'s extra \"");
PRINT_POOL_STR (hash_text[field_name_loc]);
BIB_WARN_NEWLINE ("\" field");
END
else
BEGIN
field_info[field_ptr] = hash_text[field_val_loc];
if ((ilk_info[field_name_loc] == crossref_num)
&& ( ! all_entries))
BEGIN
/***************************************************************************
* WEB section number: 264
* ~~~~~~~~~~~~~~~~~~~
* If the cross-referenced entry isn't already on |cite_list| we add it
* (at least temporarily); if it is already on |cite_list| we update the
* cross-reference count, if necessary. Note that |all_entries| is
* |false| here. The alias kludge helps make the stack space not
* overflow on some machines.
***************************************************************************/
tmp_ptr = FIELD_START;
while (tmp_ptr < FIELD_END)
BEGIN
EXTRA_BUF[tmp_ptr] = FIELD_VL_STR[tmp_ptr];
INCR (tmp_ptr);
END
lower_case (EXTRA_BUF, FIELD_START, FIELD_END - FIELD_START);
lc_cite_loc = str_lookup (EXTRA_BUF, FIELD_START,
FIELD_END - FIELD_START, LC_CITE_ILK,
DO_INSERT);
if (hash_found)
BEGIN
cite_loc = ilk_info[lc_cite_loc];
if (ilk_info[cite_loc] >= old_num_cites)
BEGIN
INCR (cite_info[ilk_info[cite_loc]]);
END
END
else
BEGIN
cite_loc = str_lookup (FIELD_VL_STR, FIELD_START,
FIELD_END - FIELD_START, CITE_ILK,
DO_INSERT);
if (hash_found)
BEGIN
hash_cite_confusion ();
END
add_database_cite (&cite_ptr);
cite_info[ilk_info[cite_loc]] = 1;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 264 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 263 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 261 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
scan_and_store_the_field_value = TRUE;
Exit_Label: DO_NOTHING;
return (scan_and_store_the_field_value);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 249 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 253
* ~~~~~~~~~~~~~~~~~~~
* This .bib-specific function scans a string with balanced braces,
* stopping just past the matching |right_str_delim|. How much work it
* does depends on whether |store_field = true|. It returns |false| if
* there was a serious syntax error.
***************************************************************************/
Boolean_T scan_balanced_braces (void)
BEGIN
Boolean_T scan_balanced_braces;
scan_balanced_braces = FALSE;
INCR (buf_ptr2);
CHECK_FOR_AND_COMPRESS_BIB_WHIT;
if (FIELD_END > 1)
BEGIN
if (FIELD_VL_STR[FIELD_END- 1] == SPACE)
BEGIN
if (ex_buf[FIELD_END- 2] == SPACE)
BEGIN
DECR (FIELD_END);
END
END
END
bib_brace_level = 0;
if (store_field)
BEGIN
/***************************************************************************
* WEB section number: 256
* ~~~~~~~~~~~~~~~~~~~
* This module scans over a brace-balanced string, compressing multiple
* |white_space| characters into a single |space|. It starts with
* |bib_brace_level = 0| and starts at a non|white_space| character.
***************************************************************************/
while (SCAN_CHAR != right_str_delim)
BEGIN
switch (SCAN_CHAR)
BEGIN
case LEFT_BRACE:
INCR (bib_brace_level);
COPY_CHAR (LEFT_BRACE);
INCR (buf_ptr2);
CHECK_FOR_AND_COMPRESS_BIB_WHIT;
/***************************************************************************
* WEB section number: 257
* ~~~~~~~~~~~~~~~~~~~
* This module is similar to the last but starts with |bib_brace_level > 0|
* (and, like the last, it starts at a non|white_space| character).
***************************************************************************/
LOOP
BEGIN
switch (SCAN_CHAR)
BEGIN
case RIGHT_BRACE:
DECR (bib_brace_level);
COPY_CHAR (RIGHT_BRACE);
INCR (buf_ptr2);
CHECK_FOR_AND_COMPRESS_BIB_WHIT;
if (bib_brace_level == 0)
BEGIN
goto Loop_Exit_Label;
END
break;
case LEFT_BRACE:
INCR (bib_brace_level);
COPY_CHAR (LEFT_BRACE);
INCR (buf_ptr2);
CHECK_FOR_AND_COMPRESS_BIB_WHIT;
break;
default:
COPY_CHAR (SCAN_CHAR);
INCR (buf_ptr2);
CHECK_FOR_AND_COMPRESS_BIB_WHIT;
break;
END
END
Loop_Exit_Label: DO_NOTHING
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 257 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
break;
case RIGHT_BRACE:
BIB_UNBALANCED_BRACES_ERR;
default:
COPY_CHAR (SCAN_CHAR);
INCR (buf_ptr2);
CHECK_FOR_AND_COMPRESS_BIB_WHIT;
break;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 256 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
else
BEGIN
/***************************************************************************
* WEB section number: 254
* ~~~~~~~~~~~~~~~~~~~
* This module scans over a brace-balanced string without keeping track
* of anything but the brace level. It starts with |bib_brace_level = 0|
* and at a non|white_space| character.
***************************************************************************/
while (SCAN_CHAR != right_str_delim)
BEGIN
if (SCAN_CHAR == LEFT_BRACE)
BEGIN
INCR (bib_brace_level);
INCR (buf_ptr2);
EAT_BIB_WHITE_AND_EOF_CHECK;
while (bib_brace_level > 0)
BEGIN
/***************************************************************************
* WEB section number: 255
* ~~~~~~~~~~~~~~~~~~~
* This module does the same as above but, because |bib_brace_level > 0|, it
* doesn't have to look for a |right_str_delim|.
***************************************************************************/
if (SCAN_CHAR == RIGHT_BRACE)
BEGIN
DECR (bib_brace_level);
INCR (buf_ptr2);
EAT_BIB_WHITE_AND_EOF_CHECK;
END
else if (SCAN_CHAR == LEFT_BRACE)
BEGIN
INCR (bib_brace_level);
INCR (buf_ptr2);
EAT_BIB_WHITE_AND_EOF_CHECK;
END
else
BEGIN
INCR (buf_ptr2);
if ( ! scan2 (RIGHT_BRACE, LEFT_BRACE))
BEGIN
EAT_BIB_WHITE_AND_EOF_CHECK;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 255 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
END
else if (SCAN_CHAR == RIGHT_BRACE)
BEGIN
BIB_UNBALANCED_BRACES_ERR;
END
else
BEGIN
INCR (buf_ptr2);
if ( ! scan3 (right_str_delim, LEFT_BRACE, RIGHT_BRACE))
BEGIN
EAT_BIB_WHITE_AND_EOF_CHECK;
END
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 254 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
INCR (buf_ptr2);
scan_balanced_braces = TRUE;
Exit_Label: DO_NOTHING;
return (scan_balanced_braces);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 253 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 188
* ~~~~~~~~~~~~~~~~~~~
* This macro inserts a hash-table location (or one of the two
* special markers |quote_next_fn| and |end_of_def|) into the
* |singl_function| array, which will later be copied into the
* |wiz_functions| array.
***************************************************************************/
#define INSERT_FN_LOC(X) {\
singl_function[single_ptr] = (X);\
if (single_ptr == Single_Fn_Space)\
{BIB_XRETALLOC ("singl_function", singl_function, HashPtr2_T,\
Single_Fn_Space, Single_Fn_Space + Single_Fn_Space);}\
INCR (single_ptr);}
/***************************************************************************
* WEB section number: 187
* ~~~~~~~~~~~~~~~~~~~
* This recursive function reads and stores the list of functions
* (separated by |white_space| characters or ends-of-line) that define
* this new function, and reads a |right_brace|.
***************************************************************************/
void scan_fn_def (HashLoc_T fn_hash_loc)
BEGIN
typedef Integer_T FnDefLoc_T;
HashPtr2_T *singl_function;
FnDefLoc_T single_ptr;
FnDefLoc_T copy_ptr;
BufPointer_T end_of_num;
HashLoc_T impl_fn_loc;
Integer_T Single_Fn_Space;
Single_Fn_Space = SINGLE_FN_SPACE;
singl_function = (HashPtr2_T *) mymalloc ((Single_Fn_Space + 1)
* (unsigned long) sizeof (HashPtr2_T), "singl_function");
EAT_BST_WHITE_AND_EOF_CHECK ("function");
single_ptr = 0;
while (SCAN_CHAR != RIGHT_BRACE)
BEGIN
/***************************************************************************
* WEB section number: 189
* ~~~~~~~~~~~~~~~~~~~
* There are five possibilities for the first character of the token
* representing the next function of the definition: If it's a
* |number_sign|, the token is an |int_literal|; if it's a
* |double_quote|, the token is a |str_literal|; if it's a
* |single_quote|, the token is a quoted function; if it's a
* |left_brace|, the token isn't really a token, but rather the start of
* another function definition (which will result in a recursive call to
* |scan_fn_def|); if it's anything else, the token is the name of an
* already-defined function. Note: To prevent the wizard from using
* recursion, we have to check that neither a quoted function nor an
* already-defined-function is actually the currently-being-defined
* function (which is stored at |wiz_loc|).
***************************************************************************/
switch (SCAN_CHAR)
BEGIN
case NUMBER_SIGN:
/***************************************************************************
* WEB section number: 190
* ~~~~~~~~~~~~~~~~~~~
* An |int_literal| is preceded by a |number_sign|, consists of an
* integer (i.e., an optional |minus_sign| followed by one or more
* |numeric| characters), and is followed either by a |white_space|
* character, an end-of-line, or a |right_brace|. The array |fn_info|
* contains the value of the integer for |int_literal|s.
***************************************************************************/
BEGIN
INCR (buf_ptr2);
if ( ! scan_integer ())
BEGIN
SKIP_TOKEN ("Illegal integer in integer literal");
END
#ifdef TRACE
if (Flag_trace) {
TRACE_PR ("#");
TRACE_PR_TOKEN;
TRACE_PR_LN2 (" is an integer literal with value %ld",
(long) token_value);
}
#endif /* TRACE */
literal_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, INTEGER_ILK,
DO_INSERT);
if ( ! hash_found)
BEGIN
fn_type[literal_loc] = INT_LITERAL;
FN_INFO[literal_loc] = token_value;
END
if ((lex_class[SCAN_CHAR] != WHITE_SPACE) && (buf_ptr2 < last)
&& (SCAN_CHAR != RIGHT_BRACE) && (SCAN_CHAR != COMMENT))
BEGIN
SKIP_TOKEN_ILLEGAL_STUFF_AFTER;
END
INSERT_FN_LOC (literal_loc);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 190 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
break;
case DOUBLE_QUOTE:
/***************************************************************************
* WEB section number: 191
* ~~~~~~~~~~~~~~~~~~~
* A |str_literal| is preceded by a |double_quote| and consists of all
* characters on this line up to the next |double_quote|. Also, there
* must be either a |white_space| character, an end-of-line, a
* |right_brace|, or a |comment| following (since functions in the
* definition must be separated by |white_space|). The array |fn_info|
* contains nothing for |str_literal|s.
***************************************************************************/
BEGIN
INCR (buf_ptr2);
if ( ! scan1 (DOUBLE_QUOTE))
BEGIN
SKIP_TOKEN2 ("No `%c' to end string literal", xchr[DOUBLE_QUOTE]);
END
#ifdef TRACE
if (Flag_trace) {
TRACE_PR ("\"");
TRACE_PR_TOKEN;
TRACE_PR ("\"");
TRACE_PR_LN (" is a string literal");
}
#endif /* TRACE */
literal_loc = str_lookup (buffer, buf_ptr1, TOKEN_LEN, TEXT_ILK,
DO_INSERT);
fn_type[literal_loc] = STR_LITERAL;
INCR (buf_ptr2);
if ((lex_class[SCAN_CHAR] != WHITE_SPACE) && (buf_ptr2 < last)
&& (SCAN_CHAR != RIGHT_BRACE) && (SCAN_CHAR != COMMENT))
BEGIN
SKIP_TOKEN_ILLEGAL_STUFF_AFTER;
END
INSERT_FN_LOC (literal_loc);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 191 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
break;
case SINGLE_QUOTE:
/***************************************************************************
* WEB section number: 192
* ~~~~~~~~~~~~~~~~~~~
* A quoted function is preceded by a |single_quote| and consists of all
* characters up to the next |white_space| character, end-of-line,
* |right_brace|, or |comment|.
***************************************************************************/
BEGIN
INCR (buf_ptr2);
if (scan2_white (RIGHT_BRACE, COMMENT))
BEGIN
DO_NOTHING;
END
#ifdef TRACE
if (Flag_trace) {
TRACE_PR ("'");
TRACE_PR_TOKEN;
TRACE_PR (" is a quoted function ");
}
#endif /* TRACE */
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
SKIP_TOKEN_UNKNOWN_FUNCTION;
END
else
/***************************************************************************
* WEB section number: 193
* ~~~~~~~~~~~~~~~~~~~
* Here we check that this quoted function is a legal one---the function
* name must already exist, but it mustn't be the currently-being-defined
* function (which is stored at |wiz_loc|).
***************************************************************************/
BEGIN
if (fn_loc == wiz_loc)
BEGIN
SKIP_RECURSIVE_TOKEN;
END
else
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR ("of type ");
trace_pr_fn_class (fn_loc);
TRACE_PR_NEWLINE;
}
#endif /* TRACE */
INSERT_FN_LOC (QUOTE_NEXT_FN);
INSERT_FN_LOC (fn_loc);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 193 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 192 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
break;
case LEFT_BRACE:
/***************************************************************************
* WEB section number: 194
* ~~~~~~~~~~~~~~~~~~~
* This module marks the implicit function as being quoted, generates a
* name, and stores it in the hash table. This name is strictly internal
* to this program, starts with a |single_quote| (since that will make
* this function name unique), and ends with the variable |impl_fn_num|
* converted to ASCII. The alias kludge helps make the stack space not
* overflow on some machines.
***************************************************************************/
BEGIN
EX_BUF2[0] = SINGLE_QUOTE;
int_to_ASCII (impl_fn_num, EX_BUF2, 1, &end_of_num);
impl_fn_loc = str_lookup (EX_BUF2, 0, end_of_num, BST_FN_ILK,
DO_INSERT);
if (hash_found)
BEGIN
CONFUSION ("Already encountered implicit function");
END
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_POOL_STR (hash_text[impl_fn_loc]);
TRACE_PR_LN (" is an implicit function");
}
#endif /* TRACE */
INCR (impl_fn_num);
fn_type[impl_fn_loc] = WIZ_DEFINED;
INSERT_FN_LOC (QUOTE_NEXT_FN);
INSERT_FN_LOC (impl_fn_loc);
INCR (buf_ptr2);
scan_fn_def (impl_fn_loc);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 194 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
break;
default:
/***************************************************************************
* WEB section number: 199
* ~~~~~~~~~~~~~~~~~~~
* An already-defined function consists of all characters up to the next
* |white_space| character, end-of-line, |right_brace|, or |comment|.
* This function name must already exist, but it mustn't be the
* currently-being-defined function (which is stored at |wiz_loc|).
***************************************************************************/
BEGIN
if (scan2_white (RIGHT_BRACE, COMMENT))
BEGIN
DO_NOTHING;
END
#ifdef TRACE
if (Flag_trace) {
TRACE_PR_TOKEN;
TRACE_PR (" is a function ");
}
#endif /* TRACE */
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
SKIP_TOKEN_UNKNOWN_FUNCTION;
END
else if (fn_loc == wiz_loc)
BEGIN
SKIP_RECURSIVE_TOKEN;
END
else
BEGIN
#ifdef TRACE
if (Flag_trace) {
TRACE_PR ("of type ");
trace_pr_fn_class (fn_loc);
TRACE_PR_NEWLINE;
}
#endif /* TRACE */
INSERT_FN_LOC (fn_loc);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 199 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
break;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 189 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Next_Token_Label:
EAT_BST_WHITE_AND_EOF_CHECK ("function");
END
/***************************************************************************
* WEB section number: 200
* ~~~~~~~~~~~~~~~~~~~
* Now we add the |end_of_def| special marker, make sure this function will
* fit into |wiz_functions|, and put it there.
***************************************************************************/
BEGIN
INSERT_FN_LOC (END_OF_DEF);
while ((single_ptr + wiz_def_ptr) > Wiz_Fn_Space)
BEGIN
BIB_XRETALLOC ("wiz_functions", wiz_functions, HashPtr2_T,
Wiz_Fn_Space, Wiz_Fn_Space + WIZ_FN_SPACE);
END
FN_INFO[fn_hash_loc] = wiz_def_ptr;
copy_ptr = 0;
while (copy_ptr < single_ptr)
BEGIN
wiz_functions[wiz_def_ptr] = singl_function[copy_ptr];
INCR (copy_ptr);
INCR (wiz_def_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 200 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
INCR (buf_ptr2);
Exit_Label: free (singl_function);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 187 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 90
* ~~~~~~~~~~~~~~~~~~~
* This procedure scans for an identifier, stopping at the first
* |illegal_id_char|, or stopping at the first character if it's
* |numeric|. It sets the global variable |scan_result| to |id_null| if
* the identifier is null, else to |white_adjacent| if it ended at a
* |white_space| character or an end-of-line, else to
* |specified_char_adjacent| if it ended at one of |char1| or |char2| or
* |char3|, else to |other_char_adjacent| if it ended at a nonspecified,
* non|white_space| |illegal_id_char|. By convention, when some calling
* code really wants just one or two ``specified'' characters, it merely
* repeats one of the characters.
***************************************************************************/
void scan_identifier (ASCIICode_T char1, ASCIICode_T char2,
ASCIICode_T char3)
BEGIN
buf_ptr1 = buf_ptr2;
if (lex_class[SCAN_CHAR] != NUMERIC)
BEGIN
while ((id_class[SCAN_CHAR] == LEGAL_ID_CHAR) && (buf_ptr2 < last))
BEGIN
INCR (buf_ptr2);
END
END
if (TOKEN_LEN == 0)
BEGIN
scan_result = ID_NULL;
END
else if ((lex_class[SCAN_CHAR] == WHITE_SPACE) || (buf_ptr2 == last))
BEGIN
scan_result = SPECIFIED_CHAR_ADJACENT;
END
else if ((SCAN_CHAR == char1) || (SCAN_CHAR == char2)
|| (SCAN_CHAR == char3))
BEGIN
scan_result = SPECIFIED_CHAR_ADJACENT;
END
else
BEGIN
scan_result = OTHER_CHAR_ADJACENT;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 90 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 93
* ~~~~~~~~~~~~~~~~~~~
* This procedure scans for an integer, stopping at the first nondigit;
* it sets the value of |token_value| accordingly. It returns |true| if
* the token was a legal integer (i.e., consisted of an optional
* |minus_sign| followed by one or more digits).
***************************************************************************/
Boolean_T scan_integer (void)
BEGIN
Integer8_T sign_length;
Boolean_T scan_integer;
buf_ptr1 = buf_ptr2;
if (SCAN_CHAR == MINUS_SIGN)
BEGIN
sign_length = 1;
INCR (buf_ptr2);
END
else
BEGIN
sign_length = 0;
END
token_value = 0;
while ((lex_class[SCAN_CHAR] == NUMERIC) && (buf_ptr2 < last))
BEGIN
token_value = (token_value * 10) + CHAR_VALUE;
INCR (buf_ptr2);
END
if (NEGATIVE)
BEGIN
token_value = -token_value;
END
if (TOKEN_LEN == sign_length)
BEGIN
scan_integer = FALSE;
END
else
BEGIN
scan_integer = TRUE;
END
return(scan_integer);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 93 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 92
* ~~~~~~~~~~~~~~~~~~~
* This function scans for a nonnegative integer, stopping at the first
* nondigit; it sets the value of |token_value| accordingly. It returns
* |true| if the token was a legal nonnegative integer (i.e., consisted
* of one or more digits).
***************************************************************************/
Boolean_T scan_nonneg_integer (void)
BEGIN
Boolean_T scan_nonneg_integer;
buf_ptr1 = buf_ptr2;
token_value = 0;
while ((lex_class[SCAN_CHAR] == NUMERIC) && (buf_ptr2 < last))
BEGIN
token_value = (token_value * 10) + CHAR_VALUE;
INCR (buf_ptr2);
END
if (TOKEN_LEN == 0)
BEGIN
scan_nonneg_integer = FALSE;
END
else
BEGIN
scan_nonneg_integer = TRUE;
END
return (scan_nonneg_integer);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 92 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 94
* ~~~~~~~~~~~~~~~~~~~
* This function scans over |white_space| characters, stopping either at
* the first nonwhite character or the end of the line, respectively
* returning |true| or |false|.
***************************************************************************/
Boolean_T scan_white_space (void)
BEGIN
Boolean_T scan_white_space;
while ((lex_class[SCAN_CHAR] == WHITE_SPACE) && (buf_ptr2 < last))
BEGIN
INCR (buf_ptr2);
END
if (buf_ptr2 < last)
BEGIN
scan_white_space = TRUE;
END
else
BEGIN
scan_white_space = FALSE;
END
return (scan_white_space);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 94 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 186
* ~~~~~~~~~~~~~~~~~~~
* And another.
***************************************************************************/
void skip_illegal_stuff_after_token (void)
BEGIN
PRINT2 ("\"%c\" can't follow a literal", xchr[SCAN_CHAR]);
skip_token_print ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 186 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 404
* ~~~~~~~~~~~~~~~~~~~
* When we come here |sp_ptr| is just past the |left_brace|, and when we
* leave it's either at |sp_end| or just past the matching |right_brace|.
***************************************************************************/
void skip_stuff_at_sp_brace_level_gr (void)
BEGIN
while ((sp_brace_level > 1) && (sp_ptr < sp_end))
BEGIN
if (str_pool[sp_ptr] == RIGHT_BRACE)
BEGIN
DECR (sp_brace_level);
END
else if (str_pool[sp_ptr] == LEFT_BRACE)
BEGIN
INCR (sp_brace_level);
END
INCR (sp_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 404 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 183
* ~~~~~~~~~~~~~~~~~~~
* We're about to start scanning tokens in a function definition. When a
* function token is illegal, we skip until it ends; a |white_space|
* character, an end-of-line, a |right_brace|, or a |comment| marks the
* end of the current token.
***************************************************************************/
void skip_token_print (void)
BEGIN
PRINT ("-");
bst_ln_num_print ();
mark_error ();
if (scan2_white (RIGHT_BRACE, COMMENT))
BEGIN
DO_NOTHING;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 183 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 185
* ~~~~~~~~~~~~~~~~~~~
* Here's another macro for saving some space when there's a problem with
* a token.
***************************************************************************/
void skp_token_unknown_function_prin (void)
BEGIN
PRINT_TOKEN;
PRINT (" is an unknown function");
skip_token_print ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 185 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 58
* ~~~~~~~~~~~~~~~~~~~
* This procedure copies file name |file_name| into the beginning of
* |name_of_file|, if it will fit. 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 start_name (StrNumber_T file_name)
BEGIN
PoolPointer_T p_ptr;
free (name_of_file);
name_of_file = (unsigned char *) mymalloc (LENGTH (file_name) + 5, "name_of_file");
name_ptr = 0;
p_ptr = str_start[file_name];
while (p_ptr < str_start[file_name + 1])
BEGIN
name_of_file[name_ptr] = CHR (str_pool[p_ptr]);
INCR (name_ptr);
INCR (p_ptr);
END
name_length = LENGTH (file_name);
name_of_file[name_length] = 0;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 58 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 56
* ~~~~~~~~~~~~~~~~~~~
* This subroutine compares string |s| with another string that appears
* in the buffer |buf| between positions |bf_ptr| and |bf_ptr+len-1|; the
* result is |true| if and only if the strings are equal.
***************************************************************************/
Boolean_T str_eq_buf (StrNumber_T s, BufType_T buf,
BufPointer_T bf_ptr, BufPointer_T len)
BEGIN
BufPointer_T i;
PoolPointer_T j;
Boolean_T str_eq_buf;
if (LENGTH (s) != len)
BEGIN
str_eq_buf = FALSE;
goto Exit_Label;
END
i = bf_ptr;
j = str_start[s];
while (j < str_start[s + 1])
BEGIN
if (str_pool[j] != buf[i])
BEGIN
str_eq_buf = FALSE;
goto Exit_Label;
END
INCR (i);
INCR (j);
END
str_eq_buf = TRUE;
Exit_Label:
return (str_eq_buf);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 56 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 57
* ~~~~~~~~~~~~~~~~~~~
* This subroutine compares two |str_pool| strings and returns true
* |true| if and only if the strings are equal.
***************************************************************************/
Boolean_T str_eq_str (StrNumber_T s1, StrNumber_T s2)
BEGIN
Boolean_T str_eq_str;
if (LENGTH (s1) != LENGTH (s2))
BEGIN
str_eq_str = FALSE;
goto Exit_Label;
END
p_ptr1 = str_start[s1];
p_ptr2 = str_start[s2];
while (p_ptr1 < str_start[s1 + 1])
BEGIN
if (str_pool[p_ptr1] != str_pool[p_ptr2])
BEGIN
str_eq_str = FALSE;
goto Exit_Label;
END
INCR (p_ptr1);
INCR (p_ptr2);
END
str_eq_str = TRUE;
Exit_Label:
return (str_eq_str);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 57 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 68
* ~~~~~~~~~~~~~~~~~~~
* Here is the subroutine that searches the hash table for a
* (string,~|str_ilk|) pair, where the string is of length |l>=0| and
* appears in |buffer[j..(j+l-1)]|. If it finds the pair, it returns the
* corresponding hash-table location and sets the global variable
* |hash_found| to |true|. Otherwise it sets |hash_found| to |false|,
* and if the parameter |insert_it| is |true|, it inserts the pair into
* the hash table, inserts the string into |str_pool| if not previously
* encountered, and returns its location. Note that two different pairs
* can have the same string but different |str_ilk|s, in which case the
* second pair encountered, if |insert_it| were |true|, would be inserted
* into the hash table though its string wouldn't be inserted into
* |str_pool| because it would already be there.
***************************************************************************/
HashLoc_T str_lookup (BufType_T buf, BufPointer_T j, BufPointer_T l,
StrIlk_T ilk, Boolean_T insert_it)
BEGIN
HashLoc_T str_lookup;
long h;
HashLoc_T p;
BufPointer_T k;
Boolean_T old_string;
StrNumber_T str_num;
/***************************************************************************
* WEB section number: 69
* ~~~~~~~~~~~~~~~~~~~
* The value of |Hash_Prime| should be roughly 85\% of |Hash_Size|, and
* it should be a prime number
* (it should also be less than $2^14 + 2^6 = 16320$ because of
* WEB's simple-macro bound). The theory of hashing tells us to expect
* fewer than two table probes, on the average, when the search is
* successful.
*
* NOTE: the limit imposed on the value of Hash_Prime no longer applies
* because we are using C #defines.
***************************************************************************/
BEGIN
h = 0;
k = j;
while (k < (j + l))
BEGIN
h = h + h + buf[k];
while (h >= Hash_Prime)
h = h - Hash_Prime;
INCR (k);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 69 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
p = h + HASH_BASE;
hash_found = FALSE;
old_string = FALSE;
str_num = 0; /* avoid uninitialized warning */
LOOP
BEGIN
/***************************************************************************
* WEB section number: 70
* ~~~~~~~~~~~~~~~~~~~
* Here we handle the case in which we've already encountered this
* string; note that even if we have, we'll still have to insert the pair
* into the hash table if |str_ilk| doesn't match.
***************************************************************************/
BEGIN
if (hash_text[p] > 0)
BEGIN
if (str_eq_buf (hash_text[p], buf, j, l))
BEGIN
if (hash_ilk[p] == ilk)
BEGIN
hash_found = TRUE;
goto Str_Found_Label;
END
else
BEGIN
old_string = TRUE;
str_num = hash_text[p];
END
END
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 70 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
if (hash_next[p] == EMPTY)
BEGIN
if ( ! insert_it)
BEGIN
goto Str_Not_Found_Label;
END
/***************************************************************************
* WEB section number: 71
* ~~~~~~~~~~~~~~~~~~~
* This code inserts the pair in the appropriate unused location.
***************************************************************************/
BEGIN
if (hash_text[p] > 0)
BEGIN
REPEAT
BEGIN
if (HASH_IS_FULL)
BEGIN
BIBTEX_OVERFLOW ("hash size ", Hash_Size);
END
DECR (hash_used);
END UNTIL (hash_text[hash_used] == 0);
hash_next[p] = hash_used;
p = hash_used;
END
if (old_string)
BEGIN
hash_text[p] = str_num;
END
else
BEGIN
STR_ROOM (l);
k = j;
while (k < (j + l))
BEGIN
APPEND_CHAR (buf[k]);
INCR (k);
END
hash_text[p] = make_string ();
END
hash_ilk[p] = ilk;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 71 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
goto Str_Found_Label;
END
p = hash_next[p];
END
Str_Not_Found_Label: DO_NOTHING;
Str_Found_Label: str_lookup = p;
return (str_lookup);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 68 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 300
* ~~~~~~~~~~~~~~~~~~~
* The |swap| procedure exchanges the two elements its arguments point
* to.
***************************************************************************/
void swap (CiteNumber_T swap1, CiteNumber_T swap2)
BEGIN
CiteNumber_T innocent_bystander;
innocent_bystander = SORTED_CITES[swap2];
SORTED_CITES[swap2] = SORTED_CITES[swap1];
SORTED_CITES[swap1] = innocent_bystander;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 300 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 456
* ~~~~~~~~~~~~~~~~~~~
* Here we print |trace| and/or |stat| information, if desired.
***************************************************************************/
void trace_and_stat_printing (void)
BEGIN
#ifdef TRACE
if (Flag_trace) {
/***************************************************************************
* WEB section number: 457
* ~~~~~~~~~~~~~~~~~~~
* This prints information obtained from the .aux file about the
* other files.
***************************************************************************/
BEGIN
if (num_bib_files == 1)
BEGIN
TRACE_PR_LN ("The 1 database file is");
END
else
BEGIN
TRACE_PR_LN2 ("The %ld database files are", (long) num_bib_files);
END
if (num_bib_files == 0)
BEGIN
TRACE_PR_LN (" undefined");
END
else
BEGIN
bib_ptr = 0;
while (bib_ptr < num_bib_files)
BEGIN
TRACE_PR (" ");
TRACE_PR_POOL_STR (CUR_BIB_STR);
TRACE_PR_POOL_STR (s_bib_extension);
TRACE_PR_NEWLINE;
INCR (bib_ptr);
END
END
TRACE_PR ("The style file is ");
if (bst_str == 0)
BEGIN
TRACE_PR_LN ("undefined");
END
else
BEGIN
TRACE_PR_POOL_STR (bst_str);
TRACE_PR_POOL_STR (s_bst_extension);
TRACE_PR_NEWLINE;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 457 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 458
* ~~~~~~~~~~~~~~~~~~~
* In entry-sorted order, this prints an entry's |cite_list| string and,
* indirectly, its entry type and entry variables.
***************************************************************************/
BEGIN
if (all_entries)
BEGIN
TRACE_PR2 ("all_marker=%ld, ", (long) all_marker);
END
if (read_performed)
BEGIN
TRACE_PR_LN2 ("old_num_cites=%ld", (long) old_num_cites);
END
else
BEGIN
TRACE_PR_NEWLINE;
END
TRACE_PR2 ("The %ld", (long) num_cites);
if (num_cites == 1)
BEGIN
TRACE_PR_LN (" entry:");
END
else
BEGIN
TRACE_PR_LN (" entries:");
END
if (num_cites == 0)
BEGIN
TRACE_PR_LN (" undefined");
END
else
BEGIN
sort_cite_ptr = 0;
while (sort_cite_ptr < num_cites)
BEGIN
if ( ! read_completed)
BEGIN
cite_ptr = sort_cite_ptr;
END
else
BEGIN
cite_ptr = SORTED_CITES[sort_cite_ptr];
END
TRACE_PR_POOL_STR (CUR_CITE_STR);
if (read_performed)
/***************************************************************************
* WEB section number: 458
* ~~~~~~~~~~~~~~~~~~~
* This prints information gathered while reading the .bst and
* .bib files.
***************************************************************************/
BEGIN
TRACE_PR (", entry-type ");
if (type_list[cite_ptr] == UNDEFINED)
BEGIN
TRACE_PR ("unknown");
END
else if (type_list[cite_ptr] == EMPTY)
BEGIN
TRACE_PR ("--- no type found");
END
else
BEGIN
TRACE_PR_POOL_STR (hash_text[type_list[cite_ptr]]);
END
TRACE_PR_LN (", has entry strings");
/***************************************************************************
* WEB section number: 460
* ~~~~~~~~~~~~~~~~~~~
* This prints, for the current entry, the strings declared by the
* entry command.
***************************************************************************/
BEGIN
if (num_ent_strs == 0)
BEGIN
TRACE_PR_LN (" undefined");
END
else if ( ! read_completed)
BEGIN
TRACE_PR_LN (" uninitialized");
END
else
BEGIN
str_ent_ptr = cite_ptr * num_ent_strs;
while (str_ent_ptr < ((cite_ptr + 1) * num_ent_strs))
BEGIN
ent_chr_ptr = 0;
TRACE_PR (" \"");
while (ENTRY_STRS(str_ent_ptr, ent_chr_ptr) != END_OF_STRING)
BEGIN
TRACE_PR2 ("%c",
xchr[ENTRY_STRS(str_ent_ptr, ent_chr_ptr)]);
INCR (ent_chr_ptr);
END
TRACE_PR_LN ("\"");
INCR (str_ent_ptr);
END
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 460 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
TRACE_PR (" has entry integers");
/***************************************************************************
* WEB section number: 461
* ~~~~~~~~~~~~~~~~~~~
* This prints, for the current entry, the integers declared by the
* entry command.
***************************************************************************/
BEGIN
if (num_ent_ints == 0)
BEGIN
TRACE_PR (" undefined");
END
else if ( ! read_completed)
BEGIN
TRACE_PR (" uninitialized");
END
else
BEGIN
int_ent_ptr = cite_ptr * num_ent_ints;
while (int_ent_ptr < ((cite_ptr + 1) * num_ent_ints))
BEGIN
TRACE_PR2 (" %ld", (long) entry_ints[int_ent_ptr]);
INCR (int_ent_ptr);
END
END
TRACE_PR_NEWLINE;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 461 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
TRACE_PR_LN (" and has fields");
/***************************************************************************
* WEB section number: 462
* ~~~~~~~~~~~~~~~~~~~
* This prints the fields stored for the current entry.
***************************************************************************/
BEGIN
if ( ! read_performed)
BEGIN
TRACE_PR_LN (" uninitialized");
END
else
BEGIN
field_ptr = cite_ptr * num_fields;
field_end_ptr = field_ptr + num_fields;
no_fields = TRUE;
while (field_ptr < field_end_ptr)
BEGIN
if (field_info[field_ptr] != MISSING)
BEGIN
TRACE_PR (" \"");
TRACE_PR_POOL_STR (field_info[field_ptr]);
TRACE_PR_LN ("\"");
no_fields = FALSE;
END
INCR (field_ptr);
END
if (no_fields)
BEGIN
TRACE_PR_LN (" missing");
END
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 462 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 459 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
else
BEGIN
TRACE_PR_NEWLINE;
END
INCR (sort_cite_ptr);
END
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 458 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 463
* ~~~~~~~~~~~~~~~~~~~
* This gives all the |wiz_defined| functions that appeared in the
* .bst file.
***************************************************************************/
BEGIN
TRACE_PR_LN ("The wiz-defined functions are");
if (wiz_def_ptr == 0)
BEGIN
TRACE_PR_LN (" nonexistent");
END
else
BEGIN
wiz_fn_ptr = 0;
while (wiz_fn_ptr < wiz_def_ptr)
BEGIN
if (wiz_functions[wiz_fn_ptr] == END_OF_DEF)
BEGIN
TRACE_PR_LN2 ("%ld--end-of-def--", (long) wiz_fn_ptr);
END
else if (wiz_functions[wiz_fn_ptr] == QUOTE_NEXT_FN)
BEGIN
TRACE_PR2 ("%ld quote_next_function ", (long) wiz_fn_ptr);
END
else
BEGIN
TRACE_PR2 ("%ld `", (long) wiz_fn_ptr);
TRACE_PR_POOL_STR (hash_text[wiz_functions[wiz_fn_ptr]]);
TRACE_PR_LN ("'");
END
INCR (wiz_fn_ptr);
END
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 463 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 464
* ~~~~~~~~~~~~~~~~~~~
* This includes all the `static' strings (that is, those that are also
* in the hash table), but none of the dynamic strings (that is, those
* put on the stack while executing .bst commands).
***************************************************************************/
BEGIN
TRACE_PR_LN ("The string pool is");
str_num = 1;
while (str_num < str_ptr)
BEGIN
TRACE_PR3 ("%4ld%6ld \"", (long) str_num, (long) str_start[str_num]);
TRACE_PR_POOL_STR (str_num);
TRACE_PR_LN ("\"");
INCR (str_num);
END
END
} /* end if (Flag_trace) */
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 464 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* TRACE */
#ifdef STAT
/***************************************************************************
* WEB section number: 465
* ~~~~~~~~~~~~~~~~~~~
* These statistics can help determine how large some of the constants
* should be and can tell how useful certain |built_in| functions are.
* They are written to the same files as tracing information.
***************************************************************************/
if (Flag_stats) {
BEGIN
STAT_PR2 ("You've used %ld", (long) num_cites);
if (num_cites == 1)
BEGIN
STAT_PR_LN (" entry,");
END
else
BEGIN
STAT_PR_LN (" entries,");
END
STAT_PR_LN2 (" %ld wiz_defined-function locations,",
(long) wiz_def_ptr);
STAT_PR_LN3 (" %ld strings with %ld characters,",
(long) str_ptr, (long) str_start[str_ptr]);
blt_in_ptr = 0;
total_ex_count = 0;
while (blt_in_ptr < NUM_BLT_IN_FNS)
BEGIN
total_ex_count = total_ex_count + execution_count[blt_in_ptr];
INCR (blt_in_ptr);
END
STAT_PR_LN2 ("and the built_in function-call counts, %ld in all, are:",
(long) total_ex_count);
blt_in_ptr = 0;
while (blt_in_ptr < NUM_BLT_IN_FNS)
BEGIN
STAT_PR_POOL_STR (hash_text[blt_in_loc[blt_in_ptr]]);
STAT_PR_LN2 (" -- %ld", (long) execution_count[blt_in_ptr]);
INCR (blt_in_ptr);
END
END
} /* end if (Flag_stats) */
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 465 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
#endif /* STAT */
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 456 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 159
* ~~~~~~~~~~~~~~~~~~~
* This version is for printing when in |trace| mode.
***************************************************************************/
#ifdef TRACE
void trace_pr_fn_class (HashLoc_T fn_loc)
BEGIN
if (!Flag_trace)
return;
switch (fn_type[fn_loc])
BEGIN
case BUILT_IN:
TRACE_PR ("built-in");
break;
case WIZ_DEFINED:
TRACE_PR ("wizard-defined");
break;
case INT_LITERAL:
TRACE_PR ("integer-literal");
break;
case STR_LITERAL:
TRACE_PR ("string-literal");
break;
case FIELD:
TRACE_PR ("field");
break;
case INT_ENTRY_VAR:
TRACE_PR ("integer-entry-variable");
break;
case STR_ENTRY_VAR:
TRACE_PR ("string-entry-variable");
break;
case INT_GLOBAL_VAR:
TRACE_PR ("integer-global-variable");
break;
case STR_GLOBAL_VAR:
TRACE_PR ("string-global-variable");
break;
default:
unknwn_function_class_confusion ();
break;
END
END
#endif /* TRACE */
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 159 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 157
* ~~~~~~~~~~~~~~~~~~~
* Here's another bug report.
***************************************************************************/
void unknwn_function_class_confusion (void)
BEGIN
CONFUSION ("Unknown function class");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 157 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 310
* ~~~~~~~~~~~~~~~~~~~
* More bug complaints, this time about bad literals.
***************************************************************************/
void unknwn_literal_confusion (void)
BEGIN
CONFUSION ("Unknown literal type");
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 310 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 63
* ~~~~~~~~~~~~~~~~~~~
* This system-independent procedure is the same as the previous except
* that it converts lower- to upper-case letters.
***************************************************************************/
#ifndef UTF_8
void upper_case (BufType_T buf, BufPointer_T bf_ptr,
BufPointer_T len)
BEGIN
BufPointer_T i;
if (len > 0)
BEGIN
for (i = bf_ptr; i <= (bf_ptr+len-1); i++)
BEGIN
#ifdef SUPPORT_8BIT
if (IsLower (buf[i]))
BEGIN
buf[i] = ToUpper(buf[i]);
END
#else /* NOT SUPPORT_8BIT */
if ((buf[i] >= 'a') && (buf[i] <= 'z'))
BEGIN
buf[i] = buf[i] - CASE_DIFFERENCE;
END
#endif /* SUPPORT_8BIT */
END
END
END
#else
/*
This foction "upper_case_uni" is for prcessing the character UTF-8.
It's like lower_case_uni. 23/sep/2009
*/
BufPointer_T upper_case_uni (BufType_T buf, BufPointer_T bf_ptr,
BufPointer_T len)
BEGIN
// printf("O~ lala~~");
UChar target[BUF_SIZE+1];
int32_t tarcap=BUF_SIZE+1;
int32_t tarlen = icu_toUChars(buf, bf_ptr, len, target, tarcap);
UChar tarup[BUF_SIZE+1];
int32_t tucap=BUF_SIZE+1;
int32_t tulen=icu_strToUpper(tarup, tucap,target, tarlen);
unsigned char dest[BUF_SIZE+1];
int32_t destcap= BUF_SIZE-bf_ptr;
int32_t tblen=icu_fromUChars(dest, destcap, (const UChar *) tarup, tulen);
BufPointer_T i;
if (tblen > 0)
BEGIN
if (len!=tblen)
BEGIN
unsigned char tmp[BUF_SIZE+1];
BufPointer_T tmppr=0;
for (i=bf_ptr+len;i<=(BUF_SIZE-tblen+len);i++)
BEGIN
tmp[tmppr]=buf[i];
tmppr++;
END
i=bf_ptr+tblen;
tmppr=0;
for (tmppr=0;tmppr<=(BUF_SIZE-bf_ptr-tblen);tmppr++)
BEGIN
buf[i]=tmp[tmppr];
i++;
END
END
for (i = 0; i <= (tblen - 1); i++)
BEGIN
buf[i+bf_ptr]=dest[i];
END
END
return tblen;
END
/*
This function is for transform Unicode string to up case. 23/sep/2009
*/
int32_t icu_strToUpper(UChar * tarup, int32_t tucap, UChar * target, int32_t tarlen)
BEGIN
int32_t tulen;
UErrorCode err1 = U_ZERO_ERROR;
if (!U_SUCCESS(err1))
BEGIN
printf("Error in icu_strToUpper?\n");
END
if (Flag_language)
{
tulen=u_strToUpper(tarup,tucap, target,tarlen,Str_language,&err1);
}
else
{
tulen=u_strToUpper(tarup,tucap, target,tarlen,NULL,&err1);
}
if (!U_SUCCESS(err1))
BEGIN
printf("Error in icu_strToUpper.\n");
#ifdef TRACE
if (Flag_trace)
TRACE_PR_LN ("Error in icu_strToUpper");
#endif /* TRACE */
END
return tulen;
END
#endif
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 63 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 401
* ~~~~~~~~~~~~~~~~~~~
* The last name starts just past the last token, before the first
* |comma| (if there is no |comma|, there is deemed to be one at the end
* of the string), for which there exists a first brace-level-0 letter
* (or brace-level-1 special character), and it's in lower case, unless
* this last token is also the last token before the |comma|, in which
* case the last name starts with this token (unless this last token is
* connected by a |sep_char| other than a |tie| to the previous token, in
* which case the last name starts with as many tokens earlier as are
* connected by non|tie|s to this last one (except on Tuesdays
* $\ldots\,$), although this module never sees such a case). Note that
* if there are any tokens in either the von or last names, then the last
* name has at least one, even if it starts with a lower-case letter.
***************************************************************************/
void von_name_ends_and_last_name_sta (void)
BEGIN
von_end = last_end - 1;
while (von_end > von_start)
BEGIN
name_bf_ptr = name_tok[von_end - 1];
name_bf_xptr = name_tok[von_end];
if (von_token_found ())
BEGIN
goto Exit_Label;
END
DECR (von_end);
END
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 397
* ~~~~~~~~~~~~~~~~~~~
* It's a von token if there exists a first brace-level-0 letter (or
* brace-level-1 special character), and it's in lower case; in this case
* we return |true|. The token is in |name_buf|, starting at
* |name_bf_ptr| and ending just before |name_bf_xptr|.
***************************************************************************/
Boolean_T von_token_found (void)
BEGIN
Boolean_T von_token_found;
nm_brace_level = 0;
von_token_found = FALSE;
while (name_bf_ptr < name_bf_xptr)
BEGIN
#ifdef SUPPORT_8BIT
if IsUpper(NAME_BUF[name_bf_ptr])
BEGIN
goto Exit_Label;
END
else if IsLower(NAME_BUF[name_bf_ptr])
BEGIN
RETURN_VON_FOUND;
END
#else /* NOT SUPPORT_8BIT */
if ((NAME_BUF[name_bf_ptr] >= 'A') && (NAME_BUF[name_bf_ptr] <= 'Z'))
BEGIN
goto Exit_Label;
END
else if ((NAME_BUF[name_bf_ptr] >= 'a') && (NAME_BUF[name_bf_ptr] <= 'z'))
BEGIN
RETURN_VON_FOUND;
END
#endif /* SUPPORT_8BIT */
else if (NAME_BUF[name_bf_ptr] == LEFT_BRACE)
BEGIN
INCR (nm_brace_level);
INCR (name_bf_ptr);
if (((name_bf_ptr + 2) < name_bf_xptr)
&& (NAME_BUF[name_bf_ptr] == BACKSLASH))
/***************************************************************************
* WEB section number: 398
* ~~~~~~~~~~~~~~~~~~~
* When we come here |name_bf_ptr| is just past the |left_brace|,
* but we always leave by |return|ing.
***************************************************************************/
BEGIN
INCR (name_bf_ptr);
name_bf_yptr = name_bf_ptr;
while ((name_bf_ptr < name_bf_xptr)
&& (lex_class[NAME_BUF[name_bf_ptr]] == ALPHA))
BEGIN
INCR (name_bf_ptr);
END
control_seq_loc = str_lookup (NAME_BUF, name_bf_yptr,
name_bf_ptr - name_bf_yptr,
CONTROL_SEQ_ILK, DONT_INSERT);
if (hash_found)
/***************************************************************************
* WEB section number: 399
* ~~~~~~~~~~~~~~~~~~~
* The accented or foreign character is either `\i' or `\j' or
* one of the eleven alphabetic foreign characters in Table~3.2 of the
* \LaTeX\ manual.
***************************************************************************/
BEGIN
switch (ilk_info[control_seq_loc])
BEGIN
case N_OE_UPPER:
case N_AE_UPPER:
case N_AA_UPPER:
case N_O_UPPER:
case N_L_UPPER:
goto Exit_Label;
case N_I:
case N_J:
case N_OE:
case N_AE:
case N_AA:
case N_O:
case N_L:
case N_SS:
RETURN_VON_FOUND;
default:
CONFUSION ("Control-sequence hash error");
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 399 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
while ((name_bf_ptr < name_bf_xptr) && (nm_brace_level > 0))
BEGIN
#ifdef SUPPORT_8BIT
if IsUpper(NAME_BUF[name_bf_ptr])
BEGIN
goto Exit_Label;
END
else if IsLower(NAME_BUF[name_bf_ptr])
BEGIN
RETURN_VON_FOUND;
END
#else /* NOT SUPPORT_8BIT */
if ((NAME_BUF[name_bf_ptr] >= 'A') && (NAME_BUF[name_bf_ptr] <= 'Z'))
BEGIN
goto Exit_Label;
END
else if ((NAME_BUF[name_bf_ptr] >= 'a')
&& (NAME_BUF[name_bf_ptr] <= 'z'))
BEGIN
RETURN_VON_FOUND;
END
#endif /* SUPPORT_8BIT */
else if (NAME_BUF[name_bf_ptr] == RIGHT_BRACE)
BEGIN
DECR (nm_brace_level);
END
else if (NAME_BUF[name_bf_ptr] == LEFT_BRACE)
BEGIN
INCR (nm_brace_level);
END
INCR (name_bf_ptr);
END
goto Exit_Label;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 398 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
else
/***************************************************************************
* WEB section number: 400
* ~~~~~~~~~~~~~~~~~~~
* When we come here |name_bf_ptr| is just past the |left_brace|; when we
* leave it's either at |name_bf_xptr| or just past the matching
* |right_brace|.
***************************************************************************/
BEGIN
while ((nm_brace_level > 0) && (name_bf_ptr < name_bf_xptr))
BEGIN
if (NAME_BUF[name_bf_ptr] == RIGHT_BRACE)
BEGIN
DECR (nm_brace_level);
END
else if (NAME_BUF[name_bf_ptr] == LEFT_BRACE)
BEGIN
INCR (nm_brace_level);
END
INCR (name_bf_ptr);
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 400 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
else
BEGIN
INCR (name_bf_ptr);
END
END
Exit_Label: DO_NOTHING;
return (von_token_found);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 397 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
/***************************************************************************
* WEB section number: 360
* ~~~~~~~~~~~~~~~~~~~
* The |built_in| function add.period$ pops the top (string)
* literal, adds a |period| to a nonnull string if its last
* non|right_brace| character isn't a |period|, |question_mark|, or
* |exclamation_mark|, and pushes this resulting string back onto the
* stack. If the literal isn't a string, it complains and pushes the
* null string.
***************************************************************************/
void x_add_period (void)
BEGIN
pop_lit_stk (&pop_lit1, &pop_typ1);
if (pop_typ1 != STK_STR)
BEGIN
print_wrong_stk_lit (pop_lit1, pop_typ1, STK_STR);
push_lit_stk (s_null, STK_STR);
END
else if (LENGTH (pop_lit1) == 0)
BEGIN
push_lit_stk (s_null, STK_STR);
END
else
/***************************************************************************
* WEB section number: 361
* ~~~~~~~~~~~~~~~~~~~
* Here we scan backwards from the end of the string, skipping
* non|right_brace| characters, to see if we have to add the |period|.
***************************************************************************/
BEGIN
#ifdef UTF_8
UChar ch;
#endif
sp_ptr = str_start[pop_lit1 + 1];
sp_end = str_start[pop_lit1];
while (sp_ptr > sp_end)
BEGIN
DECR (sp_ptr);
if (str_pool[sp_ptr] != RIGHT_BRACE)
BEGIN
goto Loop_Exit_Label;
END
END
Loop_Exit_Label:
#ifdef UTF_8
ch = str_pool[sp_ptr];
if (utf8len(str_pool[sp_ptr]) != 1 && utf8len(str_pool[sp_ptr-1]) != 2 && utf8len(str_pool[sp_ptr-2]) == 3)
ch = ((str_pool[sp_ptr-2]&0x0f) <<12) | ((str_pool[sp_ptr-1]&0x3f) << 6) | (str_pool[sp_ptr]&0x3f);
switch (ch)
#else
switch (str_pool[sp_ptr])
#endif
BEGIN
case PERIOD:
case QUESTION_MARK:
case EXCLAMATION_MARK:
#ifdef UTF_8
case 0x203C: case 0x203D: case 0x2047: /* ‼ ‽ ⁇ */
case 0x2048: case 0x2049: case 0x3002: /* ⁈ ⁉ 。 */
case 0xFF01: case 0xFF0E: case 0xFF1F: /* ! . ? */
#endif
REPUSH_STRING;
break;
default:
/***************************************************************************
* WEB section number: 362
* ~~~~~~~~~~~~~~~~~~~
* Ok guys, we really have to do it.
***************************************************************************/
BEGIN
if (pop_lit1 < cmd_str_ptr)
BEGIN
STR_ROOM (LENGTH (pop_lit1) + 1);
sp_ptr = str_start[pop_lit1];
sp_end = str_start[pop_lit1 + 1];
while (sp_ptr < sp_end)
BEGIN
APPEND_CHAR (str_pool[sp_ptr]);
INCR (sp_ptr);
END
END
else
BEGIN
pool_ptr = str_start[pop_lit1 + 1];
STR_ROOM (1);
END
APPEND_CHAR (PERIOD);
push_lit_stk (make_string (), STK_STR);
break;
END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 362 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 361 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 360 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
|