~ben.jackson/cuneiform-linux/working

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
/*
Copyright (c) 1993-2008, Cognitive Technologies
All rights reserved.

Ðàçðåøàåòñÿ ïîâòîðíîå ðàñïðîñòðàíåíèå è èñïîëüçîâàíèå êàê â âèäå èñõîäíîãî êîäà,
òàê è â äâîè÷íîé ôîðìå, ñ èçìåíåíèÿìè èëè áåç, ïðè ñîáëþäåíèè ñëåäóþùèõ óñëîâèé:

      * Ïðè ïîâòîðíîì ðàñïðîñòðàíåíèè èñõîäíîãî êîäà äîëæíû îñòàâàòüñÿ óêàçàííîå
        âûøå óâåäîìëåíèå îá àâòîðñêîì ïðàâå, ýòîò ñïèñîê óñëîâèé è ïîñëåäóþùèé
        îòêàç îò ãàðàíòèé.
      * Ïðè ïîâòîðíîì ðàñïðîñòðàíåíèè äâîè÷íîãî êîäà â äîêóìåíòàöèè è/èëè â
        äðóãèõ ìàòåðèàëàõ, ïîñòàâëÿåìûõ ïðè ðàñïðîñòðàíåíèè, äîëæíû ñîõðàíÿòüñÿ
        óêàçàííàÿ âûøå èíôîðìàöèÿ îá àâòîðñêîì ïðàâå, ýòîò ñïèñîê óñëîâèé è
        ïîñëåäóþùèé îòêàç îò ãàðàíòèé.
      * Íè íàçâàíèå Cognitive Technologies, íè èìåíà åå ñîòðóäíèêîâ íå ìîãóò
        áûòü èñïîëüçîâàíû â êà÷åñòâå ñðåäñòâà ïîääåðæêè è/èëè ïðîäâèæåíèÿ
        ïðîäóêòîâ, îñíîâàííûõ íà ýòîì ÏÎ, áåç ïðåäâàðèòåëüíîãî ïèñüìåííîãî
        ðàçðåøåíèÿ.

ÝÒÀ ÏÐÎÃÐÀÌÌÀ ÏÐÅÄÎÑÒÀÂËÅÍÀ ÂËÀÄÅËÜÖÀÌÈ ÀÂÒÎÐÑÊÈÕ ÏÐÀÂ È/ÈËÈ ÄÐÓÃÈÌÈ ËÈÖÀÌÈ "ÊÀÊ
ÎÍÀ ÅÑÒÜ" ÁÅÇ ÊÀÊÎÃÎ-ËÈÁÎ ÂÈÄÀ ÃÀÐÀÍÒÈÉ, ÂÛÐÀÆÅÍÍÛÕ ßÂÍÎ ÈËÈ ÏÎÄÐÀÇÓÌÅÂÀÅÌÛÕ,
ÂÊËÞ×Àß ÃÀÐÀÍÒÈÈ ÊÎÌÌÅÐ×ÅÑÊÎÉ ÖÅÍÍÎÑÒÈ È ÏÐÈÃÎÄÍÎÑÒÈ ÄËß ÊÎÍÊÐÅÒÍÎÉ ÖÅËÈ, ÍÎ ÍÅ
ÎÃÐÀÍÈ×ÈÂÀßÑÜ ÈÌÈ. ÍÈ ÂËÀÄÅËÅÖ ÀÂÒÎÐÑÊÈÕ ÏÐÀÂ È ÍÈ ÎÄÍÎ ÄÐÓÃÎÅ ËÈÖÎ, ÊÎÒÎÐÎÅ
ÌÎÆÅÒ ÈÇÌÅÍßÒÜ È/ÈËÈ ÏÎÂÒÎÐÍÎ ÐÀÑÏÐÎÑÒÐÀÍßÒÜ ÏÐÎÃÐÀÌÌÓ, ÍÈ Â ÊÎÅÌ ÑËÓ×ÀÅ ÍÅ
ÍÅÑšÒ ÎÒÂÅÒÑÒÂÅÍÍÎÑÒÈ, ÂÊËÞ×Àß ËÞÁÛÅ ÎÁÙÈÅ, ÑËÓ×ÀÉÍÛÅ, ÑÏÅÖÈÀËÜÍÛÅ ÈËÈ
ÏÎÑËÅÄÎÂÀÂØÈÅ ÓÁÛÒÊÈ, ÑÂßÇÀÍÍÛÅ Ñ ÈÑÏÎËÜÇÎÂÀÍÈÅÌ ÈËÈ ÏÎÍÅÑÅÍÍÛÅ ÂÑËÅÄÑÒÂÈÅ
ÍÅÂÎÇÌÎÆÍÎÑÒÈ ÈÑÏÎËÜÇÎÂÀÍÈß ÏÐÎÃÐÀÌÌÛ (ÂÊËÞ×Àß ÏÎÒÅÐÈ ÄÀÍÍÛÕ, ÈËÈ ÄÀÍÍÛÅ,
ÑÒÀÂØÈÅ ÍÅÃÎÄÍÛÌÈ, ÈËÈ ÓÁÛÒÊÈ È/ÈËÈ ÏÎÒÅÐÈ ÄÎÕÎÄÎÂ, ÏÎÍÅÑÅÍÍÛÅ ÈÇ-ÇÀ ÄÅÉÑÒÂÈÉ
ÒÐÅÒÜÈÕ ËÈÖ È/ÈËÈ ÎÒÊÀÇÀ ÏÐÎÃÐÀÌÌÛ ÐÀÁÎÒÀÒÜ ÑÎÂÌÅÑÒÍÎ Ñ ÄÐÓÃÈÌÈ ÏÐÎÃÐÀÌÌÀÌÈ,
ÍÎ ÍÅ ÎÃÐÀÍÈ×ÈÂÀßÑÜ ÝÒÈÌÈ ÑËÓ×ÀßÌÈ), ÍÎ ÍÅ ÎÃÐÀÍÈ×ÈÂÀßÑÜ ÈÌÈ, ÄÀÆÅ ÅÑËÈ ÒÀÊÎÉ
ÂËÀÄÅËÅÖ ÈËÈ ÄÐÓÃÎÅ ËÈÖÎ ÁÛËÈ ÈÇÂÅÙÅÍÛ Î ÂÎÇÌÎÆÍÎÑÒÈ ÒÀÊÈÕ ÓÁÛÒÊÎÂ È ÏÎÒÅÐÜ.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of the Cognitive Technologies nor the names of its
      contributors may be used to endorse or promote products derived from this
      software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#define TIGER_CORR       //alik

#ifdef _MSC_VER
#include<crtdbg.h>
#endif

#include "lst3_win.h"
#ifdef SPELL_NEW
  #include "b_open.h"
  #include "spell.h"
  #include "lm.h"
#endif

#ifdef DLL_MOD
 #define LST_WWIN
   #define MAIN2
#endif
#ifndef WIN_MOD
  #define LST_WWIN
#endif
#include "ful_txt.h"
#include "globus.h"
#include "wind32.h"
#include "aldebug.h"
#include "decl.h"
	////////////// functions, which are moved from other modules //////////////
#ifdef alDebug
static int dets=1;
#endif
static HWND h_found=NULL;

/* These were in ful_txt.h. That caused missing symbols
 * so I moved them here. JussiP.
 */

#ifdef __cplusplus
extern "C" {
#endif
//---Èç ñåêöèè êîëîíîê---
Int16 NumCol;
int SizeSectionCol;
Int16 *NumStr;//[nc]
Word32 *UserNumber;//[nc]
Word32 *FragFlag;//[nc]
SRECT *BndCol;//[nc]
STAT_COL *StatCol;//[nc]
int len_col,k_frm;
//int k_colt,slope,space;
char name[80],name1[LEN_PATH];
int k_col[MAX_LEV+1],k_lev; LEV **knot; //Äåðåâî
int fl_EditStruct; //Ïðèçíàê íåñîîòâåòñòâèÿ äåðåâà òåðìèíàë. êîëîíêàì
//---Èç ñåêöèè èìåí áàç---
int SizeSectionFntName; char *FntName;
//---Èç ñåêöèè çíàêîìåñò---
ZN ****Zn;//[nc][ns][nw][nz]
TITLE_STR **TitleStr;//[nc][ns]
TITLE_WORD ***TitleWord;//[nc][ns][nw]
TITLE_FUL TitleFul;
COOR_COMP *CoorComp; long NumComp;
//--FullSpellFull
uchar word[MAX_SYM_WORD+1],word1[MAX_SYM_WORD+1];
float dist[MAX_SYM_WORD+1],dist1[MAX_SYM_WORD+1];
PAR_FUL par_ful;
char PunctuationMarks[256];
int ExtSettings;
//char AlphabetAllow[256];
char WordOne[256];
uchar Upper[256],Lower[256],UppLow[256],UppLowOther[256],EndSentence[256];
BYTE KoderRus[256],KoderLat[256];
int FlCarryStr;
char FileParSpel[MAXFILENAME],FileParSpelOut[MAXFILENAME];
int *Pen;
int MaxValue;
//--ÊÎÐÐÅÊÒÎÐ ÏÎ ÎÄÍÎÐÎÄÍÎÑÒÈ
FEAT_LET FeatLet[256];
BYTE **ClustOCR;int K_Clust;//Êëàñòåðû ïåðåïóòûâàíèÿ
//---WORK---
BYTE buf[1024],buf1[1024];
#ifdef __cplusplus
}
#endif
/* End of things brought from ful_txt.h. */

/* Rectangles are written in frmtfile.cpp and they contain 16-bit integers.
 * They are processed as 32-bit integers here, so we need to convert.
 */

static void readSRECT(SRECT *r, FILE *f) {
    Rect16 r16;
    fread(&r16, sizeof(Rect16), 1, f);
    r->left = r16.left;
    r->top = r16.top;
    r->right = r16.right;
    r->bottom = r16.bottom;
}

BOOL __stdcall FindByPartOfTitle(
    HWND hwnd,	    // handle to parent window
    LPARAM lParam 	// application-defined value
   )
{
   char title[256];
   ::GetWindowText(hwnd, title, sizeof(title));
   if (strstr(title, (char*)lParam))
   {
		 h_found=hwnd;
      return FALSE;  // don't continue
   }
   return TRUE;
}

extern int ConsMess( const char* str, ... );
#ifdef SUB_ZN
  SUB_ALLOC SubZn;
#endif
/* // !!! Art - óñòàðåëî

#ifdef SUB_FRM
  SUB_ALLOC SubFrm;
#endif
int TypeDoc;
*/ // !!! Art - óñòàðåëî
Int16 MonoSpaceAllPage;
Int16 HeiStrAllPage;
/* // !!! Art - óñòàðåëî
int getchW(void);

FILE1 *f03;

*/  // !!! Art - óñòàðåëî


#ifdef TIGER_CORR
int CalcStatTiger(void);
//void GenArrAnsiOem(void);// !!! Art - óñòàðåëî
//int PASC CorrTiger(char *FileNameFul,char *FileNameOut,char *FilePar,int fl_cor);

int SaveFullOutTiger(char *FileName);
//Ïàðàìåòðû:
//FileNameFul - èìÿ ôàéëà Full Out Tiger
//FileNameOut - èìÿ âûõîäíîãî ôàéëà
//Return: 0 - OK
//
WORD NumZ,NumW,NumS;
Int16 SizeYGlobUpp;
int IsB1(BYTE a)
{ if((FeatLet[a].Chif && a != ',' && a != '.' && a != '-') ||
     (FeatLet[a].Let &&  a != '-' && a != '\'' &&
     (FeatLet[a].Shift==UPP || FeatLet[a].PosUpLine==UPP)))
     		return 1;
  return 0;
}
int IsB2(BYTE a)
{ if((FeatLet[a].Let && a != '-' && a != '\'' &&
      (FeatLet[a].Shift==LOW && FeatLet[a].PosUpLine==LOW)))
      	return 1;
  return 0;
}
//==Ðàñ÷åò ñòàòèñòèêè
int CalcStatTiger(void)
//==
{
	int numL,numU,maxL=1000,maxU=300,*Upp,*Low,med,mod,sig,ave,nc,ns,nw,nz;
  int numB1,*arrB1,maxB1=30;
	int ThrDif_b1b2;
  BYTE a;
	//SRECT rr;

	Upp  =(int*)malloc(maxU*sizeof(int));
	Low  =(int*)malloc(maxL*sizeof(int));
  arrB1=(int*)malloc(maxB1*sizeof(int));
  if(Upp==NULL || Low==NULL || arrB1==NULL)
		return NOT_ALLOC;
  // -- Ðàñ÷åò ãëîáàë.ðàçìåðîâ ñ ó÷åòîì OCR --
  numL=numU=0;
  for(nc=0; nc <= NumCol ; ++nc)
    for(ns=0; ns <= NumStr[nc]; ++ns)
      for(nw=0; nw < TitleStr[nc][ns].S_Gen.S_NumWord; ++nw)
        for(nz=0; nz < TitleWord[nc][ns][nw].W_Gen.W_NumSym; ++nz)
        { ZN *z=&Zn[nc][ns][nw][nz];
					     SRECT *r=&z->Title.Z_Rect;
          if(a=Get1Alt(z,0)) //ðàñïîçíàííî
          { if(IsB1(a))
            { if(numU >= maxU)
              { int MaxOld=maxU*sizeof(int); maxU*=2;
                if((Upp=(int*)realloc_m(Upp,MaxOld,maxU*sizeof(int)))==NULL)return NOT_ALLOC;
              }
              Upp[numU++]=r->bottom-r->top;
            }
            if(IsB2(a))
            { if(numL >= maxL)
              { int MaxOld=maxL*sizeof(int); maxL*=2;
                if((Low=(int*)realloc_m(Low,MaxOld,maxL*sizeof(int)))==NULL)return NOT_ALLOC;
              }
              Low[numL++]=r->bottom-r->top;
            }
        	}
				}
  sig=0; SizeYGlob=SizeYGlobUpp=INDEF;
  if(numU > 2)
		   Statist(Upp,numU,&ave,&sig,(int*)&SizeYGlobUpp,&mod,0);
  if(numL > 10)
		   Statist(Low,numL,&ave,&sig,&SizeYGlob   ,&mod,0);
  else //Ðàñ÷åò ãëîáàë.ðàçìåðîâ áåç ó÷åòà OCR
  { numL=numU=0;
    for(nc=0; nc <= NumCol; ++nc)
      for(ns=0; ns <= NumStr[nc]; ++ns)
        for(nw=0; nw < TitleStr[nc][ns].S_Gen.S_NumWord; ++nw)
          for(nz=0; nz < TitleWord[nc][ns][nw].W_Gen.W_NumSym; ++nz)
          {
											 ZN *z=&Zn[nc][ns][nw][nz];
												SRECT *r=&z->Title.Z_Rect;
            if(numL >= maxL)
            { int MaxOld=maxL*sizeof(int); maxL*=2;
              if((Low=(int*)realloc_m(Low,MaxOld,maxL*sizeof(int)))==NULL)return NOT_ALLOC;
            }
            Low[numL++]=r->bottom-r->top;
          }
    if(numL > 0)           //ALIK 01.05.99
					  Statist(Low,numL,&ave,&sig,&SizeYGlob,&mod,0);
    else
					  return -1;
  }
  // -- ðàñ÷åò êîëîííûõ ðàçìåðîâ --
  if(NumCol)
  { for(nc=0; nc <= NumCol; ++nc)
    { numL=numU=0;
      for(ns=0; ns <= NumStr[nc]; ++ns)
        for(nw=0; nw < TitleStr[nc][ns].S_Gen.S_NumWord; ++nw)
          for(nz=0; nz < TitleWord[nc][ns][nw].W_Gen.W_NumSym; ++nz)
          { ZN *z=&Zn[nc][ns][nw][nz]; SRECT *r=&z->Title.Z_Rect;
            if(a=Get1Alt(z,0))
            { if(IsB1(a))
              { if(numU >= maxU)
                { int MaxOld=maxU*sizeof(int); maxU*=2;
                  if((Upp=(int*)realloc_m(Upp,MaxOld,maxU*sizeof(int)))==NULL)return NOT_ALLOC;
                }
                Upp[numU++]=r->bottom-r->top;
              }
              if(IsB2(a))
              { if(numL >= maxL)
                { int MaxOld=maxL*sizeof(int); maxL*=2;
                  if((Low=(int*)realloc_m(Low,MaxOld,maxL*sizeof(int)))==NULL)return NOT_ALLOC;
                }
                Low[numL++]=r->bottom-r->top;
              }
          } }
      sig=0; StatCol[nc].dy_Upp=SizeYGlobUpp;
      if(numU > 2)
				Statist(Upp,numU,&ave,&sig,&StatCol[nc].dy_Upp,&mod,0);
      else
				StatCol[nc].dy_Upp=SizeYGlobUpp;
      if(numL > 10)
      { med=1;Statist(Low,numL,&ave,&sig,&med,&mod,0);
        StatCol[nc].dy_col=StatCol[nc].dy_Low=med;
      }
      else
				StatCol[nc].dy_col=StatCol[nc].dy_Low=SizeYGlob;
    }
  }
  else
  {
		StatCol[0].dy_col=StatCol[0].dy_Low=SizeYGlob;StatCol[0].dy_Upp=SizeYGlobUpp;
	}
  // -- ðàñ÷åò ñòðî÷íûõ ðàçìåðîâ ìàëûõ áóêâ è ðåâèçèÿ ëèíåéêè b2 --
  for(nc=0; nc <= NumCol; ++nc)
  { int Dif_b1b2;//ïðèçíàê ðàçëè÷èÿ ëèíååê b1 è b2
    ThrDif_b1b2=NORM_SCAN(3);
    ThrDif_b1b2=MAX(ThrDif_b1b2,(StatCol[nc].dy_Upp - StatCol[nc].dy_Low)/2);
    if((StatCol[nc].stat_str=(STAT_STR*)malloc((NumStr[nc]+1)*sizeof(STAT_STR)))==NULL)
			return NOT_ALLOC;
    for(ns=0; ns <= NumStr[nc]; ++ns)
    { SRECT *rS=&TitleStr[nc][ns].S_Rect;
      numL=numU=numB1=0; Dif_b1b2=(rS->top - rS->left > ThrDif_b1b2);
      for(nw=0; nw < TitleStr[nc][ns].S_Gen.S_NumWord; ++nw)
        for(nz=0; nz < TitleWord[nc][ns][nw].W_Gen.W_NumSym; ++nz)
        { ZN *z=&Zn[nc][ns][nw][nz]; SRECT *r=&z->Title.Z_Rect;
          if(a=Get1Alt(z,0))
          { if(IsB2(a))
            { if(numL >= maxL)
              { int MaxOld=maxL*sizeof(int); maxL*=2;
                if((Low=(int*)realloc_m(Low,MaxOld,maxL*sizeof(int)))==NULL)return NOT_ALLOC;
              }
              Low[numL++]=r->bottom-r->top;
              //ðåâèçóåì ëè òå b2, êîò. îòëè÷íû îò b1
              if(Dif_b1b2 && !FeatLet[a].ImUppLow)
              { TITLE_ZN *t=&z->Title; int na=t->Z_Num_Alt,flp,i;
                flp=TRUE;
                for(i=1; i < na; ++i)
                  if(!IsB2(a=Get1Alt(z,i)) || FeatLet[a].ImUppLow)
                    {flp=FALSE;break;}
                if(flp && abs(r->top-rS->left) < abs(r->top-rS->top))
                { if(numU >= maxU)
                  { int MaxOld=maxU*sizeof(int); maxU*=2;
                    if((Upp=(int*)realloc_m(Upp,MaxOld,maxU*sizeof(int)))==NULL)return NOT_ALLOC;
                  }
                  Upp[numU++]=r->top;
                }
              }
            }
            //==ðåâèçèÿ b1 äåëàåì ëèøü ïî ïåðâîé àëüòåð.,ò.ê. çàãëàâ.áóêâ ìàëî==
            if(IsB1(a) && (!FeatLet[a].ImUppLow || FeatLet[a].Chif) &&
               abs(rS->left-r->top) > 1)
            { if(numB1 >= maxB1)
              { int MaxOld=maxB1*sizeof(int); maxB1*=2;
                if((arrB1=(int*)realloc_m(arrB1,MaxOld,maxB1*sizeof(int)))==NULL)return NOT_ALLOC;
              }
              arrB1[numB1++]=r->top;
            }
        } }
      sig=0;
      if(numL > 5)
      { med=1; Statist(Low,numL,&ave,&sig,&med,&mod,0);
        StatCol[nc].stat_str[ns].dy=med;
      }
      else
				StatCol[nc].stat_str[ns].dy=StatCol[nc].dy_Low;
      #ifdef DRAWxxxx
      if(viz && (numU || numB1))
      { clear(); rr.left=32000;rr.top=32000;rr.right=-32000;rr.bottom=-32000;
        for(nw=0; nw < TitleStr[nc][ns].S_Gen.S_NumWord; ++nw)
          { for(nz=0; nz < TitleWord[nc][ns][nw].W_Gen.W_NumSym; ++nz)
            { rr.left  =MIN(rr.left  ,Zn[nc][ns][nw][nz].Title.Z_Rect.left  );
              rr.top   =MIN(rr.top   ,Zn[nc][ns][nw][nz].Title.Z_Rect.top   );
              rr.right =MAX(rr.right ,Zn[nc][ns][nw][nz].Title.Z_Rect.right );
              rr.bottom=MAX(rr.bottom,Zn[nc][ns][nw][nz].Title.Z_Rect.bottom);
            }
          }
        rr.top=MIN(rr.top,rS->top); rr.top-=30;
        rr.bottom=MAX(rr.bottom,rS->bottom); rr.bottom+=30;
        BoundsRect(0,(RECT*)&rr,0);
        for(nw=0; nw < TitleStr[nc][ns].S_Gen.S_NumWord; ++nw)
        { for(nz=0; nz < TitleWord[nc][ns][nw].W_Gen.W_NumSym; ++nz)
              image_rect((RECT*)&Zn[nc][ns][nw][nz].Title.Z_Rect,9,0xFFFF,_GBORDER);
        }
        { struct {int b1,b2,b3,b4;} bl; memcpy(&bl,rS,8);
          setcol(10);vector_w(rr.left,bl.b1,rr.right,bl.b1);pause();
          setcol(11);vector_w(rr.left,bl.b2,rr.right,bl.b2);pause();
          setcol(13);vector_w(rr.left,bl.b4,rr.right,bl.b4);pause();
          setcol(12);vector_w(rr.left,bl.b3,rr.right,bl.b3);pause();
        }
      }
      #endif
      if(numU) //ðåâèçèÿ ëèíåéêè b2
      { med=1; Statist(Upp,numU,&ave,&sig,&med,&mod,0);
        #ifdef DRAWxxx
          if(viz){setcol(14);vector_w(rr.left,med,rr.right,med);pause();}
        #endif
        rS->top=med;
      }
      if(numB1) //ðåâèçèÿ ëèíåéêè b2
      { med=1; Statist(arrB1,numB1,&ave,&sig,&med,&mod,0);
        #ifdef DRAWxxx
          if(viz){setcol(15);vector_w(rr.left,med,rr.right,med);pause();}
        #endif
        rS->left=med;//?èëè òîëüêî åñëè med < old b1?
      }
    }
  }
  free(Upp);
  free(Low);
  free(arrB1);
  return 0;
}

//Ôîðìàò ôàéëà:
//Int16 ScanResolution
//Int16 NumCol,NumZ,NumW,NumS - ÷èñëà êîëîíîê, çíàêîìåñò, ñëîâ è ñòðîê in all page
//Int16 MonoSpaceAllPage - distance between left margin letters-neighdoors from one word
//Int16 HeiStrAllPage - distance between top margin
//Fragm[0], ..., Fragm[NumCol-1] ôðàãìåíòû
//  Fragm[nf]: îäèí ôðàãìåíò
//    Rect16 RectFragm
//    Int16  NumStr ÷èñëî ñòðîê
//    Str[0], ..., Str[NumStr-1] ñòðîêè
//      Str[nf][ns]:
//        Rect16 S_Rect // 4 base lines
//        Int16  NumWordStr; ÷èñëî ñëîâ òåêóùåé ñòðîêè
//        Word[0], ..., Word[NumWordStr-1] ñëîâà
//          Word[nf][ns][nw]: îäíî ñëîâî
//            Int16 NumSym ÷èñëî çíàêîìåñò ñëîâà (ïðîáåëîâ íåò)
//            Sym[0], ..., Sym[NumSym-1] çíàêîìåñòà
//              Sym[nf][ns][nw][nz]:
//                Rect16 Z_Rect     ðàìêà çíàêîìåñòà
//                Int16  NumAlt     ÷èñëî àëüòåðíàòèâ
//                Alt[0], ..., Alt[NumAlt-1] àëüòåðíàòèâû
//                  Alt[nf][ns][nw][nz][na] îäíà àëüòåðíàòèâà
//                    BYTE Code êîä
//                    BYTE Prob  âåðîÿòíîñòü
//                    BYTE Spell check end string for -
//                    BYTE Base  base number ÷òîáû çàäàâàòü øðèôòû äëÿ òàáëèöû øðèôòîâ RTF (ñåìåéñòâî + èìÿ)

// -------  paragraphs mark --------
//if(BEG_PARAG1(Zn[nc][ns][0][0].Title.Z_Id) == 1 ||
//  (Zn[nc][ns][0][0].Title.Z_Num_Alt==1 &&
//   Zn[nc][ns][0][0].Alt[0].a_Code=='#') )
//     ++k_parag[nc];


extern Rect16  *RectFragm;
extern float    Twips;
extern Int16   K_TwipsInInch;

short __cdecl  OpenFullOutTiger(FILE *in)
{
	int nc,ns,nw,nz,k_word,k_z,i;
#ifdef alDebug
	if(dets)	{ ConsMess("OpenFullOutTiger Begin "); }
#endif

	rewind(in);

 fread(&ScanResolution,sizeof(WORD),1,in);
 fread(&NumCol,sizeof(WORD),1,in);
 fread(&NumZ,sizeof(WORD),1,in);
 fread(&NumW,sizeof(WORD),1,in);
 fread(&NumS,sizeof(WORD),1,in);

#ifdef alDebug
		if(dets)	{ ConsMess("OpenFullOutTiger ScanResolution=%d ",ScanResolution); }
		if(dets)	{ ConsMess("OpenFullOutTiger NumCol=%d ",NumCol); }
		if(dets)	{ ConsMess("OpenFullOutTiger NumZ=%d ",NumZ); }
		if(dets)	{ ConsMess("OpenFullOutTiger NumW=%d ",NumW); }
		if(dets)	{ ConsMess("OpenFullOutTiger NumS=%d ",NumS); }
#endif

 fread(&MonoSpaceAllPage,2,1,in);
 fread(&HeiStrAllPage,2,1,in);

 Twips = ((float)K_TwipsInInch)/ScanResolution;
// Twips = (float)((int)(Twips+0.5));
	if(NumCol)
	{
		NumStr    = (Int16*)malloc(NumCol*sizeof(Int16));
		StatCol   = (STAT_COL*)malloc(NumCol*sizeof(STAT_COL));
		if(NumStr==NULL||StatCol==NULL)
		{

#ifdef alDebug
		if(dets)	{ ConsMess("OpenFullOutTiger Memory str2367 Numstr,StatCol"); }
#endif
		goto BadReturn;
		}
	}
	else
	{
		NumStr    = NULL;
		StatCol   = NULL;
//#ifdef alDebug
//		if(dets)	{ ConsMess("OpenFullOutTiger  str2375 NumCol=0"); }
//#endif
  goto BadReturn;
	}

 BndCol     = (SRECT*)malloc(NumCol * sizeof(SRECT));
 UserNumber = (Word32*)malloc(NumCol*sizeof(Word32));
 FragFlag   = (Word32*)malloc(NumCol*sizeof(Word32));

 RectFragm = (Rect16*)malloc(NumCol*sizeof(Rect16));

 if(BndCol==NULL||UserNumber==NULL||RectFragm==NULL)
	{
#ifdef alDebug
		if(dets)	{ ConsMess("OpenFullOutTiger Memory str2385 BndCol,UserNumber,RectFragm"); }
#endif
  goto BadReturn;
	}
 // *********** ÐÀÑÑ×ÈÒÀÒÜ slope,SizeXGlob,SizeYGlob + OneColStat *********

	{
		int fl;                //---Calculate Common Size Section Zn---
  long lenZn,lenWord,lenStr,NumT=NumCol;
  if(NumT+NumS+NumW)
		{
			lenZn=(NumT+NumS+NumW)*sizeof(PTR)+NumZ*sizeof(ZN);
			lenWord=(NumT+NumS)*sizeof(PTR)+NumW*sizeof(TITLE_WORD);
			lenStr=NumT*sizeof(PTR)+NumS*sizeof(TITLE_STR);
			if((fl=InitSubAlloc(2*(lenZn+lenWord+lenStr)+10000,&SubZn)))
			{
#ifdef alDebug
  		if(dets)	{ ConsMess("OpenFullOutTiger str2400 InitSubAlloc"); }
#endif
				goto BadReturn;
			}
		}
	}

  if(NumCol)
		{
			Zn=(ZN****)Submalloc(NumCol*sizeof(ZN***),&SubZn);
			TitleStr=(TITLE_STR**)Submalloc(NumCol*sizeof(TITLE_STR*),&SubZn);
			TitleWord=(TITLE_WORD***)Submalloc(NumCol*sizeof(TITLE_WORD**),&SubZn);
			if(Zn==NULL||TitleStr==NULL||TitleWord==NULL)
			{
#ifdef alDebug
  		if(dets)	{ ConsMess("OpenFullOutTiger Memory str2413 Zn,TitleStr,TitleWord"); }
#endif
				goto BadReturn;
			}
		}

 for(nc=0; nc < NumCol; ++nc)
	{
  fread(&RectFragm[nc],1,sizeof(Rect16),in);
	 // *********** ÐÀÑ×ÅÒ ÊÎËÎÍÍÎÉ ÑÒÀÒÈÑÒÈÊÈ *************
  fread(&NumStr[nc],sizeof(Int16),1,in);
  fread(&UserNumber[nc],sizeof(Word32),1,in);
  fread(&FragFlag[nc],sizeof(Word32),1,in);

  Zn[nc]=(ZN***)Submalloc((NumStr[nc])*sizeof(ZN**),&SubZn);
  TitleStr[nc]=(TITLE_STR*)Submalloc((NumStr[nc])*sizeof(TITLE_STR),&SubZn);
  TitleWord[nc]=(TITLE_WORD**)Submalloc((NumStr[nc])*sizeof(TITLE_WORD*),&SubZn);
  if(Zn[nc]==NULL||TitleStr[nc]==NULL||TitleWord[nc]==NULL)
   goto BadReturn;
  --NumStr[nc];

		for(ns=0; ns <= NumStr[nc]; ++ns)
		{
			TITLE_STR *t = &TitleStr[nc][ns];
			Int16        tmp;

			t->Z_Code = 2;
			t->S_Attr = 0;

			//fread_m(&t->S_Rect,sizeof(SRECT),1,in);             // 4 base lines,?
			readSRECT(&t->S_Rect, in);
			//exchange : top,bottom - standard, left,right - extern
			tmp              = t->S_Rect.right;
			t->S_Rect.right  = t->S_Rect.bottom;
			t->S_Rect.bottom = tmp;
			//Ðåàëüíûå êîîð. ñòðîêè!
			//fread_m(&t->S_Real_Rect,sizeof(SRECT),1,in);
			readSRECT(&t->S_Real_Rect, in);
			fread(&tmp,2,1,in);
			t->S_Gen.S_NumWord = tmp;               // NumWrd

			fread(&t->S_Flags,sizeof(t->S_Flags),1,in); //NEGA_STR

			t->S_Gen.HeadLine = 0; // zero HeadLine
			k_word            = TitleStr[nc][ns].S_Gen.S_NumWord-1;
			Zn[nc][ns]        = (ZN**)        Submalloc((k_word+1)*sizeof(ZN*),&SubZn);
			TitleWord[nc][ns] = (TITLE_WORD*) Submalloc((k_word+1)*sizeof(TITLE_WORD),&SubZn);
			if(Zn[nc][ns] == NULL || TitleWord[nc][ns] == NULL)
				goto BadReturn;

 			for(nw=0; nw <= k_word; ++nw)
			{
				TITLE_WORD *tw=&TitleWord[nc][ns][nw];

				tw->Z_Code=1;
				fread(&tmp, sizeof(Int16), 1, in);
				tw->W_Gen.W_NumSym=tmp;// NumZn
				k_z=tw->W_Gen.W_NumSym-1;

				fread(&tmp, sizeof(Int16), 1, in);
				tw->W_Gen.FontNumber=(WORD)tmp;

				fread(&tmp, sizeof(Int16), 1, in);
				tw->W_Gen.FontSize=(WORD)tmp;

				if((Zn[nc][ns][nw]=(ZN*)Submalloc((k_z+1)*sizeof(ZN),&SubZn))==NULL)
					goto BadReturn;

				for(nz=0; nz <= k_z; ++nz)
				{
					ZN        *z  = &Zn[nc][ns][nw][nz];
					TITLE_ZN  *tz = &z->Title;
					Int16     num;
#pragma pack(1)
					//   struct RECT_TIGER {int top,left,bottom,right;} rect;
					struct ALT_TIGER1  {unsigned char let, prob;} alt1;
					struct ALT_TIGER2  {unsigned char language, spellnocarrying, FlagCapDrop, spell, base;} alt2;
#pragma pack()

					//fread_m(&tz->Z_Rect,sizeof(SRECT),1,in); // BOX
					readSRECT(&tz->Z_Rect, in);
					//fread_m(&tz->Z_RealRect,sizeof(SRECT),1,in); // Real BOX
					readSRECT(&tz->Z_RealRect, in);

					fread(&num, sizeof(Int16), 1, in);  tz->Z_Num_Alt=(BYTE)MIN(num,REC_MAX_VERS); //NumAlt
//					if(num > 1)
//						num = 1;

					tz->Z_Code     = 0;
					tz->Z_Id.col   = nc+1;
					tz->Z_Id.str   = ns+1;
					tz->Z_Id.comp  = nz+1;
					tz->Z_Id.word  = 0;
					for ( i = 0; i < num; i++ )
					{
						fread(&alt1,sizeof(struct ALT_TIGER1),1,in);
						if(i < REC_MAX_VERS)
						{
							ALT_ZN *Alt =&z->Alt[i];
							Alt->a_Code =alt1.let;
							Alt->a_Prob =alt1.prob;
							Alt->a_Dist=(float)(alt1.prob/256.);
						}
					}
					fread(&alt2,sizeof(struct ALT_TIGER2),1,in);
					for ( i=0; i<tz->Z_Num_Alt;i++)
					{
						ALT_ZN *Alt =&z->Alt[i];
						Alt->a_Base =alt2.base;
						Alt->a_language =alt2.language;
						Alt->a_SpellNoCarrying=alt2.spellnocarrying;
						Alt->a_FlagCupDrop=alt2.FlagCapDrop;
						Alt->a_Spell=alt2.spell;
					}
				}
			}
		}
	}
	--NumCol;
#ifdef alDebug
	if(dets)	{ ConsMess("OpenFullOutTiger  End"); }
#endif
 return TRUE;
BadReturn:
#ifdef alDebug
	if(dets)	{ ConsMess("OpenFullOutTiger  End"); }
#endif
	return FALSE;

}

/*// !!! Art - óñòàðåëî
BYTE *AnsiOem,*OemAnsi;
void GenArrAnsiOem(void)
{ uint i;
  for(i=0; i < 256; ++i) AnsiOem[i]=OemAnsi[i]=(BYTE)i;
  AnsiOem[256]=OemAnsi[256]=0;
  #ifdef WIN_MOD
    AnsiToOem((char*)&AnsiOem[1],(char*)&AnsiOem[1]);
    OemToAnsi((char*)&OemAnsi[1],(char*)&OemAnsi[1]);
  #else
  #endif
}*/// !!! Art - óñòàðåëî
//===Êîððåêöèè Full Out
/*
int PASC CorrTiger(char *FileNameFul,char *FileNameOut,char *FilePar,int fl_cor)
//==
{ int fl;
  AnsiOem=(BYTE*)malloc(257); OemAnsi=(BYTE*)malloc(257);
  GenArrAnsiOem();
  #ifdef DRAW
    if(viz) viz=fl_cor;
  #endif
  if(fl_cor)
  {
		//if((fl=InitSpell(FilePar,3,PLAIN))!=0)
		//	return fl-50;
    //if((fl=Init_FeatLet()) != 0)
		//	return fl-100;
  }
  if((fl=OpenFullOutTiger(FileNameFul))!=0) return fl-150;
  if(fl_cor && (fl=CalcStatTiger())!=0) return fl-250;

	//if(fl_cor && (fl=CorrFul()) != 0) //Êîððåêòîð ïî îäíîðîäíîñòÿì
	//	return fl-200;
  //Ãåíåðàöèÿ âûõîä.ôàéëà Full-ôîðìàòà è òåêñòà
  SaveFullOutTiger(FileNameOut);
  free(AnsiOem); free(OemAnsi);
  return 0;
}
*/
#endif

//Îñâîáîæäåíèå ïàìÿòè, çàõâà÷åííîé ïîä ñåêöèè çíàêîìåñò è êîëîíîê .ful-ôàéëà
//================
int FreeStructFull(void)
//================
{ int kw=0,nc,ns=0,nw=0,sp=0,num=0,i=0;
  const char *err="FreeStructFull";
  #ifdef SUB_ZN
   do0(nc,0,NumCol)
   {
		if(StatCol[nc].stat_str) free(StatCol[nc].stat_str);

   }
	 free(StatCol);
	 DeleteSubAlloc(&SubZn);
  #else
   //---Ñåêöèÿ çíàêîìåñò---
   do0(nc,0,NumCol)
   {
		 if(StatCol[nc].stat_str) free(StatCol[nc].stat_str);
		 do0(ns,0,NumStr[nc])
     { kw=TitleStr[nc][ns].S_Gen.S_NumWord-1;
       do0(nw,0,kw)
       { free(Zn[nc][ns][nw]);
         if((sp=TitleWord[nc][ns][nw].W_Gen.W_Spell) == SPELL_CORR)
         {
           #ifndef FUL
             ERR(1,err);
           #endif
           if((num=TitleWord[nc][ns][nw].NumAltSpell) <= 0) ERR(1,err);
           do0(i,0,num-1) free(TitleWord[nc][ns][nw].AltSpell[i].Alt);
           free(TitleWord[nc][ns][nw].AltSpell);
         }
       }
       free(Zn[nc][ns]);
			 free(TitleWord[nc][ns]);
     }
     free(Zn[nc]);
		 free(TitleWord[nc]);
		 free(TitleStr[nc]);
   }
   free(Zn);
	 free(TitleWord);
	 free(TitleStr);
  #endif

  #ifdef CMP
    free(CoorComp);
  #endif
  #ifndef PROF_COL
  	free(BndCol);
  #else
  	//---Ñåêöèÿ êîëîíîê---
  	free(BndCol);
		free(NumStr);
		free(StatCol);
	  #ifndef TIGER_CORR
	  { int nlev; //Îñâîáîæäåíèå ïàìÿòè ïîä èåðàðõèþ êîëîíîê
	    do0(nlev,0,k_lev)
	    { do0(nc,0,k_col[nlev])
	        if(knot[nlev][nc].kp >= 0)
						free(knot[nlev][nc].Addr);
	      free(knot[nlev]);
	    }
	    free(knot);
	  }
		#endif
  #endif //PROF_COL
  //---Ñåêöèÿ èìåí áàç---
  #ifndef TIGER_CORR
  	free(FntName);
  #endif
  return 0;
}

#ifndef WIN_MOD

	#if 0
/* // !!! Art - óñòàðåëî

	#define REWIND 0
  #define REW_SECT 2
  #define NO_REWIND 1
  static int Regim=REWIND,flSect=1;
  FILE1 *f03; //Èíèöèàëèçèðóåòñÿ â InitParTabl
  char buf03[255];
  //Regim = NO_REWIND - áûñòðûé ââîä áåç ïîçèöèîíèðîâàíèÿ ê íà÷àëó ôàéëà
  //flSect â ýòîì ñëó÷àå íàäî óñòàíàâëèâàòü â "1" ïåðåä íà÷àëîì ââîäà
  //î÷åðåäíîé ñåêöèè
  //Êîìïëåêñ ô-öèé, ýìóëèðóþùèõ ðàáîòó ñ Private-ini-ôàéëàìè ïîä Windows
  char *fnexts_m(FILE1 *f, char *buf);

	static int findname(char *sect, char *key, char *res)
  {
		if(Regim==REWIND)
			    fseek_m(f03, 0l, SEEK_SET);

    while (fnexts_m(f03, buf03))
    { if (*buf03 == ';' || *buf03 == 0) ;
      else if (*buf03 == '[' && buf03[strlen(buf03)-1] == ']')
      { buf03[strlen(buf03)-1] = 0;
        if (strcmp(buf03+1, sect) == 0)
        { while (fnexts_m(f03, buf03))
          { if (*buf03 == ';' || *buf03 == 0) ;
            else if (*buf03 == '[') break;
            else if (buf03[strlen(key)] == '=')
            { buf03[strlen(key)] = 0;
              if (strcmp(buf03, key) == 0)
               {strcpy(res, buf03+strlen(key)+1); return 1;}
            }
          }
          return 0;
        }
      }
    }
    return 0;
  }
  static int findnameNoSect(char *sect, char *key, char *res)
  {
		while (fnexts_m(f03, buf03))
    { if (*buf03 == ';' || *buf03 == 0) ;
      else if (*buf03 == '[') break;
      else if (buf03[strlen(key)] == '=')
      { buf03[strlen(key)] = 0;
        if (strcmp(buf03, key) == 0)
         {strcpy(res, buf03+strlen(key)+1); return 1;}
      }
    }
    return 0;
  }
  static int GetPrivateProfileInt(char *sect, char *key, int def, char *name)
  { int ret = def;
    char buf[88];
    if(flSect || Regim==REWIND)
         {if (findname(sect, key, buf)) ret = atoi(buf);}
    else
         {if (findnameNoSect(sect, key, buf)) ret = atoi(buf);}
    return ret;
  }
  static int GetPrivateProfileString(char *sect, char *key, char *def, char *res,
         int maxsize, char *name)
  { strcpy(res, def);
    if(flSect || Regim==REWIND)
         {if (!findname(sect, key, res)) strcpy(res, def); }
    else {if (!findnameNoSect(sect, key, res)) strcpy(res, def);}
    return 0;
  }
*/ // !!! Art - óñòàðåëî
	#endif
#endif

#ifdef SPELL_NEW
/* // !!! Art - óñòàðåëî
  int b_close(void)
  { SpellClose(); LmClose(); }
  svocab far* PASC b_char(unsigned kod);
  int PASC GetWordOcr(WORD inst, WORD instb,WORD del,WORD  Else,WORD unknow,float delta1,ZN *zz,int kz);
  void PASC SetRegimDelta(int in,int Porog);
  void PASC SetTimerOwn(DWORD NumMs);
*/ // !!! Art - óñòàðåëî
#endif

#if !defined (LST_WWIN) && !defined (TIGER_CORR)
/*====*/
/* // !!! Art - óñòàðåëî
int statis(TYPE *arr,int n,TYPE *ave1,TYPE *sig1,TYPE *med,TYPE *mod,int regim)
//====
//åñëè regim > 0, óñåêàåì êðàÿ âûáîðêè âìåñòî [0,n] - [n/regim,n-n/regim]
{ int i; long ave=0,sig=0,work;

  u4sort(arr,n+1,sizeof(TYPE),(COMP_FUN)comp1); //ìåäèàíà
  if(regim) //îáðåçàåì êðàÿ âûáîðêè
  { int beg=n/regim; if((n-=2*beg)<0){n+=2*beg;goto m1;}
    if(beg) do0(i,0,n) arr[i]=arr[i+beg];
  }
  m1: *med=arr[n>>1];
  do0(i,0,n) ave+=arr[i]; ave/=(long)(n+1);
  do0(i,0,n)
  { work=arr[i]-ave;
    sig+=work*work;
  }
  sig=(long)sqrt(sig/(float)(n+1));
  *ave1=(TYPE)ave; *sig1=(TYPE)sig;
  return 0;
}
*/ // !!! Art - óñòàðåëî
#endif
//Áèáëèîòåêà çàïðîñîâ ê ôàéëó FULL OUT OCR CRIPT:
// - ×òåíèå file.ful â ðàáî÷èå ñòðóêòóðû
// - Êîíâåðòîð file.ful â file.txt ñ ó÷åòîì êîëîíîê è âûðàâíèâàíèåì â
//   êîëîíêàõ ïî LeftMargin è ò.ï.
//Ïðî÷èòàòü äàííûå èç ôàéëà FileName ôîðìàòà .ful âî âíåøíèå ðàáî÷èå ñòðóêòóðû
//Return:
//0  - íîðìàëüíîå çàâåðøåíèå,
//-1 - îøèáêà îòêðûòèÿ ôàéëà FileName,
//-3 - íåõâàòêà ïàìÿòè
//-5 - îøèáêà ñòðóêòóðû ôàéëà FileName,
//=============
/* // !!! Art - óñòàðåëî
int OpenFullOut(char *FileName)
//=============
{ FILE1 *in; int nc,ns,nw,nz,na,k_word,k_z,nc1,ns1,nci,nsi,i,j;
  int num,sp,Len,NumZ;
  long K_MultiComp=1000,NumW,NumS;
  if((in=fopen_m(FileName,OF_READ)) == NULL) return -1;
  //ÂÂÎÄ ÇÀÃÎËÎÂÊÀ ÔÀÉËÀ .ful
  fread_m(&TitleFul,sizeof(TITLE_FUL),1,in);
  #ifdef CMP
    CoorComp=(COOR_COMP*)malloc((K_MultiComp+1)*sizeof(COOR_COMP));
    NumComp=-1L;
  #endif
  #ifdef PROF_COL
  //ÂÂÎÄ ÑÅÊÖÈÈ ÊÎËÎÍÎÊ
  //---Òåðìèíàë. êîëîíêè---
  fseek_m(in,TitleFul.ColOffset,SEEK_SET);
  fread_m(&SizeSectionCol,sizeof(int),1,in);
  fread_m(&NumCol,sizeof(int),1,in);
  ++NumCol;
  BndCol=(SRECT*)malloc(NumCol*sizeof(SRECT));
  NumStr=(int*)malloc(NumCol*sizeof(int));
  StatCol=(STAT_COL*)malloc(NumCol*sizeof(STAT_COL));
  if(BndCol==NULL||NumStr==NULL||StatCol==NULL)return -3;
  fread_m(BndCol,NumCol*sizeof(SRECT),1,in);
  fread_m(NumStr,NumCol*sizeof(int),1,in);
  --NumCol;
  do0(nc,0,NumCol)
  { fread_m(&StatCol[nc].dx_col,sizeof(int),1,in);
    fread_m(&StatCol[nc].dy_col,sizeof(int),1,in);
    fread_m(&StatCol[nc].dsym_col,sizeof(int),1,in);
    fread_m(&StatCol[nc].dy_Upp,sizeof(int),1,in);
    fread_m(&StatCol[nc].dy_Low,sizeof(int),1,in);
  }
  { int nlev; //---Èåðàðõèÿ êîëîíîê---
    //×òåíèå çàãîëîâêà ST-ôàéëà
    fread_m(&len_col,sizeof(uint),1,in);
    fread_m(name,20,1,in); fl_EditStruct = (name[17]=='Y');
    fread_m(name1,LEN_PATH,1,in);
    fread_m(&k_lev,sizeof(int),1,in);
    do0(j,0,MAX_LEV)fread_m(&k_col[j],sizeof(int),1,in);
    fread_m(&k_colt,sizeof(int),1,in);fread_m(&slope,sizeof(int),1,in);
    fread_m(&k_frm,sizeof(int),1,in); fread_m(&space,sizeof(int),1,in);
    fread_m(&SizeXGlob,sizeof(int),1,in); fread_m(&SizeYGlob,sizeof(int),1,in);
    //k_colt1=-1;//ñ÷åò÷èê òåðìèíàë. êîëîíîê
    knot=(LEV**)malloc((k_lev+1)*sizeof(LEV*));
    do0(nlev,0,k_lev) //÷òåíèå äåðåâà êîëîíîê
    { knot[nlev]=(LEV*)malloc((k_col[nlev]+1)*sizeof(LEV));
      do0(nc,0,k_col[nlev])
      { fread_m(&knot[nlev][nc].bnd,sizeof(SRECT),1,in);
        fread_m(&knot[nlev][nc].SpecInt,sizeof(WORD),1,in);
        fread_m(&knot[nlev][nc].kp,sizeof(int),1,in);
        if(knot[nlev][nc].kp >= 0)
        { knot[nlev][nc].Addr=(ADDR*)malloc((knot[nlev][nc].kp+1)*sizeof(ADDR));
          do0(i,0,knot[nlev][nc].kp)
          { fread_m(&knot[nlev][nc].Addr[i].ind,sizeof(int),1,in);
            fread_m(&knot[nlev][nc].Addr[i].lev,sizeof(int),1,in);
          }
        }
      }
    }
  }
  #endif
  //ÂÂÎÄ ÑÅÊÖÈÈ ÈÌÅÍ ÁÀÇ
  fseek_m(in,TitleFul.FntNameOffset,SEEK_SET);
  SizeSectionFntName=(int)(TitleFul.ColOffset-TitleFul.FntNameOffset);//íà÷èíàÿ ñ 1
  if((FntName=malloc(SizeSectionFntName))==NULL) return NOT_ALLOC;
  fread_m(FntName,SizeSectionFntName,1,in);
  //ÂÂÎÄ ÑÅÊÖÈÈ ÇÍÀÊÎÌÅÑÒ
  fseek_m(in,TitleFul.ZOffset,SEEK_SET);
  #ifdef SUB_ZN
   { int fl;//---Calculate Common Size Section Zn---
     long lenZn,lenWord,lenStr,NumT=NumCol+1,NumS=TitleFul.nStr,NumW=TitleFul.nWord;
     lenZn=(NumT+NumS+NumW)*sizeof(PTR)+TitleFul.dNumZ*sizeof(ZN);
     lenWord=(NumT+NumS)*sizeof(PTR)+NumW*sizeof(TITLE_WORD);
     lenStr=NumT*sizeof(PTR)+NumS*sizeof(TITLE_STR);
     if((fl=InitSubAlloc(lenZn+lenWord+lenStr,&SubZn))) return fl-100;
   }
   Zn=(ZN****)Submalloc((NumCol+1)*sizeof(ZN***),&SubZn);
   TitleStr=(TITLE_STR**)Submalloc((NumCol+1)*sizeof(TITLE_STR*),&SubZn);
   TitleWord=(TITLE_WORD***)Submalloc((NumCol+1)*sizeof(TITLE_WORD**),&SubZn);
  #else
   Zn=(ZN****)malloc((NumCol+1)*sizeof(ZN***));
   TitleStr=(TITLE_STR**)malloc((NumCol+1)*sizeof(TITLE_STR*));
   TitleWord=(TITLE_WORD***)malloc((NumCol+1)*sizeof(TITLE_WORD**));
  #endif
  if(Zn==NULL||TitleStr==NULL||TitleWord==NULL)return -3;
  NumW=NumS=NumZ=0;
  do0(nc,0,NumCol)
  {
    #ifdef SUB_ZN
     Zn[nc]=(ZN***)Submalloc((NumStr[nc]+1)*sizeof(ZN**),&SubZn);
     TitleStr[nc]=(TITLE_STR*)Submalloc((NumStr[nc]+1)*sizeof(TITLE_STR),&SubZn);
     TitleWord[nc]=(TITLE_WORD**)Submalloc((NumStr[nc]+1)*sizeof(TITLE_WORD*),&SubZn);
    #else
     Zn[nc]=(ZN***)malloc((NumStr[nc]+1)*sizeof(ZN**));
     TitleStr[nc]=(TITLE_STR*)malloc((NumStr[nc]+1)*sizeof(TITLE_STR));
     TitleWord[nc]=(TITLE_WORD**)malloc((NumStr[nc]+1)*sizeof(TITLE_WORD*));
    #endif
    if(Zn[nc]==NULL||TitleStr[nc]==NULL||TitleWord[nc]==NULL)return -3;
    do0(ns,0,NumStr[nc])
    { if(!fread_m(&TitleStr[nc][ns],sizeof(TITLE_STR),1,in))
      { int NumC;
        if((NumStr[nc]=ns-1) < 0) NumC=nc-1; else NumC=nc;
        if(NumCol < 0)
        {
          #ifndef WIN_MOD
           printf("err -40");
          #endif
          return -40;
        }

        do0(nci,NumC+1,NumCol) //Ãåíåðàöèÿ ïðîïóù. õâîñòîâûõ êîëîíîê
        { TITLE_STR *ts=&TitleStr[nci][0];TITLE_WORD *tw=&TitleWord[nci][0][0];
          TITLE_ZN *tz=&Zn[nci][0][0][0].Title;ALT_ZN *Alt=Zn[nci][0][0][0].Alt;
          NumStr[nci]=0;
          #ifdef SUB_ZN
           Zn[nci]=(ZN***)Submalloc((NumStr[nci]+1)*sizeof(ZN**),&SubZn);
           TitleStr[nci]=(TITLE_STR*)Submalloc((NumStr[nci]+1)*sizeof(TITLE_STR),&SubZn);
           TitleWord[nci]=(TITLE_WORD**)Submalloc((NumStr[nci]+1)*sizeof(TITLE_WORD*),&SubZn);
          #else
           Zn[nci]=(ZN***)malloc((NumStr[nci]+1)*sizeof(ZN**));
           TitleStr[nci]=(TITLE_STR*)malloc((NumStr[nci]+1)*sizeof(TITLE_STR));
           TitleWord[nci]=(TITLE_WORD**)malloc((NumStr[nci]+1)*sizeof(TITLE_WORD*));
          #endif
          if(Zn[nci]==NULL||TitleStr[nci]==NULL||TitleWord[nci]==NULL)return -3;
          ts->Z_Code=2;ts->S_Gen.S_NumWord=1;ts->S_Rect=BndCol[nci];
          //ts->S_Rect.left=32000;
          k_word=0;
          #ifdef SUB_ZN
           Zn[nci][0]=(ZN**)Submalloc((k_word+1)*sizeof(ZN*),&SubZn);
           TitleWord[nci][0]=(TITLE_WORD*)Submalloc((k_word+1)*sizeof(TITLE_WORD),&SubZn);
          #else
           Zn[nci][0]=(ZN**)malloc((k_word+1)*sizeof(ZN*));
           TitleWord[nci][0]=(TITLE_WORD*)malloc((k_word+1)*sizeof(TITLE_WORD));
          #endif
          if(Zn[nci][0]==NULL||TitleWord[nci][0]==NULL)return -3;
          tw->Z_Code=1;tw->W_Gen.W_NumSym=1;tw->W_Gen.W_Spell=SPELL_NOT;
          tw->NumAltSpell=0;//tw->W_Rect=BndCol[nci];
          #ifdef SUB_ZN
           if((Zn[nci][0][0]=(ZN*)Submalloc(sizeof(ZN),&SubZn))==NULL)return -3;
          #else
           if((Zn[nci][0][0]=(ZN*)malloc(sizeof(ZN)))==NULL)return -3;
          #endif
          tz->Z_Code=0;tz->Z_Id.col=(CONV)(nci+1);tz->Z_Id.str=(CONV)1;
          tz->Z_Id.comp=(CONV)1;tz->Z_Id.word=(CONV)1;tz->Z_Rect=BndCol[nci];
          tz->Z_Num_Alt=1;tz->Z_NumComp=0;//tz->Z_Rect.left=32000;
          Alt->a_Code='$';
					Alt->a_Base=0;
					Alt->a_Dist=(float)0;
        }
        #ifndef WIN_MOD
          printf("\nEOF1 nc=%d ns=%d",nc,ns);getchW();
        #endif
        goto end;
      }
      if(TitleStr[nc][ns].Z_Code != 2)
      { NumCol=nc;NumStr[nc]=ns-1;
        //fread_m(&TitleStr[nc][ns+1],sizeof(TITLE_STR),1,in);
        #ifndef WIN_MOD
          printf("\nERROR39 STR nc=%d ns=%d",nc,ns);
          //printf("\nZZ=%d ZZ+1=%d",TitleStr[nc][ns].Z_Code,TitleStr[nc][ns+1].Z_Code);
        #endif
        if(!nc && !ns) return -39;
        goto end;
      }
      k_word=TitleStr[nc][ns].S_Gen.S_NumWord-1;
      if(k_word>100)
      {
        #ifndef WIN_MOD
         printf("err -41");
        #endif
        return -41;
      }
      if(k_word < 0) //Ïóñòàÿ ñòðîêà
      {
        #ifndef WIN_MOD
         printf("\nEMPTY STRING");
        #else
         //MessageBox(NULL,"EMPTY STRING", "", MB_OK);
        #endif
        #ifndef SUB_ZN
          Zn[nc][ns]=TitleWord[nc][ns]=NULL;
        #endif
        continue;
      }
      ++NumS;
      #ifdef SUB_ZN
       Zn[nc][ns]=(ZN**)Submalloc((k_word+1)*sizeof(ZN*),&SubZn);
       TitleWord[nc][ns]=(TITLE_WORD*)Submalloc((k_word+1)*sizeof(TITLE_WORD),&SubZn);
      #else
       Zn[nc][ns]=(ZN**)malloc((k_word+1)*sizeof(ZN*));
       TitleWord[nc][ns]=(TITLE_WORD*)malloc((k_word+1)*sizeof(TITLE_WORD));
      #endif
      if(Zn[nc][ns]==NULL||TitleWord[nc][ns]==NULL)return -3;
      do0(nw,0,k_word)
      { TITLE_WORD *tw=&TitleWord[nc][ns][nw];
        if(!fread_m(tw,sizeof(TITLE_WORD),1,in))
        { if((NumStr[nc]=ns-1) < 0) NumCol=nc-1; else NumCol=nc;
          if(NumCol < 0)
          {
            #ifndef WIN_MOD
             printf("err -43");
            #endif
            return -43;
          }
          #ifndef WIN_MOD
            printf("\nEOF2");getchW();
          #endif
          goto end;
        }
        if(tw->Z_Code != 1)
        { //if(!fl_str || tw->Z_Code != 2)
          { NumCol=nc;NumStr[nc]=ns-1;
            #ifndef WIN_MOD
              printf("\nERROR WRD");getchW();
            #endif
            if(!nc && !ns) return -49;
            goto end;
          }
        }
        ++NumW;
        if((sp=tw->W_Gen.W_Spell) == SPELL_CORR)
        { if((num=tw->NumAltSpell) <= 0) return -11;
          #ifndef SUB_ZN
           if((tw->AltSpell=(ALT_SPELL*)malloc(num*sizeof(ALT_SPELL)))==NULL)return -3;
          #else
           if((tw->AltSpell=(ALT_SPELL*)Submalloc(num*sizeof(ALT_SPELL),&SubZn))==NULL)return -3;
          #endif
          do0(i,0,num-1)
          { BYTE w; ALT_SPELL *AltS=&tw->AltSpell[i];
            fread_m(&AltS->Len,sizeof(BYTE),1,in);
            fread_m(&w,sizeof(BYTE),1,in);fread_m(&AltS->Penalty,sizeof(WORD),1,in);
            Len=(int)AltS->Len;
            #ifndef SUB_ZN
             if((AltS->Alt=(char*)malloc(Len))==NULL)return NOT_ALLOC;
            #else
             if((AltS->Alt=(char*)Submalloc(Len,&SubZn))==NULL)return NOT_ALLOC;
            #endif
            fread_m(AltS->Alt,Len,1,in);
          }
        }
        k_z=tw->W_Gen.W_NumSym-1;
        if(k_z<0 ||  k_z>100)
        { if((NumStr[nc]=ns-1) < 0) NumCol=nc-1; else NumCol=nc;
          if(NumCol < 0)
          {
            #ifndef WIN_MOD
             printf("err -45");
            #endif
            return -45;
          }
          #ifndef WIN_MOD
           printf("\nerr -42 k_z=%d",k_z);
          #endif
          goto end;
        }
        #ifdef SUB_ZN
         if((Zn[nc][ns][nw]=(ZN*)Submalloc((k_z+1)*sizeof(ZN),&SubZn))==NULL)return -3;
        #else
         if((Zn[nc][ns][nw]=(ZN*)malloc((k_z+1)*sizeof(ZN)))==NULL)return -3;
        #endif
        do0(nz,0,k_z)
        { ZN *z=&Zn[nc][ns][nw][nz]; TITLE_ZN *tz=&z->Title;
          if(!fread_m(tz,TitleFul.wZHSize,1,in))
          { if((NumStr[nc]=ns-1) < 0) NumCol=nc-1; else NumCol=nc;
            if(NumCol < 0)
            {
              #ifndef WIN_MOD
               printf("err -44");
              #endif
              return -44;
            }
            #ifndef WIN_MOD
              printf("\nEOF3");getchW();
            #endif
            goto end;
          }
          ++NumZ;
          if(tz->Z_Code != 0)
          { NumCol=nc;NumStr[nc]=ns-1;
            #ifndef WIN_MOD
              printf("\nERROR SYM");
            #endif
            goto end;
          }
          nc1=tz->Z_Id.col-1; ns1=tz->Z_Id.str-1;
          if((nc1 != nc || (ns1 != ns && nc==0)) &&
           TitleFul.ProcSpell != PROC_SPELL && TitleFul.ProcSpell != PROC_OPEN)
          {
            #ifndef WIN_MOD
              printf("\nERROR SYM1 Id.col=%d nc=%d",Zn[nc][ns][nw][nz].Title.Z_Id.col-1,nc);
              printf("\nns=%d ns1=%d",ns,ns1);
            #endif
            if(nc==0&&ns==0) //Íå ñ ïåðâîé êîëîíêè èëè â ïåðâîé êîëîíêå íå ñ ïåðâîé str
            {
              #ifndef WIN_MOD
              printf("\nBegin Middle");
              #endif
              do0(j,0,ns)
              { do0(i,0,k_word) free(Zn[nc][j][i]);
                free(Zn[nc][j]); free(TitleWord[nc][j]);
              }
              free(Zn[nc]); free(TitleWord[nc]); free(TitleStr[nc]);
              do0(nci,0,nc1-1)//Ãåíåðàöèÿ ïðîïóù.êîëîíîê
              { TITLE_STR *ts=&TitleStr[nci][0];TITLE_WORD *tw=&TitleWord[nci][0][0];
                TITLE_ZN *tz=&Zn[nci][0][0][0].Title;ALT_ZN *Alt=&Zn[nci][0][0][0].Alt[0];
                NumStr[nci]=0;
                #ifdef SUB_ZN
                 Zn[nci]=(ZN***)Submalloc((NumStr[nci]+1)*sizeof(ZN**),&SubZn);
                 TitleStr[nci]=(TITLE_STR*)Submalloc((NumStr[nci]+1)*sizeof(TITLE_STR),&SubZn);
                 TitleWord[nci]=(TITLE_WORD**)Submalloc((NumStr[nci]+1)*sizeof(TITLE_WORD*),&SubZn);
                #else
                 Zn[nci]=(ZN***)malloc((NumStr[nci]+1)*sizeof(ZN**));
                 TitleStr[nci]=(TITLE_STR*)malloc((NumStr[nci]+1)*sizeof(TITLE_STR));
                 TitleWord[nci]=(TITLE_WORD**)malloc((NumStr[nci]+1)*sizeof(TITLE_WORD*));
                #endif
                if(Zn[nci]==NULL||TitleStr[nci]==NULL||TitleWord[nci]==NULL)return -3;
                ts->Z_Code=2;ts->S_Gen.S_NumWord=1;ts->S_Rect=BndCol[nci];
                k_word=0; //ts->S_Rect.left=32000;
                #ifdef SUB_ZN
                 Zn[nci][0]=(ZN**)Submalloc((k_word+1)*sizeof(ZN*),&SubZn);
                 TitleWord[nci][0]=(TITLE_WORD*)Submalloc((k_word+1)*sizeof(TITLE_WORD),&SubZn);
                #else
                 Zn[nci][0]=(ZN**)malloc((k_word+1)*sizeof(ZN*));
                 TitleWord[nci][0]=(TITLE_WORD*)malloc((k_word+1)*sizeof(TITLE_WORD));
                #endif
                if(Zn[nci][0]==NULL||TitleWord[nci][0]==NULL)return -3;
                tw->Z_Code=1;tw->W_Gen.W_NumSym=1;tw->W_Gen.W_Spell=SPELL_NOT;
                tw->NumAltSpell=0; //tw->W_Rect=BndCol[nci];
                #ifdef SUB_ZN
                 if((Zn[nci][0][0]=(ZN*)Submalloc(sizeof(ZN),&SubZn))==NULL)return -3;
                #else
                 if((Zn[nci][0][0]=(ZN*)malloc(sizeof(ZN)))==NULL)return -3;
                #endif
                tz->Z_Code=0;tz->Z_Id.col=(CONV)(nci+1);tz->Z_Id.str=(CONV)1;
                tz->Z_Id.comp=(CONV)1;tz->Z_Id.word=(CONV)1;tz->Z_Rect=BndCol[nci];
                tz->Z_NumComp=0;tz->Z_Num_Alt=1;//tz->Z_Rect.left=32000;
                Alt->a_Code='$';Alt->a_Base=0;Alt->a_Dist=(float)0;
              }
              #ifdef SUB_ZN
               Zn[nc1]=(ZN***)Submalloc((NumStr[nc1]+1)*sizeof(ZN**),&SubZn);
               TitleStr[nc1]=(TITLE_STR*)Submalloc((NumStr[nc1]+1)*sizeof(TITLE_STR),&SubZn);
               TitleWord[nc1]=(TITLE_WORD**)Submalloc((NumStr[nc1]+1)*sizeof(TITLE_WORD*),&SubZn);
              #else
               Zn[nc1]=(ZN***)malloc((NumStr[nc1]+1)*sizeof(ZN**));
               TitleStr[nc1]=(TITLE_STR*)malloc((NumStr[nc1]+1)*sizeof(TITLE_STR));
               TitleWord[nc1]=(TITLE_WORD**)malloc((NumStr[nc1]+1)*sizeof(TITLE_WORD*));
              #endif
              if(Zn[nc1]==NULL||TitleStr[nc1]==NULL||TitleWord[nc1]==NULL)return -3;
              do0(nsi,0,ns1-1)//ãåíåðàöèÿ ïðîïóù. ñòðîê òåêóù. êîëîíêè
              { TITLE_STR *ts=&TitleStr[nc1][nsi];TITLE_WORD *tw=&TitleWord[nc1][nsi][0];
                TITLE_ZN *tz=&Zn[nc1][nsi][0][0].Title;ALT_ZN *Alt=&Zn[nc1][nsi][0][0].Alt[0];
                ts->Z_Code=2;ts->S_Gen.S_NumWord=1;ts->S_Rect=BndCol[nc1];
                k_word=0; //ts->S_Rect.left=32000;
                #ifdef SUB_ZN
                 Zn[nc1][nsi]=(ZN**)Submalloc((k_word+1)*sizeof(ZN*),&SubZn);
                 TitleWord[nc1][nsi]=(TITLE_WORD*)Submalloc((k_word+1)*sizeof(TITLE_WORD),&SubZn);
                #else
                 Zn[nc1][nsi]=(ZN**)malloc((k_word+1)*sizeof(ZN*));
                 TitleWord[nc1][nsi]=(TITLE_WORD*)malloc((k_word+1)*sizeof(TITLE_WORD));
                #endif
                if(Zn[nc1][nsi]==NULL||TitleWord[nc1][nsi]==NULL)return -3;
                tw->Z_Code=1;tw->W_Gen.W_NumSym=1;tw->W_Gen.W_Spell=SPELL_NOT;
                tw->NumAltSpell=0; //tw->W_Rect=BndCol[nc1];
                #ifdef SUB_ZN
                 if((Zn[nc1][nsi][0]=(ZN*)Submalloc(sizeof(ZN),&SubZn))==NULL)return -3;
                #else
                 if((Zn[nc1][nsi][0]=(ZN*)malloc(sizeof(ZN)))==NULL)return -3;
                #endif
                tz->Z_Code=0;tz->Z_Id.col=(CONV)(nc1+1);tz->Z_Id.str=(CONV)(nsi+1);
                tz->Z_Id.comp=(CONV)1;tz->Z_Id.word=(CONV)1;tz->Z_Rect=BndCol[nc1];
                tz->Z_Num_Alt=1;tz->Z_NumComp=0; //tz->Z_Rect.left=32000;
                Alt->a_Code='#';Alt->a_Base=0;Alt->a_Dist=(float)0;
              }
              nc=nc1;ns=ns1-1;
              fseek_m(in,-3L*(long)(TitleFul.wZHSize),SEEK_CUR);
              goto end_str;
            }
            { if(nc1 < nc || nc1-nc != 1)
              { if(ns1 <= ns) return -12;
                else //Ãåíåðàöèÿ ïðîïóù. ñòðîê
                { //if(nw != 0 || nz != 0)
                  //{
                  //  #ifndef WIN_MOD
                  //   printf("\nnw=%d nz=%d",nw,nz);
                  //  #endif
                  //  return -13;
                  //}
                  if(ns1 > NumStr[nc]) return -17;
                  TitleStr[nc][ns1]=TitleStr[nc][ns];
                  TitleWord[nc][ns1]=TitleWord[nc][ns];
                  TitleWord[nc][ns1][0]=TitleWord[nc][ns][0];
                  Zn[nc][ns1]=Zn[nc][ns];
                  Zn[nc][ns1][0]=Zn[nc][ns][0];
                  Zn[nc][ns1][0][0].Title=Zn[nc][ns][0][0].Title;
                  do0(nsi,ns,ns1-1)
                  { TITLE_STR *ts=&TitleStr[nc][nsi];TITLE_WORD *tw=&TitleWord[nc][nsi][0];
                    TITLE_ZN *tz=&Zn[nc][nsi][0][0].Title;ALT_ZN *Alt=&Zn[nc][nsi][0][0].Alt[0];
                    ts->Z_Code=2;ts->S_Gen.S_NumWord=1;ts->S_Rect=BndCol[nc];
                    //ts->S_Rect.left=32000;
                    #ifdef SUB_ZN
                     Zn[nc][nsi]=(ZN**)Submalloc(sizeof(ZN*),&SubZn);
                     TitleWord[nc][nsi]=(TITLE_WORD*)Submalloc(sizeof(TITLE_WORD),&SubZn);
                    #else
                     Zn[nc][nsi]=(ZN**)malloc(sizeof(ZN*));
                     TitleWord[nc][nsi]=(TITLE_WORD*)malloc(sizeof(TITLE_WORD));
                    #endif
                    if(Zn[nc][nsi]==NULL||TitleWord[nc][nsi]==NULL)return -3;
                    tw->Z_Code=1;tw->W_Gen.W_NumSym=1;tw->W_Gen.W_Spell=SPELL_NOT;
                    tw->NumAltSpell=0;//tw->W_Rect=BndCol[nc];
                    #ifdef SUB_ZN
                     if((Zn[nc][nsi][0]=(ZN*)Submalloc(sizeof(ZN),&SubZn))==NULL)return -3;
                    #else
                     if((Zn[nc][nsi][0]=(ZN*)malloc(sizeof(ZN)))==NULL)return -3;
                    #endif
                    tz->Z_Code=0;tz->Z_Id.col=(CONV)(nc+1);tz->Z_Id.str=(CONV)(nsi+1);
                    tz->Z_Id.comp=(CONV)1;tz->Z_Id.word=(CONV)1;tz->Z_Rect=BndCol[nc];
                    tz->Z_Num_Alt=1;tz->Z_NumComp=0; //tz->Z_Rect.left=32000;
                    Alt->a_Code='*';Alt->a_Base=0;Alt->a_Dist=(float)0;
                  }
                  ns=ns1; goto alt;
                }
              }
              if(nw != 0 || nz != 0) return -13;
              --NumStr[nc];
              fseek_m(in,-3L*(long)(TitleFul.wZHSize),SEEK_CUR);
              #ifndef SUB_ZN
               free(Zn[nc][ns][nw]);free(Zn[nc][ns]);free(TitleWord[nc][ns]);
              #endif
              goto end_col;
            }
          }
          alt:
          #ifdef CMP
          { int NumC=tz->Z_NumComp-1;
            if(!NumC) //Îäíîñâÿçíûé ÷àùå âñåãî
            { if(!fread_m(tz->CoorComp.start_pos,LEN_START,1,in)||
                 !fread_m(&tz->CoorComp.lenght,sizeof(int),1,in))
                   return -42;
               //{ long ww=0;
               //  memmove_m(&ww,tz->CoorComp.start_pos,3);
               //  ww=ww;
               //}
            }
            else if(NumC > 0)//Ìíîãîñâÿçíûé
            { long w=NumComp+1;
              memmove_m(tz->CoorComp.start_pos,&w,3);
              do0(i,0,NumC)
              { if(++NumComp > K_MultiComp) return -43;
                if(!fread_m(CoorComp[NumComp].start_pos,LEN_START,1,in)||
                   !fread_m(&CoorComp[NumComp].lenght,sizeof(int),1,in))
                     return -44;
              }
            }
            else return -41;
          }
          #endif
          { int ka=tz->Z_Num_Alt-1,ii;
            float Dmin;
            ALT_ZN Alt,*AltZ=Zn[nc][ns][nw][nz].Alt;
            na=-1;
            do0(i,0,ka)
            { if(!fread_m(&Alt,sizeof(ALT_ZN),1,in))
              {
                #ifndef WIN_MOD
                  printf("\nEOF4");
                #endif
                goto end;
              }
              if(na < REC_MAX_VERS-1)
              { do0(ii,0,na) //Ôèëüòðàöèÿ ñîâïàäàþùèõ àëüòåðíàòèâ
                  if(AltZ[ii].a_Code == Alt.a_Code) goto end_alt;
                AltZ[++na]=Alt;
                end_alt: continue;
              }
            }
            tz->Z_Num_Alt=(BYTE)(na+1);
            if(na > 0) //Ïåðåìåùåíèå Alt-âû ñ min Dist ââåðõ
            { Dmin=AltZ[0].a_Dist; ii=0;
              do0(i,1,na)
               { if(AltZ[i].a_Dist < Dmin) {Dmin=AltZ[i].a_Dist; ii=i;} }
              if(ii) { Alt=AltZ[0]; AltZ[0]=AltZ[ii]; AltZ[ii]=Alt; }
            }
          }
        }
      }
      end_str: continue;
    }
    end_col: continue;
  }
  //if(TitleFul.nWord < NumW || TitleFul.nStr < NumS || TitleFul.dNumZ < NumZ)
  //  return -33;
  end:
  fclose_m(in);
  return 0;
}*/// !!! Art - óñòàðåëî
//==========Ãåíåðàöèÿ FullOutCript
/*int SaveFull(char *FileName)
//==========
{ FILE1 *in; int nc,ns,nw,nz,na,k_word,k_z,sp,num,i;
  char *err="SaveFull";
  if((in=fopen_m(FileName,OF_WRITE)) == NULL) return -1;
  //ÂÛÂÎÄ ÇÀÃÎËÎÂÊÀ ÔÀÉËÀ .ful
  fwrite_m(&TitleFul,sizeof(TITLE_FUL),1,in);
  #ifdef PROF_COL
    //ÂÛÂÎÄ ÑÅÊÖÈÈ ÊÎËÎÍÎÊ
    fseek_m(in,TitleFul.ColOffset,SEEK_SET);
    fwrite_m(&SizeSectionCol,sizeof(int),1,in);
    fwrite_m(&NumCol,sizeof(int),1,in);
    fwrite_m(BndCol,(NumCol+1)*sizeof(SRECT),1,in);
    fwrite_m(NumStr,(NumCol+1)*sizeof(int),1,in);
    do0(nc,0,NumCol)
    { fwrite_m(&StatCol[nc].dx_col,sizeof(int),1,in);
      fwrite_m(&StatCol[nc].dy_col,sizeof(int),1,in);
      fwrite_m(&StatCol[nc].dsym_col,sizeof(int),1,in);
      fwrite_m(&StatCol[nc].dy_Upp,sizeof(int),1,in);
      fwrite_m(&StatCol[nc].dy_Low,sizeof(int),1,in);
    }
    { int j,nlev; //---Èåðàðõèÿ êîëîíîê---
      fwrite_m(&len_col,sizeof(uint),1,in);
      fwrite_m(name,20,1,in); fl_EditStruct = (name[17]=='Y');
      fwrite_m(name1,LEN_PATH,1,in);
      fwrite_m(&k_lev,sizeof(int),1,in);
      do0(j,0,MAX_LEV)fwrite_m(&k_col[j],sizeof(int),1,in);
      fwrite_m(&k_colt,sizeof(int),1,in);fwrite_m(&slope,sizeof(int),1,in);
      fwrite_m(&k_frm,sizeof(int),1,in); fwrite_m(&space,sizeof(int),1,in);
      fwrite_m(&SizeXGlob,sizeof(int),1,in); fwrite_m(&SizeYGlob,sizeof(int),1,in);
      do0(nlev,0,k_lev)
      { do0(nc,0,k_col[nlev])
        { fwrite_m(&knot[nlev][nc].bnd,sizeof(SRECT),1,in);
          fwrite_m(&knot[nlev][nc].SpecInt,sizeof(WORD),1,in);
          fwrite_m(&knot[nlev][nc].kp,sizeof(int),1,in);
          if(knot[nlev][nc].kp >= 0)
          { do0(i,0,knot[nlev][nc].kp)
            { fwrite_m(&knot[nlev][nc].Addr[i].ind,sizeof(int),1,in);
              fwrite_m(&knot[nlev][nc].Addr[i].lev,sizeof(int),1,in);
            }
          }
        }
      }
    }
  #endif
  //ÂÛÂÎÄ ÑÅÊÖÈÈ ÈÌÅÍ ÁÀÇ
  fseek_m(in,TitleFul.FntNameOffset,SEEK_SET);
  fwrite_m(FntName,SizeSectionFntName,1,in);
  //ÂÛÂÎÄ ÑÅÊÖÈÈ ÇÍÀÊÎÌÅÑÒ
  fseek_m(in,TitleFul.ZOffset,SEEK_SET);
  do0(nc,0,NumCol)
  { do0(ns,0,NumStr[nc])
    { fwrite_m(&TitleStr[nc][ns],sizeof(TITLE_STR),1,in);
      k_word=TitleStr[nc][ns].S_Gen.S_NumWord-1;
      if( k_word>100) return -41;
      do0(nw,0,k_word)
      { fwrite_m(&TitleWord[nc][ns][nw],sizeof(TITLE_WORD),1,in);
        if((sp=TitleWord[nc][ns][nw].W_Gen.W_Spell) == SPELL_CORR)
        { if((num=TitleWord[nc][ns][nw].NumAltSpell) <= 0)
            ERR(1,err);
          do0(i,0,num-1)
          { BYTE w;
            fwrite_m(&TitleWord[nc][ns][nw].AltSpell[i].Len ,sizeof(BYTE),1,in);
            fwrite_m(&w ,sizeof(BYTE),1,in);
            fwrite_m(&TitleWord[nc][ns][nw].AltSpell[i].Penalty,sizeof(WORD),1,in);
            fwrite_m(TitleWord[nc][ns][nw].AltSpell[i].Alt,(int)TitleWord[nc][ns][nw].AltSpell[i].Len,1,in);
          }
        }
        k_z=TitleWord[nc][ns][nw].W_Gen.W_NumSym-1;
        if(k_z<0 ||  k_z>100) return -45;
        do0(nz,0,k_z)
        {
          #ifndef CMP
            Zn[nc][ns][nw][nz].Title.Z_NumComp=0;
          #endif
          fwrite_m(&Zn[nc][ns][nw][nz].Title,TitleFul.wZHSize,1,in);
          #ifdef CMP
          { int NumC=Zn[nc][ns][nw][nz].Title.Z_NumComp;
            if(NumC == 1) //Îäíîñâÿçíûé ÷àùå âñåãî
            { fwrite_m(Zn[nc][ns][nw][nz].Title.CoorComp.start_pos,LEN_START,1,in);
              fwrite_m(&Zn[nc][ns][nw][nz].Title.CoorComp.lenght,sizeof(int),1,in);
            }
            else if(NumC > 1)//Ìíîãîñâÿçíûé
            { long w=0L;
              memmove_m(&w,Zn[nc][ns][nw][nz].Title.CoorComp.start_pos,3);
              do0(i,0,NumC)
              { fwrite_m(CoorComp[w].start_pos,LEN_START,1,in);
                fwrite_m(&CoorComp[w].lenght,sizeof(int),1,in);
                ++w;
              }
            }
          }
          #endif
          do0(na,0,Zn[nc][ns][nw][nz].Title.Z_Num_Alt-1)
            fwrite_m(&Zn[nc][ns][nw][nz].Alt[na],sizeof(ALT_ZN),1,in);
        }
      }
    }
  }
  fclose_m(in); return 0;
}*/// !!! Art - óñòàðåëî

//=========Äëÿ íåðàñïîçíàí.çíàêîìåñòà Return=0
/* // !!! Art - óñòàðåëî
uchar GetAlt(int nc,int ns,int nw,int nz,int na)
//=========
{ int ka=Zn[nc][ns][nw][nz].Title.Z_Num_Alt;
  if(ka <= 0 || na >= ka) return 0;
  else return Zn[nc][ns][nw][nz].Alt[na].a_Code;
}
*/ // !!! Art - óñòàðåëî

//Âû÷èñëåíèå ìàêñèìàë. ðàññòîÿíèÿ äî îáðàçöà-ñèìâîëà â ñëîâå (ìîäóëè)
/* // !!! Art - óñòàðåëî
float DistMaxWord(ZN *Zn,int kz)
{ float Dmax,d; int i,j;
  Dmax=(float)0.;
  do0(i,0,kz) do0(j,0,((int)Zn[i].Title.Z_Num_Alt-1))
     if( (d=Zn[i].Alt[j].a_Dist) > Dmax) Dmax=d;
  return Dmax;
}
*/ // !!! Art - óñòàðåëî
//===Âûáîð íàèëó÷øåé SPELL-àëüòåðíàòèâû â ñîîòâåòñòâèè ñ àëüòåðíàòèâàìè OCR
/* // !!! Art - óñòàðåëî
int ChooseBestWord(ZN *Zn,TITLE_WORD t,char *word,float k1,float k2,
    float gam_Ins,float gam_Del)
{ int kz=t.W_Gen.W_NumSym-1,fl,i,num;
  fl=0;//Test Full NoRecog Word
  do0(i,0,kz) if(Zn[i].Title.Z_Num_Alt > 0) {fl=1; break;}
  do0(i,0,kz)
  { if(Zn[i].Title.Z_Num_Alt > 0) word[i]=Zn[i].Alt[0].a_Code;
    else word[i]=par_ful.KodNoRecogOut;
  }
  word[kz+1]=0;
  if(t.W_Gen.W_Spell != SPELL_CORR || !fl || !t.NumAltSpell)return 0;//Return OCR-Word
  if((num=ChooseRelationMin(t)) >= 0)
    { strcpy_m(word,t.AltSpell[num].Alt); return 1; }
  else return 0;
}
*/ // !!! Art - óñòàðåëî
//Return - >= 0 - èíäåêñ íàèëó÷øåé ïîäñêàçêè, < 0 - ïîäñêàçêè íåò
//-------------Âûáîð íàèëó÷øåé ïîäñêàçêè ïî óäàëåííîñòè åå øòðàôà îò ÁÑ
/* // !!! Art - óñòàðåëî
int ChooseRelationMin(TITLE_WORD t)
{ int num=t.NumAltSpell; float Rel;
  if(num <= 0) return -1;
  else if(num == 1) return 0;
  else
  { Rel=((float)t.AltSpell[1].Penalty)/((float)t.AltSpell[0].Penalty);
    if(Rel > par_ful.RelKrit) return 0;
    else //çàùèòà îò îäèíàêîâîñòè 0-îé è 1-îé ïîäñêàçîê ñ òî÷íîñòüþ äî ðåãèñòðà
    { int k0=strlen_m(t.AltSpell[0].Alt),k1=strlen_m(t.AltSpell[1].Alt),i;
      BYTE cod0,cod1;
      if(k0 == k1)
      { --k0;
        do0(i,0,k0)
        { cod0=t.AltSpell[0].Alt[i]; cod1=t.AltSpell[1].Alt[i];
          if(cod0 != cod1 && cod0 != UppLow[cod1]) return -1;
        }
        return 0;
      }
    }
  }
  return -1;
}
*/ // !!! Art - óñòàðåëî
#ifndef WIN_MOD
/* // !!! Art - óñòàðåëî
void AnsiToOem(const char *word1,char *word2)
{;}

void OemToAnsi(const char *word1,char *word2)
{;}
*/ // !!! Art - óñòàðåëî
#endif
//============Âñòàâèòü â Full-ñòðóêòóðó ñëîâî ïîñëå ïîçèöèè <nc,ns,nw>
/*
int InsertWord(int nc,int ns,int nw,ZN *zi,int kz)
//============
{ int k_word=++TitleStr[nc][ns].S_Gen.S_NumWord,i;
  TITLE_WORD *t=TitleWord[nc][ns]; ZN **z=Zn[nc][ns];
  #ifndef SUB_ZN
   if((t=(TITLE_WORD*)realloc_m(t,(k_word-1)*sizeof(TITLE_WORD),k_word*sizeof(TITLE_WORD)))==NULL)return -3;
   if((z=(ZN**)realloc_m(z,(k_word-1)*sizeof(ZN*),k_word*sizeof(ZN*)))==NULL)return -3;
  #else
   t=(TITLE_WORD*)Submalloc(k_word*sizeof(TITLE_WORD),&SubZn);
   z=(ZN**)Submalloc(k_word*sizeof(ZN*),&SubZn);
   if(t==NULL||z==NULL)return NOT_ALLOC;
   memcpy(t,TitleWord[nc][ns],(k_word-1)*sizeof(TITLE_WORD));
   memcpy(z,Zn[nc][ns],(k_word-1)*sizeof(ZN*));
  #endif
  TitleWord[nc][ns]=t; Zn[nc][ns]=z;
  doi(i,k_word-2,nw+1) { t[i+1]=t[i]; z[i+1]=z[i]; }
  t[nw+1].Z_Code=1;t[nw+1].W_Gen.W_NumSym=kz+1;
  t[nw+1].W_Gen.W_Spell=SPELL_NOT;t[nw+1].NumAltSpell=0;
  #ifndef SUB_ZN
   if((z[nw+1]=(ZN*)malloc((kz+1)*sizeof(ZN)))==NULL)return -3;
  #else
   if((z[nw+1]=(ZN*)Submalloc((kz+1)*sizeof(ZN),&SubZn))==NULL)return -3;
  #endif
  do0(i,0,kz) z[nw+1][i]=zi[i];
  return 0;
}
*/// !!! Art - óñòàðåëî
//s - âõîäíîå ñëîâî(áóäóò ïåðâûå àëüòåðíàòèâû), frm - ðàìêè áóêâ ñëîâà
//Return= 0 - OK, -1 - îøèáêà âõîäíûõ ïàðàìåòðîâ
//Âñòàâèòü â Full-ñòðóêòóðó ñëîâî ïîñëå ïîçèöèè <nc,ns,nw>
//====================!!Åñëè íàäî âñòàâèòü ñëîâî ïåðåä ïåðâûì ñëîâîì,òî nw=-1
/*int InsertWordFirstAlt(int nc,int ns,int nw,char *s,SRECT *frm)
//====================
{ int kz=strlen_m(s),i,num,nw1,fl;
  CONV comp,ns_curr;
  ZN *zi;
  //---Êîíòðîëü âõîäà---
  if(nc < 0 || nc > NumCol || ns < 0 || ns > NumStr[nc] ||
     nw < -1 || nw > TitleStr[nc][ns].S_Gen.S_NumWord-1) return -1;
  zi=(ZN*)malloc(kz*sizeof(ZN));
  --kz; comp=0; ns_curr=Zn[nc][ns][0][0].Title.Z_Id.str;
  if(nw >= 0)//Âñòàâëÿåì íå â íà÷àëî ñòðîêè
  { num=TitleWord[nc][ns][nw].W_Gen.W_NumSym-1;
    comp=Zn[nc][ns][nw][num].Title.Z_Id.comp;
  }
  do0(i,0,kz)
  { zi[i].Title.Z_Code=0;
    zi[i].Title.Z_Id.col=(CONV)(nc+1);
    zi[i].Title.Z_Id.str=ns_curr;
    zi[i].Title.Z_Id.comp=(CONV)(comp+i+1);
    zi[i].Title.Z_Id.word=0;
    zi[i].Title.Z_Rect=frm[i];
    zi[i].Title.Z_Num_Alt=1;
    zi[i].Alt[0].a_Code=s[i];
    zi[i].Alt[0].a_Dist=(float)0.;
    zi[i].Alt[0].a_Base=0;
  }
  do0(nw1,nw+1,TitleStr[nc][ns].S_Gen.S_NumWord-1)//Êîððåêòèðîâêà ïîëÿ Z_Id.comp
    do0(i,0,TitleWord[nc][ns][nw1].W_Gen.W_NumSym-1)
      Zn[nc][ns][nw1][i].Title.Z_Id.comp+=(CONV)(kz+1);
  fl=InsertWord(nc,ns,nw,zi,kz);
  free(zi); return fl;
}*/// !!! Art - óñòàðåëî
//Óäàëèòü ñëîâî èç ful-ñòðóêòóð
//============Return= 0 - ñëîâî óäàëåíî
/* // !!! Art - óñòàðåëî
int DelWordFul(int nc,int ns,int nw)
{ int k_word=TitleStr[nc][ns].S_Gen.S_NumWord-1,i;
  TITLE_WORD *t=TitleWord[nc][ns],t1=t[nw];
  ZN **z=Zn[nc][ns];
  //---Êîíòðîëü âõîäà---
  if(nc < 0 || nc > NumCol || ns < 0 || ns > NumStr[nc] ||
     nw < 0 || nw > TitleStr[nc][ns].S_Gen.S_NumWord-1) return -1;
  if(t1.NumAltSpell > 0 && t1.W_Gen.W_Spell == SPELL_CORR) //---îñâîáîæäåíèå ïîäñêàçîê Spell---
  { do0(i,0,t1.NumAltSpell-1) free(t1.AltSpell[i].Alt);
    free(t1.AltSpell);
  }
  free(z[nw]);
  do0(i,nw,k_word-1) { t[i]=t[i+1]; z[i]=z[i+1]; }
  if(k_word  > 0) TitleStr[nc][ns].S_Gen.S_NumWord=k_word;
  else  //Del String
  { TITLE_STR  *s=TitleStr[nc];
    TITLE_WORD **t=TitleWord[nc];
    ZN         ***z=Zn[nc];
    free(z[ns]); free(t[ns]);
    do0(i,ns,NumStr[nc]-1) { s[i]=s[i+1]; t[i]=t[i+1]; z[i]=z[i+1]; }
    if((--NumStr[nc]) < 0 && NumCol > 0) //Del Column
    { TITLE_STR  **s=TitleStr;
      TITLE_WORD ***t=TitleWord;
      ZN         ****z=Zn;
      free(z[nc]); free(t[nc]); free(s[nc]);
      do0(i,nc,NumCol-1)
      { s[i]=s[i+1]; t[i]=t[i+1]; z[i]=z[i+1];
        NumStr[i]=NumStr[i+1]; BndCol[i]=BndCol[i+1]; StatCol[i]=StatCol[i+1];
      }
      --NumCol;
    }
  }
  return 0;
}
*/ // !!! Art - óñòàðåëî
#ifdef FUL
//LastCod - ïîñëåäíèé êîä ïðåäûäóù. ñëîâà
//FirstCod - ïåðâûé êîä äàííîãî ñëîâà
//Return: 1 - ñëîâî ñ áîëüøîé áóêâû â íà÷àëå ïðåäëîæåíèÿ
//       -1 - ñëîâî ñ áîëüøîé áóêâû â ñåðåäèíå ïðåäëîæåíèÿ
//       0 - ñëîâî ñ ìàëîé áóêâû
//============
/* // !!! Art - óñòàðåëî
int TstNameOwr(uchar LastCod,uchar FirstCod)
//============
{
  if(Upper[(int)FirstCod]==0) return 0;
  else if(EndSentence[(int)LastCod]==1) return 1;
  else return -1;
}
*/ // !!! Art - óñòàðåëî
/*// !!! Art - óñòàðåëî
#define MAX_LEN 50 //max ÷èñëî çíàêîâ â ïàðàìåòðå
#define MAX_STR 249 //max ÷èñëî çíàêîâ â ïàðàìåòðå

WORD Penalty1LenWord(int n)
{ static WORD Pen[16]={ 0,2,3,3,3,6,6,8,8,8,8,8,8,8,8,8 },ii=1,i;
  if(n < 0)
  { char *str=malloc(250),param[MAX_LEN+1],*s,*err="Penalty1LenWord";
    ii=0; s=str;
    GetPrivateProfileString("orfo","REMAX","",s,100,FileParSpel);
    do0(i,0,15) {s=get_param(s,param,MAX_LEN-1); Pen[i]=(WORD)atoi(param);}
    free(str); return 0;
  }
  return Pen[MIN(n,15)];
}
*/ // !!! Art - óñòàðåëî
/* // !!! Art - óñòàðåëî
#define MAX_ZN_WORD 100
int MaxZn=MAX_ZN_WORD; ZN *zBuf;

FUNC_GEN_FULWORD FuncGenFulWord;
 */ // !!! Art - óñòàðåëî
//Èíèö-öèÿ ïàðàìåòðîâ Spell äëÿ ïîèñêà îäíîãî ñëîâà - áåðåì èç îáîëî÷êè àäðåñ
//ô-öèè ãåíåðàöèè áóôåðà ñëîâà ïî åãî ID_SYM
//int AddrFuncGenFulWord(ID_SYM id,ZN *z,int MaxZn)
//Return: ÷èñëî ñèìâîëîâ ñëîâà
//===
/* // !!! Art - óñòàðåëî
int PASC InitOneSpell(FUNC_GEN_FULWORD AddrFuncGenFulWord)
//===
{ if((zBuf=(ZN*)malloc(MaxZn*sizeof(ZN)))==NULL) return NOT_ALLOC;
  ExtSettings=1;//Ðåæèì âíåøíèõ íàñòðîåê øòðàôîâ for FindWord
  FuncGenFulWord=AddrFuncGenFulWord;  return 0;
}
*/ // !!! Art - óñòàðåëî
/* // !!! Art - óñòàðåëî
void PASC CloseOneSpell(void)
  { free(zBuf); }
*/ // !!! Art - óñòàðåëî
#else
 //int InitSpell(char *PAthName,int cod,int TypeDoc1) {return 0;}
/* // !!! Art - óñòàðåëî
 int TstNameOwr(uchar LastCod,uchar FirstCod) {return 0;}
*/ // !!! Art - óñòàðåëî
#endif
//======================Òåñò íà çíàê ïðåïèíàíèÿ
/*int TestPunctuationMarks(char sym)
//======================
  { return (int)PunctuationMarks[(int)sym]; }
*/ // !!! Art - óñòàðåëî
//===========Èíèö-öèÿ ïàðàìåòðîâ Spell
/* // !!! Art - óñòàðåëî
int PASC InitSpell(char *PathName,int cod,int TypeDoc)
//===========
{
 #if defined (WIN_MOD) && !defined (TIGER_CORR)
	FILE1 *f;
  int OpenFlag;
 #endif
  if(PathName == NULL)
  { char WinPath[100];
		WinPath[0]=0;
		_splitpath(WinPath,drive,dir,NULL,NULL);

    #ifndef SPELL_NEW
      if(TypeDoc!=NORV) _makepath(FileParSpel,drive,dir,"orfo","ini");
      else _makepath(FileParSpel,drive,dir,"norveg","ini");
    #endif
  }
  else strcpy_m(FileParSpel,PathName);
  #if defined (WIN_MOD) && !defined (TIGER_CORR)
    OpenFlag=chk_open();
    { if(OpenFlag >= 0) b_close();
      f=b_open(FileParSpel,GetAddrFunKill(), NULL, cod);
      if(f->hFile != HFILE_ERROR)
      { //int nc = b_erflag();
        fclose_m(f);
      }
      else return -5;
    }
  #else
    if( (f03=fopen_m("c:\\alik\\orfo.ini",OF_READ)) == NULL)
    	return -1;
  #endif
  init_ful();
  #ifdef WIN_MOD
  //  SetRegimDelta(par_ful.IndexDelta);
  #endif
//  free(f03);    //mycorr
  return 0;
}
*/// !!! Art - óñòàðåëî
/* // !!! Art - óñòàðåëî
void close_f03(void)
{
 //fclose_m(f03);
}
*/ // !!! Art - óñòàðåëî
//==============
// !!! Art - óñòàðåëî
//
//int Init_FeatLet(void)
////==============
//{ STATIC char *p,buf[8]; int i,k;
//  STATIC BYTE UpLine[14];//Èñúûþ÷õýø ø÷ ÿððòøûð
//  STATIC BYTE DownLine[25];//
//  STATIC BYTE Chif[25];
//  STATIC BYTE ImUppLow[80];
//  STATIC BYTE DelimSubWord[16];
//  WORD w;
//  if(TypeDoc!=NORV)
//  #ifdef WIN_MOD
//  { strcpy_m((char*)UpLine,(char*)"ñùôbdfhijklt");
//    strcpy_m((char*)DownLine,(char*)"ÄÖÙôðóôöùQfgjpqy,;");
//    strcpy_m((char*)Chif,(char*)"0123456789()[]{}+-*/=.,");
//    strcpy_m((char*)ImUppLow,(char*)"ÂòÃóÄôÆöÇ÷ÈøÉùÊúËûÌüÍýÎþÏÿÐðÑñÒòÓóÔôÕõÖö×÷ØøÙùÚúÛûÜüÝýÞþßCcKkOoPpSsUuVvWwXxZz");
//    strcpy_m((char*)DelimSubWord,"/-()[]{}\"\\'");
//  }
//  #else
//  { strcpy_m((char*)UpLine,(char*)"áéôbdfhijklt");
//    strcpy_m((char*)DownLine,(char*)"ÄÖÙäðóôöùQfgjpqy,;");
//    strcpy_m((char*)Chif,(char*)"0123456789()[]{}+-*/=.,");
//    strcpy_m((char*)ImUppLow,(char*)"ÂâÃãÄäÆæÇçÈèÉéÊêËëÌìÍíÎîÏïÐðÑñÒòÓóÔôÕõÖö×÷ØøÙùÚúÛûÜüÝýÞþßCcKkOoPpSsUuVvWwXxZz");
//    strcpy_m((char*)DelimSubWord,"/-()[]{}\"\\'");
//  }
//  #endif
//  else
//  { strcpy_m((char*)UpLine,(char*)"bdfhijklt");
//    strcpy_m((char*)Chif,(char*)"0123456789.");
//    strcpy_m((char*)ImUppLow,(char*)"CcKkOoPpSsUuVvWwXxZzØø");
//    strcpy_m((char*)DelimSubWord,(char*)"/-()[]\"\\'");
//  }
//  do0(i,0,255)
//   FeatLet[i].Let=FeatLet[i].Chif=FeatLet[i].DelimSubWord=FeatLet[i].ImUppLow=0;
//  #if defined (WIN_MOD) && !defined (TIGER_CORR)
//    #ifndef SPELL_NEW
//      b_getlang(buf);//Ñèìâîëüíàÿ öåïî÷êà êîäîâ ÿçûêîâ ("RE")
//    #else
//      SpellGetLang(buf);
//    #endif
//    p=buf;
//    while(*p!=0)
//    { svocab *pl=b_char(*p);
//      #ifndef SPELL_NEW
//       char *Lo=pl->tablet0,*Up=pl->tabletl0;//Öåïî÷êè áîëüøèõ è ìàëûõ òåêóù.ÿç.
//      #else
//       char *LoIn,*UpIn,*Lo,*Up;
//       if(pl==NULL) return -5;
//       LoIn=pl->Ltablet; UpIn=pl->Ltabletl;
//       Lo=malloc(strlen_m(LoIn)+2); strcpy_m(Lo,LoIn); LmUnWord(Lo);
//       Up=malloc(strlen_m(UpIn)+2); strcpy_m(Up,UpIn); LmUnWord(Up);
//      #endif
//      while(*Lo != 0)
//      { if(*Up != '-' && *Up != '\'')
//        { FeatLet[(BYTE)(*Up)].Let=FeatLet[(BYTE)(*Lo)].Let=1;
//          FeatLet[(BYTE)(*Up)].Lang=(*p == 'R') ? RUS : LAT;
//          FeatLet[(BYTE)(*Lo)].Lang=(*p == 'R') ? RUS : LAT;
//          FeatLet[(BYTE)(*Up)].Shift=FeatLet[(BYTE)(*Up)].PosUpLine=UPP;
//          FeatLet[(BYTE)(*Lo)].Shift=FeatLet[(BYTE)(*Lo)].PosUpLine=LOW;
//          FeatLet[(BYTE)(*Up)].PosDownLine=FeatLet[(BYTE)(*Lo)].PosDownLine=LOW;
//        }
//        ++Lo;++Up;
//      }
//      ++p;
//      #ifdef SPELL_NEW
//        free(Lo); free(Up);
//      #endif
//    }
//  #else
//    { BYTE *loR=(BYTE*)malloc(40),*upR=(BYTE*)malloc(40),*Lo,*Up;
//      BYTE *loE=(BYTE*)malloc(40),*upE=(BYTE*)malloc(40),*bLo[2],*bUp[2];
//      k=-1; bLo[0]=loR; bUp[0]=upR; bLo[1]=loE; bUp[1]=upE;
//      strcpy_m((char*)loR,"àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ-");
//      strcpy_m((char*)upR,"ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß-");
//      strcpy_m((char*)loE,"abcdefghijklmnopqrstuvwxyz-\'");
//      strcpy_m((char*)upE,"ABCDEFGHIJKLMNOPQRSTUVWXYZ-\'");
//      for(i=0; i < 2; ++i)
//      { Lo=bLo[i]; Up=bUp[i];
//        while(*Lo != 0)
//        { if(*Up != '-' && *Up != '\'')
//          { FeatLet[(BYTE)(*Up)].Let=FeatLet[(BYTE)(*Lo)].Let=1;
//            FeatLet[(BYTE)(*Up)].Lang= !i ? RUS : LAT;
//            FeatLet[(BYTE)(*Lo)].Lang= !i ? RUS : LAT;
//            FeatLet[(BYTE)(*Up)].Shift=FeatLet[(BYTE)(*Up)].PosUpLine=UPP;
//            FeatLet[(BYTE)(*Lo)].Shift=FeatLet[(BYTE)(*Lo)].PosUpLine=LOW;
//            FeatLet[(BYTE)(*Up)].PosDownLine=FeatLet[(BYTE)(*Lo)].PosDownLine=LOW;
//          }
//          ++Lo;++Up;
//        }
//      }
//      free(loR); free(upR); free(loE); free(upE);
//    }
//  #endif
//  k=strlen_m((char*)UpLine)-1;   do0(i,0,k) FeatLet[UpLine[i]].PosUpLine=UPP;
//  k=strlen_m((char*)DownLine)-1; do0(i,0,k) FeatLet[DownLine[i]].PosDownLine=UPP;
//  k=strlen_m((char*)Chif)-1;     do0(i,0,k) FeatLet[Chif[i]].Chif=1;
//  k=strlen_m((char*)ImUppLow)-1; do0(i,0,k) FeatLet[ImUppLow[i]].ImUppLow=1;
//  k=strlen_m((char*)DelimSubWord)-1;
//  do0(i,0,k) FeatLet[DelimSubWord[i]].DelimSubWord=1;
//  //---×òåíèå êëàñòåðîâ ïåðåïóòûâàíèÿ---
//  { BYTE *str=(BYTE*)malloc(50);
//    BYTE *NameCl=(BYTE*)malloc(20);
//    BYTE *NameClOne=(BYTE*)malloc(20);
//    int in,k,*act;
//    STATIC BYTE *s;
//    strcpy_m((char*)NameCl,"Clust0");
//    strcpy_m((char*)NameClOne,"ClustOneSym0");
//    ClustOCR=(BYTE**)malloc(MAX_CLUST*sizeof(BYTE*));
//    act=(int*)malloc(MAX_CLUST*sizeof(int));
//    K_Clust=-1;
//    for(;;) //Common Cluster
//    { GetPrivateProfileString("corr_word",(char *)NameCl,"",(char *)str,49,(char *)FileParSpel);
//      if(str[0] == 0) break;//Ñïèñîê êëàñòåðîâ èñ÷åðïàí
//      ClustOCR[++K_Clust]=(BYTE*)malloc(((k=strlen_m((char*)str))+1));
//      --k; strcpy_m((char *)ClustOCR[K_Clust],(char *)str);
//      do0(i,0,k)
//        FeatLet[(BYTE)str[i]].IndCl=K_Clust+1;
//      //NameCl[5]=++cod;
//      ++NameCl[strlen_m((char*)NameCl)-1];
//    }
//    for(;;) //Cluster One Sym
//    { GetPrivateProfileString("corr_word",(char *)NameClOne,"",(char *)str,49,FileParSpel);
//      if(str[0] == 0) break;//Ñïèñîê êëàñòåðîâ èñ÷åðïàí
//      do0(i,0,K_Clust) act[i]=0;
//      k=0;while(str[++k]!=':') if(k>48) goto EndOne;
//      s=&str[k+1]; --k;
//      do0(i,0,k)
//      { in=FeatLet[(BYTE)str[i]].IndCl-1;//Èíäåêñ old-cluster
//        if(in < 0) //Letter not found Cluster
//        { ClustOCR[++K_Clust]=(BYTE*)malloc(strlen_m((char*)s)+1);
//          strcpy_m((char *)ClustOCR[K_Clust],(char *)s);
//          in=K_Clust;
//        }
//        else if(act[in] == 0) //Create new Cluster
//        {
//					ClustOCR[++K_Clust]=(BYTE*)malloc(strlen_m((char*)s)+strlen_m((char*)ClustOCR[in])+2);
//          strcpy_m((char*)ClustOCR[K_Clust],(char*)ClustOCR[in]);
//					strcat((char*)ClustOCR[K_Clust],(char*)s);
//          act[in]=K_Clust; in=K_Clust;
//        }
//        else in=act[in];
//        FeatLet[(BYTE)str[i]].IndCl=in+1;
//      }
//      ++NameClOne[strlen_m((char*)NameClOne)-1];
//    }
//    EndOne:
//    GetPrivateProfileString("corr_word","PairDifShift","",(char*)str,49,FileParSpel);
//    do0(i,0,255) UppLowOther[i]=0;
//    i=0;
//    while(str[i]!=0)
//    { if(str[i+1]==0) break;
//      UppLowOther[str[i]]=str[i+1]; UppLowOther[str[i+1]]=str[i];
//      if(str[i+2]==0) break;
//      i+=3;
//    }
//
//		if(K_Clust>=0)
//		{
//		  do0(i,0,K_Clust) free(ClustOCR[i]);
//    }
//    free(ClustOCR);
//    free(str);
//		free(act);
//		free(NameCl);
//		free(NameClOne);
//  }
//  //---×òåíèå ðåæèìîâ èñïîëüçîâàíèÿ âíåø. Alt---
//  par_ful.AllowTestChifCl=GetPrivateProfileInt("corr_word","AllowTestChifCl",0,FileParSpel);
//  par_ful.AllowTestLangCl=GetPrivateProfileInt("corr_word","AllowTestLangCl",0,FileParSpel);
//  par_ful.AllowCorrChifCl=GetPrivateProfileInt("corr_word","AllowCorrChifCl",0,FileParSpel);
//  par_ful.AllowCorrLangCl=GetPrivateProfileInt("corr_word","AllowCorrLangCl",0,FileParSpel);
//  par_ful.AllowCorr=GetPrivateProfileInt("corr_word","AllowCorr",0,FileParSpel);
//  par_ful.AllowCorrShift=GetPrivateProfileInt("corr_word","AllowCorrShift",0,FileParSpel);
//  par_ful.AllowCorrChifLet=GetPrivateProfileInt("corr_word","AllowCorrChifLet",0,FileParSpel);
//  par_ful.AllowCorrRusLat=GetPrivateProfileInt("corr_word","AllowCorrRusLat",0,FileParSpel);
//  par_ful.AllowCorrFnt=GetPrivateProfileInt("corr_word","AllowCorrFnt",0,FileParSpel);
//  par_ful.DelStick=(float)(GetPrivateProfileInt("corr_word","DelStick",0,FileParSpel)/100.);
//  w=(WORD)GetPrivateProfileInt("ful_txt","RelDistAltOCR",(int)10,FileParSpel);
//  par_ful.RelDistAltOCR=(float)(w/10.);
//  return 0;
//}
// !!! Art - óñòàðåëî
//============
/* // !!! Art - óñòàðåëî
int init_ful()
//============
{ uchar Punct[22]=",.<>?/:;\"'\\[]-{}()!";int NumPunct=18,i;
  #ifdef WIN_MOD
    uchar WordOneSymb[]="ÀðÁñÂòÈøÊúÎþÑñÓóÝýßÿ";
  #else
    uchar WordOneSymb[]="ÀàÁáÂâÈèÊêÎîÑñÓóÝýßÿ";
  #endif
  int NumOne;
  BYTE s[3];WORD w;
  static uchar Upp[159]="ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕØÙÖ×ÚÛÜÝÞßABCDEFGHIJKLMNOPQRSTUVWXYZ";
  static uchar Low[159]="àáâãäåæçèéêëìíîïðñòóôõøùö÷úûüýþÿabcdefghijklmnopqrstuvwxyz";
  static uchar Punct1[5]=".!?";
  static int k=57,k1=2;
  char *p=0,buf[8];
	buf[0]=0;
  if(TypeDoc==NORV) strcpy_m((char*)WordOneSymb,"&");
  do0(i,0,255) {Upper[i]=Lower[i]=EndSentence[i]=0;UppLow[i]=(uchar)i;}
  #if defined (WIN_MOD) && !defined (TIGER_CORR)
    #ifndef SPELL_NEW
      b_getlang(buf);//Ñèìâîëüíàÿ öåïî÷êà êîäîâ ÿçûêîâ ("RE")
    #else
      SpellGetLang(buf);
    #endif
    p=buf; k=-1;
    while(*p!=0)
    { svocab *pl=b_char(*p);
      #ifndef SPELL_NEW
       char *Lo=pl->tablet0,*Up=pl->tabletl0;//Öåïî÷êè áîëüøèõ è ìàëûõ òåêóù.ÿç.
      #else
       char *LoIn,*UpIn,*Lo,*Up;
       if(pl==NULL) return -5;
       LoIn=pl->Ltablet; UpIn=pl->Ltabletl;
       Lo=malloc(strlen_m(LoIn)+2); strcpy_m(Lo,LoIn); LmUnWord(Lo);
       Up=malloc(strlen_m(UpIn)+2); strcpy_m(Up,UpIn); LmUnWord(Up);
      #endif
      while(*Lo != 0)
      { Upper[(BYTE)(*Up)]=1; Lower[(BYTE)(*Lo)]=1;
        Upp[++k]=*Up;Low[k]=*Lo;
        ++Lo;++Up;
      }
      ++p;
      #ifdef SPELL_NEW
        free(Lo); free(Up);
      #endif
    }
  #else
    { BYTE *loR=(BYTE*)malloc(40),*upR=(BYTE*)malloc(40),*Lo,*Up;
      BYTE *loE=(BYTE*)malloc(40),*upE=(BYTE*)malloc(40),*bLo[2],*bUp[2];
      k=-1; bLo[0]=loR; bUp[0]=upR; bLo[1]=loE; bUp[1]=upE;
      strcpy_m((char*)loR,"àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ-");
      strcpy_m((char*)upR,"ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß-");
      strcpy_m((char*)loE,"abcdefghijklmnopqrstuvwxyz-\'");
      strcpy_m((char*)upE,"ABCDEFGHIJKLMNOPQRSTUVWXYZ-\'");
      for(i=0; i < 2; ++i)
      { Lo=bLo[i]; Up=bUp[i];
        while(*Lo != 0)
        { Upper[(BYTE)(*Up)]=1; Lower[(BYTE)(*Lo)]=1;
          Upp[++k]=*Up;Low[k]=*Lo;
          ++Lo;++Up;
        }
      }
      free(loR); free(upR); free(loE); free(upE);
    }
  #endif
  do0(i,0,k)  {UppLow[(int)Upp[i]]=Low[i]; UppLow[(int)Low[i]]=Upp[i];}
  do0(i,0,k1)  EndSentence[Punct1[i]]=1;
  do0(i,0,255) PunctuationMarks[i]=WordOne[i]=0;
  do0(i,0,NumPunct) PunctuationMarks[(int)Punct[i]]=1;
  NumOne=strlen_m((char*)WordOneSymb)-1;
  do0(i,0,NumOne) WordOne[(int)WordOneSymb[i]]=1;
  #if defined (WIN_MOD) && !defined (TIGER_CORR)
    #ifndef SPELL_NEW
     ParSpell=b_charg();
     par_ful.KodNoRecog=ParSpell->unknow;
    #else
     ParSpell=(svocabg*)malloc(sizeof(svocabg));
     GetPrivateProfileString("b_dll","UNKNOW","@",s,20,FileParSpel);
     par_ful.KodNoRecog=s[0];
     { char *p=&s[2],*pp=p;
       while(*pp++ != ')'); *(--pp)=0;
       ParSpell->reunknow=atoi(p);
     }
     ParSpell->reinst=GetPrivateProfileInt("b_dll","REINST",0,FileParSpel);
     ParSpell->reinstb= GetPrivateProfileInt("b_dll","REINSTB",0,FileParSpel);
     ParSpell->redel=   GetPrivateProfileInt("b_dll","REDEL",0,FileParSpel);
     ParSpell->reelse=  GetPrivateProfileInt("b_dll","REELSE",0,FileParSpel);
    #endif
  #else
    GetPrivateProfileString("b_dll","UNKNOW","@",(char*)s,20,FileParSpel);
    par_ful.KodNoRecog=s[0];
  #endif
  GetPrivateProfileString("ful_txt","KodNoRecogOut","@",(char*)s,2,FileParSpel);
  par_ful.KodNoRecogOut=s[0];
  par_ful.NumAlt=GetPrivateProfileInt("ful_txt","NumAlt",2,FileParSpel);
  w=(WORD)GetPrivateProfileInt("ful_txt","RelKrit",(int)10,FileParSpel);
  par_ful.RelKrit=(float)(w/10.);
  par_ful.IndexDelta=GetPrivateProfileInt("ful_txt","IndexDelta",1,FileParSpel);
  if(par_ful.IndexDelta!=2) MaxValue=MAX_VALUE;
  else MaxValue=MAX_VALUE*MAX_VALUE;
  par_ful.IntervalTimer=(DWORD)GetPrivateProfileInt("ful_txt","IntervalTimer",32000,FileParSpel);
  { //Temp filling KoderTabl R<->L coincidal tracing
    #ifdef WIN_MOD
      BYTE *Rus=(BYTE*)"ÀðÂÅõÊúÌÍÎþÐðÑñÒÓóÕõ",*Lat=(BYTE*)"AaBEeKkMHOoPpCcTYyXx";
    #else
      BYTE *Rus=(BYTE*)"ÀàÂÅåÊêÌÍÎîÐðÑñÒÓóÕõ",*Lat=(BYTE*)"AaBEeKkMHOoPpCcTYyXx";
    #endif
    do0(i,0,255) KoderRus[i]=KoderLat[i]=(BYTE)i;
    if(TypeDoc!=NORV)
     do0(i,0,19) { KoderLat[Rus[i]]=Lat[i]; KoderRus[Lat[i]]=Rus[i]; }
  }
  return 0;
}
*/ // !!! Art - óñòàðåëî
#ifndef BLANK
 #define SPACE_RED 4
#else
 #define SPACE_RED 0
#endif
//nc - íîìåð ôîðìàòèðóåìîé êîëîíêè
//Bnd - åå òåêñòîâàÿ ðàìêà (ðàìêà â òåêñòîâûõ êîîðäèíàòàõ)
//Return:
// 0 - íîðìàëüíîå çàâåðøåíèå,
//-1 - îøèáêà ïàðàìåòðîâ,
//===========Ôîðìàòèðîâàíèå ñèìâîëîâ â ñòðîêàõ îäíîé êîëîíêè
/*// !!! Art - óñòàðåëî
int FormatStr(int nc,SRECT *Bnd,char ***Str,int **Ksym,int ncO)
//===========
{
	int DelStr=0,ks=NumStr[nc],ns,LeftMargin=0,kw,kz,nw,nz,ksy,i,k=0,del=0,fl,len,
      Fract,Znam=0,Chisl=0,inWord;
  uchar LastCod,sy=0;
  #ifdef PROF_COL
    //---Ðàñ÷åò ñðåäíåãî ìåæñòðî÷. èíòåðâàëà DelStr---
    if(!ks)
			DelStr=2*StatCol[nc].dy_col;
    else
    {
			DelStr=0; k=0; fl=0;
      do0(ns,1,ks) //ðàññòîÿíèå ì/ÖÒ
      {
				if(Zn[nc][ns][0][0].Title.Z_Num_Alt != 0 &&
           ((sy=Zn[nc][ns-1][0][0].Alt[0].a_Code) == '$' || sy == '#'))
					 			continue;
        del=(TitleStr[nc][ns].S_Rect.bottom+TitleStr[nc][ns].S_Rect.top)/2 -
            (TitleStr[nc][ns-1].S_Rect.bottom+TitleStr[nc][ns-1].S_Rect.top)/2;
        if(!del)
					{fl=1;break;}
        DelStr+=del; ++k;
      }
      if(!fl && !k)
				DelStr/=k;
			else
				DelStr=2*StatCol[nc].dy_col;
      if(!DelStr)
				DelStr=2*StatCol[nc].dy_col;
    }
    Bnd->top=Zn[nc][0][0][0].Title.Z_Rect.top/DelStr;
    LeftMargin=Zn[nc][0][0][0].Title.Z_Rect.left;
    do0(ns,0,ks)
			LeftMargin=MIN(LeftMargin,(Zn[nc][ns][0][0].Title.Z_Rect.left));
    Bnd->left=LeftMargin/(StatCol[nc].dx_col+StatCol[nc].dsym_col);
  #else
    Bnd->left=Bnd->top=0;
  #endif
  if(nc < 0 || ncO < 0)
		return -10;
  Bnd->bottom=Bnd->top+ks; Bnd->right=-32000;
  #ifdef SUB_FRM
   Str[ncO]=(char**)Submalloc((ks+1)*sizeof(char*),&SubFrm);
   Ksym[ncO]=(int*)Submalloc((ks+1)*sizeof(int),&SubFrm);
  #else
   Str[ncO]=(char**)malloc((ks+1)*sizeof(char*));
   Ksym[ncO]=(int*)malloc((ks+1)*sizeof(int));
  #endif
  if(Str[ncO]==NULL||Ksym[ncO]==NULL)
		return NOT_ALLOC;
  LastCod=0;
  do0(ns,0,ks)
  {
		Fract=0;
//		Chisl=0;
    ksy=-1;//CurrentPosition in Str
    if((kw=TitleStr[nc][ns].S_Gen.S_NumWord-1) >= 0)
    { if(BEG_PARAG1(Zn[nc][ns][0][0].Title.Z_Id)==1)//Êðàñíàÿ ñòðîêà
        do0(i,0,SPACE_RED) buf[++ksy]=' ';
      do0(nw,0,kw)
      { //if(nw > 0 && TitleWord[nc][ns][nw].W_Gen.W_NumSym == 1 &&
        //   Zn[nc][ns][nw][0].Alt[0].a_Code == '"') --ksy;
        if(par_ful.AllowSpell!=1)
        {
					if(TitleFul.ProcSpell == PROC_SPELL &&
             TitleWord[nc][ns][nw].W_Gen.W_Spell == SPELL_PART)
						 		continue;
          kz=TitleWord[nc][ns][nw].W_Gen.W_NumSym-1;
          do0(nz,0,kz)
          { if(INDICE1(Zn[nc][ns][nw][nz].Title.Z_Id))
              buf[++ksy]='^'; //Èíäåêñ
            if(MULTI_POINT1(Zn[nc][ns][nw][nz].Title.Z_Id))
              {buf[++ksy]=' ';buf[++ksy]='.';buf[++ksy]='.';goto END;}//Ìíîãîòî÷èå
            if(FRACT1(Zn[nc][ns][nw][nz].Title.Z_Id))
            { if(!Fract) //×èñëèòåëü äðîáè
                {Fract=1;buf[++ksy]='<';buf[++ksy]='<'; inWord=nw;}
              else if(nw != inWord) {inWord=nw;buf[++ksy]='/';} //îòäåëÿåì Çíàìåíàòåëü
            }
            else if(Fract)
							{ Fract=0;buf[++ksy]='>'; buf[++ksy]='>'; }
            if(Zn[nc][ns][nw][nz].Title.Z_Num_Alt) //Çíàêîìåñòî Ðàñïîçíàííî
              buf[++ksy]=Zn[nc][ns][nw][nz].Alt[0].a_Code;
            else
              #ifdef FUL
               buf[++ksy]=par_ful.KodNoRecogOut;
              #else
               buf[++ksy]='?';
              #endif
          }
        }
        else if(TitleWord[nc][ns][nw].W_Gen.W_Spell!=SPELL_PART)
        { fl=ChooseBestWord(Zn[nc][ns][nw],TitleWord[nc][ns][nw],(char*)buf1,
          par_ful.k1,par_ful.k2,par_ful.gam_Ins,par_ful.gam_Del);
          len=strlen_m((char*)buf1)-1;
          if((fl=TstNameOwr(LastCod,GetAlt(nc,ns,nw,0,0)))==1)
          { //Ñëîâî ñ áîëüøîé áóêâû âíà÷àëå ïðåäë-ÿ
            if(Upper[(int)buf1[0]]==0)
              buf1[0]=UppLow[(int)buf1[0]]; //ìåíÿåì ðåãèñòð íà çàãëàâíûé
          }
          else if(fl == 0) //Ñëîâî ñ ìàëîé áóêâû
          { if(Lower[(int)buf1[0]]==0)
              buf1[0]=UppLow[(int)buf1[0]]; //ìåíÿåì ðåãèñòð íà çàãëàâíûé
          }
          LastCod=buf1[len];
          do0(i,0,len) buf[++ksy]=buf1[i];
        }
        if(nw != kw)
        { if(!COMMA1(Zn[nc][ns][nw+1][0].Title.Z_Id) && !Fract)
            buf[++ksy]=' '; //InterWord Space,åñëè ñëåäîì íå çíàê ïðåïèíàíèÿ
        }
      }
    END:
			if(Fract)
				{buf[++ksy]='>'; buf[++ksy]='>';}
    }
    else
			buf[ksy=0]=' ';//Empty Str
    Bnd->right=MAX(Bnd->right,ksy);
    if(ksy < 0)
			return -11;
    #ifdef SUB_FRM
     if((Str[ncO][ns]=(char*)Submalloc(ksy+1,&SubFrm))==NULL)return NOT_ALLOC;
    #else
     if((Str[ncO][ns]=(char*)malloc(ksy+1))==NULL)return NOT_ALLOC;
    #endif
    Ksym[ncO][ns]=ksy; memcpy(Str[ncO][ns],buf,ksy+1);
  }
  Bnd->right+=Bnd->left;
  return 0;
}
*/ // !!! Art - óñòàðåëî
#ifdef PROF_COL
/* int PASC GenFullTxtfromTree(char *FileNameFul,char *FileNameOut,INF_TREE *Inf)
 {;}*/ // !!! Art - óñòàðåëî
#else
//Èçâëå÷ü óçåë Curr èç äåðåâà áåç ôèç.óäàëåíèÿ èç ñïèñêà(áåç çàíåñåíèÿ â ListFree)
//back è next - ñîñåäè óçëà (íóæíû äëÿ âñòàâêè åãî îáðàòíî â òîæå ìåñòî)
//==
/*// !!! Art - óñòàðåëî
void ExtrKnot(KNOTT *Curr,KNOTT **back,KNOTT **next)
//==
{ if(Curr==NULL)ERR(1,"ExtrKnot");
  *back=Curr->back; *next=Curr->next;
  if(*back)(*back)->next=*next;if(*next)(*next)->back=*back;
}
*/// !!! Art - óñòàðåëî
//Ïîäöåïèòü îáðàòíî óçåë Curr ìåæäó óçëàìè back è next
//==
/* // !!! Art - óñòàðåëî
void ReverseInsertKnot(KNOTT *Curr,KNOTT *back,KNOTT *next)
//==
{ if(back) back->next=Curr; Curr->back=back;
  if(next) next->back=Curr; Curr->next=next;
}
*/// !!! Art - óñòàðåëî
//Ïàðàìåòðû:
//FileNameFul - èìÿ ôàéëà Full Out Cript
//FileNameOut - èìÿ âûõîäíîãî ôàéëà
//Inf - äåðåâî ñòðóêòóðû â ïàìÿòè
//Return:
// 0 - íîðìàëüíîå çàâåðøåíèå
//
//==Ãåíåðàöèÿ òåêñòîâîãî ôàéëà èç ôàéëà Full Out
/* // !!! Art - óñòàðåëî
int PASC GenFullTxtfromTree(char *FileNameFul,char *FileNameOut,INF_TREE *Inf)
//==
{
	SRECT *BndColTxt;
	char ***Str;
	int **Ksym;
  char **Txt,*err="GenFullTxtfromTree"; int K_Col,K_Rows;
  int fl,nc,ns,nz,dx,dy,tmp,nT,in,beg,end,i,y0,y1,x0,x1,DelLine,j;
  BYTE *MultiPoint;
  SRECT BndPage;
  STAT_CELL *StatCell=Inf->StatCell;
  LINE_KNOT *LineH=Inf->LineHK,*LineV=Inf->LineVK;
  KNOTT *Root=Inf->Tree.Root,**AllT,*Curr;
  int NumTV=Inf->NumTV,nH=Inf->nH,nV=Inf->nV,HeiStr=StatCell[0].HeiStr,
      Space=abs(Inf->MonoSpaceTrue);
  STACK St;
  BYTE ImageLineV[MAX_TYPE_LINE],ImageLineH[MAX_TYPE_LINE],charLine;
  ImageLineV[SOLID_LINE ]='|'; ImageLineH[SOLID_LINE ]='-';
  ImageLineV[DOUBLE_LINE]='#'; ImageLineH[DOUBLE_LINE]='=';
  ImageLineV[THICK_LINE ]='*'; ImageLineH[THICK_LINE ]='*';
  //~ImageLineV[HIDDEN_LINE]=' '; ImageLineH[HIDDEN_LINE]=' ';
  ImageLineV[HIDDEN_LINE]='|'; ImageLineH[HIDDEN_LINE]='-';
  ImageLineV[DOT_LINE   ]='.'; ImageLineH[DOT_LINE   ]='.';
  #ifndef TIGER_CORR
  	if(Inf->TypeDoc==NORV)
			par_ful.AllowSpell=0;
		else
			par_ful.AllowSpell=1;
	#endif
  //--îáíóëÿåì ññûëêó down óçëà HierH äëÿ åäèíîîáðàçèÿ îáõîäà TERM-Cell Tree
  if(Inf->TypeDoc == NORV)
		Inf->HierH->down=NULL;
  //--Init Txt-Coor H- and V-Line
  for(i=0; i < nH; ++i)
  {
		if(i)
			tmp=(LineH[i].beg-LineH[i-1].beg)/HeiStr + 1;
    LineH[i].BegTxt= !i ? 2 : LineH[i-1].BegTxt + MAX(2,tmp);
  }
  for(i=0; i < nV; ++i)
  {
		if(i)
			tmp=Space ? (LineV[i].beg-LineV[i-1].beg)/Space + 1 : 0;
    LineV[i].BegTxt= !i ? 2 : LineV[i-1].BegTxt + MAX(2,tmp);
  }
  //--Ðàññ÷èòûâàåì îáùåå ÷èñëî TERM-Cell
  if(NewStack(20,&St))
		return NOT_ALLOC;
  Curr=Root; nT=0;
  while(Curr != NULL)
  {
		if(Curr->down == NULL && Curr->Type != HIER_H)
			++nT;
    Curr=NextKnot(Curr,&St);
  }
  ClearStack(&St);
  //Íîâàÿ èíòåðïðåòàöèÿ çíà÷. ïîëåé KNOTT
  //InBegFrm - íîìåð òåðìèíàë.ÿ÷åéêè â ìàññèâàõ Zn,...
  //NumFrm - èíäåêñ â ìàññèâå AllT
  AllT=(KNOTT**)malloc(nT*sizeof(PTR));
  Curr=Root; nT=-1;
  while(Curr != NULL)
  { if(Curr->down == NULL && Curr->Type != HIER_H)
    { AllT[++nT]=Curr;
			if(Curr->NumFrm < 1)
				Curr->AllowOCR=0;
      AllT[nT]->NumFrm=nT;
    }
    Curr=NextKnot(Curr,&St);
  }
  ++nT;
  DelStack(&St);
  NumCol=Inf->NumT; //!!!Ýòî èíäåêñ ïîñëåäíåé ÿ÷åéêè!!!
  //for(i=0; i < nT; ++i)
  //{ if(AllT[i]->AllowOCR)
  //   {if(AllT[i]->InBegFrm > NumCol || AllT[i]->InBegFrm < 0) ERR(5,err);}
  //  if(AllT[i]->NumFrm > nT || AllT[i]->NumFrm < 0) ERR(6,err);
  //}
  NumStr=Inf->k_str; StatCol=Inf->StatCol;
  BndCol=(SRECT*)malloc((NumCol+1)*sizeof(SRECT));
  for(i=0;i<=NumCol;++i)
  { BndCol[i].left=Inf->bnd_col[i].left;BndCol[i].right=Inf->bnd_col[i].right;
    BndCol[i].top=Inf->bnd_col[i].up;   BndCol[i].bottom=Inf->bnd_col[i].down;
  }
  #ifdef FUL
   #ifndef DLL_MOD
    if((fl=InitSpell(NULL,1,0))!=0) return fl-50;
   #endif
  #endif

	#ifndef TIGER_CORR
		if((fl=OpenFullOut(FileNameFul))!=0)
			return fl-100;
	#else

	  //~	if((fl=OpenFullOutTiger(FileNameFul))!=0)
		//~	return fl-100;
	#endif
  //!!!äëÿ áëàíêîâ nT - îáùåå ÷èñëî TERM-ÿ÷ååê, NumCol - ëèøü AllowOcr
  BndColTxt=(SRECT*)malloc(nT*sizeof(SRECT));
  #ifdef SUB_FRM
   { long Num=nT*2*sizeof(PTR)+(TitleFul.nStr+(nT-NumCol)*2)*
          (sizeof(PTR) + sizeof(int)) + (TitleFul.dNumZ+500);
     if((fl=InitSubAlloc(Num,&SubFrm))) return fl-100;
     Str=(char***)Submalloc(nT*sizeof(char**),&SubFrm);
     Ksym=(int**)Submalloc(nT*sizeof(int*),&SubFrm);
   }
  #else
    Str=(char***)malloc(nT*sizeof(char**));
    Ksym=(int**)malloc(nT*sizeof(int*));
  #endif
  if(BndColTxt==NULL||Str==NULL||Ksym==NULL)
		return NOT_ALLOC;
  #if defined (FUL) && !defined (TIGER_CORR)
  if(TitleFul.ProcSpell != PROC_SPELL &&
     ((Inf->TypeDoc==NORV  && (fl=CorrFulCell(AllT,nT,Inf)) != 0) ||
      (Inf->TypeDoc==PLAIN && (fl=CorrFul()) != 0))
    ) //Êîððåêòîð ïî îäíîðîäíîñòÿì
			return fl-3000;
  #endif
  //--Ôîðìàòèðîâàíèå ñèìâîëîâ â êîëîíêàõ--
  for(i=0; i < nT; ++i)
    if(fl=FormatKnot(AllT[i],&BndColTxt[i],Str,Ksym)) return fl-200;
  //--Ôîðìàòèðîâàíèå ãîðèçîíòàëåé è âåðòèêàëåé--
  DelLine= Inf->TypeDoc==PLAIN ? 0 : 2;
  u4sort(AllT,nT,sizeof(PTR),(COMP_FUN)compKNOTT_RectBottom);
  for(i=0; i < nT; ++i)
  { //in - èíäåêñ äàííîé ÿ÷åéêè â ìàññèâàõ BndColTxt,Str,Sym
    //beg, end - èíäåêñû ãðàíè÷íûõ ëèíèé ÿ÷åéêè
    beg=AllT[i]->Rect.top;end=AllT[i]->Rect.bottom;
    if( (tmp=BndColTxt[AllT[i]->NumFrm].bottom + 2 - (LineH[end].BegTxt -
        LineH[beg].BegTxt)) > 0)
    { for(j=end; j < nH; ++j) //ðàçäâèãàåì ðàçãðàôêó,ïîêóäà åñòü ïåðåïóòûâàíèå ëèíèé
      { LineH[j].BegTxt+=tmp;
        if(j < nH-1 && LineH[j].BegTxt+DelLine <= LineH[j+1].BegTxt)
					break;
      }
    }
  }
  for(i=1; i < nH; ++i)
		if(LineH[i].BegTxt - LineH[i-1].BegTxt < DelLine)
			ERR(8,err);
  u4sort(AllT,nT,sizeof(PTR),(COMP_FUN)compKNOTT_RectRight);
  for(i=0; i < nT; ++i)
  { beg=AllT[i]->Rect.left;end=AllT[i]->Rect.right;
    if( (tmp=BndColTxt[AllT[i]->NumFrm].right + 2 - (LineV[end].BegTxt -
        LineV[beg].BegTxt)) > 0)
    { for(j=end; j < nV; ++j) //ðàçäâèãàåì ðàçãðàôêó
      { LineV[j].BegTxt+=tmp;
        if(j < nV-1 && LineV[j].BegTxt+DelLine <= LineV[j+1].BegTxt)
					break;
      }
    }
  }
  for(i=1; i < nV; ++i)
		if(LineV[i].BegTxt - LineV[i-1].BegTxt < DelLine)
			ERR(9,err);
  //--Òåñò äîñòàòî÷íîñòè ðàçãðàôêè äëÿ ÿ÷ååê--
  for(i=0; i < nT; ++i)
  { in=AllT[i]->NumFrm;
    beg=AllT[i]->Rect.top;end=AllT[i]->Rect.bottom;
    if((tmp=BndColTxt[in].bottom+2-(LineH[end].BegTxt - LineH[beg].BegTxt)) > 0)
			ERR(1,err);
    beg=AllT[i]->Rect.left;end=AllT[i]->Rect.right;
    if((tmp=BndColTxt[in].right+2-(LineV[end].BegTxt - LineV[beg].BegTxt)) > 0)
			ERR(11,err);
  }
  //--Ôîðìèðîâàíèå âûõîäíîãî òåêñòà â áóôåðå--
  BndPage.left=LineV[0].BegTxt; BndPage.right=LineV[nV-1].BegTxt;
  BndPage.top =LineH[0].BegTxt; BndPage.bottom=LineH[nH-1].BegTxt;
  K_Col=BndPage.right-BndPage.left; K_Rows=BndPage.bottom-BndPage.top;
  if((Txt=(char**)malloc((K_Rows+1)*sizeof(char*)))==NULL)return NOT_ALLOC;
  do0(ns,0,K_Rows)
  {
		if((Txt[ns]=(char*)malloc((K_Col+1)))==NULL)
			return NOT_ALLOC;
    memset(Txt[ns],' ',K_Col+1);
  }
  if(Inf->TypeDoc==NORV)
		MultiPoint=(BYTE*)malloc(100);
  for(i=0; i < nT; ++i)
  { KNOTT *Kn=AllT[i];
    int l,nci,nw,NumAdd,dx1;
    int left=LineV[Kn->Rect.left].BegTxt,right=LineV[Kn->Rect.right].BegTxt,
        top=LineH[Kn->Rect.top].BegTxt,  bottom=LineH[Kn->Rect.bottom].BegTxt;
    nc=Kn->NumFrm; dx=left-BndPage.left+1; dy=top-BndPage.top+1;
    //--Âûðàâíèâàíèå--
    if(Kn->JustH == ALG_END && (tmp=right-left-1-BndColTxt[nc].right-1) > 0)
      dx+=tmp;
    if(Kn->JustH == ALG_CENTER && (tmp=(right-left-1-BndColTxt[nc].right)/2-1) > 0)
      dx+=tmp;
    if(Kn->JustV == ALG_END && (tmp=bottom-top-1-BndColTxt[nc].bottom-1) > 0)
      dy+=tmp;
    if(Kn->JustV == ALG_CENTER && (tmp=(bottom-top-1-BndColTxt[nc].bottom)/2-1) > 0)
      dy+=tmp;
    in=BndColTxt[nc].bottom;
    if(Inf->TypeDoc==NORV)
			memset(MultiPoint,0,in+1);
    if(Kn->AllowOCR)
    { nci=Kn->InBegFrm;
      for(l=0; l <= in; ++l)
      { nw=TitleStr[nci][l].S_Gen.S_NumWord;
        if(nw > 0)
        { if(Inf->TypeDoc==NORV && MULTI_POINT1(Zn[nci][l][nw-1][0].Title.Z_Id))
          { if(MULTI_POINT1(Zn[nci][l][0][0].Title.Z_Id))
							MultiPoint[l]=1;//AllStr ...
            else
							MultiPoint[l]=2;//EndStr ...
          }
        }
      }
    }
    //--Îêîíòóðèâàíèå V-ëèíèÿìè--
    beg=left-BndPage.left; charLine=ImageLineV[LineV[Kn->Rect.left].TypeLine];
    y0=top-BndPage.top; y1=bottom-BndPage.top;
    do0(ns,y0,y1) Txt[ns][beg]=charLine;
    beg=right-BndPage.left; charLine=ImageLineV[LineV[Kn->Rect.right].TypeLine];
    do0(ns,y0,y1) Txt[ns][beg]=charLine;
    //--Îêîíòóðèâàíèå H-ëèíèÿìè--
    beg=top-BndPage.top; charLine=ImageLineH[LineH[Kn->Rect.top].TypeLine];
    x0=left-BndPage.left; x1=right-BndPage.left;
    do0(nz,x0,x1) Txt[beg][nz]=charLine;
    beg=bottom-BndPage.top; charLine=ImageLineH[LineH[Kn->Rect.bottom].TypeLine];
    do0(nz,x0,x1) Txt[beg][nz]=charLine;
    //--âûâîä òåêñòà ÿ÷åéêè--
    do0(ns,0,in)
    { //if(ns+dy == top-BndPage.top || ns+dy == bottom-BndPage.top ||
      //   nz+dx == left-BndPage.left|| nz+dx == right-BndPage.left)
      //      ERR(13,err); //Çàòåðëè ðàçãðàôêó
      if(Inf->TypeDoc!=NORV || MultiPoint[ns] != 1)
      { do0(nz,0,Ksym[nc][ns]) Txt[ns+dy][nz+dx]=Str[nc][ns][nz];
        if(Inf->TypeDoc==NORV && MultiPoint[ns])
        { dx1=Ksym[nc][ns]+1+dx; NumAdd=right-left-2-Ksym[nc][ns];
          for(nz=0; nz < NumAdd; ++nz) Txt[ns+dy][nz+dx1]='.';
        }
      }
      else //âûâîäèì âûðàâíèâàÿ âïðàâî ìíîãîòî÷èå
        for(nz=right-3-BndPage.left; nz <= right-1-BndPage.left; ++nz)
          Txt[ns+dy][nz]='.';
    }
  }
  if(Inf->TypeDoc==NORV)free(MultiPoint);
  //--Âûâîä âûõîä. òåêñòà â ôàéë--
  { FILE1 *out=fopen_m(FileNameOut,OF_WRITE);
    char Lf[2];
    Lf[0]=0x0D; Lf[1]=0x0A;
    do0(ns,0,K_Rows)
    { fwrite_m(Txt[ns],K_Col+1,1,out); fwrite_m(Lf,2,1,out); }
    fclose_m(out);
  }
  //--Äëÿ âîçìîæíîñòè ìíîãîêðàò.ôîðìàòèðîâàíèÿ ñîõðàíÿåì ïðèçíàê ïðîéäåííîñòè
  //--óçëà åñëè îí áûë çàïîð÷åí
  for(i=0; i <= Inf->NumT; ++i)
    if(Inf->ColT[i]->NumFrm == 0) Inf->ColT[i]->NumFrm=1;
  //--Îñâîáîæäåíèå ïàìÿòè--
  do0(ns,0,K_Rows) free(Txt[ns]); free(Txt);
  #ifdef SUB_FRM
   DeleteSubAlloc(&SubFrm);
  #else
   for(i=0; i < nT; ++i)
   { nc=AllT[i]->NumFrm; in=BndColTxt[nc].bottom;
     free(Ksym[nc]); do0(ns,0,in) free(Str[nc][ns]); free(Str[nc]);
   }
   free(Ksym); free(Str);
  #endif
  free(BndColTxt);
//END:
  FreeStructFull();
  free(AllT);
  #ifdef FUL
   #ifndef DLL_MOD
    b_close();
   #endif
  #endif
  return 0;
}*/// !!! Art - óñòàðåëî

// !!! Art - óñòàðåëî
//int FormatKnot(KNOTT *Knot,SRECT *Bnd,char ***Str,int **Ksym)
//{
//	int fl;
//
//	if(TRUE/*Knot->AllowOCR && Knot->InBegFrm <= NumCol*/)//Óçåë ïðîøåäøèé OCR
//  {
//		if(fl=FormatStr(Knot->InBegFrm,Bnd,Str,Ksym,Knot->NumFrm))
//			return fl-10;
//	}
//  else //Ðàçáèðàåì ôîðìàò.ñòðîêó, åñëè îíà íå ðàâíà NULL
//  { char **str,*s;
//		int *ks,kstr,len,ksy,Num;
//
//    Knot->AllowOCR=0;
//    if(Knot->Name)
//    { //--Ðàññ÷èòûâàåì ÷èñëî ñòðîê äëÿ ãîðèçîíò. (kstr) è âåðòèê. (Num) ÿ÷ååê
//      s=Knot->Name; kstr=1; Num=0;
//      while(*s) { if(*s == '\\' && *(++s) == 'n') ++kstr; ++s; ++Num; }
//      s=Knot->Name; if(*s == '\\' && *(s+1) == 'v') kstr=Num-1;//~
//      #ifdef SUB_FRM
//       str=(char**)Submalloc(kstr*sizeof(PTR),&SubFrm);
//       ks=(int*)Submalloc(kstr*sizeof(int),&SubFrm);
//      #else
//       str=(char**)malloc(kstr*sizeof(PTR));
//       ks=(int*)malloc(kstr*sizeof(int));
//      #endif
//      kstr=-1;  len=-32000; ksy=-1;
//      if(*s == '\\' && *(s+1) == 'v') //Âåðòèêàë.íàäïèñü
//      { s+=2;
//        while(*s)
//        { len=MAX(len,1);
//          #ifdef SUB_FRM
//           str[++kstr]=(char*)Submalloc(1,&SubFrm);
//          #else
//           str[++kstr]=(char*)malloc(1);
//          #endif
//          str[kstr][0]=*s;
//          ks[kstr]=0; ++s;
//        }
//      }
//      else
//      { while(*s)
//        { if(*s == '\\')
//          { if( *(++s) == 'n')
//            { len=MAX(len,ksy);
//              #ifdef SUB_FRM
//               str[++kstr]=(char*)Submalloc(ksy+1,&SubFrm);
//              #else
//               str[++kstr]=(char*)malloc(ksy+1);
//              #endif
//              memcpy(str[kstr],buf,ksy+1); ks[kstr]=ksy;
//              ksy=-1;
//            }
//          }
//          else buf[++ksy]=*s;
//          ++s;
//        }
//        if(ksy >= 0)
//        { len=MAX(len,ksy);
//          #ifdef SUB_FRM
//           str[++kstr]=(char*)Submalloc(ksy+1,&SubFrm);
//          #else
//           str[++kstr]=(char*)malloc(ksy+1);
//          #endif
//          memcpy(str[kstr],buf,ksy+1); ks[kstr]=ksy;
//        }
//      }
//    }
//    else //ïóñòàÿ ÿ÷åéêà - çàâîäèì îäíîñèìâîë.îäíîñòðî÷.ÿ÷åéêó
//    {
//      #ifdef SUB_FRM
//       str=(char**)Submalloc(sizeof(PTR),&SubFrm);
//       str[0]=(char*)Submalloc(1,&SubFrm);
//       ks=(int*)Submalloc(sizeof(int),&SubFrm);
//      #else
//       str=(char**)malloc(sizeof(PTR));
//       str[0]=(char*)malloc(1);
//       ks=(int*)malloc(sizeof(int));
//      #endif
//      str[0][0]=' '; kstr=0; ks[0]=0; len=0;
//    }
//    Bnd->left=0;Bnd->right=len;Bnd->top=0;Bnd->bottom=kstr;
//    Str[Knot->NumFrm]=str; Ksym[Knot->NumFrm]=ks; return 0;
//  }
//  return 0;
//}// !!! Art - óñòàðåëî

// !!! Art - óñòàðåëî
/*int compKNOTT_RectBottom(KNOTT **a,KNOTT **b)
  {return (*a)->Rect.bottom >= (*b)->Rect.bottom ? 1:-1;}
int compKNOTT_RectRight(KNOTT **a,KNOTT **b)
  {return (*a)->Rect.right >= (*b)->Rect.right ? 1:-1;}
*/// !!! Art - óñòàðåëî
#endif

//InitSpell()
//{
//    if (LmOpen("d:\windows\system\",25)) ;
//    else
//      ERROR
//    if (SpellOpen("RE"))
//      SpellDeltaScript(Porog,Fr,Fd,Fi,Fi,Fo);
//    else
//      ERROR;
//    int LmSetFnt("windows.kod");//ïîäêë.Windows-òàáë.êîäèðîâêè
//     //Ïîèñê ñëîâà äëÿ òåêóùåãî èäåíòèôèêàòîðà ÿçûêà
//     int SpellFindW(char *Word, char *buf, int n);
//     //Word - ñëîâî â âèäå xxx\0
//     //buf  - áóôåð ðåçóëüòàòà.
//     //n    - ìàêñèìàëüíîå êîëè÷åñòâî ïîäñêàçîê
//     //âìåñòî b_char ---->
//      unsigned SpellCharC(unsigned L, unsigned Letter);
//     //Ïîëó÷èòü õàðàêòåðèñòèêó ñèìâîëà Letter îòíîñèòåëüíî ÿçûêà L.
//     //Ôóíêöèÿ âîçâðàùàåò: 0 - ñèìâîë íå âõîäèò â àëôàâèò &0x1 - ìàëàÿ áóêâà
//     //    &0x2 - áîëüøàÿ áóêâà
//    SpellClose();
//    LmClose();
//}