summaryrefslogtreecommitdiff
path: root/support/rtflatex/rtflatex.c
blob: a7f7385bfe9e8cfa0b3a8351ff68b139fa3ced32 (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
/* Output from p2c 1.21alpha2-dt-Jul.95, the Pascal-to-C translator */
/* From input file "rtflatex.pas" */
 
 
#include "p2crtf.h"
#include "p2c_mods.h"
#include "p2clib_m.c"
 
 
/* version 2.15 */
 
 
#define lmx             511
#define olmx            1023
#define maxlevel        72
#define maxkeyln        64
#define bfslen          24
#define numsizes        16
#define maxfonts        128
#define maxstyles       12
#define max_skip_strings  8
#define maxRTFstyles    64
#define RTFstyle_length  128
 
 
typedef Char string24[bfslen + 1];
 
typedef Char string2[3];
 
typedef Char string5[6];
 
typedef Char string128[129];
 
typedef Char string255[256];
 
typedef Char exline_type[olmx];
typedef Char string_RTFstyle[RTFstyle_length + 1];
 
 
Static FILE *inputfile, *outputfile, *figurefile, *logfile, *skipfile;
Static short catcode[256], digit[256], majusc[256], letter[256];
Static string24 acc_transl[256], ftech_transl[256];
Static Char prev_line[lmx], inpline[lmx];
Static exline_type exline;
Static short tex_verbose, verbose, icharz, numl, kout, kinp, prev_kinp,
	     bracelvl;
Static short lvlcode[maxlevel + 1], tab_nb_cellx[maxlevel + 1],
	     tab_nb_ands[maxlevel + 1], tab_cellx[maxlevel + 1];
Static Char kar, hexaone, hexatwo;
Static string255 next_rtf;
Static boolean removed_ok, write_log, do_it_again, no_space_conv, use_sl,
	       latex209, latex_header, base_flag, envir_closed_ok,
	       last_percent, simplify_ok, no_RTFrtf, par_to_begin;
Static short num_styles, input_line_number, numfonts, num_word_fonts, stdsize,
	     stdkz;
Static string24 close_kar[maxlevel + 1], form_code[maxlevel + 1],
		bfslcode[maxlevel + 1], sizecode[maxlevel + 1],
		currsize[maxlevel + 1], currbfsl[maxlevel + 1],
		spacingcode[maxlevel + 1], active_RTFf[maxlevel + 1];
Static short center_flag[maxlevel + 1], flushright_flag[maxlevel + 1],
	     math_mode[maxlevel + 1];
Static boolean underl_flag[maxlevel + 1], auto_close[maxlevel + 1];
Static string24 sizekey[numsizes];
Static short sizeval[3][numsizes];
Static short sizemags[3][numsizes];
Static string24 newfonts[maxfonts], word_fonts[maxfonts],
		equiv_fonts[maxfonts], font_names[maxfonts];
Static short word_font_num[maxfonts];
Static string255 inkeyw;
Static short num_diff_sizes, keyw, cat, ikar, numval, numsign, num_hexa,
	     num_skip_strings, decl_font_num, num_latex_options, num_indent,
	     i, j, k, l, m, n;
Static string24 works, worksa, worksb, latex_style, end_math_code;
Static string24 latex_options[maxstyles + 1];
Static string24 environ_type[11];
Static string255 skip_strings[max_skip_strings];
Static short leftskip, rightskip, leftcurskip, rightcurskip, save_skip,
	     space_after, displ_skip;
Static string_RTFstyle RTFstyles[maxRTFstyles];
Static short ref_styles[256];
 
Static boolean clbrdrr, clbrdrl, clbrdrt, clbrdrb;
 
/* indications to build file names of figure bitmaps */
Static string128 figure_name, figure_path, figure_type;
Static string24 pict_name;
Static long rtfpicw, rtfpich, pict_char_number, pict_byte_number;
Static short pict_last_hexa, pict_number;
Static boolean pict_left_hexa;
Static Char last_kar;
Static Char inputfile_NAME[_FNSIZE];
Static Char outputfile_NAME[_FNSIZE];
Static Char figurefile_NAME[_FNSIZE];
Static Char logfile_NAME[_FNSIZE];
Static Char skipfile_NAME[_FNSIZE];
 
 
/*---------------------------------------------------------------------------*/
/* resets all integers to 0, all strings to '', for safety */
 
Static Void clean_all()
{
  short z;
 
  for (z = 1; z <= lmx; z++)
    prev_line[k-1] = ' ';
  for (z = 1; z <= lmx; z++)
    inpline[k-1] = ' ';
  for (z = 1; z <= olmx; z++)
    exline[k-1] = ' ';
 
  tex_verbose = 0;
  verbose = 0;
  icharz = 0;
  numl = 0;
  kout = 0;
  kinp = 0;
  prev_kinp = 0;
  bracelvl = 0;
 
  for (z = 0; z <= maxlevel; z++) {
    lvlcode[z] = 0;
    tab_nb_cellx[z] = 0;
    tab_nb_ands[z] = 0;
    tab_cellx[z] = 0;
  }
  kar = ' ';
  hexaone = ' ';
  hexatwo = ' ';
 
  *next_rtf = '\0';
  removed_ok = false;
  write_log = false;
  do_it_again = false;
  no_space_conv = false;
  use_sl = false;
  latex209 = false;
  latex_header = false;
  base_flag = false;
  envir_closed_ok = false;
  last_percent = false;
  simplify_ok = false;
  no_RTFrtf = false;
  par_to_begin = false;
 
  num_styles = 0;
  input_line_number = 0;
  numfonts = 0;
  num_word_fonts = 0;
  stdsize = 0;
  stdkz = 0;
 
  for (z = 0; z <= maxlevel; z++) {
    *close_kar[z] = '\0';
    *form_code[z] = '\0';
    *bfslcode[z] = '\0';
    *sizecode[z] = '\0';
    *currsize[z] = '\0';
    *currbfsl[z] = '\0';
    *spacingcode[z] = '\0';
    *active_RTFf[z] = '\0';
    center_flag[z] = 0;
    flushright_flag[z] = 0;
    math_mode[z] = 0;
    underl_flag[z] = false;
    auto_close[z] = false;
  }
  /*  sizekey : array[1..numsizes] of string24; */
  /*  sizeval : array[1..3,1..numsizes] of integer; */
  /*  sizemags : array[1..3,1..numsizes] of integer; */
  for (z = 0; z <= maxfonts - 1; z++) {
    *newfonts[z] = '\0';
    *word_fonts[z] = '\0';
    *equiv_fonts[z] = '\0';
    *font_names[z] = '\0';
    word_font_num[z] = 0;
  }
  *inkeyw = '\0';
  num_diff_sizes = 0;
  keyw = 0;
  cat = 0;
  ikar = 0;
  numval = 0;
  numsign = 0;
  num_hexa = 0;
  num_skip_strings = 0;
  decl_font_num = 0;
  num_latex_options = 0;
  num_indent = 0;
  i = 0;
  j = 0;
  k = 0;
  l = 0;
  m = 0;
  n = 0;
  *works = '\0';
  *worksa = '\0';
  *worksb = '\0';
  *latex_style = '\0';
  *end_math_code = '\0';
 
  for (z = 0; z <= maxstyles; z++)
    *latex_options[z] = '\0';
  for (z = 0; z <= 10; z++)
    *environ_type[z] = '\0';
  for (z = 0; z <= max_skip_strings - 1; z++)
    *skip_strings[z] = '\0';
  leftskip = 0;
  rightskip = 0;
  leftcurskip = 0;
  rightcurskip = 0;
  save_skip = 0;
  space_after = 0;
  displ_skip = 0;
 
  for (z = 0; z <= maxRTFstyles - 1; z++)
    *RTFstyles[z] = '\0';
  for (z = 0; z <= 255; z++)
    ref_styles[z] = 0;
 
  clbrdrr = false;
  clbrdrl = false;
  clbrdrt = false;
  clbrdrb = false;
 
  /* indications to build file names of figure bitmaps */
  *figure_name = '\0';
  *figure_path = '\0';
  *figure_type = '\0';
  *pict_name = '\0';
  rtfpicw = 0;
  rtfpich = 0;
  pict_char_number = 0;
  pict_byte_number = 0;
  pict_last_hexa = 0;
  pict_number = 0;
  pict_left_hexa = false;
  last_kar = ' ';
}
 
 
/*---------------------------------------------------------------------------*/
 
Static Void title()
{
  printf("           MICROSOFT RTF(Word[Perfect]) to LaTeX conversion\n");
  printf("           Daniel Taupin, CNRS, 20th September 1996\n");
  printf("           Universite de Paris-Sud, Orsay, France\n");
  printf("           Version 2.15\n");
  printf("           E-mail: taupin@lps.u-psud.fr\n");
}
 
 
/*---------------------------------------------------------------------------*/
/* converts a hexa character into a number from 0 to 15 */
 
Static short hx_to_i(kar)
Char kar;
{
  short ikar = kar;
  short okar;
 
  if (ikar < '0') {
    okar = 0;
    return okar;
  }
  if (ikar <= '9') {
    okar = ikar - '0';
    return okar;
  }
  if (ikar <= 'Z') {
    okar = ikar + 10 - 'A';
    return okar;
  }
  if (ikar <= 'z')
    okar = ikar + 10 - 'a';
  else
    okar = 0;
  /*END IF ikar */
  return okar;
}
 
 
/*---------------------------------------------------------------------------*/
/* converts a string of two hexa character into a number from 0 to 255 */
 
Static short hs_to_i(input_stg)
Char *input_stg;
{
  return (hx_to_i(input_stg[0]) * 16 + hx_to_i(input_stg[1]));
}
 
 
/*---------------------------------------------------------------------------*/
/* truncate at bfslen a string */
 
Static Char *truncate24(Result, a)
Char *Result;
Char *a;
{
  sprintf(Result, "%.*s", bfslen, a);
  return Result;
/* p2c: rtflatex.h, line 173:
 * Note: Possible faulty string assignment [145] */
/* p2c: rtflatex.h, line 173:
 * Note: string[24] := string[255] => unpredictable crashes */
}
 
 
/* version 2.15 */
 
/*---------------------------------------------------------------------------*/
/* finds the '.' initiating the postfix of the given file name */
 
Static short pos_postfix(xx)
Char *xx;
{
  short Result = 0;
  short i, FORLIM;
 
  FORLIM = strlen(xx);
  for (i = 1; i <= FORLIM; i++) {   /*END DO*/
    if (xx[i-1] == '.')
      Result = i;
    else if (xx[i-1] == ']')
      Result = 0;
    else if (xx[i-1] == '/')
      Result = 0;
    else if (xx[i-1] == '\\')
      Result = 0;
    else if (xx[i-1] == ':')
      Result = 0;
  }
  /*END IF*/
  return Result;
}
 
 
/*---------------------------------------------------------------------------*/
/* the signed variant of str(n,stg) */
 
Static Void sign_str(num, out_sign_str)
short num;
Char *out_sign_str;
{
  string255 sign_work;
  Char STR2[256];
 
  sprintf(sign_work, "%d", num);
  /*  if (num<0) then out_sign_str:='-'+sign_work */
  if (num < 0) {
    sprintf(STR2, "-%s", sign_work);
    truncate24(out_sign_str, STR2);
  } else {
    truncate24(out_sign_str, sign_work);
    /*END IF*/
  }
}
 
 
/*---------------------------------------------------------------------------*/
/* prints/displays a message */
 
Static Void print_msg(verbose_level, msg)
short verbose_level;
Char *msg;
{
  if (verbose >= verbose_level)
    fputs(msg, stdout);
  if (write_log)
    fputs(msg, logfile);
}
 
 
/*---------------------------------------------------------------------------*/
/* prints/displays a message with RETURN */
 
Static Void println_msg(verbose_level, msg)
short verbose_level;
Char *msg;
{
  if (verbose >= verbose_level)
    puts(msg);
  if (write_log)
    fprintf(logfile, "%s\n", msg);
}
 
 
/* ======================================================================= */
/* used at initialization to store one size name (Latex) and its magnitudes */
 
Static Void sizeone(i, s, j, k, l, mag10, mag11, mag12)
short i;
Char *s;
short j, k, l, mag10, mag11, mag12;
{
  truncate24(sizekey[i-1], s);
  sizeval[0][i-1] = j;
  sizemags[0][i-1] = mag10;
  sizeval[1][i-1] = k;
  sizemags[1][i-1] = mag11;
  sizeval[2][i-1] = l;
  sizemags[2][i-1] = mag12;
}
 
 
/* ======================================================================= */
/* initialization of LaTeX font heights <==> size keywords */
 
Static Void sizeinit()
{
  short k;
 
  sizeone(1, "HUGE", 720, 720, 840, 2986, 2986, 3583);
  sizeone(2, "Huge", 600, 600, 720, 2488, 2488, 2986);
  sizeone(3, "huge", 500, 500, 600, 2074, 2074, 2488);
  sizeone(4, "LARGE", 440, 440, 500, 1728, 1728, 2074);
  sizeone(5, "Large", 360, 360, 440, 1440, 1440, 1728);
  sizeone(6, "large", 280, 280, 360, 1200, 1200, 1440);
  sizeone(7, "normalsize", 240, 272, 290, 1000, 1095, 1200);
  sizeone(8, "small", 220, 240, 272, 900, 1000, 1095);
  sizeone(9, "footnotesize", 190, 220, 240, 800, 900, 1000);
  sizeone(10, "scriptsize", 160, 190, 190, 700, 800, 800);
  sizeone(11, "tiny", 120, 140, 140, 500, 600, 600);
  for (k = 12; k <= 16; k++)
    sizeone(k, "tiny", 0, 0, 0, 500, 600, 600);
  num_diff_sizes = 11;
 
  for (k = 0; k <= 10; k++)
    strcpy(environ_type[k], "\\RTFerror");
 
  strcpy(environ_type[0], "document");
  strcpy(environ_type[1], "center");
  strcpy(environ_type[2], "flushright");
 
}
 
 
/* ======================================================================= */
 
Static Void mac_init()
{
  short k;
 
  /* install the conversions of RTF accents (coded \'xx in hexa) */
  /* build a list of conversion of accented letters */
 
  for (k = 0; k <= 255; k++)
    *acc_transl[k] = '\0';
 
  strcpy(acc_transl[hs_to_i("80")], "\"A");
  strcpy(acc_transl[hs_to_i("81")], "\\AA{}");
  strcpy(acc_transl[hs_to_i("82")], "\\c{C}");
  strcpy(acc_transl[hs_to_i("83")], "\\'E");
  strcpy(acc_transl[hs_to_i("84")], "\\~N");
  strcpy(acc_transl[hs_to_i("85")], "\\\"O");
  strcpy(acc_transl[hs_to_i("86")], "\\\"U");
  strcpy(acc_transl[hs_to_i("87")], "\\'a");
  strcpy(acc_transl[hs_to_i("88")], "\\`a");
  strcpy(acc_transl[hs_to_i("89")], "\\^a");
  strcpy(acc_transl[hs_to_i("8a")], "\\\"a");
  strcpy(acc_transl[hs_to_i("8b")], "\\~a");
  strcpy(acc_transl[hs_to_i("8c")], "\\aa{}");
  strcpy(acc_transl[hs_to_i("8d")], "\\c{c}");
  strcpy(acc_transl[hs_to_i("8e")], "\\'e");
  strcpy(acc_transl[hs_to_i("8f")], "\\`e");
  strcpy(acc_transl[hs_to_i("90")], "\\^e");
  strcpy(acc_transl[hs_to_i("91")], "\\\"e");
  strcpy(acc_transl[hs_to_i("93")], "\\'{\\i}");
  strcpy(acc_transl[hs_to_i("93")], "\\`{\\i}");
  strcpy(acc_transl[hs_to_i("94")], "\\^{\\i}");
  strcpy(acc_transl[hs_to_i("95")], "\\\"{\\i}");
  strcpy(acc_transl[hs_to_i("96")], "\\~n");
  strcpy(acc_transl[hs_to_i("97")], "\\'o");
  strcpy(acc_transl[hs_to_i("98")], "\\`o");
  strcpy(acc_transl[hs_to_i("99")], "\\^o");
  strcpy(acc_transl[hs_to_i("9a")], "\\\"o");
  strcpy(acc_transl[hs_to_i("9b")], "\\~o");
  strcpy(acc_transl[hs_to_i("9c")], "\\'u");
  strcpy(acc_transl[hs_to_i("9d")], "\\`u");
  strcpy(acc_transl[hs_to_i("9e")], "\\^u");
  strcpy(acc_transl[hs_to_i("9f")], "\\\"u");
  strcpy(acc_transl[hs_to_i("a0")], "\\dag{}");
  strcpy(acc_transl[hs_to_i("a1")], "\\degree{}");
  strcpy(acc_transl[hs_to_i("a3")], "\\pound{}");
  strcpy(acc_transl[hs_to_i("a4")], "\\S{}");
  strcpy(acc_transl[hs_to_i("a7")], "\\ss{}");
  strcpy(acc_transl[hs_to_i("ae")], "\\AE{}");
  strcpy(acc_transl[hs_to_i("af")], "\\O{}");
  strcpy(acc_transl[hs_to_i("b0")], "$\\infty ");
  strcpy(acc_transl[hs_to_i("b1")], "$\\pm ");
  strcpy(acc_transl[hs_to_i("b2")], "$\\leq ");
  strcpy(acc_transl[hs_to_i("b3")], "$\\geq ");
  strcpy(acc_transl[hs_to_i("b5")], "$\\mu ");
  strcpy(acc_transl[hs_to_i("b6")], "$\\partial ");
  strcpy(acc_transl[hs_to_i("b7")], "$\\Sigma ");
  strcpy(acc_transl[hs_to_i("b8")], "$\\Pi ");
  strcpy(acc_transl[hs_to_i("b9")], "$\\pi ");
  strcpy(acc_transl[hs_to_i("bd")], "${1\\over2}");
  strcpy(acc_transl[hs_to_i("bf")], "\\o{}");
  strcpy(acc_transl[hs_to_i("c6")], "$\\Delta ");
  strcpy(acc_transl[hs_to_i("c9")], "...");
  strcpy(acc_transl[hs_to_i("cb")], "\\`A");
  strcpy(acc_transl[hs_to_i("cc")], "\\~A");
  strcpy(acc_transl[hs_to_i("cd")], "\\~O");
  strcpy(acc_transl[hs_to_i("ce")], "\\OE{}");
  strcpy(acc_transl[hs_to_i("cf")], "\\oe{}");
  strcpy(acc_transl[hs_to_i("d0")], "--{}");
  strcpy(acc_transl[hs_to_i("d1")], "---{}");
  strcpy(acc_transl[hs_to_i("d2")], "``");
  strcpy(acc_transl[hs_to_i("d3")], "''");
  strcpy(acc_transl[hs_to_i("d4")], "`{}");
  strcpy(acc_transl[hs_to_i("d5")], "'{}");
  strcpy(acc_transl[hs_to_i("d6")], "$\\div ");
  strcpy(acc_transl[hs_to_i("d8")], "\\\"y");
  strcpy(acc_transl[hs_to_i("e1")], "$\\cdot ");
  strcpy(acc_transl[hs_to_i("e4")], "\\\"a");
  strcpy(acc_transl[hs_to_i("e5")], "\\^A");
  strcpy(acc_transl[hs_to_i("e6")], "\\^E");
  strcpy(acc_transl[hs_to_i("e7")], "\\'A");
  strcpy(acc_transl[hs_to_i("e8")], "\\\"E");
  strcpy(acc_transl[hs_to_i("e9")], "\\`E");
  strcpy(acc_transl[hs_to_i("ea")], "\\'I");
  strcpy(acc_transl[hs_to_i("eb")], "\\^I");
  strcpy(acc_transl[hs_to_i("ec")], "\\\"I");
  strcpy(acc_transl[hs_to_i("ed")], "\\`I");
  strcpy(acc_transl[hs_to_i("ee")], "\\'O");
  strcpy(acc_transl[hs_to_i("ef")], "\\^O");
  strcpy(acc_transl[hs_to_i("f1")], "\\`O");
  strcpy(acc_transl[hs_to_i("f2")], "\\'U");
  strcpy(acc_transl[hs_to_i("f3")], "\\^U");
  strcpy(acc_transl[hs_to_i("f4")], "\\`U");
  strcpy(acc_transl[hs_to_i("f6")], "\\\"o");
  strcpy(acc_transl[hs_to_i("fb")], "\\degree{}");
  strcpy(acc_transl[hs_to_i("fc")], "\\\"u");
 
}
 
 
/* ======================================================================= */
 
Static Void ansi_init()
{
  short k;
 
  /* install the conversions of RTF accents (coded \'xx in hexa) */
  /* build a list of conversion of accented letters */
 
  for (k = 0; k <= 255; k++)
    *acc_transl[k] = '\0';
 
  strcpy(acc_transl[hs_to_i("a1")], "!`");
  strcpy(acc_transl[hs_to_i("a3")], "\\pound{}");
  strcpy(acc_transl[hs_to_i("a7")], "\\S{}");
  strcpy(acc_transl[hs_to_i("a8")], "\\\"{ }");
  strcpy(acc_transl[hs_to_i("a9")], "\\copyright{}");
  strcpy(acc_transl[hs_to_i("ab")], "<<");
  strcpy(acc_transl[hs_to_i("b0")], "\\degree{}");
  strcpy(acc_transl[hs_to_i("b1")], "$\\pm ");
  strcpy(acc_transl[hs_to_i("b4")], "\\'{ }");
  strcpy(acc_transl[hs_to_i("b5")], "$\\mu ");
  strcpy(acc_transl[hs_to_i("b7")], "$\\cdot ");
  strcpy(acc_transl[hs_to_i("b8")], "\\c{ }");
  strcpy(acc_transl[hs_to_i("bb")], ">>");
  strcpy(acc_transl[hs_to_i("bc")], "${1\\over4}");
  strcpy(acc_transl[hs_to_i("bd")], "${1\\over2}");
  strcpy(acc_transl[hs_to_i("be")], "${3\\over4}");
  strcpy(acc_transl[hs_to_i("bf")], "?`");
 
  strcpy(acc_transl[hs_to_i("c0")], "\\`A");
  strcpy(acc_transl[hs_to_i("c1")], "\\'A");
  strcpy(acc_transl[hs_to_i("c2")], "\\^A");
  strcpy(acc_transl[hs_to_i("c3")], "\\~A");
  strcpy(acc_transl[hs_to_i("c4")], "\\\"A");
  strcpy(acc_transl[hs_to_i("c5")], "\\AA{}");
  strcpy(acc_transl[hs_to_i("c6")], "\\AE{}");
  strcpy(acc_transl[hs_to_i("c7")], "\\c{C}");
  strcpy(acc_transl[hs_to_i("c8")], "\\`E");
  strcpy(acc_transl[hs_to_i("c9")], "\\'E");
  strcpy(acc_transl[hs_to_i("ca")], "\\^E");
  strcpy(acc_transl[hs_to_i("cb")], "\\\"E");
  strcpy(acc_transl[hs_to_i("cc")], "\\`I");
  strcpy(acc_transl[hs_to_i("cd")], "\\'I");
  strcpy(acc_transl[hs_to_i("ce")], "\\^I");
  strcpy(acc_transl[hs_to_i("cf")], "\\\"I");
 
  strcpy(acc_transl[hs_to_i("d1")], "\\~N");
  strcpy(acc_transl[hs_to_i("d2")], "\\`O");
  strcpy(acc_transl[hs_to_i("d3")], "\\'O");
  strcpy(acc_transl[hs_to_i("d4")], "\\^O");
  strcpy(acc_transl[hs_to_i("d5")], "\\~O");
  strcpy(acc_transl[hs_to_i("d6")], "\\\"O");
  strcpy(acc_transl[hs_to_i("d8")], "\\O");
  strcpy(acc_transl[hs_to_i("d9")], "\\`U");
  strcpy(acc_transl[hs_to_i("da")], "\\'U");
  strcpy(acc_transl[hs_to_i("db")], "\\^U");
  strcpy(acc_transl[hs_to_i("dc")], "\\\"U");
  strcpy(acc_transl[hs_to_i("dd")], "\\'Y");
  strcpy(acc_transl[hs_to_i("df")], "\\ss{}");
 
 
  strcpy(acc_transl[hs_to_i("e0")], "\\`a");
  strcpy(acc_transl[hs_to_i("e1")], "\\'a");
  strcpy(acc_transl[hs_to_i("e2")], "\\^a");
  strcpy(acc_transl[hs_to_i("e3")], "\\~a");
  strcpy(acc_transl[hs_to_i("e4")], "\\\"a");
  strcpy(acc_transl[hs_to_i("e5")], "\\aa{}");
  strcpy(acc_transl[hs_to_i("e6")], "\\ae{}");
  strcpy(acc_transl[hs_to_i("e7")], "\\c{c}");
  strcpy(acc_transl[hs_to_i("e8")], "\\`e");
  strcpy(acc_transl[hs_to_i("e9")], "\\'e");
  strcpy(acc_transl[hs_to_i("ea")], "\\^e");
  strcpy(acc_transl[hs_to_i("eb")], "\\\"e");
  strcpy(acc_transl[hs_to_i("ec")], "\\`i");
  strcpy(acc_transl[hs_to_i("ed")], "\\'i");
  strcpy(acc_transl[hs_to_i("ee")], "\\^i");
  strcpy(acc_transl[hs_to_i("ef")], "\\\"i");
 
  strcpy(acc_transl[hs_to_i("f1")], "\\~n");
  strcpy(acc_transl[hs_to_i("f2")], "\\`o");
  strcpy(acc_transl[hs_to_i("f3")], "\\'o");
  strcpy(acc_transl[hs_to_i("f4")], "\\^o");
  strcpy(acc_transl[hs_to_i("f5")], "\\~o");
  strcpy(acc_transl[hs_to_i("f6")], "\\\"o");
  strcpy(acc_transl[hs_to_i("f8")], "\\o");
  strcpy(acc_transl[hs_to_i("f9")], "\\`u");
  strcpy(acc_transl[hs_to_i("fa")], "\\'u");
  strcpy(acc_transl[hs_to_i("fb")], "\\^u");
  strcpy(acc_transl[hs_to_i("fc")], "\\\"u");
  strcpy(acc_transl[hs_to_i("fd")], "\\'y");
  strcpy(acc_transl[hs_to_i("ff")], "\\\"y");
 
 
 
}
 
 
/* ======================================================================= */
 
Static Void charinit()
{
  short K;
 
  for (K = 0; K <= 255; K++)
    catcode[K] = 12;
  for (K = 'A'; K <= 'Z'; K++)
    catcode[K] = 11;
  for (K = 'a'; K <= 'z'; K++)
    catcode[K] = 11;
  for (K = '0'; K <= '9'; K++)
    catcode[K] = 16;
  K = ' ';
  catcode[K] = 10;
  K = '{';
  catcode[K] = 1;
  K = '}';
  catcode[K] = 2;
  K = '(';
  catcode[K] = 3;
  K = ')';
  catcode[K] = 4;
  K = '\\';
  catcode[K] = 0;
 
  icharz = '0';
 
  /* build an empty list of conversion of accented letters */
 
  for (K = 0; K <= 255; K++)
    *acc_transl[K] = '\0';
 
  /* Now install the conversions of "ftech" characters into math codes
... or letters*/
 
  for (K = 0; K <= 255; K++)
    *ftech_transl[K] = '\0';
  strcpy(ftech_transl['a'], "\\alpha ");
  strcpy(ftech_transl['A'], "\\Alpha ");
  strcpy(ftech_transl['b'], "\\beta ");
  strcpy(ftech_transl['B'], "\\Beta ");
  strcpy(ftech_transl['c'], "\\chi ");
  strcpy(ftech_transl['C'], "\\Chi ");
  strcpy(ftech_transl['d'], "\\delta ");
  strcpy(ftech_transl['D'], "\\Delta ");
  strcpy(ftech_transl['e'], "\\varepsilon ");
  strcpy(ftech_transl['E'], "\\Epsilon ");
  strcpy(ftech_transl['f'], "\\phi ");
  strcpy(ftech_transl['F'], "\\Phi ");
  strcpy(ftech_transl['g'], "\\gamma ");
  strcpy(ftech_transl['G'], "\\Gamma ");
  strcpy(ftech_transl['h'], "\\eta ");
  strcpy(ftech_transl['H'], "\\Eta ");
  strcpy(ftech_transl['i'], "\\iota ");
  strcpy(ftech_transl['I'], "\\Iota ");
  strcpy(ftech_transl['j'], "\\varphi ");
  strcpy(ftech_transl['J'], "\\vartheta ");
  strcpy(ftech_transl['k'], "\\kappa ");
  strcpy(ftech_transl['K'], "\\Kappa ");
  strcpy(ftech_transl['l'], "\\lambda ");
  strcpy(ftech_transl['L'], "\\Lambda ");
  strcpy(ftech_transl['m'], "\\mu ");
  strcpy(ftech_transl['M'], "\\Mu ");
  strcpy(ftech_transl['n'], "\\nu ");
  strcpy(ftech_transl['N'], "\\Nu");
  strcpy(ftech_transl['o'], "o");
  strcpy(ftech_transl['O'], "\\Omicron ");
  strcpy(ftech_transl['p'], "\\pi ");
  strcpy(ftech_transl['P'], "\\Pi ");
  strcpy(ftech_transl['q'], "\\theta ");
  strcpy(ftech_transl['Q'], "\\Theta ");
  strcpy(ftech_transl['r'], "\\rho ");
  strcpy(ftech_transl['R'], "\\Rho ");
  strcpy(ftech_transl['s'], "\\sigma ");
  strcpy(ftech_transl['S'], "\\Sigma ");
  strcpy(ftech_transl['t'], "\\tau ");
  strcpy(ftech_transl['T'], "\\Tau ");
  strcpy(ftech_transl['u'], "\\upsilon ");
  strcpy(ftech_transl['U'], "\\varUpsilon ");
  strcpy(ftech_transl['v'], "\\varpi ");
  strcpy(ftech_transl['V'], "\\varsigma ");
  strcpy(ftech_transl['w'], "\\omega ");
  strcpy(ftech_transl['W'], "\\Omega ");
  strcpy(ftech_transl['x'], "\\xi ");
  strcpy(ftech_transl['X'], "\\Xi ");
  strcpy(ftech_transl['y'], "\\psi ");
  strcpy(ftech_transl['Y'], "\\Psi ");
  strcpy(ftech_transl['z'], "\\zeta ");
  strcpy(ftech_transl['Z'], "\\Zeta ");
 
  strcpy(ftech_transl['@'], "\\cong ");
  strcpy(ftech_transl['~'], "\\sim ");
  strcpy(ftech_transl['"'], "\\forall ");
  strcpy(ftech_transl['$'], "\\exists ");
 
  strcpy(ftech_transl[hs_to_i("27")], "\\ni ");
  strcpy(ftech_transl[hs_to_i("5e")], "\\bot ");
  strcpy(ftech_transl[hs_to_i("a0")], "\\dag ");
  strcpy(ftech_transl[hs_to_i("a1")], "\\Upsilon ");
  strcpy(ftech_transl[hs_to_i("a2")], "'");
  strcpy(ftech_transl[hs_to_i("a3")], "\\leq ");
  strcpy(ftech_transl[hs_to_i("a4")], "/");
  strcpy(ftech_transl[hs_to_i("a5")], "\\infty ");
  strcpy(ftech_transl[hs_to_i("a6")], "\\cap ");
  strcpy(ftech_transl[hs_to_i("a7")], "\\clubsuit ");
  strcpy(ftech_transl[hs_to_i("a9")], "\\heartsuit ");
  strcpy(ftech_transl[hs_to_i("aa")], "\\spadesuit ");
  strcpy(ftech_transl[hs_to_i("ab")], "\\leftrightarrow ");
  strcpy(ftech_transl[hs_to_i("ac")], "\\leftarrow ");
  strcpy(ftech_transl[hs_to_i("ad")], "\\uparrow ");
  strcpy(ftech_transl[hs_to_i("ae")], "\\rightarrow ");
  strcpy(ftech_transl[hs_to_i("af")], "\\downarrow ");
  strcpy(ftech_transl[hs_to_i("b0")], "^{\\circ}");
  strcpy(ftech_transl[hs_to_i("b1")], "\\pm ");
  strcpy(ftech_transl[hs_to_i("b2")], "''");
  strcpy(ftech_transl[hs_to_i("b3")], "\\geq ");
  strcpy(ftech_transl[hs_to_i("b4")], "\\times ");
  strcpy(ftech_transl[hs_to_i("b5")], "\\propto ");
  strcpy(ftech_transl[hs_to_i("b6")], "\\partial ");
  strcpy(ftech_transl[hs_to_i("b7")], "\\bullet ");
  strcpy(ftech_transl[hs_to_i("b8")], "\\div ");
  strcpy(ftech_transl[hs_to_i("b9")], "\\neq ");
  strcpy(ftech_transl[hs_to_i("ba")], "\\equiv ");
  strcpy(ftech_transl[hs_to_i("bb")], "\\approx ");
  strcpy(ftech_transl[hs_to_i("bc")], "\\ldots ");
  strcpy(ftech_transl[hs_to_i("bd")], "\\mid ");
  strcpy(ftech_transl[hs_to_i("c0")], "\\aleph ");
  strcpy(ftech_transl[hs_to_i("c1")], "\\Im ");
  strcpy(ftech_transl[hs_to_i("c2")], "\\Re ");
  strcpy(ftech_transl[hs_to_i("c3")], "\\wp ");
  strcpy(ftech_transl[hs_to_i("c4")], "\\otimes ");
  strcpy(ftech_transl[hs_to_i("c5")], "\\oplus ");
  strcpy(ftech_transl[hs_to_i("c6")], "\\oslash ");
  strcpy(ftech_transl[hs_to_i("c7")], "\\cap ");
  strcpy(ftech_transl[hs_to_i("c8")], "\\cup ");
  strcpy(ftech_transl[hs_to_i("c9")], "\\supset ");
  strcpy(ftech_transl[hs_to_i("ca")], "\\supseteq ");
  strcpy(ftech_transl[hs_to_i("cb")], "\\not\\subset ");
  strcpy(ftech_transl[hs_to_i("cc")], "\\subset ");
  strcpy(ftech_transl[hs_to_i("cd")], "\\subseteq ");
  strcpy(ftech_transl[hs_to_i("ce")], "\\in ");
  strcpy(ftech_transl[hs_to_i("cf")], "\\not\\in ");
  strcpy(ftech_transl[hs_to_i("d0")], "\\angle ");
  strcpy(ftech_transl[hs_to_i("d1")], "\\nabla ");
  strcpy(ftech_transl[hs_to_i("d2")], "\\registered ");
  strcpy(ftech_transl[hs_to_i("d3")], "\\copyright ");
  strcpy(ftech_transl[hs_to_i("d4")], "\\trademark ");
  strcpy(ftech_transl[hs_to_i("d5")], "\\prod ");
  strcpy(ftech_transl[hs_to_i("d7")], "\\cdot ");
  strcpy(ftech_transl[hs_to_i("d8")], "\\neg ");
  strcpy(ftech_transl[hs_to_i("d9")], "\\wedge ");
  strcpy(ftech_transl[hs_to_i("da")], "\\vee ");
  strcpy(ftech_transl[hs_to_i("db")], "\\Leftrightarrow ");
  strcpy(ftech_transl[hs_to_i("dc")], "\\Leftarrow ");
  strcpy(ftech_transl[hs_to_i("dd")], "\\Uparrow ");
  strcpy(ftech_transl[hs_to_i("de")], "\\Rightarrow ");
  strcpy(ftech_transl[hs_to_i("df")], "\\Downarrow ");
  strcpy(ftech_transl[hs_to_i("e0")], "\\diamondsuit ");
  strcpy(ftech_transl[hs_to_i("e1")], "\\langle ");
  strcpy(ftech_transl[hs_to_i("e2")], "\\registered ");
  strcpy(ftech_transl[hs_to_i("e3")], "\\copyright ");
  strcpy(ftech_transl[hs_to_i("e4")], "\\trademark ");
  strcpy(ftech_transl[hs_to_i("e5")], "\\sum ");
  strcpy(ftech_transl[hs_to_i("e9")], "\\lceil ");
  strcpy(ftech_transl[hs_to_i("ea")], "\\mid ");
  strcpy(ftech_transl[hs_to_i("eb")], "\\lfloor ");
  strcpy(ftech_transl[hs_to_i("f1")], "\\rangle ");
  strcpy(ftech_transl[hs_to_i("f2")], "\\int ");
 
  strcpy(end_math_code, "$");
}
 
 
/* ======================================================================= */
/* this procedure returns a set of 4 chars, the size preamble of a non std font */
Static Char *sizealpha(Result, i)
Char *Result;
short i;
{
  short h;
 
  h = i / 2;
  if (h <= 5)
    return strcpy(Result, "\\fiv");
  else if (h <= 6)
    return strcpy(Result, "\\six");
  else if (h <= 7)
    return strcpy(Result, "\\sev");
  else if (h <= 8)
    return strcpy(Result, "\\egt");
  else if (h <= 9)
    return strcpy(Result, "\\nin");
  else if (h <= 10)
    return strcpy(Result, "\\ten");
  else if (h <= 11)
    return strcpy(Result, "\\elv");
  else if (h <= 13)
    return strcpy(Result, "\\twl");
  else if (h <= 15)
    return strcpy(Result, "\\frt");
  else if (h <= 18)
    return strcpy(Result, "\\svtn");
  else if (h <= 23)
    return strcpy(Result, "\\twty");
  else if (h <= 28)
    return strcpy(Result, "\\twfv");
  else {
    return strcpy(Result, "\\thtw");
    /*END IF*/
 
  }
}
 
 
/* ======================================================================= */
/* write "help" information */
 
Static Void write_help()
{
  printf("Usage: RTFLATEX [options] <input-file> [options] <output-file>\n");
  printf("Options:\n");
  printf("         -b         : set explicit \\baselineskip at par ends\n");
  printf("         -d<nnn>    : debug level: 1=default, 0=quiet, >1=verbose\n");
  printf("         -f<templ>  : file template to put figures (need a * )\n");
  printf("         -l<style>  : latex style (default is \"report\")\n");
  printf("         -m         : put debugging marks in output TeX\n");
  printf("         -o<option> : latex style option (cumulative)\n");
  printf("         -p<value>  : std font size (10, 11, 12)\n");
  printf("         -r<file>   : LOG output file (default is none)\n");
  printf("         -s         : use slanted instead of italic\n");
  printf("         -t         : omit LaTeX \\documentstyle etc.\n");
  printf("         -v         : convert text and fonts, not spacings\n");
  printf("         -x         : inhibit output simplification\n");
  printf("         -z<file>   : file containing list of ignored keywords\n");
  printf("         -209       : assume ancient Latex209\n");
  _Escape(0);
}
 
 
/*---------------------------------------------------------------------------*/
/* this procedure open files and set the -xxxx options */
 
Static Void open_files()
{
  string128 skipname, outputname, inputname, logname, optstr;
  short testio, cat, ikar;
  short kparm = 0;
  short L, pospt;
  Char first_char;
  boolean success;
  string24 inskipk;
  short kkk, number_params;
  Char STR1[256], STR3[256], STR4[256];
  short FORLIM1;
  Char *TEMP;
  Char STR5[40];
  Char STR6[68];
 
  strcpy(figure_path, "rtf*.bit");
  *figure_type = '\0';
  stdsize = 12;
  stdkz = 3;   /* standard LaTeX size : 10, 11, 12 pt */
  *inputname = '\0';
  *outputname = '\0';
  strcpy(skipname, P_argv[0]);
  num_skip_strings = 1;
  for (L = 0; L <= max_skip_strings - 1; L++)
    *skip_strings[L] = '\0';
 
  pospt = pos_postfix(skipname);
  if (pospt > 0) {
    if (!strcmp(strsub(STR1, skipname, pospt, strlen(skipname)), ".EXE"))
      sprintf(skipname, "%.*sSKW", pospt, strcpy(STR3, skipname));
    else if (!strcmp(strsub(STR3, skipname, pospt, strlen(skipname)), ".exe"))
      sprintf(skipname, "%.*sskw", pospt, strcpy(STR4, skipname));
  } else
    strcat(skipname, ".skw");
  /*END IF*/
  number_params = P_argc - 1;
 
  for (kkk = 1; kkk <= number_params; kkk++) {   /*END WHILE*/
    kparm = kkk;
    strcpy(optstr, P_argv[kparm]);
    first_char = optstr[0];
    if (first_char == '-') {
      printf("%cOption :>%s<\n", first_char, optstr);
      if (optstr[1] == 'p') {
	stdsize = 0;
	FORLIM1 = strlen(optstr);
	for (L = 2; L <= FORLIM1 - 1; L++) {
	  ikar = optstr[L];
	  cat = catcode[ikar];
	  if (cat != 16) {
	    printf("Illegal character in -p option: %s\n", optstr);
	    _Escape(0);
	  }
	  stdsize = stdsize * 10 + ikar - icharz;
	}
	printf("Standard size found: %dpt\n", stdsize);
	if (stdsize < 11)
	  stdkz = 1;
	else if (stdsize == 11)
	  stdkz = 2;
	else
	  stdkz = 3;
      } else if (optstr[1] == '2') {
	/*END IF*/
	latex209 = true;
      } else if (optstr[1] == 'v')
	no_space_conv = true;
      else if (optstr[1] == 's')
	use_sl = true;
      else if (optstr[1] == 't')
	latex_header = false;
      else if (optstr[1] == 'x')
	simplify_ok = false;
      else if (optstr[1] == 'b')
	base_flag = true;
      else if (optstr[1] == 'z')
	strcpy(skipname, optstr + 2);
      else if (optstr[1] == 'l') {
	truncate24(latex_style, optstr);
	if (*latex_style == '\0')
	  strcpy(latex_style, "report");
      } else if (optstr[1] == 'o') {
	if (num_latex_options >= maxstyles)
	  printf("Too many style options, %s ignored !\n", optstr);
	else {
	  num_latex_options++;
	  truncate24(latex_options[num_latex_options],
		     strsub(STR4, optstr, 3, bfslen));
	}
      } else if (optstr[1] == 'f') {
	/*END IF num_latex_options*/
	strcpy(figure_path, optstr + 2);
	printf("-f:%s\n", figure_path);
      } else if (optstr[1] == 'r') {
	strcpy(logname, optstr + 2);
	write_log = true;
      } else if (optstr[1] == 'm')
	tex_verbose = 1;   /* insert marks in TeX output */
      else if (optstr[1] == 'd') {
	verbose = 0;
	FORLIM1 = strlen(optstr);
	for (L = 2; L <= FORLIM1 - 1; L++) {
	  ikar = optstr[L];
	  cat = catcode[ikar];
	  if (cat != 16) {
	    printf("Illegal character in -d option: %s\n", optstr);
	    _Escape(0);
	  }
	  verbose = verbose * 10 + ikar - icharz;
	  /*END IF*/
	  if (verbose > 0)
	    printf("Verbose=%d\n", verbose);
	}
      } else
	printf("Unsupported option, ignored: %s\n", optstr);
    } else if (*inputname == '\0') {
      /*END IF*/
      strcpy(inputname, optstr);
    } else if (*outputname == '\0')
      strcpy(outputname, optstr);
    else if (*optstr != '\0') {
      printf("Too many non option args : %s\n", optstr);
      printf("This one ignored !\n");
    }
  }
 
  /*END IF*/
  pospt = strpos2(figure_path, "*", 1);
  if (pospt == 0) {
    printf("NO * in -f<path> option\n");
    _Escape(0);
  }
  strcpy(figure_type, figure_path + pospt);
  sprintf(figure_path, "%.*s", pospt - 1, strcpy(STR3, figure_path));
 
  if (*inputname == '\0')   /* stops if help written */
    write_help();
 
  if (pos_postfix(inputname) == 0)
    strcat(inputname, ".rtf");
 
  strcpy(inputfile_NAME, inputname);
  if (inputfile != NULL)
    inputfile = freopen(inputfile_NAME, "r", inputfile);
  else
    inputfile = fopen(inputfile_NAME, "r");
  _SETIO(inputfile != NULL, FileNotFound);
  testio = P_ioresult;
  success = (testio == 0);
  if (!success) {
    _SETIO(printf("Unable to open input file %s ; code=%d\n",
		  inputname, testio) >= 0, FileWriteError);
    _Escape(0);
  }
 
  if (*outputname == '\0') {
    pospt = pos_postfix(inputname);
    sprintf(outputname, "%.*stex", pospt, inputname);
    _SETIO(printf("Output name taken from input: %s\n", outputname) >= 0,
	   FileWriteError);
  }
 
  if (!strcmp(outputname, inputname)) {
    _SETIO(printf("Input and output files have same names, abort!\n") >= 0,
	   FileWriteError);
    _SETIO(printf("  Input:  %s\n", inputname) >= 0, FileWriteError);
    _SETIO(printf("  Output: %s\n", inputname) >= 0, FileWriteError);
    if (inputfile != NULL)
      fclose(inputfile);
    inputfile = NULL;
    _Escape(0);
  }
 
  strcpy(outputfile_NAME, outputname);
  if (outputfile != NULL)
    outputfile = freopen(outputfile_NAME, "w", outputfile);
  else
    outputfile = fopen(outputfile_NAME, "w");
  _SETIO(outputfile != NULL, FileNotFound);
  testio = P_ioresult;
  success = (testio == 0);
 
  if (!success) {
    _SETIO(printf("ioresult (output)=%d\n", testio) >= 0, FileWriteError);
    _SETIO(printf("Unable to open output file %s ; code=%d\n",
		  outputname, testio) >= 0, FileWriteError);
    if (inputfile != NULL)
      fclose(inputfile);
    inputfile = NULL;
    _Escape(0);
  }
 
  /* opening skip file to eliminate useless output \RTFxxx keywords */
  if (*skipname == '\0') {
    pospt = pos_postfix(inputname);
    sprintf(skipname, "%.*sskw", pospt, inputname);
    _SETIO(printf("keyword skip file name taken from input: %s\n", skipname) >= 0,
	   FileWriteError);
  }
 
  if (!strcmp(skipname, inputname)) {
    _SETIO(printf("Input and skip files have same names, abort!\n") >= 0,
	   FileWriteError);
    _SETIO(printf("  Input:  %s\n", inputname) >= 0, FileWriteError);
    _SETIO(printf("  skip: %s\n", inputname) >= 0, FileWriteError);
    if (inputfile != NULL)
      fclose(inputfile);
    inputfile = NULL;
    _Escape(0);
  }
 
  strcpy(skipfile_NAME, skipname);
  if (skipfile != NULL)
    skipfile = freopen(skipfile_NAME, "r", skipfile);
  else
    skipfile = fopen(skipfile_NAME, "r");
  _SETIO(skipfile != NULL, FileNotFound);
  testio = P_ioresult;
  success = (testio == 0);
 
  if (!success) {
    _SETIO(printf("ioresult (keyword skip file)=%d\n", testio) >= 0,
	   FileWriteError);
    _SETIO(printf("Unable to open keyword skip file %s ; code=%d\n",
		  skipname, testio) >= 0, FileWriteError);
    if (inputfile != NULL)
      fclose(inputfile);
    inputfile = NULL;
    _Escape(0);
  }
 
 
  if (write_log) {   /*END IF write_log*/
    if (*logname == '\0') {   /*END IF logname*/
      pospt = pos_postfix(inputname);
      sprintf(logname, "%.*slog", pospt, inputname);
      _SETIO(printf("Log name taken from input   : %s\n", logname) >= 0,
	     FileWriteError);
    }
 
    if (!strcmp(logname, inputname) || !strcmp(logname, outputname))
    {   /*END IF logname*/
      _SETIO(printf("Log and input or output files have same names, abort!\n") >=
	     0, FileWriteError);
      _SETIO(printf("  Log:    %s\n", logname) >= 0, FileWriteError);
      if (inputfile != NULL)
	fclose(inputfile);
      inputfile = NULL;
      _Escape(0);
    }
 
    strcpy(logfile_NAME, logname);
    if (logfile != NULL)
      logfile = freopen(logfile_NAME, "w", logfile);
    else
      logfile = fopen(logfile_NAME, "w");
    _SETIO(logfile != NULL, FileNotFound);
    testio = P_ioresult;
    write_log = (testio == 0);
 
    if (!write_log) {   /*END IF not success*/
      _SETIO(printf("ioresult (Log)=%d\n", testio) >= 0, FileWriteError);
      _SETIO(printf("Unable to open log file %s ; code=%d\n", logname, testio) >=
	     0, FileWriteError);
      if (inputfile != NULL)
	fclose(inputfile);
      inputfile = NULL;
      _Escape(0);
    }
    _SETIO(printf("%s, ", logname) >= 0, FileWriteError);
  }
  _SETIO(printf("%s, %s and %s successfully opened.\n",
		inputname, skipname, outputname) >= 0, FileWriteError);
 
  while (!P_eof(skipfile)) {   /*END DO*/
    _SETIO(fgets(inskipk, bfslen + 1, skipfile) != NULL, EndOfFile);
    TEMP = strchr(inskipk, '\n');
    if (TEMP != NULL)
      *TEMP = 0;
    sprintf(STR5, "Cancelling \"%s\"", inskipk);
    println_msg(2, STR5);
    if (*inskipk == '\0') {   /*END IF*/
      /*END IF*/
      continue;
    }
    if (strlen(inskipk) + strlen(skip_strings[num_skip_strings-1]) < 255)
      sprintf(skip_strings[num_skip_strings-1] +
	      strlen(skip_strings[num_skip_strings-1]), "%s ", inskipk);
    else if (num_skip_strings < max_skip_strings) {
      num_skip_strings++;
      sprintf(skip_strings[num_skip_strings-1] +
	      strlen(skip_strings[num_skip_strings-1]), "%s ", inskipk);
    } else {
      sprintf(STR6, "Too many keywords to ignore, %s not recorded!", inskipk);
      println_msg(1, STR6);
    }
  }
}
 
 
/*---------------------------------------------------------------------------*/
/* clean the output line */
 
Static Void cleanout()
{
  for (i = 1; i <= olmx; i++)
    exline[i-1] = ' ';
  kout = 0;
}
 
 
/*---------------------------------------------------------------------------*/
/* prints/displays the current stored output line */
 
Static Void print_line(verbose_level)
short verbose_level;
{
  short i, FORLIM;
  Char STR1[256];
 
  FORLIM = kout;
  for (i = 0; i <= FORLIM - 1; i++) {
    sprintf(STR1, "%c", exline[i]);
    print_msg(verbose_level, STR1);
  }
  println_msg(verbose_level, "<<<");
}
 
 
/*---------------------------------------------------------------------------*/
/* makes the pos function in an array of type exline_type */
 
Static short array_pos(oldstring, testline, array_long)
Char *oldstring;
Char *testline;
short array_long;
{
  short Result = 0;
  boolean string_found;
  short lth1, jpos, kpos, FORLIM;
 
  lth1 = strlen(oldstring);
  FORLIM = array_long - lth1 + 1;
  for (kpos = 1; kpos <= FORLIM; kpos++) {   /*END DO*/
    string_found = true;
    for (jpos = 1; jpos <= lth1; jpos++)   /*END DO*/
      string_found = (string_found &&
		      oldstring[jpos-1] == testline[kpos + jpos - 2]);
    if (string_found)   /*END IF*/
      return kpos;
  }
  return Result;
}
 
 
/*---------------------------------------------------------------------------*/
/* substitute a string with another in output line */
 
Static Void outsubstitute(oldstring, newstring)
Char *oldstring, *newstring;
{
  boolean string_found = true;
  short lth1, lth2, jpos, kpos, oldkout;
  exline_type oldline;
 
  lth1 = strlen(oldstring);
  lth2 = strlen(newstring);
  while (string_found) {   /*END DO*/
    kpos = array_pos(oldstring, exline, kout);
    string_found = (kpos > 0);
    if (!string_found)   /*END IF*/
      break;
    memcpy(oldline, exline, sizeof(exline_type));
    oldkout = kout;
    kout = kpos - 1;
    for (jpos = 0; jpos <= lth2 - 1; jpos++) {   /*END DO*/
      kout++;
      exline[kout-1] = newstring[jpos];
    }
    for (jpos = kpos + lth1 - 1; jpos <= oldkout - 1; jpos++) {   /*END DO*/
      kout++;
      exline[kout-1] = oldline[jpos];
    }
    for (jpos = kout; jpos <= olmx - 1; jpos++)   /*END DO*/
      exline[jpos] = ' ';
  }
}
 
 
/*---------------------------------------------------------------------------*/
/* converts an integer number of twips into a decimal string */
 
Static Void str_twips_pt(numval, outpts)
short numval;
Char *outpts;
{
  short k, l;
  string24 wk, STR1;
  Char STR2[28];
  Char STR3[256];
  Char STR5[256];
 
  k = numval * 5;   /* convert to hundredth of pts */
  sign_str(k, wk);
  if (strlen(wk) < 2) {
    sprintf(STR2, "00%s", wk);
    strcpy(wk, truncate24(STR1, STR2));
  }
  l = strlen(wk);
  sprintf(STR5, "%.*s.%s", l - 2, wk, strsub(STR3, wk, l - 1, 2));
  truncate24(outpts, STR5);
}
 
 
/*---------------------------------------------------------------------------*/
/* eliminates end replaces useless sequences in output -- pragmatic feature */
 
Static Void simplify(oldstring, newstring)
Char *oldstring, *newstring;
{
  if (simplify_ok)
    outsubstitute(oldstring, newstring);
}
 
 
/*---------------------------------------------------------------------------*/
/* read the future chars, excluding control chars < ord(' ') */
 
Static Void read_next_char()
{
  short next_ikar = 0;
  Char next_char;
 
  next_char = next_ikar;
  while (!P_eof(inputfile) && next_ikar < ' ' && strlen(next_rtf) < 8)
  {   /*END DO*/
    next_char = getc(inputfile);
    _SETIO(next_char != EOF, EndOfFile);
    next_ikar = next_char;
    if (next_ikar == 13) {
      input_line_number++;
      memcpy(prev_line, inpline, (long)lmx);
      prev_kinp = kinp;
      kinp = 0;
    } else if (next_ikar >= ' ') {
      sprintf(next_rtf + strlen(next_rtf), "%c", next_char);
      /*END IF*/
    }
  }
}
 
 
/*---------------------------------------------------------------------------*/
/* read one char except nulls */
 
Static Void read_char()
{
  if (*next_rtf != '\0') {
    kar = next_rtf[0];
    strdelete((Anyptr)next_rtf, 1, 1);
    read_next_char();
  } else
    kar = '\032';
  /*END IF*/
  ikar = kar;
  cat = catcode[ikar];
  if (*next_rtf == '\0')   /*END IF*/
    strcat(next_rtf, "\032");
 
  if (kinp < lmx) {   /*END IF*/
    kinp++;
    inpline[kinp-1] = kar;
  }
}
 
 
/*---------------------------------------------------------------------------*/
/* outputs the stored output line */
 
Static Void output_line()
{
  short i;
  string24 simpl_pattern;
  short FORLIM;
  Char STR1[28];
  Char STR2[26];
  Char STR3[42];
 
  numl++;
  simplify("{{}", "{");
  simplify("{}}", "}");
  simplify("{}{}", "{}");
  FORLIM = num_diff_sizes;
  for (i = 0; i <= FORLIM - 1; i++) {   /*END DO*/
    sprintf(STR2, "\\%s", sizekey[i]);
    truncate24(simpl_pattern, STR2);
    sprintf(STR1, "%s{}\\", simpl_pattern);
    sprintf(STR2, "%s\\", simpl_pattern);
    simplify(STR1, STR2);
    sprintf(STR2, "%s}", simpl_pattern);
    simplify(STR2, "}");
  }
  simplify("\\root{}\\of{", "\\sqrt{");
 
  FORLIM = kout;
  for (i = 0; i <= FORLIM - 1; i++)
    _SETIO(putc(exline[i], outputfile) >= 0, FileWriteError);
  _SETIO(putc('\n', outputfile) >= 0, FileWriteError);
 
  if (numl % 100 == 0) {   /*END IF NUML*/
/* p2c: rtflatex.cmn, line 915:
 * Note: Using % for possibly-negative arguments [317] */
    if (verbose > 0) {
      sign_str(numl, works);
      sprintf(STR3, "Output : %s lines ", works);
      print_msg(1, STR3);
      FORLIM = bracelvl;
      for (j = 1; j <= FORLIM; j++)
	print_msg(1, "{");
      println_msg(1, "");
    } else
      putchar('.');
  }
  cleanout();
}
 
 
/*---------------------------------------------------------------------------*/
/* write a character into output line */
 
Static Void output_real_line()
{
  if (kout > 0)
    output_line();
}
 
 
/*---------------------------------------------------------------------------*/
/* write a character into output line */
 
Static Void outchr(CHARAC)
Char CHARAC;
{
  Char oldchar;
  Char newchar = CHARAC;
  Char STR1[48];
 
  if (kout > 0) {
    oldchar = exline[kout-1];
    if (oldchar == ' ' && newchar == ' ')
      return;
  } else if (kout == 0 && last_percent && CHARAC == ' ') {
    kout = 1;
    exline[kout-1] = '\\';
  }
  /*END IF*/
  last_percent = false;
 
  if (kout >= olmx - 2) {
    /*END IF*/
    sign_str(kout, works);
    sprintf(STR1, "Output overflow, KOUT:=%s", works);
    println_msg(0, STR1);
    /*END IF*/
    return;
  }
  kout++;
  exline[kout-1] = newchar;
  if (newchar != '}' || kout <= 80) {
    /*END IF*/
    if (newchar == ' ' && kout > 64)
      output_line();
    return;
  }
  if (exline[kout-2] == ';') {
    exline[kout-1] = '\\';
    kout++;
    exline[kout-1] = 'r';
    kout++;
    exline[kout-1] = 'e';
    kout++;
    exline[kout-1] = 'l';
    kout++;
    exline[kout-1] = 'a';
    kout++;
    exline[kout-1] = 'x';
    output_line();
    kout++;
    exline[kout-1] = ' ';
    kout++;
    exline[kout-1] = newchar;
    return;
  }
  if (kout <= 120)
    return;
  kout++;
  exline[kout-1] = '%';
  kout++;
  exline[kout-1] = '%';
  output_line();
  last_percent = true;
}
 
 
/* ===================================================================== */
/* change contents of bfslcode[bracelvl] : replace first arg with 2nd */
/* but do not declare font, since output will be standard */
 
Static Void font_subs2e(old, new_)
Char *old, *new_;
{
  Char workstg[49];
  short positn;
 
  positn = strpos2(bfslcode[bracelvl], old, 1);
  if (positn == 0)
    return;
  if (lvlcode[bracelvl] == 9)   /* ignore new fonts in header/footer */
    return;
  if (verbose >= 2)
    _SETIO(printf("font_subs2e: %s|%s|%s", old, bfslcode[bracelvl], new_) >= 0,
	   FileWriteError);
  strcpy(workstg, bfslcode[bracelvl]);
  strdelete((Anyptr)workstg, positn, strlen(old));
  if (strpos2(workstg, new_, 1) == 0)
    strinsert(new_, (Anyptr)workstg, positn);
  truncate24(bfslcode[bracelvl], workstg);
  if (verbose >= 2)
    _SETIO(printf("=>%s\n", workstg) >= 0, FileWriteError);
}
 
 
/*---------------------------------------------------------------------------*/
/* inserts a new font specification like \bf \rm \sc into bfslcode[bracelvl] */
 
Static Void add_to_bfsl(kod)
Char *kod;
{  /* bfsl_old:=bfslcode[bracelvl]; */
  Char bfsl_try[65];
  Char STR1[256];
  string24 STR2;
 
  sprintf(bfsl_try, "%s\\", bfslcode[bracelvl]);
  sprintf(STR1, "%s\\", kod);
  if (strpos2(bfsl_try, STR1, 1) > 0)
    return;
  sprintf(STR1, "%s%s", bfslcode[bracelvl], kod);
  strcpy(bfslcode[bracelvl], truncate24(STR2, STR1));
  /*  writeln('add_to:',bfsl_old,'+',kod,'=',bfslcode[bracelvl]); */
}
 
 
/*---------------------------------------------------------------------------*/
/* output one character capitalized if needed */
 
Static Void outchrc(CHARAC)
Char CHARAC;
{
  Char kar;
 
  if (lvlcode[bracelvl] == 2)
    kar = toupper(CHARAC);
  else
    kar = CHARAC;
  outchr(kar);
}
 
 
/*---------------------------------------------------------------------------*/
/* write a string into output line */
 
Static Void outstg(CHARACs)
Char *CHARACs;
{
  short k, FORLIM;
 
  FORLIM = strlen(CHARACs);
  for (k = 0; k <= FORLIM - 1; k++)
    outchr(CHARACs[k]);
}
 
 
/* ===================================================================== */
/* checks the presence of a string at end of current output */
 
Static boolean last_is(CHARACs)
Char *CHARACs;
{
  boolean Result;
  short k, long_;
 
  long_ = strlen(CHARACs);
/* p2c: rtflatex.cmn: Note: Eliminated unused assignment statement [338] */
  if (kout < long_)
    return false;
  for (k = 0; k <= long_ - 1; k++) {
    if (exline[kout - long_ + k] != CHARACs[k])
      return false;
  }
  return true;
}
 
 
/* ===================================================================== */
/* remove one string from output */
 
Static Void outrem(CHARACs)
Char *CHARACs;
{
  short k, long_, FORLIM;
 
  long_ = strlen(CHARACs);
  removed_ok = last_is(CHARACs);
  if (!removed_ok)
    return;
  FORLIM = kout;
  for (k = kout - long_ + 1; k <= FORLIM; k++)
    exline[kout-1] = ' ';
  kout -= long_;
}
 
 
/* ===================================================================== */
/* remove all empty pairs of braces at the end of output */
 
Static Void outrem_empty_braces()
{
  short num_removed = 0;
 
  removed_ok = true;
  while (removed_ok) {   /*END WHILE*/
    outrem("{}");
    if (removed_ok)
      num_removed++;
  }
  removed_ok = (num_removed > 0);
}
 
 
/*---------------------------------------------------------------------------*/
/* output a TeX keyword ( the \ not in args ) on output line EXLINE */
 
Static Void outkeyw(CHARACs)
Char *CHARACs;
{
  short k, FORLIM;
 
  /* eliminate useless brace pairs terminating a previous keyword*/
  outrem_empty_braces();
  outchr('\\');
  FORLIM = strlen(CHARACs);
  for (k = 0; k <= FORLIM - 1; k++)
    outchr(CHARACs[k]);
}
 
 
/*---------------------------------------------------------------------------*/
/* outputs the new \bf \sl code if different from current at that level */
 
Static Void output_bfsl()
{
  if (!strcmp(bfslcode[bracelvl], currbfsl[bracelvl]))
    return;
  if (!strcmp(bfslcode[bracelvl], "\\relax"))
    return;
  if (math_mode[bracelvl] > 0)
    return;
  outrem_empty_braces();
  outrem(currbfsl[bracelvl]);
  font_subs2e("\\rm\\bf", "\\bf");
  font_subs2e("\\rm\\tt", "\\tt");
  font_subs2e("\\rm\\it", "\\it");
  font_subs2e("\\rm\\sf", "\\sf");
  font_subs2e("\\rm\\sl", "\\sl");
 
  if (!latex209) {
    font_subs2e("\\bf\\it", "\\bfit");
    font_subs2e("\\it\\bf", "\\bfit");
    font_subs2e("\\bf\\sl", "\\bfsl");
    font_subs2e("\\sl\\bf", "\\bfsl");
    font_subs2e("\\bf\\sf", "\\sfbf");
    font_subs2e("\\sf\\bf", "\\sfbf");
    font_subs2e("\\sf\\it", "\\sfit");
    font_subs2e("\\sf\\sl", "\\sfsl");
    font_subs2e("\\tt\\bf", "\\ttbf");
    font_subs2e("\\tt\\it", "\\ttit");
    font_subs2e("\\tt\\sl", "\\ttsl");
    font_subs2e("\\bf\\tt", "\\ttbf");
    font_subs2e("\\it\\tt", "\\ttit");
    font_subs2e("\\sl\\tt", "\\ttsl");
    font_subs2e("\\sfit\\bf", "\\sfbfit");
    font_subs2e("\\sfsl\\bf", "\\sfbfsl");
    font_subs2e("\\bfit\\sf", "\\sfbfit");
    font_subs2e("\\bfsl\\sf", "\\sfbfsl");
  }
  /* latex2e */
  /*END IF latex209*/
  outstg(bfslcode[bracelvl]);
  outstg("{}");
  strcpy(currbfsl[bracelvl], bfslcode[bracelvl]);
}
 
 
/*---------------------------------------------------------------------------*/
/* outputs the new \large code if different from current at that level */
 
Static Void output_size(codesize)
Char *codesize;
{
  if (!strcmp(codesize, currsize[bracelvl]))
    return;
  if (!strcmp(codesize, "relax"))
    return;
  if (lvlcode[bracelvl] == 8)
    return;
  if (lvlcode[bracelvl] == 9)
    return;
  if (math_mode[bracelvl] > 0)
    return;
  outkeyw(codesize);
  if (!base_flag) {   /*END IF*/
    outstg("{}");
    strcpy(currsize[bracelvl], codesize);
  }
  strcpy(currbfsl[bracelvl], "\\relax");
}
 
 
/* ----------------------------------------------------------------------*/
Static Void ensure_sizebfsl()
{
  if (par_to_begin)
    return;
  if (last_is("{"))
    output_size(sizecode[bracelvl]);
  output_bfsl();
}
 
 
/* ----------------------------------------------------------------------*/
Static Void output_skips()
{
  if (leftcurskip != leftskip) {
    str_twips_pt(leftskip, worksa);
    outkeyw("global\\leftskip ");
    outstg(worksa);
    outstg("pt\\relax");
    leftcurskip = leftskip;
  }
 
  if (rightcurskip == rightskip)
    return;
  str_twips_pt(rightskip, worksa);
  outkeyw("global\\rightskip ");
  outstg(worksa);
  outstg("pt\\relax");
  rightcurskip = rightskip;
}
 
 
/*---------------------------------------------------------------------------*/
Static Void close_files()
{
  if (outputfile != NULL)
    fclose(outputfile);
  outputfile = NULL;
  if (inputfile != NULL)
    fclose(inputfile);
  inputfile = NULL;
  if (!write_log)
    return;
  if (logfile != NULL)
    fclose(logfile);
  logfile = NULL;
}
 
 
/* ===================================================================== */
/* remove one keyword from output */
 
Static Void outkrem(CHARACs)
Char *CHARACs;
{
  Char STR1[256];
 
  sprintf(STR1, "\\%s", CHARACs);
  outrem(STR1);
}
 
 
/* --------------------------------------------------------------------------*/
/* open brace and increment  bracelvl */
 
Static Void open_brace()
{
  Char STR1[56];
  Char STR2[34];
 
  if (bracelvl < maxlevel) {
    bracelvl++;
    strcpy(bfslcode[bracelvl], bfslcode[bracelvl-1]);
    tab_nb_cellx[bracelvl] = tab_nb_cellx[bracelvl-1];
    tab_cellx[bracelvl] = 0;
    strcpy(sizecode[bracelvl], sizecode[bracelvl-1]);
    strcpy(currsize[bracelvl], currsize[bracelvl-1]);
    strcpy(currbfsl[bracelvl], currbfsl[bracelvl-1]);
    strcpy(spacingcode[bracelvl], spacingcode[bracelvl-1]);
    lvlcode[bracelvl] = lvlcode[bracelvl-1];
    if (bracelvl < maxlevel)
      lvlcode[bracelvl+1] = 0;
    strcpy(active_RTFf[bracelvl], active_RTFf[bracelvl-1]);
    /* propagate math_mode, but say 2 if previous was 1 to avoid extra closins by $ */
    math_mode[bracelvl] = math_mode[bracelvl-1];
    if (math_mode[bracelvl] == 1)
      math_mode[bracelvl] = 2;
 
    flushright_flag[bracelvl] = flushright_flag[bracelvl-1];
    if (flushright_flag[bracelvl] == 2)
      flushright_flag[bracelvl] = 3;
 
    center_flag[bracelvl] = center_flag[bracelvl-1];
    if (center_flag[bracelvl] == 2)
      center_flag[bracelvl] = 3;
 
    underl_flag[bracelvl] = false;
    auto_close[bracelvl] = false;
    *form_code[bracelvl] = '\0';
    strcpy(close_kar[bracelvl], " ");
    if (lvlcode[bracelvl] == 3) {
      lvlcode[bracelvl] = 4;
      return;
    }
    if (lvlcode[bracelvl] == 10) {   /*in objects*/
      lvlcode[bracelvl] = -lvlcode[bracelvl];
      return;
    }
    if (lvlcode[bracelvl] == 15)
	  /*brace opened after \RTFintbl => set normal*/
	    lvlcode[bracelvl] = 0;
    else if (lvlcode[bracelvl] >= 16)   /*in formulas*/
      lvlcode[bracelvl] = -lvlcode[bracelvl];
    return;
  } else {
    /*END IF*/
    sign_str(maxlevel, works);
    sprintf(STR1, "Too many brace levels, max is %s", works);
    print_msg(0, STR1);
    sign_str(numl + 1, works);
    sprintf(STR2, " at line%s", works);
    println_msg(0, STR2);
    print_line(0);
    if (write_log)
      close_files();
    _Escape(0);
    /*END IF bracelvl<maxlevel*/
  }
}
 
 
/*---------------------------------------------------------------------------*/
/* output \begin(<arg>) */
 
Static Void begin_env(environ)
short environ;
{
  if (kout > 0)
    output_line();
  outkeyw("begin{");
  outstg(environ_type[environ]);
  outstg("}\\strut");
  open_brace();
  output_line();
}
 
 
/* ----------------------------------------------------------------------*/
/* execute \begin{center}/{flushright} is center_flag set to 1 */
Static Void make_center()
{
  if (center_flag[bracelvl] == 1) {
    begin_env(1);
    center_flag[bracelvl] = 2;
  }
  if (flushright_flag[bracelvl] == 1) {
    begin_env(2);
    flushright_flag[bracelvl] = 2;
  }
}
 
 
/* ----------------------------------------------------------------------*/
Static Void begin_par()
{
  short k, FORLIM;
 
  if (!par_to_begin)
    return;
  if (lvlcode[bracelvl] == 6)
    return;
  if (lvlcode[bracelvl] == 8)
    return;
  if (lvlcode[bracelvl] == 9)
    return;
  if (center_flag[bracelvl] + flushright_flag[bracelvl] == 0)
    output_skips();
  space_after = save_skip;
  save_skip = 0;
  if (num_indent == 0 && lvlcode[bracelvl] != 15 &&
      center_flag[bracelvl] == 0 && flushright_flag[bracelvl] == 0)
    outkeyw("noindent ");
  FORLIM = num_indent;
  for (k = 2; k <= FORLIM; k++)
    outkeyw("indent ");
  num_indent = 0;
  make_center();
  output_size(sizecode[bracelvl]);
  output_bfsl();
  outkeyw("beginparagraph{}");
  par_to_begin = false;
}
 
 
/*---------------------------------------------------------------------------*/
/* write a string into math mode onto output line, and leave in math mode */
 
Static Void out_math_leave(CHARACs)
Char *CHARACs;
{
  if (math_mode[bracelvl] > 0)
    outchr(' ');
  else {
    outrem_empty_braces();
    outrem("$");
    if (removed_ok)
      math_mode[bracelvl] = 1;
  }
  /*END IF math_mode*/
  if (math_mode[bracelvl] == 0) {   /*END IF math_mode=0*/
    begin_par();
    outchr('$');
    math_mode[bracelvl] = 1;
  }
  outstg(CHARACs);
}
 
 
/*---------------------------------------------------------------------------*/
/* close math_mode if possible, i.e. =1 */
 
Static Void close_math()
{
  if (math_mode[bracelvl] == 1) {   /*END IF math_mode*/
    outstg(end_math_code);
    math_mode[bracelvl] = 0;
  }
}
 
 
/*---------------------------------------------------------------------------*/
/* write a string into math mode onto output and close math mode if possible*/
 
Static Void out_math(CHARACs)
Char *CHARACs;
{
  out_math_leave(CHARACs);
  close_math();
}
 
 
/* ===================================================================== */
/* output one string and capitalize it if required */
 
Static Void outstgc(CHARACs)
Char *CHARACs;
{
  short k, FORLIM;
 
  FORLIM = strlen(CHARACs);
  for (k = 0; k <= FORLIM - 1; k++)
    outchrc(CHARACs[k]);
}
 
 
/* ===================================================================== */
/* output a number */
 
Static Void output_num(numb)
short numb;
{
  string24 wkk;
 
  sign_str(numb, wkk);
  outstg(wkk);
}
 
 
/* ===================================================================== */
/* output one keyword and capitalize it */
 
Static Void outkeywc(CHARACs)
Char *CHARACs;
{
  short k, FORLIM;
 
  outrem_empty_braces();
  outchr('\\');
  FORLIM = strlen(CHARACs);
  for (k = 0; k <= FORLIM - 1; k++)
    outchrc(CHARACs[k]);
}
 
 
/* ===================================================================== */
/* close brace pair and remove all sub/superscripted empty pairs at end of output */
 
Static Void close_subs()
{
  if (math_mode[bracelvl] > 0)
    outrem(" ");
  outchr('}');
  outrem("^{}");
  outrem("_{}");
  outrem("^{ }");
  outrem("_{ }");
}
 
 
/* ===================================================================== */
/* declares a new font as \global, and record it */
 
Static Void declare_font(font_id, fontname, magnification)
Char *font_id, *fontname;
short magnification;
{
  short i, FORLIM;
  Char STR2[256];
 
  FORLIM = numfonts;
  for (i = 0; i <= FORLIM - 1; i++) {
    if (!strcmp(newfonts[i], font_id))
      return;
  }
  if (numfonts >= maxfonts) {   /*END IF*/
    sprintf(STR2, "Font %s cannot be declared... too many fonts !", font_id);
    println_msg(0, STR2);
    return;
  }
 
  numfonts++;
  truncate24(newfonts[numfonts-1], font_id);
 
  if (kout > 1)   /* to have font decl at left of a line */
    output_line();
  outstg("\\ifx");
  outstg(font_id);
  outstg("\\undefined \\global\\font");
  outstg(font_id);
  outstg("=\\FontHdg\\FontHdge ");
  outstg(fontname);
  sign_str(magnification, works);
  outstg(" scaled ");
  outstg(works);
  outstg("\\fi");
  output_line();
 
}
 
 
/* ===================================================================== */
/* change contents of bfslcode[bracelvl] : replace first arg with 2nd */
 
Static Void font_subs(old, new_, fontname, magnification)
Char *old, *new_, *fontname;
short magnification;
{
  Char workstg[49];
  short positn;
 
  positn = strpos2(bfslcode[bracelvl], old, 1);
  if (positn == 0)
    return;
  if (lvlcode[bracelvl] == 9)   /* ignore new fonts in header/footer */
    return;
  strcpy(workstg, bfslcode[bracelvl]);
  strdelete((Anyptr)workstg, positn, strlen(old));
  if (strpos2(bfslcode[bracelvl], new_, 1) == 0)
    strinsert(new_, (Anyptr)workstg, positn);
  truncate24(bfslcode[bracelvl], workstg);
  declare_font(new_, fontname, magnification);
}
 
 
/*---------------------------------------------------------------------------*/
/* builds the correct LaTeX font size according to NUMVAL (unit=1/2 pt) */
/* stores it in sizecode[bracelvl] ; uses the global variable "stdsize" */
 
Static Void outfsize(numval, magnif)
short numval, *magnif;
{
  short ll;
  short selectsize = 0;
  short latex_size;
  short best_diff = 30000;
  Char STR1[68];
 
  /* I select the nearest sizemags */
  latex_size = numval * 50;
      /* convert from half points to hundredths of points */
  /* big integer */
  strcpy(sizecode[bracelvl], "tiny");
  for (ll = 0; ll <= numsizes - 1; ll++) {   /*END DO*/
    if (abs(sizemags[stdkz-1][ll] - latex_size) < best_diff) {   /*END IF*/
      strcpy(sizecode[bracelvl], sizekey[ll]);
      selectsize = sizemags[stdkz-1][ll];
      *magnif = sizemags[stdkz-1][ll];
      best_diff = abs(selectsize - latex_size);
    }
  }
 
  sign_str(selectsize, works);
  sprintf(STR1, " selectsize=%s xkey=%s", works, sizecode[bracelvl]);
  println_msg(2, STR1);
 
}
 
 
/*---------------------------------------------------------------------------*/
Static Void font_clean(sizeheader, magnification)
Char *sizeheader;
short magnification;
{
  Char STR1[256];
 
  if (latex209) {
    sprintf(STR1, "%sbfit", sizeheader);
    font_subs("\\rm\\bf\\it", STR1, "bxti10", magnification);
    sprintf(STR1, "%sbfit", sizeheader);
    font_subs("\\rm\\it\\bf", STR1, "bxti10", magnification);
    sprintf(STR1, "%sbfsl", sizeheader);
    font_subs("\\rm\\bf\\sl", STR1, "bxsl10", magnification);
    sprintf(STR1, "%sbfsl", sizeheader);
    font_subs("\\rm\\sl\\bf", STR1, "bxsl10", magnification);
    sprintf(STR1, "%ssfbf", sizeheader);
    font_subs("\\rm\\bf\\sf", STR1, "ssbx10", magnification);
    sprintf(STR1, "%ssfbf", sizeheader);
    font_subs("\\rm\\sf\\bf", STR1, "ssbx10", magnification);
    sprintf(STR1, "%sbfit", sizeheader);
    font_subs("\\bf\\it", STR1, "bxti10", magnification);
    sprintf(STR1, "%sbfit", sizeheader);
    font_subs("\\it\\bf", STR1, "bxti10", magnification);
    sprintf(STR1, "%sbfsl", sizeheader);
    font_subs("\\bf\\sl", STR1, "bxsl10", magnification);
    sprintf(STR1, "%sbfsl", sizeheader);
    font_subs("\\sl\\bf", STR1, "bxsl10", magnification);
    sprintf(STR1, "%ssfbf", sizeheader);
    font_subs("\\bf\\sf", STR1, "ssbx10", magnification);
    sprintf(STR1, "%ssfbf", sizeheader);
    font_subs("\\sf\\bf", STR1, "ssbx10", magnification);
    if (magnification > 2000) {  /*definir explicitement les grosses polices*/
      sprintf(STR1, "%sobf", sizeheader);
      font_subs("\\rm\\oul", STR1, "obx10", magnification);
      sprintf(STR1, "%ssf", sizeheader);
      font_subs("\\rm\\sf", STR1, "ss10", magnification);
      sprintf(STR1, "%sit", sizeheader);
      font_subs("\\rm\\it", STR1, "ti10", magnification);
      sprintf(STR1, "%ssl", sizeheader);
      font_subs("\\rm\\sl", STR1, "sl10", magnification);
      sprintf(STR1, "%ssc", sizeheader);
      font_subs("\\rm\\sc", STR1, "csc10", magnification);
      sprintf(STR1, "%stt", sizeheader);
      font_subs("\\rm\\tt", STR1, "tt10", magnification);
      sprintf(STR1, "%ssf", sizeheader);
      font_subs("\\sf", STR1, "ss10", magnification);
      sprintf(STR1, "%sit", sizeheader);
      font_subs("\\it", STR1, "ti10", magnification);
      sprintf(STR1, "%ssl", sizeheader);
      font_subs("\\sl", STR1, "sl10", magnification);
      sprintf(STR1, "%ssc", sizeheader);
      font_subs("\\sc", STR1, "csc10", magnification);
      sprintf(STR1, "%stt", sizeheader);
      font_subs("\\tt", STR1, "tt10", magnification);
    }
  } else {
    font_subs2e("\\rm\\bf\\it", "\\bfit");
    font_subs2e("\\rm\\it\\bf", "\\bfit");
    font_subs2e("\\rm\\bf\\sl", "\\bfsl");
    font_subs2e("\\rm\\sl\\bf", "\\bfsl");
    font_subs2e("\\rm\\bf\\sf", "\\sfbf");
    font_subs2e("\\rm\\sf\\bf", "\\sfbf");
    font_subs2e("\\rm\\sf\\it", "\\sfit");
    font_subs2e("\\rm\\sf\\sl", "\\sfsl");
    font_subs2e("\\bf\\it", "\\bfit");
    font_subs2e("\\it\\bf", "\\bfit");
    font_subs2e("\\bf\\sl", "\\bfsl");
    font_subs2e("\\sl\\bf", "\\bfsl");
    font_subs2e("\\bf\\sf", "\\sfbf");
    font_subs2e("\\sf\\bf", "\\sfbf");
    font_subs2e("\\sf\\it", "\\sfit");
    font_subs2e("\\sf\\sl", "\\sfsl");
    if (magnification > 2000) {  /*definir explicitement les grosses polices*/
      sprintf(STR1, "%sobf", sizeheader);
      font_subs("\\rm\\oul", STR1, "obx10", magnification);
      sprintf(STR1, "%ssf", sizeheader);
      font_subs("\\rm\\sf", STR1, "ss10", magnification);
      sprintf(STR1, "%sit", sizeheader);
      font_subs("\\rm\\it", STR1, "ti10", magnification);
      sprintf(STR1, "%ssl", sizeheader);
      font_subs("\\rm\\sl", STR1, "sl10", magnification);
      sprintf(STR1, "%ssc", sizeheader);
      font_subs("\\rm\\sc", STR1, "csc10", magnification);
      sprintf(STR1, "%stt", sizeheader);
      font_subs("\\rm\\tt", STR1, "tt10", magnification);
      sprintf(STR1, "%ssf", sizeheader);
      font_subs("\\sf", STR1, "ss10", magnification);
      sprintf(STR1, "%sit", sizeheader);
      font_subs("\\it", STR1, "ti10", magnification);
      sprintf(STR1, "%ssl", sizeheader);
      font_subs("\\sl", STR1, "sl10", magnification);
      sprintf(STR1, "%ssc", sizeheader);
      font_subs("\\sc", STR1, "csc10", magnification);
      sprintf(STR1, "%stt", sizeheader);
      font_subs("\\tt", STR1, "tt10", magnification);
    }
  }
  sprintf(STR1, "%sobf", sizeheader);
  /* latex2e */
  /*END IF latex209*/
  font_subs("\\rm\\oul", STR1, "obx10", magnification);
 
}
 
 
/*---------------------------------------------------------------------------*/
/* output the correct LaTeX spacing size according to NUMVAL (unit=1/20 pt) */
/* stores it in spacingcode[bracelvl] ; uses the global variable "stdsize" */
 
Static Void outpsize(numval)
short numval;
{
  short ll;
  short selectsize = 0, best_diff = 30000;
  Char STR1[108];
  Char STR3[40];
 
  if (base_flag) {
    str_twips_pt(numval, worksa);
    sprintf(STR3, "baselineskip%spt", worksa);
    truncate24(spacingcode[bracelvl], STR3);
    return;
  }
  /* I select the nearest sizeval -- spacings in twips */
  /* big integer */
  strcpy(spacingcode[bracelvl], "tiny");
  for (ll = 0; ll <= numsizes - 1; ll++) {   /*END DO*/
    if (abs(sizeval[stdkz-1][ll] - numval) < best_diff) {   /*END IF*/
      strcpy(spacingcode[bracelvl], sizekey[ll]);
      selectsize = sizeval[stdkz-1][ll];
      best_diff = abs(sizeval[stdkz-1][ll] - numval);
    }
  }
 
  sign_str(numval, works);
  sign_str(selectsize, worksa);
  sprintf(STR1, "--> (\\par)numval=%s selectsize=%s pkey=%s",
	  works, worksa, spacingcode[bracelvl]);
  print_msg(2, STR1);
  /*END IF*/
}
 
 
/*---------------------------------------------------------------------------*/
/* remove $^ before, and remove math_mode if possible */
 
Static Void remove_mathat()
{
  if (math_mode[bracelvl] > 0) {   /*END IF math_mode*/
    if (auto_close[bracelvl]) {
      outrem("{");
      if (removed_ok)
	bracelvl--;
    }
    outrem("^");
    outrem("\\relax");
    if (math_mode[bracelvl] == 1) {
      outrem("$");
      if (removed_ok)
	math_mode[bracelvl] = 0;
    }
  }
  outrem("{}");
}
 
 
/* --------------------------------------------------------------------------*/
/* close brace and decrement  bracelvl */
 
Static Void close_brace()
{
  Char STR1[44];
  Char STR3[68];
 
  if (bracelvl <= 0) {
    sign_str(numl + 1, works);
    sprintf(STR1, "Too many } at line %s", works);
    println_msg(0, STR1);
    print_line(0);
    outstg("}%%%%% *****");
  } else {
    if (lvlcode[bracelvl] != 6) {
      if (tex_verbose > 1) {
	sign_str(bracelvl, worksa);
	sign_str(lvlcode[bracelvl], works);
	sprintf(STR3, "\\closebr{%s[%s]}\\relax", worksa, works);
	outstg(STR3);
	output_line();
      }
    }
  }
  bracelvl--;
  /* reset footnote cleaning */
  if (lvlcode[bracelvl] == 3)   /*END IF bracelvl*/
    lvlcode[bracelvl] = 0;
}
 
 
/*---------------------------------------------------------------------------*/
/* output \end(<arg>) */
 
Static Void end_env(environ)
short environ;
{
  output_line();
  outkeyw("end{");
  outstg(environ_type[environ]);
  outchr('}');
  close_brace();
  output_line();
}
 
 
/*---------------------------------------------------------------------------*/
/* stores a new couple of word font chars and number taken in
decl_font_num which is a global variable */
 
Static Void store_word_font(font_type)
Char *font_type;
{
  short k;
  Char new_fnt_name[256];
  short loc_brace_count = 0;
  short FORLIM;
  Char STR2[256], STR3[256];
 
  sign_str(decl_font_num, works);
  FORLIM = num_word_fonts;
  for (k = 0; k <= FORLIM - 1; k++) {   /*END/IF + END FOR*/
    if (word_font_num[k] == decl_font_num) {
      sprintf(STR2, "RTF font No. %s/%s already declared; this one ignored.",
	      works, font_type);
      println_msg(0, STR2);
      return;
    }
  }
  if (num_word_fonts >= maxfonts) {   /*END IF*/
    sprintf(STR3, "Too many RTF fonts: %s/%s; this one ignored.",
	    works, font_type);
    println_msg(0, STR3);
    return;
  }
  *new_fnt_name = '\0';
  while (kar != ';' && kar != '}' || loc_brace_count > 0) {
    /*  while (kar<>';') do */
    if (kar == '{')
      loc_brace_count++;
    if (kar == '}')
      loc_brace_count--;
    read_char();
    if (kar != ' ')
      sprintf(new_fnt_name + strlen(new_fnt_name), "%c", kar);
  }
  outrem_empty_braces();
  num_word_fonts++;
  word_font_num[num_word_fonts-1] = decl_font_num;
  truncate24(word_fonts[num_word_fonts-1], font_type);
  sign_str(num_word_fonts, worksa);
  if (strpos2(new_fnt_name, "Courier", 1) > 0)
    strcpy(equiv_fonts[num_word_fonts-1], "\\tt");
  else if (strpos2(new_fnt_name, "TTY", 1) > 0)
    strcpy(equiv_fonts[num_word_fonts-1], "\\tt");
  else if (strpos2(new_fnt_name, "Helvetica", 1) > 0)
    strcpy(equiv_fonts[num_word_fonts-1], "\\sf");
  else if (strpos2(new_fnt_name, "SansSerif", 1) > 0)
    strcpy(equiv_fonts[num_word_fonts-1], "\\sf");
  else
    *equiv_fonts[num_word_fonts-1] = '\0';
  sprintf(STR3, "%s Font %s stored: \"%s\" = %s",
	  worksa, works, font_type, new_fnt_name);
  /*END IF*/
  println_msg(2, STR3);
}
 
 
 
/*---------------------------------------------------------------------------*/
/* sets active_RTFf of current bracelvl at the alpha value recorded with kkk
as \F<number> in \fonttbl declaration */
 
Static Void set_active_RTFf(kkk)
short kkk;
{
  short k, FORLIM;
  Char STR1[40];
  Char STR2[100];
  Char STR3[38];
  Char STR4[62];
  Char STR5[82];
 
  FORLIM = num_word_fonts;
  for (k = 0; k <= FORLIM - 1; k++) {   /*END/IF + END FOR*/
    if (word_font_num[k] == kkk) {
      sign_str(kkk, works);
      sprintf(STR2, "RTF font No. %s of type %s \"%s\"",
	      works, word_fonts[k], equiv_fonts[k]);
      println_msg(2, STR2);
      add_to_bfsl(equiv_fonts[k]);
      ensure_sizebfsl();
      strcpy(active_RTFf[bracelvl], word_fonts[k]);
      return;
    }
  }
  if (lvlcode[bracelvl] != 6) {   /*END IF lvlcode*/
    print_line(2);
    sign_str(num_word_fonts, works);
    sprintf(STR1, "num_word_fonts=%s", works);
    println_msg(2, STR1);
    FORLIM = num_word_fonts;
    for (k = 0; k <= FORLIM - 1; k++) {
      sign_str(word_font_num[k], works);
      sprintf(STR4, "     %s --> \"%s\"", works, word_fonts[k]);
      println_msg(2, STR4);
    }
    sign_str(kkk, works);
    sprintf(STR3, "RTF font No. %s", works);
    print_msg(2, STR3);
    sign_str(lvlcode[bracelvl], works);
    sign_str(bracelvl, worksa);
    sprintf(STR5, " font of type unknown, lvlcode[%s]=%s", worksa, works);
    println_msg(2, STR5);
    sign_str(lvlcode[bracelvl-1], works);
    sign_str(bracelvl - 1, worksa);
    sprintf(STR5, " font of type unknown, lvlcode[%s]=%s", worksa, works);
    println_msg(2, STR5);
  }
  *active_RTFf[bracelvl] = '\0';
}
 
 
/* ------------------------------------------------------------------------- */
/* closing a \sum(...) ... possibly at a ) found !!!!!*/
 
Static Void close_sum()
{
  close_brace();
  close_math();
}
 
 
/* ------------------------------------------------------------------------- */
/* closing a \sum(...) ... possibly at a closing brace if no ) found !!!!!*/
 
Static Void close_sum_emergency(kode)
Char *kode;
{
  short k;
  Char STR1[256];
  Char STR3[42];
  short FORLIM;
 
  sign_str(input_line_number, works);
  sprintf(STR1, "Emergency close of \\|su or \\|i due to }%s at inp.line %s",
	  kode, works);
  println_msg(1, STR1);
  sign_str(next_rtf[0], works);
  sprintf(STR3, "pattern : \"%c%c\" %s", kar, next_rtf[0], works);
  print_msg(1, STR3);
  print_line(1);
  _SETIO(printf("kinp=%d prev_kinp=%d\n", kinp, prev_kinp) >= 0,
	 FileWriteError);
  FORLIM = prev_kinp;
  for (k = 0; k <= FORLIM - 1; k++) {
    sprintf(STR1, "%c", prev_line[k]);
    print_msg(1, STR1);
  }
  println_msg(1, " ");
  FORLIM = kinp;
  for (k = 0; k <= FORLIM - 1; k++) {
    sprintf(STR1, "%c", inpline[k]);
    print_msg(1, STR1);
  }
  println_msg(1, " ");
  outstg("\\emergcA ");
  close_sum();
}
 
 
/* --------------------------------------------------------------------------*/
Static Void perform_RTFcell()
{
  if (verbose > 0)
    _SETIO(printf("(found)%s[%d,%d,%d]\n",
		  inkeyw, lvlcode[bracelvl], tab_nb_ands[bracelvl],
		  bracelvl) >= 0, FileWriteError);
  if (lvlcode[bracelvl] == 15) {
    output_real_line();
    /* count the number of ampersands in the tabular line */
    tab_nb_ands[bracelvl]++;
    if (tab_nb_ands[bracelvl] < tab_nb_cellx[bracelvl]) {
      outstg(" & ");
      if (verbose > 1)
	_SETIO(printf("(after &)%s[%d,%d]\n",
		      inkeyw, lvlcode[bracelvl],
		      bracelvl) >= 0, FileWriteError);
      return;
    }
    outstg("\\\\");
    if (clbrdrb)
      outkeyw("hline ");
    if (verbose > 1)
      _SETIO(printf("(after &->\\\\)%s[%d,%d]\n",
		    inkeyw, lvlcode[bracelvl],
		    bracelvl) >= 0, FileWriteError);
    return;
  }
  if (verbose > 2)
    _SETIO(printf("%s[%d,%d]\n", inkeyw, lvlcode[bracelvl], bracelvl) >= 0,
	   FileWriteError);
  outkeyw("relax");
  output_line();   /* next line to ensure possible removal */
  outkeyw("RTFcell ");
  /*END IF lvlcode*/
 
}
 
 
/* --------------------------------------------------------------------------*/
/* procedure to close center and flushright environments */
 
Static Void close_envir()
{
  boolean RTF_cell_removed;
 
  envir_closed_ok = false;
  if (center_flag[bracelvl] == 2) {
    if (!no_space_conv)
      output_size(spacingcode[bracelvl]);
    outkrem("RTFcell ");
    RTF_cell_removed = removed_ok;
    center_flag[bracelvl] = 0;
    end_env(1);
    if (RTF_cell_removed)
      perform_RTFcell();
    output_line();
    envir_closed_ok = true;   /* output_line; */
    return;
  }
  if (flushright_flag[bracelvl] != 2)
    return;
  if (!no_space_conv)
    output_size(spacingcode[bracelvl]);
  outkrem("RTFcell ");
  RTF_cell_removed = removed_ok;
  flushright_flag[bracelvl] = 0;
  end_env(2);
  if (RTF_cell_removed)
    perform_RTFcell();
  output_line();
  envir_closed_ok = true;   /* output_line; */
  /*END IF center_flag*/
}
 
 
/* --------------------------------------------------------------------------*/
/* procedure to perform RTFsb/RTFsa */
 
Static Void make_RTFsab(numval)
short numval;
{
  Char STR1[48];
 
  if (numval > 300) {
    outkeyw("bigskip{}");
    return;
  }
  if (numval > 200) {
    outkeyw("medskip{}");
    return;
  }
  if (numval > 100) {
    outkeyw("smallskip{}");
    return;
  }
  if (numval > 0) {
    outkeyw("vspace 0.5\\smallskipamount{}");
    return;
  }
  if (numval < 0) {
    sign_str(numval, works);
    sprintf(STR1, "neg. spacing, NUMVAL:=%s", works);
    println_msg(1, STR1);
    /*END IF*/
  }
}
 
 
/* --------------------------------------------------------------------------*/
/* procedure to perform RTFpar (separate since it may be delayed after a } */
 
Static Void make_RTFpar(texcode)
Char *texcode;
{
  short k;
  short num_forced = 0;
  boolean was_underl;
  Char STR1[72];
  Char STR2[36];
  Char STR3[44];
 
  while (math_mode[bracelvl] > 1) {
    if (lvlcode[bracelvl] == 16)
      outstg("\\relax %%% ???");
    else
      outstg("}\\relax %%% !!!");
    output_line();
    close_brace();
    num_forced++;
  }
  close_math();
  if (num_forced > 0) {   /*END IF*/
    close_envir();
    output_size(spacingcode[bracelvl]);
    output_line();
    output_line();
    par_to_begin = true;
    num_indent = 0;
    if (space_after != 0)
      make_RTFsab(space_after);
    space_after = 0;
    sign_str(input_line_number, worksa);
    sign_str(bracelvl, works);
    sprintf(STR1, "input line %s, bracelvl=%s", worksa, works);
    println_msg(0, STR1);
    sign_str(num_forced, works);
    sprintf(STR2, "num_forced=%s", works);
    println_msg(0, STR2);
  }
 
  was_underl = underl_flag[bracelvl];
  outkrem(bfslcode[bracelvl]);
  if (was_underl)
    outchr('}');
  output_line();
  if (!no_space_conv)
    output_size(spacingcode[bracelvl]);
  close_envir();
  if (!(envir_closed_ok || no_space_conv))
    outkeyw("null ");
  outstg(texcode);
  if (space_after != 0)
    make_RTFsab(space_after);
  space_after = 0;
  par_to_begin = true;
  num_indent = 0;
 
  if (was_underl)
    outkeyw("underbar{");
 
  for (k = 1; k <= num_forced; k++) {   /*END DO*/
    outchr('{');
    bracelvl++;
    math_mode[bracelvl] = 0;   /*do not open ??? */
  }
 
  sign_str(bracelvl, works);
  if (num_forced > 0) {
    sprintf(STR3, "restored bracelvl=%s", works);
    println_msg(0, STR3);
  }
}
 
 
/* --------------------------------------------------------------------------*/
/* replace recent space with a ~ (before : ; ? ! in general */
Static Void insert_tilde(CHARAC)
Char CHARAC;
{
  if (math_mode[bracelvl] == 0) {   /*END IF*/
    outrem(" ");
    if (removed_ok)
      outchr('~');
  }
  begin_par();
  outchr(CHARAC);
  keyw = 0;
}
 
 
/* --------------------------------------------------------------------------*/
/* initiates "tabular" but does not reset parms to zero */
Static Void perform_RTFtrow()
{
  if (verbose > 0)
    _SETIO(printf("(init row)%s[%d,%d]\n",
		  inkeyw, lvlcode[bracelvl], bracelvl) >= 0, FileWriteError);
  open_brace();
  lvlcode[bracelvl] = 13;
  if (verbose > 1)
    _SETIO(printf("%s(after)[%d,%d]\n", inkeyw, lvlcode[bracelvl], bracelvl) >= 0,
	   FileWriteError);
  tab_nb_ands[bracelvl] = 0;
}
 
 
/* --------------------------------------------------------------------------*/
Static Void perform_RTFrow()
{
  if (lvlcode[bracelvl] == 15) {
    if (verbose > 0)
      _SETIO(printf("\\RTFrow[%d,%d,%d]\n",
		    lvlcode[bracelvl], tab_nb_cellx[bracelvl],
		    bracelvl) >= 0, FileWriteError);
    close_brace();
    outkeyw("end{tabular}\\par ");
    tab_nb_cellx[bracelvl] = tab_nb_cellx[bracelvl+1];
    return;
  }
  if (verbose > 1)
    _SETIO(printf("\\RTFrow[%d,%d]\n", lvlcode[bracelvl], bracelvl) >= 0,
	   FileWriteError);
  output_real_line();
  outkeyw("RTFrow ");
  /*END IF lvlcode*/
 
}
 
 
/* --------------------------------------------------------------------------*/
Static Void make_closing_brace()
{
  Char pict_byte;
  boolean already_closed = false;
  Char STR1[142];
  Char STR2[148];
  Char STR3[34];
 
  while (auto_close[bracelvl]) {   /*END WHILE auto_close*/
    if (math_mode[bracelvl] == 1)
      outchr('$');
    outchr('}');
    close_brace();
  }
  /* check "*/
  /*" within \|I(...) and similar : then ignore pair */
  if (lvlcode[bracelvl] >= 16 && next_rtf[0] == '{') {
    next_rtf[0] = '\0';
    return;
  }
  if (*form_code[bracelvl] != '\0' && next_rtf[0] == '{') {
    next_rtf[0] = '\0';
    return;
  }
  /* special case of \|su(...) closing */
  if (lvlcode[bracelvl] == 25)
    close_sum();
  else if (lvlcode[bracelvl] >= 16)
    close_sum_emergency("lvlc");
  /*END IF*/
  close_math();
 
  if (lvlcode[bracelvl] != 4) {
    if (lvlcode[bracelvl] == 5) {
      /* this is \RTFpict closing brace */
      if (pict_left_hexa) {   /*END IF pict_left_hexa*/
	/* look whether there is already one hexa digit stored*/
	pict_last_hexa *= 16;
	pict_byte = pict_last_hexa;
	_SETIO(putc(pict_byte, figurefile) >= 0, FileWriteError);
	pict_byte_number++;
	pict_last_hexa = 0;
	pict_left_hexa = false;
      }
 
      if (figurefile != NULL)
	fclose(figurefile);
      figurefile = NULL;
      sprintf(STR1, "closed file %s", figure_name);
      print_msg(1, STR1);
      sign_str((int)pict_byte_number, works);
      sprintf(STR3, "(%s bytes)", works);
      println_msg(1, STR3);
      outchr(kar);
    } else if (lvlcode[bracelvl] == 10) {
      sprintf(STR2, "closed dummy file %s", figure_name);
      /* this is \RTFobject closing brace */
      println_msg(1, STR2);
      outchr(kar);
    }
    /* if there was a \cell just before, put it outside the closing brace */
    else if (last_is("\\RTFcell ")) {
      if (verbose > 1)
	_SETIO(printf("closing}[%d,%d]\n", lvlcode[bracelvl], bracelvl) >= 0,
	       FileWriteError);
      outkrem("RTFcell ");
      if (!removed_ok)
	_SETIO(printf("*** \\RTFcell not removed before } ***\n") >= 0,
	       FileWriteError);
      outchr(kar);
      close_brace();
      already_closed = true;
      if (verbose > 0)
	_SETIO(printf("moved \\RTFcell [%d,%d]\n",
		      lvlcode[bracelvl], bracelvl) >= 0, FileWriteError);
      perform_RTFcell();
    }
    /* if there was a \row just before, put it outside the closing brace */
    else if (last_is("\\RTFrow ")) {
      if (verbose > 1)
	_SETIO(printf("closing}[%d,%d]\n", lvlcode[bracelvl], bracelvl) >= 0,
	       FileWriteError);
      outkrem("RTFrow ");
      outchr(kar);
      close_brace();
      already_closed = true;
      if (verbose > 0)
	_SETIO(printf("moved \\RTFrow [%d,%d]\n", lvlcode[bracelvl], bracelvl) >=
	       0, FileWriteError);
      perform_RTFrow();
    } else {
      /* if there was a \par just before, put it outside the closing brace */
      if (last_is("\\null \\par ")) {
	outkrem("null \\par ");
	outchr(kar);
	if (no_space_conv)
	  outkeyw("par ");
	else
	  outkeyw("null \\par ");
      } else if (last_is("\\par ")) {
	outkrem("par ");
	outchr(kar);
	outkeyw("par ");
      } else
	outchr(kar);
      /*ENF IF*/
 
      if (*form_code[bracelvl] != '\0') {   /*END IF*/
	if (*form_code[bracelvl-1] == '\0')
	  strcpy(form_code[bracelvl-1], form_code[bracelvl]);
	else {
	  close_sum_emergency("form");
	  /* this is an ordinary closing brace */
	}
      }
      /*END IF*/
    }
  }
  /* this is footnote first and dummy RTF argument closing brace */
 
  /*END IF*/
  if (!already_closed) {
    close_brace();
    /*END IF*/
  }
}
 
 
/* --------------------------------------------------------------------------*/
/* special output of single characters due to \TeX special codings */
 
Static Void special_TeX_chars()
{
  Char STR1[256];
 
  begin_par();
  if (kar == '$') {
    outstg("\\$");
    /*END IF*/
    return;
  }
  if (kar == '_') {
    outstg("\\_");
    return;
  }
  if (kar == '#') {
    outstg("\\#");
    return;
  }
  if ((kar == '>' || kar == '<') && math_mode[bracelvl] == 0) {
    sprintf(STR1, "%c", kar);
    out_math(STR1);
    return;
  }
  if (kar == '&') {
    outstg("\\&");
    return;
  }
  if (kar == '%') {
    outstg("\\%");
    return;
  }
  if (kar == '^') {
    outstg("\\^{ }");
    return;
  }
  if (kar == '~')
    out_math("\\sim{}");
  else
    outchr(kar);
}
 
 
/* --------------------------------------------------------------------------*/
/* **************** Beginning of RTF decoding procedures ******************* */
/*---------------------------------------------------------------------------*/
/* treats a character when KEYW is 0 */
/* no keyword decoding presently active */
 
Static Void keyw_is_0()
{
  short hexa_digit;
  Char pict_byte;
  string24 open_kar, RTFform, acc_converted, STR1;
  Char STR2[28];
  Char STR3[26];
  Char STR4[256];
  Char STR5[32];
  Char STR6[36];
  Char STR8[12];
 
  if (cat == 0) {   /* this is a backslash */
    if (lvlcode[bracelvl] == 3)
      return;
    /* ignore after \footnote until opening brace */
    if (lvlcode[bracelvl] == 4)
      return;
    /* ignore after \footnote { (first brace pair after) */
    if (lvlcode[bracelvl] == 9) {
      /*END IF active_RTF*/
      return;
    }
 
    keyw = 1;
    numval = 0;
    numsign = 1;
    strcpy(inkeyw, "\\RTF");
    return;
  }
  /*END IF*/
  if (cat == 1) {   /* this is an opening brace */
    if (no_RTFrtf)   /* ignore first opening brace before \rtf1 */
      return;
    if (lvlcode[bracelvl] == 3) {
      open_brace();
      return;
    }
    if (lvlcode[bracelvl] == 4) {
      open_brace();
      return;
    }
    if (lvlcode[bracelvl] == 6) {
      outchr(kar);
      open_brace();
      return;
    }
    if (par_to_begin)
      output_size(sizecode[bracelvl]);
    make_center();
    outchr(kar);
    open_brace();
    return;
  }
  /*END IF*/
  if (cat == 2) {   /* this is a closing brace */
    close_envir();
    if (bracelvl > 0)
      make_closing_brace();
    return;
  }
  if (cat == 3) {   /* this is an opening parenthesis '(' */
    if (*form_code[bracelvl] != '\0') {
      if (!strcmp(form_code[bracelvl], "\\RTFformulaB")) {
	sprintf(STR2, "%sBC(", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR1, STR2));
      }
      if (!strcmp(form_code[bracelvl], "\\RTFformulaBLC")) {
	sprintf(STR3, "%s(", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR1, STR3));
      }
      if (!strcmp(form_code[bracelvl], "\\RTFformulaBRC")) {
	sprintf(STR3, "%s(", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR1, STR3));
      }
      if (!strcmp(form_code[bracelvl], "\\RTFformulaBBC")) {
	sprintf(STR3, "%s(", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR1, STR3));
      }
      if (strpos2(form_code[bracelvl], "\\RTFformulaBBC", 1) > 0) {
	strcpy(RTFform, form_code[bracelvl]);
	sprintf(open_kar, "%c", RTFform[strlen(RTFform) - 1]);
	if (!strcmp(open_kar, "{"))
	  strcpy(open_kar, "\\{");
	out_math_leave("\\left");
	outstg(open_kar);
	outchr(' ');
	*form_code[bracelvl] = '\0';
	open_brace();
	lvlcode[bracelvl] = 16;   /* special code to close with ) */
	if (!strcmp(open_kar, "("))
	  strcpy(close_kar[bracelvl], ")");
	else if (!strcmp(open_kar, "["))
	  strcpy(close_kar[bracelvl], "]");
	else if (!strcmp(open_kar, "\\{"))
	  strcpy(close_kar[bracelvl], "\\}");
	else
	  strcpy(close_kar[bracelvl], open_kar);
	/*END IF open_kar*/
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      if (strpos2(form_code[bracelvl], "\\RTFformulaBLC", 1) > 0) {
	strcpy(RTFform, form_code[bracelvl]);
	sprintf(open_kar, "%c", RTFform[strlen(RTFform) - 1]);
	if (!strcmp(open_kar, "{"))
	  strcpy(open_kar, "\\{");
	out_math_leave("\\left");
	outstg(open_kar);
	outchr(' ');
	*form_code[bracelvl] = '\0';
	open_brace();
	lvlcode[bracelvl] = 16;   /* special code to close with ) */
	strcpy(close_kar[bracelvl], ".");
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      if (strpos2(form_code[bracelvl], "\\RTFformulaBRC", 1) > 0) {
	strcpy(RTFform, form_code[bracelvl]);
	sprintf(open_kar, "%c", RTFform[strlen(RTFform) - 1]);
	if (!strcmp(open_kar, "{"))
	  strcpy(open_kar, "\\{");
	out_math_leave("\\left. ");
	*form_code[bracelvl] = '\0';
	open_brace();
	lvlcode[bracelvl] = 16;   /* special code to close with ) */
	if (!strcmp(open_kar, "("))
	  strcpy(close_kar[bracelvl], ")");
	else if (!strcmp(open_kar, "["))
	  strcpy(close_kar[bracelvl], "]");
	else if (!strcmp(open_kar, "\\{"))
	  strcpy(close_kar[bracelvl], "\\}");
	else
	  strcpy(close_kar[bracelvl], open_kar);
	/*END IF open_kar*/
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|F( ... ; ... ) */
      if (!strcmp("\\RTFformulaF", form_code[bracelvl])) {
	*form_code[bracelvl] = '\0';
	out_math_leave("{\\displaystyle ");
	open_brace();
	lvlcode[bracelvl] = 17;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|D\|BA() or \|D\|FO() */
      if (!strcmp("\\RTFformulaDFO", form_code[bracelvl])) {
	sign_str(displ_skip, worksa);
	*form_code[bracelvl] = '\0';
	sprintf(STR5, "kern %spt", worksa);
	outkeyw(STR5);
	open_brace();
	lvlcode[bracelvl] = 28;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|D\|LI() */
      if (!strcmp("\\RTFformulaDLI", form_code[bracelvl])) {
	sign_str(displ_skip, worksa);
	*form_code[bracelvl] = '\0';
	sprintf(STR6, "RTFhrule %spt", worksa);
	outkeyw(STR6);
	open_brace();
	lvlcode[bracelvl] = 28;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|O( ... ; ... ) */
      if (!strcmp("\\RTFformulaO", form_code[bracelvl])) {
	*form_code[bracelvl] = '\0';
	begin_par();
	outkeyw("hbox{\\ooalign{\\hfil{}");
	open_brace();
	lvlcode[bracelvl] = 26;
	math_mode[bracelvl] = 0;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|L( ... ; ... ) */
      if (!strcmp("\\RTFformulaL", form_code[bracelvl])) {
	*form_code[bracelvl] = '\0';
	begin_par();
	outchr('{');
	open_brace();
	lvlcode[bracelvl] = 27;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|R( ... ; ... ) */
      if (!strcmp("\\RTFformulaR", form_code[bracelvl])) {
	*form_code[bracelvl] = '\0';
	out_math_leave("\\sqrt{");
	open_brace();
	lvlcode[bracelvl] = 23;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|X( ... ; ... ) */
      if (strpos2(form_code[bracelvl], "\\RTFformulaX", 1) > 0) {
	*form_code[bracelvl] = '\0';
	begin_par();
	sprintf(STR8, "\\boxed%s{", strsub(STR4, form_code[bracelvl], 11, 3));
	outstg(STR8);
	open_brace();
	lvlcode[bracelvl] = 7;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|S( ... ; ... ) */
      if (!strcmp("\\RTFformulaS", form_code[bracelvl]) ||
	  !strcmp("\\RTFformulaSUP", form_code[bracelvl])) {
	*form_code[bracelvl] = '\0';
	out_math_leave("^{");
	open_brace();
	lvlcode[bracelvl] = 18;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|SDO( ... ; ... ) */
      if (!strcmp("\\RTFformulaSDO", form_code[bracelvl])) {
	*form_code[bracelvl] = '\0';
	out_math_leave("_{");
	open_brace();
	lvlcode[bracelvl] = 19;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|I( ... ; ... ) */
      if (!strcmp("\\RTFformulaI", form_code[bracelvl])) {
	*form_code[bracelvl] = '\0';
	out_math_leave("\\int_{");
	open_brace();
	lvlcode[bracelvl] = 20;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|ISU( ... ; ... ) */
      if (!strcmp("\\RTFformulaISU", form_code[bracelvl])) {
	*form_code[bracelvl] = '\0';
	out_math_leave("\\displaystyle\\sum_{");
	open_brace();
	lvlcode[bracelvl] = 20;
	kar = ' ';   /* to prevent do_it_again */
	return;
      }
      /* case of \|IPR( ... ; ... ) */
      if (strcmp("\\RTFformulaIPR", form_code[bracelvl]))
	return;
      *form_code[bracelvl] = '\0';
      out_math_leave("\\displaystyle\\prod_{");
      open_brace();
      lvlcode[bracelvl] = 20;
      kar = ' ';   /* to prevent do_it_again */
      return;
    }
    /* if an opening parenthese is found inside a deep formula, set lvlcode at 25 */
    /*END IF*/
    if (abs(lvlcode[bracelvl]) < 17) {
      begin_par();
      outchr(kar);
      return;
    }
    outchr(kar);
    open_brace();
    lvlcode[bracelvl] = 25;
    return;
  }
  /*END IF form_code */
  if (cat == 4) {   /* this is a closing parenthesis ')' */
    /* test 23 sept */
    while (lvlcode[bracelvl] < 0 && auto_close[bracelvl])
    {   /*END WHILE auto_close*/
      if (math_mode[bracelvl] == 1)
	outchr('$');
      outchr('}');
      close_brace();
    }
    /* fin test 23 sept */
    /* special case of \|B..(...) closing */
    if (lvlcode[bracelvl] == 16) {
      outstg("\\right");
      outstg(close_kar[bracelvl]);
      close_sum();
      return;
    }
    /* special case of \|X..(...) closing */
    if (lvlcode[bracelvl] == 7) {
      outchr('}');
      close_sum();
      return;
    }
    /* closing parenthese found inside a formula, was opened with another ( 25 */
    if (lvlcode[bracelvl] == 25) {
      outchr(kar);
      close_brace();
      return;
    }
    /* closing parenthese found inside a formula \|O */
    if (lvlcode[bracelvl] == 26) {
      close_math();
      outstg("\\hfil}}");
      close_brace();
      return;
    }
    /* closing parenthese found inside a formula \|L */
    if (lvlcode[bracelvl] == 27) {
      outchr('}');
      close_brace();
      return;
    }
    /* closing parenthese found inside a formula \|D */
    if (lvlcode[bracelvl] == 28) {
      outstg("{}");
      close_brace();
      return;
    }
    /* special case of \|F(...) closing */
    /* special case of \|S(...) closing */
    /* special case of \|SDO(...) closing */
    /* special case of \|I(...) closing */
    /* special case of \|I(..;..) closing */
    /* special case of \|I(..;..;..) closing */
    /* special case of \|R(...) closing */
    if (lvlcode[bracelvl] >= 17) {
      close_subs();
      close_sum();
      return;
    }
    /* closing parenthese found inside a deep formula, make it 1 level lower */
    if (-lvlcode[bracelvl] >= 17)
      sprintf(next_rtf, "}){%s", strcpy(STR4, next_rtf));
    else {
      begin_par();
      outchr(kar);
    }
    return;
  }
  /* Ignore chars to be ignored */
  /*END IF lvlcode*/
  if (lvlcode[bracelvl] == 1)
    return;
 
  if (lvlcode[bracelvl] == 3)
    return;
 
  if (lvlcode[bracelvl] == 4)
    return;
 
  if (lvlcode[bracelvl] == 5) {   /* we are in the hexa part of a \RTFpict */
    /* ignore possible blanks and control characters within hexadecimal field */
    if (kar <= 32)   /*END IF*/
      return;
    hexa_digit = hx_to_i(kar);
    pict_char_number++;
    if (pict_left_hexa) {
      /* there is already one hexa digit stored*/
      pict_last_hexa = pict_last_hexa * 16 + hexa_digit;
      pict_byte = pict_last_hexa;
      _SETIO(putc(pict_byte, figurefile) >= 0, FileWriteError);
      pict_byte_number++;
      pict_last_hexa = 0;
      pict_left_hexa = false;
      return;
    }
    /* there is no hexa digit stored*/
    pict_last_hexa = hexa_digit;
    last_kar = kar;
    pict_left_hexa = true;
    return;
  }
  /*END IF pict-left_hexa*/
  if (abs(lvlcode[bracelvl]) == 10)   /* we are in \RTFobject */
    return;
 
  if (abs(lvlcode[bracelvl]) == 9)   /* ignore other than braces */
    return;
 
  if (cat == 11) {   /* this is a letter */
    begin_par();
    if (lvlcode[bracelvl] == 2) {   /* letters to be capitalized ? */
      kar = toupper(kar);
      ikar = kar;
    }
    /*END IF lvlcode=2*/
    if (!strcmp(active_RTFf[bracelvl], "ftech")) {
      strcpy(acc_converted, ftech_transl[ikar]);
      if (*acc_converted != '\0')
	out_math(acc_converted);
      else
	outchr(kar);
      return;
    }
    /*END IF acc_converted*/
    outrem("\\beginparagraph{}");
    if (removed_ok && kout > 0)
      outstg("{}");
    outchr(kar);
    return;
  }
  /*END IF active_RTF*/
  if (!strcmp(active_RTFf[bracelvl], "ftech")) {
    begin_par();
    strcpy(acc_converted, ftech_transl[ikar]);
    if (*acc_converted != '\0')
      out_math(acc_converted);
    else
      special_TeX_chars();
    return;
  }
  /*END IF acc_converted*/
  if (kar == '-') {
    if (last_is("\\beginparagraph{}")) {
      outrem("\\beginparagraph{}");
      outkeyw("plainitem{--}");
    } else
      outchr(kar);
    return;
  }
  /*END IF*/
  if (kar == '"') {
    begin_par();   /*  test march 94 */
    if (math_mode[bracelvl] == 0 && (kout == 0 || last_is(" ")))
      outstg("``");
    else
      outstg("''");
    return;
  }
  /*END IF*/
  if (kar != ';') {
    /*END IF*/
    special_TeX_chars();
    return;
  }
  /* ignore ; in colortbl section */
  if (lvlcode[bracelvl] == 9)
    return;
  /* special case of \|F(. ; .) intermediate semi-colon */
  if (lvlcode[bracelvl] == 17) {
    /* special case of \|S(. ; .) intermediate semi-colon */
    outstg(" \\over\\displaystyle ");
    return;
  }
  if (lvlcode[bracelvl] == 18) {
    close_subs();
    out_math_leave(" _{");
    return;
  }
  /* special case of \|SDO(. ; .) intermediate semi-colon */
  if (lvlcode[bracelvl] == 19) {
    close_subs();
    out_math_leave(" ^{");
    return;
  }
  /* special case of \|I(. ; .) intermediate semi-colon */
  if (lvlcode[bracelvl] == 20) {
    close_subs();
    outstg(" ^{");
    lvlcode[bracelvl] = 21;
    return;
  }
  /* special case of \|su(. ; .) second intermediate semi-colon */
  if (lvlcode[bracelvl] == 21) {
    close_subs();
    outchr('{');
    lvlcode[bracelvl] = 22;
    return;
  }
  /* special case of \|R(. ; .) intermediate semi-colon */
  if (lvlcode[bracelvl] == 23) {
    outsubstitute("\\sqrt{", "\\root{");
    outstg("}\\of{");
    lvlcode[bracelvl] = 24;
    output_line();   /* safety */
    return;
  }
  /* special case of \|O(. ; .) intermediate semi-colon */
  if (lvlcode[bracelvl] == 26) {
    /* special case of \|L(. ; .) intermediate semi-colon */
    outstg("\\hfil\\crcr\\hfil{}");
    return;
  }
  if (lvlcode[bracelvl] == 27)
    outchr(',');
  else
    outchr(kar);
}
 
 
/*---------------------------------------------------------------------------*/
/* treats a character when KEYW is 1 */
/* Keyword being decoded, we are just after the BACKSLASH */
 
Static Void keyw_is_1()
{
  Char STR1[256];
 
  if (cat == 11) {  /* letter : store and say KEYW:=2 */
    sprintf(inkeyw + strlen(inkeyw), "%c", kar);
    keyw = 2;
    return;
  }
  if (cat == 16) {  /* case of a digit : store \RTF */
    outrem_empty_braces();
    outstg(inkeyw);
    outchr(kar);
    keyw = 0;
    return;
  }
  /* turn \{ into \RTFaccol and... try to continue ! */
  if (kar == '{') {
    out_math("\\{");
    keyw = 0;
    /*  inkeyw:=inkeyw+'accol '; keyw:=2 ; */
    return;
  }
  /* turn \} into \RTFlocca and... try to continue ! */
  if (kar == '}') {
    out_math("\\}");
    keyw = 0;
    /* inkeyw:=inkeyw+'locca '; keyw:=2 ; */
    return;
  }
  if (kar == '(') {
    begin_par();
    outkeyw("RTFparen ");
    keyw = 0;
    return;
  }
  if (kar == '-') {
    /* case of a word cutting hyphen \- */
    begin_par();
    sprintf(STR1, "%c", kar);
    outkeyw(STR1);
    keyw = 0;
    return;
  }
  if (kar == '*') {
    if (abs(lvlcode[bracelvl]) < 10 || abs(lvlcode[bracelvl]) > 12) {
      begin_par();
      outchr(kar);
    }
    keyw = 0;   /*END IF*/
    return;
  }
  if (kar == '_') {
    /* case of a word non cutting hyphen \_ */
    begin_par();
    outchr('-');
    keyw = 0;
    return;
  }
  if (kar == '~') {
    /* case of a non breaking space */
    begin_par();
    outchr(kar);
    keyw = 0;
    return;
  }
  if (kar == '\'') {
    keyw = 4;
    num_hexa = 0;
    return;
  }
  if (kar == ':') {
    insert_tilde(kar);
    return;
  }
  if (kar == ';') {
    insert_tilde(kar);
    return;
  }
  if (kar == ')') {
    begin_par();
    outchr(kar);
    return;
  }
  if (kar == '(') {
    begin_par();
    outchr(kar);
    return;
  }
  if (kar == '\\') {
    if (next_rtf[0] == 'f' && lvlcode[bracelvl] == 12) {
      lvlcode[bracelvl] = 9;
      /*END IF*/
      return;
    }
    begin_par();
    outstg("{\\char92}");
    keyw = 0;
    return;
  }
  if (kar == '|') {
    if (next_rtf[0] != '}') {
      /* case of \| (in formulae) store as "formula" and expect letters */
      strcat(inkeyw, "formula");
      keyw = 2;
      return;
    }
    /* if \|} cancel \| and post it for later */
    *inkeyw = '\0';
    keyw = 0;
    strdelete((Anyptr)next_rtf, 1, 1);
    sprintf(next_rtf, "}\\|%s", strcpy(STR1, next_rtf));
    return;
  }
  /* store \RTF and try again */
  outkeyw("RTF{}");
  keyw = 0;
  do_it_again = true;
}
 
 
/*---------------------------------------------------------------------------*/
/* treats a character when KEYW is 2 */
/* We are in a letter keyword */
 
Static Void keyw_is_2()
{
  short poskeyw, k, posbsl, testio;
  string24 inkeywb;
  Char STR1[256], STR2[256];
  Char STR3[232];
  Char STR4[150];
  string24 STR5;
  Char STR6[188];
  Char STR7[28];
  Char STR8[26];
  short FORLIM;
 
  if (cat == 11) {
    /* letter : store and capitalize for formulas */
    if (strpos2(inkeyw, "\\RTFformula", 1) > 0)
      sprintf(inkeyw + strlen(inkeyw), "%c", toupper(kar));
    else
      sprintf(inkeyw + strlen(inkeyw), "%c", kar);
    return;
  }
  /*END IF*/
  if (cat == 16) {
    /* case of a digit : store with opening brace and say KEYW:=3 */
    sprintf(inkeyw + strlen(inkeyw), "{%c", kar);
    numval = kar - icharz;
    numsign = 1;
    keyw = 3;
    return;
  }
  if (kar == '-') {
    /* case of a - introduction : store opening brace and say KEYW:=3 */
    strcat(inkeyw, "{-");
    numval = 0;
    numsign = -1;
    keyw = 3;
    return;
  }
  /* delay \begin(center) to further opening \par */
  if (!strcmp(inkeyw, "\\RTFqc")) {
    if (lvlcode[bracelvl] != 9)
      center_flag[bracelvl] = 1;
  }
  /* delay \begin(flushright) to further opening \par */
  else if (!strcmp(inkeyw, "\\RTFqr")) {
    if (lvlcode[bracelvl] != 9)
      flushright_flag[bracelvl] = 1;
  }
  /* interpret some other keywords */
  else if (!strcmp(inkeyw, "\\RTFtab")) {
    if (par_to_begin)
      num_indent++;
    else
      outkeyw("indent ");
  } else if (!strcmp(inkeyw, "\\RTFchpgn")) {
    begin_par();
    outkeyw("the\\count0{}");
  } else if (!strcmp(inkeyw, "\\RTFb")) {
    add_to_bfsl("\\bf");
    ensure_sizebfsl();
  } else if (!strcmp(inkeyw, "\\RTFscaps")) {
    add_to_bfsl("\\sc");
    ensure_sizebfsl();
  } else if (!strcmp(inkeyw, "\\RTFoutl")) {
    add_to_bfsl("\\oul");
    ensure_sizebfsl();
  } else if (!strcmp(inkeyw, "\\RTFul")) {
    outrem("{");
    if (removed_ok) {
      if (math_mode[bracelvl] == 0) {
	begin_par();
	outkeyw("underbar{");
      } else {
	begin_par();
	outkeyw("underline{");
      }
    } else
      outkeyw("RTFul{}");
    /*END IF removed_OK*/
    underl_flag[bracelvl] = true;
  } else if (!strcmp(inkeyw, "\\RTFuldb")) {
    outrem("{");
    if (removed_ok) {
      if (math_mode[bracelvl] == 0) {
	begin_par();
	outkeyw("underbar{\\bf{}");
      } else {
	begin_par();
	outkeyw("underline{");
      }
    } else
      outkeyw("RTFuldb{}");
    /*END IF removed_OK*/
    underl_flag[bracelvl] = true;
  } else if (!strcmp(inkeyw, "\\RTFv")) {
    outrem("{");
    if (removed_ok) {
      begin_par();
      outkeyw("index{");
    } else
      outkeyw("RTFul{}");
    /*END IF removed_OK*/
    underl_flag[bracelvl] = true;
  } else if (strpos2(inkeyw, "\\RTFheader", 1) + strpos2(inkeyw,
	       "\\RTFfooter", 1) > 0) {
    outrem("{");
    if (removed_ok) {
      sprintf(STR1, "%s{", inkeyw + 1);
      outkeyw(STR1);
    } else {
      sprintf(STR2, "%s{\\relax}", inkeyw + 1);
      outkeyw(STR2);
    }
    /*END IF removed_OK*/
    lvlcode[bracelvl] = 9;
  } else if (!strcmp(inkeyw, "\\RTFi")) {
    if (use_sl)
      add_to_bfsl("\\sl");
    else
      add_to_bfsl("\\it");
    /*END IF*/
    ensure_sizebfsl();
  } else if (!strcmp(inkeyw, "\\RTFpard"))
  {  /* old center_flag[bracelvl]:=0; flushright_flag[bracelvl]:=0; */
    close_math();
    close_envir();
    center_flag[bracelvl] = 0;
    flushright_flag[bracelvl] = 0;
    strcpy(bfslcode[bracelvl], "\\rm");
 
    if (abs(lvlcode[bracelvl]) != 8 && abs(lvlcode[bracelvl]) != 9 &&
	lvlcode[bracelvl] != 13 && lvlcode[bracelvl] != 15)
    {   /*END IF*/
      leftskip = 0;
      rightskip = 0;
      num_indent = 0;
      par_to_begin = true;
      if (!last_is("\\end{tabular}\\par ")) {
	if (kout > 0)
	  output_line();
	outstg(" %\\check ");
	output_line();   /* for testing */
      }
    }
    /* never cut line+\check after \end{tabular} */
    if (lvlcode[bracelvl] == 2)
      lvlcode[bracelvl] = 0;
  } else if (!strcmp(inkeyw, "\\RTFpar")) {
    if (next_rtf[0] == '}') {
      *inkeyw = '\0';
      strdelete((Anyptr)next_rtf, 1, 1);
      sprintf(next_rtf, "}\\par %s", strcpy(STR2, next_rtf));
    } else
      make_RTFpar("\\par ");
  } else if (!strcmp(inkeyw, "\\RTFpagebb")) {
    /*END IF next_rtf[1]*/
    if (next_rtf[0] == '}') {
      *inkeyw = '\0';
      strdelete((Anyptr)next_rtf, 1, 1);
      sprintf(next_rtf, "}\\pagebb %s", strcpy(STR2, next_rtf));
    } else
      make_RTFpar("\\clearpage ");
  } else if (!strcmp(inkeyw, "\\RTFpage")) {
    /*END IF next_rtf[1]*/
    if (next_rtf[0] == '}') {
      *inkeyw = '\0';
      strdelete((Anyptr)next_rtf, 1, 1);
      sprintf(next_rtf, "}\\page %s", strcpy(STR2, next_rtf));
    } else {
      output_size(spacingcode[bracelvl]);
      outkeyw("break\\eject\\noindent ");
      output_size(sizecode[bracelvl]);
      output_bfsl();
    }
  } else if (!strcmp(inkeyw, "\\RTFsect")) {
    /*END IF next_rtf[1]*/
    if (next_rtf[0] == '}') {
      *inkeyw = '\0';
      strdelete((Anyptr)next_rtf, 1, 1);
      sprintf(next_rtf, "}\\par %s", strcpy(STR2, next_rtf));
    } else
      make_RTFpar("\\par  \\relax ");
  } else if (!strcmp(inkeyw, "\\RTFrquote")) {
    /*END IF next_rtf[1]*/
    outchr('\'');
  } else if (!strcmp(inkeyw, "\\RTFlquote"))
    outchr('`');
  else if (!strcmp(inkeyw, "\\RTFmac"))
    mac_init();
  else if (!strcmp(inkeyw, "\\RTFansi"))
    ansi_init();
  else if (!strcmp(inkeyw, "\\RTFline")) {
    /* flag to say future capitalized */
    outkeyw("break ");
  } else if (!strcmp(inkeyw, "\\RTFcaps")) {
    lvlcode[bracelvl] = 2;
    /* flag to say we are in \fonttbl block */
  } else if (!strcmp(inkeyw, "\\RTFfonttbl")) {
    lvlcode[bracelvl] = 6;
    outrem_empty_braces();
    outkrem(sizecode[bracelvl]);
    outrem("{");
    if (removed_ok)
      outkeyw("RTFfonttbl{");
    else
      outkeyw("RTFfonttbl{}{}{}\\relax ");
  } else if (!strcmp(inkeyw, "\\RTFcolortbl")) {
    /*END IF*/
    outrem_empty_braces();
    lvlcode[bracelvl] = 9;
    outkrem(sizecode[bracelvl]);
    outrem("{");
    if (removed_ok)
      outkeyw("RTFcolortbl{");
    else
      outkeyw("RTFcolortbl{}{}{}\\relax ");
  } else if (!strcmp(inkeyw, "\\RTFinfo")) {
    /*END IF*/
    outrem_empty_braces();
    outkrem(sizecode[bracelvl]);
    outrem("{");
    if (removed_ok)
      outkeyw("RTFinfo{");
    else
      outkeyw("RTFinfo{}{}{}\\relax ");
  } else if (!strcmp(inkeyw, "\\RTFstylesheet")) {
    /*END IF*/
    outrem_empty_braces();
    outkrem(sizecode[bracelvl]);
    outrem("{");
    if (removed_ok) {
      outkrem("RTFcolortbl{}");
      outkeyw("RTFstylesheet{");
    } else
      outkeyw("RTFstylesheet{}{}{}\\relax ");
    /*END IF*/
    lvlcode[bracelvl] = 8;
  } else if (!strcmp(inkeyw, "\\RTFfield"))
    lvlcode[bracelvl] = 11;
  else if (strcmp(inkeyw, "\\RTFflddirty")) {
 
    if (strpos2(inkeyw, "\\RTFfldinst", 1) > 0 && lvlcode[bracelvl-1] == 11) {
      lvlcode[bracelvl] = 12;
      return;   /* to avoid resetting keyw:=0 */
    }
    if (!strcmp(inkeyw, "\\RTFtrowd")) {
      perform_RTFtrow();
      outkeyw("begin{tabular}{");
      clbrdrr = false;
      clbrdrl = false;
      clbrdrt = false;
      clbrdrb = false;
      tab_nb_cellx[bracelvl] = 0;
      tab_cellx[bracelvl] = 0;
    } else if (strcmp(inkeyw, "\\RTFbrdrs") || lvlcode[bracelvl] != 13) {
      /* ignore */
      if (!strcmp(inkeyw, "\\RTFclbrdrl") && lvlcode[bracelvl] == 13) {
	outchr('|');
	if (verbose > 1)
	  _SETIO(printf("%s[%d,%d]\n", inkeyw, lvlcode[bracelvl], bracelvl) >=
		 0, FileWriteError);
	clbrdrl = false;
      } else if (!strcmp(inkeyw, "\\RTFclbrdrr") && lvlcode[bracelvl] == 13) {
	if (verbose > 1)
	  _SETIO(printf("%s[%d,%d]\n", inkeyw, lvlcode[bracelvl], bracelvl) >=
		 0, FileWriteError);
	clbrdrr = true;
      } else if (!strcmp(inkeyw, "\\RTFclbrdrt") && lvlcode[bracelvl] == 13) {
	if (verbose > 1)
	  _SETIO(printf("%s[%d,%d]\n", inkeyw, lvlcode[bracelvl], bracelvl) >=
		 0, FileWriteError);
	clbrdrt = true;
      } else if (!strcmp(inkeyw, "\\RTFclbrdrb") && lvlcode[bracelvl] == 13) {
	if (verbose > 1)
	  _SETIO(printf("%s[%d,%d]\n", inkeyw, lvlcode[bracelvl], bracelvl) >=
		 0, FileWriteError);
	clbrdrb = true;
      } else if (!strcmp(inkeyw, "\\RTFintbl")) {
	if (verbose > 0)
	  _SETIO(printf("(found)%s[%d,%d]\n",
			inkeyw, lvlcode[bracelvl],
			bracelvl) >= 0, FileWriteError);
	if (lvlcode[bracelvl] == 13) {
	  if (clbrdrr)
	    outchr('|');
	  clbrdrr = false;
	  outchr('}');
	  lvlcode[bracelvl] = 15;   /* second part of \RTFtrowd */
	  if (clbrdrt) {
	    outkeyw("hline");
	    output_line();
	  }
	  tab_nb_ands[bracelvl] = 0;
	  if (verbose > 1)
	    _SETIO(printf("(after)%s[%d,%d]\n",
			  inkeyw, lvlcode[bracelvl],
			  bracelvl) >= 0, FileWriteError);
	} else if (lvlcode[bracelvl] == 15) {
	  if (verbose > 1)
	    _SETIO(printf("(ignored)%s[%d,%d]\n",
			  inkeyw, lvlcode[bracelvl],
			  bracelvl) >= 0, FileWriteError);
	} else {
	  if (verbose > 0)
	    _SETIO(printf("forcing\\RTFtrowd%s[%d,%d]\n",
			  inkeyw, lvlcode[bracelvl],
			  bracelvl) >= 0, FileWriteError);
	  if (last_is("\\\\\\end{tabular}\\par "))
	    outkrem("end{tabular}\\par ");
	  else if (last_is("\\\\\\hline \\end{tabular}\\par "))
	    outkrem("end{tabular}\\par ");
	  else if (last_is("\\end{tabular}\\par ")) {
	    outkrem("end{tabular}\\par ");
	    outstg("\\\\");
	    if (clbrdrb)
	      outkeyw("hline ");
	  } else
	    outkeyw("begin{tabular}{ppppppppppppppp}");
	  /*END IF last_is(...)*/
	  perform_RTFtrow();
	  lvlcode[bracelvl] = 15;   /* second part of \RTFtrowd */
	  if (verbose > 1) {
	    _SETIO(printf("(<after)%s[%d,%d,%d]\n",
			  inkeyw, lvlcode[bracelvl], tab_nb_cellx[bracelvl],
			  bracelvl) >= 0, FileWriteError);
	    /* force \RTFtrowd if missing */
	    /*END IF verbose*/
	  }
	}
      } else if (!strcmp(inkeyw, "\\RTFrow"))
	perform_RTFrow();
      else if (!strcmp(inkeyw, "\\RTFcell"))
	perform_RTFcell();
      else if (!strcmp(inkeyw, "\\RTFobject")) {
	rtfpicw = 0;
	rtfpich = 0;   /* reset picture width and height to 0 */
	pict_char_number = 0;
	pict_byte_number = 0;
	pict_last_hexa = 0;   /* reset last hexa byte of the picture */
	pict_left_hexa = false;
	pict_number++;   /* count picture number */
	sign_str(pict_number, pict_name);
	sprintf(figure_name, "%s%s%s", figure_path, pict_name, figure_type);
	while (strpos2(figure_name, "\\", 1) > 0) {   /*END DO*/
	  posbsl = strpos2(figure_name, "\\", 1);
	  figure_name[posbsl-1] = '/';
	}
	begin_par();
	sprintf(STR3, "%s{%s}", strsub(STR1, inkeyw, 2, 99), figure_name);
	outkeyw(STR3);
	sprintf(figure_name, "%s%s%s", figure_path, pict_name, figure_type);
	output_line();
	sprintf(STR4, "Skipped object file %s", figure_name);
	println_msg(1, STR4);
	lvlcode[bracelvl] = 10;
      } else if (!strcmp(inkeyw, "\\RTFpict")) {
	rtfpicw = 0;
	rtfpich = 0;   /* reset picture width and height to 0 */
	pict_char_number = 0;
	pict_byte_number = 0;
	pict_last_hexa = 0;   /* reset last hexa byte of the picture */
	pict_left_hexa = false;
	pict_number++;   /* count picture number */
	sign_str(pict_number, pict_name);
	sprintf(figure_name, "%s%s%s", figure_path, pict_name, figure_type);
	while (strpos2(figure_name, "\\", 1) > 0) {   /*END DO*/
	  posbsl = strpos2(figure_name, "\\", 1);
	  figure_name[posbsl-1] = '/';
	}
	begin_par();
	sprintf(STR3, "%s{%s}", strsub(STR1, inkeyw, 2, 99), figure_name);
	outkeyw(STR3);
	sprintf(figure_name, "%s%s%s", figure_path, pict_name, figure_type);
	output_line();
	strcpy(figurefile_NAME, figure_name);
	if (figurefile != NULL)
	  figurefile = freopen(figurefile_NAME, "w", figurefile);
	else
	  figurefile = fopen(figurefile_NAME, "w");
	_SETIO(figurefile != NULL, FileNotFound);
	testio = P_ioresult;
	if (testio != 0) {   /*ENF IF testio*/
	  sign_str(testio, works);
	  sprintf(STR6, "Unable to open figure file %s ; code=%s",
		  figure_name, works);
	  println_msg(0, STR6);
	  close_files();
	  _Escape(0);
	}
	sprintf(STR4, "Opened picture file %s", figure_name);
	println_msg(1, STR4);
	lvlcode[bracelvl] = 5;
      } else if (!strcmp(inkeyw, "\\RTFfootnote")) {
	if (math_mode[bracelvl] == 0) {
	  lvlcode[bracelvl] = 3;
	  outrem("{");
	  if (removed_ok)
	    outkeyw("footnote{");
	  else
	    outkeyw("footnote ");
	} else if (math_mode[bracelvl] == 1) {
	  /*END IF removed*/
	  close_math();
	  sprintf(next_rtf, "\\footnote %s", strcpy(STR1, next_rtf));
	} else if (math_mode[bracelvl-1] == 1)
	  sprintf(next_rtf, "}{\\footnote %s", strcpy(STR1, next_rtf));
	else if (bracelvl >= 2 && math_mode[bracelvl-2] == 1)
	  sprintf(next_rtf, "}}{{\\footnote %s", strcpy(STR1, next_rtf));
	else if (bracelvl >= 3 && math_mode[bracelvl-3] == 1)
	  sprintf(next_rtf, "}}}{{{\\footnote %s", strcpy(STR1, next_rtf));
	else
	  outkeyw("footnote ");
      } else if (!strcmp(inkeyw, "\\RTFplain")) {
	/*END IF math_mode*/
	outpsize(stdsize * 20);
	strcpy(bfslcode[bracelvl], "\\rm");
	strcpy(sizecode[bracelvl], "normalsize");
      } else if (!strcmp(inkeyw, "\\RTFchftn"))
	remove_mathat();
      else if (!strcmp(inkeyw, "\\RTFendash")) {
	if (math_mode[bracelvl] > 0)
	  outchr('-');
	else
	  outstg("--");
      } else if (!strcmp(inkeyw, "\\RTFemdash")) {
	if (math_mode[bracelvl] > 0)
	  outchr('-');
	else
	  outstg("---");
      } else if (!strcmp(inkeyw, "\\RTFfnil"))
	    /* decl_font_num is a global variable */
	      store_word_font("fnil");
      else if (!strcmp(inkeyw, "\\RTFfroman"))
	store_word_font("froman");
      else if (!strcmp(inkeyw, "\\RTFfmodern"))
	store_word_font("fmodern");
      else if (!strcmp(inkeyw, "\\RTFfdecor"))
	store_word_font("fdecor");
      else if (!strcmp(inkeyw, "\\RTFfswiss"))
	store_word_font("fswiss");
      else if (!strcmp(inkeyw, "\\RTFfscript"))
	store_word_font("fscript");
      else if (!strcmp(inkeyw, "\\RTFftech"))
	store_word_font("ftech");
      else if (!strcmp(inkeyw, "\\RTFformulaB"))
	truncate24(form_code[bracelvl], inkeyw);
      else if (!strcmp(inkeyw, "\\RTFformulaO"))
	truncate24(form_code[bracelvl], inkeyw);
      else if (!strcmp(inkeyw, "\\RTFformulaLC")) {
	sprintf(STR7, "%sLC", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      } else if (!strcmp(inkeyw, "\\RTFformulaRC")) {
	sprintf(STR7, "%sRC", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      } else if (!strcmp(inkeyw, "\\RTFformulaBC")) {
	sprintf(STR7, "%sBC", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      } else if (!strcmp(inkeyw, "\\RTFformulaF"))
	truncate24(form_code[bracelvl], inkeyw);
      else if (!strcmp(inkeyw, "\\RTFformulaR"))
	truncate24(form_code[bracelvl], inkeyw);
      else if (!strcmp(inkeyw, "\\RTFformulaS"))
	truncate24(form_code[bracelvl], inkeyw);
      else if (!strcmp(inkeyw, "\\RTFformulaD"))
	truncate24(form_code[bracelvl], inkeyw);
      else if (!strcmp(inkeyw, "\\RTFformulaX"))
	truncate24(form_code[bracelvl], inkeyw);
      else if (!strcmp(inkeyw, "\\RTFformulaI"))
	truncate24(form_code[bracelvl], inkeyw);
      else if (!strcmp(inkeyw, "\\RTFformulaSU")) {
	sprintf(STR7, "%sSU", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      } else if (!strcmp(inkeyw, "\\RTFformulaPR")) {
	sprintf(STR7, "%sPR", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      } else if (!strcmp(inkeyw, "\\RTFformulaIN")) {
	sprintf(STR7, "%sIN", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      } else if (!strcmp(inkeyw, "\\RTFformulaRI")) {
	sprintf(STR7, "%sRI", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      } else if (!strcmp(inkeyw, "\\RTFformulaBO")) {
	sprintf(STR7, "%sBO", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      } else if (!strcmp(inkeyw, "\\RTFformulaLE")) {
	sprintf(STR7, "%sLE", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      } else if (!strcmp(inkeyw, "\\RTFformulaTO")) {
	sprintf(STR7, "%sTO", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
	/* case of \|<non-alpha> */
      } else if (!strcmp(inkeyw, "\\RTFformula")) {
	if (cat == 0 && next_rtf[0] == '{') {
	  sprintf(STR8, "%s{", form_code[bracelvl]);
	  strcpy(form_code[bracelvl], truncate24(STR5, STR8));
	  kar = ' ';
	  next_rtf[0] = '\0';   /* to prevent do_it_again */
	} else if (cat == 0 && next_rtf[0] == '}') {
	  sprintf(STR8, "%s}", form_code[bracelvl]);
	  strcpy(form_code[bracelvl], truncate24(STR5, STR8));
	  kar = ' ';
	  next_rtf[0] = '\0';   /* to prevent do_it_again */
	} else {
	  sprintf(STR8, "%s%c", form_code[bracelvl], kar);
	  strcpy(form_code[bracelvl], truncate24(STR5, STR8));
	  kar = ' ';   /* to prevent do_it_again */
	}
      }
      /* case of \{ */
      else if (!strcmp(inkeyw, "\\RTFaccol ")) {
	/*END IF*/
	/* case of \} */
	out_math("\\{");
      } else if (!strcmp(inkeyw, "\\RTFlocca "))
	out_math("\\}");
      else {
	poskeyw = 0;
	sprintf(STR1, "%s ", inkeyw);
	truncate24(inkeywb, STR1);
	FORLIM = num_skip_strings;
	/* check whether this keyword should be skipped in output */
	for (k = 0; k <= FORLIM - 1; k++)   /*END DO*/
	  poskeyw += strpos2(skip_strings[k], inkeyw, 1);
	/* output other keywords with an additional space */
	if (poskeyw == 0) {   /*END IF poskeyw*/
	  outrem_empty_braces();
	  outstg(inkeyw);
	  /* do not put a space if following is a (, for TeX macros syntax */
	  if (kar != '(')
	    outchr(' ');
	}
      }
    }
  }
  /*END IF*/
  /* reset KEYW and try again */
  keyw = 0;
  if (kar != ' ') {
    do_it_again = true;
    /*END IF cat=11*/
  }
}
 
 
/*---------------------------------------------------------------------------*/
/* treats a character when KEYW is 3 */
/* Numeric arg of Keyword being decoded */
 
Static Void keyw_is_3()
{
  string24 sizeheader;   /* will be 'large', 'Large', 'footnotesize'... */
  short magnification;   /* will be 1000, 1095, 900... */
  short diff_cellx, style_ref, poskeyw, k;
  string24 acc_converted, inkeywb;
  string_RTFstyle test_RTFstyle;
  Char STR1[64];
  Char STR2[186];
  Char STR3[58];
  Char STR4[256];
  short FORLIM;
  string24 STR5;
  Char STR6[26];
  Char STR7[28];
 
  if (cat == 16) {
    /* case of a digit */
    sprintf(inkeyw + strlen(inkeyw), "%c", kar);
    numval = numval * 10 + numsign * (kar - icharz);
    return;
  }
  /* case of a non digit: terminate but ignore some keywords with brace pairs */
  if (strpos2(inkeyw, "RTFsl{", 1) > 0) {
    outpsize(numval);
    sign_str(numval, works);
    sprintf(STR1, "\\RTFsl{%s} -->  \\%s", works, spacingcode[bracelvl]);
    println_msg(2, STR1);
  } else if (strpos2(inkeyw, "RTFli{", 1) > 0 && center_flag[bracelvl] < 2) {
    if (lvlcode[bracelvl] != 8)   /*END IF*/
      leftskip = numval;
  } else if (strpos2(inkeyw, "RTFri{", 1) > 0 && center_flag[bracelvl] < 2) {
    if (lvlcode[bracelvl] != 8)   /*END IF*/
      rightskip = numval;
  } else if (strpos2(inkeyw, "RTFf{", 1) > 0) {
    decl_font_num = numval;   /* store numval for further use */
    set_active_RTFf(numval);
    outstg("{}");
  }
  /* use _ and ^ for sub/superscripts and put in math mode if needed */
  else if (strpos2(inkeyw, "RTFup{", 1) > 0) {
    out_math_leave("\\relax^{");
    open_brace();
    auto_close[bracelvl] = true;
  } else if (strpos2(inkeyw, "RTFdn{", 1) > 0) {
    out_math_leave("\\relax_{");
    open_brace();
    auto_close[bracelvl] = true;
  }
  /* ignore \RTFfi if option '-v' */
  else if (strpos2(inkeyw, "RTFfi{", 1) > 0) {
    num_indent = 1;
    if (!(no_space_conv && numval > 0)) {
      outkeyw("parindent=");
      output_num(numval);
      outkeyw("RTFtwips");
      output_line();
    }
  }
  /* style description */
  else if (strpos2(inkeyw, "RTFs{", 1) > 0) {
    sign_str(numval, works);
    if (abs(lvlcode[bracelvl]) == 8) {
      if (num_styles >= maxRTFstyles) {
	sprintf(STR3, "Too many styles, style %s ignored.", works);
	println_msg(0, STR3);
      } else if (numval > 255) {
	sprintf(STR1, "Illegal style number, style %s ignored.", works);
	println_msg(0, STR1);
      } else {
	num_styles++;
	ref_styles[numval] = num_styles;
	sprintf(test_RTFstyle, "%c", kar);
	while (kar != ';' && kar != '}') {   /*END while*/
	  read_char();
	  sprintf(test_RTFstyle + strlen(test_RTFstyle), "%c", kar);
	}
	/* clean style to the first blank after \snext */
	if (kar == ';')
	  kar = ' ';
	k = strpos2(test_RTFstyle, "\\snext", 1);
	m = strlen(test_RTFstyle);
	FORLIM = strlen(test_RTFstyle);
	for (l = k; l <= FORLIM; l++) {
	  if (test_RTFstyle[l-1] == ' ' && l < m)
	    m = l;
	}
	sign_str(num_styles, worksa);
	/* start at the first space in style text */
	n = strpos2(test_RTFstyle, " ", 1) + 1;
	strsub(RTFstyles[num_styles-1], test_RTFstyle, n, m - n + 1);
	sprintf(STR2, "%s --> %s \"%s\"",
		works, worksa, RTFstyles[num_styles-1]);
	println_msg(2, STR2);
      }
    } else {
      /*END IF*/
      style_ref = ref_styles[numval];
      if (style_ref <= 0 || style_ref > 255) {
	sprintf(STR1, "Illegal style number, style %s ignored.", works);
	println_msg(0, STR1);
      } else {
	if (kar != ' ')
	  sprintf(next_rtf, "%c%s", kar, strcpy(STR4, next_rtf));
	kar = ' ';
	sprintf(next_rtf, "%s%s",
		RTFstyles[style_ref-1], strcpy(STR4, next_rtf));
	/*END IF*/
      }
    }
  }
  /* font size description */
  else if (strpos2(inkeyw, "RTFfs{", 1) + strpos2(inkeyw, "RTFfldinstfs{", 1) > 0 &&
	   lvlcode[bracelvl] != 8) {
    /*END IF*/
    /* before putting \LARGE, \Huge etc., remove previous \bf, \rm, etc. */
    outrem_empty_braces();
    outrem(bfslcode[bracelvl]);
 
    /* output \large, \normalsize, \footnotesize according to NUMVAL */
    outfsize(numval, &magnification);
 
    sprintf(STR6, "\\%s", sizecode[bracelvl]);
    truncate24(sizeheader, STR6);
    if (!strcmp(sizeheader, "\\footnotesize"))
      strcpy(sizeheader, "\\footnsize");
 
    /* correct font names in bfslcode[bracelvl] according to latex209  or latex2e */
    font_clean(sizeheader, magnification);
 
    if (!par_to_begin) {   /*END IF*/
      output_size(sizecode[bracelvl]);
      output_bfsl();
      if (!last_is("}")) {
	if (!last_is("{"))
	  outstg("{}");
      }
    }
  } else if (strpos2(inkeyw, "RTFsb{", 1) > 0) {
    /*END IF*/
    outkrem("par");
    outkrem("par ");
    if (lvlcode[bracelvl] != 8 && lvlcode[bracelvl] != 9)
      outkeyw("par ");
    make_RTFsab(numval);
  } else if (strpos2(inkeyw, "RTFsa{", 1) > 0)
    save_skip = numval;
  else if (strpos2(inkeyw, "RTFtrleft{", 1) <= 0) {   /* en attente */
    if (strpos2(inkeyw, "\\RTFcellx{", 1) > 0 && lvlcode[bracelvl] == 13) {
      /* \RTCcellx gives absolutes abscissae, but tabular's p{} needs differences */
      diff_cellx = numval - tab_cellx[bracelvl];
      outstg("p{");
      output_num(diff_cellx);
      outstg("\\RTFtwips}");
      if (clbrdrl)
	outchr('|');
      clbrdrl = false;
      tab_nb_cellx[bracelvl]++;
      tab_cellx[bracelvl] = numval;
    } else if (strpos2(inkeyw, "RTFpicw{", 1) > 0) {
      strcat(inkeyw, "}");
      outrem_empty_braces();
      outstg(inkeyw);
      rtfpicw = numval;
    } else if (strpos2(inkeyw, "RTFpich{", 1) > 0) {
      strcat(inkeyw, "}");
      outrem_empty_braces();
      outstg(inkeyw);
      rtfpich = numval;
    } else if (strpos2(inkeyw, "RTFobjw{", 1) > 0) {
      strcat(inkeyw, "}");
      outrem_empty_braces();
      outstg(inkeyw);
      rtfpicw = numval;
    } else if (strpos2(inkeyw, "RTFobjh{", 1) > 0) {
      strcat(inkeyw, "}");
      outrem_empty_braces();
      outstg(inkeyw);
      rtfpich = numval;
    }
    /* case of \|DO( ... ) */
    else if (strpos2(inkeyw, "\\RTFformulaDO{", 1) > 0) {
      if (*form_code[bracelvl] == '\0')
	strcpy(form_code[bracelvl], "\\RTFformulaSDO");
      else {
	sprintf(STR7, "%sDO", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
	/* case of \|UP( ... ) */
      }
    } else if (strpos2(inkeyw, "\\RTFformulaUP{", 1) > 0) {
      if (*form_code[bracelvl] == '\0')
	strcpy(form_code[bracelvl], "\\RTFformulaSUP");
      else {
	sprintf(STR7, "%sUP", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
	/* case of \|FO( ... ) */
      }
    } else if (strpos2(inkeyw, "\\RTFformulaFO{", 1) > 0) {
      if (*form_code[bracelvl] == '\0')
	strcpy(form_code[bracelvl], "\\RTFformulaDFO");
      else {
	sprintf(STR7, "%sFO", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      }
      displ_skip = numval;
    }
    /* case of \|UP( ... ) */
    else if (strpos2(inkeyw, "\\RTFformulaBA{", 1) > 0) {
      if (*form_code[bracelvl] == '\0')
	strcpy(form_code[bracelvl], "\\RTFformulaDFO");
      else {
	sprintf(STR7, "%sFO", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      }
      displ_skip = -numval;
    }
    /* case of \|UP( ... ) */
    else if (strpos2(inkeyw, "\\RTFformulaLI{", 1) > 0) {
      if (*form_code[bracelvl] == '\0')
	strcpy(form_code[bracelvl], "\\RTFformulaDLI");
      else {
	sprintf(STR7, "%sLI", form_code[bracelvl]);
	strcpy(form_code[bracelvl], truncate24(STR5, STR7));
      }
      displ_skip = numval;
    }
    /* case of \|AI( ... ) */
    else if (strpos2(inkeyw, "\\RTFformulaAI{", 1) <= 0) {
      /* case of \|DI( ... ) */
      if (strpos2(inkeyw, "\\RTFformulaDI{", 1) <= 0) {
	if (strpos2(inkeyw, "RTFrtf{", 1) > 0) {
	  no_RTFrtf = false;
	  strcat(inkeyw, "}");
	  outrem_empty_braces();
	  outstg(inkeyw);
	}
	/* explicit references to symbol characters */
	else if (strpos2(inkeyw, "RTFfldinstsymbol", 1) + strpos2(inkeyw,
		   "RTFfldinstbsymbol",
		   1) + strpos2(inkeyw, "RTFfldinstbisymbol", 1) > 0) {
	  if (numval > 255)
	    numval = 0;
	  strcpy(acc_converted, ftech_transl[numval]);
	  if (*acc_converted != '\0')
	    out_math(acc_converted);
	  else
	    outchr('?');
	} else {
	  /*END IF acc_converted*/
	  poskeyw = 0;
	  k = strpos2(inkeyw, "{", 1);
	  if (k > 0) {
	    sprintf(inkeywb, "%.*s", k, inkeyw);
/* p2c: rtflatex.pas, line 1513:
 * Note: Possible faulty string assignment [145] */
/* p2c: rtflatex.pas, line 1513:
 * Note: string[24] := string[255] => unpredictable crashes */
	  } else {
	    sprintf(STR4, "%s}", inkeyw);
	    truncate24(inkeywb, STR4);
	  }
	  FORLIM = num_skip_strings;
	  /* check whether this keyword should be skipped in output */
	  for (k = 0; k <= FORLIM - 1; k++)   /*END DO*/
	    poskeyw += strpos2(skip_strings[k], inkeywb, 1);
	  if (poskeyw == 0) {   /*END IF poskeyw*/
	    strcat(inkeyw, "}");
	    outrem_empty_braces();
	    outstg(inkeyw);
	  }
	}
      }
      /* this test is eliminate first brace opened */
    }
  }
  /*END IF*/
  keyw = 0;
  if (kar != ' ') {
    do_it_again = true;
    /*END IF*/
  }
}
 
 
/*---------------------------------------------------------------------------*/
/* treats a character when KEYW is 4 */
/* Hexadecimal arg of RTFac */
 
Static Void keyw_is_4()
{
  string2 acchexa;
  string24 acc_converted;
  short posbrace;
  Char STR1[256];
  Char STR2[12];
  Char STR3[40];
 
  if (cat == 10)
    return;
 
  if (num_hexa == 0) {
    num_hexa = 1;
    hexaone = kar;
    return;
  }
  if (num_hexa != 1) {
    sign_str(num_hexa, works);
    sprintf(STR3, "Wrong num_hexa:%s", works);
    println_msg(0, STR3);
    /*END IF*/
 
    return;
  }
  hexatwo = kar;
  sprintf(acchexa, "%c%c", hexaone, hexatwo);
/* p2c: rtflatex.pas, line 1546:
 * Note: Possible faulty string assignment [145] */
/* p2c: rtflatex.pas, line 1546:
 * Note: string[2] := string[3] => unpredictable crashes */
  begin_par();
  if (!strcmp(active_RTFf[bracelvl], "ftech")) {
    strcpy(acc_converted, ftech_transl[hs_to_i(acchexa)]);
    if (*acc_converted != '\0')
      out_math(acc_converted);
    else {
      sprintf(STR2, "RTFac{%s}", acchexa);
      outkeyw(STR2);
    }
  } else {
    /*END IF acc_converted*/
    strcpy(acc_converted, acc_transl[hs_to_i(acchexa)]);
    if (*acc_converted != '\0') {
      if (acc_converted[0] == '\\')
	outrem_empty_braces();
      posbrace = strpos2(acc_converted, "{", 1);
      if (acc_converted[0] == '$') {
	outrem_empty_braces();
	out_math(strcpy(STR1, acc_converted + 1));
      } else if (posbrace <= 1)
	outstgc(acc_converted);
      else if (strpos2(acc_converted, "\\c{", 1) + strpos2(acc_converted,
		 "\\dag{",
		 1) + strpos2(acc_converted, "\\pound{", 1) + strpos2(
		 acc_converted, "\\copyright{",
		 1) + strpos2(acc_converted, "\\degree{", 1) > 0) {
	sprintf(STR1, "%.*s", posbrace - 1, acc_converted);
	outstg(STR1);
	outstgc(strcpy(STR1, acc_converted + posbrace - 1));
      } else
	outstgc(acc_converted);
    } else {
      /*END IF*/
      outkeyw("RTFac{");
      outstg(acchexa);
      outchr('}');
      /*END IF acc_converted*/
    }
  }
  /*END IF active_RTF*/
  num_hexa = 0;
  keyw = 0;
}
 
 
/*---------------------------------------------------------------------------*/
Static Void make_latex_header()
{
  short i;
  string24 strpts;
  Char STR1[28];
  Char STR2[26];
  short FORLIM;
  Char STR3[30];
 
  if (latex209)
    outkeyw("documentstyle[");
  else
    outkeyw("documentclass[");
  /*END IF*/
  if (stdsize != 10) {   /*END IF*/
    sign_str(stdsize, strpts);
    sprintf(STR1, "%spt,", strpts);
    outstg(STR1);
  }
  outstg("twoside");
 
  if (latex209) {
    FORLIM = num_latex_options;
    for (i = 0; i <= FORLIM; i++) {
      sprintf(STR2, ",%s", latex_options[i]);
      outstg(STR2);
    }
    sprintf(STR3, "]{%s}", latex_style);
    outstg(STR3);
    output_line();
  } else {
    sprintf(STR3, "]{%s}", latex_style);
    outstg(STR3);
    output_line();
    outkeyw("usepackage{");
    outstg(latex_options[0]);
    FORLIM = num_latex_options;
    for (i = 1; i <= FORLIM; i++) {
      sprintf(STR2, ",%s", latex_options[i]);
      outstg(STR2);
    }
    outstg("}");
    output_line();
  }
 
 
 
  outkeyw("begin{document}\\RTFsetfontheading");
  output_line();
}
 
 
/*---------------------------------------------------------------------------*/
/*                               MAIN                                        */
/*---------------------------------------------------------------------------*/
main(argc, argv)
int argc;
Char *argv[];
{
  short FORLIM;
  Char STR1[48];
  Char STR2[56];
  Char STR3[50];
  Char STR4[30];
  Char STR5[64];
 
  PASCAL_MAIN(argc, argv);
  skipfile = NULL;
  logfile = NULL;
  figurefile = NULL;
  outputfile = NULL;
  inputfile = NULL;
  clean_all();   /* for safety... */
 
  latex209 = false;
  write_log = false;
  use_sl = false;
  latex_header = true;
  simplify_ok = true;
  no_RTFrtf = true;
  base_flag = false;
  no_space_conv = false;
  last_percent = false;
  num_latex_options = 0;
  strcpy(latex_style, "report");
  strcpy(latex_options[0], "rtflatex");
  kar = '\0';
  save_skip = 0;
  space_after = 0;
  math_mode[0] = 0;
  auto_close[0] = false;
  bracelvl = 0;
  input_line_number = 1;
  /* envir_closed_ok:=FALSE; (test) */
  envir_closed_ok = true;
  num_styles = 0;
  displ_skip = 0;
  for (k = 0; k <= 255; k++)
    ref_styles[k] = 0;
 
  verbose = 1;   /* default moderate verbosity */
  tex_verbose = 0;   /* no insertion of flags within TeX output */
 
  title();
  charinit();
  sizeinit();
  open_files();
 
  /* "lvlcode" : say what to do of the contents of that block. 1=ignore
until end of  current block, 2=caps, 3=ignore footnote headings, 4=
ignore contents of first arg of \footnote, 5= \RTFpict text, 6= \fonttbl
declaration, 7= \RTFformulaX[xx], 8= within \stylesheet, 9= within
\header/\footer, 9= within \RTFcolortbl, 10= \RTFobject text, 11=
\RTFfield text, 12= inside \RTFfldinst, 13= inside \RTFtrowd/\RTFrow,
15= inside \RTFtrowd/RTFrow after \RTFintbl, 16=
within \RTFformulaB(...), 17= within \RTFformulaF(...), 18=
\RTFformulaSUP(...), 19= \RTFformulaSDO(...), 20= \RTFformulaI, 21= idem
after ";", 22= idem after second ";", 23= \RTFformulaR, 24= \RTFformulaR
after ";", 25= ordinary brace within a formula, 26=\RTFformulaO,
27=\RTFformulaL, 28=\RTFformulaD */
  lvlcode[0] = 0;
 
  /* bfslcode stores the recorded \bf, \sl, \it, \sf commands
   to repeat them AFTER \large, \Large */
  *bfslcode[0] = '\0';
  strcpy(sizecode[0], "normalsize");
  *active_RTFf[0] = '\0';
  strcpy(close_kar[0], " ");
  *form_code[0] = '\0';
  strcpy(spacingcode[0], "relax");
  *currsize[0] = '\0';
  *currbfsl[0] = '\0';
  leftskip = 0;
  rightskip = 0;
  leftcurskip = 0;
  rightcurskip = 0;
  tab_nb_cellx[0] = 0;
      /* the number of cells in a tabular line = #\RTFcellx */
  tab_nb_ands[0] = 0;   /* the number of &, must be < #\RTFcellx */
  tab_cellx[0] = 0;   /* current \RTFcellx value */
  clbrdrr = false;
  clbrdrl = false;
  clbrdrt = false;
  clbrdrb = false;
 
  *inkeyw = '\0';
  numl = 0;
  numval = 0;
  numsign = 1;
  num_hexa = 0;
  ikar = 0;
  kinp = 0;
  prev_kinp = 0;
  *next_rtf = '\0';
  num_indent = 0;
  num_word_fonts = 0;   /* number of RTF/Word defined fonts */
  numfonts = 0;   /* number of specially defined fonts */
  keyw = 0;   /* a flag to say whether we are decoding a keyword */
  pict_number = 0;   /* counts the pictures */
 
  center_flag[0] = 0;
  flushright_flag[0] = 0;
  do_it_again = false;
  underl_flag[0] = false;
  par_to_begin = true;
 
  cleanout();   /* clean EXFILE for safety */
 
  if (latex_header)
    make_latex_header();
 
  /* main loop to read input RTF file */
 
  read_next_char();
  while (ikar != 26) {
    /* read one character unless said to be retried */
    if (do_it_again)
      do_it_again = false;
    else
      read_char();
    /*END IF*/
    if (ikar < ' ')   /*END IF ikar*/
      continue;
 
    switch (keyw) {
 
    case 0:
      keyw_is_0();
      break;
 
    case 1:
      keyw_is_1();
      break;
 
    case 2:
      keyw_is_2();
      break;
 
    case 3:
      keyw_is_3();
      break;
 
    case 4:
      keyw_is_4();
      break;
    }/* case KEYW */
  }
  if (center_flag[bracelvl] > 0)
    outkeyw("end{center}");
  if (latex_header)
    outkeyw("end{document}");
  else
    outkeyw("bye");
  /*END IF latex_header*/
  output_line();
 
  println_msg(0, "RTFLaTeX terminated");
  sign_str(bracelvl, works);
  sprintf(STR1, "brace level finally is:%s", works);
  println_msg(0, STR1);
  sign_str(numl, works);
  if (numl > 0) {
    sprintf(STR2, "%s lines of code were generated.", works);
    println_msg(0, STR2);
  }
  sign_str(numfonts, works);
  if (numfonts > 0) {
    sprintf(STR3, "%s new fonts were declared:", works);
    println_msg(0, STR3);
  }
  FORLIM = numfonts;
  for (k = 1; k <= FORLIM; k++) {
    sprintf(STR4, "    %s", newfonts[k-1]);
    println_msg(0, STR4);
  }
  sign_str(pict_number, works);
  if (pict_number > 0) {
    sprintf(STR5, "%s pictures were stored in binary files.", works);
    println_msg(0, STR5);
  }
  close_files();
  if (inputfile != NULL)
    fclose(inputfile);
  if (outputfile != NULL)
    fclose(outputfile);
  if (figurefile != NULL)
    fclose(figurefile);
  if (logfile != NULL)
    fclose(logfile);
  if (skipfile != NULL)
    fclose(skipfile);
  exit(EXIT_SUCCESS);
}
 
 
 
 
 
/* End. */
/* end of file */