summaryrefslogtreecommitdiff
path: root/biblio/bibtex/bibtex-x/bibtex-4.c
blob: 9663f5a6b8c25c962466a9c6194507e55c7ce883 (plain)
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
/*-
******************************************************************************
******************************************************************************
**
**  MODULE
**
**      file: bibtex-4.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 fourth 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:
**
**          x_change_case
**          x_chr_to_int
**          x_cite
**          x_concatenate
**          x_duplicate
**          x_empty
**          x_equals
**          x_format_name
**          x_gets
**          x_greater_than
**          x_int_to_chr
**          x_int_to_str
**          x_less_than
**          x_minus
**          x_missing
**          x_num_names
**          x_plus
**          x_preamble
**          x_purify
**          x_quote
**          x_substring
**          x_swap
**          x_text_length
**          x_text_prefix
**          x_type
**          x_warning
**          x_width
**          x_write
**
**  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-4.c,v $
**      Revision 3.71  1996/08/18  20:47:30  kempson
**      Official release 3.71 (see HISTORY file for details).
**
**      Revision 3.70  1996/04/08  10:08:40  kempson
**      Final documentation & cosmetic changes for official release 3.70.
**
**      Revision 3.5  1995/09/24  20:44:37  kempson
**      Many changes for final beta test version.
**
**      Revision 3.4  1995/04/09  22:15:41  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:	 364
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function change.case$ pops the top two (string)
 * literals; it changes the case of the second according to the
 * specifications of the first, as follows.  (Note: The word `letters' in
 * the next sentence refers only to those at brace-level~0, the top-most
 * brace level; no other characters are changed, except perhaps for
 * special characters, described shortly.)  If the first literal is the
 * string t, it converts to lower case all letters except the very
 * first character in the string, which it leaves alone, and except the
 * first character following any |colon| and then nonnull |white_space|,
 * which it also leaves alone; if it's the string l, it converts all
 * letters to lower case; if it's the string u, it converts all
 * letters to upper case; and if it's anything else, it complains and
 * does no conversion.  It then pushes this resulting string.  If either
 * type is incorrect, it complains and pushes the null string; however,
 * if both types are correct but the specification string (i.e., the
 * first string) isn't one of the legal ones, it merely pushes the second
 * back onto the stack, after complaining.  (Another note: It ignores
 * case differences in the specification string; for example, the strings
 * t and T are equivalent for the purposes of this |built_in|
 * function.)
 ***************************************************************************/
void          x_change_case (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  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 (pop_typ2 != STK_STR)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR);
    push_lit_stk (s_null, STK_STR);
  END
  else
  BEGIN

/***************************************************************************
 * WEB section number:	366
 * ~~~~~~~~~~~~~~~~~~~
 * First we define a few variables for case conversion.  The constant
 * definitions, to be used in |case| statements, are in order of probable
 * frequency.
 ***************************************************************************/
    BEGIN
      switch (str_pool[str_start[pop_lit1]])
      BEGIN
	case 't':
	case 'T':
	  conversion_type = TITLE_LOWERS;
	  break;
	case 'l':
	case 'L':
	  conversion_type = ALL_LOWERS;
	  break;
	case 'u':
	case 'U':
	  conversion_type = ALL_UPPERS;
	  break;
	default:
	  conversion_type = BAD_CONVERSION;
	  break;
      END
      if ((LENGTH (pop_lit1) != 1) || (conversion_type == BAD_CONVERSION))
      BEGIN
	conversion_type = BAD_CONVERSION;
	PRINT_POOL_STR (pop_lit1);
	BST_EX_WARN (" is an illegal case-conversion string");
      END
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 366 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

    ex_buf_length = 0;
    add_buf_pool (pop_lit2);

/***************************************************************************
 * WEB section number:	370
 * ~~~~~~~~~~~~~~~~~~~
 * Here's where we actually go through the string and do the case
 * conversion.
 ***************************************************************************/
    BEGIN
      brace_level = 0;
      ex_buf_ptr = 0;
      while (ex_buf_ptr < ex_buf_length)
      BEGIN
	if (ex_buf[ex_buf_ptr] == LEFT_BRACE)
	BEGIN
	  INCR (brace_level);
	  if (brace_level != 1)
	  BEGIN
	    goto OK_Pascal_I_Give_Up_Label;
	  END
	  if ((ex_buf_ptr + 4) > ex_buf_length)
	  BEGIN
	    goto OK_Pascal_I_Give_Up_Label;
	  END
	  else if (ex_buf[ex_buf_ptr + 1] != BACKSLASH)
	  BEGIN
	    goto OK_Pascal_I_Give_Up_Label;
	  END
	  if (conversion_type == TITLE_LOWERS)
	  BEGIN
	    if (ex_buf_ptr == 0)
	    BEGIN
	      goto OK_Pascal_I_Give_Up_Label;
	    END
	    else if ((prev_colon)
		      && (lex_class[ex_buf[ex_buf_ptr - 1]] == WHITE_SPACE))
	    BEGIN
	      goto OK_Pascal_I_Give_Up_Label;
	    END
	  END

/***************************************************************************
 * WEB section number:	371
 * ~~~~~~~~~~~~~~~~~~~
 * We're dealing with a special character (usually either an undotted
 * `\i' or `\j', or an accent like one in Table~3.1 of the \LaTeX\
 * manual, or a foreign character like one in Table~3.2) if the first
 * character after the |left_brace| is a |backslash|; the special
 * character ends with the matching |right_brace|.  How we handle what's
 * in between depends on the special character.  In general, this code
 * will do reasonably well if there is other stuff, too, between braces,
 * but it doesn't try to do anything special with |colon|s.
 ***************************************************************************/
	  BEGIN
	    INCR (ex_buf_ptr);
	    while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0))
	    BEGIN
	      INCR (ex_buf_ptr);
	      ex_buf_xptr = ex_buf_ptr;
	      while ((ex_buf_ptr < ex_buf_length)
			  && (lex_class[ex_buf[ex_buf_ptr]] == ALPHA))
	      BEGIN
		INCR (ex_buf_ptr);
	      END
	      control_seq_loc = str_lookup (ex_buf, ex_buf_xptr,
					    ex_buf_ptr - ex_buf_xptr,
					    CONTROL_SEQ_ILK, DONT_INSERT);
	      if (hash_found)

/***************************************************************************
 * WEB section number:	372
 * ~~~~~~~~~~~~~~~~~~~
 * A control sequence, for the purposes of this program, consists just of
 * the consecutive alphabetic characters following the |backslash|; it
 * might be empty (although ones in this section aren't).
 ***************************************************************************/
	      BEGIN
		switch (conversion_type)
		BEGIN
		  case TITLE_LOWERS:
		  case ALL_LOWERS:
		    switch (ilk_info[control_seq_loc])
		    BEGIN
		      case N_L_UPPER:
		      case N_O_UPPER:
		      case N_OE_UPPER:
		      case N_AE_UPPER:
		      case N_AA_UPPER:
			Lower_case (ex_buf, ex_buf_xptr,
				    ex_buf_ptr - ex_buf_xptr);
			break;
		      default:
			DO_NOTHING;
			break;
		    END
		    break;
		  case ALL_UPPERS:
		    switch (ilk_info[control_seq_loc])
		    BEGIN
		      case N_L:
		      case N_O:
		      case N_OE:
		      case N_AE:
		      case N_AA:
			upper_case (ex_buf, ex_buf_xptr,
				    ex_buf_ptr - ex_buf_xptr);
			break;
		      case N_I:
		      case N_J:
		      case N_SS:

/***************************************************************************
 * WEB section number:	374
 * ~~~~~~~~~~~~~~~~~~~
 * After converting the control sequence, we need to remove the preceding
 * |backslash| and any following |white_space|.
 ***************************************************************************/
			BEGIN
			  upper_case (ex_buf, ex_buf_xptr,
				      ex_buf_ptr - ex_buf_xptr);
			  while (ex_buf_xptr < ex_buf_ptr)
			  BEGIN
			    ex_buf[ex_buf_xptr - 1] = ex_buf[ex_buf_xptr];
			    INCR (ex_buf_xptr);
			  END
			  DECR (ex_buf_xptr);
			  while ((ex_buf_ptr < ex_buf_length)
			    && (lex_class[ex_buf[ex_buf_ptr]] == WHITE_SPACE))
			  BEGIN
			    INCR (ex_buf_ptr);
			  END
			  tmp_ptr = ex_buf_ptr;
			  while (tmp_ptr < ex_buf_length)
			  BEGIN
			    ex_buf[tmp_ptr - (ex_buf_ptr - ex_buf_xptr)]
			      = ex_buf[tmp_ptr];
			    INCR (tmp_ptr);
			  END
			  ex_buf_length = tmp_ptr - (ex_buf_ptr - ex_buf_xptr);
			  ex_buf_ptr = ex_buf_xptr;
			END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 374 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

			break;
		      default:
			DO_NOTHING;
			break;
		    END
		    break;
		  case BAD_CONVERSION:
		    DO_NOTHING;
		    break;
		  default:
		    case_conversion_confusion ();
		    break;
		END
	      END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 372 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

	      ex_buf_xptr = ex_buf_ptr;
	      while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0)
		      && (ex_buf[ex_buf_ptr] != BACKSLASH))
	      BEGIN
		if (ex_buf[ex_buf_ptr] == RIGHT_BRACE)
		BEGIN
		  DECR (brace_level);
		END
		else if (ex_buf[ex_buf_ptr] == LEFT_BRACE)
		BEGIN
		  INCR (brace_level);
		END
		INCR (ex_buf_ptr);
	      END

/***************************************************************************
 * WEB section number:	375
 * ~~~~~~~~~~~~~~~~~~~
 * There are no control sequences in what we're about to convert,
 * so a straight conversion suffices.
 ***************************************************************************/
	      switch (conversion_type)
	      BEGIN
		case TITLE_LOWERS:
		case ALL_LOWERS:
		  Lower_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr);
		  break;
		case ALL_UPPERS:
		  upper_case (ex_buf, ex_buf_xptr, ex_buf_ptr - ex_buf_xptr);
		  break;
		case BAD_CONVERSION:
		  DO_NOTHING;
		  break;
		default:
		  case_conversion_confusion ();
		  break;
	      END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 375 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

	    END
	    DECR (ex_buf_ptr);
	  END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 371 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

OK_Pascal_I_Give_Up_Label:  prev_colon = FALSE;
	END
	else if (ex_buf[ex_buf_ptr] == RIGHT_BRACE)
	BEGIN
	  decr_brace_level (pop_lit2);
	  prev_colon = FALSE;
	END
	else if (brace_level == 0)

/***************************************************************************
 * WEB section number:	376
 * ~~~~~~~~~~~~~~~~~~~
 * This code does any needed conversion for an ordinary character; it
 * won't touch nonletters.
 ***************************************************************************/
	BEGIN
	  switch (conversion_type)
	  BEGIN
	    case TITLE_LOWERS:
	      if (ex_buf_ptr == 0)
	      BEGIN
#ifdef UTF_8
/*
For the case of TITLE_LOWERS, we transform the characters to low case except the first 
character. When it's UTF-8, we should care about the length of charater.   23/sep/2009
*/
		DO_UTF8(ex_buf[ex_buf_ptr], , ex_buf_ptr = 1, ex_buf_ptr = 2, ex_buf_ptr = 3);
#else
		DO_NOTHING;
#endif
	      END
	      else if ((prev_colon)
			&& (lex_class[ex_buf[ex_buf_ptr - 1]] == WHITE_SPACE))
	      BEGIN
		DO_NOTHING;
	      END
	      else
	      BEGIN
#ifdef UTF_8
/*
When we do lower_case_uni, the length of string have been changed. So we should do some job 
for the precessing after lower case. Here there may be some potential bug.      23/sep/2009
*/
		int16_t llen;

		llen=utf8len(ex_buf[ex_buf_ptr]);
		ex_buf_ptr=ex_buf_ptr+lower_case_uni (ex_buf, ex_buf_ptr, llen)-1;
#else
		lower_case (ex_buf, ex_buf_ptr, 1);
#endif
	      END
	      if (ex_buf[ex_buf_ptr] == COLON)
	      BEGIN
		prev_colon = TRUE;
	      END
	      else if (lex_class[ex_buf[ex_buf_ptr]] != WHITE_SPACE)
	      BEGIN
		prev_colon = FALSE;
	      END
	      break;
	    case ALL_LOWERS:
#ifdef UTF_8
/*
Here the same for processing the length of string after change case. 23/sep/2009
*/
	      BEGIN
		int16_t llen;

		llen=utf8len(ex_buf[ex_buf_ptr]);
		ex_buf_ptr=ex_buf_ptr+lower_case_uni (ex_buf, ex_buf_ptr, llen)-1;
	      END
#else
	      lower_case (ex_buf, ex_buf_ptr, 1);
#endif
	      break;
	    case ALL_UPPERS:
#ifdef UTF_8
/*
Here the same for processing the length of string after change case. 23/sep/2009
*/
              BEGIN
		int16_t ulen;

		ulen=utf8len(ex_buf[ex_buf_ptr]);
		ex_buf_ptr=ex_buf_ptr+upper_case_uni (ex_buf, ex_buf_ptr, ulen)-1;
              END
#else
	      upper_case (ex_buf, ex_buf_ptr, 1);
#endif
	      break;
	    case BAD_CONVERSION:
	      DO_NOTHING;
	      break;
	    default:
	      case_conversion_confusion ();
	      break;
	  END
	END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 376 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

	INCR (ex_buf_ptr);
      END
      check_brace_level (pop_lit2);
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 370 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

    add_pool_buf_and_push ();
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 364 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 377
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function chr.to.int$ pops the top (string)
 * literal, makes sure it's a single character, converts it to the
 * corresponding |ASCII_code| integer, and pushes this integer.  If the
 * literal isn't an appropriate string, it complains and pushes the
 * integer~0.
 ***************************************************************************/
void          x_chr_to_int (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 (0, STK_INT);
  END
#ifdef UTF_8
  else if (LENGTH (pop_lit1) != utf8len(str_pool[str_start[pop_lit1]]))
#else
  else if (LENGTH (pop_lit1) != 1)
#endif
  BEGIN
    PRINT ("\"");
    PRINT_POOL_STR (pop_lit1);
    BST_EX_WARN ("\" isn't a single character");
    push_lit_stk (0, STK_INT);
  END
  else
  BEGIN
#ifdef UTF_8
    UChar32 ch;
    U8_GET_OR_FFFD(&str_pool[str_start[pop_lit1]], 0, 0, -1, ch);
    push_lit_stk (ch, STK_INT);
#else
    push_lit_stk (str_pool[str_start[pop_lit1]], STK_INT);
#endif
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 377 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 378
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function cite pushes the appropriate string
 * from |cite_list| onto the stack.
 ***************************************************************************/
void          x_cite (void)
BEGIN
  if ( ! mess_with_entries)
  BEGIN
    bst_cant_mess_with_entries_prin ();
  END
  else
  BEGIN
    push_lit_stk (CUR_CITE_STR, STK_STR);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 378 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 350
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function * pops the top two (string) literals,
 * concatenates them (in reverse order, that is, the order in which
 * pushed), and pushes the resulting string back onto the stack.  If
 * either isn't a string literal, it complains and pushes the null
 * string.
 ***************************************************************************/
void          x_concatenate (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  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 (pop_typ2 != STK_STR)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR);
    push_lit_stk (s_null, STK_STR);
  END
  else

/***************************************************************************
 * WEB section number:	351
 * ~~~~~~~~~~~~~~~~~~~
 * Often both strings will be at the top of the string pool, in which
 * case we just move some pointers.  Furthermore, it's worth doing some
 * special stuff in case either string is null, since empirically this
 * seems to happen about $20\%$ of the time.  In any case, we don't need
 * the execution buffer---we simple move the strings around in the string
 * pool when necessary.
 ***************************************************************************/
  BEGIN
    if (pop_lit2 >= cmd_str_ptr)
    BEGIN
      if (pop_lit1 >= cmd_str_ptr)
      BEGIN
        str_start[pop_lit1] = str_start[pop_lit1 + 1];
	UNFLUSH_STRING;
        INCR (lit_stk_ptr);
      END
      else if (LENGTH (pop_lit2) == 0)
      BEGIN
        push_lit_stk (pop_lit1, STK_STR);
      END
      else
      BEGIN
        pool_ptr = str_start[pop_lit2 + 1];
	STR_ROOM (LENGTH (pop_lit1));
        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
        push_lit_stk (make_string (), STK_STR);
      END
    END
    else

/***************************************************************************
 * WEB section number:	352
 * ~~~~~~~~~~~~~~~~~~~
 * We simply continue the previous module.
 ***************************************************************************/
    BEGIN
      if (pop_lit1 >= cmd_str_ptr)
      BEGIN
        if (LENGTH (pop_lit2) == 0)
        BEGIN
	  UNFLUSH_STRING;
          lit_stack[lit_stk_ptr] = pop_lit1;
          INCR (lit_stk_ptr);
        END
        else if (LENGTH (pop_lit1) == 0)
        BEGIN
          INCR (lit_stk_ptr);
        END
        else
        BEGIN
          sp_length = LENGTH (pop_lit1);
          sp2_length = LENGTH (pop_lit2);
	  STR_ROOM (sp_length + sp2_length);
          sp_ptr = str_start[pop_lit1 + 1];
          sp_end = str_start[pop_lit1];
          sp_xptr1 = sp_ptr + sp2_length;
          while (sp_ptr > sp_end)
          BEGIN
            DECR (sp_ptr);
            DECR (sp_xptr1);
            str_pool[sp_xptr1] = str_pool[sp_ptr];
          END
          sp_ptr = str_start[pop_lit2];
          sp_end = str_start[pop_lit2 + 1];
          while (sp_ptr < sp_end)
          BEGIN
            APPEND_CHAR (str_pool[sp_ptr]);
            INCR (sp_ptr);
          END
          pool_ptr = pool_ptr + sp_length;
          push_lit_stk (make_string (), STK_STR);
        END
      END
      else

/***************************************************************************
 * WEB section number:	353
 * ~~~~~~~~~~~~~~~~~~~
 * Again, we simply continue the previous module.
 ***************************************************************************/
      BEGIN
        if (LENGTH (pop_lit1) == 0)
        BEGIN
          INCR (lit_stk_ptr);
        END
        else if (LENGTH (pop_lit2) == 0)
        BEGIN
          push_lit_stk (pop_lit1, STK_STR);
        END
        else
        BEGIN
	  STR_ROOM (LENGTH (pop_lit1) + LENGTH (pop_lit2));
          sp_ptr = str_start[pop_lit2];
          sp_end = str_start[pop_lit2 + 1];
          while (sp_ptr < sp_end)
          BEGIN
	    APPEND_CHAR (str_pool[sp_ptr]);
            INCR (sp_ptr);
          END
          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
          push_lit_stk (make_string (), STK_STR);
        END
      END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 353 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 352 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

  END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 351 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 350 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 379
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function duplicate$ pops the top literal from
 * the stack and pushes two copies of it.
 ***************************************************************************/
void          x_duplicate (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  if (pop_typ1 != STK_STR)
  BEGIN
    push_lit_stk (pop_lit1, pop_typ1);
    push_lit_stk (pop_lit1, pop_typ1);
  END
  else
  BEGIN
    REPUSH_STRING;
    if (pop_lit1 < cmd_str_ptr)
    BEGIN
      push_lit_stk (pop_lit1, pop_typ1);
    END
    else
    BEGIN
      STR_ROOM (LENGTH (pop_lit1));
      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
      push_lit_stk (make_string (), STK_STR);
    END
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 379 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 380
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function empty$ pops the top literal and pushes
 * the integer 1 if it's a missing field or a string having no
 * non|white_space| characters, 0 otherwise.  If the literal isn't a
 * missing field or a string, it complains and pushes 0.
 ***************************************************************************/
void          x_empty (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  switch (pop_typ1)
  BEGIN
    case STK_STR:

/***************************************************************************
 * WEB section number:	381
 * ~~~~~~~~~~~~~~~~~~~
 * When we arrive here we're dealing with a legitimate string.  If it has
 * no characters, or has nothing but |white_space| characters, we push~1,
 * otherwise we push~0.
 ***************************************************************************/
      BEGIN
	sp_ptr = str_start[pop_lit1];
	sp_end = str_start[pop_lit1 + 1];
	while (sp_ptr < sp_end)
	BEGIN
	  if (lex_class[str_pool[sp_ptr]] != WHITE_SPACE)
	  BEGIN
	    push_lit_stk (0, STK_INT);
	    goto Exit_Label;
	  END
	  INCR (sp_ptr);
	END
	push_lit_stk (1, STK_INT);
      END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 381 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

      break;
    case STK_FIELD_MISSING:
      push_lit_stk (1, STK_INT);
      break;
    case STK_EMPTY:
      push_lit_stk (0, STK_INT);
      break;
    default:
      print_stk_lit (pop_lit1, pop_typ1);
      BST_EX_WARN (", not a string or missing field,");
      push_lit_stk (0, STK_INT);
      break;
  END
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 380 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 345
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function = pops the top two (integer or string)
 * literals, compares them, and pushes the integer 1 if they're equal, 0
 * otherwise.  If they're not either both string or both integer, it
 * complains and pushes the integer 0.
 ***************************************************************************/
void          x_equals (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  if (pop_typ1 != pop_typ2)
  BEGIN
    if ((pop_typ1 != STK_EMPTY) && (pop_typ2 != STK_EMPTY))
    BEGIN
      print_stk_lit (pop_lit1, pop_typ1);
      PRINT (", ");
      print_stk_lit (pop_lit2, pop_typ2);
      PRINT_NEWLINE;
      BST_EX_WARN ("---they aren't the same literal types");
    END
    push_lit_stk (0, STK_INT);
  END
  else if ((pop_typ1 != STK_INT) && (pop_typ1 != STK_STR))
  BEGIN
    if (pop_typ1 != STK_EMPTY)
    BEGIN
      print_stk_lit (pop_lit1, pop_typ1);
      BST_EX_WARN (", not an integer or a string,");
    END
    push_lit_stk (0, STK_INT);
  END
  else if (pop_typ1 == STK_INT)
  BEGIN
    if (pop_lit2 == pop_lit1)
    BEGIN
      push_lit_stk (1, STK_INT);
    END
    else
    BEGIN
      push_lit_stk (0, STK_INT);
    END
  END
  else if (str_eq_str (pop_lit2, pop_lit1))
  BEGIN
    push_lit_stk (1, STK_INT);
  END
  else
  BEGIN
    push_lit_stk (0, STK_INT);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 345 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 382
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function format.name$ pops the top three
 * literals (they are a string, an integer, and a string literal, in that
 * order).  The last string literal represents a name list (each name
 * corresponding to a person), the integer literal specifies which name
 * to pick from this list, and the first string literal specifies how to
 * format this name, as described in the \BibTeX\ documentation.
 * Finally, this function pushes the formatted name.  If any of the types
 * is incorrect, it complains and pushes the null string.
 ***************************************************************************/
void          x_format_name (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  pop_lit_stk (&pop_lit3, &pop_typ3);
  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 (pop_typ2 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT);
    push_lit_stk (s_null, STK_STR);
  END
  else if (pop_typ3 != STK_STR)
  BEGIN
    print_wrong_stk_lit (pop_lit3, pop_typ3, STK_STR);
    push_lit_stk (s_null, STK_STR);
  END
  else
  BEGIN
    ex_buf_length = 0;
    add_buf_pool (pop_lit3);

/***************************************************************************
 * WEB section number:	383
 * ~~~~~~~~~~~~~~~~~~~
 * This module skips over undesired names in |pop_lit3| and it throws
 * away the ``and'' from the end of the name if it exists.  When it's
 * done, |ex_buf_xptr| points to its first character and |ex_buf_ptr|
 * points just past its last.
 ***************************************************************************/
    BEGIN
      ex_buf_ptr = 0;
      num_names = 0;
      while ((num_names < pop_lit2) && (ex_buf_ptr < ex_buf_length))
      BEGIN
	INCR (num_names);
	ex_buf_xptr = ex_buf_ptr;
	name_scan_for_and (pop_lit3);
      END
      if (ex_buf_ptr < ex_buf_length)
      BEGIN
#ifdef UTF_8
        if (ex_buf[ex_buf_ptr-3]==0xE3 || ex_buf[ex_buf_ptr-3]==0xEF)
          /* expect U+3001 "、" or U+FF0C "," :: Ideographic/Fulwidth Comma */
          ex_buf_ptr = ex_buf_ptr - 3;
        else
          /* expect "and " or "AND " */
#endif
        ex_buf_ptr = ex_buf_ptr - 4;
      END
      if (num_names < pop_lit2)
      BEGIN
	if (pop_lit2 == 1)
	BEGIN
	  PRINT ("There is no name in \"");
	END
	else
	BEGIN
	  PRINT2 ("There aren't %ld names in \"", (long) pop_lit2);
	END
	PRINT_POOL_STR (pop_lit3);
	BST_EX_WARN ("\"");
      END
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 383 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/


/***************************************************************************
 * WEB section number:	387
 * ~~~~~~~~~~~~~~~~~~~
 * When we arrive here, the desired name is in |ex_buf[ex_buf_xptr]|
 * through |ex_buf[ex_buf_ptr-1]|.  This module does its thing for
 * characters only at |brace_level = 0|; the rest get processed verbatim.
 * It removes leading |white_space| (and |sep_char|s), and trailing
 * |white_space| (and |sep_char|s) and |comma|s, complaining for each
 * trailing |comma|.  It then copies the name into |name_buf|, removing
 * all |white_space|, |sep_char|s and |comma|s, counting |comma|s, and
 * constructing a list of name tokens, which are sequences of characters
 * separated (at |brace_level=0|) by |white_space|, |sep_char|s or
 * |comma|s.  Each name token but the first has an associated
 * |name_sep_char|, the character that separates it from the preceding
 * token.  If there are too many (more than two) |comma|s, a complaint is
 * in order.
 ***************************************************************************/
    BEGIN
/***************************************************************************
 * WEB section number:	388
 * ~~~~~~~~~~~~~~~~~~~
 * This module removes all leading |white_space| (and |sep_char|s), and
 * trailing |white_space| (and |sep_char|s) and |comma|s.  It complains
 * for each trailing |comma|.
 ***************************************************************************/
      BEGIN
	while ((ex_buf_xptr < ex_buf_ptr)
		&& (lex_class[ex_buf[ex_buf_ptr]] == WHITE_SPACE)
		&& (lex_class[ex_buf[ex_buf_ptr]] == SEP_CHAR))
	BEGIN
	  INCR (ex_buf_xptr);
	END
	while (ex_buf_ptr > ex_buf_xptr)
	BEGIN
	  switch (lex_class[ex_buf[ex_buf_ptr - 1]])
	  BEGIN
	    case WHITE_SPACE:
	    case SEP_CHAR:
	      DECR (ex_buf_ptr);
	      break;
	    default:
	      if (ex_buf[ex_buf_ptr - 1] == COMMA)
	      BEGIN
		PRINT2 ("Name %ld in \"", (long) pop_lit2);
		PRINT_POOL_STR (pop_lit3);
		PRINT ("\" has a comma at the end");
		bst_ex_warn_print ();
		DECR (ex_buf_ptr);
	      END
	      else
	      BEGIN
		goto Loop1_Exit_Label;
	      END
	      break;
	  END
	END
Loop1_Exit_Label:  DO_NOTHING;
      END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 388 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

      name_bf_ptr = 0;
      num_commas = 0;
      num_tokens = 0;
      token_starting = TRUE;
      while (ex_buf_xptr < ex_buf_ptr)
      BEGIN
	switch (ex_buf[ex_buf_xptr])
	BEGIN
	  case COMMA:

/***************************************************************************
 * WEB section number:	389
 * ~~~~~~~~~~~~~~~~~~~
 * Here we mark the token number at which this comma has occurred.
 ***************************************************************************/
	    BEGIN
	      if (num_commas == 2)
	      BEGIN
		PRINT2 ("Too many commas in name %ld of \"", (long) pop_lit2);
		PRINT_POOL_STR (pop_lit3);
		PRINT ("\"");
		bst_ex_warn_print ();
	      END
	      else
	      BEGIN
		INCR (num_commas);
		if (num_commas == 1)
		BEGIN
		  comma1 = num_tokens;
		END
		else
		BEGIN
		  comma2 = num_tokens;
		END
		name_sep_char[num_tokens] = COMMA;
	      END
	      INCR (ex_buf_xptr);
	      token_starting = TRUE;
	    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 389 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

	    break;
	  case LEFT_BRACE:

/***************************************************************************
 * WEB section number:	390
 * ~~~~~~~~~~~~~~~~~~~
 * We copy the stuff up through the matching |right_brace| verbatim.
 ***************************************************************************/
	    BEGIN
	      INCR (brace_level);
	      if (token_starting)
	      BEGIN
		name_tok[num_tokens] = name_bf_ptr;
		INCR (num_tokens);
	      END
	      NAME_BUF[name_bf_ptr] = ex_buf[ex_buf_xptr];
	      INCR (name_bf_ptr);
	      INCR (ex_buf_xptr);
	      while ((brace_level > 0) && (ex_buf_xptr < ex_buf_ptr))
	      BEGIN
		if (ex_buf[ex_buf_xptr] == RIGHT_BRACE)
		BEGIN
		  DECR (brace_level);
		END
		else if (ex_buf[ex_buf_xptr] == LEFT_BRACE)
		BEGIN
		  INCR (brace_level);
		END
		NAME_BUF[name_bf_ptr] = ex_buf[ex_buf_xptr];
		INCR (name_bf_ptr);
		INCR (ex_buf_xptr);
	      END
	      token_starting = FALSE;
	    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 390 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

	    break;
	  case RIGHT_BRACE:

/***************************************************************************
 * WEB section number:	391
 * ~~~~~~~~~~~~~~~~~~~
 * We don't copy an extra |right_brace|; this code will almost never be
 * executed.
 ***************************************************************************/
	    BEGIN
	      if (token_starting)
	      BEGIN
		name_tok[num_tokens] = name_bf_ptr;
		INCR (num_tokens);
	      END
	      PRINT2 ("Name %ld of \"", (long) pop_lit2);
	      PRINT_POOL_STR (pop_lit3);
	      BST_EX_WARN ("\" isn't brace balanced");
	      INCR (ex_buf_xptr);
	      token_starting = FALSE;
	    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 391 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

	    break;
	  default:
	    switch (lex_class[ex_buf[ex_buf_xptr]])
	    BEGIN
	      case WHITE_SPACE:

/***************************************************************************
 * WEB section number:	392
 * ~~~~~~~~~~~~~~~~~~~
 * A token will be starting soon in a buffer near you, one way$\ldots$
 ***************************************************************************/
		BEGIN
		  if ( ! token_starting)
		  BEGIN
		    name_sep_char[num_tokens] = SPACE;
		  END
		  INCR (ex_buf_xptr);
		  token_starting = TRUE;
		END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 392 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

		break;
	      case SEP_CHAR:

/***************************************************************************
 * WEB section number:	393
 * ~~~~~~~~~~~~~~~~~~~
 * or another.  If one of the valid |sep_char|s appears between tokens,
 * we usually use it instead of a |space|.  If the user has been silly
 * enough to have multiple |sep_char|s, or to have both |white_space| and
 * a |sep_char|, we use the first such character.
 ***************************************************************************/
		BEGIN
		  if ( ! token_starting)
		  BEGIN
		    name_sep_char[num_tokens] = ex_buf[ex_buf_xptr];
		  END
		  INCR (ex_buf_xptr);
		  token_starting = TRUE;
		END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 393 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

		break;
	      default:

/***************************************************************************
 * WEB section number:	394
 * ~~~~~~~~~~~~~~~~~~~
 * For ordinary characters, we just copy the character.
 ***************************************************************************/
		BEGIN
		  if (token_starting)
		  BEGIN
		    name_tok[num_tokens] = name_bf_ptr;
		    INCR (num_tokens);
		  END
		  NAME_BUF[name_bf_ptr] = ex_buf[ex_buf_xptr];
		  INCR (name_bf_ptr);
		  INCR (ex_buf_xptr);
		  token_starting = FALSE;
		END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 394 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

		break;
	    END
	    break;
	END
      END
      name_tok[num_tokens] = name_bf_ptr;
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 387 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

/***************************************************************************
 * WEB section number:	395
 * ~~~~~~~~~~~~~~~~~~~
 * Here we set all the pointers for the various parts of the name,
 * depending on which of the three possible syntaxes this name uses.
 ***************************************************************************/
    BEGIN
      if (num_commas == 0)
      BEGIN
	first_start = 0;
	last_end = num_tokens;
	jr_end = last_end;

  /***************************************************************************
   * WEB section number:	396
   * ~~~~~~~~~~~~~~~~~~~
   * When there are no brace-level-0 |comma|s in the name, the von name
   * starts with the first nonlast token whose first brace-level-0 letter
   * is in lower case (for the purposes of this determination, an accented
   * or foreign character at brace-level-1 that's in lower case will do, as
   * well).  A module following this one determines where the von name ends
   * and the last starts.
   ***************************************************************************/
	BEGIN
	  von_start = 0;
	  while (von_start < (last_end - 1))
	  BEGIN
	    name_bf_ptr = name_tok[von_start];
	    name_bf_xptr = name_tok[von_start + 1];
	    if (von_token_found ())
	    BEGIN
	      von_name_ends_and_last_name_sta ();
	      goto Von_Found_Label;
	    END
	    INCR (von_start);
	  END
	  while (von_start > 0)
	  BEGIN
	    if ((lex_class[name_sep_char[von_start]] != SEP_CHAR)
		  || (name_sep_char[von_start] == TIE))
	    BEGIN
	      goto Loop2_Exit_Label;
	    END
	    DECR (von_start);
	  END
  Loop2_Exit_Label:  von_end = von_start;
  Von_Found_Label:  first_end = von_start;
	END
  /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 396 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

      END
      else if (num_commas == 1)
      BEGIN
	von_start = 0;
	last_end = comma1;
	jr_end = last_end;
	first_start = jr_end;
	first_end = num_tokens;
	von_name_ends_and_last_name_sta ();
      END
      else if (num_commas == 2)
      BEGIN
	von_start = 0;
	last_end = comma1;
	jr_end = comma2;
	first_start = jr_end;
	first_end = num_tokens;
	von_name_ends_and_last_name_sta ();
      END
      else
      BEGIN
	CONFUSION ("Illegal number of comma,s");
      END
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 395 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

    ex_buf_length = 0;
    add_buf_pool (pop_lit1);
    figure_out_the_formatted_name ();
    add_pool_buf_and_push ();
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 382 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 354
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function := pops the top two literals and assigns
 * to the first (which must be an |int_entry_var|, a |str_entry_var|, an
 * |int_global_var|, or a |str_global_var|) the value of the second;
 * it complains if the value isn't of the appropriate type.
 ***************************************************************************/
void          x_gets (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  if (pop_typ1 != STK_FN)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_FN);
  END
  else if (( ! mess_with_entries)
	    && ((fn_type[pop_lit1] == STR_ENTRY_VAR)
		    || (fn_type[pop_lit1] == INT_ENTRY_VAR)))
  BEGIN
    bst_cant_mess_with_entries_prin ();
  END
  else
  BEGIN
    switch (fn_type[pop_lit1])
    BEGIN
      case INT_ENTRY_VAR:

/***************************************************************************
 * WEB section number:	355
 * ~~~~~~~~~~~~~~~~~~~
 * This module checks that what we're about to assign is really an
 * integer, and then assigns.
 ***************************************************************************/
        if (pop_typ2 != STK_INT)
        BEGIN
          print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT);
        END
        else
        BEGIN
          entry_ints[(cite_ptr * num_ent_ints) + FN_INFO[pop_lit1]] = pop_lit2;
        END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 355 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

        break;
      case STR_ENTRY_VAR:

/***************************************************************************
 * WEB section number:	357
 * ~~~~~~~~~~~~~~~~~~~
 * This module checks that what we're about to assign is really a
 * string, and then assigns.
 ***************************************************************************/
	BEGIN
	  if (pop_typ2 != STK_STR)
	  BEGIN
	    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR);
	  END
	  else
	  BEGIN
	    str_ent_ptr = (cite_ptr * num_ent_strs) + FN_INFO[pop_lit1];
	    ent_chr_ptr = 0;
	    sp_ptr = str_start[pop_lit2];
	    sp_xptr1 = str_start[pop_lit2 + 1];
	    if ((sp_xptr1 - sp_ptr) > Ent_Str_Size)
	    BEGIN
	      BST_STRING_SIZE_EXCEEDED (Ent_Str_Size, ", the entry");
	      sp_xptr1 = sp_ptr + Ent_Str_Size;
	    END
	    while (sp_ptr < sp_xptr1)
	    BEGIN
	      ENTRY_STRS(str_ent_ptr, ent_chr_ptr) = str_pool[sp_ptr];
	      INCR (ent_chr_ptr);
	      INCR (sp_ptr);
	    END
	    ENTRY_STRS(str_ent_ptr, ent_chr_ptr) = END_OF_STRING;
	  END
	END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 357 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

        break;
      case INT_GLOBAL_VAR:

/***************************************************************************
 * WEB section number:	358
 * ~~~~~~~~~~~~~~~~~~~
 * This module checks that what we're about to assign is really an
 * integer, and then assigns.
 ***************************************************************************/
        if (pop_typ2 != STK_INT)
        BEGIN
          print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT);
        END
        else
        BEGIN
          FN_INFO[pop_lit1] = pop_lit2;
        END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 358 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

        break;
      case STR_GLOBAL_VAR:

/***************************************************************************
 * WEB section number:	359
 * ~~~~~~~~~~~~~~~~~~~
 * This module checks that what we're about to assign is really a
 * string, and then assigns.
 ***************************************************************************/
	BEGIN
	  if (pop_typ2 != STK_STR)
	  BEGIN
	    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR);
	  END
	  else
	  BEGIN
	    str_glb_ptr = FN_INFO[pop_lit1];
	    if (pop_lit2 < cmd_str_ptr)
	    BEGIN
	      glb_str_ptr[str_glb_ptr] = pop_lit2;
	    END
	    else
	    BEGIN
	      glb_str_ptr[str_glb_ptr] = 0;
	      glob_chr_ptr = 0;
	      sp_ptr = str_start[pop_lit2];
	      sp_end = str_start[pop_lit2 + 1];
	      if ((sp_end - sp_ptr) > Glob_Str_Size)
	      BEGIN
		BST_STRING_SIZE_EXCEEDED (Glob_Str_Size, ", the global");
		sp_end = sp_ptr + Glob_Str_Size;
	      END
	      while (sp_ptr < sp_end)
	      BEGIN
		GLOBAL_STRS(str_glb_ptr, glob_chr_ptr) = str_pool[sp_ptr];
		INCR (glob_chr_ptr);
		INCR (sp_ptr);
	      END
	      glb_str_end[str_glb_ptr] = glob_chr_ptr;
	    END
	  END
	END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 359 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

        break;
      default:
        PRINT ("You can't assign to type ");
        print_fn_class (pop_lit1);
        BST_EX_WARN (", a nonvariable function class");
        break;
    END
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 354 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 346
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function > pops the top two (integer) literals,
 * compares them, and pushes the integer 1 if the second is greater than
 * the first, 0 otherwise.  If either isn't an integer literal, it
 * complains and pushes the integer 0.
 ***************************************************************************/
void          x_greater_than (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  if (pop_typ1 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else if (pop_typ2 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else if (pop_lit2 > pop_lit1)
  BEGIN
    push_lit_stk (1, STK_INT);
  END
  else
  BEGIN
    push_lit_stk (0, STK_INT);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 346 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 422
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function int.to.chr$ pops the top (integer)
 * literal, interpreted as the |ASCII_code| of a single character,
 * converts it to the corresponding single-character string, and pushes
 * this string.  If the literal isn't an appropriate integer, it
 * complains and pushes the null string.
 ***************************************************************************/
void          x_int_to_chr (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  if (pop_typ1 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
    push_lit_stk (s_null, STK_STR);
  END
#if UTF_8
  else if ((pop_lit1 < 0) || (pop_lit1 > LAST_UCS_CHAR))
#else
  else if ((pop_lit1 < 0) || (pop_lit1 > LAST_ASCII_CHAR))
#endif
  BEGIN
    BST_EX_WARN2 ("%ld isn't valid character code", (long) pop_lit1);
    push_lit_stk (s_null, STK_STR);
  END
  else
  BEGIN
    STR_ROOM (1);
#if UTF_8
    BEGIN
      UChar ch0[3] = {0};
      unsigned char ch1[5] = {0}, *ch;
      if (pop_lit1> 0xFFFF)
      BEGIN
        ch0[0] = U16_LEAD(pop_lit1);
        ch0[1] = U16_TRAIL(pop_lit1);
      END
      else
        ch0[0] = pop_lit1;
      icu_fromUChars(ch1, 5, ch0, 3);
      ch=ch1;
      while(*ch)
      BEGIN
        APPEND_CHAR (*ch);
        INCR (ch);
      END
    END
#else
    APPEND_CHAR (pop_lit1);
#endif
    push_lit_stk (make_string (), STK_STR);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 422 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 423
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function int.to.str$ pops the top (integer)
 * literal, converts it to its (unique) string equivalent, and pushes
 * this string.  If the literal isn't an integer, it complains and pushes
 * the null string.
 ***************************************************************************/
void          x_int_to_str (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  if (pop_typ1 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
    push_lit_stk (s_null, STK_STR);
  END
  else
  BEGIN
    int_to_ASCII (pop_lit1, ex_buf, 0, &ex_buf_length);
    add_pool_buf_and_push ();
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 423 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 347
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function < pops the top two (integer) literals,
 * compares them, and pushes the integer 1 if the second is less than the
 * first, 0 otherwise.  If either isn't an integer literal, it complains
 * and pushes the integer 0.
 ***************************************************************************/
void          x_less_than (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  if (pop_typ1 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else if (pop_typ2 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else if (pop_lit2 < pop_lit1)
  BEGIN
    push_lit_stk (1, STK_INT);
  END
  else
  BEGIN
    push_lit_stk (0, STK_INT);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 347 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 349
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function - pops the top two (integer) literals
 * and pushes their difference (the first subtracted from the second).
 * If either isn't an integer literal, it complains and pushes the
 * integer 0.
 ***************************************************************************/
void          x_minus (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  if (pop_typ1 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else if (pop_typ2 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else
  BEGIN
    push_lit_stk (pop_lit2 - pop_lit1, STK_INT);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 349 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 424
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function missing$ pops the top literal and
 * pushes the integer 1 if it's a missing field, 0 otherwise.  If the
 * literal isn't a missing field or a string, it complains and pushes 0.
 * Unlike empty$ , this function should be called only when
 * |mess_with_entries| is true.
 ***************************************************************************/
void          x_missing (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  if ( ! mess_with_entries)
  BEGIN
    bst_cant_mess_with_entries_prin ();
  END
  else if ((pop_typ1 != STK_STR) && (pop_typ1 != STK_FIELD_MISSING))
  BEGIN
    if (pop_typ1 != STK_EMPTY)
    BEGIN
      print_stk_lit (pop_lit1, pop_typ1);
      BST_EX_WARN (", not a string or missing field,");
    END
    push_lit_stk (0, STK_INT);
  END
  else if (pop_typ1 == STK_FIELD_MISSING)
  BEGIN
    push_lit_stk (1, STK_INT);
  END
  else
  BEGIN
    push_lit_stk (0, STK_INT);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 424 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 426
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function num.names$  pops the top (string)
 * literal; it pushes the number of names the string represents---one
 * plus the number of occurrences of the substring ``and'' (ignoring case
 * differences) surrounded by nonnull |white_space| at the top brace
 * level.  If the literal isn't a string, it complains and pushes the
 * value 0.
 ***************************************************************************/
void          x_num_names (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 (0, STK_INT);
  END
  else
  BEGIN
    ex_buf_length = 0;
    add_buf_pool (pop_lit1);

/***************************************************************************
 * WEB section number:	427
 * ~~~~~~~~~~~~~~~~~~~
 * This module, while scanning the list of names, counts the occurrences
 * of ``and'' (ignoring case differences) surrounded by nonnull
 * |white_space|, and adds 1.
 ***************************************************************************/
    BEGIN
      ex_buf_ptr = 0;
      num_names = 0;
      while (ex_buf_ptr < ex_buf_length)
      BEGIN
        name_scan_for_and (pop_lit1);
        INCR (num_names);
      END
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 427 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

    push_lit_stk (num_names, STK_INT);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 426 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/



/***************************************************************************
 * WEB section number:	 348
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function + pops the top two (integer) literals
 * and pushes their sum.  If either isn't an integer literal, it
 * complains and pushes the integer 0.
 ***************************************************************************/
void          x_plus (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  if (pop_typ1 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else if (pop_typ2 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else
  BEGIN
    push_lit_stk (pop_lit2 + pop_lit1, STK_INT);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 348 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 429
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function preamble$ pushes onto the stack the
 * concatenation of all the preamble strings read from the database
 * files.
 ***************************************************************************/
void          x_preamble (void)
BEGIN
  ex_buf_length = 0;
  preamble_ptr = 0;
  while (preamble_ptr < num_preamble_strings)
  BEGIN
    add_buf_pool (s_preamble[preamble_ptr]);
    INCR (preamble_ptr);
  END
  add_pool_buf_and_push ();
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 429 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 430
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function purify$ pops the top (string) literal,
 * removes nonalphanumeric characters except for |white_space| and
 * |sep_char| characters (these get converted to a |space|) and removes
 * certain alphabetic characters contained in the control sequences
 * associated with a special character, and pushes the resulting string.
 * If the literal isn't a string, it complains and pushes the null
 * string.
 ***************************************************************************/
void          x_purify (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
  BEGIN
    ex_buf_length = 0;
    add_buf_pool (pop_lit1);

/***************************************************************************
 * WEB section number:	431
 * ~~~~~~~~~~~~~~~~~~~
 * The resulting string has nonalphanumeric characters removed, and each
 * |white_space| or |sep_char| character converted to a |space|.  The next
 * module handles special characters.  This code doesn't complain if the
 * string isn't brace balanced.
 ***************************************************************************/
    BEGIN
      brace_level = 0;
      ex_buf_xptr = 0;
      ex_buf_ptr = 0;
      while (ex_buf_ptr < ex_buf_length)
      BEGIN
        switch (lex_class[ex_buf[ex_buf_ptr]])
        BEGIN
          case WHITE_SPACE:
          case SEP_CHAR:
	    BEGIN
              ex_buf[ex_buf_xptr] = SPACE;
              INCR (ex_buf_xptr);
            END
	    break;
          case ALPHA:
          case NUMERIC:
            BEGIN
#ifdef UTF_8
/*
When we processe the character UTF-8, the length has been changed. This focntion is used in
quick_sort.                                                                   23/sep/2009
*/
              DO_UTF8(ex_buf[ex_buf_ptr],
                ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr];
                ex_buf_xptr += 1,
                ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr];
                ex_buf[ex_buf_xptr+1] = ex_buf[ex_buf_ptr+1];
                ex_buf_xptr += 2; ex_buf_ptr += 1,
                ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr];
                ex_buf[ex_buf_xptr+1] = ex_buf[ex_buf_ptr+1];
                ex_buf[ex_buf_xptr+2] = ex_buf[ex_buf_ptr+2];
                ex_buf_xptr += 3; ex_buf_ptr += 2,
                ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr];
                ex_buf[ex_buf_xptr+1] = ex_buf[ex_buf_ptr+1];
                ex_buf[ex_buf_xptr+2] = ex_buf[ex_buf_ptr+2];
                ex_buf[ex_buf_xptr+3] = ex_buf[ex_buf_ptr+3];
                ex_buf_xptr += 4; ex_buf_ptr += 3);
#else
              ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr];
              INCR (ex_buf_xptr);
#endif
            END
            break;
          default:
            if (ex_buf[ex_buf_ptr] == LEFT_BRACE)
            BEGIN
              INCR (brace_level);
              if ((brace_level == 1) && ((ex_buf_ptr + 1) < ex_buf_length))
              BEGIN
	        if (ex_buf[ex_buf_ptr + 1] == BACKSLASH)

/***************************************************************************
 * WEB section number:	432
 * ~~~~~~~~~~~~~~~~~~~
 * Special characters (even without a matching |right_brace|) are
 * purified by removing the control sequences (but restoring the correct
 * thing for `\i' and `\j' as well as the eleven alphabetic
 * foreign characters in Table~3.2 of the \LaTeX\ manual) and removing
 * all nonalphanumeric characters (including |white_space| and
 * |sep_char|s).
 ***************************************************************************/
                BEGIN
                  INCR (ex_buf_ptr);
                  while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0))
                  BEGIN
                    INCR (ex_buf_ptr);
                    ex_buf_yptr = ex_buf_ptr;
                    while ((ex_buf_ptr < ex_buf_length)
			    && (lex_class[ex_buf[ex_buf_ptr]] == ALPHA))
                    BEGIN
                      INCR (ex_buf_ptr);
                    END
                    control_seq_loc = str_lookup (ex_buf, ex_buf_yptr,
						  ex_buf_ptr - ex_buf_yptr,
						  CONTROL_SEQ_ILK,
						  DONT_INSERT);
                    if (hash_found)

/***************************************************************************
 * WEB section number:	433
 * ~~~~~~~~~~~~~~~~~~~
 * We consider the purified character to be either the first alphabetic
 * character of its control sequence, or perhaps both alphabetic
 * characters.
 ***************************************************************************/
                    BEGIN
                      ex_buf[ex_buf_xptr] = ex_buf[ex_buf_yptr];
                      INCR (ex_buf_xptr);
                      switch (ilk_info[control_seq_loc])
                      BEGIN
                        case N_OE:
                        case N_OE_UPPER:
                        case N_AE:
                        case N_AE_UPPER:
                        case N_SS:
                          BEGIN
			    ex_buf[ex_buf_xptr] = ex_buf[ex_buf_yptr + 1];
                            INCR (ex_buf_xptr);
			  END
                          break;
                        default:
                          DO_NOTHING;
                          break;
                      END
                    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 433 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

                    while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0)
			    && (ex_buf[ex_buf_ptr] != BACKSLASH))
                    BEGIN
                      switch (lex_class[ex_buf[ex_buf_ptr]])
                      BEGIN
                        case ALPHA:
                        case NUMERIC:
                          BEGIN
			    ex_buf[ex_buf_xptr] = ex_buf[ex_buf_ptr];
                            INCR (ex_buf_xptr);
                          END
			  break;
                        default:
                          if (ex_buf[ex_buf_ptr] == RIGHT_BRACE)
                          BEGIN
                            DECR (brace_level);
                          END
                          else if (ex_buf[ex_buf_ptr] == LEFT_BRACE)
                          BEGIN
                            INCR (brace_level);
                          END
                          break;
                      END
                      INCR (ex_buf_ptr);
                    END
                  END
                  DECR (ex_buf_ptr);
                END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 432 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

              END
            END
            else if (ex_buf[ex_buf_ptr] == RIGHT_BRACE)
            BEGIN
              if (brace_level > 0)
              BEGIN
                DECR (brace_level);
              END
            END
            break;
        END
        INCR (ex_buf_ptr);
      END
      ex_buf_length = ex_buf_xptr;
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 431 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

    add_pool_buf_and_push ();
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 430 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/



/***************************************************************************
 * WEB section number:	 434
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function quote$ pushes the string consisting of
 * the |double_quote| character.
 ***************************************************************************/
void          x_quote (void)
BEGIN
  STR_ROOM (1);
  APPEND_CHAR (DOUBLE_QUOTE);
  push_lit_stk (make_string (), STK_STR);
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 434 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/


/***************************************************************************
 * WEB section number:	 437
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function substring$ pops the top three literals
 * (they are the two integers literals |pop_lit1| and |pop_lit2| and a
 * string literal, in that order).  It pushes the substring of the (at
 * most) |pop_lit1| consecutive characters starting at the |pop_lit2|th
 * character (assuming 1-based indexing) if |pop_lit2| is positive, and
 * ending at the |-pop_lit2|th character from the end if |pop_lit2| is
 * negative (where the first character from the end is the last
 * character).  If any of the types is incorrect, it complain and pushes
 * the null string.
 *
 * Note: If |sp_length| is compared with a signed quantity (e.g. pop_lit2),
 * must be first cast to |Integer_T| because it is an UNSIGNED variable.
 ***************************************************************************/
void          x_substring (void)
BEGIN

  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  pop_lit_stk (&pop_lit3, &pop_typ3);
  if (pop_typ1 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
    push_lit_stk (s_null, STK_STR);
  END
  else if (pop_typ2 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT);
    push_lit_stk (s_null, STK_STR);
  END
  else if (pop_typ3 != STK_STR)
  BEGIN
    print_wrong_stk_lit (pop_lit3, pop_typ3, STK_STR);
    push_lit_stk (s_null, STK_STR);
  END
  else
  BEGIN
#ifdef UTF_8
/*
This is a new code of x_substring for processing the character UTF-8.
We transform the character to Unicode and then get the substring, then 
back to UTF-8. 23/sep/2009
*/
    Integer_T str_length = LENGTH (pop_lit3);
    UChar32 uchs[BUF_SIZE+1];
    UChar uch16[BUF_SIZE+1];
    int32_t utcap = BUF_SIZE+1;
    int32_t ulen;
    unsigned char frUch1[BUF_SIZE+1];
    unsigned char frUch2[BUF_SIZE+1];
    int32_t frUchCap = BUF_SIZE + 1;
    int32_t lenfrUch;
    int32_t ptrfrUch;

    ulen = icu_toUChar32s(str_pool,str_start[pop_lit3],str_length,uchs,utcap,uch16);
    sp_length = ulen;
#else
    sp_length = LENGTH (pop_lit3);
#endif
    if (pop_lit1 >= (Integer_T) sp_length)
    BEGIN
      if ((pop_lit2 == 1) || (pop_lit2 == -1))
      BEGIN
        REPUSH_STRING;
        goto Exit_Label;
      END
    END

    if ((pop_lit1 <= 0) || (pop_lit2 == 0)
            || (pop_lit2 > (Integer_T) sp_length)
            || (pop_lit2 < -(Integer_T) sp_length))
    BEGIN
      push_lit_stk (s_null, STK_STR);
      goto Exit_Label;
    END
    else

/***************************************************************************
 * WEB section number:	438
 * ~~~~~~~~~~~~~~~~~~~
 * This module finds the substring as described in the last section,
 * and slides it into place in the string pool, if necessary.
 ***************************************************************************/
    BEGIN
      if (pop_lit2 > 0)
      BEGIN
        if (pop_lit1 > (sp_length - (pop_lit2 - 1)))
        BEGIN
          pop_lit1 = sp_length - (pop_lit2 - 1);
        END
#ifdef UTF_8
        lenfrUch = icu_fromUChar32s(frUch1, frUchCap, &uchs[pop_lit2-1], pop_lit1, uch16);
        ptrfrUch = icu_fromUChar32s(frUch2, frUchCap, uchs, pop_lit2-1, uch16);
        sp_ptr = str_start[pop_lit3] + ptrfrUch;
        sp_end = sp_ptr + lenfrUch;
#else
        sp_ptr = str_start[pop_lit3] + (pop_lit2 - 1);
        sp_end = sp_ptr + pop_lit1;
#endif
        if (pop_lit2 == 1)
        BEGIN
          if (pop_lit3 >= cmd_str_ptr)
          BEGIN
            str_start[pop_lit3 + 1] = sp_end;
            UNFLUSH_STRING;
            INCR (lit_stk_ptr);
            goto Exit_Label;
          END
        END
      END
      else
      BEGIN
        pop_lit2 = -pop_lit2;
        if (pop_lit1 > (Integer_T) (sp_length - (pop_lit2 - 1)))
        BEGIN
          pop_lit1 = sp_length - (pop_lit2 - 1);
        END
#ifdef UTF_8
        lenfrUch = icu_fromUChar32s(frUch1, frUchCap, &uchs[ulen - (pop_lit2-1) - pop_lit1], pop_lit1, uch16);
        ptrfrUch = icu_fromUChar32s(frUch2, frUchCap, uchs, ulen - (pop_lit2-1) - pop_lit1, uch16);
        sp_ptr = str_start[pop_lit3] + ptrfrUch;
        sp_end = sp_ptr + lenfrUch;
#else
        sp_end = str_start[pop_lit3 + 1] - (pop_lit2 - 1);
        sp_ptr = sp_end - pop_lit1;
#endif
      END
      STR_ROOM (sp_end - sp_ptr);
      while (sp_ptr < sp_end)
      BEGIN
        APPEND_CHAR (str_pool[sp_ptr]);
        INCR (sp_ptr);
      END
      push_lit_stk (make_string (), STK_STR);
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 438 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

  END
Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 437 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/



/***************************************************************************
 * WEB section number:	 439
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function swap$ pops the top two literals from
 * the stack and pushes them back swapped.
 ***************************************************************************/
void          x_swap (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  if ((pop_typ1 != STK_STR) || (pop_lit1 < cmd_str_ptr))
  BEGIN
    push_lit_stk (pop_lit1, pop_typ1);
    if ((pop_typ2 == STK_STR) && (pop_lit2 >= cmd_str_ptr))
    BEGIN
      UNFLUSH_STRING;
    END
    push_lit_stk (pop_lit2, pop_typ2);
  END
  else if ((pop_typ2 != STK_STR) || (pop_lit2 < cmd_str_ptr))
  BEGIN
    UNFLUSH_STRING;
    push_lit_stk (pop_lit1, STK_STR);
    push_lit_stk (pop_lit2, pop_typ2);
  END
  else

/***************************************************************************
 * WEB section number:	440
 * ~~~~~~~~~~~~~~~~~~~
 * We have to swap both (a)~the strings at the end of the string pool,
 * and (b)~their pointers on the literal stack.
 ***************************************************************************/
  BEGIN
    ex_buf_length = 0;
    add_buf_pool (pop_lit2);
    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
    push_lit_stk (make_string (), STK_STR);
    add_pool_buf_and_push ();
  END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 440 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 439 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/



/***************************************************************************
 * WEB section number:	 441
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function text.length$ pops the top (string)
 * literal, and pushes the number of text characters it contains, where
 * an accented character (more precisely, a ``special character''$\!$,
 * defined earlier) counts as a single text character, even if it's
 * missing its matching |right_brace|, and where braces don't count as
 * text characters.  If the literal isn't a string, it complains and
 * pushes the null string.
 ***************************************************************************/
void          x_text_length (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
  BEGIN
    num_text_chars = 0;

/***************************************************************************
 * WEB section number:	442
 * ~~~~~~~~~~~~~~~~~~~
 * Here we determine the number of text characters in the string, where
 * an entire special character counts as a single text character (even if
 * it's missing its matching |right_brace|), and where braces don't count
 * as text characters.
 ***************************************************************************/
    BEGIN
      sp_ptr = str_start[pop_lit1];
      sp_end = str_start[pop_lit1 + 1];
      sp_brace_level = 0;
      while (sp_ptr < sp_end)
      BEGIN
        INCR (sp_ptr);
        if (str_pool[sp_ptr - 1] == LEFT_BRACE)
        BEGIN
          INCR (sp_brace_level);
          if ((sp_brace_level == 1) && (sp_ptr < sp_end))
          BEGIN
            if (str_pool[sp_ptr] == BACKSLASH)
            BEGIN
              INCR (sp_ptr);
              while ((sp_ptr < sp_end) && (sp_brace_level > 0))
              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
#ifdef UTF_8
/*
The length of character of UTF-8 is different. 23/sep/2009
*/
              DO_UTF8(str_pool[sp_ptr-1], , sp_ptr++, sp_ptr += 2, sp_ptr += 3);
#endif
              INCR (num_text_chars);
            END
          END
        END
        else if (str_pool[sp_ptr - 1] == RIGHT_BRACE)
        BEGIN
          if (sp_brace_level > 0)
          BEGIN
            DECR (sp_brace_level);
          END
        END
        else
        BEGIN
#ifdef UTF_8
/*
The same for the length of character. 23/sep/2009
*/
          DO_UTF8(str_pool[sp_ptr-1], , sp_ptr++, sp_ptr += 2, sp_ptr += 3);
#endif
          INCR (num_text_chars);
        END
      END
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 442 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

    push_lit_stk (num_text_chars, STK_INT);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 441 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 443
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function text.prefix$ pops the top two literals
 * (the integer literal |pop_lit1| and a string literal, in that order).
 * It pushes the substring of the (at most) |pop_lit1| consecutive text
 * characters starting from the beginning of the string.  This function
 * is similar to substring$ , but this one considers an accented
 * character (or more precisely, a ``special character''$\!$, even if
 * it's missing its matching |right_brace|) to be a single text character
 * (rather than however many |ASCII_code| characters it actually
 * comprises), and this function doesn't consider braces to be text
 * characters; furthermore, this function appends any needed matching
 * |right_brace|s.  If any of the types is incorrect, it complains and
 * pushes the null string.
 ***************************************************************************/
void          x_text_prefix (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  if (pop_typ1 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
    push_lit_stk (s_null, STK_STR);
  END
  else if (pop_typ2 != STK_STR)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_STR);
    push_lit_stk (s_null, STK_STR);
  END
  else if (pop_lit1 <= 0)
  BEGIN
    push_lit_stk (s_null, STK_STR);
    goto Exit_Label;
  END
  else

/***************************************************************************
 * WEB section number:	444
 * ~~~~~~~~~~~~~~~~~~~
 * This module finds the prefix as described in the last section, and
 * appends any needed matching |right_brace|s.
 ***************************************************************************/
  BEGIN
    sp_ptr = str_start[pop_lit2];
    sp_end = str_start[pop_lit2 + 1];

/***************************************************************************
 * WEB section number:	445
 * ~~~~~~~~~~~~~~~~~~~
 * This section scans |pop_lit1| text characters, where an entire special
 * character counts as a single text character (even if it's missing its
 * matching |right_brace|), and where braces don't count as text
 * characters.
 ***************************************************************************/
    BEGIN
      num_text_chars = 0;
      sp_brace_level = 0;
      sp_xptr1 = sp_ptr;
      while ((sp_xptr1 < sp_end) && (num_text_chars < pop_lit1))
      BEGIN
        INCR (sp_xptr1);
        if (str_pool[sp_xptr1 - 1] == LEFT_BRACE)
        BEGIN
          INCR (sp_brace_level);
          if ((sp_brace_level == 1) && (sp_xptr1 < sp_end))
          BEGIN
            if (str_pool[sp_xptr1] == BACKSLASH)
            BEGIN
              INCR (sp_xptr1);
              while ((sp_xptr1 < sp_end) && (sp_brace_level > 0))
              BEGIN
                if (str_pool[sp_xptr1] == RIGHT_BRACE)
                BEGIN
                  DECR (sp_brace_level);
                END
                else if (str_pool[sp_xptr1] == LEFT_BRACE)
                BEGIN
                  INCR (sp_brace_level);
                END
                INCR (sp_xptr1);
              END
#ifdef UTF_8
/*
The same for the length of character UTF-8. 23/sep/2009
*/
              DO_UTF8(str_pool[sp_xptr1-1], , sp_xptr1++, sp_xptr1 += 2, sp_xptr1 += 3);
#endif
              INCR (num_text_chars);
            END
          END
        END
        else if (str_pool[sp_xptr1 - 1] == RIGHT_BRACE)
        BEGIN
          if (sp_brace_level > 0)
          BEGIN
            DECR (sp_brace_level);
          END
        END
        else
        BEGIN
#ifdef UTF_8
/*
The same for the length of character UTF-8. 23/sep/2009
*/
          DO_UTF8(str_pool[sp_xptr1-1], , sp_xptr1++, sp_xptr1 += 2, sp_xptr1 += 3);
#endif
          INCR (num_text_chars);
        END
      END
      sp_end = sp_xptr1;
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 445 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

    STR_ROOM (sp_brace_level + sp_end - sp_ptr);
    if (pop_lit2 >= cmd_str_ptr)
    BEGIN
      pool_ptr = sp_end;
    END
    else
    BEGIN
      while (sp_ptr < sp_end)
      BEGIN
	APPEND_CHAR (str_pool[sp_ptr]);
        INCR (sp_ptr);
      END
    END
    while (sp_brace_level > 0)
    BEGIN
      APPEND_CHAR (RIGHT_BRACE);
      DECR (sp_brace_level);
    END
    push_lit_stk (make_string (), STK_STR);
  END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 444 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

Exit_Label: DO_NOTHING;
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 443 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/



/***************************************************************************
 * WEB section number:	 447
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function type$ pushes the appropriate string
 * from |type_list| onto the stack (unless either it's |undefined| or
 * |empty|, in which case it pushes the null string).
 ***************************************************************************/
void          x_type (void)
BEGIN
  if ( ! mess_with_entries)
  BEGIN
    bst_cant_mess_with_entries_prin ();
  END
  else if ((type_list[cite_ptr] == UNDEFINED)
	    || (type_list[cite_ptr] == EMPTY))
  BEGIN
    push_lit_stk (s_null, STK_STR);
  END
  else
  BEGIN
    push_lit_stk (hash_text[type_list[cite_ptr]], STK_STR);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 447 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/




/***************************************************************************
 * WEB section number:	 448
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function warning$ pops the top (string) literal
 * and prints it following a warning message.  This is implemented as a
 * special |built_in| function rather than using the top$ function
 * so that it can |mark_warning|.
 ***************************************************************************/
void          x_warning (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);
  END
  else
  BEGIN
    PRINT ("Warning--");
    print_lit (pop_lit1, pop_typ1);
    mark_warning ();
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 448 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

#ifdef UTF_8
Integer_T    char_width_uni (ASCIICode_T * str)
BEGIN
  UChar32 ch;
  U8_GET_OR_FFFD(str, 0, 0, -1, ch);
  if (ch<=LAST_LATIN_CHAR)
    return ( char_width[ch] );
  else
  BEGIN
    switch ( u_getIntPropertyValue(ch, UCHAR_EAST_ASIAN_WIDTH) )
    BEGIN
    case U_EA_WIDE:
    case U_EA_FULLWIDTH:
        return ( 1000 );
    case U_EA_HALFWIDTH:
        return ( 500 );
    case U_EA_NARROW:
    case U_EA_NEUTRAL:
    case U_EA_AMBIGUOUS:
    default:
        return ( 700 );
    END
  END
END
#endif

/***************************************************************************
 * WEB section number:	 450
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function width$ pops the top (string) literal
 * and pushes the integer that represents its width in units specified by
 * the |char_width| array.  This function takes the literal literally;
 * that is, it assumes each character in the string is to be printed as
 * is, regardless of whether the character has a special meaning to \TeX,
 * except that special characters (even without their |right_brace|s) are
 * handled specially.  If the literal isn't a string, it complains and
 * pushes~0.
 ***************************************************************************/
void          x_width (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 (0, STK_INT);
  END
  else
  BEGIN
    ex_buf_length = 0;
    add_buf_pool (pop_lit1);
    string_width = 0;

/***************************************************************************
 * WEB section number:	451
 * ~~~~~~~~~~~~~~~~~~~
 * We use the natural width for all but special characters, and we
 * complain if the string isn't brace-balanced.
 ***************************************************************************/
    BEGIN
      brace_level = 0;
      ex_buf_ptr = 0;
      while (ex_buf_ptr < ex_buf_length)
      BEGIN
        if (ex_buf[ex_buf_ptr] == LEFT_BRACE)
        BEGIN
          INCR (brace_level);
          if ((brace_level == 1) && ((ex_buf_ptr + 1) < ex_buf_length))
          BEGIN
  	  if (ex_buf[ex_buf_ptr + 1] == BACKSLASH)

/***************************************************************************
 * WEB section number:	452
 * ~~~~~~~~~~~~~~~~~~~
 * We use the natural widths of all characters except that some
 * characters have no width: braces, control sequences (except for the
 * usual 13 accented and foreign characters, whose widths are given in
 * the next module), and |white_space| following control sequences (even
 * a null control sequence).
 ***************************************************************************/
            BEGIN
              INCR (ex_buf_ptr);
              while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0))
              BEGIN
                INCR (ex_buf_ptr);
                ex_buf_xptr = ex_buf_ptr;
                while ((ex_buf_ptr < ex_buf_length)
  			&& (lex_class[ex_buf[ex_buf_ptr]] == ALPHA))
                BEGIN
                  INCR (ex_buf_ptr);
                END
                if ((ex_buf_ptr < ex_buf_length)
		     && (ex_buf_ptr == ex_buf_xptr))
                BEGIN
                  INCR (ex_buf_ptr);
                END
                else
                BEGIN
                  control_seq_loc = str_lookup (ex_buf, ex_buf_xptr,
  					        ex_buf_ptr - ex_buf_xptr,
  					        CONTROL_SEQ_ILK, DONT_INSERT);
                  if (hash_found)

/***************************************************************************
 * WEB section number:	453
 * ~~~~~~~~~~~~~~~~~~~
 * Five of the 13 possibilities resort to special information not present
 * in the |char_width| array; the other eight simply use |char_width|'s
 * information for the first letter of the control sequence.
 ***************************************************************************/
                BEGIN
                    switch (ilk_info[control_seq_loc])
                    BEGIN
                      case N_SS:
                        string_width = string_width + SS_WIDTH;
                        break;
                      case N_AE:
                        string_width = string_width + AE_WIDTH;
                        break;
                      case N_OE:
                        string_width = string_width + OE_WIDTH;
                        break;
                      case N_AE_UPPER:
                        string_width = string_width + UPPER_AE_WIDTH;
                        break;
                      case N_OE_UPPER:
                        string_width = string_width + UPPER_OE_WIDTH;
                        break;
                      default:
                        string_width = string_width
  					+ char_width[ex_buf[ex_buf_xptr]];
                        break;
                    END
                  END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 453 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

                END
                while ((ex_buf_ptr < ex_buf_length)
  			&& (lex_class[ex_buf[ex_buf_ptr]] == WHITE_SPACE))
                BEGIN
                  INCR (ex_buf_ptr);
                END
                while ((ex_buf_ptr < ex_buf_length) && (brace_level > 0)
  			&& (ex_buf[ex_buf_ptr] != BACKSLASH))
                BEGIN
                  if (ex_buf[ex_buf_ptr] == RIGHT_BRACE)
                  BEGIN
                    DECR (brace_level);
                  END
                  else if (ex_buf[ex_buf_ptr] == LEFT_BRACE)
                  BEGIN
                    INCR (brace_level);
                  END
                  else
                  BEGIN
#if UTF_8
                    string_width = string_width
                                     + char_width_uni(&ex_buf[ex_buf_ptr]);
#else
                    string_width = string_width
                                     + char_width[ex_buf[ex_buf_ptr]];
#endif
                  END
#if UTF_8
                  if (utf8len(ex_buf[ex_buf_ptr])>0)
                    ex_buf_ptr = ex_buf_ptr + utf8len(ex_buf[ex_buf_ptr]);
                  else
                    INCR (ex_buf_ptr);
#else
                  INCR (ex_buf_ptr);
#endif
                END
              END
              DECR (ex_buf_ptr);
            END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 452 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

            else
            BEGIN
              string_width = string_width + char_width[LEFT_BRACE];
            END
          END
          else
          BEGIN
            string_width = string_width + char_width[LEFT_BRACE];
          END
        END
        else if (ex_buf[ex_buf_ptr] == RIGHT_BRACE)
        BEGIN
          decr_brace_level (pop_lit1);
          string_width = string_width + char_width[RIGHT_BRACE];
        END
        else
        BEGIN
#if UTF_8
          string_width = string_width + char_width_uni(&ex_buf[ex_buf_ptr]);
#else
          string_width = string_width + char_width[ex_buf[ex_buf_ptr]];
#endif
        END
#if UTF_8
        if (utf8len(ex_buf[ex_buf_ptr])>0)
          ex_buf_ptr = ex_buf_ptr + utf8len(ex_buf[ex_buf_ptr]);
        else
          INCR (ex_buf_ptr);
#else
        INCR (ex_buf_ptr);
#endif
      END
      check_brace_level (pop_lit1);
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 451 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

    push_lit_stk (string_width, STK_INT);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 450 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/





/***************************************************************************
 * WEB section number:	 454
 * ~~~~~~~~~~~~~~~~~~~
 * The |built_in| function write$ pops the top (string) literal
 * and writes it onto the output buffer |out_buf| (which will result in
 * stuff being written onto the .bbl file if the buffer fills up).  If
 * the literal isn't a string, it complains but does nothing else.
 ***************************************************************************/
void          x_write (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);
  END
  else
  BEGIN
    add_out_pool (pop_lit1);
  END
END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 454 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
void          x_bit_and (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  if (pop_typ1 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else if (pop_typ2 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else
  BEGIN
    push_lit_stk (pop_lit1 & pop_lit2, STK_INT);
  END
END
void          x_bit_or (void)
BEGIN
  pop_lit_stk (&pop_lit1, &pop_typ1);
  pop_lit_stk (&pop_lit2, &pop_typ2);
  if (pop_typ1 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit1, pop_typ1, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else if (pop_typ2 != STK_INT)
  BEGIN
    print_wrong_stk_lit (pop_lit2, pop_typ2, STK_INT);
    push_lit_stk (0, STK_INT);
  END
  else
  BEGIN
    push_lit_stk (pop_lit1 | pop_lit2, STK_INT);
  END
END
#ifdef UTF_8

#define FULLWIDTH_DIGIT_0    0xFF10
#define FULLWIDTH_DIGIT_9    0xFF19
#define FULLWIDTH_CAPITAL_A  0xFF21
#define FULLWIDTH_CAPITAL_Z  0xFF3A
#define FULLWIDTH_SMALL_A    0xFF41
#define FULLWIDTH_SMALL_Z    0xFF5A
#define HALFWIDTH_KATAKANA_WO         0xFF66
#define HALFWIDTH_KATAKANA_SMALL_TSU  0xFF6F
#define HALFWIDTH_KATAKANA_A          0xFF71
#define HALFWIDTH_KATAKANA_N          0xFF9D

void          x_is_cjk_string (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 (-1, STK_INT);
  END
  else
  BEGIN
    ex_buf_length = 0;
    add_buf_pool (pop_lit1);
    string_width = 0;
    BEGIN
      ex_buf_ptr = 0;
      while (ex_buf_ptr < ex_buf_length)
      BEGIN
        UChar32 ch;
        U8_NEXT_OR_FFFD(ex_buf, ex_buf_ptr, -1, ch);
        switch ( ublock_getCode(ch) )
        BEGIN
      /* hanzi */
          case UBLOCK_CJK_UNIFIED_IDEOGRAPHS:
          case UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS:
          case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A:
          case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B:
          case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C:
          case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D:
          case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_E:
          case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_F:
          case UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_G:
            string_width |= 0x001;
            break;
      /* kana */
          case UBLOCK_HIRAGANA:
          case UBLOCK_KATAKANA:
          case UBLOCK_KATAKANA_PHONETIC_EXTENSIONS:
          case UBLOCK_KANA_EXTENDED_A:
          case UBLOCK_KANA_EXTENDED_B:
          case UBLOCK_SMALL_KANA_EXTENSION:
            string_width |= 0x002;
            break;
      /* hangul */
          case UBLOCK_HANGUL_SYLLABLES:
          case UBLOCK_HANGUL_JAMO:
          case UBLOCK_HANGUL_JAMO_EXTENDED_A:
          case UBLOCK_HANGUL_JAMO_EXTENDED_B:
          case UBLOCK_HANGUL_COMPATIBILITY_JAMO:
            string_width |= 0x004;
            break;
      /* bopomofo */
          case UBLOCK_BOPOMOFO:
          case UBLOCK_BOPOMOFO_EXTENDED:
            string_width |= 0x008;
            break;
          case UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS:
      /* Fullwidth ASCII variants  except for U+FF01..FF0F, U+FF1A..FF20, U+FF3B..FF40, U+FF5B..FF5E */
            if (  (FULLWIDTH_DIGIT_0  <=ch && ch<=FULLWIDTH_DIGIT_9  )
               || (FULLWIDTH_CAPITAL_A<=ch && ch<=FULLWIDTH_CAPITAL_Z)
               || (FULLWIDTH_SMALL_A  <=ch && ch<=FULLWIDTH_SMALL_Z  ) )
              string_width |= 0x800;
      /* Halfwidth Katakana variants  except for U+FF65, U+FF70, U+FF9E..FF9F */
            if (  (HALFWIDTH_KATAKANA_WO <=ch && ch<=HALFWIDTH_KATAKANA_SMALL_TSU )
               || (HALFWIDTH_KATAKANA_A  <=ch && ch<=HALFWIDTH_KATAKANA_N  ) )
              string_width |= 0x002;
            break;
      /* miscellaneous */
          case UBLOCK_KANBUN:
          case UBLOCK_KANGXI_RADICALS:
          case UBLOCK_CJK_RADICALS_SUPPLEMENT:
            string_width |= 0x800;
            break;
        END
      END
    END
/*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 451 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/

    push_lit_stk (string_width, STK_INT);
  END
END
#endif