summaryrefslogtreecommitdiff
path: root/web/nuweb/nuweb0.87b/nuwebdoc.tex
blob: 3d6a836d76c4c66c7d1d2bc4406ff0998e22d457 (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
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
\documentstyle{report}
\newif\ifshowcode
\showcodefalse

\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}
\setlength{\topmargin}{0in}
\addtolength{\topmargin}{-\headheight}
\addtolength{\topmargin}{-\headsep}
\setlength{\textheight}{8.9in}
\setlength{\textwidth}{6.5in}
\setlength{\marginparwidth}{0.5in}

\title{Nuweb Version 0.87b \\ A Simple Literate Programming Tool}
\date{}
\author{Preston Briggs\thanks{This work has been supported by ARPA,
through ONR grant N00014-91-J-1989.} 
\\ \sl preston@cs.rice.edu
\\ HTML scrap generator by John D. Ramsdell
\\ \sl ramsdell@mitre.org}

\begin{document}
\pagenumbering{roman}
\maketitle
\tableofcontents

\chapter{Introduction}
\pagenumbering{arabic}

In 1984, Knuth introduced the idea of {\em literate programming\/} and
described a pair of tools to support the practise~\cite{knuth:84}.
His approach was to combine Pascal code with \TeX\ documentation to
produce a new language, \verb|WEB|, that offered programmers a superior
approach to programming. He wrote several programs in \verb|WEB|,
including \verb|weave| and \verb|tangle|, the programs used to support
literate programming.
The idea was that a programmer wrote one document, the web file, that
combined documentation (written in \TeX~\cite{texbook}) with code
(written in Pascal).

Running \verb|tangle| on the web file would produce a complete
Pascal program, ready for compilation by an ordinary Pascal compiler.
The primary function of \verb|tangle| is to allow the programmer to
present elements of the program in any desired order, regardless of
the restrictions imposed by the programming language. Thus, the
programmer is free to present his program in a top-down fashion,
bottom-up fashion, or whatever seems best in terms of promoting
understanding and maintenance.

Running \verb|weave| on the web file would produce a \TeX\ file, ready
to be processed by \TeX\@. The resulting document included a variety of
automatically generated indices and cross-references that made it much
easier to navigate the code. Additionally, all of the code sections
were automatically pretty printed, resulting in a quite impressive
document. 

Knuth also wrote the programs for \TeX\ and {\small\sf METAFONT}
entirely in \verb|WEB|, eventually publishing them in book
form~\cite{tex:program,metafont:program}. These are probably the
largest programs ever published in a readable form.

Inspired by Knuth's example, many people have experimented with
\verb|WEB|\@. Some people have even built web-like tools for their
own favorite combinations of programming language and typesetting
language. For example, \verb|CWEB|, Knuth's current system of choice,
works with a combination of C (or C++) and \TeX~\cite{levy:90}.
Another system, FunnelWeb, is independent of any programming language
and only mildly dependent on \TeX~\cite{funnelweb}. Inspired by the
versatility of FunnelWeb and by the daunting size of its
documentation, I decided to write my own, very simple, tool for
literate programming.%
\footnote{There is another system similar to
mine, written by Norman Ramsey, called {\em noweb}~\cite{noweb}. It
perhaps suffers from being overly Unix-dependent and requiring several
programs to use. On the other hand, its command syntax is very nice.
In any case, nuweb certainly owes its name and a number of features to
his inspiration.}


\section{Nuweb}

Nuweb works with any programming language and \LaTeX~\cite{latex}. I
wanted to use \LaTeX\ because it supports a multi-level sectioning
scheme and has facilities for drawing figures. I wanted to be able to
work with arbitrary programming languages because my friends and I
write programs in many languages (and sometimes combinations of
several languages), {\em e.g.,} C, Fortran, C++, yacc, lex, Scheme,
assembly, Postscript, and so forth. The need to support arbitrary
programming languages has many consequences:
\begin{description}
\item[No pretty printing] Both \verb|WEB| and \verb|CWEB| are able to
  pretty print the code sections of their documents because they
  understand the language well enough to parse it. Since we want to use
  {\em any\/} language, we've got to abandon this feature.
\item[No index of identifiers] Because \verb|WEB| knows about Pascal,
  it is able to construct an index of all the identifiers occurring in
  the code sections (filtering out keywords and the standard type
  identifiers). Unfortunately, this isn't as easy in our case. We don't
  know what an identifiers looks like in each language and we certainly
  don't know all the keywords. (On the other hand, see the end of
  Section~1.3)
\end{description}
Of course, we've got to have some compensation for our losses or the
whole idea would be a waste. Here are the advantages I can see:
\begin{description}
\item[Simplicity] The majority of the commands in \verb|WEB| are
  concerned with control of the automatic pretty printing. Since we
  don't pretty print, many commands are eliminated. A further set of
  commands is subsumed by \LaTeX\  and may also be eliminated. As a
  result, our set of commands is reduced to only four members (explained
  in the next section). This simplicity is also reflected in
  the size of this tool, which is quite a bit smaller than the tools
  used with other approaches.
\item[No pretty printing] Everyone disagrees about how their code
  should look, so automatic formatting annoys many people. One approach
  is to provide ways to control the formatting. Our approach is
  simpler---we perform no automatic formatting and therefore allow the
  programmer complete control of code layout.
\item[Control] We also offer the programmer complete control of the
  layout of his output files (the files generated during tangling). Of
  course, this is essential for languages that are sensitive to layout;
  but it is also important in many practical situations, {\em e.g.,}
  debugging.
\item[Speed] Since nuweb doesn't do to much, the nuweb tool runs
  quickly. I combine the functions of \verb|tangle| and \verb|weave| into
  a single program that performs both functions at once.
\item[Page numbers] Inspired by the example of noweb, nuweb refers to
  all scraps by page number to simplify navigation. If there are
  multiple scraps on a page (say page~17), they are distinguished by
  lower-case letters ({\em e.g.,} 17a, 17b, and so forth).
\item[Multiple file output] The programmer may specify more than one
  output file in a single nuweb file. This is required when constructing
  programs in a combination of languages (say, Fortran and C)\@. It's also
  an advantage when constructing very large programs that would require
  a lot of compile time.
\end{description}
This last point is very important. By allowing the creation of
multiple output files, we avoid the need for monolithic programs.
Thus we support the creation of very large programs by groups of
people. 

A further reduction in compilation time is achieved by first
writing each output file to a temporary location, then comparing the
temporary file with the old version of the file. If there is no
difference, the temporary file can be deleted. If the files differ,
the old version is deleted and the temporary file renamed. This
approach works well in combination with \verb|make| (or similar tools),
since \verb|make| will avoid recompiling untouched output files.

\subsection{Nuweb and HTML}

In addition to producing {\LaTeX} source, nuweb can be used to
generate HyperText Markup Language (HTML), the markup language used by
the World Wide Web.  HTML provides hypertext links.  When a HTML
document is viewed online, a user can navigate within the document by
activating the links.  The tools which generate HTML automatically
produce hypertext links from a nuweb source.


\section{Writing Nuweb}

The bulk of a nuweb file will be ordinary \LaTeX\@. In fact, any
{\LaTeX} file can serve as input to nuweb and will be simply copied
through unchanged to the documentation file---unless a nuweb command
is discovered. All nuweb commands begin with an ``at-sign''
(\verb|@|).  Therefore, a file without at-signs will be copied
unchanged.  Nuweb commands are used to specify {\em output files,}
define {\em macros,} and delimit {\em scraps}. These are the basic
features of interest to the nuweb tool---all else is simply text to be
copied to the documentation file.

\subsection{The Major Commands}

Files and macros are defined with the following commands:
\begin{description}
\item[{\tt @o} {\em file-name flags scrap\/}] Output a file. The file name is
  terminated by whitespace.
\item[{\tt @d} {\em macro-name scrap\/}] Define a macro. The macro name
  is terminated by a return or the beginning of a scrap.
\end{description}
A specific file may be specified several times, with each definition
being written out, one after the other, in the order they appear.
The definitions of macros may be similarly divided.

\subsubsection{Scraps}

Scraps have specific begin markers and end markers to allow precise
control over the contents and layout. Note that any amount of
whitespace (including carriage returns) may appear between a name and
the beginning of a scrap.
\begin{description}
\item[\tt @\{{\em anything\/}@\}] where the scrap body includes every
  character in {\em anything\/}---all the blanks, all the tabs, all the
  carriage returns.
\end{description}
Inside a scrap, we may invoke a macro.
\begin{description}
\item[\tt @<{\em macro-name\/}@>] Causes the macro 
  {\em macro-name\/} to be expanded inline as the code is written out
  to a file. It is an error to specify recursive macro invocations.
\end{description}
Note that macro names may be abbreviated, either during invocation or
definition. For example, it would be very tedious to have to
repeatedly type the macro name
\begin{quote}
\verb|@d Check for terminating at-sequence and return name if found|
\end{quote}
Therefore, we provide a mechanism (stolen from Knuth) of indicating
abbreviated names.
\begin{quote}
\verb|@d Check for terminating...|
\end{quote}
Basically, the programmer need only type enough characters to uniquely
identify the macro name, followed by three periods. An abbreviation
may even occur before the full version; nuweb simply preserves the
longest version of a macro name. Note also that blanks and tabs are
insignificant in a macro name; any string of them are replaced by a
single blank.

When scraps are written to a program file or a documentation file, tabs are
expanded into spaces by default. Currently, I assume tab stops are set
every eight characters. Furthermore, when a macro is expanded in a scrap,
the body of the macro is indented to match the indentation of the
macro invocation. Therefore, care must be taken with languages 
({\em e.g.,} Fortran) that are sensitive to indentation.
These default behaviors may be changed for each output file (see
below).

\subsubsection{Flags}

When defining an output file, the programmer has the option of using
flags to control output of a particular file. The flags are intended
to make life a little easier for programmers using certain languages.
They introduce little language dependences; however, they do so only
for a particular file. Thus it is still easy to mix languages within a
single document. There are three ``per-file'' flags:
\begin{description}
\item[\tt -d] Forces the creation of \verb|#line| directives in the
  output file. These are useful with C (and sometimes C++ and Fortran) on
  many Unix systems since they cause the compiler's error messages to
  refer to the web file rather than the output file. Similarly, they
  allow source debugging in terms of the web file.
\item[\tt -i] Suppresses the indentation of macros. That is, when a
  macro is expanded in a scrap, it will {\em not\/} be indented to
  match the indentation of the macro invocation. This flag would seem
  most useful for Fortran programmers.
\item[\tt -t] Suppresses expansion of tabs in the output file. This
  feature seems important when generating \verb|make| files.
\end{description}


\subsection{The Minor Commands}

We have two very low-level utility commands that may appear anywhere
in the web file.
\begin{description}
\item[\tt @@] Causes a single ``at sign'' to be copied into the output.
\item[\tt @i {\em file-name\/}] Includes a file. Includes may be
  nested, though there is currently a limit of 10~levels. The file name
  should be complete (no extension will be appended) and should be
  terminated by a carriage return.
\end{description}
Finally, there are three commands used to create indices to the macro
names, file definitions, and user-specified identifiers.
\begin{description}
\item[\tt @f] Create an index of file names.
\item[\tt @m] Create an index of macro name.
\item[\tt @u] Create an index of user-specified identifiers.
\end{description}
I usually put these in their own section
in the \LaTeX\ document; for example, see Chapter~\ref{indices}.

Identifiers must be explicitly specified for inclusion in the
\verb|@u| index. By convention, each identifier is marked at the
point of its definition; all references to each identifier (inside
scraps) will be discovered automatically. To ``mark'' an identifier
for inclusion in the index, we must mention it at the end of a scrap.
For example,
\begin{quote}
\begin{verbatim}
@d a scrap @{
Let's pretend we're declaring the variables FOO and BAR
inside this scrap.
@| FOO BAR @}
\end{verbatim}
\end{quote}
I've used alphabetic identifiers in this example, but any string of
characters (not including whitespace or \verb|@| characters) will do.
Therefore, it's possible to add index entries for things like
\verb|<<=| if desired. An identifier may be declared in more than one
scrap.

In the generated index, each identifier appears with a list of all the
scraps using and defining it, where the defining scraps are
distinguished by underlining. Note that the identifier doesn't
actually have to appear in the defining scrap; it just has to be in
the list of definitions at the end of a scrap.


\section{Running Nuweb}

Nuweb is invoked using the following command:
\begin{quote}
{\tt nuweb} {\em flags file-name}\ldots
\end{quote}
One or more files may be processed at a time. If a file name has no
extension, \verb|.w| will be appended.  {\LaTeX} suitable for
translation into HTML by {\LaTeX}2HTML will be produced from
files whose name ends with \verb|.hw|, otherwise, ordinary {\LaTeX} will be
produced.  While a file name may specify a file in another directory,
the resulting documentation file will always be created in the current
directory. For example,
\begin{quote}
{\tt nuweb /foo/bar/quux}
\end{quote}
will take as input the file \verb|/foo/bar/quux.w| and will create the
file \verb|quux.tex| in the current directory.

By default, nuweb performs both tangling and weaving at the same time.
Normally, this is not a bottleneck in the compilation process;
however, it's possible to achieve slightly faster throughput by
avoiding one or another of the default functions using command-line
flags. There are currently three possible flags:
\begin{description}
\item[\tt -t] Suppress generation of the documentation file.
\item[\tt -o] Suppress generation of the output files.
\item[\tt -c] Avoid testing output files for change before updating them.
\end{description}
Thus, the command
\begin{quote}
\verb|nuweb -to /foo/bar/quux|
\end{quote}
would simply scan the input and produce no output at all.

There are two additional command-line flags:
\begin{description}
\item[\tt -v] For ``verbose,'' causes nuweb to write information about
  its progress to \verb|stderr|.
\item[\tt -n] Forces scraps to be numbered sequentially from~1
  (instead of using page numbers). This form is perhaps more desirable
  for small webs.
\end{description}

\section{Generating HTML}

Nikos Drakos' {\LaTeX}2HTML Version 0.5.3~\cite{drakos:94} can be used
to translate {\LaTeX} with embedded HTML scraps into HTML\@.  Be sure
to include the document-style option \verb|html| so that {\LaTeX} will
understand the hypertext commands.  When translating into HTML, do not
allow a document to be split by specifying ``\verb|-split 0|''.  
You need not generate navigation links, so also specify
``\verb|-no_navigation|''.

While preparing a web, you may want to view the program's scraps without
taking the time to run {\LaTeX}2HTML\@.  Simply rename the generated
{\LaTeX} source so that its file name ends with \verb|.html|, and view
that file.  The documentations section will be jumbled, but the
scraps will be clear.

\section{Restrictions}

Because nuweb is intended to be a simple tool, I've established a few
restrictions. Over time, some of these may be eliminated; others seem
fundamental.
\begin{itemize}
\item The handling of errors is not completely ideal. In some cases, I
  simply warn of a problem and continue; in other cases I halt
  immediately. This behavior should be regularized.
\item I warn about references to macros that haven't been defined, but
  don't halt. This seems most convenient for development, but may change
  in the future.
\item File names and index entries should not contain any \verb|@|
  signs.
\item Macro names may be (almost) any well-formed \TeX\ string.
  It makes sense to change fonts or use math mode; however, care should
  be taken to ensure matching braces, brackets, and dollar signs.
  When producing HTML, macros are displayed in a preformatted element
  (PRE), so macros may contain one or more A, B, I, U, or P elements
  or data characters.
\item Anything is allowed in the body of a scrap; however, very
  long scraps (horizontally or vertically) may not typeset well.
\item Temporary files (created for comparison to the eventual
  output files) are placed in the current directory. Since they may be
  renamed to an output file name, all the output files should be on the
  same file system as the current directory.
\item Because page numbers cannot be determined until the document has
  been typeset, we have to rerun nuweb after \LaTeX\ to obtain a clean
  version of the document (very similar to the way we sometimes have
  to rerun \LaTeX\ to obtain an up-to-date table of contents after
  significant edits).  Nuweb will warn (in most cases) when this needs
  to be done; in the remaining cases, \LaTeX\ will warn that labels
  may have changed.
\end{itemize}
Very long scraps may be allowed to break across a page if declared
with \verb|@O| or \verb|@D| (instead of \verb|@o| and \verb|@d|).
This doesn't work very well as a default, since far too many short
scraps will be broken across pages; however, as a user-controlled
option, it seems very useful.  No distinction is made between the
upper case and lower case forms of these commands when generating
HTML\@.

\section{Acknowledgements}

Several people have contributed their times, ideas, and debugging
skills. In particular, I'd like to acknowledge the contributions of
Osman Buyukisik, Manuel Carriba, Adrian Clarke, Tim Harvey, Michael
Lewis, Walter Ravenek, Rob Shillingsburg, Kayvan Sylvan, Dominique
de~Waleffe, and Scott Warren.  Of course, most of these people would
never have heard or nuweb (or many other tools) without the efforts of
George Greenwade.


\ifshowcode
\chapter{The Overall Structure}

Processing a web requires three major steps:
\begin{enumerate}
\item Read the source, accumulating file names, macro names, scraps,
and lists of cross-references.
\item Reread the source, copying out to the documentation file, with
protection and cross-reference information for all the scraps.
\item Traverse the list of files names. For each file name:
\begin{enumerate}
\item Dump all the defining scraps into a temporary file. 
\item If the file already exists and is unchanged, delete the
temporary file; otherwise, rename the temporary file.
\end{enumerate}
\end{enumerate}


\section{Files}

I have divided the program into several files for quicker
recompilation during development.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap1}
\verb@"global.h"@ {\footnotesize 7a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@@$\langle$Include files {\footnotesize 7b}$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$Type declarations {\footnotesize 8a, \ldots\ }$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$Global variable declarations {\footnotesize 10a, \ldots\ }$\rangle$\verb@@\\
\mbox{}\verb@@$\langle$Function prototypes {\footnotesize 14a, \ldots\ }$\rangle$\verb@@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-2ex}
\end{minipage}\\[4ex]
\end{flushleft}
We'll need at least three of the standard system include files.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap2}
$\langle$Include files {\footnotesize 7b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include <stdlib.h>@\\
\mbox{}\verb@#include <stdio.h>@\\
\mbox{}\verb@#include <string.h>@\\
\mbox{}\verb@#include <ctype.h>@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\newpage
\noindent
I also like to use \verb|TRUE| and \verb|FALSE| in my code.
I'd use an \verb|enum| here, except that some systems seem to provide
definitions of \verb|TRUE| and \verb|FALSE| be default.  The following
code seems to work on all the local systems.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap3}
$\langle$Type declarations {\footnotesize 8a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#ifndef FALSE@\\
\mbox{}\verb@#define FALSE 0@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@#ifndef TRUE@\\
\mbox{}\verb@#define TRUE 1@\\
\mbox{}\verb@#endif@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 8a, 52c, 53a.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{The Main Files}

The code is divided into four main files (introduced here) and five
support files (introduced in the next section).
The file \verb|main.c| will contain the driver for the whole program
(see Section~\ref{main-routine}).
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap4}
\verb@"main.c"@ {\footnotesize 8b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include "global.h"@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8b, 9f.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The first pass over the source file is contained in \verb|pass1.c|.
It handles collection of all the file names, macros names, and scraps
(see Section~\ref{pass-one}).
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap5}
\verb@"pass1.c"@ {\footnotesize 8c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include "global.h"@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8c, 14b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The \verb|.tex| file is created during a second pass over the source
file. The file \verb|latex.c| contains the code controlling the
construction of the \verb|.tex| file 
(see Section~\ref{latex-file}).
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap6}
\verb@"latex.c"@ {\footnotesize 8d }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include "global.h"@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8d, 16d, 17a, 21b, 22a, 24b, 26b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The file \verb|html.c| contains the code controlling the
construction of the \verb|.tex| file appropriate for use with {\LaTeX}2HTML
(see Section~\ref{html-file}).
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap7}
\verb@"html.c"@ {\footnotesize 8e }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include "global.h"@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8e, 28ab, 32abc, 33a, 35a, 36c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The code controlling the creation of the output files is in \verb|output.c|
(see Section~\ref{output-files}).
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap8}
\verb@"output.c"@ {\footnotesize 8f }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include "global.h"@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8f, 37c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\newpage
\subsection{Support Files}

The support files contain a variety of support routines used to define
and manipulate the major data abstractions.
The file \verb|input.c| holds all the routines used for referring to
source files (see Section~\ref{source-files}).
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap9}
\verb@"input.c"@ {\footnotesize 9a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include "global.h"@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9a, 39d, 40ab, 42c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Creation and lookup of scraps is handled by routines in \verb|scraps.c|
(see Section~\ref{scraps}).
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap10}
\verb@"scraps.c"@ {\footnotesize 9b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include "global.h"@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The handling of file names and macro names is detailed in \verb|names.c|
(see Section~\ref{names}).
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap11}
\verb@"names.c"@ {\footnotesize 9c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include "global.h"@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Memory allocation and deallocation is handled by routines in \verb|arena.c|
(see Section~\ref{memory-management}).
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap12}
\verb@"arena.c"@ {\footnotesize 9d }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include "global.h"@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9d, 70abc, 71c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Finally, for best portability, I seem to need a file containing
(useless!) definitions of all the global variables.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap13}
\verb@"global.c"@ {\footnotesize 9e }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#include "global.h"@\\
\mbox{}\verb@@$\langle$Global variable definitions {\footnotesize 10b, \ldots\ }$\rangle$\verb@@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-2ex}
\end{minipage}\\[4ex]
\end{flushleft}
\section{The Main Routine} \label{main-routine}

The main routine is quite simple in structure.
It wades through the optional command-line arguments,
then handles any files listed on the command line.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap14}
\verb@"main.c"@ {\footnotesize 9f }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@int main(argc, argv)@\\
\mbox{}\verb@     int argc;@\\
\mbox{}\verb@     char **argv;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  int arg = 1;@\\
\mbox{}\verb@  @$\langle$Interpret command-line arguments {\footnotesize 10e, \ldots\ }$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Process the remaining arguments (file names) {\footnotesize 11c}$\rangle$\verb@@\\
\mbox{}\verb@  exit(0);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8b, 9f.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Command-Line Arguments}

There are five possible command-line arguments:
\begin{description}
\item[\tt -t] Suppresses generation of the {\tt .tex} file.
\item[\tt -o] Suppresses generation of the output files.
\item[\tt -c] Forces output files to overwrite old files of the same
  name without comparing for equality first.
\item[\tt -v] The verbose flag. Forces output of progress reports.
\item[\tt -n] Forces sequential numbering of scraps (instead of page
  numbers).
\end{description}

\noindent
Global flags are declared for each of the arguments.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap15}
$\langle$Global variable declarations {\footnotesize 10a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern int tex_flag;      /* if FALSE, don't emit the documentation file */@\\
\mbox{}\verb@extern int html_flag;     /* if TRUE, emit HTML instead of LaTeX scraps. */@\\
\mbox{}\verb@extern int output_flag;   /* if FALSE, don't emit the output files */@\\
\mbox{}\verb@extern int compare_flag;  /* if FALSE, overwrite without comparison */@\\
\mbox{}\verb@extern int verbose_flag;  /* if TRUE, write progress information */@\\
\mbox{}\verb@extern int number_flag;   /* if TRUE, use a sequential numbering scheme */@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10ac, 39b, 44d, 53b.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The flags are all initialized for correct default behavior.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap16}
$\langle$Global variable definitions {\footnotesize 10b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@int tex_flag = TRUE;@\\
\mbox{}\verb@int html_flag = FALSE;@\\
\mbox{}\verb@int output_flag = TRUE;@\\
\mbox{}\verb@int compare_flag = TRUE;@\\
\mbox{}\verb@int verbose_flag = FALSE;@\\
\mbox{}\verb@int number_flag = FALSE;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10bd, 39c, 45a, 53c.
\item Macro referenced in scrap 9e.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
We save the invocation name of the command in a global variable
\verb|command_name| for use in error messages.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap17}
$\langle$Global variable declarations {\footnotesize 10c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern char *command_name;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10ac, 39b, 44d, 53b.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap18}
$\langle$Global variable definitions {\footnotesize 10d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@char *command_name = NULL;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10bd, 39c, 45a, 53c.
\item Macro referenced in scrap 9e.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The invocation name is conventionally passed in \verb|argv[0]|.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap19}
$\langle$Interpret command-line arguments {\footnotesize 10e}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@command_name = argv[0];@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10e, 11a.
\item Macro referenced in scrap 9f.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
We need to examine the remaining entries in \verb|argv|, looking for
command-line arguments.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap20}
$\langle$Interpret command-line arguments {\footnotesize 11a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@while (arg < argc) {@\\
\mbox{}\verb@  char *s = argv[arg];@\\
\mbox{}\verb@  if (*s++ == '-') {@\\
\mbox{}\verb@    @$\langle$Interpret the argument string \verb|s| {\footnotesize 11b}$\rangle$\verb@@\\
\mbox{}\verb@    arg++;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else break;@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10e, 11a.
\item Macro referenced in scrap 9f.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Several flags can be stacked behind a single minus sign; therefore,
we've got to loop through the string, handling them all.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap21}
$\langle$Interpret the argument string \verb|s| {\footnotesize 11b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  char c = *s++;@\\
\mbox{}\verb@  while (c) {@\\
\mbox{}\verb@    switch (c) {@\\
\mbox{}\verb@      case 'c': compare_flag = FALSE;@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@      case 'n': number_flag = TRUE;@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@      case 'o': output_flag = FALSE;@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@      case 't': tex_flag = FALSE;@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@      case 'v': verbose_flag = TRUE;@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@      default:  fprintf(stderr, "%s: unexpected argument ignored.  ",@\\
\mbox{}\verb@                        command_name);@\\
\mbox{}\verb@                fprintf(stderr, "Usage is: %s [-cnotv] file...\n",@\\
\mbox{}\verb@                        command_name);@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    c = *s++;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 11a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{File Names}

We expect at least one file name. While a missing file name might be
ignored without causing any problems, we take the opportunity to report
the usage convention.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap22}
$\langle$Process the remaining arguments (file names) {\footnotesize 11c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (arg >= argc) {@\\
\mbox{}\verb@    fprintf(stderr, "%s: expected a file name.  ", command_name);@\\
\mbox{}\verb@    fprintf(stderr, "Usage is: %s [-cnotv] file-name...\n", command_name);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  do {@\\
\mbox{}\verb@    @$\langle$Handle the file name in \verb|argv[arg]| {\footnotesize 12a}$\rangle$\verb@@\\
\mbox{}\verb@    arg++;@\\
\mbox{}\verb@  } while (arg < argc);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 9f.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\newpage
\noindent
The code to handle a particular file name is rather more tedious than
the actual processing of the file. A file name may be an arbitrarily
complicated path name, with an optional extension. If no extension is
present, we add \verb|.w| as a default. The extended path name will be
kept in a local variable \verb|source_name|. The resulting documentation
file will be written in the current directory; its name will be kept
in the variable \verb|tex_name|.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap23}
$\langle$Handle the file name in \verb|argv[arg]| {\footnotesize 12a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  char source_name[100];@\\
\mbox{}\verb@  char tex_name[100];@\\
\mbox{}\verb@  char aux_name[100];@\\
\mbox{}\verb@  @$\langle$Build \verb|source_name| and \verb|tex_name| {\footnotesize 12b}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Process a file {\footnotesize 13}$\rangle$\verb@@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 11c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
I bump the pointer \verb|p| through all the characters in \verb|argv[arg]|,
copying all the characters into \verb|source_name| (via the pointer
\verb|q|). 

At each slash, I update \verb|trim| to point just past the
slash in \verb|source_name|. The effect is that \verb|trim| will point
at the file name without any leading directory specifications.

The pointer \verb|dot| is made to point at the file name extension, if
present. If there is no extension, we add \verb|.w| to the source name.
In any case, we create the \verb|tex_name| from \verb|trim|, taking
care to get the correct extension.  The \verb|html_flag| is set in
this scrap.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap24}
$\langle$Build \verb|source_name| and \verb|tex_name| {\footnotesize 12b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  char *p = argv[arg];@\\
\mbox{}\verb@  char *q = source_name;@\\
\mbox{}\verb@  char *trim = q;@\\
\mbox{}\verb@  char *dot = NULL;@\\
\mbox{}\verb@  char c = *p++;@\\
\mbox{}\verb@  while (c) {@\\
\mbox{}\verb@    *q++ = c;@\\
\mbox{}\verb@    if (c == '/') {@\\
\mbox{}\verb@      trim = q;@\\
\mbox{}\verb@      dot = NULL;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    else if (c == '.')@\\
\mbox{}\verb@      dot = q - 1;@\\
\mbox{}\verb@    c = *p++;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  *q = '\0';@\\
\mbox{}\verb@  if (dot) {@\\
\mbox{}\verb@    *dot = '\0'; /* produce HTML when the file extension is ".hw" */@\\
\mbox{}\verb@    html_flag = dot[1] == 'h' && dot[2] == 'w' && dot[3] == '\0';@\\
\mbox{}\verb@    sprintf(tex_name, "%s.tex", trim);@\\
\mbox{}\verb@    sprintf(aux_name, "%s.aux", trim);@\\
\mbox{}\verb@    *dot = '.';@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    sprintf(tex_name, "%s.tex", trim);@\\
\mbox{}\verb@    sprintf(aux_name, "%s.aux", trim);@\\
\mbox{}\verb@    *q++ = '.';@\\
\mbox{}\verb@    *q++ = 'w';@\\
\mbox{}\verb@    *q = '\0';@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 12a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Now that we're finally ready to process a file, it's not really too
complex.  We bundle most of the work into four routines \verb|pass1|
(see Section~\ref{pass-one}), \verb|write_tex| (see
Section~\ref{latex-file}), \verb|write_html| (see
Section~\ref{html-file}), and \verb|write_files| (see
Section~\ref{output-files}). After we're finished with a
particular file, we must remember to release its storage (see
Section~\ref{memory-management}).  The sequential numbering of scraps
is forced when generating HTML.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap25}
$\langle$Process a file {\footnotesize 13}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  pass1(source_name);@\\
\mbox{}\verb@  if (tex_flag) {@\\
\mbox{}\verb@    if (html_flag) {@\\
\mbox{}\verb@      int saved_number_flag = number_flag; @\\
\mbox{}\verb@      number_flag = TRUE;@\\
\mbox{}\verb@      collect_numbers(aux_name);@\\
\mbox{}\verb@      write_html(source_name, tex_name);@\\
\mbox{}\verb@      number_flag = saved_number_flag;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    else {@\\
\mbox{}\verb@      collect_numbers(aux_name);@\\
\mbox{}\verb@      write_tex(source_name, tex_name);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  if (output_flag)@\\
\mbox{}\verb@    write_files(file_names);@\\
\mbox{}\verb@  arena_free();@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 12a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\newpage
\section{Pass One} \label{pass-one}

During the first pass, we scan the file, recording the definitions of
each macro and file and accumulating all the scraps. 

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap26}
$\langle$Function prototypes {\footnotesize 14a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern void pass1();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The routine \verb|pass1| takes a single argument, the name of the
source file. It opens the file, then initializes the scrap structures
(see Section~\ref{scraps}) and the roots of the file-name tree, the
macro-name tree, and the tree of user-specified index entries (see 
Section~\ref{names}). After completing all the
necessary preparation, we make a pass over the file, filling in all
our data structures. Next, we seach all the scraps for references to
the user-specified index entries. Finally, we must reverse all the
cross-reference lists accumulated while scanning the scraps.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap27}
\verb@"pass1.c"@ {\footnotesize 14b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void pass1(file_name)@\\
\mbox{}\verb@     char *file_name;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  if (verbose_flag)@\\
\mbox{}\verb@    fprintf(stderr, "reading %s\n", file_name);@\\
\mbox{}\verb@  source_open(file_name);@\\
\mbox{}\verb@  init_scraps();@\\
\mbox{}\verb@  macro_names = NULL;@\\
\mbox{}\verb@  file_names = NULL;@\\
\mbox{}\verb@  user_names = NULL;@\\
\mbox{}\verb@  @$\langle$Scan the source file, looking for at-sequences {\footnotesize 14c}$\rangle$\verb@@\\
\mbox{}\verb@  if (tex_flag)@\\
\mbox{}\verb@    search();@\\
\mbox{}\verb@  @$\langle$Reverse cross-reference lists {\footnotesize 16b}$\rangle$\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8c, 14b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The only thing we look for in the first pass are the command
sequences. All ordinary text is skipped entirely.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap28}
$\langle$Scan the source file, looking for at-sequences {\footnotesize 14c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  int c = source_get();@\\
\mbox{}\verb@  while (c != EOF) {@\\
\mbox{}\verb@    if (c == '@{\tt @}\verb@')@\\
\mbox{}\verb@      @$\langle$Scan at-sequence {\footnotesize 15a}$\rangle$\verb@@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 14b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Only four of the at-sequences are interesting during the first pass.
We skip past others immediately; warning if unexpected sequences are
discovered.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap29}
$\langle$Scan at-sequence {\footnotesize 15a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case 'O':@\\
\mbox{}\verb@    case 'o': @$\langle$Build output file definition {\footnotesize 15b}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case 'D':@\\
\mbox{}\verb@    case 'd': @$\langle$Build macro definition {\footnotesize 15c}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case '@{\tt @}\verb@':@\\
\mbox{}\verb@    case 'u':@\\
\mbox{}\verb@    case 'm':@\\
\mbox{}\verb@    case 'f': /* ignore during this pass */@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    default:  fprintf(stderr,@\\
\mbox{}\verb@                      "%s: unexpected @{\tt @}\verb@ sequence ignored (%s, line %d)\n",@\\
\mbox{}\verb@                      command_name, source_name, source_line);@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 14c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Accumulating Definitions}

There are three steps required to handle a definition:
\begin{enumerate}
\item Build an entry for the name so we can look it up later.
\item Collect the scrap and save it in the table of scraps.
\item Attach the scrap to the name.
\end{enumerate}
We go through the same steps for both file names and macro names.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap30}
$\langle$Build output file definition {\footnotesize 15b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *name = collect_file_name(); /* returns a pointer to the name entry */@\\
\mbox{}\verb@  int scrap = collect_scrap();      /* returns an index to the scrap */@\\
\mbox{}\verb@  @$\langle$Add \verb|scrap| to \verb|name|'s definition list {\footnotesize 16a}$\rangle$\verb@@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 15a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap31}
$\langle$Build macro definition {\footnotesize 15c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *name = collect_macro_name();@\\
\mbox{}\verb@  int scrap = collect_scrap();@\\
\mbox{}\verb@  @$\langle$Add \verb|scrap| to \verb|name|'s definition list {\footnotesize 16a}$\rangle$\verb@@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 15a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Since a file or macro may be defined by many scraps, we maintain them
in a simple linked list. The list is actually built in reverse order,
with each new definition being added to the head of the list.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap32}
$\langle$Add \verb|scrap| to \verb|name|'s definition list {\footnotesize 16a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Scrap_Node *def = (Scrap_Node *) arena_getmem(sizeof(Scrap_Node));@\\
\mbox{}\verb@  def->scrap = scrap;@\\
\mbox{}\verb@  def->next = name->defs;@\\
\mbox{}\verb@  name->defs = def;@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 15bc.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Fixing the Cross References}

Since the definition and reference lists for each name are accumulated
in reverse order, we take the time at the end of \verb|pass1| to
reverse them all so they'll be simpler to print out prettily.
The code for \verb|reverse_lists| appears in Section~\ref{names}.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap33}
$\langle$Reverse cross-reference lists {\footnotesize 16b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  reverse_lists(file_names);@\\
\mbox{}\verb@  reverse_lists(macro_names);@\\
\mbox{}\verb@  reverse_lists(user_names);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 14b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\section{Writing the Latex File} \label{latex-file}

The second pass (invoked via a call to \verb|write_tex|) copies most of
the text from the source file straight into a \verb|.tex| file.
Definitions are formatted slightly and cross-reference information is
printed out.

Note that all the formatting is handled in this section.
If you don't like the format of definitions or indices or whatever,
it'll be in this section somewhere. Similarly, if someone wanted to
modify nuweb to work with a different typesetting system, this would
be the place to look.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap34}
$\langle$Function prototypes {\footnotesize 16c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern void write_tex();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
We need a few local function declarations before we get into the body
of \verb|write_tex|.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap35}
\verb@"latex.c"@ {\footnotesize 16d }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void copy_scrap();               /* formats the body of a scrap */@\\
\mbox{}\verb@static void print_scrap_numbers();      /* formats a list of scrap numbers */@\\
\mbox{}\verb@static void format_entry();             /* formats an index entry */@\\
\mbox{}\verb@static void format_user_entry();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8d, 16d, 17a, 21b, 22a, 24b, 26b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The routine \verb|write_tex| takes two file names as parameters: the
name of the web source file and the name of the \verb|.tex| output file.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap36}
\verb@"latex.c"@ {\footnotesize 17a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void write_tex(file_name, tex_name)@\\
\mbox{}\verb@     char *file_name;@\\
\mbox{}\verb@     char *tex_name;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  FILE *tex_file = fopen(tex_name, "w");@\\
\mbox{}\verb@  if (tex_file) {@\\
\mbox{}\verb@    if (verbose_flag)@\\
\mbox{}\verb@      fprintf(stderr, "writing %s\n", tex_name);@\\
\mbox{}\verb@    source_open(file_name);@\\
\mbox{}\verb@    @$\langle$Copy \verb|source_file| into \verb|tex_file| {\footnotesize 17b}$\rangle$\verb@@\\
\mbox{}\verb@    fclose(tex_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    fprintf(stderr, "%s: can't open %s\n", command_name, tex_name);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8d, 16d, 17a, 21b, 22a, 24b, 26b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
We make our second (and final) pass through the source web, this time
copying characters straight into the \verb|.tex| file. However, we keep
an eye peeled for \verb|@|~characters, which signal a command sequence.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap37}
$\langle$Copy \verb|source_file| into \verb|tex_file| {\footnotesize 17b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  int scraps = 1;@\\
\mbox{}\verb@  int c = source_get();@\\
\mbox{}\verb@  while (c != EOF) {@\\
\mbox{}\verb@    if (c == '@{\tt @}\verb@')@\\
\mbox{}\verb@      @$\langle$Interpret at-sequence {\footnotesize 18}$\rangle$\verb@@\\
\mbox{}\verb@    else {@\\
\mbox{}\verb@      putc(c, tex_file);@\\
\mbox{}\verb@      c = source_get();@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 17a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap38}
$\langle$Interpret at-sequence {\footnotesize 18}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  int big_definition = FALSE;@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case 'O': big_definition = TRUE;@\\
\mbox{}\verb@    case 'o': @$\langle$Write output file definition {\footnotesize 19a}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case 'D': big_definition = TRUE;@\\
\mbox{}\verb@    case 'd': @$\langle$Write macro definition {\footnotesize 19b}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case 'f': @$\langle$Write index of file names {\footnotesize 23d}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case 'm': @$\langle$Write index of macro names {\footnotesize 24a}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case 'u': @$\langle$Write index of user-specified names {\footnotesize 26a}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case '@{\tt @}\verb@': putc(c, tex_file);@\\
\mbox{}\verb@    default:  c = source_get();@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 17b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Formatting Definitions}

We go through a fair amount of effort to format a file definition.
I've derived most of the \LaTeX\ commands experimentally; it's quite
likely that an expert could do a better job. The \LaTeX\ for
the previous macro definition should look like this (perhaps modulo
the scrap references):
{\small
\begin{verbatim}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap37}
$\langle$Interpret at-sequence {\footnotesize 18}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  int big_definition = FALSE;@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case 'O': big_definition = TRUE;@\\
\mbox{}\verb@    case 'o': @$\langle$Write output file definition {\footnotesize 19a}$\rangle$\verb@@\\
\end{verbatim}
\vdots
\begin{verbatim}
\mbox{}\verb@    case '@{\tt @}\verb@': putc(c, tex_file);@\\
\mbox{}\verb@    default:  c = source_get();@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 17b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\end{verbatim}}

\noindent
The {\em flushleft\/} environment is used to avoid \LaTeX\ warnings
about underful lines. The {\em minipage\/} environment is used to
avoid page breaks in the middle of scraps. The {\em verb\/} command
allows arbitrary characters to be printed (however, note the special
handling of the \verb|@| case in the switch statement).

Macro and file definitions are formatted nearly identically.
I've factored the common parts out into separate scraps.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap39}
$\langle$Write output file definition {\footnotesize 19a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *name = collect_file_name();@\\
\mbox{}\verb@  @$\langle$Begin the scrap environment {\footnotesize 19c}$\rangle$\verb@@\\
\mbox{}\verb@  fprintf(tex_file, "\\verb@{\tt @}\verb@\"%s\"@{\tt @}\verb@ {\\footnotesize ", name->spelling);@\\
\mbox{}\verb@  write_single_scrap_ref(tex_file, scraps++);@\\
\mbox{}\verb@  fputs(" }$\\equiv$\n", tex_file);@\\
\mbox{}\verb@  @$\langle$Fill in the middle of the scrap environment {\footnotesize 19d}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Write file defs {\footnotesize 20b}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Finish the scrap environment {\footnotesize 20a}$\rangle$\verb@@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 18.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
I don't format a macro name at all specially, figuring the programmer
might want to use italics or bold face in the midst of the name.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap40}
$\langle$Write macro definition {\footnotesize 19b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *name = collect_macro_name();@\\
\mbox{}\verb@  @$\langle$Begin the scrap environment {\footnotesize 19c}$\rangle$\verb@@\\
\mbox{}\verb@  fprintf(tex_file, "$\\langle$%s {\\footnotesize ", name->spelling);@\\
\mbox{}\verb@  write_single_scrap_ref(tex_file, scraps++);@\\
\mbox{}\verb@  fputs("}$\\rangle\\equiv$\n", tex_file);@\\
\mbox{}\verb@  @$\langle$Fill in the middle of the scrap environment {\footnotesize 19d}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Write macro defs {\footnotesize 20c}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Write macro refs {\footnotesize 21a}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Finish the scrap environment {\footnotesize 20a}$\rangle$\verb@@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 18.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap41}
$\langle$Begin the scrap environment {\footnotesize 19c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  fputs("\\begin{flushleft} \\small", tex_file);@\\
\mbox{}\verb@  if (!big_definition)@\\
\mbox{}\verb@    fputs("\n\\begin{minipage}{\\linewidth}", tex_file);@\\
\mbox{}\verb@  fprintf(tex_file, " \\label{scrap%d}\n", scraps);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 19ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The interesting things here are the $\Diamond$ inserted at the end of
each scrap and the various spacing commands. The diamond helps to
clearly indicate the end of a scrap. The spacing commands were derived
empirically; they may be adjusted to taste.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap42}
$\langle$Fill in the middle of the scrap environment {\footnotesize 19d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  fputs("\\vspace{-1ex}\n\\begin{list}{}{} \\item\n", tex_file);@\\
\mbox{}\verb@  copy_scrap(tex_file);@\\
\mbox{}\verb@  fputs("$\\Diamond$\n\\end{list}\n", tex_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 19ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\newpage
\noindent
We've got one last spacing command, controlling the amount of white
space after a scrap.

Note also the whitespace eater. I use it to remove any blank lines
that appear after a scrap in the source file. This way, text following
a scrap will not be indented. Again, this is a matter of personal taste.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap43}
$\langle$Finish the scrap environment {\footnotesize 20a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (!big_definition)@\\
\mbox{}\verb@    fputs("\\end{minipage}\\\\[4ex]\n", tex_file);@\\
\mbox{}\verb@  fputs("\\end{flushleft}\n", tex_file);@\\
\mbox{}\verb@  do@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  while (isspace(c));@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 19ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsubsection{Formatting Cross References}

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap44}
$\langle$Write file defs {\footnotesize 20b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (name->defs->next) {@\\
\mbox{}\verb@    fputs("\\vspace{-1ex}\n", tex_file);@\\
\mbox{}\verb@    fputs("\\footnotesize\\addtolength{\\baselineskip}{-1ex}\n", tex_file);@\\
\mbox{}\verb@    fputs("\\begin{list}{}{\\setlength{\\itemsep}{-\\parsep}", tex_file);@\\
\mbox{}\verb@    fputs("\\setlength{\\itemindent}{-\\leftmargin}}\n", tex_file);@\\
\mbox{}\verb@    fputs("\\item File defined by scraps ", tex_file);@\\
\mbox{}\verb@    print_scrap_numbers(tex_file, name->defs);@\\
\mbox{}\verb@    fputs("\\end{list}\n", tex_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    fputs("\\vspace{-2ex}\n", tex_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 19a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap45}
$\langle$Write macro defs {\footnotesize 20c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  fputs("\\vspace{-1ex}\n", tex_file);@\\
\mbox{}\verb@  fputs("\\footnotesize\\addtolength{\\baselineskip}{-1ex}\n", tex_file);@\\
\mbox{}\verb@  fputs("\\begin{list}{}{\\setlength{\\itemsep}{-\\parsep}", tex_file);@\\
\mbox{}\verb@  fputs("\\setlength{\\itemindent}{-\\leftmargin}}\n", tex_file);@\\
\mbox{}\verb@  if (name->defs->next) {@\\
\mbox{}\verb@    fputs("\\item Macro defined by scraps ", tex_file);@\\
\mbox{}\verb@    print_scrap_numbers(tex_file, name->defs);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 19b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap46}
$\langle$Write macro refs {\footnotesize 21a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (name->uses) {@\\
\mbox{}\verb@    if (name->uses->next) {@\\
\mbox{}\verb@      fputs("\\item Macro referenced in scraps ", tex_file);@\\
\mbox{}\verb@      print_scrap_numbers(tex_file, name->uses);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    else {@\\
\mbox{}\verb@      fputs("\\item Macro referenced in scrap ", tex_file);@\\
\mbox{}\verb@      write_single_scrap_ref(tex_file, name->uses->scrap);@\\
\mbox{}\verb@      fputs(".\n", tex_file);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    fputs("\\item Macro never referenced.\n", tex_file);@\\
\mbox{}\verb@    fprintf(stderr, "%s: <%s> never referenced.\n",@\\
\mbox{}\verb@            command_name, name->spelling);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  fputs("\\end{list}\n", tex_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 19b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap47}
\verb@"latex.c"@ {\footnotesize 21b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void print_scrap_numbers(tex_file, scraps)@\\
\mbox{}\verb@     FILE *tex_file;@\\
\mbox{}\verb@     Scrap_Node *scraps;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  int page;@\\
\mbox{}\verb@  write_scrap_ref(tex_file, scraps->scrap, TRUE, &page);@\\
\mbox{}\verb@  scraps = scraps->next;@\\
\mbox{}\verb@  while (scraps) {@\\
\mbox{}\verb@    write_scrap_ref(tex_file, scraps->scrap, FALSE, &page);@\\
\mbox{}\verb@    scraps = scraps->next;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  fputs(".\n", tex_file);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8d, 16d, 17a, 21b, 22a, 24b, 26b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsubsection{Formatting a Scrap}

We add a \verb|\mbox{}| at the beginning of each line to avoid
problems with older versions of \TeX.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap48}
\verb@"latex.c"@ {\footnotesize 22a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void copy_scrap(file)@\\
\mbox{}\verb@     FILE *file;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  int indent = 0;@\\
\mbox{}\verb@  int c = source_get();@\\
\mbox{}\verb@  fputs("\\mbox{}\\verb@{\tt @}\verb@", file);@\\
\mbox{}\verb@  while (1) {@\\
\mbox{}\verb@    switch (c) {@\\
\mbox{}\verb@      case '@{\tt @}\verb@':  @$\langle$Check at-sequence for end-of-scrap {\footnotesize 22c}$\rangle$\verb@@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '\n': fputs("@{\tt @}\verb@\\\\\n\\mbox{}\\verb@{\tt @}\verb@", file);@\\
\mbox{}\verb@                 indent = 0;@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '\t': @$\langle$Expand tab into spaces {\footnotesize 22b}$\rangle$\verb@@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      default:   putc(c, file);@\\
\mbox{}\verb@                 indent++;@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8d, 16d, 17a, 21b, 22a, 24b, 26b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap49}
$\langle$Expand tab into spaces {\footnotesize 22b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  int delta = 8 - (indent % 8);@\\
\mbox{}\verb@  indent += delta;@\\
\mbox{}\verb@  while (delta > 0) {@\\
\mbox{}\verb@    putc(' ', file);@\\
\mbox{}\verb@    delta--;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 22a, 33a, 51a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap50}
$\langle$Check at-sequence for end-of-scrap {\footnotesize 22c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case '@{\tt @}\verb@': fputs("@{\tt @}\verb@{\\tt @{\tt @}\verb@}\\verb@{\tt @}\verb@", file);@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case '|': @$\langle$Skip over index entries {\footnotesize 23a}$\rangle$\verb@@\\
\mbox{}\verb@    case '}': putc('@{\tt @}\verb@', file);@\\
\mbox{}\verb@              return;@\\
\mbox{}\verb@    case '<': @$\langle$Format macro name {\footnotesize 23b}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    default:  /* ignore these since pass1 will have warned about them */@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 22a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
There's no need to check for errors here, since we will have already
pointed out any during the first pass.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap51}
$\langle$Skip over index entries {\footnotesize 23a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  do {@\\
\mbox{}\verb@    do@\\
\mbox{}\verb@      c = source_get();@\\
\mbox{}\verb@    while (c != '@{\tt @}\verb@');@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  } while (c != '}');@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 22c, 33b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap52}
$\langle$Format macro name {\footnotesize 23b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *name = collect_scrap_name();@\\
\mbox{}\verb@  fprintf(file, "@{\tt @}\verb@$\\langle$%s {\\footnotesize ", name->spelling);@\\
\mbox{}\verb@  if (name->defs)@\\
\mbox{}\verb@    @$\langle$Write abbreviated definition list {\footnotesize 23c}$\rangle$\verb@@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    putc('?', file);@\\
\mbox{}\verb@    fprintf(stderr, "%s: scrap never defined <%s>\n",@\\
\mbox{}\verb@            command_name, name->spelling);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  fputs("}$\\rangle$\\verb@{\tt @}\verb@", file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 22c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap53}
$\langle$Write abbreviated definition list {\footnotesize 23c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Scrap_Node *p = name->defs;@\\
\mbox{}\verb@  write_single_scrap_ref(file, p->scrap);@\\
\mbox{}\verb@  p = p->next;@\\
\mbox{}\verb@  if (p)@\\
\mbox{}\verb@    fputs(", \\ldots\\ ", file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 23b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Generating the Indices}

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap54}
$\langle$Write index of file names {\footnotesize 23d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (file_names) {@\\
\mbox{}\verb@    fputs("\n{\\small\\begin{list}{}{\\setlength{\\itemsep}{-\\parsep}",@\\
\mbox{}\verb@          tex_file);@\\
\mbox{}\verb@    fputs("\\setlength{\\itemindent}{-\\leftmargin}}\n", tex_file);@\\
\mbox{}\verb@    format_entry(file_names, tex_file, TRUE);@\\
\mbox{}\verb@    fputs("\\end{list}}", tex_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 18.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap55}
$\langle$Write index of macro names {\footnotesize 24a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (macro_names) {@\\
\mbox{}\verb@    fputs("\n{\\small\\begin{list}{}{\\setlength{\\itemsep}{-\\parsep}",@\\
\mbox{}\verb@          tex_file);@\\
\mbox{}\verb@    fputs("\\setlength{\\itemindent}{-\\leftmargin}}\n", tex_file);@\\
\mbox{}\verb@    format_entry(macro_names, tex_file, FALSE);@\\
\mbox{}\verb@    fputs("\\end{list}}", tex_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 18.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap56}
\verb@"latex.c"@ {\footnotesize 24b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void format_entry(name, tex_file, file_flag)@\\
\mbox{}\verb@     Name *name;@\\
\mbox{}\verb@     FILE *tex_file;@\\
\mbox{}\verb@     int file_flag;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  while (name) {@\\
\mbox{}\verb@    format_entry(name->llink, tex_file, file_flag);@\\
\mbox{}\verb@    @$\langle$Format an index entry {\footnotesize 24c}$\rangle$\verb@@\\
\mbox{}\verb@    name = name->rlink;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8d, 16d, 17a, 21b, 22a, 24b, 26b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap57}
$\langle$Format an index entry {\footnotesize 24c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  fputs("\\item ", tex_file);@\\
\mbox{}\verb@  if (file_flag) {@\\
\mbox{}\verb@    fprintf(tex_file, "\\verb@{\tt @}\verb@\"%s\"@{\tt @}\verb@ ", name->spelling);@\\
\mbox{}\verb@    @$\langle$Write file's defining scrap numbers {\footnotesize 25a}$\rangle$\verb@@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    fprintf(tex_file, "$\\langle$%s {\\footnotesize ", name->spelling);@\\
\mbox{}\verb@    @$\langle$Write defining scrap numbers {\footnotesize 25b}$\rangle$\verb@@\\
\mbox{}\verb@    fputs("}$\\rangle$ ", tex_file);@\\
\mbox{}\verb@    @$\langle$Write referencing scrap numbers {\footnotesize 25c}$\rangle$\verb@@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  putc('\n', tex_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 24b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap58}
$\langle$Write file's defining scrap numbers {\footnotesize 25a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Scrap_Node *p = name->defs;@\\
\mbox{}\verb@  fputs("{\\footnotesize Defined by scrap", tex_file);@\\
\mbox{}\verb@  if (p->next) {@\\
\mbox{}\verb@    fputs("s ", tex_file);@\\
\mbox{}\verb@    print_scrap_numbers(tex_file, p);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    putc(' ', tex_file);@\\
\mbox{}\verb@    write_single_scrap_ref(tex_file, p->scrap);@\\
\mbox{}\verb@    putc('.', tex_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  putc('}', tex_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 24c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap59}
$\langle$Write defining scrap numbers {\footnotesize 25b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Scrap_Node *p = name->defs;@\\
\mbox{}\verb@  if (p) {@\\
\mbox{}\verb@    int page;@\\
\mbox{}\verb@    write_scrap_ref(tex_file, p->scrap, TRUE, &page);@\\
\mbox{}\verb@    p = p->next;@\\
\mbox{}\verb@    while (p) {@\\
\mbox{}\verb@      write_scrap_ref(tex_file, p->scrap, FALSE, &page);@\\
\mbox{}\verb@      p = p->next;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    putc('?', tex_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 24c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap60}
$\langle$Write referencing scrap numbers {\footnotesize 25c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Scrap_Node *p = name->uses;@\\
\mbox{}\verb@  fputs("{\\footnotesize ", tex_file);@\\
\mbox{}\verb@  if (p) {@\\
\mbox{}\verb@    fputs("Referenced in scrap", tex_file);@\\
\mbox{}\verb@    if (p->next) {@\\
\mbox{}\verb@      fputs("s ", tex_file);@\\
\mbox{}\verb@      print_scrap_numbers(tex_file, p);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    else {@\\
\mbox{}\verb@      putc(' ', tex_file);@\\
\mbox{}\verb@      write_single_scrap_ref(tex_file, p->scrap);@\\
\mbox{}\verb@      putc('.', tex_file);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    fputs("Not referenced.", tex_file);@\\
\mbox{}\verb@  putc('}', tex_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 24c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap61}
$\langle$Write index of user-specified names {\footnotesize 26a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (user_names) {@\\
\mbox{}\verb@    fputs("\n{\\small\\begin{list}{}{\\setlength{\\itemsep}{-\\parsep}",@\\
\mbox{}\verb@          tex_file);@\\
\mbox{}\verb@    fputs("\\setlength{\\itemindent}{-\\leftmargin}}\n", tex_file);@\\
\mbox{}\verb@    format_user_entry(user_names, tex_file);@\\
\mbox{}\verb@    fputs("\\end{list}}", tex_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 18.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap62}
\verb@"latex.c"@ {\footnotesize 26b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void format_user_entry(name, tex_file)@\\
\mbox{}\verb@     Name *name;@\\
\mbox{}\verb@     FILE *tex_file;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  while (name) {@\\
\mbox{}\verb@    format_user_entry(name->llink, tex_file);@\\
\mbox{}\verb@    @$\langle$Format a user index entry {\footnotesize 27a}$\rangle$\verb@@\\
\mbox{}\verb@    name = name->rlink;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8d, 16d, 17a, 21b, 22a, 24b, 26b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap63}
$\langle$Format a user index entry {\footnotesize 27a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Scrap_Node *uses = name->uses;@\\
\mbox{}\verb@  if (uses) {@\\
\mbox{}\verb@    int page;@\\
\mbox{}\verb@    Scrap_Node *defs = name->defs;@\\
\mbox{}\verb@    fprintf(tex_file, "\\item \\verb@{\tt @}\verb@%s@{\tt @}\verb@: ", name->spelling);@\\
\mbox{}\verb@    if (uses->scrap < defs->scrap) {@\\
\mbox{}\verb@      write_scrap_ref(tex_file, uses->scrap, TRUE, &page);@\\
\mbox{}\verb@      uses = uses->next;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    else {@\\
\mbox{}\verb@      if (defs->scrap == uses->scrap)@\\
\mbox{}\verb@        uses = uses->next;@\\
\mbox{}\verb@      fputs("\\underline{", tex_file);@\\
\mbox{}\verb@      write_single_scrap_ref(tex_file, defs->scrap);@\\
\mbox{}\verb@      putc('}', tex_file);@\\
\mbox{}\verb@      page = -2;@\\
\mbox{}\verb@      defs = defs->next;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    while (uses || defs) {@\\
\mbox{}\verb@      if (uses && (!defs || uses->scrap < defs->scrap)) {@\\
\mbox{}\verb@        write_scrap_ref(tex_file, uses->scrap, FALSE, &page);@\\
\mbox{}\verb@        uses = uses->next;@\\
\mbox{}\verb@      }@\\
\mbox{}\verb@      else {@\\
\mbox{}\verb@        if (uses && defs->scrap == uses->scrap)@\\
\mbox{}\verb@          uses = uses->next;@\\
\mbox{}\verb@        fputs(", \\underline{", tex_file);@\\
\mbox{}\verb@        write_single_scrap_ref(tex_file, defs->scrap);@\\
\mbox{}\verb@        putc('}', tex_file);@\\
\mbox{}\verb@        page = -2;@\\
\mbox{}\verb@        defs = defs->next;@\\
\mbox{}\verb@      }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    fputs(".\n", tex_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 26b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\section{Writing the LaTeX File with HTML Scraps} \label{html-file} 

The HTML generated is patterned closely upon the {\LaTeX} generated in
the previous section.\footnote{\relax While writing this section, I
tried to follow Preston's style as displayed in
Section~\ref{latex-file}---J. D. R.}  When a file name ends in
\verb|.hw|, the second pass (invoked via a call to \verb|write_html|)
copies most of the text from the source file straight into a
\verb|.tex| file.  Definitions are formatted slightly and
cross-reference information is printed out.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap64}
$\langle$Function prototypes {\footnotesize 27b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern void write_html();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
We need a few local function declarations before we get into the body
of \verb|write_html|.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap65}
\verb@"html.c"@ {\footnotesize 28a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void copy_scrap();               /* formats the body of a scrap */@\\
\mbox{}\verb@static void display_scrap_ref();        /* formats a scrap reference */@\\
\mbox{}\verb@static void display_scrap_numbers();    /* formats a list of scrap numbers */@\\
\mbox{}\verb@static void print_scrap_numbers();      /* pluralizes scrap formats list */@\\
\mbox{}\verb@static void format_entry();             /* formats an index entry */@\\
\mbox{}\verb@static void format_user_entry();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8e, 28ab, 32abc, 33a, 35a, 36c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The routine \verb|write_html| takes two file names as parameters: the
name of the web source file and the name of the \verb|.tex| output file.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap66}
\verb@"html.c"@ {\footnotesize 28b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void write_html(file_name, html_name)@\\
\mbox{}\verb@     char *file_name;@\\
\mbox{}\verb@     char *html_name;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  FILE *html_file = fopen(html_name, "w");@\\
\mbox{}\verb@  if (html_file) {@\\
\mbox{}\verb@    if (verbose_flag)@\\
\mbox{}\verb@      fprintf(stderr, "writing %s\n", html_name);@\\
\mbox{}\verb@    source_open(file_name);@\\
\mbox{}\verb@    @$\langle$Copy \verb|source_file| into \verb|html_file| {\footnotesize 28c}$\rangle$\verb@@\\
\mbox{}\verb@    fclose(html_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    fprintf(stderr, "%s: can't open %s\n", command_name, html_name);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8e, 28ab, 32abc, 33a, 35a, 36c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
We make our second (and final) pass through the source web, this time
copying characters straight into the \verb|.tex| file. However, we keep
an eye peeled for \verb|@|~characters, which signal a command sequence.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap67}
$\langle$Copy \verb|source_file| into \verb|html_file| {\footnotesize 28c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  int scraps = 1;@\\
\mbox{}\verb@  int c = source_get();@\\
\mbox{}\verb@  while (c != EOF) {@\\
\mbox{}\verb@    if (c == '@{\tt @}\verb@')@\\
\mbox{}\verb@      @$\langle$Interpret HTML at-sequence {\footnotesize 29}$\rangle$\verb@@\\
\mbox{}\verb@    else {@\\
\mbox{}\verb@      putc(c, html_file);@\\
\mbox{}\verb@      c = source_get();@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 28b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap68}
$\langle$Interpret HTML at-sequence {\footnotesize 29}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case 'O': @\\
\mbox{}\verb@    case 'o': @$\langle$Write HTML output file definition {\footnotesize 30a}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case 'D': @\\
\mbox{}\verb@    case 'd': @$\langle$Write HTML macro definition {\footnotesize 30c}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case 'f': @$\langle$Write HTML index of file names {\footnotesize 34c}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case 'm': @$\langle$Write HTML index of macro names {\footnotesize 34d}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case 'u': @$\langle$Write HTML index of user-specified names {\footnotesize 36b}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case '@{\tt @}\verb@': putc(c, html_file);@\\
\mbox{}\verb@    default:  c = source_get();@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 28c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Formatting Definitions}

We go through only a little amount of effort to format a definition.
The HTML for the previous macro definition should look like this
(perhaps modulo the scrap references):

\begin{verbatim}
<pre>
<a name="nuweb68">&lt;Interpret HTML at-sequence 68&gt;</a> =
{
  c = source_get();
  switch (c) {
    case 'O': 
    case 'o': &lt;Write HTML output file definition <a href="#nuweb69">69</a>&gt;
              break;
    case 'D': 
    case 'd': &lt;Write HTML macro definition <a href="#nuweb71">71</a>&gt;
              break;
    case 'f': &lt;Write HTML index of file names <a href="#nuweb86">86</a>&gt;
              break;
    case 'm': &lt;Write HTML index of macro names <a href="#nuweb87">87</a>&gt;
              break;
    case 'u': &lt;Write HTML index of user-specified names <a href="#nuweb93">93</a>&gt;
              break;
    case '@': putc(c, html_file);
    default:  c = source_get();
              break;
  }
}&lt;&gt;</pre>
Macro referenced in scrap <a href="#nuweb67">67</a>.
<br>
\end{verbatim}

Macro and file definitions are formatted nearly identically.
I've factored the common parts out into separate scraps.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap69}
$\langle$Write HTML output file definition {\footnotesize 30a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *name = collect_file_name();@\\
\mbox{}\verb@  @$\langle$Begin HTML scrap environment {\footnotesize 30e}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Write HTML output file declaration {\footnotesize 30b}$\rangle$\verb@@\\
\mbox{}\verb@  scraps++;@\\
\mbox{}\verb@  @$\langle$Fill in the middle of HTML scrap environment {\footnotesize 31a}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Write HTML file defs {\footnotesize 31c}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Finish HTML scrap environment {\footnotesize 31b}$\rangle$\verb@@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 29.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap70}
$\langle$Write HTML output file declaration {\footnotesize 30b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@  fputs("<a name=\"nuweb", html_file);@\\
\mbox{}\verb@  write_single_scrap_ref(html_file, scraps);@\\
\mbox{}\verb@  fprintf(html_file, "\"><code>\"%s\"</code> ", name->spelling);@\\
\mbox{}\verb@  write_single_scrap_ref(html_file, scraps);@\\
\mbox{}\verb@  fputs("</a> =\n", html_file);@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 30a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap71}
$\langle$Write HTML macro definition {\footnotesize 30c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *name = collect_macro_name();@\\
\mbox{}\verb@  @$\langle$Begin HTML scrap environment {\footnotesize 30e}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Write HTML macro declaration {\footnotesize 30d}$\rangle$\verb@@\\
\mbox{}\verb@  scraps++;@\\
\mbox{}\verb@  @$\langle$Fill in the middle of HTML scrap environment {\footnotesize 31a}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Write HTML macro defs {\footnotesize 31d}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Write HTML macro refs {\footnotesize 31e}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Finish HTML scrap environment {\footnotesize 31b}$\rangle$\verb@@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 29.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
I don't format a macro name at all specially, figuring the programmer
might want to use italics or bold face in the midst of the name.  Note
that in this implementation, programmers may only use directives in
macro names that are recognized in preformatted text elements (PRE).

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap72}
$\langle$Write HTML macro declaration {\footnotesize 30d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@  fputs("<a name=\"nuweb", html_file);@\\
\mbox{}\verb@  write_single_scrap_ref(html_file, scraps);@\\
\mbox{}\verb@  fprintf(html_file, "\">&lt;%s ", name->spelling);@\\
\mbox{}\verb@  write_single_scrap_ref(html_file, scraps);@\\
\mbox{}\verb@  fputs("&gt;</a> =\n", html_file);@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 30c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap73}
$\langle$Begin HTML scrap environment {\footnotesize 30e}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  fputs("\\begin{rawhtml}\n", html_file);@\\
\mbox{}\verb@  fputs("<pre>\n", html_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 30ac.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The end of a scrap is marked with the characters \verb|<>|.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap74}
$\langle$Fill in the middle of HTML scrap environment {\footnotesize 31a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  copy_scrap(html_file);@\\
\mbox{}\verb@  fputs("&lt;&gt;</pre>\n", html_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 30ac.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
The only task remaining is to get rid of the current at command and
end the paragraph.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap75}
$\langle$Finish HTML scrap environment {\footnotesize 31b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  fputs("\\end{rawhtml}\n", html_file);@\\
\mbox{}\verb@  c = source_get(); /* Get rid of current at command. */@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 30ac.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsubsection{Formatting Cross References}

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap76}
$\langle$Write HTML file defs {\footnotesize 31c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (name->defs->next) {@\\
\mbox{}\verb@    fputs("File defined by ", html_file);@\\
\mbox{}\verb@    print_scrap_numbers(html_file, name->defs);@\\
\mbox{}\verb@    fputs("<br>\n", html_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 30a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap77}
$\langle$Write HTML macro defs {\footnotesize 31d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (name->defs->next) {@\\
\mbox{}\verb@    fputs("Macro defined by ", html_file);@\\
\mbox{}\verb@    print_scrap_numbers(html_file, name->defs);@\\
\mbox{}\verb@    fputs("<br>\n", html_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 30c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap78}
$\langle$Write HTML macro refs {\footnotesize 31e}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (name->uses) {@\\
\mbox{}\verb@    fputs("Macro referenced in ", html_file);@\\
\mbox{}\verb@    print_scrap_numbers(html_file, name->uses);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    fputs("Macro never referenced.\n", html_file);@\\
\mbox{}\verb@    fprintf(stderr, "%s: <%s> never referenced.\n",@\\
\mbox{}\verb@            command_name, name->spelling);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  fputs("<br>\n", html_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 30c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap79}
\verb@"html.c"@ {\footnotesize 32a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void display_scrap_ref(html_file, num)@\\
\mbox{}\verb@     FILE *html_file;@\\
\mbox{}\verb@     int num;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  fputs("<a href=\"#nuweb", html_file);@\\
\mbox{}\verb@  write_single_scrap_ref(html_file, num);@\\
\mbox{}\verb@  fputs("\">", html_file);@\\
\mbox{}\verb@  write_single_scrap_ref(html_file, num);@\\
\mbox{}\verb@  fputs("</a>", html_file);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8e, 28ab, 32abc, 33a, 35a, 36c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap80}
\verb@"html.c"@ {\footnotesize 32b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void display_scrap_numbers(html_file, scraps)@\\
\mbox{}\verb@     FILE *html_file;@\\
\mbox{}\verb@     Scrap_Node *scraps;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  display_scrap_ref(html_file, scraps->scrap);@\\
\mbox{}\verb@  scraps = scraps->next;@\\
\mbox{}\verb@  while (scraps) {@\\
\mbox{}\verb@    fputs(", ", html_file);@\\
\mbox{}\verb@    display_scrap_ref(html_file, scraps->scrap);@\\
\mbox{}\verb@    scraps = scraps->next;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8e, 28ab, 32abc, 33a, 35a, 36c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap81}
\verb@"html.c"@ {\footnotesize 32c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void print_scrap_numbers(html_file, scraps)@\\
\mbox{}\verb@     FILE *html_file;@\\
\mbox{}\verb@     Scrap_Node *scraps;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  fputs("scrap", html_file);@\\
\mbox{}\verb@  if (scraps->next) fputc('s', html_file);@\\
\mbox{}\verb@  fputc(' ', html_file);@\\
\mbox{}\verb@  display_scrap_numbers(html_file, scraps);@\\
\mbox{}\verb@  fputs(".\n", html_file);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8e, 28ab, 32abc, 33a, 35a, 36c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsubsection{Formatting a Scrap}

We must translate HTML special keywords into entities in scraps.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap82}
\verb@"html.c"@ {\footnotesize 33a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void copy_scrap(file)@\\
\mbox{}\verb@     FILE *file;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  int indent = 0;@\\
\mbox{}\verb@  int c = source_get();@\\
\mbox{}\verb@  while (1) {@\\
\mbox{}\verb@    switch (c) {@\\
\mbox{}\verb@      case '@{\tt @}\verb@':  @$\langle$Check HTML at-sequence for end-of-scrap {\footnotesize 33b}$\rangle$\verb@@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '<' : fputs("&lt;", file);@\\
\mbox{}\verb@                 indent++;@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '>' : fputs("&gt;", file);@\\
\mbox{}\verb@                 indent++;@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '&' : fputs("&amp;", file);@\\
\mbox{}\verb@                 indent++;@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '\n': fputc(c, file);@\\
\mbox{}\verb@                 indent = 0;@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '\t': @$\langle$Expand tab into spaces {\footnotesize 22b}$\rangle$\verb@@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      default:   putc(c, file);@\\
\mbox{}\verb@                 indent++;@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8e, 28ab, 32abc, 33a, 35a, 36c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap83}
$\langle$Check HTML at-sequence for end-of-scrap {\footnotesize 33b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case '@{\tt @}\verb@': fputc(c, file);@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case '|': @$\langle$Skip over index entries {\footnotesize 23a}$\rangle$\verb@@\\
\mbox{}\verb@    case '}': return;@\\
\mbox{}\verb@    case '<': @$\langle$Format HTML macro name {\footnotesize 34a}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    default:  /* ignore these since pass1 will have warned about them */@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 33a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
There's no need to check for errors here, since we will have already
pointed out any during the first pass.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap84}
$\langle$Format HTML macro name {\footnotesize 34a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *name = collect_scrap_name();@\\
\mbox{}\verb@  fprintf(file, "&lt;%s ", name->spelling);@\\
\mbox{}\verb@  if (name->defs)@\\
\mbox{}\verb@    @$\langle$Write HTML abbreviated definition list {\footnotesize 34b}$\rangle$\verb@@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    putc('?', file);@\\
\mbox{}\verb@    fprintf(stderr, "%s: scrap never defined <%s>\n",@\\
\mbox{}\verb@            command_name, name->spelling);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  fputs("&gt;", file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 33b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap85}
$\langle$Write HTML abbreviated definition list {\footnotesize 34b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Scrap_Node *p = name->defs;@\\
\mbox{}\verb@  display_scrap_ref(file, p->scrap);@\\
\mbox{}\verb@  if (p->next)@\\
\mbox{}\verb@    fputs(", ... ", file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 34a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Generating the Indices}

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap86}
$\langle$Write HTML index of file names {\footnotesize 34c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (file_names) {@\\
\mbox{}\verb@    fputs("\\begin{rawhtml}\n", html_file);@\\
\mbox{}\verb@    fputs("<dl compact>\n", html_file);@\\
\mbox{}\verb@    format_entry(file_names, html_file, TRUE);@\\
\mbox{}\verb@    fputs("</dl>\n", html_file);@\\
\mbox{}\verb@    fputs("\\end{rawhtml}\n", html_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 29.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap87}
$\langle$Write HTML index of macro names {\footnotesize 34d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (macro_names) {@\\
\mbox{}\verb@    fputs("\\begin{rawhtml}\n", html_file);@\\
\mbox{}\verb@    fputs("<dl compact>\n", html_file);@\\
\mbox{}\verb@    format_entry(macro_names, html_file, FALSE);@\\
\mbox{}\verb@    fputs("</dl>\n", html_file);@\\
\mbox{}\verb@    fputs("\\end{rawhtml}\n", html_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 29.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap88}
\verb@"html.c"@ {\footnotesize 35a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void format_entry(name, html_file, file_flag)@\\
\mbox{}\verb@     Name *name;@\\
\mbox{}\verb@     FILE *html_file;@\\
\mbox{}\verb@     int file_flag;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  while (name) {@\\
\mbox{}\verb@    format_entry(name->llink, html_file, file_flag);@\\
\mbox{}\verb@    @$\langle$Format an HTML index entry {\footnotesize 35b}$\rangle$\verb@@\\
\mbox{}\verb@    name = name->rlink;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8e, 28ab, 32abc, 33a, 35a, 36c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap89}
$\langle$Format an HTML index entry {\footnotesize 35b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  fputs("<dt> ", html_file);@\\
\mbox{}\verb@  if (file_flag) {@\\
\mbox{}\verb@    fprintf(html_file, "<code>\"%s\"</code>\n<dd> ", name->spelling);@\\
\mbox{}\verb@    @$\langle$Write HTML file's defining scrap numbers {\footnotesize 35c}$\rangle$\verb@@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    fprintf(html_file, "&lt;%s ", name->spelling);@\\
\mbox{}\verb@    @$\langle$Write HTML defining scrap numbers {\footnotesize 35d}$\rangle$\verb@@\\
\mbox{}\verb@    fputs("&gt;\n<dd> ", html_file);@\\
\mbox{}\verb@    @$\langle$Write HTML referencing scrap numbers {\footnotesize 36a}$\rangle$\verb@@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  putc('\n', html_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 35a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap90}
$\langle$Write HTML file's defining scrap numbers {\footnotesize 35c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  fputs("Defined by ", html_file);@\\
\mbox{}\verb@  print_scrap_numbers(html_file, name->defs);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 35b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap91}
$\langle$Write HTML defining scrap numbers {\footnotesize 35d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (name->defs)@\\
\mbox{}\verb@    display_scrap_numbers(html_file, name->defs);@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    putc('?', html_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 35b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap92}
$\langle$Write HTML referencing scrap numbers {\footnotesize 36a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Scrap_Node *p = name->uses;@\\
\mbox{}\verb@  if (p) {@\\
\mbox{}\verb@    fputs("Referenced in ", html_file);@\\
\mbox{}\verb@    print_scrap_numbers(html_file, p);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    fputs("Not referenced.\n", html_file);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 35b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap93}
$\langle$Write HTML index of user-specified names {\footnotesize 36b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (user_names) {@\\
\mbox{}\verb@    fputs("\\begin{rawhtml}\n", html_file);@\\
\mbox{}\verb@    fputs("<dl compact>\n", html_file);@\\
\mbox{}\verb@    format_user_entry(user_names, html_file);@\\
\mbox{}\verb@    fputs("</dl>\n", html_file);@\\
\mbox{}\verb@    fputs("\\end{rawhtml}\n", html_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 29.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap94}
\verb@"html.c"@ {\footnotesize 36c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void format_user_entry(name, html_file)@\\
\mbox{}\verb@     Name *name;@\\
\mbox{}\verb@     FILE *html_file;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  while (name) {@\\
\mbox{}\verb@    format_user_entry(name->llink, html_file);@\\
\mbox{}\verb@    @$\langle$Format a user HTML index entry {\footnotesize 37a}$\rangle$\verb@@\\
\mbox{}\verb@    name = name->rlink;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8e, 28ab, 32abc, 33a, 35a, 36c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap95}
$\langle$Format a user HTML index entry {\footnotesize 37a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Scrap_Node *uses = name->uses;@\\
\mbox{}\verb@  if (uses) {@\\
\mbox{}\verb@    Scrap_Node *defs = name->defs;@\\
\mbox{}\verb@    fprintf(html_file, "<dt><code>%s</code>:\n<dd> ", name->spelling);@\\
\mbox{}\verb@    if (uses->scrap < defs->scrap) {@\\
\mbox{}\verb@      display_scrap_ref(html_file, uses->scrap);@\\
\mbox{}\verb@      uses = uses->next;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    else {@\\
\mbox{}\verb@      if (defs->scrap == uses->scrap)@\\
\mbox{}\verb@        uses = uses->next;@\\
\mbox{}\verb@      fputs("<strong>", html_file);@\\
\mbox{}\verb@      display_scrap_ref(html_file, defs->scrap);@\\
\mbox{}\verb@      fputs("</strong>", html_file);@\\
\mbox{}\verb@      defs = defs->next;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    while (uses || defs) {@\\
\mbox{}\verb@      fputs(", ", html_file);@\\
\mbox{}\verb@      if (uses && (!defs || uses->scrap < defs->scrap)) {@\\
\mbox{}\verb@        display_scrap_ref(html_file, uses->scrap);@\\
\mbox{}\verb@        uses = uses->next;@\\
\mbox{}\verb@      }@\\
\mbox{}\verb@      else {@\\
\mbox{}\verb@        if (uses && defs->scrap == uses->scrap)@\\
\mbox{}\verb@          uses = uses->next;@\\
\mbox{}\verb@        fputs("<strong>", html_file);@\\
\mbox{}\verb@        display_scrap_ref(html_file, defs->scrap);@\\
\mbox{}\verb@        fputs("</strong>", html_file);@\\
\mbox{}\verb@        defs = defs->next;@\\
\mbox{}\verb@      }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    fputs(".\n", html_file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 36c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\section{Writing the Output Files} \label{output-files}

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap96}
$\langle$Function prototypes {\footnotesize 37b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern void write_files();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap97}
\verb@"output.c"@ {\footnotesize 37c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void write_files(files)@\\
\mbox{}\verb@     Name *files;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  while (files) {@\\
\mbox{}\verb@    write_files(files->llink);@\\
\mbox{}\verb@    @$\langle$Write out \verb|files->spelling| {\footnotesize 38a}$\rangle$\verb@@\\
\mbox{}\verb@    files = files->rlink;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 8f, 37c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
We call \verb|tempnam|, causing it to create a file name in the
current directory.  This could cause a problem for \verb|rename| if
the eventual output file will reside on a different file system.
Perhaps it would be better to examine \verb|files->spelling| to find
any directory information.

Note the superfluous call to \verb|remove| before \verb|rename|.
We're using it get around a bug in some implementations of
\verb|rename|.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap98}
$\langle$Write out \verb|files->spelling| {\footnotesize 38a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  char indent_chars[500];@\\
\mbox{}\verb@  FILE *temp_file;@\\
\mbox{}\verb@  char *temp_name = tempnam(".", 0);@\\
\mbox{}\verb@  temp_file = fopen(temp_name, "w");@\\
\mbox{}\verb@  if (!temp_file) {@\\
\mbox{}\verb@    fprintf(stderr, "%s: can't create %s for a temporary file\n",@\\
\mbox{}\verb@            command_name, temp_name);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }  @\\
\mbox{}\verb@  if (verbose_flag)@\\
\mbox{}\verb@    fprintf(stderr, "writing %s\n", files->spelling);@\\
\mbox{}\verb@  write_scraps(temp_file, files->defs, 0, indent_chars,@\\
\mbox{}\verb@               files->debug_flag, files->tab_flag, files->indent_flag);@\\
\mbox{}\verb@  fclose(temp_file);@\\
\mbox{}\verb@  if (compare_flag)@\\
\mbox{}\verb@    @$\langle$Compare the temp file and the old file {\footnotesize 38b}$\rangle$\verb@@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    remove(files->spelling);@\\
\mbox{}\verb@    rename(temp_name, files->spelling);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 37c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Again, we use a call to \verb|remove| before \verb|rename|.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap99}
$\langle$Compare the temp file and the old file {\footnotesize 38b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  FILE *old_file = fopen(files->spelling, "r");@\\
\mbox{}\verb@  if (old_file) {@\\
\mbox{}\verb@    int x, y;@\\
\mbox{}\verb@    temp_file = fopen(temp_name, "r");@\\
\mbox{}\verb@    do {@\\
\mbox{}\verb@      x = getc(old_file);@\\
\mbox{}\verb@      y = getc(temp_file);@\\
\mbox{}\verb@    } while (x == y && x != EOF);@\\
\mbox{}\verb@    fclose(old_file);@\\
\mbox{}\verb@    fclose(temp_file);@\\
\mbox{}\verb@    if (x == y)@\\
\mbox{}\verb@      remove(temp_name);@\\
\mbox{}\verb@    else {@\\
\mbox{}\verb@      remove(files->spelling);@\\
\mbox{}\verb@      rename(temp_name, files->spelling);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    rename(temp_name, files->spelling);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 38a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\chapter{The Support Routines}

\section{Source Files} \label{source-files}

\subsection{Global Declarations}

We need two routines to handle reading the source files.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap100}
$\langle$Function prototypes {\footnotesize 39a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern void source_open(); /* pass in the name of the source file */@\\
\mbox{}\verb@extern int source_get();   /* no args; returns the next char or EOF */@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
There are also two global variables maintained for use in error
messages and such.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap101}
$\langle$Global variable declarations {\footnotesize 39b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern char *source_name;  /* name of the current file */@\\
\mbox{}\verb@extern int source_line;    /* current line in the source file */@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10ac, 39b, 44d, 53b.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap102}
$\langle$Global variable definitions {\footnotesize 39c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@char *source_name = NULL;@\\
\mbox{}\verb@int source_line = 0;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10bd, 39c, 45a, 53c.
\item Macro referenced in scrap 9e.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Local Declarations}


\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap103}
\verb@"input.c"@ {\footnotesize 39d }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static FILE *source_file;  /* the current input file */@\\
\mbox{}\verb@static int source_peek;@\\
\mbox{}\verb@static int double_at;@\\
\mbox{}\verb@static int include_depth;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9a, 39d, 40ab, 42c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap104}
\verb@"input.c"@ {\footnotesize 40a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static struct {@\\
\mbox{}\verb@  FILE *file;@\\
\mbox{}\verb@  char *name;@\\
\mbox{}\verb@  int line;@\\
\mbox{}\verb@} stack[10];@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9a, 39d, 40ab, 42c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Reading a File}

The routine \verb|source_get| returns the next character from the
current source file. It notices newlines and keeps the line counter 
\verb|source_line| up to date. It also catches \verb|EOF| and watches
for \verb|@|~characters. All other characters are immediately returned.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap105}
\verb@"input.c"@ {\footnotesize 40b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@int source_get()@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  int c = source_peek;@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case EOF:  @$\langle$Handle \verb|EOF| {\footnotesize 42b}$\rangle$\verb@@\\
\mbox{}\verb@               return c;@\\
\mbox{}\verb@    case '@{\tt @}\verb@':  @$\langle$Handle an ``at'' character {\footnotesize 41a}$\rangle$\verb@@\\
\mbox{}\verb@               return c;@\\
\mbox{}\verb@    case '\n': source_line++;@\\
\mbox{}\verb@    default:   source_peek = getc(source_file);@\\
\mbox{}\verb@               return c;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9a, 39d, 40ab, 42c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
This whole \verb|@|~character handling mess is pretty annoying.
I want to recognize \verb|@i| so I can handle include files correctly.
At the same time, it makes sense to recognize illegal \verb|@|~sequences
and complain; this avoids ever having to check anywhere else.
Unfortunately, I need to avoid tripping over the \verb|@@|~sequence;
hence this whole unsatisfactory \verb|double_at| business.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap106}
$\langle$Handle an ``at'' character {\footnotesize 41a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  c = getc(source_file);@\\
\mbox{}\verb@  if (double_at) {@\\
\mbox{}\verb@    source_peek = c;@\\
\mbox{}\verb@    double_at = FALSE;@\\
\mbox{}\verb@    c = '@{\tt @}\verb@';@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    switch (c) {@\\
\mbox{}\verb@      case 'i': @$\langle$Open an include file {\footnotesize 41b}$\rangle$\verb@@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@      case 'f': case 'm': case 'u':@\\
\mbox{}\verb@      case 'd': case 'o': case 'D': case 'O':@\\
\mbox{}\verb@      case '{': case '}': case '<': case '>': case '|':@\\
\mbox{}\verb@                source_peek = c;@\\
\mbox{}\verb@                c = '@{\tt @}\verb@';@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@      case '@{\tt @}\verb@': source_peek = c;@\\
\mbox{}\verb@                double_at = TRUE;@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@      default:  fprintf(stderr, "%s: bad @{\tt @}\verb@ sequence (%s, line %d)\n",@\\
\mbox{}\verb@                        command_name, source_name, source_line);@\\
\mbox{}\verb@                exit(-1);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 40b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap107}
$\langle$Open an include file {\footnotesize 41b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  char name[100];@\\
\mbox{}\verb@  if (include_depth >= 10) {@\\
\mbox{}\verb@    fprintf(stderr, "%s: include nesting too deep (%s, %d)\n",@\\
\mbox{}\verb@            command_name, source_name, source_line);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  @$\langle$Collect include-file name {\footnotesize 42a}$\rangle$\verb@@\\
\mbox{}\verb@  stack[include_depth].name = source_name;@\\
\mbox{}\verb@  stack[include_depth].file = source_file;@\\
\mbox{}\verb@  stack[include_depth].line = source_line + 1;@\\
\mbox{}\verb@  include_depth++;@\\
\mbox{}\verb@  source_line = 1;@\\
\mbox{}\verb@  source_name = save_string(name);@\\
\mbox{}\verb@  source_file = fopen(source_name, "r");@\\
\mbox{}\verb@  if (!source_file) {@\\
\mbox{}\verb@    fprintf(stderr, "%s: can't open include file %s\n",@\\
\mbox{}\verb@     command_name, source_name);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  source_peek = getc(source_file);@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 41a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap108}
$\langle$Collect include-file name {\footnotesize 42a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@    char *p = name;@\\
\mbox{}\verb@    do @\\
\mbox{}\verb@      c = getc(source_file);@\\
\mbox{}\verb@    while (c == ' ' || c == '\t');@\\
\mbox{}\verb@    while (isgraph(c)) {@\\
\mbox{}\verb@      *p++ = c;@\\
\mbox{}\verb@      c = getc(source_file);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    *p = '\0';@\\
\mbox{}\verb@    if (c != '\n') {@\\
\mbox{}\verb@      fprintf(stderr, "%s: unexpected characters after file name (%s, %d)\n",@\\
\mbox{}\verb@              command_name, source_name, source_line);@\\
\mbox{}\verb@      exit(-1);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 41b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
If an \verb|EOF| is discovered, the current file must be closed and
input from the next stacked file must be resumed. If no more files are
on the stack, the \verb|EOF| is returned.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap109}
$\langle$Handle \verb|EOF| {\footnotesize 42b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  fclose(source_file);@\\
\mbox{}\verb@  if (include_depth) {@\\
\mbox{}\verb@    include_depth--;@\\
\mbox{}\verb@    source_file = stack[include_depth].file;@\\
\mbox{}\verb@    source_line = stack[include_depth].line;@\\
\mbox{}\verb@    source_name = stack[include_depth].name;@\\
\mbox{}\verb@    source_peek = getc(source_file);@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 40b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Opening a File}

The routine \verb|source_open| takes a file name and tries to open the
file. If unsuccessful, it complains and halts. Otherwise, it sets 
\verb|source_name|, \verb|source_line|, and \verb|double_at|.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap110}
\verb@"input.c"@ {\footnotesize 42c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void source_open(name)@\\
\mbox{}\verb@     char *name;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  source_file = fopen(name, "r");@\\
\mbox{}\verb@  if (!source_file) {@\\
\mbox{}\verb@    fprintf(stderr, "%s: couldn't open %s\n", command_name, name);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  source_name = name;@\\
\mbox{}\verb@  source_line = 1;@\\
\mbox{}\verb@  source_peek = getc(source_file);@\\
\mbox{}\verb@  double_at = FALSE;@\\
\mbox{}\verb@  include_depth = 0;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9a, 39d, 40ab, 42c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\section{Scraps} \label{scraps}


\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap111}
\verb@"scraps.c"@ {\footnotesize 43a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#define SLAB_SIZE 500@\\
\mbox{}\verb@@\\
\mbox{}\verb@typedef struct slab {@\\
\mbox{}\verb@  struct slab *next;@\\
\mbox{}\verb@  char chars[SLAB_SIZE];@\\
\mbox{}\verb@} Slab;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap112}
\verb@"scraps.c"@ {\footnotesize 43b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@typedef struct {@\\
\mbox{}\verb@  char *file_name;@\\
\mbox{}\verb@  int file_line;@\\
\mbox{}\verb@  int page;@\\
\mbox{}\verb@  char letter;@\\
\mbox{}\verb@  Slab *slab;@\\
\mbox{}\verb@} ScrapEntry;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap113}
\verb@"scraps.c"@ {\footnotesize 43c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static ScrapEntry *SCRAP[256];@\\
\mbox{}\verb@@\\
\mbox{}\verb@#define scrap_array(i) SCRAP[(i) >> 8][(i) & 255]@\\
\mbox{}\verb@@\\
\mbox{}\verb@static int scraps;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap114}
$\langle$Function prototypes {\footnotesize 43d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern void init_scraps();@\\
\mbox{}\verb@extern int collect_scrap();@\\
\mbox{}\verb@extern int write_scraps();@\\
\mbox{}\verb@extern void write_scrap_ref();@\\
\mbox{}\verb@extern void write_single_scrap_ref();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap115}
\verb@"scraps.c"@ {\footnotesize 43e }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void init_scraps()@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  scraps = 1;@\\
\mbox{}\verb@  SCRAP[0] = (ScrapEntry *) arena_getmem(256 * sizeof(ScrapEntry));@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap116}
\verb@"scraps.c"@ {\footnotesize 44a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void write_scrap_ref(file, num, first, page)@\\
\mbox{}\verb@     FILE *file;@\\
\mbox{}\verb@     int num;@\\
\mbox{}\verb@     int first;@\\
\mbox{}\verb@     int *page;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  if (scrap_array(num).page >= 0) {@\\
\mbox{}\verb@    if (first)@\\
\mbox{}\verb@      fprintf(file, "%d", scrap_array(num).page);@\\
\mbox{}\verb@    else if (scrap_array(num).page != *page)@\\
\mbox{}\verb@      fprintf(file, ", %d", scrap_array(num).page);@\\
\mbox{}\verb@    if (scrap_array(num).letter > 0)@\\
\mbox{}\verb@      fputc(scrap_array(num).letter, file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    if (first)@\\
\mbox{}\verb@      putc('?', file);@\\
\mbox{}\verb@    else@\\
\mbox{}\verb@      fputs(", ?", file);@\\
\mbox{}\verb@    @$\langle$Warn (only once) about needing to rerun after Latex {\footnotesize 44c}$\rangle$\verb@@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  *page = scrap_array(num).page;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap117}
\verb@"scraps.c"@ {\footnotesize 44b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void write_single_scrap_ref(file, num)@\\
\mbox{}\verb@     FILE *file;@\\
\mbox{}\verb@     int num;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  int page;@\\
\mbox{}\verb@  write_scrap_ref(file, num, TRUE, &page);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap118}
$\langle$Warn (only once) about needing to rerun after Latex {\footnotesize 44c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (!already_warned) {@\\
\mbox{}\verb@    fprintf(stderr, "%s: you'll need to rerun nuweb after running latex\n",@\\
\mbox{}\verb@            command_name);@\\
\mbox{}\verb@    already_warned = TRUE;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 44a, 52a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap119}
$\langle$Global variable declarations {\footnotesize 44d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern int already_warned;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10ac, 39b, 44d, 53b.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap120}
$\langle$Global variable definitions {\footnotesize 45a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@int already_warned = 0;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10bd, 39c, 45a, 53c.
\item Macro referenced in scrap 9e.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap121}
\verb@"scraps.c"@ {\footnotesize 45b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@typedef struct {@\\
\mbox{}\verb@  Slab *scrap;@\\
\mbox{}\verb@  Slab *prev;@\\
\mbox{}\verb@  int index;@\\
\mbox{}\verb@} Manager;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap122}
\verb@"scraps.c"@ {\footnotesize 45c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void push(c, manager)@\\
\mbox{}\verb@     char c;@\\
\mbox{}\verb@     Manager *manager;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  Slab *scrap = manager->scrap;@\\
\mbox{}\verb@  int index = manager->index;@\\
\mbox{}\verb@  scrap->chars[index++] = c;@\\
\mbox{}\verb@  if (index == SLAB_SIZE) {@\\
\mbox{}\verb@    Slab *new = (Slab *) arena_getmem(sizeof(Slab));@\\
\mbox{}\verb@    scrap->next = new;@\\
\mbox{}\verb@    manager->scrap = new;@\\
\mbox{}\verb@    index = 0;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  manager->index = index;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap123}
\verb@"scraps.c"@ {\footnotesize 45d }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void pushs(s, manager)@\\
\mbox{}\verb@     char *s;@\\
\mbox{}\verb@     Manager *manager;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  while (*s)@\\
\mbox{}\verb@    push(*s++, manager);@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap124}
\verb@"scraps.c"@ {\footnotesize 45e }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@int collect_scrap()@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  Manager writer;@\\
\mbox{}\verb@  @$\langle$Create new scrap, managed by \verb|writer| {\footnotesize 46a}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Accumulate scrap and return \verb|scraps++| {\footnotesize 46b}$\rangle$\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap125}
$\langle$Create new scrap, managed by \verb|writer| {\footnotesize 46a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Slab *scrap = (Slab *) arena_getmem(sizeof(Slab));@\\
\mbox{}\verb@  if ((scraps & 255) == 0)@\\
\mbox{}\verb@    SCRAP[scraps >> 8] = (ScrapEntry *) arena_getmem(256 * sizeof(ScrapEntry));@\\
\mbox{}\verb@  scrap_array(scraps).slab = scrap;@\\
\mbox{}\verb@  scrap_array(scraps).file_name = save_string(source_name);@\\
\mbox{}\verb@  scrap_array(scraps).file_line = source_line;@\\
\mbox{}\verb@  scrap_array(scraps).page = -1;@\\
\mbox{}\verb@  scrap_array(scraps).letter = 0;@\\
\mbox{}\verb@  writer.scrap = scrap;@\\
\mbox{}\verb@  writer.index = 0;@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 45e.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap126}
$\langle$Accumulate scrap and return \verb|scraps++| {\footnotesize 46b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  int c = source_get();@\\
\mbox{}\verb@  while (1) {@\\
\mbox{}\verb@    switch (c) {@\\
\mbox{}\verb@      case EOF: fprintf(stderr, "%s: unexpect EOF in scrap (%s, %d)\n",@\\
\mbox{}\verb@                        command_name, scrap_array(scraps).file_name,@\\
\mbox{}\verb@                        scrap_array(scraps).file_line);@\\
\mbox{}\verb@                exit(-1);@\\
\mbox{}\verb@      case '@{\tt @}\verb@': @$\langle$Handle at-sign during scrap accumulation {\footnotesize 46c}$\rangle$\verb@@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@      default:  push(c, &writer);@\\
\mbox{}\verb@                c = source_get();@\\
\mbox{}\verb@                break;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 45e.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap127}
$\langle$Handle at-sign during scrap accumulation {\footnotesize 46c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case '@{\tt @}\verb@': pushs("@{\tt @}\verb@@{\tt @}\verb@", &writer);@\\
\mbox{}\verb@              c = source_get();@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case '|': @$\langle$Collect user-specified index entries {\footnotesize 47a}$\rangle$\verb@@\\
\mbox{}\verb@    case '}': push('\0', &writer);@\\
\mbox{}\verb@              return scraps++;@\\
\mbox{}\verb@    case '<': @$\langle$Handle macro invocation in scrap {\footnotesize 47b}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    default : fprintf(stderr, "%s: unexpected @{\tt @}\verb@%c in scrap (%s, %d)\n",@\\
\mbox{}\verb@                      command_name, c, source_name, source_line);@\\
\mbox{}\verb@              exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 46b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap128}
$\langle$Collect user-specified index entries {\footnotesize 47a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  do {@\\
\mbox{}\verb@    char new_name[100];@\\
\mbox{}\verb@    char *p = new_name;@\\
\mbox{}\verb@    do @\\
\mbox{}\verb@      c = source_get();@\\
\mbox{}\verb@    while (isspace(c));@\\
\mbox{}\verb@    if (c != '@{\tt @}\verb@') {@\\
\mbox{}\verb@      Name *name;@\\
\mbox{}\verb@      do {@\\
\mbox{}\verb@        *p++ = c;@\\
\mbox{}\verb@        c = source_get();@\\
\mbox{}\verb@      } while (c != '@{\tt @}\verb@' && !isspace(c));@\\
\mbox{}\verb@      *p = '\0';@\\
\mbox{}\verb@      name = name_add(&user_names, new_name);@\\
\mbox{}\verb@      if (!name->defs || name->defs->scrap != scraps) {@\\
\mbox{}\verb@        Scrap_Node *def = (Scrap_Node *) arena_getmem(sizeof(Scrap_Node));@\\
\mbox{}\verb@        def->scrap = scraps;@\\
\mbox{}\verb@        def->next = name->defs;@\\
\mbox{}\verb@        name->defs = def;@\\
\mbox{}\verb@      }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  } while (c != '@{\tt @}\verb@');@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@  if (c != '}') {@\\
\mbox{}\verb@    fprintf(stderr, "%s: unexpected @{\tt @}\verb@%c in scrap (%s, %d)\n",@\\
\mbox{}\verb@            command_name, c, source_name, source_line);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 46c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap129}
$\langle$Handle macro invocation in scrap {\footnotesize 47b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *name = collect_scrap_name();@\\
\mbox{}\verb@  @$\langle$Save macro name {\footnotesize 47c}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Add current scrap to \verb|name|'s uses {\footnotesize 48a}$\rangle$\verb@@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 46c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap130}
$\langle$Save macro name {\footnotesize 47c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  char *s = name->spelling;@\\
\mbox{}\verb@  int len = strlen(s) - 1;@\\
\mbox{}\verb@  pushs("@{\tt @}\verb@<", &writer);@\\
\mbox{}\verb@  while (len > 0) {@\\
\mbox{}\verb@    push(*s++, &writer);@\\
\mbox{}\verb@    len--;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  if (*s == ' ')@\\
\mbox{}\verb@    pushs("...", &writer);@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    push(*s, &writer);@\\
\mbox{}\verb@  pushs("@{\tt @}\verb@>", &writer);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 47b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap131}
$\langle$Add current scrap to \verb|name|'s uses {\footnotesize 48a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (!name->uses || name->uses->scrap != scraps) {@\\
\mbox{}\verb@    Scrap_Node *use = (Scrap_Node *) arena_getmem(sizeof(Scrap_Node));@\\
\mbox{}\verb@    use->scrap = scraps;@\\
\mbox{}\verb@    use->next = name->uses;@\\
\mbox{}\verb@    name->uses = use;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 47b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap132}
\verb@"scraps.c"@ {\footnotesize 48b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static char pop(manager)@\\
\mbox{}\verb@     Manager *manager;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  Slab *scrap = manager->scrap;@\\
\mbox{}\verb@  int index = manager->index;@\\
\mbox{}\verb@  char c = scrap->chars[index++];@\\
\mbox{}\verb@  if (index == SLAB_SIZE) {@\\
\mbox{}\verb@    manager->prev = scrap;@\\
\mbox{}\verb@    manager->scrap = scrap->next;@\\
\mbox{}\verb@    index = 0;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  manager->index = index;@\\
\mbox{}\verb@  return c;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap133}
\verb@"scraps.c"@ {\footnotesize 48c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static Name *pop_scrap_name(manager)@\\
\mbox{}\verb@     Manager *manager;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  char name[100];@\\
\mbox{}\verb@  char *p = name;@\\
\mbox{}\verb@  int c = pop(manager);@\\
\mbox{}\verb@  while (TRUE) {@\\
\mbox{}\verb@    if (c == '@{\tt @}\verb@')@\\
\mbox{}\verb@      @$\langle$Check for end of scrap name and return {\footnotesize 49a}$\rangle$\verb@@\\
\mbox{}\verb@    else {@\\
\mbox{}\verb@      *p++ = c;@\\
\mbox{}\verb@      c = pop(manager);@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap134}
$\langle$Check for end of scrap name and return {\footnotesize 49a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  c = pop(manager);@\\
\mbox{}\verb@  if (c == '@{\tt @}\verb@') {@\\
\mbox{}\verb@    *p++ = c;@\\
\mbox{}\verb@    c = pop(manager);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else if (c == '>') {@\\
\mbox{}\verb@    if (p - name > 3 && p[-1] == '.' && p[-2] == '.' && p[-3] == '.') {@\\
\mbox{}\verb@      p[-3] = ' ';@\\
\mbox{}\verb@      p -= 2;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    *p = '\0';@\\
\mbox{}\verb@    return prefix_add(&macro_names, name);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    fprintf(stderr, "%s: found an internal problem (1)\n", command_name);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 48c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap135}
\verb@"scraps.c"@ {\footnotesize 49b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@int write_scraps(file, defs, global_indent, indent_chars,@\\
\mbox{}\verb@                   debug_flag, tab_flag, indent_flag)@\\
\mbox{}\verb@     FILE *file;@\\
\mbox{}\verb@     Scrap_Node *defs;@\\
\mbox{}\verb@     int global_indent;@\\
\mbox{}\verb@     char *indent_chars;@\\
\mbox{}\verb@     char debug_flag;@\\
\mbox{}\verb@     char tab_flag;@\\
\mbox{}\verb@     char indent_flag;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  int indent = 0;@\\
\mbox{}\verb@  while (defs) {@\\
\mbox{}\verb@    @$\langle$Copy \verb|defs->scrap| to \verb|file| {\footnotesize 50a}$\rangle$\verb@@\\
\mbox{}\verb@    defs = defs->next;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  return indent + global_indent;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap136}
$\langle$Copy \verb|defs->scrap| to \verb|file| {\footnotesize 50a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  char c;@\\
\mbox{}\verb@  Manager reader;@\\
\mbox{}\verb@  int line_number = scrap_array(defs->scrap).file_line;@\\
\mbox{}\verb@  @$\langle$Insert debugging information if required {\footnotesize 50b}$\rangle$\verb@@\\
\mbox{}\verb@  reader.scrap = scrap_array(defs->scrap).slab;@\\
\mbox{}\verb@  reader.index = 0;@\\
\mbox{}\verb@  c = pop(&reader);@\\
\mbox{}\verb@  while (c) {@\\
\mbox{}\verb@    switch (c) {@\\
\mbox{}\verb@      case '@{\tt @}\verb@':  @$\langle$Check for macro invocation in scrap {\footnotesize 51b}$\rangle$\verb@@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '\n': putc(c, file);@\\
\mbox{}\verb@                 line_number++;@\\
\mbox{}\verb@                 @$\langle$Insert appropriate indentation {\footnotesize 50c}$\rangle$\verb@@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '\t': @$\langle$Handle tab characters on output {\footnotesize 51a}$\rangle$\verb@@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      default:   putc(c, file);@\\
\mbox{}\verb@                 indent_chars[global_indent + indent] = ' ';@\\
\mbox{}\verb@                 indent++;@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    c = pop(&reader);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 49b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap137}
$\langle$Insert debugging information if required {\footnotesize 50b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@if (debug_flag) {@\\
\mbox{}\verb@  fprintf(file, "\n#line %d \"%s\"\n",@\\
\mbox{}\verb@          line_number, scrap_array(defs->scrap).file_name);@\\
\mbox{}\verb@  @$\langle$Insert appropriate indentation {\footnotesize 50c}$\rangle$\verb@@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 50a, 51b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap138}
$\langle$Insert appropriate indentation {\footnotesize 50c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (indent_flag) {@\\
\mbox{}\verb@    if (tab_flag)@\\
\mbox{}\verb@      for (indent=0; indent<global_indent; indent++)@\\
\mbox{}\verb@        putc(' ', file);@\\
\mbox{}\verb@    else@\\
\mbox{}\verb@      for (indent=0; indent<global_indent; indent++)@\\
\mbox{}\verb@        putc(indent_chars[indent], file);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  indent = 0;@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 50ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap139}
$\langle$Handle tab characters on output {\footnotesize 51a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (tab_flag)@\\
\mbox{}\verb@    @$\langle$Expand tab into spaces {\footnotesize 22b}$\rangle$\verb@@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    putc('\t', file);@\\
\mbox{}\verb@    indent_chars[global_indent + indent] = '\t';@\\
\mbox{}\verb@    indent++;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 50a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap140}
$\langle$Check for macro invocation in scrap {\footnotesize 51b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  c = pop(&reader);@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case '@{\tt @}\verb@': putc(c, file);@\\
\mbox{}\verb@              indent_chars[global_indent + indent] = ' ';@\\
\mbox{}\verb@              indent++;@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case '<': @$\langle$Copy macro into \verb|file| {\footnotesize 51c}$\rangle$\verb@@\\
\mbox{}\verb@              @$\langle$Insert debugging information if required {\footnotesize 50b}$\rangle$\verb@@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    default:  /* ignore, since we should already have a warning */@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 50a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap141}
$\langle$Copy macro into \verb|file| {\footnotesize 51c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *name = pop_scrap_name(&reader);@\\
\mbox{}\verb@  if (name->mark) {@\\
\mbox{}\verb@    fprintf(stderr, "%s: recursive macro discovered involving <%s>\n",@\\
\mbox{}\verb@            command_name, name->spelling);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  if (name->defs) {@\\
\mbox{}\verb@    name->mark = TRUE;@\\
\mbox{}\verb@    indent = write_scraps(file, name->defs, global_indent + indent,@\\
\mbox{}\verb@                          indent_chars, debug_flag, tab_flag, indent_flag);@\\
\mbox{}\verb@    indent -= global_indent;@\\
\mbox{}\verb@    name->mark = FALSE;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else if (!tex_flag)@\\
\mbox{}\verb@    fprintf(stderr, "%s: macro never defined <%s>\n",@\\
\mbox{}\verb@            command_name, name->spelling);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 51b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Collecting Page Numbers}

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap142}
$\langle$Function prototypes {\footnotesize 51d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern void collect_numbers();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap143}
\verb@"scraps.c"@ {\footnotesize 52a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void collect_numbers(aux_name)@\\
\mbox{}\verb@     char *aux_name;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  if (number_flag) {@\\
\mbox{}\verb@    int i;@\\
\mbox{}\verb@    for (i=1; i<scraps; i++)@\\
\mbox{}\verb@      scrap_array(i).page = i;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else {@\\
\mbox{}\verb@    FILE *aux_file = fopen(aux_name, "r");@\\
\mbox{}\verb@    already_warned = FALSE;@\\
\mbox{}\verb@    if (aux_file) {@\\
\mbox{}\verb@      char aux_line[500];@\\
\mbox{}\verb@      while (fgets(aux_line, 500, aux_file)) {@\\
\mbox{}\verb@        int scrap_number;@\\
\mbox{}\verb@        int page_number;@\\
\mbox{}\verb@        char dummy[50];@\\
\mbox{}\verb@        if (3 == sscanf(aux_line, "\\newlabel{scrap%d}{%[^}]}{%d}",@\\
\mbox{}\verb@                        &scrap_number, dummy, &page_number)) {@\\
\mbox{}\verb@          if (scrap_number < scraps)@\\
\mbox{}\verb@            scrap_array(scrap_number).page = page_number;@\\
\mbox{}\verb@          else@\\
\mbox{}\verb@            @$\langle$Warn (only once) about needing to rerun after Latex {\footnotesize 44c}$\rangle$\verb@@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@      }@\\
\mbox{}\verb@      fclose(aux_file);@\\
\mbox{}\verb@      @$\langle$Add letters to scraps with duplicate page numbers {\footnotesize 52b}$\rangle$\verb@@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap144}
$\langle$Add letters to scraps with duplicate page numbers {\footnotesize 52b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  int scrap;@\\
\mbox{}\verb@  for (scrap=2; scrap<scraps; scrap++) {@\\
\mbox{}\verb@    if (scrap_array(scrap-1).page == scrap_array(scrap).page) {@\\
\mbox{}\verb@      if (!scrap_array(scrap-1).letter)@\\
\mbox{}\verb@        scrap_array(scrap-1).letter = 'a';@\\
\mbox{}\verb@      scrap_array(scrap).letter = scrap_array(scrap-1).letter + 1;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 52a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\section{Names} \label{names}

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap145}
$\langle$Type declarations {\footnotesize 52c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@typedef struct scrap_node {@\\
\mbox{}\verb@  struct scrap_node *next;@\\
\mbox{}\verb@  int scrap;@\\
\mbox{}\verb@} Scrap_Node;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 8a, 52c, 53a.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap146}
$\langle$Type declarations {\footnotesize 53a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@typedef struct name {@\\
\mbox{}\verb@  char *spelling;@\\
\mbox{}\verb@  struct name *llink;@\\
\mbox{}\verb@  struct name *rlink;@\\
\mbox{}\verb@  Scrap_Node *defs;@\\
\mbox{}\verb@  Scrap_Node *uses;@\\
\mbox{}\verb@  int mark;@\\
\mbox{}\verb@  char tab_flag;@\\
\mbox{}\verb@  char indent_flag;@\\
\mbox{}\verb@  char debug_flag;@\\
\mbox{}\verb@} Name;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 8a, 52c, 53a.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap147}
$\langle$Global variable declarations {\footnotesize 53b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern Name *file_names;@\\
\mbox{}\verb@extern Name *macro_names;@\\
\mbox{}\verb@extern Name *user_names;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10ac, 39b, 44d, 53b.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap148}
$\langle$Global variable definitions {\footnotesize 53c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@Name *file_names = NULL;@\\
\mbox{}\verb@Name *macro_names = NULL;@\\
\mbox{}\verb@Name *user_names = NULL;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 10bd, 39c, 45a, 53c.
\item Macro referenced in scrap 9e.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap149}
$\langle$Function prototypes {\footnotesize 53d}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern Name *collect_file_name();@\\
\mbox{}\verb@extern Name *collect_macro_name();@\\
\mbox{}\verb@extern Name *collect_scrap_name();@\\
\mbox{}\verb@extern Name *name_add();@\\
\mbox{}\verb@extern Name *prefix_add();@\\
\mbox{}\verb@extern char *save_string();@\\
\mbox{}\verb@extern void reverse_lists();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap150}
\verb@"names.c"@ {\footnotesize 54a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@enum { LESS, GREATER, EQUAL, PREFIX, EXTENSION };@\\
\mbox{}\verb@@\\
\mbox{}\verb@static int compare(x, y)@\\
\mbox{}\verb@     char *x;@\\
\mbox{}\verb@     char *y;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  int len, result;@\\
\mbox{}\verb@  int xl = strlen(x);@\\
\mbox{}\verb@  int yl = strlen(y);@\\
\mbox{}\verb@  int xp = x[xl - 1] == ' ';@\\
\mbox{}\verb@  int yp = y[yl - 1] == ' ';@\\
\mbox{}\verb@  if (xp) xl--;@\\
\mbox{}\verb@  if (yp) yl--;@\\
\mbox{}\verb@  len = xl < yl ? xl : yl;@\\
\mbox{}\verb@  result = strncmp(x, y, len);@\\
\mbox{}\verb@  if (result < 0) return GREATER;@\\
\mbox{}\verb@  else if (result > 0) return LESS;@\\
\mbox{}\verb@  else if (xl < yl) {@\\
\mbox{}\verb@    if (xp) return EXTENSION;@\\
\mbox{}\verb@    else return LESS;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else if (xl > yl) {@\\
\mbox{}\verb@    if (yp) return PREFIX;@\\
\mbox{}\verb@    else return GREATER;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  else return EQUAL;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap151}
\verb@"names.c"@ {\footnotesize 54b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@char *save_string(s)@\\
\mbox{}\verb@     char *s;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  char *new = (char *) arena_getmem((strlen(s) + 1) * sizeof(char));@\\
\mbox{}\verb@  strcpy(new, s);@\\
\mbox{}\verb@  return new;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap152}
\verb@"names.c"@ {\footnotesize 55a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static int ambiguous_prefix();@\\
\mbox{}\verb@@\\
\mbox{}\verb@Name *prefix_add(root, spelling)@\\
\mbox{}\verb@     Name **root;@\\
\mbox{}\verb@     char *spelling;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *node = *root;@\\
\mbox{}\verb@  while (node) {@\\
\mbox{}\verb@    switch (compare(node->spelling, spelling)) {@\\
\mbox{}\verb@    case GREATER:   root = &node->rlink;@\\
\mbox{}\verb@                    break;@\\
\mbox{}\verb@    case LESS:      root = &node->llink;@\\
\mbox{}\verb@                    break;@\\
\mbox{}\verb@    case EQUAL:     return node;@\\
\mbox{}\verb@    case EXTENSION: node->spelling = save_string(spelling);@\\
\mbox{}\verb@                    return node;@\\
\mbox{}\verb@    case PREFIX:    @$\langle$Check for ambiguous prefix {\footnotesize 55b}$\rangle$\verb@@\\
\mbox{}\verb@                    return node;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    node = *root;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  @$\langle$Create new name entry {\footnotesize 58a}$\rangle$\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Since a very short prefix might match more than one macro name, I need
to check for other matches to avoid mistakes. Basically, I simply
continue the search down {\em both\/} branches of the tree.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap153}
$\langle$Check for ambiguous prefix {\footnotesize 55b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (ambiguous_prefix(node->llink, spelling) ||@\\
\mbox{}\verb@      ambiguous_prefix(node->rlink, spelling))@\\
\mbox{}\verb@    fprintf(stderr,@\\
\mbox{}\verb@            "%s: ambiguous prefix @{\tt @}\verb@<%s...@{\tt @}\verb@> (%s, line %d)\n",@\\
\mbox{}\verb@            command_name, spelling, source_name, source_line);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 55a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap154}
\verb@"names.c"@ {\footnotesize 56 }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static int ambiguous_prefix(node, spelling)@\\
\mbox{}\verb@     Name *node;@\\
\mbox{}\verb@     char *spelling;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  while (node) {@\\
\mbox{}\verb@    switch (compare(node->spelling, spelling)) {@\\
\mbox{}\verb@    case GREATER:   node = node->rlink;@\\
\mbox{}\verb@                    break;@\\
\mbox{}\verb@    case LESS:      node = node->llink;@\\
\mbox{}\verb@                    break;@\\
\mbox{}\verb@    case EQUAL:@\\
\mbox{}\verb@    case EXTENSION:@\\
\mbox{}\verb@    case PREFIX:    return TRUE;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  return FALSE;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Rob Shillingsburg suggested that I organize the index of
user-specified identifiers more traditionally; that is, not relying on
strict {\small ASCII} comparisons via \verb|strcmp|. Ideally, we'd like
to see the index ordered like this:
\begin{quote}
\begin{flushleft}
aardvark \\
Adam \\
atom \\
Atomic \\
atoms
\end{flushleft}
\end{quote}
The function \verb|robs_strcmp| implements the desired predicate.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap155}
\verb@"names.c"@ {\footnotesize 57a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static int robs_strcmp(x, y)@\\
\mbox{}\verb@     char *x;@\\
\mbox{}\verb@     char *y;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  char *xx = x;@\\
\mbox{}\verb@  char *yy = y;@\\
\mbox{}\verb@  int xc = toupper(*xx);@\\
\mbox{}\verb@  int yc = toupper(*yy);@\\
\mbox{}\verb@  while (xc == yc && xc) {@\\
\mbox{}\verb@    xx++;@\\
\mbox{}\verb@    yy++;@\\
\mbox{}\verb@    xc = toupper(*xx);@\\
\mbox{}\verb@    yc = toupper(*yy);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  if (xc != yc) return xc - yc;@\\
\mbox{}\verb@  xc = *x;@\\
\mbox{}\verb@  yc = *y;@\\
\mbox{}\verb@  while (xc == yc && xc) {@\\
\mbox{}\verb@    x++;@\\
\mbox{}\verb@    y++;@\\
\mbox{}\verb@    xc = *x;@\\
\mbox{}\verb@    yc = *y;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  if (isupper(xc) && islower(yc))@\\
\mbox{}\verb@    return xc * 2 - (toupper(yc) * 2 + 1);@\\
\mbox{}\verb@  if (islower(xc) && isupper(yc))@\\
\mbox{}\verb@    return toupper(xc) * 2 + 1 - yc * 2;@\\
\mbox{}\verb@  return xc - yc;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap156}
\verb@"names.c"@ {\footnotesize 57b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@Name *name_add(root, spelling)@\\
\mbox{}\verb@     Name **root;@\\
\mbox{}\verb@     char *spelling;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *node = *root;@\\
\mbox{}\verb@  while (node) {@\\
\mbox{}\verb@    int result = robs_strcmp(node->spelling, spelling);@\\
\mbox{}\verb@    if (result > 0)@\\
\mbox{}\verb@      root = &node->llink;@\\
\mbox{}\verb@    else if (result < 0)@\\
\mbox{}\verb@      root = &node->rlink;@\\
\mbox{}\verb@    else@\\
\mbox{}\verb@      return node;@\\
\mbox{}\verb@    node = *root;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  @$\langle$Create new name entry {\footnotesize 58a}$\rangle$\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap157}
$\langle$Create new name entry {\footnotesize 58a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  node = (Name *) arena_getmem(sizeof(Name));@\\
\mbox{}\verb@  node->spelling = save_string(spelling);@\\
\mbox{}\verb@  node->mark = FALSE;@\\
\mbox{}\verb@  node->llink = NULL;@\\
\mbox{}\verb@  node->rlink = NULL;@\\
\mbox{}\verb@  node->uses = NULL;@\\
\mbox{}\verb@  node->defs = NULL;@\\
\mbox{}\verb@  node->tab_flag = TRUE;@\\
\mbox{}\verb@  node->indent_flag = TRUE;@\\
\mbox{}\verb@  node->debug_flag = FALSE;@\\
\mbox{}\verb@  *root = node;@\\
\mbox{}\verb@  return node;@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 55a, 57b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Name terminated by whitespace.  Also check for ``per-file'' flags. Keep
skipping white space until we reach scrap.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap158}
\verb@"names.c"@ {\footnotesize 58b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@Name *collect_file_name()@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  Name *new_name;@\\
\mbox{}\verb@  char name[100];@\\
\mbox{}\verb@  char *p = name;@\\
\mbox{}\verb@  int start_line = source_line;@\\
\mbox{}\verb@  int c = source_get();@\\
\mbox{}\verb@  while (isspace(c))@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  while (isgraph(c)) {@\\
\mbox{}\verb@    *p++ = c;@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  if (p == name) {@\\
\mbox{}\verb@    fprintf(stderr, "%s: expected file name (%s, %d)\n",@\\
\mbox{}\verb@            command_name, source_name, start_line);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  *p = '\0';@\\
\mbox{}\verb@  new_name = name_add(&file_names, name);@\\
\mbox{}\verb@  @$\langle$Handle optional per-file flags {\footnotesize 59}$\rangle$\verb@@\\
\mbox{}\verb@  if (c != '@{\tt @}\verb@' || source_get() != '{') {@\\
\mbox{}\verb@    fprintf(stderr, "%s: expected @{\tt @}\verb@{ after file name (%s, %d)\n",@\\
\mbox{}\verb@            command_name, source_name, start_line);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  return new_name;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap159}
$\langle$Handle optional per-file flags {\footnotesize 59}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  while (1) {@\\
\mbox{}\verb@    while (isspace(c))@\\
\mbox{}\verb@      c = source_get();@\\
\mbox{}\verb@    if (c == '-') {@\\
\mbox{}\verb@      c = source_get();@\\
\mbox{}\verb@      do {@\\
\mbox{}\verb@        switch (c) {@\\
\mbox{}\verb@          case 't': new_name->tab_flag = FALSE;@\\
\mbox{}\verb@                    break;@\\
\mbox{}\verb@          case 'd': new_name->debug_flag = TRUE;@\\
\mbox{}\verb@                    break;@\\
\mbox{}\verb@          case 'i': new_name->indent_flag = FALSE;@\\
\mbox{}\verb@                    break;@\\
\mbox{}\verb@          default : fprintf(stderr, "%s: unexpected per-file flag (%s, %d)\n",@\\
\mbox{}\verb@                            command_name, source_name, source_line);@\\
\mbox{}\verb@                    break;@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        c = source_get();@\\
\mbox{}\verb@      } while (!isspace(c));@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    else break;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 58b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Name terminated by \verb+\n+ or \verb+@{+; but keep skipping until \verb+@{+
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap160}
\verb@"names.c"@ {\footnotesize 60a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@Name *collect_macro_name()@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  char name[100];@\\
\mbox{}\verb@  char *p = name;@\\
\mbox{}\verb@  int start_line = source_line;@\\
\mbox{}\verb@  int c = source_get();@\\
\mbox{}\verb@  while (isspace(c))@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  while (c != EOF) {@\\
\mbox{}\verb@    switch (c) {@\\
\mbox{}\verb@      case '@{\tt @}\verb@':  @$\langle$Check for terminating at-sequence and return name {\footnotesize 60b}$\rangle$\verb@@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '\t':@\\
\mbox{}\verb@      case ' ':  *p++ = ' ';@\\
\mbox{}\verb@                 do@\\
\mbox{}\verb@                   c = source_get();@\\
\mbox{}\verb@                 while (c == ' ' || c == '\t');@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '\n': @$\langle$Skip until scrap begins, then return name {\footnotesize 61b}$\rangle$\verb@@\\
\mbox{}\verb@      default:   *p++ = c;@\\
\mbox{}\verb@                 c = source_get();@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  fprintf(stderr, "%s: expected macro name (%s, %d)\n",@\\
\mbox{}\verb@          command_name, source_name, start_line);@\\
\mbox{}\verb@  exit(-1);@\\
\mbox{}\verb@  return NULL;  /* unreachable return to avoid warnings on some compilers */@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap161}
$\langle$Check for terminating at-sequence and return name {\footnotesize 60b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case '@{\tt @}\verb@': *p++ = c;@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case '{': @$\langle$Cleanup and install name {\footnotesize 61a}$\rangle$\verb@@\\
\mbox{}\verb@    default:  fprintf(stderr,@\\
\mbox{}\verb@                      "%s: unexpected @{\tt @}\verb@%c in macro name (%s, %d)\n",@\\
\mbox{}\verb@                      command_name, c, source_name, start_line);@\\
\mbox{}\verb@              exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 60a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap162}
$\langle$Cleanup and install name {\footnotesize 61a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  if (p > name && p[-1] == ' ')@\\
\mbox{}\verb@    p--;@\\
\mbox{}\verb@  if (p - name > 3 && p[-1] == '.' && p[-2] == '.' && p[-3] == '.') {@\\
\mbox{}\verb@    p[-3] = ' ';@\\
\mbox{}\verb@    p -= 2;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  if (p == name || name[0] == ' ') {@\\
\mbox{}\verb@    fprintf(stderr, "%s: empty scrap name (%s, %d)\n",@\\
\mbox{}\verb@            command_name, source_name, source_line);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  *p = '\0';@\\
\mbox{}\verb@  return prefix_add(&macro_names, name);@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scraps 60b, 61b, 62b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap163}
$\langle$Skip until scrap begins, then return name {\footnotesize 61b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  do@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  while (isspace(c));@\\
\mbox{}\verb@  if (c != '@{\tt @}\verb@' || source_get() != '{') {@\\
\mbox{}\verb@    fprintf(stderr, "%s: expected @{\tt @}\verb@{ after macro name (%s, %d)\n",@\\
\mbox{}\verb@            command_name, source_name, start_line);@\\
\mbox{}\verb@    exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  @$\langle$Cleanup and install name {\footnotesize 61a}$\rangle$\verb@@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 60a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Terminated by \verb+@>+
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap164}
\verb@"names.c"@ {\footnotesize 62a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@Name *collect_scrap_name()@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  char name[100];@\\
\mbox{}\verb@  char *p = name;@\\
\mbox{}\verb@  int c = source_get();@\\
\mbox{}\verb@  while (c == ' ' || c == '\t')@\\
\mbox{}\verb@    c = source_get();@\\
\mbox{}\verb@  while (c != EOF) {@\\
\mbox{}\verb@    switch (c) {@\\
\mbox{}\verb@      case '@{\tt @}\verb@':  @$\langle$Look for end of scrap name and return {\footnotesize 62b}$\rangle$\verb@@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      case '\t':@\\
\mbox{}\verb@      case ' ':  *p++ = ' ';@\\
\mbox{}\verb@                 do@\\
\mbox{}\verb@                   c = source_get();@\\
\mbox{}\verb@                 while (c == ' ' || c == '\t');@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@      default:   if (!isgraph(c)) {@\\
\mbox{}\verb@                   fprintf(stderr,@\\
\mbox{}\verb@                           "%s: unexpected character in macro name (%s, %d)\n",@\\
\mbox{}\verb@                           command_name, source_name, source_line);@\\
\mbox{}\verb@                   exit(-1);@\\
\mbox{}\verb@                 }@\\
\mbox{}\verb@                 *p++ = c;@\\
\mbox{}\verb@                 c = source_get();@\\
\mbox{}\verb@                 break;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  fprintf(stderr, "%s: unexpected end of file (%s, %d)\n",@\\
\mbox{}\verb@          command_name, source_name, source_line);@\\
\mbox{}\verb@  exit(-1);@\\
\mbox{}\verb@  return NULL;  /* unreachable return to avoid warnings on some compilers */@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap165}
$\langle$Look for end of scrap name and return {\footnotesize 62b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  c = source_get();@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case '@{\tt @}\verb@': *p++ = c;@\\
\mbox{}\verb@              c = source_get();@\\
\mbox{}\verb@              break;@\\
\mbox{}\verb@    case '>': @$\langle$Cleanup and install name {\footnotesize 61a}$\rangle$\verb@@\\
\mbox{}\verb@    default:  fprintf(stderr,@\\
\mbox{}\verb@                      "%s: unexpected @{\tt @}\verb@%c in macro name (%s, %d)\n",@\\
\mbox{}\verb@                      command_name, c, source_name, source_line);@\\
\mbox{}\verb@              exit(-1);@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 62a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap166}
\verb@"names.c"@ {\footnotesize 63a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static Scrap_Node *reverse();   /* a forward declaration */@\\
\mbox{}\verb@@\\
\mbox{}\verb@void reverse_lists(names)@\\
\mbox{}\verb@     Name *names;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  while (names) {@\\
\mbox{}\verb@    reverse_lists(names->llink);@\\
\mbox{}\verb@    names->defs = reverse(names->defs);@\\
\mbox{}\verb@    names->uses = reverse(names->uses);@\\
\mbox{}\verb@    names = names->rlink;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
Just for fun, here's a non-recursive version of the traditional list
reversal code. Note that it reverses the list in place; that is, it
does no new allocations.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap167}
\verb@"names.c"@ {\footnotesize 63b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static Scrap_Node *reverse(a)@\\
\mbox{}\verb@     Scrap_Node *a;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  if (a) {@\\
\mbox{}\verb@    Scrap_Node *b = a->next;@\\
\mbox{}\verb@    a->next = NULL;@\\
\mbox{}\verb@    while (b) {@\\
\mbox{}\verb@      Scrap_Node *c = b->next;@\\
\mbox{}\verb@      b->next = a;@\\
\mbox{}\verb@      a = b;@\\
\mbox{}\verb@      b = c;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  return a;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\section{Searching for Index Entries} \label{search}

Given the array of scraps and a set of index entries, we need to
search all the scraps for occurrences of each entry. The obvious
approach to this problem would be quite expensive for large documents;
however, there is an interesting  paper describing an efficient
solution~\cite{aho:75}.


\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap168}
\verb@"scraps.c"@ {\footnotesize 63c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@typedef struct name_node {@\\
\mbox{}\verb@  struct name_node *next;@\\
\mbox{}\verb@  Name *name;@\\
\mbox{}\verb@} Name_Node;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap169}
\verb@"scraps.c"@ {\footnotesize 64a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@typedef struct goto_node {@\\
\mbox{}\verb@  Name_Node *output;            /* list of words ending in this state */@\\
\mbox{}\verb@  struct move_node *moves;      /* list of possible moves */@\\
\mbox{}\verb@  struct goto_node *fail;       /* and where to go when no move fits */@\\
\mbox{}\verb@  struct goto_node *next;       /* next goto node with same depth */@\\
\mbox{}\verb@} Goto_Node;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap170}
\verb@"scraps.c"@ {\footnotesize 64b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@typedef struct move_node {@\\
\mbox{}\verb@  struct move_node *next;@\\
\mbox{}\verb@  Goto_Node *state;@\\
\mbox{}\verb@  char c;@\\
\mbox{}\verb@} Move_Node;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap171}
\verb@"scraps.c"@ {\footnotesize 64c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static Goto_Node *root[128];@\\
\mbox{}\verb@static int max_depth;@\\
\mbox{}\verb@static Goto_Node **depths;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap172}
\verb@"scraps.c"@ {\footnotesize 64d }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static Goto_Node *goto_lookup(c, g)@\\
\mbox{}\verb@     char c;@\\
\mbox{}\verb@     Goto_Node *g;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  Move_Node *m = g->moves;@\\
\mbox{}\verb@  while (m && m->c != c)@\\
\mbox{}\verb@    m = m->next;@\\
\mbox{}\verb@  if (m)@\\
\mbox{}\verb@    return m->state;@\\
\mbox{}\verb@  else@\\
\mbox{}\verb@    return NULL;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Building the Automata}


\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap173}
$\langle$Function prototypes {\footnotesize 64e}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern void search();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap174}
\verb@"scraps.c"@ {\footnotesize 65a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void build_gotos();@\\
\mbox{}\verb@static int reject_match();@\\
\mbox{}\verb@@\\
\mbox{}\verb@void search()@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  int i;@\\
\mbox{}\verb@  for (i=0; i<128; i++)@\\
\mbox{}\verb@    root[i] = NULL;@\\
\mbox{}\verb@  max_depth = 10;@\\
\mbox{}\verb@  depths = (Goto_Node **) arena_getmem(max_depth * sizeof(Goto_Node *));@\\
\mbox{}\verb@  for (i=0; i<max_depth; i++)@\\
\mbox{}\verb@    depths[i] = NULL;@\\
\mbox{}\verb@  build_gotos(user_names);@\\
\mbox{}\verb@  @$\langle$Build failure functions {\footnotesize 67}$\rangle$\verb@@\\
\mbox{}\verb@  @$\langle$Search scraps {\footnotesize 68}$\rangle$\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap175}
\verb@"scraps.c"@ {\footnotesize 65b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static void build_gotos(tree)@\\
\mbox{}\verb@     Name *tree;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  while (tree) {@\\
\mbox{}\verb@    @$\langle$Extend goto graph with \verb|tree->spelling| {\footnotesize 66}$\rangle$\verb@@\\
\mbox{}\verb@    build_gotos(tree->rlink);@\\
\mbox{}\verb@    tree = tree->llink;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap176}
$\langle$Extend goto graph with \verb|tree->spelling| {\footnotesize 66}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  int depth = 2;@\\
\mbox{}\verb@  char *p = tree->spelling;@\\
\mbox{}\verb@  char c = *p++;@\\
\mbox{}\verb@  Goto_Node *q = root[c];@\\
\mbox{}\verb@  if (!q) {@\\
\mbox{}\verb@    q = (Goto_Node *) arena_getmem(sizeof(Goto_Node));@\\
\mbox{}\verb@    root[c] = q;@\\
\mbox{}\verb@    q->moves = NULL;@\\
\mbox{}\verb@    q->fail = NULL;@\\
\mbox{}\verb@    q->moves = NULL;@\\
\mbox{}\verb@    q->output = NULL;@\\
\mbox{}\verb@    q->next = depths[1];@\\
\mbox{}\verb@    depths[1] = q;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  while (c = *p++) {@\\
\mbox{}\verb@    Goto_Node *new = goto_lookup(c, q);@\\
\mbox{}\verb@    if (!new) {@\\
\mbox{}\verb@      Move_Node *new_move = (Move_Node *) arena_getmem(sizeof(Move_Node));@\\
\mbox{}\verb@      new = (Goto_Node *) arena_getmem(sizeof(Goto_Node));@\\
\mbox{}\verb@      new->moves = NULL;@\\
\mbox{}\verb@      new->fail = NULL;@\\
\mbox{}\verb@      new->moves = NULL;@\\
\mbox{}\verb@      new->output = NULL;@\\
\mbox{}\verb@      new_move->state = new;@\\
\mbox{}\verb@      new_move->c = c;@\\
\mbox{}\verb@      new_move->next = q->moves;@\\
\mbox{}\verb@      q->moves = new_move;@\\
\mbox{}\verb@      if (depth == max_depth) {@\\
\mbox{}\verb@        int i;@\\
\mbox{}\verb@        Goto_Node **new_depths =@\\
\mbox{}\verb@            (Goto_Node **) arena_getmem(2*depth*sizeof(Goto_Node *));@\\
\mbox{}\verb@        max_depth = 2 * depth;@\\
\mbox{}\verb@        for (i=0; i<depth; i++)@\\
\mbox{}\verb@          new_depths[i] = depths[i];@\\
\mbox{}\verb@        depths = new_depths;@\\
\mbox{}\verb@        for (i=depth; i<max_depth; i++)@\\
\mbox{}\verb@          depths[i] = NULL;@\\
\mbox{}\verb@      }@\\
\mbox{}\verb@      new->next = depths[depth];@\\
\mbox{}\verb@      depths[depth] = new;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    q = new;@\\
\mbox{}\verb@    depth++;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  q->output = (Name_Node *) arena_getmem(sizeof(Name_Node));@\\
\mbox{}\verb@  q->output->next = NULL;@\\
\mbox{}\verb@  q->output->name = tree;@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 65b.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap177}
$\langle$Build failure functions {\footnotesize 67}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  int depth;@\\
\mbox{}\verb@  for (depth=1; depth<max_depth; depth++) {@\\
\mbox{}\verb@    Goto_Node *r = depths[depth];@\\
\mbox{}\verb@    while (r) {@\\
\mbox{}\verb@      Move_Node *m = r->moves;@\\
\mbox{}\verb@      while (m) {@\\
\mbox{}\verb@        char a = m->c;@\\
\mbox{}\verb@        Goto_Node *s = m->state;@\\
\mbox{}\verb@        Goto_Node *state = r->fail;@\\
\mbox{}\verb@        while (state && !goto_lookup(a, state))@\\
\mbox{}\verb@          state = state->fail;@\\
\mbox{}\verb@        if (state)@\\
\mbox{}\verb@          s->fail = goto_lookup(a, state);@\\
\mbox{}\verb@        else@\\
\mbox{}\verb@          s->fail = root[a];@\\
\mbox{}\verb@        if (s->fail) {@\\
\mbox{}\verb@          Name_Node *p = s->fail->output;@\\
\mbox{}\verb@          while (p) {@\\
\mbox{}\verb@            Name_Node *q = (Name_Node *) arena_getmem(sizeof(Name_Node));@\\
\mbox{}\verb@            q->name = p->name;@\\
\mbox{}\verb@            q->next = s->output;@\\
\mbox{}\verb@            s->output = q;@\\
\mbox{}\verb@            p = p->next;@\\
\mbox{}\verb@          }@\\
\mbox{}\verb@        }@\\
\mbox{}\verb@        m = m->next;@\\
\mbox{}\verb@      }@\\
\mbox{}\verb@      r = r->next;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 65a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Searching the Scraps}

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap178}
$\langle$Search scraps {\footnotesize 68}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  for (i=1; i<scraps; i++) {@\\
\mbox{}\verb@    char c;@\\
\mbox{}\verb@    Manager reader;@\\
\mbox{}\verb@    Goto_Node *state = NULL;@\\
\mbox{}\verb@    reader.prev = NULL;@\\
\mbox{}\verb@    reader.scrap = scrap_array(i).slab;@\\
\mbox{}\verb@    reader.index = 0;@\\
\mbox{}\verb@    c = pop(&reader);@\\
\mbox{}\verb@    while (c) {@\\
\mbox{}\verb@      while (state && !goto_lookup(c, state))@\\
\mbox{}\verb@        state = state->fail;@\\
\mbox{}\verb@      if (state)@\\
\mbox{}\verb@        state = goto_lookup(c, state);@\\
\mbox{}\verb@      else@\\
\mbox{}\verb@        state = root[c];@\\
\mbox{}\verb@      c = pop(&reader);@\\
\mbox{}\verb@      if (state && state->output) {@\\
\mbox{}\verb@        Name_Node *p = state->output;@\\
\mbox{}\verb@        do {@\\
\mbox{}\verb@          Name *name = p->name;@\\
\mbox{}\verb@          if (!reject_match(name, c, &reader) &&@\\
\mbox{}\verb@              (!name->uses || name->uses->scrap != i)) {@\\
\mbox{}\verb@            Scrap_Node *new_use =@\\
\mbox{}\verb@                (Scrap_Node *) arena_getmem(sizeof(Scrap_Node));@\\
\mbox{}\verb@            new_use->scrap = i;@\\
\mbox{}\verb@            new_use->next = name->uses;@\\
\mbox{}\verb@            name->uses = new_use;@\\
\mbox{}\verb@          }@\\
\mbox{}\verb@          p = p->next;@\\
\mbox{}\verb@        } while (p);@\\
\mbox{}\verb@      }@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 65a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsubsection{Rejecting Matches}

A problem with simple substring matching is that the string ``he''
would match longer strings like ``she'' and ``her.'' Norman Ramsey
suggested examining the characters occurring immediately before and
after a match and rejecting the match if it appears to be part of a
longer token. Of course, the concept of {\sl token\/} is
language-dependent, so we may be occasionally mistaken.
For the present, we'll consider the mechanism an experiment.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap179}
\verb@"scraps.c"@ {\footnotesize 69a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@#define sym_char(c) (isalnum(c) || (c) == '_')@\\
\mbox{}\verb@@\\
\mbox{}\verb@static int op_char(c)@\\
\mbox{}\verb@     char c;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  switch (c) {@\\
\mbox{}\verb@    case '!': case '@{\tt @}\verb@': case '#': case '%': case '$': case '^': @\\
\mbox{}\verb@    case '&': case '*': case '-': case '+': case '=': case '/':@\\
\mbox{}\verb@    case '|': case '~': case '<': case '>':@\\
\mbox{}\verb@      return TRUE;@\\
\mbox{}\verb@    default:@\\
\mbox{}\verb@      return FALSE;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap180}
\verb@"scraps.c"@ {\footnotesize 69b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static int reject_match(name, post, reader)@\\
\mbox{}\verb@     Name *name;@\\
\mbox{}\verb@     char post;@\\
\mbox{}\verb@     Manager *reader;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  int len = strlen(name->spelling);@\\
\mbox{}\verb@  char first = name->spelling[0];@\\
\mbox{}\verb@  char last = name->spelling[len - 1];@\\
\mbox{}\verb@  char prev = '\0';@\\
\mbox{}\verb@  len = reader->index - len - 2;@\\
\mbox{}\verb@  if (len >= 0)@\\
\mbox{}\verb@    prev = reader->scrap->chars[len];@\\
\mbox{}\verb@  else if (reader->prev)@\\
\mbox{}\verb@    prev = reader->scrap->chars[SLAB_SIZE - len];@\\
\mbox{}\verb@  if (sym_char(last) && sym_char(post)) return TRUE;@\\
\mbox{}\verb@  if (sym_char(first) && sym_char(prev)) return TRUE;@\\
\mbox{}\verb@  if (op_char(last) && op_char(post)) return TRUE;@\\
\mbox{}\verb@  if (op_char(first) && op_char(prev)) return TRUE;@\\
\mbox{}\verb@  return FALSE;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\section{Memory Management} \label{memory-management}

I manage memory using a simple scheme inspired by Hanson's idea of
{\em arenas\/}~\cite{hanson:90}.
Basically, I allocate all the storage required when processing a
source file (primarily for names and scraps) using calls to 
\verb|arena_getmem(n)|, where \verb|n| specifies the number of bytes to
be allocated. When the storage is no longer required, the entire arena
is freed with a single call to  \verb|arena_free()|. Both operations
are quite fast.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap181}
$\langle$Function prototypes {\footnotesize 69c}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@extern void *arena_getmem();@\\
\mbox{}\verb@extern void arena_free();@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro defined by scraps 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c.
\item Macro referenced in scrap 7a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap182}
\verb@"arena.c"@ {\footnotesize 70a }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@typedef struct chunk {@\\
\mbox{}\verb@  struct chunk *next;@\\
\mbox{}\verb@  char *limit;@\\
\mbox{}\verb@  char *avail;@\\
\mbox{}\verb@} Chunk;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9d, 70abc, 71c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
We define an empty chunk called \verb|first|. The variable \verb|arena| points
at the current chunk of memory; it's initially pointed at \verb|first|.
As soon as some storage is required, a ``real'' chunk of memory will
be allocated and attached to \verb|first->next|; storage will be
allocated from the new chunk (and later chunks if necessary).
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap183}
\verb@"arena.c"@ {\footnotesize 70b }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@static Chunk first = { NULL, NULL, NULL };@\\
\mbox{}\verb@static Chunk *arena = &first;@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9d, 70abc, 71c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Allocating Memory}

The routine \verb|arena_getmem(n)| returns a pointer to (at least) 
\verb|n| bytes of memory. Note that \verb|n| is rounded up to ensure
that returned pointers are always aligned.  We align to the nearest
8~byte segment, since that'll satisfy the more common 2-byte and
4-byte alignment restrictions too.

\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap184}
\verb@"arena.c"@ {\footnotesize 70c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void *arena_getmem(n)@\\
\mbox{}\verb@     size_t n;@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  char *q;@\\
\mbox{}\verb@  char *p = arena->avail;@\\
\mbox{}\verb@  n = (n + 7) & ~7;             /* ensuring alignment to 8 bytes */@\\
\mbox{}\verb@  q = p + n;@\\
\mbox{}\verb@  if (q <= arena->limit) {@\\
\mbox{}\verb@    arena->avail = q;@\\
\mbox{}\verb@    return p;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  @$\langle$Find a new chunk of memory {\footnotesize 71a}$\rangle$\verb@@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9d, 70abc, 71c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
If the current chunk doesn't have adequate space (at least \verb|n|
bytes) we examine the rest of the list of chunks (starting at 
\verb|arena->next|) looking for a chunk with adequate space. If \verb|n|
is very large, we may not find it right away or we may not find a
suitable chunk at all.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap185}
$\langle$Find a new chunk of memory {\footnotesize 71a}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  Chunk *ap = arena;@\\
\mbox{}\verb@  Chunk *np = ap->next;@\\
\mbox{}\verb@  while (np) {@\\
\mbox{}\verb@    char *v = sizeof(Chunk) + (char *) np;@\\
\mbox{}\verb@    if (v + n <= np->limit) {@\\
\mbox{}\verb@      np->avail = v + n;@\\
\mbox{}\verb@      arena = np;@\\
\mbox{}\verb@      return v;@\\
\mbox{}\verb@    }@\\
\mbox{}\verb@    ap = np;@\\
\mbox{}\verb@    np = ap->next;@\\
\mbox{}\verb@  }@\\
\mbox{}\verb@  @$\langle$Allocate a new chunk of memory {\footnotesize 71b}$\rangle$\verb@@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 70c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
If there isn't a suitable chunk of memory on the free list, then we
need to allocate a new one.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap186}
$\langle$Allocate a new chunk of memory {\footnotesize 71b}$\rangle\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@{@\\
\mbox{}\verb@  size_t m = n + 10000;@\\
\mbox{}\verb@  np = (Chunk *) malloc(m);@\\
\mbox{}\verb@  np->limit = m + (char *) np;@\\
\mbox{}\verb@  np->avail = n + sizeof(Chunk) + (char *) np;@\\
\mbox{}\verb@  np->next = NULL;@\\
\mbox{}\verb@  ap->next = np;@\\
\mbox{}\verb@  arena = np;@\\
\mbox{}\verb@  return sizeof(Chunk) + (char *) np;@\\
\mbox{}\verb@}@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item Macro referenced in scrap 71a.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\subsection{Freeing Memory}

To free all the memory in the arena, we need only point \verb|arena|
back to the first empty chunk.
\begin{flushleft} \small
\begin{minipage}{\linewidth} \label{scrap187}
\verb@"arena.c"@ {\footnotesize 71c }$\equiv$
\vspace{-1ex}
\begin{list}{}{} \item
\mbox{}\verb@void arena_free()@\\
\mbox{}\verb@{@\\
\mbox{}\verb@  arena = &first;@\\
\mbox{}\verb@}@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
\footnotesize\addtolength{\baselineskip}{-1ex}
\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item File defined by scraps 9d, 70abc, 71c.
\end{list}
\end{minipage}\\[4ex]
\end{flushleft}
\chapter{Indices} \label{indices}

Three sets of indices can be created automatically: an index of file
names, an index of macro names, and an index of user-specified
identifiers. An index entry includes the name of the entry, where it
was defined, and where it was referenced.

\section{Files}


{\small\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \verb@"arena.c"@ {\footnotesize Defined by scraps 9d, 70abc, 71c.
}
\item \verb@"global.c"@ {\footnotesize Defined by scrap 9e.}
\item \verb@"global.h"@ {\footnotesize Defined by scrap 7a.}
\item \verb@"html.c"@ {\footnotesize Defined by scraps 8e, 28ab, 32abc, 33a, 35a, 36c.
}
\item \verb@"input.c"@ {\footnotesize Defined by scraps 9a, 39d, 40ab, 42c.
}
\item \verb@"latex.c"@ {\footnotesize Defined by scraps 8d, 16d, 17a, 21b, 22a, 24b, 26b.
}
\item \verb@"main.c"@ {\footnotesize Defined by scraps 8b, 9f.
}
\item \verb@"names.c"@ {\footnotesize Defined by scraps 9c, 54ab, 55a, 56, 57ab, 58b, 60a, 62a, 63ab.
}
\item \verb@"output.c"@ {\footnotesize Defined by scraps 8f, 37c.
}
\item \verb@"pass1.c"@ {\footnotesize Defined by scraps 8c, 14b.
}
\item \verb@"scraps.c"@ {\footnotesize Defined by scraps 9b, 43abce, 44ab, 45bcde, 48bc, 49b, 52a, 63c, 64abcd, 65ab, 69ab.
}
\end{list}}

\section{Macros}


{\small\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item $\langle$Accumulate scrap and return \verb|scraps++| {\footnotesize 46b}$\rangle$ {\footnotesize Referenced in scrap 45e.}
\item $\langle$Add \verb|scrap| to \verb|name|'s definition list {\footnotesize 16a}$\rangle$ {\footnotesize Referenced in scraps 15bc.
}
\item $\langle$Add current scrap to \verb|name|'s uses {\footnotesize 48a}$\rangle$ {\footnotesize Referenced in scrap 47b.}
\item $\langle$Add letters to scraps with duplicate page numbers {\footnotesize 52b}$\rangle$ {\footnotesize Referenced in scrap 52a.}
\item $\langle$Allocate a new chunk of memory {\footnotesize 71b}$\rangle$ {\footnotesize Referenced in scrap 71a.}
\item $\langle$Begin HTML scrap environment {\footnotesize 30e}$\rangle$ {\footnotesize Referenced in scraps 30ac.
}
\item $\langle$Begin the scrap environment {\footnotesize 19c}$\rangle$ {\footnotesize Referenced in scraps 19ab.
}
\item $\langle$Build \verb|source_name| and \verb|tex_name| {\footnotesize 12b}$\rangle$ {\footnotesize Referenced in scrap 12a.}
\item $\langle$Build failure functions {\footnotesize 67}$\rangle$ {\footnotesize Referenced in scrap 65a.}
\item $\langle$Build macro definition {\footnotesize 15c}$\rangle$ {\footnotesize Referenced in scrap 15a.}
\item $\langle$Build output file definition {\footnotesize 15b}$\rangle$ {\footnotesize Referenced in scrap 15a.}
\item $\langle$Check HTML at-sequence for end-of-scrap {\footnotesize 33b}$\rangle$ {\footnotesize Referenced in scrap 33a.}
\item $\langle$Check at-sequence for end-of-scrap {\footnotesize 22c}$\rangle$ {\footnotesize Referenced in scrap 22a.}
\item $\langle$Check for ambiguous prefix {\footnotesize 55b}$\rangle$ {\footnotesize Referenced in scrap 55a.}
\item $\langle$Check for end of scrap name and return {\footnotesize 49a}$\rangle$ {\footnotesize Referenced in scrap 48c.}
\item $\langle$Check for macro invocation in scrap {\footnotesize 51b}$\rangle$ {\footnotesize Referenced in scrap 50a.}
\item $\langle$Check for terminating at-sequence and return name {\footnotesize 60b}$\rangle$ {\footnotesize Referenced in scrap 60a.}
\item $\langle$Cleanup and install name {\footnotesize 61a}$\rangle$ {\footnotesize Referenced in scraps 60b, 61b, 62b.
}
\item $\langle$Collect include-file name {\footnotesize 42a}$\rangle$ {\footnotesize Referenced in scrap 41b.}
\item $\langle$Collect user-specified index entries {\footnotesize 47a}$\rangle$ {\footnotesize Referenced in scrap 46c.}
\item $\langle$Compare the temp file and the old file {\footnotesize 38b}$\rangle$ {\footnotesize Referenced in scrap 38a.}
\item $\langle$Copy \verb|defs->scrap| to \verb|file| {\footnotesize 50a}$\rangle$ {\footnotesize Referenced in scrap 49b.}
\item $\langle$Copy \verb|source_file| into \verb|html_file| {\footnotesize 28c}$\rangle$ {\footnotesize Referenced in scrap 28b.}
\item $\langle$Copy \verb|source_file| into \verb|tex_file| {\footnotesize 17b}$\rangle$ {\footnotesize Referenced in scrap 17a.}
\item $\langle$Copy macro into \verb|file| {\footnotesize 51c}$\rangle$ {\footnotesize Referenced in scrap 51b.}
\item $\langle$Create new name entry {\footnotesize 58a}$\rangle$ {\footnotesize Referenced in scraps 55a, 57b.
}
\item $\langle$Create new scrap, managed by \verb|writer| {\footnotesize 46a}$\rangle$ {\footnotesize Referenced in scrap 45e.}
\item $\langle$Expand tab into spaces {\footnotesize 22b}$\rangle$ {\footnotesize Referenced in scraps 22a, 33a, 51a.
}
\item $\langle$Extend goto graph with \verb|tree->spelling| {\footnotesize 66}$\rangle$ {\footnotesize Referenced in scrap 65b.}
\item $\langle$Fill in the middle of HTML scrap environment {\footnotesize 31a}$\rangle$ {\footnotesize Referenced in scraps 30ac.
}
\item $\langle$Fill in the middle of the scrap environment {\footnotesize 19d}$\rangle$ {\footnotesize Referenced in scraps 19ab.
}
\item $\langle$Find a new chunk of memory {\footnotesize 71a}$\rangle$ {\footnotesize Referenced in scrap 70c.}
\item $\langle$Finish HTML scrap environment {\footnotesize 31b}$\rangle$ {\footnotesize Referenced in scraps 30ac.
}
\item $\langle$Finish the scrap environment {\footnotesize 20a}$\rangle$ {\footnotesize Referenced in scraps 19ab.
}
\item $\langle$Format HTML macro name {\footnotesize 34a}$\rangle$ {\footnotesize Referenced in scrap 33b.}
\item $\langle$Format a user HTML index entry {\footnotesize 37a}$\rangle$ {\footnotesize Referenced in scrap 36c.}
\item $\langle$Format a user index entry {\footnotesize 27a}$\rangle$ {\footnotesize Referenced in scrap 26b.}
\item $\langle$Format an HTML index entry {\footnotesize 35b}$\rangle$ {\footnotesize Referenced in scrap 35a.}
\item $\langle$Format an index entry {\footnotesize 24c}$\rangle$ {\footnotesize Referenced in scrap 24b.}
\item $\langle$Format macro name {\footnotesize 23b}$\rangle$ {\footnotesize Referenced in scrap 22c.}
\item $\langle$Function prototypes {\footnotesize 14a, 16c, 27b, 37b, 39a, 43d, 51d, 53d, 64e, 69c}$\rangle$ {\footnotesize Referenced in scrap 7a.}
\item $\langle$Global variable declarations {\footnotesize 10ac, 39b, 44d, 53b}$\rangle$ {\footnotesize Referenced in scrap 7a.}
\item $\langle$Global variable definitions {\footnotesize 10bd, 39c, 45a, 53c}$\rangle$ {\footnotesize Referenced in scrap 9e.}
\item $\langle$Handle \verb|EOF| {\footnotesize 42b}$\rangle$ {\footnotesize Referenced in scrap 40b.}
\item $\langle$Handle an ``at'' character {\footnotesize 41a}$\rangle$ {\footnotesize Referenced in scrap 40b.}
\item $\langle$Handle at-sign during scrap accumulation {\footnotesize 46c}$\rangle$ {\footnotesize Referenced in scrap 46b.}
\item $\langle$Handle macro invocation in scrap {\footnotesize 47b}$\rangle$ {\footnotesize Referenced in scrap 46c.}
\item $\langle$Handle optional per-file flags {\footnotesize 59}$\rangle$ {\footnotesize Referenced in scrap 58b.}
\item $\langle$Handle tab characters on output {\footnotesize 51a}$\rangle$ {\footnotesize Referenced in scrap 50a.}
\item $\langle$Handle the file name in \verb|argv[arg]| {\footnotesize 12a}$\rangle$ {\footnotesize Referenced in scrap 11c.}
\item $\langle$Include files {\footnotesize 7b}$\rangle$ {\footnotesize Referenced in scrap 7a.}
\item $\langle$Insert appropriate indentation {\footnotesize 50c}$\rangle$ {\footnotesize Referenced in scraps 50ab.
}
\item $\langle$Insert debugging information if required {\footnotesize 50b}$\rangle$ {\footnotesize Referenced in scraps 50a, 51b.
}
\item $\langle$Interpret HTML at-sequence {\footnotesize 29}$\rangle$ {\footnotesize Referenced in scrap 28c.}
\item $\langle$Interpret at-sequence {\footnotesize 18}$\rangle$ {\footnotesize Referenced in scrap 17b.}
\item $\langle$Interpret command-line arguments {\footnotesize 10e, 11a}$\rangle$ {\footnotesize Referenced in scrap 9f.}
\item $\langle$Interpret the argument string \verb|s| {\footnotesize 11b}$\rangle$ {\footnotesize Referenced in scrap 11a.}
\item $\langle$Look for end of scrap name and return {\footnotesize 62b}$\rangle$ {\footnotesize Referenced in scrap 62a.}
\item $\langle$Open an include file {\footnotesize 41b}$\rangle$ {\footnotesize Referenced in scrap 41a.}
\item $\langle$Process a file {\footnotesize 13}$\rangle$ {\footnotesize Referenced in scrap 12a.}
\item $\langle$Process the remaining arguments (file names) {\footnotesize 11c}$\rangle$ {\footnotesize Referenced in scrap 9f.}
\item $\langle$Reverse cross-reference lists {\footnotesize 16b}$\rangle$ {\footnotesize Referenced in scrap 14b.}
\item $\langle$Save macro name {\footnotesize 47c}$\rangle$ {\footnotesize Referenced in scrap 47b.}
\item $\langle$Scan at-sequence {\footnotesize 15a}$\rangle$ {\footnotesize Referenced in scrap 14c.}
\item $\langle$Scan the source file, looking for at-sequences {\footnotesize 14c}$\rangle$ {\footnotesize Referenced in scrap 14b.}
\item $\langle$Search scraps {\footnotesize 68}$\rangle$ {\footnotesize Referenced in scrap 65a.}
\item $\langle$Skip over index entries {\footnotesize 23a}$\rangle$ {\footnotesize Referenced in scraps 22c, 33b.
}
\item $\langle$Skip until scrap begins, then return name {\footnotesize 61b}$\rangle$ {\footnotesize Referenced in scrap 60a.}
\item $\langle$Type declarations {\footnotesize 8a, 52c, 53a}$\rangle$ {\footnotesize Referenced in scrap 7a.}
\item $\langle$Warn (only once) about needing to rerun after Latex {\footnotesize 44c}$\rangle$ {\footnotesize Referenced in scraps 44a, 52a.
}
\item $\langle$Write HTML abbreviated definition list {\footnotesize 34b}$\rangle$ {\footnotesize Referenced in scrap 34a.}
\item $\langle$Write HTML defining scrap numbers {\footnotesize 35d}$\rangle$ {\footnotesize Referenced in scrap 35b.}
\item $\langle$Write HTML file defs {\footnotesize 31c}$\rangle$ {\footnotesize Referenced in scrap 30a.}
\item $\langle$Write HTML file's defining scrap numbers {\footnotesize 35c}$\rangle$ {\footnotesize Referenced in scrap 35b.}
\item $\langle$Write HTML index of file names {\footnotesize 34c}$\rangle$ {\footnotesize Referenced in scrap 29.}
\item $\langle$Write HTML index of macro names {\footnotesize 34d}$\rangle$ {\footnotesize Referenced in scrap 29.}
\item $\langle$Write HTML index of user-specified names {\footnotesize 36b}$\rangle$ {\footnotesize Referenced in scrap 29.}
\item $\langle$Write HTML macro declaration {\footnotesize 30d}$\rangle$ {\footnotesize Referenced in scrap 30c.}
\item $\langle$Write HTML macro definition {\footnotesize 30c}$\rangle$ {\footnotesize Referenced in scrap 29.}
\item $\langle$Write HTML macro defs {\footnotesize 31d}$\rangle$ {\footnotesize Referenced in scrap 30c.}
\item $\langle$Write HTML macro refs {\footnotesize 31e}$\rangle$ {\footnotesize Referenced in scrap 30c.}
\item $\langle$Write HTML output file declaration {\footnotesize 30b}$\rangle$ {\footnotesize Referenced in scrap 30a.}
\item $\langle$Write HTML output file definition {\footnotesize 30a}$\rangle$ {\footnotesize Referenced in scrap 29.}
\item $\langle$Write HTML referencing scrap numbers {\footnotesize 36a}$\rangle$ {\footnotesize Referenced in scrap 35b.}
\item $\langle$Write abbreviated definition list {\footnotesize 23c}$\rangle$ {\footnotesize Referenced in scrap 23b.}
\item $\langle$Write defining scrap numbers {\footnotesize 25b}$\rangle$ {\footnotesize Referenced in scrap 24c.}
\item $\langle$Write file defs {\footnotesize 20b}$\rangle$ {\footnotesize Referenced in scrap 19a.}
\item $\langle$Write file's defining scrap numbers {\footnotesize 25a}$\rangle$ {\footnotesize Referenced in scrap 24c.}
\item $\langle$Write index of file names {\footnotesize 23d}$\rangle$ {\footnotesize Referenced in scrap 18.}
\item $\langle$Write index of macro names {\footnotesize 24a}$\rangle$ {\footnotesize Referenced in scrap 18.}
\item $\langle$Write index of user-specified names {\footnotesize 26a}$\rangle$ {\footnotesize Referenced in scrap 18.}
\item $\langle$Write macro definition {\footnotesize 19b}$\rangle$ {\footnotesize Referenced in scrap 18.}
\item $\langle$Write macro defs {\footnotesize 20c}$\rangle$ {\footnotesize Referenced in scrap 19b.}
\item $\langle$Write macro refs {\footnotesize 21a}$\rangle$ {\footnotesize Referenced in scrap 19b.}
\item $\langle$Write out \verb|files->spelling| {\footnotesize 38a}$\rangle$ {\footnotesize Referenced in scrap 37c.}
\item $\langle$Write output file definition {\footnotesize 19a}$\rangle$ {\footnotesize Referenced in scrap 18.}
\item $\langle$Write referencing scrap numbers {\footnotesize 25c}$\rangle$ {\footnotesize Referenced in scrap 24c.}
\end{list}}

\section{Identifiers}

Knuth prints his index of identifiers in a two-column format.
I could force this automatically by emitting the \verb|\twocolumn|
command; but this has the side effect of forcing a new page.
Therefore, it seems better to leave it this up to the user.


{\small\begin{list}{}{\setlength{\itemsep}{-\parsep}\setlength{\itemindent}{-\leftmargin}}
\item \verb@already_warned@: 44c, \underline{44d}, 45a, 52a.
\item \verb@arena@: \underline{70b}, 70c, 71abc.
\item \verb@arena_free@: 13, 69c, \underline{71c}.
\item \verb@arena_getmem@: 16a, 43e, 45c, 46a, 47a, 48a, 54b, 58a, 65a, 66, 67, 68, 69c, \underline{70c}.
\item \verb@build_gotos@: 65a, \underline{65b}.
\item \verb@Chunk@: \underline{70a}, 70b, 71ab.
\item \verb@collect_file_name@: 15b, 19a, 30a, 53d, \underline{58b}.
\item \verb@collect_macro_name@: 15c, 19b, 30c, 53d, \underline{60a}.
\item \verb@collect_numbers@: 13, 51d, \underline{52a}.
\item \verb@collect_scrap@: 15bc, 43d, \underline{45e}.
\item \verb@collect_scrap_name@: 23b, 34a, 47b, 53d, \underline{62a}.
\item \verb@command_name@: \underline{10c}, 10de, 11bc, 15a, 17a, 21a, 23b, 28b, 31e, 34a, 38a, 41ab, 42ac, 44c, 46bc, 47a, 49a, 51c, 55b, 58b, 59, 60ab, 61ab, 62ab.
\item \verb@compare@: \underline{54a}, 55a, 56.
\item \verb@compare_flag@: \underline{10a}, 10b, 11b, 38a.
\item \verb@copy_scrap@: 16d, 19d, \underline{22a}, 28a, 31a, \underline{33a}.
\item \verb@depths@: \underline{64c}, 65a, 66, 67.
\item \verb@display_scrap_numbers@: 28a, \underline{32b}, 32c, 35d.
\item \verb@display_scrap_ref@: 28a, \underline{32a}, 32b, 34b, 37a.
\item \verb@double_at@: \underline{39d}, 41a, 42c.
\item \verb@EQUAL@: \underline{54a}, 55a, 56.
\item \verb@exit@: \underline{7b}, 9f, 11c, 38a, 41ab, 42ac, 46bc, 47a, 49a, 51c, 58b, 60ab, 61ab, 62ab.
\item \verb@EXTENSION@: \underline{54a}, 55a, 56.
\item \verb@FALSE@: \underline{8a}, 10ab, 11b, 18, 21b, 24a, 25b, 27a, 34d, 41a, 42c, 51c, 52a, 56, 58a, 59, 69ab.
\item \verb@fclose@: \underline{7b}, 17a, 28b, 38ab, 42b, 52a.
\item \verb@FILE@: \underline{7b}, 17a, 21b, 22a, 24b, 26b, 28b, 32abc, 33a, 35a, 36c, 38ab, 39d, 40a, 44ab, 49b, 52a.
\item \verb@file_names@: 13, 14b, 16b, 23d, 34c, \underline{53b}, 53c, 58b.
\item \verb@first@: 44a, 69b, \underline{70b}, 71c.
\item \verb@fopen@: \underline{7b}, 17a, 28b, 38ab, 41b, 42c, 52a.
\item \verb@format_entry@: 16d, 23d, 24a, \underline{24b}, 28a, 34cd, \underline{35a}.
\item \verb@format_user_entry@: 16d, 26a, \underline{26b}, 28a, 36b, \underline{36c}.
\item \verb@fprintf@: \underline{7b}, 11bc, 14b, 15a, 17a, 19abc, 21a, 23b, 24c, 27a, 28b, 30bd, 31e, 34a, 35b, 37a, 38a, 41ab, 42ac, 44ac, 46bc, 47a, 49a, 50b, 51c, 55b, 58b, 59, 60ab, 61ab, 62ab.
\item \verb@fputs@: \underline{7b}, 19abcd, 20abc, 21ab, 22ac, 23bcd, 24ac, 25ac, 26a, 27a, 30bde, 31abcde, 32abc, 33a, 34abcd, 35bc, 36ab, 37a, 44a.
\item \verb@getc@: \underline{7b}, 38b, 40b, 41ab, 42abc.
\item \verb@goto_lookup@: \underline{64d}, 66, 67, 68.
\item \verb@Goto_Node@: \underline{64a}, 64bcd, 65a, 66, 67, 68.
\item \verb@GREATER@: \underline{54a}, 55a, 56.
\item \verb@html_flag@: \underline{10a}, 10b, 12b, 13.
\item \verb@include_depth@: \underline{39d}, 41b, 42bc.
\item \verb@init_scraps@: 14b, 43d, \underline{43e}.
\item \verb@isgraph@: \underline{7b}, 42a, 58b, 62a.
\item \verb@islower@: \underline{7b}, 57a.
\item \verb@isspace@: \underline{7b}, 20a, 47a, 58b, 59, 60a, 61b.
\item \verb@isupper@: \underline{7b}, 57a.
\item \verb@LESS@: \underline{54a}, 55a, 56.
\item \verb@macro_names@: 14b, 16b, 24a, 34d, 49a, \underline{53b}, 53c, 61a.
\item \verb@main@: \underline{9f}.
\item \verb@malloc@: \underline{7b}, 71b.
\item \verb@Manager@: \underline{45b}, 45cde, 48bc, 50a, 68, 69b.
\item \verb@max_depth@: \underline{64c}, 65a, 66, 67.
\item \verb@Move_Node@: \underline{64b}, 64d, 66, 67.
\item \verb@Name@: 15bc, 19ab, 23b, 24b, 26b, 30ac, 34a, 35a, 36c, 37c, 47ab, 48c, 51c, \underline{53a}, 53bcd, 55a, 56, 57b, 58ab, 60a, 62a, 63ac, 65b, 68, 69b.
\item \verb@name_add@: 47a, 53d, \underline{57b}, 58b.
\item \verb@Name_Node@: \underline{63c}, 64a, 66, 67, 68.
\item \verb@number_flag@: \underline{10a}, 10b, 11b, 13, 52a.
\item \verb@op_char@: \underline{69a}, 69b.
\item \verb@output_flag@: \underline{10a}, 10b, 11b, 13.
\item \verb@pass1@: 13, 14a, \underline{14b}, 22c, 33b.
\item \verb@pop@: \underline{48b}, 48c, 49a, 50a, 51b, 68.
\item \verb@pop_scrap_name@: \underline{48c}, 51c.
\item \verb@PREFIX@: \underline{54a}, 55a, 56.
\item \verb@prefix_add@: 49a, 53d, \underline{55a}, 61a.
\item \verb@print_scrap_numbers@: 16d, 20bc, 21a, \underline{21b}, 25ac, 28a, 31cde, \underline{32c}, 35c, 36a.
\item \verb@push@: \underline{45c}, 45d, 46bc, 47c.
\item \verb@pushs@: \underline{45d}, 46c, 47c.
\item \verb@putc@: \underline{7b}, 17b, 18, 22abc, 23b, 24c, 25abc, 27a, 28c, 29, 33a, 34a, 35bd, 44a, 50ac, 51ab.
\item \verb@reject_match@: 65a, 68, \underline{69b}.
\item \verb@remove@: \underline{7b}, 38ab.
\item \verb@reverse@: 63a, \underline{63b}.
\item \verb@reverse_lists@: 16b, 53d, \underline{63a}.
\item \verb@robs_strcmp@: \underline{57a}, 57b.
\item \verb@root@: 55a, 57b, 58a, \underline{64c}, 65a, 66, 67, 68.
\item \verb@save_string@: 41b, 46a, 53d, \underline{54b}, 55a, 58a.
\item \verb@SCRAP@: \underline{43c}, 43e, 46a.
\item \verb@ScrapEntry@: \underline{43b}, 43ce, 46a.
\item \verb@scraps@: 10a, 17b, 19abc, 20bc, 21ab, 28c, 30abcd, 32bc, \underline{43c}, 43e, 45e, 46abc, 47a, 48a, 52ab, 65a, 68.
\item \verb@scrap_array@: \underline{43c}, 44a, 46ab, 50ab, 52ab, 68.
\item \verb@Scrap_Node@: 16a, 21b, 23c, 25abc, 27a, 32bc, 34b, 36a, 37a, 47a, 48a, 49b, \underline{52c}, 53a, 63ab, 68.
\item \verb@search@: 14b, 64e, \underline{65a}.
\item \verb@size_t@: \underline{7b}, 70c, 71b.
\item \verb@Slab@: \underline{43a}, 43b, 45bc, 46a, 48b.
\item \verb@SLAB_SIZE@: \underline{43a}, 45c, 48b, 69b.
\item \verb@source_file@: 17a, 28b, \underline{39d}, 40b, 41ab, 42abc.
\item \verb@source_get@: 14c, 15a, 17b, 18, 20a, 22ac, 23ad, 24a, 26a, 28c, 29, 31b, 33ab, 34cd, 36b, 39a, \underline{40b}, 41b, 42b, 46bc, 47ab, 58b, 59, 60ab, 61b, 62ab.
\item \verb@source_line@: 15a, \underline{39b}, 39c, 40b, 41ab, 42abc, 46ac, 47a, 55b, 58b, 59, 60a, 61a, 62ab.
\item \verb@source_name@: 12ab, 13, 15a, \underline{39b}, 39c, 41ab, 42abc, 46ac, 47a, 55b, 58b, 59, 60ab, 61ab, 62ab.
\item \verb@source_open@: 14b, 17a, 28b, 39a, \underline{42c}.
\item \verb@source_peek@: \underline{39d}, 40b, 41ab, 42bc.
\item \verb@stack@: \underline{40a}, 41b, 42b.
\item \verb@stderr@: \underline{7b}, 11bc, 14b, 15a, 17a, 21a, 23b, 28b, 31e, 34a, 38a, 41ab, 42ac, 44c, 46bc, 47a, 49a, 51c, 55b, 58b, 59, 60ab, 61ab, 62ab.
\item \verb@strlen@: \underline{7b}, 47c, 54ab, 69b.
\item \verb@sym_char@: \underline{69a}, 69b.
\item \verb@tempnam@: \underline{7b}, 38a.
\item \verb@tex_flag@: \underline{10a}, 10b, 11b, 13, 14b, 51c.
\item \verb@toupper@: \underline{7b}, 57a.
\item \verb@TRUE@: \underline{8a}, 10ab, 11b, 13, 18, 21b, 23d, 25b, 27a, 34c, 41a, 44bc, 48c, 51c, 56, 58a, 59, 69ab.
\item \verb@user_names@: 14b, 16b, 26a, 36b, 47a, \underline{53b}, 53c, 65a.
\item \verb@verbose_flag@: \underline{10a}, 10b, 11b, 14b, 17a, 28b, 38a.
\item \verb@write_files@: 13, 37b, \underline{37c}.
\item \verb@write_html@: 13, 27b, \underline{28b}.
\item \verb@write_scraps@: 38a, 43d, \underline{49b}, 51c.
\item \verb@write_scrap_ref@: 21b, 25b, 27a, 43d, \underline{44a}, 44b.
\item \verb@write_single_scrap_ref@: 19ab, 21a, 23c, 25ac, 27a, 30bd, 32a, 43d, \underline{44b}.
\item \verb@write_tex@: 13, 16c, \underline{17a}.
\end{list}}

\fi

\bibliographystyle{plain}
\bibliography{literate}

\end{document}