summaryrefslogtreecommitdiff
path: root/recipes/vim/vim-7.2/001-411.diff
blob: 420ac937d34adbae04d74e0c2b442c12b582ba40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
24235
24236
24237
24238
24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24264
24265
24266
24267
24268
24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24355
24356
24357
24358
24359
24360
24361
24362
24363
24364
24365
24366
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376
24377
24378
24379
24380
24381
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393
24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
24441
24442
24443
24444
24445
24446
24447
24448
24449
24450
24451
24452
24453
24454
24455
24456
24457
24458
24459
24460
24461
24462
24463
24464
24465
24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
24502
24503
24504
24505
24506
24507
24508
24509
24510
24511
24512
24513
24514
24515
24516
24517
24518
24519
24520
24521
24522
24523
24524
24525
24526
24527
24528
24529
24530
24531
24532
24533
24534
24535
24536
24537
24538
24539
24540
24541
24542
24543
24544
24545
24546
24547
24548
24549
24550
24551
24552
24553
24554
24555
24556
24557
24558
24559
24560
24561
24562
24563
24564
24565
24566
24567
24568
24569
24570
24571
24572
24573
24574
24575
24576
24577
24578
24579
24580
24581
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596
24597
24598
24599
24600
24601
24602
24603
24604
24605
24606
24607
24608
24609
24610
24611
24612
24613
24614
24615
24616
24617
24618
24619
24620
24621
24622
24623
24624
24625
24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640
24641
24642
24643
24644
24645
24646
24647
24648
24649
24650
24651
24652
24653
24654
24655
24656
24657
24658
24659
24660
24661
24662
24663
24664
24665
24666
24667
24668
24669
24670
24671
24672
24673
24674
24675
24676
24677
24678
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
24698
24699
24700
24701
24702
24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807
24808
24809
24810
24811
24812
24813
24814
24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
24843
24844
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
24933
24934
24935
24936
24937
24938
24939
24940
24941
24942
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
25007
25008
25009
25010
25011
25012
25013
25014
25015
25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
25370
25371
25372
25373
25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401
25402
25403
25404
25405
25406
25407
25408
25409
25410
25411
25412
25413
25414
25415
25416
25417
25418
25419
25420
25421
25422
25423
25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458
25459
25460
25461
25462
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474
25475
25476
25477
25478
25479
25480
25481
25482
25483
25484
25485
25486
25487
25488
25489
25490
25491
25492
25493
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513
25514
25515
25516
25517
25518
25519
25520
25521
25522
25523
25524
25525
25526
25527
25528
25529
25530
25531
25532
25533
25534
25535
25536
25537
25538
25539
25540
25541
25542
25543
25544
25545
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
25561
25562
25563
25564
25565
25566
25567
25568
25569
25570
25571
25572
25573
25574
25575
25576
25577
25578
25579
25580
25581
25582
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596
25597
25598
25599
25600
25601
25602
25603
25604
25605
25606
25607
25608
25609
25610
25611
25612
25613
25614
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704
25705
25706
25707
25708
25709
25710
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
25738
25739
25740
25741
25742
25743
25744
25745
25746
25747
25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
25769
25770
25771
25772
25773
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803
25804
25805
25806
25807
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828
25829
25830
25831
25832
25833
25834
25835
25836
25837
25838
25839
25840
25841
25842
25843
25844
25845
25846
25847
25848
25849
25850
25851
25852
25853
25854
25855
25856
25857
25858
25859
25860
25861
25862
25863
25864
25865
25866
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
25931
25932
25933
25934
25935
25936
25937
25938
25939
25940
25941
25942
25943
25944
25945
25946
25947
25948
25949
25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
26019
26020
26021
26022
26023
26024
26025
26026
26027
26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
26071
26072
26073
26074
26075
26076
26077
26078
26079
26080
26081
26082
26083
26084
26085
26086
26087
26088
26089
26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
26100
26101
26102
26103
26104
26105
26106
26107
26108
26109
26110
26111
26112
26113
26114
26115
26116
26117
26118
26119
26120
26121
26122
26123
26124
26125
26126
26127
26128
26129
26130
26131
26132
26133
26134
26135
26136
26137
26138
26139
26140
26141
26142
26143
26144
26145
26146
26147
26148
26149
26150
26151
26152
26153
26154
26155
26156
26157
26158
26159
26160
26161
26162
26163
26164
26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
26175
26176
26177
26178
26179
26180
26181
26182
26183
26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
26194
26195
26196
26197
26198
26199
26200
26201
26202
26203
26204
26205
26206
26207
26208
26209
26210
26211
26212
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230
26231
26232
26233
26234
26235
26236
26237
26238
26239
26240
26241
26242
26243
26244
26245
26246
26247
26248
26249
26250
26251
26252
26253
26254
26255
26256
26257
26258
26259
26260
26261
26262
26263
26264
26265
26266
26267
26268
26269
26270
26271
26272
26273
26274
26275
26276
26277
26278
26279
26280
26281
26282
26283
26284
26285
26286
26287
26288
26289
26290
26291
26292
26293
26294
26295
26296
26297
26298
26299
26300
26301
26302
26303
26304
26305
26306
26307
26308
26309
26310
26311
26312
26313
26314
26315
26316
26317
26318
26319
26320
26321
26322
26323
26324
26325
26326
26327
26328
26329
26330
26331
26332
26333
26334
26335
26336
26337
26338
26339
26340
26341
26342
26343
26344
26345
26346
26347
26348
26349
26350
26351
26352
26353
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
26375
26376
26377
26378
26379
26380
26381
26382
26383
26384
26385
26386
26387
26388
26389
26390
26391
26392
26393
26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
26404
26405
26406
26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
26428
26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
26464
26465
26466
26467
26468
26469
26470
26471
26472
26473
26474
26475
26476
26477
26478
26479
26480
26481
26482
26483
26484
26485
26486
26487
26488
26489
26490
26491
26492
26493
26494
26495
26496
26497
26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
26510
26511
26512
26513
26514
26515
26516
26517
26518
26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
26530
26531
26532
26533
26534
26535
26536
26537
26538
26539
26540
26541
26542
26543
26544
26545
26546
26547
26548
26549
26550
26551
26552
26553
26554
26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
26568
26569
26570
26571
26572
26573
26574
26575
26576
26577
26578
26579
26580
26581
26582
26583
26584
26585
26586
26587
26588
26589
26590
26591
26592
26593
26594
26595
26596
26597
26598
26599
26600
26601
26602
26603
26604
26605
26606
26607
26608
26609
26610
26611
26612
26613
26614
26615
26616
26617
26618
26619
26620
26621
26622
26623
26624
26625
26626
26627
26628
26629
26630
26631
26632
26633
26634
26635
26636
26637
26638
26639
26640
26641
26642
26643
26644
26645
26646
26647
26648
26649
26650
26651
26652
26653
26654
26655
26656
26657
26658
26659
26660
26661
26662
26663
26664
26665
26666
26667
26668
26669
26670
26671
26672
26673
26674
26675
26676
26677
26678
26679
26680
26681
26682
26683
26684
26685
26686
26687
26688
26689
26690
26691
26692
26693
26694
26695
26696
26697
26698
26699
26700
26701
26702
26703
26704
26705
26706
26707
26708
26709
26710
26711
26712
26713
26714
26715
26716
26717
26718
26719
26720
26721
26722
26723
26724
26725
26726
26727
26728
26729
26730
26731
26732
26733
26734
26735
26736
26737
26738
26739
26740
26741
26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
26753
26754
26755
26756
26757
26758
26759
26760
26761
26762
26763
26764
26765
26766
26767
26768
26769
26770
26771
26772
26773
26774
26775
26776
26777
26778
26779
26780
26781
26782
26783
26784
26785
26786
26787
26788
26789
26790
26791
26792
26793
26794
26795
26796
26797
26798
26799
26800
26801
26802
26803
26804
26805
26806
26807
26808
26809
26810
26811
26812
26813
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823
26824
26825
26826
26827
26828
26829
26830
26831
26832
26833
26834
26835
26836
26837
26838
26839
26840
26841
26842
26843
26844
26845
26846
26847
26848
26849
26850
26851
26852
26853
26854
26855
26856
26857
26858
26859
26860
26861
26862
26863
26864
26865
26866
26867
26868
26869
26870
26871
26872
26873
26874
26875
26876
26877
26878
26879
26880
26881
26882
26883
26884
26885
26886
26887
26888
26889
26890
26891
26892
26893
26894
26895
26896
26897
26898
26899
26900
26901
26902
26903
26904
26905
26906
26907
26908
26909
26910
26911
26912
26913
26914
26915
26916
26917
26918
26919
26920
26921
26922
26923
26924
26925
26926
26927
26928
26929
26930
26931
26932
26933
26934
26935
26936
26937
26938
26939
26940
26941
26942
26943
26944
26945
26946
26947
26948
26949
26950
26951
26952
26953
26954
26955
26956
26957
26958
26959
26960
26961
26962
26963
26964
26965
26966
26967
26968
26969
26970
26971
26972
26973
26974
26975
26976
26977
26978
26979
26980
26981
26982
26983
26984
26985
26986
26987
26988
26989
26990
26991
26992
26993
26994
26995
26996
26997
26998
26999
27000
27001
27002
27003
27004
27005
27006
27007
27008
27009
27010
27011
27012
27013
27014
27015
27016
27017
27018
27019
27020
27021
27022
27023
27024
27025
27026
27027
27028
27029
27030
27031
27032
27033
27034
27035
27036
27037
27038
27039
27040
27041
27042
27043
27044
27045
27046
27047
27048
27049
27050
27051
27052
27053
27054
27055
27056
27057
27058
27059
27060
27061
27062
27063
27064
27065
27066
27067
27068
27069
27070
27071
27072
27073
27074
27075
27076
27077
27078
27079
27080
27081
27082
27083
27084
27085
27086
27087
27088
27089
27090
27091
27092
27093
27094
27095
27096
27097
27098
27099
27100
27101
27102
27103
27104
27105
27106
27107
27108
27109
27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129
27130
27131
27132
27133
27134
27135
27136
27137
27138
27139
27140
27141
27142
27143
27144
27145
27146
27147
27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165
27166
27167
27168
27169
27170
27171
27172
27173
27174
27175
27176
27177
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187
27188
27189
27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203
27204
27205
27206
27207
27208
27209
27210
27211
27212
27213
27214
27215
27216
27217
27218
27219
27220
27221
27222
27223
27224
27225
27226
27227
27228
27229
27230
27231
27232
27233
27234
27235
27236
27237
27238
27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253
27254
27255
27256
27257
27258
27259
27260
27261
27262
27263
27264
27265
27266
27267
27268
27269
27270
27271
27272
27273
27274
27275
27276
27277
27278
27279
27280
27281
27282
27283
27284
27285
27286
27287
27288
27289
27290
27291
27292
27293
27294
27295
27296
27297
27298
27299
27300
27301
27302
27303
27304
27305
27306
27307
27308
27309
27310
27311
27312
27313
27314
27315
27316
27317
27318
27319
27320
27321
27322
27323
27324
27325
27326
27327
27328
27329
27330
27331
27332
27333
27334
27335
27336
27337
27338
27339
27340
27341
27342
27343
27344
27345
27346
27347
27348
27349
27350
27351
27352
27353
27354
27355
27356
27357
27358
27359
27360
27361
27362
27363
27364
27365
27366
27367
27368
27369
27370
27371
27372
27373
27374
27375
27376
27377
27378
27379
27380
27381
27382
27383
27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
27399
27400
27401
27402
27403
27404
27405
27406
27407
27408
27409
27410
27411
27412
27413
27414
27415
27416
27417
27418
27419
27420
27421
27422
27423
27424
27425
27426
27427
27428
27429
27430
27431
27432
27433
27434
27435
27436
27437
27438
27439
27440
27441
27442
27443
27444
27445
27446
27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464
27465
27466
27467
27468
27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497
27498
27499
27500
27501
27502
27503
27504
27505
27506
27507
27508
27509
27510
27511
27512
27513
27514
27515
27516
27517
27518
27519
27520
27521
27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
27535
27536
27537
27538
27539
27540
27541
27542
27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
27556
27557
27558
27559
27560
27561
27562
27563
27564
27565
27566
27567
27568
27569
27570
27571
27572
27573
27574
27575
27576
27577
27578
27579
27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
27598
27599
27600
27601
27602
27603
27604
27605
27606
27607
27608
27609
27610
27611
27612
27613
27614
27615
27616
27617
27618
27619
27620
27621
27622
27623
27624
27625
27626
27627
27628
27629
27630
27631
27632
27633
27634
27635
27636
27637
27638
27639
27640
27641
27642
27643
27644
27645
27646
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661
27662
27663
27664
27665
27666
27667
27668
27669
27670
27671
27672
27673
27674
27675
27676
27677
27678
27679
27680
27681
27682
27683
27684
27685
27686
27687
27688
27689
27690
27691
27692
27693
27694
27695
27696
27697
27698
27699
27700
27701
27702
27703
27704
27705
27706
27707
27708
27709
27710
27711
27712
27713
27714
27715
27716
27717
27718
27719
27720
27721
27722
27723
27724
27725
27726
27727
27728
27729
27730
27731
27732
27733
27734
27735
27736
27737
27738
27739
27740
27741
27742
27743
27744
27745
27746
27747
27748
27749
27750
27751
27752
27753
27754
27755
27756
27757
27758
27759
27760
27761
27762
27763
27764
27765
27766
27767
27768
27769
27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813
27814
27815
27816
27817
27818
27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835
27836
27837
27838
27839
27840
27841
27842
27843
27844
27845
27846
27847
27848
27849
27850
27851
27852
27853
27854
27855
27856
27857
27858
27859
27860
27861
27862
27863
27864
27865
27866
27867
27868
27869
27870
27871
27872
27873
27874
27875
27876
27877
27878
27879
27880
27881
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896
27897
27898
27899
27900
27901
27902
27903
27904
27905
27906
27907
27908
27909
27910
27911
27912
27913
27914
27915
27916
27917
27918
27919
27920
27921
27922
27923
27924
27925
27926
27927
27928
27929
27930
27931
27932
27933
27934
27935
27936
27937
27938
27939
27940
27941
27942
27943
27944
27945
27946
27947
27948
27949
27950
27951
27952
27953
27954
27955
27956
27957
27958
27959
27960
27961
27962
27963
27964
27965
27966
27967
27968
27969
27970
27971
27972
27973
27974
27975
27976
27977
27978
27979
27980
27981
27982
27983
27984
27985
27986
27987
27988
27989
27990
27991
27992
27993
27994
27995
27996
27997
27998
27999
28000
28001
28002
28003
28004
28005
28006
28007
28008
28009
28010
28011
28012
28013
28014
28015
28016
28017
28018
28019
28020
28021
28022
28023
28024
28025
28026
28027
28028
28029
28030
28031
28032
28033
28034
28035
28036
28037
28038
28039
28040
28041
28042
28043
28044
28045
28046
28047
28048
28049
28050
28051
28052
28053
28054
28055
28056
28057
28058
28059
28060
28061
28062
28063
28064
28065
28066
28067
28068
28069
28070
28071
28072
28073
28074
28075
28076
28077
28078
28079
28080
28081
28082
28083
28084
28085
28086
28087
28088
28089
28090
28091
28092
28093
28094
28095
28096
28097
28098
28099
28100
28101
28102
28103
28104
28105
28106
28107
28108
28109
28110
28111
28112
28113
28114
28115
28116
28117
28118
28119
28120
28121
28122
28123
28124
28125
28126
28127
28128
28129
28130
28131
28132
28133
28134
28135
28136
28137
28138
28139
28140
28141
28142
28143
28144
28145
28146
28147
28148
28149
28150
28151
28152
28153
28154
28155
28156
28157
28158
28159
28160
28161
28162
28163
28164
28165
28166
28167
28168
28169
28170
28171
28172
28173
28174
28175
28176
28177
28178
28179
28180
28181
28182
28183
28184
28185
28186
28187
28188
28189
28190
28191
28192
28193
28194
28195
28196
28197
28198
28199
28200
28201
28202
28203
28204
28205
28206
28207
28208
28209
28210
28211
28212
28213
28214
28215
28216
28217
28218
28219
28220
28221
28222
28223
28224
28225
28226
28227
28228
28229
28230
28231
28232
28233
28234
28235
28236
28237
28238
28239
28240
28241
28242
28243
28244
28245
28246
28247
28248
28249
28250
28251
28252
28253
28254
28255
28256
28257
28258
28259
28260
28261
28262
28263
28264
28265
28266
28267
28268
28269
28270
28271
28272
28273
28274
28275
28276
28277
28278
28279
28280
28281
28282
28283
28284
28285
28286
28287
28288
28289
28290
28291
28292
28293
28294
28295
28296
28297
28298
28299
28300
28301
28302
28303
28304
28305
28306
28307
28308
28309
28310
28311
28312
28313
28314
28315
28316
28317
28318
28319
28320
28321
28322
28323
28324
28325
28326
28327
28328
28329
28330
28331
28332
28333
28334
28335
28336
28337
28338
28339
28340
28341
28342
28343
28344
28345
28346
28347
28348
28349
28350
28351
28352
28353
28354
28355
28356
28357
28358
28359
28360
28361
28362
28363
28364
28365
28366
28367
28368
28369
28370
28371
28372
28373
28374
28375
28376
28377
28378
28379
28380
28381
28382
28383
28384
28385
28386
28387
28388
28389
28390
28391
28392
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407
28408
28409
28410
28411
28412
28413
28414
28415
28416
28417
28418
28419
28420
28421
28422
28423
28424
28425
28426
28427
28428
28429
28430
28431
28432
28433
28434
28435
28436
28437
28438
28439
28440
28441
28442
28443
28444
28445
28446
28447
28448
28449
28450
28451
28452
28453
28454
28455
28456
28457
28458
28459
28460
28461
28462
28463
28464
28465
28466
28467
28468
28469
28470
28471
28472
28473
28474
28475
28476
28477
28478
28479
28480
28481
28482
28483
28484
28485
28486
28487
28488
28489
28490
28491
28492
28493
28494
28495
28496
28497
28498
28499
28500
28501
28502
28503
28504
28505
28506
28507
28508
28509
28510
28511
28512
28513
28514
28515
28516
28517
28518
28519
28520
28521
28522
28523
28524
28525
28526
28527
28528
28529
28530
28531
28532
28533
28534
28535
28536
28537
28538
28539
28540
28541
28542
28543
28544
28545
28546
28547
28548
28549
28550
28551
28552
28553
28554
28555
28556
28557
28558
28559
28560
28561
28562
28563
28564
28565
28566
28567
28568
28569
28570
28571
28572
28573
28574
28575
28576
28577
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588
28589
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
28609
28610
28611
28612
28613
28614
28615
28616
28617
28618
28619
28620
28621
28622
28623
28624
28625
28626
28627
28628
28629
28630
28631
28632
28633
28634
28635
28636
28637
28638
28639
28640
28641
28642
28643
28644
28645
28646
28647
28648
28649
28650
28651
28652
28653
28654
28655
28656
28657
28658
28659
28660
28661
28662
28663
28664
28665
28666
28667
28668
28669
28670
28671
28672
28673
28674
28675
28676
28677
28678
28679
28680
28681
28682
28683
28684
28685
28686
28687
28688
28689
28690
28691
28692
28693
28694
28695
28696
28697
28698
28699
28700
28701
28702
28703
28704
28705
28706
28707
28708
28709
28710
28711
28712
28713
28714
28715
28716
28717
28718
28719
28720
28721
28722
28723
28724
28725
28726
28727
28728
28729
28730
28731
28732
28733
28734
28735
28736
28737
28738
28739
28740
28741
28742
28743
28744
28745
28746
28747
28748
28749
28750
28751
28752
28753
28754
28755
28756
28757
28758
28759
28760
28761
28762
28763
28764
28765
28766
28767
28768
28769
28770
28771
28772
28773
28774
28775
28776
28777
28778
28779
28780
28781
28782
28783
28784
28785
28786
28787
28788
28789
28790
28791
28792
28793
28794
28795
28796
28797
28798
28799
28800
28801
28802
28803
28804
28805
28806
28807
28808
28809
28810
28811
28812
28813
28814
28815
28816
28817
28818
28819
28820
28821
28822
28823
28824
28825
28826
28827
28828
28829
28830
28831
28832
28833
28834
28835
28836
28837
28838
28839
28840
28841
28842
28843
28844
28845
28846
28847
28848
28849
28850
28851
28852
28853
28854
28855
28856
28857
28858
28859
28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
28871
28872
28873
28874
28875
28876
28877
28878
28879
28880
28881
28882
28883
28884
28885
28886
28887
28888
28889
28890
28891
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
28905
28906
28907
28908
28909
28910
28911
28912
28913
28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
28928
28929
28930
28931
28932
28933
28934
28935
28936
28937
28938
28939
28940
28941
28942
28943
28944
28945
28946
28947
28948
28949
28950
28951
28952
28953
28954
28955
28956
28957
28958
28959
28960
28961
28962
28963
28964
28965
28966
28967
28968
28969
28970
28971
28972
28973
28974
28975
28976
28977
28978
28979
28980
28981
28982
28983
28984
28985
28986
28987
28988
28989
28990
28991
28992
28993
28994
28995
28996
28997
28998
28999
29000
29001
29002
29003
29004
29005
29006
29007
29008
29009
29010
29011
29012
29013
29014
29015
29016
29017
29018
29019
29020
29021
29022
29023
29024
29025
29026
29027
29028
29029
29030
29031
29032
29033
29034
29035
29036
29037
29038
29039
29040
29041
29042
29043
29044
29045
29046
29047
29048
29049
29050
29051
29052
29053
29054
29055
29056
29057
29058
29059
29060
29061
29062
29063
29064
29065
29066
29067
29068
29069
29070
29071
29072
29073
29074
29075
29076
29077
29078
29079
29080
29081
29082
29083
29084
29085
29086
29087
29088
29089
29090
29091
29092
29093
29094
29095
29096
29097
29098
29099
29100
29101
29102
29103
29104
29105
29106
29107
29108
29109
29110
29111
29112
29113
29114
29115
29116
29117
29118
29119
29120
29121
29122
29123
29124
29125
29126
29127
29128
29129
29130
29131
29132
29133
29134
29135
29136
29137
29138
29139
29140
29141
29142
29143
29144
29145
29146
29147
29148
29149
29150
29151
29152
29153
29154
29155
29156
29157
29158
29159
29160
29161
29162
29163
29164
29165
29166
29167
29168
29169
29170
29171
29172
29173
29174
29175
29176
29177
29178
29179
29180
29181
29182
29183
29184
29185
29186
29187
29188
29189
29190
29191
29192
29193
29194
29195
29196
29197
29198
29199
29200
29201
29202
29203
29204
29205
29206
29207
29208
29209
29210
29211
29212
29213
29214
29215
29216
29217
29218
29219
29220
29221
29222
29223
29224
29225
29226
29227
29228
29229
29230
29231
29232
29233
29234
29235
29236
29237
29238
29239
29240
29241
29242
29243
29244
29245
29246
29247
29248
29249
29250
29251
29252
29253
29254
29255
29256
29257
29258
29259
29260
29261
29262
29263
29264
29265
29266
29267
29268
29269
29270
29271
29272
29273
29274
29275
29276
29277
29278
29279
29280
29281
29282
29283
29284
29285
29286
29287
29288
29289
29290
29291
29292
29293
29294
29295
29296
29297
29298
29299
29300
29301
29302
29303
29304
29305
29306
29307
29308
29309
29310
29311
29312
29313
29314
29315
29316
29317
29318
29319
29320
29321
29322
29323
29324
29325
29326
29327
29328
29329
29330
29331
29332
29333
29334
29335
29336
29337
29338
29339
29340
29341
29342
29343
29344
29345
29346
29347
29348
29349
29350
29351
29352
29353
29354
29355
29356
29357
29358
29359
29360
29361
29362
29363
29364
29365
29366
29367
29368
29369
29370
29371
29372
29373
29374
29375
29376
29377
29378
29379
29380
29381
29382
29383
29384
29385
29386
29387
29388
29389
29390
29391
29392
29393
29394
29395
29396
29397
29398
29399
29400
29401
29402
29403
29404
29405
29406
29407
29408
29409
29410
29411
29412
29413
29414
29415
29416
29417
29418
29419
29420
29421
29422
29423
29424
29425
29426
29427
29428
29429
29430
29431
29432
29433
29434
29435
29436
29437
29438
29439
29440
29441
29442
29443
29444
29445
29446
29447
29448
29449
29450
29451
29452
29453
29454
29455
29456
29457
29458
29459
29460
29461
29462
29463
29464
29465
29466
29467
29468
29469
29470
29471
29472
29473
29474
29475
29476
29477
29478
29479
29480
29481
29482
29483
29484
29485
29486
29487
29488
29489
29490
29491
29492
29493
29494
29495
29496
29497
29498
29499
29500
29501
29502
29503
29504
29505
29506
29507
29508
29509
29510
29511
29512
29513
29514
29515
29516
29517
29518
29519
29520
29521
29522
29523
29524
29525
29526
29527
29528
29529
29530
29531
29532
29533
29534
29535
29536
29537
29538
29539
29540
29541
29542
29543
29544
29545
29546
29547
29548
29549
29550
29551
29552
29553
29554
29555
29556
29557
29558
29559
29560
29561
29562
29563
29564
29565
29566
29567
29568
29569
29570
29571
29572
29573
29574
29575
29576
29577
29578
29579
29580
29581
29582
29583
29584
29585
29586
29587
29588
29589
29590
29591
29592
29593
29594
29595
29596
29597
29598
29599
29600
29601
29602
29603
29604
29605
29606
29607
29608
29609
29610
29611
29612
29613
29614
29615
29616
29617
29618
29619
29620
29621
29622
29623
29624
29625
29626
29627
29628
29629
29630
29631
29632
29633
29634
29635
29636
29637
29638
29639
29640
29641
29642
29643
29644
29645
29646
29647
29648
29649
29650
29651
29652
29653
29654
29655
29656
29657
29658
29659
29660
29661
29662
29663
29664
29665
29666
29667
29668
29669
29670
29671
29672
29673
29674
29675
29676
29677
29678
29679
29680
29681
29682
29683
29684
29685
29686
29687
29688
29689
29690
29691
29692
29693
29694
29695
29696
29697
29698
29699
29700
29701
29702
29703
29704
29705
29706
29707
29708
29709
29710
29711
29712
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722
29723
29724
29725
29726
29727
29728
29729
29730
29731
29732
29733
29734
29735
29736
29737
29738
29739
29740
29741
29742
29743
29744
29745
29746
29747
29748
29749
29750
29751
29752
29753
29754
29755
29756
29757
29758
29759
29760
29761
29762
29763
29764
29765
29766
29767
29768
29769
29770
29771
29772
29773
29774
29775
29776
29777
29778
29779
29780
29781
29782
29783
29784
29785
29786
29787
29788
29789
29790
29791
29792
29793
29794
29795
29796
29797
29798
29799
29800
29801
29802
29803
29804
29805
29806
29807
29808
29809
29810
29811
29812
29813
29814
29815
29816
29817
29818
29819
29820
29821
29822
29823
29824
29825
29826
29827
29828
29829
29830
29831
29832
29833
29834
29835
29836
29837
29838
29839
29840
29841
29842
29843
29844
29845
29846
29847
29848
29849
29850
29851
29852
29853
29854
29855
29856
29857
29858
29859
29860
29861
29862
29863
29864
29865
29866
29867
29868
29869
29870
29871
29872
29873
29874
29875
29876
29877
29878
29879
29880
29881
29882
29883
29884
29885
29886
29887
29888
29889
29890
29891
29892
29893
29894
29895
29896
29897
29898
29899
29900
29901
29902
29903
29904
29905
29906
29907
29908
29909
29910
29911
29912
29913
29914
29915
29916
29917
29918
29919
29920
29921
29922
29923
29924
29925
29926
29927
29928
29929
29930
29931
29932
29933
29934
29935
29936
29937
29938
29939
29940
29941
29942
29943
29944
29945
29946
29947
29948
29949
29950
29951
29952
29953
29954
29955
29956
29957
29958
29959
29960
29961
29962
29963
29964
29965
29966
29967
29968
29969
29970
29971
29972
29973
29974
29975
29976
29977
29978
29979
29980
29981
29982
29983
29984
29985
29986
29987
29988
29989
29990
29991
29992
29993
29994
29995
29996
29997
29998
29999
30000
30001
30002
30003
30004
30005
30006
30007
30008
30009
30010
30011
30012
30013
30014
30015
30016
30017
30018
30019
30020
30021
30022
30023
30024
30025
30026
30027
30028
30029
30030
30031
30032
30033
30034
30035
30036
30037
30038
30039
30040
30041
30042
30043
30044
30045
30046
30047
30048
30049
30050
30051
30052
30053
30054
30055
30056
30057
30058
30059
30060
30061
30062
30063
30064
30065
30066
30067
30068
30069
30070
30071
30072
30073
30074
30075
30076
30077
30078
30079
30080
30081
30082
30083
30084
30085
30086
30087
30088
30089
30090
30091
30092
30093
30094
30095
30096
30097
30098
30099
30100
30101
30102
30103
30104
30105
30106
30107
30108
30109
30110
30111
30112
30113
30114
30115
30116
30117
30118
30119
30120
30121
30122
30123
30124
30125
30126
30127
30128
30129
30130
30131
30132
30133
30134
30135
30136
30137
30138
30139
30140
30141
30142
30143
30144
30145
30146
30147
30148
30149
30150
30151
30152
30153
30154
30155
30156
30157
30158
30159
30160
30161
30162
30163
30164
30165
30166
30167
30168
30169
30170
30171
30172
30173
30174
30175
30176
30177
30178
30179
30180
30181
30182
30183
30184
30185
30186
30187
30188
30189
30190
30191
30192
30193
30194
30195
30196
30197
30198
30199
30200
30201
30202
30203
30204
30205
30206
30207
30208
30209
30210
30211
30212
30213
30214
30215
30216
30217
30218
30219
30220
30221
30222
30223
30224
30225
30226
30227
30228
30229
30230
30231
30232
30233
30234
30235
30236
30237
30238
30239
30240
30241
30242
30243
30244
30245
30246
30247
30248
30249
30250
30251
30252
30253
30254
30255
30256
30257
30258
30259
30260
30261
30262
30263
30264
30265
30266
30267
30268
30269
30270
30271
30272
30273
30274
30275
30276
30277
30278
30279
30280
30281
30282
30283
30284
30285
30286
30287
30288
30289
30290
30291
30292
30293
30294
30295
30296
30297
30298
30299
30300
30301
30302
30303
30304
30305
30306
30307
30308
30309
30310
30311
30312
30313
30314
30315
30316
30317
30318
30319
30320
30321
30322
30323
30324
30325
30326
30327
30328
30329
30330
30331
30332
30333
30334
30335
30336
30337
30338
30339
30340
30341
30342
30343
30344
30345
30346
30347
30348
30349
30350
30351
30352
30353
30354
30355
30356
30357
30358
30359
30360
30361
30362
30363
30364
30365
30366
30367
30368
30369
30370
30371
30372
30373
30374
30375
30376
30377
30378
30379
30380
30381
30382
30383
30384
30385
30386
30387
30388
30389
30390
30391
30392
30393
30394
30395
30396
30397
30398
30399
30400
30401
30402
30403
30404
30405
30406
30407
30408
30409
30410
30411
30412
30413
30414
30415
30416
30417
30418
30419
30420
30421
30422
30423
30424
30425
30426
30427
30428
30429
30430
30431
30432
30433
30434
30435
30436
30437
30438
30439
30440
30441
30442
30443
30444
30445
30446
30447
30448
30449
30450
30451
30452
30453
30454
30455
30456
30457
30458
30459
30460
30461
30462
30463
30464
30465
30466
30467
30468
30469
30470
30471
30472
30473
30474
30475
30476
30477
30478
30479
30480
30481
30482
30483
30484
30485
30486
30487
30488
30489
30490
30491
30492
30493
30494
30495
30496
30497
30498
30499
30500
30501
30502
30503
30504
30505
30506
30507
30508
30509
30510
30511
30512
30513
30514
30515
30516
30517
30518
30519
30520
30521
30522
30523
30524
30525
30526
30527
30528
30529
30530
30531
30532
30533
30534
30535
30536
30537
30538
30539
30540
30541
30542
30543
30544
30545
30546
30547
30548
30549
30550
30551
30552
30553
30554
30555
30556
30557
30558
30559
30560
30561
30562
30563
30564
30565
30566
30567
30568
30569
30570
30571
30572
30573
30574
30575
30576
30577
30578
30579
30580
30581
30582
30583
30584
30585
30586
30587
30588
30589
30590
30591
30592
30593
30594
30595
30596
30597
30598
30599
30600
30601
30602
30603
30604
30605
30606
30607
30608
30609
30610
30611
30612
30613
30614
30615
30616
30617
30618
30619
30620
30621
30622
30623
30624
30625
30626
30627
30628
30629
30630
30631
30632
30633
30634
30635
30636
30637
30638
30639
30640
30641
30642
30643
30644
30645
30646
30647
30648
30649
30650
30651
30652
30653
30654
30655
30656
30657
30658
30659
30660
30661
30662
30663
30664
30665
30666
30667
30668
30669
30670
30671
30672
30673
30674
30675
30676
30677
30678
30679
30680
30681
30682
30683
30684
30685
30686
30687
30688
30689
30690
30691
30692
30693
30694
30695
30696
30697
30698
30699
30700
30701
30702
30703
30704
30705
30706
30707
30708
30709
30710
30711
30712
30713
30714
30715
30716
30717
30718
30719
30720
30721
30722
30723
30724
30725
30726
30727
30728
30729
30730
30731
30732
30733
30734
30735
30736
30737
30738
30739
30740
30741
30742
30743
30744
30745
30746
30747
30748
30749
30750
30751
30752
30753
30754
30755
30756
30757
30758
30759
30760
30761
30762
30763
30764
30765
30766
30767
30768
30769
30770
30771
30772
30773
30774
30775
30776
30777
30778
30779
30780
30781
30782
30783
30784
30785
30786
30787
30788
30789
30790
30791
30792
30793
30794
30795
30796
30797
30798
30799
30800
30801
30802
30803
30804
30805
30806
30807
30808
30809
30810
30811
30812
30813
30814
30815
30816
30817
30818
30819
30820
30821
30822
30823
30824
30825
30826
30827
30828
30829
30830
30831
30832
30833
30834
30835
30836
30837
30838
30839
30840
30841
30842
30843
30844
30845
30846
30847
30848
30849
30850
30851
30852
30853
30854
30855
30856
30857
30858
30859
30860
30861
30862
30863
30864
30865
30866
30867
30868
30869
30870
30871
30872
30873
30874
30875
30876
30877
30878
30879
30880
30881
30882
30883
30884
30885
30886
30887
30888
30889
30890
30891
30892
30893
30894
30895
30896
30897
30898
30899
30900
30901
30902
30903
30904
30905
30906
30907
30908
30909
30910
30911
30912
30913
30914
30915
30916
30917
30918
30919
30920
30921
30922
30923
30924
30925
30926
30927
30928
30929
30930
30931
30932
30933
30934
30935
30936
30937
30938
30939
30940
30941
30942
30943
30944
30945
30946
30947
30948
30949
30950
30951
30952
30953
30954
30955
30956
30957
30958
30959
30960
30961
30962
30963
30964
30965
30966
30967
30968
30969
30970
30971
30972
30973
30974
30975
30976
30977
30978
30979
30980
30981
30982
30983
30984
30985
30986
30987
30988
30989
30990
30991
30992
30993
30994
30995
30996
30997
30998
30999
31000
31001
31002
31003
31004
31005
31006
31007
31008
31009
31010
31011
31012
31013
31014
31015
31016
31017
31018
31019
31020
31021
31022
31023
31024
31025
31026
31027
31028
31029
31030
31031
31032
31033
31034
31035
31036
31037
31038
31039
31040
31041
31042
31043
31044
31045
31046
31047
31048
31049
31050
31051
31052
31053
31054
31055
31056
31057
31058
31059
31060
31061
31062
31063
31064
31065
31066
31067
31068
31069
31070
31071
31072
31073
31074
31075
31076
31077
31078
31079
31080
31081
31082
31083
31084
31085
31086
31087
31088
31089
31090
31091
31092
31093
31094
31095
31096
31097
31098
31099
31100
31101
31102
31103
31104
31105
31106
31107
31108
31109
31110
31111
31112
31113
31114
31115
31116
31117
31118
31119
31120
31121
31122
31123
31124
31125
31126
31127
31128
31129
31130
31131
31132
31133
31134
31135
31136
31137
31138
31139
31140
31141
31142
31143
31144
31145
31146
31147
31148
31149
31150
31151
31152
31153
31154
31155
31156
31157
31158
31159
31160
31161
31162
31163
31164
31165
31166
31167
31168
31169
31170
31171
31172
31173
31174
31175
31176
31177
31178
31179
31180
31181
31182
31183
31184
31185
31186
31187
31188
31189
31190
31191
31192
31193
31194
31195
31196
31197
31198
31199
31200
31201
31202
31203
31204
31205
31206
31207
31208
31209
31210
31211
31212
31213
31214
31215
31216
31217
31218
31219
31220
31221
31222
31223
31224
31225
31226
31227
31228
31229
31230
31231
31232
31233
31234
31235
31236
31237
31238
31239
31240
31241
31242
31243
31244
31245
31246
31247
31248
31249
31250
31251
31252
31253
31254
31255
31256
31257
31258
31259
31260
31261
31262
31263
31264
31265
31266
31267
31268
31269
31270
31271
31272
31273
31274
31275
31276
31277
31278
31279
31280
31281
31282
31283
31284
31285
31286
31287
31288
31289
31290
31291
31292
31293
31294
31295
31296
31297
31298
31299
31300
31301
31302
31303
31304
31305
31306
31307
31308
31309
31310
31311
31312
31313
31314
31315
31316
31317
31318
31319
31320
31321
31322
31323
31324
31325
31326
31327
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338
31339
31340
31341
31342
31343
31344
31345
31346
31347
31348
31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
31361
31362
31363
31364
31365
31366
31367
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390
31391
31392
31393
31394
31395
31396
31397
31398
31399
31400
31401
31402
31403
31404
31405
31406
31407
31408
31409
31410
31411
31412
31413
31414
31415
31416
31417
31418
31419
31420
31421
31422
31423
31424
31425
31426
31427
31428
31429
31430
31431
31432
31433
31434
31435
31436
31437
31438
31439
31440
31441
31442
31443
31444
31445
31446
31447
31448
31449
31450
31451
31452
31453
31454
31455
31456
31457
31458
31459
31460
31461
31462
31463
31464
31465
31466
31467
31468
31469
31470
31471
31472
31473
31474
31475
31476
31477
31478
31479
31480
31481
31482
31483
31484
31485
31486
31487
31488
31489
31490
31491
31492
31493
31494
31495
31496
31497
31498
31499
31500
31501
31502
31503
31504
31505
31506
31507
31508
31509
31510
31511
31512
31513
31514
31515
31516
31517
31518
31519
31520
31521
31522
31523
31524
31525
31526
31527
31528
31529
31530
31531
31532
31533
31534
31535
31536
31537
31538
31539
31540
31541
31542
31543
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559
31560
31561
31562
31563
31564
31565
31566
31567
31568
31569
31570
31571
31572
31573
31574
31575
31576
31577
31578
31579
31580
31581
31582
31583
31584
31585
31586
31587
31588
31589
31590
31591
31592
31593
31594
31595
31596
31597
31598
31599
31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
31618
31619
31620
31621
31622
31623
31624
31625
31626
31627
31628
31629
31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
31644
31645
31646
31647
31648
31649
31650
31651
31652
31653
31654
31655
31656
31657
31658
31659
31660
31661
31662
31663
31664
31665
31666
31667
31668
31669
31670
31671
31672
31673
31674
31675
31676
31677
31678
31679
31680
31681
31682
31683
31684
31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825
31826
31827
31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
31838
31839
31840
31841
31842
31843
31844
31845
31846
31847
31848
31849
31850
31851
31852
31853
31854
31855
31856
31857
31858
31859
31860
31861
31862
31863
31864
31865
31866
31867
31868
31869
31870
31871
31872
31873
31874
31875
31876
31877
31878
31879
31880
31881
31882
31883
31884
31885
31886
31887
31888
31889
31890
31891
31892
31893
31894
31895
31896
31897
31898
31899
31900
31901
31902
31903
31904
31905
31906
31907
31908
31909
31910
31911
31912
31913
31914
31915
31916
31917
31918
31919
31920
31921
31922
31923
31924
31925
31926
31927
31928
31929
31930
31931
31932
31933
31934
31935
31936
31937
31938
31939
31940
31941
31942
31943
31944
31945
31946
31947
31948
31949
31950
31951
31952
31953
31954
31955
31956
31957
31958
31959
31960
31961
31962
31963
31964
31965
31966
31967
31968
31969
31970
31971
31972
31973
31974
31975
31976
31977
31978
31979
31980
31981
31982
31983
31984
31985
31986
31987
31988
31989
31990
31991
31992
31993
31994
31995
31996
31997
31998
31999
32000
32001
32002
32003
32004
32005
32006
32007
32008
32009
32010
32011
32012
32013
32014
32015
32016
32017
32018
32019
32020
32021
32022
32023
32024
32025
32026
32027
32028
32029
32030
32031
32032
32033
32034
32035
32036
32037
32038
32039
32040
32041
32042
32043
32044
32045
32046
32047
32048
32049
32050
32051
32052
32053
32054
32055
32056
32057
32058
32059
32060
32061
32062
32063
32064
32065
32066
32067
32068
32069
32070
32071
32072
32073
32074
32075
32076
32077
32078
32079
32080
32081
32082
32083
32084
32085
32086
32087
32088
32089
32090
32091
32092
32093
32094
32095
32096
32097
32098
32099
32100
32101
32102
32103
32104
32105
32106
32107
32108
32109
32110
32111
32112
32113
32114
32115
32116
32117
32118
32119
32120
32121
32122
32123
32124
32125
32126
32127
32128
32129
32130
32131
32132
32133
32134
32135
32136
32137
32138
32139
32140
32141
32142
32143
32144
32145
32146
32147
32148
32149
32150
32151
32152
32153
32154
32155
32156
32157
32158
32159
32160
32161
32162
32163
32164
32165
32166
32167
32168
32169
32170
32171
32172
32173
32174
32175
32176
32177
32178
32179
32180
32181
32182
32183
32184
32185
32186
32187
32188
32189
32190
32191
32192
32193
32194
32195
32196
32197
32198
32199
32200
32201
32202
32203
32204
32205
32206
32207
32208
32209
32210
32211
32212
32213
32214
32215
32216
32217
32218
32219
32220
32221
32222
32223
32224
32225
32226
32227
32228
32229
32230
32231
32232
32233
32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
32254
32255
32256
32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
32268
32269
32270
32271
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284
32285
32286
32287
32288
32289
32290
32291
32292
32293
32294
32295
32296
32297
32298
32299
32300
32301
32302
32303
32304
32305
32306
32307
32308
32309
32310
32311
32312
32313
32314
32315
32316
32317
32318
32319
32320
32321
32322
32323
32324
32325
32326
32327
32328
32329
32330
32331
32332
32333
32334
32335
32336
32337
32338
32339
32340
32341
32342
32343
32344
32345
32346
32347
32348
32349
32350
32351
32352
32353
32354
32355
32356
32357
32358
32359
32360
32361
32362
32363
32364
32365
32366
32367
32368
32369
32370
32371
32372
32373
32374
32375
32376
32377
32378
32379
32380
32381
32382
32383
32384
32385
32386
32387
32388
32389
32390
32391
32392
32393
32394
32395
32396
32397
32398
32399
32400
32401
32402
32403
32404
32405
32406
32407
32408
32409
32410
32411
32412
32413
32414
32415
32416
32417
32418
32419
32420
32421
32422
32423
32424
32425
32426
32427
32428
32429
32430
32431
32432
32433
32434
32435
32436
32437
32438
32439
32440
32441
32442
32443
32444
32445
32446
32447
32448
32449
32450
32451
32452
32453
32454
32455
32456
32457
32458
32459
32460
32461
32462
32463
32464
32465
32466
32467
32468
32469
32470
32471
32472
32473
32474
32475
32476
32477
32478
32479
32480
32481
32482
32483
32484
32485
32486
32487
32488
32489
32490
32491
32492
32493
32494
32495
32496
32497
32498
32499
32500
32501
32502
32503
32504
32505
32506
32507
32508
32509
32510
32511
32512
32513
32514
32515
32516
32517
32518
32519
32520
32521
32522
32523
32524
32525
32526
32527
32528
32529
32530
32531
32532
32533
32534
32535
32536
32537
32538
32539
32540
32541
32542
32543
32544
32545
32546
32547
32548
32549
32550
32551
32552
32553
32554
32555
32556
32557
32558
32559
32560
32561
32562
32563
32564
32565
32566
32567
32568
32569
32570
32571
32572
32573
32574
32575
32576
32577
32578
32579
32580
32581
32582
32583
32584
32585
32586
32587
32588
32589
32590
32591
32592
32593
32594
32595
32596
32597
32598
32599
32600
32601
32602
32603
32604
32605
32606
32607
32608
32609
32610
32611
32612
32613
32614
32615
32616
32617
32618
32619
32620
32621
32622
32623
32624
32625
32626
32627
32628
32629
32630
32631
32632
32633
32634
32635
32636
32637
32638
32639
32640
32641
32642
32643
32644
32645
32646
32647
32648
32649
32650
32651
32652
32653
32654
32655
32656
32657
32658
32659
32660
32661
32662
32663
32664
32665
32666
32667
32668
32669
32670
32671
32672
32673
32674
32675
32676
32677
32678
32679
32680
32681
32682
32683
32684
32685
32686
32687
32688
32689
32690
32691
32692
32693
32694
32695
32696
32697
32698
32699
32700
32701
32702
32703
32704
32705
32706
32707
32708
32709
32710
32711
32712
32713
32714
32715
32716
32717
32718
32719
32720
32721
32722
32723
32724
32725
32726
32727
32728
32729
32730
32731
32732
32733
32734
32735
32736
32737
32738
32739
32740
32741
32742
32743
32744
32745
32746
32747
32748
32749
32750
32751
32752
32753
32754
32755
32756
32757
32758
32759
32760
32761
32762
32763
32764
32765
32766
32767
32768
32769
32770
32771
32772
32773
32774
32775
32776
32777
32778
32779
32780
32781
32782
32783
32784
32785
32786
32787
32788
32789
32790
32791
32792
32793
32794
32795
32796
32797
32798
32799
32800
32801
32802
32803
32804
32805
32806
32807
32808
32809
32810
32811
32812
32813
32814
32815
32816
32817
32818
32819
32820
32821
32822
32823
32824
32825
32826
32827
32828
32829
32830
32831
32832
32833
32834
32835
32836
32837
32838
32839
32840
32841
32842
32843
32844
32845
32846
32847
32848
32849
32850
32851
32852
32853
32854
32855
32856
32857
32858
32859
32860
32861
32862
32863
32864
32865
32866
32867
32868
32869
32870
32871
32872
32873
32874
32875
32876
32877
32878
32879
32880
32881
32882
32883
32884
32885
32886
32887
32888
32889
32890
32891
32892
32893
32894
32895
32896
32897
32898
32899
32900
32901
32902
32903
32904
32905
32906
32907
32908
32909
32910
32911
32912
32913
32914
32915
32916
32917
32918
32919
32920
32921
32922
32923
32924
32925
32926
32927
32928
32929
32930
32931
32932
32933
32934
32935
32936
32937
32938
32939
32940
32941
32942
32943
32944
32945
32946
32947
32948
32949
32950
32951
32952
32953
32954
32955
32956
32957
32958
32959
32960
32961
32962
32963
32964
32965
32966
32967
32968
32969
32970
32971
32972
32973
32974
32975
32976
32977
32978
32979
32980
32981
32982
32983
32984
32985
32986
32987
32988
32989
32990
32991
32992
32993
32994
32995
32996
32997
32998
32999
33000
33001
33002
33003
33004
33005
33006
33007
33008
33009
33010
33011
33012
33013
33014
33015
33016
33017
33018
33019
33020
33021
33022
33023
33024
33025
33026
33027
33028
33029
33030
33031
33032
33033
33034
33035
33036
33037
33038
33039
33040
33041
33042
33043
33044
33045
33046
33047
33048
33049
33050
33051
33052
33053
33054
33055
33056
33057
33058
33059
33060
33061
33062
33063
33064
33065
33066
33067
33068
33069
33070
33071
33072
33073
33074
33075
33076
33077
33078
33079
33080
33081
33082
33083
33084
33085
33086
33087
33088
33089
33090
33091
33092
33093
33094
33095
33096
33097
33098
33099
33100
33101
33102
33103
33104
33105
33106
33107
33108
33109
33110
33111
33112
33113
33114
33115
33116
33117
33118
33119
33120
33121
33122
33123
33124
33125
33126
33127
33128
33129
33130
33131
33132
33133
33134
33135
33136
33137
33138
33139
33140
33141
33142
33143
33144
33145
33146
33147
33148
33149
33150
33151
33152
33153
33154
33155
33156
33157
33158
33159
33160
33161
33162
33163
33164
33165
33166
33167
33168
33169
33170
33171
33172
33173
33174
33175
33176
33177
33178
33179
33180
33181
33182
33183
33184
33185
33186
33187
33188
33189
33190
33191
33192
33193
33194
33195
33196
33197
33198
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211
33212
33213
33214
33215
33216
33217
33218
33219
33220
33221
33222
33223
33224
33225
33226
33227
33228
33229
33230
33231
33232
33233
33234
33235
33236
33237
33238
33239
33240
33241
33242
33243
33244
33245
33246
33247
33248
33249
33250
33251
33252
33253
33254
33255
33256
33257
33258
33259
33260
33261
33262
33263
33264
33265
33266
33267
33268
33269
33270
33271
33272
33273
33274
33275
33276
33277
33278
33279
33280
33281
33282
33283
33284
33285
33286
33287
33288
33289
33290
33291
33292
33293
33294
33295
33296
33297
33298
33299
33300
33301
33302
33303
33304
33305
33306
33307
33308
33309
33310
33311
33312
33313
33314
33315
33316
33317
33318
33319
33320
33321
33322
33323
33324
33325
33326
33327
33328
33329
33330
33331
33332
33333
33334
33335
33336
33337
33338
33339
33340
33341
33342
33343
33344
33345
33346
33347
33348
33349
33350
33351
33352
33353
33354
33355
33356
33357
33358
33359
33360
33361
33362
33363
33364
33365
33366
33367
33368
33369
33370
33371
33372
33373
33374
33375
33376
33377
33378
33379
33380
33381
33382
33383
33384
33385
33386
33387
33388
33389
33390
33391
33392
33393
33394
33395
33396
33397
33398
33399
33400
33401
33402
33403
33404
33405
33406
33407
33408
33409
33410
33411
33412
33413
33414
33415
33416
33417
33418
33419
33420
33421
33422
33423
33424
33425
33426
33427
33428
33429
33430
33431
33432
33433
33434
33435
33436
33437
33438
33439
33440
33441
33442
33443
33444
33445
33446
33447
33448
33449
33450
33451
33452
33453
33454
33455
33456
33457
33458
33459
33460
33461
33462
33463
33464
33465
33466
33467
33468
33469
33470
33471
33472
33473
33474
33475
33476
33477
33478
33479
33480
33481
33482
33483
33484
33485
33486
33487
33488
33489
33490
33491
33492
33493
33494
33495
33496
33497
33498
33499
33500
33501
33502
33503
33504
33505
33506
33507
33508
33509
33510
33511
33512
33513
33514
33515
33516
33517
33518
33519
33520
33521
33522
33523
33524
33525
33526
33527
33528
33529
33530
33531
33532
33533
33534
33535
33536
33537
33538
33539
33540
33541
33542
33543
33544
33545
33546
33547
33548
33549
33550
33551
33552
33553
33554
33555
33556
33557
33558
33559
33560
33561
33562
33563
33564
33565
33566
33567
33568
33569
33570
33571
33572
33573
33574
33575
33576
33577
33578
33579
33580
33581
33582
33583
33584
33585
33586
33587
33588
33589
33590
33591
33592
33593
33594
33595
33596
33597
33598
33599
33600
33601
33602
33603
33604
33605
33606
33607
33608
33609
33610
33611
33612
33613
33614
33615
33616
33617
33618
33619
33620
33621
33622
33623
33624
33625
33626
33627
33628
33629
33630
33631
33632
33633
33634
33635
33636
33637
33638
33639
33640
33641
33642
33643
33644
33645
33646
33647
33648
33649
33650
33651
33652
33653
33654
33655
33656
33657
33658
33659
33660
33661
33662
33663
33664
33665
33666
33667
33668
33669
33670
33671
33672
33673
33674
33675
33676
33677
33678
33679
33680
33681
33682
33683
33684
33685
33686
33687
33688
33689
33690
33691
33692
33693
33694
33695
33696
33697
33698
33699
33700
33701
33702
33703
33704
33705
33706
33707
33708
33709
33710
33711
33712
33713
33714
33715
33716
33717
33718
33719
33720
33721
33722
33723
33724
33725
33726
33727
33728
33729
33730
33731
33732
33733
33734
33735
33736
33737
33738
33739
33740
33741
33742
33743
33744
33745
33746
33747
33748
33749
33750
33751
33752
33753
33754
33755
33756
33757
33758
33759
33760
33761
33762
33763
33764
33765
33766
33767
33768
33769
33770
33771
33772
33773
33774
33775
33776
33777
33778
33779
33780
33781
33782
33783
33784
33785
33786
33787
33788
33789
33790
33791
33792
33793
33794
33795
33796
33797
33798
33799
33800
33801
33802
33803
33804
33805
33806
33807
33808
33809
33810
33811
33812
33813
33814
33815
33816
33817
33818
33819
33820
33821
33822
33823
33824
33825
33826
33827
33828
33829
33830
33831
33832
33833
33834
33835
33836
33837
33838
33839
33840
33841
33842
33843
33844
33845
33846
33847
33848
33849
33850
33851
33852
33853
33854
33855
33856
33857
33858
33859
33860
33861
33862
33863
33864
33865
33866
33867
33868
33869
33870
33871
33872
33873
33874
33875
33876
33877
33878
33879
33880
33881
33882
33883
33884
33885
33886
33887
33888
33889
33890
33891
33892
33893
33894
33895
33896
33897
33898
33899
33900
33901
33902
33903
33904
33905
33906
33907
33908
33909
33910
33911
33912
33913
33914
33915
33916
33917
33918
33919
33920
33921
33922
33923
33924
33925
33926
33927
33928
33929
33930
33931
33932
33933
33934
33935
33936
33937
33938
33939
33940
33941
33942
33943
33944
33945
33946
33947
33948
33949
33950
33951
33952
33953
33954
33955
33956
33957
33958
33959
33960
33961
33962
33963
33964
33965
33966
33967
33968
33969
33970
33971
33972
33973
33974
33975
33976
33977
33978
33979
33980
33981
33982
33983
33984
33985
33986
33987
33988
33989
33990
33991
33992
33993
33994
33995
33996
33997
33998
33999
34000
34001
34002
34003
34004
34005
34006
34007
34008
34009
34010
34011
34012
34013
34014
34015
34016
34017
34018
34019
34020
34021
34022
34023
34024
34025
34026
34027
34028
34029
34030
34031
34032
34033
34034
34035
34036
34037
34038
34039
34040
34041
34042
34043
34044
34045
34046
34047
34048
34049
34050
34051
34052
34053
34054
34055
34056
34057
34058
34059
34060
34061
34062
34063
34064
34065
34066
34067
34068
34069
34070
34071
34072
34073
34074
34075
34076
34077
34078
34079
34080
34081
34082
34083
34084
34085
34086
34087
34088
34089
34090
34091
34092
34093
34094
34095
34096
34097
34098
34099
34100
34101
34102
34103
34104
34105
34106
34107
34108
34109
34110
34111
34112
34113
34114
34115
34116
34117
34118
34119
34120
34121
34122
34123
34124
34125
34126
34127
34128
34129
34130
34131
34132
34133
34134
34135
34136
34137
34138
34139
34140
34141
34142
34143
34144
34145
34146
34147
34148
34149
34150
34151
34152
34153
34154
34155
34156
34157
34158
34159
34160
34161
34162
34163
34164
34165
34166
34167
34168
34169
34170
34171
34172
34173
34174
34175
34176
34177
34178
34179
34180
34181
34182
34183
34184
34185
34186
34187
34188
34189
34190
34191
34192
34193
34194
34195
34196
34197
34198
34199
34200
34201
34202
34203
34204
34205
34206
34207
34208
34209
34210
34211
34212
34213
34214
34215
34216
34217
34218
34219
34220
34221
34222
34223
34224
34225
34226
34227
34228
34229
34230
34231
34232
34233
34234
34235
34236
34237
34238
34239
34240
34241
34242
34243
34244
34245
34246
34247
34248
34249
34250
34251
34252
34253
34254
34255
34256
34257
34258
34259
34260
34261
34262
34263
34264
34265
34266
34267
34268
34269
34270
34271
34272
34273
34274
34275
34276
34277
34278
34279
34280
34281
34282
34283
34284
34285
34286
34287
34288
34289
34290
34291
34292
34293
34294
34295
34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
34306
34307
34308
34309
34310
34311
34312
34313
34314
34315
34316
34317
34318
34319
34320
34321
34322
34323
34324
34325
34326
34327
34328
34329
34330
34331
34332
34333
34334
34335
34336
34337
34338
34339
34340
34341
34342
34343
34344
34345
34346
34347
34348
34349
34350
34351
34352
34353
34354
34355
34356
34357
34358
34359
34360
34361
34362
34363
34364
34365
34366
34367
34368
34369
34370
34371
34372
34373
34374
34375
34376
34377
34378
34379
34380
34381
34382
34383
34384
34385
34386
34387
34388
34389
34390
34391
34392
34393
34394
34395
34396
34397
34398
34399
34400
34401
34402
34403
34404
34405
34406
34407
34408
34409
34410
34411
34412
34413
34414
34415
34416
34417
34418
34419
34420
34421
34422
34423
34424
34425
34426
34427
34428
34429
34430
34431
34432
34433
34434
34435
34436
34437
34438
34439
34440
34441
34442
34443
34444
34445
34446
34447
34448
34449
34450
34451
34452
34453
34454
34455
34456
34457
34458
34459
34460
34461
34462
34463
34464
34465
34466
34467
34468
34469
34470
34471
34472
34473
34474
34475
34476
34477
34478
34479
34480
34481
34482
34483
34484
34485
34486
34487
34488
34489
34490
34491
34492
34493
34494
34495
34496
34497
34498
34499
34500
34501
34502
34503
34504
34505
34506
34507
34508
34509
34510
34511
34512
34513
34514
34515
34516
34517
34518
34519
34520
34521
34522
34523
34524
34525
34526
34527
34528
34529
34530
34531
34532
34533
34534
34535
34536
34537
34538
34539
34540
34541
34542
34543
34544
34545
34546
34547
34548
34549
34550
34551
34552
34553
34554
34555
34556
34557
34558
34559
34560
34561
34562
34563
34564
34565
34566
34567
34568
34569
34570
34571
34572
34573
34574
34575
34576
34577
34578
34579
34580
34581
34582
34583
34584
34585
34586
34587
34588
34589
34590
34591
34592
34593
34594
34595
34596
34597
34598
34599
34600
34601
34602
34603
34604
34605
34606
34607
34608
34609
34610
34611
34612
34613
34614
34615
34616
34617
34618
34619
34620
34621
34622
34623
34624
34625
34626
34627
34628
34629
34630
34631
34632
34633
34634
34635
34636
34637
34638
34639
34640
34641
34642
34643
34644
34645
34646
34647
34648
34649
34650
34651
34652
34653
34654
34655
34656
34657
34658
34659
34660
34661
34662
34663
34664
34665
34666
34667
34668
34669
34670
34671
34672
34673
34674
34675
34676
34677
34678
34679
34680
34681
34682
34683
34684
34685
34686
34687
34688
34689
34690
34691
34692
34693
34694
34695
34696
34697
34698
34699
34700
34701
34702
34703
34704
34705
34706
34707
34708
34709
34710
34711
34712
34713
34714
34715
34716
34717
34718
34719
34720
34721
34722
34723
34724
34725
34726
34727
34728
34729
34730
34731
34732
34733
34734
34735
34736
34737
34738
34739
34740
34741
34742
34743
34744
34745
34746
34747
34748
34749
34750
34751
34752
34753
34754
34755
34756
34757
34758
34759
34760
34761
34762
34763
34764
34765
34766
34767
34768
34769
34770
34771
34772
34773
34774
34775
34776
34777
34778
34779
34780
34781
34782
34783
34784
34785
34786
34787
34788
34789
34790
34791
34792
34793
34794
34795
34796
34797
34798
34799
34800
34801
34802
34803
34804
34805
34806
34807
34808
34809
34810
34811
34812
34813
34814
34815
34816
34817
34818
34819
34820
34821
34822
34823
34824
34825
34826
34827
34828
34829
34830
34831
34832
34833
34834
34835
34836
34837
34838
34839
34840
34841
34842
34843
34844
34845
34846
34847
34848
34849
34850
34851
34852
34853
34854
34855
34856
34857
34858
34859
34860
34861
34862
34863
34864
34865
34866
34867
34868
34869
34870
34871
34872
34873
34874
34875
34876
34877
34878
34879
34880
34881
34882
34883
34884
34885
34886
34887
34888
34889
34890
34891
34892
34893
34894
34895
34896
34897
34898
34899
34900
34901
34902
34903
34904
34905
34906
34907
34908
34909
34910
34911
34912
34913
34914
34915
34916
34917
34918
34919
34920
34921
34922
34923
34924
34925
34926
34927
34928
34929
34930
34931
34932
34933
34934
34935
34936
34937
34938
34939
34940
34941
34942
34943
34944
34945
34946
34947
34948
34949
34950
34951
34952
34953
34954
34955
34956
34957
34958
34959
34960
34961
34962
34963
34964
34965
34966
34967
34968
34969
34970
34971
34972
34973
34974
34975
34976
34977
34978
34979
34980
34981
34982
34983
34984
34985
34986
34987
34988
34989
34990
34991
34992
34993
34994
34995
34996
34997
34998
34999
35000
35001
35002
35003
35004
35005
35006
35007
35008
35009
35010
35011
35012
35013
35014
35015
35016
35017
35018
35019
35020
35021
35022
35023
35024
35025
35026
35027
35028
35029
35030
35031
35032
35033
35034
35035
35036
35037
35038
35039
35040
35041
35042
35043
35044
35045
35046
35047
35048
35049
35050
35051
35052
35053
35054
35055
35056
35057
35058
35059
35060
35061
35062
35063
35064
35065
35066
35067
35068
35069
35070
35071
35072
35073
35074
35075
35076
35077
35078
35079
35080
35081
35082
35083
35084
35085
35086
35087
35088
35089
35090
35091
35092
35093
35094
35095
35096
35097
35098
35099
35100
35101
35102
35103
35104
35105
35106
35107
35108
35109
35110
35111
35112
35113
35114
35115
35116
35117
35118
35119
35120
35121
35122
35123
35124
35125
35126
35127
35128
35129
35130
35131
35132
35133
35134
35135
35136
35137
35138
35139
35140
35141
35142
35143
35144
35145
35146
35147
35148
35149
35150
35151
35152
35153
35154
35155
35156
35157
35158
35159
35160
35161
35162
35163
35164
35165
35166
35167
35168
35169
35170
35171
35172
35173
35174
35175
35176
35177
35178
35179
35180
35181
35182
35183
35184
35185
35186
35187
35188
35189
35190
35191
35192
35193
35194
35195
35196
35197
35198
35199
35200
35201
35202
35203
35204
35205
35206
35207
35208
35209
35210
35211
35212
35213
35214
35215
35216
35217
35218
35219
35220
35221
35222
35223
35224
35225
35226
35227
35228
35229
35230
35231
35232
35233
35234
35235
35236
35237
35238
35239
35240
35241
35242
35243
35244
35245
35246
35247
35248
35249
35250
35251
35252
35253
35254
35255
35256
35257
35258
35259
35260
35261
35262
35263
35264
35265
35266
35267
35268
35269
35270
35271
35272
35273
35274
35275
35276
35277
35278
35279
35280
35281
35282
35283
35284
35285
35286
35287
35288
35289
35290
35291
35292
35293
35294
35295
35296
35297
35298
35299
35300
35301
35302
35303
35304
35305
35306
35307
35308
35309
35310
35311
35312
35313
35314
35315
35316
35317
35318
35319
35320
35321
35322
35323
35324
35325
35326
35327
35328
35329
35330
35331
35332
35333
35334
35335
35336
35337
35338
35339
35340
35341
35342
35343
35344
35345
35346
35347
35348
35349
35350
35351
35352
35353
35354
35355
35356
35357
35358
35359
35360
35361
35362
35363
35364
35365
35366
35367
35368
35369
35370
35371
35372
35373
35374
35375
35376
35377
35378
35379
35380
35381
35382
35383
35384
35385
35386
35387
35388
35389
35390
35391
35392
35393
35394
35395
35396
35397
35398
35399
35400
35401
35402
35403
35404
35405
35406
35407
35408
35409
35410
35411
35412
35413
35414
35415
35416
35417
35418
35419
35420
35421
35422
35423
35424
35425
35426
35427
35428
35429
35430
35431
35432
35433
35434
35435
35436
35437
35438
35439
35440
35441
35442
35443
35444
35445
35446
35447
35448
35449
35450
35451
35452
35453
35454
35455
35456
35457
35458
35459
35460
35461
35462
35463
35464
35465
35466
35467
35468
35469
35470
35471
35472
35473
35474
35475
35476
35477
35478
35479
35480
35481
35482
35483
35484
35485
35486
35487
35488
35489
35490
35491
35492
35493
35494
35495
35496
35497
35498
35499
35500
35501
35502
35503
35504
35505
35506
35507
35508
35509
35510
35511
35512
35513
35514
35515
35516
35517
35518
35519
35520
35521
35522
35523
35524
35525
35526
35527
35528
35529
35530
35531
35532
35533
35534
35535
35536
35537
35538
35539
35540
35541
35542
35543
35544
35545
35546
35547
35548
35549
35550
35551
35552
35553
35554
35555
35556
35557
35558
35559
35560
35561
35562
35563
35564
35565
35566
35567
35568
35569
35570
35571
35572
35573
35574
35575
35576
35577
35578
35579
35580
35581
35582
35583
35584
35585
35586
35587
35588
35589
35590
35591
35592
35593
35594
35595
35596
35597
35598
35599
35600
35601
35602
35603
35604
35605
35606
35607
35608
35609
35610
35611
35612
35613
35614
35615
35616
35617
35618
35619
35620
35621
35622
35623
35624
35625
35626
35627
35628
35629
35630
35631
35632
35633
35634
35635
35636
35637
35638
35639
35640
35641
35642
35643
35644
35645
35646
35647
35648
35649
35650
35651
35652
35653
35654
35655
35656
35657
35658
35659
35660
35661
35662
35663
35664
35665
35666
35667
35668
35669
35670
35671
35672
35673
35674
35675
35676
35677
35678
35679
35680
35681
35682
35683
35684
35685
35686
35687
35688
35689
35690
35691
35692
35693
35694
35695
35696
35697
35698
35699
35700
35701
35702
35703
35704
35705
35706
35707
35708
35709
35710
35711
35712
35713
35714
35715
35716
35717
35718
35719
35720
35721
35722
35723
35724
35725
35726
35727
35728
35729
35730
35731
35732
35733
35734
35735
35736
35737
35738
35739
35740
35741
35742
35743
35744
35745
35746
35747
35748
35749
35750
35751
35752
35753
35754
35755
35756
35757
35758
35759
35760
35761
35762
35763
35764
35765
35766
35767
35768
35769
35770
35771
35772
35773
35774
35775
35776
35777
35778
35779
35780
35781
35782
35783
35784
35785
35786
35787
35788
35789
35790
35791
35792
35793
35794
35795
35796
35797
35798
35799
35800
35801
35802
35803
35804
35805
35806
35807
35808
35809
35810
35811
35812
35813
35814
35815
35816
35817
35818
35819
35820
35821
35822
35823
35824
35825
35826
35827
35828
35829
35830
35831
35832
35833
35834
35835
35836
35837
35838
35839
35840
35841
35842
35843
35844
35845
35846
35847
35848
35849
35850
35851
35852
35853
35854
35855
35856
35857
35858
35859
35860
35861
35862
35863
35864
35865
35866
35867
35868
35869
35870
35871
35872
35873
35874
35875
35876
35877
35878
35879
35880
35881
35882
35883
35884
35885
35886
35887
35888
35889
35890
35891
35892
35893
35894
35895
35896
35897
35898
35899
35900
35901
35902
35903
35904
35905
35906
35907
35908
35909
35910
35911
35912
35913
35914
35915
35916
35917
35918
35919
35920
35921
35922
35923
35924
35925
35926
35927
35928
35929
35930
35931
35932
35933
35934
35935
35936
35937
35938
35939
35940
35941
35942
35943
35944
35945
35946
35947
35948
35949
35950
35951
35952
35953
35954
35955
35956
35957
35958
35959
35960
35961
35962
35963
35964
35965
35966
35967
35968
35969
35970
35971
35972
35973
35974
35975
35976
35977
35978
35979
35980
35981
35982
35983
35984
35985
35986
35987
35988
35989
35990
35991
35992
35993
35994
35995
35996
35997
35998
35999
36000
36001
36002
36003
36004
36005
36006
36007
36008
36009
36010
36011
36012
36013
36014
36015
36016
36017
36018
36019
36020
36021
36022
36023
36024
36025
36026
36027
36028
36029
36030
36031
36032
36033
36034
36035
36036
36037
36038
36039
36040
36041
36042
36043
36044
36045
36046
36047
36048
36049
36050
36051
36052
36053
36054
36055
36056
36057
36058
36059
36060
36061
36062
36063
36064
36065
36066
36067
36068
36069
36070
36071
36072
36073
36074
36075
36076
36077
36078
36079
36080
36081
36082
36083
36084
36085
36086
36087
36088
36089
36090
36091
36092
36093
36094
36095
36096
36097
36098
36099
36100
36101
36102
36103
36104
36105
36106
36107
36108
36109
36110
36111
36112
36113
36114
36115
36116
36117
36118
36119
36120
36121
36122
36123
36124
36125
36126
36127
36128
36129
36130
36131
36132
36133
36134
36135
36136
36137
36138
36139
36140
36141
36142
36143
36144
36145
36146
36147
36148
36149
36150
36151
36152
36153
36154
36155
36156
36157
36158
36159
36160
36161
36162
36163
36164
36165
36166
36167
36168
36169
36170
36171
36172
36173
36174
36175
36176
36177
36178
36179
36180
36181
36182
36183
36184
36185
36186
36187
36188
36189
36190
36191
36192
36193
36194
36195
36196
36197
36198
36199
36200
36201
36202
36203
36204
36205
36206
36207
36208
36209
36210
36211
36212
36213
36214
36215
36216
36217
36218
36219
36220
36221
36222
36223
36224
36225
36226
36227
36228
36229
36230
36231
36232
36233
36234
36235
36236
36237
36238
36239
36240
36241
36242
36243
36244
36245
36246
36247
36248
36249
36250
36251
36252
36253
36254
36255
36256
36257
36258
36259
36260
36261
36262
36263
36264
36265
36266
36267
36268
36269
36270
36271
36272
36273
36274
36275
36276
36277
36278
36279
36280
36281
36282
36283
36284
36285
36286
36287
36288
36289
36290
36291
36292
36293
36294
36295
36296
36297
36298
36299
36300
36301
36302
36303
36304
36305
36306
36307
36308
36309
36310
36311
36312
36313
36314
36315
36316
36317
36318
36319
36320
36321
36322
36323
36324
36325
36326
36327
36328
36329
36330
36331
36332
36333
36334
36335
36336
36337
36338
36339
36340
36341
36342
36343
36344
36345
36346
36347
36348
36349
36350
36351
36352
36353
36354
36355
36356
36357
36358
36359
36360
36361
36362
36363
36364
36365
36366
36367
36368
36369
36370
36371
36372
36373
36374
36375
36376
36377
36378
36379
36380
36381
36382
36383
36384
36385
36386
36387
36388
36389
36390
36391
36392
36393
36394
36395
36396
36397
36398
36399
36400
36401
36402
36403
36404
36405
36406
36407
36408
36409
36410
36411
36412
36413
36414
36415
36416
36417
36418
36419
36420
36421
36422
36423
36424
36425
36426
36427
36428
36429
36430
36431
36432
36433
36434
36435
36436
36437
36438
36439
36440
36441
36442
36443
36444
36445
36446
36447
36448
36449
36450
36451
36452
36453
36454
36455
36456
36457
36458
36459
36460
36461
36462
36463
36464
36465
36466
36467
36468
36469
36470
36471
36472
36473
36474
36475
36476
36477
36478
36479
36480
36481
36482
36483
36484
36485
36486
36487
36488
36489
36490
36491
36492
36493
36494
36495
36496
36497
36498
36499
36500
36501
36502
36503
36504
36505
36506
36507
36508
36509
36510
36511
36512
36513
36514
36515
36516
36517
36518
36519
36520
36521
36522
36523
36524
36525
36526
36527
36528
36529
36530
36531
36532
36533
36534
36535
36536
36537
36538
36539
36540
36541
36542
36543
36544
36545
36546
36547
36548
36549
36550
36551
36552
36553
36554
36555
36556
36557
36558
36559
36560
36561
36562
36563
36564
36565
36566
36567
36568
36569
36570
36571
36572
36573
36574
36575
36576
36577
36578
36579
36580
36581
36582
36583
36584
36585
36586
36587
36588
36589
36590
36591
36592
36593
36594
36595
36596
36597
36598
36599
36600
36601
36602
36603
36604
36605
36606
36607
36608
36609
36610
36611
36612
36613
36614
36615
36616
36617
36618
36619
36620
36621
36622
36623
36624
36625
36626
36627
36628
36629
36630
36631
36632
36633
36634
36635
36636
36637
36638
36639
36640
36641
36642
36643
36644
36645
36646
36647
36648
36649
36650
36651
36652
36653
36654
36655
36656
36657
36658
36659
36660
36661
36662
36663
36664
36665
36666
36667
36668
36669
36670
36671
36672
36673
36674
36675
36676
36677
36678
36679
36680
36681
36682
36683
36684
36685
36686
36687
36688
36689
36690
36691
36692
36693
36694
36695
36696
36697
36698
36699
36700
36701
36702
36703
36704
36705
36706
36707
36708
36709
36710
36711
36712
36713
36714
36715
36716
36717
36718
36719
36720
36721
36722
36723
36724
36725
36726
36727
36728
36729
36730
36731
36732
36733
36734
36735
36736
36737
36738
36739
36740
36741
36742
36743
36744
36745
36746
36747
36748
36749
36750
36751
36752
36753
36754
36755
36756
36757
36758
36759
36760
36761
36762
36763
36764
36765
36766
36767
36768
36769
36770
36771
36772
36773
36774
36775
36776
36777
36778
36779
36780
36781
36782
36783
36784
36785
36786
36787
36788
36789
36790
36791
36792
36793
36794
36795
36796
36797
36798
36799
36800
36801
36802
36803
36804
36805
36806
36807
36808
36809
36810
36811
36812
36813
36814
36815
36816
36817
36818
36819
36820
36821
36822
36823
36824
36825
36826
36827
36828
36829
36830
36831
36832
36833
36834
36835
36836
36837
36838
36839
36840
36841
36842
36843
36844
36845
36846
36847
36848
36849
36850
36851
36852
36853
36854
36855
36856
36857
36858
36859
36860
36861
36862
36863
36864
36865
36866
36867
36868
36869
36870
36871
36872
36873
36874
36875
36876
36877
36878
36879
36880
36881
36882
36883
36884
36885
36886
36887
36888
36889
36890
36891
36892
36893
36894
36895
36896
36897
36898
36899
36900
36901
36902
36903
36904
36905
36906
36907
36908
36909
36910
36911
36912
36913
36914
36915
36916
36917
36918
36919
36920
36921
36922
36923
36924
36925
36926
36927
36928
36929
36930
36931
36932
36933
36934
36935
36936
36937
36938
36939
36940
36941
36942
36943
36944
36945
36946
36947
36948
36949
36950
36951
36952
36953
36954
36955
36956
36957
36958
36959
36960
36961
36962
36963
36964
36965
36966
36967
36968
36969
36970
36971
36972
36973
36974
36975
36976
36977
36978
36979
36980
36981
36982
36983
36984
36985
36986
36987
36988
36989
36990
36991
36992
36993
36994
36995
36996
36997
36998
36999
37000
37001
37002
37003
37004
37005
37006
37007
37008
37009
37010
37011
37012
37013
37014
37015
37016
37017
37018
37019
37020
37021
37022
37023
37024
37025
37026
37027
37028
37029
37030
37031
37032
37033
37034
37035
37036
37037
37038
37039
37040
37041
37042
37043
37044
37045
37046
37047
37048
37049
37050
37051
37052
37053
37054
37055
37056
37057
37058
37059
37060
37061
37062
37063
37064
37065
37066
37067
37068
37069
37070
37071
37072
37073
37074
37075
37076
37077
37078
37079
37080
37081
37082
37083
37084
37085
37086
37087
37088
37089
37090
37091
37092
37093
37094
37095
37096
37097
37098
37099
37100
37101
37102
37103
37104
37105
37106
37107
37108
37109
37110
37111
37112
37113
37114
37115
37116
37117
37118
37119
37120
37121
37122
37123
37124
37125
37126
37127
37128
37129
37130
37131
37132
37133
37134
37135
37136
37137
37138
37139
37140
37141
37142
37143
37144
37145
37146
37147
37148
37149
37150
37151
37152
37153
37154
37155
37156
37157
37158
37159
37160
37161
37162
37163
37164
37165
37166
37167
37168
37169
37170
37171
37172
37173
37174
37175
37176
37177
37178
37179
37180
37181
37182
37183
37184
37185
37186
37187
37188
37189
37190
37191
37192
37193
37194
37195
37196
37197
37198
37199
37200
37201
37202
37203
37204
37205
37206
37207
37208
37209
37210
37211
37212
37213
37214
37215
37216
37217
37218
37219
37220
37221
37222
37223
37224
37225
37226
37227
37228
37229
37230
37231
37232
37233
37234
37235
37236
37237
37238
37239
37240
37241
37242
37243
37244
37245
37246
37247
37248
37249
37250
37251
37252
37253
37254
37255
37256
37257
37258
37259
37260
37261
37262
37263
37264
37265
37266
37267
37268
37269
37270
37271
37272
37273
37274
37275
37276
37277
37278
37279
37280
37281
37282
37283
37284
37285
37286
37287
37288
37289
37290
37291
37292
37293
37294
37295
37296
37297
37298
37299
37300
37301
37302
37303
37304
37305
37306
37307
37308
37309
37310
37311
37312
37313
37314
37315
37316
37317
37318
37319
37320
37321
37322
37323
37324
37325
37326
37327
37328
37329
37330
37331
37332
37333
37334
37335
37336
37337
37338
37339
37340
37341
37342
37343
37344
37345
37346
37347
37348
37349
37350
37351
37352
37353
37354
37355
37356
37357
37358
37359
37360
37361
37362
37363
37364
37365
37366
37367
37368
37369
37370
37371
37372
37373
37374
37375
37376
37377
37378
37379
37380
37381
37382
37383
37384
37385
37386
37387
37388
37389
37390
37391
37392
37393
37394
37395
37396
37397
37398
37399
37400
37401
37402
37403
37404
37405
37406
37407
37408
37409
37410
37411
37412
37413
37414
37415
37416
37417
37418
37419
37420
37421
37422
37423
37424
37425
37426
37427
37428
37429
37430
37431
37432
37433
37434
37435
37436
37437
37438
37439
37440
37441
37442
37443
37444
37445
37446
37447
37448
37449
37450
37451
37452
37453
37454
37455
37456
37457
37458
37459
37460
37461
37462
37463
37464
37465
37466
37467
37468
37469
37470
37471
37472
37473
37474
37475
37476
37477
37478
37479
37480
37481
37482
37483
37484
37485
37486
37487
37488
37489
37490
37491
37492
37493
37494
37495
37496
37497
37498
37499
37500
37501
37502
37503
37504
37505
37506
37507
37508
37509
37510
37511
37512
37513
37514
37515
37516
37517
37518
37519
37520
37521
37522
37523
37524
37525
37526
37527
37528
37529
37530
37531
37532
37533
37534
37535
37536
37537
37538
37539
37540
37541
37542
37543
37544
37545
37546
37547
37548
37549
37550
37551
37552
37553
37554
37555
37556
37557
37558
37559
37560
37561
37562
37563
37564
37565
37566
37567
37568
37569
37570
37571
37572
37573
37574
37575
37576
37577
37578
37579
37580
37581
37582
37583
37584
37585
37586
37587
37588
37589
37590
37591
37592
37593
37594
37595
37596
37597
37598
37599
37600
37601
37602
37603
37604
37605
37606
37607
37608
37609
37610
37611
37612
37613
37614
37615
37616
37617
37618
37619
37620
37621
37622
37623
37624
37625
37626
37627
37628
37629
37630
37631
37632
37633
37634
37635
37636
37637
37638
37639
37640
37641
37642
37643
37644
37645
37646
37647
37648
37649
37650
37651
37652
37653
37654
37655
37656
37657
37658
37659
37660
37661
37662
37663
37664
37665
37666
37667
37668
37669
37670
37671
37672
37673
37674
37675
37676
37677
37678
37679
37680
37681
37682
37683
37684
37685
37686
37687
37688
37689
37690
37691
37692
37693
37694
37695
37696
37697
37698
37699
37700
37701
37702
37703
37704
37705
37706
37707
37708
37709
37710
37711
37712
37713
37714
37715
37716
37717
37718
37719
37720
37721
37722
37723
37724
37725
37726
37727
37728
37729
37730
37731
37732
37733
37734
37735
37736
37737
37738
37739
37740
37741
37742
37743
37744
37745
37746
37747
37748
37749
37750
37751
37752
37753
37754
37755
37756
37757
37758
37759
37760
37761
37762
37763
37764
37765
37766
37767
37768
37769
37770
37771
37772
37773
37774
37775
37776
37777
37778
37779
37780
37781
37782
37783
37784
37785
37786
37787
37788
37789
37790
37791
37792
37793
37794
37795
37796
37797
37798
37799
37800
37801
37802
37803
37804
37805
37806
37807
37808
37809
37810
37811
37812
37813
37814
37815
37816
37817
37818
37819
37820
37821
37822
37823
37824
37825
37826
37827
37828
37829
37830
37831
37832
37833
37834
37835
37836
37837
37838
37839
37840
37841
37842
37843
37844
37845
37846
37847
37848
37849
37850
37851
37852
37853
37854
37855
37856
37857
37858
37859
37860
37861
37862
37863
37864
37865
37866
37867
37868
37869
37870
37871
37872
37873
37874
37875
37876
37877
37878
37879
37880
37881
37882
37883
37884
37885
37886
37887
37888
37889
37890
37891
37892
37893
37894
37895
37896
37897
37898
37899
37900
37901
37902
37903
37904
37905
37906
37907
37908
37909
37910
37911
37912
37913
37914
37915
37916
37917
37918
37919
37920
37921
37922
37923
37924
37925
37926
37927
37928
37929
37930
37931
37932
37933
37934
37935
37936
37937
37938
37939
37940
37941
37942
37943
37944
37945
37946
37947
37948
37949
37950
37951
37952
37953
37954
37955
37956
37957
37958
37959
37960
37961
37962
37963
37964
37965
37966
37967
37968
37969
37970
37971
37972
37973
37974
37975
37976
37977
37978
37979
37980
37981
37982
37983
37984
37985
37986
37987
37988
37989
37990
37991
37992
37993
37994
37995
37996
37997
37998
37999
38000
38001
38002
38003
38004
38005
38006
38007
38008
38009
38010
38011
38012
38013
38014
38015
38016
38017
38018
38019
38020
38021
38022
38023
38024
38025
38026
38027
38028
38029
38030
38031
38032
38033
38034
38035
38036
38037
38038
38039
38040
38041
38042
38043
38044
38045
38046
38047
38048
38049
38050
38051
38052
38053
38054
38055
38056
38057
38058
38059
38060
38061
38062
38063
38064
38065
38066
38067
38068
38069
38070
38071
38072
38073
38074
38075
38076
38077
38078
38079
38080
38081
38082
38083
38084
38085
38086
38087
38088
38089
38090
38091
38092
38093
38094
38095
38096
38097
38098
38099
38100
38101
38102
38103
38104
38105
38106
38107
38108
38109
38110
38111
38112
38113
38114
38115
38116
38117
38118
38119
38120
38121
38122
38123
38124
38125
38126
38127
38128
38129
38130
38131
38132
38133
38134
38135
38136
38137
38138
38139
38140
38141
38142
38143
38144
38145
38146
38147
38148
38149
38150
38151
38152
38153
38154
38155
38156
38157
38158
38159
38160
38161
38162
38163
38164
38165
38166
38167
38168
38169
38170
38171
38172
38173
38174
38175
38176
38177
38178
38179
38180
38181
38182
38183
38184
38185
38186
38187
38188
38189
38190
38191
38192
38193
38194
38195
38196
38197
38198
38199
38200
38201
38202
38203
38204
38205
38206
38207
38208
38209
38210
38211
38212
38213
38214
38215
38216
38217
38218
38219
38220
38221
38222
38223
38224
38225
38226
38227
38228
38229
38230
38231
38232
38233
38234
38235
38236
38237
38238
38239
38240
38241
38242
38243
38244
38245
38246
38247
38248
38249
38250
38251
38252
38253
38254
38255
38256
38257
38258
38259
38260
38261
38262
38263
38264
38265
38266
38267
38268
38269
38270
38271
38272
38273
38274
38275
38276
38277
38278
38279
38280
38281
38282
38283
38284
38285
38286
38287
38288
38289
38290
38291
38292
38293
38294
38295
38296
38297
38298
38299
38300
38301
38302
38303
38304
38305
38306
38307
38308
38309
38310
38311
38312
38313
38314
38315
38316
38317
38318
38319
38320
38321
38322
38323
38324
38325
38326
38327
38328
38329
38330
38331
38332
38333
38334
38335
38336
38337
38338
38339
38340
38341
38342
38343
38344
38345
38346
38347
38348
38349
38350
38351
38352
38353
38354
38355
38356
38357
38358
38359
38360
38361
38362
38363
38364
38365
38366
38367
38368
38369
38370
38371
38372
38373
38374
38375
38376
38377
38378
38379
38380
38381
38382
38383
38384
38385
38386
38387
38388
38389
38390
38391
38392
38393
38394
38395
38396
38397
38398
38399
38400
38401
38402
38403
38404
38405
38406
38407
38408
38409
38410
38411
38412
38413
38414
38415
38416
38417
38418
38419
38420
38421
38422
38423
38424
38425
38426
38427
38428
38429
38430
38431
38432
38433
38434
38435
38436
38437
38438
38439
38440
38441
38442
38443
38444
38445
38446
38447
38448
38449
38450
38451
38452
38453
38454
38455
38456
38457
38458
38459
38460
38461
38462
38463
38464
38465
38466
38467
38468
38469
38470
38471
38472
38473
38474
38475
38476
38477
38478
38479
38480
38481
38482
38483
38484
38485
38486
38487
38488
38489
38490
38491
38492
38493
38494
38495
38496
38497
38498
38499
38500
38501
38502
38503
38504
38505
38506
38507
38508
38509
38510
38511
38512
38513
38514
38515
38516
38517
38518
38519
38520
38521
38522
38523
38524
38525
38526
38527
38528
38529
38530
38531
38532
38533
38534
38535
38536
38537
38538
38539
38540
38541
38542
38543
38544
38545
38546
38547
38548
38549
38550
38551
38552
38553
38554
38555
38556
38557
38558
38559
38560
38561
38562
38563
38564
38565
38566
38567
38568
38569
38570
38571
38572
38573
38574
38575
38576
38577
38578
38579
38580
38581
38582
38583
38584
38585
38586
38587
38588
38589
38590
38591
38592
38593
38594
38595
38596
38597
38598
38599
38600
38601
38602
38603
38604
38605
38606
38607
38608
38609
38610
38611
38612
38613
38614
38615
38616
38617
38618
38619
38620
38621
38622
38623
38624
38625
38626
38627
38628
38629
38630
38631
38632
38633
38634
38635
38636
38637
38638
38639
38640
38641
38642
38643
38644
38645
38646
38647
38648
38649
38650
38651
38652
38653
38654
38655
38656
38657
38658
38659
38660
38661
38662
38663
38664
38665
38666
38667
38668
38669
38670
38671
38672
38673
38674
38675
38676
38677
38678
38679
38680
38681
38682
38683
38684
38685
38686
38687
38688
38689
38690
38691
38692
38693
38694
38695
38696
38697
38698
38699
38700
38701
38702
38703
38704
38705
38706
38707
38708
38709
38710
38711
38712
38713
38714
38715
38716
38717
38718
38719
38720
38721
38722
38723
38724
38725
38726
38727
38728
38729
38730
38731
38732
38733
38734
38735
38736
38737
38738
38739
38740
38741
38742
38743
38744
38745
38746
38747
38748
38749
38750
38751
38752
38753
38754
38755
38756
38757
38758
38759
38760
38761
38762
38763
38764
38765
38766
38767
38768
38769
38770
38771
38772
38773
38774
38775
38776
38777
38778
38779
38780
38781
38782
38783
38784
38785
38786
38787
38788
38789
38790
38791
38792
38793
38794
38795
38796
38797
38798
38799
38800
38801
38802
38803
38804
38805
38806
38807
38808
38809
38810
38811
38812
38813
38814
38815
38816
38817
38818
38819
38820
38821
38822
38823
38824
38825
38826
38827
38828
38829
38830
38831
38832
38833
38834
38835
38836
38837
38838
38839
38840
38841
38842
38843
38844
38845
38846
38847
38848
38849
38850
38851
38852
38853
38854
38855
38856
38857
38858
38859
38860
38861
38862
38863
38864
38865
38866
38867
38868
38869
38870
38871
38872
38873
38874
38875
38876
38877
38878
38879
38880
38881
38882
38883
38884
38885
38886
38887
38888
38889
38890
38891
38892
38893
38894
38895
38896
38897
38898
38899
38900
38901
38902
38903
38904
38905
38906
38907
38908
38909
38910
38911
38912
38913
38914
38915
38916
38917
38918
38919
38920
38921
38922
38923
38924
38925
38926
38927
38928
38929
38930
38931
38932
38933
38934
38935
38936
38937
38938
38939
38940
38941
38942
38943
38944
38945
38946
38947
38948
38949
38950
38951
38952
38953
38954
38955
38956
38957
38958
38959
38960
38961
38962
38963
38964
38965
38966
38967
38968
38969
38970
38971
38972
38973
38974
38975
38976
38977
38978
38979
38980
38981
38982
38983
38984
38985
38986
38987
38988
38989
38990
38991
38992
38993
38994
38995
38996
38997
38998
38999
39000
39001
39002
39003
39004
39005
39006
39007
39008
39009
39010
39011
39012
39013
39014
39015
39016
39017
39018
39019
39020
39021
39022
39023
39024
39025
39026
39027
39028
39029
39030
39031
39032
39033
39034
39035
39036
39037
39038
39039
39040
39041
39042
39043
39044
39045
39046
39047
39048
39049
39050
39051
39052
39053
39054
39055
39056
39057
39058
39059
39060
39061
39062
39063
39064
39065
39066
39067
39068
39069
39070
39071
39072
39073
39074
39075
39076
39077
39078
39079
39080
39081
39082
39083
39084
39085
39086
39087
39088
39089
39090
39091
39092
39093
39094
39095
39096
39097
39098
39099
39100
39101
39102
39103
39104
39105
39106
39107
39108
39109
39110
39111
39112
39113
39114
39115
39116
39117
39118
39119
39120
39121
39122
39123
39124
39125
39126
39127
39128
39129
39130
39131
39132
39133
39134
39135
39136
39137
39138
39139
39140
39141
39142
39143
39144
39145
39146
39147
39148
39149
39150
39151
39152
39153
39154
39155
39156
39157
39158
39159
39160
39161
39162
39163
39164
39165
39166
39167
39168
39169
39170
39171
39172
39173
39174
39175
39176
39177
39178
39179
39180
39181
39182
39183
39184
39185
39186
39187
39188
39189
39190
39191
39192
39193
39194
39195
39196
39197
39198
39199
39200
39201
39202
39203
39204
39205
39206
39207
39208
39209
39210
39211
39212
39213
39214
39215
39216
39217
39218
39219
39220
39221
39222
39223
39224
39225
39226
39227
39228
39229
39230
39231
39232
39233
39234
39235
39236
39237
39238
39239
39240
39241
39242
39243
39244
39245
39246
39247
39248
39249
39250
39251
39252
39253
39254
39255
39256
39257
39258
39259
39260
39261
39262
39263
39264
39265
39266
39267
39268
39269
39270
39271
39272
39273
39274
39275
39276
39277
39278
39279
39280
39281
39282
39283
39284
39285
39286
39287
39288
39289
39290
39291
39292
39293
39294
39295
39296
39297
39298
39299
39300
39301
39302
39303
39304
39305
39306
39307
39308
39309
39310
39311
39312
39313
39314
39315
39316
39317
39318
39319
39320
39321
39322
39323
39324
39325
39326
39327
39328
39329
39330
39331
39332
39333
39334
39335
39336
39337
39338
39339
39340
39341
39342
39343
39344
39345
39346
39347
39348
39349
39350
39351
39352
39353
39354
39355
39356
39357
39358
39359
39360
39361
39362
39363
39364
39365
39366
39367
39368
39369
39370
39371
39372
39373
39374
39375
39376
39377
39378
39379
39380
39381
39382
39383
39384
39385
39386
39387
39388
39389
39390
39391
39392
39393
39394
39395
39396
39397
39398
39399
39400
39401
39402
39403
39404
39405
39406
39407
39408
39409
39410
39411
39412
39413
39414
39415
39416
39417
39418
39419
39420
39421
39422
39423
39424
39425
39426
39427
39428
39429
39430
39431
39432
39433
39434
39435
39436
39437
39438
39439
39440
39441
39442
39443
39444
39445
39446
39447
39448
39449
39450
39451
39452
39453
39454
39455
39456
39457
39458
39459
39460
39461
39462
39463
39464
39465
39466
39467
39468
39469
39470
39471
39472
39473
39474
39475
39476
39477
39478
39479
39480
39481
39482
39483
39484
39485
39486
39487
39488
39489
39490
39491
39492
39493
39494
39495
39496
39497
39498
39499
39500
39501
39502
39503
39504
39505
39506
39507
39508
39509
39510
39511
39512
39513
39514
39515
39516
39517
39518
39519
39520
39521
39522
39523
39524
39525
39526
39527
39528
39529
39530
39531
39532
39533
39534
39535
39536
39537
39538
39539
39540
39541
39542
39543
39544
39545
39546
39547
39548
39549
39550
39551
39552
39553
39554
39555
39556
39557
39558
39559
39560
39561
39562
39563
39564
39565
39566
39567
39568
39569
39570
39571
39572
39573
39574
39575
39576
39577
39578
39579
39580
39581
39582
39583
39584
39585
39586
39587
39588
39589
39590
39591
39592
39593
39594
39595
39596
39597
39598
39599
39600
39601
39602
39603
39604
39605
39606
39607
39608
39609
39610
39611
39612
39613
39614
39615
39616
39617
39618
39619
39620
39621
39622
39623
39624
39625
39626
39627
39628
39629
39630
39631
39632
39633
39634
39635
39636
39637
39638
39639
39640
39641
39642
39643
39644
39645
39646
39647
39648
39649
39650
39651
39652
39653
39654
39655
39656
39657
39658
39659
39660
39661
39662
39663
39664
39665
39666
39667
39668
39669
39670
39671
39672
39673
39674
39675
39676
39677
39678
39679
39680
39681
39682
39683
39684
39685
39686
39687
39688
39689
39690
39691
39692
39693
39694
39695
39696
39697
39698
39699
39700
39701
39702
39703
39704
39705
39706
39707
39708
39709
39710
39711
39712
39713
39714
39715
39716
39717
39718
39719
39720
39721
39722
39723
39724
39725
39726
39727
39728
39729
39730
39731
39732
39733
39734
39735
39736
39737
39738
39739
39740
39741
39742
39743
39744
39745
39746
39747
39748
39749
39750
39751
39752
39753
39754
39755
39756
39757
39758
39759
39760
39761
39762
39763
39764
39765
39766
39767
39768
39769
39770
39771
39772
39773
39774
39775
39776
39777
39778
39779
39780
39781
39782
39783
39784
39785
39786
39787
39788
39789
39790
39791
39792
39793
39794
39795
39796
39797
39798
39799
39800
39801
39802
39803
39804
39805
39806
39807
39808
39809
39810
39811
39812
39813
39814
39815
39816
39817
39818
39819
39820
39821
39822
39823
39824
39825
39826
39827
39828
39829
39830
39831
39832
39833
39834
39835
39836
39837
39838
39839
39840
39841
39842
39843
39844
39845
39846
39847
39848
39849
39850
39851
39852
39853
39854
39855
39856
39857
39858
39859
39860
39861
39862
39863
39864
39865
39866
39867
39868
39869
39870
39871
39872
39873
39874
39875
39876
39877
39878
39879
39880
39881
39882
39883
39884
39885
39886
39887
39888
39889
39890
39891
39892
39893
39894
39895
39896
39897
39898
39899
39900
39901
39902
39903
39904
39905
39906
39907
39908
39909
39910
39911
39912
39913
39914
39915
39916
39917
39918
39919
39920
39921
39922
39923
39924
39925
39926
39927
39928
39929
39930
39931
39932
39933
39934
39935
39936
39937
39938
39939
39940
39941
39942
39943
39944
39945
39946
39947
39948
39949
39950
39951
39952
39953
39954
39955
39956
39957
39958
39959
39960
39961
39962
39963
39964
39965
39966
39967
39968
39969
39970
39971
39972
39973
39974
39975
39976
39977
39978
39979
39980
39981
39982
39983
39984
39985
39986
39987
39988
39989
39990
39991
39992
39993
39994
39995
39996
39997
39998
39999
40000
40001
40002
40003
40004
40005
40006
40007
40008
40009
40010
40011
40012
40013
40014
40015
40016
40017
40018
40019
40020
40021
40022
40023
40024
40025
40026
40027
40028
40029
40030
40031
40032
40033
40034
40035
40036
40037
40038
40039
40040
40041
40042
40043
40044
40045
40046
40047
40048
40049
40050
40051
40052
40053
40054
40055
40056
40057
40058
40059
40060
40061
40062
40063
40064
40065
40066
40067
40068
40069
40070
40071
40072
40073
40074
40075
40076
40077
40078
40079
40080
40081
40082
40083
40084
40085
40086
40087
40088
40089
40090
40091
40092
40093
40094
40095
40096
40097
40098
40099
40100
40101
40102
40103
40104
40105
40106
40107
40108
40109
40110
40111
40112
40113
40114
40115
40116
40117
40118
40119
40120
40121
40122
40123
40124
40125
40126
40127
40128
40129
40130
40131
40132
40133
40134
40135
40136
40137
40138
40139
40140
40141
40142
40143
40144
40145
40146
40147
40148
40149
40150
40151
40152
40153
40154
40155
40156
40157
40158
40159
40160
40161
40162
40163
40164
40165
40166
40167
40168
40169
40170
40171
40172
40173
40174
40175
40176
40177
40178
40179
40180
40181
40182
40183
40184
40185
40186
40187
40188
40189
40190
40191
40192
40193
40194
40195
40196
40197
40198
40199
40200
40201
40202
40203
40204
40205
40206
40207
40208
40209
40210
40211
40212
40213
40214
40215
40216
40217
40218
40219
40220
40221
40222
40223
40224
40225
40226
40227
40228
40229
40230
40231
40232
40233
40234
40235
40236
40237
40238
40239
40240
40241
40242
40243
40244
40245
40246
40247
40248
40249
40250
40251
40252
40253
40254
40255
40256
40257
40258
40259
40260
40261
40262
40263
40264
40265
40266
40267
40268
40269
40270
40271
40272
40273
40274
40275
40276
40277
40278
40279
40280
40281
40282
40283
40284
40285
40286
40287
40288
40289
40290
40291
40292
40293
40294
40295
40296
40297
40298
40299
40300
40301
40302
40303
40304
40305
40306
40307
40308
40309
40310
40311
40312
40313
40314
40315
40316
40317
40318
40319
40320
40321
40322
40323
40324
40325
40326
40327
40328
40329
40330
40331
40332
40333
40334
40335
40336
40337
40338
40339
40340
40341
40342
40343
40344
40345
40346
40347
40348
40349
40350
40351
40352
40353
40354
40355
40356
40357
40358
40359
40360
40361
40362
40363
40364
40365
40366
40367
40368
40369
40370
40371
40372
40373
40374
40375
40376
40377
40378
40379
40380
40381
40382
40383
40384
40385
40386
40387
40388
40389
40390
40391
40392
40393
40394
40395
40396
40397
40398
40399
40400
40401
40402
40403
40404
40405
40406
40407
40408
40409
40410
40411
40412
40413
40414
40415
40416
40417
40418
40419
40420
40421
40422
40423
40424
40425
40426
40427
40428
40429
40430
40431
40432
40433
40434
40435
40436
40437
40438
40439
40440
40441
40442
40443
40444
40445
40446
40447
40448
40449
40450
40451
40452
40453
40454
40455
40456
40457
40458
40459
40460
40461
40462
40463
40464
40465
40466
40467
40468
40469
40470
40471
40472
40473
40474
40475
40476
40477
40478
40479
40480
40481
40482
40483
40484
40485
40486
40487
40488
40489
40490
40491
40492
40493
40494
40495
40496
40497
40498
40499
40500
40501
40502
40503
40504
40505
40506
40507
40508
40509
40510
40511
40512
40513
40514
40515
40516
40517
40518
40519
40520
40521
40522
40523
40524
40525
40526
40527
40528
40529
40530
40531
40532
40533
40534
40535
40536
40537
40538
40539
40540
40541
40542
40543
40544
40545
40546
40547
40548
40549
40550
40551
40552
40553
40554
40555
40556
40557
40558
40559
40560
40561
40562
40563
40564
40565
40566
40567
40568
40569
40570
40571
40572
40573
40574
40575
40576
40577
40578
40579
40580
40581
40582
40583
40584
40585
40586
40587
40588
40589
40590
40591
40592
40593
40594
40595
40596
40597
40598
40599
40600
40601
40602
40603
40604
40605
40606
40607
40608
40609
40610
40611
40612
40613
40614
40615
40616
40617
40618
40619
40620
40621
40622
40623
40624
40625
40626
40627
40628
40629
40630
40631
40632
40633
40634
40635
40636
40637
40638
40639
40640
40641
40642
40643
40644
40645
40646
40647
40648
40649
40650
40651
40652
40653
40654
40655
40656
40657
40658
40659
40660
40661
40662
40663
40664
40665
40666
40667
40668
40669
40670
40671
40672
40673
40674
40675
40676
40677
40678
40679
40680
40681
40682
40683
40684
40685
40686
40687
40688
40689
40690
40691
40692
40693
40694
40695
40696
40697
40698
40699
40700
40701
40702
40703
40704
40705
40706
40707
40708
40709
40710
40711
40712
40713
40714
40715
40716
40717
40718
40719
40720
40721
40722
40723
40724
40725
40726
40727
40728
40729
40730
40731
40732
40733
40734
40735
40736
40737
40738
40739
40740
40741
40742
40743
40744
40745
40746
40747
40748
40749
40750
40751
40752
40753
40754
40755
40756
40757
40758
40759
40760
40761
40762
40763
40764
40765
40766
40767
40768
40769
40770
40771
40772
40773
40774
40775
40776
40777
40778
40779
40780
40781
40782
40783
40784
40785
40786
40787
40788
40789
40790
40791
40792
40793
40794
40795
40796
40797
40798
40799
40800
40801
40802
40803
40804
40805
40806
40807
40808
40809
40810
40811
40812
40813
40814
40815
40816
40817
40818
40819
40820
40821
40822
40823
40824
40825
40826
40827
40828
40829
40830
40831
40832
40833
40834
40835
40836
40837
40838
40839
40840
40841
40842
40843
40844
40845
40846
40847
40848
40849
40850
40851
40852
40853
40854
40855
40856
40857
40858
40859
40860
40861
40862
40863
40864
40865
40866
40867
40868
40869
40870
40871
40872
40873
40874
40875
40876
40877
40878
40879
40880
40881
40882
40883
40884
40885
40886
40887
40888
40889
40890
40891
40892
40893
40894
40895
40896
40897
40898
40899
40900
40901
40902
40903
40904
40905
40906
40907
40908
40909
40910
40911
40912
40913
40914
40915
40916
40917
40918
40919
40920
40921
40922
40923
40924
40925
40926
40927
40928
40929
40930
40931
40932
40933
40934
40935
40936
40937
40938
40939
40940
40941
40942
40943
40944
40945
40946
40947
40948
40949
40950
40951
40952
40953
40954
40955
40956
40957
40958
40959
40960
40961
40962
40963
40964
40965
40966
40967
40968
40969
40970
40971
40972
40973
40974
40975
40976
40977
40978
40979
40980
40981
40982
40983
40984
40985
40986
40987
40988
40989
40990
40991
40992
40993
40994
40995
40996
40997
40998
40999
41000
41001
41002
41003
41004
41005
41006
41007
41008
41009
41010
41011
41012
41013
41014
41015
41016
41017
41018
41019
41020
41021
41022
41023
41024
41025
41026
41027
41028
41029
41030
41031
41032
41033
41034
41035
41036
41037
41038
41039
41040
41041
41042
41043
41044
41045
41046
41047
41048
41049
41050
41051
41052
41053
41054
41055
41056
41057
41058
41059
41060
41061
41062
41063
41064
41065
41066
41067
41068
41069
41070
41071
41072
41073
41074
41075
41076
41077
41078
41079
41080
41081
41082
41083
41084
41085
41086
41087
41088
41089
41090
41091
41092
41093
41094
41095
41096
41097
41098
41099
41100
41101
41102
41103
41104
41105
41106
41107
41108
41109
41110
41111
41112
41113
41114
41115
41116
41117
41118
41119
41120
41121
41122
41123
41124
41125
41126
41127
41128
41129
41130
41131
41132
41133
41134
41135
41136
41137
41138
41139
41140
41141
41142
41143
41144
41145
41146
41147
41148
41149
41150
41151
41152
41153
41154
41155
41156
41157
41158
41159
41160
41161
41162
41163
41164
41165
41166
41167
41168
41169
41170
41171
41172
41173
41174
41175
41176
41177
41178
41179
41180
41181
41182
41183
41184
41185
41186
41187
41188
41189
41190
41191
41192
41193
41194
41195
41196
41197
41198
41199
41200
41201
41202
41203
41204
41205
41206
41207
41208
41209
41210
41211
41212
41213
41214
41215
41216
41217
41218
41219
41220
41221
41222
41223
41224
41225
41226
41227
41228
41229
41230
41231
41232
41233
41234
41235
41236
41237
41238
41239
41240
41241
41242
41243
41244
41245
41246
41247
41248
41249
41250
41251
41252
41253
41254
41255
41256
41257
41258
41259
41260
41261
41262
41263
41264
41265
41266
41267
41268
41269
41270
41271
41272
41273
41274
41275
41276
41277
41278
41279
41280
41281
41282
41283
41284
41285
41286
41287
41288
41289
41290
41291
41292
41293
41294
41295
41296
41297
41298
41299
41300
41301
41302
41303
41304
41305
41306
41307
41308
41309
41310
41311
41312
41313
41314
41315
41316
41317
41318
41319
41320
41321
41322
41323
41324
41325
41326
41327
41328
41329
41330
41331
41332
41333
41334
41335
41336
41337
41338
41339
41340
41341
41342
41343
41344
41345
41346
41347
41348
41349
41350
41351
41352
41353
41354
41355
41356
41357
41358
41359
41360
41361
41362
41363
41364
41365
41366
41367
41368
41369
41370
41371
41372
41373
41374
41375
41376
41377
41378
41379
41380
41381
41382
41383
41384
41385
41386
41387
41388
41389
41390
41391
41392
41393
41394
41395
41396
41397
41398
41399
41400
41401
41402
41403
41404
41405
41406
41407
41408
41409
41410
41411
41412
41413
41414
41415
41416
41417
41418
41419
41420
41421
41422
41423
41424
41425
41426
41427
41428
41429
41430
41431
41432
41433
41434
41435
41436
41437
41438
41439
41440
41441
41442
41443
41444
41445
41446
41447
41448
41449
41450
41451
41452
41453
41454
41455
41456
41457
41458
41459
41460
41461
41462
41463
41464
41465
41466
41467
41468
41469
41470
41471
41472
41473
41474
41475
41476
41477
41478
41479
41480
41481
41482
41483
41484
41485
41486
41487
41488
41489
41490
41491
41492
41493
41494
41495
41496
41497
41498
41499
41500
41501
41502
41503
41504
41505
41506
41507
41508
41509
41510
41511
41512
41513
41514
41515
41516
41517
41518
41519
41520
41521
41522
41523
41524
41525
41526
41527
41528
41529
41530
41531
41532
41533
41534
41535
41536
41537
41538
41539
41540
41541
41542
41543
41544
41545
41546
41547
41548
41549
41550
41551
41552
41553
41554
41555
41556
41557
41558
41559
41560
41561
41562
41563
41564
41565
41566
41567
41568
41569
41570
41571
41572
41573
41574
41575
41576
41577
41578
41579
41580
41581
41582
41583
41584
41585
41586
41587
41588
41589
41590
41591
41592
41593
41594
41595
41596
41597
41598
41599
41600
41601
41602
41603
41604
41605
41606
41607
41608
41609
41610
41611
41612
41613
41614
41615
41616
41617
41618
41619
41620
41621
41622
41623
41624
41625
41626
41627
41628
41629
41630
41631
41632
41633
41634
41635
41636
41637
41638
41639
41640
41641
41642
41643
41644
41645
41646
41647
41648
41649
41650
41651
41652
41653
41654
41655
41656
41657
41658
41659
41660
41661
41662
41663
41664
41665
41666
41667
41668
41669
41670
41671
41672
41673
41674
41675
41676
41677
41678
41679
41680
41681
41682
41683
41684
41685
41686
41687
41688
41689
41690
41691
41692
41693
41694
41695
41696
41697
41698
41699
41700
41701
41702
41703
41704
41705
41706
41707
41708
41709
41710
41711
41712
41713
41714
41715
41716
41717
41718
41719
41720
41721
41722
41723
41724
41725
41726
41727
41728
41729
41730
41731
41732
41733
41734
41735
41736
41737
41738
41739
41740
41741
41742
41743
41744
41745
41746
41747
41748
41749
41750
41751
41752
41753
41754
41755
41756
41757
41758
41759
41760
41761
41762
41763
41764
41765
41766
41767
41768
41769
41770
41771
41772
41773
41774
41775
41776
41777
41778
41779
41780
41781
41782
41783
41784
41785
41786
41787
41788
41789
41790
41791
41792
41793
41794
41795
41796
41797
41798
41799
41800
41801
41802
41803
41804
41805
41806
41807
41808
41809
41810
41811
41812
41813
41814
41815
41816
41817
41818
41819
41820
41821
41822
41823
41824
41825
41826
41827
41828
41829
41830
41831
41832
41833
41834
41835
41836
41837
41838
41839
41840
41841
41842
41843
41844
41845
41846
41847
41848
41849
41850
41851
41852
41853
41854
41855
41856
41857
41858
41859
41860
41861
41862
41863
41864
41865
41866
41867
41868
41869
41870
41871
41872
41873
41874
41875
41876
41877
41878
41879
41880
41881
41882
41883
41884
41885
41886
41887
41888
41889
41890
41891
41892
41893
41894
41895
41896
41897
41898
41899
41900
41901
41902
41903
41904
41905
41906
41907
41908
41909
41910
41911
41912
41913
41914
41915
41916
41917
41918
41919
41920
41921
41922
41923
41924
41925
41926
41927
41928
41929
41930
41931
41932
41933
41934
41935
41936
41937
41938
41939
41940
41941
41942
41943
41944
41945
41946
41947
41948
41949
41950
41951
41952
41953
41954
41955
41956
41957
41958
41959
41960
41961
41962
41963
41964
41965
41966
41967
41968
41969
41970
41971
41972
41973
41974
41975
41976
41977
41978
41979
41980
41981
41982
41983
41984
41985
41986
41987
41988
41989
41990
41991
41992
41993
41994
41995
41996
41997
41998
41999
42000
42001
42002
42003
42004
42005
42006
42007
42008
42009
42010
42011
42012
42013
42014
42015
42016
42017
42018
42019
42020
42021
42022
42023
42024
42025
42026
42027
42028
42029
42030
42031
42032
42033
42034
42035
42036
42037
42038
42039
42040
42041
42042
42043
42044
42045
42046
42047
42048
42049
42050
42051
42052
42053
42054
42055
42056
42057
42058
42059
42060
42061
42062
42063
42064
42065
42066
42067
42068
42069
42070
42071
42072
42073
42074
42075
42076
42077
42078
42079
42080
42081
42082
42083
42084
42085
42086
42087
42088
42089
42090
42091
42092
42093
42094
42095
42096
42097
42098
42099
42100
42101
42102
42103
42104
42105
42106
42107
42108
42109
42110
42111
42112
42113
42114
42115
42116
42117
42118
42119
42120
42121
42122
42123
42124
42125
42126
42127
42128
42129
42130
42131
42132
42133
42134
42135
42136
42137
42138
42139
42140
42141
42142
42143
42144
42145
42146
42147
42148
42149
42150
42151
42152
42153
42154
42155
42156
42157
42158
42159
42160
42161
42162
42163
42164
42165
42166
42167
42168
42169
42170
42171
42172
42173
42174
42175
42176
42177
42178
42179
42180
42181
42182
42183
42184
42185
42186
42187
42188
42189
42190
42191
42192
42193
42194
42195
42196
42197
42198
42199
42200
42201
42202
42203
42204
42205
42206
42207
42208
42209
42210
42211
42212
42213
42214
42215
42216
42217
42218
42219
42220
42221
42222
42223
42224
42225
42226
42227
42228
42229
42230
42231
42232
42233
42234
42235
42236
42237
42238
42239
42240
42241
42242
42243
42244
42245
42246
42247
42248
42249
42250
42251
42252
42253
42254
42255
42256
42257
42258
42259
42260
42261
42262
42263
42264
42265
42266
42267
42268
42269
42270
42271
42272
42273
42274
42275
42276
42277
42278
42279
42280
42281
42282
42283
42284
42285
42286
42287
42288
42289
42290
42291
42292
42293
42294
42295
42296
42297
42298
42299
42300
42301
42302
42303
42304
42305
42306
42307
42308
42309
42310
42311
42312
42313
42314
42315
42316
42317
42318
42319
42320
42321
42322
42323
42324
42325
42326
42327
42328
42329
42330
42331
42332
42333
42334
42335
42336
42337
42338
42339
42340
42341
42342
42343
42344
42345
42346
42347
42348
42349
42350
42351
42352
42353
42354
42355
42356
42357
42358
42359
42360
42361
42362
42363
42364
42365
42366
42367
42368
42369
42370
42371
42372
42373
42374
42375
42376
42377
42378
42379
42380
42381
42382
42383
42384
42385
42386
42387
42388
42389
42390
42391
42392
42393
42394
42395
42396
42397
42398
42399
42400
42401
42402
42403
42404
42405
42406
42407
42408
42409
42410
42411
42412
42413
42414
42415
42416
42417
42418
42419
42420
42421
42422
42423
42424
42425
42426
42427
42428
42429
42430
42431
42432
42433
42434
42435
42436
42437
42438
42439
42440
42441
42442
42443
42444
42445
42446
42447
42448
42449
42450
42451
42452
42453
42454
42455
42456
42457
42458
42459
42460
42461
42462
42463
42464
42465
42466
42467
42468
42469
42470
42471
42472
42473
42474
42475
42476
42477
42478
42479
42480
42481
42482
42483
42484
42485
42486
42487
42488
42489
42490
42491
42492
42493
42494
42495
42496
42497
42498
42499
42500
42501
42502
42503
42504
42505
42506
42507
42508
42509
42510
42511
42512
42513
42514
42515
42516
42517
42518
42519
42520
42521
42522
42523
42524
42525
42526
42527
42528
42529
42530
42531
42532
42533
42534
42535
42536
42537
42538
42539
42540
42541
42542
42543
42544
42545
42546
42547
42548
42549
42550
42551
42552
42553
42554
42555
42556
42557
42558
42559
42560
42561
42562
42563
42564
42565
42566
42567
42568
42569
42570
42571
42572
42573
42574
42575
42576
42577
42578
42579
42580
42581
42582
42583
42584
42585
42586
42587
42588
42589
42590
42591
42592
42593
42594
42595
42596
42597
42598
42599
42600
42601
42602
42603
42604
42605
42606
42607
42608
42609
42610
42611
42612
42613
42614
42615
42616
42617
42618
42619
42620
42621
42622
42623
42624
42625
42626
42627
42628
42629
42630
42631
42632
42633
42634
42635
42636
42637
42638
42639
42640
42641
42642
42643
42644
42645
42646
42647
42648
42649
42650
42651
42652
42653
42654
42655
42656
42657
42658
42659
42660
42661
42662
42663
42664
42665
42666
42667
42668
42669
42670
42671
42672
42673
42674
42675
42676
42677
42678
42679
42680
42681
42682
42683
42684
42685
42686
42687
42688
42689
42690
42691
42692
42693
42694
42695
42696
42697
42698
42699
42700
42701
42702
42703
42704
42705
42706
42707
42708
42709
42710
42711
42712
42713
42714
42715
42716
42717
42718
42719
42720
42721
42722
42723
42724
42725
42726
42727
42728
42729
42730
42731
42732
42733
42734
42735
42736
42737
42738
42739
42740
42741
42742
42743
42744
42745
42746
42747
42748
42749
42750
42751
42752
42753
42754
42755
42756
42757
42758
42759
42760
42761
42762
42763
42764
42765
42766
42767
42768
42769
42770
42771
42772
42773
42774
42775
42776
42777
42778
42779
42780
42781
42782
42783
42784
42785
42786
42787
42788
42789
42790
42791
42792
42793
42794
42795
42796
42797
42798
42799
42800
42801
42802
42803
42804
42805
42806
42807
42808
42809
42810
42811
42812
42813
42814
42815
42816
42817
42818
42819
42820
42821
42822
42823
42824
42825
42826
42827
42828
42829
42830
42831
42832
42833
42834
42835
42836
42837
42838
42839
42840
42841
42842
42843
42844
42845
42846
42847
42848
42849
42850
42851
42852
42853
42854
42855
42856
42857
42858
42859
42860
42861
42862
42863
42864
42865
42866
42867
42868
42869
42870
42871
42872
42873
42874
42875
42876
42877
42878
42879
42880
42881
42882
42883
42884
42885
42886
42887
42888
42889
42890
42891
42892
42893
42894
42895
42896
42897
42898
42899
42900
42901
42902
42903
42904
42905
42906
42907
42908
42909
42910
42911
42912
42913
42914
42915
42916
42917
42918
42919
42920
42921
42922
42923
42924
42925
42926
42927
42928
42929
42930
42931
42932
42933
42934
42935
42936
42937
42938
42939
42940
42941
42942
42943
42944
42945
42946
42947
42948
42949
42950
42951
42952
42953
42954
42955
42956
42957
42958
42959
42960
42961
42962
42963
42964
42965
42966
42967
42968
42969
42970
42971
42972
42973
42974
42975
42976
42977
42978
42979
42980
42981
42982
42983
42984
42985
42986
42987
42988
42989
42990
42991
42992
42993
42994
42995
42996
42997
42998
42999
43000
43001
43002
43003
43004
43005
43006
43007
43008
43009
43010
43011
43012
43013
43014
43015
43016
43017
43018
43019
43020
43021
43022
43023
43024
43025
43026
43027
43028
43029
43030
43031
43032
43033
43034
43035
43036
43037
43038
43039
43040
43041
43042
43043
43044
43045
43046
43047
43048
43049
43050
43051
43052
43053
43054
43055
43056
43057
43058
43059
43060
43061
43062
43063
43064
43065
43066
43067
43068
43069
43070
43071
43072
43073
43074
43075
43076
43077
43078
43079
43080
43081
43082
43083
43084
43085
43086
43087
43088
43089
43090
43091
43092
43093
43094
43095
43096
43097
43098
43099
43100
43101
43102
43103
43104
43105
43106
43107
43108
43109
43110
43111
43112
43113
43114
43115
43116
43117
43118
43119
43120
43121
43122
43123
43124
43125
43126
43127
43128
43129
43130
43131
43132
43133
43134
43135
43136
43137
43138
43139
43140
43141
43142
43143
43144
43145
43146
43147
43148
43149
43150
43151
43152
43153
43154
43155
43156
43157
43158
43159
43160
43161
43162
43163
43164
43165
43166
43167
43168
43169
43170
43171
43172
43173
43174
43175
43176
43177
43178
43179
43180
43181
43182
43183
43184
43185
43186
43187
43188
43189
43190
43191
43192
43193
43194
43195
43196
43197
43198
43199
43200
43201
43202
43203
43204
43205
43206
43207
43208
43209
43210
43211
43212
43213
43214
43215
43216
43217
43218
43219
43220
43221
43222
43223
43224
43225
43226
43227
43228
43229
43230
43231
43232
43233
43234
43235
43236
43237
43238
43239
43240
43241
43242
43243
43244
43245
43246
43247
43248
43249
43250
43251
43252
43253
43254
43255
43256
43257
43258
43259
43260
43261
43262
43263
43264
43265
43266
43267
43268
43269
43270
43271
43272
43273
43274
43275
43276
43277
43278
43279
43280
43281
43282
43283
43284
43285
43286
43287
43288
43289
43290
43291
43292
43293
43294
43295
43296
43297
43298
43299
43300
43301
43302
43303
43304
43305
43306
43307
43308
43309
43310
43311
43312
43313
43314
43315
43316
43317
43318
43319
43320
43321
43322
43323
43324
43325
43326
43327
43328
43329
43330
43331
43332
43333
43334
43335
43336
43337
43338
43339
43340
43341
43342
43343
43344
43345
43346
43347
43348
43349
43350
43351
43352
43353
43354
43355
43356
43357
43358
43359
43360
43361
43362
43363
43364
43365
43366
43367
43368
43369
43370
43371
43372
43373
43374
43375
43376
43377
43378
43379
43380
43381
43382
43383
43384
43385
43386
43387
43388
43389
43390
43391
43392
43393
43394
43395
43396
43397
43398
43399
43400
43401
43402
43403
43404
43405
43406
43407
43408
43409
43410
43411
43412
43413
43414
43415
43416
43417
43418
43419
43420
43421
43422
43423
43424
43425
43426
43427
43428
43429
43430
43431
43432
43433
43434
43435
43436
43437
43438
43439
43440
43441
43442
43443
43444
43445
43446
43447
43448
43449
43450
43451
43452
43453
43454
43455
43456
43457
43458
43459
43460
43461
43462
43463
43464
43465
43466
43467
43468
43469
43470
43471
43472
43473
43474
43475
43476
43477
43478
43479
43480
43481
43482
43483
43484
43485
43486
43487
43488
43489
43490
43491
43492
43493
43494
43495
43496
43497
43498
43499
43500
43501
43502
43503
43504
43505
43506
43507
43508
43509
43510
43511
43512
43513
43514
43515
43516
43517
43518
43519
43520
43521
43522
43523
43524
43525
43526
43527
43528
43529
43530
43531
43532
43533
43534
43535
43536
43537
43538
43539
43540
43541
43542
43543
43544
43545
43546
43547
43548
43549
43550
43551
43552
43553
43554
43555
43556
43557
43558
43559
43560
43561
43562
43563
43564
43565
43566
43567
43568
43569
43570
43571
43572
43573
43574
43575
43576
43577
43578
43579
43580
43581
43582
43583
43584
43585
43586
43587
43588
43589
43590
43591
43592
43593
43594
43595
43596
43597
43598
43599
43600
43601
43602
43603
43604
43605
43606
43607
43608
43609
43610
43611
43612
43613
43614
43615
43616
43617
43618
43619
43620
43621
43622
43623
43624
43625
43626
43627
43628
43629
43630
43631
43632
43633
43634
43635
43636
43637
43638
43639
43640
43641
43642
43643
43644
43645
43646
43647
43648
43649
43650
43651
43652
43653
43654
43655
43656
43657
43658
43659
43660
43661
43662
43663
43664
43665
43666
43667
43668
43669
43670
43671
43672
43673
43674
43675
43676
43677
43678
43679
43680
43681
43682
43683
43684
43685
43686
43687
43688
43689
43690
43691
43692
43693
43694
43695
43696
43697
43698
43699
43700
43701
43702
43703
43704
43705
43706
43707
43708
43709
43710
43711
43712
43713
43714
43715
43716
43717
43718
43719
43720
43721
43722
43723
43724
43725
43726
43727
43728
43729
43730
43731
43732
43733
43734
43735
43736
43737
43738
43739
43740
43741
43742
43743
43744
43745
43746
43747
43748
43749
43750
43751
43752
43753
43754
43755
43756
43757
43758
43759
43760
43761
43762
43763
43764
43765
43766
43767
43768
43769
43770
43771
43772
43773
43774
43775
43776
43777
43778
43779
43780
43781
43782
43783
43784
43785
43786
43787
43788
43789
43790
43791
43792
43793
43794
43795
43796
43797
43798
43799
43800
43801
43802
43803
43804
43805
43806
43807
43808
43809
43810
43811
43812
43813
43814
43815
43816
43817
43818
43819
43820
43821
43822
43823
43824
43825
43826
43827
43828
43829
43830
43831
43832
43833
43834
43835
43836
43837
43838
43839
43840
43841
43842
43843
43844
43845
43846
43847
43848
43849
43850
43851
43852
43853
43854
43855
43856
43857
43858
43859
43860
43861
43862
43863
43864
43865
43866
43867
43868
43869
43870
43871
43872
43873
43874
43875
43876
43877
43878
43879
43880
43881
43882
43883
43884
43885
43886
43887
43888
43889
43890
43891
43892
43893
43894
43895
43896
43897
43898
43899
43900
43901
43902
43903
43904
43905
43906
43907
43908
43909
43910
43911
43912
43913
43914
43915
43916
43917
43918
43919
43920
43921
43922
43923
43924
43925
43926
43927
43928
43929
43930
43931
43932
43933
43934
43935
43936
43937
43938
43939
43940
43941
43942
43943
43944
43945
43946
43947
43948
43949
43950
43951
43952
43953
43954
43955
43956
43957
43958
43959
43960
43961
43962
43963
43964
43965
43966
43967
43968
43969
43970
43971
43972
43973
43974
43975
43976
43977
43978
43979
43980
43981
43982
43983
43984
43985
43986
43987
43988
43989
43990
43991
43992
43993
43994
43995
43996
43997
43998
43999
44000
44001
44002
44003
44004
44005
44006
44007
44008
44009
44010
44011
44012
44013
44014
44015
44016
44017
44018
44019
44020
44021
44022
44023
44024
44025
44026
44027
44028
44029
44030
44031
44032
44033
44034
44035
44036
44037
44038
44039
44040
44041
44042
44043
44044
44045
44046
44047
44048
44049
44050
44051
44052
44053
44054
44055
44056
44057
44058
44059
44060
44061
44062
44063
44064
44065
44066
44067
44068
44069
44070
44071
44072
44073
44074
44075
44076
44077
44078
44079
44080
44081
44082
44083
44084
44085
44086
44087
44088
44089
44090
44091
44092
44093
44094
44095
44096
44097
44098
44099
44100
44101
44102
44103
44104
44105
44106
44107
44108
44109
44110
44111
44112
44113
44114
44115
44116
44117
44118
44119
44120
44121
44122
44123
44124
44125
44126
44127
44128
44129
44130
44131
44132
44133
44134
44135
44136
44137
44138
44139
44140
44141
44142
44143
44144
44145
44146
44147
44148
44149
44150
44151
44152
44153
44154
44155
44156
44157
44158
44159
44160
44161
44162
44163
44164
44165
44166
44167
44168
44169
44170
44171
44172
44173
44174
44175
44176
44177
44178
44179
44180
44181
44182
44183
44184
44185
44186
44187
44188
44189
44190
44191
44192
44193
44194
44195
44196
44197
44198
44199
44200
44201
44202
44203
44204
44205
44206
44207
44208
44209
44210
44211
44212
44213
44214
44215
44216
44217
44218
44219
44220
44221
44222
44223
44224
44225
44226
44227
44228
44229
44230
44231
44232
44233
44234
44235
44236
44237
44238
44239
44240
44241
44242
44243
44244
44245
44246
44247
44248
44249
44250
44251
44252
44253
44254
44255
44256
44257
44258
44259
44260
44261
44262
44263
44264
44265
44266
44267
44268
44269
44270
44271
44272
44273
44274
44275
44276
44277
44278
44279
44280
44281
44282
44283
44284
44285
44286
44287
44288
44289
44290
44291
44292
44293
44294
44295
44296
44297
44298
44299
44300
44301
44302
44303
44304
44305
44306
44307
44308
44309
44310
44311
44312
44313
44314
44315
44316
44317
44318
44319
44320
44321
44322
44323
44324
44325
44326
44327
44328
44329
44330
44331
44332
44333
44334
44335
44336
44337
44338
44339
44340
44341
44342
44343
44344
44345
44346
44347
44348
44349
44350
44351
44352
44353
44354
44355
44356
44357
44358
44359
44360
44361
44362
44363
44364
44365
44366
44367
44368
44369
44370
44371
44372
44373
44374
44375
44376
44377
44378
44379
44380
44381
44382
44383
44384
44385
44386
44387
44388
44389
44390
44391
44392
44393
44394
44395
44396
44397
44398
44399
44400
44401
44402
44403
44404
44405
44406
44407
44408
44409
44410
44411
44412
44413
44414
44415
44416
44417
44418
44419
44420
44421
44422
44423
44424
44425
44426
44427
44428
44429
44430
44431
44432
44433
44434
44435
44436
44437
44438
44439
44440
44441
44442
44443
44444
44445
44446
44447
44448
44449
44450
44451
44452
44453
44454
44455
44456
44457
44458
44459
44460
44461
44462
44463
44464
44465
44466
44467
44468
44469
44470
44471
44472
44473
44474
44475
44476
44477
44478
44479
44480
44481
44482
44483
44484
44485
44486
44487
44488
44489
44490
44491
44492
44493
44494
44495
44496
44497
44498
44499
44500
44501
44502
44503
44504
44505
44506
44507
44508
44509
44510
44511
44512
44513
44514
44515
44516
44517
44518
44519
44520
44521
44522
44523
44524
44525
44526
44527
44528
44529
44530
44531
44532
44533
44534
44535
44536
44537
44538
44539
44540
44541
44542
44543
44544
44545
44546
44547
44548
44549
44550
44551
44552
44553
44554
44555
44556
44557
44558
44559
44560
44561
44562
44563
44564
44565
44566
44567
44568
44569
44570
44571
44572
44573
44574
44575
44576
44577
44578
44579
44580
44581
44582
44583
44584
44585
44586
44587
44588
44589
44590
44591
44592
44593
44594
44595
44596
44597
44598
44599
44600
44601
44602
44603
44604
44605
44606
44607
44608
44609
44610
44611
44612
44613
44614
44615
44616
44617
44618
44619
44620
44621
44622
44623
44624
44625
44626
44627
44628
44629
44630
44631
44632
44633
44634
44635
44636
44637
44638
44639
44640
44641
44642
44643
44644
44645
44646
44647
44648
44649
44650
44651
44652
44653
44654
44655
44656
44657
44658
44659
44660
44661
44662
44663
44664
44665
44666
44667
44668
44669
44670
44671
44672
44673
44674
44675
44676
44677
44678
44679
44680
44681
44682
44683
44684
44685
44686
44687
44688
44689
44690
44691
44692
44693
44694
44695
44696
44697
44698
44699
44700
44701
44702
44703
44704
44705
44706
44707
44708
44709
44710
44711
44712
44713
44714
44715
44716
44717
44718
44719
44720
44721
44722
44723
44724
44725
44726
44727
44728
44729
44730
44731
44732
44733
44734
44735
44736
44737
44738
44739
44740
44741
44742
44743
44744
44745
44746
44747
44748
44749
44750
44751
44752
44753
44754
44755
44756
44757
44758
44759
44760
44761
44762
44763
44764
44765
44766
44767
44768
44769
44770
44771
44772
44773
44774
44775
44776
44777
44778
44779
44780
44781
44782
44783
44784
44785
44786
44787
44788
44789
44790
44791
44792
44793
44794
44795
44796
44797
44798
44799
44800
44801
44802
44803
44804
44805
44806
44807
44808
44809
44810
44811
44812
44813
44814
44815
44816
44817
44818
44819
44820
44821
44822
44823
44824
44825
44826
44827
44828
44829
44830
44831
44832
44833
44834
44835
44836
44837
44838
44839
44840
44841
44842
44843
44844
44845
44846
44847
44848
44849
44850
44851
44852
44853
44854
44855
44856
44857
44858
44859
44860
44861
44862
44863
44864
44865
44866
44867
44868
44869
44870
44871
44872
44873
44874
44875
44876
44877
44878
44879
44880
44881
44882
44883
44884
44885
44886
44887
44888
44889
44890
44891
44892
44893
44894
44895
44896
44897
44898
44899
44900
44901
44902
44903
44904
44905
44906
44907
44908
44909
44910
44911
44912
44913
44914
44915
44916
44917
44918
44919
44920
44921
44922
44923
44924
44925
44926
44927
44928
44929
44930
44931
44932
44933
44934
44935
44936
44937
44938
44939
44940
44941
44942
44943
44944
44945
44946
44947
44948
44949
44950
44951
44952
44953
44954
44955
44956
44957
44958
44959
44960
44961
44962
44963
44964
44965
44966
44967
44968
44969
44970
44971
44972
44973
44974
44975
44976
44977
44978
44979
44980
44981
44982
44983
44984
44985
44986
44987
44988
44989
44990
44991
44992
44993
44994
44995
44996
44997
44998
44999
45000
45001
45002
45003
45004
45005
45006
45007
45008
45009
45010
45011
45012
45013
45014
45015
45016
45017
45018
45019
45020
45021
45022
45023
45024
45025
45026
45027
45028
45029
45030
45031
45032
45033
45034
45035
45036
45037
45038
45039
45040
45041
45042
45043
45044
45045
45046
45047
45048
45049
45050
45051
45052
45053
45054
45055
45056
45057
45058
45059
45060
45061
45062
45063
45064
45065
45066
45067
45068
45069
45070
45071
45072
45073
45074
45075
45076
45077
45078
45079
45080
45081
45082
45083
45084
45085
45086
45087
45088
45089
45090
45091
45092
45093
45094
45095
45096
45097
45098
45099
45100
45101
45102
45103
45104
45105
45106
45107
45108
45109
45110
45111
45112
45113
45114
45115
45116
45117
45118
45119
45120
45121
45122
45123
45124
45125
45126
45127
45128
45129
45130
45131
45132
45133
45134
45135
45136
45137
45138
45139
45140
45141
45142
45143
45144
45145
45146
45147
45148
45149
45150
45151
45152
45153
45154
45155
45156
45157
45158
45159
45160
45161
45162
45163
45164
45165
45166
45167
45168
45169
45170
45171
45172
45173
45174
45175
45176
45177
45178
45179
45180
45181
45182
45183
45184
45185
45186
45187
45188
45189
45190
45191
45192
45193
45194
45195
45196
45197
45198
45199
45200
45201
45202
45203
45204
45205
45206
45207
45208
45209
45210
45211
45212
45213
45214
45215
45216
45217
45218
45219
45220
45221
45222
45223
45224
45225
45226
45227
45228
45229
45230
45231
45232
45233
45234
45235
45236
45237
45238
45239
45240
45241
45242
45243
45244
45245
45246
45247
45248
45249
45250
45251
45252
45253
45254
45255
45256
45257
45258
45259
45260
45261
45262
45263
45264
45265
45266
45267
45268
45269
45270
45271
45272
45273
45274
45275
45276
45277
45278
45279
45280
45281
45282
45283
45284
45285
45286
45287
45288
45289
45290
45291
45292
45293
45294
45295
45296
45297
45298
45299
45300
45301
45302
45303
45304
45305
45306
45307
45308
45309
45310
45311
45312
45313
45314
45315
45316
45317
45318
45319
45320
45321
45322
45323
45324
45325
45326
45327
45328
45329
45330
45331
45332
45333
45334
45335
45336
45337
45338
45339
45340
45341
45342
45343
45344
45345
45346
45347
45348
45349
45350
45351
45352
45353
45354
45355
45356
45357
45358
45359
45360
45361
45362
45363
45364
45365
45366
45367
45368
45369
45370
45371
45372
45373
45374
45375
45376
45377
45378
45379
45380
45381
45382
45383
45384
45385
45386
45387
45388
45389
45390
45391
45392
45393
45394
45395
45396
45397
45398
45399
45400
45401
45402
45403
45404
45405
45406
45407
45408
45409
45410
45411
45412
45413
45414
45415
45416
45417
45418
45419
45420
45421
45422
45423
45424
45425
45426
45427
45428
45429
45430
45431
45432
45433
45434
45435
45436
45437
45438
45439
45440
45441
45442
45443
45444
45445
45446
45447
45448
45449
45450
45451
45452
45453
45454
45455
45456
45457
45458
45459
45460
45461
45462
45463
45464
45465
45466
45467
45468
45469
45470
45471
45472
45473
45474
45475
45476
45477
45478
45479
45480
45481
45482
45483
45484
45485
45486
45487
45488
45489
45490
45491
45492
45493
45494
45495
45496
45497
45498
45499
45500
45501
45502
45503
45504
45505
45506
45507
45508
45509
45510
45511
45512
45513
45514
45515
45516
45517
45518
45519
45520
45521
45522
45523
45524
45525
45526
45527
45528
45529
45530
45531
45532
45533
45534
45535
45536
45537
45538
45539
45540
45541
45542
45543
45544
45545
45546
45547
45548
45549
45550
45551
45552
45553
45554
45555
45556
45557
45558
45559
45560
45561
45562
45563
45564
45565
45566
45567
45568
45569
45570
45571
45572
45573
45574
45575
45576
45577
45578
45579
45580
45581
45582
45583
45584
45585
45586
45587
45588
45589
45590
45591
45592
45593
45594
45595
45596
45597
45598
45599
45600
45601
45602
45603
45604
45605
45606
45607
45608
45609
45610
45611
45612
45613
45614
45615
45616
45617
45618
45619
45620
45621
45622
45623
45624
45625
45626
45627
45628
45629
45630
45631
45632
45633
45634
45635
45636
45637
45638
45639
45640
45641
45642
45643
45644
45645
45646
45647
45648
45649
45650
45651
45652
45653
45654
45655
45656
45657
45658
45659
45660
45661
45662
45663
45664
45665
45666
45667
45668
45669
45670
45671
45672
45673
45674
45675
45676
45677
45678
45679
45680
45681
45682
45683
45684
45685
45686
45687
45688
45689
45690
45691
45692
45693
45694
45695
45696
45697
45698
45699
45700
45701
45702
45703
45704
45705
45706
45707
45708
45709
45710
45711
45712
45713
45714
45715
45716
45717
45718
45719
45720
45721
45722
45723
45724
45725
45726
45727
45728
45729
45730
45731
45732
45733
45734
45735
45736
45737
45738
45739
45740
45741
45742
45743
45744
45745
45746
45747
45748
45749
45750
45751
45752
45753
45754
45755
45756
45757
45758
45759
45760
45761
45762
45763
45764
45765
45766
45767
45768
45769
45770
45771
45772
45773
45774
45775
45776
45777
45778
45779
45780
45781
45782
45783
45784
45785
45786
45787
45788
45789
45790
45791
45792
45793
45794
45795
45796
45797
45798
45799
45800
45801
45802
45803
45804
45805
45806
45807
45808
45809
45810
45811
45812
45813
45814
45815
45816
45817
45818
45819
45820
45821
45822
45823
45824
45825
45826
45827
45828
45829
45830
45831
45832
45833
45834
45835
45836
45837
45838
45839
45840
45841
45842
45843
45844
45845
45846
45847
45848
45849
45850
45851
45852
45853
45854
45855
45856
45857
45858
45859
45860
45861
45862
45863
45864
45865
45866
45867
45868
45869
45870
45871
45872
45873
45874
45875
45876
45877
45878
45879
45880
45881
45882
45883
45884
45885
45886
45887
45888
45889
45890
45891
45892
45893
45894
45895
45896
45897
45898
45899
45900
45901
45902
45903
45904
45905
45906
45907
45908
45909
45910
45911
45912
45913
45914
45915
45916
45917
45918
45919
45920
45921
45922
45923
45924
45925
45926
45927
45928
45929
45930
45931
45932
45933
45934
45935
45936
45937
45938
45939
45940
45941
45942
45943
45944
45945
45946
45947
45948
45949
45950
45951
45952
45953
45954
45955
45956
45957
45958
45959
45960
45961
45962
45963
45964
45965
45966
45967
45968
45969
45970
45971
45972
45973
45974
45975
45976
45977
45978
45979
45980
45981
45982
45983
45984
45985
45986
45987
45988
45989
45990
45991
45992
45993
45994
45995
45996
45997
45998
45999
46000
46001
46002
46003
46004
46005
46006
46007
46008
46009
46010
46011
46012
46013
46014
46015
46016
46017
46018
46019
46020
46021
46022
46023
46024
46025
46026
46027
46028
46029
46030
46031
46032
46033
46034
46035
46036
46037
46038
46039
46040
46041
46042
46043
46044
46045
46046
46047
46048
46049
46050
46051
46052
46053
46054
46055
46056
46057
46058
46059
46060
46061
46062
46063
46064
46065
46066
46067
46068
46069
46070
46071
46072
46073
46074
46075
46076
46077
46078
46079
46080
46081
46082
46083
46084
46085
46086
46087
46088
46089
46090
46091
46092
46093
46094
46095
46096
46097
46098
46099
46100
46101
46102
46103
46104
46105
46106
46107
46108
46109
46110
46111
46112
46113
46114
46115
46116
46117
46118
46119
46120
46121
46122
46123
46124
46125
46126
46127
46128
46129
46130
46131
46132
46133
46134
46135
46136
46137
46138
46139
46140
46141
46142
46143
46144
46145
46146
46147
46148
46149
46150
46151
46152
46153
46154
46155
46156
46157
46158
46159
46160
46161
46162
46163
46164
46165
46166
46167
46168
46169
46170
46171
46172
46173
46174
46175
46176
46177
46178
46179
46180
46181
46182
46183
46184
46185
46186
46187
46188
46189
46190
46191
46192
46193
46194
46195
46196
46197
46198
46199
46200
46201
46202
46203
46204
46205
46206
46207
46208
46209
46210
46211
46212
46213
46214
46215
46216
46217
46218
46219
46220
46221
46222
46223
46224
46225
46226
46227
46228
46229
46230
46231
46232
46233
46234
46235
46236
46237
46238
46239
46240
46241
46242
46243
46244
46245
46246
46247
46248
46249
46250
46251
46252
46253
46254
46255
46256
46257
46258
46259
46260
46261
46262
46263
46264
46265
46266
46267
46268
46269
46270
46271
46272
46273
46274
46275
46276
46277
46278
46279
46280
46281
46282
46283
46284
46285
46286
46287
46288
46289
46290
46291
46292
46293
46294
46295
46296
46297
46298
46299
46300
46301
46302
46303
46304
46305
46306
46307
46308
46309
46310
46311
46312
46313
46314
46315
46316
46317
46318
46319
46320
46321
46322
46323
46324
46325
46326
46327
46328
46329
46330
46331
46332
46333
46334
46335
46336
46337
46338
46339
46340
46341
46342
46343
46344
46345
46346
46347
46348
46349
46350
46351
46352
46353
46354
46355
46356
46357
46358
46359
46360
46361
46362
46363
46364
46365
46366
46367
46368
46369
46370
46371
46372
46373
46374
46375
46376
46377
46378
46379
46380
46381
46382
46383
46384
46385
46386
46387
46388
46389
46390
46391
46392
46393
46394
46395
46396
46397
46398
46399
46400
46401
46402
46403
46404
46405
46406
46407
46408
46409
46410
46411
46412
46413
46414
46415
46416
46417
46418
46419
46420
46421
46422
46423
46424
46425
46426
46427
46428
46429
46430
46431
46432
46433
46434
46435
46436
46437
46438
46439
46440
46441
46442
46443
46444
46445
46446
46447
46448
46449
46450
46451
46452
46453
46454
46455
46456
46457
46458
46459
46460
46461
46462
46463
46464
46465
46466
46467
46468
46469
46470
46471
46472
46473
46474
46475
46476
46477
46478
46479
46480
46481
46482
46483
46484
46485
46486
46487
46488
46489
46490
46491
46492
46493
46494
46495
46496
46497
46498
46499
46500
46501
46502
46503
46504
46505
46506
46507
46508
46509
46510
46511
46512
46513
46514
46515
46516
46517
46518
46519
46520
46521
46522
46523
46524
46525
46526
46527
46528
46529
46530
46531
46532
46533
46534
46535
46536
46537
46538
46539
46540
46541
46542
46543
46544
46545
46546
46547
46548
46549
46550
46551
46552
46553
46554
46555
46556
46557
46558
46559
46560
46561
46562
46563
46564
46565
46566
46567
46568
46569
46570
46571
46572
46573
46574
46575
46576
46577
46578
46579
46580
46581
46582
46583
46584
46585
46586
46587
46588
46589
46590
46591
46592
46593
46594
46595
46596
46597
46598
46599
46600
46601
46602
46603
46604
46605
46606
46607
46608
46609
46610
46611
46612
46613
46614
46615
46616
46617
46618
46619
46620
46621
46622
46623
46624
46625
46626
46627
46628
46629
46630
46631
46632
46633
46634
46635
46636
46637
46638
46639
46640
46641
46642
46643
46644
46645
46646
46647
46648
46649
46650
46651
46652
46653
46654
46655
46656
46657
46658
46659
46660
46661
46662
46663
46664
46665
46666
46667
46668
46669
46670
46671
46672
46673
46674
46675
46676
46677
46678
46679
46680
46681
46682
46683
46684
46685
46686
46687
46688
46689
46690
46691
46692
46693
46694
46695
46696
46697
46698
46699
46700
46701
46702
46703
46704
46705
46706
46707
46708
46709
46710
46711
46712
46713
46714
46715
46716
46717
46718
46719
46720
46721
46722
46723
46724
46725
46726
46727
46728
46729
46730
46731
46732
46733
46734
46735
46736
46737
46738
46739
46740
46741
46742
46743
46744
46745
46746
46747
46748
46749
46750
46751
46752
46753
46754
46755
46756
46757
46758
46759
46760
46761
46762
46763
46764
46765
46766
46767
46768
46769
46770
46771
46772
46773
46774
46775
46776
46777
46778
46779
46780
46781
46782
46783
46784
46785
46786
46787
46788
46789
46790
46791
46792
46793
46794
46795
46796
46797
46798
46799
46800
46801
46802
46803
46804
46805
46806
46807
46808
46809
46810
46811
46812
46813
46814
46815
46816
46817
46818
46819
46820
46821
46822
46823
46824
46825
46826
46827
46828
46829
46830
46831
46832
46833
46834
46835
46836
46837
46838
46839
46840
46841
46842
46843
46844
46845
46846
46847
46848
46849
46850
46851
46852
46853
46854
46855
46856
46857
46858
46859
46860
46861
46862
46863
46864
46865
46866
46867
46868
46869
46870
46871
46872
46873
46874
46875
46876
46877
46878
46879
46880
46881
46882
46883
46884
46885
46886
46887
46888
46889
46890
46891
46892
46893
46894
46895
46896
46897
46898
46899
46900
46901
46902
46903
46904
46905
46906
46907
46908
46909
46910
46911
46912
46913
46914
46915
46916
46917
46918
46919
46920
46921
46922
46923
46924
46925
46926
46927
46928
46929
46930
46931
46932
46933
46934
46935
46936
46937
46938
46939
46940
46941
46942
46943
46944
46945
46946
46947
46948
46949
46950
46951
46952
46953
46954
46955
46956
46957
46958
46959
46960
46961
46962
46963
46964
46965
46966
46967
46968
46969
46970
46971
46972
46973
46974
46975
46976
46977
46978
46979
46980
46981
46982
46983
46984
46985
46986
46987
46988
46989
46990
46991
46992
46993
46994
46995
46996
46997
46998
46999
47000
47001
47002
47003
47004
47005
47006
47007
47008
47009
47010
47011
47012
47013
47014
47015
47016
47017
47018
47019
47020
47021
47022
47023
47024
47025
47026
47027
47028
47029
47030
47031
47032
47033
47034
47035
47036
47037
47038
47039
47040
47041
47042
47043
47044
47045
47046
47047
47048
47049
47050
47051
47052
47053
47054
47055
47056
47057
47058
47059
47060
47061
47062
47063
47064
47065
47066
47067
47068
47069
47070
47071
47072
47073
47074
47075
47076
47077
47078
47079
47080
47081
47082
47083
47084
47085
47086
47087
47088
47089
47090
47091
47092
47093
47094
47095
47096
47097
47098
47099
47100
47101
47102
47103
47104
47105
47106
47107
47108
47109
47110
47111
47112
47113
47114
47115
47116
47117
47118
47119
47120
47121
47122
47123
47124
47125
47126
47127
47128
47129
47130
47131
47132
47133
47134
47135
47136
47137
47138
47139
47140
47141
47142
47143
47144
47145
47146
47147
47148
47149
47150
47151
47152
47153
47154
47155
47156
47157
47158
47159
47160
47161
47162
47163
47164
47165
47166
47167
47168
47169
47170
47171
47172
47173
47174
47175
47176
47177
47178
47179
47180
47181
47182
47183
47184
47185
47186
47187
47188
47189
47190
47191
47192
47193
47194
47195
47196
47197
47198
47199
47200
47201
47202
47203
47204
47205
47206
47207
47208
47209
47210
47211
47212
47213
47214
47215
47216
47217
47218
47219
47220
47221
47222
47223
47224
47225
47226
47227
47228
47229
47230
47231
47232
47233
47234
47235
47236
47237
47238
47239
47240
47241
47242
47243
47244
47245
47246
47247
47248
47249
47250
47251
47252
47253
47254
47255
47256
47257
47258
47259
47260
47261
47262
47263
47264
47265
47266
47267
47268
47269
47270
47271
47272
47273
47274
47275
47276
47277
47278
47279
47280
47281
47282
47283
47284
47285
47286
47287
47288
47289
47290
47291
47292
47293
47294
47295
47296
47297
47298
47299
47300
47301
47302
47303
47304
47305
47306
47307
47308
47309
47310
47311
47312
47313
47314
47315
47316
47317
47318
47319
47320
47321
47322
47323
47324
47325
47326
47327
47328
47329
47330
47331
47332
47333
47334
47335
47336
47337
47338
47339
47340
47341
47342
47343
47344
47345
47346
47347
47348
47349
47350
47351
47352
47353
47354
47355
47356
47357
47358
47359
47360
47361
47362
47363
47364
47365
47366
47367
47368
47369
47370
47371
47372
47373
47374
47375
47376
47377
47378
47379
47380
47381
47382
47383
47384
47385
47386
47387
47388
47389
47390
47391
47392
47393
47394
47395
47396
47397
47398
47399
47400
47401
47402
47403
47404
47405
47406
47407
47408
47409
47410
47411
47412
47413
47414
47415
47416
47417
47418
47419
47420
47421
47422
47423
47424
47425
47426
47427
47428
47429
47430
47431
47432
47433
47434
47435
47436
47437
47438
47439
47440
47441
47442
47443
47444
47445
47446
47447
47448
47449
47450
47451
47452
47453
47454
47455
47456
47457
47458
47459
47460
47461
47462
47463
47464
47465
47466
47467
47468
47469
47470
47471
47472
47473
47474
47475
47476
47477
47478
47479
47480
47481
47482
47483
47484
47485
47486
47487
47488
47489
47490
47491
47492
47493
47494
47495
47496
47497
47498
47499
47500
47501
47502
47503
47504
47505
47506
47507
47508
47509
47510
47511
47512
47513
47514
47515
47516
47517
47518
47519
47520
47521
47522
47523
47524
47525
47526
47527
47528
47529
47530
47531
47532
47533
47534
47535
47536
47537
47538
47539
47540
47541
47542
47543
47544
47545
47546
47547
47548
47549
47550
47551
47552
47553
47554
47555
47556
47557
47558
47559
47560
47561
47562
47563
47564
47565
47566
47567
47568
47569
47570
47571
47572
47573
47574
47575
47576
47577
47578
47579
47580
47581
47582
47583
47584
47585
47586
47587
47588
47589
47590
47591
47592
47593
47594
47595
47596
47597
47598
47599
47600
47601
47602
47603
47604
47605
47606
47607
47608
47609
47610
47611
47612
47613
47614
47615
47616
47617
47618
47619
47620
47621
47622
47623
47624
47625
47626
47627
47628
47629
47630
47631
47632
47633
47634
47635
47636
47637
47638
47639
47640
47641
47642
47643
47644
47645
47646
47647
47648
47649
47650
47651
47652
47653
47654
47655
47656
47657
47658
47659
47660
47661
47662
47663
47664
47665
47666
47667
47668
47669
47670
47671
47672
47673
47674
47675
47676
47677
47678
47679
47680
47681
47682
47683
47684
47685
47686
47687
47688
47689
47690
47691
47692
47693
47694
47695
47696
47697
47698
47699
47700
47701
47702
47703
47704
47705
47706
47707
47708
47709
47710
47711
47712
47713
47714
47715
47716
47717
47718
47719
47720
47721
47722
47723
47724
47725
47726
47727
47728
47729
47730
47731
47732
47733
47734
47735
47736
47737
47738
47739
47740
47741
47742
47743
47744
47745
47746
47747
47748
47749
47750
47751
47752
47753
47754
47755
47756
47757
47758
47759
47760
47761
47762
47763
47764
47765
47766
47767
47768
47769
47770
47771
47772
47773
47774
47775
47776
47777
47778
47779
47780
47781
47782
47783
47784
47785
47786
47787
47788
47789
47790
47791
47792
47793
47794
47795
47796
47797
47798
47799
47800
47801
47802
47803
47804
47805
47806
47807
47808
47809
47810
47811
47812
47813
47814
47815
47816
47817
47818
47819
47820
47821
47822
47823
47824
47825
47826
47827
47828
47829
47830
47831
47832
47833
47834
47835
47836
47837
47838
47839
47840
47841
47842
47843
47844
47845
47846
47847
47848
47849
47850
47851
47852
47853
47854
47855
47856
47857
47858
47859
47860
47861
47862
47863
47864
47865
47866
47867
47868
47869
47870
47871
47872
47873
47874
47875
47876
47877
47878
47879
47880
47881
47882
47883
47884
47885
47886
47887
47888
47889
47890
47891
47892
47893
47894
47895
47896
47897
47898
47899
47900
47901
47902
47903
47904
47905
47906
47907
47908
47909
47910
47911
47912
47913
47914
47915
47916
47917
47918
47919
47920
47921
47922
47923
47924
47925
47926
47927
47928
47929
47930
47931
47932
47933
47934
47935
47936
47937
47938
47939
47940
47941
47942
47943
47944
47945
47946
47947
47948
47949
47950
47951
47952
47953
47954
47955
47956
47957
47958
47959
47960
47961
47962
47963
47964
47965
47966
47967
47968
47969
47970
47971
47972
47973
47974
47975
47976
47977
47978
47979
47980
47981
47982
47983
47984
47985
47986
47987
47988
47989
47990
47991
47992
47993
47994
47995
47996
47997
47998
47999
48000
48001
48002
48003
48004
48005
48006
48007
48008
48009
48010
48011
48012
48013
48014
48015
48016
48017
48018
48019
48020
48021
48022
48023
48024
48025
48026
48027
48028
48029
48030
48031
48032
48033
48034
48035
48036
48037
48038
48039
48040
48041
48042
48043
48044
48045
48046
48047
48048
48049
48050
48051
48052
48053
48054
48055
48056
48057
48058
48059
48060
48061
48062
48063
48064
48065
48066
48067
48068
48069
48070
48071
48072
48073
48074
48075
48076
48077
48078
48079
48080
48081
48082
48083
48084
48085
48086
48087
48088
48089
48090
48091
48092
48093
48094
48095
48096
48097
48098
48099
48100
48101
48102
48103
48104
48105
48106
48107
48108
48109
48110
48111
48112
48113
48114
48115
48116
48117
48118
48119
48120
48121
48122
48123
48124
48125
48126
48127
48128
48129
48130
48131
48132
48133
48134
48135
48136
48137
48138
48139
48140
48141
48142
48143
48144
48145
48146
48147
48148
48149
48150
48151
48152
48153
48154
48155
48156
48157
48158
48159
48160
48161
48162
48163
48164
48165
48166
48167
48168
48169
48170
48171
48172
48173
48174
48175
48176
48177
48178
48179
48180
48181
48182
48183
48184
48185
48186
48187
48188
48189
48190
48191
48192
48193
48194
48195
48196
48197
48198
48199
48200
48201
48202
48203
48204
48205
48206
48207
48208
48209
48210
48211
48212
48213
48214
48215
48216
48217
48218
48219
48220
48221
48222
48223
48224
48225
48226
48227
48228
48229
48230
48231
48232
48233
48234
48235
48236
48237
48238
48239
48240
48241
48242
48243
48244
48245
48246
48247
48248
48249
48250
48251
48252
48253
48254
48255
48256
48257
48258
48259
48260
48261
48262
48263
48264
48265
48266
48267
48268
48269
48270
48271
48272
48273
48274
48275
48276
48277
48278
48279
48280
48281
48282
48283
48284
48285
48286
48287
48288
48289
48290
48291
48292
48293
48294
48295
48296
48297
48298
48299
48300
48301
48302
48303
48304
48305
48306
48307
48308
48309
48310
48311
48312
48313
48314
48315
48316
48317
48318
48319
48320
48321
48322
48323
48324
48325
48326
48327
48328
48329
48330
48331
48332
48333
48334
48335
48336
48337
48338
48339
48340
48341
48342
48343
48344
48345
48346
48347
48348
48349
48350
48351
48352
48353
48354
48355
48356
48357
48358
48359
48360
48361
48362
48363
48364
48365
48366
48367
48368
48369
48370
48371
48372
48373
48374
48375
48376
48377
48378
48379
48380
48381
48382
48383
48384
48385
48386
48387
48388
48389
48390
48391
48392
48393
48394
48395
48396
48397
48398
48399
48400
48401
48402
48403
48404
48405
48406
48407
48408
48409
48410
48411
48412
48413
48414
48415
48416
48417
48418
48419
48420
48421
48422
48423
48424
48425
48426
48427
48428
48429
48430
48431
48432
48433
48434
48435
48436
48437
48438
48439
48440
48441
48442
48443
48444
48445
48446
48447
48448
48449
48450
48451
48452
48453
48454
48455
48456
48457
48458
48459
48460
48461
48462
48463
48464
48465
48466
48467
48468
48469
48470
48471
48472
48473
48474
48475
48476
48477
48478
48479
48480
48481
48482
48483
48484
48485
48486
48487
48488
48489
48490
48491
48492
48493
48494
48495
48496
48497
48498
48499
48500
48501
48502
48503
48504
48505
48506
48507
48508
48509
48510
48511
48512
48513
48514
48515
48516
48517
48518
48519
48520
48521
48522
48523
48524
48525
48526
48527
48528
48529
48530
48531
48532
48533
48534
48535
48536
48537
48538
48539
48540
48541
48542
48543
48544
48545
48546
48547
48548
48549
48550
48551
48552
48553
48554
48555
48556
48557
48558
48559
48560
48561
48562
48563
48564
48565
48566
48567
48568
48569
48570
48571
48572
48573
48574
48575
48576
48577
48578
48579
48580
48581
48582
48583
48584
48585
48586
48587
48588
48589
48590
48591
48592
48593
48594
48595
48596
48597
48598
48599
48600
48601
48602
48603
48604
48605
48606
48607
48608
48609
48610
48611
48612
48613
48614
48615
48616
48617
48618
48619
48620
48621
48622
48623
48624
48625
48626
48627
48628
48629
48630
48631
48632
48633
48634
48635
48636
48637
48638
48639
48640
48641
48642
48643
48644
48645
48646
48647
48648
48649
48650
48651
48652
48653
48654
48655
48656
48657
48658
48659
48660
48661
48662
48663
48664
48665
48666
48667
48668
48669
48670
48671
48672
48673
48674
48675
48676
48677
48678
48679
48680
48681
48682
48683
48684
48685
48686
48687
48688
48689
48690
48691
48692
48693
48694
48695
48696
48697
48698
48699
48700
48701
48702
48703
48704
48705
48706
48707
48708
48709
48710
48711
48712
48713
48714
48715
48716
48717
48718
48719
48720
48721
48722
48723
48724
48725
48726
48727
48728
48729
48730
48731
48732
48733
48734
48735
48736
48737
48738
48739
48740
48741
48742
48743
48744
48745
48746
48747
48748
48749
48750
48751
48752
48753
48754
48755
48756
48757
48758
48759
48760
48761
48762
48763
48764
48765
48766
48767
48768
48769
48770
48771
48772
48773
48774
48775
48776
48777
48778
48779
48780
48781
48782
48783
48784
48785
48786
48787
48788
48789
48790
48791
48792
48793
48794
48795
48796
48797
48798
48799
48800
48801
48802
48803
48804
48805
48806
48807
48808
48809
48810
48811
48812
48813
48814
48815
48816
48817
48818
48819
48820
48821
48822
48823
48824
48825
48826
48827
48828
48829
48830
48831
48832
48833
48834
48835
48836
48837
48838
48839
48840
48841
48842
48843
48844
48845
48846
48847
48848
48849
48850
48851
48852
48853
48854
48855
48856
48857
48858
48859
48860
48861
48862
48863
48864
48865
48866
48867
48868
48869
48870
48871
48872
48873
48874
48875
48876
48877
48878
48879
48880
48881
48882
48883
48884
48885
48886
48887
48888
48889
48890
48891
48892
48893
48894
48895
48896
48897
48898
48899
48900
48901
48902
48903
48904
48905
48906
48907
48908
48909
48910
48911
48912
48913
48914
48915
48916
48917
48918
48919
48920
48921
48922
48923
48924
48925
48926
48927
48928
48929
48930
48931
48932
48933
48934
48935
48936
48937
48938
48939
48940
48941
48942
48943
48944
48945
48946
48947
48948
48949
48950
48951
48952
48953
48954
48955
48956
48957
48958
48959
48960
48961
48962
48963
48964
48965
48966
48967
48968
48969
48970
48971
48972
48973
48974
48975
48976
48977
48978
48979
48980
48981
48982
48983
48984
48985
48986
48987
48988
48989
48990
48991
48992
48993
48994
48995
48996
48997
48998
48999
49000
49001
49002
49003
49004
49005
49006
49007
49008
49009
49010
49011
49012
49013
49014
49015
49016
49017
49018
49019
49020
49021
49022
49023
49024
49025
49026
49027
49028
49029
49030
49031
49032
49033
49034
49035
49036
49037
49038
49039
49040
49041
49042
49043
49044
49045
49046
49047
49048
49049
49050
49051
49052
49053
49054
49055
49056
49057
49058
49059
49060
49061
49062
49063
49064
49065
49066
49067
49068
49069
49070
49071
49072
49073
49074
49075
49076
49077
49078
49079
49080
49081
49082
49083
49084
49085
49086
49087
49088
49089
49090
49091
49092
49093
49094
49095
49096
49097
49098
49099
49100
49101
49102
49103
49104
49105
49106
49107
49108
49109
49110
49111
49112
49113
49114
49115
49116
49117
49118
49119
49120
49121
49122
49123
49124
49125
49126
49127
49128
49129
49130
49131
49132
49133
49134
49135
49136
49137
49138
49139
49140
49141
49142
49143
49144
49145
49146
49147
49148
49149
49150
49151
49152
49153
49154
49155
49156
49157
49158
49159
49160
49161
49162
49163
49164
49165
49166
49167
49168
49169
49170
49171
49172
49173
49174
49175
49176
49177
49178
49179
49180
49181
49182
49183
49184
49185
49186
49187
49188
49189
49190
49191
49192
49193
49194
49195
49196
49197
49198
49199
49200
49201
49202
49203
49204
49205
49206
49207
49208
49209
49210
49211
49212
49213
49214
49215
49216
49217
49218
49219
49220
49221
49222
49223
49224
49225
49226
49227
49228
49229
49230
49231
49232
49233
49234
49235
49236
49237
49238
49239
49240
49241
49242
49243
49244
49245
49246
49247
49248
49249
49250
49251
49252
49253
49254
49255
49256
49257
49258
49259
49260
49261
49262
49263
49264
49265
49266
49267
49268
49269
49270
49271
49272
49273
49274
49275
49276
49277
49278
49279
49280
49281
49282
49283
49284
49285
49286
49287
49288
49289
49290
49291
49292
49293
49294
49295
49296
49297
49298
49299
49300
49301
49302
49303
49304
49305
49306
49307
49308
49309
49310
49311
49312
49313
49314
49315
49316
49317
49318
49319
49320
49321
49322
49323
49324
49325
49326
49327
49328
49329
49330
49331
49332
49333
49334
49335
49336
49337
49338
49339
49340
49341
49342
49343
49344
49345
49346
49347
49348
49349
49350
49351
49352
49353
49354
49355
49356
49357
49358
49359
49360
49361
49362
49363
49364
49365
49366
49367
49368
49369
49370
49371
49372
49373
49374
49375
49376
49377
49378
49379
49380
49381
49382
49383
49384
49385
49386
49387
49388
49389
49390
49391
49392
49393
49394
49395
49396
49397
49398
49399
49400
49401
49402
49403
49404
49405
49406
49407
49408
49409
49410
49411
49412
49413
49414
49415
49416
49417
49418
49419
49420
49421
49422
49423
49424
49425
49426
49427
49428
49429
49430
49431
49432
49433
49434
49435
49436
49437
49438
49439
49440
49441
49442
49443
49444
49445
49446
49447
49448
49449
49450
49451
49452
49453
49454
49455
49456
49457
49458
49459
49460
49461
49462
49463
49464
49465
49466
49467
49468
49469
49470
49471
49472
49473
49474
49475
49476
49477
49478
49479
49480
49481
49482
49483
49484
49485
49486
49487
49488
49489
49490
49491
49492
49493
49494
49495
49496
49497
49498
49499
49500
49501
49502
49503
49504
49505
49506
49507
49508
49509
49510
49511
49512
49513
49514
49515
49516
49517
49518
49519
49520
49521
49522
49523
49524
49525
49526
49527
49528
49529
49530
49531
49532
49533
49534
49535
49536
49537
49538
49539
49540
49541
49542
49543
49544
49545
49546
49547
49548
49549
49550
49551
49552
49553
49554
49555
49556
49557
49558
49559
49560
49561
49562
49563
49564
49565
49566
49567
49568
49569
49570
49571
49572
49573
49574
49575
49576
49577
49578
49579
49580
49581
49582
49583
49584
49585
49586
49587
49588
49589
49590
49591
49592
49593
49594
49595
49596
49597
49598
49599
49600
49601
49602
49603
49604
49605
49606
49607
49608
49609
49610
49611
49612
49613
49614
49615
49616
49617
49618
49619
49620
49621
49622
49623
49624
49625
49626
49627
49628
49629
49630
49631
49632
49633
49634
49635
49636
49637
49638
49639
49640
49641
49642
49643
49644
49645
49646
49647
49648
49649
49650
49651
49652
49653
49654
49655
49656
49657
49658
49659
49660
49661
49662
49663
49664
49665
49666
49667
49668
49669
49670
49671
49672
49673
49674
49675
49676
49677
49678
49679
49680
49681
49682
49683
49684
49685
49686
49687
49688
49689
49690
49691
49692
49693
49694
49695
49696
49697
49698
49699
49700
49701
49702
49703
49704
49705
49706
49707
49708
49709
49710
49711
49712
49713
49714
49715
49716
49717
49718
49719
49720
49721
49722
49723
49724
49725
49726
49727
49728
49729
49730
49731
49732
49733
49734
49735
49736
49737
49738
49739
49740
49741
49742
49743
49744
49745
49746
49747
49748
49749
49750
49751
49752
49753
49754
49755
49756
49757
49758
49759
49760
49761
49762
49763
49764
49765
49766
49767
49768
49769
49770
49771
49772
49773
49774
49775
49776
49777
49778
49779
49780
49781
49782
49783
49784
49785
49786
49787
49788
49789
49790
49791
49792
49793
49794
49795
49796
49797
49798
49799
49800
49801
49802
49803
49804
49805
49806
49807
49808
49809
49810
49811
49812
49813
49814
49815
49816
49817
49818
49819
49820
49821
49822
49823
49824
49825
49826
49827
49828
49829
49830
49831
49832
49833
49834
49835
49836
49837
49838
49839
49840
49841
49842
49843
49844
49845
49846
49847
49848
49849
49850
49851
49852
49853
49854
49855
49856
49857
49858
49859
49860
49861
49862
49863
49864
49865
49866
49867
49868
49869
49870
49871
49872
49873
49874
49875
49876
49877
49878
49879
49880
49881
49882
49883
49884
49885
49886
49887
49888
49889
49890
49891
49892
49893
49894
49895
49896
49897
49898
49899
49900
49901
49902
49903
49904
49905
49906
49907
49908
49909
49910
49911
49912
49913
49914
49915
49916
49917
49918
49919
49920
49921
49922
49923
49924
49925
49926
49927
49928
49929
49930
49931
49932
49933
49934
49935
49936
49937
49938
49939
49940
49941
49942
49943
49944
49945
49946
49947
49948
49949
49950
49951
49952
49953
49954
49955
49956
49957
49958
49959
49960
49961
49962
49963
49964
49965
49966
49967
49968
49969
49970
49971
49972
49973
49974
49975
49976
49977
49978
49979
49980
49981
49982
49983
49984
49985
49986
49987
49988
49989
49990
49991
49992
49993
49994
49995
49996
49997
49998
49999
50000
50001
50002
50003
50004
50005
50006
50007
50008
50009
50010
50011
50012
50013
50014
50015
50016
50017
50018
50019
50020
50021
50022
50023
50024
50025
50026
50027
50028
50029
50030
50031
50032
50033
50034
50035
50036
50037
50038
50039
50040
50041
50042
50043
50044
50045
50046
50047
50048
50049
50050
50051
50052
50053
50054
50055
50056
50057
50058
50059
50060
50061
50062
50063
50064
50065
50066
50067
50068
50069
50070
50071
50072
50073
50074
50075
50076
50077
50078
50079
50080
50081
50082
50083
50084
50085
50086
50087
50088
50089
50090
50091
50092
50093
50094
50095
50096
50097
50098
50099
50100
50101
50102
50103
50104
50105
50106
50107
50108
50109
50110
50111
50112
50113
50114
50115
50116
50117
50118
50119
50120
50121
50122
50123
50124
50125
50126
50127
50128
50129
50130
50131
50132
50133
50134
50135
50136
50137
50138
50139
50140
50141
50142
50143
50144
50145
50146
50147
50148
50149
50150
50151
50152
50153
50154
50155
50156
50157
50158
50159
50160
50161
50162
50163
50164
50165
50166
50167
50168
50169
50170
50171
50172
50173
50174
50175
50176
50177
50178
50179
50180
50181
50182
50183
50184
50185
50186
50187
50188
50189
50190
50191
50192
50193
50194
50195
50196
50197
50198
50199
50200
50201
50202
50203
50204
50205
50206
50207
50208
50209
50210
50211
50212
50213
50214
50215
50216
50217
50218
50219
50220
50221
50222
50223
50224
50225
50226
50227
50228
50229
50230
50231
50232
50233
50234
50235
50236
50237
50238
50239
50240
50241
50242
50243
50244
50245
50246
50247
50248
50249
50250
50251
50252
50253
50254
50255
50256
50257
50258
50259
50260
50261
50262
50263
50264
50265
50266
50267
50268
50269
50270
50271
50272
50273
50274
50275
50276
50277
50278
50279
50280
50281
50282
50283
50284
50285
50286
50287
50288
50289
50290
50291
50292
50293
50294
50295
50296
50297
50298
50299
50300
50301
50302
50303
50304
50305
50306
50307
50308
50309
50310
50311
50312
50313
50314
50315
50316
50317
50318
50319
50320
50321
50322
50323
50324
50325
50326
50327
50328
50329
50330
50331
50332
50333
50334
50335
50336
50337
50338
50339
50340
50341
50342
50343
50344
50345
50346
50347
50348
50349
50350
50351
50352
50353
50354
50355
50356
50357
50358
50359
50360
50361
50362
50363
50364
50365
50366
50367
50368
50369
50370
50371
50372
50373
50374
50375
50376
50377
50378
50379
50380
50381
50382
50383
50384
50385
50386
50387
50388
50389
50390
50391
50392
50393
50394
50395
50396
50397
50398
50399
50400
50401
50402
50403
50404
50405
50406
50407
50408
50409
50410
50411
50412
50413
50414
50415
50416
50417
50418
50419
50420
50421
50422
50423
50424
50425
50426
50427
50428
50429
50430
50431
50432
50433
50434
50435
50436
50437
50438
50439
50440
50441
50442
50443
50444
50445
50446
50447
50448
50449
50450
50451
50452
50453
50454
50455
50456
50457
50458
50459
50460
50461
50462
50463
50464
50465
50466
50467
50468
50469
50470
50471
50472
50473
50474
50475
50476
50477
50478
50479
50480
50481
50482
50483
50484
50485
50486
50487
50488
50489
50490
50491
50492
50493
50494
50495
50496
50497
50498
50499
50500
50501
50502
50503
50504
50505
50506
50507
50508
50509
50510
50511
50512
50513
50514
50515
50516
50517
50518
50519
50520
50521
50522
50523
50524
50525
50526
50527
50528
50529
50530
50531
50532
50533
50534
50535
50536
50537
50538
50539
50540
50541
50542
50543
50544
50545
50546
50547
50548
50549
50550
50551
50552
50553
50554
50555
50556
50557
50558
50559
50560
50561
50562
50563
50564
50565
50566
50567
50568
50569
50570
50571
50572
50573
50574
50575
50576
50577
50578
50579
50580
50581
50582
50583
50584
50585
50586
50587
50588
50589
50590
50591
50592
50593
50594
50595
50596
50597
50598
50599
50600
50601
50602
50603
50604
50605
50606
50607
50608
50609
50610
50611
50612
50613
50614
50615
50616
50617
50618
50619
50620
50621
50622
50623
50624
50625
50626
50627
50628
50629
50630
50631
50632
50633
50634
50635
50636
50637
50638
50639
50640
50641
50642
50643
50644
50645
50646
50647
50648
50649
50650
50651
50652
50653
50654
50655
50656
50657
50658
50659
50660
50661
50662
50663
50664
50665
50666
50667
50668
50669
50670
50671
50672
50673
50674
50675
50676
50677
50678
50679
50680
50681
50682
50683
50684
50685
50686
50687
50688
50689
50690
50691
50692
50693
50694
50695
50696
50697
50698
50699
50700
50701
50702
50703
50704
50705
50706
50707
50708
50709
50710
50711
50712
50713
50714
50715
50716
50717
50718
50719
50720
50721
50722
50723
50724
50725
50726
50727
50728
50729
50730
50731
50732
50733
50734
50735
50736
50737
50738
50739
50740
50741
50742
50743
50744
50745
50746
50747
50748
50749
50750
50751
50752
50753
50754
50755
50756
50757
50758
50759
50760
50761
50762
50763
50764
50765
50766
50767
50768
50769
50770
50771
50772
50773
50774
50775
50776
50777
50778
50779
50780
50781
50782
50783
50784
50785
50786
50787
50788
50789
50790
50791
50792
50793
50794
50795
50796
50797
50798
50799
50800
50801
50802
50803
50804
50805
50806
50807
50808
50809
50810
50811
50812
50813
50814
50815
50816
50817
50818
50819
50820
50821
50822
50823
50824
50825
50826
50827
50828
50829
50830
50831
50832
50833
50834
50835
50836
50837
50838
50839
50840
50841
50842
50843
50844
50845
50846
50847
50848
50849
50850
50851
50852
50853
50854
50855
50856
50857
50858
50859
50860
50861
50862
50863
50864
50865
50866
50867
50868
50869
50870
50871
50872
50873
50874
50875
50876
50877
50878
50879
50880
50881
50882
50883
50884
50885
50886
50887
50888
50889
50890
50891
50892
50893
50894
50895
50896
50897
50898
50899
50900
50901
50902
50903
50904
50905
50906
50907
50908
50909
50910
50911
50912
50913
50914
50915
50916
50917
50918
50919
50920
50921
50922
50923
50924
50925
50926
50927
50928
50929
50930
50931
50932
50933
50934
50935
50936
50937
50938
50939
50940
50941
50942
50943
50944
50945
50946
50947
50948
50949
50950
50951
50952
50953
50954
50955
50956
50957
50958
50959
50960
50961
50962
50963
50964
50965
50966
50967
50968
50969
50970
50971
50972
50973
50974
50975
50976
50977
50978
50979
50980
50981
50982
50983
50984
50985
50986
50987
50988
50989
50990
50991
50992
50993
50994
50995
50996
50997
50998
50999
51000
51001
51002
51003
51004
51005
51006
51007
51008
51009
51010
51011
51012
51013
51014
51015
51016
51017
51018
51019
51020
51021
51022
51023
51024
51025
51026
51027
51028
51029
51030
51031
51032
51033
51034
51035
51036
51037
51038
51039
51040
51041
51042
51043
51044
51045
51046
51047
51048
51049
51050
51051
51052
51053
51054
51055
51056
51057
51058
51059
51060
51061
51062
51063
51064
51065
51066
51067
51068
51069
51070
51071
51072
51073
51074
51075
51076
51077
51078
51079
51080
51081
51082
51083
51084
51085
51086
51087
51088
51089
51090
51091
51092
51093
51094
51095
51096
51097
51098
51099
51100
51101
51102
51103
51104
51105
51106
51107
51108
51109
51110
51111
51112
51113
51114
51115
51116
51117
51118
51119
51120
51121
51122
51123
51124
51125
51126
51127
51128
51129
51130
51131
51132
51133
51134
51135
51136
51137
51138
51139
51140
51141
51142
51143
51144
51145
51146
51147
51148
51149
51150
51151
51152
51153
51154
51155
51156
51157
51158
51159
51160
51161
51162
51163
51164
51165
51166
51167
51168
51169
51170
51171
51172
51173
51174
51175
51176
51177
51178
51179
51180
51181
51182
51183
51184
51185
51186
51187
51188
51189
51190
51191
51192
51193
51194
51195
51196
51197
51198
51199
51200
51201
51202
51203
51204
51205
51206
51207
51208
51209
51210
51211
51212
51213
51214
51215
51216
51217
51218
51219
51220
51221
51222
51223
51224
51225
51226
51227
51228
51229
51230
51231
51232
51233
51234
51235
51236
51237
51238
51239
51240
51241
51242
51243
51244
51245
51246
51247
51248
51249
51250
51251
51252
51253
51254
51255
51256
51257
51258
51259
51260
51261
51262
51263
51264
51265
51266
51267
51268
51269
51270
51271
51272
51273
51274
51275
51276
51277
51278
51279
51280
51281
51282
51283
51284
51285
51286
51287
Patches for Vim - Vi IMproved 7.2

Individual patches for Vim 7.2:

  SIZE  NAME     FIXES
  1877  7.2.001  Mac: pseudo-ttys don't work properly on Leopard
  1462  7.2.002  leaking memory when displaying menus
  3663  7.2.003  typo in translated message, message not translated
  3413  7.2.004  Cscope help message is not translated
  4638  7.2.005  a few problems when profiling
  1552  7.2.006  HTML files are not recognized by contents
 16735  7.2.007  (extra) minor issues for VMS
  1947  7.2.008  wrong window count when using :bunload in a BufHidden autocmd
  2245  7.2.009  can't compile with Perl 5.10 on MS-aindows
  5415  7.2.010  "K" in Visual mode does not properly escape all characters
  2873  7.2.011  error when inserting a float value from expression register
  1444  7.2.012  compiler warnings when building with startup timing
  4157  7.2.013  hang when waiting for X selection, consuming lots of CPU time
  1769  7.2.014  synstack() doesn't work in an emptly line
  1943  7.2.015  "make all test install" doesn't stop when the test fails
  4536  7.2.016  cmdline completion pattern can be in freed memory
  5319  7.2.017  X11: strlen() used wrongly, pasting very big selection fails
  1390  7.2.018  memory leak when substitute is aborted
  2269  7.2.019  completion and exists() don't work for ":noautocmd"
  1521  7.2.020  "kvim" starts the GUI even though KDE is no longer supported
  4806  7.2.021  getting full file name when executing autocmds may be slow
  3823  7.2.022  (extra) cannot run tests with the MingW compiler
  2062  7.2.023  'cursorcolumn' wrong in a closed fold when display is shifted
  1452  7.2.024  'history' can be made negative, causes out-of-memory error
  1470  7.2.025  a CursorHold event that invokes system() is retriggered
  2969  7.2.026  (after 7.2.010) 'K' uses the rest of the line
  3235  7.2.027  can use cscope commands in the sandbox, might not be safe
  1466  7.2.028  confusing error message for missing ()
  1291  7.2.029  no completion for ":doautoall" like for ":doautocmd"
  1546  7.2.030  (after 7.2.027) can't compile, ex_oldfiles undefined
 39400  7.2.031  file names from viminfo are not available to the user
  1583  7.2.032  (after 7.2.031) can't compile with EXITFREE defined
  2270  7.2.033  using "ucs-2le" for two-byte BOM, but text might be "utf-16le"
  2372  7.2.034  memory leak in spell info when deleting a buffer
  3522  7.2.035  mismatches for library and Vim alloc/free functions
  7545  7.2.036  (extra) mismatches for library and Vim alloc/free functions
  1576  7.2.037  double free with GTK 1 and compiled with EXITFREE
  2438  7.2.038  overlapping arguments to memcpy()
  1378  7.2.039  accessing freed memory on exit when EXITFREE is defined
  1836  7.2.040  ":e ++ff=dos foo" gets "unix" 'ff' when CR before NL missing
 22993  7.2.041  (extra) diff wrong when edit diff buffer in another tab page
  4987  7.2.042  restoring view in autocmd sometimes doesn't work completely
  2550  7.2.043  VMS: Too many chars escaped in filename and shell commands
  5639  7.2.044  crash because of gcc 4 being over protective for strcpy()
  2056  7.2.045  the Python interface has an empty entry in sys.path
  1704  7.2.046  wrong check for filling buffer with encoding
  2470  7.2.047  using -nb while it is not supported makes other side hang
  4758  7.2.048  v:count and v:prevcount are not set correctly
 32552  7.2.049  (extra) Win32: the clipboard doesn't support UTF-16
  8484  7.2.050  compiler warnings for not using return value of fwrite()
 15179  7.2.051  can't avoid 'wig' and 'suffixes' for glob() and globpath()
  2611  7.2.052  synIDattr() doesn't support "sp" for special color
  1754  7.2.053  crash when using WorkShop command ":ws foo"
  2006  7.2.054  compilation warnings for fprintf format
 34319  7.2.055  various compiler warnings with strict checking
  1635  7.2.056  (after 7.2.050) tests 58 and 59 fail
  3210  7.2.057  (after 7.2.056) trying to put size_t in int variable
  2338  7.2.058  can't add a feature name in the :version output
  1847  7.2.059  diff is not always displayed properly
 34772  7.2.060  spell checking doesn't work well for compound words
  1886  7.2.061  creating funcref requires loading the autoload script first
  1657  7.2.062  "[Scratch]" is not translated
  3558  7.2.063  warning for NULL argument of Perl_sys_init3()
  1942  7.2.064  repeating "~" on a Visual block doesn't always update screen
  5149  7.2.065  GTK GUI: cursor disappears doing ":vsp" when maximized
  2759  7.2.066  not easy to check if 'encoding' is a multi-byte encoding
  1683  7.2.067  can't load sesison extra file when it contains special chars
  2598  7.2.068  error when Emacs tags file line is too long
  1726  7.2.069  (after 7.2.060) compiler warning for putting size_t in int
 17606  7.2.070  crash when a function returns a:000
  2353  7.2.071  (extra) Win32: Handling netbeans events may cause a crash
  1615  7.2.072  (extra, fixed patch) compiler warning in Sniff code
  4121  7.2.073  ":set <xHome>" has the same output as ":set <Home>"
  1832  7.2.074  (extra, after 7.2.073) extra part of 7.2.073
  2218  7.2.075  (after 7.2.058) unclear comment about making a diff
  2666  7.2.076  rename(from, to) deletes file if names refer to the same file
  4745  7.2.077  (after 7.2.076) rename() fails if names differ only in case
  3298  7.2.078  problems with deleting folds
  6947  7.2.079  "killed" netbeans events are not handled correctly
  9942  7.2.080  accessing wrong memory with completion and composing char
  1728  7.2.081  compiler warning for float overflow on VAX
  2134  7.2.082  if 'ff' is "mac" then "ga" on a ^J shows 0x0d instead of 0x0a
  1733  7.2.083  ":tag" doesn't return to the right tag entry in the tag stack
  4331  7.2.084  Python: vim.eval() is wrong for recursive structures 
  1862  7.2.085  ":set <M-b>=<Esc>b" does not work when 'encoding' is utf-8
  3045  7.2.086  using ":diffget 1" in buffer 1 corrupts the text
  1570  7.2.087  adding URL to 'path' doesn't work to edit a file
  2895  7.2.088  (extra) Win32: Using the clipboard sometimes fails
  2473  7.2.089  (extra) Win32: crash when using Ultramon buttons
  3286  7.2.090  user command containing 0x80 does not work properly
  2113  7.2.091  ":cs help" output is not aligned for some languages
  4538  7.2.092  some error messages are not translated
  7287  7.2.093  (extra) dialogs can't always handle multi-byte text
  3430  7.2.094  compiler warning for signed/unsigned compare, typos
  1902  7.2.095  using "r" and then CTRL-C Visual highlighting is not removed
  1464  7.2.096  after ":number" "Press Enter" msg may be on the wrong screen
  1692  7.2.097  "!xterm&" doesn't work when 'shell' is "bash"
  1864  7.2.098  warning for signed/unsigned pointer
  3498  7.2.099  unnecessary redraw when changing GUI options in terminal
  3846  7.2.100  missing first three bytes on sourced FIFO
  1362  7.2.101  (extra) MSVC version not recognized
  1496  7.2.102  (after 7.2.100) BOM at start of Vim script not removed
  5153  7.2.103  tab page line isn't always updated, e.g. when 'bomb' is set
  1523  7.2.104  after ":saveas foo" the tab label isn't updated right away
  2159  7.2.105  modeline setting for 'foldmethod' overrules diff options
  3422  7.2.106  endless loop for "]s" in HTML when there are no misspellings
  1825  7.2.107  After a GUI dialog ":echo" messages are deleted
  1622  7.2.108  (after 7.2.105) can't compile without the diff feature
 11901  7.2.109  'langmap' does not work for multi-byte characters
  1407  7.2.110  compiler warning for unused variable
  2724  7.2.111  selection unclear for Visual block mode with 'cursorcolumn'
  1509  7.2.112  cursor invisible in first col in Visual mode if 'number' set
  2700  7.2.113  crash when using submatch() in substitute()
  2531  7.2.114  using wrong printf format: %d instead of %ld
  2716  7.2.115  some debugging code is never used
  1619  7.2.116  not all memory is freed when EXITFREE is defined
  2592  7.2.117  location list incorrectly labelled "Quickfix List"
  2068  7.2.118  <PageUp> at the more prompt only does half a page
  1550  7.2.119  status line is redrawn too often
  8305  7.2.120  location list is copied and then deleted when opening window
  4993  7.2.121  can't stop output of "!grep a *.c" in gvim with CTRL-C
  2472  7.2.122  invalid mem access if VimResized autocmd changes screen size
  1568  7.2.123  ":map" output continues after typing 'q' at more prompt
  3127  7.2.124  ":tselect" output continues after typing 'q' at more prompt
  3936  7.2.125  leaking memory when reading XPM bitmap for a sign
  4326  7.2.126  when EXITFREE is defined signs and keymaps are not freed
  1708  7.2.127  get another more prompt after typing 'q'
  1537  7.2.128  (after 7.2.055) ":lcd" causes invalid session file
  2229  7.2.129  opening command window from input() uses the search history
 12852  7.2.130  Vim may haing until CTRL-C is typed when using CTRL-Z
  2612  7.2.131  using wrong cursor highlighting after clearing 'keymap'
  7823  7.2.132  accessing freed memory when changing dir in SwapExists autocmd
  1665  7.2.133  ":diffoff!" changes settings in windows not in diff mode
  2314  7.2.134  compiler warnings for discarding "const" from pointer
  1991  7.2.135  memory leak when redefining user command with complete arg
  1326  7.2.136  (after 7.2.132) ":cd" still possible in SwapExists autocmd
 11328  7.2.137  wrong left shift of blockwise selection in tab when 've' set
  5428  7.2.138  extra part of 7.2.137
  2229  7.2.139  crash when 'virtualedit' is "all"
  1974  7.2.140  diff highlighting missing if Visual area starts at cursor pos
  6622  7.2.141  fixing bold spill redraws too many characters
  1753  7.2.142  Motif and Athena balloons don't use tooltip colors
  6830  7.2.143  no command line completion for ":cscope" command
  2304  7.2.144  colorscheme is reloaded when 't_Co' is set to the same value
  3379  7.2.145  white space in ":cscope find" is not ignored
  3394  7.2.146  v:warningmsg isn't used for all warnings
  1548  7.2.147  cursor in wrong position after Tab for small version
  4275  7.2.148  highlighting a character after the line doesn't always work
 15646  7.2.149  read uninit memory when using return value that wasn't set
 35686  7.2.150  (extra) VisVim doesn't support tabs
  1533  7.2.151  ":hist a" doesn't work like ":hist all" as the docs suggest
  2963  7.2.152  "silent echo x" inside ":redir" leaves cursor halfway the line
  2908  7.2.153  memory leak for ":recover empty_dir/"
  2390  7.2.154  (after 7.2.132) can still do ":cd" in SwapExists autocmd
  1249  7.2.155  memory leak in ":function /pat"
  5543  7.2.156  no completion for :scscope and :lcscope commands
  4299  7.2.157  illegal memory access when searching in path
  2177  7.2.158  warnings from VisualC compiler
  2478  7.2.159  when $x_includes ends up being "NONE" configure fails
  1353  7.2.160  search pattern not freed on exit when 'rightleft' set
  5400  7.2.161  folds messed up in other tab page
  2363  7.2.162  the quickfix window may get the wrong filetype
  1754  7.2.163  the command line window may get folding
  4089  7.2.164  when 'showbreak' is set wrong Visual block size reported
  1794  7.2.165  FuncUndefined autocmd event argument is expanded like filename
 10538  7.2.166  no completion for ":sign" command
 54715  7.2.167  splint doesn't work well for checking the code (part 1)
  2936  7.2.168  if no ctags program found, "make tags" executes first C file
 35841  7.2.169  fix more splint warnings, define colnr_T to be int
  4481  7.2.170  using b_dev while it was not set
  2261  7.2.171  (after 7.2.169) compiler warnings
  1883  7.2.172  (extra) compiler warning
 17875  7.2.173  use gcc instead of lint to check for unused function arguments
 42277  7.2.174  too many warnings from gcc -Wextra
  1455  7.2.175  compiler warning in OpenBSD
  5956  7.2.176  exceptions for splint are not useful
 57904  7.2.177  more warnings from gcc -Wextra
  3898  7.2.178  using negative value for device number might not always work
  2944  7.2.179  using negative value for device number might not always work
198701  7.2.180  some more compiler warnings when using gcc -Wextra
 49635  7.2.181  some more compiler warnings when using gcc -Wextra
  2128  7.2.182  compilation fails for Motif, gvim with GTK crashes on startup
 52709  7.2.183  configure problem for sys/sysctl.h on OpenBSD
 84846  7.2.184  some more compiler warnings when using gcc -Wextra
  8242  7.2.185  some more compiler warnings when using gcc -Wextra
  7260  7.2.186  some more compiler warnings when using gcc -Wextra
  3334  7.2.187  (after 7.2.186) doesn't compile with older tcl versions
  8531  7.2.188  crash with specific use of function calls
  2889  7.2.189  possible hang for deleting auto-indent
  4827  7.2.190  the register executed by @@ isn't stored in viminfo
106448  7.2.191  Mzscheme interface doesn't work on Ubuntu
  4206  7.2.192  (after 7.2.188) still a crash in the garbage collector
  1545  7.2.193  warning for uninitialized values in struct
  1345  7.2.194  (extra) MSVC: rem commands are echoed
  2229  7.2.195  leaking memory for the command Vim was started with
  3466  7.2.196  remove support for splint, it doesn't work well
  1530  7.2.197  warning for uninitialized values of typebuf
  2006  7.2.198  buffer used for termcap entry may be too small
  1894  7.2.199  strange character in comment
 10318  7.2.200  reading past string end when using menu bar or resizing window
 14460  7.2.201  cannot copy/paste HTML to/from Firefox via the clipboard
  1846  7.2.202  BufWipeout autocmd that edits another buffer causes problems
 40481  7.2.203  using current window to work on hidden buffer has side effects
  4407  7.2.204  (extra) Win32: Can't build with Visual Studio 2010 beta 1
  2852  7.2.205  (extra) Win32: No support for High DPI awarenes
  1485  7.2.206  Win32: Can't build netbeans interface with Visual Studio 2010
  2237  7.2.207  using freed memory when ":redrawstatus" works recursively
  2569  7.2.208  "set novice" gives an error message, it should be ignored
  2532  7.2.209  for xxd setmode() is undefined on Cygwin
  1896  7.2.210  warning for file changed outside of vim even after :checktime
  1639  7.2.211  memory leak when expanding a series of file names
  1727  7.2.212  (extra) warnings for redefining SIG macros
  1521  7.2.213  warning for using vsprintf()
  1983  7.2.214  crash with complete function for user command
  8298  7.2.215  ml_get error when using ":vimgrep"
  4822  7.2.216  two error messages have the same number E812
  2020  7.2.217  running tests with valgrind doesn't work as advertised
  1448  7.2.218  cannot build GTK with hangul_input feature
  2052  7.2.219  (extra) Photon GUI is outdated
  2958  7.2.220  (after 7.2.215) BufEnter "cd" autocommand causes problems
  7103  7.2.221  X cut_buffer0 text may be used in the wrong encoding
  1816  7.2.222  ":mksession" doesn't work properly with 'acd' set
  5132  7.2.223  a script run with ":silent" cannot give any messages
  2542  7.2.224  crash when using 'completefunc'
  2874  7.2.225  when using ":normal" a saved character may be executed
  7470  7.2.226  ml_get error after deleting the last line
  1574  7.2.227  when using ":cd" in a script there is no way to track this
 14946  7.2.228  cscope is limited to 8 connections
  1595  7.2.229  warning for shadowed variable
  2442  7.2.230  a few old lint-style ARGUSED comments
  1473  7.2.231  warning for unreacheable code in Perl interface
  2704  7.2.232  cannot debug problems with being in a wrong directory
  2901  7.2.233  extra part of 7.2.232
  3831  7.2.234  it is not possible to ignore file names without a suffix
  2696  7.2.235  Using CTRL-O z= in Insert mode has a delay before redrawing
  2809  7.2.236  Mac: Compiling with Ruby doesn't always work
  1965  7.2.237  crash on exit when window icon not set
  3941  7.2.238  leaking memory when setting term to "builtin_dumb"
  4151  7.2.239  using :diffpatch twice may cause a crash
  2078  7.2.240  crash when using GUI find/replace dialog repeatedly
  5174  7.2.241  problems with using ":bufdo" and "doautoall" or ":vimgrep"
  2505  7.2.242  setting 'lazyredraw' causes the cursor column to be recomputed
  1918  7.2.243  memory leak when using :vimgrep and resizing
  4757  7.2.244  insufficient info for a conversion error from utf-8 to latin1
  5093  7.2.245  wrong conversion when writing Unicode encoded files
  1848  7.2.246  Cscope home page link is wrong
  2561  7.2.247  Mzscheme interface minor problem
  4408  7.2.248  (extra) Win32: Mzscheme interface building minor problems
  1555  7.2.249  script that checks .po files can't handle '%' in plural forms
  1693  7.2.250  (extra) possible buffer overflow in GvimExt
  2802  7.2.251  compiler adds invalid memory bounds check
  1495  7.2.252  when 'enc' is multi-byte 'iskeyword' can't contain chars > 128
  4223  7.2.253  netbeans interface: getLength always uses current buffer
  1654  7.2.254  compiler warning for assigning size_t to int
  1870  7.2.255  (after 7.2.242) cursor column may be wrong after :set
  1783  7.2.256  GTK font dialog doesn't have a default when 'guifont' not set
  2092  7.2.257  GTK 2.17: lots of assertion error messages
  1989  7.2.258  v:beval_col and b:beval_text are wrong in UTF-8 text
  5393  7.2.259  exists() doesn't work properly for an empty aucmd group
  5431  7.2.260  (extra part of 7.2.259)
  2515  7.2.261  E38 may appear when deleting folded lines
  5652  7.2.262  string passed to user cmd custom completion can be too long
  2634  7.2.263  GTK2: Vim window in wrong position using the -geom argument
  5161  7.2.264  GTK2: When Vim window maximized, set 'columns' doesn't work
  1892  7.2.265  with ":silent broken" inside try/catch silency may persist
  6560  7.2.266  in an expression abbreviation the typed character is unknown
  1461  7.2.267  crash for narrow window and double-width character
  2274  7.2.268  crash when using Python to set cursor beyond end of line
  7128  7.2.269  add --startuptime so that slow startup can be analysed
  2281  7.2.270  ":@c" does not execute everything if the c register has a CR
  2649  7.2.271  Motif GUI: Using freed memory when making a choice
  2582  7.2.272  "_.svz" is not recognized as a swap file
  3404  7.2.273  crash when redirirecting to unknown array
  3749  7.2.274  syntax folding doesn't work properly when adding a comment
  2717  7.2.275  warning for unused argument and comparing signed and unsigned
  1875  7.2.276  crash when setting 'isprint' to a small bullet
  1937  7.2.277  CTRL-Y in a diff'ed window may move cursor outside of window
  2312  7.2.278  using magic number in the folding code
  3413  7.2.279  invalid memory read with visual mode "r"
  6656  7.2.280  a redraw in a custom statusline with %! may cause a crash
  2241  7.2.281  'cursorcolumn' highlighting is wrong in diff mode
  1584  7.2.282  a fold can't be closed
  2030  7.2.283  GTK: changing font doesn't keep the window maximized
  1572  7.2.284  two windows on a buffer + folding: display error after change
  1931  7.2.285  (after 7.2.169) CTRL-U in Insert mode also deletes indent
  7058  7.2.286  (after 7.2.269) --startuptime argument is not consistent
  1733  7.2.287  warning from gcc 3.4 about uninitialized variable
  1680  7.2.288  Python 2.6 pyconfig.h redefines macros
  3979  7.2.289  checking wrong struct member
  5344  7.2.290  not freeing memory from ":lmap", ":xmap" and ":menutranslate"
  1498  7.2.291  reading uninitialised memory in arabic mode
  1518  7.2.292  block right-shift wrong with multibyte encoding and 'list' set
  1954  7.2.293  when setting 'comments' option it may be used in a wrong way
  8992  7.2.294  when using TEMPDIRS dir name could get too long
  4053  7.2.295  in map() on a List the index is not known, set v:key to index
  1809  7.2.296  (after 7.2.286) help message about startuptime is wrong
  1846  7.2.297  reading freed memory when writing ":reg" output to a register
  1608  7.2.298  ":vimgrep" crashes with an autocommand that sets w: variable
  1733  7.2.299  crash when comment middle is longer than start
  5886  7.2.300  file descriptors not closed when executing external command
 14601  7.2.301  formatting is wrong when 'tw' is set to a small value
  4941  7.2.302  (extra, after 7.2.301) extra part of the 7.2.301 tests
  2073  7.2.303  (after 7.2.294) can't build on MS-Windows
  1831  7.2.304  compiler warning for bad pointer cast
  2727  7.2.305  recursively redrawing causes a memory leak
  1541  7.2.306  shellescape("10%%", 1) only escapes first %
  4869  7.2.307  crash with a very long syntax match statement
  5504  7.2.308  submatch() in "\=" of ":s" command returns empty string
  1533  7.2.309  (after 7.2.308) warning for missing function prototype
  1874  7.2.310  ftdetect plugin using ":setf" doesn't work with # comment
  1408  7.2.311  can't compile with FreeMiNT
  9769  7.2.312  iconv() returns invalid char sequence when conversion fails
  3744  7.2.313  command line completion doesn't work after "%:h" and similar
  1620  7.2.314  small build broken after 7.2.313
  4605  7.2.315  Python libs can't be found on 64 bit system
  3370  7.2.316  may get multiple _FORTIFY_SOURCE arguments
  5249  7.2.317  memory leak when adding a highlight group resulting in E669
  2637  7.2.318  wrong locale value breaks floating point numbers for gvim
  1846  7.2.319  Motif: accessing freed memory when cancelling font dialog
  6269  7.2.320  unused function in Mzscheme interface
  1899  7.2.321  histadd() and "*" fail to add entry to empty history
  1517  7.2.322  wrong indenting in virtual replace for CTRL-Y and a short line
  2424  7.2.323  (extra) balloon evaluation crashes on Win64
  1901  7.2.324  a negative column argument in setpos() may cause a crash
  1616  7.2.325  stray "w" in the startup vimrc file makes edited file empty
  1790  7.2.326  Win32: $HOME doesn't work when %HOMEPATH% is not defined
  7899  7.2.327  unused functions in Workshop
  1453  7.2.328  has("win64") does not return 1 on 64 bit MS-Windows version
  1390  7.2.329  cursor pos wrong after "g_" in Visual mode and excl. selection
 45468  7.2.330  tables for Unicode case operators are outdated
  1385  7.2.331  can't interrupt "echo list" for a very long list
  3492  7.2.332  crash if spell correcting triggers autocmd to reload a buffer
 10075  7.2.333  warnings from static code analysis
  9095  7.2.334  postponing keys in Netbeans interface does not work properly
  2802  7.2.335  the CTRL-] command escapes too many characters
 26204  7.2.336  MzScheme interface can't evaluate an expression
  3828  7.2.337  ":compiler" doesn't function properly in a function
  3535  7.2.338  (after 7.2.300) part of FD_CLOEXEC change is missing
  1977  7.2.339  (after 7.2.269) part of --startuptime patch is missing
  1587  7.2.340  gcc warning for condition that can never be true
  2072  7.2.341  popup menu wraps to next line if wide character doesn't fit
  2507  7.2.342  popup menu wrong in 'rightleft' mode with multi-byte chars
  1370  7.2.343  (after 7.2.338) can't compile on Win32
  1728  7.2.344  (after 7.2.338) can't compile on some systems
  1324  7.2.345  tab line is not updated when the value of 'bt' is changed
  2895  7.2.346  repeating a command with @: causes mapping to be applied twice
  3784  7.2.347  crash when executing <expr> mapping redefines that mapping
  7230  7.2.348  (after 7.2.330) Unicode double width table is outdated
  1714  7.2.349  CTRL-W gf puts the new tab in the wrong place
  2766  7.2.350  Win32: When changing font window may jump to another screen
  2195  7.2.351  (after 7.2.347) compilation fails with some compilers
  1825  7.2.352  Win64: Vim doesn't work when cross-compiled with MingW libs
  4764  7.2.353  no command line completion for ":profile"
  2270  7.2.354  Japanese single-width double-byte chars not handled correctly
  2663  7.2.355  popup menu in wrong position when 'number' is set
  2166  7.2.356  not all folds are closed when 'foldmethod' is changed
  1565  7.2.357  CR displayed wrong when changing 'fileformat' from/to "mac"
  2384  7.2.358  compiler warnings on VMS
  1805  7.2.359  crash when using the Netbeans join command
  2839  7.2.360  Ruby on MS-Windows: can't use sockets
 23442  7.2.361  Ruby 1.9 is not supported
  2964  7.2.362  (extra, after 7.2.352) Win64 cross-compile problems
  2521  7.2.363  Perl 5.10 dynamic loading doesn't work
  2958  7.2.364  (extra) can't build gvimext.dll on Win 7 x64 using MinGW
  2390  7.2.365  (extra) MS-Windows with MingW: "File->Save As" does not work
  3802  7.2.366  CTRL-B doesn't go back to the first line of the buffer
  3236  7.2.367  "xxd -r -p" doesn't work as documented
  1623  7.2.368  (after 7.2.361) append line with Ruby interface doesn't work
  1872  7.2.369  error message for :profile is not easy to understand
  4352  7.2.370  (after 7.2.356) a redraw may cause folds to be closed
 10029  7.2.371  build problems on Tandem NonStop
  9674  7.2.372  (extra) cross-compiling GvimExt and xxd doesn't work.
  2901  7.2.373  new messages from gcc 4.5 are not in 'errorformat'
  4434  7.2.374  Ruby eval() doesn't understand Vim types
  1794  7.2.375  ml_get errors when using ":bprevious" in a BufEnter autocmd
  1577  7.2.376  ml_get error when using SiSU syntax
  1983  7.2.377  (extra, after 7.2.372) small mistakes in Ming build file
  2832  7.2.378  C function declaration indented too much
  1758  7.2.379  'eventignore' is set to an invalid value inside ":doau"
  3699  7.2.380  (after 7.2.363) Perl builds with 5.10.1 but not with 5.10.0
  6835  7.2.381  no completion for :behave
  1766  7.2.382  close cmdline window when 'bufhide' is "wipe" uses freed mem
  3021  7.2.383  Vim doesn't build cleanly with MSVC 2010
  1849  7.2.384  (extra) Vim doesn't build properly with MSVC 2010
  2147  7.2.385  can't drag status line when in the command line window
  2051  7.2.386  KDE 3.1 focus hack causes problems for other window managers
  8233  7.2.387  Ruby with MingW still doesn't build all versions
  2486  7.2.388  (extra part of 7.2.387) Ruby with MingW
  4805  7.2.389  synIDattr() cannot return the font
  2302  7.2.390  in some situations the popup menu can be displayed wrong
  3426  7.2.391  internal alloc(0) error when doing "CTRL-V $ c"
  4898  7.2.392  netbeans hangs reading from a socket at the maximum block size
  9605  7.2.393  Mac: Can't build with different Xcode developer tools dir
  4298  7.2.394  .lzma and .xz files are not supported
  1554  7.2.395  in help CTRL=] on g?g? escapes the ?, causing it to fail
  1554  7.2.396  get E38 errors
  1722  7.2.397  redundant check for w_lines_valid
  4127  7.2.398  when moving windows the cursor ends up in the wrong line
  1784  7.2.399  (extra, after 7.2.388) cannot compile on MingW
 12865  7.2.400  (after 7.2.387) Ruby problems with init and empty string
  1982  7.2.401  wildmode list doesn't highlight directory names with a space
  2649  7.2.402  error 705 when re-using funcref variable
  1548  7.2.403  (after 7.2.400) compiler warning for pointer type
  1880  7.2.404  pointers for composing characters are not properly initialized
  1636  7.2.405  with small features match is not highlighted for ":s/p/r/c"
  4701  7.2.406  (after 7.2.119) uninit memory read
  1916  7.2.407  when using :s with an expression backslashes are dropped
  2152  7.2.408  ":g/the/s/a/b/" can set '[ and '] marks to an unchanged line
  1814  7.2.409  summary of number of substitutes is incorrect for ":folddo"
  2526  7.2.410  highlighting directories for completion doesn't work properly
  1462  7.2.411  when parsing 'cino' a comma isn't skipped properly

--- vim72.orig/Filelist
+++ vim72/Filelist
@@ -283,10 +283,11 @@ SRC_DOS =	\
 		src/proto/os_msdos.pro \
 		src/proto/os_win16.pro \
 		src/proto/os_win32.pro \
 		src/proto/os_mswin.pro \
 		src/testdir/Make_dos.mak \
+		src/testdir/Make_ming.mak \
 		src/testdir/dos.vim \
 		src/uninstal.c \
 		src/vim.def \
 		src/vim.rc \
 		src/vimio.h \
@@ -680,13 +681,11 @@ LANG_GEN = \
 		runtime/spell/README.txt \
 		runtime/spell/??/*.diff \
 		runtime/spell/??/main.aap \
 		runtime/spell/yi/README.txt \
 		runtime/spell/main.aap \
-		runtime/spell/cleanadd.vim \
 		runtime/spell/*.vim \
-		runtime/spell/fixdup \
 
 # generic language files, binary
 LANG_GEN_BIN = \
 		runtime/spell/README_en.txt \
 		runtime/spell/en.ascii.spl \
--- vim72.orig/runtime/doc/autocmd.txt
+++ vim72/runtime/doc/autocmd.txt
@@ -333,10 +333,12 @@ BufDelete			Before deleting a buffer fro
 				Also used just before a buffer in the buffer
 				list is renamed.
 				NOTE: When this autocommand is executed, the
 				current buffer "%" may be different from the
 				buffer being deleted "<afile>" and "<abuf>".
+				Don't change to another buffer, it will cause
+				problems.
 							*BufEnter*
 BufEnter			After entering a buffer.  Useful for setting
 				options for a file type.  Also executed when
 				starting to edit a buffer, after the
 				BufReadPost autocommands.
@@ -395,10 +397,12 @@ BufUnload			Before unloading a buffer.
 				BufDelete.  Also used for all buffers that are
 				loaded when Vim is going to exit.
 				NOTE: When this autocommand is executed, the
 				current buffer "%" may be different from the
 				buffer being unloaded "<afile>".
+				Don't change to another buffer, it will cause
+				problems.
 							*BufWinEnter*
 BufWinEnter			After a buffer is displayed in a window.  This
 				can be when the buffer is loaded (after
 				processing the modelines) or when a hidden
 				buffer is displayed in a window (and is no
@@ -426,10 +430,12 @@ BufWipeout			Before completely deleting
 				is renamed (also when it's not in the buffer
 				list).
 				NOTE: When this autocommand is executed, the
 				current buffer "%" may be different from the
 				buffer being deleted "<afile>".
+				Don't change to another buffer, it will cause
+				problems.
 						*BufWrite* *BufWritePre*
 BufWrite or BufWritePre		Before writing the whole buffer to a file.
 							*BufWriteCmd*
 BufWriteCmd			Before writing the whole buffer to a file.
 				Should do the writing of the file and reset
@@ -746,12 +752,14 @@ SwapExists			Detected an existing swap f
 					'd'	delete the swap file
 					'q'	quit, don't edit the file
 					'a'	abort, like hitting CTRL-C
 				When set to an empty string the user will be
 				asked, as if there was no SwapExists autocmd.
-				Note: Do not try to change the buffer, the
-				results are unpredictable.
+							*E812*
+				It is not allowed to change to another buffer,
+				change a buffer name or change directory
+				here.
 							*Syntax*
 Syntax				When the 'syntax' option has been set.  The
 				pattern is matched against the syntax name.
 				<afile> can be used for the name of the file
 				where this option was set, and <amatch> for
--- vim72.orig/runtime/doc/cmdline.txt
+++ vim72/runtime/doc/cmdline.txt
@@ -1,6 +1,6 @@
-*cmdline.txt*   For Vim version 7.2.  Last change: 2008 Jul 29
+*cmdline.txt*   For Vim version 7.2.  Last change: 2008 Sep 18
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 
 
@@ -155,10 +155,15 @@ CTRL-R {0-9a-z"%#:-=.}					*c_CTRL-R* *c
 			'='	the expression register: you are prompted to
 				enter an expression (see |expression|)
 				(doesn't work at the expression prompt; some
 				things such as changing the buffer or current
 				window are not allowed to avoid side effects)
+				When the result is a |List| the items are used
+				as lines.  They can have line breaks inside
+				too.
+				When the result is a Float it's automatically
+				converted to a String.
 		See |registers| about registers.  {not in Vi}
 		Implementation detail: When using the |expression| register
 		and invoking setcmdpos(), this sets the position before
 		inserting the resulting string.  Use CTRL-R CTRL-R to set the
 		position afterwards.
@@ -434,17 +439,24 @@ matching files with the next.
 For file name completion you can use the 'suffixes' option to set a priority
 between files with almost the same name.  If there are multiple matches,
 those files with an extension that is in the 'suffixes' option are ignored.
 The default is ".bak,~,.o,.h,.info,.swp,.obj", which means that files ending
 in ".bak", "~", ".o", ".h", ".info", ".swp" and ".obj" are sometimes ignored.
-It is impossible to ignore suffixes with two dots.  Examples:
+
+An empty entry, two consecutive commas, match a file name that does not
+contain a ".", thus has no suffix.  This is useful to ignore "prog" and prefer
+"prog.c".
+
+Examples:
 
   pattern:	files:				match:	~
    test*	test.c test.h test.o		test.c
    test*	test.h test.o			test.h and test.o
    test*	test.i test.h test.c		test.i and test.c
 
+It is impossible to ignore suffixes with two dots.
+
 If there is more than one matching file (after ignoring the ones matching
 the 'suffixes' option) the first file name is inserted.  You can see that
 there is only one match when you type 'wildchar' twice and the completed
 match stays the same.  You can get to the other matches by entering
 'wildchar', CTRL-N or CTRL-P.  All files are included, also the ones with
@@ -728,23 +740,33 @@ to use |fnameescape()|.
 
 
 In Ex commands, at places where a file name can be used, the following
 characters have a special meaning.  These can also be used in the expression
 function expand() |expand()|.
-	%	is replaced with the current file name			*:_%*
-	#	is replaced with the alternate file name		*:_#*
+	%	Is replaced with the current file name.		  *:_%* *c_%*
+	#	Is replaced with the alternate file name.	  *:_#* *c_#*
 	#n	(where n is a number) is replaced with the file name of
-		buffer n.  "#0" is the same as "#"
-	##	is replaced with all names in the argument list		*:_##*
+		buffer n.  "#0" is the same as "#".
+	##	Is replaced with all names in the argument list	  *:_##* *c_##*
 		concatenated, separated by spaces.  Each space in a name
 		is preceded with a backslash.
-Note that these give the file name as it was typed.  If an absolute path is
-needed (when using the file name from a different directory), you need to add
-":p".  See |filename-modifiers|.
+	#<n	(where n is a number > 0) is replaced with old	  *:_#<* *c_#<*
+		file name n.  See |:oldfiles| or |v:oldfiles| to get the
+		number.							*E809*
+		{only when compiled with the +eval and +viminfo features}
+
+Note that these, except "#<n", give the file name as it was typed.  If an
+absolute path is needed (when using the file name from a different directory),
+you need to add ":p".  See |filename-modifiers|.
+
+The "#<n" item returns an absolute path, but it will start with "~/" for files
+below your home directory.
+
 Note that backslashes are inserted before spaces, so that the command will
 correctly interpret the file name.  But this doesn't happen for shell
-commands.  For those you probably have to use quotes: >
+commands.  For those you probably have to use quotes (this fails for files
+that contain a quote and wildcards): >
 	:!ls "%"
 	:r !spell "%"
 
 To avoid the special meaning of '%' and '#' insert a backslash before it.
 Detail: The special meaning is always escaped when there is a backslash before
--- vim72.orig/runtime/doc/eval.txt
+++ vim72/runtime/doc/eval.txt
@@ -1,6 +1,6 @@
-*eval.txt*	For Vim version 7.2.  Last change: 2008 Aug 09
+*eval.txt*	For Vim version 7.2.  Last change: 2008 Nov 27
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
 
 
@@ -1482,10 +1482,21 @@ v:mouse_lnum	Line number for a mouse cli
 					*v:mouse_col* *mouse_col-variable*
 v:mouse_col	Column number for a mouse click obtained with |getchar()|.
 		This is the screen column number, like with |virtcol()|.  The
 		value is zero when there was no mouse button click.
 
+					*v:oldfiles* *oldfiles-variable*
+v:oldfiles	List of file names that is loaded from the |viminfo| file on
+		startup.  These are the files that Vim remembers marks for.
+		The length of the List is limited by the ' argument of the
+		'viminfo' option (default is 100).
+		Also see |:oldfiles| and |c_#<|.
+		The List can be modified, but this has no effect on what is
+		stored in the |viminfo| file later.  If you use values other
+		than String this will cause trouble.
+		{only when compiled with the +viminfo feature}
+
 					*v:operator* *operator-variable*
 v:operator	The last operator given in Normal mode.  This is a single
 		character except for commands starting with <g> or <z>,
 		in which case it is two characters.  Best used alongside
 		|v:prevcount| and |v:register|.  Useful if you want to cancel
@@ -1693,11 +1704,11 @@ eval( {string})			any	evaluate {string}
 eventhandler( )			Number	TRUE if inside an event handler
 executable( {expr})		Number	1 if executable {expr} exists
 exists( {expr})			Number	TRUE if {expr} exists
 extend({expr1}, {expr2} [, {expr3}])
 				List/Dict insert items of {expr2} into {expr1}
-expand( {expr})			String	expand special keywords in {expr}
+expand( {expr} [, {flag}])	String	expand special keywords in {expr}
 feedkeys( {string} [, {mode}])	Number	add key sequence to typeahead buffer
 filereadable( {file})		Number	TRUE if {file} is a readable file
 filewritable( {file})		Number	TRUE if {file} is a writable file
 filter( {expr}, {string})	List/Dict  remove items from {expr} where
 					{string} is 0
@@ -1745,12 +1756,13 @@ getregtype( [{regname}])	String	type of
 gettabwinvar( {tabnr}, {winnr}, {name})
 				any	{name} in {winnr} in tab page {tabnr}
 getwinposx()			Number	X coord in pixels of GUI Vim window
 getwinposy()			Number	Y coord in pixels of GUI Vim window
 getwinvar( {nr}, {varname})	any	variable {varname} in window {nr}
-glob( {expr})			String	expand file wildcards in {expr}
-globpath( {path}, {expr})	String	do glob({expr}) for all dirs in {path}
+glob( {expr} [, {flag}])	String	expand file wildcards in {expr}
+globpath( {path}, {expr} [, {flag}])
+				String	do glob({expr}) for all dirs in {path}
 has( {feature})			Number	TRUE if feature {feature} supported
 has_key( {dict}, {key})		Number	TRUE if {dict} has entry {key}
 haslocaldir()			Number	TRUE if current window executed |:lcd|
 hasmapto( {what} [, {mode} [, {abbr}]])
 				Number	TRUE if mapping to {what} exists
@@ -1801,15 +1813,16 @@ matchend( {expr}, {pat}[, {start}[, {cou
 				Number	position where {pat} ends in {expr}
 matchlist( {expr}, {pat}[, {start}[, {count}]])
 				List	match and submatches of {pat} in {expr}
 matchstr( {expr}, {pat}[, {start}[, {count}]])
 				String	{count}'th match of {pat} in {expr}
-max({list})			Number	maximum value of items in {list}
-min({list})			Number	minimum value of items in {list}
-mkdir({name} [, {path} [, {prot}]])
+max( {list})			Number	maximum value of items in {list}
+min( {list})			Number	minimum value of items in {list}
+mkdir( {name} [, {path} [, {prot}]])
 				Number	create directory {name}
 mode( [expr])			String	current editing mode
+mzeval( {expr})			any	evaluate |MzScheme| expression
 nextnonblank( {lnum})		Number	line nr of non-blank line >= {lnum}
 nr2char( {expr})		String	single char with ASCII value {expr}
 pathshorten( {expr})		String	shorten directory names in a path
 pow( {x}, {y})			Float	{x} to the power of {y}
 prevnonblank( {lnum})		Number	line nr of non-blank line <= {lnum}
@@ -2400,10 +2413,11 @@ cursor({list})
 		line.
 		If {col} is zero, the cursor will stay in the current column.
 		When 'virtualedit' is used {off} specifies the offset in
 		screen columns from the start of the character.  E.g., a
 		position within a <Tab> or after the last character.
+		Returns 0 when the position could be set, -1 otherwise.
 
 
 deepcopy({expr}[, {noref}])				*deepcopy()* *E698*
 		Make a copy of {expr}.	For Numbers and Strings this isn't
 		different from using {expr} directly.
@@ -3273,18 +3287,20 @@ getwinvar({winnr}, {varname})				*getwin
 		Like |gettabwinvar()| for the current tabpage.
 		Examples: >
 			:let list_is_on = getwinvar(2, '&list')
 			:echo "myvar = " . getwinvar(1, 'myvar')
 <
-							*glob()*
-glob({expr})	Expand the file wildcards in {expr}.  See |wildcards| for the
+glob({expr} [, {flag}])					*glob()*
+		Expand the file wildcards in {expr}.  See |wildcards| for the
 		use of special characters.
 		The result is a String.
 		When there are several matches, they are separated by <NL>
 		characters.
-		The 'wildignore' option applies: Names matching one of the
-		patterns in 'wildignore' will be skipped.
+		Unless the optional {flag} argument is given and is non-zero,
+		the 'suffixes' and 'wildignore' options apply: Names matching
+		one of the patterns in 'wildignore' will be skipped and
+		'suffixes' affect the ordering of matches.
 		If the expansion fails, the result is an empty string.
 		A name for a non-existing file is not included.
 
 		For most systems backticks can be used to get files names from
 		any external command.  Example: >
@@ -3294,24 +3310,26 @@ glob({expr})	Expand the file wildcards i
 		item per line.	Spaces inside an item are allowed.
 
 		See |expand()| for expanding special Vim variables.  See
 		|system()| for getting the raw output of an external command.
 
-globpath({path}, {expr})				*globpath()*
+globpath({path}, {expr} [, {flag}])			*globpath()*
 		Perform glob() on all directories in {path} and concatenate
 		the results.  Example: >
 			:echo globpath(&rtp, "syntax/c.vim")
 <		{path} is a comma-separated list of directory names.  Each
 		directory name is prepended to {expr} and expanded like with
-		glob().  A path separator is inserted when needed.
+		|glob()|.  A path separator is inserted when needed.
 		To add a comma inside a directory name escape it with a
 		backslash.  Note that on MS-Windows a directory may have a
 		trailing backslash, remove it if you put a comma after it.
 		If the expansion fails for one of the directories, there is no
 		error message.
-		The 'wildignore' option applies: Names matching one of the
-		patterns in 'wildignore' will be skipped.
+		Unless the optional {flag} argument is given and is non-zero,
+		the 'suffixes' and 'wildignore' options apply: Names matching
+		one of the patterns in 'wildignore' will be skipped and
+		'suffixes' affect the ordering of matches.
 
 		The "**" item can be used to search in a directory tree.
 		For example, to find all "README.txt" files in the directories
 		in 'runtimepath' and below: >
 			:echo globpath(&rtp, "**/README.txt")
@@ -3783,11 +3801,12 @@ log10({expr})						*log10()*
 map({expr}, {string})					*map()*
 		{expr} must be a |List| or a |Dictionary|.
 		Replace each item in {expr} with the result of evaluating
 		{string}.
 		Inside {string} |v:val| has the value of the current item.
-		For a |Dictionary| |v:key| has the key of the current item.
+		For a |Dictionary| |v:key| has the key of the current item
+		and for a |List| |v:key| has the index of the current item.
 		Example: >
 			:call map(mylist, '"> " . v:val . " <"')
 <		This puts "> " before and " <" after each item in "mylist".
 
 		Note that {string} is the result of an expression and is then
@@ -4070,10 +4089,27 @@ mode([expr])	Return a string that indica
 		This is useful in the 'statusline' option or when used
 		with |remote_expr()| In most other places it always returns
 		"c" or "n".
 		Also see |visualmode()|.
 
+mzeval({expr})							*mzeval()*
+		Evaluate MzScheme expression {expr} and return its result
+		convert to Vim data structures.
+		Numbers and strings are returned as they are.
+		Pairs (including lists and improper lists) and vectors are
+		returned as Vim |Lists|.
+		Hash tables are represented as Vim |Dictionary| type with keys
+		converted to strings.
+		All other types are converted to string with display function.
+		Examples: >
+		    :mz (define l (list 1 2 3))
+		    :mz (define h (make-hash)) (hash-set! h "list" l)
+		    :echo mzeval("l")
+		    :echo mzeval("h")
+<
+		{only available when compiled with the |+mzscheme| feature}
+
 nextnonblank({lnum})					*nextnonblank()*
 		Return the line number of the first line at or below {lnum}
 		that is not blank.  Example: >
 			if getline(nextnonblank(1)) =~ "Java"
 <		When {lnum} is invalid or there is no non-blank line at or
@@ -4498,10 +4534,11 @@ remove({dict}, {key})
 rename({from}, {to})					*rename()*
 		Rename the file by the name {from} to the name {to}.  This
 		should also work to move files across file systems.  The
 		result is a Number, which is 0 if the file was renamed
 		successfully, and non-zero when the renaming failed.
+		NOTE: If {to} exists it is overwritten without warning.
 		This function is not available in the |sandbox|.
 
 repeat({expr}, {count})					*repeat()*
 		Repeat {expr} {count} times and return the concatenated
 		result.  Example: >
@@ -5330,18 +5367,23 @@ synIDattr({synID}, {what} [, {mode}])
 		{what}		result
 		"name"		the name of the syntax item
 		"fg"		foreground color (GUI: color name used to set
 				the color, cterm: color number as a string,
 				term: empty string)
-		"bg"		background color (like "fg")
+		"bg"		background color (as with "fg")
+		"font"		font name (only available in the GUI)
+				|highlight-font|
+		"sp"		special color (as with "fg") |highlight-guisp|
 		"fg#"		like "fg", but for the GUI and the GUI is
 				running the name in "#RRGGBB" form
 		"bg#"		like "fg#" for "bg"
+		"sp#"		like "fg#" for "sp"
 		"bold"		"1" if bold
 		"italic"	"1" if italic
 		"reverse"	"1" if reverse
 		"inverse"	"1" if inverse (= reverse)
+		"standout"	"1" if standout
 		"underline"	"1" if underlined
 		"undercurl"	"1" if undercurled
 
 		Example (echoes the color of the syntax item under the
 		cursor): >
@@ -5821,11 +5863,12 @@ mouse_dec		Compiled with support for Dec
 mouse_gpm		Compiled with support for gpm (Linux console mouse)
 mouse_netterm		Compiled with support for netterm mouse.
 mouse_pterm		Compiled with support for qnx pterm mouse.
 mouse_sysmouse		Compiled with support for sysmouse (*BSD console mouse)
 mouse_xterm		Compiled with support for xterm mouse.
-multi_byte		Compiled with support for editing Korean et al.
+multi_byte		Compiled with support for 'encoding'
+multi_byte_encoding	'encoding' is set to a multi-byte encoding.
 multi_byte_ime		Compiled with support for IME input method.
 multi_lang		Compiled with support for multiple languages.
 mzscheme		Compiled with MzScheme interface |mzscheme|.
 netbeans_intg		Compiled with support for |netbeans|.
 netbeans_enabled	Compiled with support for |netbeans| and it's used.
@@ -5846,10 +5889,11 @@ ruby			Compiled with Ruby interface |rub
 scrollbind		Compiled with 'scrollbind' support.
 showcmd			Compiled with 'showcmd' support.
 signs			Compiled with |:sign| support.
 smartindent		Compiled with 'smartindent' support.
 sniff			Compiled with SNiFF interface support.
+startuptime		Compiled with |--startuptime| support.
 statusline		Compiled with support for 'statusline', 'rulerformat'
 			and special formats of 'titlestring' and 'iconstring'.
 sun_workshop		Compiled with support for Sun |workshop|.
 spell			Compiled with spell checking support |spell|.
 syntax			Compiled with syntax highlighting support |syntax|.
--- vim72.orig/runtime/doc/if_cscop.txt
+++ vim72/runtime/doc/if_cscop.txt
@@ -1,6 +1,6 @@
-*if_cscop.txt*  For Vim version 7.2.  Last change: 2005 Mar 29
+*if_cscop.txt*  For Vim version 7.2.  Last change: 2009 Mar 18
 
 
 		  VIM REFERENCE MANUAL    by Andy Kahn
 
 							*cscope* *Cscope*
@@ -129,15 +129,26 @@ The available subcommands are:
 		4 or t: Find this text string
 		6 or e: Find this egrep pattern
 		7 or f: Find this file
 		8 or i: Find files #including this file
 
+	For all types, except 4 and 6, leading white space for {name} is
+	removed.  For 4 and 6 there is exactly one space between {querytype}
+	and {name}.  Further white space is included in {name}.
+
 	EXAMPLES >
 	    :cscope find c vim_free
-	    :cscope find 3 vim_free
+	    :cscope find 3  vim_free
+<
+	    These two examples perform the same query: functions calling
+	    "vim_free". >
+
+	    :cscope find t initOnce
+	    :cscope find t  initOnce
 <
-	    These two examples perform the same query. >
+	    The first one searches for the text "initOnce", the second one for
+	    " initOnce". >
 
 	    :cscope find 0 DEFAULT_TERM
 <
 	    Executing this example on the source code for Vim 5.1 produces the
 	    following output:
@@ -342,17 +353,12 @@ cscope version for Win32 see:
 	http://iamphet.nm.ru/cscope/index.html
 
 The DJGPP-built version from http://cscope.sourceforge.net is known to not
 work with Vim.
 
-There are a couple of hard-coded limitations:
-
-    1. The maximum number of cscope connections allowed is 8.  Do you
-    really need more?
-
-    2. Doing a |:tjump| when |:cstag| searches the tag files is not
-    configurable (e.g., you can't do a tselect instead).
+Hard-coded limitation: doing a |:tjump| when |:cstag| searches the tag files
+is not configurable (e.g., you can't do a tselect instead).
 
 ==============================================================================
 6. Suggested usage					*cscope-suggestions*
 
 Put these entries in your .vimrc (adjust the pathname accordingly to your
@@ -473,11 +479,12 @@ The cscope interface/support for Vim was
 Andy Kahn <ackahn@netapp.com>.  The original structure (as well as a tiny
 bit of code) was adapted from the cscope interface in nvi.  Please report
 any problems, suggestions, patches, et al., you have for the usage of
 cscope within Vim to him.
 							*cscope-win32*
-For a cscope version for Win32 see: http://iamphet.nm.ru/cscope/index.html
+For a cscope version for Win32 see:
+	http://code.google.com/p/cscope-win32/
 
 Win32 support was added by Sergey Khorev <sergey.khorev@gmail.com>.  Contact
 him if you have Win32-specific issues.
 
  vim:tw=78:ts=8:ft=help:norl:
--- vim72.orig/runtime/doc/if_mzsch.txt
+++ vim72/runtime/doc/if_mzsch.txt
@@ -1,18 +1,19 @@
-*if_mzsch.txt*  For Vim version 7.2.  Last change: 2008 Jun 28
+*if_mzsch.txt*  For Vim version 7.2.  Last change: 2010 Jan 19
 
 
 		  VIM REFERENCE MANUAL    by Sergey Khorev
 
 
 The MzScheme Interface to Vim				*mzscheme* *MzScheme*
 
 1. Commands				|mzscheme-commands|
 2. Examples				|mzscheme-examples|
 3. Threads				|mzscheme-threads|
-4. The Vim access procedures		|mzscheme-vim|
-5. Dynamic loading			|mzscheme-dynamic|
+4. Vim access from MzScheme		|mzscheme-vim|
+5. mzeval() Vim function		|mzscheme-mzeval|
+6. Dynamic loading			|mzscheme-dynamic|
 
 {Vi does not have any of these commands}
 
 The MzScheme interface is available only if Vim was compiled with the
 |+mzscheme| feature.
@@ -40,24 +41,18 @@ Note: On FreeBSD you should use the "drs
 			feature wasn't compiled in.  To avoid errors, see
 			|script-here|.
 
 							*:mzfile* *:mzf*
 :[range]mzf[ile] {file}	Execute the MzScheme script in {file}.  {not in Vi}
-			All statements are executed in the namespace of the
-			buffer that was current during :mzfile start.
-			If you want to access other namespaces, use
-			'parameterize'.
 
 All of these commands do essentially the same thing - they execute a piece of
 MzScheme code, with the "current range" set to the given line
 range.
 
 In the case of :mzscheme, the code to execute is in the command-line.
 In the case of :mzfile, the code to execute is the contents of the given file.
 
-Each buffer has its own MzScheme namespace. Global namespace is bound to
-the "global-namespace" value from the 'vimext' module.
 MzScheme interface defines exception exn:vim, derived from exn.
 It is raised for various Vim errors.
 
 During compilation, the MzScheme interface will remember the current MzScheme
 collection path. If you want to specify additional paths use the
@@ -77,79 +72,68 @@ The exn:vim is available without explici
 
 To avoid clashes with MzScheme, consider using prefix when requiring module,
 e.g.: >
 	:mzscheme (require (prefix vim- vimext))
 <
-All the examples below assume this naming scheme.  Note that you need to do
-this again for every buffer.
+All the examples below assume this naming scheme.
 
-The auto-instantiation can be achieved with autocommands, e.g. you can put
-something like this in your .vimrc (EOFs should not have indentation): >
-    function s:MzRequire()
-	if has("mzscheme")
-	    :mz << EOF
-	    (require (prefix vim- vimext))
-	    (let ((buf (vim-get-buff-by-name (vim-eval "expand(\"<afile>\")"))))
-	      (when (and buf (not (eq? buf (vim-curr-buff))))
-		(parameterize ((current-namespace (vim-get-buff-namespace buf)))
-		  (namespace-attach-module vim-global-namespace 'vimext)
-		  (namespace-require '(prefix vim vimext)))))
-    EOF
-	endif
-    endfunction
-
-    function s:MzStartup()
-	if has("mzscheme")
-	    au BufNew,BufNewFile,BufAdd,BufReadPre * :call s:MzRequire()
-	    :mz << EOF
-	    (current-library-collection-paths
-		(cons
-		    (build-path (find-system-path 'addon-dir) (version) "collects")
-		    (current-library-collection-paths)))
-    EOF
-	endif
-    endfunction
-
-    call s:MzStartup()
-<
-
-The global namespace just instantiated this module with the prefix "vimext:".
 							*mzscheme-sandbox*
 When executed in the |sandbox|, access to some filesystem and Vim interface
 procedures is restricted.
 
 ==============================================================================
 2. Examples						*mzscheme-examples*
 >
 	:mzscheme (display "Hello")
+	:mz (display (string-append "Using MzScheme version " (version)))
+	:mzscheme (require (prefix vim- vimext)) ; for MzScheme < 4.x
+	:mzscheme (require (prefix-in vim- 'vimext)) ; MzScheme 4.x
 	:mzscheme (vim-set-buff-line 10 "This is line #10")
 <
 Inline script usage: >
 	function! <SID>SetFirstLine()
 	    :mz << EOF
 	    (display "!!!")
+	    (require (prefix vim- vimext))
+	    ; for newer versions (require (prefix-in vim- 'vimext))
 	    (vim-set-buff-line 1 "This is line #1")
 	    (vim-beep)
-	    EOF
+	EOF
 	endfunction
 
 	nmap <F9> :call <SID>SetFirstLine() <CR>
 <
 File execution: >
 	:mzfile supascript.scm
 <
-Accessing the current buffer namespace from an MzScheme program running in
-another buffer within |:mzfile|-executed script : >
-	; Move to the window below
-	(vim-command "wincmd j")
-	; execute in the context of buffer, to which window belongs
-	; assume that buffer has 'textstring' defined
-	(parameterize ((current-namespace
-			(vim-get-buff-namespace (vim-curr-buff))))
-	 (eval '(vim-set-buff-line 1 textstring)))
-<
+Vim exception handling: >
+	:mz << EOF
+	(require (prefix vim- vimext))
+	; for newer versions (require (prefix-in vim- 'vimext))
+	(with-handlers
+	  ([exn:vim? (lambda (e) (display (exn-message e)))])
+	  (vim-eval "nonsense-string"))
+	EOF
+<
+Auto-instantiation of vimext module (can be placed in your |vimrc|): >
+    function! MzRequire()
+	:redir => l:mzversion
+	:mz (version)
+	:redir END
+	if strpart(l:mzversion, 1, 1) < "4"
+	    " MzScheme versions < 4.x:
+	    :mz (require (prefix vim- vimext))
+	else
+	    " newer versions:
+	    :mz (require (prefix-in vim- 'vimext))
+	endif
+    endfunction
 
+    if has("mzscheme")
+	silent call MzRequire()
+    endif
+<
 ==============================================================================
 3. Threads						*mzscheme-threads*
 
 The MzScheme interface supports threads. They are independent from OS threads,
 thus scheduling is required. The option 'mzquantum' determines how often
@@ -157,24 +141,24 @@ Vim should poll for available MzScheme t
 NOTE
 Thread scheduling in the console version of Vim is less reliable than in the
 GUI version.
 
 ==============================================================================
-5. VIM Functions					*mzscheme-vim*
+4. Vim access from MzScheme				*mzscheme-vim*
 
 							*mzscheme-vimext*
 The 'vimext' module provides access to procedures defined in the MzScheme
 interface.
 
 Common
 ------
     (command {command-string})	    Perform the vim ":Ex" style command.
-    (eval {expr-string})	    Evaluate the vim expression to a string.
-				    A |List| is turned into a string by
-				    joining the items and inserting line
-				    breaks.
-				    NOTE clashes with MzScheme eval
+    (eval {expr-string})	    Evaluate the vim expression into
+				    respective MzScheme object: |Lists| are
+				    represented as Scheme lists,
+				    |Dictionaries| as hash tables.
+				    NOTE the name clashes with MzScheme eval
     (range-start)		    Start/End of the range passed with
     (range-end)			    the Scheme command.
     (beep)			    beep
     (get-option {option-name} [buffer-or-window]) Get Vim option value (either
 				    local or global, see set-option).
@@ -184,11 +168,10 @@ Common
 				    optname+=optval, etc.) When called with
 				    {buffer} or {window} the local option will
 				    be set. The symbol 'global can be passed
 				    as {buffer-or-window}. Then |:setglobal|
 				    will be used.
-    global-namespace		    The MzScheme main namespace.
 
 Buffers							 *mzscheme-buffer*
 -------
     (buff? {object})		    Is object a buffer?
     (buff-valid? {object})	    Is object a valid buffer? (i.e.
@@ -226,11 +209,10 @@ Buffers							 *mzscheme-buffer*
     (open-buff {filename})	    Open a new buffer (for file "name")
     (get-buff-by-name {buffername}) Get a buffer by its filename or #f
 					if there is no such buffer.
     (get-buff-by-num {buffernum})   Get a buffer by its number (return #f if
 				    there is no buffer with this number).
-    (get-buff-namespace [buffer])   Get buffer namespace.
 
 Windows							    *mzscheme-window*
 ------
     (win? {object})		    Is object a window?
     (win-valid? {object})	    Is object a valid window (i.e. corresponds
@@ -248,11 +230,17 @@ Windows							    *mzscheme-window*
     (get-cursor [window])	    Get cursor position in a window as
 				    a pair (linenr . column).
     (set-cursor (line . col) [window])  Set cursor position.
 
 ==============================================================================
-5. Dynamic loading					*mzscheme-dynamic*
+5. mzeval() Vim function				    *mzscheme-mzeval*
+
+To facilitate bi-directional interface, you can use |mzeval| function to
+evaluate MzScheme expressions and pass their values to VimL.
+
+==============================================================================
+6. Dynamic loading				    *mzscheme-dynamic* *E815*
 
 On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version|
 output then includes |+mzscheme/dyn|.
 
 This means that Vim will search for the MzScheme DLL files only when needed.
--- vim72.orig/runtime/doc/map.txt
+++ vim72/runtime/doc/map.txt
@@ -222,10 +222,14 @@ define a new mapping or abbreviation, th
 expression is evaluated to obtain the {rhs} that is used.  Example: >
 	:inoremap <expr> . InsertDot()
 The result of the InsertDot() function will be inserted.  It could check the
 text before the cursor and start omni completion when some condition is met.
 
+For abbreviations |v:char| is set to the character that was typed to trigger
+the abbreviation.  You can use this to decide how to expand the {lhs}.  You
+can't change v:char and you should not insert it.
+
 Be very careful about side effects!  The expression is evaluated while
 obtaining characters, you may very well make the command dysfunctional.
 For this reason the following is blocked:
 - Changing the buffer text |textlock|.
 - Editing another buffer.
--- vim72.orig/runtime/doc/netbeans.txt
+++ vim72/runtime/doc/netbeans.txt
@@ -1,6 +1,6 @@
-*netbeans.txt*  For Vim version 7.2.  Last change: 2008 Jun 28
+*netbeans.txt*  For Vim version 7.2.  Last change: 2009 Jan 06
 
 
 		  VIM REFERENCE MANUAL    by Gordon Prieur et al.
 
 
@@ -720,12 +720,14 @@ keyCommand keyName
 keyAtPos keyName lnum/col
 		Like "keyCommand" and also report the line number and column
 		of the cursor.
 		New in version 2.1.
 
-killed		A file was closed by the user.  Only for files that have been
-		assigned a number by the IDE.
+killed		A file was deleted or wiped out by the user and the buffer
+		annotations have been removed.  The bufID number for this
+		buffer has become invalid.  Only for files that have been
+		assigned a bufID number by the IDE.
 
 newDotAndMark off off
 		Reports the position of the cursor being at "off" bytes into
 		the buffer.  Only sent just before a "keyCommand" event.
 
--- vim72.orig/runtime/doc/options.txt
+++ vim72/runtime/doc/options.txt
@@ -1,6 +1,6 @@
-*options.txt*	For Vim version 7.2.  Last change: 2008 Aug 06
+*options.txt*	For Vim version 7.2.  Last change: 2008 Nov 25
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
 
 
@@ -1441,10 +1441,18 @@ A jump table for the options with a shor
 			Also applies to the modeless selection.
 
 	autoselectml	Like "autoselect", but for the modeless selection
 			only.  Compare to the 'A' flag in 'guioptions'.
 
+	html		When the clipboard contains HTML, use this when
+			pasting.  When putting text on the clipboard, mark it
+			as HTML.  This works to copy rendered HTML from
+			Firefox, paste it as raw HTML in Vim, select the HTML
+			in Vim and paste it in a rich edit box in Firefox.
+			Only supported for GTK version 2 and later.
+			Only available with the |+multi_byte| feature.
+
 	exclude:{pattern}
 			Defines a pattern that is matched against the name of
 			the terminal 'term'.  If there is a match, no
 			connection will be made to the X server.  This is
 			useful in this situation:
@@ -4173,13 +4181,10 @@ A jump table for the options with a shor
 	care of translating these special characters to the original meaning
 	of the key.  This means you don't have to change the keyboard mode to
 	be able to execute Normal mode commands.
 	This is the opposite of the 'keymap' option, where characters are
 	mapped in Insert mode.
-	This only works for 8-bit characters.  The value of 'langmap' may be
-	specified with multi-byte characters (e.g., UTF-8), but only the lower
-	8 bits of each character will be used.
 
 	Example (for Greek, in UTF-8):				*greek*  >
 	    :set langmap=ΑA,ΒB,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR,ΣS,ΤT,ΘU,ΩV,WW,ΧX,ΥY,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj,κk,λl,μm,νn,οo,πp,qq,ρr,σs,τt,θu,ωv,ςw,χx,υy,ζz
 <	Example (exchanges meaning of z and y for commands): >
 	    :set langmap=zy,yz,ZY,YZ
@@ -7470,11 +7475,13 @@ A jump table for the options with a shor
 			global
 			{not in Vi}
 			{not available when compiled without the |+wildignore|
 			feature}
 	A list of file patterns.  A file that matches with one of these
-	patterns is ignored when completing file or directory names.
+	patterns is ignored when completing file or directory names, and
+	influences the result of |expand()|, |glob()| and |globpath()| unless
+	a flag is passed to disable this.
 	The pattern is used like with |:autocmd|, see |autocmd-patterns|.
 	Also see 'suffixes'.
 	Example: >
 		:set wildignore=*.o,*.obj
 <	The use of |:set+=| and |:set-=| is preferred when adding or removing
--- vim72.orig/runtime/doc/os_vms.txt
+++ vim72/runtime/doc/os_vms.txt
@@ -1,6 +1,6 @@
-*os_vms.txt*    For Vim version 7.2.  Last change: 2006 Nov 18
+*os_vms.txt*    For Vim version 7.2.  Last change: 2008 Aug 19
 
 
 		  VIM REFERENCE MANUAL
 
 
@@ -310,11 +310,11 @@ features, it is worth to choose non GUI
 
 ==============================================================================
 
 8. Useful notes						*vms-notes*
 
-8.1 backspace/delete
+8.1 Backspace/delete
 8.2 Filters
 8.3 VMS file version numbers
 8.4 Directory conversion
 8.5 Remote host invocation
 8.6 Terminal problems
@@ -324,12 +324,14 @@ features, it is worth to choose non GUI
 8.10 Setting up the symbols
 8.11 diff and other GNU programs
 8.12 diff-mode
 8.13 Allow '$' in C keywords
 8.14 VIMTUTOR for beginners
+8.15 Slow start in console mode issue
+8.16 Common VIM directory - different architectures
 
-8.1 backspace/delete
+8.1 Backspace/delete
 
 There are backspace/delete key inconsistencies with VMS.
 :fixdel doesn't do the trick, but the solution is: >
 
 	:inoremap ^? ^H		" for terminal mode
@@ -661,16 +663,134 @@ start it with: >
 
 	@vim:vimtutor
 
 (Thomas.R.Wyant III, Vim 6.1)
 
+8.14 Slow start in console mode issue
+
+As GUI/GTK Vim works equally well in console mode, many administartors
+deploy those executables system wide.
+Unfortunately, on a remote slow connections GUI/GTK executables behave rather
+slow when user wants to run Vim just in the console mode - because of X environment detection timeout.
+
+Luckily, there is a simple solution for that. Administrators need to deploy
+both GUI/GTK build and just console build executables, like below: >
+
+    |- vim72
+    |----- doc
+    |----- syntax
+       vimrc    (system rc files)
+       gvimrc
+       gvim.exe (the remaned GUI or GTK built vim.exe)
+       vim.exe  (the console only executable)
+
+Define system symbols like below in for ex in LOGIN.COM or SYLOGIN.COM: >
+
+	$ define/nolog VIM RF10:[UTIL.VIM72] ! where you VIM directory is
+	$ vi*m  :== mcr VIM:VIM.EXE
+	$ gvi*m :== mcr VIM:GVIM.EXE
+	$ ! or you can try to spawn with
+	$ gv*im :== spawn/nowait/input=NLA0 mcr VIM:GVIM.EXE -g -GEOMETRY 80x40
+
+
+Like this, users that do not have X environment and want to use Vim just in
+console mode can avoid performance problems.
+
+(Zoltan Arpadffy, Vim 7.2)
+
+8.15 Common VIM directory - different architectures
+
+In a cluster that contains nodes with different architectures like below:
+
+$show cluster
+View of Cluster from system ID 11655  node: TOR                                                                     18-AUG-2008 11:58:31
++---------------------------------+
+        SYSTEMS         MEMBERS 
++-----------------------+---------
+  NODE     SOFTWARE     STATUS 
++--------+--------------+---------
+ TOR     VMS V7.3-2    MEMBER  
+ TITAN2  VMS V8.3      MEMBER  
+ ODIN    VMS V7.3-2    MEMBER  
++---------------------------------+
+
+It is convinient to have a common VIM directory but execute different
+executables.
+There are more solutions for this problem:
+
+solution 1. all executables in the same directory with different names
+This is easily done with the following script that can be added
+to the login.com or sylogin.com: >
+
+	$ if f$getsyi("NODE_HWTYPE") .eqs. "VAX"
+	$ then
+	$       say "VAX platform"
+	$       vi*m:== mcr vim:VIM.EXE_VAX
+	$ endif
+	$ if f$getsyi("NODE_HWTYPE") .eqs. "ALPH"
+	$ then
+	$       say "ALPHA platform"
+	$       vi*m :== mcr vim:VIM.EXE_AXP
+	$ endif
+	$ if f$getsyi("ARCH_NAME") .eqs. "IA64"
+	$ then
+	$      say "IA64 platform"
+	$      vi*m :== mcr vim:VIM.EXE_IA64
+	$ endif
+
+solution 2. different directories: >
+
+	$ if f$getsyi("NODE_HWTYPE") .eqs. "VAX"
+	$ then
+	$       say "VAX platform"
+	$       define/nolog VIM RF10:[UTIL.VAX_EXE] ! VAX executables
+	$ endif
+	$ if f$getsyi("NODE_HWTYPE") .eqs. "ALPH"
+	$ then
+	$       say "ALPHA platform"
+	$       define/nolog VIM RF10:[UTIL.AXP_EXE] ! AXP executables
+	$ endif
+	$ if f$getsyi("ARCH_NAME") .eqs. "IA64"
+	$ then
+	$      say "IA64 platform"
+	$      define/nolog VIM RF10:[UTIL.IA64_EXE] ! IA64 executables
+	$ endif
+        $! VIMRUNTIME must be defined in order to find runtime files
+	$ define/nolog VIMRUNTIME RF10:[UTIL.VIM72]
+
+A good examle for this approach is the [GNU]gnu_tools.com script from GNU_TOOLS.ZIP
+package downloadable from http://www.polarhome.com/vim/
+
+(Zoltan Arpadffy, Vim 7.2)
+
 ==============================================================================
 
 9. VMS related changes					*vms-changes*
 
-Version 7
+Recent changes
+- The following plugins are included into VMS runtime:
+  genutils 2.4, multiselect 2.2, multvals 3.1, selectbuf 4.3,
+  bufexplorer 7.1.7, taglist 4.5
+- minor changes in vimrc (just in VMS runtime)
+- make_vms.mms - HUGE model is the default
+- [TESTDIR]make_vms.mms include as many tests possible
+- modify test30 and test54 for VMS
+- enable FLOAT feature in VMS port
+- os_vms.txt updated
+
+Version 7.2 (2008 Aug 9)
+- VCF files write corrected
+- CTAGS 5.7 included
+- corrected make_vms.mms (on VAX gave syntax error)
+
+Version 7.1 (2007 Jun 15)
+- create TAGS file from menu
+
+Version 7 (2006 May 8)
 - Improved low level char input (affects just console mode)
+- Fixed plugin bug
+- CTAGS 5.6 included
 
 Version 6.4 (2005 Oct 15)
 - GTKLIB and Vim build on IA64
 - colors in terminal mode
 - syntax highlighting in terminal mode
@@ -804,10 +924,11 @@ Version 4.5 (1996 Dec 16)
 
 10. Authors						*vms-authors*
 
 OpenVMS documentation and executables are maintained by:
 Zoltan Arpadffy <arpadffy@polarhome.com>
+OpenVMS Vim page: http://www.polarhome.com/vim/
 
 This document uses parts and remarks from earlier authors and contributors
 of OS_VMS.TXT:
 	Charles E. Campbell, Jr. <cec@gryphon.gsfc.nasa.gov>
 	Bruce Hunsaker <BNHunsaker@chq.byu.edu>
--- vim72.orig/runtime/doc/spell.txt
+++ vim72/runtime/doc/spell.txt
@@ -1,6 +1,6 @@
-*spell.txt*	For Vim version 7.2.  Last change: 2008 Jun 21
+*spell.txt*	For Vim version 7.2.  Last change: 2008 Nov 30
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
 
 
@@ -829,12 +829,15 @@ AFFIX FILE FORMAT			*spell-aff-format* *
 							*spell-affix-comment*
 Comment lines in the .aff file start with a '#':
 
 	# comment line ~
 
-With some items it's also possible to put a comment after it, but this isn't
-supported in general.
+Items with a fixed number of arguments can be followed by a comment.  But only
+if none of the arguments can contain white space.  The comment must start with
+a "#" character.  Example:
+
+	KEEPCASE =  # fix case for words with this flag ~
 
 
 ENCODING							*spell-SET*
 
 The affix file can be in any encoding that is supported by "iconv".  However,
@@ -963,10 +966,13 @@ When using "caplong" the two-character f
 "B1", "BB", etc.  This is useful to use one-character flags for the most
 common items and two-character flags for uncommon items.
 
 Note: When using utf-8 only characters up to 65000 may be used for flags.
 
+Note: even when using "num" or "long" the number of flags available to
+compounding and prefixes is limited to about 250.
+
 
 AFFIXES
 					    *spell-PFX* *spell-SFX*
 The usual PFX (prefix) and SFX (suffix) lines are supported (see the Myspell
 documentation or the Aspell manual:
@@ -1176,10 +1182,13 @@ Once a word has been marked as bad it wo
 word as good.
 
 The flag also applies to the word with affixes, thus this can be used to mark
 a whole bunch of related words as bad.
 
+							*spell-FORBIDDENWORD*
+FORBIDDENWORD can be used just like BAD.  For compatibility with Hunspell.
+
 							*spell-NEEDAFFIX*
 The NEEDAFFIX flag is used to require that a word is used with an affix.  The
 word itself is not a good word (unless there is an empty affix).  Example:
 
 	NEEDAFFIX + ~
@@ -1266,10 +1275,14 @@ on the inside of a compound word.  This
 The NEEDCOMPOUND flag is used to require that a word is used as part of a
 compound word.  The word itself is not a good word.  Example:
 
 	NEEDCOMPOUND & ~
 
+							*spell-ONLYINCOMPOUND*
+The ONLYINCOMPOUND does exactly the same as NEEDCOMPOUND.  Supported for
+compatiblity with Hunspell.
+
 							*spell-COMPOUNDMIN*
 The minimal character length of a word used for compounding is specified with
 COMPOUNDMIN.  Example:
 	COMPOUNDMIN 5 ~
 
@@ -1326,10 +1339,24 @@ Note: this doesn't work for postponed pr
 The COMPOUNDROOT flag is used for words in the dictionary that are already a
 compound.  This means it counts for two words when checking the compounding
 rules.  Can also be used for an affix to count the affix as a compounding
 word.
 
+						*spell-CHECKCOMPOUNDPATTERN*
+CHECKCOMPOUNDPATTERN is used to define patterns that, when matching at the
+position where two words are compounded together forbids the compound.
+For example:
+	CHECKCOMPOUNDPATTERN o e ~
+
+This forbids compounding if the first word ends in "o" and the second word
+starts with "e".
+
+The arguments must be plain text, no patterns are actually supported, despite
+the item name.  Case is always ignored.
+
+The Hunspell feature to use three arguments and flags is not supported.
+
 							*spell-SYLLABLE*
 The SYLLABLE item defines characters or character sequences that are used to
 count the number of syllables in a word.  Example:
 	SYLLABLE aeiouy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui ~
 
@@ -1494,10 +1521,14 @@ These items appear in the affix file of
 ignored, not supported or defined in another way.
 
 ACCENT		(Hunspell)				*spell-ACCENT*
 		Use MAP instead. |spell-MAP|
 
+BREAK		(Hunspell)				*spell-BREAK*
+		Define break points.  Unclear how it works exactly.
+		Not supported.
+
 CHECKCOMPOUNDCASE  (Hunspell)			*spell-CHECKCOMPOUNDCASE*
 		Disallow uppercase letters at compound word boundaries.
 		Not supported.
 
 CHECKCOMPOUNDDUP  (Hunspell)			*spell-CHECKCOMPOUNDDUP*
@@ -1510,13 +1541,10 @@ CHECKCOMPOUNDREP  (Hunspell)			*spell-CH
 
 CHECKCOMPOUNDTRIPLE  (Hunspell)			*spell-CHECKCOMPOUNDTRIPLE*
 		Forbid three identical characters when compounding.  Not
 		supported.
 
-CHECKCOMPOUNDPATTERN  (Hunspell)		*spell-CHECKCOMPOUNDPATTERN*
-		Forbid compounding when patterns match.  Not supported.
-
 COMPLEXPREFIXES  (Hunspell)				*spell-COMPLEXPREFIXES*
 		Enables using two prefixes.  Not supported.
 
 COMPOUND	(Hunspell)				*spell-COMPOUND*
 		This is one line with the count of COMPOUND items, followed by
@@ -1534,16 +1562,21 @@ COMPOUNDEND	(Hunspell)				*spell-COMPOUN
 		Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
 
 COMPOUNDMIDDLE	(Hunspell)				*spell-COMPOUNDMIDDLE*
 		Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
 
+COMPOUNDRULES	(Hunspell)				*spell-COMPOUNDRULES*
+		Number of COMPOUNDRULE lines following.  Ignored, but the
+		argument must be a number.
+
 COMPOUNDSYLLABLE  (Hunspell)			*spell-COMPOUNDSYLLABLE*
 		Use SYLLABLE and COMPOUNDSYLMAX instead. |spell-SYLLABLE|
 		|spell-COMPOUNDSYLMAX|
 
-FORBIDDENWORD	(Hunspell)				*spell-FORBIDDENWORD*
-		Use BAD instead. |spell-BAD|
+KEY		(Hunspell)				*spell-KEY*
+		Define characters that are close together on the keyboard.
+		Used to give better suggestions.  Not supported.
 
 LANG		(Hunspell)				*spell-LANG*
 		This specifies language-specific behavior.  This actually
 		moves part of the language knowledge into the program,
 		therefore Vim does not support it.  Each language property
@@ -1551,14 +1584,11 @@ LANG		(Hunspell)				*spell-LANG*
 
 LEMMA_PRESENT	(Hunspell)				*spell-LEMMA_PRESENT*
 		Only needed for morphological analysis.
 
 MAXNGRAMSUGS	(Hunspell)				*spell-MAXNGRAMSUGS*
-		Not supported.
-
-ONLYINCOMPOUND	(Hunspell)				*spell-ONLYINCOMPOUND*
-		Use NEEDCOMPOUND instead. |spell-NEEDCOMPOUND|
+		Set number of n-gram suggestions.  Not supported.
 
 PSEUDOROOT	(Hunspell)				*spell-PSEUDOROOT*
 		Use NEEDAFFIX instead. |spell-NEEDAFFIX|
 
 SUGSWITHDOTS	(Hunspell)				*spell-SUGSWITHDOTS*
--- vim72.orig/runtime/doc/starting.txt
+++ vim72/runtime/doc/starting.txt
@@ -1,6 +1,6 @@
-*starting.txt*  For Vim version 7.2.  Last change: 2008 Jun 21
+*starting.txt*  For Vim version 7.2.  Last change: 2008 Nov 09
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
 
 
@@ -142,10 +142,18 @@ a slash.  Thus "-R" means recovery and "
 			(nothing)		yes		    yes
 			-u NONE			no		    no
 			-u NORC			no		    yes
 			--noplugin		yes		    no
 
+--startuptime {fname}					*--startuptime*
+		During startup write timing messages to the file {fname}.
+		This can be used to find out where time is spent while loading
+		your .vimrc, plugins and opening the first file.
+		When {fname} already exists new messages are appended.
+		(Only available when compiled with the |+startuptime|
+		feature).
+
 							*--literal*
 --literal	Take file names literally, don't expand wildcards.  Not needed
 		for Unix, because Vim always takes file names literally (the
 		shell expands wildcards).
 		Applies to all the names, also the ones that come before this
@@ -469,10 +477,11 @@ a slash.  Thus "-R" means recovery and "
 							*-X*
 -X		Do not try connecting to the X server to get the current
 		window title and copy/paste using the X clipboard.  This
 		avoids a long startup time when running Vim in a terminal
 		emulator and the connection to the X server is slow.
+		See |--startuptime| to find out if affects you.
 		Only makes a difference on Unix or VMS, when compiled with the
 		|+X11| feature.  Otherwise it's ignored.
 		To disable the connection only for specific terminals, see the
 		'clipboard' option.
 		When the X11 Session Management Protocol (XSMP) handler has
@@ -1335,12 +1344,13 @@ working on.  Viminfo and Session files t
 enter Vim and directly start working in your desired setup. |session-file|
 
 							*viminfo-read*
 When Vim is started and the 'viminfo' option is non-empty, the contents of
 the viminfo file are read and the info can be used in the appropriate places.
-The marks are not read in at startup (but file marks are).  See
-|initialization| for how to set the 'viminfo' option upon startup.
+The |v:oldfiles| variable is filled.  The marks are not read in at startup
+(but file marks are).  See |initialization| for how to set the 'viminfo'
+option upon startup.
 
 							*viminfo-write*
 When Vim exits and 'viminfo' is non-empty, the info is stored in the viminfo
 file (it's actually merged with the existing one, if one exists).  The
 'viminfo' option is a string containing information about what info should be
@@ -1370,10 +1380,12 @@ about to abandon with ":bdel", use ":wv"
 stored, but the '"' mark is.  The '"' mark is very useful for jumping to the
 cursor position when the file was last exited.  No marks are saved for files
 that start with any string given with the "r" flag in 'viminfo'.  This can be
 used to avoid saving marks for files on removable media (for MS-DOS you would
 use "ra:,rb:", for Amiga "rdf0:,rdf1:,rdf2:").
+The |v:oldfiles| variable is filled with the file names that the viminfo file
+has marks for.
 
 							*viminfo-file-marks*
 Uppercase marks ('A to 'Z) are stored when writing the viminfo file.  The
 numbered marks ('0 to '9) are a bit special.  When the viminfo file is written
 (when exiting or with the ":wviminfo" command), '0 is set to the current cursor
@@ -1461,12 +1473,12 @@ either have to fix the error, or delete
 most of the information will be restored).
 
 						   *:rv* *:rviminfo* *E195*
 :rv[iminfo][!] [file]	Read from viminfo file [file] (default: see above).
 			If [!] is given, then any information that is
-			already set (registers, marks, etc.) will be
-			overwritten.  {not in Vi}
+			already set (registers, marks, |v:oldfiles|, etc.)
+			will be overwritten   {not in Vi}
 
 					*:wv* *:wviminfo* *E137* *E138* *E574*
 :wv[iminfo][!] [file]	Write to viminfo file [file] (default: see above).
 			The information in the file is first read in to make
 			a merge between old and new info.  When [!] is used,
@@ -1477,6 +1489,22 @@ most of the information will be restored
 			check that no old temp files were left behind (e.g.
 			~/.viminf*) and that you can write in the directory of
 			the .viminfo file.
 			{not in Vi}
 
+						*:ol* *:oldfiles*
+:ol[dfiles]		List the files that have marks stored in the viminfo
+			file.  This list is read on startup and only changes
+			afterwards with ":rviminfo!".  Also see |v:oldfiles|.
+			The number can be used with |c_#<|.
+			{not in Vi, only when compiled with the +eval feature}
+
+:bro[wse] ol[dfiles][!]
+			List file names as with |:oldfiles|, and then prompt
+			for a number.  When the number is valid that file from
+			the list is edited.
+			If you get the |press-enter| prompt you can press "q"
+			and still get the prompt to enter a file number.
+			Use ! to abondon a modified buffer. |abandon|
+			{not when compiled with tiny or small features}
+
  vim:tw=78:ts=8:ft=help:norl:
--- vim72.orig/runtime/doc/usr_21.txt
+++ vim72/runtime/doc/usr_21.txt
@@ -1,6 +1,6 @@
-*usr_21.txt*	For Vim version 7.2.  Last change: 2007 May 01
+*usr_21.txt*	For Vim version 7.2.  Last change: 2008 Nov 09
 
 		     VIM USER MANUAL - by Bram Moolenaar
 
 			   Go away and come back
 
@@ -151,11 +151,11 @@ See the 'viminfo' option and |viminfo-fi
 When you run Vim multiple times, the last one exiting will store its
 information.  This may cause information that previously exiting Vims stored
 to be lost.  Each item can be remembered only once.
 
 
-GETTING BACK TO WHERE YOU WERE
+GETTING BACK TO WHERE YOU STOPPED VIM
 
 You are halfway editing a file and it's time to leave for holidays.  You exit
 Vim and go enjoy yourselves, forgetting all about your work.  After a couple
 of weeks you start Vim, and type:
 >
@@ -166,10 +166,52 @@ And you are right back where you left Vi
 position that '0 pointed to is made '1.  And '1 is made to '2, and so forth.
 Mark '9 is lost.
    The |:marks| command is useful to find out where '0 to '9 will take you.
 
 
+GETTING BACK TO SOME FILE
+
+If you want to go back to a file that you edited recently, but not when
+exiting Vim, there is a slightly more complicated way.  You can see a list of
+files by typing the command: >
+
+	:oldfiles
+<	1: ~/.viminfo ~
+	2: ~/text/resume.txt ~
+	3: /tmp/draft ~
+
+Now you would like to edit the second file, which is in the list preceded by
+"2:".  You type: >
+
+	:e #<2
+
+Instead of ":e" you can use any command that has a file name argument, the
+"#<2" item works in the same place as "%" (current file name) and "#"
+(alternate file name).  So you can also split the window to edit the third
+file: >
+
+	:split #<3
+
+That #<123 thing is a bit complicated when you just want to edit a file.
+Fortunately there is a simpler way: >
+
+	:browse oldfiles
+<	1: ~/.viminfo ~
+	2: ~/text/resume.txt ~
+	3: /tmp/draft ~
+	-- More --
+
+You get the same list of files as with |:oldfiles|.  If you want to edit
+"resume.txt" first press "q" to stop the listing.  You will get a prompt:
+
+	Type number and <Enter> (empty cancels): ~
+
+Type "2" and press <Enter> to edit the second file.
+
+More info at |:oldfiles|, |v:oldfiles| and |c_#<|.
+
+
 MOVE INFO FROM ONE VIM TO ANOTHER
 
 You can use the ":wviminfo" and ":rviminfo" commands to save and restore the
 information while still running Vim.  This is useful for exchanging register
 contents between two instances of Vim, for example.  In the first Vim do: >
--- vim72.orig/runtime/doc/usr_41.txt
+++ vim72/runtime/doc/usr_41.txt
@@ -866,10 +866,12 @@ Various:
 	setreg()		set contents and type of a register
 
 	taglist()		get list of matching tags
 	tagfiles()		get a list of tags files
 
+	mzeval()		evaluate |MzScheme| expression
+
 ==============================================================================
 *41.7*	Defining a function
 
 Vim enables you to define your own functions.  The basic function declaration
 begins as follows: >
--- vim72.orig/runtime/doc/various.txt
+++ vim72/runtime/doc/various.txt
@@ -372,10 +372,11 @@ m  *+ruby*		Ruby interface |ruby|
 m  *+ruby/dyn*		Ruby interface |ruby-dynamic| |/dyn|
 N  *+scrollbind*	|'scrollbind'|
 B  *+signs*		|:sign|
 N  *+smartindent*	|'smartindent'|
 m  *+sniff*		SniFF interface |sniff|
+N  *+startuptime*	|--startuptime| argument
 N  *+statusline*	Options 'statusline', 'rulerformat' and special
 			formats of 'titlestring' and 'iconstring'
 m  *+sun_workshop*	|workshop|
 N  *+syntax*		Syntax highlighting |syntax|
    *+system()*		Unix only: opposite of |+fork|
@@ -506,10 +507,21 @@ N  *+X11*		Unix only: can restore window
 			":silent menu ..." defines a menu that will not echo a
 			Command-line command.  The command will still produce
 			messages though.  Use ":silent" in the command itself
 			to avoid that: ":silent menu .... :silent command".
 
+						*:uns* *:unsilent*
+:uns[ilent] {command}	Execute {command} not silently.  Only makes a
+			difference when |:silent| was used to get to this
+			command.
+			Use this for giving a message even when |:silent| was
+			used.  In this example |:silent| is used to avoid the
+			message about reading the file and |:unsilent| to be
+			able to list the first line of each file. >
+    		:silent argdo unsilent echo expand('%') . ": " . getline(1)
+<
+
 						*:verb* *:verbose*
 :[count]verb[ose] {command}
 			Execute {command} with 'verbose' set to [count].  If
 			[count] is omitted one is used. ":0verbose" can be
 			used to set 'verbose' to zero.
--- vim72.orig/runtime/filetype.vim
+++ vim72/runtime/filetype.vim
@@ -2398,22 +2398,24 @@ au BufNewFile,BufRead /etc/xinetd.d/*		c
 
 " Z-Shell script
 au BufNewFile,BufRead zsh*,zlog*		call s:StarSetf('zsh')
 
 
+
+" Use the filetype detect plugins.  They may overrule any of the previously
+" detected filetypes.
+runtime! ftdetect/*.vim
+
+
 " Generic configuration file (check this last, it's just guessing!)
 au BufNewFile,BufRead,StdinReadPost *
 	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
 	\    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
 	\	|| getline(4) =~ '^#' || getline(5) =~ '^#') |
 	\   setf conf |
 	\ endif
 
-" Use the plugin-filetype checks last, they may overrule any of the previously
-" detected filetypes.
-runtime! ftdetect/*.vim
-
 augroup END
 
 
 " If the GUI is already running, may still need to install the Syntax menu.
 " Don't do it when the 'M' flag is included in 'guioptions'.
--- vim72.orig/runtime/plugin/gzip.vim
+++ vim72/runtime/plugin/gzip.vim
@@ -1,8 +1,8 @@
 " Vim plugin for editing compressed files.
 " Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2005 Jul 26
+" Last Change: 2010 Mar 10
 
 " Exit quickly when:
 " - this plugin was already loaded
 " - when 'compatible' is set
 " - some autocommands are already taking care of compressed files
@@ -18,19 +18,27 @@ augroup gzip
   " Enable editing of gzipped files.
   " The functions are defined in autoload/gzip.vim.
   "
   " Set binary mode before reading the file.
   " Use "gzip -d", gunzip isn't always available.
-  autocmd BufReadPre,FileReadPre	*.gz,*.bz2,*.Z setlocal bin
+  autocmd BufReadPre,FileReadPre	*.gz,*.bz2,*.Z,*.lzma,*.xz setlocal bin
   autocmd BufReadPost,FileReadPost	*.gz  call gzip#read("gzip -dn")
   autocmd BufReadPost,FileReadPost	*.bz2 call gzip#read("bzip2 -d")
   autocmd BufReadPost,FileReadPost	*.Z   call gzip#read("uncompress")
+  autocmd BufReadPost,FileReadPost	*.lzma call gzip#read("lzma -d")
+  autocmd BufReadPost,FileReadPost	*.xz  call gzip#read("xz -d")
   autocmd BufWritePost,FileWritePost	*.gz  call gzip#write("gzip")
   autocmd BufWritePost,FileWritePost	*.bz2 call gzip#write("bzip2")
   autocmd BufWritePost,FileWritePost	*.Z   call gzip#write("compress -f")
+  autocmd BufWritePost,FileWritePost	*.lzma call gzip#write("lzma -z")
+  autocmd BufWritePost,FileWritePost	*.xz  call gzip#write("xz -z")
   autocmd FileAppendPre			*.gz  call gzip#appre("gzip -dn")
   autocmd FileAppendPre			*.bz2 call gzip#appre("bzip2 -d")
   autocmd FileAppendPre			*.Z   call gzip#appre("uncompress")
+  autocmd FileAppendPre			*.lzma call gzip#appre("lzma -d")
+  autocmd FileAppendPre			*.xz   call gzip#appre("xz -d")
   autocmd FileAppendPost		*.gz  call gzip#write("gzip")
   autocmd FileAppendPost		*.bz2 call gzip#write("bzip2")
   autocmd FileAppendPost		*.Z   call gzip#write("compress -f")
+  autocmd FileAppendPost		*.lzma call gzip#write("lzma -z")
+  autocmd FileAppendPost		*.xz call gzip#write("xz -z")
 augroup END
--- vim72.orig/runtime/scripts.vim
+++ vim72/runtime/scripts.vim
@@ -232,10 +232,14 @@ else
 
     " XHTML (e.g.: PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN")
   elseif s:line1 =~ '\<DTD\s\+XHTML\s'
     set ft=xhtml
 
+    " HTML (e.g.: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN")
+  elseif s:line1 =~? '\<DOCTYPE\s\+html\>'
+    set ft=html
+
     " PDF
   elseif s:line1 =~ '^%PDF-'
     set ft=pdf
 
     " XXD output
--- vim72.orig/runtime/tools/README.txt
+++ vim72/runtime/tools/README.txt
@@ -30,6 +30,8 @@ vim_vs_net.cmd: MS-Windows command file
 		later.
 
 xcmdsrv_client.c:  Example for a client program that communicates with a Vim
 		   server through the X-Windows interface.
 
+unicode.vim	Vim script to generate tables for src/mbyte.c.
+
 [xxd (and tee for OS/2) can be found in the src directory]
--- /dev/null
+++ vim72/runtime/tools/unicode.vim
@@ -0,0 +1,290 @@
+" Script to extract tables from Unicode .txt files, to be used in src/mbyte.c.
+" The format of the UnicodeData.txt file is explained here:
+" http://www.unicode.org/Public/5.1.0/ucd/UCD.html
+" For the other files see the header.
+"
+" Usage: Vim -S <this-file>
+"
+" Author: Bram Moolenaar
+" Last Update: 2010 Jan 12
+
+" Parse lines of UnicodeData.txt.  Creates a list of lists in s:dataprops.
+func! ParseDataToProps()
+  let s:dataprops = []
+  let lnum = 1
+  while lnum <= line('$')
+    let l = split(getline(lnum), '\s*;\s*', 1)
+    if len(l) != 15
+      echoerr 'Found ' . len(l) . ' items in line ' . lnum . ', expected 15'
+      return
+    endif
+    call add(s:dataprops, l)
+    let lnum += 1
+  endwhile
+endfunc
+
+" Parse lines of CaseFolding.txt.  Creates a list of lists in s:foldprops.
+func! ParseFoldProps()
+  let s:foldprops = []
+  let lnum = 1
+  while lnum <= line('$')
+    let line = getline(lnum)
+    if line !~ '^#' && line !~ '^\s*$'
+      let l = split(line, '\s*;\s*', 1)
+      if len(l) != 4
+	echoerr 'Found ' . len(l) . ' items in line ' . lnum . ', expected 4'
+	return
+      endif
+      call add(s:foldprops, l)
+    endif
+    let lnum += 1
+  endwhile
+endfunc
+
+" Parse lines of EastAsianWidth.txt.  Creates a list of lists in s:widthprops.
+func! ParseWidthProps()
+  let s:widthprops = []
+  let lnum = 1
+  while lnum <= line('$')
+    let line = getline(lnum)
+    if line !~ '^#' && line !~ '^\s*$'
+      let l = split(line, '\s*;\s*', 1)
+      if len(l) != 2
+	echoerr 'Found ' . len(l) . ' items in line ' . lnum . ', expected 2'
+	return
+      endif
+      call add(s:widthprops, l)
+    endif
+    let lnum += 1
+  endwhile
+endfunc
+
+" Build the toLower or toUpper table in a new buffer.
+" Uses s:dataprops.
+func! BuildCaseTable(name, index)
+  let start = -1
+  let end = -1
+  let step = 0
+  let add = -1
+  let ranges = []
+  for p in s:dataprops
+    if p[a:index] != ''
+      let n = ('0x' . p[0]) + 0
+      let nl = ('0x' . p[a:index]) + 0
+      if start >= 0 && add == nl - n && (step == 0 || n - end == step)
+	" continue with same range.
+	let step = n - end
+	let end = n
+      else
+	if start >= 0
+	  " produce previous range
+	  call Range(ranges, start, end, step, add)
+	endif
+	let start = n
+	let end = n
+	let step = 0
+	let add = nl - n
+      endif
+    endif
+  endfor
+  if start >= 0
+    call Range(ranges, start, end, step, add)
+  endif
+
+  " New buffer to put the result in.
+  new
+  exe "file to" . a:name
+  call setline(1, "static convertStruct to" . a:name . "[] =")
+  call setline(2, "{")
+  call append('$', ranges)
+  call setline('$', getline('$')[:-2])  " remove last comma
+  call setline(line('$') + 1, "};")
+  wincmd p
+endfunc
+
+" Build the foldCase table in a new buffer.
+" Uses s:foldprops.
+func! BuildFoldTable()
+  let start = -1
+  let end = -1
+  let step = 0
+  let add = -1
+  let ranges = []
+  for p in s:foldprops
+    if p[1] == 'C' || p[1] == 'S'
+      let n = ('0x' . p[0]) + 0
+      let nl = ('0x' . p[2]) + 0
+      if start >= 0 && add == nl - n && (step == 0 || n - end == step)
+	" continue with same range.
+	let step = n - end
+	let end = n
+      else
+	if start >= 0
+	  " produce previous range
+	  call Range(ranges, start, end, step, add)
+	endif
+	let start = n
+	let end = n
+	let step = 0
+	let add = nl - n
+      endif
+    endif
+  endfor
+  if start >= 0
+    call Range(ranges, start, end, step, add)
+  endif
+
+  " New buffer to put the result in.
+  new
+  file foldCase
+  call setline(1, "static convertStruct foldCase[] =")
+  call setline(2, "{")
+  call append('$', ranges)
+  call setline('$', getline('$')[:-2])  " remove last comma
+  call setline(line('$') + 1, "};")
+  wincmd p
+endfunc
+
+func! Range(ranges, start, end, step, add)
+  let s = printf("\t{0x%x,0x%x,%d,%d},", a:start, a:end, a:step == 0 ? -1 : a:step, a:add)
+  call add(a:ranges, s)
+endfunc
+
+" Build the combining table.
+" Uses s:dataprops.
+func! BuildCombiningTable()
+  let start = -1
+  let end = -1
+  let ranges = []
+  for p in s:dataprops
+    if p[2] == 'Mn' || p[2] == 'Mc' || p[2] == 'Me'
+      let n = ('0x' . p[0]) + 0
+      if start >= 0 && end + 1 == n
+	" continue with same range.
+	let end = n
+      else
+	if start >= 0
+	  " produce previous range
+	  call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
+	endif
+	let start = n
+	let end = n
+      endif
+    endif
+  endfor
+  if start >= 0
+    call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
+  endif
+
+  " New buffer to put the result in.
+  new
+  file combining
+  call setline(1, "    static struct interval combining[] =")
+  call setline(2, "    {")
+  call append('$', ranges)
+  call setline('$', getline('$')[:-2])  " remove last comma
+  call setline(line('$') + 1, "    };")
+  wincmd p
+endfunc
+
+" Build the double width or ambiguous width table in a new buffer.
+" Uses s:widthprops and s:dataprops.
+func! BuildWidthTable(pattern, tableName)
+  let start = -1
+  let end = -1
+  let ranges = []
+  let dataidx = 0
+  for p in s:widthprops
+    if p[1][0] =~ a:pattern
+      if p[0] =~ '\.\.'
+	" It is a range.  we don't check for composing char then.
+	let rng = split(p[0], '\.\.')
+	if len(rng) != 2
+	  echoerr "Cannot parse range: '" . p[0] . "' in width table"
+	endif
+	let n = ('0x' . rng[0]) + 0
+	let n_last =  ('0x' . rng[1]) + 0
+      else
+	let n = ('0x' . p[0]) + 0
+	let n_last = n
+      endif
+      " Find this char in the data table.
+      while 1
+	let dn = ('0x' . s:dataprops[dataidx][0]) + 0
+	if dn >= n
+	  break
+	endif
+	let dataidx += 1
+      endwhile
+      if dn != n && n_last == n
+	echoerr "Cannot find character " . n . " in data table"
+      endif
+      " Only use the char when it's not a composing char.
+      " But use all chars from a range.
+      let dp = s:dataprops[dataidx]
+      if n_last > n || (dp[2] != 'Mn' && dp[2] != 'Mc' && dp[2] != 'Me')
+	if start >= 0 && end + 1 == n
+	  " continue with same range.
+	else
+	  if start >= 0
+	    " produce previous range
+	    call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
+	  endif
+	  let start = n
+	endif
+	let end = n_last
+      endif
+    endif
+  endfor
+  if start >= 0
+    call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
+  endif
+
+  " New buffer to put the result in.
+  new
+  exe "file " . a:tableName
+  call setline(1, "    static struct interval " . a:tableName . "[] =")
+  call setline(2, "    {")
+  call append('$', ranges)
+  call setline('$', getline('$')[:-2])  " remove last comma
+  call setline(line('$') + 1, "    };")
+  wincmd p
+endfunc
+
+
+
+" Edit the Unicode text file.  Requires the netrw plugin.
+edit http://unicode.org/Public/UNIDATA/UnicodeData.txt
+
+" Parse each line, create a list of lists.
+call ParseDataToProps()
+
+" Build the toLower table.
+call BuildCaseTable("Lower", 13)
+
+" Build the toUpper table.
+call BuildCaseTable("Upper", 12)
+
+" Build the ranges of composing chars.
+call BuildCombiningTable()
+
+" Edit the case folding text file.  Requires the netrw plugin.
+edit http://www.unicode.org/Public/UNIDATA/CaseFolding.txt
+
+" Parse each line, create a list of lists.
+call ParseFoldProps()
+
+" Build the foldCase table.
+call BuildFoldTable()
+
+" Edit the width text file.  Requires the netrw plugin.
+edit http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt
+
+" Parse each line, create a list of lists.
+call ParseWidthProps()
+
+" Build the double width table.
+call BuildWidthTable('[WF]', 'doublewidth')
+
+" Build the ambiguous width table.
+call BuildWidthTable('A', 'ambiguous')
--- vim72.orig/src/GvimExt/Make_ming.mak
+++ vim72/src/GvimExt/Make_ming.mak
@@ -18,28 +18,24 @@ CROSS = no
 MINGWOLD = no
 
 ifeq ($(CROSS),yes)
 DEL = rm
 ifeq ($(MINGWOLD),yes)
-CXX = i586-mingw32msvc-g++
 CXXFLAGS := -O2 -mno-cygwin -fvtable-thunks
-WINDRES = i586-mingw32msvc-windres
 else
-CXX = i386-mingw32msvc-g++
 CXXFLAGS := -O2 -mno-cygwin
-WINDRES = i386-mingw32msvc-windres
 endif
 else
-CXX := g++
-WINDRES := windres
 CXXFLAGS := -O2 -mno-cygwin
 ifneq (sh.exe, $(SHELL))
 DEL = rm
 else
 DEL = del
 endif
 endif
+CXX := $(CROSS_COMPILE)g++
+WINDRES := $(CROSS_COMPILE)windres
 LIBS :=  -luuid
 RES  := gvimext.res
 DEFFILE = gvimext_ming.def
 OBJ  := gvimext.o
 
--- vim72.orig/src/GvimExt/gvimext.cpp
+++ vim72/src/GvimExt/gvimext.cpp
@@ -633,11 +633,13 @@ STDMETHODIMP CShellExt::QueryContextMenu
 		--pos;
 	    *pos = 0;
 	}
 	// Now concatenate
 	strncpy(temp, _("Edit with existing Vim - "), BUFSIZE - 1);
-	strncat(temp, title, BUFSIZE - 1);
+	temp[BUFSIZE - 1] = '\0';
+	strncat(temp, title, BUFSIZE - 1 - strlen(temp));
+	temp[BUFSIZE - 1] = '\0';
 	InsertMenu(hMenu,
 		indexMenu++,
 		MF_STRING|MF_BYPOSITION,
 		idCmd++,
 		temp);
--- vim72.orig/src/GvimExt/gvimext.h
+++ vim72/src/GvimExt/gvimext.h
@@ -12,13 +12,13 @@
  */
 
 #if !defined(AFX_STDAFX_H__3389658B_AD83_11D3_9C1E_0090278BBD99__INCLUDED_)
 #define AFX_STDAFX_H__3389658B_AD83_11D3_9C1E_0090278BBD99__INCLUDED_
 
-#if _MSC_VER > 1000
+#if defined(_MSC_VER) && _MSC_VER > 1000
 #pragma once
-#endif // _MSC_VER > 1000
+#endif
 
 // Insert your headers here
 // #define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
 
 //--------------------------------------------------------------
@@ -32,21 +32,21 @@
 #endif
 
 #define INC_OLE2	// WIN32, get ole2 from windows.h
 
 /* Visual Studio 2005 has 'deprecated' many of the standard CRT functions */
-#if _MSC_VER >= 1400
+#if defined(_MSC_VER) && _MSC_VER >= 1400
 # define _CRT_SECURE_NO_DEPRECATE
 # define _CRT_NONSTDC_NO_DEPRECATE
 #endif
 
 #include <windows.h>
 #include <windowsx.h>
 #include <shlobj.h>
 
 /* Accommodate old versions of VC that don't have a modern Platform SDK */
-#if _MSC_VER < 1300
+#if defined(_MSC_VER) && _MSC_VER < 1300
 # undef  UINT_PTR
 # define UINT_PTR UINT
 #endif
 
 #define ResultFromShort(i)  ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i)))
--- vim72.orig/src/INSTALLpc.txt
+++ vim72/src/INSTALLpc.txt
@@ -213,12 +213,13 @@ and you type:
 After churning for a while, you will end up with 'gvim.exe' in the 'vim\src'
 directory.
 
 You should not need to do *any* editing of any files to get vim compiled this
 way.  If, for some reason, you want the console-mode-only version of vim (this
-is NOT recommended on Win32, especially on '95/'98!!!), you need only change
-the 'gvim.exe' to 'vim.exe' in the 'make' commands given above.
+is NOT recommended on Win32, especially on '95/'98!!!), you can use:
+
+    make -f Make_ming.mak GUI=no vim.exe
 
 If you are dismayed by how big the EXE is, I strongly recommend you get 'UPX'
 (also free!) and compress the file (typical compression is 50%). UPX can be
 found at
     http://www.upx.org/
@@ -238,11 +239,11 @@ Use Make_cyg.mak with Cygwin's GCC. See
     http://users.skynet.be/antoine.mechelynck/vim/compile.htm
 
 The Cygnus one many not fully work yet.
 With Cygnus gcc you can use the Unix Makefile instead (you need to get the
 Unix archive then).  Then you get a Cygwin application (feels like Vim is
-runnin on Unix), while with Make_cyg.mak you get a Windows application (like
+running on Unix), while with Make_cyg.mak you get a Windows application (like
 with the other makefiles).
 
 
 4. Borland
 ===========
@@ -257,14 +258,17 @@ Use Make_bc5.mak with Borland C++ 5.x. S
 [Update of 1) needs to be verified]
 
 If you like, you can compile the 'mingw' Win32 version from the comfort of
 your Linux (or other unix) box.  To do this, you need to follow a few steps:
     1) Install the mingw32 cross-compiler. See
+	http://www.mingw.org/wiki/LinuxCrossMinGW
 	http://www.libsdl.org/extras/win32/cross/README.txt
     2) Get and unpack both the Unix sources and the extra archive
     3) in 'Make_ming.mak', set 'CROSS' to 'yes' instead of 'no'.
        Make further changes to 'Make_ming.mak' as you wish.
+       If your cross-compiler prefix differs from the predefined value,
+       set 'CROSS_COMPILE' corresponding.
     4) make -f Make_ming.mak gvim.exe
 
 Now you have created the Windows binary from your Linux box!  Have fun...
 
 
--- vim72.orig/src/Make_cyg.mak
+++ vim72/src/Make_cyg.mak
@@ -1,8 +1,8 @@
 #
 # Makefile for VIM on Win32, using Cygnus gcc
-# Last updated by Dan Sharp.  Last Change: 2007 Sep 29
+# Last updated by Dan Sharp.  Last Change: 2010 Feb 24
 #
 # Also read INSTALLpc.txt!
 #
 # This compiles Vim as a Windows application.  If you want Vim to run as a
 # Cygwin application use the Makefile (just like on Unix).
@@ -30,13 +30,16 @@
 # IME		no or yes: set to yes to include IME support (yes)
 #   DYNAMIC_IME no or yes: set to yes to load imm32.dll dynamically (yes)
 # OLE		no or yes: set to yes to make OLE gvim (no)
 # DEBUG		no or yes: set to yes if you wish a DEBUGging build (no)
 # CPUNR		No longer supported, use ARCH.
-# ARCH		i386 through pentium4: select -march argument to compile with (i386)
+# ARCH		i386 through pentium4: select -march argument to compile with
+#               (i386)
 # USEDLL	no or yes: set to yes to use the Runtime library DLL (no)
 #		For USEDLL=yes the cygwin1.dll is required to run Vim.
+#		"no" does not work with latest version of Cygwin, use
+#		Make_ming.mak instead.  Or set CC to gcc-3.
 # POSTSCRIPT	no or yes: set to yes for PostScript printing (no)
 # FEATURES	TINY, SMALL, NORMAL, BIG or HUGE (BIG)
 # WINVER	Lowest Win32 version to support.  (0x0400)
 # CSCOPE	no or yes: to include cscope interface support (yes)
 # OPTIMIZE	SPACE, SPEED, or MAXSPEED: set optimization level (MAXSPEED)
@@ -97,10 +100,11 @@ endif
 DEFINES = -DWIN32 -DHAVE_PATHDEF -DFEAT_$(FEATURES) \
 	  -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER)
 INCLUDES = -march=$(ARCH) -Iproto
 
 #>>>>> name of the compiler and linker, name of lib directory
+CROSS_COMPILE =
 CC = gcc
 RC = windres
 
 ##############################
 # DYNAMIC_PERL=yes and no both work
@@ -210,17 +214,38 @@ endif
 
 ifndef MZSCHEME_VER
 MZSCHEME_VER = 209_000
 endif
 
+ifndef MZSCHEME_PRECISE_GC
+MZSCHEME_PRECISE_GC=no
+endif
+
+# for version 4.x we need to generate byte-code for Scheme base
+ifndef MZSCHEME_GENERATE_BASE
+MZSCHEME_GENERATE_BASE=no
+endif
+
 ifeq (yes, $(DYNAMIC_MZSCHEME))
 DEFINES += -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libmzsch$(MZSCHEME_VER).dll\" -DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\"
 else
 ifndef MZSCHEME_DLLS
 MZSCHEME_DLLS = $(MZSCHEME)
 endif
-EXTRA_LIBS += -L$(MZSCHEME_DLLS) -lmzsch$(MZSCHEME_VER) -lmzgc$(MZSCHEME_VER)
+ifeq (yes,$(MZSCHEME_PRECISE_GC))
+MZSCHEME_LIB=-lmzsch$(MZSCHEME_VER)
+else
+MZSCHEME_LIB = -lmzsch$(MZSCHEME_VER) -lmzgc$(MZSCHEME_VER)
+endif
+EXTRA_LIBS += -L$(MZSCHEME_DLLS) -L$(MZSCHEME_DLLS)/lib $(MZSCHEME_LIB)
+endif
+ifeq (yes,$(MZSCHEME_GENERATE_BASE))
+DEFINES += -DINCLUDE_MZSCHEME_BASE
+MZ_EXTRA_DEP += mzscheme_base.c
+endif
+ifeq (yes,$(MZSCHEME_PRECISE_GC))
+DEFINES += -DMZ_PRECISE_GC
 endif
 endif
 
 ##############################
 # DYNAMIC_TCL=yes and no both work.
@@ -444,14 +469,14 @@ all: $(EXE) xxd/xxd.exe vimrun.exe insta
 # See /usr/doc/cygwin-doc-1.2/html/faq_toc.html#TOC93 for more information.
 $(EXE): $(OUTDIR) $(OBJ)
 	$(CC) $(CFLAGS) -o $(EXE) $(OBJ) $(LIBS) -luuid -lole32 $(EXTRA_LIBS)
 
 xxd/xxd.exe: xxd/xxd.c
-	$(MAKE) -C xxd -f Make_cyg.mak USEDLL=$(USEDLL)
+	$(MAKE) -C xxd -f Make_cyg.mak CC=$(CC) USEDLL=$(USEDLL)
 
 GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h
-	$(MAKE) -C GvimExt -f Make_ming.mak
+	$(MAKE) -C GvimExt -f Make_ming.mak CROSS_COMPILE=$(CROSS_COMPILE)
 
 vimrun.exe: vimrun.c
 	$(CC) $(CFLAGS) -o vimrun.exe vimrun.c  $(LIBS)
 
 install.exe: dosinst.c
@@ -471,10 +496,13 @@ clean:
 	-rmdir $(OUTDIR)
 	-$(DEL) $(EXE) vimrun.exe install.exe uninstal.exe
 ifdef PERL
 	-$(DEL) if_perl.c
 endif
+ifdef MZSCHEME
+	-$(DEL) mzscheme_base.c
+endif
 	-$(DEL) pathdef.c
 	$(MAKE) -C xxd -f Make_cyg.mak clean
 	$(MAKE) -C GvimExt -f Make_ming.mak clean
 
 distclean: clean
@@ -521,13 +549,19 @@ ifeq (16, $(RUBY_VER))
 endif
 
 $(OUTDIR)/netbeans.o:	netbeans.c $(INCL) $(NBDEBUG_DEP)
 	$(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o
 
+$(OUTDIR)/if_mzsch.o:	if_mzsch.c $(INCL) if_mzsch.h $(MZ_EXTRA_DEP)
+	$(CC) -c $(CFLAGS) if_mzsch.c -o $(OUTDIR)/if_mzsch.o
+
 $(OUTDIR)/vimrc.o:	vim.rc version.h gui_w32_rc.h
 	$(RC) $(RCFLAGS) vim.rc -o $(OUTDIR)/vimrc.o
 
+mzscheme_base.c:
+	$(MZSCHEME)/mzc --c-mods mzscheme_base.c ++lib scheme/base
+
 pathdef.c: $(INCL)
 ifneq (sh.exe, $(SHELL))
 	@echo creating pathdef.c
 	@echo '/* pathdef.c */' > pathdef.c
 	@echo '#include "vim.h"' >> pathdef.c
--- vim72.orig/src/Make_ming.mak
+++ vim72/src/Make_ming.mak
@@ -113,18 +113,31 @@ endif
 
 ifndef MZSCHEME_VER
 MZSCHEME_VER=205_000
 endif
 
+ifndef MZSCHEME_PRECISE_GC
+MZSCHEME_PRECISE_GC=no
+endif
+
+# for version 4.x we need to generate byte-code for Scheme base
+ifndef MZSCHEME_GENERATE_BASE
+MZSCHEME_GENERATE_BASE=no
+endif
+
 ifeq (no,$(DYNAMIC_MZSCHEME))
+ifeq (yes,$(MZSCHEME_PRECISE_GC))
+MZSCHEME_LIB=-lmzsch$(MZSCHEME_VER)
+else
 MZSCHEME_LIB = -lmzsch$(MZSCHEME_VER) -lmzgc$(MZSCHEME_VER)
+endif
 # the modern MinGW can dynamically link to dlls directly.
 # point MZSCHEME_DLLS to where you put libmzschXXXXXXX.dll and libgcXXXXXXX.dll
 ifndef MZSCHEME_DLLS
 MZSCHEME_DLLS=$(MZSCHEME)
 endif
-MZSCHEME_LIBDIR=-L$(MZSCHEME_DLLS)
+MZSCHEME_LIBDIR=-L$(MZSCHEME_DLLS) -L$(MZSCHEME_DLLS)\lib
 endif
 
 endif
 
 # Python support -- works with the ActiveState python 2.0 release (and others
@@ -197,27 +210,31 @@ RUBY_VER = 16
 endif
 ifndef RUBY_VER_LONG
 RUBY_VER_LONG = 1.6
 endif
 
-ifeq ($(RUBY_VER), 16)
 ifndef RUBY_PLATFORM
+ifeq ($(RUBY_VER), 16)
 RUBY_PLATFORM = i586-mswin32
-endif
-ifndef RUBY_INSTALL_NAME
-RUBY_INSTALL_NAME = mswin32-ruby$(RUBY_VER)
-endif
 else
-ifndef RUBY_PLATFORM
+ifneq ($(wildcard $(RUBY)/lib/ruby/$(RUBY_VER_LONG)/i386-mingw32),)
+RUBY_PLATFORM = i386-mingw32
+else
 RUBY_PLATFORM = i386-mswin32
 endif
+endif
+endif
+
 ifndef RUBY_INSTALL_NAME
+ifeq ($(RUBY_VER), 16)
+RUBY_INSTALL_NAME = mswin32-ruby$(RUBY_VER)
+else
 RUBY_INSTALL_NAME = msvcrt-ruby$(RUBY_VER)
 endif
 endif
 
-RUBYINC =-I $(RUBY)/lib/ruby/$(RUBY_VER_LONG)/$(RUBY_PLATFORM)
+RUBYINC =-I $(RUBY)/lib/ruby/$(RUBY_VER_LONG)/$(RUBY_PLATFORM) -I $(RUBY)/include/ruby-$(RUBY_VER_LONG) -I $(RUBY)/include/ruby-$(RUBY_VER_LONG)/$(RUBY_PLATFORM)
 ifeq (no, $(DYNAMIC_RUBY))
 RUBYLIB = -L$(RUBY)/lib -l$(RUBY_INSTALL_NAME)
 endif
 
 endif # RUBY
@@ -226,29 +243,30 @@ endif # RUBY
 # Any other defines can be included here.
 DEF_GUI=-DFEAT_GUI_W32 -DFEAT_CLIPBOARD
 DEFINES=-DWIN32 -DWINVER=$(WINVER) -D_WIN32_WINNT=$(WINVER) \
 	-DHAVE_PATHDEF -DFEAT_$(FEATURES)
 ifeq ($(CROSS),yes)
-# cross-compiler:
-CC = i586-pc-mingw32msvc-gcc
+# cross-compiler prefix:
+CROSS_COMPILE = i586-pc-mingw32msvc-
 DEL = rm
 MKDIR = mkdir -p
-WINDRES = i586-pc-mingw32msvc-windres
+DIRSLASH = /
 else
 # normal (Windows) compilation:
-CC = gcc
+CROSS_COMPILE =
 ifneq (sh.exe, $(SHELL))
 DEL = rm
 MKDIR = mkdir -p
 DIRSLASH = /
 else
 DEL = del
 MKDIR = mkdir
 DIRSLASH = \\
 endif
-WINDRES = windres
 endif
+CC := $(CROSS_COMPILE)gcc
+WINDRES := $(CROSS_COMPILE)windres
 
 #>>>>> end of choices
 ###########################################################################
 
 CFLAGS = -Iproto $(DEFINES) -pipe -w -march=$(ARCH) -Wall
@@ -408,10 +426,17 @@ ifdef PERL
 OBJ += $(OUTDIR)/if_perl.o
 endif
 ifdef MZSCHEME
 OBJ += $(OUTDIR)/if_mzsch.o
 MZSCHEME_INCL = if_mzsch.h
+ifeq (yes,$(MZSCHEME_GENERATE_BASE))
+CFLAGS += -DINCLUDE_MZSCHEME_BASE
+MZ_EXTRA_DEP += mzscheme_base.c
+endif
+ifeq (yes,$(MZSCHEME_PRECISE_GC))
+CFLAGS += -DMZ_PRECISE_GC
+endif
 endif
 ifdef PYTHON
 OBJ += $(OUTDIR)/if_python.o
 endif
 ifdef RUBY
@@ -527,24 +552,27 @@ $(TARGET): $(OUTDIR) $(OBJ)
 upx: exes
 	upx gvim.exe
 	upx vim.exe
 
 xxd/xxd.exe: xxd/xxd.c
-	$(MAKE) -C xxd -f Make_cyg.mak
+	$(MAKE) -C xxd -f Make_cyg.mak CC=$(CC)
 
 GvimExt/gvimext.dll: GvimExt/gvimext.cpp GvimExt/gvimext.rc GvimExt/gvimext.h
-	$(MAKE) -C GvimExt -f Make_ming.mak
+	$(MAKE) -C GvimExt -f Make_ming.mak CROSS=$(CROSS) CROSS_COMPILE=$(CROSS_COMPILE)
 
 clean:
 	-$(DEL) $(OUTDIR)$(DIRSLASH)*.o
 	-$(DEL) $(OUTDIR)$(DIRSLASH)*.res
 	-rmdir $(OUTDIR)
 	-$(DEL) *.exe
 	-$(DEL) pathdef.c
 ifdef PERL
 	-$(DEL) if_perl.c
 endif
+ifdef MZSCHEME
+	-$(DEL) mzscheme_base.c
+endif
 	$(MAKE) -C GvimExt -f Make_ming.mak clean
 	$(MAKE) -C xxd -f Make_cyg.mak clean
 
 ###########################################################################
 INCL = vim.h feature.h os_win32.h os_dos.h ascii.h keymap.h term.h macros.h \
@@ -586,10 +614,16 @@ if_perl.c: if_perl.xs typemap
 	     $(PERLLIB)/ExtUtils/typemap if_perl.xs > $@
 
 $(OUTDIR)/netbeans.o:	netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC)
 	$(CC) -c $(CFLAGS) netbeans.c -o $(OUTDIR)/netbeans.o
 
+$(OUTDIR)/if_mzsch.o:	if_mzsch.c $(INCL) if_mzsch.h $(MZ_EXTRA_DEP)
+	$(CC) -c $(CFLAGS) if_mzsch.c -o $(OUTDIR)/if_mzsch.o
+
+mzscheme_base.c:
+	$(MZSCHEME)/mzc --c-mods mzscheme_base.c ++lib scheme/base
+
 pathdef.c: $(INCL)
 ifneq (sh.exe, $(SHELL))
 	@echo creating pathdef.c
 	@echo '/* pathdef.c */' > pathdef.c
 	@echo '#include "vim.h"' >> pathdef.c
--- vim72.orig/src/Make_mvc.mak
+++ vim72/src/Make_mvc.mak
@@ -1,20 +1,20 @@
 # Makefile for Vim on Win32 (Windows NT/2000/XP/2003 and Windows 95/98/Me)
 # and Win64, using the Microsoft Visual C++ compilers. Known to work with
 # VC5, VC6 (VS98), VC7.0 (VS2002), VC7.1 (VS2003), VC8 (VS2005),
-# and VC9 (VS2008).
+# VC9 (VS2008), and VC10 (VS2010).
 #
 # To build using other Windows compilers, see INSTALLpc.txt
 #
 # This makefile can build the console, GUI, OLE-enable, Perl-enabled and
-# Python-enabled versions of vim for Win32 platforms.
+# Python-enabled versions of Vim for Win32 platforms.
 #
-# The basic command line to build vim is:
+# The basic command line to build Vim is:
 #
 #	nmake -f Make_mvc.mak
 #
-# This will build the console version of vim with no additional interfaces.
+# This will build the console version of Vim with no additional interfaces.
 # To add features, define any of the following:
 #
 #	!!!!  After changing features do "nmake clean" first  !!!!
 #
 #       Feature Set: FEATURES=[TINY, SMALL, NORMAL, BIG, HUGE] (default is BIG)
@@ -32,10 +32,11 @@
 #
 #	MzScheme interface:
 #	  MZSCHEME=[Path to MzScheme directory]
 #	  DYNAMIC_MZSCHEME=yes (to load the MzScheme DLLs dynamically)
 #	  MZSCHEME_VER=[version, 205_000, ...]
+#	  MZSCHEME_DEBUG=no
 #
 #	Perl interface:
 #	  PERL=[Path to Perl directory]
 #	  DYNAMIC_PERL=yes (to load the Perl DLL dynamically)
 #	  PERL_VER=[Perl version, in the form 55 (5.005), 56 (5.6.x), etc]
@@ -352,10 +353,19 @@ MSVCVER = 8.0
 MSVCVER = 9.0
 !endif
 !if "$(_NMAKE_VER)" == "9.00.21022.08"
 MSVCVER = 9.0
 !endif
+!if "$(_NMAKE_VER)" == "9.00.30729.01"
+MSVCVER = 9.0
+!endif
+!if "$(_NMAKE_VER)" == "10.00.20506.01"
+MSVCVER = 10.0
+!endif
+!if "$(_NMAKE_VER)" == "10.00.30128.01"
+MSVCVER = 10.0
+!endif
 !endif
 
 # Abort bulding VIM if version of VC is unrecognised.
 !ifndef MSVCVER
 !message *** ERROR
@@ -366,11 +376,11 @@ MSVCVER = 9.0
 !message to handle the new value for _NMAKE_VER, "$(_NMAKE_VER)".
 !error Make aborted.
 !endif
 
 # Convert processor ID to MVC-compatible number
-!if ("$(MSVCVER)" != "8.0") && ("$(MSVCVER)" != "9.0")
+!if ("$(MSVCVER)" != "8.0") && ("$(MSVCVER)" != "9.0") && ("$(MSVCVER)" != "10.0")
 !if "$(CPUNR)" == "i386"
 CPUARG = /G3
 !elseif "$(CPUNR)" == "i486"
 CPUARG = /G4
 !elseif "$(CPUNR)" == "i586"
@@ -399,11 +409,11 @@ OPTFLAG = /O1
 !elseif "$(OPTIMIZE)" == "SPEED"
 OPTFLAG = /O2
 !else # MAXSPEED
 OPTFLAG = /Ox
 !endif
-!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0")
+!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0") || ("$(MSVCVER)" == "10.0")
 # Use link time code generation if not worried about size
 !if "$(OPTIMIZE)" != "SPACE"
 OPTFLAG = $(OPTFLAG) /GL
 !endif
 !endif
@@ -616,19 +626,41 @@ PYTHON_LIB = $(PYTHON)\libs\python$(PYTH
 !message MzScheme requested - root dir is "$(MZSCHEME)"
 !ifndef MZSCHEME_VER
 MZSCHEME_VER = 205_000
 !endif
 CFLAGS = $(CFLAGS) -DFEAT_MZSCHEME -I $(MZSCHEME)\include
+!if EXIST("$(MZSCHEME)\collects\scheme\base.ss")
+# for MzScheme 4.x we need to include byte code for basic Scheme stuff
+MZSCHEME_EXTRA_DEP = mzscheme_base.c
+CFLAGS = $(CFLAGS) -DINCLUDE_MZSCHEME_BASE
+!endif
+!if EXIST("$(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib") \
+	&& !EXIST("$(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib")
+!message Building with Precise GC
+MZSCHEME_PRECISE_GC = yes
+CFLAGS = $(CFLAGS) -DMZ_PRECISE_GC
+!endif
 !if "$(DYNAMIC_MZSCHEME)" == "yes"
+!if "$(MZSCHEME_PRECISE_GC)" == "yes"
+!error MzScheme with Precise GC cannot be loaded dynamically
+!endif
 !message MzScheme DLLs will be loaded dynamically
 CFLAGS = $(CFLAGS) -DDYNAMIC_MZSCHEME \
 		-DDYNAMIC_MZSCH_DLL=\"libmzsch$(MZSCHEME_VER).dll\" \
 		-DDYNAMIC_MZGC_DLL=\"libmzgc$(MZSCHEME_VER).dll\"
 !else
+!if "$(MZSCHEME_DEBUG)" == "yes"
+CFLAGS = $(CFLAGS) -DMZSCHEME_FORCE_GC
+!endif
+!if "$(MZSCHEME_PRECISE_GC)" == "yes"
+# Precise GC does not use separate dll
+MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib
+!else
 MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib \
 		$(MZSCHEME)\lib\msvc\libmzsch$(MZSCHEME_VER).lib
 !endif
+!endif
 MZSCHEME_OBJ = $(OUTDIR)\if_mzsch.obj
 !endif
 
 # Perl interface
 !ifdef PERL
@@ -765,11 +797,11 @@ LINKARGS2 = $(CON_LIB) $(GUI_LIB) $(LIBC
 		$(MZSCHEME_LIB) $(PERL_LIB) $(PYTHON_LIB) $(RUBY_LIB) \
 		$(TCL_LIB) $(NETBEANS_LIB) $(XPM_LIB) $(LINK_PDB)
 
 # Report link time code generation progress if used. 
 !ifdef NODEBUG
-!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0")
+!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0") || ("$(MSVCVER)" == "10.0")
 !if "$(OPTIMIZE)" != "SPACE"
 LINKARGS1 = $(LINKARGS1) /LTCG:STATUS
 !endif
 !endif
 !endif
@@ -834,10 +866,11 @@ clean:
 	- if exist if_perl.c del if_perl.c
 	- if exist dimm.h del dimm.h
 	- if exist dimm_i.c del dimm_i.c
 	- if exist dimm.tlb del dimm.tlb
 	- if exist dosinst.exe del dosinst.exe
+	- if exist mzscheme_base.c del mzscheme_base.c
 	cd xxd
 	$(MAKE) /NOLOGO -f Make_mvc.mak clean
 	cd ..
 	cd GvimExt
 	$(MAKE) /NOLOGO -f Makefile clean
@@ -925,13 +958,15 @@ $(OUTDIR)/if_perl.obj: $(OUTDIR) if_perl
 	$(CC) $(CFLAGS) $(PERL_INC) if_perl.c
 
 $(OUTDIR)/if_perlsfio.obj: $(OUTDIR) if_perlsfio.c  $(INCL)
 	$(CC) $(CFLAGS) $(PERL_INC) if_perlsfio.c
 
-$(OUTDIR)/if_mzsch.obj: $(OUTDIR) if_mzsch.c  $(INCL)
+$(OUTDIR)/if_mzsch.obj: $(OUTDIR) if_mzsch.c  $(INCL) $(MZSCHEME_EXTRA_DEP)
 	$(CC) $(CFLAGS) if_mzsch.c \
 		-DMZSCHEME_COLLECTS=\"$(MZSCHEME:\=\\)\\collects\"
+mzscheme_base.c:
+	$(MZSCHEME)\mzc --c-mods mzscheme_base.c ++lib scheme/base
 
 $(OUTDIR)/if_python.obj: $(OUTDIR) if_python.c  $(INCL)
 	$(CC) $(CFLAGS) $(PYTHON_INC) if_python.c
 
 $(OUTDIR)/if_ole.obj: $(OUTDIR) if_ole.cpp  $(INCL) if_ole.h
@@ -1007,11 +1042,11 @@ $(OUTDIR)/undo.obj:	$(OUTDIR) undo.c  $(
 $(OUTDIR)/window.obj:	$(OUTDIR) window.c  $(INCL)
 
 $(OUTDIR)/xpm_w32.obj: $(OUTDIR) xpm_w32.c
 	$(CC) $(CFLAGS) $(XPM_INC) xpm_w32.c
 
-$(OUTDIR)/vim.res:	$(OUTDIR) vim.rc version.h tools.bmp tearoff.bmp \
+$(OUTDIR)/vim.res:	$(OUTDIR) vim.rc gvim.exe.mnf version.h tools.bmp tearoff.bmp \
 		vim.ico vim_error.ico vim_alert.ico vim_info.ico vim_quest.ico
 	$(RC) /l 0x409 /Fo$(OUTDIR)/vim.res $(RCFLAGS) vim.rc
 
 iid_ole.c if_ole.h vim.tlb: if_ole.idl
 	midl /nologo /error none /proxy nul /iid iid_ole.c /tlb vim.tlb \
--- vim72.orig/src/Make_vms.mms
+++ vim72/src/Make_vms.mms
@@ -1,10 +1,10 @@
 #
 # Makefile for Vim on OpenVMS
 #
 # Maintainer:   Zoltan Arpadffy <arpadffy@polarhome.com>
-# Last change:  2007 Oct 22
+# Last change:  2008 Aug 16
 #
 # This has script been tested on VMS 6.2 to 8.2 on DEC Alpha, VAX and IA64
 # with MMS and MMK
 #
 # The following could be built:
@@ -34,11 +34,11 @@ DECC = YES
 # SMALL  - Few features enabled, as basic as possible
 # NORMAL - A default selection of features enabled
 # BIG    - Many features enabled, as rich as possible. (default)
 # HUGE   - All possible featues enabled.
 # Please select one of these alternatives above.
-MODEL = BIG
+MODEL = HUGE
 
 # GUI or terminal mode executable.
 # Comment out if you want just the character terminal mode only.
 # GUI with Motif
 GUI = YES
--- vim72.orig/src/Makefile
+++ vim72/src/Makefile
@@ -103,12 +103,12 @@
 #	  solution for a non-standard system.
 #
 # 4. "make test"  {{{1
 #	This is optional.  This will run Vim scripts on a number of test
 #	files, and compare the produced output with the expected output.
-#	If all is well, you will get the "ALL DONE" message in the end.  See
-#	below (search for "/^test").
+#	If all is well, you will get the "ALL DONE" message in the end.  If a
+#	test fails you get "TEST FAILURE".  See below (search for "/^test").
 #
 # 5. "make install"  {{{1
 #	If the new Vim seems to be working OK you can install it and the
 #	documentation in the appropriate location. The default is
 #	"/usr/local".  Change "prefix" below to change the location.
@@ -393,11 +393,13 @@ CClink = $(CC)
 #CONF_OPT_TCL = --enable-tclinterp
 #CONF_OPT_TCL = --enable-tclinterp --with-tclsh=tclsh8.4
 
 # RUBY
 # Uncomment this when you want to include the Ruby interface.
-#CONF_OPT_RUBY = --enable-rubyinterp
+# Note: you need the development package (e.g., ruby1.9.1-dev on Ubuntu).
+# CONF_OPT_RUBY = --enable-rubyinterp
+# CONF_OPT_RUBY = --enable-rubyinterp --with-ruby-command=ruby1.9.1
 
 # MZSCHEME
 # Uncomment this when you want to include the MzScheme interface.
 #CONF_OPT_MZSCHEME = --enable-mzschemeinterp
 # PLT/mrscheme/drscheme Home dir; the PLTHOME environment variable also works
@@ -531,10 +533,15 @@ CClink = $(CC)
 #CFLAGS = -g -Wall -Wmissing-prototypes
 #CFLAGS = -O6 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes
 #CFLAGS = -g -DDEBUG -Wall -Wshadow -Wmissing-prototypes
 #CFLAGS = -g -O2 '-DSTARTUPTIME="vimstartup"' -fno-strength-reduce -Wall -Wmissing-prototypes
 
+# Use this with GCC to check for mistakes, unused arguments, etc.
+#CFLAGS = -g -Wall -Wextra -Wmissing-prototypes -Wunreachable-code
+#PYTHON_CFLAGS_EXTRA = -Wno-missing-field-initializers
+#MZSCHEME_CFLAGS_EXTRA = -Wno-unreachable-code -Wno-unused-parameter
+
 # EFENCE - Electric-Fence malloc debugging: catches memory accesses beyond
 # allocated memory (and makes every malloc()/free() very slow).
 # Electric Fence is free (search ftp sites).
 # You may want to set the EF_PROTECT_BELOW environment variable to check the
 # other side of allocated memory.
@@ -549,11 +556,17 @@ CClink = $(CC)
 #EXTRA_DEFS = -DNBDEBUG
 
 # }}}
 
 # LINT - for running lint
+#  For standard Unix lint
+LINT = lint
 LINT_OPTIONS = -beprxzF
+#  For splint
+#  It doesn't work well, crashes on include files and non-ascii characters.
+#LINT = splint
+#LINT_OPTIONS = +unixlib -weak -macrovarprefixexclude -showfunc -linelen 9999
 
 # PROFILING - Uncomment the next two lines to do profiling with gcc and gprof.
 # Might not work with GUI or Perl.
 # For unknown reasons adding "-lc" fixes a linking problem with GCC.  That's
 # probably a bug in the "-pg" implementation.
@@ -1257,20 +1270,20 @@ CPP_DEPEND = $(CC) -I$(srcdir) -M$(CPP_M
 
 # flags for cproto
 #     This is for cproto 3 patchlevel 8 or below
 #     __inline, __attribute__ and __extension__ are not recognized by cproto
 #     G_IMPLEMENT_INLINES is to avoid functions defined in glib/gutils.h.
-NO_ATTR = -D__inline= -D__inline__= -DG_IMPLEMENT_INLINES \
-	  -D"__attribute__\\(x\\)=" -D"__asm__\\(x\\)=" \
-	  -D__extension__= -D__restrict="" \
-	  -D__gnuc_va_list=char -D__builtin_va_list=char
+#NO_ATTR = -D__inline= -D__inline__= -DG_IMPLEMENT_INLINES \
+#	  -D"__attribute__\\(x\\)=" -D"__asm__\\(x\\)=" \
+#	  -D__extension__= -D__restrict="" \
+#	  -D__gnuc_va_list=char -D__builtin_va_list=char
 
 #
-#     This is for cproto 3 patchlevel 9 or above (currently 4.6)
+#     This is for cproto 3 patchlevel 9 or above (currently 4.6, 4.7g)
 #     __inline and __attribute__ are now recognized by cproto
 #     -D"foo()=" is not supported by all compilers so do not use it
-# NO_ATTR=
+NO_ATTR=
 #
 #     maybe the "/usr/bin/cc -E" has to be adjusted for some systems
 # This is for cproto 3.5 patchlevel 3:
 # PROTO_FLAGS = -f4 -m__ARGS -d -E"$(CPP)" $(NO_ATTR)
 #
@@ -1430,10 +1443,11 @@ ALL_SRC = $(BASIC_SRC) $(ALL_GUI_SRC) $(
 # The perl sources also don't work well with lint.
 LINT_SRC = $(BASIC_SRC) $(GUI_SRC) $(HANGULIN_SRC) $(PYTHON_SRC) $(TCL_SRC) \
 	$(SNIFF_SRC) $(WORKSHOP_SRC) $(WSDEBUG_SRC) $(NETBEANS_SRC)
 #LINT_SRC = $(SRC)
 #LINT_SRC = $(ALL_SRC)
+#LINT_SRC = $(BASIC_SRC)
 
 OBJ = \
 	objects/buffer.o \
 	objects/charset.o \
 	objects/diff.o \
@@ -1735,11 +1749,12 @@ types.vim: $(TAGS_SRC) $(TAGS_INCL)
 #
 # This will produce a lot of garbage on your screen, including a few error
 # messages.  Don't worry about that.
 # If there is a real error, there will be a difference between "test.out" and
 # a "test99.ok" file.
-# If everything is alright, the final message will be "ALL DONE".
+# If everything is alright, the final message will be "ALL DONE".  If not you
+# get "TEST FAILURE".
 #
 test check:
 	$(MAKE) -f Makefile $(VIMTARGET)
 	-if test -n "$(MAKEMO)" -a -f $(PODIR)/Makefile; then \
 		cd $(PODIR); $(MAKE) -f Makefile check VIM=../$(VIMTARGET); \
@@ -2185,10 +2200,11 @@ uninstall_runtime:
 clean celan: testclean
 	-rm -f *.o objects/* core $(VIMTARGET).core $(VIMTARGET) vim xxd/*.o
 	-rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c
 	-rm -f conftest* *~ auto/link.sed
 	-rm -rf $(APPDIR)
+	-rm -rf mzscheme_base.c
 	if test -d $(PODIR); then \
 		cd $(PODIR); $(MAKE) prefix=$(DESTDIR)$(prefix) clean; \
 	fi
 
 # Make a shadow directory for compilation on another system or with different
@@ -2270,16 +2286,16 @@ depend:
 		sed -e 's+^\([^ ]*\.o\)+objects/\1+' >> tmp_make; done
 	mv tmp_make Makefile
 
 # Run lint.  Clean up the *.ln files that are sometimes left behind.
 lint:
-	lint $(LINT_OPTIONS) $(LINT_CFLAGS) $(LINT_EXTRA) $(LINT_SRC)
+	$(LINT) $(LINT_OPTIONS) $(LINT_CFLAGS) $(LINT_EXTRA) $(LINT_SRC)
 	-rm -f *.ln
 
 # Check dosinst.c with lint.
 lintinstall:
-	lint $(LINT_OPTIONS) -DWIN32 -DUNIX_LINT dosinst.c
+	$(LINT) $(LINT_OPTIONS) -DWIN32 -DUNIX_LINT dosinst.c
 	-rm -f dosinst.ln
 
 ###########################################################################
 
 .c.o:
@@ -2418,21 +2434,24 @@ objects/if_cscope.o: if_cscope.c
 	$(CCC) -o $@ if_cscope.c
 
 objects/if_xcmdsrv.o: if_xcmdsrv.c
 	$(CCC) -o $@ if_xcmdsrv.c
 
-objects/if_mzsch.o: if_mzsch.c
-	$(CCC) -o $@ if_mzsch.c
+objects/if_mzsch.o: if_mzsch.c $(MZSCHEME_EXTRA)
+	$(CCC) -o $@ $(MZSCHEME_CFLAGS_EXTRA) if_mzsch.c
+
+mzscheme_base.c:
+	$(MZSCHEME_MZC) --c-mods mzscheme_base.c ++lib scheme/base
 
 objects/if_perl.o: auto/if_perl.c
 	$(CCC) -o $@ auto/if_perl.c
 
 objects/if_perlsfio.o: if_perlsfio.c
 	$(CCC) -o $@ if_perlsfio.c
 
 objects/if_python.o: if_python.c
-	$(CCC) -o $@ if_python.c
+	$(CCC) -o $@ $(PYTHON_CFLAGS_EXTRA) if_python.c
 
 objects/if_ruby.o: if_ruby.c
 	$(CCC) -o $@ if_ruby.c
 
 objects/if_sniff.o: if_sniff.c
--- vim72.orig/src/VisVim/Commands.cpp
+++ vim72/src/VisVim/Commands.cpp
@@ -18,100 +18,103 @@ static char THIS_FILE[] = __FILE__;
 #define CD_NONE			2	// No cd
 
 
 static BOOL g_bEnableVim = TRUE;	// Vim enabled
 static BOOL g_bDevStudioEditor = FALSE;	// Open file in Dev Studio editor simultaneously
+static BOOL g_bNewTabs = FALSE;
 static int g_ChangeDir = CD_NONE;	// CD after file open?
 
-static void VimSetEnableState (BOOL bEnableState);
-static BOOL VimOpenFile (BSTR& FileName, long LineNr);
-static DISPID VimGetDispatchId (COleAutomationControl& VimOle, char* Method);
-static void VimErrDiag (COleAutomationControl& VimOle);
-static void VimChangeDir (COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName);
-static void DebugMsg (char* Msg, char* Arg = NULL);
+static void VimSetEnableState(BOOL bEnableState);
+static BOOL VimOpenFile(BSTR& FileName, long LineNr);
+static DISPID VimGetDispatchId(COleAutomationControl& VimOle, char* Method);
+static void VimErrDiag(COleAutomationControl& VimOle);
+static void VimChangeDir(COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName);
+static void DebugMsg(char* Msg, char* Arg = NULL);
 
 
 /////////////////////////////////////////////////////////////////////////////
 // CCommands
 
-CCommands::CCommands ()
+CCommands::CCommands()
 {
 	// m_pApplication == NULL; M$ Code generation bug!!!
 	m_pApplication = NULL;
 	m_pApplicationEventsObj = NULL;
 	m_pDebuggerEventsObj = NULL;
 }
 
-CCommands::~CCommands ()
+CCommands::~CCommands()
 {
-	ASSERT (m_pApplication != NULL);
+	ASSERT(m_pApplication != NULL);
 	if (m_pApplication)
 	{
-		m_pApplication->Release ();
+		m_pApplication->Release();
 		m_pApplication = NULL;
 	}
 }
 
-void CCommands::SetApplicationObject (IApplication * pApplication)
+void CCommands::SetApplicationObject(IApplication * pApplication)
 {
 	// This function assumes pApplication has already been AddRef'd
 	// for us, which CDSAddIn did in it's QueryInterface call
 	// just before it called us.
 	m_pApplication = pApplication;
 	if (! m_pApplication)
 		return;
 
 	// Create Application event handlers
-	XApplicationEventsObj::CreateInstance (&m_pApplicationEventsObj);
+	XApplicationEventsObj::CreateInstance(&m_pApplicationEventsObj);
 	if (! m_pApplicationEventsObj)
 	{
-		ReportInternalError ("XApplicationEventsObj::CreateInstance");
+		ReportInternalError("XApplicationEventsObj::CreateInstance");
 		return;
 	}
-	m_pApplicationEventsObj->AddRef ();
-	m_pApplicationEventsObj->Connect (m_pApplication);
+	m_pApplicationEventsObj->AddRef();
+	m_pApplicationEventsObj->Connect(m_pApplication);
 	m_pApplicationEventsObj->m_pCommands = this;
 
 #ifdef NEVER
 	// Create Debugger event handler
 	CComPtr < IDispatch > pDebugger;
-	if (SUCCEEDED (m_pApplication->get_Debugger (&pDebugger))
+	if (SUCCEEDED(m_pApplication->get_Debugger(&pDebugger))
 	    && pDebugger != NULL)
 	{
-		XDebuggerEventsObj::CreateInstance (&m_pDebuggerEventsObj);
-		m_pDebuggerEventsObj->AddRef ();
-		m_pDebuggerEventsObj->Connect (pDebugger);
+		XDebuggerEventsObj::CreateInstance(&m_pDebuggerEventsObj);
+		m_pDebuggerEventsObj->AddRef();
+		m_pDebuggerEventsObj->Connect(pDebugger);
 		m_pDebuggerEventsObj->m_pCommands = this;
 	}
 #endif
 
 	// Get settings from registry HKEY_CURRENT_USER\Software\Vim\VisVim
-	HKEY hAppKey = GetAppKey ("Vim");
+	HKEY hAppKey = GetAppKey("Vim");
 	if (hAppKey)
 	{
-		HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim");
+		HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim");
 		if (hSectionKey)
 		{
-			g_bEnableVim = GetRegistryInt (hSectionKey, "EnableVim",
+			g_bEnableVim = GetRegistryInt(hSectionKey, "EnableVim",
 						       g_bEnableVim);
-			g_bDevStudioEditor = GetRegistryInt(hSectionKey,"DevStudioEditor",
-							    g_bDevStudioEditor);
-			g_ChangeDir = GetRegistryInt (hSectionKey, "ChangeDir",
+			g_bDevStudioEditor = GetRegistryInt(hSectionKey,
+					"DevStudioEditor", g_bDevStudioEditor);
+			g_bNewTabs = GetRegistryInt(hSectionKey, "NewTabs",
+						    g_bNewTabs);
+			g_ChangeDir = GetRegistryInt(hSectionKey, "ChangeDir",
 						      g_ChangeDir);
-			RegCloseKey (hSectionKey);
+			RegCloseKey(hSectionKey);
 		}
-		RegCloseKey (hAppKey);
+		RegCloseKey(hAppKey);
 	}
 }
 
-void CCommands::UnadviseFromEvents ()
+void CCommands::UnadviseFromEvents()
 {
-	ASSERT (m_pApplicationEventsObj != NULL);
+	ASSERT(m_pApplicationEventsObj != NULL);
 	if (m_pApplicationEventsObj)
 	{
-		m_pApplicationEventsObj->Disconnect (m_pApplication);
-		m_pApplicationEventsObj->Release ();
+		m_pApplicationEventsObj->Disconnect(m_pApplication);
+		m_pApplicationEventsObj->Release();
 		m_pApplicationEventsObj = NULL;
 	}
 
 #ifdef NEVER
 	if (m_pDebuggerEventsObj)
@@ -119,14 +122,14 @@ void CCommands::UnadviseFromEvents ()
 		// Since we were able to connect to the Debugger events, we
 		// should be able to access the Debugger object again to
 		// unadvise from its events (thus the VERIFY_OK below--see
 		// stdafx.h).
 		CComPtr < IDispatch > pDebugger;
-		VERIFY_OK (m_pApplication->get_Debugger (&pDebugger));
-		ASSERT (pDebugger != NULL);
-		m_pDebuggerEventsObj->Disconnect (pDebugger);
-		m_pDebuggerEventsObj->Release ();
+		VERIFY_OK(m_pApplication->get_Debugger(&pDebugger));
+		ASSERT(pDebugger != NULL);
+		m_pDebuggerEventsObj->Disconnect(pDebugger);
+		m_pDebuggerEventsObj->Release();
 		m_pDebuggerEventsObj = NULL;
 	}
 #endif
 }
 
@@ -134,365 +137,372 @@ void CCommands::UnadviseFromEvents ()
 /////////////////////////////////////////////////////////////////////////////
 // Event handlers
 
 // Application events
 
-HRESULT CCommands::XApplicationEvents::BeforeBuildStart ()
+HRESULT CCommands::XApplicationEvents::BeforeBuildStart()
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
-HRESULT CCommands::XApplicationEvents::BuildFinish (long nNumErrors, long nNumWarnings)
+HRESULT CCommands::XApplicationEvents::BuildFinish(long nNumErrors, long nNumWarnings)
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
-HRESULT CCommands::XApplicationEvents::BeforeApplicationShutDown ()
+HRESULT CCommands::XApplicationEvents::BeforeApplicationShutDown()
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
 // The open document event handle is the place where the real interface work
 // is done.
 // Vim gets called from here.
 //
-HRESULT CCommands::XApplicationEvents::DocumentOpen (IDispatch * theDocument)
+HRESULT CCommands::XApplicationEvents::DocumentOpen(IDispatch * theDocument)
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 
 	if (! g_bEnableVim)
 		// Vim not enabled or empty command line entered
 		return S_OK;
 
 	// First get the current file name and line number
 
 	// Get the document object
-	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument);
+	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(theDocument);
 	if (! pDoc)
 		return S_OK;
 
 	BSTR FileName;
 	long LineNr = -1;
 
 	// Get the document name
-	if (FAILED (pDoc->get_FullName (&FileName)))
+	if (FAILED(pDoc->get_FullName(&FileName)))
 		return S_OK;
 
 	LPDISPATCH pDispSel;
 
 	// Get a selection object dispatch pointer
-	if (SUCCEEDED (pDoc->get_Selection (&pDispSel)))
+	if (SUCCEEDED(pDoc->get_Selection(&pDispSel)))
 	{
 		// Get the selection object
-		CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel);
+		CComQIPtr < ITextSelection, &IID_ITextSelection > pSel(pDispSel);
 
 		if (pSel)
 			// Get the selection line number
-			pSel->get_CurrentLine (&LineNr);
+			pSel->get_CurrentLine(&LineNr);
 
-		pDispSel->Release ();
+		pDispSel->Release();
 	}
 
 	// Open the file in Vim and position to the current line
-	if (VimOpenFile (FileName, LineNr))
+	if (VimOpenFile(FileName, LineNr))
 	{
 		if (! g_bDevStudioEditor)
 		{
 			// Close the document in developer studio
 			CComVariant vSaveChanges = dsSaveChangesPrompt;
 			DsSaveStatus Saved;
 
-			pDoc->Close (vSaveChanges, &Saved);
+			pDoc->Close(vSaveChanges, &Saved);
 		}
 	}
 
 	// We're done here
-	SysFreeString (FileName);
+	SysFreeString(FileName);
 	return S_OK;
 }
 
-HRESULT CCommands::XApplicationEvents::BeforeDocumentClose (IDispatch * theDocument)
+HRESULT CCommands::XApplicationEvents::BeforeDocumentClose(IDispatch * theDocument)
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
-HRESULT CCommands::XApplicationEvents::DocumentSave (IDispatch * theDocument)
+HRESULT CCommands::XApplicationEvents::DocumentSave(IDispatch * theDocument)
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
-HRESULT CCommands::XApplicationEvents::NewDocument (IDispatch * theDocument)
+HRESULT CCommands::XApplicationEvents::NewDocument(IDispatch * theDocument)
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 
 	if (! g_bEnableVim)
 		// Vim not enabled or empty command line entered
 		return S_OK;
 
 	// First get the current file name and line number
 
-	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (theDocument);
+	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(theDocument);
 	if (! pDoc)
 		return S_OK;
 
 	BSTR FileName;
 	HRESULT hr;
 
-	hr = pDoc->get_FullName (&FileName);
-	if (FAILED (hr))
+	hr = pDoc->get_FullName(&FileName);
+	if (FAILED(hr))
 		return S_OK;
 
 	// Open the file in Vim and position to the current line
-	if (VimOpenFile (FileName, 0))
+	if (VimOpenFile(FileName, 0))
 	{
 		if (! g_bDevStudioEditor)
 		{
 			// Close the document in developer studio
 			CComVariant vSaveChanges = dsSaveChangesPrompt;
 			DsSaveStatus Saved;
 
-			pDoc->Close (vSaveChanges, &Saved);
+			pDoc->Close(vSaveChanges, &Saved);
 		}
 	}
 
-	SysFreeString (FileName);
+	SysFreeString(FileName);
 	return S_OK;
 }
 
-HRESULT CCommands::XApplicationEvents::WindowActivate (IDispatch * theWindow)
+HRESULT CCommands::XApplicationEvents::WindowActivate(IDispatch * theWindow)
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
-HRESULT CCommands::XApplicationEvents::WindowDeactivate (IDispatch * theWindow)
+HRESULT CCommands::XApplicationEvents::WindowDeactivate(IDispatch * theWindow)
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
-HRESULT CCommands::XApplicationEvents::WorkspaceOpen ()
+HRESULT CCommands::XApplicationEvents::WorkspaceOpen()
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
-HRESULT CCommands::XApplicationEvents::WorkspaceClose ()
+HRESULT CCommands::XApplicationEvents::WorkspaceClose()
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
-HRESULT CCommands::XApplicationEvents::NewWorkspace ()
+HRESULT CCommands::XApplicationEvents::NewWorkspace()
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
 // Debugger event
 
-HRESULT CCommands::XDebuggerEvents::BreakpointHit (IDispatch * pBreakpoint)
+HRESULT CCommands::XDebuggerEvents::BreakpointHit(IDispatch * pBreakpoint)
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 	return S_OK;
 }
 
 
 /////////////////////////////////////////////////////////////////////////////
 // VisVim dialog
 
 class CMainDialog : public CDialog
 {
     public:
-	CMainDialog (CWnd * pParent = NULL);	// Standard constructor
+	CMainDialog(CWnd * pParent = NULL);	// Standard constructor
 
 	//{{AFX_DATA(CMainDialog)
 	enum { IDD = IDD_ADDINMAIN };
 	int	m_ChangeDir;
 	BOOL	m_bDevStudioEditor;
+	BOOL	m_bNewTabs;
 	//}}AFX_DATA
 
 	//{{AFX_VIRTUAL(CMainDialog)
     protected:
-	virtual void DoDataExchange (CDataExchange * pDX);	// DDX/DDV support
+	virtual void DoDataExchange(CDataExchange * pDX);	// DDX/DDV support
 	//}}AFX_VIRTUAL
 
     protected:
 	//{{AFX_MSG(CMainDialog)
 	afx_msg void OnEnable();
 	afx_msg void OnDisable();
 	//}}AFX_MSG
-	DECLARE_MESSAGE_MAP ()
+	DECLARE_MESSAGE_MAP()
 };
 
-CMainDialog::CMainDialog (CWnd * pParent /* =NULL */ )
-	: CDialog (CMainDialog::IDD, pParent)
+CMainDialog::CMainDialog(CWnd * pParent /* =NULL */ )
+	: CDialog(CMainDialog::IDD, pParent)
 {
 	//{{AFX_DATA_INIT(CMainDialog)
 	m_ChangeDir = -1;
 	m_bDevStudioEditor = FALSE;
+	m_bNewTabs = FALSE;
 	//}}AFX_DATA_INIT
 }
 
-void CMainDialog::DoDataExchange (CDataExchange * pDX)
+void CMainDialog::DoDataExchange(CDataExchange * pDX)
 {
-	CDialog::DoDataExchange (pDX);
+	CDialog::DoDataExchange(pDX);
 	//{{AFX_DATA_MAP(CMainDialog)
 	DDX_Radio(pDX, IDC_CD_SOURCE_PATH, m_ChangeDir);
-	DDX_Check (pDX, IDC_DEVSTUDIO_EDITOR, m_bDevStudioEditor);
+	DDX_Check(pDX, IDC_DEVSTUDIO_EDITOR, m_bDevStudioEditor);
+	DDX_Check(pDX, IDC_NEW_TABS, m_bNewTabs);
 	//}}AFX_DATA_MAP
 }
 
-BEGIN_MESSAGE_MAP (CMainDialog, CDialog)
+BEGIN_MESSAGE_MAP(CMainDialog, CDialog)
 	//{{AFX_MSG_MAP(CMainDialog)
 	//}}AFX_MSG_MAP
-END_MESSAGE_MAP ()
+END_MESSAGE_MAP()
 
 
 /////////////////////////////////////////////////////////////////////////////
 // CCommands methods
 
-STDMETHODIMP CCommands::VisVimDialog ()
+STDMETHODIMP CCommands::VisVimDialog()
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 
 	// Use m_pApplication to access the Developer Studio Application
 	// object,
 	// and VERIFY_OK to see error strings in DEBUG builds of your add-in
 	// (see stdafx.h)
 
-	VERIFY_OK (m_pApplication->EnableModeless (VARIANT_FALSE));
+	VERIFY_OK(m_pApplication->EnableModeless(VARIANT_FALSE));
 
 	CMainDialog Dlg;
 
 	Dlg.m_bDevStudioEditor = g_bDevStudioEditor;
+	Dlg.m_bNewTabs = g_bNewTabs;
 	Dlg.m_ChangeDir = g_ChangeDir;
-	if (Dlg.DoModal () == IDOK)
+	if (Dlg.DoModal() == IDOK)
 	{
 		g_bDevStudioEditor = Dlg.m_bDevStudioEditor;
+		g_bNewTabs = Dlg.m_bNewTabs;
 		g_ChangeDir = Dlg.m_ChangeDir;
 
 		// Save settings to registry HKEY_CURRENT_USER\Software\Vim\VisVim
-		HKEY hAppKey = GetAppKey ("Vim");
+		HKEY hAppKey = GetAppKey("Vim");
 		if (hAppKey)
 		{
-			HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim");
+			HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim");
 			if (hSectionKey)
 			{
-				WriteRegistryInt (hSectionKey, "DevStudioEditor",
+				WriteRegistryInt(hSectionKey, "DevStudioEditor",
 						  g_bDevStudioEditor);
-				WriteRegistryInt (hSectionKey, "ChangeDir", g_ChangeDir);
-				RegCloseKey (hSectionKey);
+				WriteRegistryInt(hSectionKey, "NewTabs",
+						  g_bNewTabs);
+				WriteRegistryInt(hSectionKey, "ChangeDir", g_ChangeDir);
+				RegCloseKey(hSectionKey);
 			}
-			RegCloseKey (hAppKey);
+			RegCloseKey(hAppKey);
 		}
 	}
 
-	VERIFY_OK (m_pApplication->EnableModeless (VARIANT_TRUE));
+	VERIFY_OK(m_pApplication->EnableModeless(VARIANT_TRUE));
 	return S_OK;
 }
 
-STDMETHODIMP CCommands::VisVimEnable ()
+STDMETHODIMP CCommands::VisVimEnable()
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
-	VimSetEnableState (true);
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
+	VimSetEnableState(true);
 	return S_OK;
 }
 
-STDMETHODIMP CCommands::VisVimDisable ()
+STDMETHODIMP CCommands::VisVimDisable()
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
-	VimSetEnableState (false);
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
+	VimSetEnableState(false);
 	return S_OK;
 }
 
-STDMETHODIMP CCommands::VisVimToggle ()
+STDMETHODIMP CCommands::VisVimToggle()
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
-	VimSetEnableState (! g_bEnableVim);
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
+	VimSetEnableState(! g_bEnableVim);
 	return S_OK;
 }
 
-STDMETHODIMP CCommands::VisVimLoad ()
+STDMETHODIMP CCommands::VisVimLoad()
 {
-	AFX_MANAGE_STATE (AfxGetStaticModuleState ());
+	AFX_MANAGE_STATE(AfxGetStaticModuleState());
 
 	// Use m_pApplication to access the Developer Studio Application object,
 	// and VERIFY_OK to see error strings in DEBUG builds of your add-in
 	// (see stdafx.h)
 
 	CComBSTR bStr;
 	// Define dispatch pointers for document and selection objects
 	CComPtr < IDispatch > pDispDoc, pDispSel;
 
 	// Get a document object dispatch pointer
-	VERIFY_OK (m_pApplication->get_ActiveDocument (&pDispDoc));
+	VERIFY_OK(m_pApplication->get_ActiveDocument(&pDispDoc));
 	if (! pDispDoc)
 		return S_OK;
 
 	BSTR FileName;
 	long LineNr = -1;
 
 	// Get the document object
-	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc (pDispDoc);
+	CComQIPtr < ITextDocument, &IID_ITextDocument > pDoc(pDispDoc);
 
 	if (! pDoc)
 		return S_OK;
 
 	// Get the document name
-	if (FAILED (pDoc->get_FullName (&FileName)))
+	if (FAILED(pDoc->get_FullName(&FileName)))
 		return S_OK;
 
 	// Get a selection object dispatch pointer
-	if (SUCCEEDED (pDoc->get_Selection (&pDispSel)))
+	if (SUCCEEDED(pDoc->get_Selection(&pDispSel)))
 	{
 		// Get the selection object
-		CComQIPtr < ITextSelection, &IID_ITextSelection > pSel (pDispSel);
+		CComQIPtr < ITextSelection, &IID_ITextSelection > pSel(pDispSel);
 
 		if (pSel)
 			// Get the selection line number
-			pSel->get_CurrentLine (&LineNr);
+			pSel->get_CurrentLine(&LineNr);
 	}
 
 	// Open the file in Vim
-	VimOpenFile (FileName, LineNr);
+	VimOpenFile(FileName, LineNr);
 
-	SysFreeString (FileName);
+	SysFreeString(FileName);
 	return S_OK;
 }
 
 
 //
 // Here we do the actual processing and communication with Vim
 //
 
 // Set the enable state and save to registry
 //
-static void VimSetEnableState (BOOL bEnableState)
+static void VimSetEnableState(BOOL bEnableState)
 {
 	g_bEnableVim = bEnableState;
-	HKEY hAppKey = GetAppKey ("Vim");
+	HKEY hAppKey = GetAppKey("Vim");
 	if (hAppKey)
 	{
-		HKEY hSectionKey = GetSectionKey (hAppKey, "VisVim");
+		HKEY hSectionKey = GetSectionKey(hAppKey, "VisVim");
 		if (hSectionKey)
-			WriteRegistryInt (hSectionKey, "EnableVim", g_bEnableVim);
-		RegCloseKey (hAppKey);
+			WriteRegistryInt(hSectionKey, "EnableVim", g_bEnableVim);
+		RegCloseKey(hAppKey);
 	}
 }
 
 // Open the file 'FileName' in Vim and goto line 'LineNr'
 // 'FileName' is expected to contain an absolute DOS path including the drive
 // letter.
 // 'LineNr' must contain a valid line number or 0, e. g. for a new file
 //
-static BOOL VimOpenFile (BSTR& FileName, long LineNr)
+static BOOL VimOpenFile(BSTR& FileName, long LineNr)
 {
 
 	// OLE automation object for com. with Vim
 	// When the object goes out of scope, it's destructor destroys the OLE
 	// connection;
@@ -505,11 +515,11 @@ static BOOL VimOpenFile (BSTR& FileName,
 	// :cd D:/Src2/VisVim/
 	//
 	// Get a dispatch id for the SendKeys method of Vim;
 	// enables connection to Vim if necessary
 	DISPID DispatchId;
-	DispatchId = VimGetDispatchId (VimOle, "SendKeys");
+	DispatchId = VimGetDispatchId(VimOle, "SendKeys");
 	if (! DispatchId)
 		// OLE error, can't obtain dispatch id
 		goto OleError;
 
 	OLECHAR Buf[MAX_OLE_STR];
@@ -523,24 +533,32 @@ static BOOL VimOpenFile (BSTR& FileName,
 	VimCmd[2] = 0;
 
 #ifdef SINGLE_WINDOW
 	// Update the current file in Vim if it has been modified.
 	// Disabled, because it could write the file when you don't want to.
-	sprintf (VimCmd + 2, ":up\n");
+	sprintf(VimCmd + 2, ":up\n");
 #endif
-	if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
+	if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf)))
 		goto OleError;
 
 	// Change Vim working directory to where the file is if desired
 	if (g_ChangeDir != CD_NONE)
-		VimChangeDir (VimOle, DispatchId, FileName);
+		VimChangeDir(VimOle, DispatchId, FileName);
 
 	// Make Vim open the file.
 	// In the filename convert all \ to /, put a \ before a space.
-	sprintf(VimCmd, ":drop ");
+	if (g_bNewTabs)
+	{
+		sprintf(VimCmd, ":tab drop ");
+		s = VimCmd + 11;
+	}
+	else
+	{
+		sprintf(VimCmd, ":drop ");
+		s = VimCmd + 6;
+	}
 	sprintf(FileNameTmp, "%S", (char *)FileName);
-	s = VimCmd + 6;
 	for (p = FileNameTmp; *p != '\0' && s < FileNameTmp + MAX_OLE_STR - 4;
 									  ++p)
 		if (*p == '\\')
 			*s++ = '/';
 		else
@@ -550,51 +568,51 @@ static BOOL VimOpenFile (BSTR& FileName,
 			*s++ = *p;
 		}
 	*s++ = '\n';
 	*s = '\0';
 
-	if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
+	if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf)))
 		goto OleError;
 
 	if (LineNr > 0)
 	{
 		// Goto line
-		sprintf (VimCmd, ":%d\n", LineNr);
-		if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
+		sprintf(VimCmd, ":%d\n", LineNr);
+		if (! VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf)))
 			goto OleError;
 	}
 
 	// Make Vim come to the foreground
-	if (! VimOle.Method ("SetForeground"))
-		VimOle.ErrDiag ();
+	if (! VimOle.Method("SetForeground"))
+		VimOle.ErrDiag();
 
 	// We're done
 	return true;
 
     OleError:
 	// There was an OLE error
 	// Check if it's the "unknown class string" error
-	VimErrDiag (VimOle);
+	VimErrDiag(VimOle);
 	return false;
 }
 
 // Return the dispatch id for the Vim method 'Method'
 // Create the Vim OLE object if necessary
 // Returns a valid dispatch id or null on error
 //
-static DISPID VimGetDispatchId (COleAutomationControl& VimOle, char* Method)
+static DISPID VimGetDispatchId(COleAutomationControl& VimOle, char* Method)
 {
 	// Initialize Vim OLE connection if not already done
-	if (! VimOle.IsCreated ())
+	if (! VimOle.IsCreated())
 	{
-		if (! VimOle.CreateObject ("Vim.Application"))
+		if (! VimOle.CreateObject("Vim.Application"))
 			return NULL;
 	}
 
 	// Get the dispatch id for the SendKeys method.
 	// By doing this, we are checking if Vim is still there...
-	DISPID DispatchId = VimOle.GetDispatchId ("SendKeys");
+	DISPID DispatchId = VimOle.GetDispatchId("SendKeys");
 	if (! DispatchId)
 	{
 		// We can't get a dispatch id.
 		// This means that probably Vim has been terminated.
 		// Don't issue an error message here, instead
@@ -602,62 +620,62 @@ static DISPID VimGetDispatchId (COleAuto
 		//
 		// In fact, this should never happen, because the OLE aut. object
 		// should not be kept long enough to allow the user to terminate Vim
 		// to avoid memory corruption (why the heck is there no system garbage
 		// collection for those damned OLE memory chunks???).
-		VimOle.DeleteObject ();
-		if (! VimOle.CreateObject ("Vim.Application"))
+		VimOle.DeleteObject();
+		if (! VimOle.CreateObject("Vim.Application"))
 			// If this create fails, it's time for an error msg
 			return NULL;
 
-		if (! (DispatchId = VimOle.GetDispatchId ("SendKeys")))
+		if (! (DispatchId = VimOle.GetDispatchId("SendKeys")))
 			// There is something wrong...
 			return NULL;
 	}
 
 	return DispatchId;
 }
 
 // Output an error message for an OLE error
 // Check on the classstring error, which probably means Vim wasn't registered.
 //
-static void VimErrDiag (COleAutomationControl& VimOle)
+static void VimErrDiag(COleAutomationControl& VimOle)
 {
-	SCODE sc = GetScode (VimOle.GetResult ());
+	SCODE sc = GetScode(VimOle.GetResult());
 	if (sc == CO_E_CLASSSTRING)
 	{
 		char Buf[256];
-		sprintf (Buf, "There is no registered OLE automation server named "
+		sprintf(Buf, "There is no registered OLE automation server named "
 			 "\"Vim.Application\".\n"
 			 "Use the OLE-enabled version of Vim with VisVim and "
 			 "make sure to register Vim by running \"vim -register\".");
-		MessageBox (NULL, Buf, "OLE Error", MB_OK);
+		MessageBox(NULL, Buf, "OLE Error", MB_OK);
 	}
 	else
-		VimOle.ErrDiag ();
+		VimOle.ErrDiag();
 }
 
 // Change directory to the directory the file 'FileName' is in or it's parent
 // directory according to the setting of the global 'g_ChangeDir':
 // 'FileName' is expected to contain an absolute DOS path including the drive
 // letter.
 //	CD_NONE
 //	CD_SOURCE_PATH
 //	CD_SOURCE_PARENT
 //
-static void VimChangeDir (COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName)
+static void VimChangeDir(COleAutomationControl& VimOle, DISPID DispatchId, BSTR& FileName)
 {
 	// Do a :cd first
 
 	// Get the path name of the file ("dir/")
 	CString StrFileName = FileName;
 	char Drive[_MAX_DRIVE];
 	char Dir[_MAX_DIR];
 	char DirUnix[_MAX_DIR * 2];
 	char *s, *t;
 
-	_splitpath (StrFileName, Drive, Dir, NULL, NULL);
+	_splitpath(StrFileName, Drive, Dir, NULL, NULL);
 
 	// Convert to Unix path name format, escape spaces.
 	t = DirUnix;
 	for (s = Dir; *s; ++s)
 		if (*s == '\\')
@@ -674,21 +692,20 @@ static void VimChangeDir (COleAutomation
 	// Construct the cd command; append /.. if cd to parent
 	// directory and not in root directory
 	OLECHAR Buf[MAX_OLE_STR];
 	char VimCmd[MAX_OLE_STR];
 
-	sprintf (VimCmd, ":cd %s%s%s\n", Drive, DirUnix,
+	sprintf(VimCmd, ":cd %s%s%s\n", Drive, DirUnix,
 		 g_ChangeDir == CD_SOURCE_PARENT && DirUnix[1] ? ".." : "");
-	VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf));
+	VimOle.Method(DispatchId, "s", TO_OLE_STR_BUF(VimCmd, Buf));
 }
 
 #ifdef _DEBUG
 // Print out a debug message
 //
-static void DebugMsg (char* Msg, char* Arg)
+static void DebugMsg(char* Msg, char* Arg)
 {
 	char Buf[400];
-	sprintf (Buf, Msg, Arg);
-	AfxMessageBox (Buf);
+	sprintf(Buf, Msg, Arg);
+	AfxMessageBox(Buf);
 }
 #endif
-
--- vim72.orig/src/VisVim/Resource.h
+++ vim72/src/VisVim/Resource.h
@@ -14,10 +14,11 @@
 #define IDD_ADDINMAIN			130
 #define IDC_DEVSTUDIO_EDITOR		1000
 #define IDC_CD_SOURCE_PATH		1001
 #define IDC_CD_SOURCE_PARENT		1002
 #define IDC_CD_NONE			1003
+#define IDC_NEW_TABS			1004
 
 // Next default values for new objects
 //
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
--- vim72.orig/src/VisVim/VisVim.rc
+++ vim72/src/VisVim/VisVim.rc
@@ -120,10 +120,13 @@ CAPTION "Vim Add-In 1.4"
 FONT 8, "MS Sans Serif"
 BEGIN
     CONTROL         "&Open file in DevStudio editor simultaneously",
                     IDC_DEVSTUDIO_EDITOR,"Button",BS_AUTOCHECKBOX | WS_GROUP | 
                     WS_TABSTOP,7,7,153,10
+    CONTROL         "Open files in new tabs",
+                    IDC_NEW_TABS,"Button",BS_AUTOCHECKBOX | WS_GROUP |
+                    WS_TABSTOP,7,21,153,10
     GROUPBOX        "Current directory",IDC_STATIC,7,35,164,58,WS_GROUP
     CONTROL         "Set to &source file path",IDC_CD_SOURCE_PATH,"Button",
                     BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,17,49,85,10
     CONTROL         "Set to &parent directory of source file path",
                     IDC_CD_SOURCE_PARENT,"Button",BS_AUTORADIOBUTTON,17,63,
--- vim72.orig/src/auto/configure
+++ vim72/src/auto/configure
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.62.
+# Generated by GNU Autoconf 2.63.
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
 # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
@@ -633,147 +633,151 @@ ac_includes_default="\
 #endif
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL
-PATH_SEPARATOR
-PACKAGE_NAME
-PACKAGE_TARNAME
-PACKAGE_VERSION
-PACKAGE_STRING
-PACKAGE_BUGREPORT
-exec_prefix
-prefix
-program_transform_name
-bindir
-sbindir
-libexecdir
-datarootdir
-datadir
-sysconfdir
-sharedstatedir
-localstatedir
-includedir
-oldincludedir
-docdir
-infodir
-htmldir
-dvidir
-pdfdir
-psdir
-libdir
-localedir
-mandir
-DEFS
-ECHO_C
-ECHO_N
-ECHO_T
-LIBS
-build_alias
-host_alias
-target_alias
-SET_MAKE
-CC
-CFLAGS
-LDFLAGS
-CPPFLAGS
-ac_ct_CC
-EXEEXT
-OBJEXT
-CPP
-GREP
-EGREP
-AWK
-STRIP
-CPP_MM
-OS_EXTRA_SRC
-OS_EXTRA_OBJ
-VIMNAME
-EXNAME
-VIEWNAME
-line_break
-dovimdiff
-dogvimdiff
-compiledby
-vi_cv_path_mzscheme
-MZSCHEME_SRC
-MZSCHEME_OBJ
-MZSCHEME_PRO
-MZSCHEME_LIBS
-MZSCHEME_CFLAGS
-vi_cv_path_perl
-vi_cv_perllib
-shrpenv
-PERL_SRC
-PERL_OBJ
-PERL_PRO
-PERL_CFLAGS
-PERL_LIBS
-vi_cv_path_python
-PYTHON_CONFDIR
-PYTHON_LIBS
-PYTHON_GETPATH_CFLAGS
-PYTHON_CFLAGS
-PYTHON_SRC
-PYTHON_OBJ
-vi_cv_path_tcl
-TCL_SRC
-TCL_OBJ
-TCL_PRO
-TCL_CFLAGS
-TCL_LIBS
-vi_cv_path_ruby
-RUBY_SRC
-RUBY_OBJ
-RUBY_PRO
-RUBY_CFLAGS
-RUBY_LIBS
-WORKSHOP_SRC
-WORKSHOP_OBJ
-NETBEANS_SRC
-NETBEANS_OBJ
-SNIFF_SRC
-SNIFF_OBJ
-xmkmfpath
-XMKMF
-X_CFLAGS
-X_PRE_LIBS
-X_LIBS
-X_EXTRA_LIBS
-X_LIB
-GTK_CONFIG
-GTK12_CONFIG
-PKG_CONFIG
-GTK_CFLAGS
-GTK_LIBS
-GTK_LIBNAME
-GNOME_LIBS
-GNOME_LIBDIR
-GNOME_INCLUDEDIR
-GNOME_CONFIG
-MOTIF_LIBNAME
-NARROW_PROTO
-GUI_INC_LOC
-GUI_LIB_LOC
-GUITYPE
-GUI_X_LIBS
-HANGULIN_SRC
-HANGULIN_OBJ
-TAGPRG
-INSTALL_LANGS
-INSTALL_TOOL_LANGS
-MSGFMT
-MAKEMO
-DEPEND_CFLAGS_FILTER
+ac_subst_vars='LTLIBOBJS
 LIBOBJS
-LTLIBOBJS'
+DEPEND_CFLAGS_FILTER
+MAKEMO
+MSGFMT
+INSTALL_TOOL_LANGS
+INSTALL_LANGS
+TAGPRG
+HANGULIN_OBJ
+HANGULIN_SRC
+GUI_X_LIBS
+GUITYPE
+GUI_LIB_LOC
+GUI_INC_LOC
+NARROW_PROTO
+MOTIF_LIBNAME
+GNOME_CONFIG
+GNOME_INCLUDEDIR
+GNOME_LIBDIR
+GNOME_LIBS
+GTK_LIBNAME
+GTK_LIBS
+GTK_CFLAGS
+PKG_CONFIG
+GTK12_CONFIG
+GTK_CONFIG
+X_LIB
+X_EXTRA_LIBS
+X_LIBS
+X_PRE_LIBS
+X_CFLAGS
+XMKMF
+xmkmfpath
+SNIFF_OBJ
+SNIFF_SRC
+NETBEANS_OBJ
+NETBEANS_SRC
+WORKSHOP_OBJ
+WORKSHOP_SRC
+RUBY_LIBS
+RUBY_CFLAGS
+RUBY_PRO
+RUBY_OBJ
+RUBY_SRC
+vi_cv_path_ruby
+TCL_LIBS
+TCL_CFLAGS
+TCL_PRO
+TCL_OBJ
+TCL_SRC
+vi_cv_path_tcl
+PYTHON_OBJ
+PYTHON_SRC
+PYTHON_CFLAGS
+PYTHON_GETPATH_CFLAGS
+PYTHON_LIBS
+PYTHON_CONFDIR
+vi_cv_path_python
+PERL_LIBS
+PERL_CFLAGS
+PERL_PRO
+PERL_OBJ
+PERL_SRC
+shrpenv
+vi_cv_perllib
+vi_cv_path_perl
+MZSCHEME_MZC
+MZSCHEME_EXTRA
+MZSCHEME_CFLAGS
+MZSCHEME_LIBS
+MZSCHEME_PRO
+MZSCHEME_OBJ
+MZSCHEME_SRC
+vi_cv_path_mzscheme
+compiledby
+dogvimdiff
+dovimdiff
+line_break
+VIEWNAME
+EXNAME
+VIMNAME
+OS_EXTRA_OBJ
+OS_EXTRA_SRC
+XCODE_SELECT
+CPP_MM
+STRIP
+AWK
+EGREP
+GREP
+CPP
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+SET_MAKE
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
 enable_darwin
 with_mac_arch
+with_developer_dir
 with_local_dir
 with_vim_name
 with_ex_name
 with_view_name
 with_global_runtime
@@ -789,10 +793,11 @@ enable_perlinterp
 enable_pythoninterp
 with_python_config_dir
 enable_tclinterp
 with_tclsh
 enable_rubyinterp
+with_ruby_command
 enable_cscope
 enable_workshop
 enable_netbeans
 enable_sniff
 enable_multibyte
@@ -1251,13 +1256,13 @@ if test -n "$ac_prev"; then
 fi
 
 if test -n "$ac_unrecognized_opts"; then
   case $enable_option_checking in
     no) ;;
-    fatal) { $as_echo "$as_me: error: Unrecognized options: $ac_unrecognized_opts" >&2
+    fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
    { (exit 1); exit 1; }; } ;;
-    *)     $as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2 ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
   esac
 fi
 
 # Check all directory arguments for consistency.
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
@@ -1306,11 +1311,11 @@ test "$silent" = yes && exec 6>/dev/null
 
 
 ac_pwd=`pwd` && test -n "$ac_pwd" &&
 ac_ls_di=`ls -di .` &&
 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  { $as_echo "$as_me: error: Working directory cannot be determined" >&2
+  { $as_echo "$as_me: error: working directory cannot be determined" >&2
    { (exit 1); exit 1; }; }
 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
   { $as_echo "$as_me: error: pwd does not report name of working directory" >&2
    { (exit 1); exit 1; }; }
 
@@ -1487,10 +1492,11 @@ Optional Features:
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-mac-arch=ARCH    current, intel, ppc or both
+  --with-developer-dir=PATH    use PATH as location for Xcode developer tools
   --with-local-dir=PATH   search PATH instead of /usr/local for local libraries.
   --without-local-dir     do not search /usr/local for local libraries.
   --with-vim-name=NAME    what to call the Vim executable
   --with-ex-name=NAME     what to call the Ex executable
   --with-view-name=NAME   what to call the View executable
@@ -1499,10 +1505,11 @@ Optional Packages:
   --with-features=TYPE    tiny, small, normal, big or huge (default: normal)
   --with-compiledby=NAME  name to show in :version message
   --with-plthome=PLTHOME   Use PLTHOME.
   --with-python-config-dir=PATH  Python's config directory
   --with-tclsh=PATH       which tclsh to use (default: tclsh8.0)
+  --with-ruby-command=RUBY  name of the Ruby command (default: ruby)
   --with-x                use the X Window System
   --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)
   --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)
   --with-gnome-includes=DIR Specify location of GNOME headers
   --with-gnome-libs=DIR   Specify location of GNOME libs
@@ -1585,11 +1592,11 @@ fi
 
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
 configure
-generated by GNU Autoconf 2.62
+generated by GNU Autoconf 2.63
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
@@ -1599,11 +1606,11 @@ fi
 cat >auto/config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by $as_me, which was
-generated by GNU Autoconf 2.62.  Invocation command line was
+generated by GNU Autoconf 2.63.  Invocation command line was
 
   $ $0 $@
 
 _ACEOF
 exec 5>>auto/config.log
@@ -1722,12 +1729,12 @@ _ASBOX
   for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
     eval ac_val=\$$ac_var
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
-$as_echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
       BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
       *) $as_unset $ac_var ;;
@@ -1926,10 +1933,12 @@ $as_echo "$as_me:   current value: \`$ac
       *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
     esac
   fi
 done
 if $ac_cache_corrupted; then
+  { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
   { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
   { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
 $as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
    { (exit 1); exit 1; }; }
@@ -2082,16 +2091,12 @@ fi
   if test "x$ac_ct_CC" = x; then
     CC=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf@gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CC=$ac_ct_CC
   fi
 else
@@ -2286,30 +2291,28 @@ done
   if test "x$ac_ct_CC" = x; then
     CC=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
-{ $as_echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf@gnu.org." >&5
-$as_echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
-whose name does not start with the host triplet.  If you think this
-configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
     CC=$ac_ct_CC
   fi
 fi
 
 fi
 
 
-test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: no acceptable C compiler found in \$PATH
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 
 # Provide some information about the compiler.
 $as_echo "$as_me:$LINENO: checking for C compiler version" >&5
 set X $ac_compile
 ac_compiler=$2
@@ -2435,15 +2438,17 @@ fi
 $as_echo "$ac_file" >&6; }
 if test -z "$ac_file"; then
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 { { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: C compiler cannot create executables
 See \`config.log' for more details." >&2;}
-   { (exit 77); exit 77; }; }
+   { (exit 77); exit 77; }; }; }
 fi
 
 ac_exeext=$ac_cv_exeext
 
 # Check that the compiler produces executables we can run.  If not, either
@@ -2467,17 +2472,19 @@ $as_echo "$ac_try_echo") >&5
     cross_compiling=no
   else
     if test "$cross_compiling" = maybe; then
 	cross_compiling=yes
     else
-	{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
+	{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'.
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'.
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
     fi
   fi
 fi
 { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
@@ -2516,15 +2523,17 @@ for ac_file in conftest.exe conftest con
 	  break;;
     * ) break;;
   esac
 done
 else
-  { { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 fi
 
 rm -f conftest$ac_cv_exeext
 { $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
 $as_echo "$ac_cv_exeext" >&6; }
@@ -2574,15 +2583,17 @@ $as_echo "$ac_try_echo") >&5
 done
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 { { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: cannot compute suffix of object files: cannot compile
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 fi
 
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
@@ -3146,15 +3157,17 @@ done
 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
 rm -f conftest.err conftest.$ac_ext
 if $ac_preproc_ok; then
   :
 else
-  { { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
 See \`config.log' for more details." >&5
 $as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
 See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+   { (exit 1); exit 1; }; }; }
 fi
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3821,17 +3834,82 @@ else
   MACARCH="current"; { $as_echo "$as_me:$LINENO: result: defaulting to $MACARCH" >&5
 $as_echo "defaulting to $MACARCH" >&6; }
 fi
 
 
+  { $as_echo "$as_me:$LINENO: checking --with-developer-dir argument" >&5
+$as_echo_n "checking --with-developer-dir argument... " >&6; }
+
+# Check whether --with-developer-dir was given.
+if test "${with_developer_dir+set}" = set; then
+  withval=$with_developer_dir; DEVELOPER_DIR="$withval"; { $as_echo "$as_me:$LINENO: result: $DEVELOPER_DIR" >&5
+$as_echo "$DEVELOPER_DIR" >&6; }
+else
+  DEVELOPER_DIR=""; { $as_echo "$as_me:$LINENO: result: not present" >&5
+$as_echo "not present" >&6; }
+fi
+
+
+  if test "x$DEVELOPER_DIR" = "x"; then
+    # Extract the first word of "xcode-select", so it can be a program name with args.
+set dummy xcode-select; ac_word=$2
+{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_XCODE_SELECT+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  case $XCODE_SELECT in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_XCODE_SELECT="$XCODE_SELECT" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_XCODE_SELECT="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+XCODE_SELECT=$ac_cv_path_XCODE_SELECT
+if test -n "$XCODE_SELECT"; then
+  { $as_echo "$as_me:$LINENO: result: $XCODE_SELECT" >&5
+$as_echo "$XCODE_SELECT" >&6; }
+else
+  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    if test "x$XCODE_SELECT" != "x"; then
+      { $as_echo "$as_me:$LINENO: checking for developer dir using xcode-select" >&5
+$as_echo_n "checking for developer dir using xcode-select... " >&6; }
+      DEVELOPER_DIR=`$XCODE_SELECT -print-path`
+      { $as_echo "$as_me:$LINENO: result: $DEVELOPER_DIR" >&5
+$as_echo "$DEVELOPER_DIR" >&6; }
+    else
+      DEVELOPER_DIR=/Developer
+    fi
+  fi
+
   if test "x$MACARCH" = "xboth"; then
     { $as_echo "$as_me:$LINENO: checking for 10.4 universal SDK" >&5
 $as_echo_n "checking for 10.4 universal SDK... " >&6; }
                             save_cppflags="$CPPFLAGS"
     save_cflags="$CFLAGS"
     save_ldflags="$LDFLAGS"
-    CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
+    CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
     cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
@@ -3948,13 +4026,13 @@ rm -f core conftest.err conftest.$ac_obj
     MACOSX=yes
     OS_EXTRA_SRC="os_macosx.c os_mac_conv.c";
     OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
         CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX -no-cpp-precomp"
     if test "x$MACARCH" = "xboth"; then
-      CPPFLAGS="$CPPFLAGS -I/Developer/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
+      CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
     else
-      CPPFLAGS="$CPPFLAGS -I/Developer/Headers/FlatCarbon"
+      CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
     fi
 
                 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
 
 
@@ -4014,12 +4092,13 @@ rm -f core conftest.err conftest.$ac_obj
 fi
 ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -4152,11 +4231,11 @@ else
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_header_Carbon_Carbon_h" >&5
 $as_echo "$ac_cv_header_Carbon_Carbon_h" >&6; }
 
 fi
-if test $ac_cv_header_Carbon_Carbon_h = yes; then
+if test "x$ac_cv_header_Carbon_Carbon_h" = x""yes; then
   CARBON=yes
 fi
 
 
     if test "x$CARBON" = "xyes"; then
@@ -4482,11 +4561,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_selinux_is_selinux_enabled" >&5
 $as_echo "$ac_cv_lib_selinux_is_selinux_enabled" >&6; }
-if test $ac_cv_lib_selinux_is_selinux_enabled = yes; then
+if test "x$ac_cv_lib_selinux_is_selinux_enabled" = x""yes; then
   LIBS="$LIBS -lselinux"
 	   cat >>confdefs.h <<\_ACEOF
 #define HAVE_SELINUX 1
 _ACEOF
 
@@ -4632,12 +4711,12 @@ $as_echo_n "checking PLTHOME environment
     if test "X$PLTHOME" != "X"; then
 	{ $as_echo "$as_me:$LINENO: result: \"$PLTHOME\"" >&5
 $as_echo "\"$PLTHOME\"" >&6; }
 	vi_cv_path_mzscheme_pfx="$PLTHOME"
     else
-	{ $as_echo "$as_me:$LINENO: result: \"not set\"" >&5
-$as_echo "\"not set\"" >&6; }
+	{ $as_echo "$as_me:$LINENO: result: not set" >&5
+$as_echo "not set" >&6; }
 		# Extract the first word of "mzscheme", so it can be a program name with args.
 set dummy mzscheme; ac_word=$2
 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_path_vi_cv_path_mzscheme+set}" = set; then
@@ -4688,66 +4767,90 @@ fi
 	    	    { $as_echo "$as_me:$LINENO: checking MzScheme install prefix" >&5
 $as_echo_n "checking MzScheme install prefix... " >&6; }
 if test "${vi_cv_path_mzscheme_pfx+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
-   vi_cv_path_mzscheme_pfx=`
-	    ${vi_cv_path_mzscheme} -evm \
-	    "(display (simplify-path		\
+  	    	    echo "(display (simplify-path		\
 	       (build-path (call-with-values	\
 		(lambda () (split-path (find-system-path (quote exec-file)))) \
-		(lambda (base name must-be-dir?) base)) (quote up))))"`
+		(lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
+	    	     vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
+		sed -e 's+/$++'`
 fi
 { $as_echo "$as_me:$LINENO: result: $vi_cv_path_mzscheme_pfx" >&5
 $as_echo "$vi_cv_path_mzscheme_pfx" >&6; }
-	    	    vi_cv_path_mzscheme_pfx=`echo "$vi_cv_path_mzscheme_pfx" | sed 's+/$++'`
+	    rm -f mzdirs.scm
 	fi
     fi
   fi
 
   SCHEME_INC=
   if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
     { $as_echo "$as_me:$LINENO: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include" >&5
 $as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include... " >&6; }
     if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
-      { $as_echo "$as_me:$LINENO: result: \"yes\"" >&5
-$as_echo "\"yes\"" >&6; }
+      SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
+      { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
     else
-      { $as_echo "$as_me:$LINENO: result: \"no\"" >&5
-$as_echo "\"no\"" >&6; }
-      { $as_echo "$as_me:$LINENO: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/plt/include" >&5
-$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/plt/include... " >&6; }
+      { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+      { $as_echo "$as_me:$LINENO: checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt" >&5
+$as_echo_n "checking if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt... " >&6; }
       if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
-	{ $as_echo "$as_me:$LINENO: result: \"yes\"" >&5
-$as_echo "\"yes\"" >&6; }
-	SCHEME_INC=/plt
+	{ $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+	SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
       else
-	{ $as_echo "$as_me:$LINENO: result: \"no\"" >&5
-$as_echo "\"no\"" >&6; }
-	vi_cv_path_mzscheme_pfx=
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+	{ $as_echo "$as_me:$LINENO: checking if scheme.h can be found in /usr/include/plt/" >&5
+$as_echo_n "checking if scheme.h can be found in /usr/include/plt/... " >&6; }
+	if test -f /usr/include/plt/scheme.h; then
+	  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+	  SCHEME_INC=/usr/include/plt
+	else
+	  { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+	  vi_cv_path_mzscheme_pfx=
+	fi
       fi
     fi
   fi
 
   if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
     if test "x$MACOSX" = "xyes"; then
       MZSCHEME_LIBS="-framework PLT_MzScheme"
+    elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
+      MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
+      MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
     elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
       MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
     else
-      MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
+            if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then
+        MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m"
+	MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
+      else
+        MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
+      fi
       if test "$GCC" = yes; then
-			MZSCHEME_LIBS="$MZSCHEME_LIBS -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
+			MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
       elif test "`(uname) 2>/dev/null`" = SunOS &&
 			       uname -r | grep '^5' >/dev/null; then
-	MZSCHEME_LIBS="$MZSCHEME_LIBS -R ${vi_cv_path_mzscheme_pfx}/lib"
+	MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib"
       fi
     fi
     if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
       SCHEME_COLLECTS=lib/plt/
     fi
-    MZSCHEME_CFLAGS="-I${vi_cv_path_mzscheme_pfx}/include${SCHEME_INC}   \
+    if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
+            MZSCHEME_EXTRA="mzscheme_base.c"
+      MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
+      MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
+    fi
+    MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
       -DMZSCHEME_COLLECTS='\"${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects\"'"
     MZSCHEME_SRC="if_mzsch.c"
     MZSCHEME_OBJ="objects/if_mzsch.o"
     MZSCHEME_PRO="if_mzsch.pro"
     cat >>confdefs.h <<\_ACEOF
@@ -4758,10 +4861,12 @@ _ACEOF
 
 
 
 
 
+
+
 fi
 
 
 { $as_echo "$as_me:$LINENO: checking --enable-perlinterp argument" >&5
 $as_echo_n "checking --enable-perlinterp argument... " >&6; }
@@ -5089,11 +5194,11 @@ if test "${vi_cv_path_python_conf+set}"
   $as_echo_n "(cached) " >&6
 else
 
 	vi_cv_path_python_conf=
 	for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
-	  for subdir in lib share; do
+	  for subdir in lib64 lib share; do
 	    d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
 	    if test -d "$d" && test -f "$d/config.c"; then
 	      vi_cv_path_python_conf="$d"
 	    fi
 	  done
@@ -5666,13 +5771,25 @@ else
 fi
 
 { $as_echo "$as_me:$LINENO: result: $enable_rubyinterp" >&5
 $as_echo "$enable_rubyinterp" >&6; }
 if test "$enable_rubyinterp" = "yes"; then
+  { $as_echo "$as_me:$LINENO: checking --with-ruby-command argument" >&5
+$as_echo_n "checking --with-ruby-command argument... " >&6; }
+
+# Check whether --with-ruby-command was given.
+if test "${with_ruby_command+set}" = set; then
+  withval=$with_ruby_command; RUBY_CMD="$withval"; { $as_echo "$as_me:$LINENO: result: $RUBY_CMD" >&5
+$as_echo "$RUBY_CMD" >&6; }
+else
+  RUBY_CMD="ruby"; { $as_echo "$as_me:$LINENO: result: defaulting to $RUBY_CMD" >&5
+$as_echo "defaulting to $RUBY_CMD" >&6; }
+fi
 
-  # Extract the first word of "ruby", so it can be a program name with args.
-set dummy ruby; ac_word=$2
+
+  # Extract the first word of "$RUBY_CMD", so it can be a program name with args.
+set dummy $RUBY_CMD; ac_word=$2
 { $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if test "${ac_cv_path_vi_cv_path_ruby+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
@@ -5715,15 +5832,21 @@ $as_echo_n "checking Ruby version... " >
     if $vi_cv_path_ruby -e '(VERSION rescue RUBY_VERSION) >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then
       { $as_echo "$as_me:$LINENO: result: OK" >&5
 $as_echo "OK" >&6; }
       { $as_echo "$as_me:$LINENO: checking Ruby header files" >&5
 $as_echo_n "checking Ruby header files... " >&6; }
-      rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null`
+      rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG["rubyhdrdir"] || Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null`
       if test "X$rubyhdrdir" != "X"; then
 	{ $as_echo "$as_me:$LINENO: result: $rubyhdrdir" >&5
 $as_echo "$rubyhdrdir" >&6; }
 	RUBY_CFLAGS="-I$rubyhdrdir"
+        rubyarch=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["arch"]'`
+        if test -d "$rubyhdrdir/$rubyarch"; then
+          RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
+        fi
+        rubyversion=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["ruby_version"].gsub(/\./, "")[0,2]'`
+        RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
 	rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["LIBS"]'`
 	if test "X$rubylibs" != "X"; then
 	  RUBY_LIBS="$rubylibs"
 	fi
 	librubyarg=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG["LIBRUBYARG"])'`
@@ -5743,22 +5866,25 @@ $as_echo "$rubyhdrdir" >&6; }
 	if test "X$librubyarg" != "X"; then
 	  RUBY_LIBS="$librubyarg $RUBY_LIBS"
 	fi
 	rubyldflags=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG["LDFLAGS"]'`
 	if test "X$rubyldflags" != "X"; then
-	  LDFLAGS="$rubyldflags $LDFLAGS"
+	  	  	  	  rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//'`
+	  if test "X$rubyldflags" != "X"; then
+	    LDFLAGS="$rubyldflags $LDFLAGS"
+	  fi
 	fi
 	RUBY_SRC="if_ruby.c"
 	RUBY_OBJ="objects/if_ruby.o"
 	RUBY_PRO="if_ruby.pro"
 	cat >>confdefs.h <<\_ACEOF
 #define FEAT_RUBY 1
 _ACEOF
 
       else
-	{ $as_echo "$as_me:$LINENO: result: not found" >&5
-$as_echo "not found" >&6; }
+	{ $as_echo "$as_me:$LINENO: result: not found; disabling Ruby" >&5
+$as_echo "not found; disabling Ruby" >&6; }
       fi
     else
       { $as_echo "$as_me:$LINENO: result: too old; need Ruby version 1.6.0 or later" >&5
 $as_echo "too old; need Ruby version 1.6.0 or later" >&6; }
     fi
@@ -5889,11 +6015,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket" >&5
 $as_echo "$ac_cv_lib_socket_socket" >&6; }
-if test $ac_cv_lib_socket_socket = yes; then
+if test "x$ac_cv_lib_socket_socket" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBSOCKET 1
 _ACEOF
 
   LIBS="-lsocket $LIBS"
@@ -5964,11 +6090,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5
 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; }
-if test $ac_cv_lib_nsl_gethostbyname = yes; then
+if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBNSL 1
 _ACEOF
 
   LIBS="-lnsl $LIBS"
@@ -6201,12 +6327,12 @@ fi
 if test "x$with_x" = xno; then
   # The user explicitly disabled X.
   have_x=disabled
 else
   case $x_includes,$x_libraries in #(
-    *\'*) { { $as_echo "$as_me:$LINENO: error: Cannot use X directory names containing '" >&5
-$as_echo "$as_me: error: Cannot use X directory names containing '" >&2;}
+    *\'*) { { $as_echo "$as_me:$LINENO: error: cannot use X directory names containing '" >&5
+$as_echo "$as_me: error: cannot use X directory names containing '" >&2;}
    { (exit 1); exit 1; }; };; #(
     *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   # One or both of the vars are not set, and there is no cached value.
@@ -6240,11 +6366,11 @@ _ACEOF
     case $ac_im_incroot in
 	/usr/include) ac_x_includes= ;;
 	*) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
     esac
     case $ac_im_usrlibdir in
-	/usr/lib | /lib) ;;
+	/usr/lib | /usr/lib64 | /lib | /lib64) ;;
 	*) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
     esac
   fi
   cd ..
   rm -f -r conftest.dir
@@ -6680,11 +6806,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
 $as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; }
-if test $ac_cv_lib_dnet_dnet_ntoa = yes; then
+if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
 fi
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       { $as_echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5
@@ -6750,11 +6876,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
 $as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; }
-if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then
+if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = x""yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
 fi
 
     fi
 fi
@@ -6922,11 +7048,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5
 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; }
-if test $ac_cv_lib_nsl_gethostbyname = yes; then
+if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
 fi
 
       if test $ac_cv_lib_nsl_gethostbyname = no; then
 	{ $as_echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5
@@ -6992,11 +7118,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5
 $as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; }
-if test $ac_cv_lib_bsd_gethostbyname = yes; then
+if test "x$ac_cv_lib_bsd_gethostbyname" = x""yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
 fi
 
       fi
     fi
@@ -7158,11 +7284,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5
 $as_echo "$ac_cv_lib_socket_connect" >&6; }
-if test $ac_cv_lib_socket_connect = yes; then
+if test "x$ac_cv_lib_socket_connect" = x""yes; then
   X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
 fi
 
     fi
 
@@ -7317,11 +7443,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5
 $as_echo "$ac_cv_lib_posix_remove" >&6; }
-if test $ac_cv_lib_posix_remove = yes; then
+if test "x$ac_cv_lib_posix_remove" = x""yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
 fi
 
     fi
 
@@ -7476,11 +7602,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5
 $as_echo "$ac_cv_lib_ipc_shmat" >&6; }
-if test $ac_cv_lib_ipc_shmat = yes; then
+if test "x$ac_cv_lib_ipc_shmat" = x""yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
 fi
 
     fi
   fi
@@ -7557,11 +7683,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
 $as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; }
-if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then
+if test "x$ac_cv_lib_ICE_IceConnectionNumber" = x""yes; then
   X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
 fi
 
   LDFLAGS=$ac_save_LDFLAGS
 
@@ -7725,11 +7851,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_Xdmcp__XdmcpAuthDoIt" >&5
 $as_echo "$ac_cv_lib_Xdmcp__XdmcpAuthDoIt" >&6; }
-if test $ac_cv_lib_Xdmcp__XdmcpAuthDoIt = yes; then
+if test "x$ac_cv_lib_Xdmcp__XdmcpAuthDoIt" = x""yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lXdmcp"
 fi
 
 
                     { $as_echo "$as_me:$LINENO: checking for IceOpenConnection in -lICE" >&5
@@ -7795,11 +7921,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceOpenConnection" >&5
 $as_echo "$ac_cv_lib_ICE_IceOpenConnection" >&6; }
-if test $ac_cv_lib_ICE_IceOpenConnection = yes; then
+if test "x$ac_cv_lib_ICE_IceOpenConnection" = x""yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lSM -lICE"
 fi
 
 
         LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
@@ -7866,11 +7992,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_Xpm_XpmCreatePixmapFromData" >&5
 $as_echo "$ac_cv_lib_Xpm_XpmCreatePixmapFromData" >&6; }
-if test $ac_cv_lib_Xpm_XpmCreatePixmapFromData = yes; then
+if test "x$ac_cv_lib_Xpm_XpmCreatePixmapFromData" = x""yes; then
   X_PRE_LIBS="$X_PRE_LIBS -lXpm"
 fi
 
 
         { $as_echo "$as_me:$LINENO: checking if X11 header files implicitly declare return values" >&5
@@ -7968,10 +8094,86 @@ fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     CFLAGS=$cflags_save
 
     LDFLAGS="$ac_save_LDFLAGS"
 
+    { $as_echo "$as_me:$LINENO: checking size of wchar_t is 2 bytes" >&5
+$as_echo_n "checking size of wchar_t is 2 bytes... " >&6; }
+    if test "${ac_cv_small_wchar_t+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  if test "$cross_compiling" = yes; then
+  { { $as_echo "$as_me:$LINENO: error: failed to compile test program" >&5
+$as_echo "$as_me: error: failed to compile test program" >&2;}
+   { (exit 1); exit 1; }; }
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <X11/Xlib.h>
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#endif
+		main()
+		{
+		  if (sizeof(wchar_t) <= 2)
+		    exit(1);
+		  exit(0);
+		}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_small_wchar_t="no"
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_small_wchar_t="yes"
+fi
+rm -rf conftest.dSYM
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+
+    { $as_echo "$as_me:$LINENO: result: $ac_cv_small_wchar_t" >&5
+$as_echo "$ac_cv_small_wchar_t" >&6; }
+    if test "x$ac_cv_small_wchar_t" = "xyes" ; then
+      cat >>confdefs.h <<\_ACEOF
+#define SMALL_WCHAR_T 1
+_ACEOF
+
+    fi
+
   fi
 fi
 
 test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
 
@@ -9249,11 +9451,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_Xext_XShapeQueryExtension" >&5
 $as_echo "$ac_cv_lib_Xext_XShapeQueryExtension" >&6; }
-if test $ac_cv_lib_Xext_XShapeQueryExtension = yes; then
+if test "x$ac_cv_lib_Xext_XShapeQueryExtension" = x""yes; then
   GUI_X_LIBS="-lXext"
 fi
 
     { $as_echo "$as_me:$LINENO: checking for wslen in -lw" >&5
 $as_echo_n "checking for wslen in -lw... " >&6; }
@@ -9318,11 +9520,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_w_wslen" >&5
 $as_echo "$ac_cv_lib_w_wslen" >&6; }
-if test $ac_cv_lib_w_wslen = yes; then
+if test "x$ac_cv_lib_w_wslen" = x""yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -lw"
 fi
 
   { $as_echo "$as_me:$LINENO: checking for dlsym in -ldl" >&5
 $as_echo_n "checking for dlsym in -ldl... " >&6; }
@@ -9387,11 +9589,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlsym" >&5
 $as_echo "$ac_cv_lib_dl_dlsym" >&6; }
-if test $ac_cv_lib_dl_dlsym = yes; then
+if test "x$ac_cv_lib_dl_dlsym" = x""yes; then
   X_EXTRA_LIBS="$X_EXTRA_LIBS -ldl"
 fi
 
   { $as_echo "$as_me:$LINENO: checking for XmuCreateStippledPixmap in -lXmu" >&5
 $as_echo_n "checking for XmuCreateStippledPixmap in -lXmu... " >&6; }
@@ -9456,11 +9658,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_Xmu_XmuCreateStippledPixmap" >&5
 $as_echo "$ac_cv_lib_Xmu_XmuCreateStippledPixmap" >&6; }
-if test $ac_cv_lib_Xmu_XmuCreateStippledPixmap = yes; then
+if test "x$ac_cv_lib_Xmu_XmuCreateStippledPixmap" = x""yes; then
   GUI_X_LIBS="-lXmu $GUI_X_LIBS"
 fi
 
   if test -z "$SKIP_MOTIF"; then
     { $as_echo "$as_me:$LINENO: checking for XpEndJob in -lXp" >&5
@@ -9526,11 +9728,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_Xp_XpEndJob" >&5
 $as_echo "$ac_cv_lib_Xp_XpEndJob" >&6; }
-if test $ac_cv_lib_Xp_XpEndJob = yes; then
+if test "x$ac_cv_lib_Xp_XpEndJob" = x""yes; then
   GUI_X_LIBS="-lXp $GUI_X_LIBS"
 fi
 
   fi
   LDFLAGS=$ldflags_save
@@ -9697,12 +9899,13 @@ ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
 
 fi
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -9850,12 +10053,13 @@ ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
 
 fi
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -10096,12 +10300,13 @@ ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
 
 fi
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -10360,10 +10565,60 @@ sed 's/^/| /' conftest.$ac_ext >&5
 $as_echo "no" >&6; }
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
+{ $as_echo "$as_me:$LINENO: checking whether __attribute__((unused)) is allowed" >&5
+$as_echo_n "checking whether __attribute__((unused)) is allowed... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+int x __attribute__((unused));
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF
+#define HAVE_ATTRIBUTE_UNUSED 1
+_ACEOF
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	{ $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 if test "${ac_cv_header_elf_h+set}" = set; then
   { $as_echo "$as_me:$LINENO: checking for elf.h" >&5
 $as_echo_n "checking for elf.h... " >&6; }
 if test "${ac_cv_header_elf_h+set}" = set; then
   $as_echo_n "(cached) " >&6
@@ -10487,11 +10742,11 @@ else
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_header_elf_h" >&5
 $as_echo "$ac_cv_header_elf_h" >&6; }
 
 fi
-if test $ac_cv_header_elf_h = yes; then
+if test "x$ac_cv_header_elf_h" = x""yes; then
   HAS_ELF=1
 fi
 
 
 if test "$HAS_ELF" = 1; then
@@ -10553,11 +10808,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_elf_main" >&5
 $as_echo "$ac_cv_lib_elf_main" >&6; }
-if test $ac_cv_lib_elf_main = yes; then
+if test "x$ac_cv_lib_elf_main" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBELF 1
 _ACEOF
 
   LIBS="-lelf $LIBS"
@@ -10627,12 +10882,13 @@ rm -f core conftest.err conftest.$ac_obj
 fi
 ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
 _ACEOF
 
 ac_header_dirent=$ac_hdr; break
@@ -10914,19 +11170,18 @@ fi
 
 
 
 
 
-
 for ac_header in stdarg.h stdlib.h string.h sys/select.h sys/utsname.h \
 	termcap.h fcntl.h sgtty.h sys/ioctl.h sys/time.h sys/types.h termio.h \
 	iconv.h langinfo.h math.h unistd.h stropts.h errno.h \
 	sys/resource.h sys/systeminfo.h locale.h \
 	sys/stream.h termios.h libc.h sys/statfs.h \
 	poll.h sys/poll.h pwd.h utime.h sys/param.h libintl.h \
 	libgen.h util/debug.h util/msg18n.h frame.h \
-	sys/acl.h sys/access.h sys/sysctl.h sys/sysinfo.h wchar.h wctype.h
+	sys/acl.h sys/access.h sys/sysinfo.h wchar.h wctype.h
 do
 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
 $as_echo_n "checking for $ac_header... " >&6; }
@@ -11048,31 +11303,97 @@ esac
 { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
 $as_echo_n "checking for $ac_header... " >&6; }
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   $as_echo_n "(cached) " >&6
 else
-  eval "$as_ac_Header=\$ac_header_preproc"
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+
+fi
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+for ac_header in sys/ptem.h
+do
+as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
+$as_echo_n "checking for $ac_header... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#if defined HAVE_SYS_STREAM_H
+#  include <sys/stream.h>
+#endif
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  eval "$as_ac_Header=yes"
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	eval "$as_ac_Header=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-
-fi
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
 
 done
 
 
 
-for ac_header in sys/ptem.h
+for ac_header in sys/sysctl.h
 do
 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
 $as_echo_n "checking for $ac_header... " >&6; }
 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -11082,12 +11403,12 @@ else
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#if defined HAVE_SYS_STREAM_H
-#  include <sys/stream.h>
+#if defined HAVE_SYS_PARAM_H
+#  include <sys/param.h>
 #endif
 
 #include <$ac_header>
 _ACEOF
 rm -f conftest.$ac_objext
@@ -11120,12 +11441,13 @@ rm -f core conftest.err conftest.$ac_obj
 fi
 ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -11320,12 +11642,13 @@ ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
 
 fi
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -11563,10 +11886,71 @@ cat >>confdefs.h <<\_ACEOF
 #define const /**/
 _ACEOF
 
 fi
 
+{ $as_echo "$as_me:$LINENO: checking for working volatile" >&5
+$as_echo_n "checking for working volatile... " >&6; }
+if test "${ac_cv_c_volatile+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+volatile int x;
+int * volatile y = (int *) 0;
+return !x && !y;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_c_volatile=yes
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_c_volatile=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_volatile" >&5
+$as_echo "$ac_cv_c_volatile" >&6; }
+if test $ac_cv_c_volatile = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define volatile /**/
+_ACEOF
+
+fi
+
 { $as_echo "$as_me:$LINENO: checking for mode_t" >&5
 $as_echo_n "checking for mode_t... " >&6; }
 if test "${ac_cv_type_mode_t+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
@@ -11657,11 +12041,11 @@ fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5
 $as_echo "$ac_cv_type_mode_t" >&6; }
-if test $ac_cv_type_mode_t = yes; then
+if test "x$ac_cv_type_mode_t" = x""yes; then
   :
 else
 
 cat >>confdefs.h <<_ACEOF
 #define mode_t int
@@ -11761,11 +12145,11 @@ fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5
 $as_echo "$ac_cv_type_off_t" >&6; }
-if test $ac_cv_type_off_t = yes; then
+if test "x$ac_cv_type_off_t" = x""yes; then
   :
 else
 
 cat >>confdefs.h <<_ACEOF
 #define off_t long int
@@ -11865,11 +12249,11 @@ fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5
 $as_echo "$ac_cv_type_pid_t" >&6; }
-if test $ac_cv_type_pid_t = yes; then
+if test "x$ac_cv_type_pid_t" = x""yes; then
   :
 else
 
 cat >>confdefs.h <<_ACEOF
 #define pid_t int
@@ -11969,11 +12353,11 @@ fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
 $as_echo "$ac_cv_type_size_t" >&6; }
-if test $ac_cv_type_size_t = yes; then
+if test "x$ac_cv_type_size_t" = x""yes; then
   :
 else
 
 cat >>confdefs.h <<_ACEOF
 #define size_t unsigned int
@@ -12173,11 +12557,11 @@ fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_type_ino_t" >&5
 $as_echo "$ac_cv_type_ino_t" >&6; }
-if test $ac_cv_type_ino_t = yes; then
+if test "x$ac_cv_type_ino_t" = x""yes; then
   :
 else
 
 cat >>confdefs.h <<_ACEOF
 #define ino_t long
@@ -12277,11 +12661,11 @@ fi
 
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_type_dev_t" >&5
 $as_echo "$ac_cv_type_dev_t" >&6; }
-if test $ac_cv_type_dev_t = yes; then
+if test "x$ac_cv_type_dev_t" = x""yes; then
   :
 else
 
 cat >>confdefs.h <<_ACEOF
 #define dev_t unsigned
@@ -12567,12 +12951,13 @@ LIBS=$ac_check_lib_save_LIBS
 fi
 ac_res=`eval 'as_val=${'$as_ac_Lib'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-if test `eval 'as_val=${'$as_ac_Lib'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Lib'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_LIB${libname}" | $as_tr_cpp` 1
 _ACEOF
 
   LIBS="-l${libname} $LIBS"
@@ -13419,24 +13804,24 @@ $as_echo "$ac_try_echo") >&5
 	fi
 	{ $as_echo "$as_me:$LINENO: result: pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group" >&5
 $as_echo "pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group" >&6; }
       else
 	vim_cv_tty_group=world
-	{ $as_echo "$as_me:$LINENO: result: ptys are world accessable" >&5
-$as_echo "ptys are world accessable" >&6; }
+	{ $as_echo "$as_me:$LINENO: result: ptys are world accessible" >&5
+$as_echo "ptys are world accessible" >&6; }
       fi
 
 else
   $as_echo "$as_me: program exited with status $ac_status" >&5
 $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
 
       vim_cv_tty_group=world
-      { $as_echo "$as_me:$LINENO: result: can't determine - assume ptys are world accessable" >&5
-$as_echo "can't determine - assume ptys are world accessable" >&6; }
+      { $as_echo "$as_me:$LINENO: result: can't determine - assume ptys are world accessible" >&5
+$as_echo "can't determine - assume ptys are world accessible" >&6; }
 
 fi
 rm -rf conftest.dSYM
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
@@ -13719,14 +14104,13 @@ fi
 
 
 
 
 
-
-for ac_func in bcmp fchdir fchown fseeko fsync ftello getcwd getpseudotty \
+for ac_func in bcmp fchdir fchown fsync getcwd getpseudotty \
 	getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
-	memset nanosleep opendir putenv qsort readlink select setenv \
+	memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
 	setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
 	sigvec strcasecmp strerror strftime stricmp strncasecmp \
 	strnicmp strpbrk strtol tgetent towlower towupper iswupper \
 	usleep utime utimes
 do
@@ -13816,19 +14200,152 @@ rm -f core conftest.err conftest.$ac_obj
 fi
 ac_res=`eval 'as_val=${'$as_ac_var'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-if test `eval 'as_val=${'$as_ac_var'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_var'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
 fi
 done
 
+{ $as_echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5
+$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; }
+if test "${ac_cv_sys_largefile_source+set}" = set; then
+  $as_echo_n "(cached) " >&6
+else
+  while :; do
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h> /* for off_t */
+     #include <stdio.h>
+int
+main ()
+{
+int (*fp) (FILE *, off_t, int) = fseeko;
+     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
+  ac_cv_sys_largefile_source=no; break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#define _LARGEFILE_SOURCE 1
+#include <sys/types.h> /* for off_t */
+     #include <stdio.h>
+int
+main ()
+{
+int (*fp) (FILE *, off_t, int) = fseeko;
+     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then
+  ac_cv_sys_largefile_source=1; break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+  ac_cv_sys_largefile_source=unknown
+  break
+done
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5
+$as_echo "$ac_cv_sys_largefile_source" >&6; }
+case $ac_cv_sys_largefile_source in #(
+  no | unknown) ;;
+  *)
+cat >>confdefs.h <<_ACEOF
+#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source
+_ACEOF
+;;
+esac
+rm -rf conftest*
+
+# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
+# in glibc 2.1.3, but that breaks too many other things.
+# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
+if test $ac_cv_sys_largefile_source != unknown; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FSEEKO 1
+_ACEOF
+
+fi
+
 
 { $as_echo "$as_me:$LINENO: checking for st_blksize" >&5
 $as_echo_n "checking for st_blksize... " >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -14200,11 +14717,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_m_strtod" >&5
 $as_echo "$ac_cv_lib_m_strtod" >&6; }
-if test $ac_cv_lib_m_strtod = yes; then
+if test "x$ac_cv_lib_m_strtod" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define HAVE_LIBM 1
 _ACEOF
 
   LIBS="-lm $LIBS"
@@ -14360,11 +14877,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_posix1e_acl_get_file" >&5
 $as_echo "$ac_cv_lib_posix1e_acl_get_file" >&6; }
-if test $ac_cv_lib_posix1e_acl_get_file = yes; then
+if test "x$ac_cv_lib_posix1e_acl_get_file" = x""yes; then
   LIBS="$LIBS -lposix1e"
 else
   { $as_echo "$as_me:$LINENO: checking for acl_get_file in -lacl" >&5
 $as_echo_n "checking for acl_get_file in -lacl... " >&6; }
 if test "${ac_cv_lib_acl_acl_get_file+set}" = set; then
@@ -14428,11 +14945,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_acl_acl_get_file" >&5
 $as_echo "$ac_cv_lib_acl_acl_get_file" >&6; }
-if test $ac_cv_lib_acl_acl_get_file = yes; then
+if test "x$ac_cv_lib_acl_acl_get_file" = x""yes; then
   LIBS="$LIBS -lacl"
 		  { $as_echo "$as_me:$LINENO: checking for fgetxattr in -lattr" >&5
 $as_echo_n "checking for fgetxattr in -lattr... " >&6; }
 if test "${ac_cv_lib_attr_fgetxattr+set}" = set; then
   $as_echo_n "(cached) " >&6
@@ -14495,11 +15012,11 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_attr_fgetxattr" >&5
 $as_echo "$ac_cv_lib_attr_fgetxattr" >&6; }
-if test $ac_cv_lib_attr_fgetxattr = yes; then
+if test "x$ac_cv_lib_attr_fgetxattr" = x""yes; then
   LIBS="$LIBS -lattr"
 fi
 
 fi
 
@@ -14873,10 +15390,62 @@ _ACEOF
 else
   { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
 fi
 
+{ $as_echo "$as_me:$LINENO: checking for FD_CLOEXEC" >&5
+$as_echo_n "checking for FD_CLOEXEC... " >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#if HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+int
+main ()
+{
+	int flag = FD_CLOEXEC;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF
+#define HAVE_FD_CLOEXEC 1
+_ACEOF
+
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	{ $as_echo "$as_me:$LINENO: result: not usable" >&5
+$as_echo "not usable" >&6; }
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 { $as_echo "$as_me:$LINENO: checking for rename" >&5
 $as_echo_n "checking for rename... " >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -15224,11 +15793,10 @@ cat >>confdefs.h <<_ACEOF
 #define SIZEOF_INT $ac_cv_sizeof_int
 _ACEOF
 
 
 
-
 bcopy_test_prog='
 #include "confdefs.h"
 #ifdef HAVE_STRING_H
 # include <string.h>
 #endif
@@ -15456,11 +16024,11 @@ fi
 
 
 if test "$enable_multibyte" = "yes"; then
   cflags_save=$CFLAGS
   ldflags_save=$LDFLAGS
-  if test -n "$x_includes" ; then
+  if test "x$x_includes" != "xNONE" ; then
     CFLAGS="$CFLAGS -I$x_includes"
     LDFLAGS="$X_LIBS $LDFLAGS -lX11"
     { $as_echo "$as_me:$LINENO: checking whether X_LOCALE needed" >&5
 $as_echo_n "checking whether X_LOCALE needed... " >&6; }
     cat >conftest.$ac_ext <<_ACEOF
@@ -15633,21 +16201,22 @@ rm -f core conftest.err conftest.$ac_obj
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_xpg4__xpg4_setrunelocale" >&5
 $as_echo "$ac_cv_lib_xpg4__xpg4_setrunelocale" >&6; }
-if test $ac_cv_lib_xpg4__xpg4_setrunelocale = yes; then
+if test "x$ac_cv_lib_xpg4__xpg4_setrunelocale" = x""yes; then
   LIBS="$LIBS -lxpg4"
 fi
 
 
 { $as_echo "$as_me:$LINENO: checking how to create tags" >&5
 $as_echo_n "checking how to create tags... " >&6; }
 test -f tags && mv tags tags.save
 if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&5 2>&1; then
   TAGPRG="ctags -I INIT+ --fields=+S"
 else
+  TAGPRG="ctags"
   (eval etags	   /dev/null) < /dev/null 1>&5 2>&1 && TAGPRG="etags"
   (eval etags -c   /dev/null) < /dev/null 1>&5 2>&1 && TAGPRG="etags -c"
   (eval ctags	   /dev/null) < /dev/null 1>&5 2>&1 && TAGPRG="ctags"
   (eval ctags -t   /dev/null) < /dev/null 1>&5 2>&1 && TAGPRG="ctags -t"
   (eval ctags -ts  /dev/null) < /dev/null 1>&5 2>&1 && TAGPRG="ctags -ts"
@@ -15931,12 +16500,13 @@ rm -f core conftest.err conftest.$ac_obj
 fi
 ac_res=`eval 'as_val=${'$as_ac_var'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-if test `eval 'as_val=${'$as_ac_var'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_var'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -16132,11 +16702,11 @@ else
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_header_dlfcn_h" >&5
 $as_echo "$ac_cv_header_dlfcn_h" >&6; }
 
 fi
-if test $ac_cv_header_dlfcn_h = yes; then
+if test "x$ac_cv_header_dlfcn_h" = x""yes; then
   DLL=dlfcn.h
 else
   if test "${ac_cv_header_dl_h+set}" = set; then
   { $as_echo "$as_me:$LINENO: checking for dl.h" >&5
 $as_echo_n "checking for dl.h... " >&6; }
@@ -16262,11 +16832,11 @@ else
 fi
 { $as_echo "$as_me:$LINENO: result: $ac_cv_header_dl_h" >&5
 $as_echo "$ac_cv_header_dl_h" >&6; }
 
 fi
-if test $ac_cv_header_dl_h = yes; then
+if test "x$ac_cv_header_dl_h" = x""yes; then
   DLL=dl.h
 fi
 
 
 fi
@@ -16781,12 +17351,13 @@ ac_res=`eval 'as_val=${'$as_ac_Header'}
 		 $as_echo "$as_val"'`
 	       { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
 
 fi
-if test `eval 'as_val=${'$as_ac_Header'}
-		 $as_echo "$as_val"'` = yes; then
+as_val=`eval 'as_val=${'$as_ac_Header'}
+		 $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
   cat >>confdefs.h <<_ACEOF
 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -16814,28 +17385,36 @@ $as_echo "yes" >&6; }
     { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
   fi
 fi
 if test "x$MACARCH" = "xboth"; then
-  LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
+  LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
 fi
 
-{ $as_echo "$as_me:$LINENO: checking for GCC 3 or later" >&5
-$as_echo_n "checking for GCC 3 or later... " >&6; }
 DEPEND_CFLAGS_FILTER=
 if test "$GCC" = yes; then
+  { $as_echo "$as_me:$LINENO: checking for GCC 3 or later" >&5
+$as_echo_n "checking for GCC 3 or later... " >&6; }
   gccmajor=`echo "$gccversion" | sed -e 's/^\([1-9]\)\..*$/\1/g'`
   if test "$gccmajor" -gt "2"; then
     DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
-  fi
-fi
-if test "$DEPEND_CFLAGS_FILTER" = ""; then
-  { $as_echo "$as_me:$LINENO: result: no" >&5
+    { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+  else
+    { $as_echo "$as_me:$LINENO: result: no" >&5
 $as_echo "no" >&6; }
-else
-  { $as_echo "$as_me:$LINENO: result: yes" >&5
+  fi
+        { $as_echo "$as_me:$LINENO: checking whether we need -D_FORTIFY_SOURCE=1" >&5
+$as_echo_n "checking whether we need -D_FORTIFY_SOURCE=1... " >&6; }
+  if test "$gccmajor" -gt "3"; then
+    CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -D_FORTIFY_SOURCE=1/'`
+    { $as_echo "$as_me:$LINENO: result: yes" >&5
 $as_echo "yes" >&6; }
+  else
+    { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+  fi
 fi
 
 
 ac_config_files="$ac_config_files auto/config.mk:config.mk.in"
 
@@ -16864,12 +17443,12 @@ _ACEOF
   for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
     eval ac_val=\$$ac_var
     case $ac_val in #(
     *${as_nl}*)
       case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
-$as_echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
       esac
       case $ac_var in #(
       _ | IFS | as_nl) ;; #(
       BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
       *) $as_unset $ac_var ;;
@@ -17257,11 +17836,11 @@ exec 6>&1
 # Save the log message, to keep $[0] and so on meaningful, and to
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
 This file was extended by $as_me, which was
-generated by GNU Autoconf 2.62.  Invocation command line was
+generated by GNU Autoconf 2.63.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
   CONFIG_LINKS    = $CONFIG_LINKS
   CONFIG_COMMANDS = $CONFIG_COMMANDS
@@ -17270,10 +17849,19 @@ generated by GNU Autoconf 2.62.  Invocat
 on `(hostname || uname -n) 2>/dev/null | sed 1q`
 "
 
 _ACEOF
 
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 # Files that config.status was made for.
 config_files="$ac_config_files"
 config_headers="$ac_config_headers"
 
@@ -17282,20 +17870,21 @@ _ACEOF
 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 ac_cs_usage="\
 \`$as_me' instantiates files from templates according to the
 current configuration.
 
-Usage: $0 [OPTIONS] [FILE]...
+Usage: $0 [OPTION]... [FILE]...
 
   -h, --help       print this help, then exit
   -V, --version    print version number and configuration settings, then exit
-  -q, --quiet      do not print progress messages
+  -q, --quiet, --silent
+                   do not print progress messages
   -d, --debug      don't remove temporary files
       --recheck    update $as_me by reconfiguring in the same conditions
-  --file=FILE[:TEMPLATE]
+      --file=FILE[:TEMPLATE]
                    instantiate the configuration file FILE
-  --header=FILE[:TEMPLATE]
+      --header=FILE[:TEMPLATE]
                    instantiate the configuration header FILE
 
 Configuration files:
 $config_files
 
@@ -17306,11 +17895,11 @@ Report bugs to <bug-autoconf@gnu.org>."
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.62,
+configured by $0, generated by GNU Autoconf 2.63,
   with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
 Copyright (C) 2008 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
@@ -17503,11 +18092,12 @@ for ac_last_try in false false false fal
   . ./conf$$subs.sh ||
     { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
 $as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
    { (exit 1); exit 1; }; }
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` = $ac_delim_num; then
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
     break
   elif $ac_last_try; then
     { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
 $as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
    { (exit 1); exit 1; }; }
@@ -17708,21 +18298,21 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_writ
     defundef = substr(arg[1], 2)
     mac1 = arg[2]
   }
   split(mac1, mac2, "(") #)
   macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
   if (D_is_set[macro]) {
     # Preserve the white space surrounding the "#".
-    prefix = substr(line, 1, index(line, defundef) - 1)
     print prefix "define", macro P[macro] D[macro]
     next
   } else {
     # Replace #undef with comments.  This is necessary, for example,
     # in the case of _POSIX_SOURCE, which is predefined and required
     # on some systems where configure will not decide to define it.
     if (defundef == "undef") {
-      print "/*", line, "*/"
+      print "/*", prefix defundef, macro, "*/"
       next
     }
   }
 }
 { print }
@@ -17742,12 +18332,12 @@ do
   case $ac_tag in
   :[FHLC]) ac_mode=$ac_tag; continue;;
   esac
   case $ac_mode$ac_tag in
   :[FHL]*:*);;
-  :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
-$as_echo "$as_me: error: Invalid tag $ac_tag." >&2;}
+  :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5
+$as_echo "$as_me: error: invalid tag $ac_tag" >&2;}
    { (exit 1); exit 1; }; };;
   :[FH]-) ac_tag=-:-;;
   :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
   esac
   ac_save_IFS=$IFS
@@ -18061,10 +18651,10 @@ if test "$no_create" != yes; then
   # Use ||, not &&, to avoid exiting from the if with $? = 1, which
   # would make configure fail if this is the last instruction.
   $ac_cs_success || { (exit 1); exit 1; }
 fi
 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:$LINENO: WARNING: Unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2;}
+  { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
 
 
--- vim72.orig/src/buffer.c
+++ vim72/src/buffer.c
@@ -31,21 +31,22 @@
 static char_u	*buflist_match __ARGS((regprog_T *prog, buf_T *buf));
 # define HAVE_BUFLIST_MATCH
 static char_u	*fname_match __ARGS((regprog_T *prog, char_u *name));
 #endif
 static void	buflist_setfpos __ARGS((buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options));
-static wininfo_T *find_wininfo __ARGS((buf_T *buf));
+static wininfo_T *find_wininfo __ARGS((buf_T *buf, int skip_diff_buffer));
 #ifdef UNIX
 static buf_T	*buflist_findname_stat __ARGS((char_u *ffname, struct stat *st));
 static int	otherfile_buf __ARGS((buf_T *buf, char_u *ffname, struct stat *stp));
 static int	buf_same_ino __ARGS((buf_T *buf, struct stat *stp));
 #else
 static int	otherfile_buf __ARGS((buf_T *buf, char_u *ffname));
 #endif
 #ifdef FEAT_TITLE
 static int	ti_change __ARGS((char_u *str, char_u **last));
 #endif
+static int	append_arg_number __ARGS((win_T *wp, char_u *buf, int buflen, int add_file));
 static void	free_buffer __ARGS((buf_T *));
 static void	free_buffer_stuff __ARGS((buf_T *buf, int free_options));
 static void	clear_wininfo __ARGS((buf_T *buf));
 
 #ifdef UNIX
@@ -112,11 +113,11 @@ open_buffer(read_stdin, eap)
     old_curbuf = curbuf;
     modified_was_set = FALSE;
 #endif
 
     /* mark cursor position as being invalid */
-    changed_line_abv_curs();
+    curwin->w_valid = 0;
 
     if (curbuf->b_ffname != NULL
 #ifdef FEAT_NETBEANS_INTG
 	    && netbeansReadFile
 #endif
@@ -312,11 +313,11 @@ close_buffer(win, buf, action)
     buf_T	*buf;
     int		action;
 {
 #ifdef FEAT_AUTOCMD
     int		is_curbuf;
-    int		nwindows = buf->b_nwindows;
+    int		nwindows;
 #endif
     int		unload_buf = (action != 0);
     int		del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
     int		wipe_buf = (action == DOBUF_WIPE);
 
@@ -435,14 +436,10 @@ close_buffer(win, buf, action)
      */
     if (buf == curbuf && !is_curbuf)
 	return;
 #endif
 
-#ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans)
-	netbeans_file_closed(buf);
-#endif
     /* Change directories when the 'acd' option is set. */
     DO_AUTOCHDIR
 
     /*
      * Remove the buffer from the list.
@@ -513,16 +510,15 @@ buf_clear_file(buf)
 
 /*
  * buf_freeall() - free all things allocated for a buffer that are related to
  * the file.
  */
-/*ARGSUSED*/
     void
 buf_freeall(buf, del_buf, wipe_buf)
     buf_T	*buf;
-    int		del_buf;	/* buffer is going to be deleted */
-    int		wipe_buf;	/* buffer is going to be wiped out */
+    int		del_buf UNUSED;	    /* buffer is going to be deleted */
+    int		wipe_buf UNUSED;    /* buffer is going to be wiped out */
 {
 #ifdef FEAT_AUTOCMD
     int		is_curbuf = (buf == curbuf);
 
     apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf);
@@ -637,18 +633,25 @@ free_buffer_stuff(buf, free_options)
     uc_clear(&buf->b_ucmds);		/* clear local user commands */
 #endif
 #ifdef FEAT_SIGNS
     buf_delete_signs(buf);		/* delete any signs */
 #endif
+#ifdef FEAT_NETBEANS_INTG
+    if (usingNetbeans)
+        netbeans_file_killed(buf);
+#endif
 #ifdef FEAT_LOCALMAP
     map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE);  /* clear local mappings */
     map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE);   /* clear local abbrevs */
 #endif
 #ifdef FEAT_MBYTE
     vim_free(buf->b_start_fenc);
     buf->b_start_fenc = NULL;
 #endif
+#ifdef FEAT_SPELL
+    ga_clear(&buf->b_langp);
+#endif
 }
 
 /*
  * Free the b_wininfo list for buffer "buf".
  */
@@ -810,13 +813,10 @@ do_bufdel(command, arg, addr_count, star
     int		deleted = 0;	/* number of buffers deleted */
     char_u	*errormsg = NULL; /* return value */
     int		bnr;		/* buffer number */
     char_u	*p;
 
-#ifdef FEAT_NETBEANS_INTG
-    netbeansCloseFile = 1;
-#endif
     if (addr_count == 0)
     {
 	(void)do_buffer(command, DOBUF_CURRENT, FORWARD, 0, forceit);
     }
     else
@@ -907,13 +907,10 @@ do_bufdel(command, arg, addr_count, star
 		    smsg((char_u *)_("%d buffers wiped out"), deleted);
 	    }
 	}
     }
 
-#ifdef FEAT_NETBEANS_INTG
-    netbeansCloseFile = 0;
-#endif
 
     return errormsg;
 }
 
 /*
@@ -1088,11 +1085,11 @@ do_buffer(action, start, dir, count, for
 #ifdef FEAT_WINDOWS
 	    close_windows(buf, TRUE);
 #endif
 	    setpcmark();
 	    retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE,
-						  forceit ? ECMD_FORCEIT : 0);
+					  forceit ? ECMD_FORCEIT : 0, curwin);
 
 	    /*
 	     * do_ecmd() may create a new buffer, then we have to delete
 	     * the old one.  But do_ecmd() may have done that already, check
 	     * if the buffer still exists.
@@ -1235,11 +1232,11 @@ do_buffer(action, start, dir, count, for
 # ifdef FEAT_WINDOWS
 	/* If 'switchbuf' contains "useopen": jump to first window containing
 	 * "buf" if one exists */
 	if ((swb_flags & SWB_USEOPEN) && buf_jump_open_win(buf))
 	    return OK;
-	/* If 'switchbuf' contians "usetab": jump to first window in any tab
+	/* If 'switchbuf' contains "usetab": jump to first window in any tab
 	 * page containing "buf" if one exists */
 	if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf))
 	    return OK;
 	if (win_split(0, 0) == FAIL)
 # endif
@@ -1311,11 +1308,11 @@ set_curbuf(buf, action)
 						     || action == DOBUF_WIPE);
 
     setpcmark();
     if (!cmdmod.keepalt)
 	curwin->w_alt_fnum = curbuf->b_fnum; /* remember alternate file */
-    buflist_altfpos();			 /* remember curpos */
+    buflist_altfpos(curwin);			 /* remember curpos */
 
 #ifdef FEAT_VISUAL
     /* Don't restart Select mode after switching to another buffer. */
     VIsual_reselect = FALSE;
 #endif
@@ -1349,15 +1346,16 @@ set_curbuf(buf, action)
 			&& !P_HID(prevbuf)
 			&& !bufIsChanged(prevbuf)) ? DOBUF_UNLOAD : 0);
 	}
     }
 #ifdef FEAT_AUTOCMD
+    /* An autocommand may have deleted "buf", already entered it (e.g., when
+     * it did ":bunload") or aborted the script processing! */
 # ifdef FEAT_EVAL
-    /* An autocommand may have deleted buf or aborted the script processing! */
-    if (buf_valid(buf) && !aborting())
+    if (buf_valid(buf) && buf != curbuf && !aborting())
 # else
-    if (buf_valid(buf))	    /* an autocommand may have deleted buf! */
+    if (buf_valid(buf) && buf != curbuf)
 # endif
 #endif
 	enter_buffer(buf);
 }
 
@@ -1395,10 +1393,16 @@ enter_buffer(buf)
     curwin->w_cursor.col = 0;
 #ifdef FEAT_VIRTUALEDIT
     curwin->w_cursor.coladd = 0;
 #endif
     curwin->w_set_curswant = TRUE;
+#ifdef FEAT_AUTOCMD
+    curwin->w_topline_was_set = FALSE;
+#endif
+
+    /* mark cursor position as being invalid */
+    curwin->w_valid = 0;
 
     /* Make sure the buffer is loaded. */
     if (curbuf->b_ml.ml_mfp == NULL)	/* need to load the file */
     {
 #ifdef FEAT_AUTOCMD
@@ -1434,11 +1438,12 @@ enter_buffer(buf)
     check_arg_idx(curwin);		/* check for valid arg_idx */
 #ifdef FEAT_TITLE
     maketitle();
 #endif
 #ifdef FEAT_AUTOCMD
-    if (curwin->w_topline == 1)		/* when autocmds didn't change it */
+	/* when autocmds didn't change it */
+    if (curwin->w_topline == 1 && !curwin->w_topline_was_set)
 #endif
 	scroll_cursor_halfway(FALSE);	/* redisplay at correct position */
 
 #ifdef FEAT_NETBEANS_INTG
     /* Send fileOpened event because we've changed buffers. */
@@ -1449,17 +1454,17 @@ enter_buffer(buf)
     /* Change directories when the 'acd' option is set. */
     DO_AUTOCHDIR
 
 #ifdef FEAT_KEYMAP
     if (curbuf->b_kmap_state & KEYMAP_INIT)
-	keymap_init();
+	(void)keymap_init();
 #endif
 #ifdef FEAT_SPELL
     /* May need to set the spell language.  Can only do this after the buffer
      * has been properly setup. */
     if (!curbuf->b_help && curwin->w_p_spell && *curbuf->b_p_spl != NUL)
-	did_set_spelllang(curbuf);
+	(void)did_set_spelllang(curbuf);
 #endif
 
     redraw_later(NOT_VALID);
 }
 
@@ -1673,13 +1678,14 @@ buflist_new(ffname, sfname, lnum, flags)
 #endif
 
     buf->b_fname = buf->b_sfname;
 #ifdef UNIX
     if (st.st_dev == (dev_T)-1)
-	buf->b_dev = -1;
+	buf->b_dev_valid = FALSE;
     else
     {
+	buf->b_dev_valid = TRUE;
 	buf->b_dev = st.st_dev;
 	buf->b_ino = st.st_ino;
     }
 #endif
     buf->b_u_synced = TRUE;
@@ -2020,17 +2026,16 @@ buflist_findname_stat(ffname, stp)
 /*
  * Find file in buffer list by a regexp pattern.
  * Return fnum of the found buffer.
  * Return < 0 for error.
  */
-/*ARGSUSED*/
     int
 buflist_findpat(pattern, pattern_end, unlisted, diffmode)
     char_u	*pattern;
     char_u	*pattern_end;	/* pointer to first char after pattern */
     int		unlisted;	/* find unlisted buffers */
-    int		diffmode;	/* find diff-mode buffers only */
+    int		diffmode UNUSED; /* find diff-mode buffers only */
 {
     buf_T	*buf;
     regprog_T	*prog;
     int		match = -1;
     int		find_listed;
@@ -2398,26 +2403,73 @@ buflist_setfpos(buf, win, lnum, col, cop
 	wip->wi_next->wi_prev = wip;
 
     return;
 }
 
+#ifdef FEAT_DIFF
+static int wininfo_other_tab_diff __ARGS((wininfo_T *wip));
+
+/*
+ * Return TRUE when "wip" has 'diff' set and the diff is only for another tab
+ * page.  That's because a diff is local to a tab page.
+ */
+    static int
+wininfo_other_tab_diff(wip)
+    wininfo_T	*wip;
+{
+    win_T	*wp;
+
+    if (wip->wi_opt.wo_diff)
+    {
+	for (wp = firstwin; wp != NULL; wp = wp->w_next)
+	    /* return FALSE when it's a window in the current tab page, thus
+	     * the buffer was in diff mode here */
+	    if (wip->wi_win == wp)
+		return FALSE;
+	return TRUE;
+    }
+    return FALSE;
+}
+#endif
+
 /*
  * Find info for the current window in buffer "buf".
  * If not found, return the info for the most recently used window.
+ * When "skip_diff_buffer" is TRUE avoid windows with 'diff' set that is in
+ * another tab page.
  * Returns NULL when there isn't any info.
  */
     static wininfo_T *
-find_wininfo(buf)
+find_wininfo(buf, skip_diff_buffer)
     buf_T	*buf;
+    int		skip_diff_buffer UNUSED;
 {
     wininfo_T	*wip;
 
     for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next)
-	if (wip->wi_win == curwin)
+	if (wip->wi_win == curwin
+#ifdef FEAT_DIFF
+		&& (!skip_diff_buffer || !wininfo_other_tab_diff(wip))
+#endif
+	   )
 	    break;
-    if (wip == NULL)	/* if no fpos for curwin, use the first in the list */
-	wip = buf->b_wininfo;
+
+    /* If no wininfo for curwin, use the first in the list (that doesn't have
+     * 'diff' set and is in another tab page). */
+    if (wip == NULL)
+    {
+#ifdef FEAT_DIFF
+	if (skip_diff_buffer)
+	{
+	    for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next)
+		if (!wininfo_other_tab_diff(wip))
+		    break;
+	}
+	else
+#endif
+	    wip = buf->b_wininfo;
+    }
     return wip;
 }
 
 /*
  * Reset the local window options to the values last used in this window.
@@ -2434,11 +2486,11 @@ get_winopts(buf)
     clear_winopt(&curwin->w_onebuf_opt);
 #ifdef FEAT_FOLDING
     clearFolding(curwin);
 #endif
 
-    wip = find_wininfo(buf);
+    wip = find_wininfo(buf, TRUE);
     if (wip != NULL && wip->wi_optset)
     {
 	copy_winopt(&wip->wi_opt, &curwin->w_onebuf_opt);
 #ifdef FEAT_FOLDING
 	curwin->w_fold_manual = wip->wi_fold_manual;
@@ -2464,13 +2516,13 @@ get_winopts(buf)
     pos_T *
 buflist_findfpos(buf)
     buf_T	*buf;
 {
     wininfo_T	*wip;
-    static pos_T no_position = {1, 0};
+    static pos_T no_position = INIT_POS_T(1, 0, 0);
 
-    wip = find_wininfo(buf);
+    wip = find_wininfo(buf, FALSE);
     if (wip != NULL)
 	return &(wip->wi_fpos);
     else
 	return &no_position;
 }
@@ -2487,11 +2539,10 @@ buflist_findlnum(buf)
 
 #if defined(FEAT_LISTCMDS) || defined(PROTO)
 /*
  * List all know file names (for :files and :buffers command).
  */
-/*ARGSUSED*/
     void
 buflist_list(eap)
     exarg_T	*eap;
 {
     buf_T	*buf;
@@ -2525,12 +2576,12 @@ buflist_list(eap)
 	i = 40 - vim_strsize(IObuff);
 	do
 	{
 	    IObuff[len++] = ' ';
 	} while (--i > 0 && len < IOSIZE - 18);
-	vim_snprintf((char *)IObuff + len, IOSIZE - len, _("line %ld"),
-		buf == curbuf ? curwin->w_cursor.lnum
+	vim_snprintf((char *)IObuff + len, (size_t)(IOSIZE - len),
+		_("line %ld"), buf == curbuf ? curwin->w_cursor.lnum
 					       : (long)buflist_findlnum(buf));
 	msg_outtrans(IObuff);
 	out_flush();	    /* output one line at a time */
 	ui_breakcheck();
     }
@@ -2640,13 +2691,14 @@ setfname(buf, ffname, sfname, message)
 	buf->b_sfname = sfname;
     }
     buf->b_fname = buf->b_sfname;
 #ifdef UNIX
     if (st.st_dev == (dev_T)-1)
-	buf->b_dev = -1;
+	buf->b_dev_valid = FALSE;
     else
     {
+	buf->b_dev_valid = TRUE;
 	buf->b_dev = st.st_dev;
 	buf->b_ino = st.st_ino;
     }
 #endif
 
@@ -2787,18 +2839,18 @@ buflist_slash_adjust()
     }
 }
 #endif
 
 /*
- * Set alternate cursor position for current window.
+ * Set alternate cursor position for the current buffer and window "win".
  * Also save the local window option values.
  */
     void
-buflist_altfpos()
+buflist_altfpos(win)
+    win_T *win;
 {
-    buflist_setfpos(curbuf, curwin, curwin->w_cursor.lnum,
-						  curwin->w_cursor.col, TRUE);
+    buflist_setfpos(curbuf, win, win->w_cursor.lnum, win->w_cursor.col, TRUE);
 }
 
 /*
  * Return TRUE if 'ffname' is not the same file as current file.
  * Fname must have a full path (expanded by mch_FullName()).
@@ -2836,11 +2888,11 @@ otherfile_buf(buf, ffname
 	struct stat	st;
 
 	/* If no struct stat given, get it now */
 	if (stp == NULL)
 	{
-	    if (buf->b_dev < 0 || mch_stat((char *)ffname, &st) < 0)
+	    if (!buf->b_dev_valid || mch_stat((char *)ffname, &st) < 0)
 		st.st_dev = (dev_T)-1;
 	    stp = &st;
 	}
 	/* Use dev/ino to check if the files are the same, even when the names
 	 * are different (possible with links).  Still need to compare the
@@ -2873,26 +2925,27 @@ buf_setino(buf)
 {
     struct stat	st;
 
     if (buf->b_fname != NULL && mch_stat((char *)buf->b_fname, &st) >= 0)
     {
+	buf->b_dev_valid = TRUE;
 	buf->b_dev = st.st_dev;
 	buf->b_ino = st.st_ino;
     }
     else
-	buf->b_dev = -1;
+	buf->b_dev_valid = FALSE;
 }
 
 /*
  * Return TRUE if dev/ino in buffer "buf" matches with "stp".
  */
     static int
 buf_same_ino(buf, stp)
     buf_T	*buf;
     struct stat *stp;
 {
-    return (buf->b_dev >= 0
+    return (buf->b_dev_valid
 	    && stp->st_dev == buf->b_dev
 	    && stp->st_ino == buf->b_ino);
 }
 #endif
 
@@ -2915,11 +2968,11 @@ fileinfo(fullname, shorthelp, dont_trunc
     if (buffer == NULL)
 	return;
 
     if (fullname > 1)	    /* 2 CTRL-G: include buffer number */
     {
-	sprintf((char *)buffer, "buf %d: ", curbuf->b_fnum);
+	vim_snprintf((char *)buffer, IOSIZE, "buf %d: ", curbuf->b_fnum);
 	p = buffer + STRLEN(buffer);
     }
     else
 	p = buffer;
 
@@ -2989,15 +3042,16 @@ fileinfo(fullname, shorthelp, dont_trunc
 		_("line %ld of %ld --%d%%-- col "),
 		(long)curwin->w_cursor.lnum,
 		(long)curbuf->b_ml.ml_line_count,
 		n);
 	validate_virtcol();
-	col_print(buffer + STRLEN(buffer),
+	len = STRLEN(buffer);
+	col_print(buffer + len, IOSIZE - len,
 		   (int)curwin->w_cursor.col + 1, (int)curwin->w_virtcol + 1);
     }
 
-    (void)append_arg_number(curwin, buffer, !shortmess(SHM_FILE), IOSIZE);
+    (void)append_arg_number(curwin, buffer, IOSIZE, !shortmess(SHM_FILE));
 
     if (dont_truncate)
     {
 	/* Temporarily set msg_scroll to avoid the message being truncated.
 	 * First call msg_start() to get the message in the right place. */
@@ -3021,19 +3075,20 @@ fileinfo(fullname, shorthelp, dont_trunc
 
     vim_free(buffer);
 }
 
     void
-col_print(buf, col, vcol)
+col_print(buf, buflen, col, vcol)
     char_u  *buf;
+    size_t  buflen;
     int	    col;
     int	    vcol;
 {
     if (col == vcol)
-	sprintf((char *)buf, "%d", col);
+	vim_snprintf((char *)buf, buflen, "%d", col);
     else
-	sprintf((char *)buf, "%d-%d", col, vcol);
+	vim_snprintf((char *)buf, buflen, "%d-%d", col, vcol);
 }
 
 #if defined(FEAT_TITLE) || defined(PROTO)
 /*
  * put file name in title bar of window and in icon title
@@ -3142,22 +3197,22 @@ maketitle()
 		/* remove the file name */
 		p = gettail_sep(buf + off);
 		if (p == buf + off)
 		    /* must be a help buffer */
 		    vim_strncpy(buf + off, (char_u *)_("help"),
-							    IOSIZE - off - 1);
+						  (size_t)(IOSIZE - off - 1));
 		else
 		    *p = NUL;
 
 		/* translate unprintable chars */
 		p = transstr(buf + off);
-		vim_strncpy(buf + off, p, IOSIZE - off - 1);
+		vim_strncpy(buf + off, p, (size_t)(IOSIZE - off - 1));
 		vim_free(p);
 		STRCAT(buf, ")");
 	    }
 
-	    append_arg_number(curwin, buf, FALSE, IOSIZE);
+	    append_arg_number(curwin, buf, IOSIZE, FALSE);
 
 #if defined(FEAT_CLIENTSERVER)
 	    if (serverName != NULL)
 	    {
 		STRCAT(buf, " - ");
@@ -3290,18 +3345,17 @@ free_titles()
  * Item: %-<minwid>.<maxwid><itemch> All but <itemch> are optional
  *
  * If maxwidth is not zero, the string will be filled at any middle marker
  * or truncated if too long, fillchar is used for all whitespace.
  */
-/*ARGSUSED*/
     int
 build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hltab, tabtab)
     win_T	*wp;
     char_u	*out;		/* buffer to write into != NameBuff */
     size_t	outlen;		/* length of out[] */
     char_u	*fmt;
-    int		use_sandbox;	/* "fmt" was set insecurely, use sandbox */
+    int		use_sandbox UNUSED; /* "fmt" was set insecurely, use sandbox */
     int		fillchar;
     int		maxwidth;
     struct stl_hlrec *hltab;	/* return: HL attributes (can be NULL) */
     struct stl_hlrec *tabtab;	/* return: tab page nrs (can be NULL) */
 {
@@ -3468,11 +3522,11 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 		else
 #endif
 		    n = (long)(p - t) - item[groupitem[groupdepth]].maxwid + 1;
 
 		*t = '<';
-		mch_memmove(t + 1, t + n, p - (t + n));
+		mch_memmove(t + 1, t + n, (size_t)(p - (t + n)));
 		p = p - n + 1;
 #ifdef FEAT_MBYTE
 		/* Fill up space left over by half a double-wide char. */
 		while (++l < item[groupitem[groupdepth]].minwid)
 		    *p++ = fillchar;
@@ -3498,11 +3552,11 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 			*p++ = fillchar;
 		}
 		else
 		{
 		    /* fill by inserting characters */
-		    mch_memmove(t + n - l, t, p - t);
+		    mch_memmove(t + n - l, t, (size_t)(p - t));
 		    l = n - l;
 		    if (p + l >= out + outlen)
 			l = (long)((out + outlen) - p - 1);
 		    p += l;
 		    for (n = groupitem[groupdepth] + 1; n < curitem; n++)
@@ -3634,11 +3688,11 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 	    s++;
 	    *p = 0;
 	    p = t;
 
 #ifdef FEAT_EVAL
-	    sprintf((char *)tmp, "%d", curbuf->b_fnum);
+	    vim_snprintf((char *)tmp, sizeof(tmp), "%d", curbuf->b_fnum);
 	    set_internal_string_var((char_u *)"actual_curbuf", tmp);
 
 	    o_curbuf = curbuf;
 	    o_curwin = curwin;
 	    curwin = wp;
@@ -3701,17 +3755,17 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 			(long)wp->w_buffer->b_ml.ml_line_count);
 	    break;
 
 	case STL_ALTPERCENT:
 	    str = tmp;
-	    get_rel_pos(wp, str);
+	    get_rel_pos(wp, str, TMPLEN);
 	    break;
 
 	case STL_ARGLISTSTAT:
 	    fillable = FALSE;
 	    tmp[0] = 0;
-	    if (append_arg_number(wp, tmp, FALSE, (int)sizeof(tmp)))
+	    if (append_arg_number(wp, tmp, (int)sizeof(tmp), FALSE))
 		str = tmp;
 	    break;
 
 	case STL_KEYMAP:
 	    fillable = FALSE;
@@ -3742,11 +3796,11 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 	    break;
 
 	case STL_BYTEVAL_X:
 	    base = 'X';
 	case STL_BYTEVAL:
-	    if (wp->w_cursor.col > STRLEN(linecont))
+	    if (wp->w_cursor.col > (colnr_T)STRLEN(linecont))
 		num = 0;
 	    else
 	    {
 #ifdef FEAT_MBYTE
 		num = (*mb_ptr2char)(linecont + wp->w_cursor.col);
@@ -3915,11 +3969,11 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 	    }
 	    *t++ = '%';
 	    if (zeropad)
 		*t++ = '0';
 	    *t++ = '*';
-	    *t++ = nbase == 16 ? base : (nbase == 8 ? 'o' : 'd');
+	    *t++ = nbase == 16 ? base : (char_u)(nbase == 8 ? 'o' : 'd');
 	    *t = 0;
 
 	    for (n = num, l = 1; n >= nbase; n /= nbase)
 		l++;
 	    if (opt == STL_VIRTCOL_ALT)
@@ -3961,11 +4015,11 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 #endif
 
     width = vim_strsize(out);
     if (maxwidth > 0 && width > maxwidth)
     {
-	/* Result is too long, must trunctate somewhere. */
+	/* Result is too long, must truncate somewhere. */
 	l = 0;
 	if (itemcnt == 0)
 	    s = out;
 	else
 	{
@@ -4108,64 +4162,67 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 #endif /* FEAT_STL_OPT */
 
 #if defined(FEAT_STL_OPT) || defined(FEAT_CMDL_INFO) \
 	    || defined(FEAT_GUI_TABLINE) || defined(PROTO)
 /*
- * Get relative cursor position in window into "str[]", in the form 99%, using
- * "Top", "Bot" or "All" when appropriate.
+ * Get relative cursor position in window into "buf[buflen]", in the form 99%,
+ * using "Top", "Bot" or "All" when appropriate.
  */
     void
-get_rel_pos(wp, str)
+get_rel_pos(wp, buf, buflen)
     win_T	*wp;
-    char_u	*str;
+    char_u	*buf;
+    int		buflen;
 {
     long	above; /* number of lines above window */
     long	below; /* number of lines below window */
 
     above = wp->w_topline - 1;
 #ifdef FEAT_DIFF
     above += diff_check_fill(wp, wp->w_topline) - wp->w_topfill;
 #endif
     below = wp->w_buffer->b_ml.ml_line_count - wp->w_botline + 1;
     if (below <= 0)
-	STRCPY(str, above == 0 ? _("All") : _("Bot"));
+	vim_strncpy(buf, (char_u *)(above == 0 ? _("All") : _("Bot")),
+							(size_t)(buflen - 1));
     else if (above <= 0)
-	STRCPY(str, _("Top"));
+	vim_strncpy(buf, (char_u *)_("Top"), (size_t)(buflen - 1));
     else
-	sprintf((char *)str, "%2d%%", above > 1000000L
+	vim_snprintf((char *)buf, (size_t)buflen, "%2d%%", above > 1000000L
 				    ? (int)(above / ((above + below) / 100L))
 				    : (int)(above * 100L / (above + below)));
 }
 #endif
 
 /*
- * Append (file 2 of 8) to 'buf', if editing more than one file.
+ * Append (file 2 of 8) to "buf[buflen]", if editing more than one file.
  * Return TRUE if it was appended.
  */
-    int
-append_arg_number(wp, buf, add_file, maxlen)
+    static int
+append_arg_number(wp, buf, buflen, add_file)
     win_T	*wp;
     char_u	*buf;
+    int		buflen;
     int		add_file;	/* Add "file" before the arg number */
-    int		maxlen;		/* maximum nr of chars in buf or zero*/
 {
     char_u	*p;
 
     if (ARGCOUNT <= 1)		/* nothing to do */
 	return FALSE;
 
-    p = buf + STRLEN(buf);		/* go to the end of the buffer */
-    if (maxlen && p - buf + 35 >= maxlen) /* getting too long */
+    p = buf + STRLEN(buf);	/* go to the end of the buffer */
+    if (p - buf + 35 >= buflen)	/* getting too long */
 	return FALSE;
     *p++ = ' ';
     *p++ = '(';
     if (add_file)
     {
 	STRCPY(p, "file ");
 	p += 5;
     }
-    sprintf((char *)p, wp->w_arg_idx_invalid ? "(%d) of %d)"
+    vim_snprintf((char *)p, (size_t)(buflen - (p - buf)),
+		wp->w_arg_idx_invalid ? "(%d) of %d)"
 				  : "%d of %d)", wp->w_arg_idx + 1, ARGCOUNT);
     return TRUE;
 }
 
 /*
@@ -4217,14 +4274,13 @@ fix_fname(fname)
 
 /*
  * Make "ffname" a full file name, set "sfname" to "ffname" if not NULL.
  * "ffname" becomes a pointer to allocated memory (or NULL).
  */
-/*ARGSUSED*/
     void
 fname_expand(buf, ffname, sfname)
-    buf_T	*buf;
+    buf_T	*buf UNUSED;
     char_u	**ffname;
     char_u	**sfname;
 {
     if (*ffname == NULL)	/* if no file name given, nothing to do */
 	return;
@@ -4486,11 +4542,11 @@ do_arg_all(count, forceit, keep_tabs)
 	    }
 	    (void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL,
 		      ECMD_ONE,
 		      ((P_HID(curwin->w_buffer)
 			   || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0)
-							       + ECMD_OLDBUF);
+						       + ECMD_OLDBUF, curwin);
 #ifdef FEAT_AUTOCMD
 	    if (use_firstwin)
 		++autocmd_no_leave;
 #endif
 	    use_firstwin = FALSE;
@@ -4944,11 +5000,11 @@ read_viminfo_bufferlist(virp, writing)
 	col = 0;
 	tab = vim_strrchr(xline, '\t');
 	if (tab != NULL)
 	{
 	    *tab++ = '\0';
-	    col = atoi((char *)tab);
+	    col = (colnr_T)atoi((char *)tab);
 	    tab = vim_strrchr(xline, '\t');
 	    if (tab != NULL)
 	    {
 		*tab++ = '\0';
 		lnum = atol((char *)tab);
@@ -4982,19 +5038,21 @@ write_viminfo_bufferlist(fp)
     win_T	*win;
     tabpage_T	*tp;
 #endif
     char_u	*line;
     int		max_buffers;
+    size_t	len;
 
     if (find_viminfo_parameter('%') == NULL)
 	return;
 
     /* Without a number -1 is returned: do all buffers. */
     max_buffers = get_viminfo_parameter('%');
 
     /* Allocate room for the file name, lnum and col. */
-    line = alloc(MAXPATHL + 40);
+#define LINE_BUF_LEN (MAXPATHL + 40)
+    line = alloc(LINE_BUF_LEN);
     if (line == NULL)
 	return;
 
 #ifdef FEAT_WINDOWS
     FOR_ALL_TAB_WINDOWS(tp, win)
@@ -5016,11 +5074,12 @@ write_viminfo_bufferlist(fp)
 
 	if (max_buffers-- == 0)
 	    break;
 	putc('%', fp);
 	home_replace(NULL, buf->b_ffname, line, MAXPATHL, TRUE);
-	sprintf((char *)line + STRLEN(line), "\t%ld\t%d",
+	len = STRLEN(line);
+	vim_snprintf((char *)line + len, len - LINE_BUF_LEN, "\t%ld\t%d",
 			(long)buf->b_last_cursor.lnum,
 			buf->b_last_cursor.col);
 	viminfo_writestring(fp, line);
     }
     vim_free(line);
@@ -5046,11 +5105,12 @@ buf_spname(buf)
 	 * For location list window, w_llist_ref points to the location list.
 	 * For quickfix window, w_llist_ref is NULL.
 	 */
 	FOR_ALL_TAB_WINDOWS(tp, win)
 	    if (win->w_buffer == buf)
-		break;
+		goto win_found;
+win_found:
 	if (win != NULL && win->w_llist_ref != NULL)
 	    return _("[Location List]");
 	else
 	    return _("[Quickfix List]");
     }
@@ -5060,11 +5120,11 @@ buf_spname(buf)
      * contains the name as specified by the user */
     if (bt_nofile(buf))
     {
 	if (buf->b_sfname != NULL)
 	    return (char *)buf->b_sfname;
-	return "[Scratch]";
+	return _("[Scratch]");
     }
 #endif
     if (buf->b_fname == NULL)
 	return _("[No Name]");
     return NULL;
@@ -5173,11 +5233,11 @@ buf_addsign(buf, id, lnum, typenr)
     insert_sign(buf, prev, sign, id, lnum, typenr);
 
     return;
 }
 
-    int
+    linenr_T
 buf_change_sign_type(buf, markId, typenr)
     buf_T	*buf;		/* buffer to store sign in */
     int		markId;		/* sign ID */
     int		typenr;		/* typenr of sign we are adding */
 {
@@ -5190,14 +5250,14 @@ buf_change_sign_type(buf, markId, typenr
 	    sign->typenr = typenr;
 	    return sign->lnum;
 	}
     }
 
-    return 0;
+    return (linenr_T)0;
 }
 
-    int_u
+    int
 buf_getsigntype(buf, lnum, type)
     buf_T	*buf;
     linenr_T	lnum;
     int		type;	/* SIGN_ICON, SIGN_TEXT, SIGN_ANY, SIGN_LINEHL */
 {
@@ -5512,15 +5572,14 @@ buf_contents_changed(buf)
 /*
  * Wipe out a buffer and decrement the last buffer number if it was used for
  * this buffer.  Call this to wipe out a temp buffer that does not contain any
  * marks.
  */
-/*ARGSUSED*/
     void
 wipe_buffer(buf, aucmd)
     buf_T	*buf;
-    int		aucmd;	    /* When TRUE trigger autocommands. */
+    int		aucmd UNUSED;	    /* When TRUE trigger autocommands. */
 {
     if (buf->b_fnum == top_file_num - 1)
 	--top_file_num;
 
 #ifdef FEAT_AUTOCMD
--- vim72.orig/src/charset.c
+++ vim72/src/charset.c
@@ -15,11 +15,11 @@ static int win_chartabsize __ARGS((win_T
 
 #ifdef FEAT_MBYTE
 static int win_nolbr_chartabsize __ARGS((win_T *wp, char_u *s, colnr_T col, int *headp));
 #endif
 
-static int nr2hex __ARGS((int c));
+static unsigned nr2hex __ARGS((unsigned c));
 
 static int    chartab_initialized = FALSE;
 
 /* b_chartab[] is an array of 32 bytes, each bit representing one of the
  * characters 0-255. */
@@ -172,21 +172,31 @@ buf_init_chartab(buf, global)
 		++p;
 	    }
 	    if (VIM_ISDIGIT(*p))
 		c = getdigits(&p);
 	    else
+#ifdef FEAT_MBYTE
+		 if (has_mbyte)
+		c = mb_ptr2char_adv(&p);
+	    else
+#endif
 		c = *p++;
 	    c2 = -1;
 	    if (*p == '-' && p[1] != NUL)
 	    {
 		++p;
 		if (VIM_ISDIGIT(*p))
 		    c2 = getdigits(&p);
 		else
+#ifdef FEAT_MBYTE
+		     if (has_mbyte)
+		    c2 = mb_ptr2char_adv(&p);
+		else
+#endif
 		    c2 = *p++;
 	    }
-	    if (c <= 0 || (c2 < c && c2 != -1) || c2 >= 256
+	    if (c <= 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256
 						 || !(*p == NUL || *p == ','))
 		return FAIL;
 
 	    if (c2 == -1)	/* not a range */
 	    {
@@ -662,23 +672,23 @@ transchar_hex(buf, c)
 	buf[++i] = nr2hex((unsigned)c >> 12);
 	buf[++i] = nr2hex((unsigned)c >> 8);
     }
 #endif
     buf[++i] = nr2hex((unsigned)c >> 4);
-    buf[++i] = nr2hex(c);
+    buf[++i] = nr2hex((unsigned)c);
     buf[++i] = '>';
     buf[++i] = NUL;
 }
 
 /*
  * Convert the lower 4 bits of byte "c" to its hex character.
  * Lower case letters are used to avoid the confusion of <F1> being 0xf1 or
  * function key 1.
  */
-    static int
+    static unsigned
 nr2hex(c)
-    int		c;
+    unsigned	c;
 {
     if ((c & 0xf) <= 9)
 	return (c & 0xf) + '0';
     return (c & 0xf) - 10 + 'a';
 }
@@ -882,11 +892,11 @@ vim_iswordc(c)
 {
 #ifdef FEAT_MBYTE
     if (c >= 0x100)
     {
 	if (enc_dbcs != 0)
-	    return dbcs_class((unsigned)c >> 8, c & 0xff) >= 2;
+	    return dbcs_class((unsigned)c >> 8, (unsigned)(c & 0xff)) >= 2;
 	if (enc_utf8)
 	    return utf_class(c) >= 2;
     }
 #endif
     return (c > 0 && c < 0x100 && GET_CHARTAB(curbuf, c) != 0);
@@ -1024,17 +1034,16 @@ lbr_chartabsize_adv(s, col)
  *
  * If "headp" not NULL, set *headp to the size of what we for 'showbreak'
  * string at start of line.  Warning: *headp is only set if it's a non-zero
  * value, init to 0 before calling.
  */
-/*ARGSUSED*/
     int
 win_lbr_chartabsize(wp, s, col, headp)
     win_T	*wp;
     char_u	*s;
     colnr_T	col;
-    int		*headp;
+    int		*headp UNUSED;
 {
 #ifdef FEAT_LINEBREAK
     int		c;
     int		size;
     colnr_T	col2;
@@ -1088,11 +1097,11 @@ win_lbr_chartabsize(wp, s, col, headp)
 	 * Count all characters from first non-blank after a blank up to next
 	 * non-blank after a blank.
 	 */
 	numberextra = win_col_off(wp);
 	col2 = col;
-	colmax = W_WIDTH(wp) - numberextra;
+	colmax = (colnr_T)(W_WIDTH(wp) - numberextra);
 	if (col >= colmax)
 	{
 	    n = colmax + win_col_off2(wp);
 	    if (n > 0)
 		colmax += (((col - colmax) / n) + 1) * n;
@@ -1199,23 +1208,25 @@ win_nolbr_chartabsize(wp, s, col, headp)
     int
 in_win_border(wp, vcol)
     win_T	*wp;
     colnr_T	vcol;
 {
-    colnr_T	width1;		/* width of first line (after line number) */
-    colnr_T	width2;		/* width of further lines */
+    int		width1;		/* width of first line (after line number) */
+    int		width2;		/* width of further lines */
 
 #ifdef FEAT_VERTSPLIT
     if (wp->w_width == 0)	/* there is no border */
 	return FALSE;
 #endif
     width1 = W_WIDTH(wp) - win_col_off(wp);
-    if (vcol < width1 - 1)
+    if ((int)vcol < width1 - 1)
 	return FALSE;
-    if (vcol == width1 - 1)
+    if ((int)vcol == width1 - 1)
 	return TRUE;
     width2 = width1 + win_col_off2(wp);
+    if (width2 <= 0)
+	return FALSE;
     return ((vcol - width1) % width2 == width2 - 1);
 }
 #endif /* FEAT_MBYTE */
 
 /*
@@ -1242,11 +1253,14 @@ getvcol(wp, pos, start, cursor, end)
     int		ts = wp->w_buffer->b_p_ts;
     int		c;
 
     vcol = 0;
     ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
-    posptr = ptr + pos->col;
+    if (pos->col == MAXCOL)
+	posptr = NULL;  /* continue until the NUL */
+    else
+	posptr = ptr + pos->col;
 
     /*
      * This function is used very often, do some speed optimizations.
      * When 'list', 'linebreak' and 'showbreak' are not set use a simple loop.
      * Also use this when 'list' is set but tabs take their normal size.
@@ -1300,11 +1314,11 @@ getvcol(wp, pos, start, cursor, end)
 		else
 #endif
 		    incr = CHARSIZE(c);
 	    }
 
-	    if (ptr >= posptr)	/* character at pos->col */
+	    if (posptr != NULL && ptr >= posptr) /* character at pos->col */
 		break;
 
 	    vcol += incr;
 	    mb_ptr_adv(ptr);
 	}
@@ -1321,11 +1335,11 @@ getvcol(wp, pos, start, cursor, end)
 	    {
 		incr = 1;	/* NUL at end of line only takes one column */
 		break;
 	    }
 
-	    if (ptr >= posptr)	/* character at pos->col */
+	    if (posptr != NULL && ptr >= posptr) /* character at pos->col */
 		break;
 
 	    vcol += incr;
 	    mb_ptr_adv(ptr);
 	}
@@ -1394,17 +1408,17 @@ getvvcol(wp, pos, start, cursor, end)
 	coladd = pos->coladd;
 	endadd = 0;
 # ifdef FEAT_MBYTE
 	/* Cannot put the cursor on part of a wide character. */
 	ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
-	if (pos->col < STRLEN(ptr))
+	if (pos->col < (colnr_T)STRLEN(ptr))
 	{
 	    int c = (*mb_ptr2char)(ptr + pos->col);
 
 	    if (c != TAB && vim_isprintc(c))
 	    {
-		endadd = char2cells(c) - 1;
+		endadd = (colnr_T)(char2cells(c) - 1);
 		if (coladd > endadd)	/* past end of line */
 		    endadd = 0;
 		else
 		    coladd = 0;
 	    }
--- vim72.orig/src/config.h.in
+++ vim72/src/config.h.in
@@ -28,16 +28,22 @@
 #undef HAVE_OUTFUNTYPE
 
 /* Define when __DATE__ " " __TIME__ can be used */
 #undef HAVE_DATE_TIME
 
+/* Define when __attribute__((unused)) can be used */
+#undef HAVE_ATTRIBUTE_UNUSED
+
 /* defined always when using configure */
 #undef UNIX
 
 /* Defined to the size of an int */
 #undef SIZEOF_INT
 
+/* Define when wchar_t is only 2 bytes. */
+#undef SMALL_WCHAR_T
+
 /*
  * If we cannot trust one of the following from the libraries, we use our
  * own safe but probably slower vim_memmove().
  */
 #undef USEBCOPY
@@ -48,10 +54,13 @@
 #undef USEMAN_S
 
 /* Define to empty if the keyword does not work.  */
 #undef const
 
+/* Define to empty if the keyword does not work.  */
+#undef volatile
+
 /* Define to `int' if <sys/types.h> doesn't define.  */
 #undef mode_t
 
 /* Define to `long' if <sys/types.h> doesn't define.  */
 #undef off_t
@@ -133,11 +142,10 @@
 #undef HAVE_BCMP
 #undef HAVE_FCHDIR
 #undef HAVE_FCHOWN
 #undef HAVE_FSEEKO
 #undef HAVE_FSYNC
-#undef HAVE_FTELLO
 #undef HAVE_GETCWD
 #undef HAVE_GETPSEUDOTTY
 #undef HAVE_GETPWNAM
 #undef HAVE_GETPWUID
 #undef HAVE_GETRLIMIT
@@ -146,10 +154,11 @@
 #undef HAVE_ICONV
 #undef HAVE_NL_LANGINFO_CODESET
 #undef HAVE_LSTAT
 #undef HAVE_MEMCMP
 #undef HAVE_MEMSET
+#undef HAVE_MKDTEMP
 #undef HAVE_NANOSLEEP
 #undef HAVE_OPENDIR
 #undef HAVE_FLOAT_FUNCS
 #undef HAVE_PUTENV
 #undef HAVE_QSORT
@@ -376,5 +385,8 @@
 /* Define name of who modified a released Vim */
 #undef MODIFIED_BY
 
 /* Define if you want XSMP interaction as well as vanilla swapfile safety */
 #undef USE_XSMP_INTERACT
+
+/* Define if fcntl()'s F_SETFD command knows about FD_CLOEXEC */
+#undef HAVE_FD_CLOEXEC
--- vim72.orig/src/config.mk.in
+++ vim72/src/config.mk.in
@@ -39,10 +39,12 @@ X_LIBS		= @X_LIB@
 MZSCHEME_LIBS	= @MZSCHEME_LIBS@
 MZSCHEME_SRC	= @MZSCHEME_SRC@
 MZSCHEME_OBJ	= @MZSCHEME_OBJ@
 MZSCHEME_CFLAGS	= @MZSCHEME_CFLAGS@
 MZSCHEME_PRO	= @MZSCHEME_PRO@
+MZSCHEME_EXTRA  = @MZSCHEME_EXTRA@
+MZSCHEME_MZC	= @MZSCHEME_MZC@
 
 PERL		= @vi_cv_path_perl@
 PERLLIB		= @vi_cv_perllib@
 PERL_LIBS	= @PERL_LIBS@
 SHRPENV		= @shrpenv@
--- vim72.orig/src/configure.in
+++ vim72/src/configure.in
@@ -114,10 +114,26 @@ if test "`(uname) 2>/dev/null`" = Darwin
   AC_MSG_CHECKING(--with-mac-arch argument)
   AC_ARG_WITH(mac-arch, [  --with-mac-arch=ARCH    current, intel, ppc or both],
 	MACARCH="$withval"; AC_MSG_RESULT($MACARCH),
 	MACARCH="current"; AC_MSG_RESULT(defaulting to $MACARCH))
 
+  AC_MSG_CHECKING(--with-developer-dir argument)
+  AC_ARG_WITH(developer-dir, [  --with-developer-dir=PATH    use PATH as location for Xcode developer tools],
+	DEVELOPER_DIR="$withval"; AC_MSG_RESULT($DEVELOPER_DIR),
+        DEVELOPER_DIR=""; AC_MSG_RESULT(not present))
+
+  if test "x$DEVELOPER_DIR" = "x"; then
+    AC_PATH_PROG(XCODE_SELECT, xcode-select)
+    if test "x$XCODE_SELECT" != "x"; then
+      AC_MSG_CHECKING(for developer dir using xcode-select)
+      DEVELOPER_DIR=`$XCODE_SELECT -print-path`
+      AC_MSG_RESULT([$DEVELOPER_DIR])
+    else
+      DEVELOPER_DIR=/Developer
+    fi
+  fi
+
   if test "x$MACARCH" = "xboth"; then
     AC_MSG_CHECKING(for 10.4 universal SDK)
     dnl There is a terrible inconsistency (but we appear to get away with it):
     dnl $CFLAGS uses the 10.4u SDK library for the headers, while $CPPFLAGS
     dnl doesn't, because "gcc -E" doesn't grok it.  That means the configure
@@ -125,11 +141,11 @@ if test "`(uname) 2>/dev/null`" = Darwin
     dnl files. $LDFLAGS is set at the end, because configure uses it together
     dnl with $CFLAGS and we can only have one -sysroot argument.
     save_cppflags="$CPPFLAGS"
     save_cflags="$CFLAGS"
     save_ldflags="$LDFLAGS"
-    CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
+    CFLAGS="$CFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
     AC_TRY_LINK([ ], [ ],
 	AC_MSG_RESULT(found, will make universal binary),
 
 	AC_MSG_RESULT(not found)
 	CFLAGS="$save_cflags"
@@ -155,13 +171,13 @@ if test "`(uname) 2>/dev/null`" = Darwin
     OS_EXTRA_SRC="os_macosx.c os_mac_conv.c";
     OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o"
     dnl TODO: use -arch i386 on Intel machines
     CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX -no-cpp-precomp"
     if test "x$MACARCH" = "xboth"; then
-      CPPFLAGS="$CPPFLAGS -I/Developer/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
+      CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk/Developer/Headers/FlatCarbon"
     else
-      CPPFLAGS="$CPPFLAGS -I/Developer/Headers/FlatCarbon"
+      CPPFLAGS="$CPPFLAGS -I$DEVELOPER_DIR/Headers/FlatCarbon"
     fi
 
     dnl If Carbon is found, assume we don't want X11
     dnl unless it was specifically asked for (--with-x)
     dnl or Motif, Athena or GTK GUI is used.
@@ -412,11 +428,11 @@ if test "$enable_mzschemeinterp" = "yes"
     AC_MSG_CHECKING(PLTHOME environment var)
     if test "X$PLTHOME" != "X"; then
 	AC_MSG_RESULT("$PLTHOME")
 	vi_cv_path_mzscheme_pfx="$PLTHOME"
     else
-	AC_MSG_RESULT("not set")
+	AC_MSG_RESULT(not set)
 	dnl -- try to find MzScheme executable
 	AC_PATH_PROG(vi_cv_path_mzscheme, mzscheme)
 
 	dnl resolve symbolic link, the executable is often elsewhere and there
 	dnl are no links for the include files.
@@ -428,60 +444,85 @@ if test "$enable_mzschemeinterp" = "yes"
 	fi
 
 	if test "X$vi_cv_path_mzscheme" != "X"; then
 	    dnl -- find where MzScheme thinks it was installed
 	    AC_CACHE_CHECK(MzScheme install prefix,vi_cv_path_mzscheme_pfx,
-	    [ vi_cv_path_mzscheme_pfx=`
-	    ${vi_cv_path_mzscheme} -evm \
-	    "(display (simplify-path		\
+	    dnl different versions of MzScheme differ in command line processing
+	    dnl use universal approach
+	    echo "(display (simplify-path		\
 	       (build-path (call-with-values	\
 		(lambda () (split-path (find-system-path (quote exec-file)))) \
-		(lambda (base name must-be-dir?) base)) (quote up))))"` ])
-	    dnl Remove a trailing slash.
-	    vi_cv_path_mzscheme_pfx=`echo "$vi_cv_path_mzscheme_pfx" | sed 's+/$++'`
+		(lambda (base name must-be-dir?) base)) (quote up))))" > mzdirs.scm
+	    dnl Remove a trailing slash
+	    [ vi_cv_path_mzscheme_pfx=`${vi_cv_path_mzscheme} -r mzdirs.scm | \
+		sed -e 's+/$++'` ])
+	    rm -f mzdirs.scm
 	fi
     fi
   fi
 
   SCHEME_INC=
   if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
     AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include)
     if test -f $vi_cv_path_mzscheme_pfx/include/scheme.h; then
-      AC_MSG_RESULT("yes")
+      SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include
+      AC_MSG_RESULT(yes)
     else
-      AC_MSG_RESULT("no")
-      AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/plt/include)
+      AC_MSG_RESULT(no)
+      AC_MSG_CHECKING(if scheme.h can be found in $vi_cv_path_mzscheme_pfx/include/plt)
       if test -f $vi_cv_path_mzscheme_pfx/include/plt/scheme.h; then
-	AC_MSG_RESULT("yes")
-	SCHEME_INC=/plt
+	AC_MSG_RESULT(yes)
+	SCHEME_INC=${vi_cv_path_mzscheme_pfx}/include/plt
       else
-	AC_MSG_RESULT("no")
-	vi_cv_path_mzscheme_pfx=
+	AC_MSG_RESULT(no)
+	AC_MSG_CHECKING(if scheme.h can be found in /usr/include/plt/)
+	if test -f /usr/include/plt/scheme.h; then
+	  AC_MSG_RESULT(yes)
+	  SCHEME_INC=/usr/include/plt
+	else
+	  AC_MSG_RESULT(no)
+	  vi_cv_path_mzscheme_pfx=
+	fi
       fi
     fi
   fi
 
   if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
     if test "x$MACOSX" = "xyes"; then
       MZSCHEME_LIBS="-framework PLT_MzScheme"
+    elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
+      MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
+      MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
     elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
       MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
     else
-      MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
+      dnl Using shared objects
+      if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.so"; then
+        MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme3m"
+	MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
+      else
+        MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
+      fi
       if test "$GCC" = yes; then
 	dnl Make Vim remember the path to the library.  For when it's not in
 	dnl $LD_LIBRARY_PATH.
-	MZSCHEME_LIBS="$MZSCHEME_LIBS -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
+	MZSCHEME_LIBS="${MZSCHEME_LIBS} -Wl,-rpath -Wl,${vi_cv_path_mzscheme_pfx}/lib"
       elif test "`(uname) 2>/dev/null`" = SunOS &&
 			       uname -r | grep '^5' >/dev/null; then
-	MZSCHEME_LIBS="$MZSCHEME_LIBS -R ${vi_cv_path_mzscheme_pfx}/lib"
+	MZSCHEME_LIBS="${MZSCHEME_LIBS} -R ${vi_cv_path_mzscheme_pfx}/lib"
       fi
     fi
     if test -d $vi_cv_path_mzscheme_pfx/lib/plt/collects; then
       SCHEME_COLLECTS=lib/plt/
     fi
-    MZSCHEME_CFLAGS="-I${vi_cv_path_mzscheme_pfx}/include${SCHEME_INC}   \
+    if test -f "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.ss" ; then
+      dnl need to generate bytecode for MzScheme base
+      MZSCHEME_EXTRA="mzscheme_base.c"
+      MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -DINCLUDE_MZSCHEME_BASE"
+      MZSCHEME_MZC="${vi_cv_path_mzscheme_pfx}/bin/mzc"
+    fi
+    MZSCHEME_CFLAGS="${MZSCHEME_CFLAGS} -I${SCHEME_INC} \
       -DMZSCHEME_COLLECTS='\"${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects\"'"
     MZSCHEME_SRC="if_mzsch.c"
     MZSCHEME_OBJ="objects/if_mzsch.o"
     MZSCHEME_PRO="if_mzsch.pro"
     AC_DEFINE(FEAT_MZSCHEME)
@@ -489,10 +530,12 @@ if test "$enable_mzschemeinterp" = "yes"
   AC_SUBST(MZSCHEME_SRC)
   AC_SUBST(MZSCHEME_OBJ)
   AC_SUBST(MZSCHEME_PRO)
   AC_SUBST(MZSCHEME_LIBS)
   AC_SUBST(MZSCHEME_CFLAGS)
+  AC_SUBST(MZSCHEME_EXTRA)
+  AC_SUBST(MZSCHEME_MZC)
 fi
 
 
 AC_MSG_CHECKING(--enable-perlinterp argument)
 AC_ARG_ENABLE(perlinterp,
@@ -657,11 +700,11 @@ if test "$enable_pythoninterp" = "yes";
 
       AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python_conf,
       [
 	vi_cv_path_python_conf=
 	for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
-	  for subdir in lib share; do
+	  for subdir in lib64 lib share; do
 	    d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
 	    if test -d "$d" && test -f "$d/config.c"; then
 	      vi_cv_path_python_conf="$d"
 	    fi
 	  done
@@ -920,21 +963,31 @@ AC_MSG_CHECKING(--enable-rubyinterp argu
 AC_ARG_ENABLE(rubyinterp,
 	[  --enable-rubyinterp     Include Ruby interpreter.], ,
 	[enable_rubyinterp="no"])
 AC_MSG_RESULT($enable_rubyinterp)
 if test "$enable_rubyinterp" = "yes"; then
+  AC_MSG_CHECKING(--with-ruby-command argument)
+  AC_ARG_WITH(ruby-command, [  --with-ruby-command=RUBY  name of the Ruby command (default: ruby)],
+	RUBY_CMD="$withval"; AC_MSG_RESULT($RUBY_CMD),
+	RUBY_CMD="ruby"; AC_MSG_RESULT(defaulting to $RUBY_CMD))
   AC_SUBST(vi_cv_path_ruby)
-  AC_PATH_PROG(vi_cv_path_ruby, ruby)
+  AC_PATH_PROG(vi_cv_path_ruby, $RUBY_CMD)
   if test "X$vi_cv_path_ruby" != "X"; then
     AC_MSG_CHECKING(Ruby version)
     if $vi_cv_path_ruby -e '(VERSION rescue RUBY_VERSION) >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then
       AC_MSG_RESULT(OK)
       AC_MSG_CHECKING(Ruby header files)
-      rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
+      rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG[["rubyhdrdir"]] || Config::CONFIG[["archdir"]] || $hdrdir' 2>/dev/null`
       if test "X$rubyhdrdir" != "X"; then
 	AC_MSG_RESULT($rubyhdrdir)
 	RUBY_CFLAGS="-I$rubyhdrdir"
+        rubyarch=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["arch"]]'`
+        if test -d "$rubyhdrdir/$rubyarch"; then
+          RUBY_CFLAGS="$RUBY_CFLAGS -I$rubyhdrdir/$rubyarch"
+        fi
+        rubyversion=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["ruby_version"]].gsub(/\./, "")[[0,2]]'`
+        RUBY_CFLAGS="$RUBY_CFLAGS -DRUBY_VERSION=$rubyversion"
 	rubylibs=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LIBS"]]'`
 	if test "X$rubylibs" != "X"; then
 	  RUBY_LIBS="$rubylibs"
 	fi
 	librubyarg=`$vi_cv_path_ruby -r rbconfig -e 'print Config.expand(Config::CONFIG[["LIBRUBYARG"]])'`
@@ -955,18 +1008,24 @@ if test "$enable_rubyinterp" = "yes"; th
 	if test "X$librubyarg" != "X"; then
 	  RUBY_LIBS="$librubyarg $RUBY_LIBS"
 	fi
 	rubyldflags=`$vi_cv_path_ruby -r rbconfig -e 'print Config::CONFIG[["LDFLAGS"]]'`
 	if test "X$rubyldflags" != "X"; then
-	  LDFLAGS="$rubyldflags $LDFLAGS"
+	  dnl Ruby on Mac OS X 10.5 adds "-arch" flags but these should only
+	  dnl be included if requested by passing --with-mac-arch to
+	  dnl configure, so strip these flags first (if present)
+	  rubyldflags=`echo "$rubyldflags" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//'`
+	  if test "X$rubyldflags" != "X"; then
+	    LDFLAGS="$rubyldflags $LDFLAGS"
+	  fi
 	fi
 	RUBY_SRC="if_ruby.c"
 	RUBY_OBJ="objects/if_ruby.o"
 	RUBY_PRO="if_ruby.pro"
 	AC_DEFINE(FEAT_RUBY)
       else
-	AC_MSG_RESULT(not found, disabling Ruby)
+	AC_MSG_RESULT(not found; disabling Ruby)
       fi
     else
       AC_MSG_RESULT(too old; need Ruby version 1.6.0 or later)
     fi
   fi
@@ -1191,10 +1250,32 @@ else
     )
     CFLAGS=$cflags_save
 
     LDFLAGS="$ac_save_LDFLAGS"
 
+    AC_MSG_CHECKING(size of wchar_t is 2 bytes)
+    AC_CACHE_VAL(ac_cv_small_wchar_t,
+	[AC_TRY_RUN([
+#include <X11/Xlib.h>
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#endif
+		main()
+		{
+		  if (sizeof(wchar_t) <= 2)
+		    exit(1);
+		  exit(0);
+		}],
+		ac_cv_small_wchar_t="no",
+		ac_cv_small_wchar_t="yes",
+		AC_MSG_ERROR(failed to compile test program))])
+    AC_MSG_RESULT($ac_cv_small_wchar_t)
+    if test "x$ac_cv_small_wchar_t" = "xyes" ; then
+      AC_DEFINE(SMALL_WCHAR_T)
+    fi
+
   fi
 fi
 
 test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
 
@@ -2065,10 +2146,15 @@ fi
 AC_MSG_CHECKING(whether __DATE__ and __TIME__ work)
 AC_TRY_COMPILE([#include <stdio.h>], [printf("(" __DATE__ " " __TIME__ ")");],
 	AC_MSG_RESULT(yes); AC_DEFINE(HAVE_DATE_TIME),
 	AC_MSG_RESULT(no))
 
+AC_MSG_CHECKING(whether __attribute__((unused)) is allowed)
+AC_TRY_COMPILE([#include <stdio.h>], [int x __attribute__((unused));],
+	AC_MSG_RESULT(yes); AC_DEFINE(HAVE_ATTRIBUTE_UNUSED),
+	AC_MSG_RESULT(no))
+
 dnl Checks for header files.
 AC_CHECK_HEADER(elf.h, HAS_ELF=1)
 dnl AC_CHECK_HEADER(dwarf.h, SVR4=1)
 if test "$HAS_ELF" = 1; then
   AC_CHECK_LIB(elf, main)
@@ -2093,18 +2179,24 @@ AC_CHECK_HEADERS(stdarg.h stdlib.h strin
 	iconv.h langinfo.h math.h unistd.h stropts.h errno.h \
 	sys/resource.h sys/systeminfo.h locale.h \
 	sys/stream.h termios.h libc.h sys/statfs.h \
 	poll.h sys/poll.h pwd.h utime.h sys/param.h libintl.h \
 	libgen.h util/debug.h util/msg18n.h frame.h \
-	sys/acl.h sys/access.h sys/sysctl.h sys/sysinfo.h wchar.h wctype.h)
+	sys/acl.h sys/access.h sys/sysinfo.h wchar.h wctype.h)
 
 dnl sys/ptem.h depends on sys/stream.h on Solaris
 AC_CHECK_HEADERS(sys/ptem.h, [], [],
 [#if defined HAVE_SYS_STREAM_H
 #  include <sys/stream.h>
 #endif])
 
+dnl sys/sysctl.h depends on sys/param.h on OpenBSD
+AC_CHECK_HEADERS(sys/sysctl.h, [], [],
+[#if defined HAVE_SYS_PARAM_H
+#  include <sys/param.h>
+#endif])
+
 
 dnl pthread_np.h may exist but can only be used after including pthread.h
 AC_MSG_CHECKING([for pthread_np.h])
 AC_TRY_COMPILE([
 #include <pthread.h>
@@ -2146,10 +2238,11 @@ CPPFLAGS=$cppflags_save
 fi
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_PROG_GCC_TRADITIONAL
 AC_C_CONST
+AC_C_VOLATILE
 AC_TYPE_MODE_T
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
 AC_TYPE_SIZE_T
 AC_TYPE_UID_T
@@ -2488,15 +2581,15 @@ main()
 	  vim_cv_tty_mode=0620
 	fi
 	AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
       else
 	vim_cv_tty_group=world
-	AC_MSG_RESULT([ptys are world accessable])
+	AC_MSG_RESULT([ptys are world accessible])
       fi
     ],[
       vim_cv_tty_group=world
-      AC_MSG_RESULT([can't determine - assume ptys are world accessable])
+      AC_MSG_RESULT([can't determine - assume ptys are world accessible])
     ],[
       AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
     ])
   ])
 rm -f conftest_grp
@@ -2563,18 +2656,20 @@ main()
 
 if test "x$vim_cv_getcwd_broken" = "xyes" ; then
   AC_DEFINE(BAD_GETCWD)
 fi
 
-dnl Check for functions in one big call, to reduce the size of configure
-AC_CHECK_FUNCS(bcmp fchdir fchown fseeko fsync ftello getcwd getpseudotty \
+dnl Check for functions in one big call, to reduce the size of configure.
+dnl Can only be used for functions that do not require any include.
+AC_CHECK_FUNCS(bcmp fchdir fchown fsync getcwd getpseudotty \
 	getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
-	memset nanosleep opendir putenv qsort readlink select setenv \
+	memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
 	setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
 	sigvec strcasecmp strerror strftime stricmp strncasecmp \
 	strnicmp strpbrk strtol tgetent towlower towupper iswupper \
 	usleep utime utimes)
+AC_FUNC_FSEEKO
 
 dnl fstatfs() can take 2 to 4 arguments, try to use st_blksize if possible
 AC_MSG_CHECKING(for st_blksize)
 AC_TRY_COMPILE(
 [#include <sys/types.h>
@@ -2786,10 +2881,20 @@ if test "$enable_sysmouse" = "yes"; then
   fi
 else
   AC_MSG_RESULT(yes)
 fi
 
+dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
+AC_MSG_CHECKING(for FD_CLOEXEC)
+AC_TRY_COMPILE(
+[#if HAVE_FCNTL_H
+# include <fcntl.h>
+#endif],
+[	int flag = FD_CLOEXEC;],
+	AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
+	AC_MSG_RESULT(not usable))
+
 dnl rename needs to be checked separately to work on Nextstep with cc
 AC_MSG_CHECKING(for rename)
 AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
 	AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
 	AC_MSG_RESULT(no))
@@ -2867,11 +2972,10 @@ main()
 	    ac_cv_sizeof_int=0,
 	    AC_MSG_ERROR(failed to compile test program))])
 AC_MSG_RESULT($ac_cv_sizeof_int)
 AC_DEFINE_UNQUOTED(SIZEOF_INT, $ac_cv_sizeof_int)
 
-
 dnl Check for memmove() before bcopy(), makes memmove() be used when both are
 dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
 
 [bcopy_test_prog='
 #include "confdefs.h"
@@ -2949,11 +3053,11 @@ dnl Find out if _Xsetlocale() is support
 dnl Check if X_LOCALE should be defined.
 
 if test "$enable_multibyte" = "yes"; then
   cflags_save=$CFLAGS
   ldflags_save=$LDFLAGS
-  if test -n "$x_includes" ; then
+  if test "x$x_includes" != "xNONE" ; then
     CFLAGS="$CFLAGS -I$x_includes"
     LDFLAGS="$X_LIBS $LDFLAGS -lX11"
     AC_MSG_CHECKING(whether X_LOCALE needed)
     AC_TRY_COMPILE([#include <X11/Xlocale.h>],,
 	AC_TRY_LINK_FUNC([_Xsetlocale], [AC_MSG_RESULT(yes)
@@ -2965,11 +3069,11 @@ if test "$enable_multibyte" = "yes"; the
 fi
 
 dnl Link with xpg4, it is said to make Korean locale working
 AC_CHECK_LIB(xpg4, _xpg4_setrunelocale, [LIBS="$LIBS -lxpg4"],,)
 
-dnl Check how we can run ctags
+dnl Check how we can run ctags.  Default to "ctags" when nothing works.
 dnl --version for Exuberant ctags (preferred)
 dnl       Add --fields=+S to get function signatures for omni completion.
 dnl -t for typedefs (many ctags have this)
 dnl -s for static functions (Elvis ctags only?)
 dnl -v for variables. Dangerous, most ctags take this for 'vgrind style'.
@@ -2977,10 +3081,11 @@ dnl -i+m to test for older Exuberant cta
 AC_MSG_CHECKING(how to create tags)
 test -f tags && mv tags tags.save
 if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&AC_FD_CC 2>&1; then
   TAGPRG="ctags -I INIT+ --fields=+S"
 else
+  TAGPRG="ctags"
   (eval etags	   /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags"
   (eval etags -c   /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="etags -c"
   (eval ctags	   /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags"
   (eval ctags -t   /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -t"
   (eval ctags -ts  /dev/null) < /dev/null 1>&AC_FD_CC 2>&1 && TAGPRG="ctags -ts"
@@ -3142,30 +3247,38 @@ if test "x$MACOSX" = "xyes" && test "x$C
   else
     AC_MSG_RESULT(no)
   fi
 fi
 if test "x$MACARCH" = "xboth"; then
-  LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
+  LDFLAGS="$LDFLAGS -isysroot $DEVELOPER_DIR/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
 fi
 
 dnl gcc 3.1 changed the meaning of -MM.  The only solution appears to be to
 dnl use "-isystem" instead of "-I" for all non-Vim include dirs.
 dnl But only when making dependencies, cproto and lint don't take "-isystem".
 dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
 dnl the number before the version number.
-AC_MSG_CHECKING(for GCC 3 or later)
 DEPEND_CFLAGS_FILTER=
 if test "$GCC" = yes; then
+  AC_MSG_CHECKING(for GCC 3 or later)
   gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
   if test "$gccmajor" -gt "2"; then
     DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
+    AC_MSG_RESULT(yes)
+  else
+    AC_MSG_RESULT(no)
+  fi
+  dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
+  dnl declared as char x[1] but actually longer.  Introduced in gcc 4.0.
+  dnl Also remove duplicate _FORTIFY_SOURCE arguments.
+  AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
+  if test "$gccmajor" -gt "3"; then
+    CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -D_FORTIFY_SOURCE=1/'`
+    AC_MSG_RESULT(yes)
+  else
+    AC_MSG_RESULT(no)
   fi
-fi
-if test "$DEPEND_CFLAGS_FILTER" = ""; then
-  AC_MSG_RESULT(no)
-else
-  AC_MSG_RESULT(yes)
 fi
 AC_SUBST(DEPEND_CFLAGS_FILTER)
 
 dnl write output files
 AC_OUTPUT(auto/config.mk:config.mk.in)
--- vim72.orig/src/diff.c
+++ vim72/src/diff.c
@@ -6,11 +6,11 @@
  * Do ":help credits" in Vim to see a list of people who contributed.
  * See README.txt for an overview of the Vim source code.
  */
 
 /*
- * diff.c: code for diff'ing two or three buffers.
+ * diff.c: code for diff'ing two, three or four buffers.
  */
 
 #include "vim.h"
 
 #if defined(FEAT_DIFF) || defined(PROTO)
@@ -71,10 +71,12 @@ diff_buf_delete(buf)
 	i = diff_buf_idx_tp(buf, tp);
 	if (i != DB_COUNT)
 	{
 	    tp->tp_diffbuf[i] = NULL;
 	    tp->tp_diff_invalid = TRUE;
+	    if (tp == curtab)
+		diff_redraw(TRUE);
 	}
     }
 }
 
 /*
@@ -100,10 +102,11 @@ diff_buf_adjust(win)
 	    i = diff_buf_idx(win->w_buffer);
 	    if (i != DB_COUNT)
 	    {
 		curtab->tp_diffbuf[i] = NULL;
 		curtab->tp_diff_invalid = TRUE;
+		diff_redraw(TRUE);
 	    }
 	}
     }
     else
 	diff_buf_add(win->w_buffer);
@@ -111,11 +114,11 @@ diff_buf_adjust(win)
 
 /*
  * Add a buffer to make diffs for.
  * Call this when a new buffer is being edited in the current window where
  * 'diff' is set.
- * Marks the current buffer as being part of the diff and requireing updating.
+ * Marks the current buffer as being part of the diff and requiring updating.
  * This must be done before any autocmd, because a command may use info
  * about the screen contents.
  */
     void
 diff_buf_add(buf)
@@ -129,10 +132,11 @@ diff_buf_add(buf)
     for (i = 0; i < DB_COUNT; ++i)
 	if (curtab->tp_diffbuf[i] == NULL)
 	{
 	    curtab->tp_diffbuf[i] = buf;
 	    curtab->tp_diff_invalid = TRUE;
+	    diff_redraw(TRUE);
 	    return;
 	}
 
     EMSGN(_("E96: Can not diff more than %ld buffers"), DB_COUNT);
 }
@@ -646,23 +650,23 @@ diff_write(buf, fname)
  * Completely update the diffs for the buffers involved.
  * This uses the ordinary "diff" command.
  * The buffers are written to a file, also for unmodified buffers (the file
  * could have been produced by autocommands, e.g. the netrw plugin).
  */
-/*ARGSUSED*/
     void
 ex_diffupdate(eap)
-    exarg_T	*eap;	    /* can be NULL, it's not used */
+    exarg_T	*eap UNUSED;	    /* can be NULL */
 {
     buf_T	*buf;
     int		idx_orig;
     int		idx_new;
     char_u	*tmp_orig;
     char_u	*tmp_new;
     char_u	*tmp_diff;
     FILE	*fd;
     int		ok;
+    int		io_error = FALSE;
 
     /* Delete all diffblocks. */
     diff_clear(curtab);
     curtab->tp_diff_invalid = FALSE;
 
@@ -695,22 +699,30 @@ ex_diffupdate(eap)
      */
     for (;;)
     {
 	ok = FALSE;
 	fd = mch_fopen((char *)tmp_orig, "w");
-	if (fd != NULL)
+	if (fd == NULL)
+	    io_error = TRUE;
+	else
 	{
-	    fwrite("line1\n", (size_t)6, (size_t)1, fd);
+	    if (fwrite("line1\n", (size_t)6, (size_t)1, fd) != 1)
+		io_error = TRUE;
 	    fclose(fd);
 	    fd = mch_fopen((char *)tmp_new, "w");
-	    if (fd != NULL)
+	    if (fd == NULL)
+		io_error = TRUE;
+	    else
 	    {
-		fwrite("line2\n", (size_t)6, (size_t)1, fd);
+		if (fwrite("line2\n", (size_t)6, (size_t)1, fd) != 1)
+		    io_error = TRUE;
 		fclose(fd);
 		diff_file(tmp_orig, tmp_new, tmp_diff);
 		fd = mch_fopen((char *)tmp_diff, "r");
-		if (fd != NULL)
+		if (fd == NULL)
+		    io_error = TRUE;
+		else
 		{
 		    char_u	linebuf[LBUFLEN];
 
 		    for (;;)
 		    {
@@ -759,10 +771,12 @@ ex_diffupdate(eap)
 	if (ok)
 	    break;
     }
     if (!ok)
     {
+	if (io_error)
+	    EMSG(_("E810: Cannot read or write temp files"));
 	EMSG(_("E97: Cannot create diffs"));
 	diff_a_works = MAYBE;
 #if defined(MSWIN) || defined(MSDOS)
 	diff_bin_works = MAYBE;
 #endif
@@ -810,40 +824,42 @@ diff_file(tmp_orig, tmp_new, tmp_diff)
     char_u	*tmp_orig;
     char_u	*tmp_new;
     char_u	*tmp_diff;
 {
     char_u	*cmd;
+    size_t	len;
 
 #ifdef FEAT_EVAL
     if (*p_dex != NUL)
 	/* Use 'diffexpr' to generate the diff file. */
 	eval_diff(tmp_orig, tmp_new, tmp_diff);
     else
 #endif
     {
-	cmd = alloc((unsigned)(STRLEN(tmp_orig) + STRLEN(tmp_new)
-				+ STRLEN(tmp_diff) + STRLEN(p_srr) + 27));
+	len = STRLEN(tmp_orig) + STRLEN(tmp_new)
+				      + STRLEN(tmp_diff) + STRLEN(p_srr) + 27;
+	cmd = alloc((unsigned)len);
 	if (cmd != NULL)
 	{
 	    /* We don't want $DIFF_OPTIONS to get in the way. */
 	    if (getenv("DIFF_OPTIONS"))
 		vim_setenv((char_u *)"DIFF_OPTIONS", (char_u *)"");
 
 	    /* Build the diff command and execute it.  Always use -a, binary
 	     * differences are of no use.  Ignore errors, diff returns
 	     * non-zero when differences have been found. */
-	    sprintf((char *)cmd, "diff %s%s%s%s%s %s",
+	    vim_snprintf((char *)cmd, len, "diff %s%s%s%s%s %s",
 		    diff_a_works == FALSE ? "" : "-a ",
 #if defined(MSWIN) || defined(MSDOS)
 		    diff_bin_works == TRUE ? "--binary " : "",
 #else
 		    "",
 #endif
 		    (diff_flags & DIFF_IWHITE) ? "-b " : "",
 		    (diff_flags & DIFF_ICASE) ? "-i " : "",
 		    tmp_orig, tmp_new);
-	    append_redir(cmd, p_srr, tmp_diff);
+	    append_redir(cmd, (int)len, p_srr, tmp_diff);
 #ifdef FEAT_AUTOCMD
 	    block_autocmds();	/* Avoid ShellCmdPost stuff */
 #endif
 	    (void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT);
 #ifdef FEAT_AUTOCMD
@@ -864,20 +880,22 @@ ex_diffpatch(eap)
     exarg_T	*eap;
 {
     char_u	*tmp_orig;	/* name of original temp file */
     char_u	*tmp_new;	/* name of patched temp file */
     char_u	*buf = NULL;
+    size_t	buflen;
     win_T	*old_curwin = curwin;
     char_u	*newname = NULL;	/* name of patched file buffer */
 #ifdef UNIX
     char_u	dirbuf[MAXPATHL];
     char_u	*fullname = NULL;
 #endif
 #ifdef FEAT_BROWSE
     char_u	*browseFile = NULL;
     int		browse_flag = cmdmod.browse;
 #endif
+    struct stat st;
 
 #ifdef FEAT_BROWSE
     if (cmdmod.browse)
     {
 	browseFile = do_browse(0, (char_u *)_("Patch file"),
@@ -903,34 +921,35 @@ ex_diffpatch(eap)
 
 #ifdef UNIX
     /* Get the absolute path of the patchfile, changing directory below. */
     fullname = FullName_save(eap->arg, FALSE);
 #endif
-    buf = alloc((unsigned)(STRLEN(tmp_orig) + (
+    buflen = STRLEN(tmp_orig) + (
 # ifdef UNIX
 		    fullname != NULL ? STRLEN(fullname) :
 # endif
-		    STRLEN(eap->arg)) + STRLEN(tmp_new) + 16));
+		    STRLEN(eap->arg)) + STRLEN(tmp_new) + 16;
+    buf = alloc((unsigned)buflen);
     if (buf == NULL)
 	goto theend;
 
 #ifdef UNIX
-    /* Temporaraly chdir to /tmp, to avoid patching files in the current
+    /* Temporarily chdir to /tmp, to avoid patching files in the current
      * directory when the patch file contains more than one patch.  When we
      * have our own temp dir use that instead, it will be cleaned up when we
      * exit (any .rej files created).  Don't change directory if we can't
      * return to the current. */
     if (mch_dirname(dirbuf, MAXPATHL) != OK || mch_chdir((char *)dirbuf) != 0)
 	dirbuf[0] = NUL;
     else
     {
 # ifdef TEMPDIRNAMES
 	if (vim_tempdir != NULL)
-	    mch_chdir((char *)vim_tempdir);
+	    ignored = mch_chdir((char *)vim_tempdir);
 	else
 # endif
-	    mch_chdir("/tmp");
+	    ignored = mch_chdir("/tmp");
 	shorten_fnames(TRUE);
     }
 #endif
 
 #ifdef FEAT_EVAL
@@ -944,11 +963,12 @@ ex_diffpatch(eap)
     else
 #endif
     {
 	/* Build the patch command and execute it.  Ignore errors.  Switch to
 	 * cooked mode to allow the user to respond to prompts. */
-	sprintf((char *)buf, "patch -o %s %s < \"%s\"", tmp_new, tmp_orig,
+	vim_snprintf((char *)buf, buflen, "patch -o %s %s < \"%s\"",
+		tmp_new, tmp_orig,
 # ifdef UNIX
 		fullname != NULL ? fullname :
 # endif
 		eap->arg);
 #ifdef FEAT_AUTOCMD
@@ -978,48 +998,55 @@ ex_diffpatch(eap)
     mch_remove(buf);
     STRCPY(buf, tmp_new);
     STRCAT(buf, ".rej");
     mch_remove(buf);
 
-    if (curbuf->b_fname != NULL)
+    /* Only continue if the output file was created. */
+    if (mch_stat((char *)tmp_new, &st) < 0 || st.st_size == 0)
+	EMSG(_("E816: Cannot read patch output"));
+    else
     {
-	newname = vim_strnsave(curbuf->b_fname,
+	if (curbuf->b_fname != NULL)
+	{
+	    newname = vim_strnsave(curbuf->b_fname,
 					  (int)(STRLEN(curbuf->b_fname) + 4));
-	if (newname != NULL)
-	    STRCAT(newname, ".new");
-    }
+	    if (newname != NULL)
+		STRCAT(newname, ".new");
+	}
 
 #ifdef FEAT_GUI
-    need_mouse_correct = TRUE;
+	need_mouse_correct = TRUE;
 #endif
-    /* don't use a new tab page, each tab page has its own diffs */
-    cmdmod.tab = 0;
-
-    if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
-    {
-	/* Pretend it was a ":split fname" command */
-	eap->cmdidx = CMD_split;
-	eap->arg = tmp_new;
-	do_exedit(eap, old_curwin);
+	/* don't use a new tab page, each tab page has its own diffs */
+	cmdmod.tab = 0;
 
-	if (curwin != old_curwin)		/* split must have worked */
+	if (win_split(0, (diff_flags & DIFF_VERTICAL) ? WSP_VERT : 0) != FAIL)
 	{
-	    /* Set 'diff', 'scrollbind' on and 'wrap' off. */
-	    diff_win_options(curwin, TRUE);
-	    diff_win_options(old_curwin, TRUE);
+	    /* Pretend it was a ":split fname" command */
+	    eap->cmdidx = CMD_split;
+	    eap->arg = tmp_new;
+	    do_exedit(eap, old_curwin);
 
-	    if (newname != NULL)
+	    /* check that split worked and editing tmp_new */
+	    if (curwin != old_curwin && win_valid(old_curwin))
 	    {
-		/* do a ":file filename.new" on the patched buffer */
-		eap->arg = newname;
-		ex_file(eap);
+		/* Set 'diff', 'scrollbind' on and 'wrap' off. */
+		diff_win_options(curwin, TRUE);
+		diff_win_options(old_curwin, TRUE);
+
+		if (newname != NULL)
+		{
+		    /* do a ":file filename.new" on the patched buffer */
+		    eap->arg = newname;
+		    ex_file(eap);
 
 #ifdef FEAT_AUTOCMD
-		/* Do filetype detection with the new name. */
-		if (au_has_group((char_u *)"filetypedetect"))
-		    do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
+		    /* Do filetype detection with the new name. */
+		    if (au_has_group((char_u *)"filetypedetect"))
+			do_cmdline_cmd((char_u *)":doau filetypedetect BufRead");
 #endif
+		}
 	    }
 	}
     }
 
 theend:
@@ -1072,14 +1099,13 @@ ex_diffsplit(eap)
 }
 
 /*
  * Set options to show difs for the current window.
  */
-/*ARGSUSED*/
     void
 ex_diffthis(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     /* Set 'diff', 'scrollbind' on and 'wrap' off. */
     diff_win_options(curwin, TRUE);
 }
 
@@ -1089,30 +1115,35 @@ ex_diffthis(eap)
     void
 diff_win_options(wp, addbuf)
     win_T	*wp;
     int		addbuf;		/* Add buffer to diff. */
 {
+# ifdef FEAT_FOLDING
+    win_T *old_curwin = curwin;
+
+    /* close the manually opened folds */
+    curwin = wp;
+    newFoldLevel();
+    curwin = old_curwin;
+# endif
+
     wp->w_p_diff = TRUE;
     wp->w_p_scb = TRUE;
     wp->w_p_wrap = FALSE;
 # ifdef FEAT_FOLDING
-    {
-	win_T	    *old_curwin = curwin;
-
-	curwin = wp;
-	curbuf = curwin->w_buffer;
-	set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
+    curwin = wp;
+    curbuf = curwin->w_buffer;
+    set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff",
 						       OPT_LOCAL|OPT_FREE, 0);
-	curwin = old_curwin;
-	curbuf = curwin->w_buffer;
-	wp->w_p_fdc = diff_foldcolumn;
-	wp->w_p_fen = TRUE;
-	wp->w_p_fdl = 0;
-	foldUpdateAll(wp);
-	/* make sure topline is not halfway a fold */
-	changed_window_setting_win(wp);
-    }
+    curwin = old_curwin;
+    curbuf = curwin->w_buffer;
+    wp->w_p_fdc = diff_foldcolumn;
+    wp->w_p_fen = TRUE;
+    wp->w_p_fdl = 0;
+    foldUpdateAll(wp);
+    /* make sure topline is not halfway a fold */
+    changed_window_setting_win(wp);
 # endif
 #ifdef FEAT_SCROLLBIND
     if (vim_strchr(p_sbo, 'h') == NULL)
 	do_cmdline_cmd((char_u *)"set sbo+=hor");
 #endif
@@ -1136,11 +1167,11 @@ ex_diffoff(eap)
     int		diffwin = FALSE;
 #endif
 
     for (wp = firstwin; wp != NULL; wp = wp->w_next)
     {
-	if (wp == curwin || eap->forceit)
+	if (wp == curwin || (eap->forceit && wp->w_p_diff))
 	{
 	    /* Set 'diff', 'scrollbind' off and 'wrap' on. */
 	    wp->w_p_diff = FALSE;
 	    wp->w_p_scb = FALSE;
 	    wp->w_p_wrap = TRUE;
@@ -2112,10 +2143,12 @@ ex_diffgetput(eap)
 	if (buf == NULL)
 	{
 	    EMSG2(_("E102: Can't find buffer \"%s\""), eap->arg);
 	    return;
 	}
+	if (buf == curbuf)
+	    return;		/* nothing to do */
 	idx_other = diff_buf_idx(buf);
 	if (idx_other == DB_COUNT)
 	{
 	    EMSG2(_("E103: Buffer \"%s\" is not in diff mode"), eap->arg);
 	    return;
--- vim72.orig/src/digraph.c
+++ vim72/src/digraph.c
@@ -30,11 +30,11 @@ typedef struct digraph
 
 static int getexactdigraph __ARGS((int, int, int));
 static void printdigraph __ARGS((digr_T *));
 
 /* digraphs added by the user */
-static garray_T	user_digraphs = {0, 0, sizeof(digr_T), 10, NULL};
+static garray_T	user_digraphs = {0, 0, (int)sizeof(digr_T), 10, NULL};
 
 /*
  * Note: Characters marked with XX are not included literally, because some
  * compilers cannot handle them (Amiga SAS/C is the most picky one).
  */
@@ -2369,14 +2369,14 @@ printdigraph(dp)
 		*p++ = ' ';
 	    p += (*mb_char2bytes)(dp->result, p);
 	}
 	else
 #endif
-	    *p++ = dp->result;
+	    *p++ = (char_u)dp->result;
 	if (char2cells(dp->result) == 1)
 	    *p++ = ' ';
-	sprintf((char *)p, " %3d", dp->result);
+	vim_snprintf((char *)p, sizeof(buf) - (p - buf), " %3d", dp->result);
 	msg_outtrans(buf);
     }
 }
 
 #endif /* FEAT_DIGRAPHS */
@@ -2393,11 +2393,14 @@ typedef struct
 #define KMAP_MAXLEN 20	    /* maximum length of "from" or "to" */
 
 static void keymap_unload __ARGS((void));
 
 /*
- * Set up key mapping tables for the 'keymap' option
+ * Set up key mapping tables for the 'keymap' option.
+ * Returns NULL if OK, an error message for failure.  This only needs to be
+ * used when setting the option, not later when the value has already been
+ * checked.
  */
     char_u *
 keymap_init()
 {
     curbuf->b_kmap_state &= ~KEYMAP_INIT;
@@ -2410,29 +2413,33 @@ keymap_init()
 	do_cmdline_cmd((char_u *)"unlet! b:keymap_name");
     }
     else
     {
 	char_u	*buf;
+	size_t  buflen;
 
 	/* Source the keymap file.  It will contain a ":loadkeymap" command
 	 * which will call ex_loadkeymap() below. */
-	buf = alloc((unsigned)(STRLEN(curbuf->b_p_keymap)
+	buflen = STRLEN(curbuf->b_p_keymap)
 # ifdef FEAT_MBYTE
-						       + STRLEN(p_enc)
+					   + STRLEN(p_enc)
 # endif
-						       + 14));
+						       + 14;
+	buf = alloc((unsigned)buflen);
 	if (buf == NULL)
 	    return e_outofmem;
 
 # ifdef FEAT_MBYTE
 	/* try finding "keymap/'keymap'_'encoding'.vim"  in 'runtimepath' */
-	sprintf((char *)buf, "keymap/%s_%s.vim", curbuf->b_p_keymap, p_enc);
+	vim_snprintf((char *)buf, buflen, "keymap/%s_%s.vim",
+						   curbuf->b_p_keymap, p_enc);
 	if (source_runtime(buf, FALSE) == FAIL)
 # endif
 	{
 	    /* try finding "keymap/'keymap'.vim" in 'runtimepath'  */
-	    sprintf((char *)buf, "keymap/%s.vim", curbuf->b_p_keymap);
+	    vim_snprintf((char *)buf, buflen, "keymap/%s.vim",
+							  curbuf->b_p_keymap);
 	    if (source_runtime(buf, FALSE) == FAIL)
 	    {
 		vim_free(buf);
 		return (char_u *)N_("E544: Keymap file not found");
 	    }
--- vim72.orig/src/edit.c
+++ vim72/src/edit.c
@@ -55,11 +55,11 @@ static char *ctrl_x_msgs[] =
     N_(" Omni completion (^O^N^P)"),
     N_(" Spelling suggestion (s^N^P)"),
     N_(" Keyword Local completion (^N^P)"),
 };
 
-static char_u e_hitend[] = N_("Hit end of paragraph");
+static char e_hitend[] = N_("Hit end of paragraph");
 
 /*
  * Structure used to store one match for insert completion.
  */
 typedef struct compl_S compl_T;
@@ -112,10 +112,14 @@ static int	  compl_restarting = FALSE;	/
 
 /* When the first completion is done "compl_started" is set.  When it's
  * FALSE the word to be completed must be located. */
 static int	  compl_started = FALSE;
 
+/* Set when doing something for completion that may call edit() recursively,
+ * which is not allowed. */
+static int	  compl_busy = FALSE;
+
 static int	  compl_matches = 0;
 static char_u	  *compl_pattern = NULL;
 static int	  compl_direction = FORWARD;
 static int	  compl_shows_dir = FORWARD;
 static int	  compl_pending = 0;	    /* > 1 for postponed CTRL-N */
@@ -145,10 +149,11 @@ static char_u *find_line_end __ARGS((cha
 static void ins_compl_free __ARGS((void));
 static void ins_compl_clear __ARGS((void));
 static int  ins_compl_bs __ARGS((void));
 static void ins_compl_new_leader __ARGS((void));
 static void ins_compl_addleader __ARGS((int c));
+static int ins_compl_len __ARGS((void));
 static void ins_compl_restart __ARGS((void));
 static void ins_compl_set_original_text __ARGS((char_u *str));
 static void ins_compl_addfrommatch __ARGS((void));
 static int  ins_compl_prep __ARGS((int c));
 static buf_T *ins_compl_next_buf __ARGS((buf_T *buf, int flag));
@@ -162,11 +167,11 @@ static int  ins_compl_next __ARGS((int a
 static int  ins_compl_key2dir __ARGS((int c));
 static int  ins_compl_pum_key __ARGS((int c));
 static int  ins_compl_key2count __ARGS((int c));
 static int  ins_compl_use_match __ARGS((int c));
 static int  ins_complete __ARGS((int c));
-static int  quote_meta __ARGS((char_u *dest, char_u *str, int len));
+static unsigned  quote_meta __ARGS((char_u *dest, char_u *str, int len));
 #endif /* FEAT_INS_EXPAND */
 
 #define BACKSPACE_CHAR		    1
 #define BACKSPACE_WORD		    2
 #define BACKSPACE_WORD_NOT_SPACE    3
@@ -174,11 +179,11 @@ static int  quote_meta __ARGS((char_u *d
 
 static void ins_redraw __ARGS((int ready));
 static void ins_ctrl_v __ARGS((void));
 static void undisplay_dollar __ARGS((void));
 static void insert_special __ARGS((int, int, int));
-static void internal_format __ARGS((int textwidth, int second_indent, int flags, int format_only));
+static void internal_format __ARGS((int textwidth, int second_indent, int flags, int format_only, int c));
 static void check_auto_format __ARGS((int));
 static void redo_literal __ARGS((int c));
 static void start_arrow __ARGS((pos_T *end_insert_pos));
 #ifdef FEAT_SPELL
 static void check_spell_redraw __ARGS((void));
@@ -195,11 +200,12 @@ static void replace_join __ARGS((int off
 static void replace_pop_ins __ARGS((void));
 #ifdef FEAT_MBYTE
 static void mb_replace_pop_ins __ARGS((int cc));
 #endif
 static void replace_flush __ARGS((void));
-static void replace_do_bs __ARGS((void));
+static void replace_do_bs __ARGS((int limit_col));
+static int del_char_after_col __ARGS((int limit_col));
 #ifdef FEAT_CINDENT
 static int cindent_on __ARGS((void));
 #endif
 static void ins_reg __ARGS((void));
 static void ins_ctrl_g __ARGS((void));
@@ -302,11 +308,11 @@ edit(cmdchar, startln, count)
     long	count;
 {
     int		c = 0;
     char_u	*ptr;
     int		lastc;
-    colnr_T	mincol;
+    int		mincol;
     static linenr_T o_lnum = 0;
     int		i;
     int		did_backspace = TRUE;	    /* previous char was backspace */
 #ifdef FEAT_CINDENT
     int		line_is_white = FALSE;	    /* line is empty before insert */
@@ -342,11 +348,11 @@ edit(cmdchar, startln, count)
 	return FALSE;
     }
 
 #ifdef FEAT_INS_EXPAND
     /* Don't allow recursive insert mode when busy with completion. */
-    if (compl_started || pum_visible())
+    if (compl_started || compl_busy || pum_visible())
     {
 	EMSG(_(e_secure));
 	return FALSE;
     }
     ins_compl_clear();	    /* clear stuff for CTRL-X mode */
@@ -383,11 +389,11 @@ edit(cmdchar, startln, count)
     {
 	Insstart = curwin->w_cursor;
 	if (startln)
 	    Insstart.col = 0;
     }
-    Insstart_textlen = linetabsize(ml_get_curline());
+    Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());
     Insstart_blank_vcol = MAXCOL;
     if (!did_ai)
 	ai_col = 0;
 
     if (cmdchar != NUL && restart_edit == 0)
@@ -649,11 +655,11 @@ edit(cmdchar, startln, count)
 		)
 	{
 	    mincol = curwin->w_wcol;
 	    validate_cursor_col();
 
-	    if ((int)curwin->w_wcol < (int)mincol - curbuf->b_p_ts
+	    if ((int)curwin->w_wcol < mincol - curbuf->b_p_ts
 		    && curwin->w_wrow == W_WINROW(curwin)
 						 + curwin->w_height - 1 - p_so
 		    && (curwin->w_cursor.lnum != curwin->w_topline
 #ifdef FEAT_DIFF
 			|| curwin->w_topfill > 0
@@ -749,11 +755,11 @@ edit(cmdchar, startln, count)
 		/* CTRL-L: Add one character from the current match to
 		 * "compl_leader".  Except when at the original match and
 		 * there is nothing to add, CTRL-L works like CTRL-P then. */
 		if (c == Ctrl_L
 			&& (ctrl_x_mode != CTRL_X_WHOLE_LINE
-			    || STRLEN(compl_shown_match->cp_str)
+			    || (int)STRLEN(compl_shown_match->cp_str)
 					  > curwin->w_cursor.col - compl_col))
 		{
 		    ins_compl_addfrommatch();
 		    continue;
 		}
@@ -1336,12 +1342,14 @@ doESCkey:
 		    && ctrl_x_mode != 0
 		    && !(compl_cont_status & CONT_LOCAL))
 		goto normalchar;
 
 docomplete:
+	    compl_busy = TRUE;
 	    if (ins_complete(c) == FAIL)
 		compl_cont_status = 0;
+	    compl_busy = FALSE;
 	    break;
 #endif /* FEAT_INS_EXPAND */
 
 	case Ctrl_Y:	/* copy from previous line or scroll down */
 	case Ctrl_E:	/* copy from next line	   or scroll up */
@@ -1439,14 +1447,13 @@ force_cindent:
  * This is postponed until getting the next character to make '$' in the 'cpo'
  * option work correctly.
  * Only redraw when there are no characters available.  This speeds up
  * inserting sequences of characters (e.g., for CTRL-R).
  */
-/*ARGSUSED*/
     static void
 ins_redraw(ready)
-    int		ready;	    /* not busy with something */
+    int		ready UNUSED;	    /* not busy with something */
 {
     if (!char_avail())
     {
 #ifdef FEAT_AUTOCMD
 	/* Trigger CursorMoved if the cursor moved.  Not when the popup menu is
@@ -1769,11 +1776,11 @@ change_indent(type, amount, round, repla
     {
 	/*
 	 * Compute the screen column where the cursor should be.
 	 */
 	vcol = get_indent() - vcol;
-	curwin->w_virtcol = (vcol < 0) ? 0 : vcol;
+	curwin->w_virtcol = (colnr_T)((vcol < 0) ? 0 : vcol);
 
 	/*
 	 * Advance the cursor until we reach the right screen column.
 	 */
 	vcol = last_vcol = 0;
@@ -1796,13 +1803,13 @@ change_indent(type, amount, round, repla
 	 * May need to insert spaces to be able to position the cursor on
 	 * the right screen column.
 	 */
 	if (vcol != (int)curwin->w_virtcol)
 	{
-	    curwin->w_cursor.col = new_cursor_col;
+	    curwin->w_cursor.col = (colnr_T)new_cursor_col;
 	    i = (int)curwin->w_virtcol - vcol;
-	    ptr = alloc(i + 1);
+	    ptr = alloc((unsigned)(i + 1));
 	    if (ptr != NULL)
 	    {
 		new_cursor_col += i;
 		ptr[i] = NUL;
 		while (--i >= 0)
@@ -1822,11 +1829,11 @@ change_indent(type, amount, round, repla
     curwin->w_p_list = save_p_list;
 
     if (new_cursor_col <= 0)
 	curwin->w_cursor.col = 0;
     else
-	curwin->w_cursor.col = new_cursor_col;
+	curwin->w_cursor.col = (colnr_T)new_cursor_col;
     curwin->w_set_curswant = TRUE;
     changed_cline_bef_curs();
 
     /*
      * May have to adjust the start of the insert.
@@ -1931,26 +1938,64 @@ truncate_spaces(line)
 #if defined(FEAT_VREPLACE) || defined(FEAT_INS_EXPAND) \
 	|| defined(FEAT_COMMENTS) || defined(PROTO)
 /*
  * Backspace the cursor until the given column.  Handles REPLACE and VREPLACE
  * modes correctly.  May also be used when not in insert mode at all.
+ * Will attempt not to go before "col" even when there is a composing
+ * character.
  */
     void
 backspace_until_column(col)
     int	    col;
 {
     while ((int)curwin->w_cursor.col > col)
     {
 	curwin->w_cursor.col--;
 	if (State & REPLACE_FLAG)
-	    replace_do_bs();
-	else
-	    (void)del_char(FALSE);
+	    replace_do_bs(col);
+	else if (!del_char_after_col(col))
+	    break;
     }
 }
 #endif
 
+/*
+ * Like del_char(), but make sure not to go before column "limit_col".
+ * Only matters when there are composing characters.
+ * Return TRUE when something was deleted.
+ */
+   static int
+del_char_after_col(limit_col)
+    int limit_col UNUSED;
+{
+#ifdef FEAT_MBYTE
+    if (enc_utf8 && limit_col >= 0)
+    {
+	colnr_T ecol = curwin->w_cursor.col + 1;
+
+	/* Make sure the cursor is at the start of a character, but
+	 * skip forward again when going too far back because of a
+	 * composing character. */
+	mb_adjust_cursor();
+	while (curwin->w_cursor.col < (colnr_T)limit_col)
+	{
+	    int l = utf_ptr2len(ml_get_cursor());
+
+	    if (l == 0)  /* end of line */
+		break;
+	    curwin->w_cursor.col += l;
+	}
+	if (*ml_get_cursor() == NUL || curwin->w_cursor.col == ecol)
+	    return FALSE;
+	del_bytes((long)((int)ecol - curwin->w_cursor.col), FALSE, TRUE);
+    }
+    else
+#endif
+	(void)del_char(FALSE);
+    return TRUE;
+}
+
 #if defined(FEAT_INS_EXPAND) || defined(PROTO)
 /*
  * CTRL-X pressed in Insert mode.
  */
     static void
@@ -2117,11 +2162,11 @@ ins_compl_add_infercase(str, len, icase,
 {
     char_u	*p;
     int		i, c;
     int		actual_len;		/* Take multi-byte characters */
     int		actual_compl_length;	/* into account. */
-    int		*wca;		        /* Wide character array. */
+    int		*wca;			/* Wide character array. */
     int		has_lower = FALSE;
     int		was_letter = FALSE;
 
     if (p_ic && curbuf->b_p_inf && len > 0)
     {
@@ -2158,11 +2203,11 @@ ins_compl_add_infercase(str, len, icase,
 	else
 #endif
 	    actual_compl_length = compl_length;
 
 	/* Allocate wide character array for the completion and fill it. */
-	wca = (int *)alloc(actual_len * sizeof(int));
+	wca = (int *)alloc((unsigned)(actual_len * sizeof(int)));
 	if (wca != NULL)
 	{
 	    p = str;
 	    for (i = 0; i < actual_len; ++i)
 #ifdef FEAT_MBYTE
@@ -2416,11 +2461,11 @@ ins_compl_longest_match(match)
 	compl_leader = vim_strsave(match->cp_str);
 	if (compl_leader != NULL)
 	{
 	    had_match = (curwin->w_cursor.col > compl_col);
 	    ins_compl_delete();
-	    ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
+	    ins_bytes(compl_leader + ins_compl_len());
 	    ins_redraw(FALSE);
 
 	    /* When the match isn't there (to avoid matching itself) remove it
 	     * again after redrawing. */
 	    if (!had_match)
@@ -2468,11 +2513,11 @@ ins_compl_longest_match(match)
 	{
 	    /* Leader was shortened, need to change the inserted text. */
 	    *p = NUL;
 	    had_match = (curwin->w_cursor.col > compl_col);
 	    ins_compl_delete();
-	    ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
+	    ins_bytes(compl_leader + ins_compl_len());
 	    ins_redraw(FALSE);
 
 	    /* When the match isn't there (to avoid matching itself) remove it
 	     * again after redrawing. */
 	    if (!had_match)
@@ -2537,25 +2582,25 @@ ins_compl_make_cyclic()
  * "startcol" is where the matched text starts (1 is first column).
  * "list" is the list of matches.
  */
     void
 set_completion(startcol, list)
-    int	    startcol;
+    colnr_T startcol;
     list_T  *list;
 {
     /* If already doing completions stop it. */
     if (ctrl_x_mode != 0)
 	ins_compl_prep(' ');
     ins_compl_clear();
 
     if (stop_arrow() == FAIL)
 	return;
 
-    if (startcol > (int)curwin->w_cursor.col)
+    if (startcol > curwin->w_cursor.col)
 	startcol = curwin->w_cursor.col;
     compl_col = startcol;
-    compl_length = curwin->w_cursor.col - startcol;
+    compl_length = (int)curwin->w_cursor.col - (int)startcol;
     /* compl_pattern doesn't need to be set */
     compl_orig_text = vim_strnsave(ml_get_curline() + compl_col, compl_length);
     if (compl_orig_text == NULL || ins_compl_add(compl_orig_text,
 			-1, p_ic, NULL, NULL, 0, ORIGINAL_TEXT, FALSE) != OK)
 	return;
@@ -2817,11 +2862,10 @@ ins_compl_dictionaries(dict_start, pat,
     char_u	*ptr;
     char_u	*buf;
     regmatch_T	regmatch;
     char_u	**files;
     int		count;
-    int		i;
     int		save_p_scs;
     int		dir = compl_direction;
 
     if (*dict == NUL)
     {
@@ -2849,21 +2893,22 @@ ins_compl_dictionaries(dict_start, pat,
      * to only match at the start of a line.  Otherwise just match the
      * pattern. Also need to double backslashes. */
     if (ctrl_x_mode == CTRL_X_WHOLE_LINE)
     {
 	char_u *pat_esc = vim_strsave_escaped(pat, (char_u *)"\\");
+	size_t len;
 
 	if (pat_esc == NULL)
 	    goto theend;
-	i = (int)STRLEN(pat_esc) + 10;
-	ptr = alloc(i);
+	len = STRLEN(pat_esc) + 10;
+	ptr = alloc((unsigned)len);
 	if (ptr == NULL)
 	{
 	    vim_free(pat_esc);
 	    goto theend;
 	}
-	vim_snprintf((char *)ptr, i, "^\\s*\\zs\\V%s", pat_esc);
+	vim_snprintf((char *)ptr, len, "^\\s*\\zs\\V%s", pat_esc);
 	regmatch.regprog = vim_regcomp(ptr, RE_MAGIC);
 	vim_free(pat_esc);
 	vim_free(ptr);
     }
     else
@@ -2950,11 +2995,11 @@ ins_compl_files(count, files, thesaurus,
 	fp = mch_fopen((char *)files[i], "r");  /* open dictionary file */
 	if (flags != DICT_EXACT)
 	{
 	    vim_snprintf((char *)IObuff, IOSIZE,
 			      _("Scanning dictionary: %s"), (char *)files[i]);
-	    msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R));
+	    (void)msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R));
 	}
 
 	if (fp != NULL)
 	{
 	    /*
@@ -3131,10 +3176,11 @@ ins_compl_free()
 	for (i = 0; i < CPT_COUNT; ++i)
 	    vim_free(match->cp_text[i]);
 	vim_free(match);
     } while (compl_curr_match != NULL && compl_curr_match != compl_first_match);
     compl_first_match = compl_curr_match = NULL;
+    compl_shown_match = NULL;
 }
 
     static void
 ins_compl_clear()
 {
@@ -3207,11 +3253,11 @@ ins_compl_bs()
     static void
 ins_compl_new_leader()
 {
     ins_compl_del_pum();
     ins_compl_delete();
-    ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
+    ins_bytes(compl_leader + ins_compl_len());
     compl_used_match = FALSE;
 
     if (compl_started)
 	ins_compl_set_original_text(compl_leader);
     else
@@ -3262,10 +3308,24 @@ ins_compl_new_leader()
     if (compl_match_array == NULL)
 	compl_enter_selects = FALSE;
 }
 
 /*
+ * Return the length of the completion, from the completion start column to
+ * the cursor column.  Making sure it never goes below zero.
+ */
+    static int
+ins_compl_len()
+{
+    int off = (int)curwin->w_cursor.col - (int)compl_col;
+
+    if (off < 0)
+	return 0;
+    return off;
+}
+
+/*
  * Append one character to the match leader.  May reduce the number of
  * matches.
  */
     static void
 ins_compl_addleader(c)
@@ -3290,11 +3350,11 @@ ins_compl_addleader(c)
     if (compl_was_interrupted)
 	ins_compl_restart();
 
     vim_free(compl_leader);
     compl_leader = vim_strnsave(ml_get_curline() + compl_col,
-					    curwin->w_cursor.col - compl_col);
+				     (int)(curwin->w_cursor.col - compl_col));
     if (compl_leader != NULL)
 	ins_compl_new_leader();
 }
 
 /*
@@ -3338,11 +3398,11 @@ ins_compl_set_original_text(str)
  */
     static void
 ins_compl_addfrommatch()
 {
     char_u	*p;
-    int		len = curwin->w_cursor.col - compl_col;
+    int		len = (int)curwin->w_cursor.col - (int)compl_col;
     int		c;
     compl_T	*cp;
 
     p = compl_shown_match->cp_str;
     if ((int)STRLEN(p) <= len)   /* the match is too short */
@@ -3619,14 +3679,13 @@ ins_compl_prep(c)
 	    /* CTRL-E means completion is Ended, go back to the typed text. */
 	    if (c == Ctrl_E)
 	    {
 		ins_compl_delete();
 		if (compl_leader != NULL)
-		    ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
+		    ins_bytes(compl_leader + ins_compl_len());
 		else if (compl_first_match != NULL)
-		    ins_bytes(compl_orig_text
-					  + curwin->w_cursor.col - compl_col);
+		    ins_bytes(compl_orig_text + ins_compl_len());
 		retval = TRUE;
 	    }
 
 	    auto_format(FALSE, TRUE);
 
@@ -3905,11 +3964,11 @@ ins_compl_get_exp(ini)
 			ins_buf->b_fname == NULL
 			    ? buf_spname(ins_buf)
 			    : ins_buf->b_sfname == NULL
 				? (char *)ins_buf->b_fname
 				: (char *)ins_buf->b_sfname);
-		msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R));
+		(void)msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R));
 	    }
 	    else if (*e_cpt == NUL)
 		break;
 	    else
 	    {
@@ -3934,12 +3993,12 @@ ins_compl_get_exp(ini)
 		    type = CTRL_X_PATH_DEFINES;
 #endif
 		else if (*e_cpt == ']' || *e_cpt == 't')
 		{
 		    type = CTRL_X_TAGS;
-		    sprintf((char*)IObuff, _("Scanning tags."));
-		    msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R));
+		    vim_snprintf((char *)IObuff, IOSIZE, _("Scanning tags."));
+		    (void)msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R));
 		}
 		else
 		    type = -1;
 
 		/* in any case e_cpt is advanced to the next entry */
@@ -3987,11 +4046,11 @@ ins_compl_get_exp(ini)
 	case CTRL_X_TAGS:
 	    /* set p_ic according to p_ic, p_scs and pat for find_tags(). */
 	    save_p_ic = p_ic;
 	    p_ic = ignorecase(compl_pattern);
 
-	    /* Find up to TAG_MANY matches.  Avoids that an enourmous number
+	    /* Find up to TAG_MANY matches.  Avoids that an enormous number
 	     * of matches is found when compl_pattern is empty */
 	    if (find_tags(compl_pattern, &num_matches, &matches,
 		    TAG_REGEXP | TAG_NAMES | TAG_NOIC |
 		    TAG_INS_COMP | (ctrl_x_mode ? TAG_VERBOSE : 0),
 		    TAG_MANY, curbuf->b_ffname) == OK && num_matches > 0)
@@ -4033,11 +4092,11 @@ ins_compl_get_exp(ini)
 #endif
 
 	case CTRL_X_SPELL:
 #ifdef FEAT_SPELL
 	    num_matches = expand_spelling(first_match_pos.lnum,
-				 first_match_pos.col, compl_pattern, &matches);
+						     compl_pattern, &matches);
 	    if (num_matches > 0)
 		ins_compl_add_matches(num_matches, matches, p_ic);
 #endif
 	    break;
 
@@ -4158,11 +4217,11 @@ ins_compl_get_exp(ini)
 								       == NULL
 						&& (IObuff[len - 2] == '?'
 						 || IObuff[len - 2] == '!'))))
 					IObuff[len++] = ' ';
 				}
-				/* copy as much as posible of the new word */
+				/* copy as much as possible of the new word */
 				if (tmp_ptr - ptr >= IOSIZE - len)
 				    tmp_ptr = ptr + IOSIZE - len - 1;
 				STRNCPY(IObuff + len, ptr, tmp_ptr - ptr);
 				len += (int)(tmp_ptr - ptr);
 				flags |= CONT_S_IPOS;
@@ -4185,11 +4244,11 @@ ins_compl_get_exp(ini)
 	    p_scs = save_p_scs;
 	    p_ws = save_p_ws;
 	}
 
 	/* check if compl_curr_match has changed, (e.g. other type of
-	 * expansion added somenthing) */
+	 * expansion added something) */
 	if (type != 0 && compl_curr_match != old_match)
 	    found_new_match = OK;
 
 	/* break the loop for specialized modes (use 'complete' just for the
 	 * generic ctrl_x_mode == 0) or when we've found a new match */
@@ -4254,11 +4313,11 @@ ins_compl_delete()
 
 /* Insert the new text being completed. */
     static void
 ins_compl_insert()
 {
-    ins_bytes(compl_shown_match->cp_str + curwin->w_cursor.col - compl_col);
+    ins_bytes(compl_shown_match->cp_str + ins_compl_len());
     if (compl_shown_match->cp_flags & ORIGINAL_TEXT)
 	compl_used_match = FALSE;
     else
 	compl_used_match = TRUE;
 }
@@ -4423,11 +4482,11 @@ ins_compl_next(allow_get_expansion, coun
     if (insert_match)
     {
 	if (!compl_get_longest || compl_used_match)
 	    ins_compl_insert();
 	else
-	    ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
+	    ins_bytes(compl_leader + ins_compl_len());
     }
     else
 	compl_used_match = FALSE;
 
     if (!allow_get_expansion)
@@ -4623,10 +4682,11 @@ ins_complete(c)
 {
     char_u	*line;
     int		startcol = 0;	    /* column where searched text starts */
     colnr_T	curs_col;	    /* cursor column */
     int		n;
+    int		save_w_wrow;
 
     compl_direction = ins_compl_key2dir(c);
     if (!compl_started)
     {
 	/* First time we hit ^N or ^P (in a row, I mean) */
@@ -4686,11 +4746,11 @@ ins_complete(c)
 		    }
 		    compl_col = compl_startpos.col;
 		}
 		compl_length = curwin->w_cursor.col - (int)compl_col;
 		/* IObuff is used to add a "word from the next line" would we
-		 * have enough space?  just being paranoic */
+		 * have enough space?  just being paranoid */
 #define	MIN_SPACE 75
 		if (compl_length > (IOSIZE - MIN_SPACE))
 		{
 		    compl_cont_status &= ~CONT_SOL;
 		    compl_length = (IOSIZE - MIN_SPACE);
@@ -4743,14 +4803,13 @@ ins_complete(c)
 	    }
 	    else if (compl_cont_status & CONT_ADDING)
 	    {
 		char_u	    *prefix = (char_u *)"\\<";
 
-		/* we need 3 extra chars, 1 for the NUL and
-		 * 2 >= strlen(prefix)	-- Acevedo */
+		/* we need up to 2 extra chars for the prefix */
 		compl_pattern = alloc(quote_meta(NULL, line + compl_col,
-							   compl_length) + 3);
+							   compl_length) + 2);
 		if (compl_pattern == NULL)
 		    return FAIL;
 		if (!vim_iswordp(line + compl_col)
 			|| (compl_col > 0
 			    && (
@@ -4821,11 +4880,11 @@ ins_complete(c)
 		    STRCAT((char *)compl_pattern, "\\k");
 		}
 		else
 		{
 		    compl_pattern = alloc(quote_meta(NULL, line + compl_col,
-							   compl_length) + 3);
+							   compl_length) + 2);
 		    if (compl_pattern == NULL)
 			return FAIL;
 		    STRCPY((char *)compl_pattern, "\\<");
 		    (void)quote_meta(compl_pattern + 2, line + compl_col,
 								compl_length);
@@ -4903,11 +4962,11 @@ ins_complete(c)
 	    curwin->w_cursor = pos;	/* restore the cursor position */
 
 	    if (col < 0)
 		col = curs_col;
 	    compl_col = col;
-	    if ((colnr_T)compl_col > curs_col)
+	    if (compl_col > curs_col)
 		compl_col = curs_col;
 
 	    /* Setup variables for completion.  Need to obtain "line" again,
 	     * it may have become invalid. */
 	    line = ml_get(curwin->w_cursor.lnum);
@@ -5007,10 +5066,11 @@ ins_complete(c)
     compl_shows_dir = compl_direction;
 
     /*
      * Find next match (and following matches).
      */
+    save_w_wrow = curwin->w_wrow;
     n = ins_compl_next(TRUE, ins_compl_key2count(c), ins_compl_use_match(c));
 
     /* may undisplay the popup menu */
     ins_compl_upd_pum();
 
@@ -5160,10 +5220,16 @@ ins_complete(c)
     if (!compl_interrupted)
     {
 	/* RedrawingDisabled may be set when invoked through complete(). */
 	n = RedrawingDisabled;
 	RedrawingDisabled = 0;
+
+	/* If the cursor moved we need to remove the pum first. */
+	setcursor();
+	if (save_w_wrow != curwin->w_wrow)
+	    ins_compl_del_pum();
+
 	ins_compl_show_pum();
 	setcursor();
 	RedrawingDisabled = n;
     }
     compl_was_interrupted = compl_interrupted;
@@ -5176,19 +5242,19 @@ ins_complete(c)
  * Looks in the first "len" chars. of "src" for search-metachars.
  * If dest is not NULL the chars. are copied there quoting (with
  * a backslash) the metachars, and dest would be NUL terminated.
  * Returns the length (needed) of dest
  */
-    static int
+    static unsigned
 quote_meta(dest, src, len)
     char_u	*dest;
     char_u	*src;
     int		len;
 {
-    int	m;
+    unsigned	m = (unsigned)len + 1;  /* one extra for the NUL */
 
-    for (m = len; --len >= 0; src++)
+    for ( ; --len >= 0; src++)
     {
 	switch (*src)
 	{
 	    case '.':
 	    case '*':
@@ -5498,11 +5564,11 @@ insertchar(c, flags, second_indent)
 	     * was called. */
 	    ins_need_undo = TRUE;
 	}
 	if (do_internal)
 #endif
-	    internal_format(textwidth, second_indent, flags, c == NUL);
+	    internal_format(textwidth, second_indent, flags, c == NUL, c);
     }
 
     if (c == NUL)	    /* only formatting was wanted */
 	return;
 
@@ -5678,15 +5744,16 @@ insertchar(c, flags, second_indent)
 
 /*
  * Format text at the current insert position.
  */
     static void
-internal_format(textwidth, second_indent, flags, format_only)
+internal_format(textwidth, second_indent, flags, format_only, c)
     int		textwidth;
     int		second_indent;
     int		flags;
     int		format_only;
+    int		c; /* character to be inserted (can be NUL) */
 {
     int		cc;
     int		save_char = NUL;
     int		haveto_redraw = FALSE;
     int		fo_ins_blank = has_format_option(FO_INS_BLANK);
@@ -5703,11 +5770,15 @@ internal_format(textwidth, second_indent
 
     /*
      * When 'ai' is off we don't want a space under the cursor to be
      * deleted.  Replace it with an 'x' temporarily.
      */
-    if (!curbuf->b_p_ai)
+    if (!curbuf->b_p_ai
+#ifdef FEAT_VREPLACE
+	    && !(State & VREPLACE_FLAG)
+#endif
+	    )
     {
 	cc = gchar_cursor();
 	if (vim_iswhite(cc))
 	{
 	    save_char = cc;
@@ -5729,13 +5800,15 @@ internal_format(textwidth, second_indent
 #ifdef FEAT_VREPLACE
 	int	orig_col = 0;
 	char_u	*saved_text = NULL;
 #endif
 	colnr_T	col;
+	colnr_T	end_col;
 
-	virtcol = get_nolist_virtcol();
-	if (virtcol < (colnr_T)textwidth)
+	virtcol = get_nolist_virtcol()
+		+ char2cells(c != NUL ? c : gchar_cursor());
+	if (virtcol <= (colnr_T)textwidth)
 	    break;
 
 #ifdef FEAT_COMMENTS
 	if (no_leader)
 	    do_comments = FALSE;
@@ -5760,42 +5833,37 @@ internal_format(textwidth, second_indent
 #ifdef FEAT_COMMENTS
 		&& leader_len == 0
 #endif
 		&& !has_format_option(FO_WRAP))
 
-	{
-	    textwidth = 0;
 	    break;
-	}
 	if ((startcol = curwin->w_cursor.col) == 0)
 	    break;
 
 	/* find column of textwidth border */
 	coladvance((colnr_T)textwidth);
 	wantcol = curwin->w_cursor.col;
 
-	curwin->w_cursor.col = startcol - 1;
-#ifdef FEAT_MBYTE
-	/* Correct cursor for multi-byte character. */
-	if (has_mbyte)
-	    mb_adjust_cursor();
-#endif
+	curwin->w_cursor.col = startcol;
 	foundcol = 0;
 
 	/*
 	 * Find position to break at.
 	 * Stop at first entered white when 'formatoptions' has 'v'
 	 */
 	while ((!fo_ins_blank && !has_format_option(FO_INS_VI))
 		    || curwin->w_cursor.lnum != Insstart.lnum
 		    || curwin->w_cursor.col >= Insstart.col)
 	{
-	    cc = gchar_cursor();
+	    if (curwin->w_cursor.col == startcol && c != NUL)
+		cc = c;
+	    else
+		cc = gchar_cursor();
 	    if (WHITECHAR(cc))
 	    {
 		/* remember position of blank just before text */
-		end_foundcol = curwin->w_cursor.col;
+		end_col = curwin->w_cursor.col;
 
 		/* find start of sequence of blanks */
 		while (curwin->w_cursor.col > 0 && WHITECHAR(cc))
 		{
 		    dec_cursor();
@@ -5811,39 +5879,77 @@ internal_format(textwidth, second_indent
 		if (has_format_option(FO_ONE_LETTER))
 		{
 		    /* do not break after one-letter words */
 		    if (curwin->w_cursor.col == 0)
 			break;	/* one-letter word at begin */
-
+#ifdef FEAT_COMMENTS
+		    /* do not break "#a b" when 'tw' is 2 */
+		    if (curwin->w_cursor.col <= leader_len)
+			break;
+#endif
 		    col = curwin->w_cursor.col;
 		    dec_cursor();
 		    cc = gchar_cursor();
 
 		    if (WHITECHAR(cc))
 			continue;	/* one-letter, continue */
 		    curwin->w_cursor.col = col;
 		}
-#ifdef FEAT_MBYTE
-		if (has_mbyte)
-		    foundcol = curwin->w_cursor.col
-					 + (*mb_ptr2len)(ml_get_cursor());
-		else
-#endif
-		    foundcol = curwin->w_cursor.col + 1;
-		if (curwin->w_cursor.col < (colnr_T)wantcol)
+
+		inc_cursor();
+
+		end_foundcol = end_col + 1;
+		foundcol = curwin->w_cursor.col;
+		if (curwin->w_cursor.col <= (colnr_T)wantcol)
 		    break;
 	    }
 #ifdef FEAT_MBYTE
-	    else if (cc >= 0x100 && fo_multibyte
-			      && curwin->w_cursor.col <= (colnr_T)wantcol)
+	    else if (cc >= 0x100 && fo_multibyte)
 	    {
 		/* Break after or before a multi-byte character. */
+		if (curwin->w_cursor.col != startcol)
+		{
+#ifdef FEAT_COMMENTS
+		    /* Don't break until after the comment leader */
+		    if (curwin->w_cursor.col < leader_len)
+			break;
+#endif
+		    col = curwin->w_cursor.col;
+		    inc_cursor();
+		    /* Don't change end_foundcol if already set. */
+		    if (foundcol != curwin->w_cursor.col)
+		    {
+			foundcol = curwin->w_cursor.col;
+			end_foundcol = foundcol;
+			if (curwin->w_cursor.col <= (colnr_T)wantcol)
+			    break;
+		    }
+		    curwin->w_cursor.col = col;
+		}
+
+		if (curwin->w_cursor.col == 0)
+		    break;
+
+		col = curwin->w_cursor.col;
+
+		dec_cursor();
+		cc = gchar_cursor();
+
+		if (WHITECHAR(cc))
+		    continue;		/* break with space */
+#ifdef FEAT_COMMENTS
+		/* Don't break until after the comment leader */
+		if (curwin->w_cursor.col < leader_len)
+		    break;
+#endif
+
+		curwin->w_cursor.col = col;
+
 		foundcol = curwin->w_cursor.col;
-		if (curwin->w_cursor.col < (colnr_T)wantcol)
-		    foundcol += (*mb_char2len)(cc);
 		end_foundcol = foundcol;
-		break;
+		if (curwin->w_cursor.col <= (colnr_T)wantcol)
+		    break;
 	    }
 #endif
 	    if (curwin->w_cursor.col == 0)
 		break;
 	    dec_cursor();
@@ -5866,18 +5972,19 @@ internal_format(textwidth, second_indent
 #ifdef FEAT_VREPLACE
 	if (State & VREPLACE_FLAG)
 	    orig_col = startcol;	/* Will start backspacing from here */
 	else
 #endif
-	    replace_offset = startcol - end_foundcol - 1;
+	    replace_offset = startcol - end_foundcol;
 
 	/*
 	 * adjust startcol for spaces that will be deleted and
 	 * characters that will remain on top line
 	 */
 	curwin->w_cursor.col = foundcol;
-	while (cc = gchar_cursor(), WHITECHAR(cc))
+	while ((cc = gchar_cursor(), WHITECHAR(cc))
+		    && (!fo_white_par || curwin->w_cursor.col < startcol))
 	    inc_cursor();
 	startcol -= curwin->w_cursor.col;
 	if (startcol < 0)
 	    startcol = 0;
 
@@ -6013,11 +6120,11 @@ auto_format(trailblank, prev_line)
     /* Don't format in Insert mode when the cursor is on a trailing blank, the
      * user might insert normal text next.  Also skip formatting when "1" is
      * in 'formatoptions' and there is a single character before the cursor.
      * Otherwise the line would be broken and when typing another non-white
      * next they are not joined back together. */
-    wasatend = (pos.col == STRLEN(old));
+    wasatend = (pos.col == (colnr_T)STRLEN(old));
     if (*old != NUL && !trailblank && wasatend)
     {
 	dec_cursor();
 	cc = gchar_cursor();
 	if (!WHITECHAR(cc) && curwin->w_cursor.col > 0
@@ -6190,11 +6297,11 @@ redo_literal(c)
 
     /* Only digits need special treatment.  Translate them into a string of
      * three digits. */
     if (VIM_ISDIGIT(c))
     {
-	sprintf((char *)buf, "%03d", c);
+	vim_snprintf((char *)buf, sizeof(buf), "%03d", c);
 	AppendToRedobuff(buf);
     }
     else
 	AppendCharToRedobuff(c);
 }
@@ -6264,11 +6371,11 @@ stop_arrow()
 	{
 	    arrow_used = FALSE;
 	    ins_need_undo = FALSE;
 	}
 	Insstart = curwin->w_cursor;	/* new insertion starts here */
-	Insstart_textlen = linetabsize(ml_get_curline());
+	Insstart_textlen = (colnr_T)linetabsize(ml_get_curline());
 	ai_col = 0;
 #ifdef FEAT_VREPLACE
 	if (State & VREPLACE_FLAG)
 	{
 	    orig_line_count = curbuf->b_ml.ml_line_count;
@@ -6367,25 +6474,30 @@ stop_insert(end_insert_pos, esc)
 	/* If a space was inserted for auto-formatting, remove it now. */
 	check_auto_format(TRUE);
 
 	/* If we just did an auto-indent, remove the white space from the end
 	 * of the line, and put the cursor back.
-	 * Do this when ESC was used or moving the cursor up/down. */
+	 * Do this when ESC was used or moving the cursor up/down.
+	 * Check for the old position still being valid, just in case the text
+	 * got changed unexpectedly. */
 	if (did_ai && (esc || (vim_strchr(p_cpo, CPO_INDENT) == NULL
-			&& curwin->w_cursor.lnum != end_insert_pos->lnum)))
+			&& curwin->w_cursor.lnum != end_insert_pos->lnum))
+		&& end_insert_pos->lnum <= curbuf->b_ml.ml_line_count)
 	{
 	    pos_T	tpos = curwin->w_cursor;
 
 	    curwin->w_cursor = *end_insert_pos;
+	    check_cursor_col();  /* make sure it is not past the line */
 	    for (;;)
 	    {
 		if (gchar_cursor() == NUL && curwin->w_cursor.col > 0)
 		    --curwin->w_cursor.col;
 		cc = gchar_cursor();
 		if (!vim_iswhite(cc))
 		    break;
-		(void)del_char(TRUE);
+		if (del_char(TRUE) == FAIL)
+		    break;  /* should not happen */
 	    }
 	    if (curwin->w_cursor.lnum != tpos.lnum)
 		curwin->w_cursor = tpos;
 	    else if (cc != NUL)
 		++curwin->w_cursor.col;	/* put cursor back on the NUL */
@@ -6393,14 +6505,15 @@ stop_insert(end_insert_pos, esc)
 #ifdef FEAT_VISUAL
 	    /* <C-S-Right> may have started Visual mode, adjust the position for
 	     * deleted characters. */
 	    if (VIsual_active && VIsual.lnum == curwin->w_cursor.lnum)
 	    {
-		cc = (int)STRLEN(ml_get_curline());
-		if (VIsual.col > (colnr_T)cc)
+		int len = (int)STRLEN(ml_get_curline());
+
+		if (VIsual.col > len)
 		{
-		    VIsual.col = cc;
+		    VIsual.col = len;
 # ifdef FEAT_VIRTUALEDIT
 		    VIsual.coladd = 0;
 # endif
 		}
 	    }
@@ -7121,13 +7234,16 @@ replace_flush()
  * Handle doing a BS for one character.
  * cc < 0: replace stack empty, just move cursor
  * cc == 0: character was inserted, delete it
  * cc > 0: character was replaced, put cc (first byte of original char) back
  * and check for more characters to be put back
+ * When "limit_col" is >= 0, don't delete before this column.  Matters when
+ * using composing characters, use del_char_after_col() instead of del_char().
  */
     static void
-replace_do_bs()
+replace_do_bs(limit_col)
+    int		limit_col;
 {
     int		cc;
 #ifdef FEAT_VREPLACE
     int		orig_len = 0;
     int		ins_len;
@@ -7151,11 +7267,11 @@ replace_do_bs()
 	}
 #endif
 #ifdef FEAT_MBYTE
 	if (has_mbyte)
 	{
-	    del_char(FALSE);
+	    (void)del_char_after_col(limit_col);
 # ifdef FEAT_VREPLACE
 	    if (State & VREPLACE_FLAG)
 		orig_len = (int)STRLEN(ml_get_cursor());
 # endif
 	    replace_push(cc);
@@ -7201,11 +7317,11 @@ replace_do_bs()
 
 	/* mark the buffer as changed and prepare for displaying */
 	changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col);
     }
     else if (cc == 0)
-	(void)del_char(FALSE);
+	(void)del_char_after_col(limit_col);
 }
 
 #ifdef FEAT_CINDENT
 /*
  * Return TRUE if C-indenting is on.
@@ -7284,10 +7400,14 @@ in_cinkeys(keytyped, when, line_is_empty
     char_u	*p;
     char_u	*line;
     int		icase;
     int		i;
 
+    if (keytyped == NUL)
+	/* Can happen with CTRL-Y and CTRL-E on a short line. */
+	return FALSE;
+
 #ifdef FEAT_EVAL
     if (*curbuf->b_p_inde != NUL)
 	look = curbuf->b_p_indk;	/* 'indentexpr' set: use 'indentkeys' */
     else
 #endif
@@ -7644,24 +7764,20 @@ ins_reg()
      * Don't map the register name. This also prevents the mode message to be
      * deleted when ESC is hit.
      */
     ++no_mapping;
     regname = plain_vgetc();
-#ifdef FEAT_LANGMAP
     LANGMAP_ADJUST(regname, TRUE);
-#endif
     if (regname == Ctrl_R || regname == Ctrl_O || regname == Ctrl_P)
     {
 	/* Get a third key for literal register insertion */
 	literally = regname;
 #ifdef FEAT_CMDL_INFO
 	add_to_showcmd_c(literally);
 #endif
 	regname = plain_vgetc();
-#ifdef FEAT_LANGMAP
 	LANGMAP_ADJUST(regname, TRUE);
-#endif
     }
     --no_mapping;
 
 #ifdef FEAT_EVAL
     /*
@@ -8148,11 +8264,11 @@ ins_ctrl_o()
 }
 
 /*
  * If the cursor is on an indent, ^T/^D insert/delete one
  * shiftwidth.	Otherwise ^T/^D behave like a "<<" or ">>".
- * Always round the indent to 'shiftwith', this is compatible
+ * Always round the indent to 'shiftwidth', this is compatible
  * with vi.  But vi only supports ^T and ^D after an
  * autoindent, we support it everywhere.
  */
     static void
 ins_shift(c, lastc)
@@ -8237,11 +8353,11 @@ ins_bs_one(vcolp)
     {
 	/* Don't delete characters before the insert point when in
 	 * Replace mode */
 	if (curwin->w_cursor.lnum != Insstart.lnum
 		|| curwin->w_cursor.col >= Insstart.col)
-	    replace_do_bs();
+	    replace_do_bs(-1);
     }
     else
 	(void)del_char(FALSE);
 }
 
@@ -8256,10 +8372,11 @@ ins_bs(c, mode, inserted_space_p)
     int		*inserted_space_p;
 {
     linenr_T	lnum;
     int		cc;
     int		temp = 0;	    /* init for GCC */
+    colnr_T	save_col;
     colnr_T	mincol;
     int		did_backspace = FALSE;
     int		in_indent;
     int		oldState;
 #ifdef FEAT_MBYTE
@@ -8413,17 +8530,17 @@ ins_bs(c, mode, inserted_space_p)
 		/*
 		 * restore characters (blanks) deleted after cursor
 		 */
 		while (cc > 0)
 		{
-		    temp = curwin->w_cursor.col;
+		    save_col = curwin->w_cursor.col;
 #ifdef FEAT_MBYTE
 		    mb_replace_pop_ins(cc);
 #else
 		    ins_char(cc);
 #endif
-		    curwin->w_cursor.col = temp;
+		    curwin->w_cursor.col = save_col;
 		    cc = replace_pop();
 		}
 		/* restore the characters that NL replaced */
 		replace_pop_ins();
 		State = oldState;
@@ -8443,23 +8560,23 @@ ins_bs(c, mode, inserted_space_p)
 	mincol = 0;
 						/* keep indent */
 	if (mode == BACKSPACE_LINE
 		&& (curbuf->b_p_ai
 #ifdef FEAT_CINDENT
-                    || cindent_on()
+		    || cindent_on()
 #endif
 		   )
 #ifdef FEAT_RIGHTLEFT
 		&& !revins_on
 #endif
 			    )
 	{
-	    temp = curwin->w_cursor.col;
+	    save_col = curwin->w_cursor.col;
 	    beginline(BL_WHITE);
-	    if (curwin->w_cursor.col < (colnr_T)temp)
+	    if (curwin->w_cursor.col < save_col)
 		mincol = curwin->w_cursor.col;
-	    curwin->w_cursor.col = temp;
+	    curwin->w_cursor.col = save_col;
 	}
 
 	/*
 	 * Handle deleting one 'shiftwidth' or 'softtabstop'.
 	 */
@@ -8554,11 +8671,11 @@ ins_bs(c, mode, inserted_space_p)
 		    dec_cursor();
 #endif
 		break;
 	    }
 	    if (State & REPLACE_FLAG)
-		replace_do_bs();
+		replace_do_bs(-1);
 	    else
 	    {
 #ifdef FEAT_MBYTE
 		if (enc_utf8 && p_deco)
 		    (void)utfc_ptr2char(ml_get_cursor(), cpc);
@@ -8929,11 +9046,14 @@ ins_right()
 #ifdef FEAT_FOLDING
     if ((fdo_flags & FDO_HOR) && KeyTyped)
 	foldOpenCursor();
 #endif
     undisplay_dollar();
-    if (gchar_cursor() != NUL || virtual_active()
+    if (gchar_cursor() != NUL
+#ifdef FEAT_VIRTUALEDIT
+	    || virtual_active()
+#endif
 	    )
     {
 	start_arrow(&curwin->w_cursor);
 	curwin->w_set_curswant = TRUE;
 #ifdef FEAT_VIRTUALEDIT
--- vim72.orig/src/eval.c
+++ vim72/src/eval.c
@@ -30,10 +30,13 @@
 # include <math.h>
 #endif
 
 #define DICT_MAXNEST 100	/* maximum nesting of lists and dicts */
 
+#define DO_NOT_FREE_CNT 99999	/* refcount for dict or list that should not
+				   be freed. */
+
 /*
  * In a hashtab item "hi_key" points to "di_key" in a dictitem.
  * This avoids adding a pointer to the hashtab item.
  * DI2HIKEY() converts a dictitem pointer to a hashitem key pointer.
  * HIKEY2DI() converts a hashitem key pointer to a dictitem pointer.
@@ -124,12 +127,15 @@ static dictitem_T	globvars_var;
 static hashtab_T	compat_hashtab;
 
 /*
  * When recursively copying lists and dicts we need to remember which ones we
  * have done to avoid endless recursiveness.  This unique ID is used for that.
+ * The last bit is used for previous_funccal, ignored when comparing.
  */
 static int current_copyID = 0;
+#define COPYID_INC 2
+#define COPYID_MASK (~0x1)
 
 /*
  * Array to hold the hashtab with variables local to each sourced script.
  * Each item holds a variable (nameless) that points to the dict_T.
  */
@@ -278,11 +284,11 @@ typedef struct
 /* values for vv_flags: */
 #define VV_COMPAT	1	/* compatible, also used without "v:" */
 #define VV_RO		2	/* read-only */
 #define VV_RO_SBX	4	/* read-only in the sandbox */
 
-#define VV_NAME(s, t)	s, {{t}}, {0}
+#define VV_NAME(s, t)	s, {{t, 0, {0}}, 0, {0}}, {0}
 
 static struct vimvar
 {
     char	*vv_name;	/* name of variable, without v: */
     dictitem_T	vv_di;		/* value and name for key */
@@ -346,17 +352,19 @@ static struct vimvar
     {VV_NAME("mouse_win",	 VAR_NUMBER), 0},
     {VV_NAME("mouse_lnum",	 VAR_NUMBER), 0},
     {VV_NAME("mouse_col",	 VAR_NUMBER), 0},
     {VV_NAME("operator",	 VAR_STRING), VV_RO},
     {VV_NAME("searchforward",	 VAR_NUMBER), 0},
+    {VV_NAME("oldfiles",	 VAR_LIST), 0},
 };
 
 /* shorthand */
 #define vv_type		vv_di.di_tv.v_type
 #define vv_nr		vv_di.di_tv.vval.v_number
 #define vv_float	vv_di.di_tv.vval.v_float
 #define vv_str		vv_di.di_tv.vval.v_string
+#define vv_list		vv_di.di_tv.vval.v_list
 #define vv_tv		vv_di.di_tv
 
 /*
  * The v: variables are stored in dictionary "vimvardict".
  * "vimvars_var" is the variable that is used for the "l:" scope.
@@ -423,31 +431,27 @@ static int dict_equal __ARGS((dict_T *d1
 static int tv_equal __ARGS((typval_T *tv1, typval_T *tv2, int ic));
 static listitem_T *list_find __ARGS((list_T *l, long n));
 static long list_find_nr __ARGS((list_T *l, long idx, int *errorp));
 static long list_idx_of_item __ARGS((list_T *l, listitem_T *item));
 static void list_append __ARGS((list_T *l, listitem_T *item));
-static int list_append_tv __ARGS((list_T *l, typval_T *tv));
-static int list_append_string __ARGS((list_T *l, char_u *str, int len));
 static int list_append_number __ARGS((list_T *l, varnumber_T n));
 static int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item));
 static int list_extend __ARGS((list_T	*l1, list_T *l2, listitem_T *bef));
 static int list_concat __ARGS((list_T *l1, list_T *l2, typval_T *tv));
 static list_T *list_copy __ARGS((list_T *orig, int deep, int copyID));
 static void list_remove __ARGS((list_T *l, listitem_T *item, listitem_T *item2));
 static char_u *list2string __ARGS((typval_T *tv, int copyID));
 static int list_join __ARGS((garray_T *gap, list_T *l, char_u *sep, int echo, int copyID));
+static int free_unref_items __ARGS((int copyID));
 static void set_ref_in_ht __ARGS((hashtab_T *ht, int copyID));
 static void set_ref_in_list __ARGS((list_T *l, int copyID));
 static void set_ref_in_item __ARGS((typval_T *tv, int copyID));
 static void dict_unref __ARGS((dict_T *d));
 static void dict_free __ARGS((dict_T *d, int recurse));
-static dictitem_T *dictitem_alloc __ARGS((char_u *key));
 static dictitem_T *dictitem_copy __ARGS((dictitem_T *org));
 static void dictitem_remove __ARGS((dict_T *dict, dictitem_T *item));
-static void dictitem_free __ARGS((dictitem_T *item));
 static dict_T *dict_copy __ARGS((dict_T *orig, int deep, int copyID));
-static int dict_add __ARGS((dict_T *d, dictitem_T *item));
 static long dict_len __ARGS((dict_T *d));
 static dictitem_T *dict_find __ARGS((dict_T *d, char_u *key, int len));
 static char_u *dict2string __ARGS((typval_T *tv, int copyID));
 static int get_dict_tv __ARGS((char_u **arg, typval_T *rettv, int evaluate));
 static char_u *echo_string __ARGS((typval_T *tv, char_u **tofree, char_u *numbuf, int copyID));
@@ -618,10 +622,13 @@ static void f_max __ARGS((typval_T *argv
 static void f_min __ARGS((typval_T *argvars, typval_T *rettv));
 #ifdef vim_mkdir
 static void f_mkdir __ARGS((typval_T *argvars, typval_T *rettv));
 #endif
 static void f_mode __ARGS((typval_T *argvars, typval_T *rettv));
+#ifdef FEAT_MZSCHEME
+static void f_mzeval __ARGS((typval_T *argvars, typval_T *rettv));
+#endif
 static void f_nextnonblank __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_nr2char __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_pathshorten __ARGS((typval_T *argvars, typval_T *rettv));
 #ifdef FEAT_FLOAT
 static void f_pow __ARGS((typval_T *argvars, typval_T *rettv));
@@ -754,11 +761,10 @@ static void list_one_var __ARGS((dictite
 static void list_one_var_a __ARGS((char_u *prefix, char_u *name, int type, char_u *string, int *first));
 static void set_var __ARGS((char_u *name, typval_T *varp, int copy));
 static int var_check_ro __ARGS((int flags, char_u *name));
 static int var_check_fixed __ARGS((int flags, char_u *name));
 static int tv_check_lock __ARGS((int lock, char_u *name));
-static void copy_tv __ARGS((typval_T *from, typval_T *to));
 static int item_copy __ARGS((typval_T *from, typval_T *to, int deep, int copyID));
 static char_u *find_option_end __ARGS((char_u **arg, int *opt_flags));
 static char_u *trans_function_name __ARGS((char_u **pp, int skip, int flags, funcdict_T *fd));
 static int eval_fname_script __ARGS((char_u *p));
 static int eval_fname_sid __ARGS((char_u *p));
@@ -786,10 +792,12 @@ static char_u *autoload_name __ARGS((cha
 static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
 static void func_free __ARGS((ufunc_T *fp));
 static void func_unref __ARGS((char_u *name));
 static void func_ref __ARGS((char_u *name));
 static void call_user_func __ARGS((ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rettv, linenr_T firstline, linenr_T lastline, dict_T *selfdict));
+static int can_free_funccal __ARGS((funccall_T *fc, int copyID)) ;
+static void free_funccal __ARGS((funccall_T *fc, int free_val));
 static void add_nr_var __ARGS((dict_T *dp, dictitem_T *v, char *name, varnumber_T nr));
 static win_T *find_win_by_nr __ARGS((typval_T *vp, tabpage_T *tp));
 static void getwinvar __ARGS((typval_T *argvars, typval_T *rettv, int off));
 static int searchpair_cmn __ARGS((typval_T *argvars, pos_T *match_pos));
 static int search_cmn __ARGS((typval_T *argvars, pos_T *match_pos, int *flagsp));
@@ -843,15 +851,21 @@ eval_clear()
     for (i = 0; i < VV_LEN; ++i)
     {
 	p = &vimvars[i];
 	if (p->vv_di.di_tv.v_type == VAR_STRING)
 	{
-	    vim_free(p->vv_di.di_tv.vval.v_string);
-	    p->vv_di.di_tv.vval.v_string = NULL;
+	    vim_free(p->vv_str);
+	    p->vv_str = NULL;
+	}
+	else if (p->vv_di.di_tv.v_type == VAR_LIST)
+	{
+	    list_unref(p->vv_list);
+	    p->vv_list = NULL;
 	}
     }
     hash_clear(&vimvarht);
+    hash_init(&vimvarht);  /* garbage_collect() will access it */
     hash_clear(&compat_hashtab);
 
     /* script-local variables */
     for (i = 1; i <= ga_scripts.ga_len; ++i)
 	vars_clear(&SCRIPT_VARS(i));
@@ -914,10 +928,14 @@ func_level(cookie)
 }
 
 /* pointer to funccal for currently active function */
 funccall_T *current_funccal = NULL;
 
+/* pointer to list of previously used funccal, still around because some
+ * item in it is still being used. */
+funccall_T *previous_funccal = NULL;
+
 /*
  * Return TRUE when a function was ended by a ":return" command.
  */
     int
 current_func_returned()
@@ -966,17 +984,18 @@ var_redir_start(name, append)
 {
     int		save_emsg;
     int		err;
     typval_T	tv;
 
-    /* Make sure a valid variable name is specified */
+    /* Catch a bad name early. */
     if (!eval_isnamec1(*name))
     {
 	EMSG(_(e_invarg));
 	return FAIL;
     }
 
+    /* Make a copy of the name, it is used in redir_lval until redir ends. */
     redir_varname = vim_strsave(name);
     if (redir_varname == NULL)
 	return FAIL;
 
     redir_lval = (lval_T *)alloc_clear((unsigned)sizeof(lval_T));
@@ -997,10 +1016,11 @@ var_redir_start(name, append)
 	if (redir_endp != NULL && *redir_endp != NUL)
 	    /* Trailing characters are present after the variable name */
 	    EMSG(_(e_trailing));
 	else
 	    EMSG(_(e_invarg));
+	redir_endp = NULL;  /* don't store a value, only cleanup */
 	var_redir_stop();
 	return FAIL;
     }
 
     /* check if we can write to the variable: set it to or append an empty
@@ -1015,10 +1035,11 @@ var_redir_start(name, append)
 	set_var_lval(redir_lval, redir_endp, &tv, TRUE, (char_u *)"=");
     err = did_emsg;
     did_emsg |= save_emsg;
     if (err)
     {
+	redir_endp = NULL;  /* don't store a value, only cleanup */
 	var_redir_stop();
 	return FAIL;
     }
     if (redir_lval->ll_newkey != NULL)
     {
@@ -1063,26 +1084,31 @@ var_redir_str(value, value_len)
 	var_redir_stop();
 }
 
 /*
  * Stop redirecting command output to a variable.
+ * Frees the allocated memory.
  */
     void
 var_redir_stop()
 {
     typval_T	tv;
 
     if (redir_lval != NULL)
     {
-	/* Append the trailing NUL. */
-	ga_append(&redir_ga, NUL);
+	/* If there was no error: assign the text to the variable. */
+	if (redir_endp != NULL)
+	{
+	    ga_append(&redir_ga, NUL);  /* Append the trailing NUL. */
+	    tv.v_type = VAR_STRING;
+	    tv.vval.v_string = redir_ga.ga_data;
+	    set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
+	}
 
-	/* Assign the text to the variable. */
-	tv.v_type = VAR_STRING;
-	tv.vval.v_string = redir_ga.ga_data;
-	set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
-	vim_free(tv.vval.v_string);
+	/* free the collected output */
+	vim_free(redir_ga.ga_data);
+	redir_ga.ga_data = NULL;
 
 	clear_lval(redir_lval);
 	vim_free(redir_lval);
 	redir_lval = NULL;
     }
@@ -1254,34 +1280,46 @@ skip_expr(pp)
     return eval1(pp, &rettv, FALSE);
 }
 
 /*
  * Top level evaluation function, returning a string.
+ * When "convert" is TRUE convert a List into a sequence of lines and convert
+ * a Float to a String.
  * Return pointer to allocated memory, or NULL for failure.
  */
     char_u *
-eval_to_string(arg, nextcmd, dolist)
+eval_to_string(arg, nextcmd, convert)
     char_u	*arg;
     char_u	**nextcmd;
-    int		dolist;		/* turn List into sequence of lines */
+    int		convert;
 {
     typval_T	tv;
     char_u	*retval;
     garray_T	ga;
+#ifdef FEAT_FLOAT
+    char_u	numbuf[NUMBUFLEN];
+#endif
 
     if (eval0(arg, &tv, nextcmd, TRUE) == FAIL)
 	retval = NULL;
     else
     {
-	if (dolist && tv.v_type == VAR_LIST)
+	if (convert && tv.v_type == VAR_LIST)
 	{
 	    ga_init2(&ga, (int)sizeof(char), 80);
 	    if (tv.vval.v_list != NULL)
 		list_join(&ga, tv.vval.v_list, (char_u *)"\n", TRUE, 0);
 	    ga_append(&ga, NUL);
 	    retval = (char_u *)ga.ga_data;
 	}
+#ifdef FEAT_FLOAT
+	else if (convert && tv.v_type == VAR_FLOAT)
+	{
+	    vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv.vval.v_float);
+	    retval = vim_strsave(numbuf);
+	}
+#endif
 	else
 	    retval = vim_strsave(get_tv_string(&tv));
 	clear_tv(&tv);
     }
 
@@ -3275,11 +3313,11 @@ ex_call(eap)
     startarg = skipwhite(arg);
     rettv.v_type = VAR_UNKNOWN;	/* clear_tv() uses this */
 
     if (*startarg != '(')
     {
-	EMSG2(_("E107: Missing braces: %s"), eap->arg);
+	EMSG2(_("E107: Missing parentheses: %s"), eap->arg);
 	goto end;
     }
 
     /*
      * When skipping, evaluate the function once, to find the end of the
@@ -3655,12 +3693,12 @@ item_lock(tv, deep, lock)
     }
     --recurse;
 }
 
 /*
- * Return TRUE if typeval "tv" is locked: Either tha value is locked itself or
- * it refers to a List or Dictionary that is locked.
+ * Return TRUE if typeval "tv" is locked: Either that value is locked itself
+ * or it refers to a List or Dictionary that is locked.
  */
     static int
 tv_islocked(tv)
     typval_T	*tv;
 {
@@ -3742,11 +3780,10 @@ cat_prefix_varname(prefix, name)
 
 /*
  * Function given to ExpandGeneric() to obtain the list of user defined
  * (global/buffer/window/built-in) variable names.
  */
-/*ARGSUSED*/
     char_u *
 get_user_var_name(xp, idx)
     expand_T	*xp;
     int		idx;
 {
@@ -3900,11 +3937,11 @@ eval0(arg, rettv, nextcmd, evaluate)
     return ret;
 }
 
 /*
  * Handle top level expression:
- *	expr1 ? expr0 : expr0
+ *	expr2 ? expr1 : expr1
  *
  * "arg" must point to the first non-white of the expression.
  * "arg" is advanced to the next non-white after the recognized expression.
  *
  * Note: "rettv.v_lock" is not set.
@@ -5833,11 +5870,12 @@ list_equal(l1, l2, ic)
 	if (!tv_equal(&item1->li_tv, &item2->li_tv, ic))
 	    return FALSE;
     return item1 == NULL && item2 == NULL;
 }
 
-#if defined(FEAT_PYTHON) || defined(PROTO)
+#if defined(FEAT_RUBY) || defined(FEAT_PYTHON) || defined(FEAT_MZSCHEME) \
+	|| defined(PROTO)
 /*
  * Return the dictitem that an entry in a hashtable points to.
  */
     dictitem_T *
 dict_lookup(hi)
@@ -6045,10 +6083,29 @@ list_find_nr(l, idx, errorp)
     }
     return get_tv_number_chk(&li->li_tv, errorp);
 }
 
 /*
+ * Get list item "l[idx - 1]" as a string.  Returns NULL for failure.
+ */
+    char_u *
+list_find_str(l, idx)
+    list_T	*l;
+    long	idx;
+{
+    listitem_T	*li;
+
+    li = list_find(l, idx - 1);
+    if (li == NULL)
+    {
+	EMSGN(_(e_listidx), idx);
+	return NULL;
+    }
+    return get_tv_string(&li->li_tv);
+}
+
+/*
  * Locate "item" list "l" and return its index.
  * Returns -1 when "item" is not in the list.
  */
     static long
 list_idx_of_item(l, item)
@@ -6095,11 +6152,11 @@ list_append(l, item)
 
 /*
  * Append typval_T "tv" to the end of list "l".
  * Return FAIL when out of memory.
  */
-    static int
+    int
 list_append_tv(l, tv)
     list_T	*l;
     typval_T	*tv;
 {
     listitem_T	*li = listitem_alloc();
@@ -6135,11 +6192,11 @@ list_append_dict(list, dict)
 /*
  * Make a copy of "str" and append it as an item to list "l".
  * When "len" >= 0 use "str[len]".
  * Returns FAIL when out of memory.
  */
-    static int
+    int
 list_append_string(l, str, len)
     list_T	*l;
     char_u	*str;
     int		len;
 {
@@ -6415,10 +6472,11 @@ list_join(gap, l, sep, echo, copyID)
 	if (s != NULL)
 	    ga_concat(gap, s);
 	vim_free(tofree);
 	if (s == NULL)
 	    return FAIL;
+	line_breakcheck();
     }
     return OK;
 }
 
 /*
@@ -6446,31 +6504,45 @@ list_join(gap, l, sep, echo, copyID)
  * Return TRUE if some memory was freed.
  */
     int
 garbage_collect()
 {
-    dict_T	*dd;
-    list_T	*ll;
-    int		copyID = ++current_copyID;
+    int		copyID;
     buf_T	*buf;
     win_T	*wp;
     int		i;
-    funccall_T	*fc;
-    int		did_free = FALSE;
+    funccall_T	*fc, **pfc;
+    int		did_free;
+    int		did_free_funccal = FALSE;
 #ifdef FEAT_WINDOWS
     tabpage_T	*tp;
 #endif
 
     /* Only do this once. */
     want_garbage_collect = FALSE;
     may_garbage_collect = FALSE;
     garbage_collect_at_exit = FALSE;
 
+    /* We advance by two because we add one for items referenced through
+     * previous_funccal. */
+    current_copyID += COPYID_INC;
+    copyID = current_copyID;
+
     /*
      * 1. Go through all accessible variables and mark all lists and dicts
      *    with copyID.
      */
+
+    /* Don't free variables in the previous_funccal list unless they are only
+     * referenced through previous_funccal.  This must be first, because if
+     * the item is referenced elsewhere the funccal must not be freed. */
+    for (fc = previous_funccal; fc != NULL; fc = fc->caller)
+    {
+	set_ref_in_ht(&fc->l_vars.dv_hashtab, copyID + 1);
+	set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID + 1);
+    }
+
     /* script-local variables */
     for (i = 1; i <= ga_scripts.ga_len; ++i)
 	set_ref_in_ht(&SCRIPT_VARS(i), copyID);
 
     /* buffer-local variables */
@@ -6495,15 +6567,58 @@ garbage_collect()
     {
 	set_ref_in_ht(&fc->l_vars.dv_hashtab, copyID);
 	set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID);
     }
 
+    /* v: vars */
+    set_ref_in_ht(&vimvarht, copyID);
+
+    /*
+     * 2. Free lists and dictionaries that are not referenced.
+     */
+    did_free = free_unref_items(copyID);
+
     /*
-     * 2. Go through the list of dicts and free items without the copyID.
+     * 3. Check if any funccal can be freed now.
+     */
+    for (pfc = &previous_funccal; *pfc != NULL; )
+    {
+	if (can_free_funccal(*pfc, copyID))
+	{
+	    fc = *pfc;
+	    *pfc = fc->caller;
+	    free_funccal(fc, TRUE);
+	    did_free = TRUE;
+	    did_free_funccal = TRUE;
+	}
+	else
+	    pfc = &(*pfc)->caller;
+    }
+    if (did_free_funccal)
+	/* When a funccal was freed some more items might be garbage
+	 * collected, so run again. */
+	(void)garbage_collect();
+
+    return did_free;
+}
+
+/*
+ * Free lists and dictionaries that are no longer referenced.
+ */
+    static int
+free_unref_items(copyID)
+    int copyID;
+{
+    dict_T	*dd;
+    list_T	*ll;
+    int		did_free = FALSE;
+
+    /*
+     * Go through the list of dicts and free items without the copyID.
      */
     for (dd = first_dict; dd != NULL; )
-	if (dd->dv_copyID != copyID)
+	if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK))
 	{
 	    /* Free the Dictionary and ordinary items it contains, but don't
 	     * recurse into Lists and Dictionaries, they will be in the list
 	     * of dicts or list of lists. */
 	    dict_free(dd, FALSE);
@@ -6514,16 +6629,17 @@ garbage_collect()
 	}
 	else
 	    dd = dd->dv_used_next;
 
     /*
-     * 3. Go through the list of lists and free items without the copyID.
-     *    But don't free a list that has a watcher (used in a for loop), these
-     *    are not referenced anywhere.
+     * Go through the list of lists and free items without the copyID.
+     * But don't free a list that has a watcher (used in a for loop), these
+     * are not referenced anywhere.
      */
     for (ll = first_list; ll != NULL; )
-	if (ll->lv_copyID != copyID && ll->lv_watch == NULL)
+	if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)
+						      && ll->lv_watch == NULL)
 	{
 	    /* Free the List and ordinary items it contains, but don't recurse
 	     * into Lists and Dictionaries, they will be in the list of dicts
 	     * or list of lists. */
 	    list_free(ll, FALSE);
@@ -6585,21 +6701,21 @@ set_ref_in_item(tv, copyID)
 
     switch (tv->v_type)
     {
 	case VAR_DICT:
 	    dd = tv->vval.v_dict;
-	    if (dd->dv_copyID != copyID)
+	    if (dd != NULL && dd->dv_copyID != copyID)
 	    {
 		/* Didn't see this dict yet. */
 		dd->dv_copyID = copyID;
 		set_ref_in_ht(&dd->dv_hashtab, copyID);
 	    }
 	    break;
 
 	case VAR_LIST:
 	    ll = tv->vval.v_list;
-	    if (ll->lv_copyID != copyID)
+	    if (ll != NULL && ll->lv_copyID != copyID)
 	    {
 		/* Didn't see this list yet. */
 		ll->lv_copyID = copyID;
 		set_ref_in_list(ll, copyID);
 	    }
@@ -6693,11 +6809,11 @@ dict_free(d, recurse)
  * Allocate a Dictionary item.
  * The "key" is copied to the new item.
  * Note that the value of the item "di_tv" still needs to be initialized!
  * Returns NULL when out of memory.
  */
-    static dictitem_T *
+    dictitem_T *
 dictitem_alloc(key)
     char_u	*key;
 {
     dictitem_T *di;
 
@@ -6749,11 +6865,11 @@ dictitem_remove(dict, item)
 }
 
 /*
  * Free a dict item.  Also clears the value.
  */
-    static void
+    void
 dictitem_free(item)
     dictitem_T *item;
 {
     clear_tv(&item->di_tv);
     vim_free(item);
@@ -6829,11 +6945,11 @@ dict_copy(orig, deep, copyID)
 
 /*
  * Add item "item" to Dictionary "d".
  * Returns FAIL when out of memory and when key already existed.
  */
-    static int
+    int
 dict_add(d, item)
     dict_T	*d;
     dictitem_T	*item;
 {
     return hash_add(&d->dv_hashtab, item->di_key);
@@ -7523,12 +7639,12 @@ static struct fst
     {"getregtype",	0, 1, f_getregtype},
     {"gettabwinvar",	3, 3, f_gettabwinvar},
     {"getwinposx",	0, 0, f_getwinposx},
     {"getwinposy",	0, 0, f_getwinposy},
     {"getwinvar",	2, 2, f_getwinvar},
-    {"glob",		1, 1, f_glob},
-    {"globpath",	2, 2, f_globpath},
+    {"glob",		1, 2, f_glob},
+    {"globpath",	2, 3, f_globpath},
     {"has",		1, 1, f_has},
     {"has_key",		2, 2, f_has_key},
     {"haslocaldir",	0, 0, f_haslocaldir},
     {"hasmapto",	1, 3, f_hasmapto},
     {"highlightID",	1, 1, f_hlID},		/* obsolete */
@@ -7580,10 +7696,13 @@ static struct fst
     {"min",		1, 1, f_min},
 #ifdef vim_mkdir
     {"mkdir",		1, 3, f_mkdir},
 #endif
     {"mode",		0, 1, f_mode},
+#ifdef FEAT_MZSCHEME
+    {"mzeval",		1, 1, f_mzeval},
+#endif
     {"nextnonblank",	1, 1, f_nextnonblank},
     {"nr2char",		1, 1, f_nr2char},
     {"pathshorten",	1, 1, f_pathshorten},
 #ifdef FEAT_FLOAT
     {"pow",		2, 2, f_pow},
@@ -7721,11 +7840,10 @@ get_function_name(xp, idx)
 
 /*
  * Function given to ExpandGeneric() to obtain the list of internal or
  * user defined variable or function names.
  */
-/*ARGSUSED*/
     char_u *
 get_expr_name(xp, idx)
     expand_T	*xp;
     int		idx;
 {
@@ -7854,13 +7972,13 @@ get_func_tv(name, len, rettv, arg, first
 	ret = call_func(name, len, rettv, argcount, argvars,
 			  firstline, lastline, doesrange, evaluate, selfdict);
     else if (!aborting())
     {
 	if (argcount == MAX_FUNC_ARGS)
-	    emsg_funcname("E740: Too many arguments for function %s", name);
+	    emsg_funcname(N_("E740: Too many arguments for function %s"), name);
 	else
-	    emsg_funcname("E116: Invalid arguments for function %s", name);
+	    emsg_funcname(N_("E116: Invalid arguments for function %s"), name);
     }
 
     while (--argcount >= 0)
 	clear_tv(&argvars[argcount]);
 
@@ -7954,11 +8072,12 @@ call_func(name, len, rettv, argcount, ar
 
 
     /* execute the function if no errors detected and executing */
     if (evaluate && error == ERROR_NONE)
     {
-	rettv->v_type = VAR_NUMBER;	/* default is number rettv */
+	rettv->v_type = VAR_NUMBER;	/* default rettv is number zero */
+	rettv->vval.v_number = 0;
 	error = ERROR_UNKNOWN;
 
 	if (!builtin_function(fname))
 	{
 	    /*
@@ -8089,10 +8208,11 @@ call_func(name, len, rettv, argcount, ar
     return ret;
 }
 
 /*
  * Give an error message with a function name.  Handle <SNR> things.
+ * "ermsg" is to be passed without translation, use N_() instead of _().
  */
     static void
 emsg_funcname(ermsg, name)
     char	*ermsg;
     char_u	*name;
@@ -8203,11 +8323,10 @@ f_append(argvars, rettv)
 	    l = argvars[1].vval.v_list;
 	    if (l == NULL)
 		return;
 	    li = l->lv_first;
 	}
-	rettv->vval.v_number = 0;	/* Default: Success */
 	for (;;)
 	{
 	    if (l == NULL)
 		tv = &argvars[1];	/* append a string */
 	    else if (li == NULL)
@@ -8236,26 +8355,24 @@ f_append(argvars, rettv)
 }
 
 /*
  * "argc()" function
  */
-/* ARGSUSED */
     static void
 f_argc(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = ARGCOUNT;
 }
 
 /*
  * "argidx()" function
  */
-/* ARGSUSED */
     static void
 f_argidx(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = curwin->w_arg_idx;
 }
 
@@ -8329,14 +8446,13 @@ f_atan(argvars, rettv)
 #endif
 
 /*
  * "browse(save, title, initdir, default)" function
  */
-/* ARGSUSED */
     static void
 f_browse(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_BROWSE
     int		save;
     char_u	*title;
@@ -8364,14 +8480,13 @@ f_browse(argvars, rettv)
 }
 
 /*
  * "browsedir(title, initdir)" function
  */
-/* ARGSUSED */
     static void
 f_browsedir(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_BROWSE
     char_u	*title;
     char_u	*initdir;
@@ -8592,14 +8707,13 @@ f_bufwinnr(argvars, rettv)
 }
 
 /*
  * "byte2line(byte)" function
  */
-/*ARGSUSED*/
     static void
 f_byte2line(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifndef FEAT_BYTEOFF
     rettv->vval.v_number = -1;
 #else
@@ -8615,11 +8729,10 @@ f_byte2line(argvars, rettv)
 }
 
 /*
  * "byteidx()" function
  */
-/*ARGSUSED*/
     static void
 f_byteidx(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
@@ -8663,11 +8776,10 @@ f_call(argvars, rettv)
     int		argc = 0;
     listitem_T	*item;
     int		dummy;
     dict_T	*selfdict = NULL;
 
-    rettv->vval.v_number = 0;
     if (argvars[1].v_type != VAR_LIST)
     {
 	EMSG(_(e_listreq));
 	return;
     }
@@ -8735,14 +8847,13 @@ f_ceil(argvars, rettv)
 #endif
 
 /*
  * "changenr()" function
  */
-/*ARGSUSED*/
     static void
 f_changenr(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = curbuf->b_u_seq_cur;
 }
 
@@ -8788,15 +8899,14 @@ f_cindent(argvars, rettv)
 }
 
 /*
  * "clearmatches()" function
  */
-/*ARGSUSED*/
     static void
 f_clearmatches(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
 #ifdef FEAT_SEARCH_EXTRA
     clear_matches(curwin);
 #endif
 }
@@ -8856,15 +8966,14 @@ f_col(argvars, rettv)
 
 #if defined(FEAT_INS_EXPAND)
 /*
  * "complete()" function
  */
-/*ARGSUSED*/
     static void
 f_complete(argvars, rettv)
     typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*rettv UNUSED;
 {
     int	    startcol;
 
     if ((State & INSERT) == 0)
     {
@@ -8891,11 +9000,10 @@ f_complete(argvars, rettv)
 }
 
 /*
  * "complete_add()" function
  */
-/*ARGSUSED*/
     static void
 f_complete_add(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
@@ -8903,14 +9011,13 @@ f_complete_add(argvars, rettv)
 }
 
 /*
  * "complete_check()" function
  */
-/*ARGSUSED*/
     static void
 f_complete_check(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     int		saved = RedrawingDisabled;
 
     RedrawingDisabled = 0;
@@ -8921,15 +9028,14 @@ f_complete_check(argvars, rettv)
 #endif
 
 /*
  * "confirm(message, buttons[, default [, type]])" function
  */
-/*ARGSUSED*/
     static void
 f_confirm(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
     char_u	*message;
     char_u	*buttons = NULL;
     char_u	buf[NUMBUFLEN];
@@ -8971,17 +9077,13 @@ f_confirm(argvars, rettv)
     }
 
     if (buttons == NULL || *buttons == NUL)
 	buttons = (char_u *)_("&Ok");
 
-    if (error)
-	rettv->vval.v_number = 0;
-    else
+    if (!error)
 	rettv->vval.v_number = do_dialog(type, NULL, message, buttons,
 								   def, NULL);
-#else
-    rettv->vval.v_number = 0;
 #endif
 }
 
 /*
  * "copy()" function
@@ -9094,15 +9196,14 @@ f_count(argvars, rettv)
 /*
  * "cscope_connection([{num} , {dbpath} [, {prepend}]])" function
  *
  * Checks the existence of a cscope connection.
  */
-/*ARGSUSED*/
     static void
 f_cscope_connection(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
 #ifdef FEAT_CSCOPE
     int		num = 0;
     char_u	*dbpath = NULL;
     char_u	*prepend = NULL;
@@ -9116,31 +9217,30 @@ f_cscope_connection(argvars, rettv)
 	if (argvars[2].v_type != VAR_UNKNOWN)
 	    prepend = get_tv_string_buf(&argvars[2], buf);
     }
 
     rettv->vval.v_number = cs_connection(num, dbpath, prepend);
-#else
-    rettv->vval.v_number = 0;
 #endif
 }
 
 /*
  * "cursor(lnum, col)" function
  *
- * Moves the cursor to the specified line and column
+ * Moves the cursor to the specified line and column.
+ * Returns 0 when the position could be set, -1 otherwise.
  */
-/*ARGSUSED*/
     static void
 f_cursor(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
     long	line, col;
 #ifdef FEAT_VIRTUALEDIT
     long	coladd = 0;
 #endif
 
+    rettv->vval.v_number = -1;
     if (argvars[1].v_type == VAR_UNKNOWN)
     {
 	pos_T	    pos;
 
 	if (list2fpos(argvars, &pos, NULL) == FAIL)
@@ -9181,10 +9281,11 @@ f_cursor(argvars, rettv)
     if (has_mbyte)
 	mb_adjust_cursor();
 #endif
 
     curwin->w_set_curswant = TRUE;
+    rettv->vval.v_number = 0;
 }
 
 /*
  * "deepcopy()" function
  */
@@ -9198,11 +9299,14 @@ f_deepcopy(argvars, rettv)
     if (argvars[1].v_type != VAR_UNKNOWN)
 	noref = get_tv_number_chk(&argvars[1], NULL);
     if (noref < 0 || noref > 1)
 	EMSG(_(e_invarg));
     else
-	item_copy(&argvars[0], rettv, TRUE, noref == 0 ? ++current_copyID : 0);
+    {
+	current_copyID += COPYID_INC;
+	item_copy(&argvars[0], rettv, TRUE, noref == 0 ? current_copyID : 0);
+    }
 }
 
 /*
  * "delete()" function
  */
@@ -9218,45 +9322,40 @@ f_delete(argvars, rettv)
 }
 
 /*
  * "did_filetype()" function
  */
-/*ARGSUSED*/
     static void
 f_did_filetype(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
 #ifdef FEAT_AUTOCMD
     rettv->vval.v_number = did_filetype;
-#else
-    rettv->vval.v_number = 0;
 #endif
 }
 
 /*
  * "diff_filler()" function
  */
-/*ARGSUSED*/
     static void
 f_diff_filler(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
 #ifdef FEAT_DIFF
     rettv->vval.v_number = diff_check_fill(curwin, get_tv_lnum(argvars));
 #endif
 }
 
 /*
  * "diff_hlID()" function
  */
-/*ARGSUSED*/
     static void
 f_diff_hlID(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
 #ifdef FEAT_DIFF
     linenr_T		lnum = get_tv_lnum(argvars);
     static linenr_T	prev_lnum = 0;
     static int		changedtick = 0;
@@ -9365,11 +9464,10 @@ f_escape(argvars, rettv)
 }
 
 /*
  * "eval()" function
  */
-/*ARGSUSED*/
     static void
 f_eval(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
@@ -9389,14 +9487,13 @@ f_eval(argvars, rettv)
 }
 
 /*
  * "eventhandler()" function
  */
-/*ARGSUSED*/
     static void
 f_eventhandler(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = vgetc_busy;
 }
 
@@ -9516,11 +9613,11 @@ f_expand(argvars, rettv)
 	--emsg_off;
     }
     else
     {
 	/* When the optional second argument is non-zero, don't remove matches
-	 * for 'suffixes' and 'wildignore' */
+	 * for 'wildignore' and don't put matches for 'suffixes' at the end. */
 	if (argvars[1].v_type != VAR_UNKNOWN
 				    && get_tv_number_chk(&argvars[1], &error))
 	    flags |= WILD_KEEP_ALL;
 	if (!error)
 	{
@@ -9540,11 +9637,10 @@ f_expand(argvars, rettv)
     static void
 f_extend(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
-    rettv->vval.v_number = 0;
     if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST)
     {
 	list_T		*l1, *l2;
 	listitem_T	*item;
 	long		before;
@@ -9650,15 +9746,14 @@ f_extend(argvars, rettv)
 }
 
 /*
  * "feedkeys()" function
  */
-/*ARGSUSED*/
     static void
 f_feedkeys(argvars, rettv)
     typval_T    *argvars;
-    typval_T    *rettv;
+    typval_T    *rettv UNUSED;
 {
     int		remap = TRUE;
     char_u	*keys, *flags;
     char_u	nbuf[NUMBUFLEN];
     int		typed = FALSE;
@@ -9668,11 +9763,10 @@ f_feedkeys(argvars, rettv)
      * executed in the sandbox it would be OK, but it probably happens later,
      * when "sandbox" is no longer set. */
     if (check_secure())
 	return;
 
-    rettv->vval.v_number = 0;
     keys = get_tv_string(&argvars[0]);
     if (*keys != NUL)
     {
 	if (argvars[1].v_type != VAR_UNKNOWN)
 	{
@@ -9835,12 +9929,12 @@ filter_map(argvars, rettv, map)
     typval_T	save_key;
     int		rem;
     int		todo;
     char_u	*ermsg = map ? (char_u *)"map()" : (char_u *)"filter()";
     int		save_did_emsg;
+    int		index = 0;
 
-    rettv->vval.v_number = 0;
     if (argvars[0].v_type == VAR_LIST)
     {
 	if ((l = argvars[0].vval.v_list) == NULL
 		|| (map && tv_check_lock(l->lv_lock, ermsg)))
 	    return;
@@ -9869,13 +9963,13 @@ filter_map(argvars, rettv, map)
 	/* We reset "did_emsg" to be able to detect whether an error
 	 * occurred during evaluation of the expression. */
 	save_did_emsg = did_emsg;
 	did_emsg = FALSE;
 
+	prepare_vimvar(VV_KEY, &save_key);
 	if (argvars[0].v_type == VAR_DICT)
 	{
-	    prepare_vimvar(VV_KEY, &save_key);
 	    vimvars[VV_KEY].vv_type = VAR_STRING;
 
 	    ht = &d->dv_hashtab;
 	    hash_lock(ht);
 	    todo = (int)ht->ht_used;
@@ -9895,28 +9989,31 @@ filter_map(argvars, rettv, map)
 			dictitem_remove(d, di);
 		    clear_tv(&vimvars[VV_KEY].vv_tv);
 		}
 	    }
 	    hash_unlock(ht);
-
-	    restore_vimvar(VV_KEY, &save_key);
 	}
 	else
 	{
+	    vimvars[VV_KEY].vv_type = VAR_NUMBER;
+
 	    for (li = l->lv_first; li != NULL; li = nli)
 	    {
 		if (tv_check_lock(li->li_tv.v_lock, ermsg))
 		    break;
 		nli = li->li_next;
+		vimvars[VV_KEY].vv_nr = index;
 		if (filter_map_one(&li->li_tv, expr, map, &rem) == FAIL
 								  || did_emsg)
 		    break;
 		if (!map && rem)
 		    listitem_remove(l, li);
+		++index;
 	    }
 	}
 
+	restore_vimvar(VV_KEY, &save_key);
 	restore_vimvar(VV_VAL, &save_val);
 
 	did_emsg |= save_did_emsg;
     }
 
@@ -10019,12 +10116,10 @@ f_float2nr(argvars, rettv)
 	else if (f > 0x7fffffff)
 	    rettv->vval.v_number = 0x7fffffff;
 	else
 	    rettv->vval.v_number = (varnumber_T)f;
     }
-    else
-	rettv->vval.v_number = 0;
 }
 
 /*
  * "floor({float})" function
  */
@@ -10154,22 +10249,19 @@ f_foldlevel(argvars, rettv)
     linenr_T	lnum;
 
     lnum = get_tv_lnum(argvars);
     if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count)
 	rettv->vval.v_number = foldLevel(lnum);
-    else
 #endif
-	rettv->vval.v_number = 0;
 }
 
 /*
  * "foldtext()" function
  */
-/*ARGSUSED*/
     static void
 f_foldtext(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_FOLDING
     linenr_T	lnum;
     char_u	*s;
@@ -10230,14 +10322,13 @@ f_foldtext(argvars, rettv)
 }
 
 /*
  * "foldtextresult(lnum)" function
  */
-/*ARGSUSED*/
     static void
 f_foldtextresult(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_FOLDING
     linenr_T	lnum;
     char_u	*text;
@@ -10266,17 +10357,15 @@ f_foldtextresult(argvars, rettv)
 }
 
 /*
  * "foreground()" function
  */
-/*ARGSUSED*/
     static void
 f_foreground(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
-    rettv->vval.v_number = 0;
 #ifdef FEAT_GUI
     if (gui.in_use)
 	gui_mch_set_foreground();
 #else
 # ifdef WIN32
@@ -10286,23 +10375,22 @@ f_foreground(argvars, rettv)
 }
 
 /*
  * "function()" function
  */
-/*ARGSUSED*/
     static void
 f_function(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
     char_u	*s;
 
-    rettv->vval.v_number = 0;
     s = get_tv_string(&argvars[0]);
     if (s == NULL || *s == NUL || VIM_ISDIGIT(*s))
 	EMSG2(_(e_invarg2), s);
-    else if (!function_exists(s))
+    /* Don't check an autoload name for existence here. */
+    else if (vim_strchr(s, AUTOLOAD_CHAR) == NULL && !function_exists(s))
 	EMSG2(_("E700: Unknown function: %s"), s);
     else
     {
 	rettv->vval.v_string = vim_strsave(s);
 	rettv->v_type = VAR_FUNC;
@@ -10310,15 +10398,14 @@ f_function(argvars, rettv)
 }
 
 /*
  * "garbagecollect()" function
  */
-/*ARGSUSED*/
     static void
 f_garbagecollect(argvars, rettv)
     typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*rettv UNUSED;
 {
     /* This is postponed until we are back at the toplevel, because we may be
      * using Lists and Dicts internally.  E.g.: ":echo [garbagecollect()]". */
     want_garbage_collect = TRUE;
 
@@ -10363,13 +10450,11 @@ f_get(argvars, rettv)
     else
 	EMSG2(_(e_listdictarg), "get()");
 
     if (tv == NULL)
     {
-	if (argvars[2].v_type == VAR_UNKNOWN)
-	    rettv->vval.v_number = 0;
-	else
+	if (argvars[2].v_type != VAR_UNKNOWN)
 	    copy_tv(&argvars[2], rettv);
     }
     else
 	copy_tv(tv, rettv);
 }
@@ -10390,17 +10475,12 @@ get_buffer_lines(buf, start, end, retlis
     int		retlist;
     typval_T	*rettv;
 {
     char_u	*p;
 
-    if (retlist)
-    {
-	if (rettv_list_alloc(rettv) == FAIL)
-	    return;
-    }
-    else
-	rettv->vval.v_number = 0;
+    if (retlist && rettv_list_alloc(rettv) == FAIL)
+	return;
 
     if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0)
 	return;
 
     if (!retlist)
@@ -10600,23 +10680,23 @@ f_getchar(argvars, rettv)
 	    win_T	*win;
 	    linenr_T	lnum;
 # ifdef FEAT_WINDOWS
 	    win_T	*wp;
 # endif
-	    int		n = 1;
+	    int		winnr = 1;
 
 	    if (row >= 0 && col >= 0)
 	    {
 		/* Find the window at the mouse coordinates and compute the
 		 * text position. */
 		win = mouse_find_win(&row, &col);
 		(void)mouse_comp_pos(win, &row, &col, &lnum);
 # ifdef FEAT_WINDOWS
 		for (wp = firstwin; wp != win; wp = wp->w_next)
-		    ++n;
+		    ++winnr;
 # endif
-		vimvars[VV_MOUSE_WIN].vv_nr = n;
+		vimvars[VV_MOUSE_WIN].vv_nr = winnr;
 		vimvars[VV_MOUSE_LNUM].vv_nr = lnum;
 		vimvars[VV_MOUSE_COL].vv_nr = col + 1;
 	    }
 	}
 #endif
@@ -10624,51 +10704,47 @@ f_getchar(argvars, rettv)
 }
 
 /*
  * "getcharmod()" function
  */
-/*ARGSUSED*/
     static void
 f_getcharmod(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = mod_mask;
 }
 
 /*
  * "getcmdline()" function
  */
-/*ARGSUSED*/
     static void
 f_getcmdline(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->v_type = VAR_STRING;
     rettv->vval.v_string = get_cmdline_str();
 }
 
 /*
  * "getcmdpos()" function
  */
-/*ARGSUSED*/
     static void
 f_getcmdpos(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = get_cmdline_pos() + 1;
 }
 
 /*
  * "getcmdtype()" function
  */
-/*ARGSUSED*/
     static void
 f_getcmdtype(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->v_type = VAR_STRING;
     rettv->vval.v_string = alloc(2);
     if (rettv->vval.v_string != NULL)
@@ -10679,14 +10755,13 @@ f_getcmdtype(argvars, rettv)
 }
 
 /*
  * "getcwd()" function
  */
-/*ARGSUSED*/
     static void
 f_getcwd(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     char_u	cwd[MAXPATHL];
 
     rettv->v_type = VAR_STRING;
@@ -10703,14 +10778,13 @@ f_getcwd(argvars, rettv)
 }
 
 /*
  * "getfontname()" function
  */
-/*ARGSUSED*/
     static void
 f_getfontname(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->v_type = VAR_STRING;
     rettv->vval.v_string = NULL;
 #ifdef FEAT_GUI
@@ -10933,22 +11007,19 @@ f_getline(argvars, rettv)
 }
 
 /*
  * "getmatches()" function
  */
-/*ARGSUSED*/
     static void
 f_getmatches(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_SEARCH_EXTRA
     dict_T	*dict;
     matchitem_T	*cur = curwin->w_match_head;
 
-    rettv->vval.v_number = 0;
-
     if (rettv_list_alloc(rettv) == OK)
     {
 	while (cur != NULL)
 	{
 	    dict = dict_alloc();
@@ -10966,14 +11037,13 @@ f_getmatches(argvars, rettv)
 }
 
 /*
  * "getpid()" function
  */
-/*ARGSUSED*/
     static void
 f_getpid(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = mch_get_pid();
 }
 
@@ -11013,21 +11083,19 @@ f_getpos(argvars, rettv)
 }
 
 /*
  * "getqflist()" and "getloclist()" functions
  */
-/*ARGSUSED*/
     static void
 f_getqflist(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
 #ifdef FEAT_QUICKFIX
     win_T	*wp;
 #endif
 
-    rettv->vval.v_number = 0;
 #ifdef FEAT_QUICKFIX
     if (rettv_list_alloc(rettv) == OK)
     {
 	wp = NULL;
 	if (argvars[0].v_type != VAR_UNKNOWN)	/* getloclist() */
@@ -11133,14 +11201,13 @@ f_gettabwinvar(argvars, rettv)
 }
 
 /*
  * "getwinposx()" function
  */
-/*ARGSUSED*/
     static void
 f_getwinposx(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = -1;
 #ifdef FEAT_GUI
     if (gui.in_use)
@@ -11154,14 +11221,13 @@ f_getwinposx(argvars, rettv)
 }
 
 /*
  * "getwinposy()" function
  */
-/*ARGSUSED*/
     static void
 f_getwinposy(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = -1;
 #ifdef FEAT_GUI
     if (gui.in_use)
@@ -11282,35 +11348,55 @@ getwinvar(argvars, rettv, off)
     static void
 f_glob(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
+    int		flags = WILD_SILENT|WILD_USE_NL;
     expand_T	xpc;
+    int		error = FALSE;
 
-    ExpandInit(&xpc);
-    xpc.xp_context = EXPAND_FILES;
+    /* When the optional second argument is non-zero, don't remove matches
+    * for 'wildignore' and don't put matches for 'suffixes' at the end. */
+    if (argvars[1].v_type != VAR_UNKNOWN
+				&& get_tv_number_chk(&argvars[1], &error))
+	flags |= WILD_KEEP_ALL;
     rettv->v_type = VAR_STRING;
-    rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
-				     NULL, WILD_USE_NL|WILD_SILENT, WILD_ALL);
+    if (!error)
+    {
+	ExpandInit(&xpc);
+	xpc.xp_context = EXPAND_FILES;
+	rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
+						       NULL, flags, WILD_ALL);
+    }
+    else
+	rettv->vval.v_string = NULL;
 }
 
 /*
  * "globpath()" function
  */
     static void
 f_globpath(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
+    int		flags = 0;
     char_u	buf1[NUMBUFLEN];
     char_u	*file = get_tv_string_buf_chk(&argvars[1], buf1);
+    int		error = FALSE;
 
+    /* When the optional second argument is non-zero, don't remove matches
+    * for 'wildignore' and don't put matches for 'suffixes' at the end. */
+    if (argvars[2].v_type != VAR_UNKNOWN
+				&& get_tv_number_chk(&argvars[2], &error))
+	flags |= WILD_KEEP_ALL;
     rettv->v_type = VAR_STRING;
-    if (file == NULL)
+    if (file == NULL || error)
 	rettv->vval.v_string = NULL;
     else
-	rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file);
+	rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file,
+								       flags);
 }
 
 /*
  * "has()" function
  */
@@ -11368,11 +11454,11 @@ f_has(argvars, rettv)
 	"win32",
 #endif
 #if defined(UNIX) && (defined(__CYGWIN32__) || defined(__CYGWIN__))
 	"win32unix",
 #endif
-#ifdef WIN64
+#if defined(WIN64) || defined(_WIN64)
 	"win64",
 #endif
 #ifdef EBCDIC
 	"ebcdic",
 #endif
@@ -11655,10 +11741,13 @@ f_has(argvars, rettv)
 	"smartindent",
 #endif
 #ifdef FEAT_SNIFF
 	"sniff",
 #endif
+#ifdef STARTUPTIME
+	"startuptime",
+#endif
 #ifdef FEAT_STL_OPT
 	"statusline",
 #endif
 #ifdef FEAT_SUN_WORKSHOP
 	"sun_workshop",
@@ -11780,10 +11869,14 @@ f_has(argvars, rettv)
     {
 	if (STRNICMP(name, "patch", 5) == 0)
 	    n = has_patch(atoi((char *)name + 5));
 	else if (STRICMP(name, "vim_starting") == 0)
 	    n = (starting != 0);
+#ifdef FEAT_MBYTE
+	else if (STRICMP(name, "multi_byte_encoding") == 0)
+	    n = has_mbyte;
+#endif
 #if defined(FEAT_BEVAL) && defined(FEAT_GUI_W32)
 	else if (STRICMP(name, "balloon_multiline") == 0)
 	    n = multiline_balloon_available();
 #endif
 #ifdef DYNAMIC_TCL
@@ -11845,11 +11938,10 @@ f_has(argvars, rettv)
     static void
 f_has_key(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
-    rettv->vval.v_number = 0;
     if (argvars[0].v_type != VAR_DICT)
     {
 	EMSG(_(e_dictreq));
 	return;
     }
@@ -11861,14 +11953,13 @@ f_has_key(argvars, rettv)
 }
 
 /*
  * "haslocaldir()" function
  */
-/*ARGSUSED*/
     static void
 f_haslocaldir(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = (curwin->w_localdir != NULL);
 }
 
@@ -11902,14 +11993,13 @@ f_hasmapto(argvars, rettv)
 }
 
 /*
  * "histadd()" function
  */
-/*ARGSUSED*/
     static void
 f_histadd(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_CMDHIST
     int		histype;
     char_u	*str;
@@ -11925,10 +12015,11 @@ f_histadd(argvars, rettv)
     if (histype >= 0)
     {
 	str = get_tv_string_buf(&argvars[1], buf);
 	if (*str != NUL)
 	{
+	    init_history();
 	    add_to_history(histype, str, FALSE, NUL);
 	    rettv->vval.v_number = TRUE;
 	    return;
 	}
     }
@@ -11936,15 +12027,14 @@ f_histadd(argvars, rettv)
 }
 
 /*
  * "histdel()" function
  */
-/*ARGSUSED*/
     static void
 f_histdel(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
 #ifdef FEAT_CMDHIST
     int		n;
     char_u	buf[NUMBUFLEN];
     char_u	*str;
@@ -11962,22 +12052,19 @@ f_histdel(argvars, rettv)
     else
 	/* string given: remove all matching entries */
 	n = del_history_entry(get_histtype(str),
 				      get_tv_string_buf(&argvars[1], buf));
     rettv->vval.v_number = n;
-#else
-    rettv->vval.v_number = 0;
 #endif
 }
 
 /*
  * "histget()" function
  */
-/*ARGSUSED*/
     static void
 f_histget(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_CMDHIST
     int		type;
     int		idx;
@@ -12003,14 +12090,13 @@ f_histget(argvars, rettv)
 }
 
 /*
  * "histnr()" function
  */
-/*ARGSUSED*/
     static void
 f_histnr(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     int		i;
 
 #ifdef FEAT_CMDHIST
@@ -12048,14 +12134,13 @@ f_hlexists(argvars, rettv)
 }
 
 /*
  * "hostname()" function
  */
-/*ARGSUSED*/
     static void
 f_hostname(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     char_u hostname[256];
 
     mch_get_host_name(hostname, 256);
@@ -12064,14 +12149,13 @@ f_hostname(argvars, rettv)
 }
 
 /*
  * iconv() function
  */
-/*ARGSUSED*/
     static void
 f_iconv(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_MBYTE
     char_u	buf1[NUMBUFLEN];
     char_u	buf2[NUMBUFLEN];
@@ -12325,11 +12409,10 @@ f_inputlist(argvars, rettv)
 {
     listitem_T	*li;
     int		selected;
     int		mouse_used;
 
-    rettv->vval.v_number = 0;
 #ifdef NO_CONSOLE_INPUT
     /* While starting up, there is no place to enter text. */
     if (no_console_input())
 	return;
 #endif
@@ -12363,22 +12446,21 @@ f_inputlist(argvars, rettv)
 static garray_T	    ga_userinput = {0, 0, sizeof(tasave_T), 4, NULL};
 
 /*
  * "inputrestore()" function
  */
-/*ARGSUSED*/
     static void
 f_inputrestore(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     if (ga_userinput.ga_len > 0)
     {
 	--ga_userinput.ga_len;
 	restore_typeahead((tasave_T *)(ga_userinput.ga_data)
 						       + ga_userinput.ga_len);
-	rettv->vval.v_number = 0; /* OK */
+	/* default return is zero == OK */
     }
     else if (p_verbose > 1)
     {
 	verb_msg((char_u *)_("called inputrestore() more often than inputsave()"));
 	rettv->vval.v_number = 1; /* Failed */
@@ -12386,23 +12468,22 @@ f_inputrestore(argvars, rettv)
 }
 
 /*
  * "inputsave()" function
  */
-/*ARGSUSED*/
     static void
 f_inputsave(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     /* Add an entry to the stack of typeahead storage. */
     if (ga_grow(&ga_userinput, 1) == OK)
     {
 	save_typeahead((tasave_T *)(ga_userinput.ga_data)
 						       + ga_userinput.ga_len);
 	++ga_userinput.ga_len;
-	rettv->vval.v_number = 0; /* OK */
+	/* default return is zero == OK */
     }
     else
 	rettv->vval.v_number = 1; /* Failed */
 }
 
@@ -12432,11 +12513,10 @@ f_insert(argvars, rettv)
     long	before = 0;
     listitem_T	*item;
     list_T	*l;
     int		error = FALSE;
 
-    rettv->vval.v_number = 0;
     if (argvars[0].v_type != VAR_LIST)
 	EMSG2(_(e_listarg), "insert()");
     else if ((l = argvars[0].vval.v_list) != NULL
 	    && !tv_check_lock(l->lv_lock, (char_u *)"insert()"))
     {
@@ -12551,11 +12631,10 @@ dict_list(argvars, rettv, what)
     listitem_T	*li;
     listitem_T	*li2;
     dict_T	*d;
     int		todo;
 
-    rettv->vval.v_number = 0;
     if (argvars[0].v_type != VAR_DICT)
     {
 	EMSG(_(e_dictreq));
 	return;
     }
@@ -12639,11 +12718,10 @@ f_join(argvars, rettv)
     typval_T	*rettv;
 {
     garray_T	ga;
     char_u	*sep;
 
-    rettv->vval.v_number = 0;
     if (argvars[0].v_type != VAR_LIST)
     {
 	EMSG(_(e_listreq));
 	return;
     }
@@ -12679,14 +12757,13 @@ f_keys(argvars, rettv)
 }
 
 /*
  * "last_buffer_nr()" function.
  */
-/*ARGSUSED*/
     static void
 f_last_buffer_nr(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     int		n = 0;
     buf_T	*buf;
 
@@ -12737,13 +12814,11 @@ libcall_common(argvars, rettv, type)
     char_u		**string_result;
     int			nr_result;
 #endif
 
     rettv->v_type = type;
-    if (type == VAR_NUMBER)
-	rettv->vval.v_number = 0;
-    else
+    if (type != VAR_NUMBER)
 	rettv->vval.v_string = NULL;
 
     if (check_restricted() || check_secure())
 	return;
 
@@ -12811,14 +12886,13 @@ f_line(argvars, rettv)
 }
 
 /*
  * "line2byte(lnum)" function
  */
-/*ARGSUSED*/
     static void
 f_line2byte(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifndef FEAT_BYTEOFF
     rettv->vval.v_number = -1;
 #else
@@ -12860,14 +12934,13 @@ f_lispindent(argvars, rettv)
 }
 
 /*
  * "localtime()" function
  */
-/*ARGSUSED*/
     static void
 f_localtime(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->vval.v_number = (varnumber_T)time(NULL);
 }
 
@@ -13445,11 +13518,10 @@ f_mkdir(argvars, rettv)
 #endif
 
 /*
  * "mode()" function
  */
-/*ARGSUSED*/
     static void
 f_mode(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
@@ -13519,10 +13591,27 @@ f_mode(argvars, rettv)
 
     rettv->vval.v_string = vim_strsave(buf);
     rettv->v_type = VAR_STRING;
 }
 
+#ifdef FEAT_MZSCHEME
+/*
+ * "mzeval()" function
+ */
+    static void
+f_mzeval(argvars, rettv)
+    typval_T	*argvars;
+    typval_T	*rettv;
+{
+    char_u	*str;
+    char_u	buf[NUMBUFLEN];
+
+    str = get_tv_string_buf(&argvars[0], buf);
+    do_mzeval(str, rettv);
+}
+#endif
+
 /*
  * "nextnonblank()" function
  */
     static void
 f_nextnonblank(argvars, rettv)
@@ -13674,17 +13763,15 @@ f_printf(argvars, rettv)
 }
 
 /*
  * "pumvisible()" function
  */
-/*ARGSUSED*/
     static void
 f_pumvisible(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
-    rettv->vval.v_number = 0;
 #ifdef FEAT_INS_EXPAND
     if (pum_visible())
 	rettv->vval.v_number = 1;
 #endif
 }
@@ -13714,11 +13801,10 @@ f_range(argvars, rettv)
 	end = get_tv_number_chk(&argvars[1], &error);
 	if (argvars[2].v_type != VAR_UNKNOWN)
 	    stride = get_tv_number_chk(&argvars[2], &error);
     }
 
-    rettv->vval.v_number = 0;
     if (error)
 	return;		/* type error; errmsg already given */
     if (stride == 0)
 	EMSG(_("E726: Stride is zero"));
     else if (stride > 0 ? end + 1 < start : end - 1 > start)
@@ -14081,14 +14167,13 @@ remote_common(argvars, rettv, expr)
 #endif
 
 /*
  * "remote_expr()" function
  */
-/*ARGSUSED*/
     static void
 f_remote_expr(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->v_type = VAR_STRING;
     rettv->vval.v_string = NULL;
 #ifdef FEAT_CLIENTSERVER
@@ -14097,17 +14182,15 @@ f_remote_expr(argvars, rettv)
 }
 
 /*
  * "remote_foreground()" function
  */
-/*ARGSUSED*/
     static void
 f_remote_foreground(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
-    rettv->vval.v_number = 0;
 #ifdef FEAT_CLIENTSERVER
 # ifdef WIN32
     /* On Win32 it's done in this application. */
     {
 	char_u	*server_name = get_tv_string_chk(&argvars[0]);
@@ -14124,14 +14207,13 @@ f_remote_foreground(argvars, rettv)
     vim_free(argvars[1].vval.v_string);
 # endif
 #endif
 }
 
-/*ARGSUSED*/
     static void
 f_remote_peek(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_CLIENTSERVER
     dictitem_T	v;
     char_u	*s = NULL;
@@ -14159,11 +14241,10 @@ f_remote_peek(argvars, rettv)
     {
 	s = serverGetReply((HWND)n, FALSE, FALSE, FALSE);
 	rettv->vval.v_number = (s != NULL);
     }
 # else
-    rettv->vval.v_number = 0;
     if (check_connection() == FAIL)
 	return;
 
     rettv->vval.v_number = serverPeekReply(X_DISPLAY,
 						serverStrToWin(serverid), &s);
@@ -14183,14 +14264,13 @@ f_remote_peek(argvars, rettv)
 #else
     rettv->vval.v_number = -1;
 #endif
 }
 
-/*ARGSUSED*/
     static void
 f_remote_read(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     char_u	*r = NULL;
 
 #ifdef FEAT_CLIENTSERVER
@@ -14218,14 +14298,13 @@ f_remote_read(argvars, rettv)
 }
 
 /*
  * "remote_send()" function
  */
-/*ARGSUSED*/
     static void
 f_remote_send(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     rettv->v_type = VAR_STRING;
     rettv->vval.v_string = NULL;
 #ifdef FEAT_CLIENTSERVER
@@ -14248,11 +14327,10 @@ f_remove(argvars, rettv)
     long	end;
     char_u	*key;
     dict_T	*d;
     dictitem_T	*di;
 
-    rettv->vval.v_number = 0;
     if (argvars[0].v_type == VAR_DICT)
     {
 	if (argvars[2].v_type != VAR_UNKNOWN)
 	    EMSG2(_(e_toomanyarg), "remove()");
 	else if ((d = argvars[0].vval.v_dict) != NULL
@@ -14351,11 +14429,10 @@ f_rename(argvars, rettv)
 }
 
 /*
  * "repeat()" function
  */
-/*ARGSUSED*/
     static void
 f_repeat(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
@@ -14606,11 +14683,10 @@ f_reverse(argvars, rettv)
     typval_T	*rettv;
 {
     list_T	*l;
     listitem_T	*li, *ni;
 
-    rettv->vval.v_number = 0;
     if (argvars[0].v_type != VAR_LIST)
 	EMSG2(_(e_listarg), "reverse()");
     else if ((l = argvars[0].vval.v_list) != NULL
 	    && !tv_check_lock(l->lv_lock, (char_u *)"reverse()"))
     {
@@ -14958,12 +15034,10 @@ f_searchpairpos(argvars, rettv)
 {
     pos_T	match_pos;
     int		lnum = 0;
     int		col = 0;
 
-    rettv->vval.v_number = 0;
-
     if (rettv_list_alloc(rettv) == FAIL)
 	return;
 
     if (searchpair_cmn(argvars, &match_pos) > 0)
     {
@@ -15146,12 +15220,10 @@ f_searchpos(argvars, rettv)
     int		lnum = 0;
     int		col = 0;
     int		n;
     int		flags = 0;
 
-    rettv->vval.v_number = 0;
-
     if (rettv_list_alloc(rettv) == FAIL)
 	return;
 
     n = search_cmn(argvars, &match_pos, &flags);
     if (n > 0)
@@ -15165,14 +15237,13 @@ f_searchpos(argvars, rettv)
     if (flags & SP_SUBPAT)
 	list_append_number(rettv->vval.v_list, (varnumber_T)n);
 }
 
 
-/*ARGSUSED*/
     static void
 f_server2client(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_CLIENTSERVER
     char_u	buf[NUMBUFLEN];
     char_u	*server = get_tv_string_chk(&argvars[0]);
@@ -15197,14 +15268,13 @@ f_server2client(argvars, rettv)
 #else
     rettv->vval.v_number = -1;
 #endif
 }
 
-/*ARGSUSED*/
     static void
 f_serverlist(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     char_u	*r = NULL;
 
 #ifdef FEAT_CLIENTSERVER
@@ -15221,24 +15291,21 @@ f_serverlist(argvars, rettv)
 }
 
 /*
  * "setbufvar()" function
  */
-/*ARGSUSED*/
     static void
 f_setbufvar(argvars, rettv)
     typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*rettv UNUSED;
 {
     buf_T	*buf;
     aco_save_T	aco;
     char_u	*varname, *bufvarname;
     typval_T	*varp;
     char_u	nbuf[NUMBUFLEN];
 
-    rettv->vval.v_number = 0;
-
     if (check_restricted() || check_secure())
 	return;
     (void)get_tv_number(&argvars[0]);	    /* issue errmsg if type error */
     varname = get_tv_string_chk(&argvars[1]);
     buf = get_buf_tv(&argvars[0]);
@@ -15314,11 +15381,11 @@ f_setline(argvars, rettv)
 	li = l->lv_first;
     }
     else
 	line = get_tv_string_chk(&argvars[1]);
 
-    rettv->vval.v_number = 0;		/* OK */
+    /* default result is zero == OK */
     for (;;)
     {
 	if (l != NULL)
 	{
 	    /* list argument, get next string */
@@ -15362,16 +15429,15 @@ f_setline(argvars, rettv)
 static void set_qf_ll_list __ARGS((win_T *wp, typval_T *list_arg, typval_T *action_arg, typval_T *rettv));
 
 /*
  * Used by "setqflist()" and "setloclist()" functions
  */
-/*ARGSUSED*/
     static void
 set_qf_ll_list(wp, list_arg, action_arg, rettv)
-    win_T	*wp;
-    typval_T	*list_arg;
-    typval_T	*action_arg;
+    win_T	*wp UNUSED;
+    typval_T	*list_arg UNUSED;
+    typval_T	*action_arg UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_QUICKFIX
     char_u	*act;
     int		action = ' ';
@@ -15402,11 +15468,10 @@ set_qf_ll_list(wp, list_arg, action_arg,
 }
 
 /*
  * "setloclist()" function
  */
-/*ARGSUSED*/
     static void
 f_setloclist(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
@@ -15480,11 +15545,10 @@ f_setmatches(argvars, rettv)
 }
 
 /*
  * "setpos()" function
  */
-/*ARGSUSED*/
     static void
 f_setpos(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
@@ -15496,11 +15560,12 @@ f_setpos(argvars, rettv)
     name = get_tv_string_chk(argvars);
     if (name != NULL)
     {
 	if (list2fpos(&argvars[1], &pos, &fnum) == OK)
 	{
-	    --pos.col;
+	    if (--pos.col < 0)
+		pos.col = 0;
 	    if (name[0] == '.' && name[1] == NUL)
 	    {
 		/* set cursor */
 		if (fnum == curbuf->b_fnum)
 		{
@@ -15524,11 +15589,10 @@ f_setpos(argvars, rettv)
 }
 
 /*
  * "setqflist()" function
  */
-/*ARGSUSED*/
     static void
 f_setqflist(argvars, rettv)
     typval_T	*argvars;
     typval_T	*rettv;
 {
@@ -15630,11 +15694,11 @@ f_setwinvar(argvars, rettv)
  * "setwinvar()" and "settabwinvar()" functions
  */
     static void
 setwinvar(argvars, rettv, off)
     typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*rettv UNUSED;
     int		off;
 {
     win_T	*win;
 #ifdef FEAT_WINDOWS
     win_T	*save_curwin;
@@ -15643,12 +15707,10 @@ setwinvar(argvars, rettv, off)
     char_u	*varname, *winvarname;
     typval_T	*varp;
     char_u	nbuf[NUMBUFLEN];
     tabpage_T	*tp;
 
-    rettv->vval.v_number = 0;
-
     if (check_restricted() || check_secure())
 	return;
 
 #ifdef FEAT_WINDOWS
     if (off == 1)
@@ -15836,14 +15898,13 @@ item_compare2(s1, s2)
     clear_tv(&argv[1]);
 
     if (res == FAIL)
 	res = ITEM_COMPARE_FAIL;
     else
-	/* return value has wrong type */
 	res = get_tv_number_chk(&rettv, &item_compare_func_err);
     if (item_compare_func_err)
-	res = ITEM_COMPARE_FAIL;
+	res = ITEM_COMPARE_FAIL;  /* return value has wrong type */
     clear_tv(&rettv);
     return res;
 }
 
 /*
@@ -15858,11 +15919,10 @@ f_sort(argvars, rettv)
     listitem_T	*li;
     listitem_T	**ptrs;
     long	len;
     long	i;
 
-    rettv->vval.v_number = 0;
     if (argvars[0].v_type != VAR_LIST)
 	EMSG2(_(e_listarg), "sort()");
     else
     {
 	l = argvars[0].vval.v_list;
@@ -15950,14 +16010,13 @@ f_soundfold(argvars, rettv)
 }
 
 /*
  * "spellbadword()" function
  */
-/* ARGSUSED */
     static void
 f_spellbadword(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     char_u	*word = (char_u *)"";
     hlf_T	attr = HLF_COUNT;
     int		len = 0;
@@ -16005,14 +16064,13 @@ f_spellbadword(argvars, rettv)
 }
 
 /*
  * "spellsuggest()" function
  */
-/*ARGSUSED*/
     static void
 f_spellsuggest(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_SPELL
     char_u	*str;
     int		typeerr = FALSE;
@@ -16491,14 +16549,13 @@ f_substitute(argvars, rettv)
 }
 
 /*
  * "synID(lnum, col, trans)" function
  */
-/*ARGSUSED*/
     static void
 f_synID(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     int		id = 0;
 #ifdef FEAT_SYN_HL
     long	lnum;
@@ -16519,14 +16576,13 @@ f_synID(argvars, rettv)
 }
 
 /*
  * "synIDattr(id, what [, mode])" function
  */
-/*ARGSUSED*/
     static void
 f_synIDattr(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     char_u	*p = NULL;
 #ifdef FEAT_SYN_HL
     int		id;
@@ -16569,11 +16625,11 @@ f_synIDattr(argvars, rettv)
 		    p = highlight_color(id, what, modec);
 		else					/* bold */
 		    p = highlight_has_attr(id, HL_BOLD, modec);
 		break;
 
-	case 'f':					/* fg[#] */
+	case 'f':					/* fg[#] or font */
 		p = highlight_color(id, what, modec);
 		break;
 
 	case 'i':
 		if (TOLOWER_ASC(what[1]) == 'n')	/* inverse */
@@ -16588,12 +16644,15 @@ f_synIDattr(argvars, rettv)
 
 	case 'r':					/* reverse */
 		p = highlight_has_attr(id, HL_INVERSE, modec);
 		break;
 
-	case 's':					/* standout */
-		p = highlight_has_attr(id, HL_STANDOUT, modec);
+	case 's':
+		if (TOLOWER_ASC(what[1]) == 'p')	/* sp[#] */
+		    p = highlight_color(id, what, modec);
+		else					/* standout */
+		    p = highlight_has_attr(id, HL_STANDOUT, modec);
 		break;
 
 	case 'u':
 		if (STRLEN(what) <= 5 || TOLOWER_ASC(what[5]) != 'c')
 							/* underline */
@@ -16612,14 +16671,13 @@ f_synIDattr(argvars, rettv)
 }
 
 /*
  * "synIDtrans(id)" function
  */
-/*ARGSUSED*/
     static void
 f_synIDtrans(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     int		id;
 
 #ifdef FEAT_SYN_HL
@@ -16635,14 +16693,13 @@ f_synIDtrans(argvars, rettv)
 }
 
 /*
  * "synstack(lnum, col)" function
  */
-/*ARGSUSED*/
     static void
 f_synstack(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_SYN_HL
     long	lnum;
     long	col;
@@ -16656,11 +16713,11 @@ f_synstack(argvars, rettv)
 #ifdef FEAT_SYN_HL
     lnum = get_tv_lnum(argvars);		/* -1 on type error */
     col = get_tv_number(&argvars[1]) - 1;	/* -1 on type error */
 
     if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
-	    && col >= 0 && col < (long)STRLEN(ml_get(lnum))
+	    && col >= 0 && (col == 0 || col < (long)STRLEN(ml_get(lnum)))
 	    && rettv_list_alloc(rettv) != FAIL)
     {
 	(void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL, TRUE);
 	for (i = 0; ; ++i)
 	{
@@ -16772,19 +16829,16 @@ done:
 }
 
 /*
  * "tabpagebuflist()" function
  */
-/* ARGSUSED */
     static void
 f_tabpagebuflist(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
-#ifndef FEAT_WINDOWS
-    rettv->vval.v_number = 0;
-#else
+#ifdef FEAT_WINDOWS
     tabpage_T	*tp;
     win_T	*wp = NULL;
 
     if (argvars[0].v_type == VAR_UNKNOWN)
 	wp = firstwin;
@@ -16792,35 +16846,27 @@ f_tabpagebuflist(argvars, rettv)
     {
 	tp = find_tabpage((int)get_tv_number(&argvars[0]));
 	if (tp != NULL)
 	    wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
     }
-    if (wp == NULL)
-	rettv->vval.v_number = 0;
-    else
+    if (wp != NULL && rettv_list_alloc(rettv) != FAIL)
     {
-	if (rettv_list_alloc(rettv) == FAIL)
-	    rettv->vval.v_number = 0;
-	else
-	{
-	    for (; wp != NULL; wp = wp->w_next)
-		if (list_append_number(rettv->vval.v_list,
+	for (; wp != NULL; wp = wp->w_next)
+	    if (list_append_number(rettv->vval.v_list,
 						wp->w_buffer->b_fnum) == FAIL)
-		    break;
-	}
+		break;
     }
 #endif
 }
 
 
 /*
  * "tabpagenr()" function
  */
-/* ARGSUSED */
     static void
 f_tabpagenr(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     int		nr = 1;
 #ifdef FEAT_WINDOWS
     char_u	*arg;
@@ -16898,14 +16944,13 @@ get_winnr(tp, argvar)
 #endif
 
 /*
  * "tabpagewinnr()" function
  */
-/* ARGSUSED */
     static void
 f_tabpagewinnr(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     int		nr = 1;
 #ifdef FEAT_WINDOWS
     tabpage_T	*tp;
@@ -16921,25 +16966,21 @@ f_tabpagewinnr(argvars, rettv)
 
 
 /*
  * "tagfiles()" function
  */
-/*ARGSUSED*/
     static void
 f_tagfiles(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     char_u	fname[MAXPATHL + 1];
     tagname_T	tn;
     int		first;
 
     if (rettv_list_alloc(rettv) == FAIL)
-    {
-	rettv->vval.v_number = 0;
 	return;
-    }
 
     for (first = TRUE; ; first = FALSE)
 	if (get_tagfname(&tn, first, fname) == FAIL
 		|| list_append_string(rettv->vval.v_list, fname, -1) == FAIL)
 	    break;
@@ -16967,14 +17008,13 @@ f_taglist(argvars, rettv)
 }
 
 /*
  * "tempname()" function
  */
-/*ARGSUSED*/
     static void
 f_tempname(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     static int	x = 'A';
 
     rettv->v_type = VAR_STRING;
@@ -17003,15 +17043,14 @@ f_tempname(argvars, rettv)
 }
 
 /*
  * "test(list)" function: Just checking the walls...
  */
-/*ARGSUSED*/
     static void
 f_test(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
     /* Used for unit testing.  Change the code below to your liking. */
 #if 0
     listitem_T	*li;
     list_T	*l;
@@ -17292,15 +17331,14 @@ f_virtcol(argvars, rettv)
 }
 
 /*
  * "visualmode()" function
  */
-/*ARGSUSED*/
     static void
 f_visualmode(argvars, rettv)
-    typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*argvars UNUSED;
+    typval_T	*rettv UNUSED;
 {
 #ifdef FEAT_VISUAL
     char_u	str[2];
 
     rettv->v_type = VAR_STRING;
@@ -17309,12 +17347,10 @@ f_visualmode(argvars, rettv)
     rettv->vval.v_string = vim_strsave(str);
 
     /* A non-zero number or non-empty string argument: reset mode. */
     if (non_zero_arg(&argvars[0]))
 	curbuf->b_visual_mode_eval = NUL;
-#else
-    rettv->vval.v_number = 0; /* return anything, it won't work anyway */
 #endif
 }
 
 /*
  * "winbufnr(nr)" function
@@ -17334,14 +17370,13 @@ f_winbufnr(argvars, rettv)
 }
 
 /*
  * "wincol()" function
  */
-/*ARGSUSED*/
     static void
 f_wincol(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     validate_cursor();
     rettv->vval.v_number = curwin->w_wcol + 1;
 }
@@ -17364,27 +17399,25 @@ f_winheight(argvars, rettv)
 }
 
 /*
  * "winline()" function
  */
-/*ARGSUSED*/
     static void
 f_winline(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     validate_cursor();
     rettv->vval.v_number = curwin->w_wrow + 1;
 }
 
 /*
  * "winnr()" function
  */
-/* ARGSUSED */
     static void
 f_winnr(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     int		nr = 1;
 
 #ifdef FEAT_WINDOWS
@@ -17394,14 +17427,13 @@ f_winnr(argvars, rettv)
 }
 
 /*
  * "winrestcmd()" function
  */
-/* ARGSUSED */
     static void
 f_winrestcmd(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_WINDOWS
     win_T	*wp;
     int		winnr = 1;
@@ -17429,15 +17461,14 @@ f_winrestcmd(argvars, rettv)
 }
 
 /*
  * "winrestview()" function
  */
-/* ARGSUSED */
     static void
 f_winrestview(argvars, rettv)
     typval_T	*argvars;
-    typval_T	*rettv;
+    typval_T	*rettv UNUSED;
 {
     dict_T	*dict;
 
     if (argvars[0].v_type != VAR_DICT
 	    || (dict = argvars[0].vval.v_dict) == NULL)
@@ -17475,14 +17506,13 @@ f_winrestview(argvars, rettv)
 }
 
 /*
  * "winsaveview()" function
  */
-/* ARGSUSED */
     static void
 f_winsaveview(argvars, rettv)
-    typval_T	*argvars;
+    typval_T	*argvars UNUSED;
     typval_T	*rettv;
 {
     dict_T	*dict;
 
     dict = dict_alloc();
@@ -18095,18 +18125,57 @@ get_vim_var_str(idx)
 {
     return get_tv_string(&vimvars[idx].vv_tv);
 }
 
 /*
- * Set v:count, v:count1 and v:prevcount.
+ * Get List v: variable value.  Caller must take care of reference count when
+ * needed.
+ */
+    list_T *
+get_vim_var_list(idx)
+    int		idx;
+{
+    return vimvars[idx].vv_list;
+}
+
+/*
+ * Set v:char to character "c".
  */
     void
-set_vcount(count, count1)
+set_vim_var_char(c)
+    int c;
+{
+#ifdef FEAT_MBYTE
+    char_u	buf[MB_MAXBYTES];
+#else
+    char_u	buf[2];
+#endif
+
+#ifdef FEAT_MBYTE
+    if (has_mbyte)
+	buf[(*mb_char2bytes)(c, buf)] = NUL;
+    else
+#endif
+    {
+	buf[0] = c;
+	buf[1] = NUL;
+    }
+    set_vim_var_string(VV_CHAR, buf, -1);
+}
+
+/*
+ * Set v:count to "count" and v:count1 to "count1".
+ * When "set_prevcount" is TRUE first set v:prevcount from v:count.
+ */
+    void
+set_vcount(count, count1, set_prevcount)
     long	count;
     long	count1;
+    int		set_prevcount;
 {
-    vimvars[VV_PREVCOUNT].vv_nr = vimvars[VV_COUNT].vv_nr;
+    if (set_prevcount)
+	vimvars[VV_PREVCOUNT].vv_nr = vimvars[VV_COUNT].vv_nr;
     vimvars[VV_COUNT].vv_nr = count;
     vimvars[VV_COUNT1].vv_nr = count1;
 }
 
 /*
@@ -18130,10 +18199,24 @@ set_vim_var_string(idx, val, len)
     else
 	vimvars[idx].vv_str = vim_strnsave(val, len);
 }
 
 /*
+ * Set List v: variable to "val".
+ */
+    void
+set_vim_var_list(idx, val)
+    int		idx;
+    list_T	*val;
+{
+    list_unref(vimvars[idx].vv_list);
+    vimvars[idx].vv_list = val;
+    if (val != NULL)
+	++val->lv_refcount;
+}
+
+/*
  * Set v:register if needed.
  */
     void
 set_reg_var(c)
     int		c;
@@ -18866,11 +18949,12 @@ new_script_vars(id)
 init_var_dict(dict, dict_var)
     dict_T	*dict;
     dictitem_T	*dict_var;
 {
     hash_init(&dict->dv_hashtab);
-    dict->dv_refcount = 99999;
+    dict->dv_refcount = DO_NOT_FREE_CNT;
+    dict->dv_copyID = 0;
     dict_var->di_tv.vval.v_dict = dict;
     dict_var->di_tv.v_type = VAR_DICT;
     dict_var->di_tv.v_lock = VAR_FIXED;
     dict_var->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
     dict_var->di_key[0] = NUL;
@@ -18949,11 +19033,12 @@ list_one_var(v, prefix, first)
 {
     char_u	*tofree;
     char_u	*s;
     char_u	numbuf[NUMBUFLEN];
 
-    s = echo_string(&v->di_tv, &tofree, numbuf, ++current_copyID);
+    current_copyID += COPYID_INC;
+    s = echo_string(&v->di_tv, &tofree, numbuf, current_copyID);
     list_one_var_a(prefix, v->di_key, v->di_tv.v_type,
 					 s == NULL ? (char_u *)"" : s, first);
     vim_free(tofree);
 }
 
@@ -19016,35 +19101,38 @@ set_var(name, tv, copy)
     dictitem_T	*v;
     char_u	*varname;
     hashtab_T	*ht;
     char_u	*p;
 
+    ht = find_var_ht(name, &varname);
+    if (ht == NULL || *varname == NUL)
+    {
+	EMSG2(_(e_illvar), name);
+	return;
+    }
+    v = find_var_in_ht(ht, varname, TRUE);
+
     if (tv->v_type == VAR_FUNC)
     {
 	if (!(vim_strchr((char_u *)"wbs", name[0]) != NULL && name[1] == ':')
 		&& !ASCII_ISUPPER((name[0] != NUL && name[1] == ':')
 							 ? name[2] : name[0]))
 	{
 	    EMSG2(_("E704: Funcref variable name must start with a capital: %s"), name);
 	    return;
 	}
-	if (function_exists(name))
+	/* Don't allow hiding a function.  When "v" is not NULL we migth be
+	 * assigning another function to the same var, the type is checked
+	 * below. */
+	if (v == NULL && function_exists(name))
 	{
 	    EMSG2(_("E705: Variable name conflicts with existing function: %s"),
 									name);
 	    return;
 	}
     }
 
-    ht = find_var_ht(name, &varname);
-    if (ht == NULL || *varname == NUL)
-    {
-	EMSG2(_(e_illvar), name);
-	return;
-    }
-
-    v = find_var_in_ht(ht, varname, TRUE);
     if (v != NULL)
     {
 	/* existing variable, need to clear the value */
 	if (var_check_ro(v->di_flags, name)
 				      || tv_check_lock(v->di_tv.v_lock, name))
@@ -19203,12 +19291,14 @@ tv_check_lock(lock, name)
 
 /*
  * Copy the values from typval_T "from" to typval_T "to".
  * When needed allocates string or increases reference count.
  * Does not make a copy of a list or dict but copies the reference!
+ * It is OK for "from" and "to" to point to the same item.  This is used to
+ * make a copy later.
  */
-    static void
+    void
 copy_tv(from, to)
     typval_T *from;
     typval_T *to;
 {
     to->v_type = from->v_type;
@@ -19382,11 +19472,12 @@ ex_echo(eap)
 		if (eap->cmdidx == CMD_echo)
 		    msg_start();
 	    }
 	    else if (eap->cmdidx == CMD_echo)
 		msg_puts_attr((char_u *)" ", echo_attr);
-	    p = echo_string(&rettv, &tofree, numbuf, ++current_copyID);
+	    current_copyID += COPYID_INC;
+	    p = echo_string(&rettv, &tofree, numbuf, current_copyID);
 	    if (p != NULL)
 		for ( ; *p != NUL && !got_int; ++p)
 		{
 		    if (*p == '\n' || *p == '\r' || *p == TAB)
 		    {
@@ -19658,10 +19749,11 @@ ex_function(eap)
 			if (!isdigit(*fp->uf_name)
 				    && vim_regexec(&regmatch, fp->uf_name, 0))
 			    list_func_head(fp, FALSE);
 		    }
 		}
+		vim_free(regmatch.regprog);
 	    }
 	}
 	if (*p == '/')
 	    ++p;
 	eap->nextcmd = check_nextcmd(p);
@@ -19746,11 +19838,11 @@ ex_function(eap)
 		    msg_putchar('\n');
 		    msg_puts((char_u *)"   endfunction");
 		}
 	    }
 	    else
-		emsg_funcname("E123: Undefined function: %s", name);
+		emsg_funcname(N_("E123: Undefined function: %s"), name);
 	}
 	goto ret_free;
     }
 
     /*
@@ -19790,11 +19882,11 @@ ex_function(eap)
 		j = 0;
 	    while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j])
 						      : eval_isnamec(arg[j])))
 		++j;
 	    if (arg[j] != NUL)
-		emsg_funcname(_(e_invarg2), arg);
+		emsg_funcname((char *)e_invarg2, arg);
 	}
     }
 
     /*
      * Isolate the arguments: "arg1, arg2, ...)"
@@ -20062,11 +20154,11 @@ ex_function(eap)
     if (fudi.fd_dict == NULL)
     {
 	v = find_var(name, &ht);
 	if (v != NULL && v->di_tv.v_type == VAR_FUNC)
 	{
-	    emsg_funcname("E707: Function name conflicts with variable: %s",
+	    emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
 									name);
 	    goto erret;
 	}
 
 	fp = find_func(name);
@@ -20077,11 +20169,11 @@ ex_function(eap)
 		emsg_funcname(e_funcexts, name);
 		goto erret;
 	    }
 	    if (fp->uf_calls > 0)
 	    {
-		emsg_funcname("E127: Cannot redefine function %s: It is in use",
+		emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"),
 									name);
 		goto erret;
 	    }
 	    /* redefine existing function */
 	    ga_clear_strings(&(fp->uf_args));
@@ -20588,10 +20680,13 @@ func_dump_profile(fd)
     int		i;
     ufunc_T	**sorttab;
     int		st_len = 0;
 
     todo = (int)func_hashtab.ht_used;
+    if (todo == 0)
+	return;     /* nothing to dump */
+
     sorttab = (ufunc_T **)alloc((unsigned)(sizeof(ufunc_T) * todo));
 
     for (hi = func_hashtab.ht_array; todo > 0; ++hi)
     {
 	if (!HASHITEM_EMPTY(hi))
@@ -20636,10 +20731,12 @@ func_dump_profile(fd)
 	prof_sort_list(fd, sorttab, st_len, "TOTAL", FALSE);
 	qsort((void *)sorttab, (size_t)st_len, sizeof(ufunc_T *),
 							      prof_self_cmp);
 	prof_sort_list(fd, sorttab, st_len, "SELF", TRUE);
     }
+
+    vim_free(sorttab);
 }
 
     static void
 prof_sort_list(fd, sorttab, st_len, title, prefer_self)
     FILE	*fd;
@@ -21010,11 +21107,11 @@ call_user_func(fp, argcount, argvars, re
     dict_T	*selfdict;	/* Dictionary for "self" */
 {
     char_u	*save_sourcing_name;
     linenr_T	save_sourcing_lnum;
     scid_T	save_current_SID;
-    funccall_T	fc;
+    funccall_T	*fc;
     int		save_did_emsg;
     static int	depth = 0;
     dictitem_T	*v;
     int		fixvar_idx = 0;	/* index in fixvar[] */
     int		i;
@@ -21036,40 +21133,41 @@ call_user_func(fp, argcount, argvars, re
     }
     ++depth;
 
     line_breakcheck();		/* check for CTRL-C hit */
 
-    fc.caller = current_funccal;
-    current_funccal = &fc;
-    fc.func = fp;
-    fc.rettv = rettv;
+    fc = (funccall_T *)alloc(sizeof(funccall_T));
+    fc->caller = current_funccal;
+    current_funccal = fc;
+    fc->func = fp;
+    fc->rettv = rettv;
     rettv->vval.v_number = 0;
-    fc.linenr = 0;
-    fc.returned = FALSE;
-    fc.level = ex_nesting_level;
+    fc->linenr = 0;
+    fc->returned = FALSE;
+    fc->level = ex_nesting_level;
     /* Check if this function has a breakpoint. */
-    fc.breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name, (linenr_T)0);
-    fc.dbg_tick = debug_tick;
+    fc->breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name, (linenr_T)0);
+    fc->dbg_tick = debug_tick;
 
     /*
-     * Note about using fc.fixvar[]: This is an array of FIXVAR_CNT variables
+     * Note about using fc->fixvar[]: This is an array of FIXVAR_CNT variables
      * with names up to VAR_SHORT_LEN long.  This avoids having to alloc/free
      * each argument variable and saves a lot of time.
      */
     /*
      * Init l: variables.
      */
-    init_var_dict(&fc.l_vars, &fc.l_vars_var);
+    init_var_dict(&fc->l_vars, &fc->l_vars_var);
     if (selfdict != NULL)
     {
 	/* Set l:self to "selfdict".  Use "name" to avoid a warning from
 	 * some compiler that checks the destination size. */
-	v = &fc.fixvar[fixvar_idx++].var;
+	v = &fc->fixvar[fixvar_idx++].var;
 	name = v->di_key;
 	STRCPY(name, "self");
 	v->di_flags = DI_FLAGS_RO + DI_FLAGS_FIX;
-	hash_add(&fc.l_vars.dv_hashtab, DI2HIKEY(v));
+	hash_add(&fc->l_vars.dv_hashtab, DI2HIKEY(v));
 	v->di_tv.v_type = VAR_DICT;
 	v->di_tv.v_lock = 0;
 	v->di_tv.vval.v_dict = selfdict;
 	++selfdict->dv_refcount;
     }
@@ -21077,32 +21175,35 @@ call_user_func(fp, argcount, argvars, re
     /*
      * Init a: variables.
      * Set a:0 to "argcount".
      * Set a:000 to a list with room for the "..." arguments.
      */
-    init_var_dict(&fc.l_avars, &fc.l_avars_var);
-    add_nr_var(&fc.l_avars, &fc.fixvar[fixvar_idx++].var, "0",
+    init_var_dict(&fc->l_avars, &fc->l_avars_var);
+    add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "0",
 				(varnumber_T)(argcount - fp->uf_args.ga_len));
-    v = &fc.fixvar[fixvar_idx++].var;
-    STRCPY(v->di_key, "000");
+    /* Use "name" to avoid a warning from some compiler that checks the
+     * destination size. */
+    v = &fc->fixvar[fixvar_idx++].var;
+    name = v->di_key;
+    STRCPY(name, "000");
     v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
-    hash_add(&fc.l_avars.dv_hashtab, DI2HIKEY(v));
+    hash_add(&fc->l_avars.dv_hashtab, DI2HIKEY(v));
     v->di_tv.v_type = VAR_LIST;
     v->di_tv.v_lock = VAR_FIXED;
-    v->di_tv.vval.v_list = &fc.l_varlist;
-    vim_memset(&fc.l_varlist, 0, sizeof(list_T));
-    fc.l_varlist.lv_refcount = 99999;
-    fc.l_varlist.lv_lock = VAR_FIXED;
+    v->di_tv.vval.v_list = &fc->l_varlist;
+    vim_memset(&fc->l_varlist, 0, sizeof(list_T));
+    fc->l_varlist.lv_refcount = DO_NOT_FREE_CNT;
+    fc->l_varlist.lv_lock = VAR_FIXED;
 
     /*
      * Set a:firstline to "firstline" and a:lastline to "lastline".
      * Set a:name to named arguments.
      * Set a:N to the "..." arguments.
      */
-    add_nr_var(&fc.l_avars, &fc.fixvar[fixvar_idx++].var, "firstline",
+    add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "firstline",
 						      (varnumber_T)firstline);
-    add_nr_var(&fc.l_avars, &fc.fixvar[fixvar_idx++].var, "lastline",
+    add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "lastline",
 						       (varnumber_T)lastline);
     for (i = 0; i < argcount; ++i)
     {
 	ai = i - fp->uf_args.ga_len;
 	if (ai < 0)
@@ -21114,11 +21215,11 @@ call_user_func(fp, argcount, argvars, re
 	    sprintf((char *)numbuf, "%d", ai + 1);
 	    name = numbuf;
 	}
 	if (fixvar_idx < FIXVAR_CNT && STRLEN(name) <= VAR_SHORT_LEN)
 	{
-	    v = &fc.fixvar[fixvar_idx++].var;
+	    v = &fc->fixvar[fixvar_idx++].var;
 	    v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
 	}
 	else
 	{
 	    v = (dictitem_T *)alloc((unsigned)(sizeof(dictitem_T)
@@ -21126,22 +21227,22 @@ call_user_func(fp, argcount, argvars, re
 	    if (v == NULL)
 		break;
 	    v->di_flags = DI_FLAGS_RO;
 	}
 	STRCPY(v->di_key, name);
-	hash_add(&fc.l_avars.dv_hashtab, DI2HIKEY(v));
+	hash_add(&fc->l_avars.dv_hashtab, DI2HIKEY(v));
 
 	/* Note: the values are copied directly to avoid alloc/free.
 	 * "argvars" must have VAR_FIXED for v_lock. */
 	v->di_tv = argvars[i];
 	v->di_tv.v_lock = VAR_FIXED;
 
 	if (ai >= 0 && ai < MAX_FUNC_ARGS)
 	{
-	    list_append(&fc.l_varlist, &fc.l_listitems[ai]);
-	    fc.l_listitems[ai].li_tv = argvars[i];
-	    fc.l_listitems[ai].li_tv.v_lock = VAR_FIXED;
+	    list_append(&fc->l_varlist, &fc->l_listitems[ai]);
+	    fc->l_listitems[ai].li_tv = argvars[i];
+	    fc->l_listitems[ai].li_tv.v_lock = VAR_FIXED;
 	}
     }
 
     /* Don't redraw while executing the function. */
     ++RedrawingDisabled;
@@ -21202,11 +21303,11 @@ call_user_func(fp, argcount, argvars, re
     if (do_profiling == PROF_YES)
     {
 	if (!fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL))
 	    func_do_profile(fp);
 	if (fp->uf_profiling
-		       || (fc.caller != NULL && &fc.caller->func->uf_profiling))
+		    || (fc->caller != NULL && fc->caller->func->uf_profiling))
 	{
 	    ++fp->uf_tm_count;
 	    profile_start(&call_start);
 	    profile_zero(&fp->uf_tm_children);
 	}
@@ -21218,11 +21319,11 @@ call_user_func(fp, argcount, argvars, re
     current_SID = fp->uf_script_ID;
     save_did_emsg = did_emsg;
     did_emsg = FALSE;
 
     /* call do_cmdline() to execute the lines */
-    do_cmdline(NULL, get_func_line, (void *)&fc,
+    do_cmdline(NULL, get_func_line, (void *)fc,
 				     DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT);
 
     --RedrawingDisabled;
 
     /* when the function was aborted because of an error, return -1 */
@@ -21233,20 +21334,20 @@ call_user_func(fp, argcount, argvars, re
 	rettv->vval.v_number = -1;
     }
 
 #ifdef FEAT_PROFILE
     if (do_profiling == PROF_YES && (fp->uf_profiling
-		    || (fc.caller != NULL && &fc.caller->func->uf_profiling)))
+		    || (fc->caller != NULL && fc->caller->func->uf_profiling)))
     {
 	profile_end(&call_start);
 	profile_sub_wait(&wait_start, &call_start);
 	profile_add(&fp->uf_tm_total, &call_start);
 	profile_self(&fp->uf_tm_self, &call_start, &fp->uf_tm_children);
-	if (fc.caller != NULL && &fc.caller->func->uf_profiling)
+	if (fc->caller != NULL && fc->caller->func->uf_profiling)
 	{
-	    profile_add(&fc.caller->func->uf_tm_children, &call_start);
-	    profile_add(&fc.caller->func->uf_tml_children, &call_start);
+	    profile_add(&fc->caller->func->uf_tm_children, &call_start);
+	    profile_add(&fc->caller->func->uf_tml_children, &call_start);
 	}
     }
 #endif
 
     /* when being verbose, mention the return value */
@@ -21255,24 +21356,24 @@ call_user_func(fp, argcount, argvars, re
 	++no_wait_return;
 	verbose_enter_scroll();
 
 	if (aborting())
 	    smsg((char_u *)_("%s aborted"), sourcing_name);
-	else if (fc.rettv->v_type == VAR_NUMBER)
+	else if (fc->rettv->v_type == VAR_NUMBER)
 	    smsg((char_u *)_("%s returning #%ld"), sourcing_name,
-					       (long)fc.rettv->vval.v_number);
+					       (long)fc->rettv->vval.v_number);
 	else
 	{
 	    char_u	buf[MSG_BUF_LEN];
 	    char_u	numbuf2[NUMBUFLEN];
 	    char_u	*tofree;
 	    char_u	*s;
 
 	    /* The value may be very long.  Skip the middle part, so that we
 	     * have some idea how it starts and ends. smsg() would always
 	     * truncate it at the end. */
-	    s = tv2string(fc.rettv, &tofree, numbuf2, 0);
+	    s = tv2string(fc->rettv, &tofree, numbuf2, 0);
 	    if (s != NULL)
 	    {
 		trunc_string(s, buf, MSG_BUF_CLEN);
 		smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
 		vim_free(tofree);
@@ -21304,18 +21405,88 @@ call_user_func(fp, argcount, argvars, re
 	verbose_leave_scroll();
 	--no_wait_return;
     }
 
     did_emsg |= save_did_emsg;
-    current_funccal = fc.caller;
+    current_funccal = fc->caller;
+    --depth;
 
-    /* The a: variables typevals were not allocated, only free the allocated
-     * variables. */
-    vars_clear_ext(&fc.l_avars.dv_hashtab, FALSE);
+    /* If the a:000 list and the l: and a: dicts are not referenced we can
+     * free the funccall_T and what's in it. */
+    if (fc->l_varlist.lv_refcount == DO_NOT_FREE_CNT
+	    && fc->l_vars.dv_refcount == DO_NOT_FREE_CNT
+	    && fc->l_avars.dv_refcount == DO_NOT_FREE_CNT)
+    {
+	free_funccal(fc, FALSE);
+    }
+    else
+    {
+	hashitem_T	*hi;
+	listitem_T	*li;
+	int		todo;
 
-    vars_clear(&fc.l_vars.dv_hashtab);		/* free all l: variables */
-    --depth;
+	/* "fc" is still in use.  This can happen when returning "a:000" or
+	 * assigning "l:" to a global variable.
+	 * Link "fc" in the list for garbage collection later. */
+	fc->caller = previous_funccal;
+	previous_funccal = fc;
+
+	/* Make a copy of the a: variables, since we didn't do that above. */
+	todo = (int)fc->l_avars.dv_hashtab.ht_used;
+	for (hi = fc->l_avars.dv_hashtab.ht_array; todo > 0; ++hi)
+	{
+	    if (!HASHITEM_EMPTY(hi))
+	    {
+		--todo;
+		v = HI2DI(hi);
+		copy_tv(&v->di_tv, &v->di_tv);
+	    }
+	}
+
+	/* Make a copy of the a:000 items, since we didn't do that above. */
+	for (li = fc->l_varlist.lv_first; li != NULL; li = li->li_next)
+	    copy_tv(&li->li_tv, &li->li_tv);
+    }
+}
+
+/*
+ * Return TRUE if items in "fc" do not have "copyID".  That means they are not
+ * referenced from anywhere that is in use.
+ */
+    static int
+can_free_funccal(fc, copyID)
+    funccall_T	*fc;
+    int		copyID;
+{
+    return (fc->l_varlist.lv_copyID != copyID
+	    && fc->l_vars.dv_copyID != copyID
+	    && fc->l_avars.dv_copyID != copyID);
+}
+
+/*
+ * Free "fc" and what it contains.
+ */
+   static void
+free_funccal(fc, free_val)
+    funccall_T	*fc;
+    int		free_val;  /* a: vars were allocated */
+{
+    listitem_T	*li;
+
+    /* The a: variables typevals may not have been allocated, only free the
+     * allocated variables. */
+    vars_clear_ext(&fc->l_avars.dv_hashtab, free_val);
+
+    /* free all l: variables */
+    vars_clear(&fc->l_vars.dv_hashtab);
+
+    /* Free the a:000 variables if they were allocated. */
+    if (free_val)
+	for (li = fc->l_varlist.lv_first; li != NULL; li = li->li_next)
+	    clear_tv(&li->li_tv);
+
+    vim_free(fc);
 }
 
 /*
  * Add a number variable "name" to dict "dp" with value "nr".
  */
@@ -21510,16 +21681,15 @@ get_return_cmd(rettv)
 /*
  * Get next function line.
  * Called by do_cmdline() to get the next line.
  * Returns allocated string, or NULL for end of function.
  */
-/* ARGSUSED */
     char_u *
 get_func_line(c, cookie, indent)
-    int	    c;		    /* not used */
+    int	    c UNUSED;
     void    *cookie;
-    int	    indent;	    /* not used */
+    int	    indent UNUSED;
 {
     funccall_T	*fcp = (funccall_T *)cookie;
     ufunc_T	*fp = fcp->func;
     char_u	*retval;
     garray_T	*gap;  /* growarray with function lines */
@@ -21884,10 +22054,65 @@ last_set_msg(scriptID)
 	    verbose_leave();
 	}
     }
 }
 
+/*
+ * List v:oldfiles in a nice way.
+ */
+    void
+ex_oldfiles(eap)
+    exarg_T	*eap UNUSED;
+{
+    list_T	*l = vimvars[VV_OLDFILES].vv_list;
+    listitem_T	*li;
+    int		nr = 0;
+
+    if (l == NULL)
+	msg((char_u *)_("No old files"));
+    else
+    {
+	msg_start();
+	msg_scroll = TRUE;
+	for (li = l->lv_first; li != NULL && !got_int; li = li->li_next)
+	{
+	    msg_outnum((long)++nr);
+	    MSG_PUTS(": ");
+	    msg_outtrans(get_tv_string(&li->li_tv));
+	    msg_putchar('\n');
+	    out_flush();	    /* output one line at a time */
+	    ui_breakcheck();
+	}
+	/* Assume "got_int" was set to truncate the listing. */
+	got_int = FALSE;
+
+#ifdef FEAT_BROWSE_CMD
+	if (cmdmod.browse)
+	{
+	    quit_more = FALSE;
+	    nr = prompt_for_number(FALSE);
+	    msg_starthere();
+	    if (nr > 0)
+	    {
+		char_u *p = list_find_str(get_vim_var_list(VV_OLDFILES),
+								    (long)nr);
+
+		if (p != NULL)
+		{
+		    p = expand_env_save(p);
+		    eap->arg = p;
+		    eap->cmdidx = CMD_edit;
+		    cmdmod.browse = FALSE;
+		    do_exedit(eap, NULL);
+		    vim_free(p);
+		}
+	    }
+	}
+#endif
+    }
+}
+
 #endif /* FEAT_EVAL */
 
 
 #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO)
 
--- vim72.orig/src/ex_cmds.c
+++ vim72/src/ex_cmds.c
@@ -22,11 +22,11 @@
 static int linelen __ARGS((int *has_tab));
 #endif
 static void do_filter __ARGS((linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd, int do_in, int do_out));
 #ifdef FEAT_VIMINFO
 static char_u *viminfo_filename __ARGS((char_u	*));
-static void do_viminfo __ARGS((FILE *fp_in, FILE *fp_out, int want_info, int want_marks, int force_read));
+static void do_viminfo __ARGS((FILE *fp_in, FILE *fp_out, int flags));
 static int viminfo_encoding __ARGS((vir_T *virp));
 static int read_viminfo_up_to_marks __ARGS((vir_T *virp, int forceit, int writing));
 #endif
 
 static int check_overwrite __ARGS((exarg_T *eap, buf_T *buf, char_u *fname, char_u *ffname, int other));
@@ -41,16 +41,16 @@ static int
 	help_compare __ARGS((const void *s1, const void *s2));
 
 /*
  * ":ascii" and "ga".
  */
-/*ARGSUSED*/
     void
 do_ascii(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     int		c;
+    int		cval;
     char	buf1[20];
     char	buf2[20];
     char_u	buf3[7];
 #ifdef FEAT_MBYTE
     int		cc[MAX_MCO];
@@ -73,30 +73,35 @@ do_ascii(eap)
     if (!has_mbyte || (enc_dbcs != 0 && c < 0x100) || c < 0x80)
 #endif
     {
 	if (c == NL)	    /* NUL is stored as NL */
 	    c = NUL;
+	if (c == CAR && get_fileformat(curbuf) == EOL_MAC)
+	    cval = NL;	    /* NL is stored as CR */
+	else
+	    cval = c;
 	if (vim_isprintc_strict(c) && (c < ' '
 #ifndef EBCDIC
 		    || c > '~'
 #endif
 			       ))
 	{
 	    transchar_nonprint(buf3, c);
-	    sprintf(buf1, "  <%s>", (char *)buf3);
+	    vim_snprintf(buf1, sizeof(buf1), "  <%s>", (char *)buf3);
 	}
 	else
 	    buf1[0] = NUL;
 #ifndef EBCDIC
 	if (c >= 0x80)
-	    sprintf(buf2, "  <M-%s>", transchar(c & 0x7f));
+	    vim_snprintf(buf2, sizeof(buf2), "  <M-%s>",
+						 (char *)transchar(c & 0x7f));
 	else
 #endif
 	    buf2[0] = NUL;
 	vim_snprintf((char *)IObuff, IOSIZE,
 		_("<%s>%s%s  %d,  Hex %02x,  Octal %03o"),
-					   transchar(c), buf1, buf2, c, c, c);
+				  transchar(c), buf1, buf2, cval, cval, cval);
 #ifdef FEAT_MBYTE
 	if (enc_utf8)
 	    c = cc[ci++];
 	else
 	    c = 0;
@@ -351,11 +356,11 @@ ex_sort(eap)
     regmatch_T	regmatch;
     int		len;
     linenr_T	lnum;
     long	maxlen = 0;
     sorti_T	*nrs;
-    size_t	count = eap->line2 - eap->line1 + 1;
+    size_t	count = (size_t)(eap->line2 - eap->line1 + 1);
     size_t	i;
     char_u	*p;
     char_u	*s;
     char_u	*s2;
     char_u	c;			/* temporary character storage */
@@ -950,11 +955,11 @@ do_bang(addr_count, eap, forceit, do_in,
 		vim_free(newcmd);
 		return;
 	    }
 	    len += (int)STRLEN(prevcmd);
 	}
-	if ((t = alloc(len)) == NULL)
+	if ((t = alloc((unsigned)len)) == NULL)
 	{
 	    vim_free(newcmd);
 	    return;
 	}
 	*t = NUL;
@@ -1541,11 +1546,11 @@ make_filter_cmd(cmd, itmp, otmp)
     /*
      * Put braces around the command (for concatenated commands) when
      * redirecting input and/or output.
      */
     if (itmp != NULL || otmp != NULL)
-	sprintf((char *)buf, "(%s)", (char *)cmd);
+	vim_snprintf((char *)buf, len, "(%s)", (char *)cmd);
     else
 	STRCPY(buf, cmd);
     if (itmp != NULL)
     {
 	STRCAT(buf, " < ");
@@ -1590,41 +1595,45 @@ make_filter_cmd(cmd, itmp, otmp)
 	    }
 	}
     }
 #endif
     if (otmp != NULL)
-	append_redir(buf, p_srr, otmp);
+	append_redir(buf, (int)len, p_srr, otmp);
 
     return buf;
 }
 
 /*
- * Append output redirection for file "fname" to the end of string buffer "buf"
+ * Append output redirection for file "fname" to the end of string buffer
+ * "buf[buflen]"
  * Works with the 'shellredir' and 'shellpipe' options.
  * The caller should make sure that there is enough room:
  *	STRLEN(opt) + STRLEN(fname) + 3
  */
     void
-append_redir(buf, opt, fname)
+append_redir(buf, buflen, opt, fname)
     char_u	*buf;
+    int		buflen;
     char_u	*opt;
     char_u	*fname;
 {
     char_u	*p;
+    char_u	*end;
 
-    buf += STRLEN(buf);
+    end = buf + STRLEN(buf);
     /* find "%s", skipping "%%" */
     for (p = opt; (p = vim_strchr(p, '%')) != NULL; ++p)
 	if (p[1] == 's')
 	    break;
     if (p != NULL)
     {
-	*buf = ' '; /* not really needed? Not with sh, ksh or bash */
-	sprintf((char *)buf + 1, (char *)opt, (char *)fname);
+	*end = ' '; /* not really needed? Not with sh, ksh or bash */
+	vim_snprintf((char *)end + 1, (size_t)(buflen - (end + 1 - buf)),
+						  (char *)opt, (char *)fname);
     }
     else
-	sprintf((char *)buf,
+	vim_snprintf((char *)end, (size_t)(buflen - (end - buf)),
 #ifdef FEAT_QUICKFIX
 # ifndef RISCOS
 		opt != p_sp ? " %s%s" :
 # endif
 		" %s %s",
@@ -1674,50 +1683,48 @@ viminfo_error(errnum, message, line)
     return FALSE;
 }
 
 /*
  * read_viminfo() -- Read the viminfo file.  Registers etc. which are already
- * set are not over-written unless force is TRUE. -- webb
+ * set are not over-written unless "flags" includes VIF_FORCEIT. -- webb
  */
     int
-read_viminfo(file, want_info, want_marks, forceit)
-    char_u	*file;
-    int		want_info;
-    int		want_marks;
-    int		forceit;
+read_viminfo(file, flags)
+    char_u	*file;	    /* file name or NULL to use default name */
+    int		flags;	    /* VIF_WANT_INFO et al. */
 {
     FILE	*fp;
     char_u	*fname;
 
     if (no_viminfo())
 	return FAIL;
 
-    fname = viminfo_filename(file);	    /* may set to default if NULL */
+    fname = viminfo_filename(file);	/* get file name in allocated buffer */
     if (fname == NULL)
 	return FAIL;
     fp = mch_fopen((char *)fname, READBIN);
 
     if (p_verbose > 0)
     {
 	verbose_enter();
 	smsg((char_u *)_("Reading viminfo file \"%s\"%s%s%s"),
 		fname,
-		want_info ? _(" info") : "",
-		want_marks ? _(" marks") : "",
+		(flags & VIF_WANT_INFO) ? _(" info") : "",
+		(flags & VIF_WANT_MARKS) ? _(" marks") : "",
+		(flags & VIF_GET_OLDFILES) ? _(" oldfiles") : "",
 		fp == NULL ? _(" FAILED") : "");
 	verbose_leave();
     }
 
     vim_free(fname);
     if (fp == NULL)
 	return FAIL;
 
     viminfo_errcnt = 0;
-    do_viminfo(fp, NULL, want_info, want_marks, forceit);
+    do_viminfo(fp, NULL, flags);
 
     fclose(fp);
-
     return OK;
 }
 
 /*
  * write_viminfo() -- Write the viminfo file.  The old one is read in first so
@@ -1784,11 +1791,11 @@ write_viminfo(file, forceit)
 	/*
 	 * For Unix we check the owner of the file.  It's not very nice to
 	 * overwrite a user's viminfo file after a "su root", with a
 	 * viminfo file that the user can't read.
 	 */
-	st_old.st_dev = 0;
+	st_old.st_dev = (dev_t)0;
 	st_old.st_ino = 0;
 	st_old.st_mode = 0600;
 	if (mch_stat((char *)fname, &st_old) == 0
 		&& getuid() != ROOT_UID
 		&& !(st_old.st_uid == getuid()
@@ -1941,11 +1948,11 @@ write_viminfo(file, forceit)
 	    /*
 	     * Make sure the owner can read/write it.  This only works for
 	     * root.
 	     */
 	    if (fp_out != NULL)
-		(void)fchown(fileno(fp_out), st_old.st_uid, st_old.st_gid);
+		ignored = fchown(fileno(fp_out), st_old.st_uid, st_old.st_gid);
 #endif
 	}
     }
 
     /*
@@ -1966,11 +1973,11 @@ write_viminfo(file, forceit)
 	smsg((char_u *)_("Writing viminfo file \"%s\""), fname);
 	verbose_leave();
     }
 
     viminfo_errcnt = 0;
-    do_viminfo(fp_in, fp_out, !forceit, !forceit, FALSE);
+    do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS));
 
     fclose(fp_out);	    /* errors are ignored !? */
     if (fp_in != NULL)
     {
 	fclose(fp_in);
@@ -2039,16 +2046,14 @@ viminfo_filename(file)
 
 /*
  * do_viminfo() -- Should only be called from read_viminfo() & write_viminfo().
  */
     static void
-do_viminfo(fp_in, fp_out, want_info, want_marks, force_read)
+do_viminfo(fp_in, fp_out, flags)
     FILE	*fp_in;
     FILE	*fp_out;
-    int		want_info;
-    int		want_marks;
-    int		force_read;
+    int		flags;
 {
     int		count = 0;
     int		eof = FALSE;
     vir_T	vir;
 
@@ -2059,12 +2064,13 @@ do_viminfo(fp_in, fp_out, want_info, wan
     vir.vir_conv.vc_type = CONV_NONE;
 #endif
 
     if (fp_in != NULL)
     {
-	if (want_info)
-	    eof = read_viminfo_up_to_marks(&vir, force_read, fp_out != NULL);
+	if (flags & VIF_WANT_INFO)
+	    eof = read_viminfo_up_to_marks(&vir,
+					 flags & VIF_FORCEIT, fp_out != NULL);
 	else
 	    /* Skip info, find start of marks */
 	    while (!(eof = viminfo_readline(&vir))
 		    && vir.vir_line[0] != '>')
 		;
@@ -2090,12 +2096,13 @@ do_viminfo(fp_in, fp_out, want_info, wan
 #endif
 	write_viminfo_filemarks(fp_out);
 	write_viminfo_bufferlist(fp_out);
 	count = write_viminfo_marks(fp_out);
     }
-    if (fp_in != NULL && want_marks)
-	copy_viminfo_marks(&vir, fp_out, count, eof);
+    if (fp_in != NULL
+	    && (flags & (VIF_WANT_MARKS | VIF_GET_OLDFILES | VIF_FORCEIT)))
+	copy_viminfo_marks(&vir, fp_out, count, eof, flags);
 
     vim_free(vir.vir_line);
 #ifdef FEAT_MBYTE
     if (vir.vir_conv.vc_type != CONV_NONE)
 	convert_setup(&vir.vir_conv, NULL, NULL);
@@ -2246,16 +2253,15 @@ viminfo_readline(virp)
  *
  * Check for a long line as written by viminfo_writestring().
  *
  * Return the string in allocated memory (NULL when out of memory).
  */
-/*ARGSUSED*/
     char_u *
 viminfo_readstring(virp, off, convert)
     vir_T	*virp;
     int		off;		    /* offset for virp->vir_line */
-    int		convert;	    /* convert the string */
+    int		convert UNUSED;	    /* convert the string */
 {
     char_u	*retval;
     char_u	*s, *d;
     long	len;
 
@@ -2363,14 +2369,13 @@ viminfo_writestring(fd, p)
  * Implementation of ":fixdel", also used by get_stty().
  *  <BS>    resulting <Del>
  *   ^?		^H
  * not ^?	^?
  */
-/*ARGSUSED*/
     void
 do_fixdel(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     char_u  *p;
 
     p = find_termcode((char_u *)"kb");
     add_termcode((char_u *)"kD", p != NULL
@@ -2385,11 +2390,12 @@ print_line_no_prefix(lnum, use_number, l
 {
     char_u	numbuf[30];
 
     if (curwin->w_p_nu || use_number)
     {
-	sprintf((char *)numbuf, "%*ld ", number_width(curwin), (long)lnum);
+	vim_snprintf((char *)numbuf, sizeof(numbuf),
+				   "%*ld ", number_width(curwin), (long)lnum);
 	msg_puts_attr(numbuf, hl_attr(HLF_N));	/* Highlight line nrs */
     }
     msg_prt_line(ml_get(lnum), list);
 }
 
@@ -2412,12 +2418,12 @@ print_line(lnum, use_number, list)
     {
 	msg_putchar('\n');
 	cursor_on();		/* msg_start() switches it off */
 	out_flush();
 	silent_mode = save_silent;
-	info_message = FALSE;
     }
+    info_message = FALSE;
 }
 
 /*
  * ":file[!] [fname]".
  */
@@ -2702,11 +2708,16 @@ do_write(eap)
 
 	/* After ":saveas fname" reset 'readonly'. */
 	if (eap->cmdidx == CMD_saveas)
 	{
 	    if (retval == OK)
+	    {
 		curbuf->b_p_ro = FALSE;
+#ifdef FEAT_WINDOWS
+		redraw_tabline = TRUE;
+#endif
+	    }
 	    /* Change directories when the 'acd' option is set. */
 	    DO_AUTOCHDIR
 	}
     }
 
@@ -2722,11 +2733,10 @@ theend:
  * Check if it is allowed to overwrite a file.  If b_flags has BF_NOTEDITED,
  * BF_NEW or BF_READERR, check for overwriting current file.
  * May set eap->forceit if a dialog says it's OK to overwrite.
  * Return OK if it's OK, FAIL if it is not.
  */
-/*ARGSUSED*/
     static int
 check_overwrite(eap, buf, fname, ffname, other)
     exarg_T	*eap;
     buf_T	*buf;
     char_u	*fname;	    /* file name to be used (can differ from
@@ -3052,11 +3062,12 @@ getfile(fnum, ffname, sfname, setpm, lnu
 	check_cursor_lnum();
 	beginline(BL_SOL | BL_FIX);
 	retval = 0;	/* it's in the same file */
     }
     else if (do_ecmd(fnum, ffname, sfname, NULL, lnum,
-		(P_HID(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0)) == OK)
+		(P_HID(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0),
+		curwin) == OK)
 	retval = -1;	/* opened another file */
     else
 	retval = 1;	/* error encountered */
 
 theend:
@@ -3085,21 +3096,25 @@ theend:
  *	   ECMD_HIDE: if TRUE don't free the current buffer
  *     ECMD_SET_HELP: set b_help flag of (new) buffer before opening file
  *	 ECMD_OLDBUF: use existing buffer if it exists
  *	ECMD_FORCEIT: ! used for Ex command
  *	 ECMD_ADDBUF: don't edit, just add to buffer list
+ *   oldwin: Should be "curwin" when editing a new buffer in the current
+ *           window, NULL when splitting the window first.  When not NULL info
+ *           of the previous buffer for "oldwin" is stored.
  *
  * return FAIL for failure, OK otherwise
  */
     int
-do_ecmd(fnum, ffname, sfname, eap, newlnum, flags)
+do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
     int		fnum;
     char_u	*ffname;
     char_u	*sfname;
     exarg_T	*eap;			/* can be NULL! */
     linenr_T	newlnum;
     int		flags;
+    win_T	*oldwin;
 {
     int		other_file;		/* TRUE if editing another file */
     int		oldbuf;			/* TRUE if using existing buffer */
 #ifdef FEAT_AUTOCMD
     int		auto_buf = FALSE;	/* TRUE if autocommands brought us
@@ -3267,11 +3282,12 @@ do_ecmd(fnum, ffname, sfname, eap, newln
 	if (!(flags & ECMD_ADDBUF))
 #endif
 	{
 	    if (!cmdmod.keepalt)
 		curwin->w_alt_fnum = curbuf->b_fnum;
-	    buflist_altfpos();
+	    if (oldwin != NULL)
+		buflist_altfpos(oldwin);
 	}
 
 	if (fnum)
 	    buf = buflist_findnr(fnum);
 	else
@@ -3371,11 +3387,11 @@ do_ecmd(fnum, ffname, sfname, eap, newln
 #endif
 		    buf_copy_options(buf, BCO_ENTER);
 
 		/* close the link to the current buffer */
 		u_sync(FALSE);
-		close_buffer(curwin, curbuf,
+		close_buffer(oldwin, curbuf,
 				      (flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD);
 
 #ifdef FEAT_AUTOCMD
 # ifdef FEAT_EVAL
 		if (aborting())	    /* autocmds may abort script processing */
@@ -3699,11 +3715,11 @@ do_ecmd(fnum, ffname, sfname, eap, newln
 
 #ifdef FEAT_SPELL
     /* If the window options were changed may need to set the spell language.
      * Can only do this after the buffer has been properly setup. */
     if (did_get_winopts && curwin->w_p_spell && *curbuf->b_p_spl != NUL)
-	did_set_spelllang(curbuf);
+	(void)did_set_spelllang(curbuf);
 #endif
 
     if (command == NULL)
     {
 	if (newcol >= 0)	/* position set by autocommands */
@@ -3772,11 +3788,11 @@ do_ecmd(fnum, ffname, sfname, eap, newln
     if (command != NULL)
 	do_cmdline(command, NULL, NULL, DOCMD_VERBOSE);
 
 #ifdef FEAT_KEYMAP
     if (curbuf->b_kmap_state & KEYMAP_INIT)
-	keymap_init();
+	(void)keymap_init();
 #endif
 
     --RedrawingDisabled;
     if (!skip_redraw)
     {
@@ -3995,10 +4011,13 @@ ex_change(eap)
     {
 	if (curbuf->b_ml.ml_flags & ML_EMPTY)	    /* nothing to delete */
 	    break;
 	ml_delete(eap->line1, FALSE);
     }
+
+    /* make sure the cursor is not beyond the end of the file now */
+    check_cursor_lnum();
     deleted_lines_mark(eap->line1, (long)(eap->line2 - lnum));
 
     /* ":append" on the line above the deleted lines. */
     eap->line2 = eap->line1;
     ex_append(eap);
@@ -4020,12 +4039,14 @@ ex_z(eap)
      * 'scroll' */
     if (eap->forceit)
 	bigness = curwin->w_height;
     else if (firstwin == lastwin)
 	bigness = curwin->w_p_scr * 2;
+#ifdef FEAT_WINDOWS
     else
 	bigness = curwin->w_height - 3;
+#endif
     if (bigness < 1)
 	bigness = 1;
 
     x = eap->arg;
     kind = x;
@@ -4215,17 +4236,19 @@ do_sub(eap)
     linenr_T	line2;
     long	nmatch;			/* number of lines in match */
     char_u	*sub_firstline;		/* allocated copy of first sub line */
     int		endcolumn = FALSE;	/* cursor in last column when done */
     pos_T	old_cursor = curwin->w_cursor;
+    int		start_nsubs;
 
     cmd = eap->arg;
     if (!global_busy)
     {
 	sub_nsubs = 0;
 	sub_nlines = 0;
     }
+    start_nsubs = sub_nsubs;
 
     if (eap->cmdidx == CMD_tilde)
 	which_pat = RE_LAST;	/* use last used regexp */
     else
 	which_pat = RE_SUBST;	/* use last substitute regexp */
@@ -4470,11 +4493,11 @@ do_sub(eap)
 	    char_u	*new_end, *new_start = NULL;
 	    unsigned	new_start_len = 0;
 	    char_u	*p1;
 	    int		did_sub = FALSE;
 	    int		lastone;
-	    unsigned	len, needed_len;
+	    int		len, copy_len, needed_len;
 	    long	nmatch_tl = 0;	/* nr of lines matched below lnum */
 	    int		do_again;	/* do it again after joining lines */
 	    int		skip_match = FALSE;
 	    linenr_T	sub_firstlnum;	/* nr of first sub line */
 
@@ -4615,10 +4638,12 @@ do_sub(eap)
 		    goto skip;
 		}
 
 		if (do_ask)
 		{
+		    int typed = 0;
+
 		    /* change State to CONFIRM, so that the mouse works
 		     * properly */
 		    save_State = State;
 		    State = CONFIRM;
 #ifdef FEAT_MOUSE
@@ -4653,11 +4678,11 @@ do_sub(eap)
 				msg_putchar('^');
 
 			    resp = getexmodeline('?', NULL, 0);
 			    if (resp != NULL)
 			    {
-				i = *resp;
+				typed = *resp;
 				vim_free(resp);
 			    }
 			}
 			else
 			{
@@ -4705,61 +4730,61 @@ do_sub(eap)
 #ifdef USE_ON_FLY_SCROLL
 			    dont_scroll = FALSE; /* allow scrolling here */
 #endif
 			    ++no_mapping;	/* don't map this key */
 			    ++allow_keys;	/* allow special keys */
-			    i = plain_vgetc();
+			    typed = plain_vgetc();
 			    --allow_keys;
 			    --no_mapping;
 
 			    /* clear the question */
 			    msg_didout = FALSE;	/* don't scroll up */
 			    msg_col = 0;
 			    gotocmdline(TRUE);
 			}
 
 			need_wait_return = FALSE; /* no hit-return prompt */
-			if (i == 'q' || i == ESC || i == Ctrl_C
+			if (typed == 'q' || typed == ESC || typed == Ctrl_C
 #ifdef UNIX
-				|| i == intr_char
+				|| typed == intr_char
 #endif
 				)
 			{
 			    got_quit = TRUE;
 			    break;
 			}
-			if (i == 'n')
+			if (typed == 'n')
 			    break;
-			if (i == 'y')
+			if (typed == 'y')
 			    break;
-			if (i == 'l')
+			if (typed == 'l')
 			{
 			    /* last: replace and then stop */
 			    do_all = FALSE;
 			    line2 = lnum;
 			    break;
 			}
-			if (i == 'a')
+			if (typed == 'a')
 			{
 			    do_ask = FALSE;
 			    break;
 			}
 #ifdef FEAT_INS_EXPAND
-			if (i == Ctrl_E)
+			if (typed == Ctrl_E)
 			    scrollup_clamp();
-			else if (i == Ctrl_Y)
+			else if (typed == Ctrl_Y)
 			    scrolldown_clamp();
 #endif
 		    }
 		    State = save_State;
 #ifdef FEAT_MOUSE
 		    setmouse();
 #endif
 		    if (vim_strchr(p_cpo, CPO_UNDO) != NULL)
 			--no_u_sync;
 
-		    if (i == 'n')
+		    if (typed == 'n')
 		    {
 			/* For a multi-line match, put matchcol at the NUL at
 			 * the end of the line and set nmatch to one, so that
 			 * we continue looking for a match on the next line.
 			 * Avoids that ":%s/\nB\@=//gc" and ":%s/\n/,\r/gc"
@@ -4806,13 +4831,13 @@ do_sub(eap)
 		else
 		{
 		    p1 = ml_get(sub_firstlnum + nmatch - 1);
 		    nmatch_tl += nmatch - 1;
 		}
-		i = regmatch.startpos[0].col - copycol;
-		needed_len = i + ((unsigned)STRLEN(p1) - regmatch.endpos[0].col)
-								 + sublen + 1;
+		copy_len = regmatch.startpos[0].col - copycol;
+		needed_len = copy_len + ((unsigned)STRLEN(p1)
+				       - regmatch.endpos[0].col) + sublen + 1;
 		if (new_start == NULL)
 		{
 		    /*
 		     * Get some space for a temporary buffer to do the
 		     * substitution into (and some extra space to avoid
@@ -4831,11 +4856,11 @@ do_sub(eap)
 		     * substitution into.  If not, make it larger (with a bit
 		     * extra to avoid too many calls to alloc()/free()).
 		     */
 		    len = (unsigned)STRLEN(new_start);
 		    needed_len += len;
-		    if (needed_len > new_start_len)
+		    if (needed_len > (int)new_start_len)
 		    {
 			new_start_len = needed_len + 50;
 			if ((p1 = alloc_check(new_start_len)) == NULL)
 			{
 			    vim_free(new_start);
@@ -4849,12 +4874,12 @@ do_sub(eap)
 		}
 
 		/*
 		 * copy the text up to the part that matched
 		 */
-		mch_memmove(new_end, sub_firstline + copycol, (size_t)i);
-		new_end += i;
+		mch_memmove(new_end, sub_firstline + copycol, (size_t)copy_len);
+		new_end += copy_len;
 
 		(void)vim_regsub_multi(&regmatch,
 				    sub_firstlnum - regmatch.startpos[0].lnum,
 					   sub, new_end, TRUE, p_magic, TRUE);
 		sub_nsubs++;
@@ -5057,10 +5082,11 @@ skip:
 		line_breakcheck();
 	    }
 
 	    if (did_sub)
 		++sub_nlines;
+	    vim_free(new_start);	/* for when substitute was cancelled */
 	    vim_free(sub_firstline);	/* free the copy of the original line */
 	    sub_firstline = NULL;
 	}
 
 	line_breakcheck();
@@ -5080,11 +5106,11 @@ outofmem:
 
     /* ":s/pat//n" doesn't move the cursor */
     if (do_count)
 	curwin->w_cursor = old_cursor;
 
-    if (sub_nsubs)
+    if (sub_nsubs > start_nsubs)
     {
 	/* Set the '[ and '] marks. */
 	curbuf->b_op_start.lnum = eap->line1;
 	curbuf->b_op_end.lnum = line2;
 	curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
@@ -5210,12 +5236,10 @@ ex_global(eap)
 	type = 'v';
     else
 	type = *eap->cmd;
     cmd = eap->arg;
     which_pat = RE_LAST;	    /* default: use last used regexp */
-    sub_nsubs = 0;
-    sub_nlines = 0;
 
     /*
      * undocumented vi feature:
      *	"\/" and "\?": use previous search pattern.
      *		 "\&": use previous substitute pattern.
@@ -5315,10 +5339,12 @@ global_exe(cmd)
     setpcmark();
 
     /* When the command writes a message, don't overwrite the command. */
     msg_didout = TRUE;
 
+    sub_nsubs = 0;
+    sub_nlines = 0;
     global_need_beginline = FALSE;
     global_busy = 1;
     old_lcount = curbuf->b_ml.ml_line_count;
     while (!got_int && (lnum = ml_firstmarked()) != 0 && global_busy == 1)
     {
@@ -5608,11 +5634,17 @@ ex_help(eap)
 	     * set b_p_ro flag).
 	     * Set the alternate file to the previously edited file.
 	     */
 	    alt_fnum = curbuf->b_fnum;
 	    (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL,
-						   ECMD_HIDE + ECMD_SET_HELP);
+			  ECMD_HIDE + ECMD_SET_HELP,
+#ifdef FEAT_WINDOWS
+			  NULL  /* buffer is still open, don't store info */
+#else
+			  curwin
+#endif
+		    );
 	    if (!cmdmod.keepalt)
 		curwin->w_alt_fnum = alt_fnum;
 	    empty_fnum = curbuf->b_fnum;
 	}
     }
@@ -5767,11 +5799,11 @@ find_help_tags(arg, num_matches, matches
 
     /*
      * Recognize a few exceptions to the rule.	Some strings that contain '*'
      * with "star".  Otherwise '*' is recognized as a wildcard.
      */
-    for (i = sizeof(mtable) / sizeof(char *); --i >= 0; )
+    for (i = (int)(sizeof(mtable) / sizeof(char *)); --i >= 0; )
 	if (STRCMP(arg, mtable[i]) == 0)
 	{
 	    STRCPY(d, rtable[i]);
 	    break;
 	}
@@ -6091,25 +6123,23 @@ fix_help_buffer()
 }
 
 /*
  * ":exusage"
  */
-/*ARGSUSED*/
     void
 ex_exusage(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     do_cmdline_cmd((char_u *)"help ex-cmd-index");
 }
 
 /*
  * ":viusage"
  */
-/*ARGSUSED*/
     void
 ex_viusage(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     do_cmdline_cmd((char_u *)"help normal-index");
 }
 
 #if defined(FEAT_EX_EXTRA) || defined(PROTO)
@@ -6517,26 +6547,15 @@ struct sign
 };
 
 static sign_T	*first_sign = NULL;
 static int	last_sign_typenr = MAX_TYPENR;	/* is decremented */
 
+static int sign_cmd_idx __ARGS((char_u *begin_cmd, char_u *end_cmd));
 static void sign_list_defined __ARGS((sign_T *sp));
+static void sign_undefine __ARGS((sign_T *sp, sign_T *sp_prev));
 
-/*
- * ":sign" command
- */
-    void
-ex_sign(eap)
-    exarg_T	*eap;
-{
-    char_u	*arg = eap->arg;
-    char_u	*p;
-    int		idx;
-    sign_T	*sp;
-    sign_T	*sp_prev;
-    buf_T	*buf;
-    static char	*cmds[] = {
+static char *cmds[] = {
 			"define",
 #define SIGNCMD_DEFINE	0
 			"undefine",
 #define SIGNCMD_UNDEFINE 1
 			"list",
@@ -6545,26 +6564,55 @@ ex_sign(eap)
 #define SIGNCMD_PLACE	3
 			"unplace",
 #define SIGNCMD_UNPLACE	4
 			"jump",
 #define SIGNCMD_JUMP	5
+			NULL
 #define SIGNCMD_LAST	6
-    };
+};
+
+/*
+ * Find index of a ":sign" subcmd from its name.
+ * "*end_cmd" must be writable.
+ */
+    static int
+sign_cmd_idx(begin_cmd, end_cmd)
+    char_u	*begin_cmd;	/* begin of sign subcmd */
+    char_u	*end_cmd;	/* just after sign subcmd */
+{
+    int		idx;
+    char	save = *end_cmd;
+
+    *end_cmd = NUL;
+    for (idx = 0; ; ++idx)
+	if (cmds[idx] == NULL || STRCMP(begin_cmd, cmds[idx]) == 0)
+	    break;
+    *end_cmd = save;
+    return idx;
+}
+
+/*
+ * ":sign" command
+ */
+    void
+ex_sign(eap)
+    exarg_T	*eap;
+{
+    char_u	*arg = eap->arg;
+    char_u	*p;
+    int		idx;
+    sign_T	*sp;
+    sign_T	*sp_prev;
+    buf_T	*buf;
 
     /* Parse the subcommand. */
     p = skiptowhite(arg);
-    if (*p != NUL)
-	*p++ = NUL;
-    for (idx = 0; ; ++idx)
+    idx = sign_cmd_idx(arg, p);
+    if (idx == SIGNCMD_LAST)
     {
-	if (idx == SIGNCMD_LAST)
-	{
-	    EMSG2(_("E160: Unknown sign command: %s"), arg);
-	    return;
-	}
-	if (STRCMP(arg, cmds[idx]) == 0)
-	    break;
+	EMSG2(_("E160: Unknown sign command: %s"), arg);
+	return;
     }
     arg = skipwhite(p);
 
     if (idx <= SIGNCMD_LIST)
     {
@@ -6726,28 +6774,12 @@ ex_sign(eap)
 		EMSG2(_("E155: Unknown sign: %s"), arg);
 	    else if (idx == SIGNCMD_LIST)
 		/* ":sign list {name}" */
 		sign_list_defined(sp);
 	    else
-	    {
 		/* ":sign undefine {name}" */
-		vim_free(sp->sn_name);
-		vim_free(sp->sn_icon);
-#ifdef FEAT_SIGN_ICONS
-		if (sp->sn_image != NULL)
-		{
-		    out_flush();
-		    gui_mch_destroy_sign(sp->sn_image);
-		}
-#endif
-		vim_free(sp->sn_text);
-		if (sp_prev == NULL)
-		    first_sign = sp->sn_next;
-		else
-		    sp_prev->sn_next = sp->sn_next;
-		vim_free(sp);
-	    }
+		sign_undefine(sp, sp_prev);
 	}
     }
     else
     {
 	int		id = -1;
@@ -6992,10 +7024,35 @@ sign_list_defined(sp)
 	    msg_puts(p);
     }
 }
 
 /*
+ * Undefine a sign and free its memory.
+ */
+    static void
+sign_undefine(sp, sp_prev)
+    sign_T	*sp;
+    sign_T	*sp_prev;
+{
+    vim_free(sp->sn_name);
+    vim_free(sp->sn_icon);
+#ifdef FEAT_SIGN_ICONS
+    if (sp->sn_image != NULL)
+    {
+	out_flush();
+	gui_mch_destroy_sign(sp->sn_image);
+    }
+#endif
+    vim_free(sp->sn_text);
+    if (sp_prev == NULL)
+	first_sign = sp->sn_next;
+    else
+	sp_prev->sn_next = sp->sn_next;
+    vim_free(sp);
+}
+
+/*
  * Get highlighting attribute for sign "typenr".
  * If "line" is TRUE: line highl, if FALSE: text highl.
  */
     int
 sign_get_attr(typenr, line)
@@ -7065,10 +7122,201 @@ sign_typenr2name(typenr)
 	if (sp->sn_typenr == typenr)
 	    return sp->sn_name;
     return (char_u *)_("[Deleted]");
 }
 
+#if defined(EXITFREE) || defined(PROTO)
+/*
+ * Undefine/free all signs.
+ */
+    void
+free_signs()
+{
+    while (first_sign != NULL)
+	sign_undefine(first_sign, NULL);
+}
+#endif
+
+#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
+static enum
+{
+    EXP_SUBCMD,		/* expand :sign sub-commands */
+    EXP_DEFINE,		/* expand :sign define {name} args */
+    EXP_PLACE,		/* expand :sign place {id} args */
+    EXP_UNPLACE,	/* expand :sign unplace" */
+    EXP_SIGN_NAMES	/* expand with name of placed signs */
+} expand_what;
+
+/*
+ * Function given to ExpandGeneric() to obtain the sign command
+ * expansion.
+ */
+    char_u *
+get_sign_name(xp, idx)
+    expand_T	*xp UNUSED;
+    int		idx;
+{
+    sign_T	*sp;
+    int		current_idx;
+
+    switch (expand_what)
+    {
+    case EXP_SUBCMD:
+	return (char_u *)cmds[idx];
+    case EXP_DEFINE:
+	{
+	    char *define_arg[] =
+	    {
+		"icon=", "linehl=", "text=", "texthl=", NULL
+	    };
+	    return (char_u *)define_arg[idx];
+	}
+    case EXP_PLACE:
+	{
+	    char *place_arg[] =
+	    {
+		"line=", "name=", "file=", "buffer=", NULL
+	    };
+	    return (char_u *)place_arg[idx];
+	}
+    case EXP_UNPLACE:
+	{
+	    char *unplace_arg[] = { "file=", "buffer=", NULL };
+	    return (char_u *)unplace_arg[idx];
+	}
+    case EXP_SIGN_NAMES:
+	/* Complete with name of signs already defined */
+	current_idx = 0;
+	for (sp = first_sign; sp != NULL; sp = sp->sn_next)
+	    if (current_idx++ == idx)
+		return sp->sn_name;
+	return NULL;
+    default:
+	return NULL;
+    }
+}
+
+/*
+ * Handle command line completion for :sign command.
+ */
+    void
+set_context_in_sign_cmd(xp, arg)
+    expand_T	*xp;
+    char_u	*arg;
+{
+    char_u	*p;
+    char_u	*end_subcmd;
+    char_u	*last;
+    int		cmd_idx;
+    char_u	*begin_subcmd_args;
+
+    /* Default: expand subcommands. */
+    xp->xp_context = EXPAND_SIGN;
+    expand_what = EXP_SUBCMD;
+    xp->xp_pattern = arg;
+
+    end_subcmd = skiptowhite(arg);
+    if (*end_subcmd == NUL)
+	/* expand subcmd name
+	 * :sign {subcmd}<CTRL-D>*/
+	return;
+
+    cmd_idx = sign_cmd_idx(arg, end_subcmd);
+
+    /* :sign {subcmd} {subcmd_args}
+     *                |
+     *                begin_subcmd_args */
+    begin_subcmd_args = skipwhite(end_subcmd);
+    p = skiptowhite(begin_subcmd_args);
+    if (*p == NUL)
+    {
+	/*
+	 * Expand first argument of subcmd when possible.
+	 * For ":jump {id}" and ":unplace {id}", we could
+	 * possibly expand the ids of all signs already placed.
+	 */
+	xp->xp_pattern = begin_subcmd_args;
+	switch (cmd_idx)
+	{
+	    case SIGNCMD_LIST:
+	    case SIGNCMD_UNDEFINE:
+		/* :sign list <CTRL-D>
+		 * :sign undefine <CTRL-D> */
+		expand_what = EXP_SIGN_NAMES;
+		break;
+	    default:
+		xp->xp_context = EXPAND_NOTHING;
+	}
+	return;
+    }
+
+    /* expand last argument of subcmd */
+
+    /* :sign define {name} {args}...
+     *              |
+     *              p */
+
+    /* Loop until reaching last argument. */
+    do
+    {
+	p = skipwhite(p);
+	last = p;
+	p = skiptowhite(p);
+    } while (*p != NUL);
+
+    p = vim_strchr(last, '=');
+
+    /* :sign define {name} {args}... {last}=
+     *                               |     |
+     *                            last     p */
+    if (p == NUL)
+    {
+	/* Expand last argument name (before equal sign). */
+	xp->xp_pattern = last;
+	switch (cmd_idx)
+	{
+	    case SIGNCMD_DEFINE:
+		expand_what = EXP_DEFINE;
+		break;
+	    case SIGNCMD_PLACE:
+		expand_what = EXP_PLACE;
+		break;
+	    case SIGNCMD_JUMP:
+	    case SIGNCMD_UNPLACE:
+		expand_what = EXP_UNPLACE;
+		break;
+	    default:
+		xp->xp_context = EXPAND_NOTHING;
+	}
+    }
+    else
+    {
+	/* Expand last argument value (after equal sign). */
+	xp->xp_pattern = p + 1;
+	switch (cmd_idx)
+	{
+	    case SIGNCMD_DEFINE:
+		if (STRNCMP(last, "texthl", p - last) == 0 ||
+		    STRNCMP(last, "linehl", p - last) == 0)
+		    xp->xp_context = EXPAND_HIGHLIGHT;
+		else if (STRNCMP(last, "icon", p - last) == 0)
+		    xp->xp_context = EXPAND_FILES;
+		else
+		    xp->xp_context = EXPAND_NOTHING;
+		break;
+	    case SIGNCMD_PLACE:
+		if (STRNCMP(last, "name", p - last) == 0)
+		    expand_what = EXP_SIGN_NAMES;
+		else
+		    xp->xp_context = EXPAND_NOTHING;
+		break;
+	    default:
+		xp->xp_context = EXPAND_NOTHING;
+	}
+    }
+}
+#endif
 #endif
 
 #if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO)
 /*
  * ":drop"
--- vim72.orig/src/ex_cmds.h
+++ vim72/src/ex_cmds.h
@@ -276,11 +276,11 @@ EX(CMD_cpfile,		"cpfile",	ex_cnext,
 EX(CMD_cquit,		"cquit",	ex_cquit,
 			TRLBAR|BANG),
 EX(CMD_crewind,		"crewind",	ex_cc,
 			RANGE|NOTADR|COUNT|TRLBAR|BANG),
 EX(CMD_cscope,		"cscope",	do_cscope,
-			EXTRA|NOTRLCOM|SBOXOK|XFILE),
+			EXTRA|NOTRLCOM|XFILE),
 EX(CMD_cstag,		"cstag",	do_cstag,
 			BANG|TRLBAR|WORD1),
 EX(CMD_cunmap,		"cunmap",	ex_unmap,
 			EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
 EX(CMD_cunabbrev,	"cunabbrev",	ex_abbreviate,
@@ -504,11 +504,11 @@ EX(CMD_lcd,		"lcd",		ex_cd,
 EX(CMD_lchdir,		"lchdir",	ex_cd,
 			BANG|FILE1|TRLBAR|CMDWIN),
 EX(CMD_lclose,		"lclose",	ex_cclose,
 			RANGE|NOTADR|COUNT|TRLBAR),
 EX(CMD_lcscope,		"lcscope",	do_cscope,
-			EXTRA|NOTRLCOM|SBOXOK|XFILE),
+			EXTRA|NOTRLCOM|XFILE),
 EX(CMD_left,		"left",		ex_align,
 			TRLBAR|RANGE|WHOLEFOLD|EXTRA|CMDWIN|MODIFY),
 EX(CMD_leftabove,	"leftabove",	ex_wrongmodifier,
 			NEEDARG|EXTRA|NOTRLCOM),
 EX(CMD_let,		"let",		ex_let,
@@ -633,10 +633,12 @@ EX(CMD_nnoremap,	"nnoremap",	ex_map,
 			EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
 EX(CMD_nnoremenu,	"nnoremenu",	ex_menu,
 			RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
 EX(CMD_noremap,		"noremap",	ex_map,
 			BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
+EX(CMD_noautocmd,	"noautocmd",	ex_wrongmodifier,
+			NEEDARG|EXTRA|NOTRLCOM),
 EX(CMD_nohlsearch,	"nohlsearch",	ex_nohlsearch,
 			TRLBAR|SBOXOK|CMDWIN),
 EX(CMD_noreabbrev,	"noreabbrev",	ex_abbreviate,
 			EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
 EX(CMD_noremenu,	"noremenu",	ex_menu,
@@ -649,10 +651,12 @@ EX(CMD_nunmap,		"nunmap",	ex_unmap,
 			EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
 EX(CMD_nunmenu,		"nunmenu",	ex_menu,
 			EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
 EX(CMD_open,		"open",		ex_open,
 			RANGE|EXTRA),
+EX(CMD_oldfiles,	"oldfiles",	ex_oldfiles,
+			BANG|TRLBAR|SBOXOK|CMDWIN),
 EX(CMD_omap,		"omap",		ex_map,
 			EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
 EX(CMD_omapclear,	"omapclear",	ex_mapclear,
 			EXTRA|TRLBAR|CMDWIN),
 EX(CMD_omenu,		"omenu",	ex_menu,
@@ -800,11 +804,11 @@ EX(CMD_sbrewind,	"sbrewind",	ex_brewind,
 EX(CMD_scriptnames,	"scriptnames",	ex_scriptnames,
 			TRLBAR|CMDWIN),
 EX(CMD_scriptencoding,	"scriptencoding", ex_scriptencoding,
 			WORD1|TRLBAR|CMDWIN),
 EX(CMD_scscope,		"scscope",	do_scscope,
-			EXTRA|NOTRLCOM|SBOXOK),
+			EXTRA|NOTRLCOM),
 EX(CMD_set,		"set",		ex_set,
 			TRLBAR|EXTRA|CMDWIN|SBOXOK),
 EX(CMD_setfiletype,	"setfiletype",	ex_setfiletype,
 			TRLBAR|EXTRA|NEEDARG|CMDWIN),
 EX(CMD_setglobal,	"setglobal",	ex_set,
@@ -985,10 +989,12 @@ EX(CMD_unlockvar,	"unlockvar",	ex_lockva
 			BANG|EXTRA|NEEDARG|SBOXOK|CMDWIN),
 EX(CMD_unmap,		"unmap",	ex_unmap,
 			BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
 EX(CMD_unmenu,		"unmenu",	ex_menu,
 			BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
+EX(CMD_unsilent,	"unsilent",	ex_wrongmodifier,
+			NEEDARG|EXTRA|NOTRLCOM|SBOXOK|CMDWIN),
 EX(CMD_update,		"update",	ex_update,
 			RANGE|WHOLEFOLD|BANG|FILE1|ARGOPT|DFLALL|TRLBAR),
 EX(CMD_vglobal,		"vglobal",	ex_global,
 			RANGE|WHOLEFOLD|EXTRA|DFLALL|CMDWIN),
 EX(CMD_version,		"version",	ex_version,
--- vim72.orig/src/ex_cmds2.c
+++ vim72/src/ex_cmds2.c
@@ -26,11 +26,12 @@ static void	cmd_source __ARGS((char_u *f
  * script when going through the list. */
 typedef struct scriptitem_S
 {
     char_u	*sn_name;
 # ifdef UNIX
-    int		sn_dev;
+    int		sn_dev_valid;
+    dev_t	sn_dev;
     ino_t	sn_ino;
 # endif
 # ifdef FEAT_PROFILE
     int		sn_prof_on;	/* TRUE when script is/was profiled */
     int		sn_pr_force;	/* forceit: profile functions in this script */
@@ -678,14 +679,13 @@ ex_breakdel(eap)
 }
 
 /*
  * ":breaklist".
  */
-/*ARGSUSED*/
     void
 ex_breaklist(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     struct debuggy *bp;
     int		i;
 
     if (dbg_breakp.ga_len == 0)
@@ -1090,11 +1090,11 @@ ex_profile(eap)
 	do_profiling = PROF_YES;
 	profile_zero(&prof_wait_time);
 	set_vim_var_nr(VV_PROFILING, 1L);
     }
     else if (do_profiling == PROF_NONE)
-	EMSG(_("E750: First use :profile start <fname>"));
+	EMSG(_("E750: First use \":profile start {fname}\""));
     else if (STRCMP(eap->arg, "pause") == 0)
     {
 	if (do_profiling == PROF_YES)
 	    profile_start(&pause_time);
 	do_profiling = PROF_PAUSED;
@@ -1113,10 +1113,81 @@ ex_profile(eap)
 	/* The rest is similar to ":breakadd". */
 	ex_breakadd(eap);
     }
 }
 
+/* Command line expansion for :profile. */
+static enum
+{
+    PEXP_SUBCMD,	/* expand :profile sub-commands */
+    PEXP_FUNC,		/* expand :profile func {funcname} */
+} pexpand_what;
+
+static char *pexpand_cmds[] = {
+			"start",
+#define PROFCMD_START	0
+			"pause",
+#define PROFCMD_PAUSE	1
+			"continue",
+#define PROFCMD_CONTINUE 2
+			"func",
+#define PROFCMD_FUNC	3
+			"file",
+#define PROFCMD_FILE	4
+			NULL
+#define PROFCMD_LAST	5
+};
+
+/*
+ * Function given to ExpandGeneric() to obtain the profile command
+ * specific expansion.
+ */
+    char_u *
+get_profile_name(xp, idx)
+    expand_T	*xp UNUSED;
+    int		idx;
+{
+    switch (pexpand_what)
+    {
+    case PEXP_SUBCMD:
+	return (char_u *)pexpand_cmds[idx];
+    /* case PEXP_FUNC: TODO */
+    default:
+	return NULL;
+    }
+}
+
+/*
+ * Handle command line completion for :profile command.
+ */
+    void
+set_context_in_profile_cmd(xp, arg)
+    expand_T	*xp;
+    char_u	*arg;
+{
+    char_u	*end_subcmd;
+
+    /* Default: expand subcommands. */
+    xp->xp_context = EXPAND_PROFILE;
+    pexpand_what = PEXP_SUBCMD;
+    xp->xp_pattern = arg;
+
+    end_subcmd = skiptowhite(arg);
+    if (*end_subcmd == NUL)
+	return;
+
+    if (end_subcmd - arg == 5 && STRNCMP(arg, "start", 5) == 0)
+    {
+	xp->xp_context = EXPAND_FILES;
+	xp->xp_pattern = skipwhite(end_subcmd);
+	return;
+    }
+
+    /* TODO: expand function names after "func" */
+    xp->xp_context = EXPAND_NOTHING;
+}
+
 /*
  * Dump the profiling info.
  */
     void
 profile_dump()
@@ -1340,18 +1411,17 @@ autowrite_all()
 }
 
 /*
  * return TRUE if buffer was changed and cannot be abandoned.
  */
-/*ARGSUSED*/
     int
 check_changed(buf, checkaw, mult_win, forceit, allbuf)
     buf_T	*buf;
     int		checkaw;	/* do autowrite if buffer was changed */
     int		mult_win;	/* check also when several wins for the buf */
     int		forceit;
-    int		allbuf;		/* may write all buffers */
+    int		allbuf UNUSED;	/* may write all buffers */
 {
     if (       !forceit
 	    && bufIsChanged(buf)
 	    && (mult_win || buf->b_nwindows <= 1)
 	    && (!checkaw || autowrite(buf, forceit) == FAIL))
@@ -1757,16 +1827,15 @@ set_arglist(str)
  * "what" == AL_ADD: add files in 'str' to the argument list after "after".
  * "what" == AL_DEL: remove files in 'str' from the argument list.
  *
  * Return FAIL for failure, OK otherwise.
  */
-/*ARGSUSED*/
     static int
 do_arglist(str, what, after)
     char_u	*str;
-    int		what;
-    int		after;		/* 0 means before first one */
+    int		what UNUSED;
+    int		after UNUSED;		/* 0 means before first one */
 {
     garray_T	new_ga;
     int		exp_count;
     char_u	**exp_files;
     int		i;
@@ -2130,12 +2199,12 @@ do_argfile(eap, argn)
 	/* Edit the file; always use the last known line number.
 	 * When it fails (e.g. Abort for already edited file) restore the
 	 * argument index. */
 	if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
 		      eap, ECMD_LAST,
-		      (P_HID(curwin->w_buffer) ? ECMD_HIDE : 0) +
-				   (eap->forceit ? ECMD_FORCEIT : 0)) == FAIL)
+		      (P_HID(curwin->w_buffer) ? ECMD_HIDE : 0)
+			 + (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)
 	    curwin->w_arg_idx = old_arg_idx;
 	/* like Vi: set the mark where the cursor is in the file. */
 	else if (eap->cmdidx != CMD_argdo)
 	    setmark('\'');
     }
@@ -2496,43 +2565,44 @@ ex_compiler(eap)
 	    {
 		/* ":compiler! {name}" sets local options.
 		 * To remain backwards compatible "current_compiler" is always
 		 * used.  A user's compiler plugin may set it, the distributed
 		 * plugin will then skip the settings.  Afterwards set
-		 * "b:current_compiler" and restore "current_compiler". */
-		old_cur_comp = get_var_value((char_u *)"current_compiler");
+		 * "b:current_compiler" and restore "current_compiler".
+		 * Explicitly prepend "g:" to make it work in a function. */
+		old_cur_comp = get_var_value((char_u *)"g:current_compiler");
 		if (old_cur_comp != NULL)
 		    old_cur_comp = vim_strsave(old_cur_comp);
 		do_cmdline_cmd((char_u *)
 			      "command -nargs=* CompilerSet setlocal <args>");
 	    }
-	    do_unlet((char_u *)"current_compiler", TRUE);
+	    do_unlet((char_u *)"g:current_compiler", TRUE);
 	    do_unlet((char_u *)"b:current_compiler", TRUE);
 
 	    sprintf((char *)buf, "compiler/%s.vim", eap->arg);
 	    if (source_runtime(buf, TRUE) == FAIL)
 		EMSG2(_("E666: compiler not supported: %s"), eap->arg);
 	    vim_free(buf);
 
 	    do_cmdline_cmd((char_u *)":delcommand CompilerSet");
 
 	    /* Set "b:current_compiler" from "current_compiler". */
-	    p = get_var_value((char_u *)"current_compiler");
+	    p = get_var_value((char_u *)"g:current_compiler");
 	    if (p != NULL)
 		set_internal_string_var((char_u *)"b:current_compiler", p);
 
 	    /* Restore "current_compiler" for ":compiler {name}". */
 	    if (!eap->forceit)
 	    {
 		if (old_cur_comp != NULL)
 		{
-		    set_internal_string_var((char_u *)"current_compiler",
+		    set_internal_string_var((char_u *)"g:current_compiler",
 								old_cur_comp);
 		    vim_free(old_cur_comp);
 		}
 		else
-		    do_unlet((char_u *)"current_compiler", TRUE);
+		    do_unlet((char_u *)"g:current_compiler", TRUE);
 	    }
 	}
     }
 }
 #endif
@@ -2547,15 +2617,14 @@ ex_runtime(eap)
     source_runtime(eap->arg, eap->forceit);
 }
 
 static void source_callback __ARGS((char_u *fname, void *cookie));
 
-/*ARGSUSED*/
     static void
 source_callback(fname, cookie)
     char_u	*fname;
-    void	*cookie;
+    void	*cookie UNUSED;
 {
     (void)do_source(fname, FALSE, DOSO_NONE);
 }
 
 /*
@@ -2678,14 +2747,13 @@ do_in_runtimepath(name, all, callback, c
 
 #if defined(FEAT_EVAL) && defined(FEAT_AUTOCMD)
 /*
  * ":options"
  */
-/*ARGSUSED*/
     void
 ex_options(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     cmd_source((char_u *)SYS_OPTWIN_FILE, NULL);
 }
 #endif
 
@@ -2803,24 +2871,39 @@ source_level(cookie)
 }
 #endif
 
 static char_u *get_one_sourceline __ARGS((struct source_cookie *sp));
 
-#if defined(WIN32) && defined(FEAT_CSCOPE)
+#if (defined(WIN32) && defined(FEAT_CSCOPE)) || defined(HAVE_FD_CLOEXEC)
+# define USE_FOPEN_NOINH
 static FILE *fopen_noinh_readbin __ARGS((char *filename));
 
 /*
  * Special function to open a file without handle inheritance.
+ * When possible the handle is closed on exec().
  */
     static FILE *
 fopen_noinh_readbin(filename)
     char    *filename;
 {
+# ifdef WIN32
     int	fd_tmp = mch_open(filename, O_RDONLY | O_BINARY | O_NOINHERIT, 0);
+# else
+    int	fd_tmp = mch_open(filename, O_RDONLY, 0);
+# endif
 
     if (fd_tmp == -1)
 	return NULL;
+
+# ifdef HAVE_FD_CLOEXEC
+    {
+	int fdflags = fcntl(fd_tmp, F_GETFD);
+	if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
+	    fcntl(fd_tmp, F_SETFD, fdflags | FD_CLOEXEC);
+    }
+# endif
+
     return fdopen(fd_tmp, READBIN);
 }
 #endif
 
 
@@ -2840,10 +2923,11 @@ do_source(fname, check_other, is_vimrc)
     struct source_cookie    cookie;
     char_u		    *save_sourcing_name;
     linenr_T		    save_sourcing_lnum;
     char_u		    *p;
     char_u		    *fname_exp;
+    char_u		    *firstline = NULL;
     int			    retval = FAIL;
 #ifdef FEAT_EVAL
     scid_T		    save_current_SID;
     static scid_T	    last_current_SID = 0;
     void		    *save_funccalp;
@@ -2895,11 +2979,11 @@ do_source(fname, check_other, is_vimrc)
 
     /* Apply SourcePre autocommands, they may get the file. */
     apply_autocmds(EVENT_SOURCEPRE, fname_exp, fname_exp, FALSE, curbuf);
 #endif
 
-#if defined(WIN32) && defined(FEAT_CSCOPE)
+#ifdef USE_FOPEN_NOINH
     cookie.fp = fopen_noinh_readbin((char *)fname_exp);
 #else
     cookie.fp = mch_fopen((char *)fname_exp, READBIN);
 #endif
     if (cookie.fp == NULL && check_other)
@@ -2916,11 +3000,11 @@ do_source(fname, check_other, is_vimrc)
 	{
 	    if (*p == '_')
 		*p = '.';
 	    else
 		*p = '_';
-#if defined(WIN32) && defined(FEAT_CSCOPE)
+#ifdef USE_FOPEN_NOINH
 	    cookie.fp = fopen_noinh_readbin((char *)fname_exp);
 #else
 	    cookie.fp = mch_fopen((char *)fname_exp, READBIN);
 #endif
 	}
@@ -2990,38 +3074,43 @@ do_source(fname, check_other, is_vimrc)
     cookie.fname = fname_exp;
     cookie.dbg_tick = debug_tick;
 
     cookie.level = ex_nesting_level;
 #endif
-#ifdef FEAT_MBYTE
-    cookie.conv.vc_type = CONV_NONE;		/* no conversion */
-
-    /* Try reading the first few bytes to check for a UTF-8 BOM. */
-    {
-	char_u	    buf[3];
-
-	if (fread((char *)buf, sizeof(char_u), (size_t)3, cookie.fp)
-								  == (size_t)3
-		&& buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf)
-	    /* Found BOM, setup conversion and skip over it. */
-	    convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
-	else
-	    /* No BOM found, rewind. */
-	    fseek(cookie.fp, 0L, SEEK_SET);
-    }
-#endif
 
     /*
      * Keep the sourcing name/lnum, for recursive calls.
      */
     save_sourcing_name = sourcing_name;
     sourcing_name = fname_exp;
     save_sourcing_lnum = sourcing_lnum;
     sourcing_lnum = 0;
 
+#ifdef FEAT_MBYTE
+    cookie.conv.vc_type = CONV_NONE;		/* no conversion */
+
+    /* Read the first line so we can check for a UTF-8 BOM. */
+    firstline = getsourceline(0, (void *)&cookie, 0);
+    if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef
+			      && firstline[1] == 0xbb && firstline[2] == 0xbf)
+    {
+	/* Found BOM; setup conversion, skip over BOM and recode the line. */
+	convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
+	p = string_convert(&cookie.conv, firstline + 3, NULL);
+	if (p == NULL)
+	    p = vim_strsave(firstline + 3);
+	if (p != NULL)
+	{
+	    vim_free(firstline);
+	    firstline = p;
+	}
+    }
+#endif
+
 #ifdef STARTUPTIME
-    time_push(&tv_rel, &tv_start);
+    if (time_fd != NULL)
+	time_push(&tv_rel, &tv_start);
 #endif
 
 #ifdef FEAT_EVAL
 # ifdef FEAT_PROFILE
     if (do_profiling == PROF_YES)
@@ -3047,11 +3136,11 @@ do_source(fname, check_other, is_vimrc)
 		&& (
 # ifdef UNIX
 		    /* Compare dev/ino when possible, it catches symbolic
 		     * links.  Also compare file names, the inode may change
 		     * when the file was edited. */
-		    ((stat_ok && si->sn_dev != -1)
+		    ((stat_ok && si->sn_dev_valid)
 			&& (si->sn_dev == st.st_dev
 			    && si->sn_ino == st.st_ino)) ||
 # endif
 		fnamecmp(si->sn_name, fname_exp) == 0))
 	    break;
@@ -3074,15 +3163,16 @@ do_source(fname, check_other, is_vimrc)
 	si->sn_name = fname_exp;
 	fname_exp = NULL;
 # ifdef UNIX
 	if (stat_ok)
 	{
+	    si->sn_dev_valid = TRUE;
 	    si->sn_dev = st.st_dev;
 	    si->sn_ino = st.st_ino;
 	}
 	else
-	    si->sn_dev = -1;
+	    si->sn_dev_valid = FALSE;
 # endif
 
 	/* Allocate the local script variables to use for this script. */
 	new_script_vars(current_SID);
     }
@@ -3109,13 +3199,12 @@ do_source(fname, check_other, is_vimrc)
 #endif
 
     /*
      * Call do_cmdline, which will call getsourceline() to get the lines.
      */
-    do_cmdline(NULL, getsourceline, (void *)&cookie,
+    do_cmdline(firstline, getsourceline, (void *)&cookie,
 				     DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);
-
     retval = OK;
 
 #ifdef FEAT_PROFILE
     if (do_profiling == PROF_YES)
     {
@@ -3143,13 +3232,16 @@ do_source(fname, check_other, is_vimrc)
 	if (sourcing_name != NULL)
 	    smsg((char_u *)_("continuing in %s"), sourcing_name);
 	verbose_leave();
     }
 #ifdef STARTUPTIME
-    vim_snprintf(IObuff, IOSIZE, "sourcing %s", fname);
-    time_msg(IObuff, &tv_start);
-    time_pop(&tv_rel);
+    if (time_fd != NULL)
+    {
+	vim_snprintf((char *)IObuff, IOSIZE, "sourcing %s", fname);
+	time_msg((char *)IObuff, &tv_start);
+	time_pop(&tv_rel);
+    }
 #endif
 
 #ifdef FEAT_EVAL
     /*
      * After a "finish" in debug mode, need to break at first command of next
@@ -3169,10 +3261,11 @@ almosttheend:
 	prof_child_exit(&wait_start);		/* leaving a child now */
 # endif
 #endif
     fclose(cookie.fp);
     vim_free(cookie.nextline);
+    vim_free(firstline);
 #ifdef FEAT_MBYTE
     convert_setup(&cookie.conv, NULL, NULL);
 #endif
 
 theend:
@@ -3183,14 +3276,13 @@ theend:
 #if defined(FEAT_EVAL) || defined(PROTO)
 
 /*
  * ":scriptnames"
  */
-/*ARGSUSED*/
     void
 ex_scriptnames(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     int i;
 
     for (i = 1; i <= script_items.ga_len && !got_int; ++i)
 	if (SCRIPT_ITEM(i).sn_name != NULL)
@@ -3310,16 +3402,15 @@ fgets_cr(s, n, stream)
  * Called by do_cmdline() when it's called from do_source().
  *
  * Return a pointer to the line in allocated memory.
  * Return NULL for end-of-file or some error.
  */
-/* ARGSUSED */
     char_u *
 getsourceline(c, cookie, indent)
-    int		c;		/* not used */
+    int		c UNUSED;
     void	*cookie;
-    int		indent;		/* not used */
+    int		indent UNUSED;
 {
     struct source_cookie *sp = (struct source_cookie *)cookie;
     char_u		*line;
     char_u		*p, *s;
 
@@ -3366,11 +3457,11 @@ getsourceline(c, cookie, indent)
 	    if (sp->nextline == NULL)
 		break;
 	    p = skipwhite(sp->nextline);
 	    if (*p != '\\')
 		break;
-	    s = alloc((int)(STRLEN(line) + STRLEN(p)));
+	    s = alloc((unsigned)(STRLEN(line) + STRLEN(p)));
 	    if (s == NULL)	/* out of memory */
 		break;
 	    STRCPY(s, line);
 	    STRCAT(s, p + 1);
 	    vim_free(line);
@@ -3642,14 +3733,13 @@ script_line_end()
 
 /*
  * ":scriptencoding": Set encoding conversion for a sourced script.
  * Without the multi-byte feature it's simply ignored.
  */
-/*ARGSUSED*/
     void
 ex_scriptencoding(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
 #ifdef FEAT_MBYTE
     struct source_cookie	*sp;
     char_u			*name;
 
@@ -4094,14 +4184,13 @@ ex_language(eap)
 # if defined(FEAT_CMDL_COMPL) || defined(PROTO)
 /*
  * Function given to ExpandGeneric() to obtain the possible arguments of the
  * ":language" command.
  */
-/*ARGSUSED*/
     char_u *
 get_lang_arg(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     if (idx == 0)
 	return (char_u *)"messages";
     if (idx == 1)
--- vim72.orig/src/ex_docmd.c
+++ vim72/src/ex_docmd.c
@@ -24,14 +24,16 @@ typedef struct ucmd
 {
     char_u	*uc_name;	/* The command name */
     long_u	uc_argt;	/* The argument type */
     char_u	*uc_rep;	/* The command's replacement string */
     long	uc_def;		/* The default value for a range/count */
-    scid_T	uc_scriptID;	/* SID where the command was defined */
     int		uc_compl;	/* completion type */
-# if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
+# ifdef FEAT_EVAL
+    scid_T	uc_scriptID;	/* SID where the command was defined */
+#  ifdef FEAT_CMDL_COMPL
     char_u	*uc_compl_arg;	/* completion argument if any */
+#  endif
 # endif
 } ucmd_T;
 
 #define UC_BUFFER	1	/* -buffer: local to current buffer */
 
@@ -362,10 +364,11 @@ static void	ex_tag_cmd __ARGS((exarg_T *
 # define ex_lockvar		ex_ni
 # define ex_unlockvar		ex_ni
 # define ex_function		ex_ni
 # define ex_delfunction		ex_ni
 # define ex_return		ex_ni
+# define ex_oldfiles		ex_ni
 #endif
 static char_u	*arg_all __ARGS((void));
 #ifdef FEAT_SESSION
 static int	makeopens __ARGS((FILE *fd, char_u *dirnow));
 static int	put_view __ARGS((FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int current_arg_idx));
@@ -1575,15 +1578,14 @@ free_cmdlines(gap)
 
 /*
  * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals
  * "func".  * Otherwise return TRUE when "fgetline" equals "func".
  */
-/*ARGSUSED*/
     int
 getline_equal(fgetline, cookie, func)
     char_u	*(*fgetline) __ARGS((int, void *, int));
-    void	*cookie;		/* argument for fgetline() */
+    void	*cookie UNUSED;		/* argument for fgetline() */
     char_u	*(*func) __ARGS((int, void *, int));
 {
 #ifdef FEAT_EVAL
     char_u		*(*gp) __ARGS((int, void *, int));
     struct loop_cookie *cp;
@@ -1607,14 +1609,13 @@ getline_equal(fgetline, cookie, func)
 #if defined(FEAT_EVAL) || defined(FEAT_MBYTE) || defined(PROTO)
 /*
  * If "fgetline" is get_loop_line(), return the cookie used by the original
  * getline function.  Otherwise return "cookie".
  */
-/*ARGSUSED*/
     void *
 getline_cookie(fgetline, cookie)
-    char_u	*(*fgetline) __ARGS((int, void *, int));
+    char_u	*(*fgetline) __ARGS((int, void *, int)) UNUSED;
     void	*cookie;		/* argument for fgetline() */
 {
 # ifdef FEAT_EVAL
     char_u		*(*gp) __ARGS((int, void *, int));
     struct loop_cookie *cp;
@@ -1676,12 +1677,12 @@ do_one_cmd(cmdlinep, sourcing,
     linenr_T		lnum;
     long		n;
     char_u		*errormsg = NULL;	/* error message */
     exarg_T		ea;			/* Ex command arguments */
     long		verbose_save = -1;
-    int			save_msg_scroll = 0;
-    int			did_silent = 0;
+    int			save_msg_scroll = msg_scroll;
+    int			save_msg_silent = -1;
     int			did_esilent = 0;
 #ifdef HAVE_SANDBOX
     int			did_sandbox = FALSE;
 #endif
     cmdmod_T		save_cmdmod;
@@ -1768,11 +1769,11 @@ do_one_cmd(cmdlinep, sourcing,
 #endif
 			    continue;
 			}
 			if (checkforcmd(&ea.cmd, "browse", 3))
 			{
-#ifdef FEAT_BROWSE
+#ifdef FEAT_BROWSE_CMD
 			    cmdmod.browse = TRUE;
 #endif
 			    continue;
 			}
 			if (!checkforcmd(&ea.cmd, "botright", 2))
@@ -1855,13 +1856,13 @@ do_one_cmd(cmdlinep, sourcing,
 #endif
 			    continue;
 			}
 			if (!checkforcmd(&ea.cmd, "silent", 3))
 			    break;
-			++did_silent;
+			if (save_msg_silent == -1)
+			    save_msg_silent = msg_silent;
 			++msg_silent;
-			save_msg_scroll = msg_scroll;
 			if (*ea.cmd == '!' && !vim_iswhite(ea.cmd[-1]))
 			{
 			    /* ":silent!", but not "silent !cmd" */
 			    ea.cmd = skipwhite(ea.cmd + 1);
 			    ++emsg_silent;
@@ -1885,10 +1886,17 @@ do_one_cmd(cmdlinep, sourcing,
 #ifdef FEAT_WINDOWS
 			cmdmod.split |= WSP_TOP;
 #endif
 			continue;
 
+	    case 'u':	if (!checkforcmd(&ea.cmd, "unsilent", 3))
+			    break;
+			if (save_msg_silent == -1)
+			    save_msg_silent = msg_silent;
+			msg_silent = 0;
+			continue;
+
 	    case 'v':	if (checkforcmd(&ea.cmd, "vertical", 4))
 			{
 #ifdef FEAT_VERTSPLIT
 			    cmdmod.split |= WSP_VERT;
 #endif
@@ -2683,23 +2691,27 @@ doend:
     }
 #endif
 
     cmdmod = save_cmdmod;
 
-    if (did_silent > 0)
+    if (save_msg_silent != -1)
     {
 	/* messages could be enabled for a serious error, need to check if the
 	 * counters don't become negative */
-	msg_silent -= did_silent;
-	if (msg_silent < 0)
-	    msg_silent = 0;
+	if (!did_emsg || msg_silent > save_msg_silent)
+	    msg_silent = save_msg_silent;
 	emsg_silent -= did_esilent;
 	if (emsg_silent < 0)
 	    emsg_silent = 0;
 	/* Restore msg_scroll, it's set by file I/O commands, even when no
 	 * message is actually displayed. */
 	msg_scroll = save_msg_scroll;
+
+	/* "silent reg" or "silent echo x" inside "redir" leaves msg_col
+	 * somewhere in the line.  Put it back in the first column. */
+	if (redirecting())
+	    msg_col = 0;
     }
 
 #ifdef HAVE_SANDBOX
     if (did_sandbox)
 	--sandbox;
@@ -2729,11 +2741,11 @@ checkforcmd(pp, cmd, len)
     int		len;		/* required length */
 {
     int		i;
 
     for (i = 0; cmd[i] != NUL; ++i)
-	if (cmd[i] != (*pp)[i])
+	if (((char_u *)cmd)[i] != (*pp)[i])
 	    break;
     if (i >= len && !isalpha((*pp)[i]))
     {
 	*pp = skipwhite(*pp + i);
 	return TRUE;
@@ -2746,15 +2758,14 @@ checkforcmd(pp, cmd, len)
  * Start of the name can be found at eap->cmd.
  * Returns pointer to char after the command name.
  * "full" is set to TRUE if the whole command name matched.
  * Returns NULL for an ambiguous user command.
  */
-/*ARGSUSED*/
     static char_u *
 find_command(eap, full)
     exarg_T	*eap;
-    int		*full;
+    int		*full UNUSED;
 {
     int		len;
     char_u	*p;
     int		i;
 
@@ -2795,11 +2806,11 @@ find_command(eap, full)
 	if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))
 	{
 	    /* Check for ":dl", ":dell", etc. to ":deletel": that's
 	     * :delete with the 'l' flag.  Same for 'p'. */
 	    for (i = 0; i < len; ++i)
-		if (eap->cmd[i] != "delete"[i])
+		if (eap->cmd[i] != ((char_u *)"delete")[i])
 		    break;
 	    if (i == len - 1)
 	    {
 		--len;
 		if (p[-1] == 'l')
@@ -2976,15 +2987,17 @@ static struct cmdmod
     {"keepalt", 5, FALSE},
     {"keepjumps", 5, FALSE},
     {"keepmarks", 3, FALSE},
     {"leftabove", 5, FALSE},
     {"lockmarks", 3, FALSE},
+    {"noautocmd", 3, FALSE},
     {"rightbelow", 6, FALSE},
     {"sandbox", 3, FALSE},
     {"silent", 3, FALSE},
     {"tab", 3, TRUE},
     {"topleft", 2, FALSE},
+    {"unsilent", 3, FALSE},
     {"verbose", 4, TRUE},
     {"vertical", 4, FALSE},
 };
 
 /*
@@ -2998,11 +3011,11 @@ modifier_len(cmd)
     int		i, j;
     char_u	*p = cmd;
 
     if (VIM_ISDIGIT(*cmd))
 	p = skipwhite(skipdigits(cmd));
-    for (i = 0; i < sizeof(cmdmods) / sizeof(struct cmdmod); ++i)
+    for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i)
     {
 	for (j = 0; p[j] != NUL; ++j)
 	    if (p[j] != cmdmods[i].name[j])
 		break;
 	if (!isalpha(p[j]) && j >= cmdmods[i].minlen
@@ -3026,11 +3039,11 @@ cmd_exists(name)
     int		i;
     int		j;
     char_u	*p;
 
     /* Check command modifiers. */
-    for (i = 0; i < sizeof(cmdmods) / sizeof(struct cmdmod); ++i)
+    for (i = 0; i < (int)(sizeof(cmdmods) / sizeof(struct cmdmod)); ++i)
     {
 	for (j = 0; name[j] != NUL; ++j)
 	    if (name[j] != cmdmods[i].name[j])
 		break;
 	if (name[j] == NUL && j >= cmdmods[i].minlen)
@@ -3143,21 +3156,19 @@ set_one_cmd_context(xp, buff)
 	{
 	    xp->xp_context = EXPAND_UNSUCCESSFUL;
 	    return NULL;
 	}
 	for (ea.cmdidx = (cmdidx_T)0; (int)ea.cmdidx < (int)CMD_SIZE;
-					 ea.cmdidx = (cmdidx_T)((int)ea.cmdidx + 1))
-	    if (STRNCMP(cmdnames[(int)ea.cmdidx].cmd_name, cmd, (size_t)len) == 0)
+				   ea.cmdidx = (cmdidx_T)((int)ea.cmdidx + 1))
+	    if (STRNCMP(cmdnames[(int)ea.cmdidx].cmd_name, cmd,
+							    (size_t)len) == 0)
 		break;
 
 #ifdef FEAT_USR_CMDS
 	if (cmd[0] >= 'A' && cmd[0] <= 'Z')
-	{
 	    while (ASCII_ISALNUM(*p) || *p == '*')	/* Allow * wild card */
 		++p;
-	    len = (int)(p - cmd);
-	}
 #endif
     }
 
     /*
      * If the cursor is touching the command, and it ends in an alpha-numeric
@@ -3606,10 +3617,11 @@ set_one_cmd_context(xp, buff)
 #ifdef FEAT_AUTOCMD
 	case CMD_autocmd:
 	    return set_context_in_autocmd(xp, arg, FALSE);
 
 	case CMD_doautocmd:
+	case CMD_doautoall:
 	    return set_context_in_autocmd(xp, arg, TRUE);
 #endif
 	case CMD_set:
 	    set_context_in_set_cmd(xp, arg, 0);
 	    break;
@@ -3678,10 +3690,22 @@ set_one_cmd_context(xp, buff)
 	    break;
 #endif
 	case CMD_highlight:
 	    set_context_in_highlight_cmd(xp, arg);
 	    break;
+#ifdef FEAT_CSCOPE
+	case CMD_cscope:
+	case CMD_lcscope:
+	case CMD_scscope:
+	    set_context_in_cscope_cmd(xp, arg, ea.cmdidx);
+	    break;
+#endif
+#ifdef FEAT_SIGNS
+	case CMD_sign:
+	    set_context_in_sign_cmd(xp, arg);
+	    break;
+#endif
 #ifdef FEAT_LISTCMDS
 	case CMD_bdelete:
 	case CMD_bwipeout:
 	case CMD_bunload:
 	    while ((xp->xp_pattern = vim_strchr(arg, ' ')) != NULL)
@@ -3778,10 +3802,18 @@ set_one_cmd_context(xp, buff)
 	    }
 	    else
 		xp->xp_context = EXPAND_NOTHING;
 	    break;
 #endif
+#if defined(FEAT_PROFILE)
+	case CMD_profile:
+	    set_context_in_profile_cmd(xp, arg);
+	    break;
+#endif
+	case CMD_behave:
+	    xp->xp_context = EXPAND_BEHAVE;
+	    break;
 
 #endif /* FEAT_CMDL_COMPL */
 
 	default:
 	    break;
@@ -3801,11 +3833,11 @@ set_one_cmd_context(xp, buff)
     char_u *
 skip_range(cmd, ctx)
     char_u	*cmd;
     int		*ctx;	/* pointer to xp_context or NULL */
 {
-    int		delim;
+    unsigned	delim;
 
     while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;", *cmd) != NULL)
     {
 	if (*cmd == '\'')
 	{
@@ -5031,14 +5063,13 @@ check_more(message, forceit)
 
 #ifdef FEAT_CMDL_COMPL
 /*
  * Function given to ExpandGeneric() to obtain the list of command names.
  */
-/*ARGSUSED*/
     char_u *
 get_command_name(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     if (idx >= (int)CMD_SIZE)
 # ifdef FEAT_USR_CMDS
 	return get_user_command_name(idx);
@@ -5119,11 +5150,15 @@ uc_add_command(name, name_len, rep, argt
 		EMSG(_("E174: Command already exists: add ! to replace it"));
 		goto fail;
 	    }
 
 	    vim_free(cmd->uc_rep);
-	    cmd->uc_rep = 0;
+	    cmd->uc_rep = NULL;
+#if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
+	    vim_free(cmd->uc_compl_arg);
+	    cmd->uc_compl_arg = NULL;
+#endif
 	    break;
 	}
 
 	/* Stop as soon as we pass the name to add */
 	if (cmp < 0)
@@ -5178,10 +5213,13 @@ static struct
 } command_complete[] =
 {
     {EXPAND_AUGROUP, "augroup"},
     {EXPAND_BUFFERS, "buffer"},
     {EXPAND_COMMANDS, "command"},
+#if defined(FEAT_CSCOPE)
+    {EXPAND_CSCOPE, "cscope"},
+#endif
 #if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
     {EXPAND_USER_DEFINED, "custom"},
     {EXPAND_USER_LIST, "customlist"},
 #endif
     {EXPAND_DIRECTORIES, "dir"},
@@ -5194,10 +5232,13 @@ static struct
     {EXPAND_HIGHLIGHT, "highlight"},
     {EXPAND_MAPPINGS, "mapping"},
     {EXPAND_MENUS, "menu"},
     {EXPAND_SETTINGS, "option"},
     {EXPAND_SHELLCMD, "shellcmd"},
+#if defined(FEAT_SIGNS)
+    {EXPAND_SIGN, "sign"},
+#endif
     {EXPAND_TAGS, "tag"},
     {EXPAND_TAGS_LISTFILES, "tag_listfiles"},
     {EXPAND_USER_VARS, "var"},
     {0, NULL}
 };
@@ -5477,10 +5518,13 @@ invalid_count:
     }
 
     return OK;
 }
 
+/*
+ * ":command ..."
+ */
     static void
 ex_command(eap)
     exarg_T   *eap;
 {
     char_u  *name;
@@ -5538,14 +5582,13 @@ ex_command(eap)
 
 /*
  * ":comclear"
  * Clear all user commands, global and for current buffer.
  */
-/*ARGSUSED*/
     void
 ex_comclear(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     uc_clear(&ucmds);
     uc_clear(&curbuf->b_ucmds);
 }
 
@@ -5908,11 +5951,12 @@ do_ucmd(eap)
     char_u	*buf;
     char_u	*p;
     char_u	*q;
 
     char_u	*start;
-    char_u	*end;
+    char_u	*end = NULL;
+    char_u	*ksp;
     size_t	len, totlen;
 
     size_t	split_len = 0;
     char_u	*split_buf = NULL;
     ucmd_T	*cmd;
@@ -5925,20 +5969,55 @@ do_ucmd(eap)
     else
 	cmd = USER_CMD_GA(&curbuf->b_ucmds, eap->useridx);
 
     /*
      * Replace <> in the command by the arguments.
+     * First round: "buf" is NULL, compute length, allocate "buf".
+     * Second round: copy result into "buf".
      */
     buf = NULL;
     for (;;)
     {
-	p = cmd->uc_rep;
-	q = buf;
+	p = cmd->uc_rep;    /* source */
+	q = buf;	    /* destination */
 	totlen = 0;
-	while ((start = vim_strchr(p, '<')) != NULL
-	       && (end = vim_strchr(start + 1, '>')) != NULL)
+
+	for (;;)
 	{
+	    start = vim_strchr(p, '<');
+	    if (start != NULL)
+		end = vim_strchr(start + 1, '>');
+	    if (buf != NULL)
+	    {
+		ksp = vim_strchr(p, K_SPECIAL);
+		if (ksp != NULL && (start == NULL || ksp < start || end == NULL)
+			&& ((ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER)
+# ifdef FEAT_GUI
+			    || (ksp[1] == KS_EXTRA && ksp[2] == (int)KE_CSI)
+# endif
+			    ))
+		{
+		    /* K_SPECIAL han been put in the buffer as K_SPECIAL
+		     * KS_SPECIAL KE_FILLER, like for mappings, but
+		     * do_cmdline() doesn't handle that, so convert it back.
+		     * Also change K_SPECIAL KS_EXTRA KE_CSI into CSI. */
+		    len = ksp - p;
+		    if (len > 0)
+		    {
+			mch_memmove(q, p, len);
+			q += len;
+		    }
+		    *q++ = ksp[1] == KS_SPECIAL ? K_SPECIAL : CSI;
+		    p = ksp + 3;
+		    continue;
+		}
+	    }
+
+	    /* break if there no <item> is found */
+	    if (start == NULL || end == NULL)
+		break;
+
 	    /* Include the '>' */
 	    ++end;
 
 	    /* Take everything up to the '<' */
 	    len = start - p;
@@ -6001,14 +6080,13 @@ get_user_command_name(idx)
 }
 
 /*
  * Function given to ExpandGeneric() to obtain the list of user command names.
  */
-/*ARGSUSED*/
     char_u *
 get_user_commands(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     if (idx < curbuf->b_ucmds.ga_len)
 	return USER_CMD_GA(&curbuf->b_ucmds, idx)->uc_name;
     idx -= curbuf->b_ucmds.ga_len;
@@ -6019,48 +6097,45 @@ get_user_commands(xp, idx)
 
 /*
  * Function given to ExpandGeneric() to obtain the list of user command
  * attributes.
  */
-/*ARGSUSED*/
     char_u *
 get_user_cmd_flags(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     static char *user_cmd_flags[] =
 	{"bang", "bar", "buffer", "complete", "count",
 	    "nargs", "range", "register"};
 
-    if (idx >= sizeof(user_cmd_flags) / sizeof(user_cmd_flags[0]))
+    if (idx >= (int)(sizeof(user_cmd_flags) / sizeof(user_cmd_flags[0])))
 	return NULL;
     return (char_u *)user_cmd_flags[idx];
 }
 
 /*
  * Function given to ExpandGeneric() to obtain the list of values for -nargs.
  */
-/*ARGSUSED*/
     char_u *
 get_user_cmd_nargs(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     static char *user_cmd_nargs[] = {"0", "1", "*", "?", "+"};
 
-    if (idx >= sizeof(user_cmd_nargs) / sizeof(user_cmd_nargs[0]))
+    if (idx >= (int)(sizeof(user_cmd_nargs) / sizeof(user_cmd_nargs[0])))
 	return NULL;
     return (char_u *)user_cmd_nargs[idx];
 }
 
 /*
  * Function given to ExpandGeneric() to obtain the list of values for -complete.
  */
-/*ARGSUSED*/
     char_u *
 get_user_cmd_complete(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     return (char_u *)command_complete[idx].name;
 }
 # endif /* FEAT_CMDL_COMPL */
@@ -6234,14 +6309,13 @@ ex_quit(eap)
 }
 
 /*
  * ":cquit".
  */
-/*ARGSUSED*/
     static void
 ex_cquit(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     getout(1);	/* this does not always pass on the exit code to the Manx
 		   compiler. why? */
 }
 
@@ -6679,14 +6753,13 @@ ex_goto(eap)
 #endif
 
 /*
  * ":shell".
  */
-/*ARGSUSED*/
     static void
 ex_shell(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     do_shell(NULL, 0);
 }
 
 #if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) \
@@ -6986,14 +7059,13 @@ alist_slash_adjust()
 #endif
 
 /*
  * ":preserve".
  */
-/*ARGSUSED*/
     static void
 ex_preserve(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     curbuf->b_flags |= BF_PRESERVED;
     ml_preserve(curbuf, TRUE);
 }
 
@@ -7221,14 +7293,13 @@ ex_tabmove(eap)
 }
 
 /*
  * :tabs command: List tabs and their contents.
  */
-/*ARGSUSED*/
     static void
 ex_tabs(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     tabpage_T	*tp;
     win_T	*wp;
     int		tabcount = 1;
 
@@ -7411,11 +7482,10 @@ ex_edit(eap)
 }
 
 /*
  * ":edit <file>" command and alikes.
  */
-/*ARGSUSED*/
     void
 do_exedit(eap, old_curwin)
     exarg_T	*eap;
     win_T	*old_curwin;	    /* curwin before doing a split or NULL */
 {
@@ -7483,11 +7553,12 @@ do_exedit(eap, old_curwin)
 		) && *eap->arg == NUL)
     {
 	/* ":new" or ":tabnew" without argument: edit an new empty buffer */
 	setpcmark();
 	(void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE,
-			       ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0));
+		      ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0),
+		      old_curwin == NULL ? curwin : NULL);
     }
     else if ((eap->cmdidx != CMD_split
 #ifdef FEAT_VERTSPLIT
 		&& eap->cmdidx != CMD_vsplit
 #endif
@@ -7520,11 +7591,11 @@ do_exedit(eap, old_curwin)
 		    (P_HID(curbuf) ? ECMD_HIDE : 0)
 		    + (eap->forceit ? ECMD_FORCEIT : 0)
 #ifdef FEAT_LISTCMDS
 		    + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 )
 #endif
-		    ) == FAIL)
+		    , old_curwin == NULL ? curwin : NULL) == FAIL)
 	{
 	    /* Editing the file failed.  If the window was split, close it. */
 #ifdef FEAT_WINDOWS
 	    if (old_curwin != NULL)
 	    {
@@ -7622,14 +7693,13 @@ ex_popup(eap)
 {
     gui_make_popup(eap->arg, eap->forceit);
 }
 #endif
 
-/*ARGSUSED*/
     static void
 ex_swapname(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     if (curbuf->b_ml.ml_mfp == NULL || curbuf->b_ml.ml_mfp->mf_fname == NULL)
 	MSG(_("No swap file"));
     else
 	msg(curbuf->b_ml.ml_mfp->mf_fname);
@@ -7638,14 +7708,13 @@ ex_swapname(eap)
 /*
  * ":syncbind" forces all 'scrollbind' windows to have the same relative
  * offset.
  * (1998-11-02 16:21:01  R. Edward Ralston <eralston@computer.org>)
  */
-/*ARGSUSED*/
     static void
 ex_syncbind(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
 #ifdef FEAT_SCROLLBIND
     win_T	*wp;
     long	topline;
     long	y;
@@ -7782,14 +7851,14 @@ ex_read(eap)
 		else
 		    lnum = 1;
 		if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK)
 		{
 		    ml_delete(lnum, FALSE);
-		    deleted_lines_mark(lnum, 1L);
 		    if (curwin->w_cursor.lnum > 1
 					     && curwin->w_cursor.lnum >= lnum)
 			--curwin->w_cursor.lnum;
+		    deleted_lines_mark(lnum, 1L);
 		}
 	    }
 	    redraw_curbuf_later(VALID);
 	}
     }
@@ -7801,10 +7870,13 @@ static char_u	*prev_dir = NULL;
     void
 free_cd_dir()
 {
     vim_free(prev_dir);
     prev_dir = NULL;
+
+    vim_free(globaldir);
+    globaldir = NULL;
 }
 #endif
 
 
 /*
@@ -7823,10 +7895,14 @@ ex_cd(eap)
     if (*new_dir == NUL)
 	ex_pwd(NULL);
     else
 #endif
     {
+#ifdef FEAT_AUTOCMD
+	if (allbuf_locked())
+	    return;
+#endif
 	if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged()
 							     && !eap->forceit)
 	{
 	    EMSG(_("E747: Cannot change directory, buffer is modified (add ! to override)"));
 	    return;
@@ -7894,24 +7970,23 @@ ex_cd(eap)
 	    }
 
 	    shorten_fnames(TRUE);
 
 	    /* Echo the new current directory if the command was typed. */
-	    if (KeyTyped)
+	    if (KeyTyped || p_verbose >= 5)
 		ex_pwd(eap);
 	}
 	vim_free(tofree);
     }
 }
 
 /*
  * ":pwd".
  */
-/*ARGSUSED*/
     static void
 ex_pwd(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     if (mch_dirname(NameBuff, MAXPATHL) == OK)
     {
 #ifdef BACKSLASH_IN_FILENAME
 	slash_adjust(NameBuff);
@@ -8289,10 +8364,11 @@ ex_join(eap)
     static void
 ex_at(eap)
     exarg_T	*eap;
 {
     int		c;
+    int		prev_len = typebuf.tb_len;
 
     curwin->w_cursor.lnum = eap->line2;
 
 #ifdef USE_ON_FLY_SCROLL
     dont_scroll = TRUE;		/* disallow scrolling here */
@@ -8314,15 +8390,14 @@ ex_at(eap)
 
 	exec_from_reg = TRUE;
 
 	/*
 	 * Execute from the typeahead buffer.
-	 * Originally this didn't check for the typeahead buffer to be empty,
-	 * thus could read more Ex commands from stdin.  It's not clear why,
-	 * it is certainly unexpected.
+	 * Continue until the stuff buffer is empty and all added characters
+	 * have been consumed.
 	 */
-	while ((!stuff_empty() || typebuf.tb_len > 0) && vpeekc() == ':')
+	while (!stuff_empty() || typebuf.tb_len > prev_len)
 	    (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
 
 	exec_from_reg = save_efr;
     }
 }
@@ -8338,36 +8413,33 @@ ex_bang(eap)
 }
 
 /*
  * ":undo".
  */
-/*ARGSUSED*/
     static void
 ex_undo(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     if (eap->addr_count == 1)	    /* :undo 123 */
 	undo_time(eap->line2, FALSE, TRUE);
     else
 	u_undo(1);
 }
 
 /*
  * ":redo".
  */
-/*ARGSUSED*/
     static void
 ex_redo(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     u_redo(1);
 }
 
 /*
  * ":earlier" and ":later".
  */
-/*ARGSUSED*/
     static void
 ex_later(eap)
     exarg_T	*eap;
 {
     long	count = 0;
@@ -8548,14 +8620,13 @@ ex_redraw(eap)
 }
 
 /*
  * ":redrawstatus": force redraw of status line(s)
  */
-/*ARGSUSED*/
     static void
 ex_redrawstatus(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
 #if defined(FEAT_WINDOWS)
     int		r = RedrawingDisabled;
     int		p = p_lz;
 
@@ -8628,10 +8699,12 @@ ex_mkrc(eap)
 	return;
 #endif
     }
 
 #ifdef FEAT_SESSION
+    /* Use the short file name until ":lcd" is used.  We also don't use the
+     * short file name when 'acd' is set, that is checked later. */
     did_lcd = FALSE;
 
     /* ":mkview" or ":mkview 9": generate file name with 'viewdir' */
     if (eap->cmdidx == CMD_mkview
 	    && (*eap->arg == NUL
@@ -8747,12 +8820,12 @@ ex_mkrc(eap)
 			shorten_fnames(TRUE);
 		}
 		else if (*dirnow != NUL
 			&& (ssop_flags & SSOP_CURDIR) && globaldir != NULL)
 		{
-		    (void)mch_chdir((char *)globaldir);
-		    shorten_fnames(TRUE);
+		    if (mch_chdir((char *)globaldir) == 0)
+			shorten_fnames(TRUE);
 		}
 
 		failed |= (makeopens(fd, dirnow) == FAIL);
 
 		/* restore original dir */
@@ -8812,15 +8885,14 @@ theend:
 #endif
 }
 
 #if ((defined(FEAT_SESSION) || defined(FEAT_EVAL)) && defined(vim_mkdir)) \
 	|| defined(PROTO)
-/*ARGSUSED*/
     int
 vim_mkdir_emsg(name, prot)
     char_u	*name;
-    int		prot;
+    int		prot UNUSED;
 {
     if (vim_mkdir(name, prot) != 0)
     {
 	EMSG2(_("E739: Cannot create directory: %s"), name);
 	return FAIL;
@@ -9087,14 +9159,13 @@ ex_startinsert(eap)
 }
 
 /*
  * ":stopinsert"
  */
-/*ARGSUSED*/
     static void
 ex_stopinsert(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     restart_edit = 0;
     stop_insert_mode = TRUE;
 }
 #endif
@@ -9364,13 +9435,12 @@ find_cmdline_var(src, usedlen)
 #ifdef FEAT_CLIENTSERVER
 		    "<client>"
 # define SPEC_CLIENT 9
 #endif
     };
-#define SPEC_COUNT  (sizeof(spec_str) / sizeof(char *))
 
-    for (i = 0; i < SPEC_COUNT; ++i)
+    for (i = 0; i < (int)(sizeof(spec_str) / sizeof(char *)); ++i)
     {
 	len = (int)STRLEN(spec_str[i]);
 	if (STRNCMP(src, spec_str[i], len) == 0)
 	{
 	    *usedlen = len;
@@ -9504,28 +9574,54 @@ eval_vars(src, srcstart, usedlen, lnump,
 		    skip_mod = TRUE;
 #endif
 		    break;
 		}
 		s = src + 1;
+		if (*s == '<')		/* "#<99" uses v:oldfiles */
+		    ++s;
 		i = (int)getdigits(&s);
 		*usedlen = (int)(s - src); /* length of what we expand */
 
-		buf = buflist_findnr(i);
-		if (buf == NULL)
+		if (src[1] == '<')
 		{
-		    *errormsg = (char_u *)_("E194: No alternate file name to substitute for '#'");
+		    if (*usedlen < 2)
+		    {
+			/* Should we give an error message for #<text? */
+			*usedlen = 1;
+			return NULL;
+		    }
+#ifdef FEAT_EVAL
+		    result = list_find_str(get_vim_var_list(VV_OLDFILES),
+								     (long)i);
+		    if (result == NULL)
+		    {
+			*errormsg = (char_u *)"";
+			return NULL;
+		    }
+#else
+		    *errormsg = (char_u *)_("E809: #< is not available without the +eval feature");
 		    return NULL;
+#endif
 		}
-		if (lnump != NULL)
-		    *lnump = ECMD_LAST;
-		if (buf->b_fname == NULL)
+		else
 		{
-		    result = (char_u *)"";
-		    valid = 0;	    /* Must have ":p:h" to be valid */
+		    buf = buflist_findnr(i);
+		    if (buf == NULL)
+		    {
+			*errormsg = (char_u *)_("E194: No alternate file name to substitute for '#'");
+			return NULL;
+		    }
+		    if (lnump != NULL)
+			*lnump = ECMD_LAST;
+		    if (buf->b_fname == NULL)
+		    {
+			result = (char_u *)"";
+			valid = 0;	    /* Must have ":p:h" to be valid */
+		    }
+		    else
+			result = buf->b_fname;
 		}
-		else
-		    result = buf->b_fname;
 		break;
 
 #ifdef FEAT_SEARCHPATH
 	case SPEC_CFILE:	/* file name under cursor */
 		result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);
@@ -9539,10 +9635,19 @@ eval_vars(src, srcstart, usedlen, lnump,
 #endif
 
 #ifdef FEAT_AUTOCMD
 	case SPEC_AFILE:	/* file name for autocommand */
 		result = autocmd_fname;
+		if (result != NULL && !autocmd_fname_full)
+		{
+		    /* Still need to turn the fname into a full path.  It is
+		     * postponed to avoid a delay when <afile> is not used. */
+		    autocmd_fname_full = TRUE;
+		    result = FullName_save(autocmd_fname, FALSE);
+		    vim_free(autocmd_fname);
+		    autocmd_fname = result;
+		}
 		if (result == NULL)
 		{
 		    *errormsg = (char_u *)_("E495: no autocommand file name to substitute for \"<afile>\"");
 		    return NULL;
 		}
@@ -9682,11 +9787,11 @@ arg_all()
 	    retval[len] = NUL;
 	    break;
 	}
 
 	/* allocate memory */
-	retval = alloc(len + 1);
+	retval = alloc((unsigned)len + 1);
 	if (retval == NULL)
 	    break;
     }
 
     return retval;
@@ -10065,11 +10170,11 @@ makeopens(fd, dirnow)
     /*
      * Lastly, execute the x.vim file if it exists.
      */
     if (put_line(fd, "let s:sx = expand(\"<sfile>:p:r\").\"x.vim\"") == FAIL
 	    || put_line(fd, "if file_readable(s:sx)") == FAIL
-	    || put_line(fd, "  exe \"source \" . s:sx") == FAIL
+	    || put_line(fd, "  exe \"source \" . fnameescape(s:sx)") == FAIL
 	    || put_line(fd, "endif") == FAIL)
 	return FAIL;
 
     return OK;
 }
@@ -10483,10 +10588,13 @@ ses_fname(fd, buf, flagp)
      * Don't do this after ":lcd", we don't keep track of what the current
      * directory is. */
     if (buf->b_sfname != NULL
 	    && flagp == &ssop_flags
 	    && (ssop_flags & (SSOP_CURDIR | SSOP_SESDIR))
+#ifdef FEAT_AUTOCHDIR
+	    && !p_acd
+#endif
 	    && !did_lcd)
 	name = buf->b_sfname;
     else
 	name = buf->b_ffname;
     if (ses_put_fname(fd, name, flagp) == FAIL || put_eol(fd) == FAIL)
@@ -10687,11 +10795,12 @@ ex_viminfo(eap)
     save_viminfo = p_viminfo;
     if (*p_viminfo == NUL)
 	p_viminfo = (char_u *)"'100";
     if (eap->cmdidx == CMD_rviminfo)
     {
-	if (read_viminfo(eap->arg, TRUE, TRUE, eap->forceit) == FAIL)
+	if (read_viminfo(eap->arg, VIF_WANT_INFO | VIF_WANT_MARKS
+				  | (eap->forceit ? VIF_FORCEIT : 0)) == FAIL)
 	    EMSG(_("E195: Cannot open viminfo file for reading"));
     }
     else
 	write_viminfo(eap->arg, eap->forceit);
     p_viminfo = save_viminfo;
@@ -10739,10 +10848,28 @@ ex_behave(eap)
     }
     else
 	EMSG2(_(e_invarg2), eap->arg);
 }
 
+#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
+/*
+ * Function given to ExpandGeneric() to obtain the possible arguments of the
+ * ":behave {mswin,xterm}" command.
+ */
+    char_u *
+get_behave_arg(xp, idx)
+    expand_T	*xp UNUSED;
+    int		idx;
+{
+    if (idx == 0)
+	return (char_u *)"mswin";
+    if (idx == 1)
+	return (char_u *)"xterm";
+    return NULL;
+}
+#endif
+
 #ifdef FEAT_AUTOCMD
 static int filetype_detect = FALSE;
 static int filetype_plugin = FALSE;
 static int filetype_indent = FALSE;
 
@@ -10848,14 +10975,13 @@ ex_setfiletype(eap)
     if (!did_filetype)
 	set_option_value((char_u *)"filetype", 0L, eap->arg, OPT_LOCAL);
 }
 #endif
 
-/*ARGSUSED*/
     static void
 ex_digraphs(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
 #ifdef FEAT_DIGRAPHS
     if (*eap->arg != NUL)
 	putdigraph(eap->arg);
     else
@@ -10885,14 +11011,13 @@ ex_set(eap)
 
 #ifdef FEAT_SEARCH_EXTRA
 /*
  * ":nohlsearch"
  */
-/*ARGSUSED*/
     static void
 ex_nohlsearch(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     no_hlsearch = TRUE;
     redraw_all_later(SOME_VALID);
 }
 
@@ -10967,14 +11092,13 @@ ex_match(eap)
 
 #ifdef FEAT_CRYPT
 /*
  * ":X": Get crypt key
  */
-/*ARGSUSED*/
     static void
 ex_X(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     (void)get_crypt_key(TRUE, TRUE);
 }
 #endif
 
--- vim72.orig/src/ex_eval.c
+++ vim72/src/ex_eval.c
@@ -58,11 +58,13 @@ static char_u	*get_end_emsg __ARGS((stru
 # define THROW_ON_INTERRUPT	(!eval_to_number("$VIMNOINTTHROW"))
 # define THROW_TEST
 #else
 /* Values used for the Vim release. */
 # define THROW_ON_ERROR		TRUE
+# define THROW_ON_ERROR_TRUE
 # define THROW_ON_INTERRUPT	TRUE
+# define THROW_ON_INTERRUPT_TRUE
 #endif
 
 static void	catch_exception __ARGS((except_T *excp));
 static void	finish_exception __ARGS((except_T *excp));
 static void	discard_exception __ARGS((except_T *excp, int was_finished));
@@ -1318,20 +1320,24 @@ do_throw(cstack)
      * if a previous error or interrupt has not been converted to an exception,
      * inactivate the try conditional, too, as if the conversion had been done,
      * and reset the did_emsg or got_int flag, so this won't happen again at
      * the next surrounding try conditional.
      */
+#ifndef THROW_ON_ERROR_TRUE
     if (did_emsg && !THROW_ON_ERROR)
     {
 	inactivate_try = TRUE;
 	did_emsg = FALSE;
     }
+#endif
+#ifndef THROW_ON_INTERRUPT_TRUE
     if (got_int && !THROW_ON_INTERRUPT)
     {
 	inactivate_try = TRUE;
 	got_int = FALSE;
     }
+#endif
     idx = cleanup_conditionals(cstack, 0, inactivate_try);
     if (idx >= 0)
     {
 	/*
 	 * If this try conditional is active and we are before its first
@@ -2252,14 +2258,13 @@ rewind_conditionals(cstack, idx, cond_ty
 }
 
 /*
  * ":endfunction" when not after a ":function"
  */
-/*ARGSUSED*/
     void
 ex_endfunction(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     EMSG(_("E193: :endfunction not inside a function"));
 }
 
 /*
--- vim72.orig/src/ex_getln.c
+++ vim72/src/ex_getln.c
@@ -29,18 +29,24 @@ struct cmdline_info
     int		cmdindent;	/* number of spaces before cmdline */
     char_u	*cmdprompt;	/* message in front of cmdline */
     int		cmdattr;	/* attributes for prompt */
     int		overstrike;	/* Typing mode on the command line.  Shared by
 				   getcmdline() and put_on_cmdline(). */
+    expand_T	*xpc;		/* struct being used for expansion, xp_pattern
+				   may point into cmdbuff */
     int		xp_context;	/* type of expansion */
 # ifdef FEAT_EVAL
     char_u	*xp_arg;	/* user-defined expansion arg */
     int		input_fn;	/* when TRUE Invoked for input() function */
 # endif
 };
 
-static struct cmdline_info ccline;	/* current cmdline_info */
+/* The current cmdline_info.  It is initialized in getcmdline() and after that
+ * used by other functions.  When invoking getcmdline() recursively it needs
+ * to be saved with save_cmdline() and restored with restore_cmdline().
+ * TODO: make it local to getcmdline() and pass it around. */
+static struct cmdline_info ccline;
 
 static int	cmd_showtail;		/* Only show path tail in lists ? */
 
 #ifdef FEAT_EVAL
 static int	new_cmdpos;	/* position set by set_cmdline_pos() */
@@ -132,15 +138,14 @@ static int	ex_window __ARGS((void));
  * Careful: getcmdline() can be called recursively!
  *
  * Return pointer to allocated string if there is a commandline, NULL
  * otherwise.
  */
-/*ARGSUSED*/
     char_u *
 getcmdline(firstc, count, indent)
     int		firstc;
-    long	count;		/* only used for incremental search */
+    long	count UNUSED;	/* only used for incremental search */
     int		indent;		/* indent for inside conditionals */
 {
     int		c;
     int		i;
     int		j;
@@ -236,10 +241,11 @@ getcmdline(firstc, count, indent)
 	ccline.cmdspos = indent;
 	ccline.cmdlen = indent;
     }
 
     ExpandInit(&xpc);
+    ccline.xpc = &xpc;
 
 #ifdef FEAT_RIGHTLEFT
     if (curwin->w_p_rl && *curwin->w_p_rlc == 's'
 					  && (firstc == '/' || firstc == '?'))
 	cmdmsg_rl = TRUE;
@@ -316,11 +322,11 @@ getcmdline(firstc, count, indent)
     hiscnt = hislen;		/* set hiscnt to impossible history value */
     histype = hist_char2type(firstc);
 #endif
 
 #ifdef FEAT_DIGRAPHS
-    do_digraph(-1);		/* init digraph typahead */
+    do_digraph(-1);		/* init digraph typeahead */
 #endif
 
     /*
      * Collect the command string, handling editing keys.
      */
@@ -406,13 +412,14 @@ getcmdline(firstc, count, indent)
 	    lookfor = NULL;
 	}
 #endif
 
 	/*
-	 * <S-Tab> works like CTRL-P (unless 'wc' is <S-Tab>).
+	 * When there are matching completions to select <S-Tab> works like
+	 * CTRL-P (unless 'wc' is <S-Tab>).
 	 */
-	if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles != -1)
+	if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles > 0)
 	    c = Ctrl_P;
 
 #ifdef FEAT_WILDMENU
 	/* Special translations for 'wildmenu' */
 	if (did_wild_list && p_wmnu)
@@ -1511,10 +1518,11 @@ getcmdline(firstc, count, indent)
 		    char_u	*p;
 		    int		len;
 		    int		old_firstc;
 
 		    vim_free(ccline.cmdbuff);
+		    xpc.xp_context = EXPAND_NOTHING;
 		    if (hiscnt == hislen)
 			p = lookfor;	/* back to the old one */
 		    else
 			p = history[histype][hiscnt].hisstr;
 
@@ -1837,10 +1845,11 @@ returncmd:
 #ifdef FEAT_FKMAP
     cmd_fkmap = 0;
 #endif
 
     ExpandCleanup(&xpc);
+    ccline.xpc = NULL;
 
 #ifdef FEAT_SEARCH_EXTRA
     if (did_incsearch)
     {
 	curwin->w_cursor = old_cursor;
@@ -1988,21 +1997,36 @@ text_locked_msg()
 	EMSG(_(e_secure));
 }
 
 #if defined(FEAT_AUTOCMD) || defined(PROTO)
 /*
- * Check if "curbuf_lock" is set and return TRUE when it is and give an error
- * message.
+ * Check if "curbuf_lock" or "allbuf_lock" is set and return TRUE when it is
+ * and give an error message.
  */
     int
 curbuf_locked()
 {
     if (curbuf_lock > 0)
     {
 	EMSG(_("E788: Not allowed to edit another buffer now"));
 	return TRUE;
     }
+    return allbuf_locked();
+}
+
+/*
+ * Check if "allbuf_lock" is set and return TRUE when it is and give an error
+ * message.
+ */
+    int
+allbuf_locked()
+{
+    if (allbuf_lock > 0)
+    {
+	EMSG(_("E811: Not allowed to change buffer information now"));
+	return TRUE;
+    }
     return FALSE;
 }
 #endif
 
     static int
@@ -2086,15 +2110,14 @@ correct_cmdspos(idx, cells)
 #endif
 
 /*
  * Get an Ex command line for the ":" command.
  */
-/* ARGSUSED */
     char_u *
-getexline(c, dummy, indent)
+getexline(c, cookie, indent)
     int		c;		/* normally ':', NUL for ":append" */
-    void	*dummy;		/* cookie not used */
+    void	*cookie UNUSED;
     int		indent;		/* indent for inside conditionals */
 {
     /* When executing a register, remove ':' that's in front of each line. */
     if (exec_from_reg && vpeekc() == ':')
 	(void)vgetc();
@@ -2105,16 +2128,15 @@ getexline(c, dummy, indent)
  * Get an Ex command line for Ex mode.
  * In Ex mode we only use the OS supplied line editing features and no
  * mappings or abbreviations.
  * Returns a string in allocated memory or NULL.
  */
-/* ARGSUSED */
     char_u *
-getexmodeline(promptc, dummy, indent)
+getexmodeline(promptc, cookie, indent)
     int		promptc;	/* normally ':', NUL for ":append" and '?' for
 				   :s prompt */
-    void	*dummy;		/* cookie not used */
+    void	*cookie UNUSED;
     int		indent;		/* indent for inside conditionals */
 {
     garray_T	line_ga;
     char_u	*pend;
     int		startcol = 0;
@@ -2169,11 +2191,10 @@ getexmodeline(promptc, dummy, indent)
     got_int = FALSE;
     while (!got_int)
     {
 	if (ga_grow(&line_ga, 40) == FAIL)
 	    break;
-	pend = (char_u *)line_ga.ga_data + line_ga.ga_len;
 
 	/* Get one character at a time.  Don't use inchar(), it can't handle
 	 * special characters. */
 	prev_char = c1;
 	c1 = vgetc();
@@ -2506,10 +2527,24 @@ realloc_cmdbuff(len)
 	ccline.cmdbuff = p;		/* keep the old one */
 	return FAIL;
     }
     mch_memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen + 1);
     vim_free(p);
+
+    if (ccline.xpc != NULL
+	    && ccline.xpc->xp_pattern != NULL
+	    && ccline.xpc->xp_context != EXPAND_NOTHING
+	    && ccline.xpc->xp_context != EXPAND_UNSUCCESSFUL)
+    {
+	int i = (int)(ccline.xpc->xp_pattern - p);
+
+	/* If xp_pattern points inside the old cmdbuff it needs to be adjusted
+	 * to point into the newly allocated memory. */
+	if (i >= 0 && i <= ccline.cmdlen)
+	    ccline.xpc->xp_pattern = ccline.cmdbuff + i;
+    }
+
     return OK;
 }
 
 #if defined(FEAT_ARABIC) || defined(PROTO)
 static char_u	*arshape_buf = NULL;
@@ -2873,10 +2908,11 @@ save_cmdline(ccp)
     }
     *ccp = prev_ccline;
     prev_ccline = ccline;
     ccline.cmdbuff = NULL;
     ccline.cmdprompt = NULL;
+    ccline.xpc = NULL;
 }
 
 /*
  * Restore ccline after it has been saved with save_cmdline().
  */
@@ -3227,11 +3263,10 @@ nextwild(xp, type, options)
     int		options;	/* extra options for ExpandOne() */
 {
     int		i, j;
     char_u	*p1;
     char_u	*p2;
-    int		oldlen;
     int		difflen;
     int		v;
 
     if (xp->xp_numfiles == -1)
     {
@@ -3252,11 +3287,11 @@ nextwild(xp, type, options)
 
     MSG_PUTS("...");	    /* show that we are busy */
     out_flush();
 
     i = (int)(xp->xp_pattern - ccline.cmdbuff);
-    oldlen = ccline.cmdpos - i;
+    xp->xp_pattern_len = ccline.cmdpos - i;
 
     if (type == WILD_NEXT || type == WILD_PREV)
     {
 	/*
 	 * Get next/previous match for a previous expanded pattern.
@@ -3266,22 +3301,24 @@ nextwild(xp, type, options)
     else
     {
 	/*
 	 * Translate string into pattern and expand it.
 	 */
-	if ((p1 = addstar(&ccline.cmdbuff[i], oldlen, xp->xp_context)) == NULL)
+	if ((p1 = addstar(xp->xp_pattern, xp->xp_pattern_len,
+						     xp->xp_context)) == NULL)
 	    p2 = NULL;
 	else
 	{
-	    p2 = ExpandOne(xp, p1, vim_strnsave(&ccline.cmdbuff[i], oldlen),
+	    p2 = ExpandOne(xp, p1,
+			 vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len),
 		    WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE
 							      |options, type);
 	    vim_free(p1);
-	    /* longest match: make sure it is not shorter (happens with :help */
+	    /* longest match: make sure it is not shorter, happens with :help */
 	    if (p2 != NULL && type == WILD_LONGEST)
 	    {
-		for (j = 0; j < oldlen; ++j)
+		for (j = 0; j < xp->xp_pattern_len; ++j)
 		     if (ccline.cmdbuff[i + j] == '*'
 			     || ccline.cmdbuff[i + j] == '?')
 			 break;
 		if ((int)STRLEN(p2) < j)
 		{
@@ -3292,11 +3329,11 @@ nextwild(xp, type, options)
 	}
     }
 
     if (p2 != NULL && !got_int)
     {
-	difflen = (int)STRLEN(p2) - oldlen;
+	difflen = (int)STRLEN(p2) - xp->xp_pattern_len;
 	if (ccline.cmdlen + difflen > ccline.cmdbufflen - 4)
 	{
 	    v = realloc_cmdbuff(ccline.cmdlen + difflen);
 	    xp->xp_pattern = ccline.cmdbuff + i;
 	}
@@ -3580,10 +3617,12 @@ ExpandOne(xp, str, orig, options, mode)
  */
     void
 ExpandInit(xp)
     expand_T	*xp;
 {
+    xp->xp_pattern = NULL;
+    xp->xp_pattern_len = 0;
     xp->xp_backslash = XP_BS_NONE;
 #ifndef BACKSLASH_IN_FILENAME
     xp->xp_shell = FALSE;
 #endif
     xp->xp_numfiles = -1;
@@ -3789,15 +3828,14 @@ tilde_replace(orig_pat, num_files, files
 /*
  * Show all matches for completion on the command line.
  * Returns EXPAND_NOTHING when the character that triggered expansion should
  * be inserted like a normal character.
  */
-/*ARGSUSED*/
     static int
 showmatches(xp, wildmenu)
     expand_T	*xp;
-    int		wildmenu;
+    int		wildmenu UNUSED;
 {
 #define L_SHOWFILE(m) (showtail ? sm_gettail(files_found[m]) : files_found[m])
     int		num_files;
     char_u	**files_found;
     int		i, j, k;
@@ -3908,12 +3946,30 @@ showmatches(xp, wildmenu)
 		    msg_putchar(' ');
 		if (xp->xp_context == EXPAND_FILES
 					  || xp->xp_context == EXPAND_SHELLCMD
 					  || xp->xp_context == EXPAND_BUFFERS)
 		{
-			    /* highlight directories */
-		    j = (mch_isdir(files_found[k]));
+		    /* highlight directories */
+		    if (xp->xp_numfiles != -1)
+		    {
+			char_u	*halved_slash;
+			char_u	*exp_path;
+
+			/* Expansion was done before and special characters
+			 * were escaped, need to halve backslashes.  Also
+			 * $HOME has been replaced with ~/. */
+			exp_path = expand_env_save_opt(files_found[k], TRUE);
+			halved_slash = backslash_halve_save(
+				exp_path != NULL ? exp_path : files_found[k]);
+			j = mch_isdir(halved_slash != NULL ? halved_slash
+							    : files_found[k]);
+			vim_free(exp_path);
+			vim_free(halved_slash);
+		    }
+		    else
+			/* Expansion was done here, file names are literal. */
+			j = mch_isdir(files_found[k]);
 		    if (showtail)
 			p = L_SHOWFILE(k);
 		    else
 		    {
 			home_replace(NULL, files_found[k], NameBuff, MAXPATHL,
@@ -4272,12 +4328,12 @@ expand_cmdline(xp, str, col, matchcount,
 	/* Caller can use the character as a normal char instead */
 	return EXPAND_NOTHING;
     }
 
     /* add star to file name, or convert to regexp if not exp. files. */
-    file_str = addstar(xp->xp_pattern,
-			   (int)(str + col - xp->xp_pattern), xp->xp_context);
+    xp->xp_pattern_len = (int)(str + col - xp->xp_pattern);
+    file_str = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
     if (file_str == NULL)
 	return EXPAND_UNSUCCESSFUL;
 
     /* find all files that match the description */
     if (ExpandFromContext(xp, file_str, matchcount, matches,
@@ -4381,11 +4437,12 @@ ExpandFromContext(xp, pat, num_file, fil
 
 	if (xp->xp_context == EXPAND_FILES)
 	    flags |= EW_FILE;
 	else
 	    flags = (flags | EW_DIR) & ~EW_FILE;
-	ret = expand_wildcards(1, &pat, num_file, file, flags);
+	/* Expand wildcards, supporting %:h and the like. */
+	ret = expand_wildcards_eval(&pat, num_file, file, flags);
 	if (free_pat)
 	    vim_free(pat);
 	return ret;
     }
 
@@ -4451,10 +4508,11 @@ ExpandFromContext(xp, pat, num_file, fil
 	    char_u	*((*func)__ARGS((expand_T *, int)));
 	    int		ic;
 	} tab[] =
 	{
 	    {EXPAND_COMMANDS, get_command_name, FALSE},
+	    {EXPAND_BEHAVE, get_behave_arg, TRUE},
 #ifdef FEAT_USR_CMDS
 	    {EXPAND_USER_COMMANDS, get_user_commands, FALSE},
 	    {EXPAND_USER_CMD_FLAGS, get_user_cmd_flags, FALSE},
 	    {EXPAND_USER_NARGS, get_user_cmd_nargs, FALSE},
 	    {EXPAND_USER_COMPLETE, get_user_cmd_complete, FALSE},
@@ -4475,10 +4533,19 @@ ExpandFromContext(xp, pat, num_file, fil
 	    {EXPAND_HIGHLIGHT, get_highlight_name, TRUE},
 #ifdef FEAT_AUTOCMD
 	    {EXPAND_EVENTS, get_event_name, TRUE},
 	    {EXPAND_AUGROUP, get_augroup_name, TRUE},
 #endif
+#ifdef FEAT_CSCOPE
+	    {EXPAND_CSCOPE, get_cscope_name, TRUE},
+#endif
+#ifdef FEAT_SIGNS
+	    {EXPAND_SIGN, get_sign_name, TRUE},
+#endif
+#ifdef FEAT_PROFILE
+	    {EXPAND_PROFILE, get_profile_name, TRUE},
+#endif
 #if (defined(HAVE_LOCALE_H) || defined(X_LOCALE)) \
 	&& (defined(FEAT_GETTEXT) || defined(FEAT_MBYTE))
 	    {EXPAND_LANGUAGE, get_lang_arg, TRUE},
 #endif
 	    {EXPAND_ENV_VARS, get_env_name, TRUE},
@@ -4488,11 +4555,11 @@ ExpandFromContext(xp, pat, num_file, fil
 	/*
 	 * Find a context in the table and call the ExpandGeneric() with the
 	 * right function to do the expansion.
 	 */
 	ret = FAIL;
-	for (i = 0; i < sizeof(tab) / sizeof(struct expgen); ++i)
+	for (i = 0; i < (int)(sizeof(tab) / sizeof(struct expgen)); ++i)
 	    if (xp->xp_context == tab[i].context)
 	    {
 		if (tab[i].ic)
 		    regmatch.rm_ic = TRUE;
 		ret = ExpandGeneric(xp, &regmatch, num_file, file, tab[i].func);
@@ -4736,11 +4803,11 @@ call_user_expand_func(user_expand_func,
 	keep = ccline.cmdbuff[ccline.cmdlen];
 	ccline.cmdbuff[ccline.cmdlen] = 0;
 	sprintf((char *)num, "%d", ccline.cmdpos);
 	args[1] = ccline.cmdbuff;
     }
-    args[0] = xp->xp_pattern;
+    args[0] = vim_strnsave(xp->xp_pattern, xp->xp_pattern_len);
     args[2] = num;
 
     /* Save the cmdline, we don't know what the function may do. */
     save_ccline = ccline;
     ccline.cmdbuff = NULL;
@@ -4752,10 +4819,11 @@ call_user_expand_func(user_expand_func,
     ccline = save_ccline;
     current_SID = save_current_SID;
     if (ccline.cmdbuff != NULL)
 	ccline.cmdbuff[ccline.cmdlen] = keep;
 
+    vim_free(args[0]);
     return ret;
 }
 
 /*
  * Expand names with a function defined by the user.
@@ -4829,18 +4897,18 @@ ExpandUserList(xp, num_file, file)
 
     ga_init2(&ga, (int)sizeof(char *), 3);
     /* Loop over the items in the list. */
     for (li = retlist->lv_first; li != NULL; li = li->li_next)
     {
-	if (li->li_tv.v_type != VAR_STRING)
-	    continue;  /* Skip non-string items */
+	if (li->li_tv.v_type != VAR_STRING || li->li_tv.vval.v_string == NULL)
+	    continue;  /* Skip non-string items and empty strings */
 
 	if (ga_grow(&ga, 1) == FAIL)
 	    break;
 
 	((char_u **)ga.ga_data)[ga.ga_len] =
-	    vim_strsave(li->li_tv.vval.v_string);
+					 vim_strsave(li->li_tv.vval.v_string);
 	++ga.ga_len;
     }
     list_unref(retlist);
 
     *file = ga.ga_data;
@@ -4869,11 +4937,11 @@ ExpandRTDir(pat, num_file, file, dirname
     *file = NULL;
     s = alloc((unsigned)(STRLEN(pat) + STRLEN(dirname) + 7));
     if (s == NULL)
 	return FAIL;
     sprintf((char *)s, "%s/%s*.vim", dirname, pat);
-    all = globpath(p_rtp, s);
+    all = globpath(p_rtp, s, 0);
     vim_free(s);
     if (all == NULL)
 	return FAIL;
 
     ga_init2(&ga, (int)sizeof(char *), 3);
@@ -4910,13 +4978,14 @@ ExpandRTDir(pat, num_file, file, dirname
  * Expand "file" for all comma-separated directories in "path".
  * Returns an allocated string with all matches concatenated, separated by
  * newlines.  Returns NULL for an error or no matches.
  */
     char_u *
-globpath(path, file)
+globpath(path, file, expand_options)
     char_u	*path;
     char_u	*file;
+    int		expand_options;
 {
     expand_T	xpc;
     char_u	*buf;
     garray_T	ga;
     int		i;
@@ -4941,14 +5010,14 @@ globpath(path, file)
 	copy_option_part(&path, buf, MAXPATHL, ",");
 	if (STRLEN(buf) + STRLEN(file) + 2 < MAXPATHL)
 	{
 	    add_pathsep(buf);
 	    STRCAT(buf, file);
-	    if (ExpandFromContext(&xpc, buf, &num_p, &p, WILD_SILENT) != FAIL
-								 && num_p > 0)
+	    if (ExpandFromContext(&xpc, buf, &num_p, &p,
+			     WILD_SILENT|expand_options) != FAIL && num_p > 0)
 	    {
-		ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT);
+		ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT|expand_options);
 		for (len = 0, i = 0; i < num_p; ++i)
 		    len += (int)STRLEN(p[i]) + 1;
 
 		/* Concatenate new results to previous ones. */
 		if (ga_grow(&ga, len) == OK)
@@ -5639,11 +5708,11 @@ ex_history(eap)
 	i = *end;
 	*end = NUL;
 	histype1 = get_histtype(arg);
 	if (histype1 == -1)
 	{
-	    if (STRICMP(arg, "all") == 0)
+	    if (STRNICMP(arg, "all", STRLEN(arg)) == 0)
 	    {
 		histype1 = 0;
 		histype2 = HIST_COUNT-1;
 	    }
 	    else
@@ -6018,20 +6087,21 @@ ex_window()
 # ifdef FEAT_AUTOCMD
 	unblock_autocmds();
 # endif
 	return K_IGNORE;
     }
-    cmdwin_type = ccline.cmdfirstc;
-    if (cmdwin_type == NUL)
-	cmdwin_type = '-';
+    cmdwin_type = get_cmdline_type();
 
     /* Create the command-line buffer empty. */
-    (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE);
+    (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL);
     (void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE);
     set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL);
     set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
     curbuf->b_p_ma = TRUE;
+#ifdef FEAT_FOLDING
+    curwin->w_p_fen = FALSE;
+#endif
 # ifdef FEAT_RIGHTLEFT
     curwin->w_p_rl = cmdmsg_rl;
     cmdmsg_rl = FALSE;
 # endif
 # ifdef FEAT_SCROLLBIND
@@ -6044,11 +6114,11 @@ ex_window()
 # endif
 
     /* Showing the prompt may have set need_wait_return, reset it. */
     need_wait_return = FALSE;
 
-    histtype = hist_char2type(ccline.cmdfirstc);
+    histtype = hist_char2type(cmdwin_type);
     if (histtype == HIST_CMD || histtype == HIST_DEBUG)
     {
 	if (p_wc == TAB)
 	{
 	    add_map((char_u *)"<buffer> <Tab> <C-X><C-V>", INSERT);
@@ -6198,11 +6268,15 @@ ex_window()
 # endif
 	wp = curwin;
 	bp = curbuf;
 	win_goto(old_curwin);
 	win_close(wp, TRUE);
-	close_buffer(NULL, bp, DOBUF_WIPE);
+
+	/* win_close() may have already wiped the buffer when 'bh' is
+	 * set to 'wipe' */
+	if (buf_valid(bp))
+	    close_buffer(NULL, bp, DOBUF_WIPE);
 
 	/* Restore window sizes. */
 	win_size_restore(&winsizes);
 
 # ifdef FEAT_AUTOCMD
--- vim72.orig/src/farsi.c
+++ vim72/src/farsi.c
@@ -101,11 +101,12 @@ toF_Xor_X_(c)
 	case IE_:
 		return _IE;
 	case F_HE:
 		tempc = _HE;
 
-		if (p_ri && (curwin->w_cursor.col+1 < STRLEN(ml_get_curline())))
+		if (p_ri && (curwin->w_cursor.col + 1
+					 < (colnr_T)STRLEN(ml_get_curline())))
 		{
 		    inc_cursor();
 
 		    if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))
 			tempc = _HE_;
@@ -342,11 +343,11 @@ put_curr_and_l_to_X(c)
     int	tempc;
 
     if (curwin->w_p_rl && p_ri)
 	return;
 
-    if ( (curwin->w_cursor.col < STRLEN(ml_get_curline())))
+    if ((curwin->w_cursor.col < (colnr_T)STRLEN(ml_get_curline())))
     {
 	if ((p_ri && curwin->w_cursor.col) || !p_ri)
 	{
 	    if (p_ri)
 		dec_cursor();
@@ -563,11 +564,11 @@ chg_c_to_X_or_X ()
 {
     int	tempc;
 
     tempc = gchar_cursor();
 
-    if (curwin->w_cursor.col+1 < STRLEN(ml_get_curline()))
+    if (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(ml_get_curline()))
     {
 	inc_cursor();
 
 	if ((tempc == F_HE) && (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)))
 	{
@@ -592,12 +593,12 @@ chg_c_to_X_or_X ()
     static void
 chg_l_to_X_orX_ ()
 {
     int	tempc;
 
-    if (!curwin->w_cursor.col &&
-	(curwin->w_cursor.col+1 == STRLEN(ml_get_curline())))
+    if (curwin->w_cursor.col != 0 &&
+	(curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline())))
 	return;
 
     if (!curwin->w_cursor.col && p_ri)
 	return;
 
@@ -661,12 +662,12 @@ chg_l_to_X_orX_ ()
     static void
 chg_l_toXor_X ()
 {
     int	tempc;
 
-    if (!curwin->w_cursor.col &&
-	(curwin->w_cursor.col+1 == STRLEN(ml_get_curline())))
+    if (curwin->w_cursor.col != 0 &&
+	(curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline())))
 	return;
 
     if (!curwin->w_cursor.col && p_ri)
 	return;
 
--- vim72.orig/src/feature.h
+++ vim72/src/feature.h
@@ -765,13 +765,17 @@
 # define FEAT_GUI_TABLINE
 #endif
 
 /*
  * +browse		":browse" command.
+ *			or just the ":browse" command modifier
  */
-#if defined(FEAT_NORMAL) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC))
-# define FEAT_BROWSE
+#if defined(FEAT_NORMAL)
+# define FEAT_BROWSE_CMD
+# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)
+#  define FEAT_BROWSE
+# endif
 #endif
 
 /*
  * +dialog_gui		Use GUI dialog.
  * +dialog_con		May use Console dialog.
@@ -838,14 +842,18 @@
  * DEBUG		Output a lot of debugging garbage.
  */
 /* #define DEBUG */
 
 /*
- * STARTUPTIME		Time the startup process.  Writes a "vimstartup" file
- *			with timestamps.
+ * STARTUPTIME		Time the startup process.  Writes a file with
+ *			timestamps.
  */
-/* #define STARTUPTIME "vimstartup" */
+#if defined(FEAT_NORMAL) \
+	&& ((defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)) \
+		|| defined(WIN3264))
+# define STARTUPTIME 1
+#endif
 
 /*
  * MEM_PROFILE		Debugging of memory allocation and freeing.
  */
 /* #define MEM_PROFILE */
--- vim72.orig/src/fileio.c
+++ vim72/src/fileio.c
@@ -19,11 +19,11 @@
 # include "vimio.h"	/* for mktemp(), CJW 1997-12-03 */
 #endif
 
 #include "vim.h"
 
-#ifdef __TANDEM
+#if defined(__TANDEM) || defined(__MINT__)
 # include <limits.h>		/* for SSIZE_MAX */
 #endif
 
 #if defined(HAVE_UTIME) && defined(HAVE_UTIME_H)
 # include <utime.h>		/* for struct utimbuf */
@@ -67,11 +67,11 @@ static int time_differs __ARGS((long t1,
 #ifdef FEAT_AUTOCMD
 static int apply_autocmds_exarg __ARGS((event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, exarg_T *eap));
 static int au_find_group __ARGS((char_u *name));
 
 # define AUGROUP_DEFAULT    -1	    /* default autocmd group */
-# define AUGROUP_ERROR	    -2	    /* errornouse autocmd group */
+# define AUGROUP_ERROR	    -2	    /* erroneous autocmd group */
 # define AUGROUP_ALL	    -3	    /* all autocmd groups */
 #endif
 
 #if defined(FEAT_CRYPT) || defined(FEAT_MBYTE)
 # define HAS_BW_FLAGS
@@ -119,10 +119,12 @@ struct bw_info
     int		bw_restlen;	/* nr of bytes in bw_rest[] */
     int		bw_first;	/* first write call */
     char_u	*bw_conv_buf;	/* buffer for writing converted chars */
     int		bw_conv_buflen; /* size of bw_conv_buf */
     int		bw_conv_error;	/* set for conversion error */
+    linenr_T	bw_conv_error_lnum;  /* first line with error or zero */
+    linenr_T	bw_start_lnum;  /* line number at start of buffer */
 # ifdef USE_ICONV
     iconv_t	bw_iconv_fd;	/* descriptor for iconv() or -1 */
 # endif
 #endif
 };
@@ -130,11 +132,11 @@ struct bw_info
 static int  buf_write_bytes __ARGS((struct bw_info *ip));
 
 #ifdef FEAT_MBYTE
 static linenr_T readfile_linenr __ARGS((linenr_T linecnt, char_u *p, char_u *endp));
 static int ucs2bytes __ARGS((unsigned c, char_u **pp, int flags));
-static int same_encoding __ARGS((char_u *a, char_u *b));
+static int need_conversion __ARGS((char_u *fenc));
 static int get_fio_flags __ARGS((char_u *ptr));
 static char_u *check_for_bom __ARGS((char_u *p, long size, int *lenp, int flags));
 static int make_bom __ARGS((char_u *buf, char_u *name));
 # ifdef WIN3264
 static int get_win_fio_flags __ARGS((char_u *ptr));
@@ -142,11 +144,16 @@ static int get_win_fio_flags __ARGS((cha
 # ifdef MACOS_X
 static int get_mac_fio_flags __ARGS((char_u *ptr));
 # endif
 #endif
 static int move_lines __ARGS((buf_T *frombuf, buf_T *tobuf));
-
+#ifdef TEMPDIRNAMES
+static void vim_settempdir __ARGS((char_u *tempdir));
+#endif
+#ifdef FEAT_AUTOCMD
+static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name");
+#endif
 
     void
 filemess(buf, name, s, attr)
     buf_T	*buf;
     char_u	*name;
@@ -293,10 +300,23 @@ readfile(fname, sfname, from, lines_to_s
 					   wasn't possible */
     char_u	conv_rest[CONV_RESTLEN];
     int		conv_restlen = 0;	/* nr of bytes in conv_rest[] */
 #endif
 
+#ifdef FEAT_AUTOCMD
+    /* Remember the initial values of curbuf, curbuf->b_ffname and
+     * curbuf->b_fname to detect whether they are altered as a result of
+     * executing nasty autocommands.  Also check if "fname" and "sfname"
+     * point to one of these values. */
+    buf_T   *old_curbuf = curbuf;
+    char_u  *old_b_ffname = curbuf->b_ffname;
+    char_u  *old_b_fname = curbuf->b_fname;
+    int     using_b_ffname = (fname == curbuf->b_ffname)
+					      || (sfname == curbuf->b_ffname);
+    int     using_b_fname = (fname == curbuf->b_fname)
+					       || (sfname == curbuf->b_fname);
+#endif
     write_no_eol_lnum = 0;	/* in case it was set by the previous read */
 
     /*
      * If there is no file name yet, use the one for the read file.
      * BF_NOTEDITED is set to reflect this.
@@ -587,11 +607,25 @@ readfile(fname, sfname, from, lines_to_s
 		     * that we are editing this file.  Don't do this for a
 		     * "nofile" or "nowrite" buffer type. */
 #ifdef FEAT_QUICKFIX
 		    if (!bt_dontwrite(curbuf))
 #endif
+		    {
 			check_need_swap(newfile);
+#ifdef FEAT_AUTOCMD
+			/* SwapExists autocommand may mess things up */
+			if (curbuf != old_curbuf
+				|| (using_b_ffname
+					&& (old_b_ffname != curbuf->b_ffname))
+				|| (using_b_fname
+					 && (old_b_fname != curbuf->b_fname)))
+			{
+			    EMSG(_(e_auchangedbuf));
+			    return FAIL;
+			}
+#endif
+		    }
 		    if (dir_of_file_exists(fname))
 			filemess(curbuf, sfname, (char_u *)_("[New File]"), 0);
 		    else
 			filemess(curbuf, sfname,
 					   (char_u *)_("[New DIRECTORY]"), 0);
@@ -666,13 +700,25 @@ readfile(fname, sfname, from, lines_to_s
 #ifdef FEAT_QUICKFIX
     if (!bt_dontwrite(curbuf))
 #endif
     {
 	check_need_swap(newfile);
+#ifdef FEAT_AUTOCMD
+	if (!read_stdin && (curbuf != old_curbuf
+		|| (using_b_ffname && (old_b_ffname != curbuf->b_ffname))
+		|| (using_b_fname && (old_b_fname != curbuf->b_fname))))
+	{
+	    EMSG(_(e_auchangedbuf));
+	    if (!read_buffer)
+		close(fd);
+	    return FAIL;
+	}
+#endif
 #ifdef UNIX
 	/* Set swap file protection bits after creating it. */
-	if (swap_mode > 0 && curbuf->b_ml.ml_mfp->mf_fname != NULL)
+	if (swap_mode > 0 && curbuf->b_ml.ml_mfp != NULL
+			  && curbuf->b_ml.ml_mfp->mf_fname != NULL)
 	    (void)mch_setperm(curbuf->b_ml.ml_mfp->mf_fname, (long)swap_mode);
 #endif
     }
 
 #if defined(HAS_SWAP_EXISTS_ACTION)
@@ -696,11 +742,10 @@ readfile(fname, sfname, from, lines_to_s
 #ifdef FEAT_AUTOCMD
     if (!read_buffer)
     {
 	int	m = msg_scroll;
 	int	n = msg_scrolled;
-	buf_T	*old_curbuf = curbuf;
 
 	/*
 	 * The file must be closed again, the autocommands may want to change
 	 * the file before reading it.
 	 */
@@ -738,12 +783,17 @@ readfile(fname, sfname, from, lines_to_s
 	}
 #endif
 	/*
 	 * Don't allow the autocommands to change the current buffer.
 	 * Try to re-open the file.
+	 *
+	 * Don't allow the autocommands to change the buffer name either
+	 * (cd for example) if it invalidates fname or sfname.
 	 */
 	if (!read_stdin && (curbuf != old_curbuf
+		|| (using_b_ffname && (old_b_ffname != curbuf->b_ffname))
+		|| (using_b_fname && (old_b_fname != curbuf->b_fname))
 		|| (fd = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0)) < 0))
 	{
 	    --no_wait_return;
 	    msg_scroll = msg_save;
 	    if (fd < 0)
@@ -930,11 +980,14 @@ retry:
     if (keep_fileformat)
 	keep_fileformat = FALSE;
     else
     {
 	if (eap != NULL && eap->force_ff != 0)
+	{
 	    fileformat = get_fileformat_force(curbuf, eap);
+	    try_unix = try_dos = try_mac = FALSE;
+	}
 	else if (curbuf->b_p_bin)
 	    fileformat = EOL_UNIX;		/* binary: use Unix format */
 	else if (*p_ffs == NUL)
 	    fileformat = get_fileformat(curbuf);/* use format from buffer */
 	else
@@ -991,17 +1044,16 @@ retry:
 	    tmpname = NULL;
 	}
     }
 
     /*
-     * Conversion is required when the encoding of the file is different
-     * from 'encoding' or 'encoding' is UTF-16, UCS-2 or UCS-4 (requires
-     * conversion to UTF-8).
+     * Conversion may be required when the encoding of the file is different
+     * from 'encoding' or 'encoding' is UTF-16, UCS-2 or UCS-4.
      */
     fio_flags = 0;
-    converted = (*fenc != NUL && !same_encoding(p_enc, fenc));
-    if (converted || enc_unicode != 0)
+    converted = need_conversion(fenc);
+    if (converted)
     {
 
 	/* "ucs-bom" means we need to check the first bytes of the file
 	 * for a BOM. */
 	if (STRCMP(fenc, ENC_UCSBOM) == 0)
@@ -2202,18 +2254,26 @@ failed:
 # endif
 #endif
 
     if (!read_buffer && !read_stdin)
 	close(fd);				/* errors are ignored */
+#ifdef HAVE_FD_CLOEXEC
+    else
+    {
+	int fdflags = fcntl(fd, F_GETFD);
+	if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
+	    fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
+    }
+#endif
     vim_free(buffer);
 
 #ifdef HAVE_DUP
     if (read_stdin)
     {
 	/* Use stderr for stdin, makes shell commands work. */
 	close(0);
-	dup(2);
+	ignored = dup(2);
     }
 #endif
 
 #ifdef FEAT_MBYTE
     if (tmpname != NULL)
@@ -2339,15 +2399,10 @@ failed:
 	    if (ff_error == EOL_DOS)
 	    {
 		STRCAT(IObuff, _("[CR missing]"));
 		c = TRUE;
 	    }
-	    if (ff_error == EOL_MAC)
-	    {
-		STRCAT(IObuff, _("[NL found]"));
-		c = TRUE;
-	    }
 	    if (split)
 	    {
 		STRCAT(IObuff, _("[long lines split]"));
 		c = TRUE;
 	    }
@@ -2709,11 +2764,11 @@ readfile_charconvert(fname, fenc, fdp)
     static void
 check_marks_read()
 {
     if (!curbuf->b_marks_read && get_viminfo_parameter('\'') > 0
 						  && curbuf->b_ffname != NULL)
-	read_viminfo(NULL, FALSE, TRUE, FALSE);
+	read_viminfo(NULL, VIF_WANT_MARKS);
 
     /* Always set b_marks_read; needed when 'viminfo' is changed to include
      * the ' parameter after opening a buffer. */
     curbuf->b_marks_read = TRUE;
 }
@@ -2879,10 +2934,11 @@ buf_write(buf, fname, sfname, start, end
     char_u	    c;
     int		    len;
     linenr_T	    lnum;
     long	    nchars;
     char_u	    *errmsg = NULL;
+    int		    errmsg_allocated = FALSE;
     char_u	    *errnum = NULL;
     char_u	    *buffer;
     char_u	    smallbuf[SMBUFSIZE];
     char_u	    *backup_ext;
     int		    bufsize;
@@ -2923,10 +2979,17 @@ buf_write(buf, fname, sfname, start, end
 					   backup or new file */
 #endif
 
     if (fname == NULL || *fname == NUL)	/* safety check */
 	return FAIL;
+    if (buf->b_ml.ml_mfp == NULL)
+    {
+	/* This can happen during startup when there is a stray "w" in the
+	 * vimrc file. */
+	EMSG(_(e_emptybuf));
+	return FAIL;
+    }
 
     /*
      * Disallow writing from .exrc and .vimrc in current directory for
      * security reasons.
      */
@@ -2942,10 +3005,11 @@ buf_write(buf, fname, sfname, start, end
 
 #ifdef FEAT_MBYTE
     /* must init bw_conv_buf and bw_iconv_fd before jumping to "fail" */
     write_info.bw_conv_buf = NULL;
     write_info.bw_conv_error = FALSE;
+    write_info.bw_conv_error_lnum = 0;
     write_info.bw_restlen = 0;
 # ifdef USE_ICONV
     write_info.bw_iconv_fd = (iconv_t)-1;
 # endif
 #endif
@@ -3449,16 +3513,16 @@ buf_write(buf, fname, sfname, start, end
 		    backup_copy = TRUE;
 		else
 		{
 # ifdef UNIX
 #  ifdef HAVE_FCHOWN
-		    fchown(fd, st_old.st_uid, st_old.st_gid);
+		    ignored = fchown(fd, st_old.st_uid, st_old.st_gid);
 #  endif
 		    if (mch_stat((char *)IObuff, &st) < 0
 			    || st.st_uid != st_old.st_uid
 			    || st.st_gid != st_old.st_gid
-			    || st.st_mode != perm)
+			    || (long)st.st_mode != perm)
 			backup_copy = TRUE;
 # endif
 		    /* Close the file before removing it, on MS-Windows we
 		     * can't delete an open file. */
 		    close(fd);
@@ -3920,14 +3984,13 @@ buf_write(buf, fname, sfname, start, end
     }
     else
 	fenc = buf->b_p_fenc;
 
     /*
-     * The file needs to be converted when 'fileencoding' is set and
-     * 'fileencoding' differs from 'encoding'.
+     * Check if the file needs to be converted.
      */
-    converted = (*fenc != NUL && !same_encoding(p_enc, fenc));
+    converted = need_conversion(fenc);
 
     /*
      * Check if UTF-8 to UCS-2/4 or Latin1 conversion needs to be done.  Or
      * Latin1 to Unicode conversion.  This is handled in buf_write_bytes().
      * Prepare the flags for it and allocate bw_conv_buf when needed.
@@ -4198,10 +4261,11 @@ restore_backup:
 		end = 0;
 	    else
 		nchars += write_info.bw_len;
 	}
     }
+    write_info.bw_start_lnum = start;
 #endif
 
     write_info.bw_len = bufsize;
 #ifdef HAS_BW_FLAGS
     write_info.bw_flags = wb_flags;
@@ -4233,10 +4297,13 @@ restore_backup:
 		break;
 	    }
 	    nchars += bufsize;
 	    s = buffer;
 	    len = 0;
+#ifdef FEAT_MBYTE
+	    write_info.bw_start_lnum = lnum;
+#endif
 	}
 	/* write failed or last line has no EOL: stop here */
 	if (end == 0
 		|| (lnum == end
 		    && write_bin
@@ -4365,18 +4432,18 @@ restore_backup:
 	 * permission or ACL stuff */
 	if (mch_stat((char *)wfname, &st) < 0
 		|| st.st_uid != st_old.st_uid
 		|| st.st_gid != st_old.st_gid)
 	{
-	    fchown(fd, st_old.st_uid, st_old.st_gid);
+	    ignored = fchown(fd, st_old.st_uid, st_old.st_gid);
 	    if (perm >= 0)	/* set permission again, may have changed */
 		(void)mch_setperm(wfname, perm);
 	}
 # endif
 	buf_setino(buf);
     }
-    else if (buf->b_dev < 0)
+    else if (!buf->b_dev_valid)
 	/* Set the inode when creating a new file. */
 	buf_setino(buf);
 #endif
 
     if (close(fd) != 0)
@@ -4429,11 +4496,21 @@ restore_backup:
     {
 	if (errmsg == NULL)
 	{
 #ifdef FEAT_MBYTE
 	    if (write_info.bw_conv_error)
-		errmsg = (char_u *)_("E513: write error, conversion failed (make 'fenc' empty to override)");
+	    {
+		if (write_info.bw_conv_error_lnum == 0)
+		    errmsg = (char_u *)_("E513: write error, conversion failed (make 'fenc' empty to override)");
+		else
+		{
+		    errmsg_allocated = TRUE;
+		    errmsg = alloc(300);
+		    vim_snprintf((char *)errmsg, 300, _("E513: write error, conversion failed in line %ld (make 'fenc' empty to override)"),
+					 (long)write_info.bw_conv_error_lnum);
+		}
+	    }
 	    else
 #endif
 		if (got_int)
 		    errmsg = (char_u *)_(e_interr);
 		else
@@ -4505,10 +4582,16 @@ restore_backup:
 #ifdef FEAT_MBYTE
 	if (write_info.bw_conv_error)
 	{
 	    STRCAT(IObuff, _(" CONVERSION ERROR"));
 	    c = TRUE;
+	    if (write_info.bw_conv_error_lnum != 0)
+	    {
+		size_t l = STRLEN(IObuff);
+		vim_snprintf((char *)IObuff + l, IOSIZE - l, _(" in line %ld;"),
+			(long)write_info.bw_conv_error_lnum);
+	    }
 	}
 	else if (notconverted)
 	{
 	    STRCAT(IObuff, _("[NOT converted]"));
 	    c = TRUE;
@@ -4701,10 +4784,12 @@ nofail:
 	    STRMOVE(IObuff + numlen, IObuff);
 	    mch_memmove(IObuff, errnum, (size_t)numlen);
 	}
 	STRCAT(IObuff, errmsg);
 	emsg(IObuff);
+	if (errmsg_allocated)
+	    vim_free(errmsg);
 
 	retval = FAIL;
 	if (end == 0)
 	{
 	    MSG_PUTS_ATTR(_("\nWARNING: Original file may be lost or damaged\n"),
@@ -4780,18 +4865,26 @@ nofail:
 set_rw_fname(fname, sfname)
     char_u	*fname;
     char_u	*sfname;
 {
 #ifdef FEAT_AUTOCMD
+    buf_T	*buf = curbuf;
+
     /* It's like the unnamed buffer is deleted.... */
     if (curbuf->b_p_bl)
 	apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
     apply_autocmds(EVENT_BUFWIPEOUT, NULL, NULL, FALSE, curbuf);
 # ifdef FEAT_EVAL
     if (aborting())	    /* autocmds may abort script processing */
 	return FAIL;
 # endif
+    if (curbuf != buf)
+    {
+	/* We are in another buffer now, don't do the renaming. */
+	EMSG(_(e_auchangedbuf));
+	return FAIL;
+    }
 #endif
 
     if (setfname(curbuf, fname, sfname, FALSE) == OK)
 	curbuf->b_flags |= BF_NOTEDITED;
 
@@ -5052,11 +5145,17 @@ buf_write_bytes(ip)
 			c = utf_ptr2char(buf + wlen);
 		    else
 			c = buf[wlen];
 		}
 
-		ip->bw_conv_error |= ucs2bytes(c, &p, flags);
+		if (ucs2bytes(c, &p, flags) && !ip->bw_conv_error)
+		{
+		    ip->bw_conv_error = TRUE;
+		    ip->bw_conv_error_lnum = ip->bw_start_lnum;
+		}
+		if (c == NL)
+		    ++ip->bw_start_lnum;
 	    }
 	    if (flags & FIO_LATIN1)
 		len = (int)(p - buf);
 	    else
 	    {
@@ -5244,17 +5343,20 @@ buf_write_bytes(ip)
 	    size_t	tolen;
 
 	    /* Convert with iconv(). */
 	    if (ip->bw_restlen > 0)
 	    {
+		char *fp;
+
 		/* Need to concatenate the remainder of the previous call and
 		 * the bytes of the current call.  Use the end of the
 		 * conversion buffer for this. */
 		fromlen = len + ip->bw_restlen;
-		from = (char *)ip->bw_conv_buf + ip->bw_conv_buflen - fromlen;
-		mch_memmove((void *)from, ip->bw_rest, (size_t)ip->bw_restlen);
-		mch_memmove((void *)(from + ip->bw_restlen), buf, (size_t)len);
+		fp = (char *)ip->bw_conv_buf + ip->bw_conv_buflen - fromlen;
+		mch_memmove(fp, ip->bw_rest, (size_t)ip->bw_restlen);
+		mch_memmove(fp + ip->bw_restlen, buf, (size_t)len);
+		from = fp;
 		tolen = ip->bw_conv_buflen - fromlen;
 	    }
 	    else
 	    {
 		from = (const char *)buf;
@@ -5330,10 +5432,11 @@ buf_write_bytes(ip)
 }
 
 #ifdef FEAT_MBYTE
 /*
  * Convert a Unicode character to bytes.
+ * Return TRUE for an error, FALSE when it's OK.
  */
     static int
 ucs2bytes(c, pp, flags)
     unsigned	c;		/* in: character */
     char_u	**pp;		/* in/out: pointer to result */
@@ -5413,24 +5516,41 @@ ucs2bytes(c, pp, flags)
     *pp = p;
     return error;
 }
 
 /*
- * Return TRUE if "a" and "b" are the same 'encoding'.
- * Ignores difference between "ansi" and "latin1", "ucs-4" and "ucs-4be", etc.
+ * Return TRUE if file encoding "fenc" requires conversion from or to
+ * 'encoding'.
  */
     static int
-same_encoding(a, b)
-    char_u	*a;
-    char_u	*b;
+need_conversion(fenc)
+    char_u	*fenc;
 {
-    int		f;
+    int		same_encoding;
+    int		enc_flags;
+    int		fenc_flags;
 
-    if (STRCMP(a, b) == 0)
-	return TRUE;
-    f = get_fio_flags(a);
-    return (f != 0 && get_fio_flags(b) == f);
+    if (*fenc == NUL || STRCMP(p_enc, fenc) == 0)
+	same_encoding = TRUE;
+    else
+    {
+	/* Ignore difference between "ansi" and "latin1", "ucs-4" and
+	 * "ucs-4be", etc. */
+	enc_flags = get_fio_flags(p_enc);
+	fenc_flags = get_fio_flags(fenc);
+	same_encoding = (enc_flags != 0 && fenc_flags == enc_flags);
+    }
+    if (same_encoding)
+    {
+	/* Specified encoding matches with 'encoding'.  This requires
+	 * conversion when 'encoding' is Unicode but not UTF-8. */
+	return enc_unicode != 0;
+    }
+
+    /* Encodings differ.  However, conversion is not needed when 'enc' is any
+     * Unicode encoding and the file is UTF-8. */
+    return !(enc_utf8 && fenc_flags == FIO_UTF8);
 }
 
 /*
  * Check "ptr" for a unicode encoding and return the FIO_ flags needed for the
  * internal conversion.
@@ -5548,13 +5668,14 @@ check_for_bom(p, size, lenp, flags)
 	    && (flags == FIO_ALL || flags == (FIO_UCS4 | FIO_ENDIAN_L)))
 	{
 	    name = "ucs-4le";	/* FF FE 00 00 */
 	    len = 4;
 	}
-	else if (flags == FIO_ALL || flags == (FIO_UCS2 | FIO_ENDIAN_L))
+	else if (flags == (FIO_UCS2 | FIO_ENDIAN_L))
 	    name = "ucs-2le";	/* FF FE */
-	else if (flags == (FIO_UTF16 | FIO_ENDIAN_L))
+	else if (flags == FIO_ALL || flags == (FIO_UTF16 | FIO_ENDIAN_L))
+	    /* utf-16le is preferred, it also works for ucs-2le text */
 	    name = "utf-16le";	/* FF FE */
     }
     else if (p[0] == 0xfe && p[1] == 0xff
 	    && (flags == FIO_ALL || flags == FIO_UCS2 || flags == FIO_UTF16))
     {
@@ -5915,11 +6036,11 @@ buf_modname(shortname, fname, ext, prepe
 	else if (*ext == '/' || *ext == '_')
 #else
 	else if (*ext == '.')
 #endif
 	{
-	    if (s - ptr > (size_t)8)
+	    if ((size_t)(s - ptr) > (size_t)8)
 	    {
 		s = ptr + 8;
 		*s = '\0';
 	    }
 	}
@@ -6029,13 +6150,13 @@ vim_fgets(buf, size, fp)
 	/* Now throw away the rest of the line: */
 	do
 	{
 	    tbuf[FGETS_SIZE - 2] = NUL;
 #ifdef USE_CR
-	    fgets_cr((char *)tbuf, FGETS_SIZE, fp);
+	    ignoredp = fgets_cr((char *)tbuf, FGETS_SIZE, fp);
 #else
-	    fgets((char *)tbuf, FGETS_SIZE, fp);
+	    ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp);
 #endif
 	} while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n');
     }
     return (eof == NULL);
 }
@@ -6105,23 +6226,84 @@ vim_rename(from, to)
     struct stat	st;
     long	perm;
 #ifdef HAVE_ACL
     vim_acl_T	acl;		/* ACL from original file */
 #endif
+#if defined(UNIX) || defined(CASE_INSENSITIVE_FILENAME)
+    int		use_tmp_file = FALSE;
+#endif
 
     /*
-     * When the names are identical, there is nothing to do.
+     * When the names are identical, there is nothing to do.  When they refer
+     * to the same file (ignoring case and slash/backslash differences) but
+     * the file name differs we need to go through a temp file.
      */
     if (fnamecmp(from, to) == 0)
-	return 0;
+    {
+#ifdef CASE_INSENSITIVE_FILENAME
+	if (STRCMP(gettail(from), gettail(to)) != 0)
+	    use_tmp_file = TRUE;
+	else
+#endif
+	    return 0;
+    }
 
     /*
      * Fail if the "from" file doesn't exist.  Avoids that "to" is deleted.
      */
     if (mch_stat((char *)from, &st) < 0)
 	return -1;
 
+#ifdef UNIX
+    {
+	struct stat	st_to;
+
+	/* It's possible for the source and destination to be the same file.
+	 * This happens when "from" and "to" differ in case and are on a FAT32
+	 * filesystem.  In that case go through a temp file name. */
+	if (mch_stat((char *)to, &st_to) >= 0
+		&& st.st_dev == st_to.st_dev
+		&& st.st_ino == st_to.st_ino)
+	    use_tmp_file = TRUE;
+    }
+#endif
+
+#if defined(UNIX) || defined(CASE_INSENSITIVE_FILENAME)
+    if (use_tmp_file)
+    {
+	char	tempname[MAXPATHL + 1];
+
+	/*
+	 * Find a name that doesn't exist and is in the same directory.
+	 * Rename "from" to "tempname" and then rename "tempname" to "to".
+	 */
+	if (STRLEN(from) >= MAXPATHL - 5)
+	    return -1;
+	STRCPY(tempname, from);
+	for (n = 123; n < 99999; ++n)
+	{
+	    sprintf((char *)gettail((char_u *)tempname), "%d", n);
+	    if (mch_stat(tempname, &st) < 0)
+	    {
+		if (mch_rename((char *)from, tempname) == 0)
+		{
+		    if (mch_rename(tempname, (char *)to) == 0)
+			return 0;
+		    /* Strange, the second step failed.  Try moving the
+		     * file back and return failure. */
+		    mch_rename(tempname, (char *)from);
+		    return -1;
+		}
+		/* If it fails for one temp name it will most likely fail
+		 * for any temp name, give up. */
+		return -1;
+	    }
+	}
+	return -1;
+    }
+#endif
+
     /*
      * Delete the "to" file, this is required on some systems to make the
      * mch_rename() work, on other systems it makes sure that we don't have
      * two files when the mch_rename() fails.
      */
@@ -6258,11 +6440,11 @@ check_timestamps(focus)
 	return FALSE;
     }
 
     if (!stuff_empty() || global_busy || !typebuf_typed()
 #ifdef FEAT_AUTOCMD
-			|| autocmd_busy || curbuf_lock > 0
+			|| autocmd_busy || curbuf_lock > 0 || allbuf_lock > 0
 #endif
 					)
 	need_check_timestamps = TRUE;		/* check later */
     else
     {
@@ -6351,15 +6533,14 @@ move_lines(frombuf, tobuf)
  * Also check if the file for a new buffer unexpectedly appeared.
  * return 1 if a changed buffer was found.
  * return 2 if a message has been displayed.
  * return 0 otherwise.
  */
-/*ARGSUSED*/
     int
 buf_check_timestamp(buf, focus)
     buf_T	*buf;
-    int		focus;		/* called for GUI focus event */
+    int		focus UNUSED;	/* called for GUI focus event */
 {
     struct stat	st;
     int		stat_res;
     int		retval = 0;
     char_u	*path;
@@ -6460,12 +6641,14 @@ buf_check_timestamp(buf, focus)
 	    busy = TRUE;
 # ifdef FEAT_EVAL
 	    set_vim_var_string(VV_FCS_REASON, (char_u *)reason, -1);
 	    set_vim_var_string(VV_FCS_CHOICE, (char_u *)"", -1);
 # endif
+	    ++allbuf_lock;
 	    n = apply_autocmds(EVENT_FILECHANGEDSHELL,
 				      buf->b_fname, buf->b_fname, FALSE, buf);
+	    --allbuf_lock;
 	    busy = FALSE;
 	    if (n)
 	    {
 		if (!buf_valid(buf))
 		    EMSG(_("E246: FileChangedShell autocommand deleted buffer"));
@@ -6509,11 +6692,14 @@ buf_check_timestamp(buf, focus)
 		    else if (*reason == 'm')
 		    {
 			mesg = _("W16: Warning: Mode of file \"%s\" has changed since editing started");
 			mesg2 = _("See \":help W16\" for more info.");
 		    }
-		    /* Else: only timestamp changed, ignored */
+		    else
+			/* Only timestamp changed, store it to avoid a warning
+			 * in check_mtime() later. */
+			buf->b_mtime_read = buf->b_mtime;
 		}
 	    }
 	}
 
     }
@@ -6536,10 +6722,15 @@ buf_check_timestamp(buf, focus)
 	    if (!helpmesg)
 		mesg2 = "";
 	    tbuf = alloc((unsigned)(STRLEN(path) + STRLEN(mesg)
 							+ STRLEN(mesg2) + 2));
 	    sprintf((char *)tbuf, mesg, path);
+#ifdef FEAT_EVAL
+	    /* Set warningmsg here, before the unimportant and output-specific
+	     * mesg2 has been appended. */
+	    set_vim_var_string(VV_WARNINGMSG, tbuf, -1);
+#endif
 #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
 	    if (can_reload)
 	    {
 		if (*mesg2 != NUL)
 		{
@@ -6730,14 +6921,15 @@ buf_reload(buf, orig_mode)
 #ifdef FEAT_AUTOCMD
 	keep_filetype = FALSE;
 #endif
 #ifdef FEAT_FOLDING
 	{
-	    win_T *wp;
+	    win_T	*wp;
+	    tabpage_T	*tp;
 
 	    /* Update folds unless they are defined manually. */
-	    FOR_ALL_WINDOWS(wp)
+	    FOR_ALL_TAB_WINDOWS(tp, wp)
 		if (wp->w_buffer == curwin->w_buffer
 			&& !foldmethodIsManual(wp))
 		    foldUpdateAll(wp);
 	}
 #endif
@@ -6751,16 +6943,15 @@ buf_reload(buf, orig_mode)
     /* restore curwin/curbuf and a few other things */
     aucmd_restbuf(&aco);
     /* Careful: autocommands may have made "buf" invalid! */
 }
 
-/*ARGSUSED*/
     void
 buf_store_time(buf, st, fname)
     buf_T	*buf;
     struct stat	*st;
-    char_u	*fname;
+    char_u	*fname UNUSED;
 {
     buf->b_mtime = (long)st->st_mtime;
     buf->b_orig_size = (size_t)st->st_size;
 #ifdef HAVE_ST_MODE
     buf->b_orig_mode = (int)st->st_mode;
@@ -6811,34 +7002,60 @@ vim_deltempdir()
 	vim_tempdir = NULL;
     }
 }
 #endif
 
+#ifdef TEMPDIRNAMES
+/*
+ * Directory "tempdir" was created.  Expand this name to a full path and put
+ * it in "vim_tempdir".  This avoids that using ":cd" would confuse us.
+ * "tempdir" must be no longer than MAXPATHL.
+ */
+    static void
+vim_settempdir(tempdir)
+    char_u	*tempdir;
+{
+    char_u	*buf;
+
+    buf = alloc((unsigned)MAXPATHL + 2);
+    if (buf != NULL)
+    {
+	if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL)
+	    STRCPY(buf, tempdir);
+# ifdef __EMX__
+	if (vim_strchr(buf, '/') != NULL)
+	    STRCAT(buf, "/");
+	else
+# endif
+	    add_pathsep(buf);
+	vim_tempdir = vim_strsave(buf);
+	vim_free(buf);
+    }
+}
+#endif
+
 /*
  * vim_tempname(): Return a unique name that can be used for a temp file.
  *
  * The temp file is NOT created.
  *
  * The returned pointer is to allocated memory.
  * The returned pointer is NULL if no valid name was found.
  */
-/*ARGSUSED*/
     char_u  *
 vim_tempname(extra_char)
-    int	    extra_char;	    /* character to use in the name instead of '?' */
+    int	    extra_char UNUSED;  /* char to use in the name instead of '?' */
 {
 #ifdef USE_TMPNAM
     char_u	itmp[L_tmpnam];	/* use tmpnam() */
 #else
     char_u	itmp[TEMPNAMELEN];
 #endif
 
 #ifdef TEMPDIRNAMES
     static char	*(tempdirs[]) = {TEMPDIRNAMES};
     int		i;
-    long	nr;
-    long	off;
 # ifndef EEXIST
     struct stat	st;
 # endif
 
     /*
@@ -6851,12 +7068,18 @@ vim_tempname(extra_char)
     if (vim_tempdir == NULL)
     {
 	/*
 	 * Try the entries in TEMPDIRNAMES to create the temp directory.
 	 */
-	for (i = 0; i < sizeof(tempdirs) / sizeof(char *); ++i)
+	for (i = 0; i < (int)(sizeof(tempdirs) / sizeof(char *)); ++i)
 	{
+# ifndef HAVE_MKDTEMP
+	    size_t	itmplen;
+	    long	nr;
+	    long	off;
+# endif
+
 	    /* expand $TMP, leave room for "/v1100000/999999999" */
 	    expand_env((char_u *)tempdirs[i], itmp, TEMPNAMELEN - 20);
 	    if (mch_isdir(itmp))		/* directory exists */
 	    {
 # ifdef __EMX__
@@ -6867,74 +7090,63 @@ vim_tempname(extra_char)
 		    STRCAT(itmp, "/");
 		else
 # endif
 		    add_pathsep(itmp);
 
+# ifdef HAVE_MKDTEMP
+		/* Leave room for filename */
+		STRCAT(itmp, "vXXXXXX");
+		if (mkdtemp((char *)itmp) != NULL)
+		    vim_settempdir(itmp);
+# else
 		/* Get an arbitrary number of up to 6 digits.  When it's
 		 * unlikely that it already exists it will be faster,
 		 * otherwise it doesn't matter.  The use of mkdir() avoids any
 		 * security problems because of the predictable number. */
 		nr = (mch_get_pid() + (long)time(NULL)) % 1000000L;
+		itmplen = STRLEN(itmp);
 
 		/* Try up to 10000 different values until we find a name that
 		 * doesn't exist. */
 		for (off = 0; off < 10000L; ++off)
 		{
 		    int		r;
-#if defined(UNIX) || defined(VMS)
+#  if defined(UNIX) || defined(VMS)
 		    mode_t	umask_save;
-#endif
+#  endif
 
-		    sprintf((char *)itmp + STRLEN(itmp), "v%ld", nr + off);
-# ifndef EEXIST
+		    sprintf((char *)itmp + itmplen, "v%ld", nr + off);
+#  ifndef EEXIST
 		    /* If mkdir() does not set errno to EEXIST, check for
 		     * existing file here.  There is a race condition then,
 		     * although it's fail-safe. */
 		    if (mch_stat((char *)itmp, &st) >= 0)
 			continue;
-# endif
-#if defined(UNIX) || defined(VMS)
+#  endif
+#  if defined(UNIX) || defined(VMS)
 		    /* Make sure the umask doesn't remove the executable bit.
 		     * "repl" has been reported to use "177". */
 		    umask_save = umask(077);
-#endif
+#  endif
 		    r = vim_mkdir(itmp, 0700);
-#if defined(UNIX) || defined(VMS)
+#  if defined(UNIX) || defined(VMS)
 		    (void)umask(umask_save);
-#endif
+#  endif
 		    if (r == 0)
 		    {
-			char_u	*buf;
-
-			/* Directory was created, use this name.
-			 * Expand to full path; When using the current
-			 * directory a ":cd" would confuse us. */
-			buf = alloc((unsigned)MAXPATHL + 1);
-			if (buf != NULL)
-			{
-			    if (vim_FullName(itmp, buf, MAXPATHL, FALSE)
-								      == FAIL)
-				STRCPY(buf, itmp);
-# ifdef __EMX__
-			    if (vim_strchr(buf, '/') != NULL)
-				STRCAT(buf, "/");
-			    else
-# endif
-				add_pathsep(buf);
-			    vim_tempdir = vim_strsave(buf);
-			    vim_free(buf);
-			}
+			vim_settempdir(itmp);
 			break;
 		    }
-# ifdef EEXIST
+#  ifdef EEXIST
 		    /* If the mkdir() didn't fail because the file/dir exists,
 		     * we probably can't create any dir here, try another
 		     * place. */
 		    if (errno != EEXIST)
-# endif
+#  endif
 			break;
 		}
+# endif /* HAVE_MKDTEMP */
 		if (vim_tempdir != NULL)
 		    break;
 	    }
 	}
     }
@@ -7711,11 +7923,14 @@ au_event_disable(what)
     if (save_ei != NULL)
     {
 	new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what)));
 	if (new_ei != NULL)
 	{
-	    STRCAT(new_ei, what);
+	    if (*what == ',' && *p_ei == NUL)
+		STRCPY(new_ei, what + 1);
+	    else
+		STRCAT(new_ei, what);
 	    set_string_option_direct((char_u *)"ei", -1, new_ei,
 							  OPT_FREE, SID_NONE);
 	    vim_free(new_ei);
 	}
     }
@@ -8243,11 +8458,11 @@ ex_doautoall(eap)
 	    /* execute the autocommands for this buffer */
 	    retval = do_doautocmd(eap->arg, FALSE);
 
 	    /* Execute the modeline settings, but don't set window-local
 	     * options if we are using the current window for another buffer. */
-	    do_modelines(aco.save_curwin == NULL ? OPT_NOWIN : 0);
+	    do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
 
 	    /* restore the current window */
 	    aucmd_restbuf(&aco);
 
 	    /* stop if there is some error or buffer was deleted */
@@ -8259,23 +8474,24 @@ ex_doautoall(eap)
     check_cursor();	    /* just in case lines got deleted */
 }
 
 /*
  * Prepare for executing autocommands for (hidden) buffer "buf".
- * Search a window for the current buffer.  Save the cursor position and
- * screen offset.
+ * Search for a visible window containing the current buffer.  If there isn't
+ * one then use "aucmd_win".
  * Set "curbuf" and "curwin" to match "buf".
  * When FEAT_AUTOCMD is not defined another version is used, see below.
  */
     void
 aucmd_prepbuf(aco, buf)
     aco_save_T	*aco;		/* structure to save values in */
     buf_T	*buf;		/* new curbuf */
 {
     win_T	*win;
-
-    aco->new_curbuf = buf;
+#ifdef FEAT_WINDOWS
+    int		save_ea;
+#endif
 
     /* Find a window that is for the new buffer */
     if (buf == curbuf)		/* be quick when buf is curbuf */
 	win = curwin;
     else
@@ -8285,46 +8501,71 @@ aucmd_prepbuf(aco, buf)
 		break;
 #else
 	win = NULL;
 #endif
 
-    /*
-     * Prefer to use an existing window for the buffer, it has the least side
-     * effects (esp. if "buf" is curbuf).
-     * Otherwise, use curwin for "buf".  It might make some items in the
-     * window invalid.  At least save the cursor and topline.
-     */
+    /* Allocate "aucmd_win" when needed.  If this fails (out of memory) fall
+     * back to using the current window. */
+    if (win == NULL && aucmd_win == NULL)
+    {
+	win_alloc_aucmd_win();
+	if (aucmd_win == NULL)
+	    win = curwin;
+    }
+    if (win == NULL && aucmd_win_used)
+	/* Strange recursive autocommand, fall back to using the current
+	 * window.  Expect a few side effects... */
+	win = curwin;
+
+    aco->save_curwin = curwin;
+    aco->save_curbuf = curbuf;
     if (win != NULL)
     {
-	/* there is a window for "buf", make it the curwin */
-	aco->save_curwin = curwin;
+	/* There is a window for "buf" in the current tab page, make it the
+	 * curwin.  This is preferred, it has the least side effects (esp. if
+	 * "buf" is curbuf). */
+	aco->use_aucmd_win = FALSE;
 	curwin = win;
-	aco->save_buf = win->w_buffer;
-	aco->new_curwin = win;
     }
     else
     {
-	/* there is no window for "buf", use curwin */
-	aco->save_curwin = NULL;
-	aco->save_buf = curbuf;
-	--curbuf->b_nwindows;
-	curwin->w_buffer = buf;
+	/* There is no window for "buf", use "aucmd_win".  To minimize the side
+	 * effects, insert it in a the current tab page.
+	 * Anything related to a window (e.g., setting folds) may have
+	 * unexpected results. */
+	aco->use_aucmd_win = TRUE;
+	aucmd_win_used = TRUE;
+	aucmd_win->w_buffer = buf;
 	++buf->b_nwindows;
+	win_init_empty(aucmd_win); /* set cursor and topline to safe values */
+	vim_free(aucmd_win->w_localdir);
+	aucmd_win->w_localdir = NULL;
+
+	/* Make sure w_localdir and globaldir are NULL to avoid a chdir() in
+	 * win_enter_ext(). */
+	aucmd_win->w_localdir = NULL;
+	aco->globaldir = globaldir;
+	globaldir = NULL;
 
-	/* save cursor and topline, set them to safe values */
-	aco->save_cursor = curwin->w_cursor;
-	curwin->w_cursor.lnum = 1;
-	curwin->w_cursor.col = 0;
-	aco->save_topline = curwin->w_topline;
-	curwin->w_topline = 1;
-#ifdef FEAT_DIFF
-	aco->save_topfill = curwin->w_topfill;
-	curwin->w_topfill = 0;
+
+#ifdef FEAT_WINDOWS
+	/* Split the current window, put the aucmd_win in the upper half.
+	 * We don't want the BufEnter or WinEnter autocommands. */
+	block_autocmds();
+	make_snapshot(SNAP_AUCMD_IDX);
+	save_ea = p_ea;
+	p_ea = FALSE;
+	(void)win_split_ins(0, WSP_TOP, aucmd_win, 0);
+	(void)win_comp_pos();   /* recompute window positions */
+	p_ea = save_ea;
+	unblock_autocmds();
 #endif
+	curwin = aucmd_win;
     }
-
     curbuf = buf;
+    aco->new_curwin = curwin;
+    aco->new_curbuf = curbuf;
 }
 
 /*
  * Cleanup after executing autocommands for a (hidden) buffer.
  * Restore the window as it was (if possible).
@@ -8332,61 +8573,105 @@ aucmd_prepbuf(aco, buf)
  */
     void
 aucmd_restbuf(aco)
     aco_save_T	*aco;		/* structure holding saved values */
 {
-    if (aco->save_curwin != NULL)
+#ifdef FEAT_WINDOWS
+    int dummy;
+#endif
+
+    if (aco->use_aucmd_win)
+    {
+	--curbuf->b_nwindows;
+#ifdef FEAT_WINDOWS
+	/* Find "aucmd_win", it can't be closed, but it may be in another tab
+	 * page. Do not trigger autocommands here. */
+	block_autocmds();
+	if (curwin != aucmd_win)
+	{
+	    tabpage_T	*tp;
+	    win_T	*wp;
+
+	    FOR_ALL_TAB_WINDOWS(tp, wp)
+	    {
+		if (wp == aucmd_win)
+		{
+		    if (tp != curtab)
+			goto_tabpage_tp(tp);
+		    win_goto(aucmd_win);
+		    break;
+		}
+	    }
+	}
+
+	/* Remove the window and frame from the tree of frames. */
+	(void)winframe_remove(curwin, &dummy, NULL);
+	win_remove(curwin, NULL);
+	aucmd_win_used = FALSE;
+	last_status(FALSE);	    /* may need to remove last status line */
+	restore_snapshot(SNAP_AUCMD_IDX, FALSE);
+	(void)win_comp_pos();   /* recompute window positions */
+	unblock_autocmds();
+
+	if (win_valid(aco->save_curwin))
+	    curwin = aco->save_curwin;
+	else
+	    /* Hmm, original window disappeared.  Just use the first one. */
+	    curwin = firstwin;
+# ifdef FEAT_EVAL
+	vars_clear(&aucmd_win->w_vars.dv_hashtab);  /* free all w: variables */
+	hash_init(&aucmd_win->w_vars.dv_hashtab);   /* re-use the hashtab */
+# endif
+#else
+	curwin = aco->save_curwin;
+#endif
+	curbuf = curwin->w_buffer;
+
+	vim_free(globaldir);
+	globaldir = aco->globaldir;
+
+	/* the buffer contents may have changed */
+	check_cursor();
+	if (curwin->w_topline > curbuf->b_ml.ml_line_count)
+	{
+	    curwin->w_topline = curbuf->b_ml.ml_line_count;
+#ifdef FEAT_DIFF
+	    curwin->w_topfill = 0;
+#endif
+	}
+#if defined(FEAT_GUI)
+	/* Hide the scrollbars from the aucmd_win and update. */
+	gui_mch_enable_scrollbar(&aucmd_win->w_scrollbars[SBAR_LEFT], FALSE);
+	gui_mch_enable_scrollbar(&aucmd_win->w_scrollbars[SBAR_RIGHT], FALSE);
+	gui_may_update_scrollbars();
+#endif
+    }
+    else
     {
 	/* restore curwin */
 #ifdef FEAT_WINDOWS
 	if (win_valid(aco->save_curwin))
 #endif
 	{
-	    /* restore the buffer which was previously edited by curwin, if
-	     * it's still the same window and it's valid */
+	    /* Restore the buffer which was previously edited by curwin, if
+	     * it was changed, we are still the same window and the buffer is
+	     * valid. */
 	    if (curwin == aco->new_curwin
-		    && buf_valid(aco->save_buf)
-		    && aco->save_buf->b_ml.ml_mfp != NULL)
+		    && curbuf != aco->new_curbuf
+		    && buf_valid(aco->new_curbuf)
+		    && aco->new_curbuf->b_ml.ml_mfp != NULL)
 	    {
 		--curbuf->b_nwindows;
-		curbuf = aco->save_buf;
+		curbuf = aco->new_curbuf;
 		curwin->w_buffer = curbuf;
 		++curbuf->b_nwindows;
 	    }
 
 	    curwin = aco->save_curwin;
 	    curbuf = curwin->w_buffer;
 	}
     }
-    else
-    {
-	/* restore buffer for curwin if it still exists and is loaded */
-	if (buf_valid(aco->save_buf) && aco->save_buf->b_ml.ml_mfp != NULL)
-	{
-	    --curbuf->b_nwindows;
-	    curbuf = aco->save_buf;
-	    curwin->w_buffer = curbuf;
-	    ++curbuf->b_nwindows;
-	    curwin->w_cursor = aco->save_cursor;
-	    check_cursor();
-	    /* check topline < line_count, in case lines got deleted */
-	    if (aco->save_topline <= curbuf->b_ml.ml_line_count)
-	    {
-		curwin->w_topline = aco->save_topline;
-#ifdef FEAT_DIFF
-		curwin->w_topfill = aco->save_topfill;
-#endif
-	    }
-	    else
-	    {
-		curwin->w_topline = curbuf->b_ml.ml_line_count;
-#ifdef FEAT_DIFF
-		curwin->w_topfill = 0;
-#endif
-	    }
-	}
-    }
 }
 
 static int	autocmd_nested = FALSE;
 
 /*
@@ -8521,10 +8806,11 @@ apply_autocmds_group(event, fname, fname
     buf_T	*old_curbuf;
     int		retval = FALSE;
     char_u	*save_sourcing_name;
     linenr_T	save_sourcing_lnum;
     char_u	*save_autocmd_fname;
+    int		save_autocmd_fname_full;
     int		save_autocmd_bufnr;
     char_u	*save_autocmd_match;
     int		save_autocmd_busy;
     int		save_autocmd_nested;
     static int	nesting = 0;
@@ -8599,10 +8885,11 @@ apply_autocmds_group(event, fname, fname
 
     /*
      * Save the autocmd_* variables and info about the current buffer.
      */
     save_autocmd_fname = autocmd_fname;
+    save_autocmd_fname_full = autocmd_fname_full;
     save_autocmd_bufnr = autocmd_bufnr;
     save_autocmd_match = autocmd_match;
     save_autocmd_busy = autocmd_busy;
     save_autocmd_nested = autocmd_nested;
     save_changed = curbuf->b_changed;
@@ -8616,18 +8903,19 @@ apply_autocmds_group(event, fname, fname
     if (fname_io == NULL)
     {
 	if (fname != NULL && *fname != NUL)
 	    autocmd_fname = fname;
 	else if (buf != NULL)
-	    autocmd_fname = buf->b_fname;
+	    autocmd_fname = buf->b_ffname;
 	else
 	    autocmd_fname = NULL;
     }
     else
 	autocmd_fname = fname_io;
     if (autocmd_fname != NULL)
-	autocmd_fname = FullName_save(autocmd_fname, FALSE);
+	autocmd_fname = vim_strsave(autocmd_fname);
+    autocmd_fname_full = FALSE; /* call FullName_save() later */
 
     /*
      * Set the buffer number to be used for <abuf>.
      */
     if (buf == NULL)
@@ -8665,13 +8953,15 @@ apply_autocmds_group(event, fname, fname
 	fname = vim_strsave(fname);	/* make a copy, so we can change it */
     }
     else
     {
 	sfname = vim_strsave(fname);
-	/* Don't try expanding FileType, Syntax, WindowID or QuickFixCmd* */
+	/* Don't try expanding FileType, Syntax, FuncUndefined, WindowID or
+	 * QuickFixCmd* */
 	if (event == EVENT_FILETYPE
 		|| event == EVENT_SYNTAX
+		|| event == EVENT_FUNCUNDEFINED
 		|| event == EVENT_REMOTEREPLY
 		|| event == EVENT_SPELLFILEMISSING
 		|| event == EVENT_QUICKFIXCMDPRE
 		|| event == EVENT_QUICKFIXCMDPOST)
 	    fname = vim_strsave(fname);
@@ -8808,10 +9098,11 @@ apply_autocmds_group(event, fname, fname
     vim_free(sourcing_name);
     sourcing_name = save_sourcing_name;
     sourcing_lnum = save_sourcing_lnum;
     vim_free(autocmd_fname);
     autocmd_fname = save_autocmd_fname;
+    autocmd_fname_full = save_autocmd_fname_full;
     autocmd_bufnr = save_autocmd_bufnr;
     autocmd_match = save_autocmd_match;
 #ifdef FEAT_EVAL
     current_SID = save_current_SID;
     restore_funccal(save_funccalp);
@@ -8916,11 +9207,11 @@ auto_next_pat(apc, stop_at_last)
 
     for (ap = apc->curpat; ap != NULL && !got_int; ap = ap->next)
     {
 	apc->curpat = NULL;
 
-	/* only use a pattern when it has not been removed, has commands and
+	/* Only use a pattern when it has not been removed, has commands and
 	 * the group matches. For buffer-local autocommands only check the
 	 * buffer number. */
 	if (ap->pat != NULL && ap->cmds != NULL
 		&& (apc->group == AUGROUP_ALL || apc->group == ap->group))
 	{
@@ -8965,16 +9256,15 @@ auto_next_pat(apc, stop_at_last)
 /*
  * Get next autocommand command.
  * Called by do_cmdline() to get the next line for ":if".
  * Returns allocated string, or NULL for end of autocommands.
  */
-/* ARGSUSED */
     static char_u *
 getnextac(c, cookie, indent)
-    int	    c;		    /* not used */
+    int	    c UNUSED;
     void    *cookie;
-    int	    indent;	    /* not used */
+    int	    indent UNUSED;
 {
     AutoPatCmd	    *acp = (AutoPatCmd *)cookie;
     char_u	    *retval;
     AutoCmd	    *ac;
 
@@ -9081,14 +9371,13 @@ has_autocmd(event, sfname, buf)
 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
 /*
  * Function given to ExpandGeneric() to obtain the list of autocommand group
  * names.
  */
-/*ARGSUSED*/
     char_u *
 get_augroup_name(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     if (idx == augroups.ga_len)		/* add "END" add the end */
 	return (char_u *)"END";
     if (idx >= augroups.ga_len)		/* end of list */
@@ -9102,11 +9391,11 @@ static int include_groups = FALSE;
 
     char_u  *
 set_context_in_autocmd(xp, arg, doautocmd)
     expand_T	*xp;
     char_u	*arg;
-    int		doautocmd;	/* TRUE for :doautocmd, FALSE for :autocmd */
+    int		doautocmd;	/* TRUE for :doauto*, FALSE for :autocmd */
 {
     char_u	*p;
     int		group;
 
     /* check for a group name, skip it if present */
@@ -9150,14 +9439,13 @@ set_context_in_autocmd(xp, arg, doautocm
 }
 
 /*
  * Function given to ExpandGeneric() to obtain the list of event names.
  */
-/*ARGSUSED*/
     char_u *
 get_event_name(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     if (idx < augroups.ga_len)		/* First list group names, if wanted */
     {
 	if (!include_groups || AUGROUP_NAME(idx) == NULL)
@@ -9252,30 +9540,26 @@ au_exists(arg)
      * If there isn't any, return FALSE;
      * If there is one and no pattern given, return TRUE; */
     ap = first_autopat[(int)event];
     if (ap == NULL)
 	goto theend;
-    if (pattern == NULL)
-    {
-	retval = TRUE;
-	goto theend;
-    }
 
     /* if pattern is "<buffer>", special handling is needed which uses curbuf */
     /* for pattern "<buffer=N>, fnamecmp() will work fine */
-    if (STRICMP(pattern, "<buffer>") == 0)
+    if (pattern != NULL && STRICMP(pattern, "<buffer>") == 0)
 	buflocal_buf = curbuf;
 
     /* Check if there is an autocommand with the given pattern. */
     for ( ; ap != NULL; ap = ap->next)
 	/* only use a pattern when it has not been removed and has commands. */
 	/* For buffer-local autocommands, fnamecmp() works fine. */
 	if (ap->pat != NULL && ap->cmds != NULL
 	    && (group == AUGROUP_ALL || ap->group == group)
-	    && (buflocal_buf == NULL
-		 ? fnamecmp(ap->pat, pattern) == 0
-		 : ap->buflocal_nr == buflocal_buf->b_fnum))
+	    && (pattern == NULL
+		|| (buflocal_buf == NULL
+		    ? fnamecmp(ap->pat, pattern) == 0
+		    : ap->buflocal_nr == buflocal_buf->b_fnum)))
 	{
 	    retval = TRUE;
 	    break;
 	}
 
@@ -9294,25 +9578,29 @@ theend:
     void
 aucmd_prepbuf(aco, buf)
     aco_save_T	*aco;		/* structure to save values in */
     buf_T	*buf;		/* new curbuf */
 {
-    aco->save_buf = curbuf;
+    aco->save_curbuf = curbuf;
+    --curbuf->b_nwindows;
     curbuf = buf;
     curwin->w_buffer = buf;
+    ++curbuf->b_nwindows;
 }
 
 /*
  * Restore after executing commands for a (hidden) buffer.
  * This is the non-autocommand version.
  */
     void
 aucmd_restbuf(aco)
     aco_save_T	*aco;		/* structure holding saved values */
 {
-    curbuf = aco->save_buf;
+    --curbuf->b_nwindows;
+    curbuf = aco->save_curbuf;
     curwin->w_buffer = curbuf;
+    ++curbuf->b_nwindows;
 }
 
 #endif	/* FEAT_AUTOCMD */
 
 
@@ -9465,17 +9753,16 @@ match_file_list(list, sfname, ffname)
  * If FEAT_OSFILETYPE defined then pass initial <type> through unchanged. Eg:
  * '<html>myfile' becomes '<html>^myfile$' -- leonard.
  *
  * Returns NULL when out of memory.
  */
-/*ARGSUSED*/
     char_u *
 file_pat_to_reg_pat(pat, pat_end, allow_dirs, no_bslash)
     char_u	*pat;
     char_u	*pat_end;	/* first char after pattern or NULL */
     char	*allow_dirs;	/* Result passed back out in here */
-    int		no_bslash;	/* Don't use a backward slash as pathsep */
+    int		no_bslash UNUSED; /* Don't use a backward slash as pathsep */
 {
     int		size;
     char_u	*endp;
     char_u	*reg_pat;
     char_u	*p;
--- vim72.orig/src/fold.c
+++ vim72/src/fold.c
@@ -46,11 +46,11 @@ typedef struct
 static void newFoldLevelWin __ARGS((win_T *wp));
 static int checkCloseRec __ARGS((garray_T *gap, linenr_T lnum, int level));
 static int foldFind __ARGS((garray_T *gap, linenr_T lnum, fold_T **fpp));
 static int foldLevelWin __ARGS((win_T *wp, linenr_T lnum));
 static void checkupdate __ARGS((win_T *wp));
-static void setFoldRepeat __ARGS((linenr_T lnum, long count, int open));
+static void setFoldRepeat __ARGS((linenr_T lnum, long count, int do_open));
 static linenr_T setManualFold __ARGS((linenr_T lnum, int opening, int recurse, int *donep));
 static linenr_T setManualFoldWin __ARGS((win_T *wp, linenr_T lnum, int opening, int recurse, int *donep));
 static void foldOpenNested __ARGS((fold_T *fpr));
 static void deleteFoldEntry __ARGS((garray_T *gap, int idx, int recursive));
 static void foldMarkAdjustRecurse __ARGS((garray_T *gap, linenr_T line1, linenr_T line2, long amount, long amount_after));
@@ -738,11 +738,11 @@ deleteFold(start, end, recursive, had_vi
     garray_T	*gap;
     fold_T	*fp;
     garray_T	*found_ga;
     fold_T	*found_fp = NULL;
     linenr_T	found_off = 0;
-    int		use_level = FALSE;
+    int		use_level;
     int		maybe_small = FALSE;
     int		level = 0;
     linenr_T	lnum = start;
     linenr_T	lnum_off;
     int		did_one = FALSE;
@@ -755,10 +755,11 @@ deleteFold(start, end, recursive, had_vi
     {
 	/* Find the deepest fold for "start". */
 	gap = &curwin->w_folds;
 	found_ga = NULL;
 	lnum_off = 0;
+	use_level = FALSE;
 	for (;;)
 	{
 	    if (!foldFind(gap, lnum - lnum_off, &fp))
 		break;
 	    /* lnum is inside this fold, remember info */
@@ -781,24 +782,25 @@ deleteFold(start, end, recursive, had_vi
 	    ++lnum;
 	}
 	else
 	{
 	    lnum = found_fp->fd_top + found_fp->fd_len + found_off;
-	    did_one = TRUE;
 
 	    if (foldmethodIsManual(curwin))
 		deleteFoldEntry(found_ga,
 		    (int)(found_fp - (fold_T *)found_ga->ga_data), recursive);
 	    else
 	    {
-		if (found_fp->fd_top + found_off < first_lnum)
-		    first_lnum = found_fp->fd_top;
-		if (lnum > last_lnum)
+		if (first_lnum > found_fp->fd_top + found_off)
+		    first_lnum = found_fp->fd_top + found_off;
+		if (last_lnum < lnum)
 		    last_lnum = lnum;
-		parseMarker(curwin);
+		if (!did_one)
+		    parseMarker(curwin);
 		deleteFoldMarkers(found_fp, recursive, found_off);
 	    }
+	    did_one = TRUE;
 
 	    /* redraw window */
 	    changed_window_setting();
 	}
     }
@@ -809,10 +811,14 @@ deleteFold(start, end, recursive, had_vi
 	/* Force a redraw to remove the Visual highlighting. */
 	if (had_visual)
 	    redraw_curbuf_later(INVERTED);
 #endif
     }
+    else
+	/* Deleting markers may make cursor column invalid. */
+	check_cursor_col();
+
     if (last_lnum > 0)
 	changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L);
 }
 
 /* clearFolding() {{{2 */
@@ -841,11 +847,11 @@ foldUpdate(wp, top, bot)
     linenr_T	bot;
 {
     fold_T	*fp;
 
     /* Mark all folds from top to bot as maybe-small. */
-    (void)foldFind(&curwin->w_folds, curwin->w_cursor.lnum, &fp);
+    (void)foldFind(&curwin->w_folds, top, &fp);
     while (fp < (fold_T *)curwin->w_folds.ga_data + curwin->w_folds.ga_len
 	    && fp->fd_top < bot)
     {
 	fp->fd_small = MAYBE;
 	++fp;
@@ -1045,19 +1051,18 @@ find_wl_entry(win, lnum)
     win_T	*win;
     linenr_T	lnum;
 {
     int		i;
 
-    if (win->w_lines_valid > 0)
-	for (i = 0; i < win->w_lines_valid; ++i)
-	    if (win->w_lines[i].wl_valid)
-	    {
-		if (lnum < win->w_lines[i].wl_lnum)
-		    return -1;
-		if (lnum <= win->w_lines[i].wl_lastlnum)
-		    return i;
-	    }
+    for (i = 0; i < win->w_lines_valid; ++i)
+	if (win->w_lines[i].wl_valid)
+	{
+	    if (lnum < win->w_lines[i].wl_lnum)
+		return -1;
+	    if (lnum <= win->w_lines[i].wl_lastlnum)
+		return i;
+	}
     return -1;
 }
 
 /* foldAdjustVisual() {{{2 */
 #ifdef FEAT_VISUAL
@@ -1239,22 +1244,22 @@ checkupdate(wp)
 /*
  * Open or close fold for current window at line "lnum".
  * Repeat "count" times.
  */
     static void
-setFoldRepeat(lnum, count, open)
+setFoldRepeat(lnum, count, do_open)
     linenr_T	lnum;
     long	count;
-    int		open;
+    int		do_open;
 {
     int		done;
     long	n;
 
     for (n = 0; n < count; ++n)
     {
 	done = DONE_NOTHING;
-	(void)setManualFold(lnum, open, FALSE, &done);
+	(void)setManualFold(lnum, do_open, FALSE, &done);
 	if (!(done & DONE_ACTION))
 	{
 	    /* Only give an error message when no fold could be opened. */
 	    if (n == 0 && !(done & DONE_FOLD))
 		EMSG(_(e_nofold));
@@ -1599,15 +1604,15 @@ foldMarkAdjustRecurse(gap, line1, line2,
 		else
 		    fp->fd_top += amount;
 	    }
 	    else
 	    {
-		/* 2, 3, or 5: need to correct nested folds too */
-		foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top,
-				  line2 - fp->fd_top, amount, amount_after);
 		if (fp->fd_top < top)
 		{
+		    /* 2 or 3: need to correct nested folds too */
+		    foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top,
+				  line2 - fp->fd_top, amount, amount_after);
 		    if (last <= line2)
 		    {
 			/* 2. fold contains line1, line2 is below fold */
 			if (amount == MAXLNUM)
 			    fp->fd_len = line1 - fp->fd_top;
@@ -1620,11 +1625,15 @@ foldMarkAdjustRecurse(gap, line1, line2,
 			fp->fd_len += amount_after;
 		    }
 		}
 		else
 		{
-		    /* 5. fold is below line1 and contains line2 */
+		    /* 5. fold is below line1 and contains line2; need to
+		     * correct nested folds too */
+		    foldMarkAdjustRecurse(&fp->fd_nested, line1 - fp->fd_top,
+				  line2 - fp->fd_top, amount,
+				  amount_after + (fp->fd_top - top));
 		    if (amount == MAXLNUM)
 		    {
 			fp->fd_len -= line2 - fp->fd_top + 1;
 			fp->fd_top = line1;
 		    }
@@ -1920,11 +1929,11 @@ get_foldtext(wp, lnum, lnume, foldinfo,
     char_u	*text = NULL;
 
 #ifdef FEAT_EVAL
     if (*wp->w_p_fdt != NUL)
     {
-	char_u	dashes[51];
+	char_u	dashes[MAX_LEVEL + 2];
 	win_T	*save_curwin;
 	int	level;
 	char_u	*p;
 
 	/* Set "v:foldstart" and "v:foldend". */
@@ -1932,12 +1941,12 @@ get_foldtext(wp, lnum, lnume, foldinfo,
 	set_vim_var_nr(VV_FOLDEND, lnume);
 
 	/* Set "v:folddashes" to a string of "level" dashes. */
 	/* Set "v:foldlevel" to "level". */
 	level = foldinfo->fi_level;
-	if (level > 50)
-	    level = 50;
+	if (level > (int)sizeof(dashes) - 1)
+	    level = (int)sizeof(dashes) - 1;
 	vim_memset(dashes, '-', (size_t)level);
 	dashes[level] = NUL;
 	set_vim_var_string(VV_FOLDDASHES, dashes, -1);
 	set_vim_var_nr(VV_FOLDLEVEL, (long)level);
 	save_curwin = curwin;
@@ -2244,10 +2253,44 @@ foldUpdateIEMS(wp, top, bot)
 	    if (fline.lvl >= 0)
 		break;
 	}
     }
 
+    /*
+     * If folding is defined by the syntax, it is possible that a change in
+     * one line will cause all sub-folds of the current fold to change (e.g.,
+     * closing a C-style comment can cause folds in the subsequent lines to
+     * appear). To take that into account we should adjust the value of "bot"
+     * to point to the end of the current fold:
+     */
+    if (foldlevelSyntax == getlevel)
+    {
+	garray_T *gap = &wp->w_folds;
+	fold_T	 *fp = NULL;
+	int	  current_fdl = 0;
+	linenr_T  fold_start_lnum = 0;
+	linenr_T  lnum_rel = fline.lnum;
+
+	while (current_fdl < fline.lvl)
+	{
+	    if (!foldFind(gap, lnum_rel, &fp))
+		break;
+	    ++current_fdl;
+
+	    fold_start_lnum += fp->fd_top;
+	    gap = &fp->fd_nested;
+	    lnum_rel -= fp->fd_top;
+	}
+	if (fp != NULL && current_fdl == fline.lvl)
+	{
+	    linenr_T fold_end_lnum = fold_start_lnum + fp->fd_len;
+
+	    if (fold_end_lnum > bot)
+		bot = fold_end_lnum;
+	}
+    }
+
     start = fline.lnum;
     end = bot;
     /* Do at least one line. */
     if (start > end && end < wp->w_buffer->b_ml.ml_line_count)
 	end = start;
@@ -2805,10 +2848,12 @@ foldSplit(gap, i, top, bot)
 	return;
     fp = (fold_T *)gap->ga_data + i;
     fp[1].fd_top = bot + 1;
     fp[1].fd_len = fp->fd_len - (fp[1].fd_top - fp->fd_top);
     fp[1].fd_flags = fp->fd_flags;
+    fp[1].fd_small = MAYBE;
+    fp->fd_small = MAYBE;
 
     /* Move nested folds below bot to new fold.  There can't be
      * any between top and bot, they have been removed by the caller. */
     gap1 = &fp->fd_nested;
     gap2 = &fp[1].fd_nested;
@@ -3191,12 +3236,12 @@ foldlevelMarker(flp)
 		if (n > 0)
 		{
 		    flp->lvl = n;
 		    flp->lvl_next = n - 1;
 		    /* never start a fold with an end marker */
-		    if (flp->lvl_next > flp->lvl)
-			flp->lvl_next = flp->lvl;
+		    if (flp->lvl_next > start_lvl)
+			flp->lvl_next = start_lvl;
 		}
 	    }
 	    else
 		--flp->lvl_next;
 	}
--- vim72.orig/src/getchar.c
+++ vim72/src/getchar.c
@@ -20,11 +20,11 @@
 
 /*
  * These buffers are used for storing:
  * - stuffed characters: A command that is translated into another command.
  * - redo characters: will redo the last change.
- * - recorded chracters: for the "q" command.
+ * - recorded characters: for the "q" command.
  *
  * The bytes are stored like in the typeahead buffer:
  * - K_SPECIAL introduces a special key (two more bytes follow).  A literal
  *   K_SPECIAL is stored as K_SPECIAL KS_SPECIAL KE_FILLER.
  * - CSI introduces a GUI termcap code (also when gui.in_use is FALSE,
@@ -127,11 +127,11 @@ static void	closescript __ARGS((void));
 static int	vgetorpeek __ARGS((int));
 static void	map_free __ARGS((mapblock_T **));
 static void	validate_maphash __ARGS((void));
 static void	showmap __ARGS((mapblock_T *mp, int local));
 #ifdef FEAT_EVAL
-static char_u	*eval_map_expr __ARGS((char_u *str));
+static char_u	*eval_map_expr __ARGS((char_u *str, int c));
 #endif
 
 /*
  * Free and clear a buffer.
  */
@@ -1281,11 +1281,11 @@ free_typebuf()
 {
     if (typebuf.tb_buf == typebuf_init)
 	EMSG2(_(e_intern2), "Free typebuf 1");
     else
 	vim_free(typebuf.tb_buf);
-    if (typebuf.tb_buf == noremapbuf_init)
+    if (typebuf.tb_noremap == noremapbuf_init)
 	EMSG2(_(e_intern2), "Free typebuf 2");
     else
 	vim_free(typebuf.tb_noremap);
 }
 
@@ -1307,10 +1307,13 @@ save_typebuf()
 	return FAIL;
     }
     return OK;
 }
 
+static int old_char = -1;	/* character put back by vungetc() */
+static int old_mod_mask;	/* mod_mask for ungotten character */
+
 #if defined(FEAT_EVAL) || defined(FEAT_EX_EXTRA) || defined(PROTO)
 
 /*
  * Save all three kinds of typeahead, so that the user must type at a prompt.
  */
@@ -1321,10 +1324,14 @@ save_typeahead(tp)
     tp->save_typebuf = typebuf;
     tp->typebuf_valid = (alloc_typebuf() == OK);
     if (!tp->typebuf_valid)
 	typebuf = tp->save_typebuf;
 
+    tp->old_char = old_char;
+    tp->old_mod_mask = old_mod_mask;
+    old_char = -1;
+
     tp->save_stuffbuff = stuffbuff;
     stuffbuff.bh_first.b_next = NULL;
 # ifdef USE_INPUT_BUF
     tp->save_inputbuf = get_input_buf();
 # endif
@@ -1342,10 +1349,13 @@ restore_typeahead(tp)
     {
 	free_typebuf();
 	typebuf = tp->save_typebuf;
     }
 
+    old_char = tp->old_char;
+    old_mod_mask = tp->old_mod_mask;
+
     free_buff(&stuffbuff);
     stuffbuff = tp->save_stuffbuff;
 # ifdef USE_INPUT_BUF
     set_input_buf(tp->save_inputbuf);
 # endif
@@ -1497,21 +1507,18 @@ updatescript(c)
 }
 
 #define KL_PART_KEY -1		/* keylen value for incomplete key-code */
 #define KL_PART_MAP -2		/* keylen value for incomplete mapping */
 
-static int old_char = -1;	/* character put back by vungetc() */
-static int old_mod_mask;	/* mod_mask for ungotten character */
-
 /*
  * Get the next input character.
  * Can return a special key or a multi-byte character.
  * Can return NUL when called recursively, use safe_vgetc() if that's not
  * wanted.
  * This translates escaped K_SPECIAL and CSI bytes to a K_SPECIAL or CSI byte.
  * Collects the bytes of a multibyte character into the whole character.
- * Returns the modifers in the global "mod_mask".
+ * Returns the modifiers in the global "mod_mask".
  */
     int
 vgetc()
 {
     int		c, c2;
@@ -2380,10 +2387,21 @@ vgetorpeek(advance)
 		    }
 
 		    /* complete match */
 		    if (keylen >= 0 && keylen <= typebuf.tb_len)
 		    {
+#ifdef FEAT_EVAL
+			int save_m_expr;
+			int save_m_noremap;
+			int save_m_silent;
+			char_u *save_m_keys;
+			char_u *save_m_str;
+#else
+# define save_m_noremap mp->m_noremap
+# define save_m_silent mp->m_silent
+#endif
+
 			/* write chars to script file(s) */
 			if (keylen > typebuf.tb_maplen)
 			    gotchars(typebuf.tb_buf + typebuf.tb_off
 							  + typebuf.tb_maplen,
 						  keylen - typebuf.tb_maplen);
@@ -2422,10 +2440,20 @@ vgetorpeek(advance)
 							      0, TRUE, FALSE);
 			}
 #endif
 
 #ifdef FEAT_EVAL
+			/* Copy the values from *mp that are used, because
+			 * evaluating the expression may invoke a function
+			 * that redefines the mapping, thereby making *mp
+			 * invalid. */
+			save_m_expr = mp->m_expr;
+			save_m_noremap = mp->m_noremap;
+			save_m_silent = mp->m_silent;
+			save_m_keys = NULL;  /* only saved when needed */
+			save_m_str = NULL;  /* only saved when needed */
+
 			/*
 			 * Handle ":map <expr>": evaluate the {rhs} as an
 			 * expression.  Save and restore the typeahead so that
 			 * getchar() can be used.  Also save and restore the
 			 * command line for "normal :".
@@ -2437,11 +2465,13 @@ vgetorpeek(advance)
 
 			    save_typeahead(&tabuf);
 			    if (tabuf.typebuf_valid)
 			    {
 				vgetc_busy = 0;
-				s = eval_map_expr(mp->m_str);
+				save_m_keys = vim_strsave(mp->m_keys);
+				save_m_str = vim_strsave(mp->m_str);
+				s = eval_map_expr(save_m_str, NUL);
 				vgetc_busy = save_vgetc_busy;
 			    }
 			    else
 				s = NULL;
 			    restore_typeahead(&tabuf);
@@ -2460,22 +2490,37 @@ vgetorpeek(advance)
 			 */
 			if (s == NULL)
 			    i = FAIL;
 			else
 			{
-			    i = ins_typebuf(s,
-				    mp->m_noremap != REMAP_YES
-					    ? mp->m_noremap
-					    : STRNCMP(s, mp->m_keys,
-							  (size_t)keylen) != 0
-						     ? REMAP_YES : REMAP_SKIP,
-				0, TRUE, cmd_silent || mp->m_silent);
+			    int noremap;
+
+			    if (save_m_noremap != REMAP_YES)
+				noremap = save_m_noremap;
+			    else if (
+#ifdef FEAT_EVAL
+				STRNCMP(s, save_m_keys != NULL
+						   ? save_m_keys : mp->m_keys,
+							 (size_t)keylen)
+#else
+				STRNCMP(s, mp->m_keys, (size_t)keylen)
+#endif
+				   != 0)
+				noremap = REMAP_YES;
+			    else
+				noremap = REMAP_SKIP;
+			    i = ins_typebuf(s, noremap,
+					0, TRUE, cmd_silent || save_m_silent);
 #ifdef FEAT_EVAL
-			    if (mp->m_expr)
+			    if (save_m_expr)
 				vim_free(s);
 #endif
 			}
+#ifdef FEAT_EVAL
+			vim_free(save_m_keys);
+			vim_free(save_m_str);
+#endif
 			if (i == FAIL)
 			{
 			    c = -1;
 			    break;
 			}
@@ -3311,11 +3356,11 @@ do_map(maptype, arg, mode, abbrev)
 			if (vim_iswordc(keys[n]) != vim_iswordc(keys[len - 2]))
 			{
 			    retval = 1;
 			    goto theend;
 			}
-	    /* An abbrevation cannot contain white space. */
+	    /* An abbreviation cannot contain white space. */
 	    for (n = 0; n < len; ++n)
 		if (vim_iswhite(keys[n]))
 		{
 		    retval = 1;
 		    goto theend;
@@ -3699,15 +3744,14 @@ get_map_mode(cmdp, forceit)
 
 /*
  * Clear all mappings or abbreviations.
  * 'abbr' should be FALSE for mappings, TRUE for abbreviations.
  */
-/*ARGSUSED*/
     void
 map_clear(cmdp, arg, forceit, abbr)
     char_u	*cmdp;
-    char_u	*arg;
+    char_u	*arg UNUSED;
     int		forceit;
     int		abbr;
 {
     int		mode;
 #ifdef FEAT_LOCALMAP
@@ -3732,17 +3776,16 @@ map_clear(cmdp, arg, forceit, abbr)
 }
 
 /*
  * Clear all mappings in "mode".
  */
-/*ARGSUSED*/
     void
 map_clear_int(buf, mode, local, abbr)
-    buf_T	*buf;	    /* buffer for local mappings */
-    int		mode;	    /* mode in which to delete */
-    int		local;	    /* TRUE for buffer-local mappings */
-    int		abbr;	    /* TRUE for abbreviations */
+    buf_T	*buf UNUSED;	/* buffer for local mappings */
+    int		mode;		/* mode in which to delete */
+    int		local UNUSED;	/* TRUE for buffer-local mappings */
+    int		abbr;		/* TRUE for abbreviations */
 {
     mapblock_T	*mp, **mpp;
     int		hash;
     int		new_hash;
 
@@ -3814,11 +3857,15 @@ showmap(mp, local)
     int		local;	    /* TRUE for buffer-local map */
 {
     int len = 1;
 
     if (msg_didout || msg_silent != 0)
+    {
 	msg_putchar('\n');
+	if (got_int)	    /* 'q' typed at MORE prompt */
+	    return;
+    }
     if ((mp->m_mode & (INSERT + CMDLINE)) == INSERT + CMDLINE)
 	msg_putchar('!');			/* :map! */
     else if (mp->m_mode & INSERT)
 	msg_putchar('i');			/* :imap */
     else if (mp->m_mode & LANGMAP)
@@ -4261,11 +4308,11 @@ check_abbr(c, ptr, col, mincol)
 	/* no remapping implies no abbreviation */
 	return FALSE;
 
     /*
      * Check for word before the cursor: If it ends in a keyword char all
-     * chars before it must be al keyword chars or non-keyword chars, but not
+     * chars before it must be keyword chars or non-keyword chars, but not
      * white space. If it ends in a non-keyword char we accept any characters
      * before it except white space.
      */
     if (col == 0)				/* cannot be an abbr. */
 	return FALSE;
@@ -4356,13 +4403,13 @@ check_abbr(c, ptr, col, mincol)
 	     *
 	     * Character CTRL-] is treated specially - it completes the
 	     * abbreviation, but is not inserted into the input stream.
 	     */
 	    j = 0;
-					/* special key code, split up */
 	    if (c != Ctrl_RSB)
 	    {
+					/* special key code, split up */
 		if (IS_SPECIAL(c) || c == K_SPECIAL)
 		{
 		    tb[j++] = K_SPECIAL;
 		    tb[j++] = K_SECOND(c);
 		    tb[j++] = K_THIRD(c);
@@ -4387,11 +4434,11 @@ check_abbr(c, ptr, col, mincol)
 					/* insert the last typed char */
 		(void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent);
 	    }
 #ifdef FEAT_EVAL
 	    if (mp->m_expr)
-		s = eval_map_expr(mp->m_str);
+		s = eval_map_expr(mp->m_str, c);
 	    else
 #endif
 		s = mp->m_str;
 	    if (s != NULL)
 	    {
@@ -4423,12 +4470,13 @@ check_abbr(c, ptr, col, mincol)
 /*
  * Evaluate the RHS of a mapping or abbreviations and take care of escaping
  * special characters.
  */
     static char_u *
-eval_map_expr(str)
+eval_map_expr(str, c)
     char_u	*str;
+    int		c;	    /* NUL or typed character for abbreviation */
 {
     char_u	*res;
     char_u	*p;
     char_u	*save_cmd;
     pos_T	save_cursor;
@@ -4441,10 +4489,11 @@ eval_map_expr(str)
      * effects.  Also restore the cursor position. */
     ++textlock;
 #ifdef FEAT_EX_EXTRA
     ++ex_normal_lock;
 #endif
+    set_vim_var_char(c);  /* set v:char to the typed character */
     save_cursor = curwin->w_cursor;
     p = eval_to_string(str, NULL, FALSE);
     --textlock;
 #ifdef FEAT_EX_EXTRA
     --ex_normal_lock;
@@ -4700,11 +4749,11 @@ makemap(fd, buf)
 		    }
 		    if (c1 && putc(c1, fd) < 0)
 			return FAIL;
 		    if (mp->m_noremap != REMAP_YES && fprintf(fd, "nore") < 0)
 			return FAIL;
-		    if (fprintf(fd, cmd) < 0)
+		    if (fputs(cmd, fd) < 0)
 			return FAIL;
 		    if (buf != NULL && fputs(" <buffer>", fd) < 0)
 			return FAIL;
 		    if (mp->m_silent && fputs(" <silent>", fd) < 0)
 			return FAIL;
@@ -4799,11 +4848,11 @@ put_escstr(fd, strstart, what)
 		c = TO_SPECIAL(str[1], str[2]);
 		str += 2;
 	    }
 	    if (IS_SPECIAL(c) || modifiers)	/* special key */
 	    {
-		if (fprintf(fd, (char *)get_special_key_name(c, modifiers)) < 0)
+		if (fputs((char *)get_special_key_name(c, modifiers), fd) < 0)
 		    return FAIL;
 		continue;
 	    }
 	}
 
--- vim72.orig/src/globals.h
+++ vim72/src/globals.h
@@ -480,12 +480,14 @@ EXTERN char	*foreground_argument INIT(=
 # endif
 
 /*
  * While executing external commands or in Ex mode, should not insert GUI
  * events in the input buffer: Set hold_gui_events to non-zero.
+ *
+ * volatile because it is used in signal handler sig_sysmouse().
  */
-EXTERN int	hold_gui_events INIT(= 0);
+EXTERN volatile int hold_gui_events INIT(= 0);
 
 /*
  * When resizing the shell is postponed, remember the new size, and call
  * gui_resize_shell() later.
  */
@@ -505,10 +507,11 @@ EXTERN VimClipboard clip_plus;	/* CLIPBO
 #  define clip_plus clip_star	/* there is only one clipboard */
 # endif
 EXTERN int	clip_unnamed INIT(= FALSE);
 EXTERN int	clip_autoselect INIT(= FALSE);
 EXTERN int	clip_autoselectml INIT(= FALSE);
+EXTERN int	clip_html INIT(= FALSE);
 EXTERN regprog_T *clip_exclude_prog INIT(= NULL);
 #endif
 
 /*
  * All windows are linked in a list. firstwin points to the first entry,
@@ -520,11 +523,11 @@ EXTERN regprog_T *clip_exclude_prog INIT
 EXTERN win_T	*firstwin;		/* first window */
 EXTERN win_T	*lastwin;		/* last window */
 EXTERN win_T	*prevwin INIT(= NULL);	/* previous window */
 # define W_NEXT(wp) ((wp)->w_next)
 # define FOR_ALL_WINDOWS(wp) for (wp = firstwin; wp != NULL; wp = wp->w_next)
-#define FOR_ALL_TAB_WINDOWS(tp, wp) \
+# define FOR_ALL_TAB_WINDOWS(tp, wp) \
     for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next) \
 	for ((wp) = ((tp) == curtab) \
 		? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
 #else
 # define firstwin curwin
@@ -534,10 +537,15 @@ EXTERN win_T	*prevwin INIT(= NULL);	/* p
 # define FOR_ALL_TAB_WINDOWS(tp, wp) wp = curwin;
 #endif
 
 EXTERN win_T	*curwin;	/* currently active window */
 
+#ifdef FEAT_AUTOCMD
+EXTERN win_T	*aucmd_win;	/* window used in aucmd_prepbuf() */
+EXTERN int	aucmd_win_used INIT(= FALSE);	/* aucmd_win is being used */
+#endif
+
 /*
  * The window layout is kept in a tree of frames.  topframe points to the top
  * of the tree.
  */
 EXTERN frame_T	*topframe;	/* top of the window frame tree */
@@ -595,11 +603,12 @@ EXTERN int	exiting INIT(= FALSE);
 				 * still keep on running if there is a changed
 				 * buffer. */
 EXTERN int	really_exiting INIT(= FALSE);
 				/* TRUE when we are sure to exit, e.g., after
 				 * a deadly signal */
-EXTERN int	full_screen INIT(= FALSE);
+/* volatile because it is used in signal handler deathtrap(). */
+EXTERN volatile int full_screen INIT(= FALSE);
 				/* TRUE when doing full-screen output
 				 * otherwise only writing some messages */
 
 EXTERN int	restricted INIT(= FALSE);
 				/* TRUE when started as "rvim" */
@@ -614,10 +623,15 @@ EXTERN int	textlock INIT(= 0);
 
 #ifdef FEAT_AUTOCMD
 EXTERN int	curbuf_lock INIT(= 0);
 				/* non-zero when the current buffer can't be
 				 * changed.  Used for FileChangedRO. */
+EXTERN int	allbuf_lock INIT(= 0);
+				/* non-zero when no buffer name can be
+				 * changed, no buffer can be deleted and
+				 * current directory can't be changed.
+				 * Used for SwapExists et al. */
 #endif
 #ifdef FEAT_EVAL
 # define HAVE_SANDBOX
 EXTERN int	sandbox INIT(= 0);
 				/* Non-zero when evaluating an expression in a
@@ -708,11 +722,11 @@ EXTERN int	can_si INIT(= FALSE);
 EXTERN int	can_si_back INIT(= FALSE);
 #endif
 
 EXTERN pos_T	saved_cursor		/* w_cursor before formatting text. */
 # ifdef DO_INIT
-	= INIT_POS_T
+	= INIT_POS_T(0, 0, 0)
 # endif
 	;
 
 /*
  * Stuff for insert mode.
@@ -737,14 +751,16 @@ EXTERN JMP_BUF x_jump_env;
  * Stuff for setjmp() and longjmp().
  * Used to protect areas where we could crash.
  */
 EXTERN JMP_BUF lc_jump_env;	/* argument to SETJMP() */
 # ifdef SIGHASARG
-EXTERN int lc_signal;		/* catched signal number, 0 when no was signal
-				   catched; used for mch_libcall() */
+/* volatile because it is used in signal handlers. */
+EXTERN volatile int lc_signal;	/* caught signal number, 0 when no was signal
+				   caught; used for mch_libcall() */
 # endif
-EXTERN int lc_active INIT(= FALSE); /* TRUE when lc_jump_env is valid. */
+/* volatile because it is used in signal handler deathtrap(). */
+EXTERN volatile int lc_active INIT(= FALSE); /* TRUE when lc_jump_env is valid. */
 #endif
 
 #if defined(FEAT_MBYTE) || defined(FEAT_POSTSCRIPT)
 /*
  * These flags are set based upon 'fileencoding'.
@@ -798,15 +814,18 @@ EXTERN vimconv_T output_conv;			/* type
  * (DBCS).
  * The value is set in mb_init();
  */
 /* length of char in bytes, including following composing chars */
 EXTERN int (*mb_ptr2len) __ARGS((char_u *p)) INIT(= latin_ptr2len);
+/* idem, with limit on string length */
+EXTERN int (*mb_ptr2len_len) __ARGS((char_u *p, int size)) INIT(= latin_ptr2len_len);
 /* byte length of char */
 EXTERN int (*mb_char2len) __ARGS((int c)) INIT(= latin_char2len);
 /* convert char to bytes, return the length */
 EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
 EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
+EXTERN int (*mb_ptr2cells_len) __ARGS((char_u *p, int size)) INIT(= latin_ptr2cells_len);
 EXTERN int (*mb_char2cells) __ARGS((int c)) INIT(= latin_char2cells);
 EXTERN int (*mb_off2cells) __ARGS((unsigned off, unsigned max_off)) INIT(= latin_off2cells);
 EXTERN int (*mb_ptr2char) __ARGS((char_u *p)) INIT(= latin_ptr2char);
 EXTERN int (*mb_head_off) __ARGS((char_u *base, char_u *p)) INIT(= latin_head_off);
 
@@ -948,11 +967,11 @@ EXTERN struct buffheader stuffbuff	/* st
 		    = {{NULL, {NUL}}, NULL, 0, 0}
 #endif
 		    ;
 EXTERN typebuf_T typebuf		/* typeahead buffer */
 #ifdef DO_INIT
-		    = {NULL, NULL}
+		    = {NULL, NULL, 0, 0, 0, 0, 0, 0, 0}
 #endif
 		    ;
 #ifdef FEAT_EX_EXTRA
 EXTERN int	ex_normal_busy INIT(= 0); /* recursiveness of ex_normal() */
 EXTERN int	ex_normal_lock INIT(= 0); /* forbid use of ex_normal() */
@@ -984,11 +1003,12 @@ EXTERN char_u	*use_viminfo INIT(= NULL);
 EXTERN FILE	*scriptin[NSCRIPT];	    /* streams to read script from */
 EXTERN int	curscript INIT(= 0);	    /* index in scriptin[] */
 EXTERN FILE	*scriptout  INIT(= NULL);   /* stream to write script to */
 EXTERN int	read_cmd_fd INIT(= 0);	    /* fd to read commands from */
 
-EXTERN int	got_int INIT(= FALSE);	    /* set to TRUE when interrupt
+/* volatile because it is used in signal handler catch_sigint(). */
+EXTERN volatile int got_int INIT(= FALSE);    /* set to TRUE when interrupt
 						signal occurred */
 #ifdef USE_TERM_CONSOLE
 EXTERN int	term_console INIT(= FALSE); /* set to TRUE when console used */
 #endif
 EXTERN int	termcap_active INIT(= FALSE);	/* set by starttermcap() */
@@ -1020,16 +1040,17 @@ EXTERN char_u	*repeat_cmdline INIT(= NUL
 #ifdef FEAT_CMDHIST
 EXTERN char_u	*new_last_cmdline INIT(= NULL);	/* new value for last_cmdline */
 #endif
 #ifdef FEAT_AUTOCMD
 EXTERN char_u	*autocmd_fname INIT(= NULL); /* fname for <afile> on cmdline */
+EXTERN int	autocmd_fname_full;	     /* autocmd_fname is full path */
 EXTERN int	autocmd_bufnr INIT(= 0);     /* fnum for <abuf> on cmdline */
 EXTERN char_u	*autocmd_match INIT(= NULL); /* name for <amatch> on cmdline */
 EXTERN int	did_cursorhold INIT(= FALSE); /* set when CursorHold t'gerd */
 EXTERN pos_T	last_cursormoved	    /* for CursorMoved event */
 # ifdef DO_INIT
-			= INIT_POS_T
+			= INIT_POS_T(0, 0, 0)
 # endif
 			;
 #endif
 
 EXTERN linenr_T	write_no_eol_lnum INIT(= 0); /* non-zero lnum when last line
@@ -1337,11 +1358,10 @@ EXTERN garray_T error_ga
 	;
 #endif
 
 #ifdef FEAT_NETBEANS_INTG
 EXTERN char *netbeansArg INIT(= NULL);	/* the -nb[:host:port:passwd] arg */
-EXTERN int netbeansCloseFile INIT(= 0);	/* send killed if != 0 */
 EXTERN int netbeansFireChanges INIT(= 1); /* send buffer changes if != 0 */
 EXTERN int netbeansForcedQuit INIT(= 0);/* don't write modified files */
 EXTERN int netbeansReadFile INIT(= 1);	/* OK to read from disk if != 0 */
 EXTERN int netbeansSuppressNoLines INIT(= 0); /* skip "No lines in buffer" */
 EXTERN int usingNetbeans INIT(= 0);	/* set if -nb flag is used */
@@ -1545,10 +1565,22 @@ EXTERN int xsmp_icefd INIT(= -1);   /* T
 #endif
 
 /* For undo we need to know the lowest time possible. */
 EXTERN time_t starttime;
 
+#ifdef STARTUPTIME
+EXTERN FILE *time_fd INIT(= NULL);  /* where to write startup timing */
+#endif
+
+/*
+ * Some compilers warn for not using a return value, but in some situations we
+ * can't do anything useful with the value.  Assign to this variable to avoid
+ * the warning.
+ */
+EXTERN int ignored;
+EXTERN char *ignoredp;
+
 /*
  * Optional Farsi support.  Include it here, so EXTERN and INIT are defined.
  */
 #ifdef FEAT_FKMAP
 # include "farsi.h"
--- vim72.orig/src/gui.c
+++ vim72/src/gui.c
@@ -137,11 +137,11 @@ gui_start()
 	    else
 	    {
 		/* The read returns when the child closes the pipe (or when
 		 * the child dies for some reason). */
 		close(pipefd[1]);
-		(void)read(pipefd[0], &dummy, (size_t)1);
+		ignored = (int)read(pipefd[0], &dummy, (size_t)1);
 		close(pipefd[0]);
 	    }
 
 	    /* When swapping screens we may need to go to the next line, e.g.,
 	     * after a hit-enter prompt and using ":gui". */
@@ -676,15 +676,14 @@ gui_shell_closed()
  * font.
  * If "fontset" is TRUE, the "font_list" is used as one name for the fontset.
  * Return OK when able to set the font.  When it failed FAIL is returned and
  * the fonts are unchanged.
  */
-/*ARGSUSED*/
     int
 gui_init_font(font_list, fontset)
     char_u	*font_list;
-    int		fontset;
+    int		fontset UNUSED;
 {
 #define FONTLEN 320
     char_u	font_name[FONTLEN];
     int		font_list_empty = FALSE;
     int		ret = FAIL;
@@ -958,11 +957,11 @@ gui_update_cursor(force, clear_selection
 	    {
 		static int iid;
 		guicolor_T fg, bg;
 
 		if (
-# ifdef HAVE_GTK2
+# if defined(HAVE_GTK2) && !defined(FEAT_HANGULIN)
 			preedit_get_status()
 # else
 			im_get_status()
 # endif
 			)
@@ -1136,14 +1135,13 @@ gui_position_menu()
 
 /*
  * Position the various GUI components (text area, menu).  The vertical
  * scrollbars are NOT handled here.  See gui_update_scrollbars().
  */
-/*ARGSUSED*/
     static void
 gui_position_components(total_width)
-    int	    total_width;
+    int	    total_width UNUSED;
 {
     int	    text_area_x;
     int	    text_area_y;
     int	    text_area_width;
     int	    text_area_height;
@@ -1372,14 +1370,13 @@ gui_get_shellsize()
 /*
  * Set the size of the Vim shell according to Rows and Columns.
  * If "fit_to_display" is TRUE then the size may be reduced to fit the window
  * on the screen.
  */
-/*ARGSUSED*/
     void
 gui_set_shellsize(mustset, fit_to_display, direction)
-    int		mustset;		/* set by the user */
+    int		mustset UNUSED;		/* set by the user */
     int		fit_to_display;
     int		direction;		/* RESIZE_HOR, RESIZE_VER */
 {
     int		base_width;
     int		base_height;
@@ -1387,10 +1384,15 @@ gui_set_shellsize(mustset, fit_to_displa
     int		height;
     int		min_width;
     int		min_height;
     int		screen_w;
     int		screen_h;
+#ifdef HAVE_GTK2
+    int		un_maximize = mustset;
+    int         did_adjust = 0;
+#endif
+    int		x = -1, y = -1;
 
     if (!gui.shell_created)
 	return;
 
 #ifdef MSWIN
@@ -1403,10 +1405,14 @@ gui_set_shellsize(mustset, fit_to_displa
     }
 #endif
 
     base_width = gui_get_base_width();
     base_height = gui_get_base_height();
+    if (fit_to_display)
+	/* Remember the original window position. */
+	gui_mch_get_winpos(&x, &y);
+
 #ifdef USE_SUN_WORKSHOP
     if (!mustset && usingSunWorkShop
 				&& workshop_get_width_height(&width, &height))
     {
 	Columns = (width - base_width + gui.char_width - 1) / gui.char_width;
@@ -1426,34 +1432,60 @@ gui_set_shellsize(mustset, fit_to_displa
 	{
 	    Columns = (screen_w - base_width) / gui.char_width;
 	    if (Columns < MIN_COLUMNS)
 		Columns = MIN_COLUMNS;
 	    width = Columns * gui.char_width + base_width;
+#ifdef HAVE_GTK2
+	    ++did_adjust;
+#endif
 	}
 	if ((direction & RESIZE_VERT) && height > screen_h)
 	{
 	    Rows = (screen_h - base_height) / gui.char_height;
 	    check_shellsize();
 	    height = Rows * gui.char_height + base_height;
+#ifdef HAVE_GTK2
+	    ++did_adjust;
+#endif
 	}
+#ifdef HAVE_GTK2
+	if (did_adjust == 2 || (width + gui.char_width >= screen_w
+				     && height + gui.char_height >= screen_h))
+	    /* don't unmaximize if at maximum size */
+	    un_maximize = FALSE;
+#endif
     }
     gui.num_cols = Columns;
     gui.num_rows = Rows;
 
     min_width = base_width + MIN_COLUMNS * gui.char_width;
     min_height = base_height + MIN_LINES * gui.char_height;
-# ifdef FEAT_WINDOWS
+#ifdef FEAT_WINDOWS
     min_height += tabline_height() * gui.char_height;
-# endif
+#endif
+
+#ifdef HAVE_GTK2
+    if (un_maximize)
+    {
+	/* If the window size is smaller than the screen unmaximize the
+	 * window, otherwise resizing won't work. */
+	gui_mch_get_screen_dimensions(&screen_w, &screen_h);
+	if ((width + gui.char_width < screen_w
+				   || height + gui.char_height * 2 < screen_h)
+		&& gui_mch_maximized())
+	    gui_mch_unmaximize();
+    }
+#endif
 
     gui_mch_set_shellsize(width, height, min_width, min_height,
 					  base_width, base_height, direction);
-    if (fit_to_display)
-    {
-	int	    x, y;
 
-	/* Some window managers put the Vim window left of/above the screen. */
+    if (fit_to_display && x >= 0 && y >= 0)
+    {
+	/* Some window managers put the Vim window left of/above the screen.
+	 * Only change the position if it wasn't already negative before
+	 * (happens on MS-Windows with a secondary monitor). */
 	gui_mch_update();
 	if (gui_mch_get_winpos(&x, &y) == OK && (x < 0 || y < 0))
 	    gui_mch_set_winpos(x < 0 ? 0 : x, y < 0 ? 0 : y);
     }
 
@@ -3118,14 +3150,13 @@ static int	prev_which_scrollbars[3];
 /*
  * Set which components are present.
  * If "oldval" is not NULL, "oldval" is the previous value, the new value is
  * in p_go.
  */
-/*ARGSUSED*/
     void
 gui_init_which_components(oldval)
-    char_u	*oldval;
+    char_u	*oldval UNUSED;
 {
 #ifdef FEAT_MENU
     static int	prev_menu_is_active = -1;
 #endif
 #ifdef FEAT_TOOLBAR
@@ -3239,11 +3270,11 @@ gui_init_which_components(oldval)
 	    /* We don't want a resize event change "Rows" here, save and
 	     * restore it.  Resizing is handled below. */
 	    i = Rows;
 	    gui_update_tabline();
 	    Rows = i;
-	    need_set_size = RESIZE_VERT;
+	    need_set_size |= RESIZE_VERT;
 	    if (using_tabline)
 		fix_size = TRUE;
 	    if (!gui_use_tabline())
 		redraw_tabline = TRUE;    /* may draw non-GUI tab line */
 	}
@@ -3273,13 +3304,13 @@ gui_init_which_components(oldval)
 		    }
 		}
 		if (gui.which_scrollbars[i] != prev_which_scrollbars[i])
 		{
 		    if (i == SBAR_BOTTOM)
-			need_set_size = RESIZE_VERT;
+			need_set_size |= RESIZE_VERT;
 		    else
-			need_set_size = RESIZE_HOR;
+			need_set_size |= RESIZE_HOR;
 		    if (gui.which_scrollbars[i])
 			fix_size = TRUE;
 		}
 	    }
 #ifdef FEAT_WINDOWS
@@ -3295,32 +3326,32 @@ gui_init_which_components(oldval)
 	     * restore it.  Resizing is handled below. */
 	    i = Rows;
 	    gui_mch_enable_menu(gui.menu_is_active);
 	    Rows = i;
 	    prev_menu_is_active = gui.menu_is_active;
-	    need_set_size = RESIZE_VERT;
+	    need_set_size |= RESIZE_VERT;
 	    if (gui.menu_is_active)
 		fix_size = TRUE;
 	}
 #endif
 
 #ifdef FEAT_TOOLBAR
 	if (using_toolbar != prev_toolbar)
 	{
 	    gui_mch_show_toolbar(using_toolbar);
 	    prev_toolbar = using_toolbar;
-	    need_set_size = RESIZE_VERT;
+	    need_set_size |= RESIZE_VERT;
 	    if (using_toolbar)
 		fix_size = TRUE;
 	}
 #endif
 #ifdef FEAT_FOOTER
 	if (using_footer != prev_footer)
 	{
 	    gui_mch_enable_footer(using_footer);
 	    prev_footer = using_footer;
-	    need_set_size = RESIZE_VERT;
+	    need_set_size |= RESIZE_VERT;
 	    if (using_footer)
 		fix_size = TRUE;
 	}
 #endif
 #if defined(FEAT_MENU) && !defined(WIN16) && !(defined(WIN3264) && !defined(FEAT_TEAROFF))
@@ -3328,14 +3359,15 @@ gui_init_which_components(oldval)
 	{
 	    gui_mch_toggle_tearoffs(using_tearoff);
 	    prev_tearoff = using_tearoff;
 	}
 #endif
-	if (need_set_size)
+	if (need_set_size != 0)
 	{
 #ifdef FEAT_GUI_GTK
-	    long    c = Columns;
+	    long    prev_Columns = Columns;
+	    long    prev_Rows = Rows;
 #endif
 	    /* Adjust the size of the window to make the text area keep the
 	     * same size and to avoid that part of our window is off-screen
 	     * and a scrollbar can't be used, for example. */
 	    gui_set_shellsize(FALSE, fix_size, need_set_size);
@@ -3347,15 +3379,18 @@ gui_init_which_components(oldval)
 	     * change Columns and Rows when we don't want it.  Wait for a
 	     * character here to avoid this effect.
 	     * If you remove this, please test this command for resizing
 	     * effects (with optional left scrollbar): ":vsp|q|vsp|q|vsp|q".
 	     * Don't do this while starting up though.
-	     * And don't change Rows, it may have be reduced intentionally
-	     * when adding menu/toolbar/tabline. */
-	    if (!gui.starting)
+	     * Don't change Rows when adding menu/toolbar/tabline.
+	     * Don't change Columns when adding vertical toolbar. */
+	    if (!gui.starting && need_set_size != (RESIZE_VERT | RESIZE_HOR))
 		(void)char_avail();
-	    Columns = c;
+	    if ((need_set_size & RESIZE_VERT) == 0)
+		Rows = prev_Rows;
+	    if ((need_set_size & RESIZE_HOR) == 0)
+		Columns = prev_Columns;
 #endif
 	}
 #ifdef FEAT_WINDOWS
 	/* When the console tabline appears or disappears the window positions
 	 * change. */
@@ -3877,10 +3912,25 @@ gui_drag_scrollbar(sb, value, still_drag
 
 /*
  * Scrollbar stuff:
  */
 
+/*
+ * Called when something in the window layout has changed.
+ */
+    void
+gui_may_update_scrollbars()
+{
+    if (gui.in_use && starting == 0)
+    {
+	out_flush();
+	gui_init_which_components(NULL);
+	gui_update_scrollbars(TRUE);
+    }
+    need_mouse_correct = TRUE;
+}
+
     void
 gui_update_scrollbars(force)
     int		force;	    /* Force all scrollbars to get updated */
 {
     win_T	*wp;
@@ -4405,11 +4455,11 @@ gui_do_horiz_scroll()
 {
     /* no wrapping, no scrolling */
     if (curwin->w_p_wrap)
 	return FALSE;
 
-    if (curwin->w_leftcol == scrollbar_value)
+    if ((long_u)curwin->w_leftcol == scrollbar_value)
 	return FALSE;
 
     curwin->w_leftcol = (colnr_T)scrollbar_value;
 
     /* When the line of the cursor is too short, move the cursor to the
@@ -4418,11 +4468,11 @@ gui_do_horiz_scroll()
     if (vim_strchr(p_go, GO_HORSCROLL) == NULL
 	    && longest_lnum >= curwin->w_topline
 	    && longest_lnum < curwin->w_botline
 	    && !virtual_active())
     {
-	if (scrollbar_value > scroll_line_len(curwin->w_cursor.lnum))
+	if (scrollbar_value > (long_u)scroll_line_len(curwin->w_cursor.lnum))
 	{
 	    curwin->w_cursor.lnum = longest_lnum;
 	    curwin->w_cursor.col = 0;
 	}
     }
@@ -4664,15 +4714,14 @@ gui_mouse_correct()
 }
 
 /*
  * Find window where the mouse pointer "y" coordinate is in.
  */
-/*ARGSUSED*/
     static win_T *
 xy2win(x, y)
-    int		x;
-    int		y;
+    int		x UNUSED;
+    int		y UNUSED;
 {
 #ifdef FEAT_WINDOWS
     int		row;
     int		col;
     win_T	*wp;
@@ -4988,10 +5037,23 @@ gui_do_findrepl(flags, find_text, repl_t
     int		i;
     int		type = (flags & FRD_TYPE_MASK);
     char_u	*p;
     regmatch_T	regmatch;
     int		save_did_emsg = did_emsg;
+    static int  busy = FALSE;
+
+    /* When the screen is being updated we should not change buffers and
+     * windows structures, it may cause freed memory to be used.  Also don't
+     * do this recursively (pressing "Find" quickly several times. */
+    if (updating_screen || busy)
+	return FALSE;
+
+    /* refuse replace when text cannot be changed */
+    if ((type == FRD_REPLACE || type == FRD_REPLACEALL) && text_locked())
+	return FALSE;
+
+    busy = TRUE;
 
     ga_init2(&ga, 1, 100);
     if (type == FRD_REPLACEALL)
 	ga_concat(&ga, (char_u *)"%s/");
 
@@ -5078,10 +5140,11 @@ gui_do_findrepl(flags, find_text, repl_t
 	msg_didout = 0;			/* overwrite any message */
 	need_wait_return = FALSE;	/* don't wait for return */
     }
 
     vim_free(ga.ga_data);
+    busy = FALSE;
     return (ga.ga_len > 0);
 }
 
 #endif
 
@@ -5118,15 +5181,14 @@ gui_wingoto_xy(x, y)
  * Process file drop.  Mouse cursor position, key modifiers, name of files
  * and count of files are given.  Argument "fnames[count]" has full pathnames
  * of dropped files, they will be freed in this function, and caller can't use
  * fnames after call this function.
  */
-/*ARGSUSED*/
     void
 gui_handle_drop(x, y, modifiers, fnames, count)
-    int		x;
-    int		y;
+    int		x UNUSED;
+    int		y UNUSED;
     int_u	modifiers;
     char_u	**fnames;
     int		count;
 {
     int		i;
--- vim72.orig/src/gui_at_fs.c
+++ vim72/src/gui_at_fs.c
@@ -827,11 +827,11 @@ SFsetText(path)
     text.length = strlen(path);
     text.ptr = path;
     text.format = FMT8BIT;
 
 #ifdef XtNinternational
-    if (_XawTextFormat((TextWidget)selFileField) == XawFmtWide)
+    if ((unsigned long)_XawTextFormat((TextWidget)selFileField) == XawFmtWide)
     {
 	XawTextReplace(selFileField, (XawTextPosition)0,
 				    (XawTextPosition)WcsLen((wchar_t *)&SFtextBuffer[0]), &text);
 	XawTextSetInsertionPoint(selFileField,
 					   (XawTextPosition)WcsLen((wchar_t *)&SFtextBuffer[0]));
@@ -849,21 +849,19 @@ SFsetText(path)
     XawTextSetInsertionPoint(selFileField,
 				       (XawTextPosition)strlen(SFtextBuffer));
 #endif
 }
 
-/* ARGSUSED */
     static void
 SFbuttonPressList(w, n, event)
-    Widget		w;
-    int			n;
-    XButtonPressedEvent	*event;
+    Widget		w UNUSED;
+    int			n UNUSED;
+    XButtonPressedEvent	*event UNUSED;
 {
     SFbuttonPressed = 1;
 }
 
-/* ARGSUSED */
     static void
 SFbuttonReleaseList(w, n, event)
     Widget		 w;
     int			 n;
     XButtonReleasedEvent *event;
@@ -987,15 +985,14 @@ SFcheckFiles(dir)
     }
 
     return result;
 }
 
-/* ARGSUSED */
     static void
 SFdirModTimer(cl, id)
-    XtPointer		cl;
-    XtIntervalId	*id;
+    XtPointer		cl UNUSED;
+    XtIntervalId	*id UNUSED;
 {
     static int		n = -1;
     static int		f = 0;
     char		save;
     SFDir		*dir;
@@ -1594,15 +1591,14 @@ SFscrollTimerInterval()
     return (unsigned long)t;
 }
 
 static void SFscrollTimer __ARGS((XtPointer p, XtIntervalId *id));
 
-/* ARGSUSED */
     static void
 SFscrollTimer(p, id)
     XtPointer		p;
-    XtIntervalId	*id;
+    XtIntervalId	*id UNUSED;
 {
     SFDir	*dir;
     int		save;
     int		n;
 
@@ -1693,14 +1689,13 @@ SFnewInvertEntry(n, event)
 	}
 	return -1;
     }
 }
 
-/* ARGSUSED */
     static void
 SFenterList(w, n, event)
-    Widget		w;
+    Widget		w UNUSED;
     int			n;
     XEnterWindowEvent	*event;
 {
     int			nw;
 
@@ -1717,28 +1712,26 @@ SFenterList(w, n, event)
 	SFcurrentInvert[n] = nw;
 	SFinvertEntry(n);
     }
 }
 
-/* ARGSUSED */
     static void
 SFleaveList(w, n, event)
-    Widget	w;
+    Widget	w UNUSED;
     int		n;
-    XEvent	*event;
+    XEvent	*event UNUSED;
 {
     if (SFcurrentInvert[n] != -1)
     {
 	SFinvertEntry(n);
 	SFcurrentInvert[n] = -1;
     }
 }
 
-/* ARGSUSED */
     static void
 SFmotionList(w, n, event)
-    Widget		w;
+    Widget		w UNUSED;
     int			n;
     XMotionEvent	*event;
 {
     int		nw;
 
@@ -1752,11 +1745,10 @@ SFmotionList(w, n, event)
 	if (nw != -1)
 	    SFinvertEntry(n);
     }
 }
 
-/* ARGSUSED */
     static void
 SFvFloatSliderMovedCallback(w, n, fnew)
     Widget	w;
     XtPointer	n;
     XtPointer	fnew;
@@ -1765,14 +1757,13 @@ SFvFloatSliderMovedCallback(w, n, fnew)
 
     nw = (*(float *)fnew) * SFdirs[SFdirPtr + (int)(long)n].nEntries;
     SFvSliderMovedCallback(w, (int)(long)n, nw);
 }
 
-/* ARGSUSED */
     static void
 SFvSliderMovedCallback(w, n, nw)
-    Widget	w;
+    Widget	w UNUSED;
     int		n;
     int		nw;
 {
     int		old;
     Window	win;
@@ -1851,14 +1842,13 @@ SFvSliderMovedCallback(w, n, nw)
 		False);
 	SFdrawStrings(win, dir, 0, SFlistSize - 1);
     }
 }
 
-/* ARGSUSED */
     static void
 SFvAreaSelectedCallback(w, n, pnew)
-    Widget		w;
+    Widget	w;
     XtPointer	n;
     XtPointer	pnew;
 {
     SFDir	*dir;
     int		nw = (int)(long)pnew;
@@ -1912,14 +1902,13 @@ SFvAreaSelectedCallback(w, n, pnew)
     }
 
     SFvSliderMovedCallback(w, (int)(long)n, nw);
 }
 
-/* ARGSUSED */
     static void
 SFhSliderMovedCallback(w, n, nw)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	n;
     XtPointer	nw;
 {
     SFDir	*dir;
     int	save;
@@ -1931,14 +1920,13 @@ SFhSliderMovedCallback(w, n, nw)
 	return;
 
     SFdrawList((int)(long)n, SF_DO_NOT_SCROLL);
 }
 
-/* ARGSUSED */
     static void
 SFhAreaSelectedCallback(w, n, pnew)
-    Widget		w;
+    Widget	w;
     XtPointer	n;
     XtPointer	pnew;
 {
     SFDir	*dir;
     int		nw = (int)(long)pnew;
@@ -1992,15 +1980,14 @@ SFhAreaSelectedCallback(w, n, pnew)
 
 	SFhSliderMovedCallback(w, n, (XtPointer)&f);
     }
 }
 
-/* ARGSUSED */
     static void
 SFpathSliderMovedCallback(w, client_data, nw)
-    Widget		w;
-    XtPointer	client_data;
+    Widget	w UNUSED;
+    XtPointer	client_data UNUSED;
     XtPointer	nw;
 {
     SFDir		*dir;
     int			n;
     XawTextPosition	pos;
@@ -2029,15 +2016,14 @@ SFpathSliderMovedCallback(w, client_data
     }
 
     XawTextSetInsertionPoint(selFileField, pos);
 }
 
-/* ARGSUSED */
     static void
 SFpathAreaSelectedCallback(w, client_data, pnew)
     Widget	w;
-    XtPointer	client_data;
+    XtPointer	client_data UNUSED;
     XtPointer	pnew;
 {
     int		nw = (int)(long)pnew;
     float	f;
 
@@ -2204,33 +2190,31 @@ static char *oneLineTextEditTranslations
 	Ctrl<Key>M:	redraw-display()\n\
 ";
 
 static void SFexposeList __ARGS((Widget w, XtPointer n, XEvent *event, Boolean *cont));
 
-/* ARGSUSED */
     static void
 SFexposeList(w, n, event, cont)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	n;
     XEvent	*event;
-    Boolean	*cont;
+    Boolean	*cont UNUSED;
 {
     if ((event->type == NoExpose) || event->xexpose.count)
 	return;
 
     SFdrawList((int)(long)n, SF_DO_NOT_SCROLL);
 }
 
 static void SFmodVerifyCallback __ARGS((Widget w, XtPointer client_data, XEvent *event, Boolean *cont));
 
-/* ARGSUSED */
     static void
 SFmodVerifyCallback(w, client_data, event, cont)
-    Widget		w;
-    XtPointer		client_data;
+    Widget		w UNUSED;
+    XtPointer		client_data UNUSED;
     XEvent		*event;
-    Boolean		*cont;
+    Boolean		*cont UNUSED;
 {
     char	buf[2];
 
     if ((XLookupString(&(event->xkey), buf, 2, NULL, NULL) == 1) &&
 	    ((*buf) == '\r'))
@@ -2239,15 +2223,15 @@ SFmodVerifyCallback(w, client_data, even
 	SFstatus = SEL_FILE_TEXT;
 }
 
 static void SFokCallback __ARGS((Widget w, XtPointer cl, XtPointer cd));
 
-/* ARGSUSED */
     static void
 SFokCallback(w, cl, cd)
-    Widget	w;
-    XtPointer	cl, cd;
+    Widget	w UNUSED;
+    XtPointer	cl UNUSED;
+    XtPointer	cd UNUSED;
 {
     SFstatus = SEL_FILE_OK;
 }
 
 static XtCallbackRec SFokSelect[] =
@@ -2256,15 +2240,15 @@ static XtCallbackRec SFokSelect[] =
     { NULL, (XtPointer) NULL },
 };
 
 static void SFcancelCallback __ARGS((Widget w, XtPointer cl, XtPointer cd));
 
-/* ARGSUSED */
     static void
 SFcancelCallback(w, cl, cd)
-    Widget	w;
-    XtPointer	cl, cd;
+    Widget	w UNUSED;
+    XtPointer	cl UNUSED;
+    XtPointer	cd UNUSED;
 {
     SFstatus = SEL_FILE_CANCEL;
 }
 
 static XtCallbackRec SFcancelSelect[] =
@@ -2273,20 +2257,19 @@ static XtCallbackRec SFcancelSelect[] =
     { NULL, (XtPointer) NULL },
 };
 
 static void SFdismissAction __ARGS((Widget w, XEvent *event, String *params, Cardinal *num_params));
 
-/* ARGSUSED */
     static void
 SFdismissAction(w, event, params, num_params)
-    Widget	w;
-    XEvent *event;
-    String *params;
-    Cardinal *num_params;
+    Widget	w UNUSED;
+    XEvent	*event;
+    String	*params UNUSED;
+    Cardinal	*num_params UNUSED;
 {
-    if (event->type == ClientMessage &&
-	    event->xclient.data.l[0] != SFwmDeleteWindow)
+    if (event->type == ClientMessage
+	    && (Atom)event->xclient.data.l[0] != SFwmDeleteWindow)
 	return;
 
     SFstatus = SEL_FILE_CANCEL;
 }
 
@@ -2701,11 +2684,11 @@ SFcreateWidgets(toplevel, prompt, ok, ca
 
     static void
 SFtextChanged()
 {
 #if defined(FEAT_XFONTSET) && defined(XtNinternational)
-    if (_XawTextFormat((TextWidget)selFileField) == XawFmtWide)
+    if ((unsigned long)_XawTextFormat((TextWidget)selFileField) == XawFmtWide)
     {
 	wchar_t *wcbuf=(wchar_t *)SFtextBuffer;
 
 	if ((wcbuf[0] == L'/') || (wcbuf[0] == L'~'))
 	{
@@ -2747,11 +2730,11 @@ SFtextChanged()
 SFgetText()
 {
 #if defined(FEAT_XFONTSET) && defined(XtNinternational)
     char *buf;
 
-    if (_XawTextFormat((TextWidget)selFileField) == XawFmtWide)
+    if ((unsigned long)_XawTextFormat((TextWidget)selFileField) == XawFmtWide)
     {
 	wchar_t *wcbuf;
 	int mbslength;
 
 	XtVaGetValues(selFileField,
--- vim72.orig/src/gui_at_sb.c
+++ vim72/src/gui_at_sb.c
@@ -196,14 +196,17 @@ ScrollbarClassRec vim_scrollbarClassRec
     /* query_geometry	*/  XtInheritQueryGeometry,
     /* display_accelerator*/	XtInheritDisplayAccelerator,
     /* extension	*/  NULL
   },
   { /* simple fields */
-    /* change_sensitive	*/  XtInheritChangeSensitive
+    /* change_sensitive	*/  XtInheritChangeSensitive,
+#ifndef OLDXAW
+    /* extension */	    NULL
+#endif
   },
   { /* scrollbar fields */
-    /* ignore	    */	0
+    /* empty	    */	    0
   }
 };
 
 WidgetClass vim_scrollbarWidgetClass = (WidgetClass)&vim_scrollbarClassRec;
 
@@ -239,11 +242,12 @@ FillArea(sbw, top, bottom, fill, draw_sh
     int sw, margin, floor;
     int lx, ly, lw, lh;
 
     if (bottom <= 0 || bottom <= top)
 	return;
-    if ((sw = sbw->scrollbar.shadow_width) < 0)
+    sw = sbw->scrollbar.shadow_width;
+    if (sw < 0)
 	sw = 0;
     margin = MARGIN (sbw);
     floor = sbw->scrollbar.length - margin + 2;
 
     if (sbw->scrollbar.orientation == XtorientHorizontal)
@@ -514,17 +518,16 @@ SetDimensions(sbw)
 	sbw->scrollbar.length = sbw->core.width;
 	sbw->scrollbar.thickness = sbw->core.height;
     }
 }
 
-/* ARGSUSED */
     static void
 Initialize(request, new, args, num_args)
-    Widget	request;	/* what the client asked for */
+    Widget	request UNUSED;	/* what the client asked for */
     Widget	new;		/* what we're going to give him */
-    ArgList	args;
-    Cardinal	*num_args;
+    ArgList	args UNUSED;
+    Cardinal	*num_args UNUSED;
 {
     ScrollbarWidget sbw = (ScrollbarWidget) new;
 
     CreateGC(new);
     AllocTopShadowGC(new);
@@ -554,18 +557,17 @@ Realize(w, valueMask, attributes)
     /* The Simple widget actually stuffs the value in the valuemask. */
     (*vim_scrollbarWidgetClass->core_class.superclass->core_class.realize)
 	(w, valueMask, attributes);
 }
 
-/* ARGSUSED */
     static Boolean
 SetValues(current, request, desired, args, num_args)
-    Widget  current,	    /* what I am */
-	    request,	    /* what he wants me to be */
-	    desired;	    /* what I will become */
-    ArgList args;
-    Cardinal *num_args;
+    Widget  current;	    /* what I am */
+    Widget  request UNUSED; /* what he wants me to be */
+    Widget  desired;	    /* what I will become */
+    ArgList args UNUSED;
+    Cardinal *num_args UNUSED;
 {
     ScrollbarWidget	sbw = (ScrollbarWidget) current;
     ScrollbarWidget	dsbw = (ScrollbarWidget) desired;
     Boolean		redraw = FALSE;
 
@@ -607,11 +609,10 @@ Resize(w)
     SetDimensions ((ScrollbarWidget) w);
     Redisplay(w, (XEvent*) NULL, (Region)NULL);
 }
 
 
-/* ARGSUSED */
     static void
 Redisplay(w, event, region)
     Widget w;
     XEvent *event;
     Region region;
@@ -787,15 +788,14 @@ HandleThumb(w, event, params, num_params
 	XtCallActionProc(w, "MoveThumb", event, params, *num_params);
 	XtCallActionProc(w, "NotifyThumb", event, params, *num_params);
     }
 }
 
-/* ARGSUSED */
     static void
 RepeatNotify(client_data, idp)
     XtPointer client_data;
-    XtIntervalId *idp;
+    XtIntervalId *idp UNUSED;
 {
     ScrollbarWidget sbw = (ScrollbarWidget) client_data;
     int		    call_data;
     char	    mode = sbw->scrollbar.scroll_mode;
     unsigned long   rep;
@@ -837,50 +837,46 @@ FloatInRange(num, small, big)
     float num, small, big;
 {
     return (num < small) ? small : ((num > big) ? big : num);
 }
 
-/* ARGSUSED */
     static void
 ScrollOneLineUp(w, event, params, num_params)
     Widget	w;
     XEvent	*event;
-    String	*params;
-    Cardinal	*num_params;
+    String	*params UNUSED;
+    Cardinal	*num_params UNUSED;
 {
     ScrollSome(w, event, -ONE_LINE_DATA);
 }
 
-/* ARGSUSED */
     static void
 ScrollOneLineDown(w, event, params, num_params)
     Widget	w;
     XEvent	*event;
-    String	*params;
-    Cardinal	*num_params;
+    String	*params UNUSED;
+    Cardinal	*num_params UNUSED;
 {
     ScrollSome(w, event, ONE_LINE_DATA);
 }
 
-/* ARGSUSED */
     static void
 ScrollPageDown(w, event, params, num_params)
     Widget	w;
     XEvent	*event;
-    String	*params;
-    Cardinal	*num_params;
+    String	*params UNUSED;
+    Cardinal	*num_params UNUSED;
 {
     ScrollSome(w, event, ONE_PAGE_DATA);
 }
 
-/* ARGSUSED */
     static void
 ScrollPageUp(w, event, params, num_params)
     Widget	w;
     XEvent	*event;
-    String	*params;
-    Cardinal	*num_params;
+    String	*params UNUSED;
+    Cardinal	*num_params UNUSED;
 {
     ScrollSome(w, event, -ONE_PAGE_DATA);
 }
 
     static void
@@ -899,17 +895,16 @@ ScrollSome(w, event, call_data)
 
     sbw->scrollbar.scroll_mode = SMODE_LINE_UP;
     XtCallCallbacks(w, XtNscrollProc, (XtPointer)call_data);
 }
 
-/* ARGSUSED */
     static void
 NotifyScroll(w, event, params, num_params)
     Widget	w;
     XEvent	*event;
-    String	*params;
-    Cardinal	*num_params;
+    String	*params UNUSED;
+    Cardinal	*num_params UNUSED;
 {
     ScrollbarWidget sbw = (ScrollbarWidget) w;
     Position	    x, y, loc;
     Dimension	    arrow_size;
     unsigned long   delay = 0;
@@ -989,17 +984,16 @@ NotifyScroll(w, event, params, num_param
 	sbw->scrollbar.timer_id =
 	    XtAppAddTimeOut(XtWidgetToApplicationContext(w),
 					   delay, RepeatNotify, (XtPointer)w);
 }
 
-/* ARGSUSED */
     static void
 EndScroll(w, event, params, num_params)
     Widget w;
-    XEvent *event;	/* unused */
-    String *params;	/* unused */
-    Cardinal *num_params;   /* unused */
+    XEvent *event UNUSED;
+    String *params UNUSED;
+    Cardinal *num_params UNUSED;
 {
     ScrollbarWidget sbw = (ScrollbarWidget) w;
 
     sbw->scrollbar.scroll_mode = SMODE_NONE;
     /* no need to remove any autoscroll timeout; it will no-op */
@@ -1021,17 +1015,16 @@ FractionLoc(sbw, x, y)
     height = (float)sbw->core.height - 2 * margin;
     width = (float)sbw->core.width - 2 * margin;
     return PICKLENGTH(sbw, x / width, y / height);
 }
 
-/* ARGSUSED */
     static void
 MoveThumb(w, event, params, num_params)
     Widget	w;
     XEvent	*event;
-    String	*params;	/* unused */
-    Cardinal	*num_params;	/* unused */
+    String	*params UNUSED;
+    Cardinal	*num_params UNUSED;
 {
     ScrollbarWidget	sbw = (ScrollbarWidget)w;
     Position		x, y;
     float		top;
     char		old_mode = sbw->scrollbar.scroll_mode;
@@ -1067,31 +1060,36 @@ MoveThumb(w, event, params, num_params)
     PaintThumb(sbw);
     XFlush(XtDisplay(w));   /* re-draw it before Notifying */
 }
 
 
-/* ARGSUSED */
     static void
 NotifyThumb(w, event, params, num_params)
     Widget	w;
     XEvent	*event;
-    String	*params;	/* unused */
-    Cardinal	*num_params;	/* unused */
+    String	*params UNUSED;
+    Cardinal	*num_params UNUSED;
 {
     ScrollbarWidget sbw = (ScrollbarWidget)w;
+    /* Use a union to avoid a warning for the weird conversion from float to
+     * XtPointer.  Comes from Xaw/Scrollbar.c. */
+    union {
+	XtPointer xtp;
+	float xtf;
+    } xtpf;
 
     if (LookAhead(w, event))
 	return;
 
     /* thumbProc is not pretty, but is necessary for backwards
        compatibility on those architectures for which it work{s,ed};
        the intent is to pass a (truncated) float by value. */
-    XtCallCallbacks(w, XtNthumbProc, *(XtPointer*)&sbw->scrollbar.top);
+    xtpf.xtf = sbw->scrollbar.top;
+    XtCallCallbacks(w, XtNthumbProc, xtpf.xtp);
     XtCallCallbacks(w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top);
 }
 
-/* ARGSUSED */
     static void
 AllocTopShadowGC(w)
     Widget w;
 {
     ScrollbarWidget sbw = (ScrollbarWidget) w;
@@ -1101,11 +1099,10 @@ AllocTopShadowGC(w)
     valuemask = GCForeground;
     myXGCV.foreground = sbw->scrollbar.top_shadow_pixel;
     sbw->scrollbar.top_shadow_GC = XtGetGC(w, valuemask, &myXGCV);
 }
 
-/* ARGSUSED */
     static void
 AllocBotShadowGC(w)
     Widget w;
 {
     ScrollbarWidget sbw = (ScrollbarWidget) w;
@@ -1115,15 +1112,14 @@ AllocBotShadowGC(w)
     valuemask = GCForeground;
     myXGCV.foreground = sbw->scrollbar.bot_shadow_pixel;
     sbw->scrollbar.bot_shadow_GC = XtGetGC(w, valuemask, &myXGCV);
 }
 
-/* ARGSUSED */
     static void
 _Xaw3dDrawShadows(gw, event, region, out)
     Widget  gw;
-    XEvent  *event;
+    XEvent  *event UNUSED;
     Region  region;
     int	    out;
 {
     XPoint  pt[6];
     ScrollbarWidget sbw = (ScrollbarWidget) gw;
--- vim72.orig/src/gui_athena.c
+++ vim72/src/gui_athena.c
@@ -84,14 +84,13 @@ static int		puller_width = 0;
 
 /*
  * Scrollbar callback (XtNjumpProc) for when the scrollbar is dragged with the
  * left or middle mouse button.
  */
-/* ARGSUSED */
     static void
 gui_athena_scroll_cb_jump(w, client_data, call_data)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data, call_data;
 {
     scrollbar_T *sb, *sb_info;
     long	value;
 
@@ -120,14 +119,13 @@ gui_athena_scroll_cb_jump(w, client_data
 
 /*
  * Scrollbar callback (XtNscrollProc) for paging up or down with the left or
  * right mouse buttons.
  */
-/* ARGSUSED */
     static void
 gui_athena_scroll_cb_scroll(w, client_data, call_data)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data, call_data;
 {
     scrollbar_T *sb, *sb_info;
     long	value;
     int		data = (int)(long)call_data;
@@ -490,11 +488,11 @@ get_toolbar_pixmap(menu, sen)
     }
 
     if (menu->icon_builtin || gui_find_bitmap(menu->name, buf, "xpm") == FAIL)
     {
 	if (menu->iconidx >= 0 && menu->iconidx
-		   < (sizeof(built_in_pixmaps) / sizeof(built_in_pixmaps[0])))
+	      < (int)(sizeof(built_in_pixmaps) / sizeof(built_in_pixmaps[0])))
 	    xpm = built_in_pixmaps[menu->iconidx];
 	else
 	    xpm = tb_blank_xpm;
     }
 
@@ -761,11 +759,11 @@ athena_calculate_ins_pos(widget)
     XtSetArg(args[n], XtNchildren, &children); n++;
     XtSetArg(args[n], XtNnumChildren, &num_children); n++;
     XtGetValues(XtParent(widget), args, n);
 
     retval = num_children;
-    for (i = 0; i < num_children; ++i)
+    for (i = 0; i < (int)num_children; ++i)
     {
 	Widget	current = children[i];
 	vimmenu_T	*menu = NULL;
 
 	for (menu = (a_cur_menu->parent == NULL)
@@ -778,15 +776,14 @@ athena_calculate_ins_pos(widget)
 		retval = i;
     }
     return retval;
 }
 
-/* ARGSUSED */
     void
 gui_mch_add_menu(menu, idx)
     vimmenu_T	*menu;
-    int		idx;
+    int		idx UNUSED;
 {
     char_u	*pullright_name;
     Dimension	height, space, border;
     vimmenu_T	*parent = menu->parent;
 
@@ -867,11 +864,11 @@ gui_mch_add_menu(menu, idx)
 	    int		i;
 
 	    XtVaGetValues(parent->submenu_id, XtNchildren, &children,
 					      XtNnumChildren, &num_children,
 					      NULL);
-	    for (i = 0; i < num_children; ++i)
+	    for (i = 0; i < (int)num_children; ++i)
 	    {
 		XtVaSetValues(children[i],
 			      XtNrightMargin, puller_width,
 			      NULL);
 	    }
@@ -911,11 +908,11 @@ gui_athena_menu_has_submenus(id, ignore)
     int		i;
 
     XtVaGetValues(id, XtNchildren, &children,
 		      XtNnumChildren, &num_children,
 		      NULL);
-    for (i = 0; i < num_children; ++i)
+    for (i = 0; i < (int)num_children; ++i)
     {
 	if (children[i] == ignore)
 	    continue;
 	if (has_submenu(children[i]))
 	    return True;
@@ -1173,15 +1170,14 @@ make_pull_name(name)
 	    *p = '_';
     }
     return pname;
 }
 
-/* ARGSUSED */
     void
 gui_mch_add_menu_item(menu, idx)
     vimmenu_T	*menu;
-    int		idx;
+    int		idx UNUSED;
 {
     vimmenu_T	*parent = menu->parent;
 
     a_cur_menu = menu;
 # ifdef FEAT_TOOLBAR
@@ -1442,11 +1438,11 @@ gui_mch_compute_toolbar_height()
 		XtNborderWidth,	    &shadowThickness,
 		XtNvSpace,	    &marginHeight,
 		XtNchildren,	    &children,
 		XtNnumChildren,	    &numChildren,
 		NULL);
-	for (i = 0; i < numChildren; i++)
+	for (i = 0; i < (int)numChildren; i++)
 	{
 	    whgt = 0;
 
 	    XtVaGetValues(children[i], XtNheight, &whgt, NULL);
 	    if (height < whgt)
@@ -1471,14 +1467,13 @@ gui_mch_get_toolbar_colors(bgp, fgp, bsp
     *hsp = *tsp;
 }
 #endif
 
 
-/* ARGSUSED */
     void
 gui_mch_toggle_tearoffs(enable)
-    int		enable;
+    int		enable UNUSED;
 {
     /* no tearoff menus */
 }
 
     void
@@ -1535,11 +1530,11 @@ gui_mch_destroy_menu(menu)
 	    if (gui_athena_menu_has_submenus(parent, menu->id))
 		right_margin = puller_width;
 	    else
 		get_left_margin = True;
 
-	    for (i = 0; i < num_children; ++i)
+	    for (i = 0; i < (int)num_children; ++i)
 	    {
 		if (children[i] == menu->id)
 		    continue;
 		if (get_left_margin == True)
 		{
@@ -1643,15 +1638,14 @@ gui_mch_destroy_menu(menu)
 	XtDestroyWidget(menu->submenu_id);
 	menu->submenu_id = (Widget)0;
     }
 }
 
-/*ARGSUSED*/
     static void
 gui_athena_menu_timeout(client_data, id)
     XtPointer	    client_data;
-    XtIntervalId    *id;
+    XtIntervalId    *id UNUSED;
 {
     Widget  w = (Widget)client_data;
     Widget  popup;
 
     timer = 0;
@@ -1676,16 +1670,15 @@ gui_athena_menu_timeout(client_data, id)
  * up.  It should appear even with and just slightly to the left of the
  * rightmost end of the menu entry that caused the popup.
  *
  * This is called when XtPopup() is called.
  */
-/*ARGSUSED*/
     static void
 gui_athena_popup_callback(w, client_data, call_data)
     Widget	w;
     XtPointer	client_data;
-    XtPointer	call_data;
+    XtPointer	call_data UNUSED;
 {
     /* Assumption: XtIsSubclass(XtParent(w),simpleMenuWidgetClass) */
     vimmenu_T	*menu = (vimmenu_T *)client_data;
     Dimension	width;
     Position	root_x, root_y;
@@ -1709,11 +1702,10 @@ gui_athena_popup_callback(w, client_data
     XtVaSetValues(w, XtNx, root_x,
 		     XtNy, root_y,
 		     NULL);
 }
 
-/* ARGSUSED */
     static void
 gui_athena_popdown_submenus_action(w, event, args, nargs)
     Widget	w;
     XEvent	*event;
     String	*args;
@@ -1754,11 +1746,10 @@ has_submenu(widget)
 	    return True;
     }
     return False;
 }
 
-/* ARGSUSED */
     static void
 gui_athena_delayed_arm_action(w, event, args, nargs)
     Widget	w;
     XEvent	*event;
     String	*args;
@@ -1835,11 +1826,10 @@ submenu_widget(widget)
     return popup;
     /* Postcondition: (popup != NULL) implies
      * (XtIsSubclass(popup,simpleMenuWidgetClass) == True) */
 }
 
-/* ARGSUSED */
     void
 gui_mch_show_popupmenu(menu)
     vimmenu_T *menu;
 {
     int		rootx, rooty, winx, winy;
@@ -2044,19 +2034,18 @@ gui_x11_get_wid()
 #if defined(FEAT_BROWSE) || defined(PROTO)
 /*
  * Put up a file requester.
  * Returns the selected name in allocated memory, or NULL for Cancel.
  */
-/* ARGSUSED */
     char_u *
 gui_mch_browse(saving, title, dflt, ext, initdir, filter)
-    int		saving;		/* select file to write */
-    char_u	*title;		/* not used (title for the window) */
-    char_u	*dflt;		/* not used (default name) */
-    char_u	*ext;		/* not used (extension added) */
+    int		saving UNUSED;	/* select file to write */
+    char_u	*title;		/* title for the window */
+    char_u	*dflt;		/* default name */
+    char_u	*ext UNUSED;	/* extension added */
     char_u	*initdir;	/* initial directory, NULL for current dir */
-    char_u	*filter;	/* not used (file name filter) */
+    char_u	*filter UNUSED;	/* file name filter */
 {
     Position x, y;
     char_u	dirbuf[MAXPATHL];
 
     /* Concatenate "initdir" and "dflt". */
@@ -2098,17 +2087,16 @@ static void dialog_wm_handler __ARGS((Wi
 
 /*
  * Callback function for the textfield.  When CR is hit this works like
  * hitting the "OK" button, ESC like "Cancel".
  */
-/* ARGSUSED */
     static void
 keyhit_callback(w, client_data, event, cont)
-    Widget		w;
-    XtPointer		client_data;
+    Widget		w UNUSED;
+    XtPointer		client_data UNUSED;
     XEvent		*event;
-    Boolean		*cont;
+    Boolean		*cont UNUSED;
 {
     char	buf[2];
 
     if (XLookupString(&(event->xkey), buf, 2, NULL, NULL) == 1)
     {
@@ -2117,44 +2105,41 @@ keyhit_callback(w, client_data, event, c
 	else if (*buf == ESC)
 	    dialogStatus = 0;
     }
 }
 
-/* ARGSUSED */
     static void
 butproc(w, client_data, call_data)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data;
-    XtPointer	call_data;
+    XtPointer	call_data UNUSED;
 {
     dialogStatus = (int)(long)client_data + 1;
 }
 
 /*
  * Function called when dialog window closed.
  */
-/*ARGSUSED*/
     static void
 dialog_wm_handler(w, client_data, event, dum)
-    Widget	w;
-    XtPointer	client_data;
+    Widget	w UNUSED;
+    XtPointer	client_data UNUSED;
     XEvent	*event;
-    Boolean	*dum;
+    Boolean	*dum UNUSED;
 {
     if (event->type == ClientMessage
-	    && ((XClientMessageEvent *)event)->data.l[0] == dialogatom)
+	    && (Atom)((XClientMessageEvent *)event)->data.l[0] == dialogatom)
 	dialogStatus = 0;
 }
 
-/* ARGSUSED */
     int
 gui_mch_dialog(type, title, message, buttons, dfltbutton, textfield)
-    int		type;
+    int		type UNUSED;
     char_u	*title;
     char_u	*message;
     char_u	*buttons;
-    int		dfltbutton;
+    int		dfltbutton UNUSED;
     char_u	*textfield;
 {
     char_u		*buts;
     char_u		*p, *next;
     XtAppContext	app;
--- vim72.orig/src/gui_beval.c
+++ vim72/src/gui_beval.c
@@ -13,15 +13,14 @@
 #if defined(FEAT_BEVAL) || defined(PROTO)
 
 /*
  * Common code, invoked when the mouse is resting for a moment.
  */
-/*ARGSUSED*/
     void
 general_beval_cb(beval, state)
     BalloonEval *beval;
-    int state;
+    int		state UNUSED;
 {
     win_T	*wp;
     int		col;
     int		use_sandbox;
     linenr_T	lnum;
@@ -549,13 +548,12 @@ target_event_cb(GtkWidget *widget, GdkEv
     }
 
     return FALSE; /* continue emission */
 }
 
-/*ARGSUSED*/
     static gint
-mainwin_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
+mainwin_event_cb(GtkWidget *widget UNUSED, GdkEvent *event, gpointer data)
 {
     BalloonEval *beval = (BalloonEval *)data;
 
     switch (event->type)
     {
@@ -661,24 +659,24 @@ timeout_cb(gpointer data)
     requestBalloon(beval);
 
     return FALSE; /* don't call me again */
 }
 
-/*ARGSUSED2*/
     static gint
-balloon_expose_event_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
+balloon_expose_event_cb(GtkWidget *widget,
+			GdkEventExpose *event,
+			gpointer data UNUSED)
 {
     gtk_paint_flat_box(widget->style, widget->window,
 		       GTK_STATE_NORMAL, GTK_SHADOW_OUT,
 		       &event->area, widget, "tooltip",
 		       0, 0, -1, -1);
 
     return FALSE; /* continue emission */
 }
 
 # ifndef HAVE_GTK2
-/*ARGSUSED2*/
     static void
 balloon_draw_cb(GtkWidget *widget, GdkRectangle *area, gpointer data)
 {
     GtkWidget	    *child;
     GdkRectangle    child_area;
@@ -724,17 +722,16 @@ removeEventHandler(beval)
 
 
 /*
  * The X event handler. All it does is call the real event handler.
  */
-/*ARGSUSED*/
     static void
 pointerEventEH(w, client_data, event, unused)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data;
     XEvent	*event;
-    Boolean	*unused;
+    Boolean	*unused UNUSED;
 {
     BalloonEval *beval = (BalloonEval *)client_data;
     pointerEvent(beval, event);
 }
 
@@ -875,15 +872,14 @@ pointerEvent(beval, event)
 	default:
 	    break;
     }
 }
 
-/*ARGSUSED*/
     static void
 timerRoutine(dx, id)
     XtPointer	    dx;
-    XtIntervalId    *id;
+    XtIntervalId    *id UNUSED;
 {
     BalloonEval *beval = (BalloonEval *)dx;
 
     beval->timerID = (XtIntervalId)NULL;
 
@@ -1289,10 +1285,27 @@ drawBalloon(beval)
 	XtVaSetValues(beval->balloonShell,
 		XtNx, tx,
 		XtNy, ty,
 		NULL);
 #endif
+	/* Set tooltip colors */
+	{
+	    Arg args[2];
+
+#ifdef FEAT_GUI_MOTIF
+	    args[0].name = XmNbackground;
+	    args[0].value = gui.tooltip_bg_pixel;
+	    args[1].name = XmNforeground;
+	    args[1].value = gui.tooltip_fg_pixel;
+#else /* Athena */
+	    args[0].name = XtNbackground;
+	    args[0].value = gui.tooltip_bg_pixel;
+	    args[1].name = XtNforeground;
+	    args[1].value = gui.tooltip_fg_pixel;
+#endif
+	    XtSetValues(beval->balloonLabel, &args[0], XtNumber(args));
+	}
 
 	XtPopup(beval->balloonShell, XtGrabNone);
 
 	beval->showState = ShS_SHOWING;
 
--- vim72.orig/src/gui_gtk.c
+++ vim72/src/gui_gtk.c
@@ -283,18 +283,18 @@ create_menu_icon(vimmenu_T *menu, GtkIco
     }
 
     return image;
 }
 
-/*ARGSUSED*/
     static gint
-toolbar_button_focus_in_event(GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
-    /* When we're in a GtkPlug, we don't have window focus events, only widget focus.
-     * To emulate stand-alone gvim, if a button gets focus (e.g., <Tab> into GtkPlug)
-     * immediately pass it to mainwin.
-     */
+toolbar_button_focus_in_event(GtkWidget *widget UNUSED,
+			      GdkEventFocus *event UNUSED,
+			      gpointer data UNUSED)
+{
+    /* When we're in a GtkPlug, we don't have window focus events, only widget
+     * focus.  To emulate stand-alone gvim, if a button gets focus (e.g.,
+     * <Tab> into GtkPlug) immediately pass it to mainwin. */
     if (gtk_socket_id != 0)
 	gtk_widget_grab_focus(gui.drawarea);
 
     return TRUE;
 }
@@ -583,13 +583,12 @@ gui_mch_add_menu(vimmenu_T *menu, int id
     if (vim_strchr(p_go, GO_TEAROFF) != NULL)
 	gtk_widget_show(menu->tearoff_handle);
     gtk_menu_prepend(GTK_MENU(menu->submenu_id), menu->tearoff_handle);
 }
 
-/*ARGSUSED*/
     static void
-menu_item_activate(GtkWidget *widget, gpointer data)
+menu_item_activate(GtkWidget *widget UNUSED, gpointer data)
 {
     gui_menu_cb((vimmenu_T *)data);
 
 # ifndef HAVE_GTK2
     /* Work around a bug in GTK+ 1: we don't seem to get a focus-in
@@ -1200,13 +1199,12 @@ gui_mch_destroy_scrollbar(scrollbar_T *s
  * on just about any event. */
 /* # define USE_FILE_CHOOSER */
 #endif
 
 #ifndef USE_FILE_CHOOSER
-/*ARGSUSED*/
     static void
-browse_ok_cb(GtkWidget *widget, gpointer cbdata)
+browse_ok_cb(GtkWidget *widget UNUSED, gpointer cbdata)
 {
     gui_T *vw = (gui_T *)cbdata;
 
     if (vw->browse_fname != NULL)
 	g_free(vw->browse_fname);
@@ -1216,13 +1214,12 @@ browse_ok_cb(GtkWidget *widget, gpointer
     gtk_widget_hide(vw->filedlg);
     if (gtk_main_level() > 0)
 	gtk_main_quit();
 }
 
-/*ARGSUSED*/
     static void
-browse_cancel_cb(GtkWidget *widget, gpointer cbdata)
+browse_cancel_cb(GtkWidget *widget UNUSED, gpointer cbdata)
 {
     gui_T *vw = (gui_T *)cbdata;
 
     if (vw->browse_fname != NULL)
     {
@@ -1232,13 +1229,12 @@ browse_cancel_cb(GtkWidget *widget, gpoi
     gtk_widget_hide(vw->filedlg);
     if (gtk_main_level() > 0)
 	gtk_main_quit();
 }
 
-/*ARGSUSED*/
     static gboolean
-browse_destroy_cb(GtkWidget * widget)
+browse_destroy_cb(GtkWidget *widget UNUSED)
 {
     if (gui.browse_fname != NULL)
     {
 	g_free(gui.browse_fname);
 	gui.browse_fname = NULL;
@@ -1260,18 +1256,17 @@ browse_destroy_cb(GtkWidget * widget)
  * dflt				default name
  * ext				not used (extension added)
  * initdir			initial directory, NULL for current dir
  * filter			not used (file name filter)
  */
-/*ARGSUSED*/
     char_u *
-gui_mch_browse(int saving,
+gui_mch_browse(int saving UNUSED,
 	       char_u *title,
 	       char_u *dflt,
-	       char_u *ext,
+	       char_u *ext UNUSED,
 	       char_u *initdir,
-	       char_u *filter)
+	       char_u *filter UNUSED)
 {
 #ifdef USE_FILE_CHOOSER
     GtkWidget		*fc;
 #endif
     char_u		dirbuf[MAXPATHL];
@@ -1375,11 +1370,10 @@ gui_mch_browse(int saving,
  * Returns the selected name in allocated memory, or NULL for Cancel.
  * title			title for the window
  * dflt				default name
  * initdir			initial directory, NULL for current dir
  */
-/*ARGSUSED*/
     char_u *
 gui_mch_browsedir(
 	       char_u *title,
 	       char_u *initdir)
 {
@@ -1458,11 +1452,10 @@ dlg_destroy(GtkWidget *dlg)
     /* Destroy the dialog, will break the waiting loop. */
     gtk_widget_destroy(dlg);
 }
 
 # ifdef FEAT_GUI_GNOME
-/* ARGSUSED */
     static int
 gui_gnome_dialog( int	type,
 		char_u	*title,
 		char_u	*message,
 		char_u	*buttons,
@@ -1609,22 +1602,20 @@ typedef struct _CancelData
     int		*status;
     int		ignore_enter;
     GtkWidget	*dialog;
 } CancelData;
 
-/* ARGSUSED */
     static void
 dlg_button_clicked(GtkWidget * widget, ButtonData *data)
 {
     *(data->status) = data->index + 1;
     dlg_destroy(data->dialog);
 }
 
 /*
  * This makes the Escape key equivalent to the cancel button.
  */
-/*ARGSUSED*/
     static int
 dlg_key_press_event(GtkWidget *widget, GdkEventKey *event, CancelData *data)
 {
     /* Ignore hitting Enter (or Space) when there is no default button. */
     if (data->ignore_enter && (event->keyval == GDK_Return
@@ -1653,11 +1644,10 @@ dlg_destroy_cb(int *p)
     *p = TRUE;		/* set dialog_destroyed to break out of the loop */
     if (gtk_main_level() > 0)
 	gtk_main_quit();
 }
 
-/* ARGSUSED */
     int
 gui_mch_dialog(	int	type,		/* type of dialog */
 		char_u	*title,		/* title of dialog */
 		char_u	*message,	/* message text */
 		char_u	*buttons,	/* names of buttons */
@@ -2213,11 +2203,10 @@ typedef struct _DialogInfo
     int		ignore_enter;	    /* no default button, ignore "Enter" */
     int		noalt;		    /* accept accelerators without Alt */
     GtkDialog	*dialog;	    /* Widget of the dialog */
 } DialogInfo;
 
-/*ARGSUSED2*/
     static gboolean
 dialog_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
     DialogInfo *di = (DialogInfo *)data;
 
@@ -2322,23 +2311,10 @@ gui_mch_dialog(int	type,	    /* type of
 	    CONVERT_FROM_UTF8_FREE(text);
 	}
 	gtk_widget_destroy(dialog);
     }
 
-    /* Terrible hack: When the text area still has focus when we remove the
-     * dialog, somehow gvim loses window focus.  This is with "point to type"
-     * in the KDE 3.1 window manager.  Warp the mouse pointer to outside the
-     * window and back to avoid that. */
-    if (!gui.in_focus)
-    {
-	int x, y;
-
-	gdk_window_get_pointer(gui.drawarea->window, &x, &y, NULL);
-	gui_mch_setmouse(-100, -100);
-	gui_mch_setmouse(x, y);
-    }
-
     return response > 0 ? response : 0;
 }
 
 #endif /* FEAT_GUI_DIALOG && HAVE_GTK2 */
 
@@ -2396,18 +2372,17 @@ static int popup_mouse_pos;
  * at the current text cursor position.
  *
  * Note: The push_in output argument seems to affect scrolling of huge
  * menus that don't fit on the screen.	Leave it at the default for now.
  */
-/*ARGSUSED0*/
     static void
-popup_menu_position_func(GtkMenu *menu,
+popup_menu_position_func(GtkMenu *menu UNUSED,
 			 gint *x, gint *y,
 # ifdef HAVE_GTK2
-			 gboolean *push_in,
+			 gboolean *push_in UNUSED,
 # endif
-			 gpointer user_data)
+			 gpointer user_data UNUSED)
 {
     gdk_window_get_origin(gui.drawarea->window, x, y);
 
     if (popup_mouse_pos)
     {
@@ -2462,17 +2437,16 @@ typedef struct _SharedFindReplace
     GtkWidget *find;	/* 'Find Next' action button */
     GtkWidget *replace;	/* 'Replace With' action button */
     GtkWidget *all;	/* 'Replace All' action button */
 } SharedFindReplace;
 
-static SharedFindReplace find_widgets = { NULL, };
-static SharedFindReplace repl_widgets = { NULL, };
+static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+static SharedFindReplace repl_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
 
-/* ARGSUSED */
     static int
 find_key_press_event(
-		GtkWidget	*widget,
+		GtkWidget	*widget UNUSED,
 		GdkEventKey	*event,
 		SharedFindReplace *frdp)
 {
     /* If the user is holding one of the key modifiers we will just bail out,
      * thus preserving the possibility of normal focus traversal.
@@ -2960,13 +2934,12 @@ gui_gtk_synch_fonts(void)
 
 
 /*
  * Callback for actions of the find and replace dialogs
  */
-/*ARGSUSED*/
     static void
-find_replace_cb(GtkWidget *widget, gpointer data)
+find_replace_cb(GtkWidget *widget UNUSED, gpointer data)
 {
     int			flags;
     char_u		*find_text;
     char_u		*repl_text;
     gboolean		direction_down;
@@ -3008,13 +2981,12 @@ find_replace_cb(GtkWidget *widget, gpoin
     if (rc && gtk_main_level() > 0)
 	gtk_main_quit(); /* make sure cmd will be handled immediately */
 }
 
 /* our usual callback function */
-/*ARGSUSED*/
     static void
-entry_activate_cb(GtkWidget *widget, gpointer data)
+entry_activate_cb(GtkWidget *widget UNUSED, gpointer data)
 {
     gtk_widget_grab_focus(GTK_WIDGET(data));
 }
 
 /*
@@ -3053,14 +3025,13 @@ entry_changed_cb(GtkWidget * entry, GtkW
 }
 
 /*
  * ":helpfind"
  */
-/*ARGSUSED*/
     void
 ex_helpfind(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     /* This will fail when menus are not loaded.  Well, it's only for
      * backwards compatibility anyway. */
     do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp");
 }
--- vim72.orig/src/gui_gtk_f.c
+++ vim72/src/gui_gtk_f.c
@@ -225,18 +225,18 @@ gtk_form_get_type(void)
 {
     static GtkType form_type = 0;
 
     if (!form_type)
     {
-	GtkTypeInfo form_info =
-	{
-	    "GtkForm",
-	    sizeof(GtkForm),
-	    sizeof(GtkFormClass),
-	    (GtkClassInitFunc) gtk_form_class_init,
-	    (GtkObjectInitFunc) gtk_form_init
-	};
+	GtkTypeInfo form_info;
+
+	vim_memset(&form_info, 0, sizeof(form_info));
+	form_info.type_name = "GtkForm";
+	form_info.object_size = sizeof(GtkForm);
+	form_info.class_size = sizeof(GtkFormClass);
+	form_info.class_init_func = (GtkClassInitFunc)gtk_form_class_init;
+	form_info.object_init_func = (GtkObjectInitFunc)gtk_form_init;
 
 	form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info);
     }
     return form_type;
 }
@@ -609,14 +609,13 @@ gtk_form_remove(GtkContainer *container,
 	g_list_free_1(tmp_list);
 	g_free(child);
     }
 }
 
-/*ARGSUSED1*/
     static void
 gtk_form_forall(GtkContainer	*container,
-		gboolean	include_internals,
+		gboolean	include_internals UNUSED,
 		GtkCallback	callback,
 		gpointer	callback_data)
 {
     GtkForm *form;
     GtkFormChild *child;
@@ -784,13 +783,12 @@ gtk_form_position_children(GtkForm *form
  * This routine identifies expose events that are generated when
  * we've temporarily moved the bin_window_origin, and translates
  * them or discards them, depending on whether we are obscured
  * or not.
  */
-/*ARGSUSED1*/
     static GdkFilterReturn
-gtk_form_filter(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
+gtk_form_filter(GdkXEvent *gdk_xevent, GdkEvent *event UNUSED, gpointer data)
 {
     XEvent *xevent;
     GtkForm *form;
 
     xevent = (XEvent *) gdk_xevent;
@@ -819,13 +817,14 @@ gtk_form_filter(GdkXEvent *gdk_xevent, G
 
 /* Although GDK does have a GDK_VISIBILITY_NOTIFY event,
  * there is no corresponding event in GTK, so we have
  * to get the events from a filter
  */
-/*ARGSUSED1*/
     static GdkFilterReturn
-gtk_form_main_filter(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
+gtk_form_main_filter(GdkXEvent *gdk_xevent,
+		     GdkEvent *event UNUSED,
+		     gpointer data)
 {
     XEvent *xevent;
     GtkForm *form;
 
     xevent = (XEvent *) gdk_xevent;
@@ -859,15 +858,13 @@ gtk_form_main_filter(GdkXEvent *gdk_xeve
  */
     static void
 gtk_form_set_static_gravity(GdkWindow *window, gboolean use_static)
 {
 #ifdef HAVE_GTK2
-    gboolean static_gravity_supported;
-
-    static_gravity_supported = gdk_window_set_static_gravities(window,
-							       use_static);
-    g_return_if_fail(static_gravity_supported);
+    /* We don't check if static gravity is actually supported, because it
+     * results in an annoying assertion error message. */
+    gdk_window_set_static_gravities(window, use_static);
 #else
     XSetWindowAttributes xattributes;
 
     xattributes.win_gravity = (use_static) ? StaticGravity : NorthWestGravity;
     xattributes.bit_gravity = (use_static) ? StaticGravity : NorthWestGravity;
@@ -909,25 +906,23 @@ gtk_form_send_configure(GtkForm *form)
 #else
     gtk_widget_event(widget, (GdkEvent*)&event);
 #endif
 }
 
-/*ARGSUSED0*/
     static void
-gtk_form_child_map(GtkWidget *widget, gpointer user_data)
+gtk_form_child_map(GtkWidget *widget UNUSED, gpointer user_data)
 {
     GtkFormChild *child;
 
     child = (GtkFormChild *)user_data;
 
     child->mapped = TRUE;
     gdk_window_show(child->window);
 }
 
-/*ARGSUSED0*/
     static void
-gtk_form_child_unmap(GtkWidget *widget, gpointer user_data)
+gtk_form_child_unmap(GtkWidget *widget UNUSED, gpointer user_data)
 {
     GtkFormChild *child;
 
     child = (GtkFormChild *)user_data;
 
--- vim72.orig/src/gui_gtk_x11.c
+++ vim72/src/gui_gtk_x11.c
@@ -105,10 +105,11 @@ enum
 {
     TARGET_TYPE_NONE,
     TARGET_UTF8_STRING,
     TARGET_STRING,
     TARGET_COMPOUND_TEXT,
+    TARGET_HTML,
     TARGET_TEXT,
     TARGET_TEXT_URI_LIST,
     TARGET_TEXT_PLAIN,
     TARGET_VIM,
     TARGET_VIMENC
@@ -121,10 +122,11 @@ enum
 static const GtkTargetEntry selection_targets[] =
 {
     {VIMENC_ATOM_NAME,	0, TARGET_VIMENC},
     {VIM_ATOM_NAME,	0, TARGET_VIM},
 #ifdef FEAT_MBYTE
+    {"text/html",	0, TARGET_HTML},
     {"UTF8_STRING",	0, TARGET_UTF8_STRING},
 #endif
     {"COMPOUND_TEXT",	0, TARGET_COMPOUND_TEXT},
     {"TEXT",		0, TARGET_TEXT},
     {"STRING",		0, TARGET_STRING}
@@ -138,10 +140,11 @@ static const GtkTargetEntry selection_ta
  */
 static const GtkTargetEntry dnd_targets[] =
 {
     {"text/uri-list",	0, TARGET_TEXT_URI_LIST},
 # ifdef FEAT_MBYTE
+    {"text/html",	0, TARGET_HTML},
     {"UTF8_STRING",	0, TARGET_UTF8_STRING},
 # endif
     {"STRING",		0, TARGET_STRING},
     {"text/plain",	0, TARGET_TEXT_PLAIN}
 };
@@ -176,10 +179,11 @@ static GdkAtom save_yourself_atom = GDK_
 
 /*
  * Atoms used to control/reference X11 selections.
  */
 #ifdef FEAT_MBYTE
+static GdkAtom html_atom = GDK_NONE;
 static GdkAtom utf8_string_atom = GDK_NONE;
 #endif
 #ifndef HAVE_GTK2
 static GdkAtom compound_text_atom = GDK_NONE;
 static GdkAtom text_atom = GDK_NONE;
@@ -410,10 +414,11 @@ static char **gui_argv = NULL;
 #ifdef HAVE_GTK2
 static const char *role_argument = NULL;
 #endif
 #if defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION)
 static const char *restart_command = NULL;
+static       char *abs_restart_command = NULL;
 #endif
 static int found_iconic_arg = FALSE;
 
 #ifdef FEAT_GUI_GNOME
 /*
@@ -447,12 +452,14 @@ gui_mch_prepare(int *argc, char **argv)
     if (strchr(argv[0], G_DIR_SEPARATOR) != NULL)
     {
 	char_u buf[MAXPATHL];
 
 	if (mch_FullName((char_u *)argv[0], buf, (int)sizeof(buf), TRUE) == OK)
-	    /* Tiny leak; doesn't matter, and usually we don't even get here */
-	    restart_command = (char *)vim_strsave(buf);
+	{
+	    abs_restart_command = (char *)vim_strsave(buf);
+	    restart_command = abs_restart_command;
+	}
     }
 #endif
 
     /*
      * Move all the entries in argv which are relevant to GTK+ and GNOME
@@ -609,21 +616,25 @@ gui_mch_prepare(int *argc, char **argv)
 #if defined(EXITFREE) || defined(PROTO)
     void
 gui_mch_free_all()
 {
     vim_free(gui_argv);
+#if defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION)
+    vim_free(abs_restart_command);
+#endif
 }
 #endif
 
 /*
  * This should be maybe completely removed.
  * Doesn't seem possible, since check_copy_area() relies on
  * this information.  --danielk
  */
-/*ARGSUSED*/
     static gint
-visibility_event(GtkWidget *widget, GdkEventVisibility *event, gpointer data)
+visibility_event(GtkWidget *widget UNUSED,
+		 GdkEventVisibility *event,
+		 gpointer data UNUSED)
 {
     gui.visibility = event->state;
     /*
      * When we do an gdk_window_copy_area(), and the window is partially
      * obscured, we want to receive an event to tell us whether it worked
@@ -636,13 +647,14 @@ visibility_event(GtkWidget *widget, GdkE
 }
 
 /*
  * Redraw the corresponding portions of the screen.
  */
-/*ARGSUSED*/
     static gint
-expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
+expose_event(GtkWidget *widget UNUSED,
+	     GdkEventExpose *event,
+	     gpointer data UNUSED)
 {
     /* Skip this when the GUI isn't set up yet, will redraw later. */
     if (gui.starting)
 	return FALSE;
 
@@ -666,13 +678,14 @@ expose_event(GtkWidget *widget, GdkEvent
 
 #ifdef FEAT_CLIENTSERVER
 /*
  * Handle changes to the "Comm" property
  */
-/*ARGSUSED2*/
     static gint
-property_event(GtkWidget *widget, GdkEventProperty *event, gpointer data)
+property_event(GtkWidget *widget,
+	       GdkEventProperty *event,
+	       gpointer data UNUSED)
 {
     if (event->type == GDK_PROPERTY_NOTIFY
 	    && event->state == (int)GDK_PROPERTY_NEW_VALUE
 	    && GDK_WINDOW_XWINDOW(event->window) == commWindow
 	    && GET_X_ATOM(event->atom) == commProperty)
@@ -738,13 +751,12 @@ gui_mch_stop_blink(void)
     if (blink_state == BLINK_OFF)
 	gui_update_cursor(TRUE, FALSE);
     blink_state = BLINK_NONE;
 }
 
-/*ARGSUSED*/
     static gint
-blink_cb(gpointer data)
+blink_cb(gpointer data UNUSED)
 {
     if (blink_state == BLINK_ON)
     {
 	gui_undraw_cursor();
 	blink_state = BLINK_OFF;
@@ -779,13 +791,14 @@ gui_mch_start_blink(void)
 	blink_state = BLINK_ON;
 	gui_update_cursor(TRUE, FALSE);
     }
 }
 
-/*ARGSUSED*/
     static gint
-enter_notify_event(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
+enter_notify_event(GtkWidget *widget UNUSED,
+		   GdkEventCrossing *event UNUSED,
+		   gpointer data UNUSED)
 {
     if (blink_state == BLINK_NONE)
 	gui_mch_start_blink();
 
     /* make sure keyboard input goes there */
@@ -793,23 +806,25 @@ enter_notify_event(GtkWidget *widget, Gd
 	gtk_widget_grab_focus(gui.drawarea);
 
     return FALSE;
 }
 
-/*ARGSUSED*/
     static gint
-leave_notify_event(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
+leave_notify_event(GtkWidget *widget UNUSED,
+		   GdkEventCrossing *event UNUSED,
+		   gpointer data UNUSED)
 {
     if (blink_state != BLINK_NONE)
 	gui_mch_stop_blink();
 
     return FALSE;
 }
 
-/*ARGSUSED*/
     static gint
-focus_in_event(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+focus_in_event(GtkWidget *widget,
+	       GdkEventFocus *event UNUSED,
+	       gpointer data UNUSED)
 {
     gui_focus_change(TRUE);
 
     if (blink_state == BLINK_NONE)
 	gui_mch_start_blink();
@@ -824,13 +839,14 @@ focus_in_event(GtkWidget *widget, GdkEve
 	gtk_main_quit();
 
     return TRUE;
 }
 
-/*ARGSUSED*/
     static gint
-focus_out_event(GtkWidget *widget, GdkEventFocus *event, gpointer data)
+focus_out_event(GtkWidget *widget UNUSED,
+	        GdkEventFocus *event UNUSED,
+		gpointer data UNUSED)
 {
     gui_focus_change(FALSE);
 
     if (blink_state != BLINK_NONE)
 	gui_mch_stop_blink();
@@ -954,13 +970,14 @@ modifiers_gdk2mouse(guint state)
 }
 
 /*
  * Main keyboard handler:
  */
-/*ARGSUSED*/
     static gint
-key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
+key_press_event(GtkWidget *widget UNUSED,
+		GdkEventKey *event,
+		gpointer data UNUSED)
 {
 #ifdef HAVE_GTK2
     /* 256 bytes is way over the top, but for safety let's reduce it only
      * for GTK+ 2 where we know for sure how large the string might get.
      * (That is, up to 6 bytes + NUL + CSI escapes + safety measure.) */
@@ -1223,13 +1240,14 @@ key_press_event(GtkWidget *widget, GdkEv
 
     return TRUE;
 }
 
 #if defined(FEAT_XIM) && defined(HAVE_GTK2)
-/*ARGSUSED0*/
     static gboolean
-key_release_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
+key_release_event(GtkWidget *widget UNUSED,
+		  GdkEventKey *event,
+		  gpointer data UNUSED)
 {
     /*
      * GTK+ 2 input methods may do fancy stuff on key release events too.
      * With the default IM for instance, you can enter any UCS code point
      * by holding down CTRL-SHIFT and typing hexadecimal digits.
@@ -1241,15 +1259,14 @@ key_release_event(GtkWidget *widget, Gdk
 
 /****************************************************************************
  * Selection handlers:
  */
 
-/*ARGSUSED*/
     static gint
-selection_clear_event(GtkWidget		*widget,
+selection_clear_event(GtkWidget		*widget UNUSED,
 		      GdkEventSelection	*event,
-		      gpointer		user_data)
+		      gpointer		user_data UNUSED)
 {
     if (event->selection == clip_plus.gtk_sel_atom)
 	clip_lose_selection(&clip_plus);
     else
 	clip_lose_selection(&clip_star);
@@ -1263,16 +1280,15 @@ selection_clear_event(GtkWidget		*widget
 #define RS_NONE	0	/* selection_received_cb() not called yet */
 #define RS_OK	1	/* selection_received_cb() called and OK */
 #define RS_FAIL	2	/* selection_received_cb() called and failed */
 static int received_selection = RS_NONE;
 
-/*ARGSUSED*/
     static void
-selection_received_cb(GtkWidget		*widget,
+selection_received_cb(GtkWidget		*widget UNUSED,
 		      GtkSelectionData	*data,
-		      guint		time_,
-		      gpointer		user_data)
+		      guint		time_ UNUSED,
+		      gpointer		user_data UNUSED)
 {
     VimClipboard    *cbd;
     char_u	    *text;
     char_u	    *tmpbuf = NULL;
 #ifdef HAVE_GTK2
@@ -1350,10 +1366,28 @@ selection_received_cb(GtkWidget		*widget
 		    text = tmpbuf;
 	    }
 	    else
 		text = tmpbuf_utf8;
 	}
+	else if (len >= 2 && text[0] == 0xff && text[1] == 0xfe)
+	{
+	    vimconv_T conv;
+
+	    /* UTF-16, we get this for HTML */
+	    conv.vc_type = CONV_NONE;
+	    convert_setup_ext(&conv, (char_u *)"utf-16le", FALSE, p_enc, TRUE);
+
+	    if (conv.vc_type != CONV_NONE)
+	    {
+		text += 2;
+		len -= 2;
+		tmpbuf = string_convert(&conv, text, &len);
+		convert_setup(&conv, NULL, NULL);
+	    }
+	    if (tmpbuf != NULL)
+		text = tmpbuf;
+	}
     }
 #else /* !HAVE_GTK2 */
 # ifdef FEAT_MBYTE
     else if (data->type == utf8_string_atom)
     {
@@ -1412,17 +1446,16 @@ selection_received_cb(GtkWidget		*widget
 
 /*
  * Prepare our selection data for passing it to the external selection
  * client.
  */
-/*ARGSUSED*/
     static void
-selection_get_cb(GtkWidget	    *widget,
+selection_get_cb(GtkWidget	    *widget UNUSED,
 		 GtkSelectionData   *selection_data,
 		 guint		    info,
-		 guint		    time_,
-		 gpointer	    user_data)
+		 guint		    time_ UNUSED,
+		 gpointer	    user_data UNUSED)
 {
     char_u	    *string;
     char_u	    *tmpbuf;
     long_u	    tmplen;
     int		    length;
@@ -1438,10 +1471,11 @@ selection_get_cb(GtkWidget	    *widget,
     if (!cbd->owned)
 	return;			/* Shouldn't ever happen */
 
     if (info != (guint)TARGET_STRING
 #ifdef FEAT_MBYTE
+	    && (!clip_html || info != (guint)TARGET_HTML)
 	    && info != (guint)TARGET_UTF8_STRING
 	    && info != (guint)TARGET_VIMENC
 #endif
 	    && info != (guint)TARGET_VIM
 	    && info != (guint)TARGET_COMPOUND_TEXT
@@ -1473,10 +1507,44 @@ selection_get_cb(GtkWidget	    *widget,
 	string = tmpbuf;
 	type = vim_atom;
     }
 
 #ifdef FEAT_MBYTE
+    else if (info == (guint)TARGET_HTML)
+    {
+	vimconv_T conv;
+
+	/* Since we get utf-16, we probably should set it as well. */
+	conv.vc_type = CONV_NONE;
+	convert_setup_ext(&conv, p_enc, TRUE, (char_u *)"utf-16le", FALSE);
+	if (conv.vc_type != CONV_NONE)
+	{
+	    tmpbuf = string_convert(&conv, string, &length);
+	    convert_setup(&conv, NULL, NULL);
+	    vim_free(string);
+	    string = tmpbuf;
+	}
+
+	/* Prepend the BOM: "fffe" */
+	if (string != NULL)
+	{
+	    tmpbuf = alloc(length + 2);
+	    tmpbuf[0] = 0xff;
+	    tmpbuf[1] = 0xfe;
+	    mch_memmove(tmpbuf + 2, string, (size_t)length);
+	    vim_free(string);
+	    string = tmpbuf;
+	    length += 2;
+
+	    selection_data->type = selection_data->target;
+	    selection_data->format = 16;	/* 16 bits per char */
+	    gtk_selection_data_set(selection_data, html_atom, 16,
+							      string, length);
+	    vim_free(string);
+	}
+	return;
+    }
     else if (info == (guint)TARGET_VIMENC)
     {
 	int l = STRLEN(p_enc);
 
 	/* contents: motion_type 'encoding' NUL text */
@@ -1676,11 +1744,11 @@ process_motion_notify(int x, int y, GdkM
 	dx = x < 0 ? -x : x - gui.drawarea->allocation.width;
 	dy = y < 0 ? -y : y - gui.drawarea->allocation.height;
 
 	offshoot = dx > dy ? dx : dy;
 
-	/* Make a linearly declaying timer delay with a threshold of 5 at a
+	/* Make a linearly decaying timer delay with a threshold of 5 at a
 	 * distance of 127 pixels from the main window.
 	 *
 	 * One could think endlessly about the most ergonomic variant here.
 	 * For example it could make sense to calculate the distance from the
 	 * drags start instead...
@@ -1705,13 +1773,12 @@ process_motion_notify(int x, int y, GdkM
 }
 
 /*
  * Timer used to recognize multiple clicks of the mouse button.
  */
-/*ARGSUSED0*/
     static gint
-motion_repeat_timer_cb(gpointer data)
+motion_repeat_timer_cb(gpointer data UNUSED)
 {
     int		    x;
     int		    y;
     GdkModifierType state;
 
@@ -1747,13 +1814,14 @@ motion_repeat_timer_cb(gpointer data)
     /* Don't happen again.  We will get reinstalled in the synthetic event
      * if needed -- thus repeating should still work. */
     return FALSE;
 }
 
-/*ARGSUSED2*/
     static gint
-motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
+motion_notify_event(GtkWidget *widget,
+		    GdkEventMotion *event,
+		    gpointer data UNUSED)
 {
     if (event->is_hint)
     {
 	int		x;
 	int		y;
@@ -1775,13 +1843,14 @@ motion_notify_event(GtkWidget *widget, G
 /*
  * Mouse button handling.  Note please that we are capturing multiple click's
  * by our own timeout mechanism instead of the one provided by GTK+ itself.
  * This is due to the way the generic VIM code is recognizing multiple clicks.
  */
-/*ARGSUSED2*/
     static gint
-button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
+button_press_event(GtkWidget *widget,
+		   GdkEventButton *event,
+		   gpointer data UNUSED)
 {
     int button;
     int repeated_click = FALSE;
     int x, y;
     int_u vim_modifiers;
@@ -1853,13 +1922,14 @@ button_press_event(GtkWidget *widget, Gd
 #ifdef HAVE_GTK2
 /*
  * GTK+ 2 doesn't handle mouse buttons 4, 5, 6 and 7 the same way as GTK+ 1.
  * Instead, it abstracts scrolling via the new GdkEventScroll.
  */
-/*ARGSUSED2*/
     static gboolean
-scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data)
+scroll_event(GtkWidget *widget,
+	     GdkEventScroll *event,
+	     gpointer data UNUSED)
 {
     int	    button;
     int_u   vim_modifiers;
 
     if (gtk_socket_id != 0 && !GTK_WIDGET_HAS_FOCUS(widget))
@@ -1894,13 +1964,14 @@ scroll_event(GtkWidget *widget, GdkEvent
     return TRUE;
 }
 #endif /* HAVE_GTK2 */
 
 
-/*ARGSUSED*/
     static gint
-button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
+button_release_event(GtkWidget *widget UNUSED,
+		     GdkEventButton *event,
+		     gpointer data UNUSED)
 {
     int x, y;
     int_u vim_modifiers;
 
     /* Remove any motion "machine gun" timers used for automatic further
@@ -2098,20 +2169,19 @@ drag_handle_text(GdkDragContext	    *con
 }
 
 /*
  * DND receiver.
  */
-/*ARGSUSED2*/
     static void
 drag_data_received_cb(GtkWidget		*widget,
 		      GdkDragContext	*context,
 		      gint		x,
 		      gint		y,
 		      GtkSelectionData	*data,
 		      guint		info,
 		      guint		time_,
-		      gpointer		user_data)
+		      gpointer		user_data UNUSED)
 {
     GdkModifierType state;
 
     /* Guard against trash */
     if (data->data == NULL
@@ -2141,11 +2211,10 @@ drag_data_received_cb(GtkWidget		*widget
 /*
  * GnomeClient interact callback.  Check for unsaved buffers that cannot
  * be abandoned and pop up a dialog asking the user for confirmation if
  * necessary.
  */
-/*ARGSUSED0*/
     static void
 sm_client_check_changed_any(GnomeClient	    *client,
 			    gint	    key,
 			    GnomeDialogType type,
 			    gpointer	    data)
@@ -2249,11 +2318,10 @@ write_session_file(char_u *filename)
 /*
  * "save_yourself" signal handler.  Initiate an interaction to ask the user
  * for confirmation if necessary.  Save the current editing session and tell
  * the session manager how to restart Vim.
  */
-/*ARGSUSED1*/
     static gboolean
 sm_client_save_yourself(GnomeClient	    *client,
 			gint		    phase,
 			GnomeSaveStyle	    save_style,
 			gboolean	    shutdown,
@@ -2337,11 +2405,10 @@ sm_client_save_yourself(GnomeClient
 /*
  * Called when the session manager wants us to die.  There isn't much to save
  * here since "save_yourself" has been emitted before (unless serious trouble
  * is happening).
  */
-/*ARGSUSED0*/
     static void
 sm_client_die(GnomeClient *client, gpointer data)
 {
     /* Don't write messages to the GUI anymore */
     full_screen = FALSE;
@@ -2377,14 +2444,13 @@ setup_save_yourself(void)
 
 # ifdef USE_XSMP
 /*
  * GTK tells us that XSMP needs attention
  */
-/*ARGSUSED*/
     static gboolean
 local_xsmp_handle_requests(source, condition, data)
-    GIOChannel		*source;
+    GIOChannel		*source UNUSED;
     GIOCondition	condition;
     gpointer		data;
 {
     if (condition == G_IO_IN)
     {
@@ -2478,20 +2544,22 @@ setup_save_yourself(void)
  *
  * The GNOME session support is much cooler anyway.  Unlike this ugly
  * WM_SAVE_YOURSELF hack it actually stores the session...  And yes,
  * it should work with KDE as well.
  */
-/*ARGSUSED1*/
     static GdkFilterReturn
-global_event_filter(GdkXEvent *xev, GdkEvent *event, gpointer data)
+global_event_filter(GdkXEvent *xev,
+		    GdkEvent *event UNUSED,
+		    gpointer data UNUSED)
 {
     XEvent *xevent = (XEvent *)xev;
 
     if (xevent != NULL
 	    && xevent->type == ClientMessage
 	    && xevent->xclient.message_type == GET_X_ATOM(wm_protocols_atom)
-	    && xevent->xclient.data.l[0] == GET_X_ATOM(save_yourself_atom))
+	    && (long_u)xevent->xclient.data.l[0]
+					    == GET_X_ATOM(save_yourself_atom))
     {
 	out_flush();
 	ml_sync_all(FALSE, FALSE); /* preserve all swap files */
 	/*
 	 * Set the window's WM_COMMAND property, to let the window manager
@@ -2510,11 +2578,10 @@ global_event_filter(GdkXEvent *xev, GdkE
 # else /* !HAVE_GTK2 */
 
 /*
  * GDK handler for X ClientMessage events.
  */
-/*ARGSUSED2*/
     static GdkFilterReturn
 gdk_wm_protocols_filter(GdkXEvent *xev, GdkEvent *event, gpointer data)
 {
     /* From example in gdkevents.c/gdk_wm_protocols_filter */
     XEvent *xevent = (XEvent *)xev;
@@ -2556,13 +2623,12 @@ gdk_wm_protocols_filter(GdkXEvent *xev,
 
 
 /*
  * Setup the window icon & xcmdsrv comm after the main window has been realized.
  */
-/*ARGSUSED*/
     static void
-mainwin_realize(GtkWidget *widget, gpointer data)
+mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED)
 {
 /* If you get an error message here, you still need to unpack the runtime
  * archive! */
 #ifdef magick
 # undef magick
@@ -2710,15 +2776,14 @@ create_blank_pointer(void)
 
     return cursor;
 }
 
 #ifdef HAVE_GTK_MULTIHEAD
-/*ARGSUSED1*/
     static void
 mainwin_screen_changed_cb(GtkWidget  *widget,
-			  GdkScreen  *previous_screen,
-			  gpointer   data)
+			  GdkScreen  *previous_screen UNUSED,
+			  gpointer   data UNUSED)
 {
     if (!gtk_widget_has_screen(widget))
 	return;
 
     /*
@@ -2755,13 +2820,12 @@ mainwin_screen_changed_cb(GtkWidget  *wi
  * dummy blank cursor.
  *
  * Don't try to set any VIM scrollbar sizes anywhere here. I'm relying on the
  * fact that the main VIM engine doesn't take them into account anywhere.
  */
-/*ARGSUSED1*/
     static void
-drawarea_realize_cb(GtkWidget *widget, gpointer data)
+drawarea_realize_cb(GtkWidget *widget, gpointer data UNUSED)
 {
     GtkWidget *sbar;
 
 #ifdef FEAT_XIM
     xim_init();
@@ -2787,13 +2851,12 @@ drawarea_realize_cb(GtkWidget *widget, g
 }
 
 /*
  * Properly clean up on shutdown.
  */
-/*ARGSUSED0*/
     static void
-drawarea_unrealize_cb(GtkWidget *widget, gpointer data)
+drawarea_unrealize_cb(GtkWidget *widget UNUSED, gpointer data UNUSED)
 {
     /* Don't write messages to the GUI anymore */
     full_screen = FALSE;
 
 #ifdef FEAT_XIM
@@ -2825,26 +2888,26 @@ drawarea_unrealize_cb(GtkWidget *widget,
     gdk_cursor_destroy(gui.blank_pointer);
     gui.blank_pointer = NULL;
 #endif
 }
 
-/*ARGSUSED0*/
     static void
-drawarea_style_set_cb(GtkWidget	*widget,
-		      GtkStyle	*previous_style,
-		      gpointer	data)
+drawarea_style_set_cb(GtkWidget	*widget UNUSED,
+		      GtkStyle	*previous_style UNUSED,
+		      gpointer	data UNUSED)
 {
     gui_mch_new_colors();
 }
 
 /*
  * Callback routine for the "delete_event" signal on the toplevel window.
  * Tries to vim gracefully, or refuses to exit with changed buffers.
  */
-/*ARGSUSED*/
     static gint
-delete_event_cb(GtkWidget *widget, GdkEventAny *event, gpointer data)
+delete_event_cb(GtkWidget *widget UNUSED,
+		GdkEventAny *event UNUSED,
+		gpointer data UNUSED)
 {
     gui_shell_closed();
     return TRUE;
 }
 
@@ -2962,11 +3025,11 @@ update_window_manager_hints(int force_wi
     int min_width;
     int min_height;
 
     /* At start-up, don't try to set the hints until the initial
      * values have been used (those that dictate our initial size)
-     * Let forced (i.e., correct) values thruogh always.
+     * Let forced (i.e., correct) values through always.
      */
     if (!(force_width && force_height)  &&  init_window_hints_state > 0)
     {
 	/* Don't do it! */
 	init_window_hints_state = 2;
@@ -3140,13 +3203,12 @@ static GtkTooltips *tabline_tooltip;
 static int clicked_page;	    /* page clicked in tab line */
 
 /*
  * Handle selecting an item in the tab line popup menu.
  */
-/*ARGSUSED*/
     static void
-tabline_menu_handler(GtkMenuItem *item, gpointer user_data)
+tabline_menu_handler(GtkMenuItem *item UNUSED, gpointer user_data)
 {
     /* Add the string cmd into input buffer */
     send_tabline_menu_event(clicked_page, (int)(long)user_data);
 
     if (gtk_main_level() > 0)
@@ -3242,17 +3304,16 @@ on_tabline_menu(GtkWidget *widget, GdkEv
 }
 
 /*
  * Handle selecting one of the tabs.
  */
-/*ARGSUSED*/
     static void
 on_select_tab(
-	GtkNotebook	*notebook,
-	GtkNotebookPage *page,
+	GtkNotebook	*notebook UNUSED,
+	GtkNotebookPage *page UNUSED,
 	gint		idx,
-	gpointer	data)
+	gpointer	data UNUSED)
 {
     if (!ignore_tabline_evt)
     {
 	if (send_tabline_event(idx + 1) && gtk_main_level() > 0)
 	    gtk_main_quit();
@@ -3458,10 +3519,11 @@ gui_mch_init(void)
     /* LINTED: avoid warning: conversion to 'unsigned long' */
     gui.spcolor = g_new0(GdkColor, 1);
 
     /* Initialise atoms */
 #ifdef FEAT_MBYTE
+    html_atom = gdk_atom_intern("text/html", FALSE);
     utf8_string_atom = gdk_atom_intern("UTF8_STRING", FALSE);
 #endif
 #ifndef HAVE_GTK2
     compound_text_atom = gdk_atom_intern("COMPOUND_TEXT", FALSE);
     text_atom = gdk_atom_intern("TEXT", FALSE);
@@ -3782,11 +3844,11 @@ gui_mch_init(void)
     wm_protocols_atom = gdk_atom_intern("WM_PROTOCOLS", FALSE);
     save_yourself_atom = gdk_atom_intern("WM_SAVE_YOURSELF", FALSE);
 #endif
 
     if (gtk_socket_id != 0)
-	/* make sure keybord input can go to the drawarea */
+	/* make sure keyboard input can go to the drawarea */
 	GTK_WIDGET_SET_FLAGS(gui.drawarea, GTK_CAN_FOCUS);
 
     /*
      * Set clipboard specific atoms
      */
@@ -3920,14 +3982,14 @@ gui_mch_new_colors(void)
 }
 
 /*
  * This signal informs us about the need to rearrange our sub-widgets.
  */
-/*ARGSUSED*/
     static gint
-form_configure_event(GtkWidget *widget, GdkEventConfigure *event,
-		     gpointer data)
+form_configure_event(GtkWidget *widget UNUSED,
+		     GdkEventConfigure *event,
+		     gpointer data UNUSED)
 {
     int usable_height = event->height;
 
     /* When in a GtkPlug, we can't guarantee valid heights (as a round
      * no. of char-heights), so we have to manually sanitise them.
@@ -3946,13 +4008,12 @@ form_configure_event(GtkWidget *widget,
 /*
  * Function called when window already closed.
  * We can't do much more here than to trying to preserve what had been done,
  * since the window is already inevitably going away.
  */
-/*ARGSUSED0*/
     static void
-mainwin_destroy_cb(GtkObject *object, gpointer data)
+mainwin_destroy_cb(GtkObject *object UNUSED, gpointer data UNUSED)
 {
     /* Don't write messages to the GUI anymore */
     full_screen = FALSE;
 
     gui.mainwin  = NULL;
@@ -3978,13 +4039,12 @@ mainwin_destroy_cb(GtkObject *object, gp
  * Thus set hints at start-up to ensure correct init. size, then a
  * second after the final attempt to reset the real minimum hinst (done by
  * scrollbar init.), actually do the standard hinst and stop the timer.
  * We'll not let the default hints be set while this timer's active.
  */
-/*ARGSUSED*/
     static gboolean
-check_startup_plug_hints(gpointer data)
+check_startup_plug_hints(gpointer data UNUSED)
 {
     if (init_window_hints_state == 1)
     {
 	/* Safe to use normal hints now */
 	init_window_hints_state = 0;
@@ -4004,10 +4064,12 @@ check_startup_plug_hints(gpointer data)
     int
 gui_mch_open(void)
 {
     guicolor_T fg_pixel = INVALCOLOR;
     guicolor_T bg_pixel = INVALCOLOR;
+    guint		pixel_width;
+    guint		pixel_height;
 
 #ifdef HAVE_GTK2
     /*
      * Allow setting a window role on the command line, or invent one
      * if none was specified.  This is mainly useful for GNOME session
@@ -4044,20 +4106,18 @@ gui_mch_open(void)
     {
 	int		mask;
 	unsigned int	w, h;
 	int		x = 0;
 	int		y = 0;
-	guint		pixel_width;
-	guint		pixel_height;
 
 	mask = XParseGeometry((char *)gui.geom, &x, &y, &w, &h);
 
 	if (mask & WidthValue)
 	    Columns = w;
 	if (mask & HeightValue)
 	{
-	    if (p_window > h - 1 || !option_was_set((char_u *)"window"))
+	    if (p_window > (long)h - 1 || !option_was_set((char_u *)"window"))
 		p_window = h - 1;
 	    Rows = h;
 	}
 
 	pixel_width = (guint)(gui_get_base_width() + Columns * gui.char_width);
@@ -4068,18 +4128,18 @@ gui_mch_open(void)
 	pixel_height += get_menu_tool_height();
 #endif
 
 	if (mask & (XValue | YValue))
 	{
-	    int w, h;
-	    gui_mch_get_screen_dimensions(&w, &h);
-	    h += p_ghr + get_menu_tool_height();
-	    w += get_menu_tool_width();
+	    int ww, hh;
+	    gui_mch_get_screen_dimensions(&ww, &hh);
+	    hh += p_ghr + get_menu_tool_height();
+	    ww += get_menu_tool_width();
 	    if (mask & XNegative)
-		x += w - pixel_width;
+		x += ww - pixel_width;
 	    if (mask & YNegative)
-		y += h - pixel_height;
+		y += hh - pixel_height;
 #ifdef HAVE_GTK2
 	    gtk_window_move(GTK_WINDOW(gui.mainwin), x, y);
 #else
 	    gtk_widget_set_uposition(gui.mainwin, x, y);
 #endif
@@ -4098,13 +4158,20 @@ gui_mch_open(void)
 	    init_window_hints_state = 1;
 	    g_timeout_add(1000, check_startup_plug_hints, NULL);
 	}
     }
 
-    gtk_form_set_size(GTK_FORM(gui.formwin),
-	    (guint)(gui_get_base_width() + Columns * gui.char_width),
-	    (guint)(gui_get_base_height() + Rows * gui.char_height));
+    pixel_width = (guint)(gui_get_base_width() + Columns * gui.char_width);
+    pixel_height = (guint)(gui_get_base_height() + Rows * gui.char_height);
+#ifdef HAVE_GTK2
+    /* For GTK2 changing the size of the form widget doesn't cause window
+     * resizing. */
+    if (gtk_socket_id == 0)
+	gtk_window_resize(GTK_WINDOW(gui.mainwin), pixel_width, pixel_height);
+#else
+    gtk_form_set_size(GTK_FORM(gui.formwin), pixel_width, pixel_height);
+#endif
     update_window_manager_hints(0, 0);
 
     if (foreground_argument != NULL)
 	fg_pixel = gui_get_color((char_u *)foreground_argument);
     if (fg_pixel == INVALCOLOR)
@@ -4227,13 +4294,12 @@ gui_mch_open(void)
 
     return OK;
 }
 
 
-/*ARGSUSED0*/
     void
-gui_mch_exit(int rc)
+gui_mch_exit(int rc UNUSED)
 {
     if (gui.mainwin != NULL)
 	gtk_widget_destroy(gui.mainwin);
 
     if (gtk_main_level() > 0)
@@ -4284,11 +4350,10 @@ static int resize_idle_installed = FALSE
  * DISABLED: When doing ":set lines+=1" this function would first invoke
  * gui_resize_shell() with the old size, then the normal callback would
  * report the new size through form_configure_event().  That caused the window
  * layout to be messed up.
  */
-/*ARGSUSED0*/
     static gboolean
 force_shell_resize_idle(gpointer data)
 {
     if (gui.mainwin != NULL
 	    && GTK_WIDGET_REALIZED(gui.mainwin)
@@ -4309,19 +4374,41 @@ force_shell_resize_idle(gpointer data)
     return FALSE; /* don't call me again */
 }
 #endif
 #endif /* HAVE_GTK2 */
 
+#if defined(HAVE_GTK2) || defined(PROTO)
+/*
+ * Return TRUE if the main window is maximized.
+ */
+    int
+gui_mch_maximized()
+{
+    return (gui.mainwin != NULL && gui.mainwin->window != NULL
+	    && (gdk_window_get_state(gui.mainwin->window)
+					       & GDK_WINDOW_STATE_MAXIMIZED));
+}
+
+/*
+ * Unmaximize the main window
+ */
+    void
+gui_mch_unmaximize()
+{
+    if (gui.mainwin != NULL)
+	gtk_window_unmaximize(GTK_WINDOW(gui.mainwin));
+}
+#endif
+
 /*
  * Set the windows size.
  */
-/*ARGSUSED2*/
     void
 gui_mch_set_shellsize(int width, int height,
-		      int min_width,  int min_height,
-		      int base_width, int base_height,
-		      int direction)
+		      int min_width UNUSED,  int min_height UNUSED,
+		      int base_width UNUSED, int base_height UNUSED,
+		      int direction UNUSED)
 {
 #ifndef HAVE_GTK2
     /* Hack: When the form already is at the desired size, the window might
      * have been resized with the mouse.  Force a resize by setting a
      * different size first. */
@@ -4411,13 +4498,12 @@ gui_mch_get_screen_dimensions(int *scree
     *screen_w -= get_menu_tool_width();
     *screen_h -= get_menu_tool_height();
 }
 
 #if defined(FEAT_TITLE) || defined(PROTO)
-/*ARGSUSED*/
     void
-gui_mch_settitle(char_u *title, char_u *icon)
+gui_mch_settitle(char_u *title, char_u *icon UNUSED)
 {
 # ifdef HAVE_GTK2
     if (title != NULL && output_conv.vc_type != CONV_NONE)
 	title = string_convert(&output_conv, title, NULL);
 # endif
@@ -4491,11 +4577,10 @@ gui_mch_show_toolbar(int showit)
 #ifndef HAVE_GTK2
 /*
  * Get a font structure for highlighting.
  * "cbdata" is a pointer to the global gui structure.
  */
-/*ARGSUSED*/
     static void
 font_sel_ok(GtkWidget *wgt, gpointer cbdata)
 {
     gui_T *vw = (gui_T *)cbdata;
     GtkFontSelectionDialog *fs = (GtkFontSelectionDialog *)vw->fontdlg;
@@ -4507,22 +4592,20 @@ font_sel_ok(GtkWidget *wgt, gpointer cbd
     gtk_widget_hide(vw->fontdlg);
     if (gtk_main_level() > 0)
 	gtk_main_quit();
 }
 
-/*ARGSUSED*/
     static void
 font_sel_cancel(GtkWidget *wgt, gpointer cbdata)
 {
     gui_T *vw = (gui_T *)cbdata;
 
     gtk_widget_hide(vw->fontdlg);
     if (gtk_main_level() > 0)
 	gtk_main_quit();
 }
 
-/*ARGSUSED*/
     static void
 font_sel_destroy(GtkWidget *wgt, gpointer cbdata)
 {
     gui_T *vw = (gui_T *)cbdata;
 
@@ -4618,11 +4701,10 @@ gui_mch_adjust_charheight(void)
 
 #if defined(FEAT_XFONTSET) || defined(PROTO)
 /*
  * Try to load the requested fontset.
  */
-/*ARGSUSED2*/
     GuiFontset
 gui_mch_get_fontset(char_u *name, int report_error, int fixed_width)
 {
     GdkFont *font;
 
@@ -4675,10 +4757,13 @@ gui_mch_font_dialog(char_u *oldval)
     }
 
     if (oldval != NULL && *oldval != NUL)
 	gtk_font_selection_dialog_set_font_name(
 		GTK_FONT_SELECTION_DIALOG(gui.fontdlg), (char *)oldval);
+    else
+	gtk_font_selection_dialog_set_font_name(
+		GTK_FONT_SELECTION_DIALOG(gui.fontdlg), DEFAULT_FONT);
 
     if (gui.fontname)
     {
 	g_free(gui.fontname);
 	gui.fontname = NULL;
@@ -4762,10 +4847,13 @@ gui_mch_font_dialog(char_u *oldval)
 		GTK_FONT_SELECTION_DIALOG(dialog), (const char *)oldname);
 
 	if (oldname != oldval)
 	    vim_free(oldname);
     }
+    else
+	gtk_font_selection_dialog_set_font_name(
+		GTK_FONT_SELECTION_DIALOG(dialog), DEFAULT_FONT);
 
     response = gtk_dialog_run(GTK_DIALOG(dialog));
 
     if (response == GTK_RESPONSE_OK)
     {
@@ -4861,11 +4949,11 @@ get_styled_font_variants(char_u * font_n
 
     styled_font[0] = &gui.bold_font;
     styled_font[1] = &gui.ital_font;
     styled_font[2] = &gui.boldital_font;
 
-    /* First free whatever was freviously there. */
+    /* First free whatever was previously there. */
     for (i = 0; i < 3; ++i)
 	if (*styled_font[i])
 	{
 	    gdk_font_unref(*styled_font[i]);
 	    *styled_font[i] = NULL;
@@ -5010,13 +5098,12 @@ ascii_glyph_table_init(void)
 
 /*
  * Initialize Vim to use the font or fontset with the given name.
  * Return FAIL if the font could not be loaded, OK otherwise.
  */
-/*ARGSUSED1*/
     int
-gui_mch_init_font(char_u *font_name, int fontset)
+gui_mch_init_font(char_u *font_name, int fontset UNUSED)
 {
 #ifdef HAVE_GTK2
     PangoFontDescription    *font_desc;
     PangoLayout		    *layout;
     int			    width;
@@ -5178,12 +5265,28 @@ gui_mch_init_font(char_u *font_name, int
 	gtk_widget_show(alignment);
     }
 # endif
 #endif /* !HAVE_GTK2 */
 
-    /* Preserve the logical dimensions of the screen. */
-    update_window_manager_hints(0, 0);
+#ifdef HAVE_GTK2
+    if (gui_mch_maximized())
+    {
+	int w, h;
+
+	/* Update lines and columns in accordance with the new font, keep the
+	 * window maximized. */
+	gtk_window_get_size(GTK_WINDOW(gui.mainwin), &w, &h);
+	w -= get_menu_tool_width();
+	h -= get_menu_tool_height();
+	gui_resize_shell(w, h);
+    }
+    else
+#endif
+    {
+	/* Preserve the logical dimensions of the screen. */
+	update_window_manager_hints(0, 0);
+    }
 
     return OK;
 }
 
 /*
@@ -5324,13 +5427,12 @@ gui_mch_get_font(char_u *name, int repor
 
 #if defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Return the name of font "font" in allocated memory.
  */
-/*ARGSUSED*/
     char_u *
-gui_mch_get_fontname(GuiFont font, char_u *name)
+gui_mch_get_fontname(GuiFont font, char_u *name UNUSED)
 {
 # ifdef HAVE_GTK2
     if (font != NOFONT)
     {
 	char	*pangoname = pango_font_description_to_string(font);
@@ -5730,11 +5832,11 @@ draw_glyph_string(int row, int col, int
     static void
 draw_under(int flags, int row, int col, int cells)
 {
     int			i;
     int			offset;
-    const static int	val[8] = {1, 0, 0, 0, 1, 2, 2, 2 };
+    static const int	val[8] = {1, 0, 0, 0, 1, 2, 2, 2 };
     int			y = FILL_Y(row + 1) - 1;
 
     /* Undercurl: draw curl at the bottom of the character cell. */
     if (flags & DRAW_UNDERC)
     {
@@ -6083,16 +6185,19 @@ gui_mch_draw_string(int row, int col, ch
 	while (p < s + len)
 	{
 # ifdef FEAT_MBYTE
 	    if (enc_utf8)
 	    {
-		c = utf_ptr2char(p);
+		int pcc[MAX_MCO];
+
+		/* TODO: use the composing characters */
+		c = utfc_ptr2char_len(p, pcc, len - (p - s));
 		if (c >= 0x10000)	/* show chars > 0xffff as ? */
 		    c = 0xbf;
 		buf[textlen].byte1 = c >> 8;
 		buf[textlen].byte2 = c;
-		p += utf_ptr2len(p);
+		p += utfc_ptr2len_len(p, len - (p - s));
 		width += utf_char2cells(c);
 	    }
 	    else
 # endif
 	    {
@@ -6112,12 +6217,12 @@ gui_mch_draw_string(int row, int col, ch
 	textlen = len;
 # ifdef FEAT_MBYTE
 	if (has_mbyte)
 	{
 	    width = 0;
-	    for (p = s; p < s + len; p += (*mb_ptr2len)(p))
-		width += (*mb_ptr2cells)(p);
+	    for (p = s; p < s + len; p += (*mb_ptr2len_len)(p, len - (p - s)))
+		width += (*mb_ptr2cells_len)(p, len - (p - s));
 	}
 	else
 # endif
 	    width = len;
     }
@@ -6400,11 +6505,10 @@ input_timer_cb(gpointer data)
 
 #ifdef FEAT_SNIFF
 /*
  * Callback function, used when data is available on the SNiFF connection.
  */
-/* ARGSUSED */
     static void
 sniff_request_cb(
     gpointer	data,
     gint	source_fd,
     GdkInputCondition condition)
@@ -6663,16 +6767,18 @@ gui_mch_insert_lines(int row, int num_li
     void
 clip_mch_request_selection(VimClipboard *cbd)
 {
     GdkAtom	target;
     unsigned	i;
-    int		nbytes;
-    char_u	*buffer;
     time_t	start;
 
     for (i = 0; i < N_SELECTION_TARGETS; ++i)
     {
+#ifdef FEAT_MBYTE
+	if (!clip_html && selection_targets[i].info == TARGET_HTML)
+	    continue;
+#endif
 	received_selection = RS_NONE;
 	target = gdk_atom_intern(selection_targets[i].target, FALSE);
 
 	gtk_selection_convert(gui.drawarea,
 			      cbd->gtk_sel_atom, target,
@@ -6688,34 +6794,18 @@ clip_mch_request_selection(VimClipboard
 	if (received_selection != RS_FAIL)
 	    return;
     }
 
     /* Final fallback position - use the X CUT_BUFFER0 store */
-    nbytes = 0;
-    buffer = (char_u *)XFetchBuffer(GDK_WINDOW_XDISPLAY(gui.mainwin->window),
-				    &nbytes, 0);
-    if (nbytes > 0)
-    {
-	/* Got something */
-	clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
-	if (p_verbose > 0)
-	{
-	    verbose_enter();
-	    smsg((char_u *)_("Used CUT_BUFFER0 instead of empty selection"));
-	    verbose_leave();
-	}
-    }
-    if (buffer != NULL)
-	XFree(buffer);
+    yank_cut_buffer0(GDK_WINDOW_XDISPLAY(gui.mainwin->window), cbd);
 }
 
 /*
  * Disown the selection.
  */
-/*ARGSUSED*/
     void
-clip_mch_lose_selection(VimClipboard *cbd)
+clip_mch_lose_selection(VimClipboard *cbd UNUSED)
 {
     /* WEIRD: when using NULL to actually disown the selection, we lose the
      * selection the first time we own it. */
     /*
     gtk_selection_owner_set(NULL, cbd->gtk_sel_atom, (guint32)GDK_CURRENT_TIME);
@@ -6739,13 +6829,12 @@ clip_mch_own_selection(VimClipboard *cbd
 
 /*
  * Send the current selection to the clipboard.  Do nothing for X because we
  * will fill in the selection only when requested by another app.
  */
-/*ARGSUSED*/
     void
-clip_mch_set_selection(VimClipboard *cbd)
+clip_mch_set_selection(VimClipboard *cbd UNUSED)
 {
 }
 
 
 #if defined(FEAT_MENU) || defined(PROTO)
@@ -6948,11 +7037,11 @@ mch_set_mouse_shape(int shape)
 	    if (id >= GDK_LAST_CURSOR)
 		id = GDK_LEFT_PTR;
 	    else
 		id &= ~1;	/* they are always even (why?) */
 	}
-	else if (shape < sizeof(mshape_ids) / sizeof(int))
+	else if (shape < (int)(sizeof(mshape_ids) / sizeof(int)))
 	    id = mshape_ids[shape];
 	else
 	    return;
 # ifdef HAVE_GTK_MULTIHEAD
 	c = gdk_cursor_new_for_display(
--- vim72.orig/src/gui_mac.c
+++ vim72/src/gui_mac.c
@@ -4964,11 +4964,11 @@ gui_mch_add_menu_item(vimmenu_T *menu, i
 	int	    key = 0;
 	int	    modifiers = 0;
 	char_u	    *p_actext;
 
 	p_actext = menu->actext;
-	key = find_special_key(&p_actext, &modifiers, /*keycode=*/0);
+	key = find_special_key(&p_actext, &modifiers, FALSE, FALSE);
 	if (*p_actext != 0)
 	    key = 0; /* error: trailing text */
 	/* find_special_key() returns a keycode with as many of the
 	 * specified modifiers as appropriate already applied (e.g., for
 	 * "<D-C-x>" it returns Ctrl-X as the keycode and MOD_MASK_CMD
--- vim72.orig/src/gui_motif.c
+++ vim72/src/gui_motif.c
@@ -115,14 +115,13 @@ static void gui_motif_scroll_colors __AR
 
 /*
  * Call-back routines.
  */
 
-/* ARGSUSED */
     static void
 scroll_cb(w, client_data, call_data)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data, call_data;
 {
     scrollbar_T *sb;
     long	value;
     int		dragging;
@@ -134,28 +133,28 @@ scroll_cb(w, client_data, call_data)
 							      (int)XmCR_DRAG);
     gui_drag_scrollbar(sb, value, dragging);
 }
 
 #ifdef FEAT_GUI_TABLINE
-/*ARGSUSED*/
     static void
 tabline_cb(w, client_data, call_data)
-    Widget	w;
-    XtPointer	client_data, call_data;
+    Widget	w UNUSED;
+    XtPointer	client_data UNUSED;
+    XtPointer	call_data;
 {
     XmNotebookCallbackStruct *nptr;
 
     nptr = (XmNotebookCallbackStruct *)call_data;
     if (nptr->reason != (int)XmCR_NONE)
 	send_tabline_event(nptr->page_number);
 }
 
-/*ARGSUSED*/
     static void
 tabline_button_cb(w, client_data, call_data)
     Widget	w;
-    XtPointer	client_data, call_data;
+    XtPointer	client_data UNUSED;
+    XtPointer	call_data UNUSED;
 {
     int		cmd, tab_idx;
 
     XtVaGetValues(w, XmNuserData, &cmd, NULL);
     XtVaGetValues(tabLine_menu, XmNuserData, &tab_idx, NULL);
@@ -164,15 +163,14 @@ tabline_button_cb(w, client_data, call_d
 }
 
 /*
  * Tabline single mouse click timeout handler
  */
-/*ARGSUSED*/
     static void
 motif_tabline_timer_cb (timed_out, interval_id)
     XtPointer		timed_out;
-    XtIntervalId	*interval_id;
+    XtIntervalId	*interval_id UNUSED;
 {
     *((int *)timed_out) = TRUE;
 }
 
 /*
@@ -201,17 +199,16 @@ tabline_scroller_clicked(scroller_name,
 	}
     }
     return FALSE;
 }
 
-/*ARGSUSED*/
     static void
 tabline_menu_cb(w, closure, e, continue_dispatch)
     Widget	w;
-    XtPointer	closure;
+    XtPointer	closure UNUSED;
     XEvent	*e;
-    Boolean	*continue_dispatch;
+    Boolean	*continue_dispatch UNUSED;
 {
     Widget			tab_w;
     XButtonPressedEvent		*event;
     int				tab_idx = 0;
     WidgetList			children;
@@ -275,15 +272,14 @@ tabline_menu_cb(w, closure, e, continue_
     XtManageChildren(children, numChildren);
     XmMenuPosition(tabLine_menu, (XButtonPressedEvent *)e) ;
     XtManageChild(tabLine_menu);
 }
 
-/*ARGSUSED*/
     static void
 tabline_balloon_cb(beval, state)
     BalloonEval	*beval;
-    int		state;
+    int		state UNUSED;
 {
     int		nr;
     tabpage_T	*tp;
 
     if (beval->target == (Widget)0)
@@ -640,17 +636,16 @@ gui_x11_destroy_widgets()
 #ifdef FEAT_MENU
     menuBar = NULL;
 #endif
 }
 
-/*ARGSUSED*/
     void
 gui_mch_set_text_area_pos(x, y, w, h)
-    int	    x;
-    int	    y;
-    int	    w;
-    int	    h;
+    int	    x UNUSED;
+    int	    y UNUSED;
+    int	    w UNUSED;
+    int	    h UNUSED;
 {
 #ifdef FEAT_TOOLBAR
     /* Give keyboard focus to the textArea instead of the toolbar. */
     reset_focus();
 #endif
@@ -1259,11 +1254,11 @@ get_toolbar_pixmap(menu, fname)
     }
 
     if (menu->icon_builtin || gui_find_bitmap(menu->name, buf, "xpm") == FAIL)
     {
 	if (menu->iconidx >= 0 && menu->iconidx
-		   < (sizeof(built_in_pixmaps) / sizeof(built_in_pixmaps[0])))
+	       < (int)(sizeof(built_in_pixmaps) / sizeof(built_in_pixmaps[0])))
 	    xpm = built_in_pixmaps[menu->iconidx];
 	else
 	    xpm = tb_blank_xpm;
     }
 
@@ -1714,14 +1709,13 @@ gui_mch_destroy_menu(menu)
 	}
 #endif
     }
 }
 
-/* ARGSUSED */
     void
 gui_mch_show_popupmenu(menu)
-    vimmenu_T *menu;
+    vimmenu_T *menu UNUSED;
 {
 #ifdef MOTIF_POPUP
     XmMenuPosition(menu->submenu_id, gui_x11_get_last_mouse_event());
     XtManageChild(menu->submenu_id);
 #endif
@@ -2044,13 +2038,12 @@ do_mnemonic(Widget w, unsigned int keyco
 }
 
 /*
  * Callback routine for dialog mnemonic processing.
  */
-/*ARGSUSED*/
     static void
-mnemonic_event(Widget w, XtPointer call_data, XKeyEvent *event)
+mnemonic_event(Widget w, XtPointer call_data UNUSED, XKeyEvent *event)
 {
     do_mnemonic(w, event->keycode);
 }
 
 
@@ -2285,17 +2278,16 @@ set_predefined_fontlist(parent, name)
 
 /*
  * Put up a file requester.
  * Returns the selected name in allocated memory, or NULL for Cancel.
  */
-/* ARGSUSED */
     char_u *
 gui_mch_browse(saving, title, dflt, ext, initdir, filter)
-    int		saving;		/* select file to write */
+    int		saving UNUSED;	/* select file to write */
     char_u	*title;		/* title for the window */
     char_u	*dflt;		/* default name */
-    char_u	*ext;		/* not used (extension added) */
+    char_u	*ext UNUSED;	/* not used (extension added) */
     char_u	*initdir;	/* initial directory, NULL for current dir */
     char_u	*filter;	/* file name filter */
 {
     char_u	dirbuf[MAXPATHL];
     char_u	dfltbuf[MAXPATHL];
@@ -2411,16 +2403,15 @@ gui_mch_browse(saving, title, dflt, ext,
  */
 
 /*
  * Process callback from Dialog cancel actions.
  */
-/* ARGSUSED */
     static void
 DialogCancelCB(w, client_data, call_data)
-    Widget	w;		/*  widget id		*/
-    XtPointer	client_data;	/*  data from application   */
-    XtPointer	call_data;	/*  data from widget class  */
+    Widget	w UNUSED;		/*  widget id		*/
+    XtPointer	client_data UNUSED;	/*  data from application   */
+    XtPointer	call_data UNUSED;	/*  data from widget class  */
 {
     if (browse_fname != NULL)
     {
 	XtFree(browse_fname);
 	browse_fname = NULL;
@@ -2429,16 +2420,15 @@ DialogCancelCB(w, client_data, call_data
 }
 
 /*
  * Process callback from Dialog actions.
  */
-/* ARGSUSED */
     static void
 DialogAcceptCB(w, client_data, call_data)
-    Widget	w;		/*  widget id		*/
-    XtPointer	client_data;	/*  data from application   */
-    XtPointer	call_data;	/*  data from widget class  */
+    Widget	w UNUSED;		/*  widget id		*/
+    XtPointer	client_data UNUSED;	/*  data from application   */
+    XtPointer	call_data;		/*  data from widget class  */
 {
     XmFileSelectionBoxCallbackStruct *fcb;
 
     if (browse_fname != NULL)
     {
@@ -2465,17 +2455,16 @@ static void butproc __ARGS((Widget w, Xt
 
 /*
  * Callback function for the textfield.  When CR is hit this works like
  * hitting the "OK" button, ESC like "Cancel".
  */
-/* ARGSUSED */
     static void
 keyhit_callback(w, client_data, event, cont)
     Widget		w;
-    XtPointer		client_data;
+    XtPointer		client_data UNUSED;
     XEvent		*event;
-    Boolean		*cont;
+    Boolean		*cont UNUSED;
 {
     char	buf[2];
     KeySym	key_sym;
 
     if (XLookupString(&(event->xkey), buf, 2, &key_sym, NULL) == 1)
@@ -2488,16 +2477,15 @@ keyhit_callback(w, client_data, event, c
     if ((key_sym == XK_Left || key_sym == XK_Right)
 	    && !(event->xkey.state & ShiftMask))
 	XmTextFieldClearSelection(w, XtLastTimestampProcessed(gui.dpy));
 }
 
-/* ARGSUSED */
     static void
 butproc(w, client_data, call_data)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data;
-    XtPointer	call_data;
+    XtPointer	call_data UNUSED;
 {
     dialogStatus = (int)(long)client_data + 1;
 }
 
 #ifdef HAVE_XPM
@@ -2565,14 +2553,13 @@ create_pixmap_label(parent, name, data,
 
     return label;
 }
 #endif
 
-/* ARGSUSED */
     int
 gui_mch_dialog(type, title, message, button_names, dfltbutton, textfield)
-    int		type;
+    int		type UNUSED;
     char_u	*title;
     char_u	*message;
     char_u	*button_names;
     int		dfltbutton;
     char_u	*textfield;		/* buffer of size IOSIZE */
@@ -3195,11 +3182,11 @@ gui_mch_compute_toolbar_height()
 		XmNshadowThickness, &tst,
 		XmNmarginHeight, &tmh,
 		XmNchildren, &children,
 		XmNnumChildren, &numChildren, NULL);
 	borders += tst + tmh;
-	for (i = 0; i < numChildren; i++)
+	for (i = 0; i < (int)numChildren; i++)
 	{
 	    whgt = 0;
 	    XtVaGetValues(children[i], XmNheight, &whgt, NULL);
 	    if (height < whgt)
 		height = whgt;
@@ -3235,34 +3222,32 @@ motif_get_toolbar_colors(bgp, fgp, bsp,
 /*
  * The next toolbar enter/leave callbacks should really do balloon help.  But
  * I have to use footer help for backwards compatability.  Hopefully both will
  * get implemented and the user will have a choice.
  */
-/*ARGSUSED*/
     static void
 toolbarbutton_enter_cb(w, client_data, event, cont)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data;
-    XEvent	*event;
-    Boolean	*cont;
+    XEvent	*event UNUSED;
+    Boolean	*cont UNUSED;
 {
     vimmenu_T	*menu = (vimmenu_T *) client_data;
 
     if (menu->strings[MENU_INDEX_TIP] != NULL)
     {
 	if (vim_strchr(p_go, GO_FOOTER) != NULL)
 	    gui_mch_set_footer(menu->strings[MENU_INDEX_TIP]);
     }
 }
 
-/*ARGSUSED*/
     static void
 toolbarbutton_leave_cb(w, client_data, event, cont)
-    Widget	w;
-    XtPointer	client_data;
-    XEvent	*event;
-    Boolean	*cont;
+    Widget	w UNUSED;
+    XtPointer	client_data UNUSED;
+    XEvent	*event UNUSED;
+    Boolean	*cont UNUSED;
 {
     gui_mch_set_footer((char_u *) "");
 }
 # endif
 #endif
@@ -3490,14 +3475,13 @@ gui_motif_scroll_colors(id)
 }
 
 /*
  * Set the fontlist for Widget "id" to use gui.menu_fontset or gui.menu_font.
  */
-/*ARGSUSED*/
     void
 gui_motif_menu_fontlist(id)
-    Widget  id;
+    Widget  id UNUSED;
 {
 #ifdef FEAT_MENU
 #ifdef FONTSET_ALWAYS
     if (gui.menu_fontset != NOFONTSET)
     {
@@ -3564,63 +3548,59 @@ typedef struct _SharedFindReplace
     Widget undo;	/* 'Undo' action button */
 
     Widget cancel;
 } SharedFindReplace;
 
-static SharedFindReplace find_widgets = { NULL };
-static SharedFindReplace repl_widgets = { NULL };
+static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+static SharedFindReplace repl_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
 
 static void find_replace_destroy_callback __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
 static void find_replace_dismiss_callback __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
 static void entry_activate_callback __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
 static void find_replace_callback __ARGS((Widget w, XtPointer client_data, XtPointer call_data));
 static void find_replace_keypress __ARGS((Widget w, SharedFindReplace * frdp, XKeyEvent * event));
 static void find_replace_dialog_create __ARGS((char_u *entry_text, int do_replace));
 
-/*ARGSUSED*/
     static void
 find_replace_destroy_callback(w, client_data, call_data)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data;
-    XtPointer	call_data;
+    XtPointer	call_data UNUSED;
 {
     SharedFindReplace *cd = (SharedFindReplace *)client_data;
 
     if (cd != NULL)
        /* suppress_dialog_mnemonics(cd->dialog); */
 	cd->dialog = (Widget)0;
 }
 
-/*ARGSUSED*/
     static void
 find_replace_dismiss_callback(w, client_data, call_data)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data;
-    XtPointer	call_data;
+    XtPointer	call_data UNUSED;
 {
     SharedFindReplace *cd = (SharedFindReplace *)client_data;
 
     if (cd != NULL)
 	XtUnmanageChild(cd->dialog);
 }
 
-/*ARGSUSED*/
     static void
 entry_activate_callback(w, client_data, call_data)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data;
-    XtPointer	call_data;
+    XtPointer	call_data UNUSED;
 {
     XmProcessTraversal((Widget)client_data, XmTRAVERSE_CURRENT);
 }
 
-/*ARGSUSED*/
     static void
 find_replace_callback(w, client_data, call_data)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	client_data;
-    XtPointer	call_data;
+    XtPointer	call_data UNUSED;
 {
     long_u	flags = (long_u)client_data;
     char	*find_text, *repl_text;
     Boolean	direction_down = TRUE;
     Boolean	wword;
@@ -3666,14 +3646,13 @@ find_replace_callback(w, client_data, ca
 	XtFree(find_text);
     if (repl_text != NULL)
 	XtFree(repl_text);
 }
 
-/*ARGSUSED*/
     static void
 find_replace_keypress(w, frdp, event)
-    Widget		w;
+    Widget		w UNUSED;
     SharedFindReplace	*frdp;
     XKeyEvent		*event;
 {
     KeySym keysym;
 
--- vim72.orig/src/gui_photon.c
+++ vim72/src/gui_photon.c
@@ -836,11 +836,16 @@ gui_ph_handle_window_open(
 
 /* TODO: Set a clipping rect? */
     static void
 gui_ph_draw_start( void )
 {
+    PhGC_t *gc;
+
+    gc = PgGetGC();
     PgSetRegion( PtWidgetRid( PtFindDisjoint( gui.vimTextArea ) ) );
+    PgClearClippingsCx( gc );
+    PgClearTranslationCx( gc );
 
     PtWidgetOffset( gui.vimTextArea, &gui_ph_raw_offset );
     PhTranslatePoint( &gui_ph_raw_offset, PtWidgetPos( gui.vimTextArea, NULL ) );
 
     PgSetTranslation( &gui_ph_raw_offset, Pg_RELATIVE );
@@ -2968,11 +2973,11 @@ gui_mch_init_font(char_u *vim_font_name,
     PhRect_t extent;
 
     if( vim_font_name == NULL )
     {
 	/* Default font */
-	vim_font_name = "PC Term";
+	vim_font_name = "PC Terminal";
     }
 
     if( STRCMP( vim_font_name, "*" ) == 0 )
     {
 	font_tag = PtFontSelection( gui.vimWindow, NULL, NULL,
--- vim72.orig/src/gui_riscos.c
+++ vim72/src/gui_riscos.c
@@ -693,11 +693,11 @@ gui_mch_set_winpos(int x, int y)
 
     void
 gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction)
     int width;		/* In OS units */
     int height;
-    int min_width;	/* Smallest permissable window size (ignored) */
+    int min_width;	/* Smallest permissible window size (ignored) */
     int min_height;
     int base_width;	/* Space for scroll bars, etc */
     int base_height;
     int direction;
 {
@@ -861,11 +861,11 @@ zap_load_file(name, style)
 	return NULL;	/* Unable to load file */
 
     if (strncmp(file, "ZapFont\015", 8) == 0)
 	return file;	/* Loaded OK! */
 
-    free(file);
+    vim_free(file);
     return NULL;	/* Not a valid font file */
 }
 
 /* Load and convert the named font.
  * If name is NULL or a null string then convert the system font.
--- vim72.orig/src/gui_w32.c
+++ vim72/src/gui_w32.c
@@ -210,34 +210,34 @@ typedef struct _DllVersionInfo
     DWORD dwMinorVersion;
     DWORD dwBuildNumber;
     DWORD dwPlatformID;
 } DLLVERSIONINFO;
 
+#include <poppack.h>
+
 typedef struct tagTOOLINFOA_NEW
 {
 	UINT cbSize;
 	UINT uFlags;
 	HWND hwnd;
-	UINT uId;
+	UINT_PTR uId;
 	RECT rect;
 	HINSTANCE hinst;
 	LPSTR lpszText;
 	LPARAM lParam;
 } TOOLINFO_NEW;
 
 typedef struct tagNMTTDISPINFO_NEW
 {
     NMHDR      hdr;
-    LPTSTR     lpszText;
+    LPSTR      lpszText;
     char       szText[80];
     HINSTANCE  hinst;
     UINT       uFlags;
     LPARAM     lParam;
 } NMTTDISPINFO_NEW;
 
-#include <poppack.h>
-
 typedef HRESULT (WINAPI* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
 #ifndef TTM_SETMAXTIPWIDTH
 # define TTM_SETMAXTIPWIDTH	(WM_USER+24)
 #endif
 
@@ -990,11 +990,11 @@ _WndProc(
 			    /* Set the maximum width, this also enables using
 			     * \n for line break. */
 			    SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
 								      0, 500);
 
-			    tt_text = enc_to_ucs2(str, NULL);
+			    tt_text = enc_to_utf16(str, NULL);
 			    lpdi->lpszText = tt_text;
 			    /* can't show tooltip if failed */
 			}
 			else
 # endif
@@ -1327,10 +1327,11 @@ gui_mch_init(void)
     const char szVimWndClass[] = VIM_CLASS;
     const char szTextAreaClass[] = "VimTextArea";
     WNDCLASS wndclass;
 #ifdef FEAT_MBYTE
     const WCHAR szVimWndClassW[] = VIM_CLASSW;
+    const WCHAR szTextAreaClassW[] = L"VimTextArea";
     WNDCLASSW wndclassw;
 #endif
 #ifdef GLOBAL_IME
     ATOM	atom;
 #endif
@@ -1477,10 +1478,32 @@ gui_mch_init(void)
 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
     dyn_imm_load();
 #endif
 
     /* Create the text area window */
+#ifdef FEAT_MBYTE
+    if (wide_WindowProc)
+    {
+	if (GetClassInfoW(s_hinst, szTextAreaClassW, &wndclassw) == 0)
+	{
+	    wndclassw.style = CS_OWNDC;
+	    wndclassw.lpfnWndProc = _TextAreaWndProc;
+	    wndclassw.cbClsExtra = 0;
+	    wndclassw.cbWndExtra = 0;
+	    wndclassw.hInstance = s_hinst;
+	    wndclassw.hIcon = NULL;
+	    wndclassw.hCursor = LoadCursor(NULL, IDC_ARROW);
+	    wndclassw.hbrBackground = NULL;
+	    wndclassw.lpszMenuName = NULL;
+	    wndclassw.lpszClassName = szTextAreaClassW;
+
+	    if (RegisterClassW(&wndclassw) == 0)
+		return FAIL;
+	}
+    }
+    else
+#endif
     if (GetClassInfo(s_hinst, szTextAreaClass, &wndclass) == 0)
     {
 	wndclass.style = CS_OWNDC;
 	wndclass.lpfnWndProc = _TextAreaWndProc;
 	wndclass.cbClsExtra = 0;
@@ -1580,10 +1603,21 @@ gui_mch_init(void)
     s_findrep_struct.lpstrFindWhat[0] = NUL;
     s_findrep_struct.lpstrReplaceWith = alloc(MSWIN_FR_BUFSIZE);
     s_findrep_struct.lpstrReplaceWith[0] = NUL;
     s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE;
     s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
+# if defined(FEAT_MBYTE) && defined(WIN3264)
+    s_findrep_struct_w.lStructSize = sizeof(s_findrep_struct_w);
+    s_findrep_struct_w.lpstrFindWhat =
+			      (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
+    s_findrep_struct_w.lpstrFindWhat[0] = NUL;
+    s_findrep_struct_w.lpstrReplaceWith =
+			      (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
+    s_findrep_struct_w.lpstrReplaceWith[0] = NUL;
+    s_findrep_struct_w.wFindWhatLen = MSWIN_FR_BUFSIZE;
+    s_findrep_struct_w.wReplaceWithLen = MSWIN_FR_BUFSIZE;
+# endif
 #endif
 
 theend:
     /* Display any pending error messages */
     display_errors();
@@ -1933,11 +1967,11 @@ GetResultStr(HWND hwnd, int GCS, int *le
     /* Reads in the composition string. */
     buf = GetCompositionString_inUCS2(hIMC, GCS, lenp);
     if (buf == NULL)
 	return NULL;
 
-    convbuf = ucs2_to_enc(buf, lenp);
+    convbuf = utf16_to_enc(buf, lenp);
     pImmReleaseContext(hwnd, hIMC);
     vim_free(buf);
     return convbuf;
 }
 #endif
@@ -2564,11 +2598,11 @@ gui_mch_add_menu(
 
 	    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
 	    {
 		/* 'encoding' differs from active codepage: convert menu name
 		 * and use wide function */
-		wn = enc_to_ucs2(menu->name, NULL);
+		wn = enc_to_utf16(menu->name, NULL);
 		if (wn != NULL)
 		{
 		    MENUITEMINFOW	infow;
 
 		    infow.cbSize = sizeof(infow);
@@ -2726,11 +2760,11 @@ gui_mch_add_menu_item(
 
 	if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
 	{
 	    /* 'encoding' differs from active codepage: convert menu item name
 	     * and use wide function */
-	    wn = enc_to_ucs2(menu->name, NULL);
+	    wn = enc_to_utf16(menu->name, NULL);
 	    if (wn != NULL)
 	    {
 		n = InsertMenuW(parent->submenu_id, (UINT)idx,
 			(menu_is_separator(menu->name)
 				 ? MF_SEPARATOR : MF_STRING) | MF_BYPOSITION,
@@ -2936,12 +2970,31 @@ dialog_callback(
 	if (button >= DLG_NONBUTTON_CONTROL)
 	    return TRUE;
 
 	/* If the edit box exists, copy the string. */
 	if (s_textfield != NULL)
-	    GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
+	{
+# if defined(FEAT_MBYTE) && defined(WIN3264)
+	    /* If the OS is Windows NT, and 'encoding' differs from active
+	     * codepage: use wide function and convert text. */
+	    if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
+		    && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+            {
+	       WCHAR  *wp = (WCHAR *)alloc(IOSIZE * sizeof(WCHAR));
+	       char_u *p;
+
+	       GetDlgItemTextW(hwnd, DLG_NONBUTTON_CONTROL + 2, wp, IOSIZE);
+	       p = utf16_to_enc(wp, NULL);
+	       vim_strncpy(s_textfield, p, IOSIZE);
+	       vim_free(p);
+	       vim_free(wp);
+	    }
+	    else
+# endif
+		GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
 							 s_textfield, IOSIZE);
+	}
 
 	/*
 	 * Need to check for IDOK because if the user just hits Return to
 	 * accept the default value, some reason this is what we get.
 	 */
@@ -3568,11 +3621,11 @@ nCopyAnsiToWideChar(
     WCHAR	*wn;
 
     if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
     {
 	/* Not a codepage, use our own conversion function. */
-	wn = enc_to_ucs2(lpAnsiIn, NULL);
+	wn = enc_to_utf16(lpAnsiIn, NULL);
 	if (wn != NULL)
 	{
 	    wcscpy(lpWCStr, wn);
 	    nChar = (int)wcslen(wn) + 1;
 	    vim_free(wn);
--- vim72.orig/src/gui_w48.c
+++ vim72/src/gui_w48.c
@@ -151,10 +151,13 @@ static int		s_busy_processing = FALSE;
 static int		destroying = FALSE;	/* call DestroyWindow() ourselves */
 
 #ifdef MSWIN_FIND_REPLACE
 static UINT		s_findrep_msg = 0;	/* set in gui_w[16/32].c */
 static FINDREPLACE	s_findrep_struct;
+# if defined(FEAT_MBYTE) && defined(WIN3264)
+static FINDREPLACEW	s_findrep_struct_w;
+# endif
 static HWND		s_findrep_hwnd = NULL;
 static int		s_findrep_is_find;	/* TRUE for find dialog, FALSE
 						   for find/replace dialog */
 #endif
 
@@ -545,11 +548,11 @@ char_to_string(int ch, char_u *string, i
 	    }
 	}
 	else
 	{
 	    len = 1;
-	    ws = ucs2_to_enc(wstring, &len);
+	    ws = utf16_to_enc(wstring, &len);
 	    if (ws == NULL)
 		len = 0;
 	    else
 	    {
 		if (len > slen)	/* just in case */
@@ -882,19 +885,68 @@ _OnMenu(
 	gui_menu_cb(pMenu);
 }
 #endif
 
 #ifdef MSWIN_FIND_REPLACE
+# if defined(FEAT_MBYTE) && defined(WIN3264)
+/*
+ * copy useful data from structure LPFINDREPLACE to structure LPFINDREPLACEW
+ */
+    static void
+findrep_atow(LPFINDREPLACEW lpfrw, LPFINDREPLACE lpfr)
+{
+    WCHAR *wp;
+
+    lpfrw->hwndOwner = lpfr->hwndOwner;
+    lpfrw->Flags = lpfr->Flags;
+
+    wp = enc_to_utf16(lpfr->lpstrFindWhat, NULL);
+    wcsncpy(lpfrw->lpstrFindWhat, wp, lpfrw->wFindWhatLen - 1);
+    vim_free(wp);
+
+    /* the field "lpstrReplaceWith" doesn't need to be copied */
+}
+
+/*
+ * copy useful data from structure LPFINDREPLACEW to structure LPFINDREPLACE
+ */
+    static void
+findrep_wtoa(LPFINDREPLACE lpfr, LPFINDREPLACEW lpfrw)
+{
+    char_u *p;
+
+    lpfr->Flags = lpfrw->Flags;
+
+    p = utf16_to_enc(lpfrw->lpstrFindWhat, NULL);
+    vim_strncpy(lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1);
+    vim_free(p);
+
+    p = utf16_to_enc(lpfrw->lpstrReplaceWith, NULL);
+    vim_strncpy(lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1);
+    vim_free(p);
+}
+# endif
+
 /*
  * Handle a Find/Replace window message.
  */
     static void
 _OnFindRepl(void)
 {
     int	    flags = 0;
     int	    down;
 
+# if defined(FEAT_MBYTE) && defined(WIN3264)
+    /* If the OS is Windows NT, and 'encoding' differs from active codepage:
+     * convert text from wide string. */
+    if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
+			&& enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+    {
+        findrep_wtoa(&s_findrep_struct, &s_findrep_struct_w);
+    }
+# endif
+
     if (s_findrep_struct.Flags & FR_DIALOGTERM)
 	/* Give main window the focus back. */
 	(void)SetFocus(s_hwnd);
 
     if (s_findrep_struct.Flags & FR_FINDNEXT)
@@ -1030,13 +1082,12 @@ _TextAreaWndProc(
 
 #ifdef FEAT_BEVAL
 	case WM_NOTIFY: Handle_WM_Notify(hwnd, (LPNMHDR)lParam);
 	    return TRUE;
 #endif
-
-    default:
-	return MyWindowProc(hwnd, uMsg, wParam, lParam);
+	default:
+	    return MyWindowProc(hwnd, uMsg, wParam, lParam);
     }
 }
 
 #if (defined(WIN3264) && defined(FEAT_MBYTE)) \
 	|| defined(GLOBAL_IME) \
@@ -1661,12 +1712,21 @@ process_message(void)
 #ifdef FEAT_OLE
     /* Look after OLE Automation commands */
     if (msg.message == WM_OLE)
     {
 	char_u *str = (char_u *)msg.lParam;
-	add_to_input_buf(str, (int)STRLEN(str));
-	vim_free(str);
+	if (str == NULL || *str == NUL)
+	{
+	    /* Message can't be ours, forward it.  Fixes problem with Ultramon
+	     * 3.0.4 */
+	    DispatchMessage(&msg);
+	}
+	else
+	{
+	    add_to_input_buf(str, (int)STRLEN(str));
+	    vim_free(str);  /* was allocated in CVim::SendKeys() */
+	}
 	return;
     }
 #endif
 
 #ifdef FEAT_NETBEANS_INTG
@@ -1935,10 +1995,15 @@ gui_mch_wait_for_chars(int wtime)
 	    (void)SetActiveWindow(s_hwnd);
 #endif
 	    s_need_activate = FALSE;
 	}
 
+#ifdef FEAT_NETBEANS_INTG
+	/* Process the queued netbeans messages. */
+	netbeans_parse_messages();
+#endif
+
 	/*
 	 * Don't use gui_mch_update() because then we will spin-lock until a
 	 * char arrives, instead we use GetMessage() to hang until an
 	 * event arrives.  No need to check for input_buf_full because we are
 	 * returning as soon as it contains a single char -- webb
@@ -2126,11 +2191,11 @@ GetTextWidthEnc(HDC hdc, char_u *str, in
 
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
 	/* 'encoding' differs from active codepage: convert text and use wide
 	 * function */
-	wstr = enc_to_ucs2(str, &wlen);
+	wstr = enc_to_utf16(str, &wlen);
 	if (wstr != NULL)
 	{
 	    n = GetTextExtentPointW(hdc, wstr, wlen, &size);
 	    vim_free(wstr);
 	    if (n)
@@ -2250,11 +2315,11 @@ add_tabline_popup_menu_entry(HMENU pmenu
 
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
 	/* 'encoding' differs from active codepage: convert menu name
 	 * and use wide function */
-	wn = enc_to_ucs2(item_text, NULL);
+	wn = enc_to_utf16(item_text, NULL);
 	if (wn != NULL)
 	{
 	    MENUITEMINFOW	infow;
 
 	    infow.cbSize = sizeof(infow);
@@ -2420,11 +2485,11 @@ gui_mch_update_tabline(void)
 #ifdef FEAT_MBYTE
 	wstr = NULL;
 	if (use_unicode)
 	{
 	    /* Need to go through Unicode. */
-	    wstr = enc_to_ucs2(NameBuff, NULL);
+	    wstr = enc_to_utf16(NameBuff, NULL);
 	    if (wstr != NULL)
 	    {
 		TCITEMW		tiw;
 
 		tiw.mask = TCIF_TEXT;
@@ -2519,12 +2584,12 @@ set_window_title(HWND hwnd, char *title)
     if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP())
     {
 	WCHAR	*wbuf;
 	int	n;
 
-	/* Convert the title from 'encoding' to ucs2. */
-	wbuf = (WCHAR *)enc_to_ucs2((char_u *)title, NULL);
+	/* Convert the title from 'encoding' to UTF-16. */
+	wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL);
 	if (wbuf != NULL)
 	{
 	    n = SetWindowTextW(hwnd, wbuf);
 	    vim_free(wbuf);
 	    if (n != 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
@@ -2546,11 +2611,23 @@ gui_mch_find_dialog(exarg_T *eap)
 	    DestroyWindow(s_findrep_hwnd);
 
 	if (!IsWindow(s_findrep_hwnd))
 	{
 	    initialise_findrep(eap->arg);
-	    s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
+# if defined(FEAT_MBYTE) && defined(WIN3264)
+	    /* If the OS is Windows NT, and 'encoding' differs from active
+	     * codepage: convert text and use wide function. */
+	    if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
+		    && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+	    {
+	        findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
+		s_findrep_hwnd = FindTextW(
+					(LPFINDREPLACEW) &s_findrep_struct_w);
+	    }
+	    else
+# endif
+		s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
 	}
 
 	set_window_title(s_findrep_hwnd,
 			       _("Find string (use '\\\\' to find  a '\\')"));
 	(void)SetFocus(s_findrep_hwnd);
@@ -2571,11 +2648,22 @@ gui_mch_replace_dialog(exarg_T *eap)
 	    DestroyWindow(s_findrep_hwnd);
 
 	if (!IsWindow(s_findrep_hwnd))
 	{
 	    initialise_findrep(eap->arg);
-	    s_findrep_hwnd = ReplaceText((LPFINDREPLACE) &s_findrep_struct);
+# if defined(FEAT_MBYTE) && defined(WIN3264)
+	    if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
+		    && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+	    {
+		findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
+		s_findrep_hwnd = ReplaceTextW(
+					(LPFINDREPLACEW) &s_findrep_struct_w);
+	    }
+	    else
+# endif
+		s_findrep_hwnd = ReplaceText(
+					   (LPFINDREPLACE) &s_findrep_struct);
 	}
 
 	set_window_title(s_findrep_hwnd,
 			    _("Find & Replace (use '\\\\' to find  a '\\')"));
 	(void)SetFocus(s_findrep_hwnd);
@@ -3220,11 +3308,11 @@ gui_mch_browseW(
 	char_u *dflt,
 	char_u *ext,
 	char_u *initdir,
 	char_u *filter)
 {
-    /* We always use the wide function.  This means enc_to_ucs2() must work,
+    /* We always use the wide function.  This means enc_to_utf16() must work,
      * otherwise it fails miserably! */
     OPENFILENAMEW	fileStruct;
     WCHAR		fileBuf[MAXPATHL];
     WCHAR		*wp;
     int			i;
@@ -3236,11 +3324,11 @@ gui_mch_browseW(
 
     if (dflt == NULL)
 	fileBuf[0] = NUL;
     else
     {
-	wp = enc_to_ucs2(dflt, NULL);
+	wp = enc_to_utf16(dflt, NULL);
 	if (wp == NULL)
 	    fileBuf[0] = NUL;
 	else
 	{
 	    for (i = 0; wp[i] != NUL && i < MAXPATHL - 1; ++i)
@@ -3255,32 +3343,32 @@ gui_mch_browseW(
 
     memset(&fileStruct, 0, sizeof(OPENFILENAMEW));
 #ifdef OPENFILENAME_SIZE_VERSION_400
     /* be compatible with Windows NT 4.0 */
     /* TODO: what to use for OPENFILENAMEW??? */
-    fileStruct.lStructSize = sizeof(OPENFILENAME_SIZE_VERSION_400);
+    fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400;
 #else
     fileStruct.lStructSize = sizeof(fileStruct);
 #endif
 
     if (title != NULL)
-	titlep = enc_to_ucs2(title, NULL);
+	titlep = enc_to_utf16(title, NULL);
     fileStruct.lpstrTitle = titlep;
 
     if (ext != NULL)
-	extp = enc_to_ucs2(ext, NULL);
+	extp = enc_to_utf16(ext, NULL);
     fileStruct.lpstrDefExt = extp;
 
     fileStruct.lpstrFile = fileBuf;
     fileStruct.nMaxFile = MAXPATHL;
     fileStruct.lpstrFilter = filterp;
     fileStruct.hwndOwner = s_hwnd;		/* main Vim window is owner*/
     /* has an initial dir been specified? */
     if (initdir != NULL && *initdir != NUL)
     {
 	/* Must have backslashes here, no matter what 'shellslash' says */
-	initdirp = enc_to_ucs2(initdir, NULL);
+	initdirp = enc_to_utf16(initdir, NULL);
 	if (initdirp != NULL)
 	{
 	    for (wp = initdirp; *wp != NUL; ++wp)
 		if (*wp == '/')
 		    *wp = '\\';
@@ -3316,11 +3404,11 @@ gui_mch_browseW(
     vim_free(initdirp);
     vim_free(titlep);
     vim_free(extp);
 
     /* Convert from UCS2 to 'encoding'. */
-    p = ucs2_to_enc(fileBuf, NULL);
+    p = utf16_to_enc(fileBuf, NULL);
     if (p != NULL)
 	/* when out of memory we get garbage for non-ASCII chars */
 	STRCPY(fileBuf, p);
     vim_free(p);
 
@@ -3333,11 +3421,11 @@ gui_mch_browseW(
 # endif /* FEAT_MBYTE */
 
 
 /*
  * Convert the string s to the proper format for a filter string by replacing
- * the \t and \n delimeters with \0.
+ * the \t and \n delimiters with \0.
  * Returns the converted string in allocated memory.
  *
  * Keep in sync with convert_filterW() above!
  */
     static char_u *
@@ -3416,11 +3504,11 @@ gui_mch_browse(
     filterp = convert_filter(filter);
 
     memset(&fileStruct, 0, sizeof(OPENFILENAME));
 #ifdef OPENFILENAME_SIZE_VERSION_400
     /* be compatible with Windows NT 4.0 */
-    fileStruct.lStructSize = sizeof(OPENFILENAME_SIZE_VERSION_400);
+    fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400;
 #else
     fileStruct.lStructSize = sizeof(fileStruct);
 #endif
 
     fileStruct.lpstrTitle = title;
@@ -3516,11 +3604,11 @@ _OnDropFiles(
     if (fnames != NULL)
 	for (i = 0; i < cFiles; ++i)
 	{
 #ifdef FEAT_MBYTE
 	    if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0)
-		fnames[i] = ucs2_to_enc(wszFile, NULL);
+		fnames[i] = utf16_to_enc(wszFile, NULL);
 	    else
 #endif
 	    {
 		DragQueryFile(hDrop, i, szFile, BUFPATHLEN);
 		fnames[i] = vim_strsave(szFile);
@@ -3672,11 +3760,12 @@ _OnScroll(
 /*
  * Get command line arguments.
  * Use "prog" as the name of the program and "cmdline" as the arguments.
  * Copy the arguments to allocated memory.
  * Return the number of arguments (including program name).
- * Return pointers to the arguments in "argvp".
+ * Return pointers to the arguments in "argvp".  Memory is allocated with
+ * malloc(), use free() instead of vim_free().
  * Return pointer to buffer in "tofree".
  * Returns zero when out of memory.
  */
 /*ARGSUSED*/
     int
@@ -3690,10 +3779,12 @@ get_cmd_args(char *prog, char *cmdline,
     int		inquote;
     int		argc;
     char	**argv = NULL;
     int		round;
 
+    *tofree = NULL;
+
 #ifdef FEAT_MBYTE
     /* Try using the Unicode version first, it takes care of conversion when
      * 'encoding' is changed. */
     argc = get_cmd_argsW(&argv);
     if (argc != 0)
@@ -3800,18 +3891,18 @@ get_cmd_args(char *prog, char *cmdline,
 	if (round == 1)
 	{
 	    argv = (char **)malloc((argc + 1) * sizeof(char *));
 	    if (argv == NULL )
 	    {
-		vim_free(newcmdline);
+		free(newcmdline);
 		return 0;		   /* malloc error */
 	    }
 	    pnew = newcmdline;
+	    *tofree = newcmdline;
 	}
     }
 
 done:
-
     argv[argc] = NULL;		/* NULL-terminated list */
     *argvp = argv;
     return argc;
 }
--- vim72.orig/src/gui_x11.c
+++ vim72/src/gui_x11.c
@@ -568,26 +568,24 @@ static char **gui_argv = NULL;
 
 /*
  * Call-back routines.
  */
 
-/* ARGSUSED */
     static void
 gui_x11_timer_cb(timed_out, interval_id)
     XtPointer	    timed_out;
-    XtIntervalId    *interval_id;
+    XtIntervalId    *interval_id UNUSED;
 {
     *((int *)timed_out) = TRUE;
 }
 
-/* ARGSUSED */
     static void
 gui_x11_visibility_cb(w, dud, event, dum)
-    Widget	w;
-    XtPointer	dud;
+    Widget	w UNUSED;
+    XtPointer	dud UNUSED;
     XEvent	*event;
-    Boolean	*dum;
+    Boolean	*dum UNUSED;
 {
     if (event->type != VisibilityNotify)
 	return;
 
     gui.visibility = event->xvisibility.state;
@@ -601,17 +599,16 @@ gui_x11_visibility_cb(w, dud, event, dum
 
     /* This is needed for when redrawing is slow. */
     gui_mch_update();
 }
 
-/* ARGSUSED */
     static void
 gui_x11_expose_cb(w, dud, event, dum)
-    Widget	w;
-    XtPointer	dud;
+    Widget	w UNUSED;
+    XtPointer	dud UNUSED;
     XEvent	*event;
-    Boolean	*dum;
+    Boolean	*dum UNUSED;
 {
     XExposeEvent	*gevent;
     int			new_x;
 
     if (event->type != Expose)
@@ -678,17 +675,16 @@ shellRectangle(Widget shell, XRectangle
     r->y = absy;
     XtVaGetValues(shell, XmNheight, &r->height, XmNwidth, &r->width, NULL);
 }
 #endif
 
-/* ARGSUSED */
     static void
 gui_x11_resize_window_cb(w, dud, event, dum)
-    Widget	w;
-    XtPointer	dud;
+    Widget	w UNUSED;
+    XtPointer	dud UNUSED;
     XEvent	*event;
-    Boolean	*dum;
+    Boolean	*dum UNUSED;
 {
     static int lastWidth, lastHeight;
 
     if (event->type != ConfigureNotify)
 	return;
@@ -725,56 +721,52 @@ gui_x11_resize_window_cb(w, dud, event,
 #ifdef FEAT_XIM
     xim_set_preedit();
 #endif
 }
 
-/* ARGSUSED */
     static void
 gui_x11_focus_change_cb(w, data, event, dum)
-    Widget	w;
-    XtPointer	data;
+    Widget	w UNUSED;
+    XtPointer	data UNUSED;
     XEvent	*event;
-    Boolean	*dum;
+    Boolean	*dum UNUSED;
 {
     gui_focus_change(event->type == FocusIn);
 }
 
-/* ARGSUSED */
     static void
 gui_x11_enter_cb(w, data, event, dum)
-    Widget	w;
-    XtPointer	data;
-    XEvent	*event;
-    Boolean	*dum;
+    Widget	w UNUSED;
+    XtPointer	data UNUSED;
+    XEvent	*event UNUSED;
+    Boolean	*dum UNUSED;
 {
     gui_focus_change(TRUE);
 }
 
-/* ARGSUSED */
     static void
 gui_x11_leave_cb(w, data, event, dum)
-    Widget	w;
-    XtPointer	data;
-    XEvent	*event;
-    Boolean	*dum;
+    Widget	w UNUSED;
+    XtPointer	data UNUSED;
+    XEvent	*event UNUSED;
+    Boolean	*dum UNUSED;
 {
     gui_focus_change(FALSE);
 }
 
 #if defined(X_HAVE_UTF8_STRING) && defined(FEAT_MBYTE)
 # if X_HAVE_UTF8_STRING
 #  define USE_UTF8LOOKUP
 # endif
 #endif
 
-/* ARGSUSED */
     void
 gui_x11_key_hit_cb(w, dud, event, dum)
-    Widget	w;
-    XtPointer	dud;
+    Widget	w UNUSED;
+    XtPointer	dud UNUSED;
     XEvent	*event;
-    Boolean	*dum;
+    Boolean	*dum UNUSED;
 {
     XKeyPressedEvent	*ev_press;
 #ifdef FEAT_XIM
     char_u		string2[256];
     char_u		string_shortbuf[256];
@@ -1076,17 +1068,16 @@ theend:
     if (string_alloced)
 	XtFree((char *)string);
 #endif
 }
 
-/* ARGSUSED */
     static void
 gui_x11_mouse_cb(w, dud, event, dum)
-    Widget	w;
-    XtPointer	dud;
+    Widget	w UNUSED;
+    XtPointer	dud UNUSED;
     XEvent	*event;
-    Boolean	*dum;
+    Boolean	*dum UNUSED;
 {
     static XtIntervalId timer = (XtIntervalId)0;
     static int	timed_out = TRUE;
 
     int		button;
@@ -1208,15 +1199,15 @@ gui_mch_prepare(argc, argv)
     gui_argv[gui_argc++] = argv[0];
     arg = 1;
     while (arg < *argc)
     {
 	/* Look for argv[arg] in cmdline_options[] table */
-	for (i = 0; i < XtNumber(cmdline_options); i++)
+	for (i = 0; i < (int)XtNumber(cmdline_options); i++)
 	    if (strcmp(argv[arg], cmdline_options[i].option) == 0)
 		break;
 
-	if (i < XtNumber(cmdline_options))
+	if (i < (int)XtNumber(cmdline_options))
 	{
 	    /* Remember finding "-rv" or "-reverse" */
 	    if (strcmp("-rv", argv[arg]) == 0
 		    || strcmp("-reverse", argv[arg]) == 0)
 		found_reverse_arg = TRUE;
@@ -1317,16 +1308,15 @@ gui_mch_init_check()
  */
 static XtInputId _xsmp_xtinputid;
 
 static void local_xsmp_handle_requests __ARGS((XtPointer c, int *s, XtInputId *i));
 
-/*ARGSUSED*/
     static void
 local_xsmp_handle_requests(c, s, i)
-    XtPointer	c;
-    int		*s;
-    XtInputId	*i;
+    XtPointer	c UNUSED;
+    int		*s UNUSED;
+    XtInputId	*i UNUSED;
 {
     if (xsmp_handle_requests() == FAIL)
 	XtRemoveInput(_xsmp_xtinputid);
 }
 #endif
@@ -1436,11 +1426,11 @@ gui_mch_init()
 	mask = XParseGeometry((char *)gui.geom, &x, &y, &w, &h);
 	if (mask & WidthValue)
 	    Columns = w;
 	if (mask & HeightValue)
 	{
-	    if (p_window > h - 1 || !option_was_set((char_u *)"window"))
+	    if (p_window > (long)h - 1 || !option_was_set((char_u *)"window"))
 		p_window = h - 1;
 	    Rows = h;
 	}
 	/*
 	 * Set the (x,y) position of the main window only if specified in the
@@ -1585,10 +1575,12 @@ gui_mch_uninit()
 {
     gui_x11_destroy_widgets();
     XtCloseDisplay(gui.dpy);
     gui.dpy = NULL;
     vimShell = (Widget)0;
+    vim_free(gui_argv);
+    gui_argv = NULL;
 }
 
 /*
  * Called when the foreground or background color has been changed.
  */
@@ -1749,20 +1741,21 @@ gui_init_menu_font()
     }
 #endif
 }
 #endif
 
-/*ARGSUSED*/
     void
 gui_mch_exit(rc)
-    int		rc;
+    int		rc UNUSED;
 {
 #if 0
     /* Lesstif gives an error message here, and so does Solaris.  The man page
      * says that this isn't needed when exiting, so just skip it. */
     XtCloseDisplay(gui.dpy);
 #endif
+    vim_free(gui_argv);
+    gui_argv = NULL;
 }
 
 /*
  * Get the position of the top left corner of the window.
  */
@@ -1793,21 +1786,20 @@ gui_mch_set_winpos(x, y)
 	XtNx,	x,
 	XtNy,	y,
 	NULL);
 }
 
-/*ARGSUSED*/
     void
 gui_mch_set_shellsize(width, height, min_width, min_height,
 		    base_width, base_height, direction)
     int		width;
     int		height;
     int		min_width;
     int		min_height;
     int		base_width;
     int		base_height;
-    int		direction;
+    int		direction UNUSED;
 {
 #ifdef FEAT_XIM
     height += xim_get_status_area_height(),
 #endif
     XtVaSetValues(vimShell,
@@ -1841,15 +1833,14 @@ gui_mch_get_screen_dimensions(screen_w,
  * Initialise vim to use the font "font_name".  If it's NULL, pick a default
  * font.
  * If "fontset" is TRUE, load the "font_name" as a fontset.
  * Return FAIL if the font could not be loaded, OK otherwise.
  */
-/*ARGSUSED*/
     int
 gui_mch_init_font(font_name, do_fontset)
     char_u	*font_name;
-    int		do_fontset;
+    int		do_fontset UNUSED;
 {
     XFontStruct	*font = NULL;
 
 #ifdef FEAT_XFONTSET
     XFontSet	fontset = NULL;
@@ -2023,14 +2014,13 @@ gui_mch_get_font(name, giveErrorIfMissin
 #if defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Return the name of font "font" in allocated memory.
  * Don't know how to get the actual name, thus use the provided name.
  */
-/*ARGSUSED*/
     char_u *
 gui_mch_get_fontname(font, name)
-    GuiFont font;
+    GuiFont font UNUSED;
     char_u  *name;
 {
     if (name == NULL)
 	return NULL;
     return vim_strsave(name);
@@ -2448,11 +2438,11 @@ find_closest_color(colormap, colorPtr)
     {
 	gui.color_approx = TRUE;
 	*colorPtr = colortable[closest];
     }
 
-    free(colortable);
+    vim_free(colortable);
     return OK;
 }
 
 /*
  * Set the current text foreground color.
@@ -2515,11 +2505,11 @@ draw_curl(row, col, cells)
     int col;
     int cells;
 {
     int			i;
     int			offset;
-    const static int	val[8] = {1, 0, 0, 0, 1, 2, 2, 2 };
+    static const int	val[8] = {1, 0, 0, 0, 1, 2, 2, 2 };
 
     XSetForeground(gui.dpy, gui.text_gc, prev_sp_color);
     for (i = FILL_X(col); i < FILL_X(col + cells); ++i)
     {
 	offset = val[i % 8];
@@ -2563,12 +2553,14 @@ gui_mch_draw_string(row, col, s, len, fl
 	{
 	    c = utf_ptr2char(p);
 # ifdef FEAT_XFONTSET
 	    if (current_fontset != NULL)
 	    {
-		if (c >= 0x10000 && sizeof(wchar_t) <= 2)
+#  ifdef SMALL_WCHAR_T
+		if (c >= 0x10000)
 		    c = 0xbf;		/* show chars > 0xffff as ? */
+#  endif
 		((wchar_t *)buf)[wlen] = c;
 	    }
 	    else
 # endif
 	    {
@@ -3130,15 +3122,15 @@ gui_mch_menu_hidden(menu, hidden)
 gui_mch_draw_menubar()
 {
     /* Nothing to do in X */
 }
 
-/* ARGSUSED */
     void
 gui_x11_menu_cb(w, client_data, call_data)
-    Widget	w;
-    XtPointer	client_data, call_data;
+    Widget	w UNUSED;
+    XtPointer	client_data;
+    XtPointer	call_data UNUSED;
 {
     gui_menu_cb((vimmenu_T *)client_data);
 }
 
 #endif /* FEAT_MENU */
@@ -3147,17 +3139,16 @@ gui_x11_menu_cb(w, client_data, call_dat
 
 /*
  * Function called when window closed.	Works like ":qa".
  * Should put up a requester!
  */
-/*ARGSUSED*/
     static void
 gui_x11_wm_protocol_handler(w, client_data, event, dum)
-    Widget	w;
-    XtPointer	client_data;
+    Widget	w UNUSED;
+    XtPointer	client_data UNUSED;
     XEvent	*event;
-    Boolean	*dum;
+    Boolean	*dum UNUSED;
 {
     /*
      * Only deal with Client messages.
      */
     if (event->type != ClientMessage)
@@ -3166,11 +3157,11 @@ gui_x11_wm_protocol_handler(w, client_da
     /*
      * The WM_SAVE_YOURSELF event arrives when the window manager wants to
      * exit.  That can be cancelled though, thus Vim shouldn't exit here.
      * Just sync our swap files.
      */
-    if (((XClientMessageEvent *)event)->data.l[0] ==
+    if ((Atom)((XClientMessageEvent *)event)->data.l[0] ==
 						  wm_atoms[SAVE_YOURSELF_IDX])
     {
 	out_flush();
 	ml_sync_all(FALSE, FALSE);	/* preserve all swap files */
 
@@ -3179,28 +3170,27 @@ gui_x11_wm_protocol_handler(w, client_da
 	 * thus set argv to NULL. */
 	XSetCommand(gui.dpy, XtWindow(vimShell), NULL, 0);
 	return;
     }
 
-    if (((XClientMessageEvent *)event)->data.l[0] !=
+    if ((Atom)((XClientMessageEvent *)event)->data.l[0] !=
 						  wm_atoms[DELETE_WINDOW_IDX])
 	return;
 
     gui_shell_closed();
 }
 
 #ifdef FEAT_CLIENTSERVER
 /*
  * Function called when property changed. Check for incoming commands
  */
-/*ARGSUSED*/
     static void
 gui_x11_send_event_handler(w, client_data, event, dum)
-    Widget	w;
-    XtPointer	client_data;
+    Widget	w UNUSED;
+    XtPointer	client_data UNUSED;
     XEvent	*event;
-    Boolean	*dum;
+    Boolean	*dum UNUSED;
 {
     XPropertyEvent *e = (XPropertyEvent *) event;
 
     if (e->type == PropertyNotify && e->window == commWindow
 	    && e->atom == commProperty &&  e->state == PropertyNewValue)
@@ -3271,15 +3261,14 @@ gui_mch_start_blink()
 	blink_state = BLINK_ON;
 	gui_update_cursor(TRUE, FALSE);
     }
 }
 
-/* ARGSUSED */
     static void
 gui_x11_blink_cb(timed_out, interval_id)
-    XtPointer	    timed_out;
-    XtIntervalId    *interval_id;
+    XtPointer	    timed_out UNUSED;
+    XtIntervalId    *interval_id UNUSED;
 {
     if (blink_state == BLINK_ON)
     {
 	gui_undraw_cursor();
 	blink_state = BLINK_OFF;
@@ -3437,62 +3426,51 @@ gui_mch_drawsign(row, col, typenr)
     void *
 gui_mch_register_sign(signfile)
     char_u	    *signfile;
 {
     XpmAttributes   attrs;
-    XImage	    *sign;
+    XImage	    *sign = NULL;
     int		    status;
 
     /*
      * Setup the color substitution table.
      */
-    sign = NULL;
     if (signfile[0] != NUL && signfile[0] != '-')
     {
-	sign = (XImage *)alloc(sizeof(XImage));
-	if (sign != NULL)
+	XpmColorSymbol color[5] =
 	{
-	    XpmColorSymbol color[5] =
-	    {
-		{"none", NULL, 0},
-		{"iconColor1", NULL, 0},
-		{"bottomShadowColor", NULL, 0},
-		{"topShadowColor", NULL, 0},
-		{"selectColor", NULL, 0}
-	    };
-	    attrs.valuemask = XpmColorSymbols;
-	    attrs.numsymbols = 2;
-	    attrs.colorsymbols = color;
-	    attrs.colorsymbols[0].pixel = gui.back_pixel;
-	    attrs.colorsymbols[1].pixel = gui.norm_pixel;
-	    status = XpmReadFileToImage(gui.dpy, (char *)signfile,
+	    {"none", NULL, 0},
+	    {"iconColor1", NULL, 0},
+	    {"bottomShadowColor", NULL, 0},
+	    {"topShadowColor", NULL, 0},
+	    {"selectColor", NULL, 0}
+	};
+	attrs.valuemask = XpmColorSymbols;
+	attrs.numsymbols = 2;
+	attrs.colorsymbols = color;
+	attrs.colorsymbols[0].pixel = gui.back_pixel;
+	attrs.colorsymbols[1].pixel = gui.norm_pixel;
+	status = XpmReadFileToImage(gui.dpy, (char *)signfile,
 							 &sign, NULL, &attrs);
-
-	    if (status == 0)
-	    {
-		/* Sign width is fixed at two columns now.
-		if (sign->width > gui.sign_width)
-		    gui.sign_width = sign->width + 8; */
-	    }
-	    else
-	    {
-		vim_free(sign);
-		sign = NULL;
-		EMSG(_(e_signdata));
-	    }
+	if (status == 0)
+	{
+	    /* Sign width is fixed at two columns now.
+	    if (sign->width > gui.sign_width)
+	        gui.sign_width = sign->width + 8; */
 	}
+	else
+	    EMSG(_(e_signdata));
     }
 
     return (void *)sign;
 }
 
     void
 gui_mch_destroy_sign(sign)
     void *sign;
 {
-    XFree(((XImage *)sign)->data);
-    vim_free(sign);
+    XDestroyImage((XImage*)sign);
 }
 #endif
 
 
 #ifdef FEAT_MOUSESHAPE
--- vim72.orig/src/gui_xmdlg.c
+++ vim72/src/gui_xmdlg.c
@@ -8,11 +8,11 @@
  */
 
 /*
  * (C) 2001,2005 by Marcin Dalecki <martin@dalecki.de>
  *
- * Implementation of dialogue functions for the Motif GUI variant.
+ * Implementation of dialog functions for the Motif GUI variant.
  *
  * Note about Lesstif: Apparently lesstif doesn't get the widget layout right,
  * when using a dynamic scrollbar policy.
  */
 
@@ -367,14 +367,14 @@ fill_lists(enum ListSpecifier fix, Share
     char	*list[NONE][MAX_ENTRIES_IN_LIST];
     int		count[NONE];
     char	buf[TEMP_BUF_SIZE];
     XmString	items[MAX_ENTRIES_IN_LIST];
     int		i;
-    int		index;
+    int		idx;
 
-    for (index = (int)ENCODING; index < (int)NONE; ++index)
-	count[index] = 0;
+    for (idx = (int)ENCODING; idx < (int)NONE; ++idx)
+	count[idx] = 0;
 
     /* First we insert the wild char into every single list. */
     if (fix != ENCODING)
 	add_to_list(list[ENCODING], wild, &count[ENCODING]);
     if (fix != NAME)
@@ -446,11 +446,11 @@ fill_lists(enum ListSpecifier fix, Share
 	{
 	    Widget button;
 
 	    items[i] = XmStringCreateLocalized(list[ENCODING][i]);
 
-	    if (i < n_items)
+	    if (i < (int)n_items)
 	    {
 		/* recycle old button */
 		XtVaSetValues(children[i],
 			XmNlabelString, items[i],
 			XmNuserData, i,
@@ -479,11 +479,11 @@ fill_lists(enum ListSpecifier fix, Share
 	    XtFree(list[ENCODING][i]);
 	}
 
 	/* Destroy all the outstanding menu items.
 	 */
-	for (i = count[ENCODING]; i < n_items; ++i)
+	for (i = count[ENCODING]; i < (int)n_items; ++i)
 	{
 	    XtUnmanageChild(children[i]);
 	    XtDestroyWidget(children[i]);
 	}
 
@@ -501,18 +501,18 @@ fill_lists(enum ListSpecifier fix, Share
     }
 
     /*
      * Now loop trough the remaining lists and set them up.
      */
-    for (index = (int)NAME; index < (int)NONE; ++index)
+    for (idx = (int)NAME; idx < (int)NONE; ++idx)
     {
 	Widget w;
 
-	if (fix == (enum ListSpecifier)index)
+	if (fix == (enum ListSpecifier)idx)
 	    continue;
 
-	switch ((enum ListSpecifier)index)
+	switch ((enum ListSpecifier)idx)
 	{
 	    case NAME:
 		w = data->list[NAME];
 		break;
 	    case STYLE:
@@ -523,32 +523,31 @@ fill_lists(enum ListSpecifier fix, Share
 		break;
 	    default:
 		w = (Widget)0;	/* for lint */
 	}
 
-	for (i = 0; i < count[index]; ++i)
+	for (i = 0; i < count[idx]; ++i)
 	{
-	    items[i] = XmStringCreateLocalized(list[index][i]);
-	    XtFree(list[index][i]);
+	    items[i] = XmStringCreateLocalized(list[idx][i]);
+	    XtFree(list[idx][i]);
 	}
 	XmListDeleteAllItems(w);
-	XmListAddItems(w, items, count[index], 1);
-	if (data->sel[index])
+	XmListAddItems(w, items, count[idx], 1);
+	if (data->sel[idx])
 	{
 	    XmStringFree(items[0]);
-	    items[0] = XmStringCreateLocalized(data->sel[index]);
+	    items[0] = XmStringCreateLocalized(data->sel[idx]);
 	    XmListSelectItem(w, items[0], False);
 	    XmListSetBottomItem(w, items[0]);
 	}
-	for (i = 0; i < count[index]; ++i)
+	for (i = 0; i < count[idx]; ++i)
 	    XmStringFree(items[i]);
     }
 }
 
-/*ARGSUSED*/
     static void
-stoggle_callback(Widget w,
+stoggle_callback(Widget w UNUSED,
 	SharedFontSelData *data,
 	XmToggleButtonCallbackStruct *call_data)
 {
     int		i, do_sel;
     char	newSize[TEMP_BUF_SIZE];
@@ -632,20 +631,23 @@ do_choice(Widget w,
 
     if (!data->sel[which])
 	data->sel[which] = XtNewString(sel);
     else
     {
-	XtFree(data->sel[which]);
 	if (!strcmp(data->sel[which], sel))
 	{
 	    /* unselecting current selection */
+	    XtFree(data->sel[which]);
 	    data->sel[which] = NULL;
 	    if (w)
 		XmListDeselectItem(w, call_data->item);
 	}
 	else
+	{
+	    XtFree(data->sel[which]);
 	    data->sel[which] = XtNewString(sel);
+	}
     }
     XtFree(sel);
 
     fill_lists(which, data);
 
@@ -693,29 +695,28 @@ do_choice(Widget w,
     else
     {
 	int	    n;
 	XmString    str;
 	Arg	    args[4];
-	char	    *msg = _("no specific match");
+	char	    *nomatch_msg = _("no specific match");
 
 	n = 0;
-	str = XmStringCreateLocalized(msg);
+	str = XmStringCreateLocalized(nomatch_msg);
 	XtSetArg(args[n], XmNlabelString, str); ++n;
 	XtSetValues(data->sample, args, n);
 	apply_fontlist(data->sample);
-	XmTextSetString(data->name, msg);
+	XmTextSetString(data->name, nomatch_msg);
 	XmStringFree(str);
 
 	return False;
     }
 }
 
-/*ARGSUSED*/
     static void
 encoding_callback(Widget w,
 	SharedFontSelData *data,
-	XtPointer dummy)
+	XtPointer dummy UNUSED)
 {
     XmString str;
     XmListCallbackStruct fake_data;
 
     XtVaGetValues(w, XmNlabelString, &str, NULL);
@@ -750,15 +751,14 @@ size_callback(Widget w,
 	XmListCallbackStruct *call_data)
 {
     do_choice(w, data, call_data, SIZE);
 }
 
-/*ARGSUSED*/
     static void
-cancel_callback(Widget w,
+cancel_callback(Widget w UNUSED,
 	SharedFontSelData *data,
-	XmListCallbackStruct *call_data)
+	XmListCallbackStruct *call_data UNUSED)
 {
     if (data->sel[ENCODING])
     {
 	XtFree(data->sel[ENCODING]);
 	data->sel[ENCODING] = NULL;
@@ -787,15 +787,14 @@ cancel_callback(Widget w,
     XFreeFontNames(data->names);
     data->names = NULL;
     data->exit = True;
 }
 
-/*ARGSUSED*/
     static void
-ok_callback(Widget w,
+ok_callback(Widget w UNUSED,
 	SharedFontSelData *data,
-	XmPushButtonCallbackStruct *call_data)
+	XmPushButtonCallbackStruct *call_data UNUSED)
 {
     char    *pattern;
     char    **name;
     int	    i;
 
@@ -884,25 +883,25 @@ gui_xm_select_font(char_u *current)
      */
 
     {
 	int	i;
 	int	max;
-	int	index = 0;
+	int	idx = 0;
 	int	size;
-	char	str[128];
+	char	buf[128];
 
 	for (i = 0, max = 0; i < data->num; i++)
 	{
-	    get_part(fn(data, i), 7, str);
-	    size = atoi(str);
+	    get_part(fn(data, i), 7, buf);
+	    size = atoi(buf);
 	    if ((size > max) && (size < MAX_DISPLAY_SIZE))
 	    {
-		index = i;
+		idx = i;
 		max = size;
 	    }
 	}
-	strcpy(big_font, fn(data, index));
+	strcpy(big_font, fn(data, idx));
     }
     data->old = XLoadQueryFont(XtDisplay(parent), big_font);
     data->old_list = gui_motif_create_fontlist(data->old);
 
     /* Set the title of the Dialog window. */
@@ -1215,32 +1214,32 @@ gui_xm_select_font(char_u *current)
 
 	names = XListFonts(XtDisplay(form), (char *) current, 1, &i);
 
 	if (i != 0)
 	{
-	    char name[TEMP_BUF_SIZE];
-	    char style[TEMP_BUF_SIZE];
-	    char size[TEMP_BUF_SIZE];
-	    char encoding[TEMP_BUF_SIZE];
+	    char namebuf[TEMP_BUF_SIZE];
+	    char stylebuf[TEMP_BUF_SIZE];
+	    char sizebuf[TEMP_BUF_SIZE];
+	    char encodingbuf[TEMP_BUF_SIZE];
 	    char *found;
 
 	    found = names[0];
 
-	    name_part(found, name);
-	    style_part(found, style);
-	    size_part(found, size, data->in_pixels);
-	    encoding_part(found, encoding);
-
-	    if (strlen(name) > 0
-		    && strlen(style) > 0
-		    && strlen(size) > 0
-		    && strlen(encoding) > 0)
+	    name_part(found, namebuf);
+	    style_part(found, stylebuf);
+	    size_part(found, sizebuf, data->in_pixels);
+	    encoding_part(found, encodingbuf);
+
+	    if (strlen(namebuf) > 0
+		    && strlen(stylebuf) > 0
+		    && strlen(sizebuf) > 0
+		    && strlen(encodingbuf) > 0)
 	    {
-		data->sel[NAME] = XtNewString(name);
-		data->sel[STYLE] = XtNewString(style);
-		data->sel[SIZE] = XtNewString(size);
-		data->sel[ENCODING] = XtNewString(encoding);
+		data->sel[NAME] = XtNewString(namebuf);
+		data->sel[STYLE] = XtNewString(stylebuf);
+		data->sel[SIZE] = XtNewString(sizebuf);
+		data->sel[ENCODING] = XtNewString(encodingbuf);
 		data->font_name = XtNewString(names[0]);
 		display_sample(data);
 		XmTextSetString(data->name, data->font_name);
 	    }
 	    else
@@ -1273,17 +1272,16 @@ gui_xm_select_font(char_u *current)
     /* modal event loop */
     while (!data->exit)
 	XtAppProcessEvent(XtWidgetToApplicationContext(data->dialog),
 							(XtInputMask)XtIMAll);
 
-    XtDestroyWidget(data->dialog);
-
     if (data->old)
     {
 	XFreeFont(XtDisplay(data->dialog),  data->old);
 	XmFontListFree(data->old_list);
     }
+    XtDestroyWidget(data->dialog);
 
     gui_motif_synch_fonts();
 
     return (char_u *) data->font_name;
 }
--- vim72.orig/src/gui_xmebw.c
+++ vim72/src/gui_xmebw.c
@@ -233,17 +233,16 @@ bump_color(unsigned short value)
     int tmp = 2 * (((int) value - 65535) / 3) + 65535;
 
     return tmp;
 }
 
-/*ARGSUSED*/
     static int
 alloc_color(Display	*display,
 	Colormap	colormap,
 	char		*colorname,
 	XColor		*xcolor,
-	void		*closure)
+	void		*closure UNUSED)
 {
     int status;
 
     if (colorname)
 	if (!XParseColor(display, colormap, colorname, xcolor))
@@ -593,13 +592,14 @@ draw_unhighlight(XmEnhancedButtonWidget
     else
 	XmeClearBorder(XtDisplay(eb), XtWindow(eb), 0, 0, XtWidth(eb),
 		       XtHeight(eb), eb->primitive.highlight_thickness);
 }
 
-/*ARGSUSED*/
     static void
-draw_pixmap(XmEnhancedButtonWidget eb, XEvent *event, Region region)
+draw_pixmap(XmEnhancedButtonWidget eb,
+	    XEvent *event UNUSED,
+	    Region region UNUSED)
 {
     Pixmap	pix;
     GC		gc = eb->label.normal_GC;
     int		depth;
     Cardinal	width;
@@ -639,11 +639,11 @@ draw_pixmap(XmEnhancedButtonWidget eb, X
     if (w < width)
 	width = w;
     height = eb->core.height - 2 * y;
     if (h < height)
 	height = h;
-    if (depth == eb->core.depth)
+    if (depth == (int)eb->core.depth)
 	XCopyArea(XtDisplay(eb), pix, XtWindow(eb), gc, 0, 0,
 		width, height, x, y);
     else if (depth == 1)
 	XCopyPlane(XtDisplay(eb), pix, XtWindow(eb), gc, 0, 0,
 		width, height, x, y, (unsigned long)1);
@@ -729,13 +729,15 @@ draw_label(XmEnhancedButtonWidget eb, XE
 
     if (replaceGC)
 	eb->label.normal_GC = tmp_gc;
 }
 
-/*ARGSUSED*/
     static void
-Enter(Widget wid, XEvent *event, String *params, Cardinal *num_params)
+Enter(Widget wid,
+      XEvent *event,
+      String *params UNUSED,
+      Cardinal *num_params UNUSED)
 {
     XmEnhancedButtonWidget eb = (XmEnhancedButtonWidget) wid;
     XmPushButtonCallbackStruct call_value;
 
     if (Lab_IsMenupane(eb))
@@ -816,13 +818,15 @@ Enter(Widget wid, XEvent *event, String
 	draw_shadows(eb);
 	draw_pixmap(eb, event, NULL);
     }
 }
 
-/*ARGSUSED*/
     static void
-Leave(Widget wid, XEvent *event, String *params, Cardinal *num_params)
+Leave(Widget wid,
+      XEvent *event,
+      String *params UNUSED,
+      Cardinal *num_params UNUSED)
 {
     XmEnhancedButtonWidget eb = (XmEnhancedButtonWidget)wid;
     XmPushButtonCallbackStruct call_value;
 
     if (Lab_IsMenupane(eb))
@@ -974,13 +978,12 @@ set_size(XmEnhancedButtonWidget newtb)
 
 	(* resize) ((Widget) newtb);
     }
 }
 
-/*ARGSUSED*/
     static void
-Initialize(Widget rq, Widget ebw, ArgList args, Cardinal *n)
+Initialize(Widget rq, Widget ebw, ArgList args UNUSED, Cardinal *n UNUSED)
 {
     XmEnhancedButtonWidget  request = (XmEnhancedButtonWidget)rq;
     XmEnhancedButtonWidget  eb = (XmEnhancedButtonWidget)ebw;
     XtWidgetProc	    resize;
 
@@ -1054,13 +1057,16 @@ Destroy(Widget w)
 	return;
 
     free_pixmaps((XmEnhancedButtonWidget)w);
 }
 
-/*ARGSUSED*/
     static Boolean
-SetValues(Widget current, Widget request, Widget new, ArgList args, Cardinal *n)
+SetValues(Widget current,
+	  Widget request UNUSED,
+	  Widget new,
+	  ArgList args UNUSED,
+	  Cardinal *n UNUSED)
 {
     XmEnhancedButtonWidget  cur = (XmEnhancedButtonWidget) current;
     XmEnhancedButtonWidget  eb = (XmEnhancedButtonWidget) new;
     Boolean		    redraw = False;
     Boolean		    change = True;
@@ -1106,11 +1112,11 @@ SetValues(Widget current, Widget request
 	    if (root == root_q)
 	    {
 		if ((win_x < 0) || (win_y < 0))
 		    return False;
 
-		if ((win_x > r_width) || (win_y > r_height))
+		if ((win_x > (int)r_width) || (win_y > (int)r_height))
 		    return False;
 		draw_highlight(eb);
 		draw_shadows(eb);
 	    }
 	}
@@ -1254,11 +1260,11 @@ Redisplay(Widget w, XEvent *event, Regio
 	       ->primitive_class.border_highlight))(w);
 	draw_pixmap(eb, event, region);
     }
     else
     {
-	int adjust = 0;
+	adjust = 0;
 
 #if !defined(LESSTIF_VERSION) && (XmVersion > 1002)
 	/*
 	 *  NOTE: PushButton has two types of shadows: primitive-shadow and
 	 *  default-button-shadow.  If pushbutton is in a menu only primitive
@@ -1266,16 +1272,15 @@ Redisplay(Widget w, XEvent *event, Regio
 	 */
 	switch (default_button_emphasis)
 	{
 	    case XmEXTERNAL_HIGHLIGHT:
 		adjust = (eb->primitive.highlight_thickness -
-			(eb->pushbutton.default_button_shadow_thickness ?
-			 Xm3D_ENHANCE_PIXEL : 0));
+			 (eb->pushbutton.default_button_shadow_thickness
+			  ?  Xm3D_ENHANCE_PIXEL : 0));
 		break;
 
 	    case XmINTERNAL_HIGHLIGHT:
-		adjust = 0;
 		break;
 
 	    default:
 		assert(FALSE);
 		return;
--- vim72.orig/src/gvim.exe.mnf
+++ vim72/src/gvim.exe.mnf
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
   <assemblyIdentity
     processorArchitecture="*"
     version="7.2.0.0"
     type="win32"
     name="Vim"
@@ -27,6 +27,12 @@
           level="asInvoker"
           uiAccess="false"/>
       </requestedPrivileges>
     </security>
   </trustInfo>
+  <!-- Vista High DPI aware -->
+  <asmv3:application>
+    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
+      <dpiAware>true</dpiAware>
+    </asmv3:windowsSettings>
+  </asmv3:application>
 </assembly>
--- vim72.orig/src/hardcopy.c
+++ vim72/src/hardcopy.c
@@ -440,16 +440,15 @@ prt_get_unit(idx)
 }
 
 /*
  * Print the page header.
  */
-/*ARGSUSED*/
     static void
 prt_header(psettings, pagenum, lnum)
     prt_settings_T  *psettings;
     int		pagenum;
-    linenr_T	lnum;
+    linenr_T	lnum UNUSED;
 {
     int		width = psettings->chars_per_line;
     int		page_line;
     char_u	*tbuf;
     char_u	*p;
@@ -1879,11 +1878,11 @@ prt_next_dsc(p_dsc_line)
     /* DSC comments always start %% */
     if (prt_resfile_strncmp(0, "%%", 2) != 0)
 	return FALSE;
 
     /* Find type of DSC comment */
-    for (comment = 0; comment < NUM_ELEMENTS(prt_dsc_table); comment++)
+    for (comment = 0; comment < (int)NUM_ELEMENTS(prt_dsc_table); comment++)
 	if (prt_resfile_strncmp(0, prt_dsc_table[comment].string,
 					    prt_dsc_table[comment].len) == 0)
 	    break;
 
     if (comment != NUM_ELEMENTS(prt_dsc_table))
@@ -2452,16 +2451,15 @@ prt_match_charset(p_charset, p_cmap, pp_
     }
     return FALSE;
 }
 #endif
 
-/*ARGSUSED*/
     int
 mch_print_init(psettings, jobname, forceit)
     prt_settings_T *psettings;
     char_u	*jobname;
-    int		forceit;
+    int		forceit UNUSED;
 {
     int		i;
     char	*paper_name;
     int		paper_strlen;
     int		fontsize;
@@ -2512,11 +2510,11 @@ mch_print_init(psettings, jobname, force
     p_mbenc = NULL;
     props = enc_canon_props(p_encoding);
     if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE)))
     {
 	p_mbenc_first = NULL;
-	for (cmap = 0; cmap < NUM_ELEMENTS(prt_ps_mbfonts); cmap++)
+	for (cmap = 0; cmap < (int)NUM_ELEMENTS(prt_ps_mbfonts); cmap++)
 	    if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap],
 								    &p_mbenc))
 	    {
 		if (p_mbenc_first == NULL)
 		    p_mbenc_first = p_mbenc;
@@ -2640,11 +2638,11 @@ mch_print_init(psettings, jobname, force
     else
     {
 	paper_name = "A4";
 	paper_strlen = 2;
     }
-    for (i = 0; i < PRT_MEDIASIZE_LEN; ++i)
+    for (i = 0; i < (int)PRT_MEDIASIZE_LEN; ++i)
 	if (STRLEN(prt_mediasize[i].name) == (unsigned)paper_strlen
 		&& STRNICMP(prt_mediasize[i].name, paper_name,
 							   paper_strlen) == 0)
 	    break;
     if (i == PRT_MEDIASIZE_LEN)
@@ -3306,14 +3304,13 @@ mch_print_end_page()
     prt_dsc_noarg("PageTrailer");
 
     return !prt_file_error;
 }
 
-/*ARGSUSED*/
     int
 mch_print_begin_page(str)
-    char_u	*str;
+    char_u	*str UNUSED;
 {
     int		page_num[2];
 
     prt_page_num++;
 
@@ -3377,15 +3374,14 @@ mch_print_start_line(margin, page_line)
 #ifdef FEAT_MBYTE
     prt_half_width = FALSE;
 #endif
 }
 
-/*ARGSUSED*/
     int
 mch_print_text_out(p, len)
     char_u	*p;
-    int		len;
+    int		len UNUSED;
 {
     int		need_break;
     char_u	ch;
     char_u      ch_buff[8];
     float       char_width;
--- vim72.orig/src/if_cscope.c
+++ vim72/src/if_cscope.c
@@ -44,11 +44,10 @@ static void	    cs_file_results __ARGS((
 static void	    cs_fill_results __ARGS((char *, int , int *, char ***,
 			char ***, int *));
 static int	    cs_find __ARGS((exarg_T *eap));
 static int	    cs_find_common __ARGS((char *opt, char *pat, int, int, int));
 static int	    cs_help __ARGS((exarg_T *eap));
-static void	    cs_init __ARGS((void));
 static void	    clear_csinfo __ARGS((int i));
 static int	    cs_insert_filelist __ARGS((char *, char *, char *,
 			struct stat *));
 static int	    cs_kill __ARGS((exarg_T *eap));
 static void	    cs_kill_execute __ARGS((int, char *));
@@ -64,52 +63,167 @@ static void	    cs_release_csp __ARGS((i
 static int	    cs_reset __ARGS((exarg_T *eap));
 static char *	    cs_resolve_file __ARGS((int, char *));
 static int	    cs_show __ARGS((exarg_T *eap));
 
 
-static csinfo_T	    csinfo[CSCOPE_MAX_CONNECTIONS];
+static csinfo_T *   csinfo = NULL;
+static int	    csinfo_size = 0;	/* number of items allocated in
+					   csinfo[] */
+
 static int	    eap_arg_len;    /* length of eap->arg, set in
 				       cs_lookup_cmd() */
 static cscmd_T	    cs_cmds[] =
 {
     { "add",	cs_add,
 		N_("Add a new database"),     "add file|dir [pre-path] [flags]", 0 },
     { "find",	cs_find,
-		N_("Query for a pattern"),    FIND_USAGE, 1 },
+		N_("Query for a pattern"),    "find c|d|e|f|g|i|s|t name", 1 },
     { "help",	cs_help,
 		N_("Show this message"),      "help", 0 },
     { "kill",	cs_kill,
 		N_("Kill a connection"),      "kill #", 0 },
     { "reset",	cs_reset,
 		N_("Reinit all connections"), "reset", 0 },
     { "show",	cs_show,
 		N_("Show connections"),       "show", 0 },
-    { NULL }
+    { NULL, NULL, NULL, NULL, 0 }
 };
 
     static void
 cs_usage_msg(x)
     csid_e x;
 {
     (void)EMSG2(_("E560: Usage: cs[cope] %s"), cs_cmds[(int)x].usage);
 }
 
+#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
+
+static enum
+{
+    EXP_CSCOPE_SUBCMD,	/* expand ":cscope" sub-commands */
+    EXP_SCSCOPE_SUBCMD,	/* expand ":scscope" sub-commands */
+    EXP_CSCOPE_FIND,	/* expand ":cscope find" arguments */
+    EXP_CSCOPE_KILL	/* expand ":cscope kill" arguments */
+} expand_what;
+
+/*
+ * Function given to ExpandGeneric() to obtain the cscope command
+ * expansion.
+ */
+    char_u *
+get_cscope_name(xp, idx)
+    expand_T	*xp UNUSED;
+    int		idx;
+{
+    int		current_idx;
+    int		i;
+
+    switch (expand_what)
+    {
+    case EXP_CSCOPE_SUBCMD:
+	/* Complete with sub-commands of ":cscope":
+	 * add, find, help, kill, reset, show */
+	return (char_u *)cs_cmds[idx].name;
+    case EXP_SCSCOPE_SUBCMD:
+	/* Complete with sub-commands of ":scscope": same sub-commands as
+	 * ":cscope" but skip commands which don't support split windows */
+	for (i = 0, current_idx = 0; cs_cmds[i].name != NULL; i++)
+	    if (cs_cmds[i].cansplit)
+		if (current_idx++ == idx)
+		    break;
+	return (char_u *)cs_cmds[i].name;
+    case EXP_CSCOPE_FIND:
+	{
+	    const char *query_type[] =
+	    {
+		"c", "d", "e", "f", "g", "i", "s", "t", NULL
+	    };
+
+	    /* Complete with query type of ":cscope find {query_type}".
+	     * {query_type} can be letters (c, d, ... t) or numbers (0, 1,
+	     * ..., 8) but only complete with letters, since numbers are
+	     * redundant. */
+	    return (char_u *)query_type[idx];
+	}
+    case EXP_CSCOPE_KILL:
+	{
+	    static char	connection[5];
+
+	    /* ":cscope kill" accepts connection numbers or partial names of
+	     * the pathname of the cscope database as argument.  Only complete
+	     * with connection numbers. -1 can also be used to kill all
+	     * connections. */
+	    for (i = 0, current_idx = 0; i < csinfo_size; i++)
+	    {
+		if (csinfo[i].fname == NULL)
+		    continue;
+		if (current_idx++ == idx)
+		{
+		    vim_snprintf(connection, sizeof(connection), "%d", i);
+		    return (char_u *)connection;
+		}
+	    }
+	    return (current_idx == idx && idx > 0) ? (char_u *)"-1" : NULL;
+	}
+    default:
+	return NULL;
+    }
+}
+
+/*
+ * Handle command line completion for :cscope command.
+ */
+    void
+set_context_in_cscope_cmd(xp, arg, cmdidx)
+    expand_T	*xp;
+    char_u	*arg;
+    cmdidx_T	cmdidx;
+{
+    char_u	*p;
+
+    /* Default: expand subcommands */
+    xp->xp_context = EXPAND_CSCOPE;
+    xp->xp_pattern = arg;
+    expand_what = (cmdidx == CMD_scscope)
+			? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD;
+
+    /* (part of) subcommand already typed */
+    if (*arg != NUL)
+    {
+	p = skiptowhite(arg);
+	if (*p != NUL)		    /* past first word */
+	{
+	    xp->xp_pattern = skipwhite(p);
+	    if (*skiptowhite(xp->xp_pattern) != NUL)
+		xp->xp_context = EXPAND_NOTHING;
+	    else if (STRNICMP(arg, "add", p - arg) == 0)
+		xp->xp_context = EXPAND_FILES;
+	    else if (STRNICMP(arg, "kill", p - arg) == 0)
+		expand_what = EXP_CSCOPE_KILL;
+	    else if (STRNICMP(arg, "find", p - arg) == 0)
+		expand_what = EXP_CSCOPE_FIND;
+	    else
+		xp->xp_context = EXPAND_NOTHING;
+	}
+    }
+}
+
+#endif /* FEAT_CMDL_COMPL */
+
 /*
  * PRIVATE: do_cscope_general
  *
- * find the command, print help if invalid, and the then call the
- * corresponding command function,
- * called from do_cscope and do_scscope
+ * Find the command, print help if invalid, and then call the corresponding
+ * command function.
  */
     static void
 do_cscope_general(eap, make_split)
     exarg_T	*eap;
     int		make_split; /* whether to split window */
 {
     cscmd_T *cmdp;
 
-    cs_init();
     if ((cmdp = cs_lookup_cmd(eap)) == NULL)
     {
 	cs_help(eap);
 	return;
     }
@@ -166,12 +280,10 @@ do_scscope(eap)
 do_cstag(eap)
     exarg_T *eap;
 {
     int ret = FALSE;
 
-    cs_init();
-
     if (*eap->arg == NUL)
     {
 	(void)EMSG(_("E562: Usage: cstag <ident>"));
 	return;
     }
@@ -323,11 +435,11 @@ cs_connection(num, dbpath, ppath)
     int i;
 
     if (num < 0 || num > 4 || (num > 0 && !dbpath))
 	return FALSE;
 
-    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+    for (i = 0; i < csinfo_size; i++)
     {
 	if (!csinfo[i].fname)
 	    continue;
 
 	if (num == 0)
@@ -377,14 +489,13 @@ cs_connection(num, dbpath, ppath)
  * add cscope database or a directory name (to look for cscope.out)
  * to the cscope connection list
  *
  * MAXPATHL 256
  */
-/* ARGSUSED */
     static int
 cs_add(eap)
-    exarg_T *eap;
+    exarg_T *eap UNUSED;
 {
     char *fname, *ppath, *flags = NULL;
 
     if ((fname = strtok((char *)NULL, (const char *)" ")) == NULL)
     {
@@ -567,11 +678,11 @@ cs_check_for_tags()
 cs_cnt_connections()
 {
     short i;
     short cnt = 0;
 
-    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+    for (i = 0; i < csinfo_size; i++)
     {
 	if (csinfo[i].fname != NULL)
 	    cnt++;
     }
     return cnt;
@@ -657,10 +768,11 @@ cs_create_cmd(csoption, pattern)
     char *csoption;
     char *pattern;
 {
     char *cmd;
     short search;
+    char *pat;
 
     switch (csoption[0])
     {
     case '0' : case 's' :
 	search = 0;
@@ -690,14 +802,21 @@ cs_create_cmd(csoption, pattern)
 	(void)EMSG(_("E561: unknown cscope search type"));
 	cs_usage_msg(Find);
 	return NULL;
     }
 
-    if ((cmd = (char *)alloc((unsigned)(strlen(pattern) + 2))) == NULL)
+    /* Skip white space before the patter, except for text and pattern search,
+     * they may want to use the leading white space. */
+    pat = pattern;
+    if (search != 4 && search != 6)
+	while vim_iswhite(*pat)
+	    ++pat;
+
+    if ((cmd = (char *)alloc((unsigned)(strlen(pat) + 2))) == NULL)
 	return NULL;
 
-    (void)sprintf(cmd, "%d%s", search, pattern);
+    (void)sprintf(cmd, "%d%s", search, pat);
 
     return cmd;
 } /* cs_create_cmd */
 
 
@@ -867,11 +986,11 @@ err_closing:
 	vim_free(prog);
 # endif
 	vim_free(ppath);
 
 #if defined(UNIX)
-	if (execl("/bin/sh", "sh", "-c", cmd, NULL) == -1)
+	if (execl("/bin/sh", "sh", "-c", cmd, (char *)NULL) == -1)
 	    PERROR(_("cs_create_connection exec failed"));
 
 	exit(127);
 	/* NOTREACHED */
     default:	/* parent. */
@@ -987,28 +1106,33 @@ cs_find_common(opt, pat, forceit, verbos
     int verbose;
     int	use_ll;
 {
     int i;
     char *cmd;
-    int nummatches[CSCOPE_MAX_CONNECTIONS], totmatches;
+    int *nummatches;
+    int totmatches;
 #ifdef FEAT_QUICKFIX
     char cmdletter;
     char *qfpos;
 #endif
 
     /* create the actual command to send to cscope */
     cmd = cs_create_cmd(opt, pat);
     if (cmd == NULL)
 	return FALSE;
 
+    nummatches = (int *)alloc(sizeof(int)*csinfo_size);
+    if (nummatches == NULL)
+	return FALSE;
+
     /* send query to all open connections, then count the total number
      * of matches so we can alloc matchesp all in one swell foop
      */
-    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+    for (i = 0; i < csinfo_size; i++)
 	nummatches[i] = 0;
     totmatches = 0;
-    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+    for (i = 0; i < csinfo_size; i++)
     {
 	if (csinfo[i].fname == NULL || csinfo[i].to_fp == NULL)
 	    continue;
 
 	/* send cmd to cscope */
@@ -1029,21 +1153,25 @@ cs_find_common(opt, pat, forceit, verbos
     {
 	char *nf = _("E259: no matches found for cscope query %s of %s");
 	char *buf;
 
 	if (!verbose)
+	{
+	    vim_free(nummatches);
 	    return FALSE;
+	}
 
 	buf = (char *)alloc((unsigned)(strlen(opt) + strlen(pat) + strlen(nf)));
 	if (buf == NULL)
 	    (void)EMSG(nf);
 	else
 	{
 	    sprintf(buf, nf, opt, pat);
 	    (void)EMSG(buf);
 	    vim_free(buf);
 	}
+	vim_free(nummatches);
 	return FALSE;
     }
 
 #ifdef FEAT_QUICKFIX
     /* get cmd letter */
@@ -1092,10 +1220,11 @@ cs_find_common(opt, pat, forceit, verbos
 	    {
 		sprintf(buf, nf, *qfpos, *(qfpos-1));
 		(void)EMSG(buf);
 		vim_free(buf);
 	    }
+	    vim_free(nummatches);
 	    return FALSE;
 	}
     }
     if (qfpos != NULL && *qfpos != '0' && totmatches > 0)
     {
@@ -1139,10 +1268,11 @@ cs_find_common(opt, pat, forceit, verbos
 		qf_jump(qi, 0, 0, forceit);
 	    }
 	}
 	mch_remove(tmp);
 	vim_free(tmp);
+	vim_free(nummatches);
 	return TRUE;
     }
     else
 #endif /* FEAT_QUICKFIX */
     {
@@ -1150,10 +1280,11 @@ cs_find_common(opt, pat, forceit, verbos
 	int matched = 0;
 
 	/* read output */
 	cs_fill_results((char *)pat, totmatches, nummatches, &matches,
 							 &contexts, &matched);
+	vim_free(nummatches);
 	if (matches == NULL)
 	    return FALSE;
 
 	(void)cs_manage_matches(matches, contexts, matched, Store);
 
@@ -1165,52 +1296,48 @@ cs_find_common(opt, pat, forceit, verbos
 /*
  * PRIVATE: cs_help
  *
  * print help
  */
-/* ARGSUSED */
     static int
 cs_help(eap)
-    exarg_T *eap;
+    exarg_T *eap UNUSED;
 {
     cscmd_T *cmdp = cs_cmds;
 
     (void)MSG_PUTS(_("cscope commands:\n"));
     while (cmdp->name != NULL)
     {
-	(void)smsg((char_u *)_("%-5s: %-30s (Usage: %s)"),
-				      cmdp->name, _(cmdp->help), cmdp->usage);
+	char *help = _(cmdp->help);
+	int  space_cnt = 30 - vim_strsize((char_u *)help);
+
+	/* Use %*s rather than %30s to ensure proper alignment in utf-8 */
+	if (space_cnt < 0)
+	    space_cnt = 0;
+	(void)smsg((char_u *)_("%-5s: %s%*s (Usage: %s)"),
+				      cmdp->name,
+				      help, space_cnt, " ",
+				      cmdp->usage);
 	if (strcmp(cmdp->name, "find") == 0)
-	    MSG_PUTS(FIND_HELP);
+	    MSG_PUTS(_("\n"
+		       "       c: Find functions calling this function\n"
+		       "       d: Find functions called by this function\n"
+		       "       e: Find this egrep pattern\n"
+		       "       f: Find this file\n"
+		       "       g: Find this definition\n"
+		       "       i: Find files #including this file\n"
+		       "       s: Find this C symbol\n"
+		       "       t: Find assignments to\n"));
+
 	cmdp++;
     }
 
     wait_return(TRUE);
     return 0;
 } /* cs_help */
 
 
-/*
- * PRIVATE: cs_init
- *
- * initialize cscope structure if not already
- */
-    static void
-cs_init()
-{
-    short i;
-    static int init_already = FALSE;
-
-    if (init_already)
-	return;
-
-    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
-	clear_csinfo(i);
-
-    init_already = TRUE;
-} /* cs_init */
-
     static void
 clear_csinfo(i)
     int	    i;
 {
     csinfo[i].fname  = NULL;
@@ -1255,17 +1382,16 @@ GetWin32Error()
 /*
  * PRIVATE: cs_insert_filelist
  *
  * insert a new cscope database filename into the filelist
  */
-/*ARGSUSED*/
     static int
 cs_insert_filelist(fname, ppath, flags, sb)
     char *fname;
     char *ppath;
     char *flags;
-    struct stat *sb;
+    struct stat *sb UNUSED;
 {
     short	i, j;
 #ifndef UNIX
     HANDLE	hFile;
     BY_HANDLE_FILE_INFORMATION bhfi;
@@ -1304,11 +1430,11 @@ cs_insert_filelist(fname, ppath, flags,
 	CloseHandle(hFile);
     }
 #endif
 
     i = -1; /* can be set to the index of an empty item in csinfo */
-    for (j = 0; j < CSCOPE_MAX_CONNECTIONS; j++)
+    for (j = 0; j < csinfo_size; j++)
     {
 	if (csinfo[j].fname != NULL
 #if defined(UNIX)
 	    && csinfo[j].st_dev == sb->st_dev && csinfo[j].st_ino == sb->st_ino
 #else
@@ -1331,13 +1457,29 @@ cs_insert_filelist(fname, ppath, flags,
 	    i = j; /* remember first empty entry */
     }
 
     if (i == -1)
     {
-	if (p_csverbose)
-	    (void)EMSG(_("E569: maximum number of cscope connections reached"));
-	return -1;
+	i = csinfo_size;
+	if (csinfo_size == 0)
+	{
+	    /* First time allocation: allocate only 1 connection. It should
+	     * be enough for most users.  If more is needed, csinfo will be
+	     * reallocated. */
+	    csinfo_size = 1;
+	    csinfo = (csinfo_T *)alloc_clear(sizeof(csinfo_T));
+	}
+	else
+	{
+	    /* Reallocate space for more connections. */
+	    csinfo_size *= 2;
+	    csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size);
+	}
+	if (csinfo == NULL)
+	    return -1;
+	for (j = csinfo_size/2; j < csinfo_size; j++)
+	    clear_csinfo(j);
     }
 
     if ((csinfo[i].fname = (char *)alloc((unsigned)strlen(fname)+1)) == NULL)
 	return -1;
 
@@ -1417,14 +1559,13 @@ cs_lookup_cmd(eap)
 /*
  * PRIVATE: cs_kill
  *
  * nuke em
  */
-/* ARGSUSED */
     static int
 cs_kill(eap)
-    exarg_T *eap;
+    exarg_T *eap UNUSED;
 {
     char *stok;
     short i;
 
     if ((stok = strtok((char *)NULL, (const char *)" ")) == NULL)
@@ -1441,28 +1582,27 @@ cs_kill(eap)
     else
     {
 	/* It must be part of a name.  We will try to find a match
 	 * within all the names in the csinfo data structure
 	 */
-	for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+	for (i = 0; i < csinfo_size; i++)
 	{
 	    if (csinfo[i].fname != NULL && strstr(csinfo[i].fname, stok))
 		break;
 	}
     }
 
-    if ((i >= CSCOPE_MAX_CONNECTIONS || i < -1 || csinfo[i].fname == NULL)
-	    && i != -1)
+    if ((i != -1) && (i >= csinfo_size || i < -1 || csinfo[i].fname == NULL))
     {
 	if (p_csverbose)
 	    (void)EMSG2(_("E261: cscope connection %s not found"), stok);
     }
     else
     {
 	if (i == -1)
 	{
-	    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+	    for (i = 0; i < csinfo_size; i++)
 	    {
 		if (csinfo[i].fname)
 		    cs_kill_execute(i, csinfo[i].fname);
 	    }
 	}
@@ -1718,11 +1858,11 @@ cs_file_results(f, nummatches_a)
 
     buf = (char *)alloc(CSREAD_BUFSIZE);
     if (buf == NULL)
 	return;
 
-    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+    for (i = 0; i < csinfo_size; i++)
     {
 	if (nummatches_a[i] < 1)
 	    continue;
 
 	for (j = 0; j < nummatches_a[i]; j++)
@@ -1790,11 +1930,11 @@ cs_fill_results(tagstr, totmatches, numm
     if ((matches = (char **)alloc(sizeof(char *) * totmatches)) == NULL)
 	goto parse_out;
     if ((cntxts = (char **)alloc(sizeof(char *) * totmatches)) == NULL)
 	goto parse_out;
 
-    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+    for (i = 0; i < csinfo_size; i++)
     {
 	if (nummatches_a[i] < 1)
 	    continue;
 
 	for (j = 0; j < nummatches_a[i]; j++)
@@ -1927,11 +2067,11 @@ cs_print_tags_priv(matches, cntxts, num_
 	 */
 	if ((tbuf = (char *)alloc((unsigned)strlen(matches[idx]) + 1)) == NULL)
 	    continue;
 	(void)strcpy(tbuf, matches[idx]);
 
-	if ((fname = strtok(tbuf, (const char *)"\t")) == NULL)
+	if (strtok(tbuf, (const char *)"\t") == NULL)
 	    continue;
 	if ((fname = strtok(NULL, (const char *)"\t")) == NULL)
 	    continue;
 	if ((lno = strtok(NULL, (const char *)"\t")) == NULL)
 	    continue;
@@ -2097,11 +2237,10 @@ cs_read_prompt(i)
 
 #if defined(UNIX) && defined(SIGALRM)
 /*
  * Used to catch and ignore SIGALRM below.
  */
-/* ARGSUSED */
     static RETSIGTYPE
 sig_handler SIGDEFARG(sigarg)
 {
     /* do nothing */
     SIGRETURN;
@@ -2137,11 +2276,15 @@ cs_release_csp(i, freefnpp)
 	struct sigaction sa, old;
 
 	/* Use sigaction() to limit the waiting time to two seconds. */
 	sigemptyset(&sa.sa_mask);
 	sa.sa_handler = sig_handler;
+#  ifdef SA_NODEFER
 	sa.sa_flags = SA_NODEFER;
+#  else
+	sa.sa_flags = 0;
+#  endif
 	sigaction(SIGALRM, &sa, &old);
 	alarm(2); /* 2 sec timeout */
 
 	/* Block until cscope exits or until timer expires */
 	pid = waitpid(csinfo[i].pid, &pstat, 0);
@@ -2237,42 +2380,44 @@ cs_release_csp(i, freefnpp)
 /*
  * PRIVATE: cs_reset
  *
  * calls cs_kill on all cscope connections then reinits
  */
-/* ARGSUSED */
     static int
 cs_reset(eap)
-    exarg_T *eap;
+    exarg_T *eap UNUSED;
 {
     char	**dblist = NULL, **pplist = NULL, **fllist = NULL;
     int	i;
     char buf[20]; /* for sprintf " (#%d)" */
 
+    if (csinfo_size == 0)
+	return CSCOPE_SUCCESS;
+
     /* malloc our db and ppath list */
-    dblist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
-    pplist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
-    fllist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *));
+    dblist = (char **)alloc(csinfo_size * sizeof(char *));
+    pplist = (char **)alloc(csinfo_size * sizeof(char *));
+    fllist = (char **)alloc(csinfo_size * sizeof(char *));
     if (dblist == NULL || pplist == NULL || fllist == NULL)
     {
 	vim_free(dblist);
 	vim_free(pplist);
 	vim_free(fllist);
 	return CSCOPE_FAILURE;
     }
 
-    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+    for (i = 0; i < csinfo_size; i++)
     {
 	dblist[i] = csinfo[i].fname;
 	pplist[i] = csinfo[i].ppath;
 	fllist[i] = csinfo[i].flags;
 	if (csinfo[i].fname != NULL)
 	    cs_release_csp(i, FALSE);
     }
 
     /* rebuild the cscope connection list */
-    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+    for (i = 0; i < csinfo_size; i++)
     {
 	if (dblist[i] != NULL)
 	{
 	    cs_add_common(dblist[i], pplist[i], fllist[i]);
 	    if (p_csverbose)
@@ -2353,24 +2498,23 @@ cs_resolve_file(i, name)
 /*
  * PRIVATE: cs_show
  *
  * show all cscope connections
  */
-/* ARGSUSED */
     static int
 cs_show(eap)
-    exarg_T *eap;
+    exarg_T *eap UNUSED;
 {
     short i;
     if (cs_cnt_connections() == 0)
 	MSG_PUTS(_("no cscope connections\n"));
     else
     {
 	MSG_PUTS_ATTR(
 	    _(" # pid    database name                       prepend path\n"),
 	    hl_attr(HLF_T));
-	for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+	for (i = 0; i < csinfo_size; i++)
 	{
 	    if (csinfo[i].fname == NULL)
 		continue;
 
 	    if (csinfo[i].ppath != NULL)
@@ -2395,12 +2539,14 @@ cs_show(eap)
     void
 cs_end()
 {
     int i;
 
-    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
+    for (i = 0; i < csinfo_size; i++)
 	cs_release_csp(i, TRUE);
+    vim_free(csinfo);
+    csinfo_size = 0;
 }
 
 #endif	/* FEAT_CSCOPE */
 
 /* the end */
--- vim72.orig/src/if_cscope.h
+++ vim72/src/if_cscope.h
@@ -23,11 +23,10 @@
 # endif
 #endif
 
 #define CSCOPE_SUCCESS		0
 #define CSCOPE_FAILURE		-1
-#define CSCOPE_MAX_CONNECTIONS	8   /* you actually need more? */
 
 #define	CSCOPE_DBFILE		"cscope.out"
 #define	CSCOPE_PROMPT		">> "
 
 /*
@@ -40,21 +39,10 @@
  *   5pattern	change pattern -- NOT USED
  * e 6pattern	Find this egrep pattern
  * f 7name	Find this file
  * i 8name	Find files #including this file
  */
-#define	FIND_USAGE "find c|d|e|f|g|i|s|t name"
-#define FIND_HELP "\n\
-       c: Find functions calling this function\n\
-       d: Find functions called by this function\n\
-       e: Find this egrep pattern\n\
-       f: Find this file\n\
-       g: Find this definition\n\
-       i: Find files #including this file\n\
-       s: Find this C symbol\n\
-       t: Find assignments to\n"
-
 
 typedef struct {
     char *  name;
     int     (*func) __ARGS((exarg_T *eap));
     char *  help;
--- vim72.orig/src/if_mzsch.c
+++ vim72/src/if_mzsch.c
@@ -2,10 +2,12 @@
  *
  * MzScheme interface by Sergey Khorev <sergey.khorev@gmail.com>
  * Original work by Brent Fulgham <bfulgham@debian.org>
  * (Based on lots of help from Matthew Flatt)
  *
+ * TODO Convert byte-strings to char strings?
+ *
  * This consists of six parts:
  * 1. MzScheme interpreter main program
  * 2. Routines that handle the external interface between MzScheme and
  *    Vim.
  * 3. MzScheme input/output handlers: writes output via [e]msg().
@@ -16,37 +18,38 @@
  * NOTES
  * 1. Memory, allocated with scheme_malloc*, need not to be freed explicitly,
  *    garbage collector will do it self
  * 2. Requires at least NORMAL features. I can't imagine why one may want
  *    to build with SMALL or TINY features but with MzScheme interface.
- * 3. I don't use K&R-style functions. Anyway, MzScheme headers are ANSI.
+ * 3. I don't use K&R-style functions. Anyways, MzScheme headers are ANSI.
  */
 
 #include "vim.h"
 
 #include "if_mzsch.h"
 
 /* Only do the following when the feature is enabled.  Needed for "make
  * depend". */
 #if defined(FEAT_MZSCHEME) || defined(PROTO)
 
+#include <assert.h>
+
 /* Base data structures */
 #define SCHEME_VIMBUFFERP(obj)  SAME_TYPE(SCHEME_TYPE(obj), mz_buffer_type)
 #define SCHEME_VIMWINDOWP(obj)  SAME_TYPE(SCHEME_TYPE(obj), mz_window_type)
 
 typedef struct
 {
-    Scheme_Type	    tag;
-    Scheme_Env	    *env;
+    Scheme_Object   so;
     buf_T	    *buf;
 } vim_mz_buffer;
 
 #define INVALID_BUFFER_VALUE ((buf_T *)(-1))
 
 typedef struct
 {
-    Scheme_Type	    tag;
+    Scheme_Object   so;
     win_T	    *win;
 } vim_mz_window;
 
 #define INVALID_WINDOW_VALUE ((win_T *)(-1))
 
@@ -65,31 +68,10 @@ typedef struct
 {
     char	    *name;
     Scheme_Object   *port;
 } Port_Info;
 
-/* info for closed prim */
-/*
- * data have different means:
- * for do_eval it is char*
- * for do_apply is Apply_Onfo*
- * for do_load is Port_Info*
- */
-typedef struct
-{
-    void	*data;
-    Scheme_Env	*env;
-} Cmd_Info;
-
-/* info for do_apply */
-typedef struct
-{
-    Scheme_Object   *proc;
-    int		    argc;
-    Scheme_Object   **argv;
-} Apply_Info;
-
 /*
  *========================================================================
  *  Vim-Control Commands
  *========================================================================
  */
@@ -120,11 +102,10 @@ static Scheme_Object *mzscheme_open_buff
 static Scheme_Object *set_buffer_line(void *, int, Scheme_Object **);
 static Scheme_Object *set_buffer_line_list(void *, int, Scheme_Object **);
 static Scheme_Object *insert_buffer_line_list(void *, int, Scheme_Object **);
 static Scheme_Object *get_range_start(void *, int, Scheme_Object **);
 static Scheme_Object *get_range_end(void *, int, Scheme_Object **);
-static Scheme_Object *get_buffer_namespace(void *, int, Scheme_Object **);
 static vim_mz_buffer *get_vim_curr_buffer(void);
 
 /*  Window-related commands */
 static Scheme_Object *window_new(win_T *win);
 static Scheme_Object *get_curr_win(void *, int, Scheme_Object **);
@@ -161,34 +142,66 @@ static Scheme_Object *vim_window_validp(
  */
 static int vim_error_check(void);
 static int do_mzscheme_command(exarg_T *, void *, Scheme_Closed_Prim *what);
 static void startup_mzscheme(void);
 static char *string_to_line(Scheme_Object *obj);
-static int mzscheme_io_init(void);
-static void mzscheme_interface_init(vim_mz_buffer *self);
 static void do_output(char *mesg, long len);
 static void do_printf(char *format, ...);
 static void do_flush(void);
 static Scheme_Object *_apply_thunk_catch_exceptions(
 	Scheme_Object *, Scheme_Object **);
 static Scheme_Object *extract_exn_message(Scheme_Object *v);
 static Scheme_Object *do_eval(void *, int noargc, Scheme_Object **noargv);
 static Scheme_Object *do_load(void *, int noargc, Scheme_Object **noargv);
-static Scheme_Object *do_apply(void *, int noargc, Scheme_Object **noargv);
-static void register_vim_exn(Scheme_Env *env);
+static void register_vim_exn(void);
 static vim_mz_buffer *get_buffer_arg(const char *fname, int argnum,
 	int argc, Scheme_Object **argv);
 static vim_mz_window *get_window_arg(const char *fname, int argnum,
 	int argc, Scheme_Object **argv);
-static void add_vim_exn(Scheme_Env *env);
 static int line_in_range(linenr_T, buf_T *);
 static void check_line_range(linenr_T, buf_T *);
 static void mz_fix_cursor(int lo, int hi, int extra);
 
-static int eval_in_namespace(void *, Scheme_Closed_Prim *, Scheme_Env *,
-		Scheme_Object **ret);
-static void make_modules(Scheme_Env *);
+static int eval_with_exn_handling(void *, Scheme_Closed_Prim *,
+	    Scheme_Object **ret);
+static void make_modules(void);
+static void init_exn_catching_apply(void);
+static int mzscheme_env_main(Scheme_Env *env, int argc, char **argv);
+static int mzscheme_init(void);
+#ifdef FEAT_EVAL
+static Scheme_Object *vim_to_mzscheme(typval_T *vim_value, int depth,
+	Scheme_Hash_Table *visited);
+static int mzscheme_to_vim(Scheme_Object *obj, typval_T *tv, int depth,
+	Scheme_Hash_Table *visited);
+#endif
+
+#ifdef MZ_PRECISE_GC
+static int buffer_size_proc(void *obj)
+{
+    return gcBYTES_TO_WORDS(sizeof(vim_mz_buffer));
+}
+static int buffer_mark_proc(void *obj)
+{
+    return buffer_size_proc(obj);
+}
+static int buffer_fixup_proc(void *obj)
+{
+    return buffer_size_proc(obj);
+}
+static int window_size_proc(void *obj)
+{
+    return gcBYTES_TO_WORDS(sizeof(vim_mz_window));
+}
+static int window_mark_proc(void *obj)
+{
+    return window_size_proc(obj);
+}
+static int window_fixup_proc(void *obj)
+{
+    return window_size_proc(obj);
+}
+#endif
 
 #ifdef DYNAMIC_MZSCHEME
 
 static Scheme_Object *dll_scheme_eof;
 static Scheme_Object *dll_scheme_false;
@@ -258,12 +271,10 @@ static Scheme_Object *(*dll_scheme_looku
 	Scheme_Env *env);
 static Scheme_Object *(*dll_scheme_make_closed_prim_w_arity)
     (Scheme_Closed_Prim *prim, void *data, const char *name, mzshort mina,
      mzshort maxa);
 static Scheme_Object *(*dll_scheme_make_integer_value)(long i);
-static Scheme_Object *(*dll_scheme_make_namespace)(int argc,
-	Scheme_Object *argv[]);
 static Scheme_Object *(*dll_scheme_make_pair)(Scheme_Object *car,
 	Scheme_Object *cdr);
 static Scheme_Object *(*dll_scheme_make_prim_w_arity)(Scheme_Prim *prim,
 	const char *name, mzshort mina, mzshort maxa);
 # if MZSCHEME_VERSION_MAJOR < 299
@@ -309,10 +320,21 @@ static Scheme_Config *(*dll_scheme_curre
 static Scheme_Object *(*dll_scheme_char_string_to_byte_string)
     (Scheme_Object *s);
 static Scheme_Object *(*dll_scheme_char_string_to_path)
     (Scheme_Object *s);
 # endif
+static Scheme_Hash_Table *(*dll_scheme_make_hash_table)(int type);
+static void (*dll_scheme_hash_set)(Scheme_Hash_Table *table,
+	Scheme_Object *key, Scheme_Object *value);
+static Scheme_Object *(*dll_scheme_hash_get)(Scheme_Hash_Table *table,
+	Scheme_Object *key);
+static Scheme_Object *(*dll_scheme_make_double)(double d);
+# ifdef INCLUDE_MZSCHEME_BASE
+static Scheme_Object *(*dll_scheme_make_sized_byte_string)(char *chars,
+	long len, int copy);
+static Scheme_Object *(*dll_scheme_namespace_require)(Scheme_Object *req);
+# endif
 
 /* arrays are imported directly */
 # define scheme_eof dll_scheme_eof
 # define scheme_false dll_scheme_false
 # define scheme_void dll_scheme_void
@@ -366,11 +388,10 @@ static Scheme_Object *(*dll_scheme_char_
 # endif
 # define scheme_intern_symbol dll_scheme_intern_symbol
 # define scheme_lookup_global dll_scheme_lookup_global
 # define scheme_make_closed_prim_w_arity dll_scheme_make_closed_prim_w_arity
 # define scheme_make_integer_value dll_scheme_make_integer_value
-# define scheme_make_namespace dll_scheme_make_namespace
 # define scheme_make_pair dll_scheme_make_pair
 # define scheme_make_prim_w_arity dll_scheme_make_prim_w_arity
 # if MZSCHEME_VERSION_MAJOR < 299
 #  define scheme_make_string dll_scheme_make_string
 #  define scheme_make_string_output_port dll_scheme_make_string_output_port
@@ -401,10 +422,18 @@ static Scheme_Object *(*dll_scheme_char_
 #  define scheme_char_string_to_byte_string \
     dll_scheme_char_string_to_byte_string
 #  define scheme_char_string_to_path \
     dll_scheme_char_string_to_path
 # endif
+# define scheme_make_hash_table dll_scheme_make_hash_table
+# define scheme_hash_set dll_scheme_hash_set
+# define scheme_hash_get dll_scheme_hash_get
+# define scheme_make_double dll_scheme_make_double
+# ifdef INCLUDE_MZSCHEME_BASE
+#  define scheme_make_sized_byte_string dll_scheme_make_sized_byte_string
+#  define scheme_namespace_require dll_scheme_namespace_require
+# endif
 
 typedef struct
 {
     char    *name;
     void    **ptr;
@@ -466,11 +495,10 @@ static Thunk_Info mzsch_imports[] = {
     {"scheme_intern_symbol", (void **)&dll_scheme_intern_symbol},
     {"scheme_lookup_global", (void **)&dll_scheme_lookup_global},
     {"scheme_make_closed_prim_w_arity",
 	(void **)&dll_scheme_make_closed_prim_w_arity},
     {"scheme_make_integer_value", (void **)&dll_scheme_make_integer_value},
-    {"scheme_make_namespace", (void **)&dll_scheme_make_namespace},
     {"scheme_make_pair", (void **)&dll_scheme_make_pair},
     {"scheme_make_prim_w_arity", (void **)&dll_scheme_make_prim_w_arity},
 # if MZSCHEME_VERSION_MAJOR < 299
     {"scheme_make_string", (void **)&dll_scheme_make_string},
     {"scheme_make_string_output_port",
@@ -500,13 +528,20 @@ static Thunk_Info mzsch_imports[] = {
 # if MZSCHEME_VERSION_MAJOR >= 299
     {"scheme_set_param", (void **)&dll_scheme_set_param},
     {"scheme_current_config", (void **)&dll_scheme_current_config},
     {"scheme_char_string_to_byte_string",
 	(void **)&dll_scheme_char_string_to_byte_string},
-    {"scheme_char_string_to_path",
-	(void **)&dll_scheme_char_string_to_path},
+    {"scheme_char_string_to_path", (void **)&dll_scheme_char_string_to_path},
 # endif
+    {"scheme_make_hash_table", (void **)&dll_scheme_make_hash_table},
+    {"scheme_hash_set", (void **)&dll_scheme_hash_set},
+    {"scheme_hash_get", (void **)&dll_scheme_hash_get},
+    {"scheme_make_double", (void **)&dll_scheme_make_double},
+# ifdef INCLUDE_MZSCHEME_BASE
+    {"scheme_make_sized_byte_string", (void **)&dll_scheme_make_sized_byte_string},
+    {"scheme_namespace_require", (void **)&dll_scheme_namespace_require},
+#endif
     {NULL, NULL}};
 
 static HINSTANCE hMzGC = 0;
 static HINSTANCE hMzSch = 0;
 
@@ -590,34 +625,42 @@ dynamic_mzscheme_end(void)
 	hMzGC = 0;
     }
 }
 #endif /* DYNAMIC_MZSCHEME */
 
+/* need to put it here for dynamic stuff to work */
+#if defined(INCLUDE_MZSCHEME_BASE)
+# include "mzscheme_base.c"
+#elif MZSCHEME_VERSION_MAJOR >= 400
+# error MzScheme 4.x must include mzscheme_base.c, for MinGW32 you need to define MZSCHEME_GENERATE_BASE=yes
+#endif
+
 /*
  *========================================================================
  *  1. MzScheme interpreter startup
  *========================================================================
  */
 
 static Scheme_Type mz_buffer_type;
 static Scheme_Type mz_window_type;
 
-static int initialized = 0;
+static int initialized = FALSE;
 
 /* global environment */
 static Scheme_Env    *environment = NULL;
 /* output/error handlers */
 static Scheme_Object *curout = NULL;
 static Scheme_Object *curerr = NULL;
-/* vim:exn exception */
+/* exn:vim exception */
 static Scheme_Object *exn_catching_apply = NULL;
 static Scheme_Object *exn_p = NULL;
 static Scheme_Object *exn_message = NULL;
 static Scheme_Object *vim_exn = NULL; /* Vim Error exception */
- /* values for exn:vim - constructor, predicate, accessors etc */
-static Scheme_Object *vim_exn_names = NULL;
-static Scheme_Object *vim_exn_values = NULL;
+
+#if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400
+static void *stack_base = NULL;
+#endif
 
 static long range_start;
 static long range_end;
 
 /* MzScheme threads scheduling stuff */
@@ -665,15 +708,13 @@ static void remove_timer(void);
 /* timers are presented in GUI only */
 # if defined(FEAT_GUI_W32)
     static void CALLBACK
 timer_proc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
 # elif defined(FEAT_GUI_GTK)
-/*ARGSUSED*/
     static gint
 timer_proc(gpointer data)
 # elif defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
-/* ARGSUSED */
     static void
 timer_proc(XtPointer timed_out, XtIntervalId *interval_id)
 # elif defined(FEAT_GUI_MAC)
     pascal void
 timer_proc(EventLoopTimerRef theTimer, void *userData)
@@ -751,203 +792,333 @@ mzscheme_end(void)
 #ifdef DYNAMIC_MZSCHEME
     dynamic_mzscheme_end();
 #endif
 }
 
+    void
+mzscheme_main(void)
+{
+#if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR >= 400
+    /* use trampoline for precise GC in MzScheme >= 4.x */
+    scheme_main_setup(TRUE, mzscheme_env_main, 0, NULL);
+#else
+    mzscheme_env_main(NULL, 0, NULL);
+#endif
+}
+
+    static int
+mzscheme_env_main(Scheme_Env *env, int argc, char **argv)
+{
+    /* neither argument nor return values are used */
+#ifdef MZ_PRECISE_GC
+# if MZSCHEME_VERSION_MAJOR < 400
+    /*
+     * Starting from version 4.x, embedding applications must use
+     * scheme_main_setup/scheme_main_stack_setup trampolines
+     * rather than setting stack base directly with scheme_set_stack_base
+     */
+    Scheme_Object   *dummy = NULL;
+    MZ_GC_DECL_REG(1);
+    MZ_GC_VAR_IN_REG(0, dummy);
+
+    stack_base = &__gc_var_stack__;
+# else
+    /* environment has been created by us by Scheme */
+    environment = env;
+# endif
+    /*
+     * In 4.x, all activities must be performed inside trampoline
+     * so we are forced to initialise GC immediately
+     * This can be postponed in 3.x but I see no point in implementing
+     * a feature which will work in older versions only.
+     * One would better use conservative GC if he needs dynamic MzScheme
+     */
+    mzscheme_init();
+#else
+    int dummy = 0;
+    stack_base = (void *)&dummy;
+#endif
+    main_loop(FALSE, FALSE);
+#if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR < 400
+    /* releasing dummy */
+    MZ_GC_REG();
+    MZ_GC_UNREG();
+#endif
+    return 0;
+}
+
     static void
 startup_mzscheme(void)
 {
-    Scheme_Object *proc_make_security_guard;
-
-    scheme_set_stack_base(NULL, 1);
+#if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400
+    scheme_set_stack_base(stack_base, 1);
+#endif
 
     MZ_REGISTER_STATIC(environment);
     MZ_REGISTER_STATIC(curout);
     MZ_REGISTER_STATIC(curerr);
     MZ_REGISTER_STATIC(exn_catching_apply);
     MZ_REGISTER_STATIC(exn_p);
     MZ_REGISTER_STATIC(exn_message);
     MZ_REGISTER_STATIC(vim_exn);
-    MZ_REGISTER_STATIC(vim_exn_names);
-    MZ_REGISTER_STATIC(vim_exn_values);
 
+#if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400
+    /* in newer versions of precise GC the initial env has been created */
     environment = scheme_basic_env();
+#endif
+    MZ_GC_CHECK();
+
+#ifdef INCLUDE_MZSCHEME_BASE
+    {
+	/*
+	 * versions 4.x do not provide Scheme bindings by default
+	 * we need to add them explicitly
+	 */
+	Scheme_Object *scheme_base_symbol = NULL;
+	MZ_GC_DECL_REG(1);
+	MZ_GC_VAR_IN_REG(0, scheme_base_symbol);
+	MZ_GC_REG();
+	/* invoke function from generated and included mzscheme_base.c */
+	declare_modules(environment);
+	scheme_base_symbol = scheme_intern_symbol("scheme/base");
+	MZ_GC_CHECK();
+	scheme_namespace_require(scheme_base_symbol);
+	MZ_GC_CHECK();
+	MZ_GC_UNREG();
+    }
+#endif
+    register_vim_exn();
+    /* use new environment to initialise exception handling */
+    init_exn_catching_apply();
 
     /* redirect output */
     scheme_console_output = do_output;
     scheme_console_printf = do_printf;
 
 #ifdef MZSCHEME_COLLECTS
     /* setup 'current-library-collection-paths' parameter */
-    scheme_set_param(scheme_config, MZCONFIG_COLLECTION_PATHS,
-	    scheme_make_pair(
 # if MZSCHEME_VERSION_MAJOR >= 299
-		scheme_char_string_to_path(
-		    scheme_byte_string_to_char_string(
-			scheme_make_byte_string(MZSCHEME_COLLECTS))),
+    {
+	Scheme_Object	*coll_byte_string = NULL;
+	Scheme_Object	*coll_char_string = NULL;
+	Scheme_Object	*coll_path = NULL;
+	Scheme_Object	*coll_pair = NULL;
+	Scheme_Config	*config = NULL;
+
+	MZ_GC_DECL_REG(5);
+	MZ_GC_VAR_IN_REG(0, coll_byte_string);
+	MZ_GC_VAR_IN_REG(1, coll_char_string);
+	MZ_GC_VAR_IN_REG(2, coll_path);
+	MZ_GC_VAR_IN_REG(3, coll_pair);
+	MZ_GC_VAR_IN_REG(4, config);
+	MZ_GC_REG();
+	coll_byte_string = scheme_make_byte_string(MZSCHEME_COLLECTS);
+	MZ_GC_CHECK();
+	coll_char_string = scheme_byte_string_to_char_string(coll_byte_string);
+	MZ_GC_CHECK();
+	coll_path = scheme_char_string_to_path(coll_char_string);
+	MZ_GC_CHECK();
+	coll_pair = scheme_make_pair(coll_path, scheme_null);
+	MZ_GC_CHECK();
+	config = scheme_config;
+	MZ_GC_CHECK();
+	scheme_set_param(config, MZCONFIG_COLLECTION_PATHS, coll_pair);
+	MZ_GC_CHECK();
+	MZ_GC_UNREG();
+    }
 # else
-		scheme_make_string(MZSCHEME_COLLECTS),
+    {
+	Scheme_Object	*coll_string = NULL;
+	Scheme_Object	*coll_pair = NULL;
+	Scheme_Config	*config = NULL;
+
+	MZ_GC_DECL_REG(3);
+	MZ_GC_VAR_IN_REG(0, coll_string);
+	MZ_GC_VAR_IN_REG(1, coll_pair);
+	MZ_GC_VAR_IN_REG(2, config);
+	MZ_GC_REG();
+	coll_string = scheme_make_string(MZSCHEME_COLLECTS);
+	MZ_GC_CHECK();
+	coll_pair = scheme_make_pair(coll_string, scheme_null);
+	MZ_GC_CHECK();
+	config = scheme_config;
+	MZ_GC_CHECK();
+	scheme_set_param(config, MZCONFIG_COLLECTION_PATHS, coll_pair);
+	MZ_GC_CHECK();
+	MZ_GC_UNREG();
+    }
 # endif
-		scheme_null));
 #endif
 #ifdef HAVE_SANDBOX
-    /* setup sandbox guards */
-    proc_make_security_guard = scheme_lookup_global(
-	    scheme_intern_symbol("make-security-guard"),
-	    environment);
-    if (proc_make_security_guard != NULL)
-    {
-	Scheme_Object *args[3];
-	Scheme_Object *guard;
-	args[0] = scheme_get_param(scheme_config, MZCONFIG_SECURITY_GUARD);
-	args[1] = scheme_make_prim_w_arity(sandbox_file_guard,
-		"sandbox-file-guard", 3, 3);
-	args[2] = scheme_make_prim_w_arity(sandbox_network_guard,
-		"sandbox-network-guard", 4, 4);
-	guard = scheme_apply(proc_make_security_guard, 3, args);
-	scheme_set_param(scheme_config, MZCONFIG_SECURITY_GUARD, guard);
+    {
+	Scheme_Object	*make_security_guard = NULL;
+	MZ_GC_DECL_REG(1);
+	MZ_GC_VAR_IN_REG(0, make_security_guard);
+	MZ_GC_REG();
+
+#if MZSCHEME_VERSION_MAJOR < 400
+	{
+	    Scheme_Object	*make_security_guard_symbol = NULL;
+	    MZ_GC_DECL_REG(1);
+	    MZ_GC_VAR_IN_REG(0, make_security_guard_symbol);
+	    MZ_GC_REG();
+	    make_security_guard_symbol = scheme_intern_symbol("make-security-guard");
+	    MZ_GC_CHECK();
+	    make_security_guard = scheme_lookup_global(
+		    make_security_guard_symbol, environment);
+	    MZ_GC_UNREG();
+	}
+#else
+	make_security_guard = scheme_builtin_value("make-security-guard");
+	MZ_GC_CHECK();
+#endif
+
+	/* setup sandbox guards */
+	if (make_security_guard != NULL)
+	{
+	    Scheme_Object   *args[3] = {NULL, NULL, NULL};
+	    Scheme_Object   *guard = NULL;
+	    Scheme_Config   *config = NULL;
+	    MZ_GC_DECL_REG(5);
+	    MZ_GC_ARRAY_VAR_IN_REG(0, args, 3);
+	    MZ_GC_VAR_IN_REG(3, guard);
+	    MZ_GC_VAR_IN_REG(4, config);
+	    MZ_GC_REG();
+	    config = scheme_config;
+	    MZ_GC_CHECK();
+	    args[0] = scheme_get_param(config, MZCONFIG_SECURITY_GUARD);
+	    MZ_GC_CHECK();
+	    args[1] = scheme_make_prim_w_arity(sandbox_file_guard,
+		    "sandbox-file-guard", 3, 3);
+	    args[2] = scheme_make_prim_w_arity(sandbox_network_guard,
+		    "sandbox-network-guard", 4, 4);
+	    guard = scheme_apply(make_security_guard, 3, args);
+	    MZ_GC_CHECK();
+	    scheme_set_param(config, MZCONFIG_SECURITY_GUARD, guard);
+	    MZ_GC_CHECK();
+	    MZ_GC_UNREG();
+	}
+	MZ_GC_UNREG();
     }
 #endif
     /* Create buffer and window types for use in Scheme code */
     mz_buffer_type = scheme_make_type("<vim-buffer>");
+    MZ_GC_CHECK();
     mz_window_type = scheme_make_type("<vim-window>");
+    MZ_GC_CHECK();
+#ifdef MZ_PRECISE_GC
+    GC_register_traversers(mz_buffer_type,
+	    buffer_size_proc, buffer_mark_proc, buffer_fixup_proc,
+	    TRUE, TRUE);
+    GC_register_traversers(mz_window_type,
+	    window_size_proc, window_mark_proc, window_fixup_proc,
+	    TRUE, TRUE);
+#endif
 
-    register_vim_exn(environment);
-    make_modules(environment);
+    make_modules();
 
     /*
      * setup callback to receive notifications
      * whether thread scheduling is (or not) required
      */
     scheme_notify_multithread = notify_multithread;
-    initialized = 1;
 }
 
 /*
  * This routine is called for each new invocation of MzScheme
  * to make sure things are properly initialized.
  */
     static int
 mzscheme_init(void)
 {
-    int do_require = FALSE;
-
     if (!initialized)
     {
-	do_require = TRUE;
 #ifdef DYNAMIC_MZSCHEME
 	if (!mzscheme_enabled(TRUE))
 	{
-	    EMSG(_("???: Sorry, this command is disabled, the MzScheme library could not be loaded."));
+	    EMSG(_("E815: Sorry, this command is disabled, the MzScheme libraries could not be loaded."));
 	    return -1;
 	}
 #endif
 	startup_mzscheme();
-
-	if (mzscheme_io_init())
-	    return -1;
-
-    }
-    /* recreate ports each call effectivelly clearing these ones */
-    curout = scheme_make_string_output_port();
-    curerr = scheme_make_string_output_port();
-    scheme_set_param(scheme_config, MZCONFIG_OUTPUT_PORT, curout);
-    scheme_set_param(scheme_config, MZCONFIG_ERROR_PORT, curerr);
-
-    if (do_require)
-    {
-	/* auto-instantiate in basic env */
-	eval_in_namespace("(require (prefix vimext: vimext))", do_eval,
-		environment, NULL);
+	initialized = TRUE;
     }
-
-    return 0;
-}
-
-/*
- * This routine fills the namespace with various important routines that can
- * be used within MzScheme.
- */
-    static void
-mzscheme_interface_init(vim_mz_buffer *mzbuff)
-{
-    Scheme_Object   *attach;
-
-    mzbuff->env = (Scheme_Env *)scheme_make_namespace(0, NULL);
-
-    /*
-     * attach instantiated modules from global namespace
-     * so they can be easily instantiated in the buffer namespace
-     */
-    attach = scheme_lookup_global(
-	    scheme_intern_symbol("namespace-attach-module"),
-	    environment);
-
-    if (attach != NULL)
     {
-	Scheme_Object   *ret;
-	Scheme_Object	*args[2];
-
-	args[0] = (Scheme_Object *)environment;
-	args[1] = scheme_intern_symbol("vimext");
-
-	ret = (Scheme_Object *)mzvim_apply(attach, 2, args);
+	Scheme_Config	*config = NULL;
+	MZ_GC_DECL_REG(1);
+	MZ_GC_VAR_IN_REG(0, config);
+	MZ_GC_REG();
+	config = scheme_config;
+	MZ_GC_CHECK();
+	/* recreate ports each call effectively clearing these ones */
+	curout = scheme_make_string_output_port();
+	MZ_GC_CHECK();
+	curerr = scheme_make_string_output_port();
+	MZ_GC_CHECK();
+	scheme_set_param(config, MZCONFIG_OUTPUT_PORT, curout);
+	MZ_GC_CHECK();
+	scheme_set_param(config, MZCONFIG_ERROR_PORT, curerr);
+	MZ_GC_CHECK();
+	MZ_GC_UNREG();
     }
 
-    add_vim_exn(mzbuff->env);
+    return 0;
 }
 
 /*
  *========================================================================
  *  2.  External Interface
  *========================================================================
  */
 
 /*
- * Evaluate command in namespace with exception handling
+ * Evaluate command with exception handling
  */
     static int
-eval_in_namespace(void *data, Scheme_Closed_Prim *what, Scheme_Env *env,
-		Scheme_Object **ret)
+eval_with_exn_handling(void *data, Scheme_Closed_Prim *what, Scheme_Object **ret)
 {
-    Scheme_Object   *value;
-    Scheme_Object   *exn;
-    Cmd_Info	    info;   /* closure info */
-
-    info.data = data;
-    info.env = env;
-
-    scheme_set_param(scheme_config, MZCONFIG_ENV,
-	    (Scheme_Object *) env);
-    /*
-     * ensure all evaluations will be in current buffer namespace,
-     * the second argument to scheme_eval_string isn't enough!
-     */
-    value = _apply_thunk_catch_exceptions(
-	    scheme_make_closed_prim_w_arity(what, &info, "mzvim", 0, 0),
-	    &exn);
+    Scheme_Object   *value = NULL;
+    Scheme_Object   *exn = NULL;
+    Scheme_Object   *prim = NULL;
+
+    MZ_GC_DECL_REG(3);
+    MZ_GC_VAR_IN_REG(0, value);
+    MZ_GC_VAR_IN_REG(1, exn);
+    MZ_GC_VAR_IN_REG(2, prim);
+    MZ_GC_REG();
+
+    prim = scheme_make_closed_prim_w_arity(what, data, "mzvim", 0, 0);
+    MZ_GC_CHECK();
+    value = _apply_thunk_catch_exceptions(prim, &exn);
+    MZ_GC_CHECK();
 
     if (!value)
     {
 	value = extract_exn_message(exn);
 	/* Got an exn? */
 	if (value)
 	{
-	    scheme_display(value, curerr);  /*  Send to stderr-vim */
+	    scheme_display(value, curerr);   /*  Send to stderr-vim */
+	    MZ_GC_CHECK();
 	    do_flush();
 	}
+	MZ_GC_UNREG();
 	/* `raise' was called on some arbitrary value */
 	return FAIL;
     }
 
     if (ret != NULL)	/* if pointer to retval supported give it up */
 	*ret = value;
     /* Print any result, as long as it's not a void */
     else if (!SCHEME_VOIDP(value))
+    {
 	scheme_display(value, curout);  /* Send to stdout-vim */
+	MZ_GC_CHECK();
+    }
 
     do_flush();
+    MZ_GC_UNREG();
     return OK;
 }
 
 /* :mzscheme */
     static int
@@ -957,11 +1128,11 @@ do_mzscheme_command(exarg_T *eap, void *
 	return FAIL;
 
     range_start = eap->line1;
     range_end = eap->line2;
 
-    return eval_in_namespace(data, what, get_vim_curr_buffer()->env, NULL);
+    return eval_with_exn_handling(data, what, NULL);
 }
 
 /*
  * Routine called by VIM when deleting a buffer
  */
@@ -974,10 +1145,11 @@ mzscheme_buffer_free(buf_T *buf)
 
 	bp = buf->b_mzscheme_ref;
 	bp->buf = INVALID_BUFFER_VALUE;
 	buf->b_mzscheme_ref = NULL;
 	scheme_gc_ptr_ok(bp);
+	MZ_GC_CHECK();
     }
 }
 
 /*
  * Routine called by VIM when deleting a Window
@@ -990,10 +1162,11 @@ mzscheme_window_free(win_T *win)
 	vim_mz_window *wp;
 	wp = win->w_mzscheme_ref;
 	wp->win = INVALID_WINDOW_VALUE;
 	win->w_mzscheme_ref = NULL;
 	scheme_gc_ptr_ok(wp);
+	MZ_GC_CHECK();
     }
 }
 
 /*
  * ":mzscheme" (or ":mz")
@@ -1014,80 +1187,67 @@ ex_mzscheme(exarg_T *eap)
 	    vim_free(script);
 	}
     }
 }
 
-/* eval MzScheme string */
-    void *
-mzvim_eval_string(char_u *str)
-{
-    Scheme_Object *ret = NULL;
-    if (mzscheme_init())
-	return FAIL;
-
-    eval_in_namespace(str, do_eval, get_vim_curr_buffer()->env, &ret);
-    return ret;
-}
-
-/*
- * apply MzScheme procedure with arguments,
- * handling errors
- */
-    Scheme_Object *
-mzvim_apply(Scheme_Object *proc, int argc, Scheme_Object **argv)
-{
-    Apply_Info	data;
-    Scheme_Object *ret = NULL;
-
-    if (mzscheme_init())
-	return FAIL;
-
-    data.proc = proc;
-    data.argc = argc;
-    data.argv = argv;
-
-    eval_in_namespace(&data, do_apply, get_vim_curr_buffer()->env, &ret);
-    return ret;
-}
-
     static Scheme_Object *
 do_load(void *data, int noargc, Scheme_Object **noargv)
 {
-    Cmd_Info	    *info = (Cmd_Info *)data;
-    Scheme_Object   *result = scheme_void;
-    Scheme_Object   *expr;
-    char_u	    *file = scheme_malloc_fail_ok(
-					  scheme_malloc_atomic, MAXPATHL + 1);
-    Port_Info	    *pinfo = (Port_Info *)(info->data);
+    Scheme_Object   *expr = NULL;
+    Scheme_Object   *result = NULL;
+    char	    *file = NULL;
+    Port_Info	    *pinfo = (Port_Info *)data;
+
+    MZ_GC_DECL_REG(3);
+    MZ_GC_VAR_IN_REG(0, expr);
+    MZ_GC_VAR_IN_REG(1, result);
+    MZ_GC_VAR_IN_REG(2, file);
+    MZ_GC_REG();
+
+    file = (char *)scheme_malloc_fail_ok(scheme_malloc_atomic, MAXPATHL + 1);
+    MZ_GC_CHECK();
 
     /* make Vim expansion */
-    expand_env((char_u *)pinfo->name, file, MAXPATHL);
-    /* scheme_load looks strange working with namespaces and error handling*/
+    expand_env((char_u *)pinfo->name, (char_u *)file, MAXPATHL);
     pinfo->port = scheme_open_input_file(file, "mzfile");
-    scheme_count_lines(pinfo->port); /* to get accurate read error location*/
+    MZ_GC_CHECK();
+    scheme_count_lines(pinfo->port);  /* to get accurate read error location*/
+    MZ_GC_CHECK();
 
     /* Like REPL but print only last result */
     while (!SCHEME_EOFP(expr = scheme_read(pinfo->port)))
-	result = scheme_eval(expr, info->env);
+    {
+	result = scheme_eval(expr, environment);
+	MZ_GC_CHECK();
+    }
 
-    /* errors will be caught in do_mzscheme_comamnd and ex_mzfile */
+    /* errors will be caught in do_mzscheme_command and ex_mzfile */
     scheme_close_input_port(pinfo->port);
+    MZ_GC_CHECK();
     pinfo->port = NULL;
+    MZ_GC_UNREG();
     return result;
 }
 
 /* :mzfile */
     void
 ex_mzfile(exarg_T *eap)
 {
-    Port_Info	pinfo;
+    Port_Info	pinfo = {NULL, NULL};
+
+    MZ_GC_DECL_REG(1);
+    MZ_GC_VAR_IN_REG(0, pinfo.port);
+    MZ_GC_REG();
 
     pinfo.name = (char *)eap->arg;
-    pinfo.port = NULL;
     if (do_mzscheme_command(eap, &pinfo, do_load) != OK
 	    && pinfo.port != NULL)	/* looks like port was not closed */
+    {
 	scheme_close_input_port(pinfo.port);
+	MZ_GC_CHECK();
+    }
+    MZ_GC_UNREG();
 }
 
 
 /*
  *========================================================================
@@ -1103,18 +1263,16 @@ init_exn_catching_apply(void)
 	char *e =
 	    "(lambda (thunk) "
 		"(with-handlers ([void (lambda (exn) (cons #f exn))]) "
 		"(cons #t (thunk))))";
 
-	/* make sure we have a namespace with the standard syntax: */
-	Scheme_Env *env = (Scheme_Env *)scheme_make_namespace(0, NULL);
-	add_vim_exn(env);
-
-	exn_catching_apply = scheme_eval_string(e, env);
-	exn_p = scheme_lookup_global(scheme_intern_symbol("exn?"), env);
-	exn_message = scheme_lookup_global(
-		scheme_intern_symbol("exn-message"), env);
+	exn_catching_apply = scheme_eval_string(e, environment);
+	MZ_GC_CHECK();
+	exn_p = scheme_builtin_value("exn?");
+	MZ_GC_CHECK();
+	exn_message = scheme_builtin_value("exn-message");
+	MZ_GC_CHECK();
     }
 }
 
 /*
  * This function applies a thunk, returning the Scheme value if there's
@@ -1124,12 +1282,10 @@ init_exn_catching_apply(void)
     static Scheme_Object *
 _apply_thunk_catch_exceptions(Scheme_Object *f, Scheme_Object **exn)
 {
     Scheme_Object *v;
 
-    init_exn_catching_apply();
-
     v = _scheme_apply(exn_catching_apply, 1, &f);
     /* v is a pair: (cons #t value) or (cons #f exn) */
 
     if (SCHEME_TRUEP(SCHEME_CAR(v)))
 	return SCHEME_CDR(v);
@@ -1141,32 +1297,20 @@ _apply_thunk_catch_exceptions(Scheme_Obj
 }
 
     static Scheme_Object *
 extract_exn_message(Scheme_Object *v)
 {
-    init_exn_catching_apply();
-
     if (SCHEME_TRUEP(_scheme_apply(exn_p, 1, &v)))
 	return _scheme_apply(exn_message, 1, &v);
     else
 	return NULL; /* Not an exn structure */
 }
 
     static Scheme_Object *
 do_eval(void *s, int noargc, Scheme_Object **noargv)
 {
-    Cmd_Info	*info = (Cmd_Info *)s;
-
-    return scheme_eval_string_all((char *)(info->data), info->env, TRUE);
-}
-
-    static Scheme_Object *
-do_apply(void *a, int noargc, Scheme_Object **noargv)
-{
-    Apply_Info	*info = (Apply_Info *)(((Cmd_Info *)a)->data);
-
-    return scheme_apply(info->proc, info->argc, info->argv);
+    return scheme_eval_string_all((char *)s, environment, TRUE);
 }
 
 /*
  *========================================================================
  *  3.  MzScheme I/O Handlers
@@ -1219,28 +1363,23 @@ do_flush(void)
 {
     char *buff;
     long length;
 
     buff = scheme_get_sized_string_output(curerr, &length);
+    MZ_GC_CHECK();
     if (length)
     {
 	do_err_output(buff, length);
 	return;
     }
 
     buff = scheme_get_sized_string_output(curout, &length);
+    MZ_GC_CHECK();
     if (length)
 	do_output(buff, length);
 }
 
-    static int
-mzscheme_io_init(void)
-{
-    /* Nothing needed so far... */
-    return 0;
-}
-
 /*
  *========================================================================
  *  4. Implementation of the Vim Features for MzScheme
  *========================================================================
  */
@@ -1263,26 +1402,34 @@ vim_command(void *data, int argc, Scheme
 /* (eval {expr-string}) */
     static Scheme_Object *
 vim_eval(void *data, int argc, Scheme_Object **argv)
 {
 #ifdef FEAT_EVAL
-    Vim_Prim	    *prim = (Vim_Prim *)data;
-    char	    *expr;
-    char	    *str;
-    Scheme_Object   *result;
+    Vim_Prim		*prim = (Vim_Prim *)data;
+    char		*expr;
+    Scheme_Object	*result;
+    /* hash table to store visited values to avoid infinite loops */
+    Scheme_Hash_Table	*visited = NULL;
+    typval_T		*vim_result;
+
+    MZ_GC_DECL_REG(1);
+    MZ_GC_VAR_IN_REG(0, visited);
+    MZ_GC_REG();
 
-    expr = SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
+    visited = scheme_make_hash_table(SCHEME_hash_ptr);
+    MZ_GC_CHECK();
 
-    str = (char *)eval_to_string((char_u *)expr, NULL, TRUE);
+    expr = SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
+    vim_result = eval_expr((char_u *)expr, NULL);
 
-    if (str == NULL)
+    if (vim_result == NULL)
 	raise_vim_exn(_("invalid expression"));
 
-    result = scheme_make_string(str);
-
-    vim_free(str);
+    result = vim_to_mzscheme(vim_result, 1, visited);
+    free_tv(vim_result);
 
+    MZ_GC_UNREG();
     return result;
 #else
     raise_vim_exn(_("expressions disabled at compile time"));
     /* unreachable */
     return scheme_false;
@@ -1318,11 +1465,11 @@ static Scheme_Object *M_global = NULL;
 get_option(void *data, int argc, Scheme_Object **argv)
 {
     Vim_Prim	    *prim = (Vim_Prim *)data;
     char_u	    *name;
     long	    value;
-    char_u	    *strval;
+    char	    *strval;
     int		    rc;
     Scheme_Object   *rval;
     int		    opt_flags = 0;
     buf_T	    *save_curb = curbuf;
     win_T	    *save_curw = curwin;
@@ -1333,10 +1480,11 @@ get_option(void *data, int argc, Scheme_
     {
 	if (M_global == NULL)
 	{
 	    MZ_REGISTER_STATIC(M_global);
 	    M_global = scheme_intern_symbol("global");
+	    MZ_GC_CHECK();
 	}
 
 	if (argv[1] == M_global)
 	    opt_flags = OPT_GLOBAL;
 	else if (SCHEME_VIMBUFFERP(argv[1]))
@@ -1354,20 +1502,21 @@ get_option(void *data, int argc, Scheme_
 	}
 	else
 	    scheme_wrong_type(prim->name, "vim-buffer/window", 1, argc, argv);
     }
 
-    rc = get_option_value(name, &value, &strval, opt_flags);
+    rc = get_option_value(name, &value, (char_u **)&strval, opt_flags);
     curbuf = save_curb;
     curwin = save_curw;
 
     switch (rc)
     {
     case 1:
 	return scheme_make_integer_value(value);
     case 0:
 	rval = scheme_make_string(strval);
+	MZ_GC_CHECK();
 	vim_free(strval);
 	return rval;
     case -1:
     case -2:
 	raise_vim_exn(_("hidden option"));
@@ -1393,10 +1542,11 @@ set_option(void *data, int argc, Scheme_
     {
 	if (M_global == NULL)
 	{
 	    MZ_REGISTER_STATIC(M_global);
 	    M_global = scheme_intern_symbol("global");
+	    MZ_GC_CHECK();
 	}
 
 	if (argv[1] == M_global)
 	    opt_flags = OPT_GLOBAL;
 	else if (SCHEME_VIMBUFFERP(argv[1]))
@@ -1463,19 +1613,26 @@ get_window_list(void *data, int argc, Sc
     buf = get_buffer_arg(prim->name, 0, argc, argv);
     list = scheme_null;
 
     for (w = firstwin; w != NULL; w = w->w_next)
 	if (w->w_buffer == buf->buf)
+	{
 	    list = scheme_make_pair(window_new(w), list);
+	    MZ_GC_CHECK();
+	}
 
     return list;
 }
 
     static Scheme_Object *
 window_new(win_T *win)
 {
-    vim_mz_window *self;
+    vim_mz_window *self = NULL;
+
+    MZ_GC_DECL_REG(1);
+    MZ_GC_VAR_IN_REG(0, self);
+    MZ_GC_REG();
 
     /* We need to handle deletion of windows underneath us.
      * If we add a "w_mzscheme_ref" field to the win_T structure,
      * then we can get at it in win_free() in vim.
      *
@@ -1485,17 +1642,18 @@ window_new(win_T *win)
      */
     if (win->w_mzscheme_ref != NULL)
 	return win->w_mzscheme_ref;
 
     self = scheme_malloc_fail_ok(scheme_malloc, sizeof(vim_mz_window));
-
     vim_memset(self, 0, sizeof(vim_mz_window));
     scheme_dont_gc_ptr(self);	/* because win isn't visible to GC */
+    MZ_GC_CHECK();
     win->w_mzscheme_ref = self;
     self->win = win;
-    self->tag = mz_window_type;
+    self->so.type = mz_window_type;
 
+    MZ_GC_UNREG();
     return (Scheme_Object *)(self);
 }
 
 /* (get-win-num [window]) */
     static Scheme_Object *
@@ -1660,27 +1818,26 @@ set_cursor(void *data, int argc, Scheme_
     return scheme_void;
 }
 /*
  *===========================================================================
  *  6. Vim Buffer-related Manipulation Functions
- *     Note that each buffer should have its own private namespace.
  *===========================================================================
  */
 
 /* (open-buff {filename}) */
     static Scheme_Object *
 mzscheme_open_buffer(void *data, int argc, Scheme_Object **argv)
 {
     Vim_Prim	    *prim = (Vim_Prim *)data;
-    char	    *fname;
+    char_u	    *fname;
     int		    num = 0;
     Scheme_Object   *onum;
 
 #ifdef HAVE_SANDBOX
     sandbox_check();
 #endif
-    fname = SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
+    fname = (char_u *)SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
     /* TODO make open existing file */
     num = buflist_add(fname, BLN_LISTED | BLN_CURBUF);
 
     if (num == 0)
 	raise_vim_exn(_("couldn't open buffer"));
@@ -1712,11 +1869,11 @@ get_buffer_by_name(void *data, int argc,
 {
     Vim_Prim	*prim = (Vim_Prim *)data;
     buf_T	*buf;
     char_u	*fname;
 
-    fname = SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
+    fname = (char_u *)SCHEME_STR_VAL(GUARANTEE_STRING(prim->name, 0));
 
     for (buf = firstbuf; buf; buf = buf->b_next)
 	if (buf->b_ffname == NULL || buf->b_sfname == NULL)
 	    /* empty string */
 	{
@@ -1783,11 +1940,11 @@ get_buffer_count(void *data, int argc, S
 get_buffer_name(void *data, int argc, Scheme_Object **argv)
 {
     Vim_Prim	    *prim = (Vim_Prim *)data;
     vim_mz_buffer   *buf = get_buffer_arg(prim->name, 0, argc, argv);
 
-    return scheme_make_string(buf->buf->b_ffname);
+    return scheme_make_string((char *)buf->buf->b_ffname);
 }
 
 /* (curr-buff) */
     static Scheme_Object *
 get_curr_buffer(void *data, int argc, Scheme_Object **argv)
@@ -1796,29 +1953,32 @@ get_curr_buffer(void *data, int argc, Sc
 }
 
     static Scheme_Object *
 buffer_new(buf_T *buf)
 {
-    vim_mz_buffer *self;
+    vim_mz_buffer *self = NULL;
+
+    MZ_GC_DECL_REG(1);
+    MZ_GC_VAR_IN_REG(0, self);
+    MZ_GC_REG();
 
     /* We need to handle deletion of buffers underneath us.
      * If we add a "b_mzscheme_ref" field to the buf_T structure,
      * then we can get at it in buf_freeall() in vim.
      */
     if (buf->b_mzscheme_ref)
 	return buf->b_mzscheme_ref;
 
     self = scheme_malloc_fail_ok(scheme_malloc, sizeof(vim_mz_buffer));
-
     vim_memset(self, 0, sizeof(vim_mz_buffer));
-    scheme_dont_gc_ptr(self);	/* because buf isn't visible to GC */
+    scheme_dont_gc_ptr(self); /* because buf isn't visible to GC */
+    MZ_GC_CHECK();
     buf->b_mzscheme_ref = self;
     self->buf = buf;
-    self->tag = mz_buffer_type;
-
-    mzscheme_interface_init(self);	/* Set up namespace */
+    self->so.type = mz_buffer_type;
 
+    MZ_GC_UNREG();
     return (Scheme_Object *)(self);
 }
 
 /*
  * (get-buff-size [buffer])
@@ -1845,18 +2005,18 @@ get_buffer_size(void *data, int argc, Sc
 get_buffer_line(void *data, int argc, Scheme_Object **argv)
 {
     Vim_Prim	    *prim = (Vim_Prim *)data;
     vim_mz_buffer   *buf;
     int		    linenr;
-    char	    *line;
+    char_u	    *line;
 
     buf = get_buffer_arg(prim->name, 1, argc, argv);
     linenr = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
     line = ml_get_buf(buf->buf, (linenr_T)linenr, FALSE);
 
     raise_if_error();
-    return scheme_make_string(line);
+    return scheme_make_string((char *)line);
 }
 
 
 /*
  * (get-buff-line-list {start} {end} [buffer])
@@ -1869,11 +2029,15 @@ get_buffer_line(void *data, int argc, Sc
 get_buffer_line_list(void *data, int argc, Scheme_Object **argv)
 {
     Vim_Prim	    *prim = (Vim_Prim *)data;
     vim_mz_buffer   *buf;
     int		    i, hi, lo, n;
-    Scheme_Object   *list;
+    Scheme_Object   *list = NULL;
+
+    MZ_GC_DECL_REG(1);
+    MZ_GC_VAR_IN_REG(0, list);
+    MZ_GC_REG();
 
     buf = get_buffer_arg(prim->name, 2, argc, argv);
     list = scheme_null;
     hi = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 1));
     lo = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
@@ -1897,12 +2061,13 @@ get_buffer_line_list(void *data, int arg
 		       (char *)ml_get_buf(buf->buf, (linenr_T)(lo+i), FALSE));
 	raise_if_error();
 
 	/* Set the list item */
 	list = scheme_make_pair(str, list);
+	MZ_GC_CHECK();
     }
-
+    MZ_GC_UNREG();
     return list;
 }
 
 /*
  * (set-buff-line {linenr} {string/#f} [buffer])
@@ -1917,23 +2082,26 @@ get_buffer_line_list(void *data, int arg
  * string changed.
  */
     static Scheme_Object *
 set_buffer_line(void *data, int argc, Scheme_Object **argv)
 {
-    /* First of all, we check the the of the supplied MzScheme object.
+    /* First of all, we check the value of the supplied MzScheme object.
      * There are three cases:
      *	  1. #f - this is a deletion.
      *	  2. A string	   - this is a replacement.
      *	  3. Anything else - this is an error.
      */
     Vim_Prim	    *prim = (Vim_Prim *)data;
     vim_mz_buffer   *buf;
-    Scheme_Object   *line;
+    Scheme_Object   *line = NULL;
     char	    *save;
-    buf_T	    *savebuf;
     int		    n;
 
+    MZ_GC_DECL_REG(1);
+    MZ_GC_VAR_IN_REG(0, line);
+    MZ_GC_REG();
+
 #ifdef HAVE_SANDBOX
     sandbox_check();
 #endif
     n = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
     if (!SCHEME_STRINGP(argv[1]) && !SCHEME_FALSEP(argv[1]))
@@ -1943,11 +2111,12 @@ set_buffer_line(void *data, int argc, Sc
 
     check_line_range(n, buf->buf);
 
     if (SCHEME_FALSEP(line))
     {
-	savebuf = curbuf;
+	buf_T	    *savebuf = curbuf;
+
 	curbuf = buf->buf;
 
 	if (u_savedel((linenr_T)n, 1L) == FAIL)
 	{
 	    curbuf = savebuf;
@@ -1956,43 +2125,66 @@ set_buffer_line(void *data, int argc, Sc
 	else if (ml_delete((linenr_T)n, FALSE) == FAIL)
 	{
 	    curbuf = savebuf;
 	    raise_vim_exn(_("cannot delete line"));
 	}
-	deleted_lines_mark((linenr_T)n, 1L);
 	if (buf->buf == curwin->w_buffer)
 	    mz_fix_cursor(n, n + 1, -1);
+	deleted_lines_mark((linenr_T)n, 1L);
 
 	curbuf = savebuf;
 
+	MZ_GC_UNREG();
 	raise_if_error();
 	return scheme_void;
     }
+    else
+    {
+	/* Otherwise it's a line */
+	buf_T	    *savebuf = curbuf;
 
-    /* Otherwise it's a line */
-    save = string_to_line(line);
-    savebuf = curbuf;
+	save = string_to_line(line);
 
-    curbuf = buf->buf;
+	curbuf = buf->buf;
+
+	if (u_savesub((linenr_T)n) == FAIL)
+	{
+	    curbuf = savebuf;
+	    vim_free(save);
+	    raise_vim_exn(_("cannot save undo information"));
+	}
+	else if (ml_replace((linenr_T)n, (char_u *)save, TRUE) == FAIL)
+	{
+	    curbuf = savebuf;
+	    vim_free(save);
+	    raise_vim_exn(_("cannot replace line"));
+	}
+	else
+	{
+	    vim_free(save);
+	    changed_bytes((linenr_T)n, 0);
+	}
 
-    if (u_savesub((linenr_T)n) == FAIL)
-    {
-	curbuf = savebuf;
-	raise_vim_exn(_("cannot save undo information"));
-    }
-    else if (ml_replace((linenr_T)n, (char_u *)save, TRUE) == FAIL)
-    {
 	curbuf = savebuf;
-	raise_vim_exn(_("cannot replace line"));
-    }
-    else
-	changed_bytes((linenr_T)n, 0);
 
-    curbuf = savebuf;
+	/* Check that the cursor is not beyond the end of the line now. */
+	if (buf->buf == curwin->w_buffer)
+	    check_cursor_col();
 
-    raise_if_error();
-    return scheme_void;
+	MZ_GC_UNREG();
+	raise_if_error();
+	return scheme_void;
+    }
+}
+
+    static void
+free_array(char **array)
+{
+    char **curr = array;
+    while (*curr != NULL)
+	vim_free(*curr++);
+    vim_free(array);
 }
 
 /*
  * (set-buff-line-list {start} {end} {string-list/#f/null} [buffer])
  *
@@ -2013,19 +2205,19 @@ set_buffer_line_list(void *data, int arg
      *	  1. #f - this is a deletion.
      *	  2. A list	   - this is a replacement.
      *	  3. Anything else - this is an error.
      */
     Vim_Prim	    *prim = (Vim_Prim *)data;
-    vim_mz_buffer   *buf;
-    Scheme_Object   *line_list;
-    Scheme_Object   *line;
-    Scheme_Object   *rest;
-    char	    **array;
-    buf_T	    *savebuf;
+    vim_mz_buffer   *buf = NULL;
+    Scheme_Object   *line_list = NULL;
     int		    i, old_len, new_len, hi, lo;
     long	    extra;
 
+    MZ_GC_DECL_REG(1);
+    MZ_GC_VAR_IN_REG(0, line_list);
+    MZ_GC_REG();
+
 #ifdef HAVE_SANDBOX
     sandbox_check();
 #endif
     lo = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 0));
     hi = SCHEME_INT_VAL(GUARANTEE_INTEGER(prim->name, 1));
@@ -2047,11 +2239,11 @@ set_buffer_line_list(void *data, int arg
     check_line_range(lo, buf->buf);	    /* inclusive */
     check_line_range(hi - 1, buf->buf);	    /* exclusive */
 
     if (SCHEME_FALSEP(line_list) || SCHEME_NULLP(line_list))
     {
-	savebuf = curbuf;
+	buf_T	*savebuf = curbuf;
 	curbuf = buf->buf;
 
 	if (u_savedel((linenr_T)lo, (long)old_len) == FAIL)
 	{
 	    curbuf = savebuf;
@@ -2063,115 +2255,138 @@ set_buffer_line_list(void *data, int arg
 		if (ml_delete((linenr_T)lo, FALSE) == FAIL)
 		{
 		    curbuf = savebuf;
 		    raise_vim_exn(_("cannot delete line"));
 		}
-	    deleted_lines_mark((linenr_T)lo, (long)old_len);
 	    if (buf->buf == curwin->w_buffer)
 		mz_fix_cursor(lo, hi, -old_len);
+	    deleted_lines_mark((linenr_T)lo, (long)old_len);
 	}
 
 	curbuf = savebuf;
 
+	MZ_GC_UNREG();
 	raise_if_error();
 	return scheme_void;
     }
+    else
+    {
+	buf_T	*savebuf = curbuf;
 
-    /* List */
-    new_len = scheme_proper_list_length(line_list);
-    if (new_len < 0)	/* improper or cyclic list */
-	scheme_wrong_type(prim->name, "proper list",
-		2, argc, argv);
+	/* List */
+	new_len = scheme_proper_list_length(line_list);
+	MZ_GC_CHECK();
+	if (new_len < 0)	/* improper or cyclic list */
+	    scheme_wrong_type(prim->name, "proper list",
+		    2, argc, argv);
+	else
+	{
+	    char		**array = NULL;
+	    Scheme_Object   *line = NULL;
+	    Scheme_Object   *rest = NULL;
+
+	    MZ_GC_DECL_REG(2);
+	    MZ_GC_VAR_IN_REG(0, line);
+	    MZ_GC_VAR_IN_REG(1, rest);
+	    MZ_GC_REG();
 
-    /* Using MzScheme allocator, so we don't need to free this and
-     * can safely keep pointers to GC collected strings
-     */
-    array = (char **)scheme_malloc_fail_ok(scheme_malloc,
-		(unsigned)(new_len * sizeof(char *)));
+	    array = (char **)alloc(new_len * sizeof(char *));
+	    vim_memset(array, 0, new_len * sizeof(char *));
 
-    rest = line_list;
-    for (i = 0; i < new_len; ++i)
-    {
-	line = SCHEME_CAR(rest);
-	rest = SCHEME_CDR(rest);
-	if (!SCHEME_STRINGP(line))
-	    scheme_wrong_type(prim->name, "string-list", 2, argc, argv);
-	array[i] = string_to_line(line);
-    }
+	    rest = line_list;
+	    for (i = 0; i < new_len; ++i)
+	    {
+		line = SCHEME_CAR(rest);
+		rest = SCHEME_CDR(rest);
+		if (!SCHEME_STRINGP(line))
+		{
+		    free_array(array);
+		    scheme_wrong_type(prim->name, "string-list", 2, argc, argv);
+		}
+		array[i] = string_to_line(line);
+	    }
 
-    savebuf = curbuf;
-    curbuf = buf->buf;
+	    curbuf = buf->buf;
 
-    if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL)
-    {
-	curbuf = savebuf;
-	raise_vim_exn(_("cannot save undo information"));
-    }
+	    if (u_save((linenr_T)(lo-1), (linenr_T)hi) == FAIL)
+	    {
+		curbuf = savebuf;
+		free_array(array);
+		raise_vim_exn(_("cannot save undo information"));
+	    }
 
-    /*
-     * If the size of the range is reducing (ie, new_len < old_len) we
-     * need to delete some old_len. We do this at the start, by
-     * repeatedly deleting line "lo".
-     */
-    for (i = 0; i < old_len - new_len; ++i)
-    {
-	if (ml_delete((linenr_T)lo, FALSE) == FAIL)
-	{
-	    curbuf = savebuf;
-	    raise_vim_exn(_("cannot delete line"));
-	}
-	extra--;
-    }
+	    /*
+	     * If the size of the range is reducing (ie, new_len < old_len) we
+	     * need to delete some old_len. We do this at the start, by
+	     * repeatedly deleting line "lo".
+	     */
+	    for (i = 0; i < old_len - new_len; ++i)
+	    {
+		if (ml_delete((linenr_T)lo, FALSE) == FAIL)
+		{
+		    curbuf = savebuf;
+		    free_array(array);
+		    raise_vim_exn(_("cannot delete line"));
+		}
+		extra--;
+	    }
 
-    /*
-     * For as long as possible, replace the existing old_len with the
-     * new old_len. This is a more efficient operation, as it requires
-     * less memory allocation and freeing.
-     */
-    for (i = 0; i < old_len && i < new_len; i++)
-	if (ml_replace((linenr_T)(lo+i), (char_u *)array[i], TRUE) == FAIL)
-	{
-	    curbuf = savebuf;
-	    raise_vim_exn(_("cannot replace line"));
-	}
+	    /*
+	     * For as long as possible, replace the existing old_len with the
+	     * new old_len. This is a more efficient operation, as it requires
+	     * less memory allocation and freeing.
+	     */
+	    for (i = 0; i < old_len && i < new_len; i++)
+		if (ml_replace((linenr_T)(lo+i), (char_u *)array[i], TRUE) == FAIL)
+		{
+		    curbuf = savebuf;
+		    free_array(array);
+		    raise_vim_exn(_("cannot replace line"));
+		}
 
-    /*
-     * Now we may need to insert the remaining new_len.  We don't need to
-     * free the string passed back because MzScheme has control of that
-     * memory.
-     */
-    while (i < new_len)
-    {
-	if (ml_append((linenr_T)(lo + i - 1),
-		(char_u *)array[i], 0, FALSE) == FAIL)
-	{
-	    curbuf = savebuf;
-	    raise_vim_exn(_("cannot insert line"));
+	    /*
+	     * Now we may need to insert the remaining new_len.  We don't need to
+	     * free the string passed back because MzScheme has control of that
+	     * memory.
+	     */
+	    while (i < new_len)
+	    {
+		if (ml_append((linenr_T)(lo + i - 1),
+			    (char_u *)array[i], 0, FALSE) == FAIL)
+		{
+		    curbuf = savebuf;
+		    free_array(array);
+		    raise_vim_exn(_("cannot insert line"));
+		}
+		++i;
+		++extra;
+	    }
+	    MZ_GC_UNREG();
+	    free_array(array);
 	}
-	++i;
-	++extra;
-    }
 
-    /*
-     * Adjust marks. Invalidate any which lie in the
-     * changed range, and move any in the remainder of the buffer.
-     */
-    mark_adjust((linenr_T)lo, (linenr_T)(hi - 1), (long)MAXLNUM, (long)extra);
-    changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
+	/*
+	 * Adjust marks. Invalidate any which lie in the
+	 * changed range, and move any in the remainder of the buffer.
+	 */
+	mark_adjust((linenr_T)lo, (linenr_T)(hi - 1), (long)MAXLNUM, (long)extra);
+	changed_lines((linenr_T)lo, 0, (linenr_T)hi, (long)extra);
 
-    if (buf->buf == curwin->w_buffer)
-	mz_fix_cursor(lo, hi, extra);
-    curbuf = savebuf;
+	if (buf->buf == curwin->w_buffer)
+	    mz_fix_cursor(lo, hi, extra);
+	curbuf = savebuf;
 
-    raise_if_error();
-    return scheme_void;
+	MZ_GC_UNREG();
+	raise_if_error();
+	return scheme_void;
+    }
 }
 
 /*
  * (insert-buff-line-list {linenr} {string/string-list} [buffer])
  *
- * Insert a number of lines into the specified buffer after the specifed line.
+ * Insert a number of lines into the specified buffer after the specified line.
  * The line number is in Vim format (1-based). The lines to be inserted are
  * given as an MzScheme list of string objects or as a single string. The lines
  * to be added are checked for validity and correct format. Errors are
  * returned as a value of FAIL.  The return value is OK on success.
  * If OK is returned and len_change is not NULL, *len_change
@@ -2179,19 +2394,19 @@ set_buffer_line_list(void *data, int arg
  */
     static Scheme_Object *
 insert_buffer_line_list(void *data, int argc, Scheme_Object **argv)
 {
     Vim_Prim	    *prim = (Vim_Prim *)data;
-    vim_mz_buffer   *buf;
-    Scheme_Object   *list;
-    Scheme_Object   *line;
-    Scheme_Object   *rest;
-    char	    **array;
-    char	    *str;
-    buf_T	    *savebuf;
+    vim_mz_buffer   *buf = NULL;
+    Scheme_Object   *list = NULL;
+    char	    *str = NULL;
     int		    i, n, size;
 
+    MZ_GC_DECL_REG(1);
+    MZ_GC_VAR_IN_REG(0, list);
+    MZ_GC_REG();
+
 #ifdef HAVE_SANDBOX
     sandbox_check();
 #endif
     /*
      * First of all, we check the type of the supplied MzScheme object.
@@ -2206,93 +2421,103 @@ insert_buffer_line_list(void *data, int
 
     if (n != 0)	    /* 0 can be used in insert */
 	check_line_range(n, buf->buf);
     if (SCHEME_STRINGP(list))
     {
-	str = string_to_line(list);
+	buf_T	    *savebuf = curbuf;
 
-	savebuf = curbuf;
+	str = string_to_line(list);
 	curbuf = buf->buf;
 
 	if (u_save((linenr_T)n, (linenr_T)(n+1)) == FAIL)
 	{
 	    curbuf = savebuf;
+	    vim_free(str);
 	    raise_vim_exn(_("cannot save undo information"));
 	}
 	else if (ml_append((linenr_T)n, (char_u *)str, 0, FALSE) == FAIL)
 	{
 	    curbuf = savebuf;
+	    vim_free(str);
 	    raise_vim_exn(_("cannot insert line"));
 	}
 	else
+	{
+	    vim_free(str);
 	    appended_lines_mark((linenr_T)n, 1L);
+	}
 
 	curbuf = savebuf;
 	update_screen(VALID);
 
+	MZ_GC_UNREG();
 	raise_if_error();
 	return scheme_void;
     }
 
     /* List */
     size = scheme_proper_list_length(list);
+    MZ_GC_CHECK();
     if (size < 0)	/* improper or cyclic list */
 	scheme_wrong_type(prim->name, "proper list",
 		2, argc, argv);
-
-    /* Using MzScheme allocator, so we don't need to free this and
-     * can safely keep pointers to GC collected strings
-     */
-    array = (char **)scheme_malloc_fail_ok(
-	    scheme_malloc, (unsigned)(size * sizeof(char *)));
-
-    rest = list;
-    for (i = 0; i < size; ++i)
+    else
     {
-	line = SCHEME_CAR(rest);
-	rest = SCHEME_CDR(rest);
-	array[i] = string_to_line(line);
-    }
+	Scheme_Object   *line = NULL;
+	Scheme_Object   *rest = NULL;
+	char		**array;
+	buf_T		*savebuf = curbuf;
+
+	MZ_GC_DECL_REG(2);
+	MZ_GC_VAR_IN_REG(0, line);
+	MZ_GC_VAR_IN_REG(1, rest);
+	MZ_GC_REG();
 
-    savebuf = curbuf;
-    curbuf = buf->buf;
+	array = (char **)alloc(size * sizeof(char *));
+	vim_memset(array, 0, size * sizeof(char *));
 
-    if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL)
-    {
-	curbuf = savebuf;
-	raise_vim_exn(_("cannot save undo information"));
-    }
-    else
-    {
+	rest = list;
 	for (i = 0; i < size; ++i)
-	    if (ml_append((linenr_T)(n + i), (char_u *)array[i],
-			0, FALSE) == FAIL)
-	    {
-		curbuf = savebuf;
-		raise_vim_exn(_("cannot insert line"));
-	    }
+	{
+	    line = SCHEME_CAR(rest);
+	    rest = SCHEME_CDR(rest);
+	    array[i] = string_to_line(line);
+	}
 
-	if (i > 0)
-	    appended_lines_mark((linenr_T)n, (long)i);
-    }
+	curbuf = buf->buf;
 
-    curbuf = savebuf;
-    update_screen(VALID);
+	if (u_save((linenr_T)n, (linenr_T)(n + 1)) == FAIL)
+	{
+	    curbuf = savebuf;
+	    free_array(array);
+	    raise_vim_exn(_("cannot save undo information"));
+	}
+	else
+	{
+	    for (i = 0; i < size; ++i)
+		if (ml_append((linenr_T)(n + i), (char_u *)array[i],
+			    0, FALSE) == FAIL)
+		{
+		    curbuf = savebuf;
+		    free_array(array);
+		    raise_vim_exn(_("cannot insert line"));
+		}
 
+	    if (i > 0)
+		appended_lines_mark((linenr_T)n, (long)i);
+	}
+	free_array(array);
+	MZ_GC_UNREG();
+	curbuf = savebuf;
+	update_screen(VALID);
+    }
+
+    MZ_GC_UNREG();
     raise_if_error();
     return scheme_void;
 }
 
-/* (get-buff-namespace [buffer]) */
-    static Scheme_Object *
-get_buffer_namespace(void *data, int argc, Scheme_Object **argv)
-{
-    Vim_Prim	*prim = (Vim_Prim *)data;
-
-    return (Scheme_Object *)get_buffer_arg(prim->name, 0, argc, argv)->env;
-}
-
 /*
  * Predicates
  */
 /* (buff? obj) */
     static Scheme_Object *
@@ -2343,44 +2568,395 @@ vim_window_validp(void *data, int argc,
  */
 
 /*
  * Convert an MzScheme string into a Vim line.
  *
- * The result is in allocated memory. All internal nulls are replaced by
- * newline characters. It is an error for the string to contain newline
- * characters.
+ * All internal nulls are replaced by newline characters.
+ * It is an error for the string to contain newline characters.
  *
+ * Returns pointer to Vim allocated memory
  */
     static char *
 string_to_line(Scheme_Object *obj)
 {
-    char	*str;
+    char	*scheme_str = NULL;
+    char	*vim_str = NULL;
     long	len;
     int		i;
 
-    str = scheme_display_to_string(obj, &len);
+    scheme_str = scheme_display_to_string(obj, &len);
 
     /* Error checking: String must not contain newlines, as we
      * are replacing a single line, and we must replace it with
      * a single line.
      */
-    if (memchr(str, '\n', len))
+    if (memchr(scheme_str, '\n', len))
 	scheme_signal_error(_("string cannot contain newlines"));
 
+    vim_str = (char *)alloc(len + 1);
+
     /* Create a copy of the string, with internal nulls replaced by
      * newline characters, as is the vim convention.
      */
     for (i = 0; i < len; ++i)
     {
-	if (str[i] == '\0')
-	    str[i] = '\n';
+	if (scheme_str[i] == '\0')
+	    vim_str[i] = '\n';
+	else
+	    vim_str[i] = scheme_str[i];
+    }
+
+    vim_str[i] = '\0';
+
+    MZ_GC_CHECK();
+    return vim_str;
+}
+
+#ifdef FEAT_EVAL
+/*
+ * Convert Vim value into MzScheme, adopted from if_python.c
+ */
+    static Scheme_Object *
+vim_to_mzscheme(typval_T *vim_value, int depth, Scheme_Hash_Table *visited)
+{
+    Scheme_Object   *result = NULL;
+    int		    new_value = TRUE;
+
+    MZ_GC_DECL_REG(1);
+    MZ_GC_VAR_IN_REG(0, result);
+    MZ_GC_REG();
+
+    /* Avoid infinite recursion */
+    if (depth > 100)
+    {
+	MZ_GC_UNREG();
+	return scheme_void;
+    }
+
+    /* Check if we run into a recursive loop.  The item must be in visited
+     * then and we can use it again.
+     */
+    result = scheme_hash_get(visited, (Scheme_Object *)vim_value);
+    MZ_GC_CHECK();
+    if (result != NULL) /* found, do nothing */
+	new_value = FALSE;
+    else if (vim_value->v_type == VAR_STRING)
+    {
+	result = scheme_make_string((char *)vim_value->vval.v_string);
+	MZ_GC_CHECK();
+    }
+    else if (vim_value->v_type == VAR_NUMBER)
+    {
+	result = scheme_make_integer((long)vim_value->vval.v_number);
+	MZ_GC_CHECK();
+    }
+# ifdef FEAT_FLOAT
+    else if (vim_value->v_type == VAR_FLOAT)
+    {
+	result = scheme_make_double((double)vim_value->vval.v_float);
+	MZ_GC_CHECK();
+    }
+# endif
+    else if (vim_value->v_type == VAR_LIST)
+    {
+	list_T		*list = vim_value->vval.v_list;
+	listitem_T	*curr;
+
+	if (list == NULL || list->lv_first == NULL)
+	    result = scheme_null;
+	else
+	{
+	    Scheme_Object   *obj = NULL;
+
+	    MZ_GC_DECL_REG(1);
+	    MZ_GC_VAR_IN_REG(0, obj);
+	    MZ_GC_REG();
+
+	    curr = list->lv_last;
+	    obj = vim_to_mzscheme(&curr->li_tv, depth + 1, visited);
+	    result = scheme_make_pair(obj, scheme_null);
+	    MZ_GC_CHECK();
+
+	    while (curr != list->lv_first)
+	    {
+		curr = curr->li_prev;
+		obj = vim_to_mzscheme(&curr->li_tv, depth + 1, visited);
+		result = scheme_make_pair(obj, result);
+		MZ_GC_CHECK();
+	    }
+	}
+	MZ_GC_UNREG();
+    }
+    else if (vim_value->v_type == VAR_DICT)
+    {
+	Scheme_Object	  *key = NULL;
+	Scheme_Object	  *obj = NULL;
+
+	MZ_GC_DECL_REG(2);
+	MZ_GC_VAR_IN_REG(0, key);
+	MZ_GC_VAR_IN_REG(1, obj);
+	MZ_GC_REG();
+
+	result = (Scheme_Object *)scheme_make_hash_table(SCHEME_hash_ptr);
+	MZ_GC_CHECK();
+	if (vim_value->vval.v_dict != NULL)
+	{
+	    hashtab_T	*ht = &vim_value->vval.v_dict->dv_hashtab;
+	    long_u	todo = ht->ht_used;
+	    hashitem_T	*hi;
+	    dictitem_T	*di;
+
+	    for (hi = ht->ht_array; todo > 0; ++hi)
+	    {
+		if (!HASHITEM_EMPTY(hi))
+		{
+		    --todo;
+
+		    di = dict_lookup(hi);
+		    obj = vim_to_mzscheme(&di->di_tv, depth + 1, visited);
+		    key = scheme_make_string((char *)hi->hi_key);
+		    MZ_GC_CHECK();
+		    scheme_hash_set((Scheme_Hash_Table *)result, key, obj);
+		    MZ_GC_CHECK();
+		}
+	    }
+	}
+	MZ_GC_UNREG();
+    }
+    else
+    {
+	result = scheme_void;
+	new_value = FALSE;
+    }
+    if (new_value)
+    {
+	scheme_hash_set(visited, (Scheme_Object *)vim_value, result);
+	MZ_GC_CHECK();
+    }
+    MZ_GC_UNREG();
+    return result;
+}
+
+    static int
+mzscheme_to_vim(Scheme_Object *obj, typval_T *tv, int depth,
+	Scheme_Hash_Table *visited)
+{
+    int		status = OK;
+    typval_T	*found;
+    MZ_GC_CHECK();
+    if (depth > 100) /* limit the deepest recursion level */
+    {
+	tv->v_type = VAR_NUMBER;
+	tv->vval.v_number = 0;
+	return FAIL;
+    }
+
+    found = (typval_T *)scheme_hash_get(visited, obj);
+    if (found != NULL)
+	copy_tv(found, tv);
+    else if (SCHEME_VOIDP(obj))
+    {
+	tv->v_type = VAR_NUMBER;
+	tv->vval.v_number = 0;
+    }
+    else if (SCHEME_INTP(obj))
+    {
+	tv->v_type = VAR_NUMBER;
+	tv->vval.v_number = SCHEME_INT_VAL(obj);
+    }
+    else if (SCHEME_BOOLP(obj))
+    {
+	tv->v_type = VAR_NUMBER;
+	tv->vval.v_number = SCHEME_TRUEP(obj);
+    }
+# ifdef FEAT_FLOAT
+    else if (SCHEME_DBLP(obj))
+    {
+	tv->v_type = VAR_FLOAT;
+	tv->vval.v_float = SCHEME_DBL_VAL(obj);
+    }
+# endif
+    else if (SCHEME_STRINGP(obj))
+    {
+	tv->v_type = VAR_STRING;
+	tv->vval.v_string = vim_strsave((char_u *)SCHEME_STR_VAL(obj));
+    }
+    else if (SCHEME_VECTORP(obj) || SCHEME_NULLP(obj)
+	    || SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj))
+    {
+	list_T  *list = list_alloc();
+	if (list == NULL)
+	    status = FAIL;
+	else
+	{
+	    int		    i;
+	    Scheme_Object   *curr = NULL;
+	    Scheme_Object   *cval = NULL;
+	    /* temporary var to hold current element of vectors and pairs */
+	    typval_T	    *v;
+
+	    MZ_GC_DECL_REG(2);
+	    MZ_GC_VAR_IN_REG(0, curr);
+	    MZ_GC_VAR_IN_REG(1, cval);
+	    MZ_GC_REG();
+
+	    tv->v_type = VAR_LIST;
+	    tv->vval.v_list = list;
+	    ++list->lv_refcount;
+
+	    v = (typval_T *)alloc(sizeof(typval_T));
+	    if (v == NULL)
+		status = FAIL;
+	    else
+	    {
+		/* add the value in advance to allow handling of self-referencial
+		 * data structures */
+		typval_T    *visited_tv = (typval_T *)alloc(sizeof(typval_T));
+		copy_tv(tv, visited_tv);
+		scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv);
+
+		if (SCHEME_VECTORP(obj))
+		{
+		    for (i = 0; i < SCHEME_VEC_SIZE(obj); ++i)
+		    {
+			cval = SCHEME_VEC_ELS(obj)[i];
+			status = mzscheme_to_vim(cval, v, depth + 1, visited);
+			if (status == FAIL)
+			    break;
+			status = list_append_tv(list, v);
+			clear_tv(v);
+			if (status == FAIL)
+			    break;
+		    }
+		}
+		else if (SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj))
+		{
+		    for (curr = obj;
+			    SCHEME_PAIRP(curr) || SCHEME_MUTABLE_PAIRP(curr);
+			    curr = SCHEME_CDR(curr))
+		    {
+			cval = SCHEME_CAR(curr);
+			status = mzscheme_to_vim(cval, v, depth + 1, visited);
+			if (status == FAIL)
+			    break;
+			status = list_append_tv(list, v);
+			clear_tv(v);
+			if (status == FAIL)
+			    break;
+		    }
+		    /* impoper list not terminated with null
+		     * need to handle the last element */
+		    if (status == OK && !SCHEME_NULLP(curr))
+		    {
+			status = mzscheme_to_vim(cval, v, depth + 1, visited);
+			if (status == OK)
+			{
+			    status = list_append_tv(list, v);
+			    clear_tv(v);
+			}
+		    }
+		}
+		/* nothing to do for scheme_null */
+		vim_free(v);
+	    }
+	    MZ_GC_UNREG();
+	}
+    }
+    else if (SCHEME_HASHTP(obj))
+    {
+	int		i;
+	dict_T		*dict;
+	Scheme_Object   *key = NULL;
+	Scheme_Object   *val = NULL;
+
+	MZ_GC_DECL_REG(2);
+	MZ_GC_VAR_IN_REG(0, key);
+	MZ_GC_VAR_IN_REG(1, val);
+	MZ_GC_REG();
+
+	dict = dict_alloc();
+	if (dict == NULL)
+	    status = FAIL;
+	else
+	{
+	    typval_T    *visited_tv = (typval_T *)alloc(sizeof(typval_T));
+
+	    tv->v_type = VAR_DICT;
+	    tv->vval.v_dict = dict;
+	    ++dict->dv_refcount;
+
+	    copy_tv(tv, visited_tv);
+	    scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv);
+
+	    for (i = 0; i < ((Scheme_Hash_Table *)obj)->size; ++i)
+	    {
+		if (((Scheme_Hash_Table *) obj)->vals[i] != NULL)
+		{
+		    /* generate item for `diplay'ed Scheme key */
+		    dictitem_T  *item = dictitem_alloc((char_u *)string_to_line(
+				((Scheme_Hash_Table *) obj)->keys[i]));
+		    /* convert Scheme val to Vim and add it to the dict */
+		    if (mzscheme_to_vim(((Scheme_Hash_Table *) obj)->vals[i],
+				    &item->di_tv, depth + 1, visited) == FAIL
+			    || dict_add(dict, item) == FAIL)
+		    {
+			dictitem_free(item);
+			status = FAIL;
+			break;
+		    }
+		}
+
+	    }
+	}
+	MZ_GC_UNREG();
+    }
+    else
+    {
+	/* `display' any other value to string */
+	tv->v_type = VAR_STRING;
+	tv->vval.v_string = (char_u *)string_to_line(obj);
     }
+    return status;
+}
+
+    void
+do_mzeval(char_u *str, typval_T *rettv)
+{
+    int i;
+    Scheme_Object	*ret = NULL;
+    Scheme_Hash_Table	*visited = NULL;
 
-    str[i] = '\0';
+    MZ_GC_DECL_REG(2);
+    MZ_GC_VAR_IN_REG(0, ret);
+    MZ_GC_VAR_IN_REG(0, visited);
+    MZ_GC_REG();
+
+    if (mzscheme_init())
+    {
+	MZ_GC_UNREG();
+	return;
+    }
 
-    return str;
+    MZ_GC_CHECK();
+    visited = scheme_make_hash_table(SCHEME_hash_ptr);
+    MZ_GC_CHECK();
+
+    if (eval_with_exn_handling(str, do_eval, &ret) == OK)
+	mzscheme_to_vim(ret, rettv, 1, visited);
+
+    for (i = 0; i < visited->size; ++i)
+    {
+	/* free up remembered objects */
+	if (visited->vals[i] != NULL)
+	{
+	    free_tv((typval_T *)visited->vals[i]);
+	}
+    }
+
+    MZ_GC_UNREG();
 }
+#endif
 
 /*
  * Check to see whether a Vim error has been reported, or a keyboard
  * interrupt (from vim --> got_int) has been detected.
  */
@@ -2392,82 +2968,119 @@ vim_error_check(void)
 
 /*
  * register Scheme exn:vim
  */
     static void
-register_vim_exn(Scheme_Env *env)
+register_vim_exn(void)
 {
-    Scheme_Object   *exn_name = scheme_intern_symbol("exn:vim");
+    int	nc = 0;
+    int i;
+    Scheme_Object   *struct_exn = NULL;
+    Scheme_Object   *exn_name = NULL;
+
+    MZ_GC_DECL_REG(2);
+    MZ_GC_VAR_IN_REG(0, struct_exn);
+    MZ_GC_VAR_IN_REG(1, exn_name);
+    MZ_GC_REG();
+
+    exn_name = scheme_intern_symbol("exn:vim");
+    MZ_GC_CHECK();
+    struct_exn = scheme_builtin_value("struct:exn");
+    MZ_GC_CHECK();
 
     if (vim_exn == NULL)
 	vim_exn = scheme_make_struct_type(exn_name,
-		scheme_builtin_value("struct:exn"), NULL, 0, 0, NULL, NULL
+		struct_exn, NULL, 0, 0, NULL, NULL
 #if MZSCHEME_VERSION_MAJOR >= 299
 		, NULL
 #endif
 		);
 
-    if (vim_exn_values == NULL)
-    {
-	int	nc = 0;
 
-	Scheme_Object   **exn_names = scheme_make_struct_names(
-		exn_name, scheme_null, 0, &nc);
-	Scheme_Object   **exn_values = scheme_make_struct_values(
-		vim_exn, exn_names, nc, 0);
-
-	vim_exn_names = scheme_make_vector(nc, scheme_false);
-	vim_exn_values = scheme_make_vector(nc, scheme_false);
-	/* remember names and values */
-	mch_memmove(SCHEME_VEC_ELS(vim_exn_names), exn_names,
-		nc * sizeof(Scheme_Object *));
-	mch_memmove(SCHEME_VEC_ELS(vim_exn_values), exn_values,
-		nc * sizeof(Scheme_Object *));
+    {
+	Scheme_Object   **tmp = NULL;
+	Scheme_Object   *exn_names[5] = {NULL, NULL, NULL, NULL, NULL};
+	Scheme_Object   *exn_values[5] = {NULL, NULL, NULL, NULL, NULL};
+	MZ_GC_DECL_REG(6);
+	MZ_GC_ARRAY_VAR_IN_REG(0, exn_names, 5);
+	MZ_GC_ARRAY_VAR_IN_REG(3, exn_values, 5);
+	MZ_GC_REG();
+
+	tmp = scheme_make_struct_names(exn_name, scheme_null, 0, &nc);
+	assert(nc <= 5);
+	mch_memmove(exn_names, tmp, nc * sizeof(Scheme_Object *));
+	MZ_GC_CHECK();
+
+	tmp = scheme_make_struct_values(vim_exn, exn_names, nc, 0);
+	mch_memmove(exn_values, tmp, nc * sizeof(Scheme_Object *));
+	MZ_GC_CHECK();
+
+	for (i = 0; i < nc; i++)
+	{
+	    scheme_add_global_symbol(exn_names[i],
+		    exn_values[i], environment);
+	    MZ_GC_CHECK();
+	}
+	MZ_GC_UNREG();
     }
-
-    add_vim_exn(env);
-}
-
-/*
- * Add stuff of exn:vim to env
- */
-    static void
-add_vim_exn(Scheme_Env *env)
-{
-    int i;
-
-    for (i = 0; i < SCHEME_VEC_SIZE(vim_exn_values); i++)
-	scheme_add_global_symbol(SCHEME_VEC_ELS(vim_exn_names)[i],
-		SCHEME_VEC_ELS(vim_exn_values)[i], env);
+    MZ_GC_UNREG();
 }
 
 /*
  * raise exn:vim, may be with additional info string
  */
     void
 raise_vim_exn(const char *add_info)
 {
-    Scheme_Object   *argv[2];
-    char_u	    *fmt = _("Vim error: ~a");
+    char	    *fmt = _("Vim error: ~a");
+    Scheme_Object   *argv[2] = {NULL, NULL};
+    Scheme_Object   *exn = NULL;
+
+    MZ_GC_DECL_REG(4);
+    MZ_GC_ARRAY_VAR_IN_REG(0, argv, 2);
+    MZ_GC_VAR_IN_REG(3, exn);
+    MZ_GC_REG();
 
     if (add_info != NULL)
     {
-	Scheme_Object   *info = scheme_make_string(add_info);
-	argv[0] = scheme_byte_string_to_char_string(scheme_make_string(
-		scheme_format(fmt, strlen(fmt), 1, &info, NULL)));
+	char		*c_string = NULL;
+	Scheme_Object	*byte_string = NULL;
+	Scheme_Object   *info = NULL;
+
+	MZ_GC_DECL_REG(3);
+	MZ_GC_VAR_IN_REG(0, c_string);
+	MZ_GC_VAR_IN_REG(1, byte_string);
+	MZ_GC_VAR_IN_REG(2, info);
+	MZ_GC_REG();
+
+	info = scheme_make_string(add_info);
+	MZ_GC_CHECK();
+	c_string = scheme_format(fmt, STRLEN(fmt), 1, &info, NULL);
+	MZ_GC_CHECK();
+	byte_string = scheme_make_string(c_string);
+	MZ_GC_CHECK();
+	argv[0] = scheme_byte_string_to_char_string(byte_string);
+	MZ_GC_CHECK();
 	SCHEME_SET_IMMUTABLE(argv[0]);
+	MZ_GC_UNREG();
     }
     else
 	argv[0] = scheme_make_string(_("Vim error"));
+    MZ_GC_CHECK();
 
 #if MZSCHEME_VERSION_MAJOR < 360
     argv[1] = scheme_current_continuation_marks();
+    MZ_GC_CHECK();
 #else
     argv[1] = scheme_current_continuation_marks(NULL);
+    MZ_GC_CHECK();
 #endif
 
-    scheme_raise(scheme_make_struct_instance(vim_exn, 2, argv));
+    exn = scheme_make_struct_instance(vim_exn, 2, argv);
+    MZ_GC_CHECK();
+    scheme_raise(exn);
+    MZ_GC_UNREG();
 }
 
     void
 raise_if_error(void)
 {
@@ -2570,10 +3183,12 @@ mz_fix_cursor(int lo, int hi, int extra)
 	else if (extra < 0)
 	{
 	    curwin->w_cursor.lnum = lo;
 	    check_cursor();
 	}
+	else
+	    check_cursor_col();
 	changed_cline_bef_curs();
     }
     invalidate_botline();
 }
 
@@ -2595,11 +3210,10 @@ static Vim_Prim prims[]=
     {get_next_buffer, "get-next-buff", 0, 1},
     {get_prev_buffer, "get-prev-buff", 0, 1},
     {mzscheme_open_buffer, "open-buff", 1, 1},
     {get_buffer_by_name, "get-buff-by-name", 1, 1},
     {get_buffer_by_num, "get-buff-by-num", 1, 1},
-    {get_buffer_namespace, "get-buff-namespace", 0, 1},
     /*
      * Window-related commands
      */
     {get_curr_win, "curr-win", 0, 0},
     {get_window_count, "win-count", 0, 0},
@@ -2653,27 +3267,39 @@ get_vim_curr_window(void)
     else
 	return (vim_mz_window *)curwin->w_mzscheme_ref;
 }
 
     static void
-make_modules(Scheme_Env *env)
+make_modules()
 {
-    int		i;
-    Scheme_Env	*mod;
-
-    mod = scheme_primitive_module(scheme_intern_symbol("vimext"), env);
+    int		    i;
+    Scheme_Env	    *mod = NULL;
+    Scheme_Object   *vimext_symbol = NULL;
+    Scheme_Object   *closed_prim = NULL;
+
+    MZ_GC_DECL_REG(3);
+    MZ_GC_VAR_IN_REG(0, mod);
+    MZ_GC_VAR_IN_REG(1, vimext_symbol);
+    MZ_GC_VAR_IN_REG(2, closed_prim);
+    MZ_GC_REG();
+
+    vimext_symbol = scheme_intern_symbol("vimext");
+    MZ_GC_CHECK();
+    mod = scheme_primitive_module(vimext_symbol, environment);
+    MZ_GC_CHECK();
     /* all prims made closed so they can access their own names */
-    for (i = 0; i < sizeof(prims)/sizeof(prims[0]); i++)
+    for (i = 0; i < (int)(sizeof(prims)/sizeof(prims[0])); i++)
     {
 	Vim_Prim *prim = prims + i;
-	scheme_add_global(prim->name,
-		scheme_make_closed_prim_w_arity(prim->prim, prim, prim->name,
-		    prim->mina, prim->maxa),
-		mod);
+	closed_prim = scheme_make_closed_prim_w_arity(prim->prim, prim, prim->name,
+			    prim->mina, prim->maxa);
+	scheme_add_global(prim->name, closed_prim, mod);
+	MZ_GC_CHECK();
     }
-    scheme_add_global("global-namespace", (Scheme_Object *)environment, mod);
     scheme_finish_primitive_module(mod);
+    MZ_GC_CHECK();
+    MZ_GC_UNREG();
 }
 
 #ifdef HAVE_SANDBOX
 static Scheme_Object *M_write = NULL;
 static Scheme_Object *M_read = NULL;
@@ -2697,25 +3323,29 @@ sandbox_file_guard(int argc, Scheme_Obje
 
 	if (M_write == NULL)
 	{
 	    MZ_REGISTER_STATIC(M_write);
 	    M_write = scheme_intern_symbol("write");
+	    MZ_GC_CHECK();
 	}
 	if (M_read == NULL)
 	{
 	    MZ_REGISTER_STATIC(M_read);
 	    M_read = scheme_intern_symbol("read");
+	    MZ_GC_CHECK();
 	}
 	if (M_execute == NULL)
 	{
 	    MZ_REGISTER_STATIC(M_execute);
 	    M_execute = scheme_intern_symbol("execute");
+	    MZ_GC_CHECK();
 	}
 	if (M_delete == NULL)
 	{
 	    MZ_REGISTER_STATIC(M_delete);
 	    M_delete = scheme_intern_symbol("delete");
+	    MZ_GC_CHECK();
 	}
 
 	while (!SCHEME_NULLP(requested_access))
 	{
 	    Scheme_Object *item = SCHEME_CAR(requested_access);
--- vim72.orig/src/if_mzsch.h
+++ vim72/src/if_mzsch.h
@@ -9,10 +9,11 @@
 # define __CYGWIN32__
 #endif
 
 /* #ifdef needed for "make depend" */
 #ifdef FEAT_MZSCHEME
+# include <schvers.h>
 # include <scheme.h>
 #endif
 
 #ifdef __MINGW32__
 # undef __CYGWIN32__
@@ -44,6 +45,33 @@
 # define SCHEME_BYTE_STRLEN_VAL SCHEME_STRLEN_VAL
 # define SCHEME_BYTE_STR_VAL SCHEME_STR_VAL
 # define scheme_byte_string_to_char_string(obj) (obj)
 #endif
 
+/* Precise GC macros */
+#ifndef MZ_GC_DECL_REG
+# define MZ_GC_DECL_REG(size)            /* empty */
+#endif
+#ifndef MZ_GC_VAR_IN_REG
+# define MZ_GC_VAR_IN_REG(x, v)          /* empty */
+#endif
+#ifndef MZ_GC_ARRAY_VAR_IN_REG
+# define MZ_GC_ARRAY_VAR_IN_REG(x, v, l) /* empty */
+#endif
+#ifndef MZ_GC_REG
+# define MZ_GC_REG()                     /* empty */
+#endif
+#ifndef MZ_GC_UNREG
+# define MZ_GC_UNREG()                   /* empty */
+#endif
+
+#ifdef MZSCHEME_FORCE_GC
+/*
+ * force garbage collection to check all references are registered
+ * seg faults will indicate not registered refs
+ */
+# define MZ_GC_CHECK() scheme_collect_garbage();
+#else
+# define MZ_GC_CHECK()			/* empty */
+#endif
+
 #endif /* _IF_MZSCH_H_ */
--- vim72.orig/src/if_ole.cpp
+++ vim72/src/if_ole.cpp
@@ -351,13 +351,17 @@ CVim::SendKeys(BSTR keys)
 	vim_free(str);
 	return E_INVALIDARG;
     }
 
     /* Pass the string to the main input loop. The memory will be freed when
-     * the message is processed.
+     * the message is processed.  Except for an empty message, we don't need
+     * to post it then.
      */
-    PostMessage(NULL, WM_OLE, 0, (LPARAM)str);
+    if (*str == NUL)
+	vim_free(str);
+    else
+	PostMessage(NULL, WM_OLE, 0, (LPARAM)str);
 
     return S_OK;
 }
 
 STDMETHODIMP
--- vim72.orig/src/if_perl.xs
+++ vim72/src/if_perl.xs
@@ -60,10 +60,15 @@
 #endif
 #if (PERL_REVISION == 5) && (PERL_VERSION >= 9)
 # define PERL589_OR_LATER
 #endif
 
+#if (PERL_REVISION == 5) && ((PERL_VERSION > 10) || \
+    (PERL_VERSION == 10) && (PERL_SUBVERSION >= 1))
+# define PERL5101_OR_LATER
+#endif
+
 #ifndef pTHX
 #    define pTHX void
 #    define pTHX_
 #endif
 
@@ -91,10 +96,13 @@ EXTERN_C void boot_DynaLoader __ARGS((pT
 # define perl_run dll_perl_run
 # define perl_destruct dll_perl_destruct
 # define perl_free dll_perl_free
 # define Perl_get_context dll_Perl_get_context
 # define Perl_croak dll_Perl_croak
+# ifdef PERL5101_OR_LATER
+#  define Perl_croak_xs_usage dll_Perl_croak_xs_usage
+# endif
 # ifndef PROTO
 #  define Perl_croak_nocontext dll_Perl_croak_nocontext
 #  define Perl_call_argv dll_Perl_call_argv
 #  define Perl_call_pv dll_Perl_call_pv
 #  define Perl_eval_sv dll_Perl_eval_sv
@@ -134,10 +142,13 @@ EXTERN_C void boot_DynaLoader __ARGS((pT
 #ifdef PERL589_OR_LATER
 #  define Perl_sv_2iv_flags dll_Perl_sv_2iv_flags
 #  define Perl_newXS_flags dll_Perl_newXS_flags
 #endif
 # define Perl_sv_free dll_Perl_sv_free
+# if (PERL_REVISION == 5) && (PERL_VERSION >= 10)
+#  define Perl_sv_free2 dll_Perl_sv_free2
+# endif
 # define Perl_sv_isa dll_Perl_sv_isa
 # define Perl_sv_magic dll_Perl_sv_magic
 # define Perl_sv_setiv dll_Perl_sv_setiv
 # define Perl_sv_setpv dll_Perl_sv_setpv
 # define Perl_sv_setpvn dll_Perl_sv_setpvn
@@ -161,11 +172,11 @@ EXTERN_C void boot_DynaLoader __ARGS((pT
 # define Perl_Idefgv_ptr dll_Perl_Idefgv_ptr
 # define Perl_Ierrgv_ptr dll_Perl_Ierrgv_ptr
 # define Perl_Isv_yes_ptr dll_Perl_Isv_yes_ptr
 # define boot_DynaLoader dll_boot_DynaLoader
 
-# define Perl_sys_init3 dll_Perl_sys_init3
+# define Perl_sys_init dll_Perl_sys_init
 # define Perl_sys_term dll_Perl_sys_term
 # define Perl_ISv_ptr dll_Perl_ISv_ptr
 # define Perl_Istack_max_ptr dll_Perl_Istack_max_ptr
 # define Perl_Istack_base_ptr dll_Perl_Istack_base_ptr
 # define Perl_Itmps_ix_ptr dll_Perl_Itmps_ix_ptr
@@ -197,10 +208,13 @@ static void (*perl_destruct)(PerlInterpr
 static void (*perl_free)(PerlInterpreter*);
 static int (*perl_run)(PerlInterpreter*);
 static int (*perl_parse)(PerlInterpreter*, XSINIT_t, int, char**, char**);
 static void* (*Perl_get_context)(void);
 static void (*Perl_croak)(pTHX_ const char*, ...);
+#ifdef PERL5101_OR_LATER
+static void (*Perl_croak_xs_usage)(pTHX_ const CV *const, const char *const params);
+#endif
 static void (*Perl_croak_nocontext)(const char*, ...);
 static I32 (*Perl_dowantarray)(pTHX);
 static void (*Perl_free_tmps)(pTHX);
 static HV* (*Perl_gv_stashpv)(pTHX_ const char*, I32);
 static void (*Perl_markstack_grow)(pTHX);
@@ -266,11 +280,12 @@ static GV** (*Perl_Idefgv_ptr)(register
 static GV** (*Perl_Ierrgv_ptr)(register PerlInterpreter*);
 static SV* (*Perl_Isv_yes_ptr)(register PerlInterpreter*);
 static void (*boot_DynaLoader)_((pTHX_ CV*));
 
 #if (PERL_REVISION == 5) && (PERL_VERSION >= 10)
-static void (*Perl_sys_init3)(int* argc, char*** argv, char*** env);
+static void (*Perl_sv_free2)(pTHX_ SV*);
+static void (*Perl_sys_init)(int* argc, char*** argv);
 static void (*Perl_sys_term)(void);
 static SV** (*Perl_ISv_ptr)(register PerlInterpreter*);
 static SV*** (*Perl_Istack_max_ptr)(register PerlInterpreter*);
 static SV*** (*Perl_Istack_base_ptr)(register PerlInterpreter*);
 static XPV** (*Perl_IXpv_ptr)(register PerlInterpreter*);
@@ -300,10 +315,13 @@ static struct {
     {"perl_free", (PERL_PROC*)&perl_free},
     {"perl_run", (PERL_PROC*)&perl_run},
     {"perl_parse", (PERL_PROC*)&perl_parse},
     {"Perl_get_context", (PERL_PROC*)&Perl_get_context},
     {"Perl_croak", (PERL_PROC*)&Perl_croak},
+#ifdef PERL5101_OR_LATER
+    {"Perl_croak_xs_usage", (PERL_PROC*)&Perl_croak_xs_usage},
+#endif
     {"Perl_croak_nocontext", (PERL_PROC*)&Perl_croak_nocontext},
     {"Perl_dowantarray", (PERL_PROC*)&Perl_dowantarray},
     {"Perl_free_tmps", (PERL_PROC*)&Perl_free_tmps},
     {"Perl_gv_stashpv", (PERL_PROC*)&Perl_gv_stashpv},
     {"Perl_markstack_grow", (PERL_PROC*)&Perl_markstack_grow},
@@ -365,11 +383,12 @@ static struct {
     {"Perl_Tmarkstack_max_ptr", (PERL_PROC*)&Perl_Tmarkstack_max_ptr},
     {"Perl_TSv_ptr", (PERL_PROC*)&Perl_TSv_ptr},
     {"Perl_TXpv_ptr", (PERL_PROC*)&Perl_TXpv_ptr},
     {"Perl_Tna_ptr", (PERL_PROC*)&Perl_Tna_ptr},
 #else
-    {"Perl_sys_init3", (PERL_PROC*)&Perl_sys_init3},
+    {"Perl_sv_free2", (PERL_PROC*)&Perl_sv_free2},
+    {"Perl_sys_init", (PERL_PROC*)&Perl_sys_init},
     {"Perl_sys_term", (PERL_PROC*)&Perl_sys_term},
     {"Perl_ISv_ptr", (PERL_PROC*)&Perl_ISv_ptr},
     {"Perl_Istack_sp_ptr", (PERL_PROC*)&Perl_Istack_sp_ptr},
     {"Perl_Iop_ptr", (PERL_PROC*)&Perl_Iop_ptr},
     {"Perl_Istack_base_ptr", (PERL_PROC*)&Perl_Istack_base_ptr},
@@ -453,11 +472,11 @@ perl_init()
     char *bootargs[] = { "VI", NULL };
     int argc = 3;
     static char *argv[] = { "", "-e", "" };
 
 #if (PERL_REVISION == 5) && (PERL_VERSION >= 10)
-    Perl_sys_init3(&argc, (char***)&argv, NULL);
+    Perl_sys_init(&argc, (char***)&argv);
 #endif
     perl_interp = perl_alloc();
     perl_construct(perl_interp);
     perl_parse(perl_interp, xs_init, argc, argv, 0);
     perl_call_argv("VIM::bootstrap", (long)G_DISCARD, bootargs);
@@ -713,13 +732,16 @@ ex_perl(eap)
     }
 
 #ifdef HAVE_SANDBOX
     if (sandbox)
     {
-	if ((safe = perl_get_sv( "VIM::safe", FALSE )) == NULL || !SvTRUE(safe))
+	safe = perl_get_sv( "VIM::safe", FALSE );
+# ifndef MAKE_TEST  /* avoid a warning for unreachable code */
+	if (safe == NULL || !SvTRUE(safe))
 	    EMSG(_("E299: Perl evaluation forbidden in sandbox without the Safe module"));
 	else
+# endif
 	{
 	    PUSHMARK(SP);
 	    XPUSHs(safe);
 	    XPUSHs(sv);
 	    PUTBACK;
@@ -1226,13 +1248,12 @@ Delete(vimbuf, ...)
 		    aucmd_prepbuf(&aco, vimbuf);
 
 		    if (u_savedel(lnum, 1) == OK)
 		    {
 			ml_delete(lnum, 0);
+			check_cursor();
 			deleted_lines_mark(lnum, 1L);
-			if (aco.save_buf == curbuf)
-			    check_cursor();
 		    }
 
 		    /* restore curwin/curbuf and a few other things */
 		    aucmd_restbuf(&aco);
 		    /* Careful: autocommands may have made "vimbuf" invalid! */
--- vim72.orig/src/if_python.c
+++ vim72/src/if_python.c
@@ -35,10 +35,16 @@
 #endif
 
 #ifdef HAVE_STDARG_H
 # undef HAVE_STDARG_H	/* Python's config.h defines it as well. */
 #endif
+#ifdef _POSIX_C_SOURCE
+# undef _POSIX_C_SOURCE	/* pyconfig.h defines it as well. */
+#endif
+#ifdef _XOPEN_SOURCE
+# undef _XOPEN_SOURCE	/* pyconfig.h defines it as well. */
+#endif
 
 #define PY_SSIZE_T_CLEAN
 
 #include <Python.h>
 #if defined(MACOS) && !defined(MACOS_X_UNIX)
@@ -529,10 +535,16 @@ Python_Init(void)
 	    goto fail;
 
 	if (PythonMod_Init())
 	    goto fail;
 
+	/* Remove the element from sys.path that was added because of our
+	 * argv[0] value in PythonMod_Init().  Previously we used an empty
+	 * string, but dependinding on the OS we then get an empty entry or
+	 * the current directory in sys.path. */
+	PyRun_SimpleString("import sys; sys.path = filter(lambda x: x != '/must>not&exist', sys.path)");
+
 	/* the first python thread is vim's, release the lock */
 	Python_SaveThread();
 
 	initialised = 1;
     }
@@ -1088,13 +1100,12 @@ static struct PyMethodDef VimMethods[] =
     { NULL,	     NULL,		0,	    NULL }
 };
 
 /* Vim module - Implementation
  */
-/*ARGSUSED*/
     static PyObject *
-VimCommand(PyObject *self, PyObject *args)
+VimCommand(PyObject *self UNUSED, PyObject *args)
 {
     char *cmd;
     PyObject *result;
 
     if (!PyArg_ParseTuple(args, "s", &cmd))
@@ -1143,48 +1154,56 @@ VimToPython(typval_T *our_tv, int depth,
 	return result;
     }
 
     /* Check if we run into a recursive loop.  The item must be in lookupDict
      * then and we can use it again. */
-    sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U, (long_u)our_tv);
-    result = PyDict_GetItemString(lookupDict, ptrBuf);
-    if (result != NULL)
-	Py_INCREF(result);
-    else if (our_tv->v_type == VAR_STRING)
+    if ((our_tv->v_type == VAR_LIST && our_tv->vval.v_list != NULL)
+	    || (our_tv->v_type == VAR_DICT && our_tv->vval.v_dict != NULL))
+    {
+	sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U,
+	        our_tv->v_type == VAR_LIST ? (long_u)our_tv->vval.v_list
+		                           : (long_u)our_tv->vval.v_dict);
+	result = PyDict_GetItemString(lookupDict, ptrBuf);
+	if (result != NULL)
+	{
+	    Py_INCREF(result);
+	    return result;
+	}
+    }
+
+    if (our_tv->v_type == VAR_STRING)
     {
 	result = Py_BuildValue("s", our_tv->vval.v_string);
-	PyDict_SetItemString(lookupDict, ptrBuf, result);
     }
     else if (our_tv->v_type == VAR_NUMBER)
     {
 	char buf[NUMBUFLEN];
 
 	/* For backwards compatibility numbers are stored as strings. */
 	sprintf(buf, "%ld", (long)our_tv->vval.v_number);
 	result = Py_BuildValue("s", buf);
-	PyDict_SetItemString(lookupDict, ptrBuf, result);
     }
 # ifdef FEAT_FLOAT
     else if (our_tv->v_type == VAR_FLOAT)
     {
 	char buf[NUMBUFLEN];
 
 	sprintf(buf, "%f", our_tv->vval.v_float);
 	result = Py_BuildValue("s", buf);
-	PyDict_SetItemString(lookupDict, ptrBuf, result);
     }
 # endif
     else if (our_tv->v_type == VAR_LIST)
     {
 	list_T		*list = our_tv->vval.v_list;
 	listitem_T	*curr;
 
 	result = PyList_New(0);
-	PyDict_SetItemString(lookupDict, ptrBuf, result);
 
 	if (list != NULL)
 	{
+	    PyDict_SetItemString(lookupDict, ptrBuf, result);
+
 	    for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
 	    {
 		newObj = VimToPython(&curr->li_tv, depth + 1, lookupDict);
 		PyList_Append(result, newObj);
 		Py_DECREF(newObj);
@@ -1192,19 +1211,20 @@ VimToPython(typval_T *our_tv, int depth,
 	}
     }
     else if (our_tv->v_type == VAR_DICT)
     {
 	result = PyDict_New();
-	PyDict_SetItemString(lookupDict, ptrBuf, result);
 
 	if (our_tv->vval.v_dict != NULL)
 	{
 	    hashtab_T	*ht = &our_tv->vval.v_dict->dv_hashtab;
 	    long_u	todo = ht->ht_used;
 	    hashitem_T	*hi;
 	    dictitem_T	*di;
 
+	    PyDict_SetItemString(lookupDict, ptrBuf, result);
+
 	    for (hi = ht->ht_array; todo > 0; ++hi)
 	    {
 		if (!HASHITEM_EMPTY(hi))
 		{
 		    --todo;
@@ -1225,13 +1245,12 @@ VimToPython(typval_T *our_tv, int depth,
 
     return result;
 }
 #endif
 
-/*ARGSUSED*/
     static PyObject *
-VimEval(PyObject *self, PyObject *args)
+VimEval(PyObject *self UNUSED, PyObject *args)
 {
 #ifdef FEAT_EVAL
     char	*expr;
     typval_T	*our_tv;
     PyObject	*result;
@@ -1877,13 +1896,12 @@ static PyTypeObject BufListType = {
 };
 
 /* Buffer list object - Implementation
  */
 
-/*ARGSUSED*/
     static PyInt
-BufListLength(PyObject *self)
+BufListLength(PyObject *self UNUSED)
 {
     buf_T	*b = firstbuf;
     PyInt	n = 0;
 
     while (b)
@@ -1893,13 +1911,12 @@ BufListLength(PyObject *self)
     }
 
     return n;
 }
 
-/*ARGSUSED*/
     static PyObject *
-BufListItem(PyObject *self, PyInt n)
+BufListItem(PyObject *self UNUSED, PyInt n)
 {
     buf_T *b;
 
     for (b = firstbuf; b; b = b->b_next, --n)
     {
@@ -2045,10 +2062,11 @@ WindowSetattr(PyObject *self, char *name
     }
     else if (strcmp(name, "cursor") == 0)
     {
 	long lnum;
 	long col;
+	long len;
 
 	if (!PyArg_Parse(val, "(ll)", &lnum, &col))
 	    return -1;
 
 	if (lnum <= 0 || lnum > this->win->w_buffer->b_ml.ml_line_count)
@@ -2059,14 +2077,20 @@ WindowSetattr(PyObject *self, char *name
 
 	/* Check for keyboard interrupts */
 	if (VimErrorCheck())
 	    return -1;
 
-	/* NO CHECK ON COLUMN - SEEMS NOT TO MATTER */
+	/* When column is out of range silently correct it. */
+	len = (long)STRLEN(ml_get_buf(this->win->w_buffer, lnum, FALSE));
+	if (col > len)
+	    col = len;
 
 	this->win->w_cursor.lnum = lnum;
 	this->win->w_cursor.col = col;
+#ifdef FEAT_VIRTUALEDIT
+	this->win->w_cursor.coladd = 0;
+#endif
 	update_screen(VALID);
 
 	return 0;
     }
     else if (strcmp(name, "height") == 0)
@@ -2193,13 +2217,12 @@ static PyTypeObject WinListType = {
     (reprfunc) 0,			/* tp_str,  str(x)  */
 };
 
 /* Window list object - Implementation
  */
-/*ARGSUSED*/
     static PyInt
-WinListLength(PyObject *self)
+WinListLength(PyObject *self UNUSED)
 {
     win_T	*w = firstwin;
     PyInt	n = 0;
 
     while (w != NULL)
@@ -2209,13 +2232,12 @@ WinListLength(PyObject *self)
     }
 
     return n;
 }
 
-/*ARGSUSED*/
     static PyObject *
-WinListItem(PyObject *self, PyInt n)
+WinListItem(PyObject *self UNUSED, PyInt n)
 {
     win_T *w;
 
     for (w = firstwin; w != NULL; w = W_NEXT(w), --n)
 	if (n == 0)
@@ -2257,13 +2279,12 @@ static PyTypeObject CurrentType = {
     (reprfunc) 0,			/* tp_str,  str(x)  */
 };
 
 /* Current items object - Implementation
  */
-/*ARGSUSED*/
     static PyObject *
-CurrentGetattr(PyObject *self, char *name)
+CurrentGetattr(PyObject *self UNUSED, char *name)
 {
     if (strcmp(name, "buffer") == 0)
 	return (PyObject *)BufferNew(curbuf);
     else if (strcmp(name, "window") == 0)
 	return (PyObject *)WindowNew(curwin);
@@ -2278,13 +2299,12 @@ CurrentGetattr(PyObject *self, char *nam
 	PyErr_SetString(PyExc_AttributeError, name);
 	return NULL;
     }
 }
 
-/*ARGSUSED*/
     static int
-CurrentSetattr(PyObject *self, char *name, PyObject *value)
+CurrentSetattr(PyObject *self UNUSED, char *name, PyObject *value)
 {
     if (strcmp(name, "line") == 0)
     {
 	if (SetBufferLine(curbuf, (PyInt)curwin->w_cursor.lnum, value, NULL) == FAIL)
 	    return -1;
@@ -2343,11 +2363,12 @@ static CurrentObject TheCurrent =
     static int
 PythonMod_Init(void)
 {
     PyObject *mod;
     PyObject *dict;
-    static char *(argv[2]) = {"", NULL};
+    /* The special value is removed from sys.path in Python_Init(). */
+    static char *(argv[2]) = {"/must>not&exist/foo", NULL};
 
     /* Fixups... */
     BufferType.ob_type = &PyType_Type;
     RangeType.ob_type = &PyType_Type;
     WindowType.ob_type = &PyType_Type;
@@ -2487,13 +2508,13 @@ SetBufferLine(buf_T *buf, PyInt n, PyObj
 	    PyErr_SetVim(_("cannot save undo information"));
 	else if (ml_delete((linenr_T)n, FALSE) == FAIL)
 	    PyErr_SetVim(_("cannot delete line"));
 	else
 	{
-	    deleted_lines_mark((linenr_T)n, 1L);
 	    if (buf == curwin->w_buffer)
 		py_fix_cursor((linenr_T)n, (linenr_T)n + 1, (linenr_T)-1);
+	    deleted_lines_mark((linenr_T)n, 1L);
 	}
 
 	curbuf = savebuf;
 
 	if (PyErr_Occurred() || VimErrorCheck())
@@ -2586,14 +2607,13 @@ SetBufferLineList(buf_T *buf, PyInt lo,
 		{
 		    PyErr_SetVim(_("cannot delete line"));
 		    break;
 		}
 	    }
-	    deleted_lines_mark((linenr_T)lo, (long)i);
-
 	    if (buf == curwin->w_buffer)
 		py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)-n);
+	    deleted_lines_mark((linenr_T)lo, (long)i);
 	}
 
 	curbuf = savebuf;
 
 	if (PyErr_Occurred() || VimErrorCheck())
--- vim72.orig/src/if_ruby.c
+++ vim72/src/if_ruby.c
@@ -37,20 +37,40 @@
 # define rb_cNilClass		(*dll_rb_cNilClass)
 # define rb_cSymbol		(*dll_rb_cSymbol)
 # define rb_cTrueClass		(*dll_rb_cTrueClass)
 # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
 /*
- * On ver 1.8, all Ruby functions are exported with "__declspce(dllimport)"
- * in ruby.h.  But it cause trouble for these variables, because it is
+ * On ver 1.8, all Ruby functions are exported with "__declspec(dllimport)"
+ * in ruby.h.  But it causes trouble for these variables, because it is
  * defined in this file.  When defined this RUBY_EXPORT it modified to
  * "extern" and be able to avoid this problem.
  */
 #  define RUBY_EXPORT
 # endif
 #endif
 
+/* suggested by Ariya Mizutani */
+#if (_MSC_VER == 1200)
+# undef _WIN32_WINNT
+#endif
+
+#if (defined(RUBY_VERSION) && RUBY_VERSION >= 19) \
+    || (defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19)
+# define RUBY19_OR_LATER 1
+#endif
+
+#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
+/* Ruby 1.9 defines a number of static functions which use rb_num2long and
+ * rb_int2big */
+# define rb_num2long rb_num2long_stub
+# define rb_int2big rb_int2big_stub
+#endif
+
 #include <ruby.h>
+#ifdef RUBY19_OR_LATER
+# include <ruby/encoding.h>
+#endif
 
 #undef EXTERN
 #undef _
 
 /* T_DATA defined both by Ruby and Mac header files, hack around it... */
@@ -58,10 +78,32 @@
 # define __OPENTRANSPORT__
 # define __OPENTRANSPORTPROTOCOL__
 # define __OPENTRANSPORTPROVIDERS__
 #endif
 
+/*
+ * Backward compatiblity for Ruby 1.8 and earlier.
+ * Ruby 1.9 does not provide STR2CSTR, instead StringValuePtr is provided.
+ * Ruby 1.9 does not provide RXXX(s)->len and RXXX(s)->ptr, instead
+ * RXXX_LEN(s) and RXXX_PTR(s) are provided.
+ */
+#ifndef StringValuePtr
+# define StringValuePtr(s) STR2CSTR(s)
+#endif
+#ifndef RARRAY_LEN
+# define RARRAY_LEN(s) RARRAY(s)->len
+#endif
+#ifndef RARRAY_PTR
+# define RARRAY_PTR(s) RARRAY(s)->ptr
+#endif
+#ifndef RSTRING_LEN
+# define RSTRING_LEN(s) RSTRING(s)->len
+#endif
+#ifndef RSTRING_PTR
+# define RSTRING_PTR(s) RSTRING(s)->ptr
+#endif
+
 #include "vim.h"
 #include "version.h"
 
 #if defined(PROTO) && !defined(FEAT_RUBY)
 /* Define these to be able to generate the function prototypes. */
@@ -127,17 +169,37 @@ static void ruby_vim_init(void);
 #define rb_str2cstr			dll_rb_str2cstr
 #define rb_str_cat			dll_rb_str_cat
 #define rb_str_concat			dll_rb_str_concat
 #define rb_str_new			dll_rb_str_new
 #define rb_str_new2			dll_rb_str_new2
-#define ruby_errinfo			(*dll_ruby_errinfo)
+#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
+# define rb_string_value_ptr		dll_rb_string_value_ptr
+# define rb_float_new			dll_rb_float_new
+# define rb_ary_new			dll_rb_ary_new
+# define rb_ary_push			dll_rb_ary_push
+#endif
+#ifdef RUBY19_OR_LATER
+# define rb_errinfo			dll_rb_errinfo
+#else
+# define ruby_errinfo			(*dll_ruby_errinfo)
+#endif
 #define ruby_init			dll_ruby_init
 #define ruby_init_loadpath		dll_ruby_init_loadpath
+#define NtInitialize			dll_NtInitialize
 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
 # define rb_w32_snprintf		dll_rb_w32_snprintf
 #endif
 
+#ifdef RUBY19_OR_LATER
+# define ruby_script			dll_ruby_script
+# define rb_enc_find_index		dll_rb_enc_find_index
+# define rb_enc_find			dll_rb_enc_find
+# define rb_enc_str_new			dll_rb_enc_str_new
+# define rb_sprintf			dll_rb_sprintf
+# define ruby_init_stack		dll_ruby_init_stack
+#endif
+
 /*
  * Pointers for dynamic link
  */
 static VALUE (*dll_rb_assoc_new) (VALUE, VALUE);
 static VALUE *dll_rb_cFalseClass;
@@ -181,17 +243,51 @@ static void (*dll_rb_raise) (VALUE, cons
 static char *(*dll_rb_str2cstr) (VALUE,int*);
 static VALUE (*dll_rb_str_cat) (VALUE, const char*, long);
 static VALUE (*dll_rb_str_concat) (VALUE, VALUE);
 static VALUE (*dll_rb_str_new) (const char*, long);
 static VALUE (*dll_rb_str_new2) (const char*);
+#ifdef RUBY19_OR_LATER
+static VALUE (*dll_rb_errinfo) (void);
+#else
 static VALUE *dll_ruby_errinfo;
+#endif
 static void (*dll_ruby_init) (void);
 static void (*dll_ruby_init_loadpath) (void);
+static void (*dll_NtInitialize) (int*, char***);
+#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
+static char * (*dll_rb_string_value_ptr) (volatile VALUE*);
+static VALUE (*dll_rb_float_new) (double);
+static VALUE (*dll_rb_ary_new) (void);
+static VALUE (*dll_rb_ary_push) (VALUE, VALUE);
+#endif
+#ifdef RUBY19_OR_LATER
+static VALUE (*dll_rb_int2big)(SIGNED_VALUE);
+#endif
 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
 static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...);
 #endif
 
+#ifdef RUBY19_OR_LATER
+static void (*dll_ruby_script) (const char*);
+static int (*dll_rb_enc_find_index) (const char*);
+static rb_encoding* (*dll_rb_enc_find) (const char*);
+static VALUE (*dll_rb_enc_str_new) (const char*, long, rb_encoding*);
+static VALUE (*dll_rb_sprintf) (const char*, ...);
+static void (*ruby_init_stack)(VALUE*);
+#endif
+
+#ifdef RUBY19_OR_LATER
+static SIGNED_VALUE rb_num2long_stub(VALUE x)
+{
+    return dll_rb_num2long(x);
+}
+static VALUE rb_int2big_stub(SIGNED_VALUE x)
+{
+    return dll_rb_int2big(x);
+}
+#endif
+
 static HINSTANCE hinstRuby = 0; /* Instance of ruby.dll */
 
 /*
  * Table of name to function pointer of ruby.
  */
@@ -243,16 +339,42 @@ static struct
     {"rb_str2cstr", (RUBY_PROC*)&dll_rb_str2cstr},
     {"rb_str_cat", (RUBY_PROC*)&dll_rb_str_cat},
     {"rb_str_concat", (RUBY_PROC*)&dll_rb_str_concat},
     {"rb_str_new", (RUBY_PROC*)&dll_rb_str_new},
     {"rb_str_new2", (RUBY_PROC*)&dll_rb_str_new2},
+#ifdef RUBY19_OR_LATER
+    {"rb_errinfo", (RUBY_PROC*)&dll_rb_errinfo},
+#else
     {"ruby_errinfo", (RUBY_PROC*)&dll_ruby_errinfo},
+#endif
     {"ruby_init", (RUBY_PROC*)&dll_ruby_init},
     {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath},
+    {
+#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER < 19
+    "NtInitialize",
+#else
+    "ruby_sysinit",
+#endif
+			(RUBY_PROC*)&dll_NtInitialize},
 #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
     {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf},
 #endif
+#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
+    {"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr},
+    {"rb_float_new", (RUBY_PROC*)&dll_rb_float_new},
+    {"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new},
+    {"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push},
+#endif
+#ifdef RUBY19_OR_LATER
+    {"rb_int2big", (RUBY_PROC*)&dll_rb_int2big},
+    {"ruby_script", (RUBY_PROC*)&dll_ruby_script},
+    {"rb_enc_find_index", (RUBY_PROC*)&dll_rb_enc_find_index},
+    {"rb_enc_find", (RUBY_PROC*)&dll_rb_enc_find},
+    {"rb_enc_str_new", (RUBY_PROC*)&dll_rb_enc_str_new},
+    {"rb_sprintf", (RUBY_PROC*)&dll_rb_sprintf},
+    {"ruby_init_stack", (RUBY_PROC*)&dll_ruby_init_stack},
+#endif
     {"", NULL},
 };
 
 /*
  * Free ruby.dll
@@ -338,10 +460,62 @@ void ex_ruby(exarg_T *eap)
 	    error_print(state);
     }
     vim_free(script);
 }
 
+/*
+ *  In Ruby 1.9 or later, ruby String object has encoding.
+ *  conversion buffer string of vim to ruby String object using
+ *  VIM encoding option.
+ */
+    static VALUE
+vim_str2rb_enc_str(const char *s)
+{
+#ifdef RUBY19_OR_LATER
+    int isnum;
+    long lval;
+    char_u *sval;
+    rb_encoding *enc;
+
+    isnum = get_option_value((char_u *)"enc", &lval, &sval, 0);
+    if (isnum == 0)
+    {
+	enc = rb_enc_find((char *)sval);
+	vim_free(sval);
+	if (enc) {
+	    return rb_enc_str_new(s, strlen(s), enc);
+	}
+    }
+#endif
+    return rb_str_new2(s);
+}
+
+    static VALUE
+eval_enc_string_protect(const char *str, int *state)
+{
+#ifdef RUBY19_OR_LATER
+    int isnum;
+    long lval;
+    char_u *sval;
+    rb_encoding *enc;
+    VALUE v;
+
+    isnum = get_option_value((char_u *)"enc", &lval, &sval, 0);
+    if (isnum == 0)
+    {
+	enc = rb_enc_find((char *)sval);
+	vim_free(sval);
+	if (enc)
+	{
+	    v = rb_sprintf("#-*- coding:%s -*-\n%s", rb_enc_name(enc), str);
+	    return rb_eval_string_protect(StringValuePtr(v), state);
+	}
+    }
+#endif
+    return rb_eval_string_protect(str, state);
+}
+
 void ex_rubydo(exarg_T *eap)
 {
     int state;
     linenr_T i;
 
@@ -350,24 +524,24 @@ void ex_rubydo(exarg_T *eap)
 	if (u_save(eap->line1 - 1, eap->line2 + 1) != OK)
 	    return;
 	for (i = eap->line1; i <= eap->line2; i++) {
 	    VALUE line, oldline;
 
-	    line = oldline = rb_str_new2((char *)ml_get(i));
+	    line = oldline = vim_str2rb_enc_str((char *)ml_get(i));
 	    rb_lastline_set(line);
-	    rb_eval_string_protect((char *) eap->arg, &state);
+	    eval_enc_string_protect((char *) eap->arg, &state);
 	    if (state) {
 		error_print(state);
 		break;
 	    }
 	    line = rb_lastline_get();
 	    if (!NIL_P(line)) {
 		if (TYPE(line) != T_STRING) {
 		    EMSG(_("E265: $_ must be an instance of String"));
 		    return;
 		}
-		ml_replace(i, (char_u *) STR2CSTR(line), 1);
+		ml_replace(i, (char_u *) StringValuePtr(line), 1);
 		changed();
 #ifdef SYNTAX_HL
 		syn_changed(i); /* recompute syntax hl. for this line */
 #endif
 	    }
@@ -412,13 +586,28 @@ static int ensure_ruby_initialized(void)
     {
 #ifdef DYNAMIC_RUBY
 	if (ruby_enabled(TRUE))
 	{
 #endif
+#ifdef _WIN32
+	    /* suggested by Ariya Mizutani */
+	    int argc = 1;
+	    char *argv[] = {"gvim.exe"};
+	    NtInitialize(&argc, &argv);
+#endif
+#ifdef RUBY19_OR_LATER
+	    RUBY_INIT_STACK;
+#endif
 	    ruby_init();
+#ifdef RUBY19_OR_LATER
+	    ruby_script("vim-ruby");
+#endif
 	    ruby_init_loadpath();
 	    ruby_io_init();
+#ifdef RUBY19_OR_LATER
+	    rb_enc_find_index("encdb");
+#endif
 	    ruby_vim_init();
 	    ruby_initialized = 1;
 #ifdef DYNAMIC_RUBY
 	}
 	else
@@ -432,12 +621,15 @@ static int ensure_ruby_initialized(void)
 }
 
 static void error_print(int state)
 {
 #ifndef DYNAMIC_RUBY
+#if !(defined(RUBY_VERSION) && RUBY_VERSION >= 19) \
+    && !(defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19)
     RUBYEXTERN VALUE ruby_errinfo;
 #endif
+#endif
     VALUE eclass;
     VALUE einfo;
     char buff[BUFSIZ];
 
 #define TAG_RETURN	0x1
@@ -466,22 +658,27 @@ static void error_print(int state)
     case TAG_RETRY:
 	EMSG(_("E271: retry outside of rescue clause"));
 	break;
     case TAG_RAISE:
     case TAG_FATAL:
+#ifdef RUBY19_OR_LATER
+	eclass = CLASS_OF(rb_errinfo());
+	einfo = rb_obj_as_string(rb_errinfo());
+#else
 	eclass = CLASS_OF(ruby_errinfo);
 	einfo = rb_obj_as_string(ruby_errinfo);
-	if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
+#endif
+	if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
 	    EMSG(_("E272: unhandled exception"));
 	}
 	else {
 	    VALUE epath;
 	    char *p;
 
 	    epath = rb_class_path(eclass);
 	    vim_snprintf(buff, BUFSIZ, "%s: %s",
-		     RSTRING(epath)->ptr, RSTRING(einfo)->ptr);
+		     RSTRING_PTR(epath), RSTRING_PTR(einfo));
 	    p = strchr(buff, '\n');
 	    if (p) *p = '\0';
 	    EMSG(buff);
 	}
 	break;
@@ -490,50 +687,119 @@ static void error_print(int state)
 	EMSG(buff);
 	break;
     }
 }
 
-static VALUE vim_message(VALUE self, VALUE str)
+static VALUE vim_message(VALUE self UNUSED, VALUE str)
 {
     char *buff, *p;
 
     str = rb_obj_as_string(str);
-    buff = ALLOCA_N(char, RSTRING(str)->len);
-    strcpy(buff, RSTRING(str)->ptr);
+    buff = ALLOCA_N(char, RSTRING_LEN(str));
+    strcpy(buff, RSTRING_PTR(str));
     p = strchr(buff, '\n');
     if (p) *p = '\0';
     MSG(buff);
     return Qnil;
 }
 
-static VALUE vim_set_option(VALUE self, VALUE str)
+static VALUE vim_set_option(VALUE self UNUSED, VALUE str)
 {
-    do_set((char_u *)STR2CSTR(str), 0);
+    do_set((char_u *)StringValuePtr(str), 0);
     update_screen(NOT_VALID);
     return Qnil;
 }
 
-static VALUE vim_command(VALUE self, VALUE str)
+static VALUE vim_command(VALUE self UNUSED, VALUE str)
 {
-    do_cmdline_cmd((char_u *)STR2CSTR(str));
+    do_cmdline_cmd((char_u *)StringValuePtr(str));
     return Qnil;
 }
 
-static VALUE vim_evaluate(VALUE self, VALUE str)
-{
 #ifdef FEAT_EVAL
-    char_u *value = eval_to_string((char_u *)STR2CSTR(str), NULL, TRUE);
+static VALUE vim_to_ruby(typval_T *tv)
+{
+    VALUE result = Qnil;
 
-    if (value != NULL)
+    if (tv->v_type == VAR_STRING)
     {
-	VALUE val = rb_str_new2((char *)value);
-	vim_free(value);
-	return val;
+	result = rb_str_new2(tv->vval.v_string == NULL
+					  ? "" : (char *)(tv->vval.v_string));
     }
-    else
+    else if (tv->v_type == VAR_NUMBER)
+    {
+	result = INT2NUM(tv->vval.v_number);
+    }
+# ifdef FEAT_FLOAT
+    else if (tv->v_type == VAR_FLOAT)
+    {
+	result = rb_float_new(tv->vval.v_float);
+    }
+# endif
+    else if (tv->v_type == VAR_LIST)
+    {
+	list_T      *list = tv->vval.v_list;
+	listitem_T  *curr;
+
+	result = rb_ary_new();
+
+	if (list != NULL)
+	{
+	    for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
+	    {
+		rb_ary_push(result, vim_to_ruby(&curr->li_tv));
+	    }
+	}
+    }
+    else if (tv->v_type == VAR_DICT)
+    {
+	result = rb_hash_new();
+
+	if (tv->vval.v_dict != NULL)
+	{
+	    hashtab_T   *ht = &tv->vval.v_dict->dv_hashtab;
+	    long_u      todo = ht->ht_used;
+	    hashitem_T  *hi;
+	    dictitem_T  *di;
+
+	    for (hi = ht->ht_array; todo > 0; ++hi)
+	    {
+		if (!HASHITEM_EMPTY(hi))
+		{
+		    --todo;
+
+		    di = dict_lookup(hi);
+		    rb_hash_aset(result, rb_str_new2((char *)hi->hi_key),
+						     vim_to_ruby(&di->di_tv));
+		}
+	    }
+	}
+    } /* else return Qnil; */
+
+    return result;
+}
 #endif
+
+static VALUE vim_evaluate(VALUE self UNUSED, VALUE str)
+{
+#ifdef FEAT_EVAL
+    typval_T    *tv;
+    VALUE       result;
+
+    tv = eval_expr((char_u *)StringValuePtr(str), NULL);
+    if (tv == NULL)
+    {
 	return Qnil;
+    }
+    result = vim_to_ruby(tv);
+
+    free_tv(tv);
+
+    return result;
+#else
+    return Qnil;
+#endif
 }
 
 static VALUE buffer_new(buf_T *buf)
 {
     if (buf->b_ruby_ref)
@@ -578,11 +844,11 @@ static VALUE buffer_s_count()
     }
 
     return INT2NUM(n);
 }
 
-static VALUE buffer_s_aref(VALUE self, VALUE num)
+static VALUE buffer_s_aref(VALUE self UNUSED, VALUE num)
 {
     buf_T *b;
     int n = NUM2INT(num);
 
     for (b = firstbuf; b != NULL; b = b->b_next)
@@ -624,14 +890,16 @@ static VALUE buffer_count(VALUE self)
 static VALUE get_buffer_line(buf_T *buf, linenr_T n)
 {
     if (n > 0 && n <= buf->b_ml.ml_line_count)
     {
 	char *line = (char *)ml_get_buf(buf, n, FALSE);
-	return line ? rb_str_new2(line) : Qnil;
+	return line ? vim_str2rb_enc_str(line) : Qnil;
     }
-    rb_raise(rb_eIndexError, "index %d out of buffer", n);
+    rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
+#ifndef __GNUC__
     return Qnil; /* For stop warning */
+#endif
 }
 
 static VALUE buffer_aref(VALUE self, VALUE num)
 {
     buf_T *buf = get_buf(self);
@@ -641,11 +909,11 @@ static VALUE buffer_aref(VALUE self, VAL
     return Qnil; /* For stop warning */
 }
 
 static VALUE set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
 {
-    char	*line = STR2CSTR(str);
+    char	*line = StringValuePtr(str);
     aco_save_T	aco;
 
     if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL)
     {
 	/* set curwin/curbuf for "buf" and save some things */
@@ -665,12 +933,14 @@ static VALUE set_buffer_line(buf_T *buf,
 
 	update_curbuf(NOT_VALID);
     }
     else
     {
-	rb_raise(rb_eIndexError, "index %d out of buffer", n);
+	rb_raise(rb_eIndexError, "line number %ld out of range", (long)n);
+#ifndef __GNUC__
 	return Qnil; /* For stop warning */
+#endif
     }
     return str;
 }
 
 static VALUE buffer_aset(VALUE self, VALUE num, VALUE str)
@@ -709,23 +979,26 @@ static VALUE buffer_delete(VALUE self, V
 
 	update_curbuf(NOT_VALID);
     }
     else
     {
-	rb_raise(rb_eIndexError, "index %d out of buffer", n);
+	rb_raise(rb_eIndexError, "line number %ld out of range", n);
     }
     return Qnil;
 }
 
 static VALUE buffer_append(VALUE self, VALUE num, VALUE str)
 {
     buf_T	*buf = get_buf(self);
-    char	*line = STR2CSTR(str);
+    char	*line = StringValuePtr(str);
     long	n = NUM2LONG(num);
     aco_save_T	aco;
 
-    if (n >= 0 && n <= buf->b_ml.ml_line_count && line != NULL)
+    if (line == NULL) {
+	rb_raise(rb_eIndexError, "NULL line");
+    }
+    else if (n >= 0 && n <= buf->b_ml.ml_line_count)
     {
 	/* set curwin/curbuf for "buf" and save some things */
 	aucmd_prepbuf(&aco, buf);
 
 	if (u_inssub(n + 1) == OK) {
@@ -743,11 +1016,11 @@ static VALUE buffer_append(VALUE self, V
 	/* Careful: autocommands may have made "buf" invalid! */
 
 	update_curbuf(NOT_VALID);
     }
     else {
-	rb_raise(rb_eIndexError, "index %d out of buffer", n);
+	rb_raise(rb_eIndexError, "line number %ld out of range", n);
     }
     return str;
 }
 
 static VALUE window_new(win_T *win)
@@ -787,11 +1060,11 @@ static VALUE window_s_current()
 static VALUE line_s_current()
 {
     return get_buffer_line(curbuf, curwin->w_cursor.lnum);
 }
 
-static VALUE set_current_line(VALUE self, VALUE str)
+static VALUE set_current_line(VALUE self UNUSED, VALUE str)
 {
     return set_buffer_line(curbuf, curwin->w_cursor.lnum, str);
 }
 
 static VALUE current_line_number()
@@ -813,11 +1086,11 @@ static VALUE window_s_count()
 #else
     return INT2NUM(1);
 #endif
 }
 
-static VALUE window_s_aref(VALUE self, VALUE num)
+static VALUE window_s_aref(VALUE self UNUSED, VALUE num)
 {
     win_T *w;
     int n = NUM2INT(num);
 
 #ifndef FEAT_WINDOWS
@@ -884,31 +1157,31 @@ static VALUE window_set_cursor(VALUE sel
 {
     VALUE lnum, col;
     win_T *win = get_win(self);
 
     Check_Type(pos, T_ARRAY);
-    if (RARRAY(pos)->len != 2)
+    if (RARRAY_LEN(pos) != 2)
 	rb_raise(rb_eArgError, "array length must be 2");
-    lnum = RARRAY(pos)->ptr[0];
-    col = RARRAY(pos)->ptr[1];
+    lnum = RARRAY_PTR(pos)[0];
+    col = RARRAY_PTR(pos)[1];
     win->w_cursor.lnum = NUM2LONG(lnum);
     win->w_cursor.col = NUM2UINT(col);
     check_cursor();		    /* put cursor on an existing line */
     update_screen(NOT_VALID);
     return Qnil;
 }
 
-static VALUE f_p(int argc, VALUE *argv, VALUE self)
+static VALUE f_p(int argc, VALUE *argv, VALUE self UNUSED)
 {
     int i;
     VALUE str = rb_str_new("", 0);
 
     for (i = 0; i < argc; i++) {
 	if (i > 0) rb_str_cat(str, ", ", 2);
 	rb_str_concat(str, rb_inspect(argv[i]));
     }
-    MSG(RSTRING(str)->ptr);
+    MSG(RSTRING_PTR(str));
     return Qnil;
 }
 
 static void ruby_io_init(void)
 {
--- vim72.orig/src/if_sniff.c
+++ vim72/src/if_sniff.c
@@ -714,12 +714,14 @@ ConnectToSniffEmacs()
     }
 
 #else		/* UNIX Version of the Code */
     int ToSniffEmacs[2], FromSniffEmacs[2];
 
-    pipe(ToSniffEmacs);
-    pipe(FromSniffEmacs);
+    if (pipe(ToSniffEmacs) != 0)
+	return 1;
+    if (pipe(FromSniffEmacs) != 0)
+	return 1;
 
     /* fork */
     if ((sniffemacs_pid=fork()) == 0)
     {
 	/* child */
@@ -1112,11 +1114,12 @@ vi_error_msg(str)
     static void
 vi_open_file(fname)
     char *fname;
 {
     ++no_wait_return;
-    do_ecmd(0, (char_u *)fname, NULL, NULL, ECMD_ONE, ECMD_HIDE+ECMD_OLDBUF);
+    do_ecmd(0, (char_u *)fname, NULL, NULL, ECMD_ONE, ECMD_HIDE+ECMD_OLDBUF,
+	    curwin);
     curbuf->b_sniff = TRUE;
     --no_wait_return;					/* [ex_docmd.c] */
 }
 
     static buf_T *
--- vim72.orig/src/if_tcl.c
+++ vim72/src/if_tcl.c
@@ -159,11 +159,11 @@ static struct ref refsdeleted;	/* dummy
 # ifndef  DYNAMIC_TCL /* Just generating prototypes */
 typedef int HANDLE;
 # endif
 
 /*
- * Declare HANDLE for perl.dll and function pointers.
+ * Declare HANDLE for tcl.dll and function pointers.
  */
 static HANDLE hTclLib = NULL;
 Tcl_Interp* (*dll_Tcl_CreateInterp)();
 
 /*
@@ -180,11 +180,11 @@ static struct {
 
 /*
  * Make all runtime-links of tcl.
  *
  * 1. Get module handle using LoadLibraryEx.
- * 2. Get pointer to perl function by GetProcAddress.
+ * 2. Get pointer to tcl function by GetProcAddress.
  * 3. Repeat 2, until get all functions will be used.
  *
  * Parameter 'libname' provides name of DLL.
  * Return OK or FAIL.
  */
@@ -288,14 +288,13 @@ tcl_end()
  * we just delete the Tcl interpreter (and create a new one with the next
  * :tcl command).
  */
 #define TCL_EXIT	5
 
-/* ARGSUSED */
     static int
 exitcmd(dummy, interp, objc, objv)
-    ClientData dummy;
+    ClientData dummy UNUSED;
     Tcl_Interp *interp;
     int objc;
     Tcl_Obj *CONST objv[];
 {
     int value = 0;
@@ -313,14 +312,13 @@ exitcmd(dummy, interp, objc, objv)
 	    Tcl_WrongNumArgs(interp, 1, objv, "?returnCode?");
     }
     return TCL_ERROR;
 }
 
-/* ARGSUSED */
     static int
 catchcmd(dummy, interp, objc, objv)
-    ClientData	dummy;
+    ClientData	dummy UNUSED;
     Tcl_Interp	*interp;
     int		objc;
     Tcl_Obj	*CONST objv[];
 {
     char    *varname = NULL;
@@ -354,14 +352,13 @@ catchcmd(dummy, interp, objc, objv)
 }
 
 /*
  *  "::vim::beep" - what Vi[m] does best :-)
  */
-/* ARGSUSED */
     static int
 beepcmd(dummy, interp, objc, objv)
-    ClientData dummy;
+    ClientData dummy UNUSED;
     Tcl_Interp *interp;
     int objc;
     Tcl_Obj *CONST objv[];
 {
     if (objc != 1)
@@ -376,14 +373,13 @@ beepcmd(dummy, interp, objc, objv)
 /*
  *  "::vim::buffer list" - create a list of buffer commands.
  *  "::vim::buffer {N}" - create buffer command for buffer N.
  *  "::vim::buffer new" - create a new buffer (not implemented)
  */
-/* ARGSUSED */
     static int
 buffercmd(dummy, interp, objc, objv)
-    ClientData dummy;
+    ClientData dummy UNUSED;
     Tcl_Interp *interp;
     int objc;
     Tcl_Obj *CONST objv[];
 {
     char	*name;
@@ -473,14 +469,13 @@ buffercmd(dummy, interp, objc, objv)
 }
 
 /*
  * "::vim::window list" - create list of window commands.
  */
-/* ARGSUSED */
     static int
 windowcmd(dummy, interp, objc, objv)
-    ClientData	dummy;
+    ClientData	dummy UNUSED;
     Tcl_Interp	*interp;
     int		objc;
     Tcl_Obj	*CONST objv[];
 {
     char	*what, *string;
@@ -1128,14 +1123,13 @@ winselfcmd(ref, interp, objc, objv)
 
     return err;
 }
 
 
-/* ARGSUSED */
     static int
 commandcmd(dummy, interp, objc, objv)
-    ClientData	dummy;
+    ClientData	dummy UNUSED;
     Tcl_Interp	*interp;
     int		objc;
     Tcl_Obj	*CONST objv[];
 {
     int		err;
@@ -1143,14 +1137,13 @@ commandcmd(dummy, interp, objc, objv)
     err = tcldoexcommand(interp, objc, objv, 1);
     update_screen(VALID);
     return err;
 }
 
-/* ARGSUSED */
     static int
 optioncmd(dummy, interp, objc, objv)
-    ClientData	dummy;
+    ClientData	dummy UNUSED;
     Tcl_Interp	*interp;
     int		objc;
     Tcl_Obj	*CONST objv[];
 {
     int		err;
@@ -1158,14 +1151,13 @@ optioncmd(dummy, interp, objc, objv)
     err = tclsetoption(interp, objc, objv, 1);
     update_screen(VALID);
     return err;
 }
 
-/* ARGSUSED */
     static int
 exprcmd(dummy, interp, objc, objv)
-    ClientData	dummy;
+    ClientData	dummy UNUSED;
     Tcl_Interp	*interp;
     int		objc;
     Tcl_Obj	*CONST objv[];
 {
     return tclvimexpr(interp, objc, objv, 1);
@@ -1582,15 +1574,14 @@ tclsetdelcmd(interp, reflist, vimobj, de
 
 /*******************************************
     I/O Channel
 ********************************************/
 
-/* ARGSUSED */
     static int
 channel_close(instance, interp)
     ClientData	instance;
-    Tcl_Interp	*interp;
+    Tcl_Interp	*interp UNUSED;
 {
     int		err = 0;
 
     /* currently does nothing */
 
@@ -1600,16 +1591,15 @@ channel_close(instance, interp)
 	err = EBADF;
     }
     return err;
 }
 
-/* ARGSUSED */
     static int
 channel_input(instance, buf, bufsiz, errptr)
-    ClientData	instance;
-    char	*buf;
-    int		bufsiz;
+    ClientData	instance UNUSED;
+    char	*buf UNUSED;
+    int		bufsiz UNUSED;
     int		*errptr;
 {
 
     /* input is currently not supported */
 
@@ -1657,43 +1647,56 @@ channel_output(instance, buf, bufsiz, er
     }
     vim_free(str);
     return result;
 }
 
-/* ARGSUSED */
     static void
 channel_watch(instance, mask)
-    ClientData	instance;
-    int		mask;
+    ClientData	instance UNUSED;
+    int		mask UNUSED;
 {
     Tcl_SetErrno(EINVAL);
 }
 
-/* ARGSUSED */
     static int
 channel_gethandle(instance, direction, handleptr)
-    ClientData	instance;
-    int		direction;
-    ClientData	*handleptr;
+    ClientData	instance UNUSED;
+    int		direction UNUSED;
+    ClientData	*handleptr UNUSED;
 {
     Tcl_SetErrno(EINVAL);
     return EINVAL;
 }
 
 
 static Tcl_ChannelType channel_type =
 {
-    "vimmessage",
-    NULL,   /* blockmode */
-    channel_close,
-    channel_input,
-    channel_output,
-    NULL,   /* seek */
-    NULL,   /* set option */
-    NULL,   /* get option */
-    channel_watch,
-    channel_gethandle
+    "vimmessage",	/* typeName */
+    NULL,		/* version */
+    channel_close,	/* closeProc */
+    channel_input,	/* inputProc */
+    channel_output,	/* outputProc */
+    NULL,		/* seekProc */
+    NULL,		/* setOptionProc */
+    NULL,		/* getOptionProc */
+    channel_watch,	/* watchProc */
+    channel_gethandle,	/* getHandleProc */
+    NULL,		/* close2Proc */
+    NULL,		/* blockModeProc */
+#ifdef TCL_CHANNEL_VERSION_2
+    NULL,		/* flushProc */
+    NULL,		/* handlerProc */
+#endif
+#ifdef TCL_CHANNEL_VERSION_3
+    NULL,		/* wideSeekProc */
+#endif
+#ifdef TCL_CHANNEL_VERSION_4
+    NULL,		/* threadActionProc */
+#endif
+#ifdef TCL_CHANNEL_VERSION_5
+    NULL		/* truncateProc */
+#endif
 };
 
 /**********************************
   Interface to vim
  **********************************/
--- vim72.orig/src/if_xcmdsrv.c
+++ vim72/src/if_xcmdsrv.c
@@ -19,25 +19,10 @@
 # ifdef FEAT_X11
 #  include <X11/Intrinsic.h>
 #  include <X11/Xatom.h>
 # endif
 
-# if defined(HAVE_SYS_SELECT_H) && \
-	(!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
-#  include <sys/select.h>
-# endif
-
-# ifndef HAVE_SELECT
-#  ifdef HAVE_SYS_POLL_H
-#   include <sys/poll.h>
-#  else
-#   ifdef HAVE_POLL_H
-#    include <poll.h>
-#   endif
-#  endif
-# endif
-
 /*
  * This file provides procedures that implement the command server
  * functionality of Vim when in contact with an X11 server.
  *
  * Adapted from TCL/TK's send command  in tkSend.c of the tk 3.6 distribution.
@@ -680,11 +665,11 @@ serverGetVimNames(dpy)
 
     /*
      * Scan all of the names out of the property.
      */
     ga_init2(&ga, 1, 100);
-    for (p = regProp; (p - regProp) < numItems; p++)
+    for (p = regProp; (long_u)(p - regProp) < numItems; p++)
     {
 	entry = p;
 	while (*p != 0 && !isspace(*p))
 	    p++;
 	if (*p != 0)
@@ -734,11 +719,11 @@ ServerReplyFind(w, op)
 	{
 	    p = ((struct ServerReply *) serverReply.ga_data)
 		+ serverReply.ga_len;
 	    e.id = w;
 	    ga_init2(&e.strings, 1, 100);
-	    memcpy(p, &e, sizeof(e));
+	    mch_memmove(p, &e, sizeof(e));
 	    serverReply.ga_len++;
 	}
     }
     else if (p != NULL && op == SROP_Delete)
     {
@@ -967,11 +952,11 @@ LookupName(dpy, name, delete, loose)
     /*
      * Scan the property for the desired name.
      */
     returnValue = (int_u)None;
     entry = NULL;	/* Not needed, but eliminates compiler warning. */
-    for (p = regProp; (p - regProp) < numItems; )
+    for (p = regProp; (long_u)(p - regProp) < numItems; )
     {
 	entry = p;
 	while (*p != 0 && !isspace(*p))
 	    p++;
 	if (*p != 0 && STRICMP(name, p + 1) == 0)
@@ -984,11 +969,11 @@ LookupName(dpy, name, delete, loose)
 	p++;
     }
 
     if (loose != NULL && returnValue == (int_u)None && !IsSerialName(name))
     {
-	for (p = regProp; (p - regProp) < numItems; )
+	for (p = regProp; (long_u)(p - regProp) < numItems; )
 	{
 	    entry = p;
 	    while (*p != 0 && !isspace(*p))
 		p++;
 	    if (*p != 0 && IsSerialName(p + 1)
@@ -1016,11 +1001,11 @@ LookupName(dpy, name, delete, loose)
 	while (*p != 0)
 	    p++;
 	p++;
 	count = numItems - (p - regProp);
 	if (count > 0)
-	    memcpy(entry, p, count);
+	    mch_memmove(entry, p, count);
 	XChangeProperty(dpy, RootWindow(dpy, 0), registryProperty, XA_STRING,
 			8, PropModeReplace, regProp,
 			(int)(numItems - (p - entry)));
 	XSync(dpy, False);
     }
@@ -1054,11 +1039,11 @@ DeleteAnyLingerer(dpy, win)
      */
     if (GetRegProp(dpy, &regProp, &numItems, FALSE) == FAIL)
 	return;
 
     /* Scan the property for the window id.  */
-    for (p = regProp; (p - regProp) < numItems; )
+    for (p = regProp; (long_u)(p - regProp) < numItems; )
     {
 	if (*p != 0)
 	{
 	    sscanf((char *)p, "%x", &wwin);
 	    if ((Window)wwin == win)
@@ -1070,11 +1055,11 @@ DeleteAnyLingerer(dpy, win)
 		while (*p != 0)
 		    p++;
 		p++;
 		lastHalf = numItems - (p - regProp);
 		if (lastHalf > 0)
-		    memcpy(entry, p, lastHalf);
+		    mch_memmove(entry, p, lastHalf);
 		numItems = (entry - regProp) + lastHalf;
 		p = entry;
 		continue;
 	    }
 	}
@@ -1194,11 +1179,11 @@ serverEventProc(dpy, eventPtr)
     /*
      * Several commands and results could arrive in the property at
      * one time;  each iteration through the outer loop handles a
      * single command or result.
      */
-    for (p = propInfo; (p - propInfo) < numItems; )
+    for (p = propInfo; (long_u)(p - propInfo) < numItems; )
     {
 	/*
 	 * Ignore leading NULs; each command or result starts with a
 	 * NUL so that no matter how badly formed a preceding command
 	 * is, we'll be able to tell that a new command/result is
@@ -1228,11 +1213,11 @@ serverEventProc(dpy, eventPtr)
 	    name = NULL;
 	    resWindow = None;
 	    serial = (char_u *)"";
 	    script = NULL;
 	    enc = NULL;
-	    while (p - propInfo < numItems && *p == '-')
+	    while ((long_u)(p - propInfo) < numItems && *p == '-')
 	    {
 		switch (p[1])
 		{
 		    case 'r':
 			end = skipwhite(p + 2);
@@ -1331,11 +1316,11 @@ serverEventProc(dpy, eventPtr)
 	    p += 2;
 	    gotSerial = 0;
 	    res = (char_u *)"";
 	    code = 0;
 	    enc = NULL;
-	    while ((p-propInfo) < numItems && *p == '-')
+	    while ((long_u)(p - propInfo) < numItems && *p == '-')
 	    {
 		switch (p[1])
 		{
 		    case 'r':
 			if (p[2] == ' ')
@@ -1399,11 +1384,11 @@ serverEventProc(dpy, eventPtr)
 	     */
 	    p += 2;
 	    gotWindow = 0;
 	    str = (char_u *)"";
 	    enc = NULL;
-	    while ((p-propInfo) < numItems && *p == '-')
+	    while ((long_u)(p - propInfo) < numItems && *p == '-')
 	    {
 		switch (p[1])
 		{
 		    case 'n':
 			if (p[2] == ' ')
@@ -1487,15 +1472,14 @@ AppendPropCarefully(dpy, window, propert
 
 
 /*
  * Another X Error handler, just used to check for errors.
  */
-/* ARGSUSED */
     static int
 x_error_check(dpy, error_event)
-    Display	*dpy;
-    XErrorEvent	*error_event;
+    Display	*dpy UNUSED;
+    XErrorEvent	*error_event UNUSED;
 {
     got_x_error = TRUE;
     return 0;
 }
 
--- vim72.orig/src/integration.c
+++ vim72/src/integration.c
@@ -76,11 +76,11 @@
 # define NOCATGETS(x) x
 #endif
 
 /* Functions private to this file */
 static void workshop_connection_closed(void);
-static void messageFromEserve(XtPointer clientData, int *NOTUSED1, XtInputId *NOTUSED2);
+static void messageFromEserve(XtPointer clientData, int *dum1, XtInputId *dum2);
 static void workshop_disconnect(void);
 static void workshop_sensitivity(int num, char *table);
 static void adjust_sign_name(char *filename);
 static void process_menuItem(char *);
 static void process_toolbarButton(char *);
@@ -155,13 +155,14 @@ getCommand(void)
 		return NULL;
 	}
 
 }
 
-/*ARGSUSED*/
 void
-messageFromEserve(XtPointer clientData, int *NOTUSED1, XtInputId *NOTUSED2)
+messageFromEserve(XtPointer clientData UNUSED,
+		  int *dum1 UNUSED,
+		  XtInputId *dum2 UNUSED)
 {
 	char	*cmd;		/* the 1st word of the command */
 
 	cmd = getCommand();
 	if (cmd == NULL) {
@@ -197,11 +198,11 @@ messageFromEserve(XtPointer clientData,
 				color++;
 			}
 			if (sign) {
 				sign++;
 			}
-			/* Change sign name to accomodate a different size? */
+			/* Change sign name to accommodate a different size? */
 			adjust_sign_name(sign);
 			workshop_add_mark_type(idx, color, sign);
 		}
 		HANDLE_ERRORS(cmd);
 		break;
@@ -578,11 +579,11 @@ unrecognised_message(
 	/* abort(); */
 }
 #endif
 
 
-/* Change sign name to accomodate a different size:
+/* Change sign name to accommodate a different size:
  * Create the filename based on the height. The filename format
  * of multisize icons are:
  *    x.xpm   : largest icon
  *    x1.xpm  : smaller icon
  *    x2.xpm  : smallest icon */
@@ -612,10 +613,11 @@ adjust_sign_name(char *filename)
 		strcpy(s, "1.xpm");
 	else
 		strcpy(s, ".xpm");
 }
 
+#if 0
 /* Were we invoked by WorkShop? This function can be used early during startup
    if you want to do things differently if the editor is started standalone
    or in WorkShop mode. For example, in standalone mode you may not want to
    add a footer/message area or a sign gutter. */
 int
@@ -625,10 +627,11 @@ workshop_invoked()
 	if (result == -1) {
 		result = (getenv(NOCATGETS("SPRO_EDITOR_SOCKET")) != NULL);
 	}
 	return result;
 }
+#endif
 
 /* Connect back to eserve */
 void	workshop_connect(XtAppContext context)
 {
 #ifdef INET_SOCKETS
@@ -748,10 +751,11 @@ void	workshop_disconnect()
 
 /*
  * Utility functions
  */
 
+#if 0
 /* Set icon for the window */
 void
 workshop_set_icon(Display *display, Widget shell, char **xpmdata,
 		  int width, int height)
 {
@@ -791,10 +795,11 @@ workshop_set_icon(Display *display, Widg
 		XtVaSetValues(shell,
 		    XtNiconWindow, iconWindow, NULL);
 	}
 	XtFree((char *)xpmAttributes.colorsymbols);
 }
+#endif
 
 /* Minimize and maximize shells. From libutil's shell.cc. */
 
 /* utility functions from libutil's shell.cc */
 static Boolean
@@ -925,11 +930,11 @@ Boolean workshop_get_width_height(int *w
 		*height = hgt;
 	}
 	return success;
 }
 
-
+#if 0
 Boolean workshop_get_rows_cols(int *rows, int *cols)
 {
 	static int	r = 0;
 	static int	c = 0;
 	static Boolean	firstTime = True;
@@ -956,10 +961,11 @@ Boolean workshop_get_rows_cols(int *rows
 		*rows = r;
 		*cols = c;
 	}
 	return success;
 }
+#endif
 
 /*
  * Toolbar code
  */
 
@@ -1041,23 +1047,23 @@ void workshop_set_option_first(char *nam
 		workshop_set_option(name, value);
 	}
 }
 
 
-
+#if 0
 /*
  * Send information to eserve on certain editor events
  * You must make sure these are called when necessary
  */
-
 void workshop_file_closed(char *filename)
 {
 	char buffer[2*MAXPATHLEN];
 	vim_snprintf(buffer, sizeof(buffer),
 			NOCATGETS("deletedFile %s\n"), filename);
 	write(sd, buffer, strlen(buffer));
 }
+#endif
 
 void workshop_file_closed_lineno(char *filename, int lineno)
 {
 	char buffer[2*MAXPATHLEN];
 	vim_snprintf(buffer, sizeof(buffer),
@@ -1084,25 +1090,27 @@ void workshop_file_saved(char *filename)
 	/* Let editor report any moved marks that the eserve client
 	 * should deal with (for example, moving location-based breakpoints) */
 	workshop_moved_marks(filename);
 }
 
-void workshop_move_mark(char *filename, int markId, int newLineno)
+#if 0
+void workshop_file_modified(char *filename)
 {
 	char buffer[2*MAXPATHLEN];
 	vim_snprintf(buffer, sizeof(buffer),
-			NOCATGETS("moveMark %s %d %d\n"), filename, markId, newLineno);
+			NOCATGETS("modifiedFile %s\n"), filename);
 	write(sd, buffer, strlen(buffer));
 }
 
-void workshop_file_modified(char *filename)
+void workshop_move_mark(char *filename, int markId, int newLineno)
 {
 	char buffer[2*MAXPATHLEN];
 	vim_snprintf(buffer, sizeof(buffer),
-			NOCATGETS("modifiedFile %s\n"), filename);
+	       NOCATGETS("moveMark %s %d %d\n"), filename, markId, newLineno);
 	write(sd, buffer, strlen(buffer));
 }
+#endif
 
 void workshop_frame_moved(int new_x, int new_y, int new_w, int new_h)
 {
 	char buffer[200];
 
@@ -1177,14 +1185,16 @@ void workshop_perform_verb(char *verb, v
 		}
 	}
 }
 
 /* Send a message to eserve */
+#if defined(NOHANDS_SUPPORT_FUNCTIONS) || defined(FEAT_BEVAL)
 void workshop_send_message(char *buf)
 {
 	write(sd, buf, strlen(buf));
 }
+#endif
 
 /* Some methods, like currentFile, cursorPos, etc. are missing here.
  * But it looks like these are used for NoHands testing only so we
  * won't bother requiring editors to implement these
  */
--- vim72.orig/src/macros.h
+++ vim72/src/macros.h
@@ -125,19 +125,35 @@
 #define CHARSIZE(c)	(chartab[c] & CT_CELL_MASK)
 
 #ifdef FEAT_LANGMAP
 /*
  * Adjust chars in a language according to 'langmap' option.
- * NOTE that there is NO overhead if 'langmap' is not set; but even
- * when set we only have to do 2 ifs and an array lookup.
+ * NOTE that there is no noticeable overhead if 'langmap' is not set.
+ * When set the overhead for characters < 256 is small.
  * Don't apply 'langmap' if the character comes from the Stuff buffer.
  * The do-while is just to ignore a ';' after the macro.
  */
-# define LANGMAP_ADJUST(c, condition) do { \
-	if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0 && (c) < 256) \
-	    c = langmap_mapchar[c]; \
+# ifdef FEAT_MBYTE
+#  define LANGMAP_ADJUST(c, condition) \
+    do { \
+        if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0) \
+	{ \
+	    if ((c) < 256) \
+		c = langmap_mapchar[c]; \
+	    else \
+		c = langmap_adjust_mb(c); \
+	} \
     } while (0)
+# else
+#  define LANGMAP_ADJUST(c, condition) \
+    do { \
+        if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0 && (c) < 256) \
+            c = langmap_mapchar[c]; \
+    } while (0)
+# endif
+#else
+# define LANGMAP_ADJUST(c, condition) /* nop */
 #endif
 
 /*
  * vim_isbreak() is used very often if 'linebreak' is set, use a macro to make
  * it work fast.
@@ -225,11 +241,11 @@
 # define ZDECODE(c)   update_keys(c ^= decrypt_byte())
 
 #endif
 
 #ifdef STARTUPTIME
-# define TIME_MSG(s) time_msg(s, NULL)
+# define TIME_MSG(s) { if (time_fd != NULL) time_msg(s, NULL); }
 #else
 # define TIME_MSG(s)
 #endif
 
 #ifdef FEAT_VREPLACE
@@ -266,11 +282,11 @@
 # define mb_ptr_back(s, p)  p -= has_mbyte ? ((*mb_head_off)(s, p - 1) + 1) : 1
 /* get length of multi-byte char, not including composing chars */
 # define mb_cptr2len(p)	    (enc_utf8 ? utf_ptr2len(p) : (*mb_ptr2len)(p))
 
 # define MB_COPY_CHAR(f, t) if (has_mbyte) mb_copy_char(&f, &t); else *t++ = *f++
-# define MB_CHARLEN(p)	    (has_mbyte ? mb_charlen(p) : STRLEN(p))
+# define MB_CHARLEN(p)	    (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
 # define PTR2CHAR(p)	    (has_mbyte ? mb_ptr2char(p) : (int)*(p))
 #else
 # define mb_ptr_adv(p)		++p
 # define mb_cptr_adv(p)		++p
 # define mb_ptr_back(s, p)	--p
--- vim72.orig/src/main.c
+++ vim72/src/main.c
@@ -128,14 +128,10 @@ static void prepare_server __ARGS((mparm
 static void cmdsrv_main __ARGS((int *argc, char **argv, char_u *serverName_arg, char_u **serverStr));
 static char_u *serverMakeName __ARGS((char_u *arg, char *cmd));
 #endif
 
 
-#ifdef STARTUPTIME
-static FILE *time_fd = NULL;
-#endif
-
 /*
  * Different types of error messages.
  */
 static char *(main_errors[]) =
 {
@@ -171,10 +167,13 @@ main
     char	**argv;
 {
     char_u	*fname = NULL;		/* file name from command line */
     mparm_T	params;			/* various parameters passed between
 					 * main() and other functions. */
+#ifdef STARTUPTIME
+    int		i;
+#endif
 
     /*
      * Do any system-specific initialisations.  These can NOT use IObuff or
      * NameBuff.  Thus emsg2() cannot be called!
      */
@@ -201,12 +200,19 @@ main
 #ifdef MEM_PROFILE
     atexit(vim_mem_profile_dump);
 #endif
 
 #ifdef STARTUPTIME
-    time_fd = mch_fopen(STARTUPTIME, "a");
-    TIME_MSG("--- VIM STARTING ---");
+    for (i = 1; i < argc; ++i)
+    {
+	if (STRICMP(argv[i], "--startuptime") == 0 && i + 1 < argc)
+	{
+	    time_fd = mch_fopen(argv[i + 1], "a");
+	    TIME_MSG("--- VIM STARTING ---");
+	    break;
+	}
+    }
 #endif
     starttime = time(NULL);
 
 #ifdef __EMX__
     _wildcard(&params.argc, &params.argv);
@@ -358,18 +364,25 @@ main
 # if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
     /*
      * Check if the GUI can be started.  Reset gui.starting if not.
      * Don't know about other systems, stay on the safe side and don't check.
      */
-    if (gui.starting && gui_init_check() == FAIL)
+    if (gui.starting)
     {
-	gui.starting = FALSE;
+	if (gui_init_check() == FAIL)
+	{
+	    gui.starting = FALSE;
 
-	/* When running "evim" or "gvim -y" we need the menus, exit if we
-	 * don't have them. */
-	if (params.evim_mode)
-	    mch_exit(1);
+	    /* When running "evim" or "gvim -y" we need the menus, exit if we
+	     * don't have them. */
+	    if (params.evim_mode)
+		mch_exit(1);
+	}
+#  if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
+	/* Re-initialize locale, it may have been altered by gui_init_check() */
+	init_locale();
+#  endif
     }
 # endif
 #endif
 
     if (GARGCOUNT > 0)
@@ -643,15 +656,16 @@ main
     init_SPAWNO("", SWAP_ANY);
 #endif
 
 #ifdef FEAT_VIMINFO
     /*
-     * Read in registers, history etc, but not marks, from the viminfo file
+     * Read in registers, history etc, but not marks, from the viminfo file.
+     * This is where v:oldfiles gets filled.
      */
     if (*p_viminfo != NUL)
     {
-	read_viminfo(NULL, TRUE, FALSE, FALSE);
+	read_viminfo(NULL, VIF_WANT_INFO | VIF_GET_OLDFILES);
 	TIME_MSG("reading viminfo");
     }
 #endif
 
 #ifdef FEAT_QUICKFIX
@@ -932,12 +946,18 @@ main
 
     TIME_MSG("before starting main loop");
 
     /*
      * Call the main command loop.  This never returns.
+     * For embedded MzScheme the main_loop will be called by Scheme
+     * for proper stack tracking
      */
+#ifndef FEAT_MZSCHEME
     main_loop(FALSE, FALSE);
+#else
+    mzscheme_main();
+#endif
 
     return 0;
 }
 #endif /* PROTO */
 
@@ -1141,10 +1161,22 @@ main_loop(cmdwin, noexmode)
 
 	    setcursor();
 	    cursor_on();
 
 	    do_redraw = FALSE;
+
+#ifdef STARTUPTIME
+	    /* Now that we have drawn the first screen all the startup stuff
+	     * has been done, close any file for startup messages. */
+	    if (time_fd != NULL)
+	    {
+		TIME_MSG("first screen update");
+		TIME_MSG("--- VIM STARTED ---");
+		fclose(time_fd);
+		time_fd = NULL;
+	    }
+#endif
 	}
 #ifdef FEAT_GUI
 	if (need_mouse_correct)
 	    gui_mouse_correct();
 #endif
@@ -1455,11 +1487,12 @@ parse_command_name(parmp)
 #endif
 	parmp->evim_mode = TRUE;
 	++initstr;
     }
 
-    if (TOLOWER_ASC(initstr[0]) == 'g' || initstr[0] == 'k')
+    /* "gvim" starts the GUI.  Also accept "Gvim" for MS-Windows. */
+    if (TOLOWER_ASC(initstr[0]) == 'g')
     {
 	main_start_gui();
 #ifdef FEAT_GUI
 	++initstr;
 #endif
@@ -1501,16 +1534,16 @@ parse_command_name(parmp)
  * Get the name of the display, before gui_prepare() removes it from
  * argv[].  Used for the xterm-clipboard display.
  *
  * Also find the --server... arguments and --socketid and --windowid
  */
-/*ARGSUSED*/
     static void
 early_arg_scan(parmp)
-    mparm_T	*parmp;
+    mparm_T	*parmp UNUSED;
 {
-#if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER)
+#if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER) \
+	|| !defined(FEAT_NETBEANS_INTG)
     int		argc = parmp->argc;
     char	**argv = parmp->argv;
     int		i;
 
     for (i = 1; i < argc; i++)
@@ -1578,10 +1611,18 @@ early_arg_scan(parmp)
 # endif
 # ifdef FEAT_GUI_GTK
 	else if (STRICMP(argv[i], "--echo-wid") == 0)
 	    echo_wid_arg = TRUE;
 # endif
+# ifndef FEAT_NETBEANS_INTG
+	else if (strncmp(argv[i], "-nb", (size_t)3) == 0)
+        {
+            mch_errmsg(_("'-nb' cannot be used: not enabled at compile time\n"));
+            mch_exit(2);
+        }
+# endif
+
     }
 #endif
 }
 
 /*
@@ -1690,10 +1731,15 @@ command_line_scan(parmp)
 		else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0)
 		{
 		    want_argument = TRUE;
 		    argv_idx += 3;
 		}
+		else if (STRNICMP(argv[0] + argv_idx, "startuptime", 11) == 0)
+		{
+		    want_argument = TRUE;
+		    argv_idx += 11;
+		}
 #ifdef FEAT_CLIENTSERVER
 		else if (STRNICMP(argv[0] + argv_idx, "serverlist", 10) == 0)
 		    ; /* already processed -- no arg */
 		else if (STRNICMP(argv[0] + argv_idx, "servername", 10) == 0
 		       || STRNICMP(argv[0] + argv_idx, "serversend", 10) == 0)
@@ -2021,11 +2067,11 @@ command_line_scan(parmp)
 		 */
 		if (argv[0][argv_idx] != NUL)
 		    mainerr(ME_GARBAGE, (char_u *)argv[0]);
 
 		--argc;
-		if (argc < 1 && c != 'S')
+		if (argc < 1 && c != 'S')  /* -S has an optional argument */
 		    mainerr_arg_missing((char_u *)argv[0]);
 		++argv;
 		argv_idx = -1;
 
 		switch (c)
@@ -2062,15 +2108,20 @@ command_line_scan(parmp)
 		    else
 			parmp->commands[parmp->n_commands++] =
 							    (char_u *)argv[0];
 		    break;
 
-		case '-':	/* "--cmd {command}" execute command */
-		    if (parmp->n_pre_commands >= MAX_ARG_CMDS)
-			mainerr(ME_EXTRA_CMD, NULL);
-		    parmp->pre_commands[parmp->n_pre_commands++] =
+		case '-':
+		    if (argv[-1][2] == 'c')
+		    {
+			/* "--cmd {command}" execute command */
+			if (parmp->n_pre_commands >= MAX_ARG_CMDS)
+			    mainerr(ME_EXTRA_CMD, NULL);
+			parmp->pre_commands[parmp->n_pre_commands++] =
 							    (char_u *)argv[0];
+		    }
+		    /* "--startuptime <file>" already handled */
 		    break;
 
 	    /*	case 'd':   -d {device} is handled in mch_check_win() for the
 	     *		    Amiga */
 
@@ -2359,22 +2410,21 @@ read_stdin()
      * Close stdin and dup it from stderr.  Required for GPM to work
      * properly, and for running external commands.
      * Is there any other system that cannot do this?
      */
     close(0);
-    dup(2);
+    ignored = dup(2);
 #endif
 }
 
 /*
  * Create the requested number of windows and edit buffers in them.
  * Also does recovery if "recoverymode" set.
  */
-/*ARGSUSED*/
     static void
 create_windows(parmp)
-    mparm_T	*parmp;
+    mparm_T	*parmp UNUSED;
 {
 #ifdef FEAT_WINDOWS
     int		dorewind;
     int		done = 0;
 
@@ -2584,11 +2634,11 @@ edit_buffers(parmp)
 # ifdef HAS_SWAP_EXISTS_ACTION
 	    swap_exists_did_quit = FALSE;
 # endif
 	    (void)do_ecmd(0, arg_idx < GARGCOUNT
 			  ? alist_name(&GARGLIST[arg_idx]) : NULL,
-			  NULL, NULL, ECMD_LASTL, ECMD_HIDE);
+			  NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin);
 # ifdef HAS_SWAP_EXISTS_ACTION
 	    if (swap_exists_did_quit)
 	    {
 		/* abort or quit selected */
 		if (got_int || only_one_window())
@@ -3105,10 +3155,13 @@ usage()
     main_msg(_("--remote-send <keys>\tSend <keys> to a Vim server and exit"));
     main_msg(_("--remote-expr <expr>\tEvaluate <expr> in a Vim server and print result"));
     main_msg(_("--serverlist\t\tList available Vim server names and exit"));
     main_msg(_("--servername <name>\tSend to/become the Vim server <name>"));
 #endif
+#ifdef STARTUPTIME
+    main_msg(_("--startuptime <file>\tWrite startup timing messages to <file>"));
+#endif
 #ifdef FEAT_VIMINFO
     main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo"));
 #endif
     main_msg(_("-h  or  --help\tPrint Help (this message) and exit"));
     main_msg(_("--version\t\tPrint version information and exit"));
@@ -3194,10 +3247,24 @@ check_swap_exists_action()
 #if defined(STARTUPTIME) || defined(PROTO)
 static void time_diff __ARGS((struct timeval *then, struct timeval *now));
 
 static struct timeval	prev_timeval;
 
+# ifdef WIN3264
+/*
+ * Windows doesn't have gettimeofday(), although it does have struct timeval.
+ */
+    static int
+gettimeofday(struct timeval *tv, char *dummy)
+{
+    long t = clock();
+    tv->tv_sec = t / CLOCKS_PER_SEC;
+    tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
+    return 0;
+}
+# endif
+
 /*
  * Save the previous time before doing something that could nest.
  * set "*tv_rel" to the time elapsed so far.
  */
     void
@@ -3282,24 +3349,10 @@ time_msg(msg, tv_start)
 	prev_timeval = now;
 	fprintf(time_fd, ": %s\n", msg);
     }
 }
 
-# ifdef WIN3264
-/*
- * Windows doesn't have gettimeofday(), although it does have struct timeval.
- */
-    int
-gettimeofday(struct timeval *tv, char *dummy)
-{
-    long t = clock();
-    tv->tv_sec = t / CLOCKS_PER_SEC;
-    tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
-    return 0;
-}
-# endif
-
 #endif
 
 #if defined(FEAT_CLIENTSERVER) || defined(PROTO)
 
 /*
@@ -3637,11 +3690,11 @@ cmdsrv_main(argc, argv, serverName_arg,
 	    if (called_emsg)
 		mch_errmsg("\n");
 	}
 	else if (STRICMP(argv[i], "--servername") == 0)
 	{
-	    /* Alredy processed. Take it out of the command line */
+	    /* Already processed. Take it out of the command line */
 	    i++;
 	    continue;
 	}
 	else
 	{
@@ -3838,14 +3891,13 @@ eval_client_expr_to_string(expr)
 /*
  * If conversion is needed, convert "data" from "client_enc" to 'encoding' and
  * return an allocated string.  Otherwise return "data".
  * "*tofree" is set to the result when it needs to be freed later.
  */
-/*ARGSUSED*/
     char_u *
 serverConvert(client_enc, data, tofree)
-    char_u *client_enc;
+    char_u *client_enc UNUSED;
     char_u *data;
     char_u **tofree;
 {
     char_u	*res = data;
 
--- vim72.orig/src/mark.c
+++ vim72/src/mark.c
@@ -882,14 +882,13 @@ ex_delmarks(eap)
 
 #if defined(FEAT_JUMPLIST) || defined(PROTO)
 /*
  * print the jumplist
  */
-/*ARGSUSED*/
     void
 ex_jumps(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     int		i;
     char_u	*name;
 
     cleanup_jumplist();
@@ -931,14 +930,13 @@ ex_jumps(eap)
 }
 
 /*
  * print the changelist
  */
-/*ARGSUSED*/
     void
 ex_changes(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     int		i;
     char_u	*name;
 
     /* Highlight title */
@@ -1021,10 +1019,13 @@ mark_adjust(line1, line2, amount, amount
 {
     int		i;
     int		fnum = curbuf->b_fnum;
     linenr_T	*lp;
     win_T	*win;
+#ifdef FEAT_WINDOWS
+    tabpage_T	*tab;
+#endif
 
     if (line2 < line1 && amount_after == 0L)	    /* nothing to do */
 	return;
 
     if (!cmdmod.lockmarks)
@@ -1062,11 +1063,11 @@ mark_adjust(line1, line2, amount, amount
 
 #ifdef FEAT_QUICKFIX
 	/* quickfix marks */
 	qf_mark_adjust(NULL, line1, line2, amount, amount_after);
 	/* location lists */
-	FOR_ALL_WINDOWS(win)
+	FOR_ALL_TAB_WINDOWS(tab, win)
 	    qf_mark_adjust(win, line1, line2, amount, amount_after);
 #endif
 
 #ifdef FEAT_SIGNS
 	sign_mark_adjust(line1, line2, amount, amount_after);
@@ -1084,11 +1085,11 @@ mark_adjust(line1, line2, amount, amount
 	one_adjust_nodel(&(saved_cursor.lnum));
 
     /*
      * Adjust items in all windows related to the current buffer.
      */
-    FOR_ALL_WINDOWS(win)
+    FOR_ALL_TAB_WINDOWS(tab, win)
     {
 #ifdef FEAT_JUMPLIST
 	if (!cmdmod.lockmarks)
 	    /* Marks in the jumplist.  When deleting lines, this may create
 	     * duplicate marks in the jumplist, they will be removed later. */
@@ -1625,19 +1626,21 @@ write_one_mark(fp_out, c, pos)
 	fprintf(fp_out, "\t%c\t%ld\t%d\n", c, (long)pos->lnum, (int)pos->col);
 }
 
 /*
  * Handle marks in the viminfo file:
- * fp_out == NULL   read marks for current buffer only
- * fp_out != NULL   copy marks for buffers not in buffer list
+ * fp_out != NULL: copy marks for buffers not in buffer list
+ * fp_out == NULL && (flags & VIF_WANT_MARKS): read marks for curbuf only
+ * fp_out == NULL && (flags & VIF_GET_OLDFILES | VIF_FORCEIT): fill v:oldfiles
  */
     void
-copy_viminfo_marks(virp, fp_out, count, eof)
+copy_viminfo_marks(virp, fp_out, count, eof, flags)
     vir_T	*virp;
     FILE	*fp_out;
     int		count;
     int		eof;
+    int		flags;
 {
     char_u	*line = virp->vir_line;
     buf_T	*buf;
     int		num_marked_files;
     int		load_marks;
@@ -1645,14 +1648,27 @@ copy_viminfo_marks(virp, fp_out, count,
     char_u	*str;
     int		i;
     char_u	*p;
     char_u	*name_buf;
     pos_T	pos;
+#ifdef FEAT_EVAL
+    list_T	*list = NULL;
+#endif
 
     if ((name_buf = alloc(LSIZE)) == NULL)
 	return;
     *name_buf = NUL;
+
+#ifdef FEAT_EVAL
+    if (fp_out == NULL && (flags & (VIF_GET_OLDFILES | VIF_FORCEIT)))
+    {
+	list = list_alloc();
+	if (list != NULL)
+	    set_vim_var_list(VV_OLDFILES, list);
+    }
+#endif
+
     num_marked_files = get_viminfo_parameter('\'');
     while (!eof && (count < num_marked_files || fp_out == NULL))
     {
 	if (line[0] != '>')
 	{
@@ -1679,18 +1695,23 @@ copy_viminfo_marks(virp, fp_out, count,
 	    p--;
 	if (*p)
 	    p++;
 	*p = NUL;
 
+#ifdef FEAT_EVAL
+	if (list != NULL)
+	    list_append_string(list, str, -1);
+#endif
+
 	/*
 	 * If fp_out == NULL, load marks for current buffer.
 	 * If fp_out != NULL, copy marks for buffers not in buflist.
 	 */
 	load_marks = copy_marks_out = FALSE;
 	if (fp_out == NULL)
 	{
-	    if (curbuf->b_ffname != NULL)
+	    if ((flags & VIF_WANT_MARKS) && curbuf->b_ffname != NULL)
 	    {
 		if (*name_buf == NUL)	    /* only need to do this once */
 		    home_replace(NULL, curbuf->b_ffname, name_buf, LSIZE, TRUE);
 		if (fnamecmp(str, name_buf) == 0)
 		    load_marks = TRUE;
--- vim72.orig/src/mbyte.c
+++ vim72/src/mbyte.c
@@ -24,11 +24,11 @@
  *		    The cell width on the display needs to be determined from
  *		    the character value.
  *		    Recognizing bytes is easy: 0xxx.xxxx is a single-byte
  *		    char, 10xx.xxxx is a trailing byte, 11xx.xxxx is a leading
  *		    byte of a multi-byte character.
- *		    To make things complicated, up to two composing characters
+ *		    To make things complicated, up to six composing characters
  *		    are allowed.  These are drawn on top of the first char.
  *		    For most editing the sequence of bytes with composing
  *		    characters included is considered to be one character.
  * "enc_unicode"    When 2 use 16-bit Unicode characters (or UTF-16).
  *		    When 4 use 32-but Unicode characters.
@@ -125,29 +125,50 @@
 
 static int enc_canon_search __ARGS((char_u *name));
 static int dbcs_char2len __ARGS((int c));
 static int dbcs_char2bytes __ARGS((int c, char_u *buf));
 static int dbcs_ptr2len __ARGS((char_u *p));
+static int dbcs_ptr2len_len __ARGS((char_u *p, int size));
+static int utf_ptr2cells_len __ARGS((char_u *p, int size));
 static int dbcs_char2cells __ARGS((int c));
+static int dbcs_ptr2cells_len __ARGS((char_u *p, int size));
 static int dbcs_ptr2char __ARGS((char_u *p));
 
-/* Lookup table to quickly get the length in bytes of a UTF-8 character from
- * the first byte of a UTF-8 string.  Bytes which are illegal when used as the
- * first byte have a one, because these will be used separately. */
+/*
+ * Lookup table to quickly get the length in bytes of a UTF-8 character from
+ * the first byte of a UTF-8 string.
+ * Bytes which are illegal when used as the first byte have a 1.
+ * The NUL byte has length 1.
+ */
 static char utf8len_tab[256] =
 {
     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
     1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /*bogus*/
-    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /*bogus*/
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
     3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1,
 };
 
 /*
+ * Like utf8len_tab above, but using a zero for illegal lead bytes.
+ */
+static char utf8len_tab_zero[256] =
+{
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+    3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0,
+};
+
+/*
  * XIM often causes trouble.  Define XIM_DEBUG to get a log of XIM callbacks
  * in the "xim.log" file.
  */
 /* #define XIM_DEBUG */
 #ifdef XIM_DEBUG
@@ -604,35 +625,41 @@ codepage_invalid:
      * Set the function pointers.
      */
     if (enc_utf8)
     {
 	mb_ptr2len = utfc_ptr2len;
+	mb_ptr2len_len = utfc_ptr2len_len;
 	mb_char2len = utf_char2len;
 	mb_char2bytes = utf_char2bytes;
 	mb_ptr2cells = utf_ptr2cells;
+	mb_ptr2cells_len = utf_ptr2cells_len;
 	mb_char2cells = utf_char2cells;
 	mb_off2cells = utf_off2cells;
 	mb_ptr2char = utf_ptr2char;
 	mb_head_off = utf_head_off;
     }
     else if (enc_dbcs != 0)
     {
 	mb_ptr2len = dbcs_ptr2len;
+	mb_ptr2len_len = dbcs_ptr2len_len;
 	mb_char2len = dbcs_char2len;
 	mb_char2bytes = dbcs_char2bytes;
 	mb_ptr2cells = dbcs_ptr2cells;
+	mb_ptr2cells_len = dbcs_ptr2cells_len;
 	mb_char2cells = dbcs_char2cells;
 	mb_off2cells = dbcs_off2cells;
 	mb_ptr2char = dbcs_ptr2char;
 	mb_head_off = dbcs_head_off;
     }
     else
     {
 	mb_ptr2len = latin_ptr2len;
+	mb_ptr2len_len = latin_ptr2len_len;
 	mb_char2len = latin_char2len;
 	mb_char2bytes = latin_char2bytes;
 	mb_ptr2cells = latin_ptr2cells;
+	mb_ptr2cells_len = latin_ptr2cells_len;
 	mb_char2cells = latin_char2cells;
 	mb_off2cells = latin_off2cells;
 	mb_ptr2char = latin_ptr2char;
 	mb_head_off = latin_head_off;
     }
@@ -715,11 +742,11 @@ codepage_invalid:
 		     * mblen() should return -1 for invalid (means the leading
 		     * multibyte) character.  However there are some platforms
 		     * where mblen() returns 0 for invalid character.
 		     * Therefore, following condition includes 0.
 		     */
-		    (void)mblen(NULL, 0);	/* First reset the state. */
+		    ignored = mblen(NULL, 0);	/* First reset the state. */
 		    if (mblen(buf, (size_t)1) <= 0)
 			n = 2;
 		    else
 			n = 1;
 		}
@@ -1013,14 +1040,13 @@ dbcs_class(lead, trail)
 /*
  * mb_char2len() function pointer.
  * Return length in bytes of character "c".
  * Returns 1 for a single-byte character.
  */
-/* ARGSUSED */
     int
 latin_char2len(c)
-    int		c;
+    int		c UNUSED;
 {
     return 1;
 }
 
     static int
@@ -1068,11 +1094,10 @@ dbcs_char2bytes(c, buf)
 /*
  * mb_ptr2len() function pointer.
  * Get byte length of character at "*p" but stop at a NUL.
  * For UTF-8 this includes following composing characters.
  * Returns 0 when *p is NUL.
- *
  */
     int
 latin_ptr2len(p)
     char_u	*p;
 {
@@ -1090,14 +1115,48 @@ dbcs_ptr2len(p)
     if (len == 2 && p[1] == NUL)
 	len = 1;
     return len;
 }
 
+/*
+ * mb_ptr2len_len() function pointer.
+ * Like mb_ptr2len(), but limit to read "size" bytes.
+ * Returns 0 for an empty string.
+ * Returns 1 for an illegal char or an incomplete byte sequence.
+ */
+    int
+latin_ptr2len_len(p, size)
+    char_u	*p;
+    int		size;
+{
+    if (size < 1 || *p == NUL)
+	return 0;
+    return 1;
+}
+
+    static int
+dbcs_ptr2len_len(p, size)
+    char_u	*p;
+    int		size;
+{
+    int		len;
+
+    if (size < 1 || *p == NUL)
+	return 0;
+    if (size == 1)
+	return 1;
+    /* Check that second byte is not missing. */
+    len = MB_BYTE2LEN(*p);
+    if (len == 2 && p[1] == NUL)
+	len = 1;
+    return len;
+}
+
 struct interval
 {
-    unsigned short first;
-    unsigned short last;
+    long first;
+    long last;
 };
 static int intable __ARGS((struct interval *table, size_t size, int c));
 
 /*
  * Return TRUE if "c" is in "table[size / sizeof(struct interval)]".
@@ -1139,66 +1198,238 @@ intable(table, size, c)
  */
     int
 utf_char2cells(c)
     int		c;
 {
-    /* sorted list of non-overlapping intervals of East Asian Ambiguous
-     * characters, generated with:
-     * "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */
-    static struct interval ambiguous[] = {
-	{0x00A1, 0x00A1}, {0x00A4, 0x00A4}, {0x00A7, 0x00A8},
-	{0x00AA, 0x00AA}, {0x00AE, 0x00AE}, {0x00B0, 0x00B4},
-	{0x00B6, 0x00BA}, {0x00BC, 0x00BF}, {0x00C6, 0x00C6},
-	{0x00D0, 0x00D0}, {0x00D7, 0x00D8}, {0x00DE, 0x00E1},
-	{0x00E6, 0x00E6}, {0x00E8, 0x00EA}, {0x00EC, 0x00ED},
-	{0x00F0, 0x00F0}, {0x00F2, 0x00F3}, {0x00F7, 0x00FA},
-	{0x00FC, 0x00FC}, {0x00FE, 0x00FE}, {0x0101, 0x0101},
-	{0x0111, 0x0111}, {0x0113, 0x0113}, {0x011B, 0x011B},
-	{0x0126, 0x0127}, {0x012B, 0x012B}, {0x0131, 0x0133},
-	{0x0138, 0x0138}, {0x013F, 0x0142}, {0x0144, 0x0144},
-	{0x0148, 0x014B}, {0x014D, 0x014D}, {0x0152, 0x0153},
-	{0x0166, 0x0167}, {0x016B, 0x016B}, {0x01CE, 0x01CE},
-	{0x01D0, 0x01D0}, {0x01D2, 0x01D2}, {0x01D4, 0x01D4},
-	{0x01D6, 0x01D6}, {0x01D8, 0x01D8}, {0x01DA, 0x01DA},
-	{0x01DC, 0x01DC}, {0x0251, 0x0251}, {0x0261, 0x0261},
-	{0x02C4, 0x02C4}, {0x02C7, 0x02C7}, {0x02C9, 0x02CB},
-	{0x02CD, 0x02CD}, {0x02D0, 0x02D0}, {0x02D8, 0x02DB},
-	{0x02DD, 0x02DD}, {0x02DF, 0x02DF}, {0x0391, 0x03A1},
-	{0x03A3, 0x03A9}, {0x03B1, 0x03C1}, {0x03C3, 0x03C9},
-	{0x0401, 0x0401}, {0x0410, 0x044F}, {0x0451, 0x0451},
-	{0x2010, 0x2010}, {0x2013, 0x2016}, {0x2018, 0x2019},
-	{0x201C, 0x201D}, {0x2020, 0x2022}, {0x2024, 0x2027},
-	{0x2030, 0x2030}, {0x2032, 0x2033}, {0x2035, 0x2035},
-	{0x203B, 0x203B}, {0x203E, 0x203E}, {0x2074, 0x2074},
-	{0x207F, 0x207F}, {0x2081, 0x2084}, {0x20AC, 0x20AC},
-	{0x2103, 0x2103}, {0x2105, 0x2105}, {0x2109, 0x2109},
-	{0x2113, 0x2113}, {0x2116, 0x2116}, {0x2121, 0x2122},
-	{0x2126, 0x2126}, {0x212B, 0x212B}, {0x2153, 0x2154},
-	{0x215B, 0x215E}, {0x2160, 0x216B}, {0x2170, 0x2179},
-	{0x2190, 0x2199}, {0x21B8, 0x21B9}, {0x21D2, 0x21D2},
-	{0x21D4, 0x21D4}, {0x21E7, 0x21E7}, {0x2200, 0x2200},
-	{0x2202, 0x2203}, {0x2207, 0x2208}, {0x220B, 0x220B},
-	{0x220F, 0x220F}, {0x2211, 0x2211}, {0x2215, 0x2215},
-	{0x221A, 0x221A}, {0x221D, 0x2220}, {0x2223, 0x2223},
-	{0x2225, 0x2225}, {0x2227, 0x222C}, {0x222E, 0x222E},
-	{0x2234, 0x2237}, {0x223C, 0x223D}, {0x2248, 0x2248},
-	{0x224C, 0x224C}, {0x2252, 0x2252}, {0x2260, 0x2261},
-	{0x2264, 0x2267}, {0x226A, 0x226B}, {0x226E, 0x226F},
-	{0x2282, 0x2283}, {0x2286, 0x2287}, {0x2295, 0x2295},
-	{0x2299, 0x2299}, {0x22A5, 0x22A5}, {0x22BF, 0x22BF},
-	{0x2312, 0x2312}, {0x2460, 0x24E9}, {0x24EB, 0x254B},
-	{0x2550, 0x2573}, {0x2580, 0x258F}, {0x2592, 0x2595},
-	{0x25A0, 0x25A1}, {0x25A3, 0x25A9}, {0x25B2, 0x25B3},
-	{0x25B6, 0x25B7}, {0x25BC, 0x25BD}, {0x25C0, 0x25C1},
-	{0x25C6, 0x25C8}, {0x25CB, 0x25CB}, {0x25CE, 0x25D1},
-	{0x25E2, 0x25E5}, {0x25EF, 0x25EF}, {0x2605, 0x2606},
-	{0x2609, 0x2609}, {0x260E, 0x260F}, {0x2614, 0x2615},
-	{0x261C, 0x261C}, {0x261E, 0x261E}, {0x2640, 0x2640},
-	{0x2642, 0x2642}, {0x2660, 0x2661}, {0x2663, 0x2665},
-	{0x2667, 0x266A}, {0x266C, 0x266D}, {0x266F, 0x266F},
-	{0x273D, 0x273D}, {0x2776, 0x277F}, {0xE000, 0xF8FF},
-	{0xFFFD, 0xFFFD}, /* {0xF0000, 0xFFFFD}, {0x100000, 0x10FFFD} */
+    /* Sorted list of non-overlapping intervals of East Asian double width
+     * characters, generated with ../runtime/tools/unicode.vim. */
+    static struct interval doublewidth[] =
+    {
+	{0x1100, 0x115f},
+	{0x11a3, 0x11a7},
+	{0x11fa, 0x11ff},
+	{0x2329, 0x232a},
+	{0x2e80, 0x2e99},
+	{0x2e9b, 0x2ef3},
+	{0x2f00, 0x2fd5},
+	{0x2ff0, 0x2ffb},
+	{0x3000, 0x3029},
+	{0x3030, 0x303e},
+	{0x3041, 0x3096},
+	{0x309b, 0x30ff},
+	{0x3105, 0x312d},
+	{0x3131, 0x318e},
+	{0x3190, 0x31b7},
+	{0x31c0, 0x31e3},
+	{0x31f0, 0x321e},
+	{0x3220, 0x3247},
+	{0x3250, 0x32fe},
+	{0x3300, 0x4dbf},
+	{0x4e00, 0xa48c},
+	{0xa490, 0xa4c6},
+	{0xa960, 0xa97c},
+	{0xac00, 0xd7a3},
+	{0xd7b0, 0xd7c6},
+	{0xd7cb, 0xd7fb},
+	{0xf900, 0xfaff},
+	{0xfe10, 0xfe19},
+	{0xfe30, 0xfe52},
+	{0xfe54, 0xfe66},
+	{0xfe68, 0xfe6b},
+	{0xff01, 0xff60},
+	{0xffe0, 0xffe6},
+	{0x1f200, 0x1f200},
+	{0x1f210, 0x1f231},
+	{0x1f240, 0x1f248},
+	{0x20000, 0x2fffd},
+	{0x30000, 0x3fffd}
+    };
+    /* Sorted list of non-overlapping intervals of East Asian Ambiguous
+     * characters, generated with ../runtime/tools/unicode.vim. */
+    static struct interval ambiguous[] =
+    {
+	{0x00a1, 0x00a1},
+	{0x00a4, 0x00a4},
+	{0x00a7, 0x00a8},
+	{0x00aa, 0x00aa},
+	{0x00ad, 0x00ae},
+	{0x00b0, 0x00b4},
+	{0x00b6, 0x00ba},
+	{0x00bc, 0x00bf},
+	{0x00c6, 0x00c6},
+	{0x00d0, 0x00d0},
+	{0x00d7, 0x00d8},
+	{0x00de, 0x00e1},
+	{0x00e6, 0x00e6},
+	{0x00e8, 0x00ea},
+	{0x00ec, 0x00ed},
+	{0x00f0, 0x00f0},
+	{0x00f2, 0x00f3},
+	{0x00f7, 0x00fa},
+	{0x00fc, 0x00fc},
+	{0x00fe, 0x00fe},
+	{0x0101, 0x0101},
+	{0x0111, 0x0111},
+	{0x0113, 0x0113},
+	{0x011b, 0x011b},
+	{0x0126, 0x0127},
+	{0x012b, 0x012b},
+	{0x0131, 0x0133},
+	{0x0138, 0x0138},
+	{0x013f, 0x0142},
+	{0x0144, 0x0144},
+	{0x0148, 0x014b},
+	{0x014d, 0x014d},
+	{0x0152, 0x0153},
+	{0x0166, 0x0167},
+	{0x016b, 0x016b},
+	{0x01ce, 0x01ce},
+	{0x01d0, 0x01d0},
+	{0x01d2, 0x01d2},
+	{0x01d4, 0x01d4},
+	{0x01d6, 0x01d6},
+	{0x01d8, 0x01d8},
+	{0x01da, 0x01da},
+	{0x01dc, 0x01dc},
+	{0x0251, 0x0251},
+	{0x0261, 0x0261},
+	{0x02c4, 0x02c4},
+	{0x02c7, 0x02c7},
+	{0x02c9, 0x02cb},
+	{0x02cd, 0x02cd},
+	{0x02d0, 0x02d0},
+	{0x02d8, 0x02db},
+	{0x02dd, 0x02dd},
+	{0x02df, 0x02df},
+	{0x0391, 0x03a1},
+	{0x03a3, 0x03a9},
+	{0x03b1, 0x03c1},
+	{0x03c3, 0x03c9},
+	{0x0401, 0x0401},
+	{0x0410, 0x044f},
+	{0x0451, 0x0451},
+	{0x2010, 0x2010},
+	{0x2013, 0x2016},
+	{0x2018, 0x2019},
+	{0x201c, 0x201d},
+	{0x2020, 0x2022},
+	{0x2024, 0x2027},
+	{0x2030, 0x2030},
+	{0x2032, 0x2033},
+	{0x2035, 0x2035},
+	{0x203b, 0x203b},
+	{0x203e, 0x203e},
+	{0x2074, 0x2074},
+	{0x207f, 0x207f},
+	{0x2081, 0x2084},
+	{0x20ac, 0x20ac},
+	{0x2103, 0x2103},
+	{0x2105, 0x2105},
+	{0x2109, 0x2109},
+	{0x2113, 0x2113},
+	{0x2116, 0x2116},
+	{0x2121, 0x2122},
+	{0x2126, 0x2126},
+	{0x212b, 0x212b},
+	{0x2153, 0x2154},
+	{0x215b, 0x215e},
+	{0x2160, 0x216b},
+	{0x2170, 0x2179},
+	{0x2189, 0x2189},
+	{0x2190, 0x2199},
+	{0x21b8, 0x21b9},
+	{0x21d2, 0x21d2},
+	{0x21d4, 0x21d4},
+	{0x21e7, 0x21e7},
+	{0x2200, 0x2200},
+	{0x2202, 0x2203},
+	{0x2207, 0x2208},
+	{0x220b, 0x220b},
+	{0x220f, 0x220f},
+	{0x2211, 0x2211},
+	{0x2215, 0x2215},
+	{0x221a, 0x221a},
+	{0x221d, 0x2220},
+	{0x2223, 0x2223},
+	{0x2225, 0x2225},
+	{0x2227, 0x222c},
+	{0x222e, 0x222e},
+	{0x2234, 0x2237},
+	{0x223c, 0x223d},
+	{0x2248, 0x2248},
+	{0x224c, 0x224c},
+	{0x2252, 0x2252},
+	{0x2260, 0x2261},
+	{0x2264, 0x2267},
+	{0x226a, 0x226b},
+	{0x226e, 0x226f},
+	{0x2282, 0x2283},
+	{0x2286, 0x2287},
+	{0x2295, 0x2295},
+	{0x2299, 0x2299},
+	{0x22a5, 0x22a5},
+	{0x22bf, 0x22bf},
+	{0x2312, 0x2312},
+	{0x2460, 0x24e9},
+	{0x24eb, 0x254b},
+	{0x2550, 0x2573},
+	{0x2580, 0x258f},
+	{0x2592, 0x2595},
+	{0x25a0, 0x25a1},
+	{0x25a3, 0x25a9},
+	{0x25b2, 0x25b3},
+	{0x25b6, 0x25b7},
+	{0x25bc, 0x25bd},
+	{0x25c0, 0x25c1},
+	{0x25c6, 0x25c8},
+	{0x25cb, 0x25cb},
+	{0x25ce, 0x25d1},
+	{0x25e2, 0x25e5},
+	{0x25ef, 0x25ef},
+	{0x2605, 0x2606},
+	{0x2609, 0x2609},
+	{0x260e, 0x260f},
+	{0x2614, 0x2615},
+	{0x261c, 0x261c},
+	{0x261e, 0x261e},
+	{0x2640, 0x2640},
+	{0x2642, 0x2642},
+	{0x2660, 0x2661},
+	{0x2663, 0x2665},
+	{0x2667, 0x266a},
+	{0x266c, 0x266d},
+	{0x266f, 0x266f},
+	{0x269e, 0x269f},
+	{0x26be, 0x26bf},
+	{0x26c4, 0x26cd},
+	{0x26cf, 0x26e1},
+	{0x26e3, 0x26e3},
+	{0x26e8, 0x26ff},
+	{0x273d, 0x273d},
+	{0x2757, 0x2757},
+	{0x2776, 0x277f},
+	{0x2b55, 0x2b59},
+	{0x3248, 0x324f},
+	{0xe000, 0xf8ff},
+	{0xfffd, 0xfffd},
+	{0x1f100, 0x1f10a},
+	{0x1f110, 0x1f12d},
+	{0x1f131, 0x1f131},
+	{0x1f13d, 0x1f13d},
+	{0x1f13f, 0x1f13f},
+	{0x1f142, 0x1f142},
+	{0x1f146, 0x1f146},
+	{0x1f14a, 0x1f14e},
+	{0x1f157, 0x1f157},
+	{0x1f15f, 0x1f15f},
+	{0x1f179, 0x1f179},
+	{0x1f17b, 0x1f17c},
+	{0x1f17f, 0x1f17f},
+	{0x1f18a, 0x1f18d},
+	{0x1f190, 0x1f190},
+	{0xf0000, 0xffffd},
+	{0x100000, 0x10fffd}
     };
 
     if (c >= 0x100)
     {
 #ifdef USE_WCHAR_FUNCTIONS
@@ -1213,24 +1444,11 @@ utf_char2cells(c)
 	if (n > 1)
 	    return n;
 #else
 	if (!utf_printable(c))
 	    return 6;		/* unprintable, displays <xxxx> */
-	if (c >= 0x1100
-	    && (c <= 0x115f			/* Hangul Jamo */
-		|| c == 0x2329
-		|| c == 0x232a
-		|| (c >= 0x2e80 && c <= 0xa4cf
-		    && c != 0x303f)		/* CJK ... Yi */
-		|| (c >= 0xac00 && c <= 0xd7a3)	/* Hangul Syllables */
-		|| (c >= 0xf900 && c <= 0xfaff)	/* CJK Compatibility
-						   Ideographs */
-		|| (c >= 0xfe30 && c <= 0xfe6f)	/* CJK Compatibility Forms */
-		|| (c >= 0xff00 && c <= 0xff60)	/* Fullwidth Forms */
-		|| (c >= 0xffe0 && c <= 0xffe6)
-		|| (c >= 0x20000 && c <= 0x2fffd)
-		|| (c >= 0x30000 && c <= 0x3fffd)))
+	if (intable(doublewidth, sizeof(doublewidth), c))
 	    return 2;
 #endif
     }
 
     /* Characters below 0x100 are influenced by 'isprint' option */
@@ -1246,14 +1464,13 @@ utf_char2cells(c)
 /*
  * mb_ptr2cells() function pointer.
  * Return the number of display cells character at "*p" occupies.
  * This doesn't take care of unprintable characters, use ptr2cells() for that.
  */
-/*ARGSUSED*/
     int
 latin_ptr2cells(p)
-    char_u	*p;
+    char_u	*p UNUSED;
 {
     return 1;
 }
 
     int
@@ -1287,18 +1504,66 @@ dbcs_ptr2cells(p)
 	return 1;
     return MB_BYTE2LEN(*p);
 }
 
 /*
+ * mb_ptr2cells_len() function pointer.
+ * Like mb_ptr2cells(), but limit string length to "size".
+ * For an empty string or truncated character returns 1.
+ */
+    int
+latin_ptr2cells_len(p, size)
+    char_u	*p UNUSED;
+    int		size UNUSED;
+{
+    return 1;
+}
+
+    static int
+utf_ptr2cells_len(p, size)
+    char_u	*p;
+    int		size;
+{
+    int		c;
+
+    /* Need to convert to a wide character. */
+    if (size > 0 && *p >= 0x80)
+    {
+	if (utf_ptr2len_len(p, size) < utf8len_tab[*p])
+	    return 1;  /* truncated */
+	c = utf_ptr2char(p);
+	/* An illegal byte is displayed as <xx>. */
+	if (utf_ptr2len(p) == 1 || c == NUL)
+	    return 4;
+	/* If the char is ASCII it must be an overlong sequence. */
+	if (c < 0x80)
+	    return char2cells(c);
+	return utf_char2cells(c);
+    }
+    return 1;
+}
+
+    static int
+dbcs_ptr2cells_len(p, size)
+    char_u	*p;
+    int		size;
+{
+    /* Number of cells is equal to number of bytes, except for euc-jp when
+     * the first byte is 0x8e. */
+    if (size <= 1 || (enc_dbcs == DBCS_JPNU && *p == 0x8e))
+	return 1;
+    return MB_BYTE2LEN(*p);
+}
+
+/*
  * mb_char2cells() function pointer.
  * Return the number of display cells character "c" occupies.
  * Only takes care of multi-byte chars, not "^C" and such.
  */
-/*ARGSUSED*/
     int
 latin_char2cells(c)
-    int		c;
+    int		c UNUSED;
 {
     return 1;
 }
 
     static int
@@ -1316,15 +1581,14 @@ dbcs_char2cells(c)
 /*
  * mb_off2cells() function pointer.
  * Return number of display cells for char at ScreenLines[off].
  * We make sure that the offset used is less than "max_off".
  */
-/*ARGSUSED*/
     int
 latin_off2cells(off, max_off)
-    unsigned	off;
-    unsigned	max_off;
+    unsigned	off UNUSED;
+    unsigned	max_off UNUSED;
 {
     return 1;
 }
 
     int
@@ -1384,11 +1648,11 @@ utf_ptr2char(p)
     int		len;
 
     if (p[0] < 0x80)	/* be quick for ASCII */
 	return p[0];
 
-    len = utf8len_tab[p[0]];
+    len = utf8len_tab_zero[p[0]];
     if (len > 1 && (p[1] & 0xc0) == 0x80)
     {
 	if (len == 2)
 	    return ((p[0] & 0x1f) << 6) + (p[1] & 0x3f);
 	if ((p[2] & 0xc0) == 0x80)
@@ -1634,10 +1898,11 @@ utf_ptr2len(p)
 }
 
 /*
  * Return length of UTF-8 character, obtained from the first byte.
  * "b" must be between 0 and 255!
+ * Returns 1 for an invalid first byte value.
  */
     int
 utf_byte2len(b)
     int		b;
 {
@@ -1648,25 +1913,28 @@ utf_byte2len(b)
  * Get the length of UTF-8 byte sequence "p[size]".  Does not include any
  * following composing characters.
  * Returns 1 for "".
  * Returns 1 for an illegal byte sequence (also in incomplete byte seq.).
  * Returns number > "size" for an incomplete byte sequence.
+ * Never returns zero.
  */
     int
 utf_ptr2len_len(p, size)
     char_u	*p;
     int		size;
 {
     int		len;
     int		i;
     int		m;
 
-    if (*p == NUL)
-	return 1;
-    m = len = utf8len_tab[*p];
+    len = utf8len_tab[*p];
+    if (len == 1)
+	return 1;	/* NUL, ascii or illegal lead byte */
     if (len > size)
 	m = size;	/* incomplete byte sequence. */
+    else
+	m = len;
     for (i = 1; i < m; ++i)
 	if ((p[i] & 0xc0) != 0x80)
 	    return 1;
     return len;
 }
@@ -1696,11 +1964,11 @@ utfc_ptr2len(p)
     /* Check for illegal byte. */
     if (len == 1 && b0 >= 0x80)
 	return 1;
 
     /*
-     * Check for composing characters.  We can handle only the first two, but
+     * Check for composing characters.  We can handle only the first six, but
      * skip all of them (otherwise the cursor would get stuck).
      */
 #ifdef FEAT_ARABIC
     prevlen = 0;
 #endif
@@ -1718,10 +1986,11 @@ utfc_ptr2len(p)
 }
 
 /*
  * Return the number of bytes the UTF-8 encoding of the character at "p[size]"
  * takes.  This includes following composing characters.
+ * Returns 0 for an empty string.
  * Returns 1 for an illegal char or an incomplete byte sequence.
  */
     int
 utfc_ptr2len_len(p, size)
     char_u	*p;
@@ -1730,11 +1999,11 @@ utfc_ptr2len_len(p, size)
     int		len;
 #ifdef FEAT_ARABIC
     int		prevlen;
 #endif
 
-    if (*p == NUL)
+    if (size < 1 || *p == NUL)
 	return 0;
     if (p[0] < 0x80 && (size == 1 || p[1] < 0x80)) /* be quick for ASCII */
 	return 1;
 
     /* Skip over first UTF-8 char, stopping at a NUL byte. */
@@ -1743,11 +2012,11 @@ utfc_ptr2len_len(p, size)
     /* Check for illegal byte and incomplete byte sequence. */
     if ((len == 1 && p[0] >= 0x80) || len > size)
 	return 1;
 
     /*
-     * Check for composing characters.  We can handle only the first two, but
+     * Check for composing characters.  We can handle only the first six, but
      * skip all of them (otherwise the cursor would get stuck).
      */
 #ifdef FEAT_ARABIC
     prevlen = 0;
 #endif
@@ -1861,42 +2130,202 @@ utf_char2bytes(c, buf)
  */
     int
 utf_iscomposing(c)
     int		c;
 {
-    /* sorted list of non-overlapping intervals */
+    /* Sorted list of non-overlapping intervals.
+     * Generated by ../runtime/tools/unicode.vim. */
     static struct interval combining[] =
     {
-	{0x0300, 0x034f}, {0x0360, 0x036f}, {0x0483, 0x0486}, {0x0488, 0x0489},
-	{0x0591, 0x05a1}, {0x05a3, 0x05b9}, {0x05bb, 0x05bd}, {0x05bf, 0x05bf},
-	{0x05c1, 0x05c2}, {0x05c4, 0x05c4}, {0x0610, 0x0615}, {0x064b, 0x0658},
-	{0x0670, 0x0670}, {0x06d6, 0x06dc}, {0x06de, 0x06e4}, {0x06e7, 0x06e8},
-	{0x06ea, 0x06ed}, {0x0711, 0x0711}, {0x0730, 0x074a}, {0x07a6, 0x07b0},
-	{0x0901, 0x0903}, {0x093c, 0x093c}, {0x093e, 0x094d}, {0x0951, 0x0954},
-	{0x0962, 0x0963}, {0x0981, 0x0983}, {0x09bc, 0x09bc}, {0x09be, 0x09c4},
-	{0x09c7, 0x09c8}, {0x09cb, 0x09cd}, {0x09d7, 0x09d7}, {0x09e2, 0x09e3},
-	{0x0a01, 0x0a03}, {0x0a3c, 0x0a3c}, {0x0a3e, 0x0a42}, {0x0a47, 0x0a48},
-	{0x0a4b, 0x0a4d}, {0x0a70, 0x0a71}, {0x0a81, 0x0a83}, {0x0abc, 0x0abc},
-	{0x0abe, 0x0ac5}, {0x0ac7, 0x0ac9}, {0x0acb, 0x0acd}, {0x0ae2, 0x0ae3},
-	{0x0b01, 0x0b03}, {0x0b3c, 0x0b3c}, {0x0b3e, 0x0b43}, {0x0b47, 0x0b48},
-	{0x0b4b, 0x0b4d}, {0x0b56, 0x0b57}, {0x0b82, 0x0b82}, {0x0bbe, 0x0bc2},
-	{0x0bc6, 0x0bc8}, {0x0bca, 0x0bcd}, {0x0bd7, 0x0bd7}, {0x0c01, 0x0c03},
-	{0x0c3e, 0x0c44}, {0x0c46, 0x0c48}, {0x0c4a, 0x0c4d}, {0x0c55, 0x0c56},
-	{0x0c82, 0x0c83}, {0x0cbc, 0x0cbc}, {0x0cbe, 0x0cc4}, {0x0cc6, 0x0cc8},
-	{0x0cca, 0x0ccd}, {0x0cd5, 0x0cd6}, {0x0d02, 0x0d03}, {0x0d3e, 0x0d43},
-	{0x0d46, 0x0d48}, {0x0d4a, 0x0d4d}, {0x0d57, 0x0d57}, {0x0d82, 0x0d83},
-	{0x0dca, 0x0dca}, {0x0dcf, 0x0dd4}, {0x0dd6, 0x0dd6}, {0x0dd8, 0x0ddf},
-	{0x0df2, 0x0df3}, {0x0e31, 0x0e31}, {0x0e34, 0x0e3a}, {0x0e47, 0x0e4e},
-	{0x0eb1, 0x0eb1}, {0x0eb4, 0x0eb9}, {0x0ebb, 0x0ebc}, {0x0ec8, 0x0ecd},
-	{0x0f18, 0x0f19}, {0x0f35, 0x0f35}, {0x0f37, 0x0f37}, {0x0f39, 0x0f39},
-	{0x0f3e, 0x0f3f}, {0x0f71, 0x0f84}, {0x0f86, 0x0f87}, {0x0f90, 0x0f97},
-	{0x0f99, 0x0fbc}, {0x0fc6, 0x0fc6}, {0x102c, 0x1032}, {0x1036, 0x1039},
-	{0x1056, 0x1059}, {0x1712, 0x1714}, {0x1732, 0x1734}, {0x1752, 0x1753},
-	{0x1772, 0x1773}, {0x17b6, 0x17d3}, {0x17dd, 0x17dd}, {0x180b, 0x180d},
-	{0x18a9, 0x18a9}, {0x1920, 0x192b}, {0x1930, 0x193b}, {0x20d0, 0x20ea},
-	{0x302a, 0x302f}, {0x3099, 0x309a}, {0xfb1e, 0xfb1e}, {0xfe00, 0xfe0f},
-	{0xfe20, 0xfe23},
+	{0x0300, 0x036f},
+	{0x0483, 0x0489},
+	{0x0591, 0x05bd},
+	{0x05bf, 0x05bf},
+	{0x05c1, 0x05c2},
+	{0x05c4, 0x05c5},
+	{0x05c7, 0x05c7},
+	{0x0610, 0x061a},
+	{0x064b, 0x065e},
+	{0x0670, 0x0670},
+	{0x06d6, 0x06dc},
+	{0x06de, 0x06e4},
+	{0x06e7, 0x06e8},
+	{0x06ea, 0x06ed},
+	{0x0711, 0x0711},
+	{0x0730, 0x074a},
+	{0x07a6, 0x07b0},
+	{0x07eb, 0x07f3},
+	{0x0816, 0x0819},
+	{0x081b, 0x0823},
+	{0x0825, 0x0827},
+	{0x0829, 0x082d},
+	{0x0900, 0x0903},
+	{0x093c, 0x093c},
+	{0x093e, 0x094e},
+	{0x0951, 0x0955},
+	{0x0962, 0x0963},
+	{0x0981, 0x0983},
+	{0x09bc, 0x09bc},
+	{0x09be, 0x09c4},
+	{0x09c7, 0x09c8},
+	{0x09cb, 0x09cd},
+	{0x09d7, 0x09d7},
+	{0x09e2, 0x09e3},
+	{0x0a01, 0x0a03},
+	{0x0a3c, 0x0a3c},
+	{0x0a3e, 0x0a42},
+	{0x0a47, 0x0a48},
+	{0x0a4b, 0x0a4d},
+	{0x0a51, 0x0a51},
+	{0x0a70, 0x0a71},
+	{0x0a75, 0x0a75},
+	{0x0a81, 0x0a83},
+	{0x0abc, 0x0abc},
+	{0x0abe, 0x0ac5},
+	{0x0ac7, 0x0ac9},
+	{0x0acb, 0x0acd},
+	{0x0ae2, 0x0ae3},
+	{0x0b01, 0x0b03},
+	{0x0b3c, 0x0b3c},
+	{0x0b3e, 0x0b44},
+	{0x0b47, 0x0b48},
+	{0x0b4b, 0x0b4d},
+	{0x0b56, 0x0b57},
+	{0x0b62, 0x0b63},
+	{0x0b82, 0x0b82},
+	{0x0bbe, 0x0bc2},
+	{0x0bc6, 0x0bc8},
+	{0x0bca, 0x0bcd},
+	{0x0bd7, 0x0bd7},
+	{0x0c01, 0x0c03},
+	{0x0c3e, 0x0c44},
+	{0x0c46, 0x0c48},
+	{0x0c4a, 0x0c4d},
+	{0x0c55, 0x0c56},
+	{0x0c62, 0x0c63},
+	{0x0c82, 0x0c83},
+	{0x0cbc, 0x0cbc},
+	{0x0cbe, 0x0cc4},
+	{0x0cc6, 0x0cc8},
+	{0x0cca, 0x0ccd},
+	{0x0cd5, 0x0cd6},
+	{0x0ce2, 0x0ce3},
+	{0x0d02, 0x0d03},
+	{0x0d3e, 0x0d44},
+	{0x0d46, 0x0d48},
+	{0x0d4a, 0x0d4d},
+	{0x0d57, 0x0d57},
+	{0x0d62, 0x0d63},
+	{0x0d82, 0x0d83},
+	{0x0dca, 0x0dca},
+	{0x0dcf, 0x0dd4},
+	{0x0dd6, 0x0dd6},
+	{0x0dd8, 0x0ddf},
+	{0x0df2, 0x0df3},
+	{0x0e31, 0x0e31},
+	{0x0e34, 0x0e3a},
+	{0x0e47, 0x0e4e},
+	{0x0eb1, 0x0eb1},
+	{0x0eb4, 0x0eb9},
+	{0x0ebb, 0x0ebc},
+	{0x0ec8, 0x0ecd},
+	{0x0f18, 0x0f19},
+	{0x0f35, 0x0f35},
+	{0x0f37, 0x0f37},
+	{0x0f39, 0x0f39},
+	{0x0f3e, 0x0f3f},
+	{0x0f71, 0x0f84},
+	{0x0f86, 0x0f87},
+	{0x0f90, 0x0f97},
+	{0x0f99, 0x0fbc},
+	{0x0fc6, 0x0fc6},
+	{0x102b, 0x103e},
+	{0x1056, 0x1059},
+	{0x105e, 0x1060},
+	{0x1062, 0x1064},
+	{0x1067, 0x106d},
+	{0x1071, 0x1074},
+	{0x1082, 0x108d},
+	{0x108f, 0x108f},
+	{0x109a, 0x109d},
+	{0x135f, 0x135f},
+	{0x1712, 0x1714},
+	{0x1732, 0x1734},
+	{0x1752, 0x1753},
+	{0x1772, 0x1773},
+	{0x17b6, 0x17d3},
+	{0x17dd, 0x17dd},
+	{0x180b, 0x180d},
+	{0x18a9, 0x18a9},
+	{0x1920, 0x192b},
+	{0x1930, 0x193b},
+	{0x19b0, 0x19c0},
+	{0x19c8, 0x19c9},
+	{0x1a17, 0x1a1b},
+	{0x1a55, 0x1a5e},
+	{0x1a60, 0x1a7c},
+	{0x1a7f, 0x1a7f},
+	{0x1b00, 0x1b04},
+	{0x1b34, 0x1b44},
+	{0x1b6b, 0x1b73},
+	{0x1b80, 0x1b82},
+	{0x1ba1, 0x1baa},
+	{0x1c24, 0x1c37},
+	{0x1cd0, 0x1cd2},
+	{0x1cd4, 0x1ce8},
+	{0x1ced, 0x1ced},
+	{0x1cf2, 0x1cf2},
+	{0x1dc0, 0x1de6},
+	{0x1dfd, 0x1dff},
+	{0x20d0, 0x20f0},
+	{0x2cef, 0x2cf1},
+	{0x2de0, 0x2dff},
+	{0x302a, 0x302f},
+	{0x3099, 0x309a},
+	{0xa66f, 0xa672},
+	{0xa67c, 0xa67d},
+	{0xa6f0, 0xa6f1},
+	{0xa802, 0xa802},
+	{0xa806, 0xa806},
+	{0xa80b, 0xa80b},
+	{0xa823, 0xa827},
+	{0xa880, 0xa881},
+	{0xa8b4, 0xa8c4},
+	{0xa8e0, 0xa8f1},
+	{0xa926, 0xa92d},
+	{0xa947, 0xa953},
+	{0xa980, 0xa983},
+	{0xa9b3, 0xa9c0},
+	{0xaa29, 0xaa36},
+	{0xaa43, 0xaa43},
+	{0xaa4c, 0xaa4d},
+	{0xaa7b, 0xaa7b},
+	{0xaab0, 0xaab0},
+	{0xaab2, 0xaab4},
+	{0xaab7, 0xaab8},
+	{0xaabe, 0xaabf},
+	{0xaac1, 0xaac1},
+	{0xabe3, 0xabea},
+	{0xabec, 0xabed},
+	{0xfb1e, 0xfb1e},
+	{0xfe00, 0xfe0f},
+	{0xfe20, 0xfe26},
+	{0x101fd, 0x101fd},
+	{0x10a01, 0x10a03},
+	{0x10a05, 0x10a06},
+	{0x10a0c, 0x10a0f},
+	{0x10a38, 0x10a3a},
+	{0x10a3f, 0x10a3f},
+	{0x11080, 0x11082},
+	{0x110b0, 0x110ba},
+	{0x1d165, 0x1d169},
+	{0x1d16d, 0x1d172},
+	{0x1d17b, 0x1d182},
+	{0x1d185, 0x1d18b},
+	{0x1d1aa, 0x1d1ad},
+	{0x1d242, 0x1d244},
+	{0xe0100, 0xe01ef}
     };
 
     return intable(combining, sizeof(combining), c);
 }
 
@@ -2040,64 +2469,185 @@ utf_class(c)
 
 /*
  * Code for Unicode case-dependent operations.  Based on notes in
  * http://www.unicode.org/Public/UNIDATA/CaseFolding.txt
  * This code uses simple case folding, not full case folding.
+ * Last updated for Unicode 5.2.
  */
 
 /*
- * The following table is built by foldExtract.pl < CaseFolding.txt .
- * It must be in numeric order, because we use binary search on it.
- * An entry such as {0x41,0x5a,1,32} means that UCS-4 characters in the range
- * from 0x41 to 0x5a inclusive, stepping by 1, are folded by adding 32.
+ * The following tables are built by ../runtime/tools/unicode.vim.
+ * They must be in numeric order, because we use binary search.
+ * An entry such as {0x41,0x5a,1,32} means that Unicode characters in the
+ * range from 0x41 to 0x5a inclusive, stepping by 1, are changed to
+ * folded/upper/lower by adding 32.
  */
-
 typedef struct
 {
     int rangeStart;
     int rangeEnd;
     int step;
     int offset;
 } convertStruct;
 
 static convertStruct foldCase[] =
 {
-	{0x41,0x5a,1,32}, {0xc0,0xd6,1,32}, {0xd8,0xde,1,32},
-	{0x100,0x12e,2,1}, {0x130,0x130,-1,-199}, {0x132,0x136,2,1},
-	{0x139,0x147,2,1}, {0x14a,0x176,2,1}, {0x178,0x178,-1,-121},
-	{0x179,0x17d,2,1}, {0x181,0x181,-1,210}, {0x182,0x184,2,1},
-	{0x186,0x186,-1,206}, {0x187,0x187,-1,1}, {0x189,0x18a,1,205},
-	{0x18b,0x18b,-1,1}, {0x18e,0x18e,-1,79}, {0x18f,0x18f,-1,202},
-	{0x190,0x190,-1,203}, {0x191,0x191,-1,1}, {0x193,0x193,-1,205},
-	{0x194,0x194,-1,207}, {0x196,0x196,-1,211}, {0x197,0x197,-1,209},
-	{0x198,0x198,-1,1}, {0x19c,0x19c,-1,211}, {0x19d,0x19d,-1,213},
-	{0x19f,0x19f,-1,214}, {0x1a0,0x1a4,2,1}, {0x1a6,0x1a6,-1,218},
-	{0x1a7,0x1a7,-1,1}, {0x1a9,0x1a9,-1,218}, {0x1ac,0x1ac,-1,1},
-	{0x1ae,0x1ae,-1,218}, {0x1af,0x1af,-1,1}, {0x1b1,0x1b2,1,217},
-	{0x1b3,0x1b5,2,1}, {0x1b7,0x1b7,-1,219}, {0x1b8,0x1bc,4,1},
-	{0x1c4,0x1c4,-1,2}, {0x1c5,0x1c5,-1,1}, {0x1c7,0x1c7,-1,2},
-	{0x1c8,0x1c8,-1,1}, {0x1ca,0x1ca,-1,2}, {0x1cb,0x1db,2,1},
-	{0x1de,0x1ee,2,1}, {0x1f1,0x1f1,-1,2}, {0x1f2,0x1f4,2,1},
-	{0x1f6,0x1f6,-1,-97}, {0x1f7,0x1f7,-1,-56}, {0x1f8,0x21e,2,1},
-	{0x220,0x220,-1,-130}, {0x222,0x232,2,1}, {0x386,0x386,-1,38},
-	{0x388,0x38a,1,37}, {0x38c,0x38c,-1,64}, {0x38e,0x38f,1,63},
-	{0x391,0x3a1,1,32}, {0x3a3,0x3ab,1,32}, {0x3d8,0x3ee,2,1},
-	{0x3f4,0x3f4,-1,-60}, {0x3f7,0x3f7,-1,1}, {0x3f9,0x3f9,-1,-7},
-	{0x3fa,0x3fa,-1,1}, {0x400,0x40f,1,80}, {0x410,0x42f,1,32},
-	{0x460,0x480,2,1}, {0x48a,0x4be,2,1}, {0x4c1,0x4cd,2,1},
-	{0x4d0,0x4f4,2,1}, {0x4f8,0x500,8,1}, {0x502,0x50e,2,1},
-	{0x531,0x556,1,48}, {0x1e00,0x1e94,2,1}, {0x1ea0,0x1ef8,2,1},
-	{0x1f08,0x1f0f,1,-8}, {0x1f18,0x1f1d,1,-8}, {0x1f28,0x1f2f,1,-8},
-	{0x1f38,0x1f3f,1,-8}, {0x1f48,0x1f4d,1,-8}, {0x1f59,0x1f5f,2,-8},
-	{0x1f68,0x1f6f,1,-8}, {0x1f88,0x1f8f,1,-8}, {0x1f98,0x1f9f,1,-8},
-	{0x1fa8,0x1faf,1,-8}, {0x1fb8,0x1fb9,1,-8}, {0x1fba,0x1fbb,1,-74},
-	{0x1fbc,0x1fbc,-1,-9}, {0x1fc8,0x1fcb,1,-86}, {0x1fcc,0x1fcc,-1,-9},
-	{0x1fd8,0x1fd9,1,-8}, {0x1fda,0x1fdb,1,-100}, {0x1fe8,0x1fe9,1,-8},
-	{0x1fea,0x1feb,1,-112}, {0x1fec,0x1fec,-1,-7}, {0x1ff8,0x1ff9,1,-128},
-	{0x1ffa,0x1ffb,1,-126}, {0x1ffc,0x1ffc,-1,-9}, {0x2126,0x2126,-1,-7517},
-	{0x212a,0x212a,-1,-8383}, {0x212b,0x212b,-1,-8262},
-	{0x2160,0x216f,1,16}, {0x24b6,0x24cf,1,26}, {0xff21,0xff3a,1,32},
+	{0x41,0x5a,1,32},
+	{0xb5,0xb5,-1,775},
+	{0xc0,0xd6,1,32},
+	{0xd8,0xde,1,32},
+	{0x100,0x12e,2,1},
+	{0x132,0x136,2,1},
+	{0x139,0x147,2,1},
+	{0x14a,0x176,2,1},
+	{0x178,0x178,-1,-121},
+	{0x179,0x17d,2,1},
+	{0x17f,0x17f,-1,-268},
+	{0x181,0x181,-1,210},
+	{0x182,0x184,2,1},
+	{0x186,0x186,-1,206},
+	{0x187,0x187,-1,1},
+	{0x189,0x18a,1,205},
+	{0x18b,0x18b,-1,1},
+	{0x18e,0x18e,-1,79},
+	{0x18f,0x18f,-1,202},
+	{0x190,0x190,-1,203},
+	{0x191,0x191,-1,1},
+	{0x193,0x193,-1,205},
+	{0x194,0x194,-1,207},
+	{0x196,0x196,-1,211},
+	{0x197,0x197,-1,209},
+	{0x198,0x198,-1,1},
+	{0x19c,0x19c,-1,211},
+	{0x19d,0x19d,-1,213},
+	{0x19f,0x19f,-1,214},
+	{0x1a0,0x1a4,2,1},
+	{0x1a6,0x1a6,-1,218},
+	{0x1a7,0x1a7,-1,1},
+	{0x1a9,0x1a9,-1,218},
+	{0x1ac,0x1ac,-1,1},
+	{0x1ae,0x1ae,-1,218},
+	{0x1af,0x1af,-1,1},
+	{0x1b1,0x1b2,1,217},
+	{0x1b3,0x1b5,2,1},
+	{0x1b7,0x1b7,-1,219},
+	{0x1b8,0x1bc,4,1},
+	{0x1c4,0x1c4,-1,2},
+	{0x1c5,0x1c5,-1,1},
+	{0x1c7,0x1c7,-1,2},
+	{0x1c8,0x1c8,-1,1},
+	{0x1ca,0x1ca,-1,2},
+	{0x1cb,0x1db,2,1},
+	{0x1de,0x1ee,2,1},
+	{0x1f1,0x1f1,-1,2},
+	{0x1f2,0x1f4,2,1},
+	{0x1f6,0x1f6,-1,-97},
+	{0x1f7,0x1f7,-1,-56},
+	{0x1f8,0x21e,2,1},
+	{0x220,0x220,-1,-130},
+	{0x222,0x232,2,1},
+	{0x23a,0x23a,-1,10795},
+	{0x23b,0x23b,-1,1},
+	{0x23d,0x23d,-1,-163},
+	{0x23e,0x23e,-1,10792},
+	{0x241,0x241,-1,1},
+	{0x243,0x243,-1,-195},
+	{0x244,0x244,-1,69},
+	{0x245,0x245,-1,71},
+	{0x246,0x24e,2,1},
+	{0x345,0x345,-1,116},
+	{0x370,0x372,2,1},
+	{0x376,0x376,-1,1},
+	{0x386,0x386,-1,38},
+	{0x388,0x38a,1,37},
+	{0x38c,0x38c,-1,64},
+	{0x38e,0x38f,1,63},
+	{0x391,0x3a1,1,32},
+	{0x3a3,0x3ab,1,32},
+	{0x3c2,0x3c2,-1,1},
+	{0x3cf,0x3cf,-1,8},
+	{0x3d0,0x3d0,-1,-30},
+	{0x3d1,0x3d1,-1,-25},
+	{0x3d5,0x3d5,-1,-15},
+	{0x3d6,0x3d6,-1,-22},
+	{0x3d8,0x3ee,2,1},
+	{0x3f0,0x3f0,-1,-54},
+	{0x3f1,0x3f1,-1,-48},
+	{0x3f4,0x3f4,-1,-60},
+	{0x3f5,0x3f5,-1,-64},
+	{0x3f7,0x3f7,-1,1},
+	{0x3f9,0x3f9,-1,-7},
+	{0x3fa,0x3fa,-1,1},
+	{0x3fd,0x3ff,1,-130},
+	{0x400,0x40f,1,80},
+	{0x410,0x42f,1,32},
+	{0x460,0x480,2,1},
+	{0x48a,0x4be,2,1},
+	{0x4c0,0x4c0,-1,15},
+	{0x4c1,0x4cd,2,1},
+	{0x4d0,0x524,2,1},
+	{0x531,0x556,1,48},
+	{0x10a0,0x10c5,1,7264},
+	{0x1e00,0x1e94,2,1},
+	{0x1e9b,0x1e9b,-1,-58},
+	{0x1e9e,0x1e9e,-1,-7615},
+	{0x1ea0,0x1efe,2,1},
+	{0x1f08,0x1f0f,1,-8},
+	{0x1f18,0x1f1d,1,-8},
+	{0x1f28,0x1f2f,1,-8},
+	{0x1f38,0x1f3f,1,-8},
+	{0x1f48,0x1f4d,1,-8},
+	{0x1f59,0x1f5f,2,-8},
+	{0x1f68,0x1f6f,1,-8},
+	{0x1f88,0x1f8f,1,-8},
+	{0x1f98,0x1f9f,1,-8},
+	{0x1fa8,0x1faf,1,-8},
+	{0x1fb8,0x1fb9,1,-8},
+	{0x1fba,0x1fbb,1,-74},
+	{0x1fbc,0x1fbc,-1,-9},
+	{0x1fbe,0x1fbe,-1,-7173},
+	{0x1fc8,0x1fcb,1,-86},
+	{0x1fcc,0x1fcc,-1,-9},
+	{0x1fd8,0x1fd9,1,-8},
+	{0x1fda,0x1fdb,1,-100},
+	{0x1fe8,0x1fe9,1,-8},
+	{0x1fea,0x1feb,1,-112},
+	{0x1fec,0x1fec,-1,-7},
+	{0x1ff8,0x1ff9,1,-128},
+	{0x1ffa,0x1ffb,1,-126},
+	{0x1ffc,0x1ffc,-1,-9},
+	{0x2126,0x2126,-1,-7517},
+	{0x212a,0x212a,-1,-8383},
+	{0x212b,0x212b,-1,-8262},
+	{0x2132,0x2132,-1,28},
+	{0x2160,0x216f,1,16},
+	{0x2183,0x2183,-1,1},
+	{0x24b6,0x24cf,1,26},
+	{0x2c00,0x2c2e,1,48},
+	{0x2c60,0x2c60,-1,1},
+	{0x2c62,0x2c62,-1,-10743},
+	{0x2c63,0x2c63,-1,-3814},
+	{0x2c64,0x2c64,-1,-10727},
+	{0x2c67,0x2c6b,2,1},
+	{0x2c6d,0x2c6d,-1,-10780},
+	{0x2c6e,0x2c6e,-1,-10749},
+	{0x2c6f,0x2c6f,-1,-10783},
+	{0x2c70,0x2c70,-1,-10782},
+	{0x2c72,0x2c75,3,1},
+	{0x2c7e,0x2c7f,1,-10815},
+	{0x2c80,0x2ce2,2,1},
+	{0x2ceb,0x2ced,2,1},
+	{0xa640,0xa65e,2,1},
+	{0xa662,0xa66c,2,1},
+	{0xa680,0xa696,2,1},
+	{0xa722,0xa72e,2,1},
+	{0xa732,0xa76e,2,1},
+	{0xa779,0xa77b,2,1},
+	{0xa77d,0xa77d,-1,-35332},
+	{0xa77e,0xa786,2,1},
+	{0xa78b,0xa78b,-1,1},
+	{0xff21,0xff3a,1,32},
 	{0x10400,0x10427,1,40}
 };
 
 static int utf_convert(int a, convertStruct table[], int tableSize);
 
@@ -2141,89 +2691,310 @@ utf_fold(a)
     int		a;
 {
     return utf_convert(a, foldCase, sizeof(foldCase));
 }
 
-/*
- * The following tables are built by upperLowerExtract.pl < UnicodeData.txt .
- * They must be in numeric order, because we use binary search on them.
- * An entry such as {0x41,0x5a,1,32} means that UCS-4 characters in the range
- * from 0x41 to 0x5a inclusive, stepping by 1, are switched to lower (for
- * example) by adding 32.
- */
 static convertStruct toLower[] =
 {
-	{0x41,0x5a,1,32}, {0xc0,0xd6,1,32}, {0xd8,0xde,1,32},
-	{0x100,0x12e,2,1}, {0x130,0x130,-1,-199}, {0x132,0x136,2,1},
-	{0x139,0x147,2,1}, {0x14a,0x176,2,1}, {0x178,0x178,-1,-121},
-	{0x179,0x17d,2,1}, {0x181,0x181,-1,210}, {0x182,0x184,2,1},
-	{0x186,0x186,-1,206}, {0x187,0x187,-1,1}, {0x189,0x18a,1,205},
-	{0x18b,0x18b,-1,1}, {0x18e,0x18e,-1,79}, {0x18f,0x18f,-1,202},
-	{0x190,0x190,-1,203}, {0x191,0x191,-1,1}, {0x193,0x193,-1,205},
-	{0x194,0x194,-1,207}, {0x196,0x196,-1,211}, {0x197,0x197,-1,209},
-	{0x198,0x198,-1,1}, {0x19c,0x19c,-1,211}, {0x19d,0x19d,-1,213},
-	{0x19f,0x19f,-1,214}, {0x1a0,0x1a4,2,1}, {0x1a6,0x1a6,-1,218},
-	{0x1a7,0x1a7,-1,1}, {0x1a9,0x1a9,-1,218}, {0x1ac,0x1ac,-1,1},
-	{0x1ae,0x1ae,-1,218}, {0x1af,0x1af,-1,1}, {0x1b1,0x1b2,1,217},
-	{0x1b3,0x1b5,2,1}, {0x1b7,0x1b7,-1,219}, {0x1b8,0x1bc,4,1},
-	{0x1c4,0x1ca,3,2}, {0x1cd,0x1db,2,1}, {0x1de,0x1ee,2,1},
-	{0x1f1,0x1f1,-1,2}, {0x1f4,0x1f4,-1,1}, {0x1f6,0x1f6,-1,-97},
-	{0x1f7,0x1f7,-1,-56}, {0x1f8,0x21e,2,1}, {0x220,0x220,-1,-130},
-	{0x222,0x232,2,1}, {0x386,0x386,-1,38}, {0x388,0x38a,1,37},
-	{0x38c,0x38c,-1,64}, {0x38e,0x38f,1,63}, {0x391,0x3a1,1,32},
-	{0x3a3,0x3ab,1,32}, {0x3d8,0x3ee,2,1}, {0x3f4,0x3f4,-1,-60},
-	{0x3f7,0x3f7,-1,1}, {0x3f9,0x3f9,-1,-7}, {0x3fa,0x3fa,-1,1},
-	{0x400,0x40f,1,80}, {0x410,0x42f,1,32}, {0x460,0x480,2,1},
-	{0x48a,0x4be,2,1}, {0x4c1,0x4cd,2,1}, {0x4d0,0x4f4,2,1},
-	{0x4f8,0x500,8,1}, {0x502,0x50e,2,1}, {0x531,0x556,1,48},
-	{0x1e00,0x1e94,2,1}, {0x1ea0,0x1ef8,2,1}, {0x1f08,0x1f0f,1,-8},
-	{0x1f18,0x1f1d,1,-8}, {0x1f28,0x1f2f,1,-8}, {0x1f38,0x1f3f,1,-8},
-	{0x1f48,0x1f4d,1,-8}, {0x1f59,0x1f5f,2,-8}, {0x1f68,0x1f6f,1,-8},
-	{0x1fb8,0x1fb9,1,-8}, {0x1fba,0x1fbb,1,-74}, {0x1fc8,0x1fcb,1,-86},
-	{0x1fd8,0x1fd9,1,-8}, {0x1fda,0x1fdb,1,-100}, {0x1fe8,0x1fe9,1,-8},
-	{0x1fea,0x1feb,1,-112}, {0x1fec,0x1fec,-1,-7}, {0x1ff8,0x1ff9,1,-128},
-	{0x1ffa,0x1ffb,1,-126}, {0x2126,0x2126,-1,-7517}, {0x212a,0x212a,-1,-8383},
-	{0x212b,0x212b,-1,-8262}, {0xff21,0xff3a,1,32}, {0x10400,0x10427,1,40}
+	{0x41,0x5a,1,32},
+	{0xc0,0xd6,1,32},
+	{0xd8,0xde,1,32},
+	{0x100,0x12e,2,1},
+	{0x130,0x130,-1,-199},
+	{0x132,0x136,2,1},
+	{0x139,0x147,2,1},
+	{0x14a,0x176,2,1},
+	{0x178,0x178,-1,-121},
+	{0x179,0x17d,2,1},
+	{0x181,0x181,-1,210},
+	{0x182,0x184,2,1},
+	{0x186,0x186,-1,206},
+	{0x187,0x187,-1,1},
+	{0x189,0x18a,1,205},
+	{0x18b,0x18b,-1,1},
+	{0x18e,0x18e,-1,79},
+	{0x18f,0x18f,-1,202},
+	{0x190,0x190,-1,203},
+	{0x191,0x191,-1,1},
+	{0x193,0x193,-1,205},
+	{0x194,0x194,-1,207},
+	{0x196,0x196,-1,211},
+	{0x197,0x197,-1,209},
+	{0x198,0x198,-1,1},
+	{0x19c,0x19c,-1,211},
+	{0x19d,0x19d,-1,213},
+	{0x19f,0x19f,-1,214},
+	{0x1a0,0x1a4,2,1},
+	{0x1a6,0x1a6,-1,218},
+	{0x1a7,0x1a7,-1,1},
+	{0x1a9,0x1a9,-1,218},
+	{0x1ac,0x1ac,-1,1},
+	{0x1ae,0x1ae,-1,218},
+	{0x1af,0x1af,-1,1},
+	{0x1b1,0x1b2,1,217},
+	{0x1b3,0x1b5,2,1},
+	{0x1b7,0x1b7,-1,219},
+	{0x1b8,0x1bc,4,1},
+	{0x1c4,0x1c4,-1,2},
+	{0x1c5,0x1c5,-1,1},
+	{0x1c7,0x1c7,-1,2},
+	{0x1c8,0x1c8,-1,1},
+	{0x1ca,0x1ca,-1,2},
+	{0x1cb,0x1db,2,1},
+	{0x1de,0x1ee,2,1},
+	{0x1f1,0x1f1,-1,2},
+	{0x1f2,0x1f4,2,1},
+	{0x1f6,0x1f6,-1,-97},
+	{0x1f7,0x1f7,-1,-56},
+	{0x1f8,0x21e,2,1},
+	{0x220,0x220,-1,-130},
+	{0x222,0x232,2,1},
+	{0x23a,0x23a,-1,10795},
+	{0x23b,0x23b,-1,1},
+	{0x23d,0x23d,-1,-163},
+	{0x23e,0x23e,-1,10792},
+	{0x241,0x241,-1,1},
+	{0x243,0x243,-1,-195},
+	{0x244,0x244,-1,69},
+	{0x245,0x245,-1,71},
+	{0x246,0x24e,2,1},
+	{0x370,0x372,2,1},
+	{0x376,0x376,-1,1},
+	{0x386,0x386,-1,38},
+	{0x388,0x38a,1,37},
+	{0x38c,0x38c,-1,64},
+	{0x38e,0x38f,1,63},
+	{0x391,0x3a1,1,32},
+	{0x3a3,0x3ab,1,32},
+	{0x3cf,0x3cf,-1,8},
+	{0x3d8,0x3ee,2,1},
+	{0x3f4,0x3f4,-1,-60},
+	{0x3f7,0x3f7,-1,1},
+	{0x3f9,0x3f9,-1,-7},
+	{0x3fa,0x3fa,-1,1},
+	{0x3fd,0x3ff,1,-130},
+	{0x400,0x40f,1,80},
+	{0x410,0x42f,1,32},
+	{0x460,0x480,2,1},
+	{0x48a,0x4be,2,1},
+	{0x4c0,0x4c0,-1,15},
+	{0x4c1,0x4cd,2,1},
+	{0x4d0,0x524,2,1},
+	{0x531,0x556,1,48},
+	{0x10a0,0x10c5,1,7264},
+	{0x1e00,0x1e94,2,1},
+	{0x1e9e,0x1e9e,-1,-7615},
+	{0x1ea0,0x1efe,2,1},
+	{0x1f08,0x1f0f,1,-8},
+	{0x1f18,0x1f1d,1,-8},
+	{0x1f28,0x1f2f,1,-8},
+	{0x1f38,0x1f3f,1,-8},
+	{0x1f48,0x1f4d,1,-8},
+	{0x1f59,0x1f5f,2,-8},
+	{0x1f68,0x1f6f,1,-8},
+	{0x1f88,0x1f8f,1,-8},
+	{0x1f98,0x1f9f,1,-8},
+	{0x1fa8,0x1faf,1,-8},
+	{0x1fb8,0x1fb9,1,-8},
+	{0x1fba,0x1fbb,1,-74},
+	{0x1fbc,0x1fbc,-1,-9},
+	{0x1fc8,0x1fcb,1,-86},
+	{0x1fcc,0x1fcc,-1,-9},
+	{0x1fd8,0x1fd9,1,-8},
+	{0x1fda,0x1fdb,1,-100},
+	{0x1fe8,0x1fe9,1,-8},
+	{0x1fea,0x1feb,1,-112},
+	{0x1fec,0x1fec,-1,-7},
+	{0x1ff8,0x1ff9,1,-128},
+	{0x1ffa,0x1ffb,1,-126},
+	{0x1ffc,0x1ffc,-1,-9},
+	{0x2126,0x2126,-1,-7517},
+	{0x212a,0x212a,-1,-8383},
+	{0x212b,0x212b,-1,-8262},
+	{0x2132,0x2132,-1,28},
+	{0x2160,0x216f,1,16},
+	{0x2183,0x2183,-1,1},
+	{0x24b6,0x24cf,1,26},
+	{0x2c00,0x2c2e,1,48},
+	{0x2c60,0x2c60,-1,1},
+	{0x2c62,0x2c62,-1,-10743},
+	{0x2c63,0x2c63,-1,-3814},
+	{0x2c64,0x2c64,-1,-10727},
+	{0x2c67,0x2c6b,2,1},
+	{0x2c6d,0x2c6d,-1,-10780},
+	{0x2c6e,0x2c6e,-1,-10749},
+	{0x2c6f,0x2c6f,-1,-10783},
+	{0x2c70,0x2c70,-1,-10782},
+	{0x2c72,0x2c75,3,1},
+	{0x2c7e,0x2c7f,1,-10815},
+	{0x2c80,0x2ce2,2,1},
+	{0x2ceb,0x2ced,2,1},
+	{0xa640,0xa65e,2,1},
+	{0xa662,0xa66c,2,1},
+	{0xa680,0xa696,2,1},
+	{0xa722,0xa72e,2,1},
+	{0xa732,0xa76e,2,1},
+	{0xa779,0xa77b,2,1},
+	{0xa77d,0xa77d,-1,-35332},
+	{0xa77e,0xa786,2,1},
+	{0xa78b,0xa78b,-1,1},
+	{0xff21,0xff3a,1,32},
+	{0x10400,0x10427,1,40}
 };
 
 static convertStruct toUpper[] =
 {
-	{0x61,0x7a,1,-32}, {0xb5,0xb5,-1,743}, {0xe0,0xf6,1,-32},
-	{0xf8,0xfe,1,-32}, {0xff,0xff,-1,121}, {0x101,0x12f,2,-1},
-	{0x131,0x131,-1,-232}, {0x133,0x137,2,-1}, {0x13a,0x148,2,-1},
-	{0x14b,0x177,2,-1}, {0x17a,0x17e,2,-1}, {0x17f,0x17f,-1,-300},
-	{0x183,0x185,2,-1}, {0x188,0x18c,4,-1}, {0x192,0x192,-1,-1},
-	{0x195,0x195,-1,97}, {0x199,0x199,-1,-1}, {0x19e,0x19e,-1,130},
-	{0x1a1,0x1a5,2,-1}, {0x1a8,0x1ad,5,-1}, {0x1b0,0x1b4,4,-1},
-	{0x1b6,0x1b9,3,-1}, {0x1bd,0x1bd,-1,-1}, {0x1bf,0x1bf,-1,56},
-	{0x1c5,0x1c6,1,-1}, {0x1c8,0x1c9,1,-1}, {0x1cb,0x1cc,1,-1},
-	{0x1ce,0x1dc,2,-1}, {0x1dd,0x1dd,-1,-79}, {0x1df,0x1ef,2,-1},
-	{0x1f2,0x1f3,1,-1}, {0x1f5,0x1f9,4,-1}, {0x1fb,0x21f,2,-1},
-	{0x223,0x233,2,-1}, {0x253,0x253,-1,-210}, {0x254,0x254,-1,-206},
-	{0x256,0x257,1,-205}, {0x259,0x259,-1,-202}, {0x25b,0x25b,-1,-203},
-	{0x260,0x260,-1,-205}, {0x263,0x263,-1,-207}, {0x268,0x268,-1,-209},
-	{0x269,0x26f,6,-211}, {0x272,0x272,-1,-213}, {0x275,0x275,-1,-214},
-	{0x280,0x283,3,-218}, {0x288,0x288,-1,-218}, {0x28a,0x28b,1,-217},
-	{0x292,0x292,-1,-219}, {0x3ac,0x3ac,-1,-38}, {0x3ad,0x3af,1,-37},
-	{0x3b1,0x3c1,1,-32}, {0x3c2,0x3c2,-1,-31}, {0x3c3,0x3cb,1,-32},
-	{0x3cc,0x3cc,-1,-64}, {0x3cd,0x3ce,1,-63}, {0x3d0,0x3d0,-1,-62},
-	{0x3d1,0x3d1,-1,-57}, {0x3d5,0x3d5,-1,-47}, {0x3d6,0x3d6,-1,-54},
-	{0x3d9,0x3ef,2,-1}, {0x3f0,0x3f0,-1,-86}, {0x3f1,0x3f1,-1,-80},
-	{0x3f2,0x3f2,-1,7}, {0x3f5,0x3f5,-1,-96}, {0x3f8,0x3fb,3,-1},
-	{0x430,0x44f,1,-32}, {0x450,0x45f,1,-80}, {0x461,0x481,2,-1},
-	{0x48b,0x4bf,2,-1}, {0x4c2,0x4ce,2,-1}, {0x4d1,0x4f5,2,-1},
-	{0x4f9,0x501,8,-1}, {0x503,0x50f,2,-1}, {0x561,0x586,1,-48},
-	{0x1e01,0x1e95,2,-1}, {0x1e9b,0x1e9b,-1,-59}, {0x1ea1,0x1ef9,2,-1},
-	{0x1f00,0x1f07,1,8}, {0x1f10,0x1f15,1,8}, {0x1f20,0x1f27,1,8},
-	{0x1f30,0x1f37,1,8}, {0x1f40,0x1f45,1,8}, {0x1f51,0x1f57,2,8},
-	{0x1f60,0x1f67,1,8}, {0x1f70,0x1f71,1,74}, {0x1f72,0x1f75,1,86},
-	{0x1f76,0x1f77,1,100}, {0x1f78,0x1f79,1,128}, {0x1f7a,0x1f7b,1,112},
-	{0x1f7c,0x1f7d,1,126}, {0x1f80,0x1f87,1,8}, {0x1f90,0x1f97,1,8},
-	{0x1fa0,0x1fa7,1,8}, {0x1fb0,0x1fb1,1,8}, {0x1fb3,0x1fb3,-1,9},
-	{0x1fbe,0x1fbe,-1,-7205}, {0x1fc3,0x1fc3,-1,9}, {0x1fd0,0x1fd1,1,8},
-	{0x1fe0,0x1fe1,1,8}, {0x1fe5,0x1fe5,-1,7}, {0x1ff3,0x1ff3,-1,9},
-	{0xff41,0xff5a,1,-32}, {0x10428,0x1044f,1,-40}
+	{0x61,0x7a,1,-32},
+	{0xb5,0xb5,-1,743},
+	{0xe0,0xf6,1,-32},
+	{0xf8,0xfe,1,-32},
+	{0xff,0xff,-1,121},
+	{0x101,0x12f,2,-1},
+	{0x131,0x131,-1,-232},
+	{0x133,0x137,2,-1},
+	{0x13a,0x148,2,-1},
+	{0x14b,0x177,2,-1},
+	{0x17a,0x17e,2,-1},
+	{0x17f,0x17f,-1,-300},
+	{0x180,0x180,-1,195},
+	{0x183,0x185,2,-1},
+	{0x188,0x18c,4,-1},
+	{0x192,0x192,-1,-1},
+	{0x195,0x195,-1,97},
+	{0x199,0x199,-1,-1},
+	{0x19a,0x19a,-1,163},
+	{0x19e,0x19e,-1,130},
+	{0x1a1,0x1a5,2,-1},
+	{0x1a8,0x1ad,5,-1},
+	{0x1b0,0x1b4,4,-1},
+	{0x1b6,0x1b9,3,-1},
+	{0x1bd,0x1bd,-1,-1},
+	{0x1bf,0x1bf,-1,56},
+	{0x1c5,0x1c5,-1,-1},
+	{0x1c6,0x1c6,-1,-2},
+	{0x1c8,0x1c8,-1,-1},
+	{0x1c9,0x1c9,-1,-2},
+	{0x1cb,0x1cb,-1,-1},
+	{0x1cc,0x1cc,-1,-2},
+	{0x1ce,0x1dc,2,-1},
+	{0x1dd,0x1dd,-1,-79},
+	{0x1df,0x1ef,2,-1},
+	{0x1f2,0x1f2,-1,-1},
+	{0x1f3,0x1f3,-1,-2},
+	{0x1f5,0x1f9,4,-1},
+	{0x1fb,0x21f,2,-1},
+	{0x223,0x233,2,-1},
+	{0x23c,0x23c,-1,-1},
+	{0x23f,0x240,1,10815},
+	{0x242,0x247,5,-1},
+	{0x249,0x24f,2,-1},
+	{0x250,0x250,-1,10783},
+	{0x251,0x251,-1,10780},
+	{0x252,0x252,-1,10782},
+	{0x253,0x253,-1,-210},
+	{0x254,0x254,-1,-206},
+	{0x256,0x257,1,-205},
+	{0x259,0x259,-1,-202},
+	{0x25b,0x25b,-1,-203},
+	{0x260,0x260,-1,-205},
+	{0x263,0x263,-1,-207},
+	{0x268,0x268,-1,-209},
+	{0x269,0x269,-1,-211},
+	{0x26b,0x26b,-1,10743},
+	{0x26f,0x26f,-1,-211},
+	{0x271,0x271,-1,10749},
+	{0x272,0x272,-1,-213},
+	{0x275,0x275,-1,-214},
+	{0x27d,0x27d,-1,10727},
+	{0x280,0x283,3,-218},
+	{0x288,0x288,-1,-218},
+	{0x289,0x289,-1,-69},
+	{0x28a,0x28b,1,-217},
+	{0x28c,0x28c,-1,-71},
+	{0x292,0x292,-1,-219},
+	{0x345,0x345,-1,84},
+	{0x371,0x373,2,-1},
+	{0x377,0x377,-1,-1},
+	{0x37b,0x37d,1,130},
+	{0x3ac,0x3ac,-1,-38},
+	{0x3ad,0x3af,1,-37},
+	{0x3b1,0x3c1,1,-32},
+	{0x3c2,0x3c2,-1,-31},
+	{0x3c3,0x3cb,1,-32},
+	{0x3cc,0x3cc,-1,-64},
+	{0x3cd,0x3ce,1,-63},
+	{0x3d0,0x3d0,-1,-62},
+	{0x3d1,0x3d1,-1,-57},
+	{0x3d5,0x3d5,-1,-47},
+	{0x3d6,0x3d6,-1,-54},
+	{0x3d7,0x3d7,-1,-8},
+	{0x3d9,0x3ef,2,-1},
+	{0x3f0,0x3f0,-1,-86},
+	{0x3f1,0x3f1,-1,-80},
+	{0x3f2,0x3f2,-1,7},
+	{0x3f5,0x3f5,-1,-96},
+	{0x3f8,0x3fb,3,-1},
+	{0x430,0x44f,1,-32},
+	{0x450,0x45f,1,-80},
+	{0x461,0x481,2,-1},
+	{0x48b,0x4bf,2,-1},
+	{0x4c2,0x4ce,2,-1},
+	{0x4cf,0x4cf,-1,-15},
+	{0x4d1,0x525,2,-1},
+	{0x561,0x586,1,-48},
+	{0x1d79,0x1d79,-1,35332},
+	{0x1d7d,0x1d7d,-1,3814},
+	{0x1e01,0x1e95,2,-1},
+	{0x1e9b,0x1e9b,-1,-59},
+	{0x1ea1,0x1eff,2,-1},
+	{0x1f00,0x1f07,1,8},
+	{0x1f10,0x1f15,1,8},
+	{0x1f20,0x1f27,1,8},
+	{0x1f30,0x1f37,1,8},
+	{0x1f40,0x1f45,1,8},
+	{0x1f51,0x1f57,2,8},
+	{0x1f60,0x1f67,1,8},
+	{0x1f70,0x1f71,1,74},
+	{0x1f72,0x1f75,1,86},
+	{0x1f76,0x1f77,1,100},
+	{0x1f78,0x1f79,1,128},
+	{0x1f7a,0x1f7b,1,112},
+	{0x1f7c,0x1f7d,1,126},
+	{0x1f80,0x1f87,1,8},
+	{0x1f90,0x1f97,1,8},
+	{0x1fa0,0x1fa7,1,8},
+	{0x1fb0,0x1fb1,1,8},
+	{0x1fb3,0x1fb3,-1,9},
+	{0x1fbe,0x1fbe,-1,-7205},
+	{0x1fc3,0x1fc3,-1,9},
+	{0x1fd0,0x1fd1,1,8},
+	{0x1fe0,0x1fe1,1,8},
+	{0x1fe5,0x1fe5,-1,7},
+	{0x1ff3,0x1ff3,-1,9},
+	{0x214e,0x214e,-1,-28},
+	{0x2170,0x217f,1,-16},
+	{0x2184,0x2184,-1,-1},
+	{0x24d0,0x24e9,1,-26},
+	{0x2c30,0x2c5e,1,-48},
+	{0x2c61,0x2c61,-1,-1},
+	{0x2c65,0x2c65,-1,-10795},
+	{0x2c66,0x2c66,-1,-10792},
+	{0x2c68,0x2c6c,2,-1},
+	{0x2c73,0x2c76,3,-1},
+	{0x2c81,0x2ce3,2,-1},
+	{0x2cec,0x2cee,2,-1},
+	{0x2d00,0x2d25,1,-7264},
+	{0xa641,0xa65f,2,-1},
+	{0xa663,0xa66d,2,-1},
+	{0xa681,0xa697,2,-1},
+	{0xa723,0xa72f,2,-1},
+	{0xa733,0xa76f,2,-1},
+	{0xa77a,0xa77c,2,-1},
+	{0xa77f,0xa787,2,-1},
+	{0xa78c,0xa78c,-1,-1},
+	{0xff41,0xff5a,1,-32},
+	{0x10428,0x1044f,1,-40}
 };
 
 /*
  * Return the upper-case equivalent of "a", which is a UCS-4 character.  Use
  * simple case folding.
@@ -2415,17 +3186,17 @@ show_utf8()
 }
 
 /*
  * mb_head_off() function pointer.
  * Return offset from "p" to the first byte of the character it points into.
+ * If "p" points to the NUL at the end of the string return 0.
  * Returns 0 when already at the first byte of a character.
  */
-/*ARGSUSED*/
     int
 latin_head_off(base, p)
-    char_u	*base;
-    char_u	*p;
+    char_u	*base UNUSED;
+    char_u	*p UNUSED;
 {
     return 0;
 }
 
     int
@@ -2435,11 +3206,11 @@ dbcs_head_off(base, p)
 {
     char_u	*q;
 
     /* It can't be a trailing byte when not using DBCS, at the start of the
      * string or the previous byte can't start a double-byte. */
-    if (p <= base || MB_BYTE2LEN(p[-1]) == 1)
+    if (p <= base || MB_BYTE2LEN(p[-1]) == 1 || *p == NUL)
 	return 0;
 
     /* This is slow: need to start at the base and go forward until the
      * byte we are looking for.  Return 1 when we went past it, 0 otherwise. */
     q = base;
@@ -2463,11 +3234,12 @@ dbcs_screen_head_off(base, p)
      * string or the previous byte can't start a double-byte.
      * For euc-jp an 0x8e byte in the previous cell always means we have a
      * lead byte in the current cell. */
     if (p <= base
 	    || (enc_dbcs == DBCS_JPNU && p[-1] == 0x8e)
-	    || MB_BYTE2LEN(p[-1]) == 1)
+	    || MB_BYTE2LEN(p[-1]) == 1
+	    || *p == NUL)
 	return 0;
 
     /* This is slow: need to start at the base and go forward until the
      * byte we are looking for.  Return 1 when we went past it, 0 otherwise.
      * For DBCS_JPNU look out for 0x8e, which means the second byte is not
@@ -2489,10 +3261,11 @@ utf_head_off(base, p)
     char_u	*p;
 {
     char_u	*q;
     char_u	*s;
     int		c;
+    int		len;
 #ifdef FEAT_ARABIC
     char_u	*j;
 #endif
 
     if (*p < 0x80)		/* be quick for ASCII */
@@ -2508,12 +3281,12 @@ utf_head_off(base, p)
 	/* Move q to the first byte of this char. */
 	while (q > base && (*q & 0xc0) == 0x80)
 	    --q;
 	/* Check for illegal sequence. Do allow an illegal byte after where we
 	 * started. */
-	if (utf8len_tab[*q] != (int)(s - q + 1)
-				       && utf8len_tab[*q] != (int)(p - q + 1))
+	len = utf8len_tab[*q];
+	if (len != (int)(s - q + 1) && len != (int)(p - q + 1))
 	    return 0;
 
 	if (q <= base)
 	    break;
 
@@ -2538,11 +3311,10 @@ utf_head_off(base, p)
     }
 
     return (int)(p - q);
 }
 
-#if defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Copy a character from "*fp" to "*tp" and advance the pointers.
  */
     void
 mb_copy_char(fp, tp)
@@ -2553,11 +3325,10 @@ mb_copy_char(fp, tp)
 
     mch_memmove(*tp, *fp, (size_t)l);
     *tp += l;
     *fp += l;
 }
-#endif
 
 /*
  * Return the offset from "p" to the first byte of a character.  When "p" is
  * at the start of a character 0 is returned, otherwise the offset to the next
  * character.  Can start anywhere in a stream of bytes.
@@ -2723,13 +3494,13 @@ utf_valid_string(s, end)
     int		l;
     char_u	*p = s;
 
     while (end == NULL ? *p != NUL : p < end)
     {
-	if ((*p & 0xc0) == 0x80)
+	l = utf8len_tab_zero[*p];
+	if (l == 0)
 	    return FALSE;	/* invalid lead byte */
-	l = utf8len_tab[*p];
 	if (end != NULL && p + l > end)
 	    return FALSE;	/* incomplete byte sequence */
 	++p;
 	while (--l > 0)
 	    if ((*p++ & 0xc0) != 0x80)
@@ -3131,11 +3902,11 @@ enc_locale()
 	    s = buf + 10;
 	}
 	else
 	    s = p + 1;
     }
-    for (i = 0; s[i] != NUL && s + i < buf + sizeof(buf) - 1; ++i)
+    for (i = 0; s[i] != NUL && i < (int)sizeof(buf) - 1; ++i)
     {
 	if (s[i] == '_' || s[i] == '-')
 	    buf[i] = '-';
 	else if (isalnum((int)s[i]))
 	    buf[i] = TOLOWER_ASC(s[i]);
@@ -3178,11 +3949,11 @@ encname2codepage(name)
 }
 #endif
 
 # if defined(USE_ICONV) || defined(PROTO)
 
-static char_u *iconv_string __ARGS((vimconv_T *vcp, char_u *str, int slen, int *unconvlenp));
+static char_u *iconv_string __ARGS((vimconv_T *vcp, char_u *str, int slen, int *unconvlenp, int *resultlenp));
 
 /*
  * Call iconv_open() with a check if iconv() works properly (there are broken
  * versions).
  * Returns (void *)-1 if failed.
@@ -3239,17 +4010,19 @@ my_iconv_open(to, from)
 /*
  * Convert the string "str[slen]" with iconv().
  * If "unconvlenp" is not NULL handle the string ending in an incomplete
  * sequence and set "*unconvlenp" to the length of it.
  * Returns the converted string in allocated memory.  NULL for an error.
+ * If resultlenp is not NULL, sets it to the result length in bytes.
  */
     static char_u *
-iconv_string(vcp, str, slen, unconvlenp)
+iconv_string(vcp, str, slen, unconvlenp, resultlenp)
     vimconv_T	*vcp;
     char_u	*str;
     int		slen;
     int		*unconvlenp;
+    int		*resultlenp;
 {
     const char	*from;
     size_t	fromlen;
     char	*to;
     size_t	tolen;
@@ -3331,10 +4104,13 @@ iconv_string(vcp, str, slen, unconvlenp)
 	    break;
 	}
 	/* Not enough room or skipping illegal sequence. */
 	done = to - (char *)result;
     }
+
+    if (resultlenp != NULL)
+	*resultlenp = (int)(to - (char *)result);
     return result;
 }
 
 #  if defined(DYNAMIC_ICONV) || defined(PROTO)
 /*
@@ -3582,13 +4358,14 @@ im_show_info(void)
 
 /*
  * Callback invoked when the user finished preediting.
  * Put the final string into the input buffer.
  */
-/*ARGSUSED0*/
     static void
-im_commit_cb(GtkIMContext *context, const gchar *str, gpointer data)
+im_commit_cb(GtkIMContext *context UNUSED,
+	     const gchar *str,
+	     gpointer data UNUSED)
 {
     int	slen = (int)STRLEN(str);
     int	add_to_input = TRUE;
     int	clen;
     int	len = slen;
@@ -3670,13 +4447,12 @@ im_commit_cb(GtkIMContext *context, cons
 }
 
 /*
  * Callback invoked after start to the preedit.
  */
-/*ARGSUSED*/
     static void
-im_preedit_start_cb(GtkIMContext *context, gpointer data)
+im_preedit_start_cb(GtkIMContext *context UNUSED, gpointer data UNUSED)
 {
 #ifdef XIM_DEBUG
     xim_log("im_preedit_start_cb()\n");
 #endif
 
@@ -3687,13 +4463,12 @@ im_preedit_start_cb(GtkIMContext *contex
 }
 
 /*
  * Callback invoked after end to the preedit.
  */
-/*ARGSUSED*/
     static void
-im_preedit_end_cb(GtkIMContext *context, gpointer data)
+im_preedit_end_cb(GtkIMContext *context UNUSED, gpointer data UNUSED)
 {
 #ifdef XIM_DEBUG
     xim_log("im_preedit_end_cb()\n");
 #endif
     im_delete_preedit();
@@ -3748,13 +4523,12 @@ im_preedit_end_cb(GtkIMContext *context,
  * at the receiving end of the queue.  This, however, would have a rather large
  * impact on the code base.  If there is an easy way to force processing of all
  * remaining input from within the "retrieve_surrounding" signal handler, this
  * might not be necessary.  Gotta ask on vim-dev for opinions.
  */
-/*ARGSUSED1*/
     static void
-im_preedit_changed_cb(GtkIMContext *context, gpointer data)
+im_preedit_changed_cb(GtkIMContext *context, gpointer data UNUSED)
 {
     char    *preedit_string = NULL;
     int	    cursor_index    = 0;
     int	    num_move_back   = 0;
     char_u  *str;
@@ -4616,15 +5390,14 @@ xim_set_focus(focus)
 #endif
 	}
     }
 }
 
-/*ARGSUSED*/
     void
 im_set_position(row, col)
-    int		row;
-    int		col;
+    int		row UNUSED;
+    int		col UNUSED;
 {
     xim_set_preedit();
 }
 
 /*
@@ -4927,16 +5700,15 @@ static int xim_real_init __ARGS((Window
 
 #ifdef USE_X11R6_XIM
 static void xim_instantiate_cb __ARGS((Display *display, XPointer client_data, XPointer	call_data));
 static void xim_destroy_cb __ARGS((XIM im, XPointer client_data, XPointer call_data));
 
-/*ARGSUSED*/
     static void
 xim_instantiate_cb(display, client_data, call_data)
     Display	*display;
-    XPointer	client_data;
-    XPointer	call_data;
+    XPointer	client_data UNUSED;
+    XPointer	call_data UNUSED;
 {
     Window	x11_window;
     Display	*x11_display;
 
 #ifdef XIM_DEBUG
@@ -4952,16 +5724,15 @@ xim_instantiate_cb(display, client_data,
     if (xic != NULL)
 	XUnregisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
 					 xim_instantiate_cb, NULL);
 }
 
-/*ARGSUSED*/
     static void
 xim_destroy_cb(im, client_data, call_data)
-    XIM		im;
-    XPointer	client_data;
-    XPointer	call_data;
+    XIM		im UNUSED;
+    XPointer	client_data UNUSED;
+    XPointer	call_data UNUSED;
 {
     Window	x11_window;
     Display	*x11_display;
 
 #ifdef XIM_DEBUG
@@ -5276,13 +6047,14 @@ xim_decide_input_style()
 	    supported_style &= ~(int)GDK_IM_STATUS_AREA;
 	xim_input_style = (int)gdk_im_decide_style((GdkIMStyle)supported_style);
     }
 }
 
-/*ARGSUSED*/
     static void
-preedit_start_cbproc(XIC xic, XPointer client_data, XPointer call_data)
+preedit_start_cbproc(XIC thexic UNUSED,
+	             XPointer client_data UNUSED,
+		     XPointer call_data UNUSED)
 {
 #ifdef XIM_DEBUG
     xim_log("xim_decide_input_style()\n");
 #endif
 
@@ -5310,13 +6082,14 @@ xim_back_delete(int n)
 }
 
 static GSList *key_press_event_queue = NULL;
 static gboolean processing_queued_event = FALSE;
 
-/*ARGSUSED*/
     static void
-preedit_draw_cbproc(XIC xic, XPointer client_data, XPointer call_data)
+preedit_draw_cbproc(XIC thexic UNUSED,
+		    XPointer client_data UNUSED,
+		    XPointer call_data)
 {
     XIMPreeditDrawCallbackStruct *draw_data;
     XIMText	*text;
     char	*src;
     GSList	*event_queue;
@@ -5384,11 +6157,11 @@ preedit_draw_cbproc(XIC xic, XPointer cl
 		{
 		    if (draw_feedback == NULL)
 			draw_feedback = (char *)alloc(draw_data->chg_first
 							      + text->length);
 		    else
-			draw_feedback = realloc(draw_feedback,
+			draw_feedback = vim_realloc(draw_feedback,
 					 draw_data->chg_first + text->length);
 		    if (draw_feedback != NULL)
 		    {
 			draw_feedback[nfeedback + draw_data->chg_first]
 				       = draw_data->text->feedback[nfeedback];
@@ -5451,22 +6224,24 @@ im_get_feedback_attr(int col)
     }
 
     return -1;
 }
 
-/*ARGSUSED*/
     static void
-preedit_caret_cbproc(XIC xic, XPointer client_data, XPointer call_data)
+preedit_caret_cbproc(XIC thexic UNUSED,
+		     XPointer client_data UNUSED,
+		     XPointer call_data UNUSED)
 {
 #ifdef XIM_DEBUG
     xim_log("preedit_caret_cbproc()\n");
 #endif
 }
 
-/*ARGSUSED*/
     static void
-preedit_done_cbproc(XIC xic, XPointer client_data, XPointer call_data)
+preedit_done_cbproc(XIC thexic UNUSED,
+		    XPointer client_data UNUSED,
+		    XPointer call_data UNUSED)
 {
 #ifdef XIM_DEBUG
     xim_log("preedit_done_cbproc()\n");
 #endif
 
@@ -5501,13 +6276,12 @@ xim_reset(void)
 	if (text != NULL)
 	    XFree(text);
     }
 }
 
-/*ARGSUSED*/
     int
-xim_queue_key_press_event(GdkEventKey *event, int down)
+xim_queue_key_press_event(GdkEventKey *event, int down UNUSED)
 {
 #ifdef XIM_DEBUG
     xim_log("xim_queue_key_press_event()\n");
 #endif
 
@@ -5519,13 +6293,12 @@ xim_queue_key_press_event(GdkEventKey *e
     key_press_event_queue = g_slist_append(key_press_event_queue,
 					   gdk_event_copy((GdkEvent *)event));
     return TRUE;
 }
 
-/*ARGSUSED*/
     static void
-preedit_callback_setup(GdkIC *ic)
+preedit_callback_setup(GdkIC *ic UNUSED)
 {
     XIC xxic;
     XVaNestedList preedit_attr;
     XIMCallback preedit_start_cb;
     XIMCallback preedit_draw_cb;
@@ -5546,13 +6319,12 @@ preedit_callback_setup(GdkIC *ic)
 			       NULL);
     XSetICValues(xxic, XNPreeditAttributes, preedit_attr, NULL);
     XFree(preedit_attr);
 }
 
-/*ARGSUSED*/
     static void
-reset_state_setup(GdkIC *ic)
+reset_state_setup(GdkIC *ic UNUSED)
 {
 #ifdef USE_X11R6_XIM
     /* don't change the input context when we call reset */
     XSetICValues(((GdkICPrivate *)ic)->xic, XNResetState, XIMPreserveState,
 									NULL);
@@ -5754,12 +6526,29 @@ im_is_preediting()
 convert_setup(vcp, from, to)
     vimconv_T	*vcp;
     char_u	*from;
     char_u	*to;
 {
+    return convert_setup_ext(vcp, from, TRUE, to, TRUE);
+}
+
+/*
+ * As convert_setup(), but only when from_unicode_is_utf8 is TRUE will all
+ * "from" unicode charsets be considered utf-8.  Same for "to".
+ */
+    int
+convert_setup_ext(vcp, from, from_unicode_is_utf8, to, to_unicode_is_utf8)
+    vimconv_T	*vcp;
+    char_u	*from;
+    int		from_unicode_is_utf8;
+    char_u	*to;
+    int		to_unicode_is_utf8;
+{
     int		from_prop;
     int		to_prop;
+    int		from_is_utf8;
+    int		to_is_utf8;
 
     /* Reset to no conversion. */
 # ifdef USE_ICONV
     if (vcp->vc_type == CONV_ICONV && vcp->vc_fd != (iconv_t)-1)
 	iconv_close(vcp->vc_fd);
@@ -5773,69 +6562,78 @@ convert_setup(vcp, from, to)
 						     || STRCMP(from, to) == 0)
 	return OK;
 
     from_prop = enc_canon_props(from);
     to_prop = enc_canon_props(to);
-    if ((from_prop & ENC_LATIN1) && (to_prop & ENC_UNICODE))
+    if (from_unicode_is_utf8)
+	from_is_utf8 = from_prop & ENC_UNICODE;
+    else
+	from_is_utf8 = from_prop == ENC_UNICODE;
+    if (to_unicode_is_utf8)
+	to_is_utf8 = to_prop & ENC_UNICODE;
+    else
+	to_is_utf8 = to_prop == ENC_UNICODE;
+
+    if ((from_prop & ENC_LATIN1) && to_is_utf8)
     {
 	/* Internal latin1 -> utf-8 conversion. */
 	vcp->vc_type = CONV_TO_UTF8;
 	vcp->vc_factor = 2;	/* up to twice as long */
     }
-    else if ((from_prop & ENC_LATIN9) && (to_prop & ENC_UNICODE))
+    else if ((from_prop & ENC_LATIN9) && to_is_utf8)
     {
 	/* Internal latin9 -> utf-8 conversion. */
 	vcp->vc_type = CONV_9_TO_UTF8;
 	vcp->vc_factor = 3;	/* up to three as long (euro sign) */
     }
-    else if ((from_prop & ENC_UNICODE) && (to_prop & ENC_LATIN1))
+    else if (from_is_utf8 && (to_prop & ENC_LATIN1))
     {
 	/* Internal utf-8 -> latin1 conversion. */
 	vcp->vc_type = CONV_TO_LATIN1;
     }
-    else if ((from_prop & ENC_UNICODE) && (to_prop & ENC_LATIN9))
+    else if (from_is_utf8 && (to_prop & ENC_LATIN9))
     {
 	/* Internal utf-8 -> latin9 conversion. */
 	vcp->vc_type = CONV_TO_LATIN9;
     }
 #ifdef WIN3264
     /* Win32-specific codepage <-> codepage conversion without iconv. */
-    else if (((from_prop & ENC_UNICODE) || encname2codepage(from) > 0)
-	    && ((to_prop & ENC_UNICODE) || encname2codepage(to) > 0))
+    else if ((from_is_utf8 || encname2codepage(from) > 0)
+	    && (to_is_utf8 || encname2codepage(to) > 0))
     {
 	vcp->vc_type = CONV_CODEPAGE;
 	vcp->vc_factor = 2;	/* up to twice as long */
-	vcp->vc_cpfrom = (from_prop & ENC_UNICODE) ? 0 : encname2codepage(from);
-	vcp->vc_cpto = (to_prop & ENC_UNICODE) ? 0 : encname2codepage(to);
+	vcp->vc_cpfrom = from_is_utf8 ? 0 : encname2codepage(from);
+	vcp->vc_cpto = to_is_utf8 ? 0 : encname2codepage(to);
     }
 #endif
 #ifdef MACOS_X
     else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_LATIN1))
     {
 	vcp->vc_type = CONV_MAC_LATIN1;
     }
-    else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_UNICODE))
+    else if ((from_prop & ENC_MACROMAN) && to_is_utf8)
     {
 	vcp->vc_type = CONV_MAC_UTF8;
 	vcp->vc_factor = 2;	/* up to twice as long */
     }
     else if ((from_prop & ENC_LATIN1) && (to_prop & ENC_MACROMAN))
     {
 	vcp->vc_type = CONV_LATIN1_MAC;
     }
-    else if ((from_prop & ENC_UNICODE) && (to_prop & ENC_MACROMAN))
+    else if (from_is_utf8 && (to_prop & ENC_MACROMAN))
     {
 	vcp->vc_type = CONV_UTF8_MAC;
     }
 #endif
 # ifdef USE_ICONV
     else
     {
 	/* Use iconv() for conversion. */
 	vcp->vc_fd = (iconv_t)my_iconv_open(
-		(to_prop & ENC_UNICODE) ? (char_u *)"utf-8" : to,
-		(from_prop & ENC_UNICODE) ? (char_u *)"utf-8" : from);
+		to_is_utf8 ? (char_u *)"utf-8" : to,
+		from_is_utf8 ? (char_u *)"utf-8" : from);
 	if (vcp->vc_fd != (iconv_t)-1)
 	{
 	    vcp->vc_type = CONV_ICONV;
 	    vcp->vc_factor = 4;	/* could be longer too... */
 	}
@@ -6003,16 +6801,24 @@ string_convert_ext(vcp, ptr, lenp, uncon
 	    if (retval == NULL)
 		break;
 	    d = retval;
 	    for (i = 0; i < len; ++i)
 	    {
-		l = utf_ptr2len(ptr + i);
+		l = utf_ptr2len_len(ptr + i, len - i);
 		if (l == 0)
 		    *d++ = NUL;
 		else if (l == 1)
 		{
-		    if (unconvlenp != NULL && utf8len_tab[ptr[i]] > len - i)
+		    int l_w = utf8len_tab_zero[ptr[i]];
+
+		    if (l_w == 0)
+		    {
+			/* Illegal utf-8 byte cannot be converted */
+			vim_free(retval);
+			return NULL;
+		    }
+		    if (unconvlenp != NULL && l_w > len - i)
 		    {
 			/* Incomplete sequence at the end. */
 			*unconvlenp = len - i;
 			break;
 		    }
@@ -6087,13 +6893,11 @@ string_convert_ext(vcp, ptr, lenp, uncon
 	    break;
 # endif
 
 # ifdef USE_ICONV
 	case CONV_ICONV:	/* conversion with output_conv.vc_fd */
-	    retval = iconv_string(vcp, ptr, len, unconvlenp);
-	    if (retval != NULL && lenp != NULL)
-		*lenp = (int)STRLEN(retval);
+	    retval = iconv_string(vcp, ptr, len, unconvlenp, lenp);
 	    break;
 # endif
 # ifdef WIN3264
 	case CONV_CODEPAGE:		/* codepage -> codepage */
 	{
@@ -6101,33 +6905,33 @@ string_convert_ext(vcp, ptr, lenp, uncon
 	    int		tmp_len;
 	    short_u	*tmp;
 
 	    /* 1. codepage/UTF-8  ->  ucs-2. */
 	    if (vcp->vc_cpfrom == 0)
-		tmp_len = utf8_to_ucs2(ptr, len, NULL, NULL);
+		tmp_len = utf8_to_utf16(ptr, len, NULL, NULL);
 	    else
 		tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0,
 							      ptr, len, 0, 0);
 	    tmp = (short_u *)alloc(sizeof(short_u) * tmp_len);
 	    if (tmp == NULL)
 		break;
 	    if (vcp->vc_cpfrom == 0)
-		utf8_to_ucs2(ptr, len, tmp, unconvlenp);
+		utf8_to_utf16(ptr, len, tmp, unconvlenp);
 	    else
 		MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, tmp, tmp_len);
 
 	    /* 2. ucs-2  ->  codepage/UTF-8. */
 	    if (vcp->vc_cpto == 0)
-		retlen = ucs2_to_utf8(tmp, tmp_len, NULL);
+		retlen = utf16_to_utf8(tmp, tmp_len, NULL);
 	    else
 		retlen = WideCharToMultiByte(vcp->vc_cpto, 0,
 						    tmp, tmp_len, 0, 0, 0, 0);
 	    retval = alloc(retlen + 1);
 	    if (retval != NULL)
 	    {
 		if (vcp->vc_cpto == 0)
-		    ucs2_to_utf8(tmp, tmp_len, retval);
+		    utf16_to_utf8(tmp, tmp_len, retval);
 		else
 		    WideCharToMultiByte(vcp->vc_cpto, 0,
 					  tmp, tmp_len, retval, retlen, 0, 0);
 		retval[retlen] = NUL;
 		if (lenp != NULL)
--- vim72.orig/src/memfile.c
+++ vim72/src/memfile.c
@@ -1341,10 +1341,15 @@ mf_do_open(mfp, fname, flags)
 	mfp->mf_fname = NULL;
 	mfp->mf_ffname = NULL;
     }
     else
     {
+#ifdef HAVE_FD_CLOEXEC
+	int fdflags = fcntl(mfp->mf_fd, F_GETFD);
+	if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
+	    fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
+#endif
 #ifdef HAVE_SELINUX
 	mch_copy_sec(fname, mfp->mf_fname);
 #endif
 	mch_hide(mfp->mf_fname);    /* try setting the 'hidden' flag */
     }
--- vim72.orig/src/memline.c
+++ vim72/src/memline.c
@@ -380,11 +380,11 @@ ml_open(buf)
 
     dp = (DATA_BL *)(hp->bh_data);
     dp->db_index[0] = --dp->db_txt_start;	/* at end of block */
     dp->db_free -= 1 + INDEX_SIZE;
     dp->db_line_count = 1;
-    *((char_u *)dp + dp->db_txt_start) = NUL;	/* emtpy line */
+    *((char_u *)dp + dp->db_txt_start) = NUL;	/* empty line */
 
     return OK;
 
 error:
     if (mfp != NULL)
@@ -488,10 +488,17 @@ ml_setname(buf)
 	{
 	    /* could not (re)open the swap file, what can we do???? */
 	    EMSG(_("E301: Oops, lost the swap file!!!"));
 	    return;
 	}
+#ifdef HAVE_FD_CLOEXEC
+	{
+	    int fdflags = fcntl(mfp->mf_fd, F_GETFD);
+	    if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
+		fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
+	}
+#endif
     }
     if (!success)
 	EMSG(_("E302: Could not rename swap file"));
 }
 
@@ -862,25 +869,28 @@ ml_recover()
     int		attr;
 
     recoverymode = TRUE;
     called_from_main = (curbuf->b_ml.ml_mfp == NULL);
     attr = hl_attr(HLF_E);
-/*
- * If the file name ends in ".sw?" we use it directly.
- * Otherwise a search is done to find the swap file(s).
- */
+
+    /*
+     * If the file name ends in ".s[uvw][a-z]" we assume this is the swap file.
+     * Otherwise a search is done to find the swap file(s).
+     */
     fname = curbuf->b_fname;
     if (fname == NULL)		    /* When there is no file name */
 	fname = (char_u *)"";
     len = (int)STRLEN(fname);
     if (len >= 4 &&
 #if defined(VMS) || defined(RISCOS)
-	    STRNICMP(fname + len - 4, "_sw" , 3)
+	    STRNICMP(fname + len - 4, "_s" , 2)
 #else
-	    STRNICMP(fname + len - 4, ".sw" , 3)
+	    STRNICMP(fname + len - 4, ".s" , 2)
 #endif
-		== 0)
+		== 0
+		&& vim_strchr((char_u *)"UVWuvw", fname[len - 2]) != NULL
+		&& ASCII_ISALPHA(fname[len - 1]))
     {
 	directly = TRUE;
 	fname = vim_strsave(fname); /* make a copy for mf_open() */
     }
     else
@@ -1280,22 +1290,23 @@ ml_recover()
 		    }
 
 		    for (i = 0; i < dp->db_line_count; ++i)
 		    {
 			txt_start = (dp->db_index[i] & DB_INDEX_MASK);
-			if (txt_start <= HEADER_SIZE
+			if (txt_start <= (int)HEADER_SIZE
 					  || txt_start >= (int)dp->db_txt_end)
 			{
 			    p = (char_u *)"???";
 			    ++error;
 			}
 			else
 			    p = (char_u *)dp + txt_start;
 			ml_append(lnum++, p, (colnr_T)0, TRUE);
 		    }
 		    if (has_error)
-			ml_append(lnum++, (char_u *)_("???END"), (colnr_T)0, TRUE);
+			ml_append(lnum++, (char_u *)_("???END"),
+							    (colnr_T)0, TRUE);
 		}
 	    }
 	}
 
 	if (buf->b_ml.ml_stack_top == 0)	/* finished */
@@ -1552,14 +1563,19 @@ recover_names(fname, list, nr)
 			       && (p = curbuf->b_ml.ml_mfp->mf_fname) != NULL)
 	{
 	    for (i = 0; i < num_files; ++i)
 		if (fullpathcmp(p, files[i], TRUE) & FPC_SAME)
 		{
+		    /* Remove the name from files[i].  Move further entries
+		     * down.  When the array becomes empty free it here, since
+		     * FreeWild() won't be called below. */
 		    vim_free(files[i]);
-		    --num_files;
-		    for ( ; i < num_files; ++i)
-			files[i] = files[i + 1];
+		    if (--num_files == 0)
+			vim_free(files);
+		    else
+			for ( ; i < num_files; ++i)
+			    files[i] = files[i + 1];
 		}
 	}
 	if (nr > 0)
 	{
 	    file_count += num_files;
@@ -2095,16 +2111,16 @@ errorret:
 	lnum = 1;
 
     if (buf->b_ml.ml_mfp == NULL)	/* there are no lines */
 	return (char_u *)"";
 
-/*
- * See if it is the same line as requested last time.
- * Otherwise may need to flush last used line.
- * Don't use the last used line when 'swapfile' is reset, need to load all
- * blocks.
- */
+    /*
+     * See if it is the same line as requested last time.
+     * Otherwise may need to flush last used line.
+     * Don't use the last used line when 'swapfile' is reset, need to load all
+     * blocks.
+     */
     if (buf->b_ml.ml_line_lnum != lnum || mf_dont_release)
     {
 	ml_flush_line(buf);
 
 	/*
@@ -3069,16 +3085,23 @@ ml_flush_line(buf)
     int		extra;
     int		idx;
     int		start;
     int		count;
     int		i;
+    static int  entered = FALSE;
 
     if (buf->b_ml.ml_line_lnum == 0 || buf->b_ml.ml_mfp == NULL)
 	return;		/* nothing to do */
 
     if (buf->b_ml.ml_flags & ML_LINE_DIRTY)
     {
+	/* This code doesn't work recursively, but Netbeans may call back here
+	 * when obtaining the cursor position. */
+	if (entered)
+	    return;
+	entered = TRUE;
+
 	lnum = buf->b_ml.ml_line_lnum;
 	new_line = buf->b_ml.ml_line_ptr;
 
 	hp = ml_find_line(buf, lnum, ML_FIND);
 	if (hp == NULL)
@@ -3142,10 +3165,12 @@ ml_flush_line(buf)
 					     (dp->db_index[idx] & DB_MARKED));
 		(void)ml_delete_int(buf, lnum, FALSE);
 	    }
 	}
 	vim_free(new_line);
+
+	entered = FALSE;
     }
 
     buf->b_ml.ml_line_lnum = 0;
 }
 
@@ -3520,11 +3545,11 @@ resolve_symlink(fname, buf)
 	if (ret <= 0)
 	{
 	    if (errno == EINVAL || errno == ENOENT)
 	    {
 		/* Found non-symlink or not existing file, stop here.
-		 * When at the first level use the unmodifed name, skip the
+		 * When at the first level use the unmodified name, skip the
 		 * call to vim_FullName(). */
 		if (depth == 1)
 		    return FAIL;
 
 		/* Use the resolved name in tmp[]. */
@@ -3566,15 +3591,14 @@ resolve_symlink(fname, buf)
 
 /*
  * Make swap file name out of the file name and a directory name.
  * Returns pointer to allocated memory or NULL.
  */
-/*ARGSUSED*/
     char_u *
 makeswapname(fname, ffname, buf, dir_name)
     char_u	*fname;
-    char_u	*ffname;
+    char_u	*ffname UNUSED;
     buf_T	*buf;
     char_u	*dir_name;
 {
     char_u	*r, *s;
 #ifdef HAVE_READLINK
@@ -3764,12 +3788,14 @@ do_swapexists(buf, fname)
 {
     set_vim_var_string(VV_SWAPNAME, fname, -1);
     set_vim_var_string(VV_SWAPCHOICE, NULL, -1);
 
     /* Trigger SwapExists autocommands with <afile> set to the file being
-     * edited. */
+     * edited.  Disallow changing directory here. */
+    ++allbuf_lock;
     apply_autocmds(EVENT_SWAPEXISTS, buf->b_fname, NULL, FALSE, NULL);
+    --allbuf_lock;
 
     set_vim_var_string(VV_SWAPNAME, NULL, -1);
 
     switch (*get_vim_var_str(VV_SWAPCHOICE))
     {
@@ -3791,10 +3817,11 @@ do_swapexists(buf, fname)
  * Several names are tried to find one that does not exist
  * Returns the name in allocated memory or NULL.
  *
  * Note: If BASENAMELEN is not correct, you will get error messages for
  *	 not being able to open the swapfile
+ * Note: May trigger SwapExists autocmd, pointers may change!
  */
     static char_u *
 findswapname(buf, dirp, old_fname)
     buf_T	*buf;
     char_u	**dirp;		/* pointer to list of directories */
@@ -4558,11 +4585,11 @@ ml_updatechunk(buf, line, len, updtype)
 
 	    mch_memmove(buf->b_ml.ml_chunksize + curix + 1,
 			buf->b_ml.ml_chunksize + curix,
 			(buf->b_ml.ml_usedchunks - curix) *
 			sizeof(chunksize_T));
-	    /* Compute length of first half of lines in the splitted chunk */
+	    /* Compute length of first half of lines in the split chunk */
 	    size = 0;
 	    linecnt = 0;
 	    while (curline < buf->b_ml.ml_line_count
 			&& linecnt < MLCS_MINL)
 	    {
--- vim72.orig/src/menu.c
+++ vim72/src/menu.c
@@ -229,19 +229,19 @@ ex_menu(eap)
 	    if (STRNCMP(menu_path, "BuiltIn", 7) == 0)
 	    {
 		if (skipdigits(menu_path + 7) == p)
 		{
 		    menuarg.iconidx = atoi((char *)menu_path + 7);
-		    if (menuarg.iconidx >= TOOLBAR_NAME_COUNT)
+		    if (menuarg.iconidx >= (int)TOOLBAR_NAME_COUNT)
 			menuarg.iconidx = -1;
 		    else
 			menuarg.icon_builtin = TRUE;
 		}
 	    }
 	    else
 	    {
-		for (i = 0; i < TOOLBAR_NAME_COUNT; ++i)
+		for (i = 0; i < (int)TOOLBAR_NAME_COUNT; ++i)
 		    if (STRNCMP(toolbar_names[i], menu_path, p - menu_path)
 									 == 0)
 		    {
 			menuarg.iconidx = i;
 			break;
@@ -1118,10 +1118,11 @@ show_menus(path_name, modes)
 	}
 	name = p;
 	parent = menu;
 	menu = menu->children;
     }
+    vim_free(path_name);
 
     /* Now we have found the matching menu, and we list the mappings */
 						    /* Highlight title */
     MSG_PUTS_TITLE(_("\n--- Menus ---"));
 
@@ -1338,14 +1339,13 @@ set_context_in_menu_cmd(xp, cmd, arg, fo
 
 /*
  * Function given to ExpandGeneric() to obtain the list of (sub)menus (not
  * entries).
  */
-/*ARGSUSED*/
     char_u *
 get_menu_name(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     static vimmenu_T	*menu = NULL;
     char_u		*str;
 
@@ -1375,14 +1375,13 @@ get_menu_name(xp, idx)
 
 /*
  * Function given to ExpandGeneric() to obtain the list of menus and menu
  * entries.
  */
-/*ARGSUSED*/
     char_u *
 get_menu_names(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     static vimmenu_T	*menu = NULL;
     static char_u	tbuffer[256]; /*hack*/
     char_u		*str;
@@ -1736,14 +1735,13 @@ menu_is_hidden(name)
 #if defined(FEAT_CMDL_COMPL) \
 	|| (defined(FEAT_GUI_W32) && defined(FEAT_TEAROFF))
 /*
  * Return TRUE if the menu is the tearoff menu.
  */
-/*ARGSUSED*/
     static int
 menu_is_tearoff(name)
-    char_u *name;
+    char_u *name UNUSED;
 {
 #ifdef FEAT_GUI
     return (STRCMP(name, TEAR_STRING) == 0);
 #else
     return FALSE;
@@ -2340,14 +2338,13 @@ static garray_T menutrans_ga = {0, 0, 0,
 /*
  * ":menutrans".
  * This function is also defined without the +multi_lang feature, in which
  * case the commands are ignored.
  */
-/*ARGSUSED*/
     void
 ex_menutranslate(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
 #ifdef FEAT_MULTI_LANG
     char_u		*arg = eap->arg;
     menutrans_T		*tp;
     int			i;
--- vim72.orig/src/message.c
+++ vim72/src/message.c
@@ -105,11 +105,11 @@ msg(s)
 {
     return msg_attr_keep(s, 0, FALSE);
 }
 
 #if defined(FEAT_EVAL) || defined(FEAT_X11) || defined(USE_XSMP) \
-    || defined(PROTO)
+    || defined(FEAT_GUI_GTK) || defined(PROTO)
 /*
  * Like msg() but keep it silent when 'verbosefile' is set.
  */
     int
 verb_msg(s)
@@ -816,14 +816,13 @@ delete_first_msg()
 }
 
 /*
  * ":messages" command.
  */
-/*ARGSUSED*/
     void
 ex_messages(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     struct msg_hist *p;
     char_u	    *s;
 
     msg_hist_off = TRUE;
@@ -974,11 +973,11 @@ wait_return(redraw)
 			c = K_IGNORE;
 			hit_return_msg();
 		    }
 		}
 		else if (msg_scrolled > Rows - 2
-				     && (c == 'j' || c == K_DOWN || c == 'd'))
+			 && (c == 'j' || c == K_DOWN || c == 'd' || c == 'f'))
 		    c = K_IGNORE;
 	    }
 	} while ((had_got_int && c == Ctrl_C)
 				|| c == K_IGNORE
 #ifdef FEAT_GUI
@@ -2502,23 +2501,24 @@ do_more_prompt(typed_char)
 	case K_DOWN:
 	    scroll = 1;
 	    break;
 
 	case 'u':		/* Up half a page */
-	case K_PAGEUP:
 	    scroll = -(Rows / 2);
 	    break;
 
 	case 'd':		/* Down half a page */
 	    scroll = Rows / 2;
 	    break;
 
 	case 'b':		/* one page back */
+	case K_PAGEUP:
 	    scroll = -(Rows - 1);
 	    break;
 
 	case ' ':		/* one extra page */
+	case 'f':
 	case K_PAGEDOWN:
 	case K_LEFTMOUSE:
 	    scroll = Rows - 1;
 	    break;
 
@@ -2550,18 +2550,20 @@ do_more_prompt(typed_char)
 #ifdef FEAT_CON_DIALOG
 	    if (confirm_msg_used)
 	    {
 		/* Jump to the choices of the dialog. */
 		retval = TRUE;
-		lines_left = Rows - 1;
 	    }
 	    else
 #endif
 	    {
 		got_int = TRUE;
 		quit_more = TRUE;
 	    }
+	    /* When there is some more output (wrapping line) display that
+	     * without another prompt. */
+	    lines_left = Rows - 1;
 	    break;
 
 #ifdef FEAT_CLIPBOARD
 	case Ctrl_Y:
 	    /* Strange way to allow copying (yanking) a modeless
@@ -3018,15 +3020,11 @@ redir_write(str, maxlen)
      * Must come before the rest because of updating "msg_col".
      */
     if (*p_vfile != NUL)
 	verbose_write(s, maxlen);
 
-    if (redir_fd != NULL
-#ifdef FEAT_EVAL
-			  || redir_reg || redir_vname
-#endif
-				       )
+    if (redirecting())
     {
 	/* If the string doesn't start with CR or NL, go to msg_col */
 	if (*s != '\n' && *s != '\r')
 	{
 	    while (cur_col < msg_col)
@@ -3069,10 +3067,20 @@ redir_write(str, maxlen)
 	if (msg_silent != 0)	/* should update msg_col */
 	    msg_col = cur_col;
     }
 }
 
+    int
+redirecting()
+{
+    return redir_fd != NULL
+#ifdef FEAT_EVAL
+			  || redir_reg || redir_vname
+#endif
+				       ;
+}
+
 /*
  * Before giving verbose message.
  * Must always be called paired with verbose_leave()!
  */
     void
@@ -3279,19 +3287,19 @@ msg_advance(col)
  * The second button should be the 'Cancel' button
  * Other buttons- use your imagination!
  * A '&' in a button name becomes a shortcut, so each '&' should be before a
  * different letter.
  */
-/* ARGSUSED */
     int
 do_dialog(type, title, message, buttons, dfltbutton, textfield)
-    int		type;
-    char_u	*title;
+    int		type UNUSED;
+    char_u	*title UNUSED;
     char_u	*message;
     char_u	*buttons;
     int		dfltbutton;
-    char_u	*textfield;	/* IObuff for inputdialog(), NULL otherwise */
+    char_u	*textfield UNUSED;	/* IObuff for inputdialog(), NULL
+					   otherwise */
 {
     int		oldState;
     int		retval = 0;
     char_u	*hotkeys;
     int		c;
@@ -3307,11 +3315,14 @@ do_dialog(type, title, message, buttons,
     /* When GUI is running and 'c' not in 'guioptions', use the GUI dialog */
     if (gui.in_use && vim_strchr(p_go, GO_CONDIALOG) == NULL)
     {
 	c = gui_mch_dialog(type, title, message, buttons, dfltbutton,
 								   textfield);
-	msg_end_prompt();
+	/* avoid a hit-enter prompt without clearing the cmdline */
+	need_wait_return = FALSE;
+	emsg_on_display = FALSE;
+	cmdline_row = msg_row;
 
 	/* Flush output to avoid that further messages and redrawing is done
 	 * in the wrong order. */
 	out_flush();
 	gui_mch_update();
@@ -4007,11 +4018,11 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
     while (*p != NUL)
     {
 	if (*p != '%')
 	{
 	    char    *q = strchr(p + 1, '%');
-	    size_t  n = (q == NULL) ? STRLEN(p) : (q - p);
+	    size_t  n = (q == NULL) ? STRLEN(p) : (size_t)(q - p);
 
 	    /* Copy up to the next '%' or NUL without any changes. */
 	    if (str_l < str_m)
 	    {
 		size_t avail = str_m - str_l;
@@ -4254,11 +4265,12 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
 			/* memchr on HP does not like n > 2^31  !!! */
 			char *q = memchr(str_arg, '\0',
 				  precision <= (size_t)0x7fffffffL ? precision
 						       : (size_t)0x7fffffffL);
 #endif
-			str_arg_l = (q == NULL) ? precision : q - str_arg;
+			str_arg_l = (q == NULL) ? precision
+						      : (size_t)(q - str_arg);
 		    }
 		    break;
 
 		default:
 		    break;
@@ -4354,11 +4366,12 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
 				uint_arg =
 #ifndef HAVE_STDARG_H
 					    get_a_arg(arg_idx);
 #else
 # if defined(FEAT_EVAL)
-					    tvs != NULL ? tv_nr(tvs, &arg_idx) :
+					    tvs != NULL ? (unsigned)
+							tv_nr(tvs, &arg_idx) :
 # endif
 						va_arg(ap, unsigned int);
 #endif
 				if (uint_arg != 0)
 				    arg_sign = 1;
@@ -4367,11 +4380,12 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
 				ulong_arg =
 #ifndef HAVE_STDARG_H
 					    get_a_arg(arg_idx);
 #else
 # if defined(FEAT_EVAL)
-					    tvs != NULL ? tv_nr(tvs, &arg_idx) :
+					    tvs != NULL ? (unsigned long)
+							tv_nr(tvs, &arg_idx) :
 # endif
 						va_arg(ap, unsigned long int);
 #endif
 				if (ulong_arg != 0)
 				    arg_sign = 1;
@@ -4554,11 +4568,17 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
 			else
 			    fmt_spec = fmt_spec == 'g' ? 'e' : 'E';
 			remove_trailing_zeroes = TRUE;
 		    }
 
-		    if (fmt_spec == 'f' && abs_f > 1.0e307)
+		    if (fmt_spec == 'f' &&
+#ifdef VAX
+			    abs_f > 1.0e38
+#else
+			    abs_f > 1.0e307
+#endif
+			    )
 		    {
 			/* Avoid a buffer overflow */
 			strcpy(tmp, "inf");
 			str_arg_l = 3;
 		    }
@@ -4583,65 +4603,66 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
 			str_arg_l = sprintf(tmp, format, f);
 
 			if (remove_trailing_zeroes)
 			{
 			    int i;
-			    char *p;
+			    char *tp;
 
 			    /* Using %g or %G: remove superfluous zeroes. */
 			    if (fmt_spec == 'f')
-				p = tmp + str_arg_l - 1;
+				tp = tmp + str_arg_l - 1;
 			    else
 			    {
-				p = (char *)vim_strchr((char_u *)tmp,
+				tp = (char *)vim_strchr((char_u *)tmp,
 						 fmt_spec == 'e' ? 'e' : 'E');
-				if (p != NULL)
+				if (tp != NULL)
 				{
 				    /* Remove superfluous '+' and leading
 				     * zeroes from the exponent. */
-				    if (p[1] == '+')
+				    if (tp[1] == '+')
 				    {
 					/* Change "1.0e+07" to "1.0e07" */
-					STRMOVE(p + 1, p + 2);
+					STRMOVE(tp + 1, tp + 2);
 					--str_arg_l;
 				    }
-				    i = (p[1] == '-') ? 2 : 1;
-				    while (p[i] == '0')
+				    i = (tp[1] == '-') ? 2 : 1;
+				    while (tp[i] == '0')
 				    {
 					/* Change "1.0e07" to "1.0e7" */
-					STRMOVE(p + i, p + i + 1);
+					STRMOVE(tp + i, tp + i + 1);
 					--str_arg_l;
 				    }
-				    --p;
+				    --tp;
 				}
 			    }
 
-			    if (p != NULL && !precision_specified)
+			    if (tp != NULL && !precision_specified)
 				/* Remove trailing zeroes, but keep the one
 				 * just after a dot. */
-				while (p > tmp + 2 && *p == '0' && p[-1] != '.')
+				while (tp > tmp + 2 && *tp == '0'
+							     && tp[-1] != '.')
 				{
-				    STRMOVE(p, p + 1);
-				    --p;
+				    STRMOVE(tp, tp + 1);
+				    --tp;
 				    --str_arg_l;
 				}
 			}
 			else
 			{
-			    char *p;
+			    char *tp;
 
 			    /* Be consistent: some printf("%e") use 1.0e+12
 			     * and some 1.0e+012.  Remove one zero in the last
 			     * case. */
-			    p = (char *)vim_strchr((char_u *)tmp,
+			    tp = (char *)vim_strchr((char_u *)tmp,
 						 fmt_spec == 'e' ? 'e' : 'E');
-			    if (p != NULL && (p[1] == '+' || p[1] == '-')
-					  && p[2] == '0'
-					  && vim_isdigit(p[3])
-					  && vim_isdigit(p[4]))
+			    if (tp != NULL && (tp[1] == '+' || tp[1] == '-')
+					  && tp[2] == '0'
+					  && vim_isdigit(tp[3])
+					  && vim_isdigit(tp[4]))
 			    {
-				STRMOVE(p + 2, p + 3);
+				STRMOVE(tp + 2, tp + 3);
 				--str_arg_l;
 			    }
 			}
 		    }
 		    str_arg = tmp;
@@ -4683,11 +4704,12 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
 		    if (str_l < str_m)
 		    {
 			size_t avail = str_m - str_l;
 
 			vim_memset(str + str_l, zero_padding ? '0' : ' ',
-					     (size_t)pn > avail ? avail : pn);
+					     (size_t)pn > avail ? avail
+								: (size_t)pn);
 		    }
 		    str_l += pn;
 		}
 	    }
 
@@ -4710,11 +4732,12 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
 		    if (str_l < str_m)
 		    {
 			size_t avail = str_m - str_l;
 
 			mch_memmove(str + str_l, str_arg,
-					     (size_t)zn > avail ? avail : zn);
+					     (size_t)zn > avail ? avail
+								: (size_t)zn);
 		    }
 		    str_l += zn;
 		}
 
 		/* insert zero padding as requested by the precision or min
@@ -4725,11 +4748,12 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
 		    if (str_l < str_m)
 		    {
 			size_t avail = str_m-str_l;
 
 			vim_memset(str + str_l, '0',
-					     (size_t)zn > avail ? avail : zn);
+					     (size_t)zn > avail ? avail
+								: (size_t)zn);
 		    }
 		    str_l += zn;
 		}
 	    }
 
@@ -4744,11 +4768,11 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
 		    {
 			size_t avail = str_m - str_l;
 
 			mch_memmove(str + str_l,
 				str_arg + zero_padding_insertion_ind,
-				(size_t)sn > avail ? avail : sn);
+				(size_t)sn > avail ? avail : (size_t)sn);
 		    }
 		    str_l += sn;
 		}
 	    }
 
@@ -4764,11 +4788,12 @@ vim_snprintf(str, str_m, fmt, a1, a2, a3
 		    if (str_l < str_m)
 		    {
 			size_t avail = str_m - str_l;
 
 			vim_memset(str + str_l, ' ',
-					     (size_t)pn > avail ? avail : pn);
+					     (size_t)pn > avail ? avail
+								: (size_t)pn);
 		    }
 		    str_l += pn;
 		}
 	    }
 	}
--- vim72.orig/src/misc1.c
+++ vim72/src/misc1.c
@@ -1024,16 +1024,18 @@ open_line(dir, flags, old_indent)
 		if (lead_repl != NULL)
 		{
 		    int		c = 0;
 		    int		off = 0;
 
-		    for (p = lead_flags; *p && *p != ':'; ++p)
+		    for (p = lead_flags; *p != NUL && *p != ':'; )
 		    {
 			if (*p == COM_RIGHT || *p == COM_LEFT)
-			    c = *p;
+			    c = *p++;
 			else if (VIM_ISDIGIT(*p) || *p == '-')
 			    off = getdigits(&p);
+			else
+			    ++p;
 		    }
 		    if (c == COM_RIGHT)    /* right adjusted leader */
 		    {
 			/* find last non-white in the leader to line up with */
 			for (p = leader + lead_len - 1; p > leader
@@ -1117,11 +1119,11 @@ open_line(dir, flags, old_indent)
 				    break;
 			    }
 			    if (i != lead_repl_len)
 			    {
 				mch_memmove(p + lead_repl_len, p + i,
-				       (size_t)(lead_len - i - (leader - p)));
+				       (size_t)(lead_len - i - (p - leader)));
 				lead_len += lead_repl_len - i;
 			    }
 			}
 #endif
 			mch_memmove(p, lead_repl, (size_t)lead_repl_len);
@@ -2186,16 +2188,15 @@ del_chars(count, fixpos)
  * If "fixpos" is TRUE, don't leave the cursor on the NUL after the line.
  * Caller must have prepared for undo.
  *
  * return FAIL for failure, OK otherwise
  */
-/*ARGSUSED*/
     int
 del_bytes(count, fixpos_arg, use_delcombine)
     long	count;
     int		fixpos_arg;
-    int		use_delcombine;	    /* 'delcombine' option applies */
+    int		use_delcombine UNUSED;	    /* 'delcombine' option applies */
 {
     char_u	*oldp, *newp;
     colnr_T	oldlen;
     linenr_T	lnum = curwin->w_cursor.lnum;
     colnr_T	col = curwin->w_cursor.col;
@@ -2344,35 +2345,39 @@ truncate_line(fixpos)
 del_lines(nlines, undo)
     long	nlines;		/* number of lines to delete */
     int		undo;		/* if TRUE, prepare for undo */
 {
     long	n;
+    linenr_T	first = curwin->w_cursor.lnum;
 
     if (nlines <= 0)
 	return;
 
     /* save the deleted lines for undo */
-    if (undo && u_savedel(curwin->w_cursor.lnum, nlines) == FAIL)
+    if (undo && u_savedel(first, nlines) == FAIL)
 	return;
 
     for (n = 0; n < nlines; )
     {
 	if (curbuf->b_ml.ml_flags & ML_EMPTY)	    /* nothing to delete */
 	    break;
 
-	ml_delete(curwin->w_cursor.lnum, TRUE);
+	ml_delete(first, TRUE);
 	++n;
 
 	/* If we delete the last line in the file, stop */
-	if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
+	if (first > curbuf->b_ml.ml_line_count)
 	    break;
     }
-    /* adjust marks, mark the buffer as changed and prepare for displaying */
-    deleted_lines_mark(curwin->w_cursor.lnum, n);
 
+    /* Correct the cursor position before calling deleted_lines_mark(), it may
+     * trigger a callback to display the cursor. */
     curwin->w_cursor.col = 0;
     check_cursor_lnum();
+
+    /* adjust marks, mark the buffer as changed and prepare for displaying */
+    deleted_lines_mark(first, n);
 }
 
     int
 gchar_pos(pos)
     pos_T *pos;
@@ -2620,10 +2625,12 @@ deleted_lines(lnum, count)
     changed_lines(lnum, 0, lnum + count, -count);
 }
 
 /*
  * Like deleted_lines(), but adjust marks first.
+ * Make sure the cursor is on a valid line before calling, a GUI callback may
+ * be triggered to display the cursor.
  */
     void
 deleted_lines_mark(lnum, count)
     linenr_T	lnum;
     long	count;
@@ -2715,10 +2722,13 @@ changed_common(lnum, col, lnume, xtra)
     colnr_T	col;
     linenr_T	lnume;
     long	xtra;
 {
     win_T	*wp;
+#ifdef FEAT_WINDOWS
+    tabpage_T	*tp;
+#endif
     int		i;
 #ifdef FEAT_JUMPLIST
     int		cols;
     pos_T	*p;
     int		add;
@@ -2767,19 +2777,19 @@ changed_common(lnum, col, lnume, xtra)
 		{
 		    /* changelist is full: remove oldest entry */
 		    curbuf->b_changelistlen = JUMPLISTSIZE - 1;
 		    mch_memmove(curbuf->b_changelist, curbuf->b_changelist + 1,
 					  sizeof(pos_T) * (JUMPLISTSIZE - 1));
-		    FOR_ALL_WINDOWS(wp)
+		    FOR_ALL_TAB_WINDOWS(tp, wp)
 		    {
 			/* Correct position in changelist for other windows on
 			 * this buffer. */
 			if (wp->w_buffer == curbuf && wp->w_changelistidx > 0)
 			    --wp->w_changelistidx;
 		    }
 		}
-		FOR_ALL_WINDOWS(wp)
+		FOR_ALL_TAB_WINDOWS(tp, wp)
 		{
 		    /* For other windows, if the position in the changelist is
 		     * at the end it stays at the end. */
 		    if (wp->w_buffer == curbuf
 			    && wp->w_changelistidx == curbuf->b_changelistlen)
@@ -2794,11 +2804,11 @@ changed_common(lnum, col, lnume, xtra)
 	 * takes you back to it. */
 	curwin->w_changelistidx = curbuf->b_changelistlen;
 #endif
     }
 
-    FOR_ALL_WINDOWS(wp)
+    FOR_ALL_TAB_WINDOWS(tp, wp)
     {
 	if (wp->w_buffer == curbuf)
 	{
 	    /* Mark this window to be redrawn later. */
 	    if (wp->w_redr_type < VALID)
@@ -2876,10 +2886,17 @@ changed_common(lnum, col, lnume, xtra)
 			 * may need to be redrawn */
 			wp->w_lines[i].wl_valid = FALSE;
 		    }
 #endif
 		}
+
+#ifdef FEAT_FOLDING
+	    /* Take care of side effects for setting w_topline when folds have
+	     * changed.  Esp. when the buffer was changed in another window. */
+	    if (hasAnyFolding(wp))
+		set_topline(wp, wp->w_topline);
+#endif
 	}
     }
 
     /* Call update_screen() later, which checks out what needs to be redrawn,
      * since it notices b_mod_set and then uses b_mod_*. */
@@ -2953,10 +2970,12 @@ check_status(buf)
     void
 change_warning(col)
     int	    col;		/* column for message; non-zero when in insert
 				   mode and 'showmode' is on */
 {
+    static char *w_readonly = N_("W10: Warning: Changing a readonly file");
+
     if (curbuf->b_did_warn == FALSE
 	    && curbufIsChanged() == 0
 #ifdef FEAT_AUTOCMD
 	    && !autocmd_busy
 #endif
@@ -2975,12 +2994,14 @@ change_warning(col)
 	 */
 	msg_start();
 	if (msg_row == Rows - 1)
 	    msg_col = col;
 	msg_source(hl_attr(HLF_W));
-	MSG_PUTS_ATTR(_("W10: Warning: Changing a readonly file"),
-						   hl_attr(HLF_W) | MSG_HIST);
+	MSG_PUTS_ATTR(_(w_readonly), hl_attr(HLF_W) | MSG_HIST);
+#ifdef FEAT_EVAL
+	set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_readonly), -1);
+#endif
 	msg_clr_eos();
 	(void)msg_end();
 	if (msg_silent == 0 && !silent_mode)
 	{
 	    out_flush();
@@ -3243,13 +3264,13 @@ prompt_for_number(mouse_used)
     int		save_cmdline_row;
     int		save_State;
 
     /* When using ":silent" assume that <CR> was entered. */
     if (mouse_used != NULL)
-	MSG_PUTS(_("Type number or click with mouse (<Enter> cancels): "));
+	MSG_PUTS(_("Type number and <Enter> or click with mouse (empty cancels): "));
     else
-	MSG_PUTS(_("Choice number (<Enter> cancels): "));
+	MSG_PUTS(_("Type number and <Enter> (empty cancels): "));
 
     /* Set the state such that text can be selected/copied/pasted and we still
      * get mouse events. */
     save_cmdline_row = cmdline_row;
     cmdline_row = 0;
@@ -3262,10 +3283,11 @@ prompt_for_number(mouse_used)
 	/* don't call wait_return() now */
 	/* msg_putchar('\n'); */
 	cmdline_row = msg_row - 1;
 	need_wait_return = FALSE;
 	msg_didany = FALSE;
+	msg_didout = FALSE;
     }
     else
 	cmdline_row = save_cmdline_row;
     State = save_State;
 
@@ -3446,11 +3468,13 @@ init_homedir()
     {
 	char_u *homedrive, *homepath;
 
 	homedrive = mch_getenv((char_u *)"HOMEDRIVE");
 	homepath = mch_getenv((char_u *)"HOMEPATH");
-	if (homedrive != NULL && homepath != NULL
+	if (homepath == NULL || *homepath == NUL)
+	    homepath = "\\";
+	if (homedrive != NULL
 			   && STRLEN(homedrive) + STRLEN(homepath) < MAXPATHL)
 	{
 	    sprintf((char *)NameBuff, "%s%s", homedrive, homepath);
 	    if (NameBuff[0] != NUL)
 	    {
@@ -4139,14 +4163,13 @@ vim_setenv(name, val)
 
 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
 /*
  * Function given to ExpandGeneric() to obtain an environment variable name.
  */
-/*ARGSUSED*/
     char_u *
 get_env_name(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
 # if defined(AMIGA) || defined(__MRC__) || defined(__SC__)
     /*
      * No environ[] on the Amiga and on the Mac (using MPW).
@@ -4643,11 +4666,10 @@ concat_fnames(fname1, fname2, sep)
 	STRCAT(dest, fname2);
     }
     return dest;
 }
 
-#if defined(FEAT_EVAL) || defined(FEAT_GETTEXT) || defined(PROTO)
 /*
  * Concatenate two strings and return the result in allocated memory.
  * Returns NULL when out of memory.
  */
     char_u  *
@@ -4664,11 +4686,10 @@ concat_str(str1, str2)
 	STRCPY(dest, str1);
 	STRCPY(dest + l, str2);
     }
     return dest;
 }
-#endif
 
 /*
  * Add a path separator to a file name, unless it already ends in a path
  * separator.
  */
@@ -4734,13 +4755,13 @@ find_start_comment(ind_maxcomment)	    /
 	/*
 	 * Check if the comment start we found is inside a string.
 	 * If it is then restrict the search to below this line and try again.
 	 */
 	line = ml_get(pos->lnum);
-	for (p = line; *p && (unsigned)(p - line) < pos->col; ++p)
+	for (p = line; *p && (colnr_T)(p - line) < pos->col; ++p)
 	    p = skip_string(p);
-	if ((unsigned)(p - line) <= pos->col)
+	if ((colnr_T)(p - line) <= pos->col)
 	    break;
 	cur_maxcomment = curwin->w_cursor.lnum - pos->lnum - 1;
 	if (cur_maxcomment <= 0)
 	{
 	    pos = NULL;
@@ -6247,10 +6268,12 @@ get_c_indent()
 	    case 'h': ind_scopedecl_code = n; break;
 	    case 'j': ind_java = n; break;
 	    case 'l': ind_keep_case_label = n; break;
 	    case '#': ind_hash_comment = n; break;
 	}
+	if (*options == ',')
+	    ++options;
     }
 
     /* remember where the cursor was when we started */
     cur_curpos = curwin->w_cursor;
 
@@ -6267,11 +6290,11 @@ get_c_indent()
      * inserting new stuff.
      * For unknown reasons the cursor might be past the end of the line, thus
      * check for that.
      */
     if ((State & INSERT)
-	    && curwin->w_cursor.col < STRLEN(linecopy)
+	    && curwin->w_cursor.col < (colnr_T)STRLEN(linecopy)
 	    && linecopy[curwin->w_cursor.col] == ')')
 	linecopy[curwin->w_cursor.col] = NUL;
 
     theline = skipwhite(linecopy);
 
@@ -7704,15 +7727,18 @@ term_again:
 	}
 
 	/*
 	 * If the NEXT line is a function declaration, the current
 	 * line needs to be indented as a function type spec.
-	 * Don't do this if the current line looks like a comment
-	 * or if the current line is terminated, ie. ends in ';'.
+	 * Don't do this if the current line looks like a comment or if the
+	 * current line is terminated, ie. ends in ';', or if the current line
+	 * contains { or }: "void f() {\n if (1)"
 	 */
 	else if (cur_curpos.lnum < curbuf->b_ml.ml_line_count
 		&& !cin_nocode(theline)
+		&& vim_strchr(theline, '{') == NULL
+		&& vim_strchr(theline, '}') == NULL
 		&& !cin_ends_in(theline, (char_u *)":", NULL)
 		&& !cin_ends_in(theline, (char_u *)",", NULL)
 		&& cin_isfuncdecl(NULL, cur_curpos.lnum + 1)
 		&& !cin_isterminated(theline, FALSE, TRUE))
 	{
@@ -8424,10 +8450,50 @@ fast_breakcheck()
 	ui_breakcheck();
     }
 }
 
 /*
+ * Invoke expand_wildcards() for one pattern.
+ * Expand items like "%:h" before the expansion.
+ * Returns OK or FAIL.
+ */
+    int
+expand_wildcards_eval(pat, num_file, file, flags)
+    char_u	 **pat;		/* pointer to input pattern */
+    int		  *num_file;	/* resulting number of files */
+    char_u	***file;	/* array of resulting files */
+    int		   flags;	/* EW_DIR, etc. */
+{
+    int		ret = FAIL;
+    char_u	*eval_pat = NULL;
+    char_u	*exp_pat = *pat;
+    char_u      *ignored_msg;
+    int		usedlen;
+
+    if (*exp_pat == '%' || *exp_pat == '#' || *exp_pat == '<')
+    {
+	++emsg_off;
+	eval_pat = eval_vars(exp_pat, exp_pat, &usedlen,
+						    NULL, &ignored_msg, NULL);
+	--emsg_off;
+	if (eval_pat != NULL)
+	    exp_pat = concat_str(eval_pat, exp_pat + usedlen);
+    }
+
+    if (exp_pat != NULL)
+	ret = expand_wildcards(1, &exp_pat, num_file, file, flags);
+
+    if (eval_pat != NULL)
+    {
+	vim_free(exp_pat);
+	vim_free(eval_pat);
+    }
+
+    return ret;
+}
+
+/*
  * Expand wildcards.  Calls gen_expand_wildcards() and removes files matching
  * 'wildignore'.
  * Returns OK or FAIL.
  */
     int
@@ -8520,15 +8586,29 @@ match_suffix(fname)
     fnamelen = (int)STRLEN(fname);
     setsuflen = 0;
     for (setsuf = p_su; *setsuf; )
     {
 	setsuflen = copy_option_part(&setsuf, suf_buf, MAXSUFLEN, ".,");
-	if (fnamelen >= setsuflen
-		&& fnamencmp(suf_buf, fname + fnamelen - setsuflen,
-					      (size_t)setsuflen) == 0)
-	    break;
-	setsuflen = 0;
+	if (setsuflen == 0)
+	{
+	    char_u *tail = gettail(fname);
+
+	    /* empty entry: match name without a '.' */
+	    if (vim_strchr(tail, '.') == NULL)
+	    {
+		setsuflen = 1;
+		break;
+	    }
+	}
+	else
+	{
+	    if (fnamelen >= setsuflen
+		    && fnamencmp(suf_buf, fname + fnamelen - setsuflen,
+						  (size_t)setsuflen) == 0)
+		break;
+	    setsuflen = 0;
+	}
     }
     return (setsuflen != 0);
 }
 
 #if !defined(NO_EXPANDPATH) || defined(PROTO)
@@ -8726,11 +8806,11 @@ dos_expandpath(
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
 	/* The active codepage differs from 'encoding'.  Attempt using the
 	 * wide function.  If it fails because it is not implemented fall back
 	 * to the non-wide version (for Windows 98) */
-	wn = enc_to_ucs2(buf, NULL);
+	wn = enc_to_utf16(buf, NULL);
 	if (wn != NULL)
 	{
 	    hFind = FindFirstFileW(wn, &wfb);
 	    if (hFind == INVALID_HANDLE_VALUE
 			      && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
@@ -8754,11 +8834,11 @@ dos_expandpath(
     while (ok)
     {
 #ifdef WIN3264
 # ifdef FEAT_MBYTE
 	if (wn != NULL)
-	    p = ucs2_to_enc(wfb.cFileName, NULL);   /* p is allocated here */
+	    p = utf16_to_enc(wfb.cFileName, NULL);   /* p is allocated here */
 	else
 # endif
 	    p = (char_u *)fb.cFileName;
 #else
 	p = (char_u *)fb.ff_name;
@@ -8828,11 +8908,11 @@ dos_expandpath(
 	    FindClose(hFind);
 # ifdef FEAT_MBYTE
 	    if (wn != NULL)
 	    {
 		vim_free(wn);
-		wn = enc_to_ucs2(buf, NULL);
+		wn = enc_to_utf16(buf, NULL);
 		if (wn != NULL)
 		    hFind = FindFirstFileW(wn, &wfb);
 	    }
 	    if (wn == NULL)
 # endif
@@ -9186,11 +9266,11 @@ gen_expand_wildcards(num_pat, pat, num_f
 		 * found file names and start all over again.
 		 */
 		else if (vim_strpbrk(p, (char_u *)"$~") != NULL)
 		{
 		    vim_free(p);
-		    ga_clear(&ga);
+		    ga_clear_strings(&ga);
 		    i = mch_expand_wildcards(num_pat, pat, num_file, file,
 								       flags);
 		    recursive = FALSE;
 		    return i;
 		}
--- vim72.orig/src/misc2.c
+++ vim72/src/misc2.c
@@ -154,11 +154,11 @@ coladvance2(pos, addspaces, finetune, wc
 #endif
 #ifdef FEAT_VIRTUALEDIT
 		    || ((ve_flags & VE_ONEMORE) && wcol < MAXCOL)
 #endif
 		    ;
-    line = ml_get_curline();
+    line = ml_get_buf(curbuf, pos->lnum, FALSE);
 
     if (wcol >= MAXCOL)
     {
 	    idx = (int)STRLEN(line) - 1 + one_more;
 	    col = wcol;
@@ -330,13 +330,13 @@ coladvance2(pos, addspaces, finetune, wc
 	}
     }
 #endif
 
 #ifdef FEAT_MBYTE
-    /* prevent cursor from moving on the trail byte */
+    /* prevent from moving onto a trail byte */
     if (has_mbyte)
-	mb_adjust_cursor();
+	mb_adjustpos(pos);
 #endif
 
     if (col < wcol)
 	return FAIL;
     return OK;
@@ -494,11 +494,12 @@ check_cursor_lnum()
     void
 check_cursor_col()
 {
     colnr_T len;
 #ifdef FEAT_VIRTUALEDIT
-    colnr_T oldcol = curwin->w_cursor.col + curwin->w_cursor.coladd;
+    colnr_T oldcol = curwin->w_cursor.col;
+    colnr_T oldcoladd = curwin->w_cursor.col + curwin->w_cursor.coladd;
 #endif
 
     len = (colnr_T)STRLEN(ml_get_curline());
     if (len == 0)
 	curwin->w_cursor.col = 0;
@@ -525,19 +526,27 @@ check_cursor_col()
 	    if (has_mbyte)
 		mb_adjust_cursor();
 #endif
 	}
     }
+    else if (curwin->w_cursor.col < 0)
+	curwin->w_cursor.col = 0;
 
 #ifdef FEAT_VIRTUALEDIT
     /* If virtual editing is on, we can leave the cursor on the old position,
      * only we must set it to virtual.  But don't do it when at the end of the
      * line. */
     if (oldcol == MAXCOL)
 	curwin->w_cursor.coladd = 0;
     else if (ve_flags == VE_ALL)
-	curwin->w_cursor.coladd = oldcol - curwin->w_cursor.col;
+    {
+	if (oldcoladd > curwin->w_cursor.col)
+	    curwin->w_cursor.coladd = oldcoladd - curwin->w_cursor.col;
+	else
+	    /* avoid weird number when there is a miscalculation or overflow */
+	    curwin->w_cursor.coladd = 0;
+    }
 #endif
 }
 
 /*
  * make sure curwin->w_cursor in on a valid character
@@ -871,11 +880,11 @@ lalloc(size, message)
 	    allocated = 0;
 # endif
 	    /* 3. check for available memory: call mch_avail_mem() */
 	    if (mch_avail_mem(TRUE) < KEEP_ROOM && !releasing)
 	    {
-		vim_free((char *)p);	/* System is low... no go! */
+		free((char *)p);	/* System is low... no go! */
 		p = NULL;
 	    }
 	    else
 		goto theend;
 #endif
@@ -996,22 +1005,30 @@ free_all_mem()
 # endif
 
 # ifdef FEAT_MENU
     /* Clear menus. */
     do_cmdline_cmd((char_u *)"aunmenu *");
+#  ifdef FEAT_MULTI_LANG
+    do_cmdline_cmd((char_u *)"menutranslate clear");
+#  endif
 # endif
 
     /* Clear mappings, abbreviations, breakpoints. */
+    do_cmdline_cmd((char_u *)"lmapclear");
+    do_cmdline_cmd((char_u *)"xmapclear");
     do_cmdline_cmd((char_u *)"mapclear");
     do_cmdline_cmd((char_u *)"mapclear!");
     do_cmdline_cmd((char_u *)"abclear");
 # if defined(FEAT_EVAL)
     do_cmdline_cmd((char_u *)"breakdel *");
 # endif
 # if defined(FEAT_PROFILE)
     do_cmdline_cmd((char_u *)"profdel *");
 # endif
+# if defined(FEAT_KEYMAP)
+    do_cmdline_cmd((char_u *)"set keymap=");
+#endif
 
 # ifdef FEAT_TITLE
     free_titles();
 # endif
 # if defined(FEAT_SEARCHPATH)
@@ -1032,10 +1049,13 @@ free_all_mem()
     free_last_insert();
     free_prev_shellcmd();
     free_regexp_stuff();
     free_tag_stuff();
     free_cd_dir();
+# ifdef FEAT_SIGNS
+    free_signs();
+# endif
 # ifdef FEAT_EVAL
     set_expr_line(NULL);
 # endif
 # ifdef FEAT_DIFF
     diff_clear(curtab);
@@ -1060,15 +1080,16 @@ free_all_mem()
     init_history();
 # endif
 
 #ifdef FEAT_QUICKFIX
     {
-	win_T	*win;
+	win_T	    *win;
+	tabpage_T   *tab;
 
 	qf_free_all(NULL);
 	/* Free all location lists */
-	FOR_ALL_WINDOWS(win)
+	FOR_ALL_TAB_WINDOWS(tab, win)
 	    qf_free_all(win);
     }
 #endif
 
     /* Close all script inputs. */
@@ -1255,25 +1276,22 @@ vim_strsave_escaped_ext(string, esc_char
 	*p2 = NUL;
     }
     return escaped_string;
 }
 
-#if !defined(BACKSLASH_IN_FILENAME) || defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Return TRUE when 'shell' has "csh" in the tail.
  */
     int
 csh_like_shell()
 {
     return (strstr((char *)gettail(p_sh), "csh") != NULL);
 }
-#endif
 
-#if defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Escape "string" for use as a shell argument with system().
- * This uses single quotes, except when we know we need to use double qoutes
+ * This uses single quotes, except when we know we need to use double quotes
  * (MS-DOS and MS-Windows without 'shellslash' set).
  * Escape a newline, depending on the 'shell' option.
  * When "do_special" is TRUE also replace "!", "%", "#" and things starting
  * with "<" like "<cfile>".
  * Returns the result in allocated memory, NULL if we have run out.
@@ -1372,10 +1390,11 @@ vim_strsave_shellescape(string, do_speci
 	    if (do_special && find_cmdline_var(p, &l) >= 0)
 	    {
 		*d++ = '\\';		/* insert backslash */
 		while (--l >= 0)	/* copy the var */
 		    *d++ = *p++;
+		continue;
 	    }
 
 	    MB_COPY_CHAR(p, d);
 	}
 
@@ -1389,11 +1408,10 @@ vim_strsave_shellescape(string, do_speci
 	*d = NUL;
     }
 
     return escaped_string;
 }
-#endif
 
 /*
  * Like vim_strsave(), but make all characters uppercase.
  * This uses ASCII lower-to-upper case translation, language independent.
  */
@@ -1525,11 +1543,11 @@ copy_spaces(ptr, count)
 }
 
 #if defined(FEAT_VISUALEXTRA) || defined(PROTO)
 /*
  * Copy a character a number of times.
- * Does not work for multi-byte charactes!
+ * Does not work for multi-byte characters!
  */
     void
 copy_chars(ptr, count, c)
     char_u	*ptr;
     size_t	count;
@@ -2563,11 +2581,11 @@ trans_special(srcp, dst, keycode)
 {
     int		modifiers = 0;
     int		key;
     int		dlen = 0;
 
-    key = find_special_key(srcp, &modifiers, keycode);
+    key = find_special_key(srcp, &modifiers, keycode, FALSE);
     if (key == 0)
 	return 0;
 
     /* Put the appropriate modifier in a string */
     if (modifiers != 0)
@@ -2599,14 +2617,15 @@ trans_special(srcp, dst, keycode)
  * Try translating a <> name at (*srcp)[], return the key and modifiers.
  * srcp is advanced to after the <> name.
  * returns 0 if there is no match.
  */
     int
-find_special_key(srcp, modp, keycode)
+find_special_key(srcp, modp, keycode, keep_x_key)
     char_u	**srcp;
     int		*modp;
-    int		keycode; /* prefer key code, e.g. K_DEL instead of DEL */
+    int		keycode;     /* prefer key code, e.g. K_DEL instead of DEL */
+    int		keep_x_key;  /* don't translate xHome to Home key */
 {
     char_u	*last_dash;
     char_u	*end_of_name;
     char_u	*src;
     char_u	*bp;
@@ -2670,11 +2689,12 @@ find_special_key(srcp, modp, keycode)
 	    if (modifiers != 0 && last_dash[2] == '>')
 		key = last_dash[1];
 	    else
 	    {
 		key = get_special_key_code(last_dash + 1);
-		key = handle_x_keys(key);
+		if (!keep_x_key)
+		    key = handle_x_keys(key);
 	    }
 
 	    /*
 	     * get_special_key_code() may return NUL for invalid
 	     * special key name.
@@ -2827,11 +2847,11 @@ get_special_key_code(name)
 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
     char_u *
 get_key_name(i)
     int	    i;
 {
-    if (i >= KEY_NAMES_TABLE_LEN)
+    if (i >= (int)KEY_NAMES_TABLE_LEN)
 	return NULL;
     return  key_names_table[i].name;
 }
 #endif
 
@@ -3855,11 +3875,12 @@ typedef struct ff_visited
 #endif
     /* for unix use inode etc for comparison (needed because of links), else
      * use filename.
      */
 #ifdef UNIX
-    int			ffv_dev;	/* device number (-1 if not set) */
+    int			ffv_dev_valid;	/* ffv_dev and ffv_ino were set */
+    dev_t		ffv_dev;	/* device number */
     ino_t		ffv_ino;	/* inode number */
 #endif
     /* The memory for this struct is allocated according to the length of
      * ffv_fname.
      */
@@ -4045,17 +4066,16 @@ vim_findnext()
  * must be NULL.
  *
  * This function silently ignores a few errors, vim_findfile() will have
  * limited functionality then.
  */
-/*ARGSUSED*/
     void *
 vim_findfile_init(path, filename, stopdirs, level, free_visited, find_what,
 					   search_ctx_arg, tagfile, rel_fname)
     char_u	*path;
     char_u	*filename;
-    char_u	*stopdirs;
+    char_u	*stopdirs UNUSED;
     int		level;
     int		free_visited;
     int		find_what;
     void	*search_ctx_arg;
     int		tagfile;
@@ -4246,11 +4266,11 @@ vim_findfile_init(path, filename, stopdi
 	 * The octet after a '**' is used as a (binary) counter.
 	 * So '**3' is transposed to '**^C' ('^C' is ASCII value 3)
 	 * or '**76' is transposed to '**N'( 'N' is ASCII value 76).
 	 * For EBCDIC you get different character values.
 	 * If no restrict is given after '**' the default is used.
-	 * Due to this technic the path looks awful if you print it as a
+	 * Due to this technique the path looks awful if you print it as a
 	 * string.
 	 */
 	len = 0;
 	while (*wc_part != NUL)
 	{
@@ -4635,11 +4655,11 @@ vim_findfile(search_ctx_arg)
 		    {
 			if (!path_with_url(stackp->ffs_filearray[i])
 				      && !mch_isdir(stackp->ffs_filearray[i]))
 			    continue;   /* not a directory */
 
-			/* prepare the filename to be checked for existance
+			/* prepare the filename to be checked for existence
 			 * below */
 			STRCPY(file_path, stackp->ffs_filearray[i]);
 			add_pathsep(file_path);
 			STRCAT(file_path, search_ctx->ffsc_file_to_search);
 
@@ -4696,11 +4716,12 @@ vim_findfile(search_ctx_arg)
 
 				/* push dir to examine rest of subdirs later */
 				stackp->ffs_filearray_cur = i + 1;
 				ff_push(search_ctx, stackp);
 
-				simplify_filename(file_path);
+				if (!path_with_url(file_path))
+				    simplify_filename(file_path);
 				if (mch_dirname(ff_expand_buffer, MAXPATHL)
 									== OK)
 				{
 				    p = shorten_fname(file_path,
 							    ff_expand_buffer);
@@ -5048,14 +5069,13 @@ ff_check_visited(visited_list, fname
     /* check against list of already visited files */
     for (vp = *visited_list; vp != NULL; vp = vp->ffv_next)
     {
 	if (
 #ifdef UNIX
-		!url
-		    ? (vp->ffv_dev == st.st_dev
-			&& vp->ffv_ino == st.st_ino)
-		    :
+		!url ? (vp->ffv_dev_valid && vp->ffv_dev == st.st_dev
+						  && vp->ffv_ino == st.st_ino)
+		     :
 #endif
 		fnamecmp(vp->ffv_fname, ff_expand_buffer) == 0
 	   )
 	{
 #ifdef FEAT_PATH_EXTRA
@@ -5076,18 +5096,18 @@ ff_check_visited(visited_list, fname
     if (vp != NULL)
     {
 #ifdef UNIX
 	if (!url)
 	{
+	    vp->ffv_dev_valid = TRUE;
 	    vp->ffv_ino = st.st_ino;
 	    vp->ffv_dev = st.st_dev;
 	    vp->ffv_fname[0] = NUL;
 	}
 	else
 	{
-	    vp->ffv_ino = 0;
-	    vp->ffv_dev = -1;
+	    vp->ffv_dev_valid = FALSE;
 #endif
 	    STRCPY(vp->ffv_fname, ff_expand_buffer);
 #ifdef UNIX
 	}
 #endif
@@ -5424,11 +5444,11 @@ find_file_in_path_option(ptr, len, optio
 	    /* "..", "../path", "." and "./path": don't use the path_option */
 	    || rel_to_curdir
 #if defined(MSWIN) || defined(MSDOS) || defined(OS2)
 	    /* handle "\tmp" as absolute path */
 	    || vim_ispathsep(ff_file_to_find[0])
-	    /* handle "c:name" as absulute path */
+	    /* handle "c:name" as absolute path */
 	    || (ff_file_to_find[0] != NUL && ff_file_to_find[1] == ':')
 #endif
 #ifdef AMIGA
 	    /* handle ":tmp" as absolute path */
 	    || ff_file_to_find[0] == ':'
@@ -5667,11 +5687,11 @@ qsort(base, elm_count, elm_size, cmp)
 		/* Compare the elements. */
 		p1 = (char_u *)base + j * elm_size;
 		p2 = (char_u *)base + (j + gap) * elm_size;
 		if ((*cmp)((void *)p1, (void *)p2) <= 0)
 		    break;
-		/* Exchange the elemets. */
+		/* Exchange the elements. */
 		mch_memmove(buf, p1, elm_size);
 		mch_memmove(p1, p2, elm_size);
 		mch_memmove(p2, buf, elm_size);
 	    }
 
--- vim72.orig/src/move.c
+++ vim72/src/move.c
@@ -181,13 +181,10 @@ update_topline()
     if (bufempty())		/* special case - file is empty */
     {
 	if (curwin->w_topline != 1)
 	    redraw_later(NOT_VALID);
 	curwin->w_topline = 1;
-#ifdef FEAT_DIFF
-	curwin->w_topfill = 0;
-#endif
 	curwin->w_botline = 2;
 	curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
 #ifdef FEAT_SCROLLBIND
 	curwin->w_scbind_pos = 1;
 #endif
@@ -278,22 +275,24 @@ update_topline()
 	if (!(curwin->w_valid & VALID_BOTLINE_AP))
 	    validate_botline();
 
 	if (curwin->w_botline <= curbuf->b_ml.ml_line_count)
 	{
-	    if (curwin->w_cursor.lnum < curwin->w_botline
-		    && ((long)curwin->w_cursor.lnum
+	    if (curwin->w_cursor.lnum < curwin->w_botline)
+	    {
+	      if (((long)curwin->w_cursor.lnum
 					     >= (long)curwin->w_botline - p_so
 #ifdef FEAT_FOLDING
 			|| hasAnyFolding(curwin)
 #endif
 			))
-	    {
+	      {
 		lineoff_T	loff;
 
-		/* Cursor is above botline, check if there are 'scrolloff'
-		 * window lines below the cursor.  If not, need to scroll. */
+		/* Cursor is (a few lines) above botline, check if there are
+		 * 'scrolloff' window lines below the cursor.  If not, need to
+		 * scroll. */
 		n = curwin->w_empty_rows;
 		loff.lnum = curwin->w_cursor.lnum;
 #ifdef FEAT_FOLDING
 		/* In a fold go to its last line. */
 		(void)hasFolding(loff.lnum, NULL, &loff.lnum);
@@ -315,10 +314,14 @@ update_topline()
 		    botline_forw(&loff);
 		}
 		if (n >= p_so)
 		    /* sufficient context, no need to scroll */
 		    check_botline = FALSE;
+	      }
+	      else
+		  /* sufficient context, no need to scroll */
+		  check_botline = FALSE;
 	    }
 	    if (check_botline)
 	    {
 #ifdef FEAT_FOLDING
 		if (hasAnyFolding(curwin))
@@ -507,10 +510,13 @@ set_topline(wp, lnum)
     (void)hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL);
 #endif
     /* Approximate the value of w_botline */
     wp->w_botline += lnum - wp->w_topline;
     wp->w_topline = lnum;
+#ifdef FEAT_AUTOCMD
+    wp->w_topline_was_set = TRUE;
+#endif
 #ifdef FEAT_DIFF
     wp->w_topfill = 0;
 #endif
     wp->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_TOPLINE);
     /* Don't set VALID_TOPLINE here, 'scrolloff' needs to be checked. */
@@ -881,26 +887,26 @@ validate_cheight()
     void
 validate_cursor_col()
 {
     colnr_T off;
     colnr_T col;
+    int     width;
 
     validate_virtcol();
     if (!(curwin->w_valid & VALID_WCOL))
     {
 	col = curwin->w_virtcol;
 	off = curwin_col_off();
 	col += off;
+	width = W_WIDTH(curwin) - off + curwin_col_off2();
 
 	/* long line wrapping, adjust curwin->w_wrow */
 	if (curwin->w_p_wrap
 		&& col >= (colnr_T)W_WIDTH(curwin)
-		&& W_WIDTH(curwin) - off + curwin_col_off2() > 0)
-	{
-	    col -= W_WIDTH(curwin);
-	    col = col % (W_WIDTH(curwin) - off + curwin_col_off2());
-	}
+		&& width > 0)
+	    /* use same formula as what is used in curs_columns() */
+	    col -= ((col - W_WIDTH(curwin)) / width + 1) * width;
 	if (col > (int)curwin->w_leftcol)
 	    col -= curwin->w_leftcol;
 	else
 	    col = 0;
 	curwin->w_wcol = col;
@@ -1033,10 +1039,11 @@ curs_columns(scroll)
 	width = textwidth + curwin_col_off2();
 
 	/* long line wrapping, adjust curwin->w_wrow */
 	if (curwin->w_wcol >= W_WIDTH(curwin))
 	{
+	    /* this same formula is used in validate_cursor_col() */
 	    n = (curwin->w_wcol - W_WIDTH(curwin)) / width + 1;
 	    curwin->w_wcol -= n * width;
 	    curwin->w_wrow += n;
 
 #ifdef FEAT_LINEBREAK
@@ -1227,15 +1234,14 @@ curs_columns(scroll)
 }
 
 /*
  * Scroll the current window down by "line_count" logical lines.  "CTRL-Y"
  */
-/*ARGSUSED*/
     void
 scrolldown(line_count, byfold)
     long	line_count;
-    int		byfold;		/* TRUE: count a closed fold as one line */
+    int		byfold UNUSED;	/* TRUE: count a closed fold as one line */
 {
     long	done = 0;	/* total # of physical lines done */
     int		wrow;
     int		moved = FALSE;
 
@@ -1247,11 +1253,12 @@ scrolldown(line_count, byfold)
 #endif
     validate_cursor();		/* w_wrow needs to be valid */
     while (line_count-- > 0)
     {
 #ifdef FEAT_DIFF
-	if (curwin->w_topfill < diff_check(curwin, curwin->w_topline))
+	if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)
+		&& curwin->w_topfill < curwin->w_height - 1)
 	{
 	    ++curwin->w_topfill;
 	    ++done;
 	}
 	else
@@ -1338,15 +1345,14 @@ scrolldown(line_count, byfold)
 }
 
 /*
  * Scroll the current window up by "line_count" logical lines.  "CTRL-E"
  */
-/*ARGSUSED*/
     void
 scrollup(line_count, byfold)
     long	line_count;
-    int		byfold;		/* TRUE: count a closed fold as one line */
+    int		byfold UNUSED;	/* TRUE: count a closed fold as one line */
 {
 #if defined(FEAT_FOLDING) || defined(FEAT_DIFF)
     linenr_T	lnum;
 
     if (
@@ -1602,11 +1608,11 @@ scrollup_clamp()
 
 /*
  * Add one line above "lp->lnum".  This can be a filler line, a closed fold or
  * a (wrapped) text line.  Uses and sets "lp->fill".
  * Returns the height of the added line in "lp->height".
- * Lines above the first one are incredibly high.
+ * Lines above the first one are incredibly high: MAXCOL.
  */
     static void
 topline_back(lp)
     lineoff_T	*lp;
 {
@@ -1934,11 +1940,11 @@ scroll_cursor_bot(min_scroll, set_topbot
 		curwin->w_topline > 1;
 		curwin->w_topline = loff.lnum)
 	{
 	    loff.lnum = curwin->w_topline;
 	    topline_back(&loff);
-	    if (used + loff.height > curwin->w_height)
+	    if (loff.height == MAXCOL || used + loff.height > curwin->w_height)
 		break;
 	    used += loff.height;
 #ifdef FEAT_DIFF
 	    curwin->w_topfill = loff.fill;
 #endif
@@ -2013,11 +2019,14 @@ scroll_cursor_bot(min_scroll, set_topbot
 		)
 	    break;
 
 	/* Add one line above */
 	topline_back(&loff);
-	used += loff.height;
+	if (loff.height == MAXCOL)
+	    used = MAXCOL;
+	else
+	    used += loff.height;
 	if (used > curwin->w_height)
 	    break;
 	if (loff.lnum >= curwin->w_botline
 #ifdef FEAT_DIFF
 		&& (loff.lnum > curwin->w_botline
@@ -2167,11 +2176,14 @@ scroll_cursor_halfway(atend)
 	}
 
 	if (below > above)	    /* add a line above the cursor */
 	{
 	    topline_back(&loff);
-	    used += loff.height;
+	    if (loff.height == MAXCOL)
+		used = MAXCOL;
+	    else
+		used += loff.height;
 	    if (used > curwin->w_height)
 		break;
 	    above += loff.height;
 	    topline = loff.lnum;
 #ifdef FEAT_DIFF
@@ -2464,13 +2476,16 @@ onepage(dir, count)
 	     * at the bottom of the window. */
 	    n = 0;
 	    while (n <= curwin->w_height && loff.lnum >= 1)
 	    {
 		topline_back(&loff);
-		n += loff.height;
+		if (loff.height == MAXCOL)
+		    n = MAXCOL;
+		else
+		    n += loff.height;
 	    }
-	    if (n <= curwin->w_height)		    /* at begin of file */
+	    if (loff.lnum < 1)			/* at begin of file */
 	    {
 		curwin->w_topline = 1;
 #ifdef FEAT_DIFF
 		max_topfill();
 #endif
--- vim72.orig/src/msvc2008.bat
+++ vim72/src/msvc2008.bat
@@ -1,5 +1,7 @@
+@echo off
 rem To be used on MS-Windows for Visual C++ 2008 Express Edition
 rem   aka Microsoft Visual Studio 9.0.
 rem See INSTALLpc.txt for information.
+@echo on
 
 call "%VS90COMNTOOLS%%vsvars32.bat"
--- vim72.orig/src/nbdebug.c
+++ vim72/src/nbdebug.c
@@ -31,11 +31,10 @@
 
 FILE		*nb_debug = NULL;
 u_int		 nb_dlevel = 0;		/* nb_debug verbosity level */
 
 void		 nbdb(char *, ...);
-void		 nbtrace(char *, ...);
 
 static int	 lookup(char *);
 #ifdef USE_NB_ERRORHANDLER
 static int	 errorHandler(Display *, XErrorEvent *);
 #endif
@@ -98,29 +97,10 @@ nbdebug_log_init(
 	}
 
 }    /* end nbdebug_log_init */
 
 
-
-
-void
-nbtrace(
-	char		*fmt,
-	...)
-{
-	va_list		 ap;
-
-	if (nb_debug!= NULL && (nb_dlevel & (NB_TRACE | NB_TRACE_VERBOSE))) {
-		va_start(ap, fmt);
-		vfprintf(nb_debug, fmt, ap);
-		va_end(ap);
-		fflush(nb_debug);
-	}
-
-}    /* end nbtrace */
-
-
 void
 nbdbg(
 	char		*fmt,
 	...)
 {
@@ -134,27 +114,10 @@ nbdbg(
 	}
 
 }    /* end nbdbg */
 
 
-void
-nbprt(
-	char		*fmt,
-	...)
-{
-	va_list		 ap;
-
-	if (nb_debug != NULL && nb_dlevel & NB_PRINT) {
-		va_start(ap, fmt);
-		vfprintf(nb_debug, fmt, ap);
-		va_end(ap);
-		fflush(nb_debug);
-	}
-
-}    /* end nbprt */
-
-
 static int
 lookup(
 	char		*file)
 {
 	char		 buf[BUFSIZ];
--- vim72.orig/src/nbdebug.h
+++ vim72/src/nbdebug.h
@@ -41,12 +41,10 @@ typedef enum {
 		WT_STOP			/* look for ~/.gvimstop if set */
 } WtWait;
 
 
 void		 nbdbg(char *, ...);
-void		 nbprt(char *, ...);
-void		 nbtrace(char *, ...);
 
 void nbdebug_wait __ARGS((u_int wait_flags, char *wait_var, u_int wait_secs));
 void nbdebug_log_init __ARGS((char *log_var, char *level_var));
 
 extern FILE	*nb_debug;
@@ -68,21 +66,7 @@ nbdbg(
 	char		*fmt,
 	...)
 {
 }
 
-void
-nbprt(
-	char		*fmt,
-	...)
-{
-}
-
-void
-nbtrace(
-	char		*fmt,
-	...)
-{
-}
-
 #endif /* NBDEBUG */
 #endif /* NBDEBUG_H */
--- vim72.orig/src/netbeans.c
+++ vim72/src/netbeans.c
@@ -30,10 +30,11 @@
 #  include <tchar.h>	/* for _T definition for TRACEn macros */
 # endif
 /* WinSock API is separated from C API, thus we can't use read(), write(),
  * errno... */
 # define sock_errno WSAGetLastError()
+# undef ECONNREFUSED
 # define ECONNREFUSED WSAECONNREFUSED
 # ifdef EINTR
 #  undef EINTR
 # endif
 # define EINTR WSAEINTR
@@ -67,11 +68,12 @@ static char *ExtEdProtocolVersion = "2.4
 
 static long pos2off __ARGS((buf_T *, pos_T *));
 static pos_T *off2pos __ARGS((buf_T *, long));
 static pos_T *get_off_or_lnum __ARGS((buf_T *buf, char_u **argp));
 static long get_buf_size __ARGS((buf_T *));
-static void netbeans_keystring __ARGS((int key, char *keystr));
+static int netbeans_keystring __ARGS((char_u *keystr));
+static void postpone_keycommand __ARGS((char_u *keystr));
 static void special_keys __ARGS((char_u *args));
 
 static void netbeans_connect __ARGS((void));
 static int getConnInfo __ARGS((char *file, char **host, char **port, char **password));
 
@@ -499,11 +501,11 @@ getConnInfo(char *file, char **host, cha
 }
 
 
 struct keyqueue
 {
-    int		     key;
+    char_u	    *keystr;
     struct keyqueue *next;
     struct keyqueue *prev;
 };
 
 typedef struct keyqueue keyQ_T;
@@ -511,17 +513,21 @@ typedef struct keyqueue keyQ_T;
 static keyQ_T keyHead; /* dummy node, header for circular queue */
 
 
 /*
  * Queue up key commands sent from netbeans.
+ * We store the string, because it may depend on the global mod_mask and
+ * :nbkey doesn't have a key number.
  */
     static void
-postpone_keycommand(int key)
+postpone_keycommand(char_u *keystr)
 {
     keyQ_T *node;
 
     node = (keyQ_T *)alloc(sizeof(keyQ_T));
+    if (node == NULL)
+	return;  /* out of memory, drop the key */
 
     if (keyHead.next == NULL) /* initialize circular queue */
     {
 	keyHead.next = &keyHead;
 	keyHead.prev = &keyHead;
@@ -531,28 +537,33 @@ postpone_keycommand(int key)
     node->next = &keyHead;
     node->prev = keyHead.prev;
     keyHead.prev->next = node;
     keyHead.prev = node;
 
-    node->key = key;
+    node->keystr = vim_strsave(keystr);
 }
 
 /*
  * Handle any queued-up NetBeans keycommands to be send.
  */
     static void
 handle_key_queue(void)
 {
-    while (keyHead.next && keyHead.next != &keyHead)
+    int postponed = FALSE;
+
+    while (!postponed && keyHead.next && keyHead.next != &keyHead)
     {
 	/* first, unlink the node */
 	keyQ_T *node = keyHead.next;
 	keyHead.next = node->next;
 	node->next->prev = node->prev;
 
-	/* now, send the keycommand */
-	netbeans_keycommand(node->key);
+	/* Now, send the keycommand.  This may cause it to be postponed again
+	 * and change keyHead. */
+	if (node->keystr != NULL)
+	    postponed = !netbeans_keystring(node->keystr);
+	vim_free(node->keystr);
 
 	/* Finally, dispose of the node */
 	vim_free(node);
     }
 }
@@ -698,33 +709,43 @@ netbeans_parse_messages(void)
 #define MAXMSGSIZE 4096
 
 /*
  * Read and process a command from netbeans.
  */
-/*ARGSUSED*/
 #if defined(FEAT_GUI_W32) || defined(PROTO)
 /* Use this one when generating prototypes, the others are static. */
     void
 messageFromNetbeansW32()
 #else
 # ifdef FEAT_GUI_MOTIF
     static void
-messageFromNetbeans(XtPointer clientData, int *unused1, XtInputId *unused2)
+messageFromNetbeans(XtPointer clientData UNUSED,
+		    int *unused1 UNUSED,
+		    XtInputId *unused2 UNUSED)
 # endif
 # ifdef FEAT_GUI_GTK
     static void
-messageFromNetbeans(gpointer clientData, gint unused1,
-						    GdkInputCondition unused2)
+messageFromNetbeans(gpointer clientData UNUSED,
+		    gint unused1 UNUSED,
+		    GdkInputCondition unused2 UNUSED)
 # endif
 #endif
 {
     static char_u	*buf = NULL;
     int			len;
     int			readlen = 0;
 #ifndef FEAT_GUI_GTK
     static int		level = 0;
 #endif
+#ifdef HAVE_SELECT
+    struct timeval	tval;
+    fd_set		rfds;
+#else
+# ifdef HAVE_POLL
+    struct pollfd	fds;
+# endif
+#endif
 
     if (sd < 0)
     {
 	nbdebug(("messageFromNetbeans() called without a socket\n"));
 	return;
@@ -740,13 +761,30 @@ messageFromNetbeans(gpointer clientData,
 	buf = alloc(MAXMSGSIZE);
 	if (buf == NULL)
 	    return;	/* out of memory! */
     }
 
-    /* Keep on reading for as long as there is something to read. */
+    /* Keep on reading for as long as there is something to read.
+     * Use select() or poll() to avoid blocking on a message that is exactly
+     * MAXMSGSIZE long. */
     for (;;)
     {
+#ifdef HAVE_SELECT
+	FD_ZERO(&rfds);
+        FD_SET(sd, &rfds);
+        tval.tv_sec = 0;
+        tval.tv_usec = 0;
+        if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0)
+            break;
+#else
+# ifdef HAVE_POLL
+	fds.fd = sd;
+	fds.events = POLLIN;
+        if (poll(&fds, 1, 0) <= 0)
+            break;
+# endif
+#endif
 	len = sock_read(sd, buf, MAXMSGSIZE);
 	if (len <= 0)
 	    break;	/* error or nothing more to read */
 
 	/* Store the read message in the queue. */
@@ -767,15 +805,18 @@ messageFromNetbeans(gpointer clientData,
 	    PERROR(_("read from Netbeans socket"));
 	}
 	return; /* don't try to parse it */
     }
 
-#ifdef FEAT_GUI_GTK
+#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32)
+    /* Let the main loop handle messages. */
+# ifdef FEAT_GUI_GTK
     if (gtk_main_level() > 0)
 	gtk_main_quit();
+# endif
 #else
-    /* Parse the messages, but avoid recursion. */
+    /* Parse the messages now, but avoid recursion. */
     if (level == 1)
 	netbeans_parse_messages();
 
     --level;
 #endif
@@ -865,11 +906,11 @@ nb_parse_cmd(char_u *cmd)
 
     if (nb_do_cmd(bufno, (char_u *)verb, isfunc, r_cmdno, (char_u *)q) == FAIL)
     {
 #ifdef NBDEBUG
 	/*
-	 * This happens because the ExtEd can send a cammand or 2 after
+	 * This happens because the ExtEd can send a command or 2 after
 	 * doing a stopDocumentListen command. It doesn't harm anything
 	 * so I'm disabling it except for debugging.
 	 */
 	nbdebug(("nb_parse_cmd: Command error for \"%s\"\n", cmd));
 	EMSG("E629: bad return from nb_do_cmd");
@@ -1041,11 +1082,11 @@ netbeans_end(void)
 	}
 	sprintf(buf, "%d:killed=%d\n", i, r_cmdno);
 	nbdebug(("EVT: %s", buf));
 /*	nb_send(buf, "netbeans_end");    avoid "write failed" messages */
 	if (sd >= 0)
-	    sock_write(sd, buf, (int)STRLEN(buf));  /* ignore errors */
+	    ignored = sock_write(sd, buf, (int)STRLEN(buf));
     }
 }
 
 /*
  * Send a message to netbeans.
@@ -1166,11 +1207,11 @@ nb_quote(char_u *txt)
 	    default:
 		*q++ = *p;
 		break;
 	}
     }
-    *q++ = '\0';
+    *q = '\0';
 
     return buf;
 }
 
 
@@ -1491,33 +1532,36 @@ nb_do_cmd(
 		    netbeansFireChanges = oldFire;
 		    netbeansSuppressNoLines = oldSuppress;
 		    return FAIL;
 		}
 		first = *pos;
-		nbdebug(("    FIRST POS: line %d, col %d\n", first.lnum, first.col));
+		nbdebug(("    FIRST POS: line %d, col %d\n",
+						      first.lnum, first.col));
 		pos = off2pos(buf->bufp, off+count-1);
 		if (!pos)
 		{
 		    nbdebug(("    !bad count\n"));
 		    nb_reply_text(cmdno, (char_u *)"!bad count");
 		    netbeansFireChanges = oldFire;
 		    netbeansSuppressNoLines = oldSuppress;
 		    return FAIL;
 		}
 		last = *pos;
-		nbdebug(("    LAST POS: line %d, col %d\n", last.lnum, last.col));
+		nbdebug(("    LAST POS: line %d, col %d\n",
+							last.lnum, last.col));
 		del_from_lnum = first.lnum;
 		del_to_lnum = last.lnum;
 		doupdate = 1;
 
 		/* Get the position of the first byte after the deleted
 		 * section.  "next" is NULL when deleting to the end of the
 		 * file. */
 		next = off2pos(buf->bufp, off + count);
 
 		/* Remove part of the first line. */
-		if (first.col != 0 || (next != NULL && first.lnum == next->lnum))
+		if (first.col != 0
+				|| (next != NULL && first.lnum == next->lnum))
 		{
 		    if (first.lnum != last.lnum
 			    || (next != NULL && first.lnum != next->lnum))
 		    {
 			/* remove to the end of the first line */
@@ -1576,18 +1620,22 @@ nb_do_cmd(
 		    for (i = del_from_lnum; i <= del_to_lnum; i++)
 		    {
 			int id = buf_findsign_id(buf->bufp, (linenr_T)i);
 			if (id > 0)
 			{
-			    nbdebug(("    Deleting sign %d on line %d\n", id, i));
+			    nbdebug(("    Deleting sign %d on line %d\n",
+								      id, i));
 			    buf_delsign(buf->bufp, id);
 			}
 			else
+			{
 			    nbdebug(("    No sign on line %d\n", i));
+			}
 		    }
 
-		    nbdebug(("    Deleting lines %d through %d\n", del_from_lnum, del_to_lnum));
+		    nbdebug(("    Deleting lines %d through %d\n",
+						 del_from_lnum, del_to_lnum));
 		    curwin->w_cursor.lnum = del_from_lnum;
 		    curwin->w_cursor.col = 0;
 		    del_lines(del_to_lnum - del_from_lnum + 1, FALSE);
 		}
 
@@ -1793,11 +1841,11 @@ nb_do_cmd(
 	    }
 	    vim_free(buf->displayname);
 	    buf->displayname = NULL;
 
 	    netbeansReadFile = 0; /* don't try to open disk file */
-	    do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF);
+	    do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF, curwin);
 	    netbeansReadFile = 1;
 	    buf->bufp = curbuf;
 	    maketitle();
 	    buf->insertDone = FALSE;
 	    gui_update_menus(0);
@@ -1919,11 +1967,11 @@ nb_do_cmd(
 		return FAIL;
 	    bufp = buflist_findname(path);
 	    vim_free(path);
 	    if (bufp == NULL)
 	    {
-	    	nbdebug(("    File %s not found in setBufferNumber\n", args));
+		nbdebug(("    File %s not found in setBufferNumber\n", args));
 		EMSG2("E642: File %s not found in setBufferNumber", args);
 		return FAIL;
 	    }
 	    buf->bufp = bufp;
 	    buf->nbbuf_number = bufp->b_fnum;
@@ -1958,11 +2006,11 @@ nb_do_cmd(
 	    vim_free(buf->displayname);
 	    buf->displayname = nb_unquote(args, NULL);
 
 	    netbeansReadFile = 0; /* don't try to open disk file */
 	    do_ecmd(0, (char_u *)buf->displayname, 0, 0, ECMD_ONE,
-						     ECMD_HIDE + ECMD_OLDBUF);
+					     ECMD_HIDE + ECMD_OLDBUF, curwin);
 	    netbeansReadFile = 1;
 	    buf->bufp = curbuf;
 	    maketitle();
 	    gui_update_menus(0);
 /* =====================================================================*/
@@ -1977,11 +2025,11 @@ nb_do_cmd(
 	    }
 	    /* Edit a file: like create + setFullName + read the file. */
 	    vim_free(buf->displayname);
 	    buf->displayname = nb_unquote(args, NULL);
 	    do_ecmd(0, (char_u *)buf->displayname, NULL, NULL, ECMD_ONE,
-						     ECMD_HIDE + ECMD_OLDBUF);
+					     ECMD_HIDE + ECMD_OLDBUF, curwin);
 	    buf->bufp = curbuf;
 	    buf->initDone = TRUE;
 	    doupdate = 1;
 #if defined(FEAT_TITLE)
 	    maketitle();
@@ -2139,11 +2187,13 @@ nb_do_cmd(
 #ifdef FEAT_FOLDING
 		foldOpenCursor();
 #endif
 	    }
 	    else
+	    {
 		nbdebug(("    BAD POSITION in setDot: %s\n", s));
+	    }
 
 	    /* gui_update_cursor(TRUE, FALSE); */
 	    /* update_curbuf(NOT_VALID); */
 	    update_topline();		/* scroll to show the line */
 	    update_screen(VALID);
@@ -2275,13 +2325,10 @@ nb_do_cmd(
 	{
 #ifdef FEAT_SIGNS
 	    int serNum;
 	    int localTypeNum;
 	    int typeNum;
-# ifdef NBDEBUG
-	    int len;
-# endif
 	    pos_T *pos;
 
 	    if (buf == NULL || buf->bufp == NULL)
 	    {
 		nbdebug(("    invalid buffer identifier in addAnno\n"));
@@ -2301,17 +2348,14 @@ nb_do_cmd(
 	    typeNum = mapsigntype(buf, localTypeNum);
 
 	    pos = get_off_or_lnum(buf->bufp, &args);
 
 	    cp = (char *)args;
-# ifdef NBDEBUG
-	    len =
-# endif
-		strtol(cp, &cp, 10);
+	    ignored = (int)strtol(cp, &cp, 10);
 	    args = (char_u *)cp;
 # ifdef NBDEBUG
-	    if (len != -1)
+	    if (ignored != -1)
 	    {
 		nbdebug(("    partial line annotation -- Not Yet Implemented!\n"));
 	    }
 # endif
 	    if (serNum >= GUARDEDOFFSET)
@@ -2319,11 +2363,11 @@ nb_do_cmd(
 		nbdebug(("    too many annotations! ignoring...\n"));
 		return FAIL;
 	    }
 	    if (pos)
 	    {
-		coloncmd(":sign place %d line=%d name=%d buffer=%d",
+		coloncmd(":sign place %d line=%ld name=%d buffer=%d",
 			   serNum, pos->lnum, typeNum, buf->bufp->b_fnum);
 		if (typeNum == curPCtype)
 		    coloncmd(":sign jump %d buffer=%d", serNum,
 						       buf->bufp->b_fnum);
 	    }
@@ -2423,11 +2467,11 @@ nb_do_cmd(
 			{
 			    if (buf_findsigntype_id(buf->bufp, lnum,
 				GUARDED) == 0)
 			    {
 				coloncmd(
-				    ":sign place %d line=%d name=%d buffer=%d",
+				    ":sign place %d line=%ld name=%d buffer=%d",
 				     guardId++, lnum, GUARDED,
 				     buf->bufp->b_fnum);
 			    }
 			}
 		    }
@@ -2484,11 +2528,11 @@ nb_do_cmd(
 #endif
 		}
 	    }
 	    else
 	    {
-	        nbdebug(("    Buffer has no changes!\n"));
+		nbdebug(("    Buffer has no changes!\n"));
 	    }
 /* =====================================================================*/
 	}
 	else if (streq((char *)cmd, "netbeansBuffer"))
 	{
@@ -2580,11 +2624,11 @@ coloncmd(char *cmd, ...)
 {
     char buf[1024];
     va_list ap;
 
     va_start(ap, cmd);
-    vsprintf(buf, cmd, ap);
+    vim_vsnprintf(buf, sizeof(buf), cmd, ap, NULL);
     va_end(ap);
 
     nbdebug(("    COLONCMD %s\n", buf));
 
 /*     ALT_INPUT_LOCK_ON; */
@@ -2647,11 +2691,11 @@ special_keys(char_u *args)
 
     void
 ex_nbkey(eap)
     exarg_T	*eap;
 {
-    netbeans_keystring(0, (char *)eap->arg);
+    (void)netbeans_keystring(eap->arg);
 }
 
 
 /*
  * Initialize highlights and signs for use by netbeans  (mostly obsolete)
@@ -2669,11 +2713,11 @@ nb_init_graphics(void)
 	did_init = TRUE;
     }
 }
 
 /*
- * Convert key to netbeans name.
+ * Convert key to netbeans name.  This uses the global "mod_mask".
  */
     static void
 netbeans_keyname(int key, char *buf)
 {
     char *name = 0;
@@ -2745,15 +2789,14 @@ netbeans_keyname(int key, char *buf)
 /*
  * Function to be called for balloon evaluation.  Grabs the text under the
  * cursor and sends it to the debugger for evaluation.  The debugger should
  * respond with a showBalloon command when there is a useful result.
  */
-/*ARGSUSED*/
     void
 netbeans_beval_cb(
 	BalloonEval	*beval,
-	int		 state)
+	int		 state UNUSED)
 {
     win_T	*wp;
     char_u	*text;
     linenr_T	lnum;
     int		col;
@@ -2922,48 +2965,30 @@ netbeans_file_opened(buf_T *bufp)
     if (p_acd && vim_chdirfile(bufp->b_ffname) == OK)
 	shorten_fnames(TRUE);
 }
 
 /*
- * Tell netbeans a file was closed.
+ * Tell netbeans that a file was deleted or wiped out.
  */
     void
-netbeans_file_closed(buf_T *bufp)
+netbeans_file_killed(buf_T *bufp)
 {
     int		bufno = nb_getbufno(bufp);
     nbbuf_T	*nbbuf = nb_get_buf(bufno);
     char	buffer[2*MAXPATHL];
 
-    if (!haveConnection || bufno < 0)
+    if (!haveConnection || bufno == -1)
 	return;
 
-    if (!netbeansCloseFile)
-    {
-	nbdebug(("Ignoring file_closed for %s. File was closed from IDE\n",
-		    bufp->b_ffname));
-	return;
-    }
-
-    nbdebug(("netbeans_file_closed:\n"));
-    nbdebug(("    Closing bufno: %d", bufno));
-    if (curbuf != NULL && curbuf != bufp)
-    {
-	nbdebug(("    Curbuf bufno:  %d\n", nb_getbufno(curbuf)));
-    }
-    else if (curbuf == bufp)
-    {
-	nbdebug(("    curbuf == bufp\n"));
-    }
-
-    if (bufno <= 0)
-	return;
+    nbdebug(("netbeans_file_killed:\n"));
+    nbdebug(("    Killing bufno: %d", bufno));
 
     sprintf(buffer, "%d:killed=%d\n", bufno, r_cmdno);
 
     nbdebug(("EVT: %s", buffer));
 
-    nb_send(buffer, "netbeans_file_closed");
+    nb_send(buffer, "netbeans_file_killed");
 
     if (nbbuf != NULL)
 	nbbuf->bufp = NULL;
 }
 
@@ -3078,15 +3103,14 @@ netbeans_removed(
     nbdebug(("EVT: %s", buf));
     nb_send((char *)buf, "netbeans_removed");
 }
 
 /*
- * Send netbeans an unmodufied command.
+ * Send netbeans an unmodified command.
  */
-/*ARGSUSED*/
     void
-netbeans_unmodified(buf_T *bufp)
+netbeans_unmodified(buf_T *bufp UNUSED)
 {
 #if 0
     char_u	buf[128];
     int		bufno;
     nbbuf_T	*nbbuf;
@@ -3136,56 +3160,59 @@ netbeans_button_release(int button)
 
 
 /*
  * Send a keypress event back to netbeans. This usually simulates some
  * kind of function key press. This function operates on a key code.
+ * Return TRUE when the key was sent, FALSE when the command has been
+ * postponed.
  */
-    void
+    int
 netbeans_keycommand(int key)
 {
     char	keyName[60];
 
     netbeans_keyname(key, keyName);
-    netbeans_keystring(key, keyName);
+    return netbeans_keystring((char_u *)keyName);
 }
 
 
 /*
  * Send a keypress event back to netbeans. This usually simulates some
  * kind of function key press. This function operates on a key string.
+ * Return TRUE when the key was sent, FALSE when the command has been
+ * postponed.
  */
-    static void
-netbeans_keystring(int key, char *keyName)
+    static int
+netbeans_keystring(char_u *keyName)
 {
     char	buf[2*MAXPATHL];
     int		bufno = nb_getbufno(curbuf);
     long	off;
     char_u	*q;
 
     if (!haveConnection)
-	return;
+	return TRUE;
 
 
     if (bufno == -1)
     {
 	nbdebug(("got keycommand for non-NetBeans buffer, opening...\n"));
 	q = curbuf->b_ffname == NULL ? (char_u *)""
 						 : nb_quote(curbuf->b_ffname);
 	if (q == NULL)
-	    return;
+	    return TRUE;
 	vim_snprintf(buf, sizeof(buf), "0:fileOpened=%d \"%s\" %s %s\n", 0,
 		q,
 		"T",  /* open in NetBeans */
 		"F"); /* modified */
 	if (curbuf->b_ffname != NULL)
 	    vim_free(q);
 	nbdebug(("EVT: %s", buf));
 	nb_send(buf, "netbeans_keycommand");
 
-	if (key > 0)
-	    postpone_keycommand(key);
-	return;
+	postpone_keycommand(keyName);
+	return FALSE;
     }
 
     /* sync the cursor position */
     off = pos2off(curbuf, &curwin->w_cursor);
     sprintf(buf, "%d:newDotAndMark=%d %ld %ld\n", bufno, r_cmdno, off, off);
@@ -3207,10 +3234,11 @@ netbeans_keystring(int key, char *keyNam
     vim_snprintf(buf, sizeof(buf), "%d:keyAtPos=%d \"%s\" %ld %ld/%ld\n",
 	    bufno, r_cmdno, keyName,
 		off, (long)curwin->w_cursor.lnum, (long)curwin->w_cursor.col);
     nbdebug(("EVT: %s", buf));
     nb_send(buf, "netbeans_keycommand");
+    return TRUE;
 }
 
 
 /*
  * Send a save event to netbeans.
@@ -3375,11 +3403,11 @@ netbeans_gutter_click(linenr_T lnum)
     }
 }
 
 
 /*
- * Add a sign of the reqested type at the requested location.
+ * Add a sign of the requested type at the requested location.
  *
  * Reverse engineering:
  * Apparently an annotation is defined the first time it is used in a buffer.
  * When the same annotation is used in two buffers, the second time we do not
  * need to define a new sign name but reuse the existing one.  But since the
@@ -3389,17 +3417,16 @@ netbeans_gutter_click(linenr_T lnum)
  *
  * globalsignmap[]	stores the signs that have been defined globally.
  * buf->signmapused[]	maps buffer-local annotation IDs to an index in
  *			globalsignmap[].
  */
-/*ARGSUSED*/
     static void
 addsigntype(
     nbbuf_T	*buf,
     int		typeNum,
     char_u	*typeName,
-    char_u	*tooltip,
+    char_u	*tooltip UNUSED,
     char_u	*glyphFile,
     int		use_fg,
     int		fg,
     int		use_bg,
     int		bg)
@@ -3529,11 +3556,12 @@ get_buf_size(buf_T *bufp)
 	    eol_size = 2;
 	else
 	    eol_size = 1;
 	for (lnum = 1; lnum <= bufp->b_ml.ml_line_count; ++lnum)
 	{
-	    char_count += (long)STRLEN(ml_get(lnum)) + eol_size;
+	    char_count += (long)STRLEN(ml_get_buf(bufp, lnum, FALSE))
+								   + eol_size;
 	    /* Check for a CTRL-C every 100000 characters */
 	    if (char_count > last_check)
 	    {
 		ui_breakcheck();
 		if (got_int)
--- vim72.orig/src/normal.c
+++ vim72/src/normal.c
@@ -181,10 +181,12 @@ static void	nv_drop __ARGS((cmdarg_T *ca
 #endif
 #ifdef FEAT_AUTOCMD
 static void	nv_cursorhold __ARGS((cmdarg_T *cap));
 #endif
 
+static char *e_noident = N_("E349: No identifier under cursor");
+
 /*
  * Function to be called for a Normal or Visual mode command.
  * The argument is a cmdarg_T.
  */
 typedef void (*nv_func_T) __ARGS((cmdarg_T *cap));
@@ -489,18 +491,18 @@ nv_compare(s1, s2)
 init_normal_cmds()
 {
     int		i;
 
     /* Fill the index table with a one to one relation. */
-    for (i = 0; i < NV_CMDS_SIZE; ++i)
+    for (i = 0; i < (int)NV_CMDS_SIZE; ++i)
 	nv_cmd_idx[i] = i;
 
     /* Sort the commands by the command character.  */
     qsort((void *)&nv_cmd_idx, (size_t)NV_CMDS_SIZE, sizeof(short), nv_compare);
 
     /* Find the first entry that can't be indexed by the command character. */
-    for (i = 0; i < NV_CMDS_SIZE; ++i)
+    for (i = 0; i < (int)NV_CMDS_SIZE; ++i)
 	if (i != nv_cmds[nv_cmd_idx[i]].cmd_char)
 	    break;
     nv_max_linear = i - 1;
 }
 
@@ -557,15 +559,14 @@ find_command(cmdchar)
 }
 
 /*
  * Execute a command in Normal mode.
  */
-/*ARGSUSED*/
     void
 normal_cmd(oap, toplevel)
     oparg_T	*oap;
-    int		toplevel;		/* TRUE when called from main() */
+    int		toplevel UNUSED;	/* TRUE when called from main() */
 {
     cmdarg_T	ca;			/* command arguments */
     int		c;
     int		ctrl_w = FALSE;		/* got CTRL-W command */
     int		old_col = curwin->w_curswant;
@@ -576,10 +577,13 @@ normal_cmd(oap, toplevel)
     pos_T	old_pos;		/* cursor position before command */
     int		mapped_len;
     static int	old_mapped_len = 0;
 #endif
     int		idx;
+#ifdef FEAT_EVAL
+    int		set_prevcount = FALSE;
+#endif
 
     vim_memset(&ca, 0, sizeof(ca));	/* also resets ca.retval */
     ca.oap = oap;
 
     /* Use a count remembered from before entering an operator.  After typing
@@ -611,11 +615,16 @@ normal_cmd(oap, toplevel)
 #endif
 
     /* When not finishing an operator and no register name typed, reset the
      * count. */
     if (!finish_op && !oap->regname)
+    {
 	ca.opcount = 0;
+#ifdef FEAT_EVAL
+	set_prevcount = TRUE;
+#endif
+    }
 
 #ifdef FEAT_AUTOCMD
     /* Restore counts from before receiving K_CURSORHOLD.  This means after
      * typing "3", handling K_CURSORHOLD and then typing "2" we get "32", not
      * "3 * 2". */
@@ -639,14 +648,11 @@ normal_cmd(oap, toplevel)
 
     /*
      * Get the command character from the user.
      */
     c = safe_vgetc();
-
-#ifdef FEAT_LANGMAP
     LANGMAP_ADJUST(c, TRUE);
-#endif
 
 #ifdef FEAT_VISUAL
     /*
      * If a mapping was started in Visual or Select mode, remember the length
      * of the mapping.  This is used below to not return to Insert mode for as
@@ -715,22 +721,28 @@ getcount:
 #ifdef FEAT_EVAL
 	    /* Set v:count here, when called from main() and not a stuffed
 	     * command, so that v:count can be used in an expression mapping
 	     * right after the count. */
 	    if (toplevel && stuff_empty())
-		set_vcount(ca.count0, ca.count0 == 0 ? 1 : ca.count0);
+	    {
+		long count = ca.count0;
+
+		/* multiply with ca.opcount the same way as below */
+		if (ca.opcount != 0)
+		    count = ca.opcount * (count == 0 ? 1 : count);
+		set_vcount(count, count == 0 ? 1 : count, set_prevcount);
+		set_prevcount = FALSE;  /* only set v:prevcount once */
+	    }
 #endif
 	    if (ctrl_w)
 	    {
 		++no_mapping;
 		++allow_keys;		/* no mapping for nchar, but keys */
 	    }
 	    ++no_zero_mapping;		/* don't map zero here */
 	    c = plain_vgetc();
-#ifdef FEAT_LANGMAP
 	    LANGMAP_ADJUST(c, TRUE);
-#endif
 	    --no_zero_mapping;
 	    if (ctrl_w)
 	    {
 		--no_mapping;
 		--allow_keys;
@@ -749,13 +761,11 @@ getcount:
 	    ca.opcount = ca.count0;	/* remember first count */
 	    ca.count0 = 0;
 	    ++no_mapping;
 	    ++allow_keys;		/* no mapping for nchar, but keys */
 	    c = plain_vgetc();		/* get next character */
-#ifdef FEAT_LANGMAP
 	    LANGMAP_ADJUST(c, TRUE);
-#endif
 	    --no_mapping;
 	    --allow_keys;
 #ifdef FEAT_CMDL_INFO
 	    need_flushbuf |= add_to_showcmd(c);
 #endif
@@ -802,11 +812,11 @@ getcount:
 #ifdef FEAT_EVAL
     /*
      * Only set v:count when called from main() and not a stuffed command.
      */
     if (toplevel && stuff_empty())
-	set_vcount(ca.count0, ca.count1);
+	set_vcount(ca.count0, ca.count1, set_prevcount);
 #endif
 
     /*
      * Find the command character in the table of commands.
      * For CTRL-W we already got nchar when looking for a count.
@@ -939,13 +949,11 @@ getcount:
 	    /*
 	     * For 'g' get the next character now, so that we can check for
 	     * "gr", "g'" and "g`".
 	     */
 	    ca.nchar = plain_vgetc();
-#ifdef FEAT_LANGMAP
 	    LANGMAP_ADJUST(ca.nchar, TRUE);
-#endif
 #ifdef FEAT_CMDL_INFO
 	    need_flushbuf |= add_to_showcmd(ca.nchar);
 #endif
 	    if (ca.nchar == 'r' || ca.nchar == '\'' || ca.nchar == '`'
 						      || ca.nchar == Ctrl_BSL)
@@ -1042,14 +1050,12 @@ getcount:
 # endif
 		    }
 		}
 #endif
 
-#ifdef FEAT_LANGMAP
 		/* adjust chars > 127, except after "tTfFr" commands */
 		LANGMAP_ADJUST(*cp, !lang);
-#endif
 #ifdef FEAT_RIGHTLEFT
 		/* adjust Hebrew mapped char */
 		if (p_hkmap && lang && KeyTyped)
 		    *cp = hkmap(*cp);
 # ifdef FEAT_FKMAP
@@ -1130,11 +1136,12 @@ getcount:
      */
     if (need_flushbuf)
 	out_flush();
 #endif
 #ifdef FEAT_AUTOCMD
-    did_cursorhold = FALSE;
+    if (ca.cmdchar != K_IGNORE)
+	did_cursorhold = FALSE;
 #endif
 
     State = NORMAL;
 
     if (ca.nchar == ESC)
@@ -2178,14 +2185,13 @@ op_colon(oap)
 }
 
 /*
  * Handle the "g@" operator: call 'operatorfunc'.
  */
-/*ARGSUSED*/
     static void
 op_function(oap)
-    oparg_T	*oap;
+    oparg_T	*oap UNUSED;
 {
 #ifdef FEAT_EVAL
     char_u	*(argv[1]);
 
     if (*p_opfunc == NUL)
@@ -3507,11 +3513,11 @@ find_ident_at_pos(wp, lnum, startcol, st
 	 * didn't find an identifier or string
 	 */
 	if (find_type & FIND_STRING)
 	    EMSG(_("E348: No string under cursor"));
 	else
-	    EMSG(_("E349: No identifier under cursor"));
+	    EMSG(_(e_noident));
 	return 0;
     }
     ptr += col;
     *string = ptr;
 
@@ -3699,17 +3705,17 @@ clear_showcmd()
 	return;
 
 #ifdef FEAT_VISUAL
     if (VIsual_active && !char_avail())
     {
-	int		i = lt(VIsual, curwin->w_cursor);
+	int		cursor_bot = lt(VIsual, curwin->w_cursor);
 	long		lines;
 	colnr_T		leftcol, rightcol;
 	linenr_T	top, bot;
 
 	/* Show the size of the Visual area. */
-	if (i)
+	if (cursor_bot)
 	{
 	    top = VIsual.lnum;
 	    bot = curwin->w_cursor.lnum;
 	}
 	else
@@ -3724,18 +3730,27 @@ clear_showcmd()
 # endif
 	lines = bot - top + 1;
 
 	if (VIsual_mode == Ctrl_V)
 	{
+#ifdef FEAT_LINEBREAK
+	    char_u *saved_sbr = p_sbr;
+
+	    /* Make 'sbr' empty for a moment to get the correct size. */
+	    p_sbr = empty_option;
+#endif
 	    getvcols(curwin, &curwin->w_cursor, &VIsual, &leftcol, &rightcol);
+#ifdef FEAT_LINEBREAK
+	    p_sbr = saved_sbr;
+#endif
 	    sprintf((char *)showcmd_buf, "%ldx%ld", lines,
 					      (long)(rightcol - leftcol + 1));
 	}
 	else if (VIsual_mode == 'V' || VIsual.lnum != curwin->w_cursor.lnum)
 	    sprintf((char *)showcmd_buf, "%ld", lines);
 	else
-	    sprintf((char *)showcmd_buf, "%ld", (long)(i
+	    sprintf((char *)showcmd_buf, "%ld", (long)(cursor_bot
 		    ? curwin->w_cursor.col - VIsual.col
 		    : VIsual.col - curwin->w_cursor.col) + (*p_sel != 'e'));
 	showcmd_buf[SHOWCMD_COLS] = NUL;	/* truncate */
 	showcmd_visual = TRUE;
     }
@@ -4081,14 +4096,13 @@ nv_ignore(cap)
 
 /*
  * Command character that doesn't do anything, but unlike nv_ignore() does
  * start edit().  Used for "startinsert" executed while starting up.
  */
-/*ARGSUSED */
     static void
 nv_nop(cap)
-    cmdarg_T	*cap;
+    cmdarg_T	*cap UNUSED;
 {
 }
 
 /*
  * Command character doesn't exist.
@@ -4609,13 +4623,11 @@ nv_zet(cap)
 	    dont_scroll = TRUE;		/* disallow scrolling here */
 #endif
 	    ++no_mapping;
 	    ++allow_keys;   /* no mapping for nchar, but allow key codes */
 	    nchar = plain_vgetc();
-#ifdef FEAT_LANGMAP
 	    LANGMAP_ADJUST(nchar, TRUE);
-#endif
 	    --no_mapping;
 	    --allow_keys;
 #ifdef FEAT_CMDL_INFO
 	    (void)add_to_showcmd(nchar);
 #endif
@@ -4967,13 +4979,11 @@ dozet:
 #ifdef FEAT_SPELL
     case 'u':	/* "zug" and "zuw": undo "zg" and "zw" */
 		++no_mapping;
 		++allow_keys;   /* no mapping for nchar, but allow key codes */
 		nchar = plain_vgetc();
-#ifdef FEAT_LANGMAP
 		LANGMAP_ADJUST(nchar, TRUE);
-#endif
 		--no_mapping;
 		--allow_keys;
 #ifdef FEAT_CMDL_INFO
 		(void)add_to_showcmd(nchar);
 #endif
@@ -5226,11 +5236,11 @@ nv_colon(cap)
 	/* The start of the operator may have become invalid by the Ex
 	 * command. */
 	if (cap->oap->op_type != OP_NOP
 		&& (cap->oap->start.lnum > curbuf->b_ml.ml_line_count
 		    || cap->oap->start.col >
-					 STRLEN(ml_get(cap->oap->start.lnum))))
+			       (colnr_T)STRLEN(ml_get(cap->oap->start.lnum))))
 	    clearopbeep(cap->oap);
     }
 }
 
 /*
@@ -5394,10 +5404,11 @@ nv_ident(cap)
     char_u	*kp;		/* value of 'keywordprg' */
     int		kp_help;	/* 'keywordprg' is ":help" */
     int		n = 0;		/* init for GCC */
     int		cmdchar;
     int		g_cmd;		/* "g" command */
+    int		tag_cmd = FALSE;
     char_u	*aux_ptr;
     int		isman;
     int		isman_s;
 
     if (cap->cmdchar == 'g')	/* "g*", "g#", "g]" and "gCTRL-]" */
@@ -5467,10 +5478,24 @@ nv_ident(cap)
 	case 'K':
 	    if (kp_help)
 		STRCPY(buf, "he! ");
 	    else
 	    {
+		/* An external command will probably use an argument starting
+		 * with "-" as an option.  To avoid trouble we skip the "-". */
+		while (*ptr == '-' && n > 0)
+		{
+		    ++ptr;
+		    --n;
+		}
+		if (n == 0)
+		{
+		    EMSG(_(e_noident));	 /* found dashes only */
+		    vim_free(buf);
+		    return;
+		}
+
 		/* When a count is given, turn it into a range.  Is this
 		 * really what we want? */
 		isman = (STRCMP(kp, "man") == 0);
 		isman_s = (STRCMP(kp, "man -s") == 0);
 		if (cap->count0 != 0 && !(isman || isman_s))
@@ -5489,61 +5514,90 @@ nv_ident(cap)
 		}
 	    }
 	    break;
 
 	case ']':
+	    tag_cmd = TRUE;
 #ifdef FEAT_CSCOPE
 	    if (p_cst)
 		STRCPY(buf, "cstag ");
 	    else
 #endif
 		STRCPY(buf, "ts ");
 	    break;
 
 	default:
+	    tag_cmd = TRUE;
 	    if (curbuf->b_help)
 		STRCPY(buf, "he! ");
-	    else if (g_cmd)
-		STRCPY(buf, "tj ");
 	    else
-		sprintf((char *)buf, "%ldta ", cap->count0);
+	    {
+		if (g_cmd)
+		    STRCPY(buf, "tj ");
+		else
+		    sprintf((char *)buf, "%ldta ", cap->count0);
+	    }
     }
 
     /*
      * Now grab the chars in the identifier
      */
-    if (cmdchar == '*')
-	aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
-    else if (cmdchar == '#')
-	aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
-    else if (cmdchar == 'K' && !kp_help)
-	aux_ptr = (char_u *)" \t\\\"|!";
-    else
-	/* Don't escape spaces and Tabs in a tag with a backslash */
-	aux_ptr = (char_u *)"\\|\"";
-
-    p = buf + STRLEN(buf);
-    while (n-- > 0)
-    {
-	/* put a backslash before \ and some others */
-	if (vim_strchr(aux_ptr, *ptr) != NULL)
-	    *p++ = '\\';
-#ifdef FEAT_MBYTE
-	/* When current byte is a part of multibyte character, copy all bytes
-	 * of that character. */
-	if (has_mbyte)
+    if (cmdchar == 'K' && !kp_help)
+    {
+	/* Escape the argument properly for a shell command */
+	ptr = vim_strnsave(ptr, n);
+	p = vim_strsave_shellescape(ptr, TRUE);
+	vim_free(ptr);
+	if (p == NULL)
 	{
-	    int i;
-	    int len = (*mb_ptr2len)(ptr) - 1;
-
-	    for (i = 0; i < len && n >= 1; ++i, --n)
-		*p++ = *ptr++;
+	    vim_free(buf);
+	    return;
+	}
+	buf = (char_u *)vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
+	if (buf == NULL)
+	{
+	    vim_free(buf);
+	    vim_free(p);
+	    return;
 	}
+	STRCAT(buf, p);
+	vim_free(p);
+    }
+    else
+    {
+	if (cmdchar == '*')
+	    aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
+	else if (cmdchar == '#')
+	    aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
+	else if (tag_cmd)
+	    /* Don't escape spaces and Tabs in a tag with a backslash */
+	    aux_ptr = (char_u *)"\\|\"\n[";
+	else
+	    aux_ptr = (char_u *)"\\|\"\n*?[";
+
+	p = buf + STRLEN(buf);
+	while (n-- > 0)
+	{
+	    /* put a backslash before \ and some others */
+	    if (vim_strchr(aux_ptr, *ptr) != NULL)
+		*p++ = '\\';
+#ifdef FEAT_MBYTE
+	    /* When current byte is a part of multibyte character, copy all
+	     * bytes of that character. */
+	    if (has_mbyte)
+	    {
+		int i;
+		int len = (*mb_ptr2len)(ptr) - 1;
+
+		for (i = 0; i < len && n >= 1; ++i, --n)
+		    *p++ = *ptr++;
+	    }
 #endif
-	*p++ = *ptr++;
+	    *p++ = *ptr++;
+	}
+	*p = NUL;
     }
-    *p = NUL;
 
     /*
      * Execute the command.
      */
     if (cmdchar == '*' || cmdchar == '#')
@@ -5554,10 +5608,11 @@ nv_ident(cap)
 #endif
 		vim_iswordc(ptr[-1])))
 	    STRCAT(buf, "\\>");
 #ifdef FEAT_CMDHIST
 	/* put pattern in search history */
+	init_history();
 	add_to_history(HIST_SEARCH, buf, TRUE, NUL);
 #endif
 	normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0);
     }
     else
@@ -5765,11 +5820,14 @@ nv_right(cap)
 #endif
 
     for (n = cap->count1; n > 0; --n)
     {
 	if ((!PAST_LINE && oneright() == FAIL)
-		|| (PAST_LINE && *ml_get_cursor() == NUL))
+#ifdef FEAT_VISUAL
+		|| (PAST_LINE && *ml_get_cursor() == NUL)
+#endif
+		)
 	{
 	    /*
 	     *	  <Space> wraps to next line if 'whichwrap' has 's'.
 	     *	      'l' wraps to next line if 'whichwrap' has 'l'.
 	     * CURS_RIGHT wraps to next line if 'whichwrap' has '>'.
@@ -6009,11 +6067,11 @@ nv_gotofile(cap)
 	/* do autowrite if necessary */
 	if (curbufIsChanged() && curbuf->b_nwindows <= 1 && !P_HID(curbuf))
 	    autowrite(curbuf, FALSE);
 	setpcmark();
 	(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
-					       P_HID(curbuf) ? ECMD_HIDE : 0);
+				       P_HID(curbuf) ? ECMD_HIDE : 0, curwin);
 	if (cap->nchar == 'F' && lnum >= 0)
 	{
 	    curwin->w_cursor.lnum = lnum;
 	    check_cursor_lnum();
 	    beginline(BL_SOL | BL_FIX);
@@ -6726,10 +6784,12 @@ nv_replace(cap)
 
 #ifdef FEAT_VISUAL
     /* Visual mode "r" */
     if (VIsual_active)
     {
+	if (got_int)
+	    reset_VIsual();
 	nv_operator(cap);
 	return;
     }
 #endif
 
@@ -7782,11 +7842,11 @@ nv_g_cmd(cap)
 		i = (curwin->w_virtcol - width1) / width2 * width2 + width1;
 	}
 	else
 	    i = curwin->w_leftcol;
 	/* Go to the middle of the screen line.  When 'number' is on and lines
-	 * are wrapping the middle can be more to the left.*/
+	 * are wrapping the middle can be more to the left. */
 	if (cap->nchar == 'm')
 	    i += (W_WIDTH(curwin) - curwin_col_off()
 		    + ((curwin->w_p_wrap && i > 0)
 			? curwin_col_off2() : 0)) / 2;
 	coladvance((colnr_T)i);
@@ -7819,10 +7879,13 @@ nv_g_cmd(cap)
 	    /* Decrease the cursor column until it's on a non-blank. */
 	    while (curwin->w_cursor.col > 0
 				    && vim_iswhite(ptr[curwin->w_cursor.col]))
 		--curwin->w_cursor.col;
 	    curwin->w_set_curswant = TRUE;
+#ifdef FEAT_VISUAL
+	    adjust_for_sel(cap);
+#endif
 	}
 	break;
 
     case '$':
     case K_END:
@@ -9190,14 +9253,13 @@ nv_open(cap)
 #endif
 	n_opencmd(cap);
 }
 
 #ifdef FEAT_SNIFF
-/*ARGSUSED*/
     static void
 nv_sniff(cap)
-    cmdarg_T	*cap;
+    cmdarg_T	*cap UNUSED;
 {
     ProcessSniffRequests();
 }
 #endif
 
@@ -9209,14 +9271,13 @@ nv_nbcmd(cap)
     netbeans_keycommand(cap->nchar);
 }
 #endif
 
 #ifdef FEAT_DND
-/*ARGSUSED*/
     static void
 nv_drop(cap)
-    cmdarg_T	*cap;
+    cmdarg_T	*cap UNUSED;
 {
     do_put('~', BACKWARD, 1L, PUT_CURSEND);
 }
 #endif
 
@@ -9224,11 +9285,10 @@ nv_drop(cap)
 /*
  * Trigger CursorHold event.
  * When waiting for a character for 'updatetime' K_CURSORHOLD is put in the
  * input buffer.  "did_cursorhold" is set to avoid retriggering.
  */
-/*ARGSUSED*/
     static void
 nv_cursorhold(cap)
     cmdarg_T	*cap;
 {
     apply_autocmds(EVENT_CURSORHOLD, NULL, NULL, FALSE, curbuf);
--- vim72.orig/src/ops.c
+++ vim72/src/ops.c
@@ -70,15 +70,15 @@ static struct yankreg	*y_previous = NULL
  * structure used by block_prep, op_delete and op_yank for blockwise operators
  * also op_change, op_shift, op_insert, op_replace - AKelly
  */
 struct block_def
 {
-    int		startspaces;	/* 'extra' cols of first char */
-    int		endspaces;	/* 'extra' cols of first char */
+    int		startspaces;	/* 'extra' cols before first char */
+    int		endspaces;	/* 'extra' cols after last char */
     int		textlen;	/* chars in block */
-    char_u	*textstart;	/* pointer to 1st char in block */
-    colnr_T	textcol;	/* cols of chars (at least part.) in block */
+    char_u	*textstart;	/* pointer to 1st char (partially) in block */
+    colnr_T	textcol;	/* index of chars (partially) in block */
     colnr_T	start_vcol;	/* start col of 1st char wholly inside block */
     colnr_T	end_vcol;	/* start col of 1st char wholly after block */
 #ifdef FEAT_VISUALEXTRA
     int		is_short;	/* TRUE if line is too short to fit in block */
     int		is_MAX;		/* TRUE if curswant==MAXCOL when starting */
@@ -380,22 +380,20 @@ shift_block(oap, amount)
     oparg_T	*oap;
     int		amount;
 {
     int			left = (oap->op_type == OP_LSHIFT);
     int			oldstate = State;
-    int			total, split;
-    char_u		*newp, *oldp, *midp, *ptr;
+    int			total;
+    char_u		*newp, *oldp;
     int			oldcol = curwin->w_cursor.col;
     int			p_sw = (int)curbuf->b_p_sw;
     int			p_ts = (int)curbuf->b_p_ts;
     struct block_def	bd;
-    int			internal = 0;
     int			incr;
-    colnr_T		vcol, col = 0, ws_vcol;
+    colnr_T		ws_vcol;
     int			i = 0, j = 0;
     int			len;
-
 #ifdef FEAT_RIGHTLEFT
     int			old_p_ri = p_ri;
 
     p_ri = 0;			/* don't want revins in ident */
 #endif
@@ -422,12 +420,13 @@ shift_block(oap, amount)
 	if (bd.startspaces)
 	{
 #ifdef FEAT_MBYTE
 	    if (has_mbyte)
 		bd.textstart += (*mb_ptr2len)(bd.textstart);
+	    else
 #endif
-	    ++bd.textstart;
+		++bd.textstart;
 	}
 	for ( ; vim_iswhite(*bd.textstart); )
 	{
 	    incr = lbr_chartabsize_adv(&bd.textstart, (colnr_T)(bd.start_vcol));
 	    total += incr;
@@ -454,71 +453,94 @@ shift_block(oap, amount)
 	/* the end */
 	mch_memmove(newp + bd.textcol + i + j, bd.textstart, (size_t)len);
     }
     else /* left */
     {
-	vcol = oap->start_vcol;
-	/* walk vcol past ws to be removed */
-	for (midp = oldp + bd.textcol;
-	      vcol < (oap->start_vcol + total) && vim_iswhite(*midp); )
-	{
-	    incr = lbr_chartabsize_adv(&midp, (colnr_T)vcol);
-	    vcol += incr;
-	}
-	/* internal is the block-internal ws replacing a split TAB */
-	if (vcol > (oap->start_vcol + total))
-	{
-	    /* we have to split the TAB *(midp-1) */
-	    internal = vcol - (oap->start_vcol + total);
-	}
-	/* if 'expandtab' is not set, use TABs */
+	colnr_T	    destination_col;	/* column to which text in block will
+					   be shifted */
+	char_u	    *verbatim_copy_end;	/* end of the part of the line which is
+					   copied verbatim */
+	colnr_T	    verbatim_copy_width;/* the (displayed) width of this part
+					   of line */
+	unsigned    fill;		/* nr of spaces that replace a TAB */
+	unsigned    new_line_len;	/* the length of the line after the
+					   block shift */
+	size_t	    block_space_width;
+	size_t	    shift_amount;
+	char_u	    *non_white = bd.textstart;
+	colnr_T	    non_white_col;
 
-	split = bd.startspaces + internal;
-	if (split > 0)
-	{
-	    if (!curbuf->b_p_et)
-	    {
-		for (ptr = oldp, col = 0; ptr < oldp+bd.textcol; )
-		    col += lbr_chartabsize_adv(&ptr, (colnr_T)col);
+	/*
+	 * Firstly, let's find the first non-whitespace character that is
+	 * displayed after the block's start column and the character's column
+	 * number. Also, let's calculate the width of all the whitespace
+	 * characters that are displayed in the block and precede the searched
+	 * non-whitespace character.
+	 */
 
-		/* col+1 now equals the start col of the first char of the
-		 * block (may be < oap.start_vcol if we're splitting a TAB) */
-		i = ((col % p_ts) + split) / p_ts; /* number of tabs */
-	    }
-	    if (i)
-		j = ((col % p_ts) + split) % p_ts; /* number of spp */
-	    else
-		j = split;
-	}
+	/* If "bd.startspaces" is set, "bd.textstart" points to the character,
+	 * the part of which is displayed at the block's beginning. Let's start
+	 * searching from the next character. */
+	if (bd.startspaces)
+	    mb_ptr_adv(non_white);
 
-	newp = alloc_check(bd.textcol + i + j + (unsigned)STRLEN(midp) + 1);
-	if (newp == NULL)
-	    return;
-	vim_memset(newp, NUL, (size_t)(bd.textcol + i + j + STRLEN(midp) + 1));
+	/* The character's column is in "bd.start_vcol".  */
+	non_white_col = bd.start_vcol;
 
-	/* copy first part we want to keep */
-	mch_memmove(newp, oldp, (size_t)bd.textcol);
-	/* Now copy any TABS and spp to ensure correct alignment! */
-	while (vim_iswhite(*midp))
+	while (vim_iswhite(*non_white))
 	{
-	    if (*midp == TAB)
-		i++;
-	    else /*space */
-		j++;
-	    midp++;
+	    incr = lbr_chartabsize_adv(&non_white, non_white_col);
+	    non_white_col += incr;
 	}
-	/* We might have an extra TAB worth of spp now! */
-	if (j / p_ts && !curbuf->b_p_et)
+
+	block_space_width = non_white_col - oap->start_vcol;
+	/* We will shift by "total" or "block_space_width", whichever is less.
+	 */
+	shift_amount = (block_space_width < (size_t)total
+					 ? block_space_width : (size_t)total);
+
+	/* The column to which we will shift the text.  */
+	destination_col = (colnr_T)(non_white_col - shift_amount);
+
+	/* Now let's find out how much of the beginning of the line we can
+	 * reuse without modification.  */
+	verbatim_copy_end = bd.textstart;
+	verbatim_copy_width = bd.start_vcol;
+
+	/* If "bd.startspaces" is set, "bd.textstart" points to the character
+	 * preceding the block. We have to subtract its width to obtain its
+	 * column number.  */
+	if (bd.startspaces)
+	    verbatim_copy_width -= bd.start_char_vcols;
+	while (verbatim_copy_width < destination_col)
 	{
-	    i++;
-	    j -= p_ts;
+	    incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width);
+	    if (verbatim_copy_width + incr > destination_col)
+		break;
+	    verbatim_copy_width += incr;
+	    mb_ptr_adv(verbatim_copy_end);
 	}
-	copy_chars(newp + bd.textcol, (size_t)i, TAB);
-	copy_spaces(newp + bd.textcol + i, (size_t)j);
 
-	/* the end */
-	STRMOVE(newp + STRLEN(newp), midp);
+	/* If "destination_col" is different from the width of the initial
+	 * part of the line that will be copied, it means we encountered a tab
+	 * character, which we will have to partly replace with spaces.  */
+	fill = destination_col - verbatim_copy_width;
+
+	/* The replacement line will consist of:
+	 * - the beginning of the original line up to "verbatim_copy_end",
+	 * - "fill" number of spaces,
+	 * - the rest of the line, pointed to by non_white.  */
+	new_line_len = (unsigned)(verbatim_copy_end - oldp)
+		       + fill
+		       + (unsigned)STRLEN(non_white) + 1;
+
+	newp = alloc_check(new_line_len);
+	if (newp == NULL)
+	    return;
+	mch_memmove(newp, oldp, (size_t)(verbatim_copy_end - oldp));
+	copy_spaces(newp + (verbatim_copy_end - oldp), (size_t)fill);
+	STRMOVE(newp + (verbatim_copy_end - oldp) + fill, non_white);
     }
     /* replace the line */
     ml_replace(curwin->w_cursor.lnum, newp, FALSE);
     changed_bytes(curwin->w_cursor.lnum, (colnr_T)bd.textcol);
     State = oldstate;
@@ -1120,10 +1142,12 @@ stuff_yank(regname, p)
 	y_current->y_type = MCHAR;  /* used to be MLINE, why? */
     }
     return OK;
 }
 
+static int execreg_lastc = NUL;
+
 /*
  * execute a yank register: copy it into the stuff buffer
  *
  * return FAIL for failure, OK otherwise
  */
@@ -1132,32 +1156,31 @@ do_execreg(regname, colon, addcr, silent
     int	    regname;
     int	    colon;		/* insert ':' before each line */
     int	    addcr;		/* always add '\n' to end of line */
     int	    silent;		/* set "silent" flag in typeahead buffer */
 {
-    static int	lastc = NUL;
     long	i;
     char_u	*p;
     int		retval = OK;
     int		remap;
 
     if (regname == '@')			/* repeat previous one */
     {
-	if (lastc == NUL)
+	if (execreg_lastc == NUL)
 	{
 	    EMSG(_("E748: No previously used register"));
 	    return FAIL;
 	}
-	regname = lastc;
+	regname = execreg_lastc;
     }
 					/* check for valid regname */
     if (regname == '%' || regname == '#' || !valid_yank_reg(regname, FALSE))
     {
 	emsg_invreg(regname);
 	return FAIL;
     }
-    lastc = regname;
+    execreg_lastc = regname;
 
 #ifdef FEAT_CLIPBOARD
     regname = may_get_selection(regname);
 #endif
 
@@ -1276,22 +1299,28 @@ put_reedit_in_typebuf(silent)
 	if (ins_typebuf(buf, REMAP_NONE, 0, TRUE, silent) == OK)
 	    restart_edit = NUL;
     }
 }
 
+/*
+ * Insert register contents "s" into the typeahead buffer, so that it will be
+ * executed again.
+ * When "esc" is TRUE it is to be taken literally: Escape CSI characters and
+ * no remapping.
+ */
     static int
 put_in_typebuf(s, esc, colon, silent)
     char_u	*s;
-    int		esc;	    /* Escape CSI characters */
+    int		esc;
     int		colon;	    /* add ':' before the line */
     int		silent;
 {
     int		retval = OK;
 
     put_reedit_in_typebuf(silent);
     if (colon)
-	retval = ins_typebuf((char_u *)"\n", REMAP_YES, 0, TRUE, silent);
+	retval = ins_typebuf((char_u *)"\n", REMAP_NONE, 0, TRUE, silent);
     if (retval == OK)
     {
 	char_u	*p;
 
 	if (esc)
@@ -1299,16 +1328,17 @@ put_in_typebuf(s, esc, colon, silent)
 	else
 	    p = s;
 	if (p == NULL)
 	    retval = FAIL;
 	else
-	    retval = ins_typebuf(p, REMAP_YES, 0, TRUE, silent);
+	    retval = ins_typebuf(p, esc ? REMAP_NONE : REMAP_YES,
+							     0, TRUE, silent);
 	if (esc)
 	    vim_free(p);
     }
     if (colon && retval == OK)
-	retval = ins_typebuf((char_u *)":", REMAP_YES, 0, TRUE, silent);
+	retval = ins_typebuf((char_u *)":", REMAP_NONE, 0, TRUE, silent);
     return retval;
 }
 
 /*
  * Insert a yank register: copy it into the Read buffer.
@@ -1996,10 +2026,11 @@ op_replace(oap, c)
     if (oap->block_mode)
     {
 	bd.is_MAX = (curwin->w_curswant == MAXCOL);
 	for ( ; curwin->w_cursor.lnum <= oap->end.lnum; ++curwin->w_cursor.lnum)
 	{
+	    curwin->w_cursor.col = 0;  /* make sure cursor position is valid */
 	    block_prep(oap, &bd, curwin->w_cursor.lnum, TRUE);
 	    if (bd.textlen == 0 && (!virtual_op || bd.is_MAX))
 		continue;	    /* nothing to replace */
 
 	    /* n == number of extra chars required
@@ -2011,10 +2042,11 @@ op_replace(oap, c)
 	     * coladd offset as part of "startspaces" */
 	    if (virtual_op && bd.is_short && *bd.textstart == NUL)
 	    {
 		pos_T vpos;
 
+		vpos.lnum = curwin->w_cursor.lnum;
 		getvpos(&vpos, oap->start_vcol);
 		bd.startspaces += vpos.coladd;
 		n = bd.startspaces;
 	    }
 	    else
@@ -2207,16 +2239,19 @@ op_tilde(oap)
 #ifdef FEAT_VISUAL
     if (oap->block_mode)		    /* Visual block mode */
     {
 	for (; pos.lnum <= oap->end.lnum; ++pos.lnum)
 	{
+	    int one_change;
+
 	    block_prep(oap, &bd, pos.lnum, FALSE);
 	    pos.col = bd.textcol;
-	    did_change = swapchars(oap->op_type, &pos, bd.textlen);
+	    one_change = swapchars(oap->op_type, &pos, bd.textlen);
+	    did_change |= one_change;
 
 # ifdef FEAT_NETBEANS_INTG
-	    if (usingNetbeans && did_change)
+	    if (usingNetbeans && one_change)
 	    {
 		char_u *ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
 
 		netbeans_removed(curbuf, pos.lnum, bd.textcol,
 							    (long)bd.textlen);
@@ -2666,15 +2701,12 @@ op_change(oap)
 
 			/* If the block starts in virtual space, count the
 			 * initial coladd offset as part of "startspaces" */
 			if (bd.is_short)
 			{
-			    linenr_T lnum = curwin->w_cursor.lnum;
-
-			    curwin->w_cursor.lnum = linenr;
+			    vpos.lnum = linenr;
 			    (void)getvpos(&vpos, oap->start_vcol);
-			    curwin->w_cursor.lnum = lnum;
 			}
 			else
 			    vpos.coladd = 0;
 # endif
 			oldp = ml_get(linenr);
@@ -3964,10 +3996,18 @@ ex_display(eap)
 	    else
 		yb = &(y_regs[0]);
 	}
 	else
 	    yb = &(y_regs[i]);
+
+#ifdef FEAT_EVAL
+	if (name == MB_TOLOWER(redir_reg)
+		|| (redir_reg == '"' && yb == y_previous))
+	    continue;	    /* do not list register being written to, the
+			     * pointer can be freed */
+#endif
+
 	if (yb->y_array != NULL)
 	{
 	    msg_putchar('\n');
 	    msg_putchar('"');
 	    msg_putchar(name);
@@ -4446,33 +4486,18 @@ fex_format(lnum, count, c)
     int		c;	/* character to be inserted */
 {
     int		use_sandbox = was_set_insecurely((char_u *)"formatexpr",
 								   OPT_LOCAL);
     int		r;
-#ifdef FEAT_MBYTE
-    char_u	buf[MB_MAXBYTES];
-#else
-    char_u	buf[2];
-#endif
 
     /*
      * Set v:lnum to the first line number and v:count to the number of lines.
      * Set v:char to the character to be inserted (can be NUL).
      */
     set_vim_var_nr(VV_LNUM, lnum);
     set_vim_var_nr(VV_COUNT, count);
-
-#ifdef FEAT_MBYTE
-    if (has_mbyte)
-	buf[(*mb_char2bytes)(c, buf)] = NUL;
-    else
-#endif
-    {
-	buf[0] = c;
-	buf[1] = NUL;
-    }
-    set_vim_var_string(VV_CHAR, buf, -1);
+    set_vim_var_char(c);
 
     /*
      * Evaluate the function.
      */
     if (use_sandbox)
@@ -4846,11 +4871,12 @@ paragraph_start(lnum)
  *
  * for delete:
  * - textlen includes the first/last char to be (partly) deleted
  * - start/endspaces is the number of columns that are taken by the
  *   first/last deleted char minus the number of columns that have to be
- *   deleted.  for yank and tilde:
+ *   deleted.
+ * for yank and tilde:
  * - textlen includes the first/last char to be wholly yanked
  * - start/endspaces is the number of columns of the first/last yanked char
  *   that are to be yanked.
  */
     static void
@@ -5310,34 +5336,45 @@ read_viminfo_register(virp, force)
     char_u	*str;
     char_u	**array = NULL;
 
     /* We only get here (hopefully) if line[0] == '"' */
     str = virp->vir_line + 1;
+
+    /* If the line starts with "" this is the y_previous register. */
     if (*str == '"')
     {
 	set_prev = TRUE;
 	str++;
     }
+
     if (!ASCII_ISALNUM(*str) && *str != '-')
     {
 	if (viminfo_error("E577: ", _("Illegal register name"), virp->vir_line))
 	    return TRUE;	/* too many errors, pretend end-of-file */
 	do_it = FALSE;
     }
     get_yank_register(*str++, FALSE);
     if (!force && y_current->y_array != NULL)
 	do_it = FALSE;
+
+    if (*str == '@')
+    {
+	/* "x@: register x used for @@ */
+	if (force || execreg_lastc == NUL)
+	    execreg_lastc = str[-1];
+    }
+
     size = 0;
     limit = 100;	/* Optimized for registers containing <= 100 lines */
     if (do_it)
     {
 	if (set_prev)
 	    y_previous = y_current;
 	vim_free(y_current->y_array);
 	array = y_current->y_array =
 		       (char_u **)alloc((unsigned)(limit * sizeof(char_u *)));
-	str = skipwhite(str);
+	str = skipwhite(skiptowhite(str));
 	if (STRNCMP(str, "CHAR", 4) == 0)
 	    y_current->y_type = MCHAR;
 #ifdef FEAT_VISUAL
 	else if (STRNCMP(str, "BLOCK", 5) == 0)
 	    y_current->y_type = MBLOCK;
@@ -5416,10 +5453,11 @@ write_viminfo_registers(fp)
     if (max_num_lines == 0)
 	return;
     max_kbyte = get_viminfo_parameter('s');
     if (max_kbyte == 0)
 	return;
+
     for (i = 0; i < NUM_REGISTERS; i++)
     {
 	if (y_regs[i].y_array == NULL)
 	    continue;
 #ifdef FEAT_CLIPBOARD
@@ -5470,11 +5508,14 @@ write_viminfo_registers(fp)
 		break;
 	}
 	if (y_previous == &y_regs[i])
 	    fprintf(fp, "\"");
 	c = get_register_name(i);
-	fprintf(fp, "\"%c\t%s\t%d\n", c, type,
+	fprintf(fp, "\"%c", c);
+	if (c == execreg_lastc)
+	    fprintf(fp, "@");
+	fprintf(fp, "\t%s\t%d\n", type,
 #ifdef FEAT_VISUAL
 		    (int)y_regs[i].y_width
 #else
 		    0
 #endif
@@ -5548,10 +5589,36 @@ x11_export_final_selection()
 
     /* Check it's OK */
     if (dpy != NULL && str != NULL && motion_type >= 0
 					       && len < 1024*1024 && len > 0)
     {
+#ifdef FEAT_MBYTE
+	/* The CUT_BUFFER0 is supposed to always contain latin1.  Convert from
+	 * 'enc' when it is a multi-byte encoding.  When 'enc' is an 8-bit
+	 * encoding conversion usually doesn't work, so keep the text as-is.
+	 */
+	if (has_mbyte)
+	{
+	    vimconv_T	vc;
+
+	    vc.vc_type = CONV_NONE;
+	    if (convert_setup(&vc, p_enc, (char_u *)"latin1") == OK)
+	    {
+		int	intlen = len;
+		char_u	*conv_str;
+
+		conv_str = string_convert(&vc, str, &intlen);
+		len = intlen;
+		if (conv_str != NULL)
+		{
+		    vim_free(str);
+		    str = conv_str;
+		}
+		convert_setup(&vc, NULL, NULL);
+	    }
+	}
+#endif
 	XStoreBuffer(dpy, (char *)str, (int)len, 0);
 	XFlush(dpy);
     }
 
     vim_free(str);
@@ -6039,11 +6106,11 @@ str_to_reg(y_ptr, type, str, len, blockl
     char_u	**pp;
 #ifdef FEAT_VISUAL
     long	maxlen;
 #endif
 
-    if (y_ptr->y_array == NULL)		/* NULL means emtpy register */
+    if (y_ptr->y_array == NULL)		/* NULL means empty register */
 	y_ptr->y_size = 0;
 
     /*
      * Count the number of lines within the string
      */
@@ -6256,15 +6323,24 @@ cursor_pos_info()
 	    if (*p_sel == 'e' && max_pos.col > 0)
 		--max_pos.col;
 
 	    if (VIsual_mode == Ctrl_V)
 	    {
+#ifdef FEAT_LINEBREAK
+		char_u * saved_sbr = p_sbr;
+
+		/* Make 'sbr' empty for a moment to get the correct size. */
+		p_sbr = empty_option;
+#endif
 		oparg.is_VIsual = 1;
 		oparg.block_mode = TRUE;
 		oparg.op_type = OP_NOP;
 		getvcols(curwin, &min_pos, &max_pos,
 					  &oparg.start_vcol, &oparg.end_vcol);
+#ifdef FEAT_LINEBREAK
+		p_sbr = saved_sbr;
+#endif
 		if (curwin->w_curswant == MAXCOL)
 		    oparg.end_vcol = MAXCOL;
 		/* Swap the start, end vcol if needed */
 		if (oparg.end_vcol < oparg.start_vcol)
 		{
@@ -6364,25 +6440,27 @@ cursor_pos_info()
 	{
 	    if (VIsual_mode == Ctrl_V && curwin->w_curswant < MAXCOL)
 	    {
 		getvcols(curwin, &min_pos, &max_pos, &min_pos.col,
 								&max_pos.col);
-		sprintf((char *)buf1, _("%ld Cols; "),
+		vim_snprintf((char *)buf1, sizeof(buf1), _("%ld Cols; "),
 			(long)(oparg.end_vcol - oparg.start_vcol + 1));
 	    }
 	    else
 		buf1[0] = NUL;
 
 	    if (char_count_cursor == byte_count_cursor
 						  && char_count == byte_count)
-		sprintf((char *)IObuff, _("Selected %s%ld of %ld Lines; %ld of %ld Words; %ld of %ld Bytes"),
+		vim_snprintf((char *)IObuff, IOSIZE,
+			_("Selected %s%ld of %ld Lines; %ld of %ld Words; %ld of %ld Bytes"),
 			buf1, line_count_selected,
 			(long)curbuf->b_ml.ml_line_count,
 			word_count_cursor, word_count,
 			byte_count_cursor, byte_count);
 	    else
-		sprintf((char *)IObuff, _("Selected %s%ld of %ld Lines; %ld of %ld Words; %ld of %ld Chars; %ld of %ld Bytes"),
+		vim_snprintf((char *)IObuff, IOSIZE,
+			_("Selected %s%ld of %ld Lines; %ld of %ld Words; %ld of %ld Chars; %ld of %ld Bytes"),
 			buf1, line_count_selected,
 			(long)curbuf->b_ml.ml_line_count,
 			word_count_cursor, word_count,
 			char_count_cursor, char_count,
 			byte_count_cursor, byte_count);
@@ -6390,24 +6468,26 @@ cursor_pos_info()
 	else
 #endif
 	{
 	    p = ml_get_curline();
 	    validate_virtcol();
-	    col_print(buf1, (int)curwin->w_cursor.col + 1,
+	    col_print(buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
 		    (int)curwin->w_virtcol + 1);
-	    col_print(buf2, (int)STRLEN(p), linetabsize(p));
+	    col_print(buf2, sizeof(buf2), (int)STRLEN(p), linetabsize(p));
 
 	    if (char_count_cursor == byte_count_cursor
 		    && char_count == byte_count)
-		sprintf((char *)IObuff, _("Col %s of %s; Line %ld of %ld; Word %ld of %ld; Byte %ld of %ld"),
+		vim_snprintf((char *)IObuff, IOSIZE,
+		    _("Col %s of %s; Line %ld of %ld; Word %ld of %ld; Byte %ld of %ld"),
 		    (char *)buf1, (char *)buf2,
 		    (long)curwin->w_cursor.lnum,
 		    (long)curbuf->b_ml.ml_line_count,
 		    word_count_cursor, word_count,
 		    byte_count_cursor, byte_count);
 	    else
-		sprintf((char *)IObuff, _("Col %s of %s; Line %ld of %ld; Word %ld of %ld; Char %ld of %ld; Byte %ld of %ld"),
+		vim_snprintf((char *)IObuff, IOSIZE,
+		    _("Col %s of %s; Line %ld of %ld; Word %ld of %ld; Char %ld of %ld; Byte %ld of %ld"),
 		    (char *)buf1, (char *)buf2,
 		    (long)curwin->w_cursor.lnum,
 		    (long)curbuf->b_ml.ml_line_count,
 		    word_count_cursor, word_count,
 		    char_count_cursor, char_count,
--- vim72.orig/src/option.c
+++ vim72/src/option.c
@@ -385,10 +385,13 @@ struct vimoption
     idopt_T	indir;		/* global option: PV_NONE;
 				 * local option: indirect option index */
     char_u	*def_val[2];	/* default values for variable (vi and vim) */
 #ifdef FEAT_EVAL
     scid_T	scriptID;	/* script in which the option was last set */
+# define SCRIPTID_INIT , 0
+#else
+# define SCRIPTID_INIT
 #endif
 };
 
 #define VI_DEFAULT  0	    /* def_val[VI_DEFAULT] is Vi default value */
 #define VIM_DEFAULT 1	    /* def_val[VIM_DEFAULT] is Vim default value */
@@ -398,12 +401,13 @@ struct vimoption
  */
 #define P_BOOL		0x01	/* the option is boolean */
 #define P_NUM		0x02	/* the option is numeric */
 #define P_STRING	0x04	/* the option is a string */
 #define P_ALLOCED	0x08	/* the string option is in allocated memory,
-				    must use vim_free() when assigning new
-				    value. Not set if default is the same. */
+				   must use free_string_option() when
+				   assigning new value. Not set if default is
+				   the same. */
 #define P_EXPAND	0x10	/* environment expansion.  NOTE: P_EXPAND can
 				   never be used for local or hidden options! */
 #define P_NODEFAULT	0x40	/* don't set to default value */
 #define P_DEF_ALLOCED	0x80	/* default value is in allocated memory, must
 				    use vim_free() when assigning new value */
@@ -475,263 +479,263 @@ static struct vimoption
 #if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
 			    (char_u *)128L,
 #else
 			    (char_u *)224L,
 #endif
-					    (char_u *)0L}},
+					    (char_u *)0L} SCRIPTID_INIT},
     {"antialias",   "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
 #if defined(FEAT_GUI) && defined(MACOS_X)
 			    (char_u *)&p_antialias, PV_NONE,
 			    {(char_u *)FALSE, (char_u *)FALSE}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)FALSE, (char_u *)FALSE}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"arabic",	    "arab", P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_ARABIC
 			    (char_u *)VAR_WIN, PV_ARAB,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
 #ifdef FEAT_ARABIC
 			    (char_u *)&p_arshape, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"allowrevins", "ari",  P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_RIGHTLEFT
 			    (char_u *)&p_ari, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"altkeymap",   "akm",  P_BOOL|P_VI_DEF,
 #ifdef FEAT_FKMAP
 			    (char_u *)&p_altkeymap, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"ambiwidth",  "ambw",  P_STRING|P_VI_DEF|P_RCLR,
 #if defined(FEAT_MBYTE)
 			    (char_u *)&p_ambw, PV_NONE,
 			    {(char_u *)"single", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
 #ifdef FEAT_AUTOCHDIR
     {"autochdir",  "acd",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_acd, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
 #endif
     {"autoindent",  "ai",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_ai, PV_AI,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"autoprint",   "ap",   P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"autoread",    "ar",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_ar, PV_AR,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"autowrite",   "aw",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_aw, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"autowriteall","awa",  P_BOOL|P_VI_DEF,
 			    (char_u *)&p_awa, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"background",  "bg",   P_STRING|P_VI_DEF|P_RCLR,
 			    (char_u *)&p_bg, PV_NONE,
 			    {
 #if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
 			    (char_u *)"dark",
 #else
 			    (char_u *)"light",
 #endif
-					    (char_u *)0L}},
+					    (char_u *)0L} SCRIPTID_INIT},
     {"backspace",   "bs",   P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP,
 			    (char_u *)&p_bs, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"backup",	    "bk",   P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_bk, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"backupcopy",  "bkc",  P_STRING|P_VIM|P_COMMA|P_NODUP,
 			    (char_u *)&p_bkc, PV_NONE,
 #ifdef UNIX
 			    {(char_u *)"yes", (char_u *)"auto"}
 #else
 			    {(char_u *)"auto", (char_u *)"auto"}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"backupdir",   "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
 			    (char_u *)&p_bdir, PV_NONE,
-			    {(char_u *)DFLT_BDIR, (char_u *)0L}},
+			    {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
     {"backupext",   "bex",  P_STRING|P_VI_DEF|P_NFNAME,
 			    (char_u *)&p_bex, PV_NONE,
 			    {
 #ifdef VMS
 			    (char_u *)"_",
 #else
 			    (char_u *)"~",
 #endif
-					    (char_u *)0L}},
+					    (char_u *)0L} SCRIPTID_INIT},
     {"backupskip",  "bsk",  P_STRING|P_VI_DEF|P_COMMA,
 #ifdef FEAT_WILDIGN
 			    (char_u *)&p_bsk, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
 #ifdef FEAT_BEVAL
     {"balloondelay","bdlay",P_NUM|P_VI_DEF,
 			    (char_u *)&p_bdlay, PV_NONE,
-			    {(char_u *)600L, (char_u *)0L}},
+			    {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
     {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
 			    (char_u *)&p_beval, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
 # ifdef FEAT_EVAL
     {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
 			    (char_u *)&p_bexpr, PV_BEXPR,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
 # endif
 #endif
     {"beautify",    "bf",   P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"binary",	    "bin",  P_BOOL|P_VI_DEF|P_RSTAT,
 			    (char_u *)&p_bin, PV_BIN,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"bioskey",	    "biosk",P_BOOL|P_VI_DEF,
 #ifdef MSDOS
 			    (char_u *)&p_biosk, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"bomb",	    NULL,   P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
 #ifdef FEAT_MBYTE
 			    (char_u *)&p_bomb, PV_BOMB,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"breakat",	    "brk",  P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
 #ifdef FEAT_LINEBREAK
 			    (char_u *)&p_breakat, PV_NONE,
 			    {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"browsedir",   "bsdir",P_STRING|P_VI_DEF,
 #ifdef FEAT_BROWSE
 			    (char_u *)&p_bsdir, PV_NONE,
 			    {(char_u *)"last", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"bufhidden",   "bh",   P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
 #if defined(FEAT_QUICKFIX)
 			    (char_u *)&p_bh, PV_BH,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"buflisted",   "bl",   P_BOOL|P_VI_DEF|P_NOGLOB,
 			    (char_u *)&p_bl, PV_BL,
 			    {(char_u *)1L, (char_u *)0L}
-			    },
+			    SCRIPTID_INIT},
     {"buftype",	    "bt",   P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
 #if defined(FEAT_QUICKFIX)
 			    (char_u *)&p_bt, PV_BT,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"casemap",	    "cmp",   P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_MBYTE
 			    (char_u *)&p_cmp, PV_NONE,
 			    {(char_u *)"internal,keepascii", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"cdpath",	    "cd",   P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_SEARCHPATH
 			    (char_u *)&p_cdpath, PV_NONE,
 			    {(char_u *)",,", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"cedit",	    NULL,   P_STRING,
 #ifdef FEAT_CMDWIN
 			    (char_u *)&p_cedit, PV_NONE,
 			    {(char_u *)"", (char_u *)CTRL_F_STR}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"charconvert",  "ccv", P_STRING|P_VI_DEF|P_SECURE,
 #if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
 			    (char_u *)&p_ccv, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"cindent",	    "cin",  P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_CINDENT
 			    (char_u *)&p_cin, PV_CIN,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"cinkeys",	    "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_CINDENT
 			    (char_u *)&p_cink, PV_CINK,
 			    {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"cinoptions",  "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_CINDENT
 			    (char_u *)&p_cino, PV_CINO,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"cinwords",    "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
 			    (char_u *)&p_cinw, PV_CINW,
 			    {(char_u *)"if,else,while,do,for,switch",
 				(char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"clipboard",   "cb",   P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_CLIPBOARD
 			    (char_u *)&p_cb, PV_NONE,
 # ifdef FEAT_XCLIPBOARD
 			    {(char_u *)"autoselect,exclude:cons\\|linux",
@@ -741,435 +745,440 @@ static struct vimoption
 # endif
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"cmdheight",   "ch",   P_NUM|P_VI_DEF|P_RALL,
 			    (char_u *)&p_ch, PV_NONE,
-			    {(char_u *)1L, (char_u *)0L}},
+			    {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
     {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
 #ifdef FEAT_CMDWIN
 			    (char_u *)&p_cwh, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)7L, (char_u *)0L}},
+			    {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
     {"columns",	    "co",   P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
 			    (char_u *)&Columns, PV_NONE,
-			    {(char_u *)80L, (char_u *)0L}},
+			    {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
     {"comments",    "com",  P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_COMMENTS
 			    (char_u *)&p_com, PV_COM,
 			    {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
 				(char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF,
 #ifdef FEAT_FOLDING
 			    (char_u *)&p_cms, PV_CMS,
 			    {(char_u *)"/*%s*/", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
 			    /* P_PRI_MKRC isn't needed here, optval_default()
 			     * always returns TRUE for 'compatible' */
     {"compatible",  "cp",   P_BOOL|P_RALL,
 			    (char_u *)&p_cp, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)FALSE}},
+			    {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
     {"complete",    "cpt",  P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_INS_EXPAND
 			    (char_u *)&p_cpt, PV_CPT,
 			    {(char_u *)".,w,b,u,t,i", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
 #ifdef FEAT_COMPL_FUNC
 			    (char_u *)&p_cfu, PV_CFU,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"completeopt",   "cot",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_INS_EXPAND
 			    (char_u *)&p_cot, PV_NONE,
 			    {(char_u *)"menu,preview", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"confirm",     "cf",   P_BOOL|P_VI_DEF,
 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
 			    (char_u *)&p_confirm, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"conskey",	    "consk",P_BOOL|P_VI_DEF,
 #ifdef MSDOS
 			    (char_u *)&p_consk, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"copyindent",  "ci",   P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_ci, PV_CI,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"cpoptions",   "cpo",  P_STRING|P_VIM|P_RALL|P_FLAGLIST,
 			    (char_u *)&p_cpo, PV_NONE,
-			    {(char_u *)CPO_VI, (char_u *)CPO_VIM}},
+			    {(char_u *)CPO_VI, (char_u *)CPO_VIM}
+			    SCRIPTID_INIT},
     {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
 #ifdef FEAT_CSCOPE
 			    (char_u *)&p_cspc, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"cscopeprg",   "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 #ifdef FEAT_CSCOPE
 			    (char_u *)&p_csprg, PV_NONE,
 			    {(char_u *)"cscope", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
 			    (char_u *)&p_csqf, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"cscopetag",   "cst",  P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_CSCOPE
 			    (char_u *)&p_cst, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
 #ifdef FEAT_CSCOPE
 			    (char_u *)&p_csto, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_CSCOPE
 			    (char_u *)&p_csverbose, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
 #ifdef FEAT_SYN_HL
 			    (char_u *)VAR_WIN, PV_CUC,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"cursorline",   "cul", P_BOOL|P_VI_DEF|P_RWIN,
 #ifdef FEAT_SYN_HL
 			    (char_u *)VAR_WIN, PV_CUL,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"debug",	    NULL,   P_STRING|P_VI_DEF,
 			    (char_u *)&p_debug, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"define",	    "def",  P_STRING|P_ALLOCED|P_VI_DEF,
 #ifdef FEAT_FIND_ID
 			    (char_u *)&p_def, PV_DEF,
 			    {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"delcombine", "deco",  P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_MBYTE
 			    (char_u *)&p_deco, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"dictionary",  "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_INS_EXPAND
 			    (char_u *)&p_dict, PV_DICT,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"diff",	    NULL,   P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
 #ifdef FEAT_DIFF
 			    (char_u *)VAR_WIN, PV_DIFF,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"diffexpr",    "dex",  P_STRING|P_VI_DEF|P_SECURE,
 #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
 			    (char_u *)&p_dex, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"diffopt",	    "dip",  P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP,
 #ifdef FEAT_DIFF
 			    (char_u *)&p_dip, PV_NONE,
 			    {(char_u *)"filler", (char_u *)NULL}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)"", (char_u *)NULL}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"digraph",	    "dg",   P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_DIGRAPHS
 			    (char_u *)&p_dg, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"directory",   "dir",  P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
 			    (char_u *)&p_dir, PV_NONE,
-			    {(char_u *)DFLT_DIR, (char_u *)0L}},
+			    {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
     {"display",	    "dy",   P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP,
 			    (char_u *)&p_dy, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"eadirection", "ead",  P_STRING|P_VI_DEF,
 #ifdef FEAT_VERTSPLIT
 			    (char_u *)&p_ead, PV_NONE,
 			    {(char_u *)"both", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"edcompatible","ed",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_ed, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"encoding",    "enc",  P_STRING|P_VI_DEF|P_RCLR,
 #ifdef FEAT_MBYTE
 			    (char_u *)&p_enc, PV_NONE,
 			    {(char_u *)ENC_DFLT, (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"endofline",   "eol",  P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
 			    (char_u *)&p_eol, PV_EOL,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"equalalways", "ea",   P_BOOL|P_VI_DEF|P_RALL,
 			    (char_u *)&p_ea, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"equalprg",    "ep",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_ep, PV_EP,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"errorbells",  "eb",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_eb, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"errorfile",   "ef",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 #ifdef FEAT_QUICKFIX
 			    (char_u *)&p_ef, PV_NONE,
 			    {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"errorformat", "efm",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_QUICKFIX
 			    (char_u *)&p_efm, PV_EFM,
-			    {(char_u *)DFLT_EFM, (char_u *)0L},
+			    {(char_u *)DFLT_EFM, (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"esckeys",	    "ek",   P_BOOL|P_VIM,
 			    (char_u *)&p_ek, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)TRUE}},
+			    {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
     {"eventignore", "ei",   P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_AUTOCMD
 			    (char_u *)&p_ei, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"expandtab",   "et",   P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_et, PV_ET,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"exrc",	    "ex",   P_BOOL|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_exrc, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC,
 #ifdef FEAT_MBYTE
 			    (char_u *)&p_fenc, PV_FENC,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA,
 #ifdef FEAT_MBYTE
 			    (char_u *)&p_fencs, PV_NONE,
 			    {(char_u *)"ucs-bom", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"fileformat",  "ff",   P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC,
 			    (char_u *)&p_ff, PV_FF,
-			    {(char_u *)DFLT_FF, (char_u *)0L}},
+			    {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
     {"fileformats", "ffs",  P_STRING|P_VIM|P_COMMA|P_NODUP,
 			    (char_u *)&p_ffs, PV_NONE,
-			    {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}},
+			    {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
+			    SCRIPTID_INIT},
     {"filetype",    "ft",   P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
 #ifdef FEAT_AUTOCMD
 			    (char_u *)&p_ft, PV_FT,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"fillchars",   "fcs",  P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
 #if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
 			    (char_u *)&p_fcs, PV_NONE,
 			    {(char_u *)"vert:|,fold:-", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"fkmap",	    "fk",   P_BOOL|P_VI_DEF,
 #ifdef FEAT_FKMAP
 			    (char_u *)&p_fkmap, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"flash",	    "fl",   P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
 #ifdef FEAT_FOLDING
     {"foldclose",   "fcl",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
 			    (char_u *)&p_fcl, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"foldcolumn",  "fdc",  P_NUM|P_VI_DEF|P_RWIN,
 			    (char_u *)VAR_WIN, PV_FDC,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"foldenable",  "fen",  P_BOOL|P_VI_DEF|P_RWIN,
 			    (char_u *)VAR_WIN, PV_FEN,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"foldexpr",    "fde",  P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
 # ifdef FEAT_EVAL
 			    (char_u *)VAR_WIN, PV_FDE,
 			    {(char_u *)"0", (char_u *)NULL}
 # else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 # endif
-			    },
+			    SCRIPTID_INIT},
     {"foldignore",  "fdi",  P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
 			    (char_u *)VAR_WIN, PV_FDI,
-			    {(char_u *)"#", (char_u *)NULL}},
+			    {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
     {"foldlevel",   "fdl",  P_NUM|P_VI_DEF|P_RWIN,
 			    (char_u *)VAR_WIN, PV_FDL,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"foldlevelstart","fdls", P_NUM|P_VI_DEF,
 			    (char_u *)&p_fdls, PV_NONE,
-			    {(char_u *)-1L, (char_u *)0L}},
+			    {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
     {"foldmarker",  "fmr",  P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
 						       P_RWIN|P_COMMA|P_NODUP,
 			    (char_u *)VAR_WIN, PV_FMR,
-			    {(char_u *)"{{{,}}}", (char_u *)NULL}},
+			    {(char_u *)"{{{,}}}", (char_u *)NULL}
+			    SCRIPTID_INIT},
     {"foldmethod",  "fdm",  P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
 			    (char_u *)VAR_WIN, PV_FDM,
-			    {(char_u *)"manual", (char_u *)NULL}},
+			    {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
     {"foldminlines","fml",  P_NUM|P_VI_DEF|P_RWIN,
 			    (char_u *)VAR_WIN, PV_FML,
-			    {(char_u *)1L, (char_u *)0L}},
+			    {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
     {"foldnestmax", "fdn",  P_NUM|P_VI_DEF|P_RWIN,
 			    (char_u *)VAR_WIN, PV_FDN,
-			    {(char_u *)20L, (char_u *)0L}},
+			    {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
     {"foldopen",    "fdo",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 			    (char_u *)&p_fdo, PV_NONE,
 		 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
-							       (char_u *)0L}},
+						 (char_u *)0L} SCRIPTID_INIT},
     {"foldtext",    "fdt",  P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
 # ifdef FEAT_EVAL
 			    (char_u *)VAR_WIN, PV_FDT,
 			    {(char_u *)"foldtext()", (char_u *)NULL}
 # else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 # endif
-			    },
+			    SCRIPTID_INIT},
 #endif
     {"formatexpr", "fex",   P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
 #ifdef FEAT_EVAL
 			    (char_u *)&p_fex, PV_FEX,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"formatoptions","fo",  P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
 			    (char_u *)&p_fo, PV_FO,
-			    {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}},
+			    {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
+			    SCRIPTID_INIT},
     {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
 			    (char_u *)&p_flp, PV_FLP,
-			    {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*", (char_u *)0L}},
+			    {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
+						 (char_u *)0L} SCRIPTID_INIT},
     {"formatprg",   "fp",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_fp, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"fsync",       "fs",   P_BOOL|P_SECURE|P_VI_DEF,
 #ifdef HAVE_FSYNC
 			    (char_u *)&p_fs, PV_NONE,
 			    {(char_u *)TRUE, (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)FALSE, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"gdefault",    "gd",   P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_gd, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"graphic",	    "gr",   P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"grepformat",  "gfm",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_QUICKFIX
 			    (char_u *)&p_gefm, PV_NONE,
-			    {(char_u *)DFLT_GREPFORMAT, (char_u *)0L},
+			    {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"grepprg",	    "gp",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 #ifdef FEAT_QUICKFIX
 			    (char_u *)&p_gp, PV_GP,
 			    {
 # ifdef WIN3264
@@ -1183,19 +1192,19 @@ static struct vimoption
 #  else
 #   ifdef VMS
 			    (char_u *)"SEARCH/NUMBERS ",
 #   else
 			    (char_u *)"grep -n ",
-#endif
-#endif
+#   endif
+#  endif
 # endif
-			    (char_u *)0L},
+			    (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"guicursor",    "gcr",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef CURSOR_SHAPE
 			    (char_u *)&p_guicursor, PV_NONE,
 			    {
 # ifdef FEAT_GUI
@@ -1206,45 +1215,45 @@ static struct vimoption
 				    (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-				    },
+			    SCRIPTID_INIT},
     {"guifont",	    "gfn",  P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
 #ifdef FEAT_GUI
 			    (char_u *)&p_guifont, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-				    },
+			    SCRIPTID_INIT},
     {"guifontset",  "gfs",  P_STRING|P_VI_DEF|P_RCLR|P_COMMA,
 #if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
 			    (char_u *)&p_guifontset, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-				    },
+			    SCRIPTID_INIT},
     {"guifontwide", "gfw",  P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
 #if defined(FEAT_GUI) && defined(FEAT_MBYTE)
 			    (char_u *)&p_guifontwide, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-				    },
+			    SCRIPTID_INIT},
     {"guiheadroom", "ghr",  P_NUM|P_VI_DEF,
 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
 			    (char_u *)&p_ghr, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)50L, (char_u *)0L}},
+			    {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
     {"guioptions",  "go",   P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
 #if defined(FEAT_GUI)
 			    (char_u *)&p_go, PV_NONE,
 # if defined(UNIX) && !defined(MACOS)
 			    {(char_u *)"aegimrLtT", (char_u *)0L}
@@ -1253,115 +1262,117 @@ static struct vimoption
 # endif
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-				    },
+			    SCRIPTID_INIT},
     {"guipty",	    NULL,   P_BOOL|P_VI_DEF,
 #if defined(FEAT_GUI)
 			    (char_u *)&p_guipty, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"guitablabel",  "gtl", P_STRING|P_VI_DEF|P_RWIN,
 #if defined(FEAT_GUI_TABLINE)
 			    (char_u *)&p_gtl, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-				    },
+			    SCRIPTID_INIT},
     {"guitabtooltip",  "gtt", P_STRING|P_VI_DEF|P_RWIN,
 #if defined(FEAT_GUI_TABLINE)
 			    (char_u *)&p_gtt, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-				    },
+			    SCRIPTID_INIT},
     {"hardtabs",    "ht",   P_NUM|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"helpfile",    "hf",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_hf, PV_NONE,
-			    {(char_u *)DFLT_HELPFILE, (char_u *)0L}},
+			    {(char_u *)DFLT_HELPFILE, (char_u *)0L}
+			    SCRIPTID_INIT},
     {"helpheight",  "hh",   P_NUM|P_VI_DEF,
 #ifdef FEAT_WINDOWS
 			    (char_u *)&p_hh, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)20L, (char_u *)0L}},
+			    {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
     {"helplang",    "hlg",  P_STRING|P_VI_DEF|P_COMMA,
 #ifdef FEAT_MULTI_LANG
 			    (char_u *)&p_hlg, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-    },
+			    SCRIPTID_INIT},
     {"hidden",	    "hid",  P_BOOL|P_VI_DEF,
 			    (char_u *)&p_hid, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"highlight",   "hl",   P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
 			    (char_u *)&p_hl, PV_NONE,
-			    {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}},
+			    {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
+			    SCRIPTID_INIT},
     {"history",	    "hi",   P_NUM|P_VIM,
 			    (char_u *)&p_hi, PV_NONE,
-			    {(char_u *)0L, (char_u *)20L}},
+			    {(char_u *)0L, (char_u *)20L} SCRIPTID_INIT},
     {"hkmap",	    "hk",   P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_RIGHTLEFT
 			    (char_u *)&p_hkmap, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"hkmapp",	    "hkp",  P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_RIGHTLEFT
 			    (char_u *)&p_hkmapp, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"hlsearch",    "hls",  P_BOOL|P_VI_DEF|P_VIM|P_RALL,
 			    (char_u *)&p_hls, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"icon",	    NULL,   P_BOOL|P_VI_DEF,
 #ifdef FEAT_TITLE
 			    (char_u *)&p_icon, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"iconstring",  NULL,   P_STRING|P_VI_DEF,
 #ifdef FEAT_TITLE
 			    (char_u *)&p_iconstring, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"ignorecase",  "ic",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_ic, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"imactivatekey","imak",P_STRING|P_VI_DEF,
 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
 			    (char_u *)&p_imak, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"imcmdline",   "imc",  P_BOOL|P_VI_DEF,
 #ifdef USE_IM_CONTROL
 			    (char_u *)&p_imcmdline, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"imdisable",   "imd",  P_BOOL|P_VI_DEF,
 #ifdef USE_IM_CONTROL
 			    (char_u *)&p_imdisable, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
@@ -1369,72 +1380,72 @@ static struct vimoption
 #ifdef __sgi
 			    {(char_u *)TRUE, (char_u *)0L}
 #else
 			    {(char_u *)FALSE, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"iminsert",    "imi",  P_NUM|P_VI_DEF,
 			    (char_u *)&p_iminsert, PV_IMI,
 #ifdef B_IMODE_IM
 			    {(char_u *)B_IMODE_IM, (char_u *)0L}
 #else
 			    {(char_u *)B_IMODE_NONE, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"imsearch",    "ims",  P_NUM|P_VI_DEF,
 			    (char_u *)&p_imsearch, PV_IMS,
 #ifdef B_IMODE_IM
 			    {(char_u *)B_IMODE_IM, (char_u *)0L}
 #else
 			    {(char_u *)B_IMODE_NONE, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"include",	    "inc",  P_STRING|P_ALLOCED|P_VI_DEF,
 #ifdef FEAT_FIND_ID
 			    (char_u *)&p_inc, PV_INC,
 			    {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
 #if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
 			    (char_u *)&p_inex, PV_INEX,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"incsearch",   "is",   P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_is, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"indentexpr", "inde",  P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
 			    (char_u *)&p_inde, PV_INDE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"indentkeys", "indk",  P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
 #if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
 			    (char_u *)&p_indk, PV_INDK,
 			    {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"infercase",   "inf",  P_BOOL|P_VI_DEF,
 			    (char_u *)&p_inf, PV_INF,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"insertmode",  "im",   P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_im, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"isfname",	    "isf",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 			    (char_u *)&p_isf, PV_NONE,
 			    {
 #ifdef BACKSLASH_IN_FILENAME
 				/* Excluded are: & and ^ are special in cmd.exe
@@ -1453,11 +1464,11 @@ static struct vimoption
 			    (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
 #   endif
 #  endif
 # endif
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"isident",	    "isi",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 			    (char_u *)&p_isi, PV_NONE,
 			    {
 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
 			    (char_u *)"@,48-57,_,128-167,224-235",
@@ -1470,11 +1481,11 @@ static struct vimoption
 				    "251-254",
 # else
 			    (char_u *)"@,48-57,_,192-255",
 # endif
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"iskeyword",   "isk",  P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
 			    (char_u *)&p_isk, PV_ISK,
 			    {
 #ifdef EBCDIC
 			     (char_u *)"@,240-249,_",
@@ -1489,11 +1500,11 @@ static struct vimoption
 				(char_u *)"@,48-57,_,128-167,224-235"
 # else
 				ISK_LATIN1
 # endif
 #endif
-				}},
+			    } SCRIPTID_INIT},
     {"isprint",	    "isp",  P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
 			    (char_u *)&p_isp, PV_NONE,
 			    {
 #if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
 		|| (defined(MACOS) && !defined(MACOS_X)) \
@@ -1505,39 +1516,39 @@ static struct vimoption
 			    (char_u *)"63-255",
 # else
 			    ISP_LATIN1,
 # endif
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"joinspaces",  "js",   P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_js, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"key",	    NULL,   P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
 #ifdef FEAT_CRYPT
 			    (char_u *)&p_key, PV_KEY,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"keymap",	    "kmp",  P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
 #ifdef FEAT_KEYMAP
 			    (char_u *)&p_keymap, PV_KMAP,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #endif
-	},
+			    SCRIPTID_INIT},
     {"keymodel",    "km",   P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_VISUAL
 			    (char_u *)&p_km, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"keywordprg",  "kp",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_kp, PV_KP,
 			    {
 #if defined(MSDOS) || defined(MSWIN)
 			    (char_u *)":help",
@@ -1554,53 +1565,53 @@ static struct vimoption
 			    (char_u *)"man",
 #  endif
 # endif
 #endif
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"langmap",     "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_LANGMAP
 			    (char_u *)&p_langmap, PV_NONE,
 			    {(char_u *)"",	/* unmatched } */
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL,
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"langmenu",    "lm",   P_STRING|P_VI_DEF|P_NFNAME,
 #if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
 			    (char_u *)&p_lm, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"laststatus",  "ls",   P_NUM|P_VI_DEF|P_RALL,
 #ifdef FEAT_WINDOWS
 			    (char_u *)&p_ls, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)1L, (char_u *)0L}},
+			    {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
     {"lazyredraw",  "lz",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_lz, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"linebreak",   "lbr",  P_BOOL|P_VI_DEF|P_RWIN,
 #ifdef FEAT_LINEBREAK
 			    (char_u *)VAR_WIN, PV_LBR,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"lines",	    NULL,   P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
 			    (char_u *)&Rows, PV_NONE,
 			    {
 #if defined(MSDOS) || defined(WIN3264) || defined(OS2)
 			    (char_u *)25L,
 #else
 			    (char_u *)24L,
 #endif
-					    (char_u *)0L}},
+					    (char_u *)0L} SCRIPTID_INIT},
     {"linespace",   "lsp",  P_NUM|P_VI_DEF|P_RCLR,
 #ifdef FEAT_GUI
 			    (char_u *)&p_linespace, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
@@ -1608,53 +1619,53 @@ static struct vimoption
 #ifdef FEAT_GUI_W32
 			    {(char_u *)1L, (char_u *)0L}
 #else
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"lisp",	    NULL,   P_BOOL|P_VI_DEF,
 #ifdef FEAT_LISP
 			    (char_u *)&p_lisp, PV_LISP,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"lispwords",   "lw",   P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_LISP
 			    (char_u *)&p_lispwords, PV_NONE,
 			    {(char_u *)LISPWORD_VALUE, (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"list",	    NULL,   P_BOOL|P_VI_DEF|P_RWIN,
 			    (char_u *)VAR_WIN, PV_LIST,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"listchars",   "lcs",  P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
 			    (char_u *)&p_lcs, PV_NONE,
-			    {(char_u *)"eol:$", (char_u *)0L}},
+			    {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
     {"loadplugins", "lpl",  P_BOOL|P_VI_DEF,
 			    (char_u *)&p_lpl, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
 #ifdef FEAT_GUI_MAC
     {"macatsui",    NULL,   P_BOOL|P_VI_DEF|P_RCLR,
 			    (char_u *)&p_macatsui, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
 #endif
     {"magic",	    NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_magic, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"makeef",	    "mef",  P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 #ifdef FEAT_QUICKFIX
 			    (char_u *)&p_mef, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"makeprg",	    "mp",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 #ifdef FEAT_QUICKFIX
 			    (char_u *)&p_mp, PV_MP,
 # ifdef VMS
 			    {(char_u *)"MMS", (char_u *)0L}
@@ -1663,100 +1674,103 @@ static struct vimoption
 # endif
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"matchpairs",  "mps",  P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
 			    (char_u *)&p_mps, PV_MPS,
-			    {(char_u *)"(:),{:},[:]", (char_u *)0L}},
+			    {(char_u *)"(:),{:},[:]", (char_u *)0L}
+			    SCRIPTID_INIT},
     {"matchtime",   "mat",  P_NUM|P_VI_DEF,
 			    (char_u *)&p_mat, PV_NONE,
-			    {(char_u *)5L, (char_u *)0L}},
+			    {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
     {"maxcombine",  "mco",  P_NUM|P_VI_DEF,
 #ifdef FEAT_MBYTE
 			    (char_u *)&p_mco, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)2, (char_u *)0L}},
+			    {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
     {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
 #ifdef FEAT_EVAL
 			    (char_u *)&p_mfd, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)100L, (char_u *)0L}},
+			    {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
     {"maxmapdepth", "mmd",  P_NUM|P_VI_DEF,
 			    (char_u *)&p_mmd, PV_NONE,
-			    {(char_u *)1000L, (char_u *)0L}},
+			    {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
     {"maxmem",	    "mm",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_mm, PV_NONE,
-			    {(char_u *)DFLT_MAXMEM, (char_u *)0L}},
+			    {(char_u *)DFLT_MAXMEM, (char_u *)0L}
+			    SCRIPTID_INIT},
     {"maxmempattern","mmp", P_NUM|P_VI_DEF,
 			    (char_u *)&p_mmp, PV_NONE,
-			    {(char_u *)1000L, (char_u *)0L}},
+			    {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
     {"maxmemtot",   "mmt",  P_NUM|P_VI_DEF,
 			    (char_u *)&p_mmt, PV_NONE,
-			    {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}},
+			    {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
+			    SCRIPTID_INIT},
     {"menuitems",   "mis",  P_NUM|P_VI_DEF,
 #ifdef FEAT_MENU
 			    (char_u *)&p_mis, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)25L, (char_u *)0L}},
+			    {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
     {"mesg",	    NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"mkspellmem",  "msm",  P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
 #ifdef FEAT_SPELL
 			    (char_u *)&p_msm, PV_NONE,
 			    {(char_u *)"460000,2000,500", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-    },
+			    SCRIPTID_INIT},
     {"modeline",    "ml",   P_BOOL|P_VIM,
 			    (char_u *)&p_ml, PV_ML,
-			    {(char_u *)FALSE, (char_u *)TRUE}},
+			    {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
     {"modelines",   "mls",  P_NUM|P_VI_DEF,
 			    (char_u *)&p_mls, PV_NONE,
-			    {(char_u *)5L, (char_u *)0L}},
+			    {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
     {"modifiable",  "ma",   P_BOOL|P_VI_DEF|P_NOGLOB,
 			    (char_u *)&p_ma, PV_MA,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"modified",    "mod",  P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
 			    (char_u *)&p_mod, PV_MOD,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"more",	    NULL,   P_BOOL|P_VIM,
 			    (char_u *)&p_more, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)TRUE}},
+			    {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
     {"mouse",	    NULL,   P_STRING|P_VI_DEF|P_FLAGLIST,
 			    (char_u *)&p_mouse, PV_NONE,
 			    {
 #if defined(MSDOS) || defined(WIN3264)
 				(char_u *)"a",
 #else
 				(char_u *)"",
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"mousefocus",   "mousef", P_BOOL|P_VI_DEF,
 #ifdef FEAT_GUI
 			    (char_u *)&p_mousef, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"mousehide",   "mh",   P_BOOL|P_VI_DEF,
 #ifdef FEAT_GUI
 			    (char_u *)&p_mh, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"mousemodel",  "mousem", P_STRING|P_VI_DEF,
 			    (char_u *)&p_mousem, PV_NONE,
 			    {
 #if defined(MSDOS) || defined(MSWIN)
 				(char_u *)"popup",
@@ -1765,103 +1779,104 @@ static struct vimoption
 				(char_u *)"popup_setpos",
 # else
 				(char_u *)"extend",
 # endif
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"mouseshape",  "mouses",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_MOUSESHAPE
 			    (char_u *)&p_mouseshape, PV_NONE,
 			    {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"mousetime",   "mouset",	P_NUM|P_VI_DEF,
 			    (char_u *)&p_mouset, PV_NONE,
-			    {(char_u *)500L, (char_u *)0L}},
+			    {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
     {"mzquantum",  "mzq",   P_NUM,
 #ifdef FEAT_MZSCHEME
 			    (char_u *)&p_mzq, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)100L, (char_u *)100L}},
+			    {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
     {"novice",	    NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"nrformats",   "nf",   P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
 			    (char_u *)&p_nf, PV_NF,
-			    {(char_u *)"octal,hex", (char_u *)0L}},
+			    {(char_u *)"octal,hex", (char_u *)0L}
+			    SCRIPTID_INIT},
     {"number",	    "nu",   P_BOOL|P_VI_DEF|P_RWIN,
 			    (char_u *)VAR_WIN, PV_NU,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"numberwidth", "nuw",  P_NUM|P_RWIN|P_VIM,
 #ifdef FEAT_LINEBREAK
 			    (char_u *)VAR_WIN, PV_NUW,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)8L, (char_u *)4L}},
+			    {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
     {"omnifunc",    "ofu",  P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
 #ifdef FEAT_COMPL_FUNC
 			    (char_u *)&p_ofu, PV_OFU,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"open",	    NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"opendevice",  "odev", P_BOOL|P_VI_DEF,
 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
 			    (char_u *)&p_odev, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
 			    {(char_u *)FALSE, (char_u *)FALSE}
-			    },
+			    SCRIPTID_INIT},
     {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_opfunc, PV_NONE,
-			    {(char_u *)"", (char_u *)0L} },
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"optimize",    "opt",  P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"osfiletype",  "oft",  P_STRING|P_ALLOCED|P_VI_DEF,
 #ifdef FEAT_OSFILETYPE
 			    (char_u *)&p_oft, PV_OFT,
 			    {(char_u *)DFLT_OFT, (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"paragraphs",  "para", P_STRING|P_VI_DEF,
 			    (char_u *)&p_para, PV_NONE,
 			    {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"paste",	    NULL,   P_BOOL|P_VI_DEF|P_PRI_MKRC,
 			    (char_u *)&p_paste, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"pastetoggle", "pt",   P_STRING|P_VI_DEF,
 			    (char_u *)&p_pt, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"patchexpr",   "pex",  P_STRING|P_VI_DEF|P_SECURE,
 #if defined(FEAT_DIFF) && defined(FEAT_EVAL)
 			    (char_u *)&p_pex, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"patchmode",   "pm",   P_STRING|P_VI_DEF|P_NFNAME,
 			    (char_u *)&p_pm, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"path",	    "pa",   P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
 			    (char_u *)&p_path, PV_PATH,
 			    {
 #if defined AMIGA || defined MSDOS || defined MSWIN
 			    (char_u *)".,,",
@@ -1870,55 +1885,55 @@ static struct vimoption
 			    (char_u *)".,/emx/include,,",
 # else /* Unix, probably */
 			    (char_u *)".,/usr/include,,",
 # endif
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_pi, PV_PI,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"previewheight", "pvh", P_NUM|P_VI_DEF,
 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
 			    (char_u *)&p_pvh, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)12L, (char_u *)0L}},
+			    {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
     {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
 			    (char_u *)VAR_WIN, PV_PVW,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
 #ifdef FEAT_PRINTER
 			    (char_u *)&p_pdev, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"printencoding", "penc", P_STRING|P_VI_DEF,
 #ifdef FEAT_POSTSCRIPT
 			    (char_u *)&p_penc, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"printexpr", "pexpr",  P_STRING|P_VI_DEF,
 #ifdef FEAT_POSTSCRIPT
 			    (char_u *)&p_pexpr, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"printfont", "pfn",    P_STRING|P_VI_DEF,
 #ifdef FEAT_PRINTER
 			    (char_u *)&p_pfn, PV_NONE,
 			    {
 # ifdef MSWIN
@@ -1929,187 +1944,190 @@ static struct vimoption
 				(char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"printheader", "pheader",  P_STRING|P_VI_DEF|P_GETTEXT,
 #ifdef FEAT_PRINTER
 			    (char_u *)&p_header, PV_NONE,
 			    {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
    {"printmbcharset", "pmbcs",  P_STRING|P_VI_DEF,
 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
 			    (char_u *)&p_pmcs, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"printmbfont", "pmbfn",  P_STRING|P_VI_DEF,
 #if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
 			    (char_u *)&p_pmfn, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_PRINTER
 			    (char_u *)&p_popt, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"prompt",	    NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_prompt, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"pumheight",   "ph",   P_NUM|P_VI_DEF,
 #ifdef FEAT_INS_EXPAND
 			    (char_u *)&p_ph, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"quoteescape", "qe",   P_STRING|P_ALLOCED|P_VI_DEF,
 #ifdef FEAT_TEXTOBJ
 			    (char_u *)&p_qe, PV_QE,
 			    {(char_u *)"\\", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"readonly",    "ro",   P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
 			    (char_u *)&p_ro, PV_RO,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"redraw",	    NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"redrawtime",  "rdt",  P_NUM|P_VI_DEF,
 #ifdef FEAT_RELTIME
 			    (char_u *)&p_rdt, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)2000L, (char_u *)0L}},
+			    {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
     {"remap",	    NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_remap, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"report",	    NULL,   P_NUM|P_VI_DEF,
 			    (char_u *)&p_report, PV_NONE,
-			    {(char_u *)2L, (char_u *)0L}},
+			    {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
     {"restorescreen", "rs", P_BOOL|P_VI_DEF,
 #ifdef WIN3264
 			    (char_u *)&p_rs, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"revins",	    "ri",   P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_RIGHTLEFT
 			    (char_u *)&p_ri, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"rightleft",   "rl",   P_BOOL|P_VI_DEF|P_RWIN,
 #ifdef FEAT_RIGHTLEFT
 			    (char_u *)VAR_WIN, PV_RL,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
 #ifdef FEAT_RIGHTLEFT
 			    (char_u *)VAR_WIN, PV_RLC,
 			    {(char_u *)"search", (char_u *)NULL}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"ruler",	    "ru",   P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
 #ifdef FEAT_CMDL_INFO
 			    (char_u *)&p_ru, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"rulerformat", "ruf",  P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
 #ifdef FEAT_STL_OPT
 			    (char_u *)&p_ruf, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"runtimepath", "rtp",  P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE,
 			    (char_u *)&p_rtp, PV_NONE,
-			    {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}},
+			    {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
+			    SCRIPTID_INIT},
     {"scroll",	    "scr",  P_NUM|P_NO_MKRC|P_VI_DEF,
 			    (char_u *)VAR_WIN, PV_SCROLL,
-			    {(char_u *)12L, (char_u *)0L}},
+			    {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
     {"scrollbind",  "scb",  P_BOOL|P_VI_DEF,
 #ifdef FEAT_SCROLLBIND
 			    (char_u *)VAR_WIN, PV_SCBIND,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"scrolljump",  "sj",   P_NUM|P_VI_DEF|P_VIM,
 			    (char_u *)&p_sj, PV_NONE,
-			    {(char_u *)1L, (char_u *)0L}},
+			    {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
     {"scrolloff",   "so",   P_NUM|P_VI_DEF|P_VIM|P_RALL,
 			    (char_u *)&p_so, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"scrollopt",   "sbo",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_SCROLLBIND
 			    (char_u *)&p_sbo, PV_NONE,
 			    {(char_u *)"ver,jump", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"sections",    "sect", P_STRING|P_VI_DEF,
 			    (char_u *)&p_sections, PV_NONE,
-			    {(char_u *)"SHNHH HUnhsh", (char_u *)0L}},
+			    {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
+			    SCRIPTID_INIT},
     {"secure",	    NULL,   P_BOOL|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_secure, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"selection",   "sel",  P_STRING|P_VI_DEF,
 #ifdef FEAT_VISUAL
 			    (char_u *)&p_sel, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"inclusive", (char_u *)0L}},
+			    {(char_u *)"inclusive", (char_u *)0L}
+			    SCRIPTID_INIT},
     {"selectmode",  "slm",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_VISUAL
 			    (char_u *)&p_slm, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_SESSION
 			    (char_u *)&p_ssop, PV_NONE,
 	 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
 							       (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"shell",	    "sh",   P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_sh, PV_NONE,
 			    {
 #ifdef VMS
 			    (char_u *)"-",
@@ -2134,11 +2152,11 @@ static struct vimoption
 #    endif
 #   endif
 #  endif
 # endif
 #endif /* VMS */
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_shcf, PV_NONE,
 			    {
 #if defined(MSDOS) || defined(MSWIN)
 			    (char_u *)"/c",
@@ -2147,11 +2165,11 @@ static struct vimoption
 			    (char_u *)"/c",
 # else
 			    (char_u *)"-c",
 # endif
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"shellpipe",   "sp",   P_STRING|P_VI_DEF|P_SECURE,
 #ifdef FEAT_QUICKFIX
 			    (char_u *)&p_sp, PV_NONE,
 			    {
 #if defined(UNIX) || defined(OS2)
@@ -2166,66 +2184,67 @@ static struct vimoption
 				(char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-    },
+			    SCRIPTID_INIT},
     {"shellquote",  "shq",  P_STRING|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_shq, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"shellredir",  "srr",  P_STRING|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_srr, PV_NONE,
-			    {(char_u *)">", (char_u *)0L}},
+			    {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
     {"shellslash",  "ssl",   P_BOOL|P_VI_DEF,
 #ifdef BACKSLASH_IN_FILENAME
 			    (char_u *)&p_ssl, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"shelltemp",   "stmp", P_BOOL,
 			    (char_u *)&p_stmp, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)TRUE}},
+			    {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
     {"shelltype",   "st",   P_NUM|P_VI_DEF,
 #ifdef AMIGA
 			    (char_u *)&p_st, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"shellxquote", "sxq",  P_STRING|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_sxq, PV_NONE,
 			    {
 #if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
 			    (char_u *)"\"",
 #else
 			    (char_u *)"",
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"shiftround",  "sr",   P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_sr, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"shiftwidth",  "sw",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_sw, PV_SW,
-			    {(char_u *)8L, (char_u *)0L}},
+			    {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
     {"shortmess",   "shm",  P_STRING|P_VIM|P_FLAGLIST,
 			    (char_u *)&p_shm, PV_NONE,
-			    {(char_u *)"", (char_u *)"filnxtToO"}},
+			    {(char_u *)"", (char_u *)"filnxtToO"}
+			    SCRIPTID_INIT},
     {"shortname",   "sn",   P_BOOL|P_VI_DEF,
 #ifdef SHORT_FNAME
 			    (char_u *)NULL, PV_NONE,
 #else
 			    (char_u *)&p_sn, PV_SN,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"showbreak",   "sbr",  P_STRING|P_VI_DEF|P_RALL,
 #ifdef FEAT_LINEBREAK
 			    (char_u *)&p_sbr, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"showcmd",	    "sc",   P_BOOL|P_VIM,
 #ifdef FEAT_CMDL_INFO
 			    (char_u *)&p_sc, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
@@ -2234,529 +2253,532 @@ static struct vimoption
 #ifdef UNIX
 				(char_u *)FALSE
 #else
 				(char_u *)TRUE
 #endif
-				}},
+				} SCRIPTID_INIT},
     {"showfulltag", "sft",  P_BOOL|P_VI_DEF,
 			    (char_u *)&p_sft, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"showmatch",   "sm",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_sm, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"showmode",    "smd",  P_BOOL|P_VIM,
 			    (char_u *)&p_smd, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)TRUE}},
+			    {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
     {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
 #ifdef FEAT_WINDOWS
 			    (char_u *)&p_stal, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)1L, (char_u *)0L}},
+			    {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
     {"sidescroll",  "ss",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_ss, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
 			    (char_u *)&p_siso, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"slowopen",    "slow", P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"smartcase",   "scs",  P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_scs, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"smartindent", "si",   P_BOOL|P_VI_DEF|P_VIM,
 #ifdef FEAT_SMARTINDENT
 			    (char_u *)&p_si, PV_SI,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"smarttab",    "sta",  P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_sta, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"softtabstop", "sts",  P_NUM|P_VI_DEF|P_VIM,
 			    (char_u *)&p_sts, PV_STS,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"sourceany",   NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"spell",	    NULL,   P_BOOL|P_VI_DEF|P_RWIN,
 #ifdef FEAT_SPELL
 			    (char_u *)VAR_WIN, PV_SPELL,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
 #ifdef FEAT_SPELL
 			    (char_u *)&p_spc, PV_SPC,
 			    {(char_u *)"[.?!]\\_[\\])'\"	 ]\\+", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"spellfile",   "spf",  P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA,
 #ifdef FEAT_SPELL
 			    (char_u *)&p_spf, PV_SPF,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"spelllang",   "spl",  P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND,
 #ifdef FEAT_SPELL
 			    (char_u *)&p_spl, PV_SPL,
 			    {(char_u *)"en", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_COMMA,
 #ifdef FEAT_SPELL
 			    (char_u *)&p_sps, PV_NONE,
 			    {(char_u *)"best", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-    },
+			    SCRIPTID_INIT},
     {"splitbelow",  "sb",   P_BOOL|P_VI_DEF,
 #ifdef FEAT_WINDOWS
 			    (char_u *)&p_sb, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"splitright",  "spr",  P_BOOL|P_VI_DEF,
 #ifdef FEAT_VERTSPLIT
 			    (char_u *)&p_spr, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"startofline", "sol",  P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_sol, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"statusline"  ,"stl",  P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
 #ifdef FEAT_STL_OPT
 			    (char_u *)&p_stl, PV_STL,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"suffixes",    "su",   P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 			    (char_u *)&p_su, PV_NONE,
 			    {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"suffixesadd", "sua",  P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP,
 #ifdef FEAT_SEARCHPATH
 			    (char_u *)&p_sua, PV_SUA,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"swapfile",    "swf",  P_BOOL|P_VI_DEF|P_RSTAT,
 			    (char_u *)&p_swf, PV_SWF,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"swapsync",    "sws",  P_STRING|P_VI_DEF,
 			    (char_u *)&p_sws, PV_NONE,
-			    {(char_u *)"fsync", (char_u *)0L}},
+			    {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
     {"switchbuf",   "swb",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 			    (char_u *)&p_swb, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"synmaxcol",   "smc",  P_NUM|P_VI_DEF|P_RBUF,
 #ifdef FEAT_SYN_HL
 			    (char_u *)&p_smc, PV_SMC,
 			    {(char_u *)3000L, (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"syntax",	    "syn",  P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
 #ifdef FEAT_SYN_HL
 			    (char_u *)&p_syn, PV_SYN,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"tabline",	    "tal",  P_STRING|P_VI_DEF|P_RALL,
 #ifdef FEAT_STL_OPT
 			    (char_u *)&p_tal, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"tabpagemax",  "tpm",  P_NUM|P_VI_DEF,
 #ifdef FEAT_WINDOWS
 			    (char_u *)&p_tpm, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)10L, (char_u *)0L}},
+			    {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
     {"tabstop",	    "ts",   P_NUM|P_VI_DEF|P_RBUF,
 			    (char_u *)&p_ts, PV_TS,
-			    {(char_u *)8L, (char_u *)0L}},
+			    {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
     {"tagbsearch",  "tbs",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_tbs, PV_NONE,
 #ifdef VMS	/* binary searching doesn't appear to work on VMS */
 			    {(char_u *)0L, (char_u *)0L}
 #else
 			    {(char_u *)TRUE, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"taglength",   "tl",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_tl, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"tagrelative", "tr",   P_BOOL|P_VIM,
 			    (char_u *)&p_tr, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)TRUE}},
+			    {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
     {"tags",	    "tag",  P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
 			    (char_u *)&p_tags, PV_TAGS,
 			    {
 #if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
 			    (char_u *)"./tags,./TAGS,tags,TAGS",
 #else
 			    (char_u *)"./tags,tags",
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"tagstack",    "tgst", P_BOOL|P_VI_DEF,
 			    (char_u *)&p_tgst, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"term",	    NULL,   P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
 			    (char_u *)&T_NAME, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"termbidi", "tbidi",   P_BOOL|P_VI_DEF,
 #ifdef FEAT_ARABIC
 			    (char_u *)&p_tbidi, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
 #ifdef FEAT_MBYTE
 			    (char_u *)&p_tenc, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"terse",	    NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_terse, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"textauto",    "ta",   P_BOOL|P_VIM,
 			    (char_u *)&p_ta, PV_NONE,
-			    {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}},
+			    {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
+			    SCRIPTID_INIT},
     {"textmode",    "tx",   P_BOOL|P_VI_DEF|P_NO_MKRC,
 			    (char_u *)&p_tx, PV_TX,
 			    {
 #ifdef USE_CRNL
 			    (char_u *)TRUE,
 #else
 			    (char_u *)FALSE,
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"textwidth",   "tw",   P_NUM|P_VI_DEF|P_VIM,
 			    (char_u *)&p_tw, PV_TW,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"thesaurus",   "tsr",  P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_INS_EXPAND
 			    (char_u *)&p_tsr, PV_TSR,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"tildeop",	    "top",  P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_to, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"timeout",	    "to",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_timeout, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"timeoutlen",  "tm",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_tm, PV_NONE,
-			    {(char_u *)1000L, (char_u *)0L}},
+			    {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
     {"title",	    NULL,   P_BOOL|P_VI_DEF,
 #ifdef FEAT_TITLE
 			    (char_u *)&p_title, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"titlelen",    NULL,   P_NUM|P_VI_DEF,
 #ifdef FEAT_TITLE
 			    (char_u *)&p_titlelen, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)85L, (char_u *)0L}},
+			    {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
     {"titleold",    NULL,   P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
 #ifdef FEAT_TITLE
 			    (char_u *)&p_titleold, PV_NONE,
 			    {(char_u *)N_("Thanks for flying Vim"),
 							       (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"titlestring", NULL,   P_STRING|P_VI_DEF,
 #ifdef FEAT_TITLE
 			    (char_u *)&p_titlestring, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
 #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
     {"toolbar",     "tb",   P_STRING|P_COMMA|P_VI_DEF|P_NODUP,
 			    (char_u *)&p_toolbar, PV_NONE,
-			    {(char_u *)"icons,tooltips", (char_u *)0L}},
+			    {(char_u *)"icons,tooltips", (char_u *)0L}
+			    SCRIPTID_INIT},
 #endif
 #if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
     {"toolbariconsize",	"tbis", P_STRING|P_VI_DEF,
 			    (char_u *)&p_tbis, PV_NONE,
-			    {(char_u *)"small", (char_u *)0L}},
+			    {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
 #endif
     {"ttimeout",    NULL,   P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_ttimeout, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"ttimeoutlen", "ttm",  P_NUM|P_VI_DEF,
 			    (char_u *)&p_ttm, PV_NONE,
-			    {(char_u *)-1L, (char_u *)0L}},
+			    {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
     {"ttybuiltin",  "tbi",  P_BOOL|P_VI_DEF,
 			    (char_u *)&p_tbi, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"ttyfast",	    "tf",   P_BOOL|P_NO_MKRC|P_VI_DEF,
 			    (char_u *)&p_tf, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"ttymouse",    "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
 #if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
 			    (char_u *)&p_ttym, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"ttyscroll",   "tsl",  P_NUM|P_VI_DEF,
 			    (char_u *)&p_ttyscroll, PV_NONE,
-			    {(char_u *)999L, (char_u *)0L}},
+			    {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
     {"ttytype",	    "tty",  P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
 			    (char_u *)&T_NAME, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"undolevels",  "ul",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_ul, PV_NONE,
 			    {
 #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
 			    (char_u *)1000L,
 #else
 			    (char_u *)100L,
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"updatecount", "uc",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_uc, PV_NONE,
-			    {(char_u *)200L, (char_u *)0L}},
+			    {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
     {"updatetime",  "ut",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_ut, PV_NONE,
-			    {(char_u *)4000L, (char_u *)0L}},
+			    {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
     {"verbose",	    "vbs",  P_NUM|P_VI_DEF,
 			    (char_u *)&p_verbose, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 			    (char_u *)&p_vfile, PV_NONE,
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"viewdir",     "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
 #ifdef FEAT_SESSION
 			    (char_u *)&p_vdir, PV_NONE,
 			    {(char_u *)DFLT_VDIR, (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"viewoptions", "vop",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_SESSION
 			    (char_u *)&p_vop, PV_NONE,
 			    {(char_u *)"folds,options,cursor", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"viminfo",	    "vi",   P_STRING|P_COMMA|P_NODUP|P_SECURE,
 #ifdef FEAT_VIMINFO
 			    (char_u *)&p_viminfo, PV_NONE,
 #if defined(MSDOS) || defined(MSWIN) || defined(OS2)
-			    {(char_u *)"", (char_u *)"'20,<50,s10,h,rA:,rB:"}
+			    {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
 #else
 # ifdef AMIGA
 			    {(char_u *)"",
-				 (char_u *)"'20,<50,s10,h,rdf0:,rdf1:,rdf2:"}
+				 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
 # else
-			    {(char_u *)"", (char_u *)"'20,<50,s10,h"}
+			    {(char_u *)"", (char_u *)"'100,<50,s10,h"}
 # endif
 #endif
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"virtualedit", "ve",   P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM,
 #ifdef FEAT_VIRTUALEDIT
 			    (char_u *)&p_ve, PV_NONE,
 			    {(char_u *)"", (char_u *)""}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)0L, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"visualbell",  "vb",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_vb, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"w300",	    NULL,   P_NUM|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"w1200",	    NULL,   P_NUM|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"w9600",	    NULL,   P_NUM|P_VI_DEF,
 			    (char_u *)NULL, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"warn",	    NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_warn, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"weirdinvert", "wiv",  P_BOOL|P_VI_DEF|P_RCLR,
 			    (char_u *)&p_wiv, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"whichwrap",   "ww",   P_STRING|P_VIM|P_COMMA|P_FLAGLIST,
 			    (char_u *)&p_ww, PV_NONE,
-			    {(char_u *)"", (char_u *)"b,s"}},
+			    {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
     {"wildchar",    "wc",   P_NUM|P_VIM,
 			    (char_u *)&p_wc, PV_NONE,
-			    {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}},
+			    {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
+			    SCRIPTID_INIT},
     {"wildcharm",   "wcm",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_wcm, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"wildignore",  "wig",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 #ifdef FEAT_WILDIGN
 			    (char_u *)&p_wig, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
     {"wildmenu",    "wmnu", P_BOOL|P_VI_DEF,
 #ifdef FEAT_WILDMENU
 			    (char_u *)&p_wmnu, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"wildmode",    "wim",  P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
 			    (char_u *)&p_wim, PV_NONE,
-			    {(char_u *)"full", (char_u *)0L}},
+			    {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
     {"wildoptions", "wop",  P_STRING|P_VI_DEF,
 #ifdef FEAT_CMDL_COMPL
 			    (char_u *)&p_wop, PV_NONE,
 			    {(char_u *)"", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"winaltkeys",  "wak",  P_STRING|P_VI_DEF,
 #ifdef FEAT_WAK
 			    (char_u *)&p_wak, PV_NONE,
 			    {(char_u *)"menu", (char_u *)0L}
 #else
 			    (char_u *)NULL, PV_NONE,
 			    {(char_u *)NULL, (char_u *)0L}
 #endif
-			    },
+			    SCRIPTID_INIT},
     {"window",	    "wi",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_window, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"winheight",   "wh",   P_NUM|P_VI_DEF,
 #ifdef FEAT_WINDOWS
 			    (char_u *)&p_wh, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)1L, (char_u *)0L}},
+			    {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
     {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
 #ifdef FEAT_WINDOWS
 			    (char_u *)VAR_WIN, PV_WFH,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
 #ifdef FEAT_VERTSPLIT
 			    (char_u *)VAR_WIN, PV_WFW,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"winminheight", "wmh", P_NUM|P_VI_DEF,
 #ifdef FEAT_WINDOWS
 			    (char_u *)&p_wmh, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)1L, (char_u *)0L}},
+			    {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
     {"winminwidth", "wmw", P_NUM|P_VI_DEF,
 #ifdef FEAT_VERTSPLIT
 			    (char_u *)&p_wmw, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)1L, (char_u *)0L}},
+			    {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
     {"winwidth",   "wiw",   P_NUM|P_VI_DEF,
 #ifdef FEAT_VERTSPLIT
 			    (char_u *)&p_wiw, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
-			    {(char_u *)20L, (char_u *)0L}},
+			    {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
     {"wrap",	    NULL,   P_BOOL|P_VI_DEF|P_RWIN,
 			    (char_u *)VAR_WIN, PV_WRAP,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"wrapmargin",  "wm",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_wm, PV_WM,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
     {"wrapscan",    "ws",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_ws, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"write",	    NULL,   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_write, PV_NONE,
-			    {(char_u *)TRUE, (char_u *)0L}},
+			    {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
     {"writeany",    "wa",   P_BOOL|P_VI_DEF,
 			    (char_u *)&p_wa, PV_NONE,
-			    {(char_u *)FALSE, (char_u *)0L}},
+			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
     {"writebackup", "wb",   P_BOOL|P_VI_DEF|P_VIM,
 			    (char_u *)&p_wb, PV_NONE,
 			    {
 #ifdef FEAT_WRITEBACKUP
 			    (char_u *)TRUE,
 #else
 			    (char_u *)FALSE,
 #endif
-				(char_u *)0L}},
+				(char_u *)0L} SCRIPTID_INIT},
     {"writedelay",  "wd",   P_NUM|P_VI_DEF,
 			    (char_u *)&p_wd, PV_NONE,
-			    {(char_u *)0L, (char_u *)0L}},
+			    {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
 
 /* terminal output codes */
 #define p_term(sss, vvv)   {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
 			    (char_u *)&vvv, PV_NONE, \
-			    {(char_u *)"", (char_u *)0L}},
+			    {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
 
     p_term("t_AB", T_CAB)
     p_term("t_AF", T_CAF)
     p_term("t_AL", T_CAL)
     p_term("t_al", T_AL)
@@ -2813,11 +2835,12 @@ static struct vimoption
     p_term("t_ZH", T_CZH)
     p_term("t_ZR", T_CZR)
 
 /* terminal key codes are not in here */
 
-    {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL}}	/* end marker */
+    /* end marker */
+    {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
 };
 
 #define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
 
 #ifdef FEAT_MBYTE
@@ -3982,11 +4005,11 @@ do_set(arg, opt_flags)
 	    arg += 7;
 	}
 	else
 	{
 	    prefix = 1;
-	    if (STRNCMP(arg, "no", 2) == 0)
+	    if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
 	    {
 		prefix = 0;
 		arg += 2;
 	    }
 	    else if (STRNCMP(arg, "inv", 3) == 0)
@@ -4117,15 +4140,27 @@ do_set(arg, opt_flags)
 	    /* Skip all options that are window-local (used for :vimgrep). */
 	    if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
 					   && options[opt_idx].var == VAR_WIN)
 		goto skip;
 
-	    /* Disallow changing some options from modelines */
-	    if ((opt_flags & OPT_MODELINE) && (flags & P_SECURE))
+	    /* Disallow changing some options from modelines. */
+	    if (opt_flags & OPT_MODELINE)
 	    {
-		errmsg = (char_u *)_("E520: Not allowed in a modeline");
-		goto skip;
+		if (flags & P_SECURE)
+		{
+		    errmsg = (char_u *)_("E520: Not allowed in a modeline");
+		    goto skip;
+		}
+#ifdef FEAT_DIFF
+		/* In diff mode some options are overruled.  This avoids that
+		 * 'foldmethod' becomes "marker" instead of "diff" and that
+		 * "wrap" gets set. */
+		if (curwin->w_p_diff
+			&& (options[opt_idx].indir == PV_FDM
+			    || options[opt_idx].indir == PV_WRAP))
+		    goto skip;
+#endif
 	    }
 
 #ifdef HAVE_SANDBOX
 	    /* Disallow changing some options in the sandbox */
 	    if (sandbox != 0 && (flags & P_SECURE))
@@ -5266,25 +5301,39 @@ insecure_flag(opt_idx, opt_flags)
     /* Nothing special, return global flags field. */
     return &options[opt_idx].flags;
 }
 #endif
 
+#ifdef FEAT_TITLE
+static void redraw_titles __ARGS((void));
+
+/*
+ * Redraw the window title and/or tab page text later.
+ */
+static void redraw_titles()
+{
+    need_maketitle = TRUE;
+# ifdef FEAT_WINDOWS
+    redraw_tabline = TRUE;
+# endif
+}
+#endif
+
 /*
  * Set a string option to a new value (without checking the effect).
  * The string is copied into allocated memory.
  * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
  * When "set_sid" is zero set the scriptID to current_SID.  When "set_sid" is
  * SID_NONE don't set the scriptID.  Otherwise set the scriptID to "set_sid".
  */
-/*ARGSUSED*/
     void
 set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
     char_u	*name;
     int		opt_idx;
     char_u	*val;
     int		opt_flags;	/* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
-    int		set_sid;
+    int		set_sid UNUSED;
 {
     char_u	*s;
     char_u	**varp;
     int		both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
     int		idx = opt_idx;
@@ -5405,10 +5454,14 @@ did_set_string_option(opt_idx, varp, new
     char_u	*errmsg = NULL;
     char_u	*s, *p;
     int		did_chartab = FALSE;
     char_u	**gvarp;
     long_u	free_oldval = (options[opt_idx].flags & P_ALLOCED);
+#ifdef FEAT_GUI
+    /* set when changing an option that only requires a redraw in the GUI */
+    int		redraw_gui_only = FALSE;
+#endif
 
     /* Get the global option to compare with, otherwise we would have to check
      * two values for all local options. */
     gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
 
@@ -5666,11 +5719,11 @@ did_set_string_option(opt_idx, varp, new
 		errmsg = e_invarg;
 	    else
 	    {
 # ifdef FEAT_TITLE
 		/* May show a "+" in the title now. */
-		need_maketitle = TRUE;
+		redraw_titles();
 # endif
 		/* Add 'fileencoding' to the swap file. */
 		ml_setflags(curbuf);
 	    }
 	}
@@ -5685,11 +5738,11 @@ did_set_string_option(opt_idx, varp, new
 	    }
 	    if (varp == &p_enc)
 	    {
 		errmsg = mb_init();
 # ifdef FEAT_TITLE
-		need_maketitle = TRUE;
+		redraw_titles();
 # endif
 	    }
 	}
 
 # if defined(FEAT_GUI_GTK) && defined(HAVE_GTK2)
@@ -5764,18 +5817,32 @@ did_set_string_option(opt_idx, varp, new
     else if (varp == &curbuf->b_p_keymap)
     {
 	/* load or unload key mapping tables */
 	errmsg = keymap_init();
 
-	/* When successfully installed a new keymap switch on using it. */
-	if (*curbuf->b_p_keymap != NUL && errmsg == NULL)
+	if (errmsg == NULL)
 	{
-	    curbuf->b_p_iminsert = B_IMODE_LMAP;
-	    if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
-		curbuf->b_p_imsearch = B_IMODE_LMAP;
-	    set_iminsert_global();
-	    set_imsearch_global();
+	    if (*curbuf->b_p_keymap != NUL)
+	    {
+		/* Installed a new keymap, switch on using it. */
+		curbuf->b_p_iminsert = B_IMODE_LMAP;
+		if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
+		    curbuf->b_p_imsearch = B_IMODE_LMAP;
+	    }
+	    else
+	    {
+		/* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
+		if (curbuf->b_p_iminsert == B_IMODE_LMAP)
+		    curbuf->b_p_iminsert = B_IMODE_NONE;
+		if (curbuf->b_p_imsearch == B_IMODE_LMAP)
+		    curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
+	    }
+	    if ((opt_flags & OPT_LOCAL) == 0)
+	    {
+		set_iminsert_global();
+		set_imsearch_global();
+	    }
 # ifdef FEAT_WINDOWS
 	    status_redraw_curbuf();
 # endif
 	}
     }
@@ -5794,14 +5861,18 @@ did_set_string_option(opt_idx, varp, new
 	    if (get_fileformat(curbuf) == EOL_DOS)
 		curbuf->b_p_tx = TRUE;
 	    else
 		curbuf->b_p_tx = FALSE;
 #ifdef FEAT_TITLE
-	    need_maketitle = TRUE;
+	    redraw_titles();
 #endif
 	    /* update flag in swap file */
 	    ml_setflags(curbuf);
+	    /* Redraw needed when switching to/from "mac": a CR in the text
+	     * will be displayed differently. */
+	    if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
+		redraw_curbuf_later(NOT_VALID);
 	}
     }
 
     /* 'fileformats' */
     else if (varp == &p_ffs)
@@ -5975,19 +6046,27 @@ did_set_string_option(opt_idx, varp, new
     else if (istermoption(&options[opt_idx]) && full_screen)
     {
 	/* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
 	if (varp == &T_CCO)
 	{
-	    t_colors = atoi((char *)T_CCO);
-	    if (t_colors <= 1)
+	    int colors = atoi((char *)T_CCO);
+
+	    /* Only reinitialize colors if t_Co value has really changed to
+	     * avoid expensive reload of colorscheme if t_Co is set to the
+	     * same value multiple times. */
+	    if (colors != t_colors)
 	    {
-		if (new_value_alloced)
-		    vim_free(T_CCO);
-		T_CCO = empty_option;
+		t_colors = colors;
+		if (t_colors <= 1)
+		{
+		    if (new_value_alloced)
+			vim_free(T_CCO);
+		    T_CCO = empty_option;
+		}
+		/* We now have a different color setup, initialize it again. */
+		init_highlight(TRUE, FALSE);
 	    }
-	    /* We now have a different color setup, initialize it again. */
-	    init_highlight(TRUE, FALSE);
 	}
 	ttest(FALSE);
 	if (varp == &T_ME)
 	{
 	    out_str(T_ME);
@@ -6053,27 +6132,30 @@ did_set_string_option(opt_idx, varp, new
 		else
 # endif
 		    errmsg = (char_u *)N_("E596: Invalid font(s)");
 	    }
 	}
+	redraw_gui_only = TRUE;
     }
 # ifdef FEAT_XFONTSET
     else if (varp == &p_guifontset)
     {
 	if (STRCMP(p_guifontset, "*") == 0)
 	    errmsg = (char_u *)N_("E597: can't select fontset");
 	else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
 	    errmsg = (char_u *)N_("E598: Invalid fontset");
+	redraw_gui_only = TRUE;
     }
 # endif
 # ifdef FEAT_MBYTE
     else if (varp == &p_guifontwide)
     {
 	if (STRCMP(p_guifontwide, "*") == 0)
 	    errmsg = (char_u *)N_("E533: can't select wide font");
 	else if (gui_get_wide_font() == FAIL)
 	    errmsg = (char_u *)N_("E534: Invalid wide font");
+	redraw_gui_only = TRUE;
     }
 # endif
 #endif
 
 #ifdef CURSOR_SHAPE
@@ -6131,17 +6213,28 @@ did_set_string_option(opt_idx, varp, new
 #endif
 
 #ifdef FEAT_GUI
     /* 'guioptions' */
     else if (varp == &p_go)
+    {
 	gui_init_which_components(oldval);
+	redraw_gui_only = TRUE;
+    }
 #endif
 
 #if defined(FEAT_GUI_TABLINE)
     /* 'guitablabel' */
     else if (varp == &p_gtl)
+    {
 	redraw_tabline = TRUE;
+	redraw_gui_only = TRUE;
+    }
+    /* 'guitabtooltip' */
+    else if (varp == &p_gtt)
+    {
+	redraw_gui_only = TRUE;
+    }
 #endif
 
 #if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
     /* 'ttymouse' */
     else if (varp == &p_ttym)
@@ -6319,10 +6412,13 @@ did_set_string_option(opt_idx, varp, new
 		curwin->w_redr_status = TRUE;
 		redraw_later(VALID);
 	    }
 # endif
 	    curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
+# ifdef FEAT_TITLE
+	    redraw_titles();
+# endif
 	}
     }
 #endif
 
 #ifdef FEAT_STL_OPT
@@ -6488,11 +6584,15 @@ did_set_string_option(opt_idx, varp, new
     {
 	if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
 		|| *curwin->w_p_fdm == NUL)
 	    errmsg = e_invarg;
 	else
+	{
 	    foldUpdateAll(curwin);
+	    if (foldmethodIsDiff(curwin))
+		newFoldLevel();
+	}
     }
 # ifdef FEAT_EVAL
     /* 'foldexpr' */
     else if (varp == &curwin->w_p_fde)
     {
@@ -6715,11 +6815,15 @@ did_set_string_option(opt_idx, varp, new
     }
 #endif
 
     if (curwin->w_curswant != MAXCOL)
 	curwin->w_set_curswant = TRUE;  /* in case 'showbreak' changed */
-    check_redraw(options[opt_idx].flags);
+#ifdef FEAT_GUI
+    /* check redraw when it's not a GUI option or the GUI is active. */
+    if (!redraw_gui_only || gui.in_use)
+#endif
+	check_redraw(options[opt_idx].flags);
 
     return errmsg;
 }
 
 /*
@@ -6930,10 +7034,11 @@ check_stl_option(s)
 check_clipboard_option()
 {
     int		new_unnamed = FALSE;
     int		new_autoselect = FALSE;
     int		new_autoselectml = FALSE;
+    int		new_html = FALSE;
     regprog_T	*new_exclude_prog = NULL;
     char_u	*errmsg = NULL;
     char_u	*p;
 
     for (p = p_cb; *p != NUL; )
@@ -6953,10 +7058,15 @@ check_clipboard_option()
 					&& (p[12] == ',' || p[12] == NUL))
 	{
 	    new_autoselectml = TRUE;
 	    p += 12;
 	}
+	else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
+	{
+	    new_html = TRUE;
+	    p += 4;
+	}
 	else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
 	{
 	    p += 8;
 	    new_exclude_prog = vim_regcomp(p, RE_MAGIC);
 	    if (new_exclude_prog == NULL)
@@ -6974,10 +7084,11 @@ check_clipboard_option()
     if (errmsg == NULL)
     {
 	clip_unnamed = new_unnamed;
 	clip_autoselect = new_autoselect;
 	clip_autoselectml = new_autoselectml;
+	clip_html = new_html;
 	vim_free(clip_exclude_prog);
 	clip_exclude_prog = new_exclude_prog;
     }
     else
 	vim_free(new_exclude_prog);
@@ -7092,10 +7203,18 @@ set_bool_option(opt_idx, varp, value, op
     if ((int *)varp == &p_cp)
     {
 	compatible_set();
     }
 
+    /* 'list', 'number' */
+    else if ((int *)varp == &curwin->w_p_list
+	  || (int *)varp == &curwin->w_p_nu)
+    {
+	if (curwin->w_curswant != MAXCOL)
+	    curwin->w_set_curswant = TRUE;
+    }
+
     else if ((int *)varp == &curbuf->b_p_ro)
     {
 	/* when 'readonly' is reset globally, also reset readonlymode */
 	if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
 	    readonlymode = FALSE;
@@ -7103,34 +7222,40 @@ set_bool_option(opt_idx, varp, value, op
 	/* when 'readonly' is set may give W10 again */
 	if (curbuf->b_p_ro)
 	    curbuf->b_did_warn = FALSE;
 
 #ifdef FEAT_TITLE
-	need_maketitle = TRUE;
+	redraw_titles();
 #endif
     }
 
 #ifdef FEAT_TITLE
     /* when 'modifiable' is changed, redraw the window title */
     else if ((int *)varp == &curbuf->b_p_ma)
-	need_maketitle = TRUE;
+    {
+	redraw_titles();
+    }
     /* when 'endofline' is changed, redraw the window title */
     else if ((int *)varp == &curbuf->b_p_eol)
-	need_maketitle = TRUE;
-#ifdef FEAT_MBYTE
-    /* when 'bomb' is changed, redraw the window title */
+    {
+	redraw_titles();
+    }
+# ifdef FEAT_MBYTE
+    /* when 'bomb' is changed, redraw the window title and tab page text */
     else if ((int *)varp == &curbuf->b_p_bomb)
-	need_maketitle = TRUE;
-#endif
+    {
+	redraw_titles();
+    }
+# endif
 #endif
 
     /* when 'bin' is set also set some other options */
     else if ((int *)varp == &curbuf->b_p_bin)
     {
 	set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
 #ifdef FEAT_TITLE
-	need_maketitle = TRUE;
+	redraw_titles();
 #endif
     }
 
 #ifdef FEAT_AUTOCMD
     /* when 'buflisted' changes, trigger autocommands */
@@ -7277,11 +7402,11 @@ set_bool_option(opt_idx, varp, value, op
     else if ((int *)varp == &curbuf->b_changed)
     {
 	if (!value)
 	    save_file_ff(curbuf);	/* Buffer is unchanged */
 #ifdef FEAT_TITLE
-	need_maketitle = TRUE;
+	redraw_titles();
 #endif
 #ifdef FEAT_AUTOCMD
 	modified_was_set = value;
 #endif
     }
@@ -7314,10 +7439,12 @@ set_bool_option(opt_idx, varp, value, op
     /* If 'wrap' is set, set w_leftcol to zero. */
     else if ((int *)varp == &curwin->w_p_wrap)
     {
 	if (curwin->w_p_wrap)
 	    curwin->w_leftcol = 0;
+	if (curwin->w_curswant != MAXCOL)
+	    curwin->w_set_curswant = TRUE;
     }
 
 #ifdef FEAT_WINDOWS
     else if ((int *)varp == &p_ea)
     {
@@ -7484,13 +7611,17 @@ set_bool_option(opt_idx, varp, value, op
 
 	    /* Arabic requires a utf-8 encoding, inform the user if its not
 	     * set. */
 	    if (STRCMP(p_enc, "utf-8") != 0)
 	    {
+		static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
+
 		msg_source(hl_attr(HLF_W));
-		MSG_ATTR(_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'"),
-			hl_attr(HLF_W));
+		MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
+#ifdef FEAT_EVAL
+		set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
+#endif
 	    }
 
 # ifdef FEAT_MBYTE
 	    /* set 'delcombine' */
 	    p_deco = TRUE;
@@ -7533,22 +7664,45 @@ set_bool_option(opt_idx, varp, value, op
 	    /* Revert to the default keymap */
 	    curbuf->b_p_iminsert = B_IMODE_NONE;
 	    curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
 # endif
 	}
+	if (curwin->w_curswant != MAXCOL)
+	    curwin->w_set_curswant = TRUE;
+    }
+
+    else if ((int *)varp == &p_arshape)
+    {
+	if (curwin->w_curswant != MAXCOL)
+	    curwin->w_set_curswant = TRUE;
+    }
+#endif
+
+#ifdef FEAT_LINEBREAK
+    if ((int *)varp == &curwin->w_p_lbr)
+    {
+	if (curwin->w_curswant != MAXCOL)
+	    curwin->w_set_curswant = TRUE;
+    }
+#endif
+
+#ifdef FEAT_RIGHTLEFT
+    if ((int *)varp == &curwin->w_p_rl)
+    {
+	if (curwin->w_curswant != MAXCOL)
+	    curwin->w_set_curswant = TRUE;
     }
 #endif
 
     /*
      * End of handling side effects for bool options.
      */
 
     options[opt_idx].flags |= P_WAS_SET;
 
     comp_col();			    /* in case 'ruler' or 'showcmd' changed */
-    if (curwin->w_curswant != MAXCOL)
-	curwin->w_set_curswant = TRUE;  /* in case 'list' changed */
+
     check_redraw(options[opt_idx].flags);
 
     return NULL;
 }
 
@@ -7712,11 +7866,11 @@ set_num_option(opt_idx, varp, value, err
 	if (curwin->w_p_fdl < 0)
 	    curwin->w_p_fdl = 0;
 	newFoldLevel();
     }
 
-    /* 'foldminlevel' */
+    /* 'foldminlines' */
     else if (pp == &curwin->w_p_fml)
     {
 	foldUpdateAll(curwin);
     }
 
@@ -7972,10 +8126,15 @@ set_num_option(opt_idx, varp, value, err
 	else if (curwin->w_p_scr <= 0)
 	    curwin->w_p_scr = 1;
 	else /* curwin->w_p_scr > curwin->w_height */
 	    curwin->w_p_scr = curwin->w_height;
     }
+    if (p_hi < 0)
+    {
+	errmsg = e_positive;
+	p_hi = 0;
+    }
     if (p_report < 0)
     {
 	errmsg = e_positive;
 	p_report = 1;
     }
@@ -8225,17 +8384,17 @@ set_option_value(name, number, string, o
 	    varp = get_varp_scope(&(options[opt_idx]), opt_flags);
 	    if (varp != NULL)	/* hidden option is not changed */
 	    {
 		if (number == 0 && string != NULL)
 		{
-		    int index;
+		    int idx;
 
 		    /* Either we are given a string or we are setting option
 		     * to zero. */
-		    for (index = 0; string[index] == '0'; ++index)
+		    for (idx = 0; string[idx] == '0'; ++idx)
 			;
-		    if (string[index] != NUL || index == 0)
+		    if (string[idx] != NUL || idx == 0)
 		    {
 			/* There's another character after zeros or the string
 			 * is empty.  In both cases, we are trying to set a
 			 * num option using a string. */
 			EMSG3(_("E521: Number required: &%s = '%s'"),
@@ -8321,11 +8480,11 @@ find_key_option(arg)
 	key = TERMCAP2KEY(arg[2], arg[3]);
     else
     {
 	--arg;			    /* put arg at the '<' */
 	modifiers = 0;
-	key = find_special_key(&arg, &modifiers, TRUE);
+	key = find_special_key(&arg, &modifiers, TRUE, TRUE);
 	if (modifiers)		    /* can't handle modifiers here */
 	    key = 0;
     }
     return key;
 }
@@ -8811,10 +8970,32 @@ free_termoptions()
 	}
     clear_termcodes();
 }
 
 /*
+ * Free the string for one term option, if it was allocated.
+ * Set the string to empty_option and clear allocated flag.
+ * "var" points to the option value.
+ */
+    void
+free_one_termoption(var)
+    char_u *var;
+{
+    struct vimoption   *p;
+
+    for (p = &options[0]; p->fullname != NULL; p++)
+	if (p->var == var)
+	{
+	    if (p->flags & P_ALLOCED)
+		free_string_option(*(char_u **)(p->var));
+	    *(char_u **)(p->var) = empty_option;
+	    p->flags &= ~P_ALLOCED;
+	    break;
+	}
+}
+
+/*
  * Set the terminal option defaults to the current value.
  * Used after setting the terminal name.
  */
     void
 set_term_defaults()
@@ -9269,14 +9450,13 @@ check_win_options(win)
 }
 
 /*
  * Check for NULL pointers in a winopt_T and replace them with empty_option.
  */
-/*ARGSUSED*/
     void
 check_winopt(wop)
-    winopt_T	*wop;
+    winopt_T	*wop UNUSED;
 {
 #ifdef FEAT_FOLDING
     check_string_option(&wop->wo_fdi);
     check_string_option(&wop->wo_fdm);
 # ifdef FEAT_EVAL
@@ -9294,14 +9474,13 @@ check_winopt(wop)
 }
 
 /*
  * Free the allocated memory inside a winopt_T.
  */
-/*ARGSUSED*/
     void
 clear_winopt(wop)
-    winopt_T	*wop;
+    winopt_T	*wop UNUSED;
 {
 #ifdef FEAT_FOLDING
     clear_string_option(&wop->wo_fdi);
     clear_string_option(&wop->wo_fdm);
 # ifdef FEAT_EVAL
@@ -9643,11 +9822,11 @@ set_context_in_set_cmd(xp, arg, opt_flag
 	    ++p;
 	    break;
 	}
 	--p;
     }
-    if (STRNCMP(p, "no", 2) == 0)
+    if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
     {
 	xp->xp_context = EXPAND_BOOL_SETTINGS;
 	p += 2;
     }
     if (STRNCMP(p, "inv", 3) == 0)
@@ -9832,11 +10011,12 @@ ExpandSettings(xp, regmatch, num_file, f
     for (loop = 0; loop <= 1; ++loop)
     {
 	regmatch->rm_ic = ic;
 	if (xp->xp_context != EXPAND_BOOL_SETTINGS)
 	{
-	    for (match = 0; match < sizeof(names) / sizeof(char *); ++match)
+	    for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
+								      ++match)
 		if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
 		{
 		    if (loop == 0)
 			num_normal++;
 		    else
@@ -10091,29 +10271,114 @@ wc_use_keyname(varp, wcp)
     return FALSE;
 }
 
 #ifdef FEAT_LANGMAP
 /*
- * Any character has an equivalent character.  This is used for keyboards that
- * have a special language mode that sends characters above 128 (although
- * other characters can be translated too).
+ * Any character has an equivalent 'langmap' character.  This is used for
+ * keyboards that have a special language mode that sends characters above
+ * 128 (although other characters can be translated too).  The "to" field is a
+ * Vim command character.  This avoids having to switch the keyboard back to
+ * ASCII mode when leaving Insert mode.
+ *
+ * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
+ * commands.
+ * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
+ * langmap_entry_T.  This does the same as langmap_mapchar[] for characters >=
+ * 256.
  */
+# ifdef FEAT_MBYTE
+/*
+ * With multi-byte support use growarray for 'langmap' chars >= 256
+ */
+typedef struct
+{
+    int	    from;
+    int     to;
+} langmap_entry_T;
+
+static garray_T langmap_mapga;
+static void langmap_set_entry __ARGS((int from, int to));
+
+/*
+ * Search for an entry in "langmap_mapga" for "from".  If found set the "to"
+ * field.  If not found insert a new entry at the appropriate location.
+ */
+    static void
+langmap_set_entry(from, to)
+    int    from;
+    int    to;
+{
+    langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
+    int             a = 0;
+    int             b = langmap_mapga.ga_len;
+
+    /* Do a binary search for an existing entry. */
+    while (a != b)
+    {
+	int i = (a + b) / 2;
+	int d = entries[i].from - from;
+
+	if (d == 0)
+	{
+	    entries[i].to = to;
+	    return;
+	}
+	if (d < 0)
+	    a = i + 1;
+	else
+	    b = i;
+    }
+
+    if (ga_grow(&langmap_mapga, 1) != OK)
+	return;  /* out of memory */
+
+    /* insert new entry at position "a" */
+    entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
+    mch_memmove(entries + 1, entries,
+			(langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
+    ++langmap_mapga.ga_len;
+    entries[0].from = from;
+    entries[0].to = to;
+}
 
 /*
- * char_u langmap_mapchar[256];
- * Normally maps each of the 128 upper chars to an <128 ascii char; used to
- * "translate" native lang chars in normal mode or some cases of
- * insert mode without having to tediously switch lang mode back&forth.
+ * Apply 'langmap' to multi-byte character "c" and return the result.
  */
+    int
+langmap_adjust_mb(c)
+    int c;
+{
+    langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
+    int a = 0;
+    int b = langmap_mapga.ga_len;
+
+    while (a != b)
+    {
+	int i = (a + b) / 2;
+	int d = entries[i].from - c;
+
+	if (d == 0)
+	    return entries[i].to;  /* found matching entry */
+	if (d < 0)
+	    a = i + 1;
+	else
+	    b = i;
+    }
+    return c;  /* no entry found, return "c" unmodified */
+}
+# endif
 
     static void
 langmap_init()
 {
     int i;
 
-    for (i = 0; i < 256; i++)		/* we init with a-one-to one map */
-	langmap_mapchar[i] = i;
+    for (i = 0; i < 256; i++)
+	langmap_mapchar[i] = i;	 /* we init with a one-to-one map */
+# ifdef FEAT_MBYTE
+    ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
+# endif
 }
 
 /*
  * Called when langmap option is set; the language map can be
  * changed at any time!
@@ -10123,11 +10388,14 @@ langmap_set()
 {
     char_u  *p;
     char_u  *p2;
     int	    from, to;
 
-    langmap_init();			    /* back to one-to-one map first */
+#ifdef FEAT_MBYTE
+    ga_clear(&langmap_mapga);		    /* clear the previous map first */
+#endif
+    langmap_init();			    /* back to one-to-one map */
 
     for (p = p_langmap; p[0] != NUL; )
     {
 	for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
 							       mb_ptr_adv(p2))
@@ -10173,11 +10441,17 @@ langmap_set()
 	    {
 		EMSG2(_("E357: 'langmap': Matching character missing for %s"),
 							     transchar(from));
 		return;
 	    }
-	    langmap_mapchar[from & 255] = to;
+
+#ifdef FEAT_MBYTE
+	    if (from >= 256)
+		langmap_set_entry(from, to);
+	    else
+#endif
+		langmap_mapchar[from & 255] = to;
 
 	    /* Advance to next pair */
 	    mb_ptr_adv(p);
 	    if (p2 == NULL)
 	    {
--- vim72.orig/src/option.h
+++ vim72/src/option.h
@@ -31,11 +31,11 @@
 #     define DFLT_EFM	"%A%p^,%C%%CC-%t-%m,%Cat line number %l in file %f,%f|%l| %m"
 #    else /* Unix, probably */
 #     ifdef EBCDIC
 #define DFLT_EFM	"%*[^ ] %*[^ ] %f:%l%*[ ]%m,%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m"
 #     else
-#define DFLT_EFM	"%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%D%*\\a: Entering directory `%f',%X%*\\a: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m"
+#define DFLT_EFM	"%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-Gfrom %f:%l:%c,%-Gfrom %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%D%*\\a: Entering directory `%f',%X%*\\a: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m"
 #     endif
 #    endif
 #   endif
 #  endif
 # endif
--- vim72.orig/src/os_mac.h
+++ vim72/src/os_mac.h
@@ -266,13 +266,19 @@
  * version with os_unix.x instead of os_mac.c. Based on the result
  * of ./configure for console MacOS X.
  */
 
 #ifdef MACOS_X_UNIX
-# define SIGPROTOARG	(int)
-# define SIGDEFARG(s)	(s) int s;
-# define SIGDUMMYARG	0
+# ifndef SIGPROTOARG
+#  define SIGPROTOARG	(int)
+# endif
+# ifndef SIGDEFARG
+#  define SIGDEFARG(s)	(s) int s UNUSED;
+# endif
+# ifndef SIGDUMMYARG
+#  define SIGDUMMYARG	0
+# endif
 # undef  HAVE_AVAIL_MEM
 # ifndef HAVE_CONFIG_H
 #  define RETSIGTYPE void
 #  define SIGRETURN  return
 /*# define USE_SYSTEM */  /* Output ship do debugger :(, but ot compile */
@@ -283,11 +289,10 @@
 #  define HAVE_SYS_SELECT_H 1
 #  define HAVE_PUTENV
 #  define HAVE_SETENV
 #  define HAVE_RENAME
 # endif
-# define mch_chdir(s) chdir(s)
 #endif
 
 #if defined(MACOS_X) && !defined(HAVE_CONFIG_H)
 # define HAVE_PUTENV
 #endif
--- vim72.orig/src/os_msdos.c
+++ vim72/src/os_msdos.c
@@ -2037,10 +2037,16 @@ mch_has_wildcard(char_u *p)
     int
 mch_chdir(char *path)
 {
     if (path[0] == NUL)		    /* just checking... */
 	return 0;
+    if (p_verbose >= 5)
+    {
+	verbose_enter();
+	smsg((char_u *)"chdir(%s)", path);
+	verbose_leave();
+    }
     if (path[1] == ':')		    /* has a drive name */
     {
 	if (change_drive(TOLOWER_ASC(path[0]) - 'a' + 1))
 	    return -1;		    /* invalid drive name */
 	path += 2;
--- vim72.orig/src/os_mswin.c
+++ vim72/src/os_mswin.c
@@ -307,11 +307,11 @@ mch_settitle(
     {
 #  ifdef FEAT_MBYTE
 	if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
 	{
 	    /* Convert the title from 'encoding' to the active codepage. */
-	    WCHAR	*wp = enc_to_ucs2(title, NULL);
+	    WCHAR	*wp = enc_to_utf16(title, NULL);
 	    int	n;
 
 	    if (wp != NULL)
 	    {
 		n = SetConsoleTitleW(wp);
@@ -404,14 +404,14 @@ mch_FullName(
 	    /* Use the wide function:
 	     * - convert the fname from 'encoding' to UCS2.
 	     * - invoke _wfullpath()
 	     * - convert the result from UCS2 to 'encoding'.
 	     */
-	    wname = enc_to_ucs2(fname, NULL);
+	    wname = enc_to_utf16(fname, NULL);
 	    if (wname != NULL && _wfullpath(wbuf, wname, MAX_PATH - 1) != NULL)
 	    {
-		cname = ucs2_to_enc((short_u *)wbuf, NULL);
+		cname = utf16_to_enc((short_u *)wbuf, NULL);
 		if (cname != NULL)
 		{
 		    vim_strncpy(buf, cname, len - 1);
 		    nResult = OK;
 		}
@@ -505,11 +505,11 @@ vim_stat(const char *name, struct stat *
 	    /* Wide functions of Borland C 5.5 do not work on Windows 98. */
 	    && g_PlatformId == VER_PLATFORM_WIN32_NT
 # endif
        )
     {
-	WCHAR	*wp = enc_to_ucs2(buf, NULL);
+	WCHAR	*wp = enc_to_utf16(buf, NULL);
 	int	n;
 
 	if (wp != NULL)
 	{
 	    n = _wstat(wp, (struct _stat *)stp);
@@ -651,10 +651,16 @@ mch_has_wildcard(char_u *p)
 mch_chdir(char *path)
 {
     if (path[0] == NUL)		/* just checking... */
 	return -1;
 
+    if (p_verbose >= 5)
+    {
+	verbose_enter();
+	smsg((char_u *)"chdir(%s)", path);
+	verbose_leave();
+    }
     if (isalpha(path[0]) && path[1] == ':')	/* has a drive name */
     {
 	/* If we can change to the drive, skip that part of the path.  If we
 	 * can't then the current directory may be invalid, try using chdir()
 	 * with the whole path. */
@@ -666,11 +672,11 @@ mch_chdir(char *path)
 	return 0;
 
 #ifdef FEAT_MBYTE
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
-	WCHAR	*p = enc_to_ucs2(path, NULL);
+	WCHAR	*p = enc_to_utf16(path, NULL);
 	int	n;
 
 	if (p != NULL)
 	{
 	    n = _wchdir(p);
@@ -889,23 +895,24 @@ mch_libcall(
 }
 #endif
 
 #if defined(FEAT_MBYTE) || defined(PROTO)
 /*
- * Convert an UTF-8 string to UCS-2.
+ * Convert an UTF-8 string to UTF-16.
  * "instr[inlen]" is the input.  "inlen" is in bytes.
- * When "outstr" is NULL only return the number of UCS-2 words produced.
+ * When "outstr" is NULL only return the number of UTF-16 words produced.
  * Otherwise "outstr" must be a buffer of sufficient size.
- * Returns the number of UCS-2 words produced.
+ * Returns the number of UTF-16 words produced.
  */
     int
-utf8_to_ucs2(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
+utf8_to_utf16(char_u *instr, int inlen, short_u *outstr, int *unconvlenp)
 {
     int		outlen = 0;
     char_u	*p = instr;
     int		todo = inlen;
     int		l;
+    int		ch;
 
     while (todo > 0)
     {
 	/* Only convert if we have a complete sequence. */
 	l = utf_ptr2len_len(p, todo);
@@ -915,44 +922,68 @@ utf8_to_ucs2(char_u *instr, int inlen, s
 	    if (unconvlenp != NULL)
 		*unconvlenp = todo;
 	    break;
 	}
 
-	if (outstr != NULL)
-	    *outstr++ = utf_ptr2char(p);
+	ch = utf_ptr2char(p);
+	if (ch >= 0x10000)
+	{
+	    /* non-BMP character, encoding with surrogate pairs */
+	    ++outlen;
+	    if (outstr != NULL)
+	    {
+		*outstr++ = (0xD800 - (0x10000 >> 10)) + (ch >> 10);
+		*outstr++ = 0xDC00 | (ch & 0x3FF);
+	    }
+	}
+	else if (outstr != NULL)
+	    *outstr++ = ch;
 	++outlen;
 	p += l;
 	todo -= l;
     }
 
     return outlen;
 }
 
 /*
- * Convert an UCS-2 string to UTF-8.
- * The input is "instr[inlen]" with "inlen" in number of ucs-2 words.
+ * Convert an UTF-16 string to UTF-8.
+ * The input is "instr[inlen]" with "inlen" in number of UTF-16 words.
  * When "outstr" is NULL only return the required number of bytes.
  * Otherwise "outstr" must be a buffer of sufficient size.
  * Return the number of bytes produced.
  */
     int
-ucs2_to_utf8(short_u *instr, int inlen, char_u *outstr)
+utf16_to_utf8(short_u *instr, int inlen, char_u *outstr)
 {
     int		outlen = 0;
     int		todo = inlen;
     short_u	*p = instr;
     int		l;
+    int		ch, ch2;
 
     while (todo > 0)
     {
+	ch = *p;
+	if (ch >= 0xD800 && ch <= 0xDBFF && todo > 1)
+	{
+	    /* surrogate pairs handling */
+	    ch2 = p[1];
+	    if (ch2 >= 0xDC00 && ch2 <= 0xDFFF)
+	    {
+		ch = ((ch - 0xD800) << 10) + (ch2 & 0x3FF) + 0x10000;
+		++p;
+		--todo;
+	    }
+	}
 	if (outstr != NULL)
 	{
-	    l = utf_char2bytes(*p, outstr);
+	    l = utf_char2bytes(ch, outstr);
 	    outstr += l;
 	}
 	else
-	    l = utf_char2len(*p);
+	    l = utf_char2len(ch);
 	++p;
 	outlen += l;
 	--todo;
     }
 
@@ -1077,18 +1108,18 @@ crnl_to_nl(const char_u *str, int *size)
  * Note: the following two functions are only guaranteed to work when using
  * valid MS-Windows codepages or when iconv() is available.
  */
 
 /*
- * Convert "str" from 'encoding' to UCS-2.
+ * Convert "str" from 'encoding' to UTF-16.
  * Input in "str" with length "*lenp".  When "lenp" is NULL, use strlen().
  * Output is returned as an allocated string.  "*lenp" is set to the length of
  * the result.  A trailing NUL is always added.
  * Returns NULL when out of memory.
  */
     short_u *
-enc_to_ucs2(char_u *str, int *lenp)
+enc_to_utf16(char_u *str, int *lenp)
 {
     vimconv_T	conv;
     WCHAR	*ret;
     char_u	*allocbuf = NULL;
     int		len_loc;
@@ -1100,11 +1131,11 @@ enc_to_ucs2(char_u *str, int *lenp)
 	lenp = &len_loc;
     }
 
     if (enc_codepage > 0)
     {
-	/* We can do any CP### -> UCS-2 in one pass, and we can do it
+	/* We can do any CP### -> UTF-16 in one pass, and we can do it
 	 * without iconv() (convert_* may need iconv). */
 	MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length);
     }
     else
     {
@@ -1121,15 +1152,15 @@ enc_to_ucs2(char_u *str, int *lenp)
 	    if (str == NULL)
 		return NULL;
 	}
 	convert_setup(&conv, NULL, NULL);
 
-	length = utf8_to_ucs2(str, *lenp, NULL, NULL);
+	length = utf8_to_utf16(str, *lenp, NULL, NULL);
 	ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR)));
 	if (ret != NULL)
 	{
-	    utf8_to_ucs2(str, *lenp, (short_u *)ret, NULL);
+	    utf8_to_utf16(str, *lenp, (short_u *)ret, NULL);
 	    ret[length] = 0;
 	}
 
 	vim_free(allocbuf);
     }
@@ -1137,19 +1168,19 @@ enc_to_ucs2(char_u *str, int *lenp)
     *lenp = length;
     return (short_u *)ret;
 }
 
 /*
- * Convert an UCS-2 string to 'encoding'.
+ * Convert an UTF-16 string to 'encoding'.
  * Input in "str" with length (counted in wide characters) "*lenp".  When
  * "lenp" is NULL, use wcslen().
  * Output is returned as an allocated string.  If "*lenp" is not NULL it is
  * set to the length of the result.
  * Returns NULL when out of memory.
  */
     char_u *
-ucs2_to_enc(short_u *str, int *lenp)
+utf16_to_enc(short_u *str, int *lenp)
 {
     vimconv_T	conv;
     char_u	*utf8_str = NULL, *enc_str = NULL;
     int		len_loc;
 
@@ -1159,24 +1190,24 @@ ucs2_to_enc(short_u *str, int *lenp)
 	lenp = &len_loc;
     }
 
     if (enc_codepage > 0)
     {
-	/* We can do any UCS-2 -> CP### in one pass. */
+	/* We can do any UTF-16 -> CP### in one pass. */
 	int length;
 
 	WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp,
 					    (LPSTR *)&enc_str, &length, 0, 0);
 	*lenp = length;
 	return enc_str;
     }
 
     /* Avoid allocating zero bytes, it generates an error message. */
-    utf8_str = alloc(ucs2_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
+    utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL));
     if (utf8_str != NULL)
     {
-	*lenp = ucs2_to_utf8(str, *lenp, utf8_str);
+	*lenp = utf16_to_utf8(str, *lenp, utf8_str);
 
 	/* We might be called before we have p_enc set up. */
 	conv.vc_type = CONV_NONE;
 	convert_setup(&conv, (char_u *)"utf-8",
 					    p_enc? p_enc: (char_u *)"latin1");
@@ -1197,10 +1228,29 @@ ucs2_to_enc(short_u *str, int *lenp)
     return enc_str;
 }
 #endif /* FEAT_MBYTE */
 
 /*
+ * Wait for another process to Close the Clipboard.
+ * Returns TRUE for success.
+ */
+    static int
+vim_open_clipboard(void)
+{
+    int delay = 10;
+
+    while (!OpenClipboard(NULL))
+    {
+        if (delay > 500)
+            return FALSE;  /* waited too long, give up */
+        Sleep(delay);
+        delay *= 2;	/* wait for 10, 20, 40, 80, etc. msec */
+    }
+    return TRUE;
+}
+
+/*
  * Get the current selection and put it in the clipboard register.
  *
  * NOTE: Must use GlobalLock/Unlock here to ensure Win32s compatibility.
  * On NT/W95 the clipboard data is a fixed global memory object and
  * so its handle = its pointer.
@@ -1227,11 +1277,11 @@ clip_mch_request_selection(VimClipboard
 
     /*
      * Don't pass GetActiveWindow() as an argument to OpenClipboard() because
      * then we can't paste back into the same window for some reason - webb.
      */
-    if (!OpenClipboard(NULL))
+    if (!vim_open_clipboard())
 	return;
 
     /* Check for vim's own clipboard format first.  This only gets the type of
      * the data, still need to use CF_UNICODETEXT or CF_TEXT for the text. */
     if (IsClipboardFormatAvailable(cbd->format))
@@ -1306,11 +1356,11 @@ clip_mch_request_selection(VimClipboard
 	    {
 		for (str_size = 0; str_size < maxlen; ++str_size)
 		    if (hMemWstr[str_size] == NUL)
 			break;
 	    }
-	    to_free = str = ucs2_to_enc((short_u *)hMemWstr, &str_size);
+	    to_free = str = utf16_to_enc((short_u *)hMemWstr, &str_size);
 	    GlobalUnlock(hMemW);
 	}
     }
     else
 #endif
@@ -1338,11 +1388,11 @@ clip_mch_request_selection(VimClipboard
 			break;
 	    }
 
 # if defined(FEAT_MBYTE) && defined(WIN3264)
 	    /* The text is in the active codepage.  Convert to 'encoding',
-	     * going through UCS-2. */
+	     * going through UTF-16. */
 	    acp_to_enc(str, str_size, &to_free, &maxlen);
 	    if (to_free != NULL)
 	    {
 		str_size = maxlen;
 		str = to_free;
@@ -1402,11 +1452,11 @@ acp_to_enc(str, str_size, out, outlen)
 
     MultiByteToWideChar_alloc(GetACP(), 0, str, str_size, &widestr, outlen);
     if (widestr != NULL)
     {
 	++*outlen;	/* Include the 0 after the string */
-	*out = ucs2_to_enc((short_u *)widestr, outlen);
+	*out = utf16_to_enc((short_u *)widestr, outlen);
 	vim_free(widestr);
     }
 }
 #endif
 
@@ -1464,13 +1514,13 @@ clip_mch_set_selection(VimClipboard *cbd
 # if defined(FEAT_MBYTE) && defined(WIN3264)
     {
 	WCHAR		*out;
 	int		len = metadata.txtlen;
 
-	/* Convert the text to UCS-2. This is put on the clipboard as
+	/* Convert the text to UTF-16. This is put on the clipboard as
 	 * CF_UNICODETEXT. */
-	out = (WCHAR *)enc_to_ucs2(str, &len);
+	out = (WCHAR *)enc_to_utf16(str, &len);
 	if (out != NULL)
 	{
 	    WCHAR *lpszMemW;
 
 	    /* Convert the text for CF_TEXT to Active codepage. Otherwise it's
@@ -1486,11 +1536,11 @@ clip_mch_set_selection(VimClipboard *cbd
 		return;		/* out of memory */
 	    }
 	    WideCharToMultiByte(GetACP(), 0, out, len,
 						  str, metadata.txtlen, 0, 0);
 
-	    /* Allocate memory for the UCS-2 text, add one NUL word to
+	    /* Allocate memory for the UTF-16 text, add one NUL word to
 	     * terminate the string. */
 	    hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,
 						   (len + 1) * sizeof(WCHAR));
 	    lpszMemW = (WCHAR *)GlobalLock(hMemW);
 	    if (lpszMemW != NULL)
@@ -1535,11 +1585,11 @@ clip_mch_set_selection(VimClipboard *cbd
      *
      * Don't pass GetActiveWindow() as an argument to OpenClipboard()
      * because then we can't paste back into the same window for some
      * reason - webb.
      */
-    if (OpenClipboard(NULL))
+    if (vim_open_clipboard())
     {
 	if (EmptyClipboard())
 	{
 	    SetClipboardData(cbd->format, hMemVim);
 	    hMemVim = 0;
--- vim72.orig/src/os_riscos.c
+++ vim72/src/os_riscos.c
@@ -1201,10 +1201,16 @@ mch_chdir(dir)
 {
     int	    length;
     int	    retval;
     char_u  *new_dir;
 
+    if (p_verbose >= 5)
+    {
+	verbose_enter();
+	smsg((char_u *)"chdir(%s)", dir);
+	verbose_leave();
+    }
     length = strlen(dir);
     if (dir[length - 1] != '.')
 	return chdir(dir);	    /* No trailing dots - nothing to do. */
     new_dir = vim_strsave(dir);
     if (new_dir == NULL)
--- vim72.orig/src/os_unix.c
+++ vim72/src/os_unix.c
@@ -179,11 +179,12 @@ static RETSIGTYPE catch_sigpwr __ARGS(SI
 #endif
 #if defined(SIGALRM) && defined(FEAT_X11) \
 	&& defined(FEAT_TITLE) && !defined(FEAT_GUI_GTK)
 # define SET_SIG_ALARM
 static RETSIGTYPE sig_alarm __ARGS(SIGPROTOARG);
-static int sig_alarm_called;
+/* volatile because it is used in signal handler sig_alarm(). */
+static volatile int sig_alarm_called;
 #endif
 static RETSIGTYPE deathtrap __ARGS(SIGPROTOARG);
 
 static void catch_int_signal __ARGS((void));
 static void set_signals __ARGS((void));
@@ -199,17 +200,20 @@ static int save_patterns __ARGS((int num
 
 #ifndef SIG_ERR
 # define SIG_ERR	((RETSIGTYPE (*)())-1)
 #endif
 
-static int	do_resize = FALSE;
+/* volatile because it is used in signal handler sig_winch(). */
+static volatile int do_resize = FALSE;
 #ifndef __EMX__
 static char_u	*extra_shell_arg = NULL;
 static int	show_shell_mess = TRUE;
 #endif
-static int	deadly_signal = 0;	    /* The signal we caught */
-static int	in_mch_delay = FALSE;	    /* sleeping in mch_delay() */
+/* volatile because it is used in signal handler deathtrap(). */
+static volatile int deadly_signal = 0;	    /* The signal we caught */
+/* volatile because it is used in signal handler deathtrap(). */
+static volatile int in_mch_delay = FALSE;    /* sleeping in mch_delay() */
 
 static int curr_tmode = TMODE_COOK;	/* contains current terminal mode */
 
 #ifdef USE_XSMP
 typedef struct
@@ -313,16 +317,36 @@ static struct signalinfo
     {SIGPIPE,	    "PIPE",	FALSE},
 #endif
     {-1,	    "Unknown!", FALSE}
 };
 
+    int
+mch_chdir(path)
+    char *path;
+{
+    if (p_verbose >= 5)
+    {
+	verbose_enter();
+	smsg((char_u *)"chdir(%s)", path);
+	verbose_leave();
+    }
+# ifdef VMS
+    return chdir(vms_fixfilename(path));
+# else
+    return chdir(path);
+# endif
+}
+
+/*
+ * Write s[len] to the screen.
+ */
     void
 mch_write(s, len)
     char_u	*s;
     int		len;
 {
-    write(1, (char *)s, len);
+    ignored = (int)write(1, (char *)s, len);
     if (p_wd)		/* Unix is too fast, slow down a bit more */
 	RealWaitForChar(read_cmd_fd, p_wd, NULL);
 }
 
 /*
@@ -445,14 +469,13 @@ mch_char_avail()
 
 /*
  * Return total amount of memory available in Kbyte.
  * Doesn't change when memory has been allocated.
  */
-/* ARGSUSED */
     long_u
 mch_total_mem(special)
-    int special;
+    int special UNUSED;
 {
 # ifdef __EMX__
     return ulimit(3, 0L) >> 10;   /* always 32MB? */
 # else
     long_u	mem = 0;
@@ -797,16 +820,15 @@ init_signal_stack()
     }
 }
 #endif
 
 /*
- * We need correct potatotypes for a signal function, otherwise mean compilers
+ * We need correct prototypes for a signal function, otherwise mean compilers
  * will barf when the second argument to signal() is ``wrong''.
  * Let me try it with a few tricky defines from my own osdef.h	(jw).
  */
 #if defined(SIGWINCH)
-/* ARGSUSED */
     static RETSIGTYPE
 sig_winch SIGDEFARG(sigarg)
 {
     /* this is not required on all systems, but it doesn't hurt anybody */
     signal(SIGWINCH, (RETSIGTYPE (*)())sig_winch);
@@ -814,11 +836,10 @@ sig_winch SIGDEFARG(sigarg)
     SIGRETURN;
 }
 #endif
 
 #if defined(SIGINT)
-/* ARGSUSED */
     static RETSIGTYPE
 catch_sigint SIGDEFARG(sigarg)
 {
     /* this is not required on all systems, but it doesn't hurt anybody */
     signal(SIGINT, (RETSIGTYPE (*)())catch_sigint);
@@ -826,11 +847,10 @@ catch_sigint SIGDEFARG(sigarg)
     SIGRETURN;
 }
 #endif
 
 #if defined(SIGPWR)
-/* ARGSUSED */
     static RETSIGTYPE
 catch_sigpwr SIGDEFARG(sigarg)
 {
     /* this is not required on all systems, but it doesn't hurt anybody */
     signal(SIGPWR, (RETSIGTYPE (*)())catch_sigpwr);
@@ -846,11 +866,10 @@ catch_sigpwr SIGDEFARG(sigarg)
 
 #ifdef SET_SIG_ALARM
 /*
  * signal function for alarm().
  */
-/* ARGSUSED */
     static RETSIGTYPE
 sig_alarm SIGDEFARG(sigarg)
 {
     /* doesn't do anything, just to break a system call */
     sig_alarm_called = TRUE;
@@ -1063,23 +1082,27 @@ deathtrap SIGDEFARG(sigarg)
 #endif
 
     SIGRETURN;
 }
 
-#ifdef _REENTRANT
+#if defined(_REENTRANT) && defined(SIGCONT)
 /*
  * On Solaris with multi-threading, suspending might not work immediately.
  * Catch the SIGCONT signal, which will be used as an indication whether the
  * suspending has been done or not.
+ *
+ * On Linux, signal is not always handled immediately either.
+ * See https://bugs.launchpad.net/bugs/291373
+ *
+ * volatile because it is used in in signal handler sigcont_handler().
  */
-static int sigcont_received;
+static volatile int sigcont_received;
 static RETSIGTYPE sigcont_handler __ARGS(SIGPROTOARG);
 
 /*
  * signal handler for SIGCONT
  */
-/* ARGSUSED */
     static RETSIGTYPE
 sigcont_handler SIGDEFARG(sigarg)
 {
     sigcont_received = TRUE;
     SIGRETURN;
@@ -1113,19 +1136,32 @@ mch_suspend()
 	if (x11_display != NULL)
 	    XFlush(x11_display);
     }
 # endif
 
-# ifdef _REENTRANT
+# if defined(_REENTRANT) && defined(SIGCONT)
     sigcont_received = FALSE;
 # endif
     kill(0, SIGTSTP);	    /* send ourselves a STOP signal */
-# ifdef _REENTRANT
-    /* When we didn't suspend immediately in the kill(), do it now.  Happens
-     * on multi-threaded Solaris. */
-    if (!sigcont_received)
-	pause();
+# if defined(_REENTRANT) && defined(SIGCONT)
+    /*
+     * Wait for the SIGCONT signal to be handled. It generally happens
+     * immediately, but somehow not all the time. Do not call pause()
+     * because there would be race condition which would hang Vim if
+     * signal happened in between the test of sigcont_received and the
+     * call to pause(). If signal is not yet received, call sleep(0)
+     * to just yield CPU. Signal should then be received. If somehow
+     * it's still not received, sleep 1, 2, 3 ms. Don't bother waiting
+     * further if signal is not received after 1+2+3+4 ms (not expected
+     * to happen).
+     */
+    {
+	long wait_time;
+	for (wait_time = 0; !sigcont_received && wait_time <= 3L; wait_time++)
+	    /* Loop is not entered most of the time */
+	    mch_delay(wait_time, FALSE);
+    }
 # endif
 
 # ifdef FEAT_TITLE
     /*
      * Set oldtitle to NULL, so the current title is obtained again.
@@ -1170,11 +1206,11 @@ set_signals()
      * For "rvim" the STOP signal is ignored.
      */
 #ifdef SIGTSTP
     signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
 #endif
-#ifdef _REENTRANT
+#if defined(_REENTRANT) && defined(SIGCONT)
     signal(SIGCONT, sigcont_handler);
 #endif
 
     /*
      * We want to ignore breaking of PIPEs.
@@ -1229,11 +1265,11 @@ catch_int_signal()
 
     void
 reset_signals()
 {
     catch_signals(SIG_DFL, SIG_DFL);
-#ifdef _REENTRANT
+#if defined(_REENTRANT) && defined(SIGCONT)
     /* SIGCONT isn't in the list, because its default action is ignore */
     signal(SIGCONT, SIG_DFL);
 #endif
 }
 
@@ -1324,15 +1360,14 @@ vim_handle_signal(sig)
 }
 
 /*
  * Check_win checks whether we have an interactive stdout.
  */
-/* ARGSUSED */
     int
 mch_check_win(argc, argv)
-    int	    argc;
-    char    **argv;
+    int	    argc UNUSED;
+    char    **argv UNUSED;
 {
 #ifdef OS2
     /*
      * Store argv[0], may be used for $VIM.  Only use it if it is an absolute
      * name, mostly it's just "vim" and found in the path, which is unusable.
@@ -1412,15 +1447,14 @@ x_error_handler(dpy, error_event)
 }
 
 /*
  * Another X Error handler, just used to check for errors.
  */
-/* ARGSUSED */
     static int
 x_error_check(dpy, error_event)
-    Display *dpy;
-    XErrorEvent	*error_event;
+    Display *dpy UNUSED;
+    XErrorEvent	*error_event UNUSED;
 {
     got_x_error = TRUE;
     return 0;
 }
 
@@ -1429,41 +1463,41 @@ x_error_check(dpy, error_event)
 /*
  * An X IO Error handler, used to catch error while opening the display.
  */
 static int x_IOerror_check __ARGS((Display *dpy));
 
-/* ARGSUSED */
     static int
 x_IOerror_check(dpy)
-    Display *dpy;
+    Display *dpy UNUSED;
 {
     /* This function should not return, it causes exit().  Longjump instead. */
     LONGJMP(lc_jump_env, 1);
-    /*NOTREACHED*/
-    return 0;
+#  ifdef VMS
+    return 0;  /* avoid the compiler complains about missing return value */
+#  endif
 }
 # endif
 
 /*
  * An X IO Error handler, used to catch terminal errors.
  */
 static int x_IOerror_handler __ARGS((Display *dpy));
 
-/* ARGSUSED */
     static int
 x_IOerror_handler(dpy)
-    Display *dpy;
+    Display *dpy UNUSED;
 {
     xterm_dpy = NULL;
     x11_window = 0;
     x11_display = NULL;
     xterm_Shell = (Widget)0;
 
     /* This function should not return, it causes exit().  Longjump instead. */
     LONGJMP(x_jump_env, 1);
-    /*NOTREACHED*/
-    return 0;
+# ifdef VMS
+    return 0;  /* avoid the compiler complains about missing return value */
+# endif
 }
 #endif
 
 /*
  * Return TRUE when connection to the X server is desired.
@@ -1704,13 +1738,13 @@ get_x11_icon(test_only)
 
     /* could not get old icon, use terminal name */
     if (oldicon == NULL && !test_only)
     {
 	if (STRNCMP(T_NAME, "builtin_", 8) == 0)
-	    oldicon = T_NAME + 8;
+	    oldicon = vim_strsave(T_NAME + 8);
 	else
-	    oldicon = T_NAME;
+	    oldicon = vim_strsave(T_NAME);
     }
 
     return retval;
 }
 
@@ -1895,14 +1929,13 @@ set_x11_icon(icon)
     XFlush(x11_display);
 }
 
 #else  /* FEAT_X11 */
 
-/*ARGSUSED*/
     static int
 get_x11_title(test_only)
-    int	    test_only;
+    int	    test_only UNUSED;
 {
     return FALSE;
 }
 
     static int
@@ -1910,13 +1943,13 @@ get_x11_icon(test_only)
     int	    test_only;
 {
     if (!test_only)
     {
 	if (STRNCMP(T_NAME, "builtin_", 8) == 0)
-	    oldicon = T_NAME + 8;
+	    oldicon = vim_strsave(T_NAME + 8);
 	else
-	    oldicon = T_NAME;
+	    oldicon = vim_strsave(T_NAME);
     }
     return FALSE;
 }
 
 #endif /* FEAT_X11 */
@@ -2412,10 +2445,16 @@ mch_FullName(fname, buf, len, force)
 	if (p != NULL)
 	{
 #ifdef HAVE_FCHDIR
 	    if (fd >= 0)
 	    {
+		if (p_verbose >= 5)
+		{
+		    verbose_enter();
+		    MSG("fchdir() to previous dir");
+		    verbose_leave();
+		}
 		l = fchdir(fd);
 		close(fd);
 	    }
 	    else
 #endif
@@ -2436,11 +2475,11 @@ mch_FullName(fname, buf, len, force)
 	}
 #endif
     }
 
     /* Catch file names which are too long. */
-    if (retval == FAIL || STRLEN(buf) + STRLEN(fname) >= len)
+    if (retval == FAIL || (int)(STRLEN(buf) + STRLEN(fname)) >= len)
 	return FAIL;
 
     /* Do not append ".", "/dir/." is equal to "/dir". */
     if (STRCMP(fname, ".") != 0)
 	STRCAT(buf, fname);
@@ -2473,15 +2512,14 @@ mch_isFullName(fname)
 /*
  * Set the case of the file name, if it already exists.  This will cause the
  * file name to remain exactly the same.
  * Only required for file systems where case is ignored and preserved.
  */
-/*ARGSUSED*/
     void
 fname_case(name, len)
     char_u	*name;
-    int		len;	    /* buffer size, only used when name gets longer */
+    int		len UNUSED;  /* buffer size, only used when name gets longer */
 {
     struct stat st;
     char_u	*slash, *tail;
     DIR		*dirp;
     struct dirent *dp;
@@ -2655,11 +2693,11 @@ mch_copy_sec(from_file, to_file)
  * Return a pointer to the ACL of file "fname" in allocated memory.
  * Return NULL if the ACL is not available for whatever reason.
  */
     vim_acl_T
 mch_get_acl(fname)
-    char_u	*fname;
+    char_u	*fname UNUSED;
 {
     vim_acl_T	ret = NULL;
 #ifdef HAVE_POSIX_ACL
     ret = (vim_acl_T)acl_get_file((char *)fname, ACL_TYPE_ACCESS);
 #else
@@ -2715,11 +2753,11 @@ mch_get_acl(fname)
 /*
  * Set the ACL of file "fname" to "acl" (unless it's NULL).
  */
     void
 mch_set_acl(fname, aclent)
-    char_u	*fname;
+    char_u	*fname UNUSED;
     vim_acl_T	aclent;
 {
     if (aclent == NULL)
 	return;
 #ifdef HAVE_POSIX_ACL
@@ -2758,14 +2796,13 @@ mch_free_acl(aclent)
 #endif
 
 /*
  * Set hidden flag for "name".
  */
-/* ARGSUSED */
     void
 mch_hide(name)
-    char_u	*name;
+    char_u	*name UNUSED;
 {
     /* can't hide a file */
 }
 
 /*
@@ -2903,11 +2940,11 @@ mch_early_init()
      * running out of stack space.
      * Use of sigaltstack() is preferred, it's more portable.
      * Ignore any errors.
      */
 #if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
-    signal_stack = malloc(SIGSTKSZ);
+    signal_stack = (char *)alloc(SIGSTKSZ);
     init_signal_stack();
 #endif
 }
 
 #if defined(EXITFREE) || defined(PROTO)
@@ -2934,11 +2971,12 @@ mch_free_mem()
 	x11_display = NULL; /* freed by XtDestroyApplicationContext() */
 #   endif
     }
 #  endif
 # endif
-# ifdef FEAT_X11
+    /* Don't close the display for GTK 1, it is done in exit(). */
+# if defined(FEAT_X11) && (!defined(FEAT_GUI_GTK) || defined(HAVE_GTK2))
     if (x11_display != NULL
 #  ifdef FEAT_XCLIPBOARD
 	    && x11_display != xterm_dpy
 #  endif
 	    )
@@ -3449,14 +3487,13 @@ check_mouse_termcode()
 #endif
 
 /*
  * set screen mode, always fails.
  */
-/* ARGSUSED */
     int
 mch_screenmode(arg)
-    char_u   *arg;
+    char_u   *arg UNUSED;
 {
     EMSG(_(e_screenmode));
     return FAIL;
 }
 
@@ -3924,13 +3961,13 @@ mch_call_shell(cmd, options)
 		 * or dup() failed we'd just do the same thing ourselves
 		 * anyway -- webb
 		 */
 		if (fd >= 0)
 		{
-		    dup(fd); /* To replace stdin  (file descriptor 0) */
-		    dup(fd); /* To replace stdout (file descriptor 1) */
-		    dup(fd); /* To replace stderr (file descriptor 2) */
+		    ignored = dup(fd); /* To replace stdin  (fd 0) */
+		    ignored = dup(fd); /* To replace stdout (fd 1) */
+		    ignored = dup(fd); /* To replace stderr (fd 2) */
 
 		    /* Don't need this now that we've duplicated it */
 		    close(fd);
 		}
 	    }
@@ -3944,11 +3981,21 @@ mch_call_shell(cmd, options)
 # ifdef HAVE_SETSID
 		/* Create our own process group, so that the child and all its
 		 * children can be kill()ed.  Don't do this when using pipes,
 		 * because stdin is not a tty, we would lose /dev/tty. */
 		if (p_stmp)
+		{
 		    (void)setsid();
+#  if defined(SIGHUP)
+		    /* When doing "!xterm&" and 'shell' is bash: the shell
+		     * will exit and send SIGHUP to all processes in its
+		     * group, killing the just started process.  Ignore SIGHUP
+		     * to avoid that. (suggested by Simon Schubert)
+		     */
+		    signal(SIGHUP, SIG_IGN);
+#  endif
+		}
 # endif
 # ifdef FEAT_GUI
 		if (pty_slave_fd >= 0)
 		{
 		    /* push stream discipline modules */
@@ -3994,42 +4041,42 @@ mch_call_shell(cmd, options)
 		{
 		    close(pty_master_fd);   /* close master side of pty */
 
 		    /* set up stdin/stdout/stderr for the child */
 		    close(0);
-		    dup(pty_slave_fd);
+		    ignored = dup(pty_slave_fd);
 		    close(1);
-		    dup(pty_slave_fd);
+		    ignored = dup(pty_slave_fd);
 		    if (gui.in_use)
 		    {
 			close(2);
-			dup(pty_slave_fd);
+			ignored = dup(pty_slave_fd);
 		    }
 
 		    close(pty_slave_fd);    /* has been dupped, close it now */
 		}
 		else
 # endif
 		{
 		    /* set up stdin for the child */
 		    close(fd_toshell[1]);
 		    close(0);
-		    dup(fd_toshell[0]);
+		    ignored = dup(fd_toshell[0]);
 		    close(fd_toshell[0]);
 
 		    /* set up stdout for the child */
 		    close(fd_fromshell[0]);
 		    close(1);
-		    dup(fd_fromshell[1]);
+		    ignored = dup(fd_fromshell[1]);
 		    close(fd_fromshell[1]);
 
 # ifdef FEAT_GUI
 		    if (gui.in_use)
 		    {
 			/* set up stderr for the child */
 			close(2);
-			dup(1);
+			ignored = dup(1);
 		    }
 # endif
 		}
 	    }
 
@@ -4076,10 +4123,13 @@ mch_call_shell(cmd, options)
 		int	    c;
 		int	    toshell_fd;
 		int	    fromshell_fd;
 		garray_T    ga;
 		int	    noread_cnt;
+# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
+		struct timeval  start_tv;
+# endif
 
 # ifdef FEAT_GUI
 		if (pty_master_fd >= 0)
 		{
 		    close(pty_slave_fd);	/* close slave side of pty */
@@ -4144,23 +4194,25 @@ mch_call_shell(cmd, options)
 				len = write(toshell_fd, "", (size_t)1);
 			    else
 			    {
 				s = vim_strchr(lp + written, NL);
 				len = write(toshell_fd, (char *)lp + written,
-					   s == NULL ? l : s - (lp + written));
+					   s == NULL ? l
+					      : (size_t)(s - (lp + written)));
 			    }
-			    if (len == l)
+			    if (len == (int)l)
 			    {
 				/* Finished a line, add a NL, unless this line
 				 * should not have one. */
 				if (lnum != curbuf->b_op_end.lnum
 					|| !curbuf->b_p_bin
 					|| (lnum != write_no_eol_lnum
 					    && (lnum !=
 						    curbuf->b_ml.ml_line_count
 						    || curbuf->b_p_eol)))
-				    write(toshell_fd, "\n", (size_t)1);
+				    ignored = write(toshell_fd, "\n",
+								   (size_t)1);
 				++lnum;
 				if (lnum > curbuf->b_op_end.lnum)
 				{
 				    /* finished all the lines, close pipe */
 				    close(toshell_fd);
@@ -4184,11 +4236,13 @@ mch_call_shell(cmd, options)
 
 		if (options & SHELL_READ)
 		    ga_init2(&ga, 1, BUFLEN);
 
 		noread_cnt = 0;
-
+# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
+		gettimeofday(&start_tv, NULL);
+# endif
 		for (;;)
 		{
 		    /*
 		     * Check if keys have been typed, write them to the child
 		     * if there are any.
@@ -4197,29 +4251,38 @@ mch_call_shell(cmd, options)
 		     * Don't do this when filtering and terminal is in cooked
 		     * mode, the shell command will handle the I/O.  Avoids
 		     * that a typed password is echoed for ssh or gpg command.
 		     * Don't get characters when the child has already
 		     * finished (wait_pid == 0).
-		     * Don't get extra characters when we already have one.
 		     * Don't read characters unless we didn't get output for a
-		     * while, avoids that ":r !ls" eats typeahead.
+		     * while (noread_cnt > 4), avoids that ":r !ls" eats
+		     * typeahead.
 		     */
 		    len = 0;
 		    if (!(options & SHELL_EXPAND)
 			    && ((options &
 					 (SHELL_READ|SHELL_WRITE|SHELL_COOKED))
 				      != (SHELL_READ|SHELL_WRITE|SHELL_COOKED)
-#ifdef FEAT_GUI
+# ifdef FEAT_GUI
 						    || gui.in_use
-#endif
+# endif
 						    )
 			    && wait_pid == 0
-			    && (ta_len > 0
-				|| (noread_cnt > 4
-				    && (len = ui_inchar(ta_buf,
-						       BUFLEN, 10L, 0)) > 0)))
+			    && (ta_len > 0 || noread_cnt > 4))
 		    {
+		      if (ta_len == 0)
+		      {
+			  /* Get extra characters when we don't have any.
+			   * Reset the counter and timer. */
+			  noread_cnt = 0;
+# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
+			  gettimeofday(&start_tv, NULL);
+# endif
+			  len = ui_inchar(ta_buf, BUFLEN, 10L, 0);
+		      }
+		      if (ta_len > 0 || len > 0)
+		      {
 			/*
 			 * For pipes:
 			 * Check for CTRL-C: send interrupt signal to child.
 			 * Check for CTRL-D: EOF, close pipe to child.
 			 */
@@ -4269,11 +4332,12 @@ mch_call_shell(cmd, options)
 			    }
 			    else if (ta_buf[i] == '\r')
 				ta_buf[i] = '\n';
 # ifdef FEAT_MBYTE
 			    if (has_mbyte)
-				i += (*mb_ptr2len)(ta_buf + i) - 1;
+				i += (*mb_ptr2len_len)(ta_buf + i,
+							ta_len + len - i) - 1;
 # endif
 			}
 
 			/*
 			 * For pipes: echo the typed characters.
@@ -4317,13 +4381,13 @@ mch_call_shell(cmd, options)
 			    len = write(toshell_fd, (char *)ta_buf, (size_t)1);
 			    if (len > 0)
 			    {
 				ta_len -= len;
 				mch_memmove(ta_buf, ta_buf + len, ta_len);
-				noread_cnt = 0;
 			    }
 			}
+		      }
 		    }
 
 		    if (got_int)
 		    {
 			/* CTRL-C sends a signal to the child, we ignore it
@@ -4427,10 +4491,29 @@ mch_call_shell(cmd, options)
 			windgoto(msg_row, msg_col);
 			cursor_on();
 			out_flush();
 			if (got_int)
 			    break;
+
+# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
+			{
+			    struct timeval  now_tv;
+			    long	    msec;
+
+			    /* Avoid that we keep looping here without
+			     * checking for a CTRL-C for a long time.  Don't
+			     * break out too often to avoid losing typeahead. */
+			    gettimeofday(&now_tv, NULL);
+			    msec = (now_tv.tv_sec - start_tv.tv_sec) * 1000L
+				+ (now_tv.tv_usec - start_tv.tv_usec) / 1000L;
+			    if (msec > 2000)
+			    {
+				noread_cnt = 5;
+				break;
+			    }
+			}
+# endif
 		    }
 
 		    /* If we already detected the child has finished break the
 		     * loop now. */
 		    if (wait_pid == pid)
@@ -4670,20 +4753,19 @@ WaitForChar(msec)
  * Time == -1 will block forever.
  * When a GUI is being used, this will not be used for input -- webb
  * Returns also, when a request from Sniff is waiting -- toni.
  * Or when a Linux GPM mouse event is waiting.
  */
-/* ARGSUSED */
 #if defined(__BEOS__)
     int
 #else
     static  int
 #endif
 RealWaitForChar(fd, msec, check_for_gpm)
     int		fd;
     long	msec;
-    int		*check_for_gpm;
+    int		*check_for_gpm UNUSED;
 {
     int		ret;
 #if defined(FEAT_XCLIPBOARD) || defined(USE_XSMP) || defined(FEAT_MZSCHEME)
     static int	busy = FALSE;
 
@@ -5074,11 +5156,10 @@ mch_expandpath(gap, path, flags)
 # define SEEK_END 2
 #endif
 
 #define SHELL_SPECIAL (char_u *)"\t \"&'$;<>()\\|"
 
-/* ARGSUSED */
     int
 mch_expand_wildcards(num_pat, pat, num_file, file, flags)
     int		   num_pat;
     char_u	 **pat;
     int		  *num_file;
@@ -5496,11 +5577,11 @@ mch_expand_wildcards(num_pat, pat, num_f
 	return FAIL;
     }
     i = fread((char *)buffer, 1, len, fd);
     fclose(fd);
     mch_remove(tempname);
-    if (i != len)
+    if (i != (int)len)
     {
 	/* unexpected read error */
 	EMSG2(_(e_notread), tempname);
 	vim_free(tempname);
 	vim_free(buffer);
@@ -5557,11 +5638,11 @@ mch_expand_wildcards(num_pat, pat, num_f
 	 */
 	check_spaces = FALSE;
 	if (shell_style == STYLE_PRINT && !did_find_nul)
 	{
 	    /* If there is a NUL, set did_find_nul, else set check_spaces */
-	    if (len && (int)STRLEN(buffer) < len - 1)
+	    if (len && (int)STRLEN(buffer) < (int)len - 1)
 		did_find_nul = TRUE;
 	    else
 		check_spaces = TRUE;
 	}
 
@@ -5849,11 +5930,13 @@ gpm_open()
 	    /* gpm library tries to handling TSTP causes
 	     * problems. Anyways, we close connection to Gpm whenever
 	     * we are going to suspend or starting an external process
 	     * so we shouldn't  have problem with this
 	     */
+# ifdef SIGTSTP
 	    signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
+# endif
 	    return 1; /* succeed */
 	}
 	if (gpm_fd == -2)
 	    Gpm_Close(); /* We don't want to talk to xterm via gpm */
 	return 0;
@@ -5999,11 +6082,10 @@ sysmouse_close()
 }
 
 /*
  * Gets info from sysmouse and adds special keys to input buf.
  */
-/* ARGSUSED */
     static RETSIGTYPE
 sig_sysmouse SIGDEFARG(sigarg)
 {
     struct mouse_info	mouse;
     struct video_info	video;
@@ -6563,15 +6645,14 @@ static void xsmp_handle_interaction __AR
 
 /*
  * This is our chance to ask the user if they want to save,
  * or abort the logout
  */
-/*ARGSUSED*/
     static void
 xsmp_handle_interaction(smc_conn, client_data)
     SmcConn	smc_conn;
-    SmPointer	client_data;
+    SmPointer	client_data UNUSED;
 {
     cmdmod_T	save_cmdmod;
     int		cancel_shutdown = False;
 
     save_cmdmod = cmdmod;
@@ -6600,20 +6681,19 @@ xsmp_handle_interaction(smc_conn, client
 # endif
 
 /*
  * Callback that starts save-yourself.
  */
-/*ARGSUSED*/
     static void
 xsmp_handle_save_yourself(smc_conn, client_data, save_type,
 					       shutdown, interact_style, fast)
     SmcConn	smc_conn;
-    SmPointer	client_data;
-    int		save_type;
+    SmPointer	client_data UNUSED;
+    int		save_type UNUSED;
     Bool	shutdown;
-    int		interact_style;
-    Bool	fast;
+    int		interact_style UNUSED;
+    Bool	fast UNUSED;
 {
     /* Handle already being in saveyourself */
     if (xsmp.save_yourself)
 	SmcSaveYourselfDone(smc_conn, True);
     xsmp.save_yourself = True;
@@ -6643,15 +6723,14 @@ xsmp_handle_save_yourself(smc_conn, clie
 
 
 /*
  * Callback to warn us of imminent death.
  */
-/*ARGSUSED*/
     static void
 xsmp_die(smc_conn, client_data)
-    SmcConn	smc_conn;
-    SmPointer	client_data;
+    SmcConn	smc_conn UNUSED;
+    SmPointer	client_data UNUSED;
 {
     xsmp_close();
 
     /* quit quickly leaving swapfiles for modified buffers behind */
     getout_preserve_modified(0);
@@ -6659,29 +6738,27 @@ xsmp_die(smc_conn, client_data)
 
 
 /*
  * Callback to tell us that save-yourself has completed.
  */
-/*ARGSUSED*/
     static void
 xsmp_save_complete(smc_conn, client_data)
-    SmcConn	smc_conn;
-    SmPointer	client_data;
+    SmcConn	smc_conn UNUSED;
+    SmPointer	client_data UNUSED;
 {
     xsmp.save_yourself = False;
 }
 
 
 /*
  * Callback to tell us that an instigated shutdown was cancelled
  * (maybe even by us)
  */
-/*ARGSUSED*/
     static void
 xsmp_shutdown_cancelled(smc_conn, client_data)
     SmcConn	smc_conn;
-    SmPointer	client_data;
+    SmPointer	client_data UNUSED;
 {
     if (xsmp.save_yourself)
 	SmcSaveYourselfDone(smc_conn, True);
     xsmp.save_yourself = False;
     xsmp.shutdown = False;
@@ -6689,17 +6766,16 @@ xsmp_shutdown_cancelled(smc_conn, client
 
 
 /*
  * Callback to tell us that a new ICE connection has been established.
  */
-/*ARGSUSED*/
     static void
 xsmp_ice_connection(iceConn, clientData, opening, watchData)
     IceConn	iceConn;
-    IcePointer	clientData;
+    IcePointer	clientData UNUSED;
     Bool	opening;
-    IcePointer	*watchData;
+    IcePointer	*watchData UNUSED;
 {
     /* Intercept creation of ICE connection fd */
     if (opening)
     {
 	xsmp_icefd = IceConnectionNumber(iceConn);
@@ -6812,11 +6888,12 @@ xsmp_init(void)
 xsmp_close()
 {
     if (xsmp_icefd != -1)
     {
 	SmcCloseConnection(xsmp.smcconn, 0, NULL);
-	vim_free(xsmp.clientid);
+	if (xsmp.clientid != NULL)
+	    free(xsmp.clientid);
 	xsmp.clientid = NULL;
 	xsmp_icefd = -1;
     }
 }
 #endif /* USE_XSMP */
--- vim72.orig/src/os_unix.h
+++ vim72/src/os_unix.h
@@ -122,11 +122,11 @@
 #  define SIGPROTOARG	(int, int, struct sigcontext *)
 #  define SIGDEFARG(s)	(s, sig2, scont) int s, sig2; struct sigcontext *scont;
 #  define SIGDUMMYARG	0, 0, (struct sigcontext *)0
 # else
 #  define SIGPROTOARG	(int)
-#  define SIGDEFARG(s)	(s) int s;
+#  define SIGDEFARG(s)	(s) int s UNUSED;
 #  define SIGDUMMYARG	0
 # endif
 #else
 # define SIGPROTOARG   (void)
 # define SIGDEFARG(s)  ()
@@ -480,15 +480,10 @@ typedef struct dsc$descriptor   DESC;
 # ifdef HAVE_RENAME
 #  define mch_rename(src, dst) rename(src, dst)
 # else
 int mch_rename __ARGS((const char *src, const char *dest));
 # endif
-# ifdef VMS
-#  define mch_chdir(s) chdir(vms_fixfilename(s))
-# else
-#  define mch_chdir(s) chdir(s)
-# endif
 # ifndef VMS
 #  ifdef __MVS__
   /* on OS390 Unix getenv() doesn't return a pointer to persistent
    * storage -> use __getenv() */
 #   define mch_getenv(x) (char_u *)__getenv((char *)(x))
--- vim72.orig/src/os_unixx.h
+++ vim72/src/os_unixx.h
@@ -26,15 +26,10 @@
 
 # if defined(HAVE_SYS_WAIT_H) || defined(HAVE_UNION_WAIT)
 #  include <sys/wait.h>
 # endif
 
-# if defined(HAVE_SYS_SELECT_H) && \
-	(!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
-#  include <sys/select.h>
-# endif
-
 # ifndef WEXITSTATUS
 #  ifdef HAVE_UNION_WAIT
 #   define WEXITSTATUS(stat_val) ((stat_val).w_T.w_Retcode)
 #  else
 #   define WEXITSTATUS(stat_val) (((stat_val) >> 8) & 0377)
@@ -63,20 +58,10 @@
 
 #ifdef HAVE_STRING_H
 # include <string.h>
 #endif
 
-#ifndef HAVE_SELECT
-# ifdef HAVE_SYS_POLL_H
-#  include <sys/poll.h>
-# else
-#  ifdef HAVE_POLL_H
-#   include <poll.h>
-#  endif
-# endif
-#endif
-
 #ifdef HAVE_SYS_STREAM_H
 # include <sys/stream.h>
 #endif
 
 #ifdef HAVE_SYS_UTSNAME_H
--- vim72.orig/src/os_vms.c
+++ vim72/src/os_vms.c
@@ -226,11 +226,11 @@ mch_getenv(char_u *lognam)
 	return(cp);
     }
     else if ((sbuf = getenv((char *)lognam)))
     {
 	lengte = strlen(sbuf) + 1;
-	cp = (char_u *)malloc((size_t)lengte);
+	cp = (char_u *)alloc((size_t)lengte);
 	if (cp)
 	    strcpy((char *)cp, sbuf);
 	return cp;
     }
     else
@@ -379,11 +379,11 @@ vms_wproc(char *name, int val)
 	    return 1;
     }
     if (--vms_match_free == 0) {
 	/* add more space to store matches */
 	vms_match_alloced += EXPL_ALLOC_INC;
-	vms_fmatch = (char_u **)realloc(vms_fmatch,
+	vms_fmatch = (char_u **)vim_realloc(vms_fmatch,
 		sizeof(char **) * vms_match_alloced);
 	if (!vms_fmatch)
 	    return 0;
 	vms_match_free = EXPL_ALLOC_INC;
     }
@@ -458,11 +458,11 @@ mch_expand_wildcards(int num_pat, char_u
 
 	    /* allocate memory for pointers */
 	    if (--files_free < 1)
 	    {
 		files_alloced += EXPL_ALLOC_INC;
-		*file = (char_u **)realloc(*file,
+		*file = (char_u **)vim_realloc(*file,
 		    sizeof(char_u **) * files_alloced);
 		if (*file == NULL)
 		{
 		    *file = (char_u **)"";
 		    *num_file = 0;
@@ -612,18 +612,18 @@ vms_fixfilename(void *instring)
     len = strlen(instring) + 1;
     if (len > buflen)
     {
 	buflen = len + 128;
 	if (buf)
-	    buf = (char *)realloc(buf, buflen);
+	    buf = (char *)vim_realloc(buf, buflen);
 	else
-	    buf = (char *)calloc(buflen, sizeof(char));
+	    buf = (char *)alloc(buflen * sizeof(char));
     }
 
 #ifdef DEBUG
      char		 *tmpbuf = NULL;
-     tmpbuf = (char *)calloc(buflen, sizeof(char));
+     tmpbuf = (char *)alloc(buflen * sizeof(char));
      strcpy(tmpbuf, instring);
 #endif
 
     Fspec_Rms = buf;				/* for decc$to_vms */
 
--- vim72.orig/src/os_vms_conf.h
+++ vim72/src/os_vms_conf.h
@@ -112,10 +112,12 @@
 #define	HAVE_ERRNO_H
 #define HAVE_OPENDIR
 #define HAVE_PUTENV
 #define HAVE_SETENV
 #define HAVE_SETJMP_H
+#define HAVE_MATH_H
+#define HAVE_FLOAT_FUNCS
 
 #undef	HAVE_DIRENT_H
 #undef	HAVE_SYS_NDIR_H
 #undef	HAVE_SYS_DIR_H
 #undef	HAVE_NDIR_H
--- vim72.orig/src/os_w32exe.c
+++ vim72/src/os_w32exe.c
@@ -127,11 +127,12 @@ WinMain(
 #ifdef VIMDLL
     FreeLibrary(hLib);
 errout:
 #endif
     free(argv);
-    free(tofree);
+    if (tofree != NULL)
+	free(tofree);
 #ifdef FEAT_MBYTE
     free_cmd_argsW();
 #endif
 
     return 0;
--- vim72.orig/src/os_win16.c
+++ vim72/src/os_win16.c
@@ -119,11 +119,12 @@ WinMain(
     pmain = VimMain;
     pSaveInst(hInstance);
     pmain(argc, argv);
 
     free(argv);
-    free(tofree);
+    if (tofree != NULL)
+	free(tofree);
 
     return 0;
 }
 #endif
 
--- vim72.orig/src/os_win32.c
+++ vim72/src/os_win32.c
@@ -1585,11 +1585,11 @@ executable_exists(char *name)
     char	fname[_MAX_PATH];
 
 #ifdef FEAT_MBYTE
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
-	WCHAR	*p = enc_to_ucs2(name, NULL);
+	WCHAR	*p = enc_to_utf16(name, NULL);
 	WCHAR	fnamew[_MAX_PATH];
 	WCHAR	*dumw;
 	long	n;
 
 	if (p != NULL)
@@ -2438,11 +2438,11 @@ mch_dirname(
     {
 	WCHAR	wbuf[_MAX_PATH + 1];
 
 	if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
 	{
-	    char_u  *p = ucs2_to_enc(wbuf, NULL);
+	    char_u  *p = utf16_to_enc(wbuf, NULL);
 
 	    if (p != NULL)
 	    {
 		vim_strncpy(buf, p, len - 1);
 		vim_free(p);
@@ -2464,11 +2464,11 @@ mch_dirname(
 mch_getperm(char_u *name)
 {
 #ifdef FEAT_MBYTE
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
-	WCHAR	*p = enc_to_ucs2(name, NULL);
+	WCHAR	*p = enc_to_utf16(name, NULL);
 	long	n;
 
 	if (p != NULL)
 	{
 	    n = (long)GetFileAttributesW(p);
@@ -2493,11 +2493,11 @@ mch_setperm(
 {
     perm |= FILE_ATTRIBUTE_ARCHIVE;	/* file has changed, set archive bit */
 #ifdef FEAT_MBYTE
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
-	WCHAR	*p = enc_to_ucs2(name, NULL);
+	WCHAR	*p = enc_to_utf16(name, NULL);
 	long	n;
 
 	if (p != NULL)
 	{
 	    n = (long)SetFileAttributesW(p, perm);
@@ -2520,11 +2520,11 @@ mch_hide(char_u *name)
     int		perm;
 #ifdef FEAT_MBYTE
     WCHAR	*p = NULL;
 
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
-	p = enc_to_ucs2(name, NULL);
+	p = enc_to_utf16(name, NULL);
 #endif
 
 #ifdef FEAT_MBYTE
     if (p != NULL)
     {
@@ -2588,11 +2588,11 @@ mch_is_linked(char_u *fname)
     BY_HANDLE_FILE_INFORMATION inf;
 #ifdef FEAT_MBYTE
     WCHAR	*wn = NULL;
 
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
-	wn = enc_to_ucs2(fname, NULL);
+	wn = enc_to_utf16(fname, NULL);
     if (wn != NULL)
     {
 	hFile = CreateFileW(wn,		/* file name */
 		    GENERIC_READ,	/* access mode */
 		    0,			/* share mode */
@@ -4237,11 +4237,11 @@ mch_remove(char_u *name)
     WCHAR	*wn = NULL;
     int		n;
 
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
-	wn = enc_to_ucs2(name, NULL);
+	wn = enc_to_utf16(name, NULL);
 	if (wn != NULL)
 	{
 	    SetFileAttributesW(wn, FILE_ATTRIBUTE_NORMAL);
 	    n = DeleteFileW(wn) ? 0 : -1;
 	    vim_free(wn);
@@ -4380,12 +4380,12 @@ mch_rename(
     WCHAR	*wnew = NULL;
     int		retval = -1;
 
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
-	wold = enc_to_ucs2((char_u *)pszOldFile, NULL);
-	wnew = enc_to_ucs2((char_u *)pszNewFile, NULL);
+	wold = enc_to_utf16((char_u *)pszOldFile, NULL);
+	wnew = enc_to_utf16((char_u *)pszNewFile, NULL);
 	if (wold != NULL && wnew != NULL)
 	    retval = mch_wrename(wold, wnew);
 	vim_free(wold);
 	vim_free(wnew);
 	if (retval == 0 || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
@@ -4490,11 +4490,11 @@ mch_access(char *n, int p)
     int		retval = -1;	    /* default: fail */
 #ifdef FEAT_MBYTE
     WCHAR	*wn = NULL;
 
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
-	wn = enc_to_ucs2(n, NULL);
+	wn = enc_to_utf16(n, NULL);
 #endif
 
     if (mch_isdir(n))
     {
 	char TempName[_MAX_PATH + 16] = "";
@@ -4616,11 +4616,11 @@ getout:
     return retval;
 }
 
 #if defined(FEAT_MBYTE) || defined(PROTO)
 /*
- * Version of open() that may use ucs2 file name.
+ * Version of open() that may use UTF-16 file name.
  */
     int
 mch_open(char *name, int flags, int mode)
 {
     /* _wopen() does not work with Borland C 5.5: creates a read-only file. */
@@ -4628,11 +4628,11 @@ mch_open(char *name, int flags, int mode
     WCHAR	*wn;
     int		f;
 
     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
     {
-	wn = enc_to_ucs2(name, NULL);
+	wn = enc_to_utf16(name, NULL);
 	if (wn != NULL)
 	{
 	    f = _wopen(wn, flags, mode);
 	    vim_free(wn);
 	    if (f >= 0)
@@ -4646,11 +4646,11 @@ mch_open(char *name, int flags, int mode
 
     return open(name, flags, mode);
 }
 
 /*
- * Version of fopen() that may use ucs2 file name.
+ * Version of fopen() that may use UTF-16 file name.
  */
     FILE *
 mch_fopen(char *name, char *mode)
 {
     WCHAR	*wn, *wm;
@@ -4673,12 +4673,12 @@ mch_fopen(char *name, char *mode)
 	if (newMode == 't')
 	    _set_fmode(_O_TEXT);
 	else if (newMode == 'b')
 	    _set_fmode(_O_BINARY);
 # endif
-	wn = enc_to_ucs2(name, NULL);
-	wm = enc_to_ucs2(mode, NULL);
+	wn = enc_to_utf16(name, NULL);
+	wm = enc_to_utf16(mode, NULL);
 	if (wn != NULL && wm != NULL)
 	    f = _wfopen(wn, wm);
 	vim_free(wn);
 	vim_free(wm);
 
@@ -4774,12 +4774,12 @@ copy_infostreams(char_u *from, char_u *t
     void		*context = NULL;
     DWORD		lo, hi;
     int			len;
 
     /* Convert the file names to wide characters. */
-    fromw = enc_to_ucs2(from, NULL);
-    tow = enc_to_ucs2(to, NULL);
+    fromw = enc_to_utf16(from, NULL);
+    tow = enc_to_utf16(to, NULL);
     if (fromw != NULL && tow != NULL)
     {
 	/* Open the file for reading. */
 	sh = CreateFileW(fromw, GENERIC_READ, FILE_SHARE_READ, NULL,
 			     OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
@@ -5120,11 +5120,11 @@ fix_arg_enc(void)
 	return;		/* out of memory */
 
     for (i = 0; i < used_file_count; ++i)
     {
 	idx = used_file_indexes[i];
-	str = ucs2_to_enc(ArglistW[idx], NULL);
+	str = utf16_to_enc(ArglistW[idx], NULL);
 	if (str != NULL)
 	{
 #ifdef FEAT_DIFF
 	    /* When using diff mode may need to concatenate file name to
 	     * directory name.  Just like it's done in main(). */
--- vim72.orig/src/osdef1.h.in
+++ vim72/src/osdef1.h.in
@@ -23,11 +23,11 @@ extern int	fclose __ARGS((FILE *));
 extern int	fseek __ARGS((FILE *, long, int));
 #ifdef HAVE_FSEEKO
 extern int	fseeko __ARGS((FILE *, off_t, int));
 #endif
 extern long	ftell __ARGS((FILE *));
-#ifdef HAVE_FTELLO
+#ifdef HAVE_FSEEKO
 extern off_t	ftello __ARGS((FILE *));
 #endif
 extern void	rewind __ARGS((FILE *));
 extern int	fread __ARGS((char *, int, int, FILE *));
 extern int	fwrite __ARGS((char *, int, int, FILE *));
--- vim72.orig/src/po/check.vim
+++ vim72/src/po/check.vim
@@ -21,10 +21,13 @@ func! GetMline()
   endwhile
 
   " remove '%', not used for formatting.
   let idline = substitute(idline, "'%'", '', 'g')
 
+  " remove '%' used for plural forms.
+  let idline = substitute(idline, '\\nPlural-Forms: .\+;\\n', '', '')
+
   " remove everything but % items.
   return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g')
 endfunc
 
 " Start at the first "msgid" line.
--- vim72.orig/src/popupmnu.c
+++ vim72/src/popupmnu.c
@@ -343,25 +343,40 @@ pum_redraw()
 			if (curwin->w_p_rl)
 			{
 			    if (st != NULL)
 			    {
 				char_u	*rt = reverse_text(st);
-				char_u	*rt_saved = rt;
-				int	len, j;
 
 				if (rt != NULL)
 				{
-				    len = (int)STRLEN(rt);
-				    if (len > pum_width)
+				    char_u	*rt_start = rt;
+				    int		size;
+
+				    size = vim_strsize(rt);
+				    if (size > pum_width)
 				    {
-					for (j = pum_width; j < len; ++j)
+					do
+					{
+					    size -= has_mbyte
+						    ? (*mb_ptr2cells)(rt) : 1;
 					    mb_ptr_adv(rt);
-					len = pum_width;
+					} while (size > pum_width);
+
+					if (size < pum_width)
+					{
+					    /* Most left character requires
+					     * 2-cells but only 1 cell is
+					     * available on screen.  Put a
+					     * '<' on the left of the pum
+					     * item */
+					    *(--rt) = '<';
+					    size++;
+					}
 				    }
-				    screen_puts_len(rt, len, row,
-							col - len + 1, attr);
-				    vim_free(rt_saved);
+				    screen_puts_len(rt, (int)STRLEN(rt),
+						   row, col - size + 1, attr);
+				    vim_free(rt_start);
 				}
 				vim_free(st);
 			    }
 			    col -= width;
 			}
@@ -571,11 +586,11 @@ pum_set_selected(n, repeat)
 		}
 		else
 		{
 		    /* Don't want to sync undo in the current buffer. */
 		    ++no_u_sync;
-		    res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0);
+		    res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0, NULL);
 		    --no_u_sync;
 		    if (res == OK)
 		    {
 			/* Edit a new, empty buffer. Set options for a "wipeout"
 			 * buffer. */
@@ -623,11 +638,11 @@ pum_set_selected(n, repeat)
 			}
 		    }
 
 		    curbuf->b_changed = 0;
 		    curbuf->b_p_ma = FALSE;
-		    curwin->w_cursor.lnum = 0;
+		    curwin->w_cursor.lnum = 1;
 		    curwin->w_cursor.col = 0;
 
 		    if (curwin != curwin_save && win_valid(curwin_save))
 		    {
 			/* Return cursor to where we were */
--- vim72.orig/src/proto/buffer.pro
+++ vim72/src/proto/buffer.pro
@@ -31,33 +31,32 @@ void buf_set_name __ARGS((int fnum, char
 void buf_name_changed __ARGS((buf_T *buf));
 buf_T *setaltfname __ARGS((char_u *ffname, char_u *sfname, linenr_T lnum));
 char_u *getaltfname __ARGS((int errmsg));
 int buflist_add __ARGS((char_u *fname, int flags));
 void buflist_slash_adjust __ARGS((void));
-void buflist_altfpos __ARGS((void));
+void buflist_altfpos __ARGS((win_T *win));
 int otherfile __ARGS((char_u *ffname));
 void buf_setino __ARGS((buf_T *buf));
 void fileinfo __ARGS((int fullname, int shorthelp, int dont_truncate));
-void col_print __ARGS((char_u *buf, int col, int vcol));
+void col_print __ARGS((char_u *buf, size_t buflen, int col, int vcol));
 void maketitle __ARGS((void));
 void resettitle __ARGS((void));
 void free_titles __ARGS((void));
 int build_stl_str_hl __ARGS((win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use_sandbox, int fillchar, int maxwidth, struct stl_hlrec *hltab, struct stl_hlrec *tabtab));
-void get_rel_pos __ARGS((win_T *wp, char_u *str));
-int append_arg_number __ARGS((win_T *wp, char_u *buf, int add_file, int maxlen));
+void get_rel_pos __ARGS((win_T *wp, char_u *buf, int buflen));
 char_u *fix_fname __ARGS((char_u *fname));
 void fname_expand __ARGS((buf_T *buf, char_u **ffname, char_u **sfname));
 char_u *alist_name __ARGS((aentry_T *aep));
 void do_arg_all __ARGS((int count, int forceit, int keep_tabs));
 void ex_buffer_all __ARGS((exarg_T *eap));
 void do_modelines __ARGS((int flags));
 int read_viminfo_bufferlist __ARGS((vir_T *virp, int writing));
 void write_viminfo_bufferlist __ARGS((FILE *fp));
 char *buf_spname __ARGS((buf_T *buf));
 void buf_addsign __ARGS((buf_T *buf, int id, linenr_T lnum, int typenr));
-int buf_change_sign_type __ARGS((buf_T *buf, int markId, int typenr));
-int_u buf_getsigntype __ARGS((buf_T *buf, linenr_T lnum, int type));
+linenr_T buf_change_sign_type __ARGS((buf_T *buf, int markId, int typenr));
+int buf_getsigntype __ARGS((buf_T *buf, linenr_T lnum, int type));
 linenr_T buf_delsign __ARGS((buf_T *buf, int id));
 int buf_findsign __ARGS((buf_T *buf, int id));
 int buf_findsign_id __ARGS((buf_T *buf, linenr_T lnum));
 int buf_findsigntype_id __ARGS((buf_T *buf, linenr_T lnum, int typenr));
 int buf_signcount __ARGS((buf_T *buf, linenr_T lnum));
--- vim72.orig/src/proto/edit.pro
+++ vim72/src/proto/edit.pro
@@ -6,11 +6,11 @@ void display_dollar __ARGS((colnr_T col)
 void change_indent __ARGS((int type, int amount, int round, int replaced, int call_changed_bytes));
 void truncate_spaces __ARGS((char_u *line));
 void backspace_until_column __ARGS((int col));
 int vim_is_ctrl_x_key __ARGS((int c));
 int ins_compl_add_infercase __ARGS((char_u *str, int len, int icase, char_u *fname, int dir, int flags));
-void set_completion __ARGS((int startcol, list_T *list));
+void set_completion __ARGS((colnr_T startcol, list_T *list));
 void ins_compl_show_pum __ARGS((void));
 char_u *find_word_start __ARGS((char_u *ptr));
 char_u *find_word_end __ARGS((char_u *ptr));
 int ins_compl_active __ARGS((void));
 int ins_compl_add_tv __ARGS((typval_T *tv, int dir));
--- vim72.orig/src/proto/eval.pro
+++ vim72/src/proto/eval.pro
@@ -15,11 +15,11 @@ int eval_printexpr __ARGS((char_u *fname
 void eval_diff __ARGS((char_u *origfile, char_u *newfile, char_u *outfile));
 void eval_patch __ARGS((char_u *origfile, char_u *difffile, char_u *outfile));
 int eval_to_bool __ARGS((char_u *arg, int *error, char_u **nextcmd, int skip));
 char_u *eval_to_string_skip __ARGS((char_u *arg, char_u **nextcmd, int skip));
 int skip_expr __ARGS((char_u **pp));
-char_u *eval_to_string __ARGS((char_u *arg, char_u **nextcmd, int dolist));
+char_u *eval_to_string __ARGS((char_u *arg, char_u **nextcmd, int convert));
 char_u *eval_to_string_safe __ARGS((char_u *arg, char_u **nextcmd, int use_sandbox));
 int eval_to_number __ARGS((char_u *expr));
 list_T *eval_spell_expr __ARGS((char_u *badword, char_u *expr));
 int get_spellword __ARGS((list_T *list, char_u **pp));
 typval_T *eval_expr __ARGS((char_u *arg, char_u **nextcmd));
@@ -44,24 +44,33 @@ void del_menutrans_vars __ARGS((void));
 char_u *get_user_var_name __ARGS((expand_T *xp, int idx));
 list_T *list_alloc __ARGS((void));
 void list_unref __ARGS((list_T *l));
 void list_free __ARGS((list_T *l, int recurse));
 dictitem_T *dict_lookup __ARGS((hashitem_T *hi));
+char_u *list_find_str __ARGS((list_T *l, long idx));
+int list_append_tv __ARGS((list_T *l, typval_T *tv));
 int list_append_dict __ARGS((list_T *list, dict_T *dict));
+int list_append_string __ARGS((list_T *l, char_u *str, int len));
 int garbage_collect __ARGS((void));
 dict_T *dict_alloc __ARGS((void));
+dictitem_T *dictitem_alloc __ARGS((char_u *key));
+void dictitem_free __ARGS((dictitem_T *item));
+int dict_add __ARGS((dict_T *d, dictitem_T *item));
 int dict_add_nr_str __ARGS((dict_T *d, char *key, long nr, char_u *str));
 char_u *get_dict_string __ARGS((dict_T *d, char_u *key, int save));
 long get_dict_number __ARGS((dict_T *d, char_u *key));
 char_u *get_function_name __ARGS((expand_T *xp, int idx));
 char_u *get_expr_name __ARGS((expand_T *xp, int idx));
 long do_searchpair __ARGS((char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit));
 void set_vim_var_nr __ARGS((int idx, long val));
 long get_vim_var_nr __ARGS((int idx));
 char_u *get_vim_var_str __ARGS((int idx));
-void set_vcount __ARGS((long count, long count1));
+list_T *get_vim_var_list __ARGS((int idx));
+void set_vim_var_char __ARGS((int c));
+void set_vcount __ARGS((long count, long count1, int set_prevcount));
 void set_vim_var_string __ARGS((int idx, char_u *val, int len));
+void set_vim_var_list __ARGS((int idx, list_T *val));
 void set_reg_var __ARGS((int c));
 char_u *v_exception __ARGS((char_u *oldval));
 char_u *v_throwpoint __ARGS((char_u *oldval));
 char_u *set_cmdarg __ARGS((exarg_T *eap, char_u *oldarg));
 void free_tv __ARGS((typval_T *varp));
@@ -70,10 +79,11 @@ long get_tv_number_chk __ARGS((typval_T
 char_u *get_tv_string_chk __ARGS((typval_T *varp));
 char_u *get_var_value __ARGS((char_u *name));
 void new_script_vars __ARGS((scid_T id));
 void init_var_dict __ARGS((dict_T *dict, dictitem_T *dict_var));
 void vars_clear __ARGS((hashtab_T *ht));
+void copy_tv __ARGS((typval_T *from, typval_T *to));
 void ex_echo __ARGS((exarg_T *eap));
 void ex_echohl __ARGS((exarg_T *eap));
 void ex_execute __ARGS((exarg_T *eap));
 void ex_function __ARGS((exarg_T *eap));
 void free_all_functions __ARGS((void));
@@ -92,8 +102,9 @@ int func_has_ended __ARGS((void *cookie)
 int func_has_abort __ARGS((void *cookie));
 int read_viminfo_varlist __ARGS((vir_T *virp, int writing));
 void write_viminfo_varlist __ARGS((FILE *fp));
 int store_session_globals __ARGS((FILE *fd));
 void last_set_msg __ARGS((scid_T scriptID));
+void ex_oldfiles __ARGS((exarg_T *eap));
 int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen));
 char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));
 /* vim: set ft=c : */
--- vim72.orig/src/proto/ex_cmds.pro
+++ vim72/src/proto/ex_cmds.pro
@@ -7,13 +7,13 @@ int do_move __ARGS((linenr_T line1, line
 void ex_copy __ARGS((linenr_T line1, linenr_T line2, linenr_T n));
 void free_prev_shellcmd __ARGS((void));
 void do_bang __ARGS((int addr_count, exarg_T *eap, int forceit, int do_in, int do_out));
 void do_shell __ARGS((char_u *cmd, int flags));
 char_u *make_filter_cmd __ARGS((char_u *cmd, char_u *itmp, char_u *otmp));
-void append_redir __ARGS((char_u *buf, char_u *opt, char_u *fname));
+void append_redir __ARGS((char_u *buf, int buflen, char_u *opt, char_u *fname));
 int viminfo_error __ARGS((char *errnum, char *message, char_u *line));
-int read_viminfo __ARGS((char_u *file, int want_info, int want_marks, int forceit));
+int read_viminfo __ARGS((char_u *file, int flags));
 void write_viminfo __ARGS((char_u *file, int forceit));
 int viminfo_readline __ARGS((vir_T *virp));
 char_u *viminfo_readstring __ARGS((vir_T *virp, int off, int convert));
 void viminfo_writestring __ARGS((FILE *fd, char_u *p));
 void do_fixdel __ARGS((exarg_T *eap));
@@ -25,11 +25,11 @@ void ex_write __ARGS((exarg_T *eap));
 int do_write __ARGS((exarg_T *eap));
 void ex_wnext __ARGS((exarg_T *eap));
 void do_wqall __ARGS((exarg_T *eap));
 int not_writing __ARGS((void));
 int getfile __ARGS((int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum, int forceit));
-int do_ecmd __ARGS((int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags));
+int do_ecmd __ARGS((int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags, win_T *oldwin));
 void ex_append __ARGS((exarg_T *eap));
 void ex_change __ARGS((exarg_T *eap));
 void ex_z __ARGS((exarg_T *eap));
 int check_restricted __ARGS((void));
 int check_secure __ARGS((void));
@@ -53,7 +53,10 @@ void ex_sign __ARGS((exarg_T *eap));
 void sign_gui_started __ARGS((void));
 int sign_get_attr __ARGS((int typenr, int line));
 char_u *sign_get_text __ARGS((int typenr));
 void *sign_get_image __ARGS((int typenr));
 char_u *sign_typenr2name __ARGS((int typenr));
+void free_signs __ARGS((void));
+char_u *get_sign_name __ARGS((expand_T *xp, int idx));
+void set_context_in_sign_cmd __ARGS((expand_T *xp, char_u *arg));
 void ex_drop __ARGS((exarg_T *eap));
 /* vim: set ft=c : */
--- vim72.orig/src/proto/ex_cmds2.pro
+++ vim72/src/proto/ex_cmds2.pro
@@ -22,10 +22,12 @@ void profile_self __ARGS((proftime_T *se
 void profile_get_wait __ARGS((proftime_T *tm));
 void profile_sub_wait __ARGS((proftime_T *tm, proftime_T *tma));
 int profile_equal __ARGS((proftime_T *tm1, proftime_T *tm2));
 int profile_cmp __ARGS((proftime_T *tm1, proftime_T *tm2));
 void ex_profile __ARGS((exarg_T *eap));
+char_u *get_profile_name __ARGS((expand_T *xp, int idx));
+void set_context_in_profile_cmd __ARGS((expand_T *xp, char_u *arg));
 void profile_dump __ARGS((void));
 void script_prof_save __ARGS((proftime_T *tm));
 void script_prof_restore __ARGS((proftime_T *tm));
 void prof_inchar_enter __ARGS((void));
 void prof_inchar_exit __ARGS((void));
--- vim72.orig/src/proto/ex_docmd.pro
+++ vim72/src/proto/ex_docmd.pro
@@ -50,6 +50,7 @@ int find_cmdline_var __ARGS((char_u *src
 char_u *eval_vars __ARGS((char_u *src, char_u *srcstart, int *usedlen, linenr_T *lnump, char_u **errormsg, int *escaped));
 char_u *expand_sfile __ARGS((char_u *arg));
 int put_eol __ARGS((FILE *fd));
 int put_line __ARGS((FILE *fd, char *s));
 void dialog_msg __ARGS((char_u *buff, char *format, char_u *fname));
+char_u *get_behave_arg __ARGS((expand_T *xp, int idx));
 /* vim: set ft=c : */
--- vim72.orig/src/proto/ex_getln.pro
+++ vim72/src/proto/ex_getln.pro
@@ -2,10 +2,11 @@
 char_u *getcmdline __ARGS((int firstc, long count, int indent));
 char_u *getcmdline_prompt __ARGS((int firstc, char_u *prompt, int attr, int xp_context, char_u *xp_arg));
 int text_locked __ARGS((void));
 void text_locked_msg __ARGS((void));
 int curbuf_locked __ARGS((void));
+int allbuf_locked __ARGS((void));
 char_u *getexline __ARGS((int c, void *dummy, int indent));
 char_u *getexmodeline __ARGS((int promptc, void *dummy, int indent));
 int cmdline_overstrike __ARGS((void));
 int cmdline_at_end __ARGS((void));
 colnr_T cmdline_getvcol_cursor __ARGS((void));
@@ -29,11 +30,11 @@ void tilde_replace __ARGS((char_u *orig_
 char_u *sm_gettail __ARGS((char_u *s));
 char_u *addstar __ARGS((char_u *fname, int len, int context));
 void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col));
 int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches));
 int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int))));
-char_u *globpath __ARGS((char_u *path, char_u *file));
+char_u *globpath __ARGS((char_u *path, char_u *file, int expand_options));
 void init_history __ARGS((void));
 int get_histtype __ARGS((char_u *name));
 void add_to_history __ARGS((int histype, char_u *new_entry, int in_map, int sep));
 int get_history_idx __ARGS((int histype));
 char_u *get_cmdline_str __ARGS((void));
--- vim72.orig/src/proto/gui.pro
+++ vim72/src/proto/gui.pro
@@ -41,10 +41,11 @@ int send_tabline_event __ARGS((int nr));
 void send_tabline_menu_event __ARGS((int tabidx, int event));
 void gui_remove_scrollbars __ARGS((void));
 void gui_create_scrollbar __ARGS((scrollbar_T *sb, int type, win_T *wp));
 scrollbar_T *gui_find_scrollbar __ARGS((long ident));
 void gui_drag_scrollbar __ARGS((scrollbar_T *sb, long value, int still_dragging));
+void gui_may_update_scrollbars __ARGS((void));
 void gui_update_scrollbars __ARGS((int force));
 int gui_do_scroll __ARGS((void));
 int gui_do_horiz_scroll __ARGS((void));
 void gui_check_colors __ARGS((void));
 guicolor_T gui_get_color __ARGS((char_u *name));
--- vim72.orig/src/proto/gui_gtk_x11.pro
+++ vim72/src/proto/gui_gtk_x11.pro
@@ -14,10 +14,12 @@ void gui_mch_forked __ARGS((void));
 void gui_mch_new_colors __ARGS((void));
 int gui_mch_open __ARGS((void));
 void gui_mch_exit __ARGS((int rc));
 int gui_mch_get_winpos __ARGS((int *x, int *y));
 void gui_mch_set_winpos __ARGS((int x, int y));
+int gui_mch_maximized __ARGS((void));
+void gui_mch_unmaximize __ARGS((void));
 void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height, int direction));
 void gui_mch_get_screen_dimensions __ARGS((int *screen_w, int *screen_h));
 void gui_mch_settitle __ARGS((char_u *title, char_u *icon));
 void gui_mch_enable_menu __ARGS((int showit));
 void gui_mch_show_toolbar __ARGS((int showit));
--- vim72.orig/src/proto/if_cscope.pro
+++ vim72/src/proto/if_cscope.pro
@@ -1,6 +1,8 @@
 /* if_cscope.c */
+char_u *get_cscope_name __ARGS((expand_T *xp, int idx));
+void set_context_in_cscope_cmd __ARGS((expand_T *xp, char_u *arg, cmdidx_T cmdidx));
 void do_cscope __ARGS((exarg_T *eap));
 void do_scscope __ARGS((exarg_T *eap));
 void do_cstag __ARGS((exarg_T *eap));
 int cs_fgets __ARGS((char_u *buf, int size));
 void cs_free_tags __ARGS((void));
--- vim72.orig/src/proto/if_mzsch.pro
+++ vim72/src/proto/if_mzsch.pro
@@ -11,14 +11,9 @@ void raise_if_error __ARGS((void));
 buf_T *get_valid_buffer __ARGS((void *));
 win_T *get_valid_window __ARGS((void *));
 void mzvim_check_threads __ARGS((void));
 void mzvim_reset_timer __ARGS((void));
 void *mzvim_eval_string __ARGS((char_u *str));
-struct Scheme_Object *mzvim_apply __ARGS((struct Scheme_Object *, int argc,
-    struct Scheme_Object **));
-int mzthreads_allowed (void);
-#ifdef FEAT_GUI_KDE
-void timer_proc (void);
-void mzscheme_kde_start_timer (void);
-void mzscheme_kde_stop_timer (void);
-#endif
+int mzthreads_allowed __ARGS((void));
+void mzscheme_main __ARGS((void));
+void do_mzeval __ARGS((char_u *str, typval_T *rettv));
 /* vim: set ft=c : */
--- vim72.orig/src/proto/mark.pro
+++ vim72/src/proto/mark.pro
@@ -24,7 +24,7 @@ void set_last_cursor __ARGS((win_T *win)
 void free_all_marks __ARGS((void));
 int read_viminfo_filemark __ARGS((vir_T *virp, int force));
 void write_viminfo_filemarks __ARGS((FILE *fp));
 int removable __ARGS((char_u *name));
 int write_viminfo_marks __ARGS((FILE *fp_out));
-void copy_viminfo_marks __ARGS((vir_T *virp, FILE *fp_out, int count, int eof));
+void copy_viminfo_marks __ARGS((vir_T *virp, FILE *fp_out, int count, int eof, int flags));
 /* vim: set ft=c : */
--- vim72.orig/src/proto/mbyte.pro
+++ vim72/src/proto/mbyte.pro
@@ -5,14 +5,16 @@ int bomb_size __ARGS((void));
 int mb_get_class __ARGS((char_u *p));
 int dbcs_class __ARGS((unsigned lead, unsigned trail));
 int latin_char2len __ARGS((int c));
 int latin_char2bytes __ARGS((int c, char_u *buf));
 int latin_ptr2len __ARGS((char_u *p));
+int latin_ptr2len_len __ARGS((char_u *p, int size));
 int utf_char2cells __ARGS((int c));
 int latin_ptr2cells __ARGS((char_u *p));
 int utf_ptr2cells __ARGS((char_u *p));
 int dbcs_ptr2cells __ARGS((char_u *p));
+int latin_ptr2cells_len __ARGS((char_u *p, int size));
 int latin_char2cells __ARGS((int c));
 int latin_off2cells __ARGS((unsigned off, unsigned max_off));
 int dbcs_off2cells __ARGS((unsigned off, unsigned max_off));
 int utf_off2cells __ARGS((unsigned off, unsigned max_off));
 int latin_ptr2char __ARGS((char_u *p));
@@ -83,10 +85,11 @@ void im_shutdown __ARGS((void));
 int xim_get_status_area_height __ARGS((void));
 int im_get_status __ARGS((void));
 int preedit_get_status __ARGS((void));
 int im_is_preediting __ARGS((void));
 int convert_setup __ARGS((vimconv_T *vcp, char_u *from, char_u *to));
+int convert_setup_ext __ARGS((vimconv_T *vcp, char_u *from, int from_unicode_is_utf8, char_u *to, int to_unicode_is_utf8));
 int convert_input __ARGS((char_u *ptr, int len, int maxlen));
 int convert_input_safe __ARGS((char_u *ptr, int len, int maxlen, char_u **restp, int *restlenp));
 char_u *string_convert __ARGS((vimconv_T *vcp, char_u *ptr, int *lenp));
 char_u *string_convert_ext __ARGS((vimconv_T *vcp, char_u *ptr, int *lenp, int *unconvlenp));
 /* vim: set ft=c : */
--- vim72.orig/src/proto/message.pro
+++ vim72/src/proto/message.pro
@@ -52,10 +52,11 @@ void repeat_message __ARGS((void));
 void msg_clr_eos __ARGS((void));
 void msg_clr_eos_force __ARGS((void));
 void msg_clr_cmdline __ARGS((void));
 int msg_end __ARGS((void));
 void msg_check __ARGS((void));
+int redirecting __ARGS((void));
 void verbose_enter __ARGS((void));
 void verbose_leave __ARGS((void));
 void verbose_enter_scroll __ARGS((void));
 void verbose_leave_scroll __ARGS((void));
 void verbose_stop __ARGS((void));
--- vim72.orig/src/proto/misc1.pro
+++ vim72/src/proto/misc1.pro
@@ -83,10 +83,11 @@ int get_lisp_indent __ARGS((void));
 void prepare_to_exit __ARGS((void));
 void preserve_exit __ARGS((void));
 int vim_fexists __ARGS((char_u *fname));
 void line_breakcheck __ARGS((void));
 void fast_breakcheck __ARGS((void));
+int expand_wildcards_eval __ARGS((char_u **pat, int *num_file, char_u ***file, int flags));
 int expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
 int match_suffix __ARGS((char_u *fname));
 int unix_expandpath __ARGS((garray_T *gap, char_u *path, int wildoff, int flags, int didstar));
 int gen_expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
 void addfile __ARGS((garray_T *gap, char_u *f, int flags));
--- vim72.orig/src/proto/misc2.pro
+++ vim72/src/proto/misc2.pro
@@ -57,11 +57,11 @@ void ga_append __ARGS((garray_T *gap, in
 int name_to_mod_mask __ARGS((int c));
 int simplify_key __ARGS((int key, int *modifiers));
 int handle_x_keys __ARGS((int key));
 char_u *get_special_key_name __ARGS((int c, int modifiers));
 int trans_special __ARGS((char_u **srcp, char_u *dst, int keycode));
-int find_special_key __ARGS((char_u **srcp, int *modp, int keycode));
+int find_special_key __ARGS((char_u **srcp, int *modp, int keycode, int keep_x_key));
 int extract_modifiers __ARGS((int key, int *modp));
 int find_special_key_in_table __ARGS((int c));
 int get_special_key_code __ARGS((char_u *name));
 char_u *get_key_name __ARGS((int i));
 int get_mouse_button __ARGS((int code, int *is_click, int *is_drag));
--- vim72.orig/src/proto/netbeans.pro
+++ vim72/src/proto/netbeans.pro
@@ -9,16 +9,16 @@ void netbeans_beval_cb __ARGS((BalloonEv
 void netbeans_startup_done __ARGS((void));
 void netbeans_send_disconnect __ARGS((void));
 void netbeans_frame_moved __ARGS((int new_x, int new_y));
 void netbeans_file_activated __ARGS((buf_T *bufp));
 void netbeans_file_opened __ARGS((buf_T *bufp));
-void netbeans_file_closed __ARGS((buf_T *bufp));
+void netbeans_file_killed __ARGS((buf_T *bufp));
 void netbeans_inserted __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, char_u *txt, int newlen));
 void netbeans_removed __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, long len));
 void netbeans_unmodified __ARGS((buf_T *bufp));
 void netbeans_button_release __ARGS((int button));
-void netbeans_keycommand __ARGS((int key));
+int netbeans_keycommand __ARGS((int key));
 void netbeans_save_buffer __ARGS((buf_T *bufp));
 void netbeans_deleted_all_lines __ARGS((buf_T *bufp));
 int netbeans_is_guarded __ARGS((linenr_T top, linenr_T bot));
 void netbeans_draw_multisign_indicator __ARGS((int row));
 void netbeans_draw_multisign_indicator __ARGS((int row));
--- vim72.orig/src/proto/option.pro
+++ vim72/src/proto/option.pro
@@ -27,10 +27,11 @@ char_u *get_highlight_default __ARGS((vo
 char_u *get_encoding_default __ARGS((void));
 int makeset __ARGS((FILE *fd, int opt_flags, int local_only));
 int makefoldset __ARGS((FILE *fd));
 void clear_termoptions __ARGS((void));
 void free_termoptions __ARGS((void));
+void free_one_termoption __ARGS((char_u *var));
 void set_term_defaults __ARGS((void));
 void comp_col __ARGS((void));
 char_u *get_equalprg __ARGS((void));
 void win_copy_options __ARGS((win_T *wp_from, win_T *wp_to));
 void copy_winopt __ARGS((winopt_T *from, winopt_T *to));
@@ -42,10 +43,11 @@ void reset_modifiable __ARGS((void));
 void set_iminsert_global __ARGS((void));
 void set_imsearch_global __ARGS((void));
 void set_context_in_set_cmd __ARGS((expand_T *xp, char_u *arg, int opt_flags));
 int ExpandSettings __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
 int ExpandOldSetting __ARGS((int *num_file, char_u ***file));
+int langmap_adjust_mb __ARGS((int c));
 int has_format_option __ARGS((int x));
 int shortmess __ARGS((int x));
 void vimrc_found __ARGS((char_u *fname, char_u *envname));
 void change_compatible __ARGS((int on));
 int option_was_set __ARGS((char_u *name));
--- vim72.orig/src/proto/os_mswin.pro
+++ vim72/src/proto/os_mswin.pro
@@ -20,18 +20,18 @@ int mch_has_exp_wildcard __ARGS((char_u
 int mch_has_wildcard __ARGS((char_u *p));
 int mch_chdir __ARGS((char *path));
 int can_end_termcap_mode __ARGS((int give_msg));
 int mch_screenmode __ARGS((char_u *arg));
 int mch_libcall __ARGS((char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result));
-int utf8_to_ucs2 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp));
-int ucs2_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr));
+int utf8_to_utf16 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp));
+int utf16_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr));
 void MultiByteToWideChar_alloc __ARGS((UINT cp, DWORD flags, LPCSTR in, int inlen, LPWSTR *out, int *outlen));
 void WideCharToMultiByte_alloc __ARGS((UINT cp, DWORD flags, LPCWSTR in, int inlen, LPSTR *out, int *outlen, LPCSTR def, LPBOOL useddef));
 int clip_mch_own_selection __ARGS((VimClipboard *cbd));
 void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
-short_u *enc_to_ucs2 __ARGS((char_u *str, int *lenp));
-char_u *ucs2_to_enc __ARGS((short_u *str, int *lenp));
+short_u *enc_to_utf16 __ARGS((char_u *str, int *lenp));
+char_u *utf16_to_enc __ARGS((short_u *str, int *lenp));
 void clip_mch_request_selection __ARGS((VimClipboard *cbd));
 void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen));
 void clip_mch_set_selection __ARGS((VimClipboard *cbd));
 void DumpPutS __ARGS((const char *psz));
 int mch_get_winpos __ARGS((int *x, int *y));
--- vim72.orig/src/proto/os_unix.pro
+++ vim72/src/proto/os_unix.pro
@@ -1,6 +1,7 @@
 /* os_unix.c */
+int mch_chdir __ARGS((char *path));
 void mch_write __ARGS((char_u *s, int len));
 int mch_inchar __ARGS((char_u *buf, int maxlen, long wtime, int tb_change_cnt));
 int mch_char_avail __ARGS((void));
 long_u mch_total_mem __ARGS((int special));
 void mch_delay __ARGS((long msec, int ignoreinput));
--- vim72.orig/src/proto/spell.pro
+++ vim72/src/proto/spell.pro
@@ -20,7 +20,7 @@ void ex_spellinfo __ARGS((exarg_T *eap))
 void ex_spelldump __ARGS((exarg_T *eap));
 void spell_dump_compl __ARGS((buf_T *buf, char_u *pat, int ic, int *dir, int dumpflags_arg));
 char_u *spell_to_word_end __ARGS((char_u *start, buf_T *buf));
 int spell_word_start __ARGS((int startcol));
 void spell_expand_check_cap __ARGS((colnr_T col));
-int expand_spelling __ARGS((linenr_T lnum, int col, char_u *pat, char_u ***matchp));
+int expand_spelling __ARGS((linenr_T lnum, char_u *pat, char_u ***matchp));
 /* vim: set ft=c : */
--- vim72.orig/src/proto/ui.pro
+++ vim72/src/proto/ui.pro
@@ -46,10 +46,11 @@ void ui_cursor_shape __ARGS((void));
 int check_col __ARGS((int col));
 int check_row __ARGS((int row));
 void open_app_context __ARGS((void));
 void x11_setup_atoms __ARGS((Display *dpy));
 void clip_x11_request_selection __ARGS((Widget myShell, Display *dpy, VimClipboard *cbd));
+void yank_cut_buffer0 __ARGS((Display *dpy, VimClipboard *cbd));
 void clip_x11_lose_selection __ARGS((Widget myShell, VimClipboard *cbd));
 int clip_x11_own_selection __ARGS((Widget myShell, VimClipboard *cbd));
 void clip_x11_set_selection __ARGS((VimClipboard *cbd));
 int jump_to_mouse __ARGS((int flags, int *inclusive, int which_button));
 int mouse_comp_pos __ARGS((win_T *win, int *rowp, int *colp, linenr_T *lnump));
--- vim72.orig/src/proto/window.pro
+++ vim72/src/proto/window.pro
@@ -1,20 +1,24 @@
 /* window.c */
 void do_window __ARGS((int nchar, long Prenum, int xchar));
 int win_split __ARGS((int size, int flags));
+int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
 int win_valid __ARGS((win_T *win));
 int win_count __ARGS((void));
 int make_windows __ARGS((int count, int vertical));
 void win_move_after __ARGS((win_T *win1, win_T *win2));
 void win_equal __ARGS((win_T *next_curwin, int current, int dir));
 void close_windows __ARGS((buf_T *buf, int keep_curwin));
 void win_close __ARGS((win_T *win, int free_buf));
 void win_close_othertab __ARGS((win_T *win, int free_buf, tabpage_T *tp));
 void win_free_all __ARGS((void));
+win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
 void close_others __ARGS((int message, int forceit));
 void curwin_init __ARGS((void));
+void win_init_empty __ARGS((win_T *wp));
 int win_alloc_first __ARGS((void));
+void win_alloc_aucmd_win __ARGS((void));
 void win_init_size __ARGS((void));
 void free_tabpage __ARGS((tabpage_T *tp));
 int win_new_tabpage __ARGS((int after));
 int may_open_tabpage __ARGS((void));
 int make_tabpages __ARGS((int maxcount));
@@ -28,10 +32,12 @@ void tabpage_move __ARGS((int nr));
 void win_goto __ARGS((win_T *wp));
 win_T *win_find_nr __ARGS((int winnr));
 void win_enter __ARGS((win_T *wp, int undo_sync));
 win_T *buf_jump_open_win __ARGS((buf_T *buf));
 win_T *buf_jump_open_tab __ARGS((buf_T *buf));
+void win_append __ARGS((win_T *after, win_T *wp));
+void win_remove __ARGS((win_T *wp, tabpage_T *tp));
 int win_alloc_lines __ARGS((win_T *wp));
 void win_free_lsize __ARGS((win_T *wp));
 void shell_new_rows __ARGS((void));
 void shell_new_columns __ARGS((void));
 void win_size_save __ARGS((garray_T *gap));
@@ -56,10 +62,12 @@ int path_with_url __ARGS((char_u *fname)
 int vim_isAbsName __ARGS((char_u *name));
 int vim_FullName __ARGS((char_u *fname, char_u *buf, int len, int force));
 int min_rows __ARGS((void));
 int only_one_window __ARGS((void));
 void check_lnums __ARGS((int do_curwin));
+void make_snapshot __ARGS((int idx));
+void restore_snapshot __ARGS((int idx, int close_curwin));
 int win_hasvertsplit __ARGS((void));
 int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
 int match_delete __ARGS((win_T *wp, int id, int perr));
 void clear_matches __ARGS((win_T *wp));
 matchitem_T *get_match __ARGS((win_T *wp, int id));
--- vim72.orig/src/pty.c
+++ vim72/src/pty.c
@@ -268,13 +268,14 @@ OpenPTY(ttyn)
     *ttyn = TtyName;
     return f;
 }
 #endif
 
-#if defined(HAVE_SVR4_PTYS) && !defined(PTY_DONE) && !defined(hpux)
+#if defined(HAVE_SVR4_PTYS) && !defined(PTY_DONE) && !defined(hpux) && !defined(MACOS_X)
 
-/* NOTE: Even though HPUX can have /dev/ptmx, the code below doesn't work! */
+/* NOTE: Even though HPUX can have /dev/ptmx, the code below doesn't work!
+ * Same for Mac OS X Leopard. */
 #define PTY_DONE
     int
 OpenPTY(ttyn)
     char **ttyn;
 {
--- vim72.orig/src/quickfix.c
+++ vim72/src/quickfix.c
@@ -1417,11 +1417,13 @@ qf_jump(qi, dir, errornr, forceit)
     char_u		*old_swb = p_swb;
     unsigned		old_swb_flags = swb_flags;
     int			opened_window = FALSE;
     win_T		*win;
     win_T		*altwin;
+    int			flags;
 #endif
+    win_T		*oldwin = curwin;
     int			print_message = TRUE;
     int			len;
 #ifdef FEAT_FOLDING
     int			old_KeyTyped = KeyTyped; /* getting file may reset it */
 #endif
@@ -1528,11 +1530,10 @@ qf_jump(qi, dir, errornr, forceit)
      * For ":helpgrep" find a help window or open one.
      */
     if (qf_ptr->qf_type == 1 && (!curwin->w_buffer->b_help || cmdmod.tab != 0))
     {
 	win_T	*wp;
-	int	n;
 
 	if (cmdmod.tab != 0)
 	    wp = NULL;
 	else
 	    for (wp = firstwin; wp != NULL; wp = wp->w_next)
@@ -1544,27 +1545,29 @@ qf_jump(qi, dir, errornr, forceit)
 	{
 	    /*
 	     * Split off help window; put it at far top if no position
 	     * specified, the current window is vertically split and narrow.
 	     */
-	    n = WSP_HELP;
+	    flags = WSP_HELP;
 # ifdef FEAT_VERTSPLIT
 	    if (cmdmod.split == 0 && curwin->w_width != Columns
 						      && curwin->w_width < 80)
-		n |= WSP_TOP;
+		flags |= WSP_TOP;
 # endif
-	    if (win_split(0, n) == FAIL)
+	    if (qi != &ql_info)
+		flags |= WSP_NEWLOC;  /* don't copy the location list */
+
+	    if (win_split(0, flags) == FAIL)
 		goto theend;
 	    opened_window = TRUE;	/* close it when fail */
 
 	    if (curwin->w_height < p_hh)
 		win_setheight((int)p_hh);
 
 	    if (qi != &ql_info)	    /* not a quickfix list */
 	    {
 		/* The new window should use the supplied location list */
-		qf_free_all(curwin);
 		curwin->w_llist = qi;
 		qi->qf_refcount++;
 	    }
 	}
 
@@ -1607,24 +1610,28 @@ qf_jump(qi, dir, errornr, forceit)
 	    {
 		if (wp->w_buffer->b_fnum == qf_ptr->qf_fnum)
 		{
 		    goto_tabpage_win(tp, wp);
 		    usable_win = 1;
-		    break;
+		    goto win_found;
 		}
 	    }
 	}
+win_found:
 
 	/*
 	 * If there is only one window and it is the quickfix window, create a
 	 * new one above the quickfix window.
 	 */
 	if (((firstwin == lastwin) && bt_quickfix(curbuf)) || !usable_win)
 	{
 	    ll_ref = curwin->w_llist_ref;
 
-	    if (win_split(0, WSP_ABOVE) == FAIL)
+	    flags = WSP_ABOVE;
+	    if (ll_ref != NULL)
+		flags |= WSP_NEWLOC;
+	    if (win_split(0, flags) == FAIL)
 		goto failed;		/* not enough room for window */
 	    opened_window = TRUE;	/* close it when fail */
 	    p_swb = empty_option;	/* don't split again */
 	    swb_flags = 0;
 # ifdef FEAT_SCROLLBIND
@@ -1632,11 +1639,10 @@ qf_jump(qi, dir, errornr, forceit)
 # endif
 	    if (ll_ref != NULL)
 	    {
 		/* The new window should use the location list from the
 		 * location list window */
-		qf_free_all(curwin);
 		curwin->w_llist = ll_ref;
 		ll_ref->qf_refcount++;
 	    }
 	}
 	else
@@ -1742,11 +1748,12 @@ qf_jump(qi, dir, errornr, forceit)
 		EMSG(_(e_nowrtmsg));
 		ok = FALSE;
 	    }
 	    else
 		ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1,
-						   ECMD_HIDE + ECMD_SET_HELP);
+					   ECMD_HIDE + ECMD_SET_HELP,
+					   oldwin == curwin ? curwin : NULL);
 	}
 	else
 	    ok = buflist_getfile(qf_ptr->qf_fnum,
 			    (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit);
     }
@@ -1890,11 +1897,10 @@ qf_list(eap)
     char_u	*fname;
     qfline_T	*qfp;
     int		i;
     int		idx1 = 1;
     int		idx2 = -1;
-    int		need_return = TRUE;
     char_u	*arg = eap->arg;
     int		all = eap->forceit;	/* if not :cl!, only show
 						   recognised errors */
     qf_info_T	*qi = &ql_info;
 
@@ -1930,17 +1936,13 @@ qf_list(eap)
     qfp = qi->qf_lists[qi->qf_curlist].qf_start;
     for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; )
     {
 	if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
 	{
-	    if (need_return)
-	    {
-		msg_putchar('\n');
-		if (got_int)
-		    break;
-		need_return = FALSE;
-	    }
+	    msg_putchar('\n');
+	    if (got_int)
+		break;
 
 	    fname = NULL;
 	    if (qfp->qf_fnum != 0
 			      && (buf = buflist_findnr(qfp->qf_fnum)) != NULL)
 	    {
@@ -1979,11 +1981,10 @@ qf_list(eap)
 	    qf_fmt_text((fname != NULL || qfp->qf_lnum != 0)
 				     ? skipwhite(qfp->qf_text) : qfp->qf_text,
 							      IObuff, IOSIZE);
 	    msg_prt_line(IObuff, FALSE);
 	    out_flush();		/* show one line at a time */
-	    need_return = TRUE;
 	}
 
 	qfp = qfp->qf_next;
 	++i;
 	ui_breakcheck();
@@ -2231,11 +2232,10 @@ ex_cwindow(eap)
 
 /*
  * ":cclose": close the window showing the list of errors.
  * ":lclose": close the window showing the location list
  */
-/*ARGSUSED*/
     void
 ex_cclose(eap)
     exarg_T	*eap;
 {
     win_T	*win = NULL;
@@ -2265,10 +2265,11 @@ ex_copen(eap)
     qf_info_T	*qi = &ql_info;
     int		height;
     win_T	*win;
     tabpage_T	*prevtab = curtab;
     buf_T	*qf_buf;
+    win_T	*oldwin = curwin;
 
     if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
     {
 	qi = GET_LOC_LIST(curwin);
 	if (qi == NULL)
@@ -2305,43 +2306,48 @@ ex_copen(eap)
 	win = curwin;
 
 	if (eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow)
 	    /* Create the new window at the very bottom. */
 	    win_goto(lastwin);
-	if (win_split(height, WSP_BELOW) == FAIL)
+	if (win_split(height, WSP_BELOW | WSP_NEWLOC) == FAIL)
 	    return;		/* not enough room for window */
 #ifdef FEAT_SCROLLBIND
 	curwin->w_p_scb = FALSE;
 #endif
 
-	/* Remove the location list for the quickfix window */
-	qf_free_all(curwin);
-
 	if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
 	{
 	    /*
 	     * For the location list window, create a reference to the
 	     * location list from the window 'win'.
 	     */
 	    curwin->w_llist_ref = win->w_llist;
 	    win->w_llist->qf_refcount++;
 	}
 
+	if (oldwin != curwin)
+	    oldwin = NULL;  /* don't store info when in another window */
 	if (qf_buf != NULL)
 	    /* Use the existing quickfix buffer */
 	    (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE,
-						     ECMD_HIDE + ECMD_OLDBUF);
+					     ECMD_HIDE + ECMD_OLDBUF, oldwin);
 	else
 	{
 	    /* Create a new quickfix buffer */
-	    (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE);
+	    (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
 	    /* switch off 'swapfile' */
 	    set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
 	    set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
 								   OPT_LOCAL);
 	    set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL);
-	    set_option_value((char_u *)"diff", 0L, NULL, OPT_LOCAL);
+#ifdef FEAT_DIFF
+	    curwin->w_p_diff = FALSE;
+#endif
+#ifdef FEAT_FOLDING
+	    set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
+								   OPT_LOCAL);
+#endif
 	}
 
 	/* Only set the height when still in the same tab page and there is no
 	 * window to the side. */
 	if (curtab == prevtab
@@ -2598,14 +2604,16 @@ qf_fill_buffer(qi)
      * autocommands. */
     set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL);
     curbuf->b_p_ma = FALSE;
 
 #ifdef FEAT_AUTOCMD
+    keep_filetype = TRUE;		/* don't detect 'filetype' */
     apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL,
 							       FALSE, curbuf);
     apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
 							       FALSE, curbuf);
+    keep_filetype = FALSE;
 #endif
 
     /* make sure it will be redrawn */
     redraw_curbuf_later(NOT_VALID);
 
@@ -2757,11 +2765,11 @@ ex_make(eap)
     if (cmd == NULL)
 	return;
     sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg,
 							       (char *)p_shq);
     if (*p_sp != NUL)
-	append_redir(cmd, p_sp, fname);
+	append_redir(cmd, len, p_sp, fname);
     /*
      * Output a newline if there's something else than the :make command that
      * was typed (in which case the cursor is in column 0).
      */
     if (msg_col == 0)
@@ -3194,11 +3202,11 @@ ex_vimgrep(eap)
 		    if ((flags & VGR_GLOBAL) == 0
 					       || regmatch.endpos[0].lnum > 0)
 			break;
 		    col = regmatch.endpos[0].col
 					    + (col == regmatch.endpos[0].col);
-		    if (col > STRLEN(ml_get_buf(buf, lnum, FALSE)))
+		    if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE)))
 			break;
 		}
 		line_breakcheck();
 		if (got_int)
 		    break;
@@ -3395,18 +3403,19 @@ load_dummy_buffer(fname)
 	return NULL;
 
     /* Init the options. */
     buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);
 
-    /* set curwin/curbuf to buf and save a few things */
-    aucmd_prepbuf(&aco, newbuf);
+    /* need to open the memfile before putting the buffer in a window */
+    if (ml_open(newbuf) == OK)
+    {
+	/* set curwin/curbuf to buf and save a few things */
+	aucmd_prepbuf(&aco, newbuf);
 
-    /* Need to set the filename for autocommands. */
-    (void)setfname(curbuf, fname, NULL, FALSE);
+	/* Need to set the filename for autocommands. */
+	(void)setfname(curbuf, fname, NULL, FALSE);
 
-    if (ml_open(curbuf) == OK)
-    {
 	/* Create swap file now to avoid the ATTENTION message. */
 	check_need_swap(TRUE);
 
 	/* Remove the "dummy" flag, otherwise autocommands may not
 	 * work. */
@@ -3425,14 +3434,14 @@ load_dummy_buffer(fname)
 		if (buf_valid(newbuf))
 		    wipe_buffer(newbuf, FALSE);
 		newbuf = curbuf;
 	    }
 	}
-    }
 
-    /* restore curwin/curbuf and a few other things */
-    aucmd_restbuf(&aco);
+	/* restore curwin/curbuf and a few other things */
+	aucmd_restbuf(&aco);
+    }
 
     if (!buf_valid(newbuf))
 	return NULL;
     if (failed)
     {
--- vim72.orig/src/regexp.c
+++ vim72/src/regexp.c
@@ -469,11 +469,11 @@ get_char_class(pp)
 #define CLASS_NONE 99
     int i;
 
     if ((*pp)[1] == ':')
     {
-	for (i = 0; i < sizeof(class_names) / sizeof(*class_names); ++i)
+	for (i = 0; i < (int)(sizeof(class_names) / sizeof(*class_names)); ++i)
 	    if (STRNCMP(*pp + 2, class_names[i], STRLEN(class_names[i])) == 0)
 	    {
 		*pp += STRLEN(class_names[i]) + 2;
 		return i;
 	    }
@@ -581,10 +581,11 @@ static int	regnpar;	/* () count. */
 static int	regnzpar;	/* \z() count. */
 static int	re_has_z;	/* \z item detected */
 #endif
 static char_u	*regcode;	/* Code-emit pointer, or JUST_CALC_SIZE */
 static long	regsize;	/* Code size. */
+static int	reg_toolong;	/* TRUE when offset out of range */
 static char_u	had_endbrace[NSUBEXP];	/* flags, TRUE if end of () found */
 static unsigned	regflags;	/* RF_ flags for prog */
 static long	brace_min[10];	/* Minimums for complex brace repeats */
 static long	brace_max[10];	/* Maximums for complex brace repeats */
 static int	brace_count[10]; /* Current counts for complex brace repeats */
@@ -1026,13 +1027,15 @@ vim_regcomp(expr, re_flags)
      * Second pass: emit code.
      */
     regcomp_start(expr, re_flags);
     regcode = r->program;
     regc(REGMAGIC);
-    if (reg(REG_NOPAREN, &flags) == NULL)
+    if (reg(REG_NOPAREN, &flags) == NULL || reg_toolong)
     {
 	vim_free(r);
+	if (reg_toolong)
+	    EMSG_RET_NULL(_("E339: Pattern too long"));
 	return NULL;
     }
 
     /* Dig out information for optimizations. */
     r->regstart = NUL;		/* Worst-case defaults. */
@@ -1139,10 +1142,11 @@ regcomp_start(expr, re_flags)
 #ifdef FEAT_SYN_HL
     regnzpar = 1;
     re_has_z = 0;
 #endif
     regsize = 0L;
+    reg_toolong = FALSE;
     regflags = 0;
 #if defined(FEAT_SYN_HL) || defined(PROTO)
     had_eol = FALSE;
 #endif
 }
@@ -1226,11 +1230,11 @@ reg(paren, flagp)
     *flagp |= flags & (SPSTART | HASNL | HASLOOKBH);
     while (peekchr() == Magic('|'))
     {
 	skipchr();
 	br = regbranch(&flags);
-	if (br == NULL)
+	if (br == NULL || reg_toolong)
 	    return NULL;
 	regtail(ret, br);	/* BRANCH -> BRANCH. */
 	if (!(flags & HASWIDTH))
 	    *flagp &= ~HASWIDTH;
 	*flagp |= flags & (SPSTART | HASNL | HASLOOKBH);
@@ -1311,10 +1315,12 @@ regbranch(flagp)
 	    regtail(chain, latest);
 	if (peekchr() != Magic('&'))
 	    break;
 	skipchr();
 	regtail(latest, regnode(END)); /* operand ends */
+	if (reg_toolong)
+	    break;
 	reginsert(MATCH, latest);
 	chain = latest;
     }
 
     return ret;
@@ -1380,11 +1386,11 @@ regconcat(flagp)
 			    skipchr_keepstart();
 			    curchr = -1;
 			    break;
 	    default:
 			    latest = regpiece(&flags);
-			    if (latest == NULL)
+			    if (latest == NULL || reg_toolong)
 				return NULL;
 			    *flagp |= flags & (HASWIDTH | HASNL | HASLOOKBH);
 			    if (chain == NULL)	/* First piece. */
 				*flagp |= flags & SPSTART;
 			    else
@@ -2538,12 +2544,20 @@ regtail(p, val)
 
     if (OP(scan) == BACK)
 	offset = (int)(scan - val);
     else
 	offset = (int)(val - scan);
-    *(scan + 1) = (char_u) (((unsigned)offset >> 8) & 0377);
-    *(scan + 2) = (char_u) (offset & 0377);
+    /* When the offset uses more than 16 bits it can no longer fit in the two
+     * bytes avaliable.  Use a global flag to avoid having to check return
+     * values in too many places. */
+    if (offset > 0xffff)
+	reg_toolong = TRUE;
+    else
+    {
+	*(scan + 1) = (char_u) (((unsigned)offset >> 8) & 0377);
+	*(scan + 2) = (char_u) (offset & 0377);
+    }
 }
 
 /*
  * regoptail - regtail on item after a BRANCH; nop if none
  */
@@ -3360,16 +3374,15 @@ vim_regexec_multi(rmp, win, buf, lnum, c
 
 /*
  * Match a regexp against a string ("line" points to the string) or multiple
  * lines ("line" is NULL, use reg_getline()).
  */
-/*ARGSUSED*/
     static long
 vim_regexec_both(line, col, tm)
     char_u	*line;
     colnr_T	col;		/* column to start looking for match */
-    proftime_T	*tm;		/* timeout limit or NULL */
+    proftime_T	*tm UNUSED;	/* timeout limit or NULL */
 {
     regprog_T	*prog;
     char_u	*s;
     long	retval = 0L;
 
@@ -4530,11 +4543,11 @@ regmatch(scan)
 
 		no = op - BACKREF;
 		cleanup_subexpr();
 		if (!REG_MULTI)		/* Single-line regexp */
 		{
-		    if (reg_endp[no] == NULL)
+		    if (reg_startp[no] == NULL || reg_endp[no] == NULL)
 		    {
 			/* Backref was not set: Match an empty string. */
 			len = 0;
 		    }
 		    else
@@ -4546,11 +4559,11 @@ regmatch(scan)
 			    status = RA_NOMATCH;
 		    }
 		}
 		else				/* Multi-line regexp */
 		{
-		    if (reg_endpos[no].lnum < 0)
+		    if (reg_startpos[no].lnum < 0 || reg_endpos[no].lnum < 0)
 		    {
 			/* Backref was not set: Match an empty string. */
 			len = 0;
 		    }
 		    else
@@ -5763,18 +5776,20 @@ do_class:
     return (int)count;
 }
 
 /*
  * regnext - dig the "next" pointer out of a node
+ * Returns NULL when calculating size, when there is no next item and when
+ * there is an error.
  */
     static char_u *
 regnext(p)
     char_u  *p;
 {
     int	    offset;
 
-    if (p == JUST_CALC_SIZE)
+    if (p == JUST_CALC_SIZE || reg_toolong)
 	return NULL;
 
     offset = NEXT(p);
     if (offset == 0)
 	return NULL;
@@ -6811,10 +6826,12 @@ static int can_f_submatch = FALSE;	/* TR
 /* These pointers are used instead of reg_match and reg_mmatch for
  * reg_submatch().  Needed for when the substitution string is an expression
  * that contains a call to substitute() and submatch(). */
 static regmatch_T	*submatch_match;
 static regmmatch_T	*submatch_mmatch;
+static linenr_T		submatch_firstlnum;
+static linenr_T		submatch_maxline;
 #endif
 
 #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO)
 /*
  * vim_regsub() - perform substitutions after a vim_regexec() or
@@ -6924,11 +6941,10 @@ vim_regsub_both(source, dest, copy, magi
 		eval_result = NULL;
 	    }
 	}
 	else
 	{
-	    linenr_T	save_reg_maxline;
 	    win_T	*save_reg_win;
 	    int		save_ireg_ic;
 
 	    vim_free(eval_result);
 
@@ -6936,34 +6952,51 @@ vim_regsub_both(source, dest, copy, magi
 	     * recursively.  Make sure submatch() gets the text from the first
 	     * level.  Don't need to save "reg_buf", because
 	     * vim_regexec_multi() can't be called recursively. */
 	    submatch_match = reg_match;
 	    submatch_mmatch = reg_mmatch;
-	    save_reg_maxline = reg_maxline;
+	    submatch_firstlnum = reg_firstlnum;
+	    submatch_maxline = reg_maxline;
 	    save_reg_win = reg_win;
 	    save_ireg_ic = ireg_ic;
 	    can_f_submatch = TRUE;
 
 	    eval_result = eval_to_string(source + 2, NULL, TRUE);
 	    if (eval_result != NULL)
 	    {
+		int had_backslash = FALSE;
+
 		for (s = eval_result; *s != NUL; mb_ptr_adv(s))
 		{
 		    /* Change NL to CR, so that it becomes a line break.
 		     * Skip over a backslashed character. */
 		    if (*s == NL)
 			*s = CAR;
 		    else if (*s == '\\' && s[1] != NUL)
+		    {
 			++s;
+			had_backslash = TRUE;
+		    }
+		}
+		if (had_backslash && backslash)
+		{
+		    /* Backslashes will be consumed, need to double them. */
+		    s = vim_strsave_escaped(eval_result, (char_u *)"\\");
+		    if (s != NULL)
+		    {
+			vim_free(eval_result);
+			eval_result = s;
+		    }
 		}
 
 		dst += STRLEN(eval_result);
 	    }
 
 	    reg_match = submatch_match;
 	    reg_mmatch = submatch_mmatch;
-	    reg_maxline = save_reg_maxline;
+	    reg_firstlnum = submatch_firstlnum;
+	    reg_maxline = submatch_maxline;
 	    reg_win = save_reg_win;
 	    ireg_ic = save_ireg_ic;
 	    can_f_submatch = FALSE;
 	}
 #endif
@@ -7194,10 +7227,35 @@ vim_regsub_both(source, dest, copy, magi
 exit:
     return (int)((dst - dest) + 1);
 }
 
 #ifdef FEAT_EVAL
+static char_u *reg_getline_submatch __ARGS((linenr_T lnum));
+
+/*
+ * Call reg_getline() with the line numbers from the submatch.  If a
+ * substitute() was used the reg_maxline and other values have been
+ * overwritten.
+ */
+    static char_u *
+reg_getline_submatch(lnum)
+    linenr_T	lnum;
+{
+    char_u *s;
+    linenr_T save_first = reg_firstlnum;
+    linenr_T save_max = reg_maxline;
+
+    reg_firstlnum = submatch_firstlnum;
+    reg_maxline = submatch_maxline;
+
+    s = reg_getline(lnum);
+
+    reg_firstlnum = save_first;
+    reg_maxline = save_max;
+    return s;
+}
+
 /*
  * Used for the submatch() function: get the string from the n'th submatch in
  * allocated memory.
  * Returns NULL when not in a ":s" command and for a non-existing submatch.
  */
@@ -7224,11 +7282,11 @@ reg_submatch(no)
 	{
 	    lnum = submatch_mmatch->startpos[no].lnum;
 	    if (lnum < 0 || submatch_mmatch->endpos[no].lnum < 0)
 		return NULL;
 
-	    s = reg_getline(lnum) + submatch_mmatch->startpos[no].col;
+	    s = reg_getline_submatch(lnum) + submatch_mmatch->startpos[no].col;
 	    if (s == NULL)  /* anti-crash check, cannot happen? */
 		break;
 	    if (submatch_mmatch->endpos[no].lnum == lnum)
 	    {
 		/* Within one line: take form start to end col. */
@@ -7250,20 +7308,20 @@ reg_submatch(no)
 		}
 		++len;
 		++lnum;
 		while (lnum < submatch_mmatch->endpos[no].lnum)
 		{
-		    s = reg_getline(lnum++);
+		    s = reg_getline_submatch(lnum++);
 		    if (round == 2)
 			STRCPY(retval + len, s);
 		    len += (int)STRLEN(s);
 		    if (round == 2)
 			retval[len] = '\n';
 		    ++len;
 		}
 		if (round == 2)
-		    STRNCPY(retval + len, reg_getline(lnum),
+		    STRNCPY(retval + len, reg_getline_submatch(lnum),
 					     submatch_mmatch->endpos[no].col);
 		len += submatch_mmatch->endpos[no].col;
 		if (round == 2)
 		    retval[len] = NUL;
 		++len;
@@ -7277,17 +7335,15 @@ reg_submatch(no)
 	    }
 	}
     }
     else
     {
-	if (submatch_match->endp[no] == NULL)
+	s = submatch_match->startp[no];
+	if (s == NULL || submatch_match->endp[no] == NULL)
 	    retval = NULL;
 	else
-	{
-	    s = submatch_match->startp[no];
 	    retval = vim_strnsave(s, (int)(submatch_match->endp[no] - s));
-	}
     }
 
     return retval;
 }
 #endif
--- vim72.orig/src/screen.c
+++ vim72/src/screen.c
@@ -23,14 +23,15 @@
  *
  * For double-byte characters, two consecutive bytes in ScreenLines[] can form
  * one character which occupies two display cells.
  * For UTF-8 a multi-byte character is converted to Unicode and stored in
  * ScreenLinesUC[].  ScreenLines[] contains the first byte only.  For an ASCII
- * character without composing chars ScreenLinesUC[] will be 0.  When the
- * character occupies two display cells the next byte in ScreenLines[] is 0.
+ * character without composing chars ScreenLinesUC[] will be 0 and
+ * ScreenLinesC[][] is not used.  When the character occupies two display
+ * cells the next byte in ScreenLines[] is 0.
  * ScreenLinesC[][] contain up to 'maxcombine' composing characters
- * (drawn on top of the first character).  They are 0 when not used.
+ * (drawn on top of the first character).  There is 0 after the last one used.
  * ScreenLines2[] is only used for euc-jp to store the second byte if the
  * first byte is 0x8e (single-width character).
  *
  * The screen_*() functions write to the screen and handle updating
  * ScreenLines[].
@@ -130,11 +131,11 @@ static void screen_line __ARGS((int row,
 #endif
 #ifdef FEAT_VERTSPLIT
 static void draw_vsep_win __ARGS((win_T *wp, int row));
 #endif
 #ifdef FEAT_STL_OPT
-static void redraw_custum_statusline __ARGS((win_T *wp));
+static void redraw_custom_statusline __ARGS((win_T *wp));
 #endif
 #ifdef FEAT_SEARCH_EXTRA
 #define SEARCH_HL_PRIORITY 0
 static void start_search_hl __ARGS((void));
 static void end_search_hl __ARGS((void));
@@ -268,15 +269,14 @@ redraw_buf_later(buf, type)
  * Used when entering/leaving Insert mode with the cursor on a folded line.
  * Used to remove the "$" from a change command.
  * Note that when also inserting/deleting lines w_redraw_top and w_redraw_bot
  * may become invalid and the whole window will have to be redrawn.
  */
-/*ARGSUSED*/
     void
 redrawWinline(lnum, invalid)
     linenr_T	lnum;
-    int		invalid;	/* window line height is invalid now */
+    int		invalid UNUSED;	/* window line height is invalid now */
 {
 #ifdef FEAT_FOLDING
     int		i;
 #endif
 
@@ -322,10 +322,11 @@ update_screen(type)
     static int	did_intro = FALSE;
 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD)
     int		did_one;
 #endif
 
+    /* Don't do anything if the screen structures are (not yet) valid. */
     if (!screen_valid(TRUE))
 	return;
 
     if (must_redraw)
     {
@@ -341,11 +342,13 @@ update_screen(type)
 
     /* Need to update w_lines[]. */
     if (curwin->w_lines_valid == 0 && type < NOT_VALID)
 	type = NOT_VALID;
 
-    if (!redrawing())
+    /* Postpone the redrawing when it's not needed and when being called
+     * recursively. */
+    if (!redrawing() || updating_screen)
     {
 	redraw_later(type);		/* remember type for next time */
 	must_redraw = type;
 	if (type > INVERTED_ALL)
 	    curwin->w_lines_valid = 0;	/* don't use w_lines[].wl_size now */
@@ -581,10 +584,11 @@ update_screen(type)
 static void update_prepare __ARGS((void));
 static void update_finish __ARGS((void));
 
 /*
  * Prepare for updating one or more windows.
+ * Caller must check for "updating_screen" already set to avoid recursiveness.
  */
     static void
 update_prepare()
 {
     cursor_off();
@@ -662,11 +666,13 @@ update_debug_sign(buf, lnum)
 	    redraw_win_later(wp, VALID);
 	if (wp->w_redr_type != 0)
 	    doit = TRUE;
     }
 
-    if (!doit)
+    /* Return when there is nothing to do or screen updating already
+     * happening. */
+    if (!doit || updating_screen)
 	return;
 
     /* update all windows that need updating */
     update_prepare();
 
@@ -695,10 +701,14 @@ update_debug_sign(buf, lnum)
  */
     void
 updateWindow(wp)
     win_T	*wp;
 {
+    /* return if already busy updating */
+    if (updating_screen)
+	return;
+
     update_prepare();
 
 #ifdef FEAT_CLIPBOARD
     /* When Visual area changed, may have to update selection. */
     if (clip_star.available && clip_isautosel())
@@ -2324,17 +2334,16 @@ fold_line(wp, fold_count, foldinfo, lnum
 		    }
 		}
 		if (cells > 1)
 		    ScreenLines[idx + 1] = 0;
 	    }
-	    else if (cells > 1)	    /* double-byte character */
-	    {
-		if (enc_dbcs == DBCS_JPNU && *p == 0x8e)
-		    ScreenLines2[idx] = p[1];
-		else
-		    ScreenLines[idx + 1] = p[1];
-	    }
+	    else if (enc_dbcs == DBCS_JPNU && *p == 0x8e)
+		/* double-byte single width character */
+		ScreenLines2[idx] = p[1];
+	    else if (cells > 1)
+		/* double-width character */
+		ScreenLines[idx + 1] = p[1];
 	    col += cells;
 	    idx += cells;
 	    p += c_len;
 	}
     }
@@ -2411,11 +2420,11 @@ fold_line(wp, fold_count, foldinfo, lnum
 			    || (lnum == top->lnum
 				&& top->col == 0))
 			&& (lnume < bot->lnum
 			    || (lnume == bot->lnum
 				&& (bot->col - (*p_sel == 'e'))
-		>= STRLEN(ml_get_buf(wp->w_buffer, lnume, FALSE)))))))
+		>= (colnr_T)STRLEN(ml_get_buf(wp->w_buffer, lnume, FALSE)))))))
 	{
 	    if (VIsual_mode == Ctrl_V)
 	    {
 		/* Visual block mode: highlight the chars part of the block */
 		if (wp->w_old_cursor_fcol + txtcol < (colnr_T)W_WIDTH(wp))
@@ -2437,13 +2446,21 @@ fold_line(wp, fold_count, foldinfo, lnum
     }
 #endif
 
 #ifdef FEAT_SYN_HL
     /* Show 'cursorcolumn' in the fold line. */
-    if (wp->w_p_cuc && (int)wp->w_virtcol + txtcol < W_WIDTH(wp))
-	ScreenAttrs[off + wp->w_virtcol + txtcol] = hl_combine_attr(
-		 ScreenAttrs[off + wp->w_virtcol + txtcol], hl_attr(HLF_CUC));
+    if (wp->w_p_cuc)
+    {
+	txtcol += wp->w_virtcol;
+	if (wp->w_p_wrap)
+	    txtcol -= wp->w_skipcol;
+	else
+	    txtcol -= wp->w_leftcol;
+	if (txtcol >= 0 && txtcol < W_WIDTH(wp))
+	    ScreenAttrs[off + txtcol] = hl_combine_attr(
+				 ScreenAttrs[off + txtcol], hl_attr(HLF_CUC));
+    }
 #endif
 
     SCREEN_LINE(row + W_WINROW(wp), W_WINCOL(wp), (int)W_WIDTH(wp),
 						     (int)W_WIDTH(wp), FALSE);
 
@@ -2539,18 +2556,17 @@ fill_foldcolumn(p, wp, closed, lnum)
  * Start at row "startrow", stop when "endrow" is reached.
  * wp->w_virtcol needs to be valid.
  *
  * Return the number of last row the line occupies.
  */
-/* ARGSUSED */
     static int
 win_line(wp, lnum, startrow, endrow, nochange)
     win_T	*wp;
     linenr_T	lnum;
     int		startrow;
     int		endrow;
-    int		nochange;		/* not updating for changed text */
+    int		nochange UNUSED;	/* not updating for changed text */
 {
     int		col;			/* visual column on screen */
     unsigned	off;			/* offset in ScreenLines/ScreenAttrs */
     int		c = 0;			/* init for GCC */
     long	vcol = 0;		/* virtual column (for tabs) */
@@ -2586,10 +2602,11 @@ win_line(wp, lnum, startrow, endrow, noc
     int		fromcol, tocol;		/* start/end of inverting */
     int		fromcol_prev = -2;	/* start of inverting after cursor */
     int		noinvcur = FALSE;	/* don't invert the cursor */
 #ifdef FEAT_VISUAL
     pos_T	*top, *bot;
+    int		lnum_in_visual_area = FALSE;
 #endif
     pos_T	pos;
     long	v;
 
     int		char_attr = 0;		/* attributes for next character */
@@ -2782,13 +2799,14 @@ win_line(wp, lnum, startrow, endrow, noc
 	else				/* Visual is before curwin->w_cursor */
 	{
 	    top = &VIsual;
 	    bot = &curwin->w_cursor;
 	}
+	lnum_in_visual_area = (lnum >= top->lnum && lnum <= bot->lnum);
 	if (VIsual_mode == Ctrl_V)	/* block mode */
 	{
-	    if (lnum >= top->lnum && lnum <= bot->lnum)
+	    if (lnum_in_visual_area)
 	    {
 		fromcol = wp->w_old_cursor_fcol;
 		tocol = wp->w_old_cursor_lcol;
 	    }
 	}
@@ -2877,12 +2895,13 @@ win_line(wp, lnum, startrow, endrow, noc
 	    pos.col = search_match_endcol;
 	    getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL);
 	}
 	else
 	    tocol = MAXCOL;
-	if (fromcol == tocol)		/* do at least one character */
-	    tocol = fromcol + 1;	/* happens when past end of line */
+	/* do at least one character; happens when past end of line */
+	if (fromcol == tocol)
+	    tocol = fromcol + 1;
 	area_highlighting = TRUE;
 	attr = hl_attr(HLF_I);
     }
 
 #ifdef FEAT_DIFF
@@ -2997,15 +3016,37 @@ win_line(wp, lnum, startrow, endrow, noc
 	    prev_ptr = ptr;
 #endif
 	    mb_ptr_adv(ptr);
 	}
 
-#ifdef FEAT_VIRTUALEDIT
-	/* When 'virtualedit' is set the end of the line may be before the
-	 * start of the displayed part. */
-	if (vcol < v && *ptr == NUL && virtual_active())
+#if defined(FEAT_SYN_HL) || defined(FEAT_VIRTUALEDIT) || defined(FEAT_VISUAL)
+	/* When:
+	 * - 'cuc' is set, or
+	 * - 'virtualedit' is set, or
+	 * - the visual mode is active,
+	 * the end of the line may be before the start of the displayed part.
+	 */
+	if (vcol < v && (
+# ifdef FEAT_SYN_HL
+	     wp->w_p_cuc
+#  if defined(FEAT_VIRTUALEDIT) || defined(FEAT_VISUAL)
+	     ||
+#  endif
+# endif
+# ifdef FEAT_VIRTUALEDIT
+	     virtual_active()
+#  ifdef FEAT_VISUAL
+	     ||
+#  endif
+# endif
+# ifdef FEAT_VISUAL
+	     (VIsual_active && wp->w_buffer == curwin->w_buffer)
+# endif
+	     ))
+	{
 	    vcol = v;
+	}
 #endif
 
 	/* Handle a character that's not completely on the screen: Put ptr at
 	 * that character but skip the first few screen characters. */
 	if (vcol > v)
@@ -3410,10 +3451,11 @@ win_line(wp, lnum, startrow, endrow, noc
 #ifdef FEAT_MBYTE
 		    || (has_mbyte && vcol + 1 == fromcol && n_extra == 0
 			&& (*mb_ptr2cells)(ptr) > 1)
 #endif
 		    || ((int)vcol_prev == fromcol_prev
+			&& vcol_prev < vcol	/* not at margin */
 			&& vcol < tocol))
 		area_attr = attr;		/* start highlighting */
 	    else if (area_attr != 0
 		    && (vcol == tocol
 			|| (noinvcur && (colnr_T)vcol == wp->w_virtcol)))
@@ -3542,11 +3584,12 @@ win_line(wp, lnum, startrow, endrow, noc
 		char_attr = search_attr;
 #ifdef LINE_ATTR
 		/* Use line_attr when not in the Visual or 'incsearch' area
 		 * (area_attr may be 0 when "noinvcur" is set). */
 	    else if (line_attr != 0 && ((fromcol == -10 && tocol == MAXCOL)
-					|| (vcol < fromcol || vcol >= tocol)))
+				|| vcol < fromcol || vcol_prev < fromcol_prev
+				|| vcol >= tocol))
 		char_attr = line_attr;
 #endif
 	    else
 	    {
 		attr_pri = FALSE;
@@ -4104,10 +4147,11 @@ win_line(wp, lnum, startrow, endrow, noc
 # ifdef FEAT_RIGHTLEFT
 				    wp->w_p_rl ? (col >= 0) :
 # endif
 				    (col < W_WIDTH(wp)))
 				&& !(noinvcur
+				    && lnum == wp->w_cursor.lnum
 				    && (colnr_T)vcol == wp->w_virtcol)))
 			&& lcs_eol_one >= 0)
 		{
 		    /* Display a '$' after the line or highlight an extra
 		     * character if the line break is included. */
@@ -4245,20 +4289,20 @@ win_line(wp, lnum, startrow, endrow, noc
 #if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
 	/* XIM don't send preedit_start and preedit_end, but they send
 	 * preedit_changed and commit.  Thus Vim can't set "im_is_active", use
 	 * im_is_preediting() here. */
 	if (xic != NULL
-		&& lnum == curwin->w_cursor.lnum
+		&& lnum == wp->w_cursor.lnum
 		&& (State & INSERT)
 		&& !p_imdisable
 		&& im_is_preediting()
 		&& draw_state == WL_LINE)
 	{
 	    colnr_T tcol;
 
 	    if (preedit_end_col == MAXCOL)
-		getvcol(curwin, &(curwin->w_cursor), &tcol, NULL, NULL);
+		getvcol(curwin, &(wp->w_cursor), &tcol, NULL, NULL);
 	    else
 		tcol = preedit_end_col;
 	    if ((long)preedit_start_col <= vcol && vcol < (long)tcol)
 	    {
 		if (feedback_old_attr < 0)
@@ -4351,11 +4395,17 @@ win_line(wp, lnum, startrow, endrow, noc
 		    cur = cur->next;
 		}
 	    }
 #endif
 	    if (lcs_eol == lcs_eol_one
-		    && ((area_attr != 0 && vcol == fromcol && c == NUL)
+		    && ((area_attr != 0 && vcol == fromcol
+#ifdef FEAT_VISUAL
+			    && (VIsual_mode != Ctrl_V
+				|| lnum == VIsual.lnum
+				|| lnum == curwin->w_cursor.lnum)
+#endif
+			    && c == NUL)
 #ifdef FEAT_SEARCH_EXTRA
 			/* highlight 'hlsearch' match at end of line */
 			|| (prevcol_hl_flag == TRUE
 # if defined(LINE_ATTR)
 			    && did_line_attr <= 1
@@ -4445,11 +4495,12 @@ win_line(wp, lnum, startrow, endrow, noc
 	 * At end of the text line.
 	 */
 	if (c == NUL)
 	{
 #ifdef FEAT_SYN_HL
-	    if (eol_hl_off > 0 && vcol - eol_hl_off == (long)wp->w_virtcol)
+	    if (eol_hl_off > 0 && vcol - eol_hl_off == (long)wp->w_virtcol
+		    && lnum == wp->w_cursor.lnum)
 	    {
 		/* highlight last char after line */
 		--col;
 		--off;
 		--vcol;
@@ -4547,11 +4598,12 @@ win_line(wp, lnum, startrow, endrow, noc
 #ifdef FEAT_SYN_HL
 	/* Highlight the cursor column if 'cursorcolumn' is set.  But don't
 	 * highlight the cursor position itself. */
 	if (wp->w_p_cuc && vcol == (long)wp->w_virtcol
 		&& lnum != wp->w_cursor.lnum
-		&& draw_state == WL_LINE)
+		&& draw_state == WL_LINE
+		&& !lnum_in_visual_area)
 	{
 	    vcol_save_attr = char_attr;
 	    char_attr = hl_combine_attr(char_attr, hl_attr(HLF_CUC));
 	}
 	else
@@ -4577,11 +4629,15 @@ win_line(wp, lnum, startrow, endrow, noc
 	    }
 #endif
 	    ScreenLines[off] = c;
 #ifdef FEAT_MBYTE
 	    if (enc_dbcs == DBCS_JPNU)
+	    {
+		if ((mb_c & 0xff00) == 0x8e00)
+		    ScreenLines[off] = 0x8e;
 		ScreenLines2[off] = mb_c & 0xff;
+	    }
 	    else if (enc_utf8)
 	    {
 		if (mb_utf8)
 		{
 		    int i;
@@ -4650,11 +4706,11 @@ win_line(wp, lnum, startrow, endrow, noc
 	}
 	else
 	    --n_skip;
 
 	/* Only advance the "vcol" when after the 'number' column. */
-	if (draw_state >= WL_SBR
+	if (draw_state > WL_NR
 #ifdef FEAT_DIFF
 		&& filler_todo <= 0
 #endif
 		)
 	    ++vcol;
@@ -4836,10 +4892,11 @@ win_line(wp, lnum, startrow, endrow, noc
 #ifdef FEAT_MBYTE
 static int comp_char_differs __ARGS((int, int));
 
 /*
  * Return if the composing characters at "off_from" and "off_to" differ.
+ * Only to be used when ScreenLinesUC[off_from] != 0.
  */
     static int
 comp_char_differs(off_from, off_to)
     int	    off_from;
     int	    off_to;
@@ -5117,12 +5174,12 @@ screen_line(row, coloff, endcol, clear_w
 	    if (char_cells == 2)
 		ScreenLines[off_to + 1] = ScreenLines[off_from + 1];
 #endif
 
 #if defined(FEAT_GUI) || defined(UNIX)
-	    /* The bold trick makes a single row of pixels appear in the next
-	     * character.  When a bold character is removed, the next
+	    /* The bold trick makes a single column of pixels appear in the
+	     * next character.  When a bold character is removed, the next
 	     * character should be redrawn too.  This happens for our own GUI
 	     * and for some xterms. */
 	    if (
 # ifdef FEAT_GUI
 		    gui.in_use
@@ -5721,10 +5778,17 @@ win_redr_status(wp)
     char_u	*p;
     int		len;
     int		fillchar;
     int		attr;
     int		this_ru_col;
+    static int  busy = FALSE;
+
+    /* It's possible to get here recursively when 'statusline' (indirectly)
+     * invokes ":redrawstatus".  Simply ignore the call then. */
+    if (busy)
+	return;
+    busy = TRUE;
 
     wp->w_redr_status = FALSE;
     if (wp->w_status_height == 0)
     {
 	/* no status line, can only be last window */
@@ -5743,11 +5807,11 @@ win_redr_status(wp)
     }
 #ifdef FEAT_STL_OPT
     else if (*p_stl != NUL || *wp->w_p_stl != NUL)
     {
 	/* redraw custom status line */
-	redraw_custum_statusline(wp);
+	redraw_custom_statusline(wp);
     }
 #endif
     else
     {
 	fillchar = fillchar_status(&attr, wp == curwin);
@@ -5859,30 +5923,44 @@ win_redr_status(wp)
 	    fillchar = fillchar_vsep(&attr);
 	screen_putchar(fillchar, W_WINROW(wp) + wp->w_height, W_ENDCOL(wp),
 									attr);
     }
 #endif
+    busy = FALSE;
 }
 
 #ifdef FEAT_STL_OPT
 /*
  * Redraw the status line according to 'statusline' and take care of any
  * errors encountered.
  */
     static void
-redraw_custum_statusline(wp)
+redraw_custom_statusline(wp)
     win_T	    *wp;
 {
-    int	save_called_emsg = called_emsg;
+    static int	    entered = FALSE;
+    int		    save_called_emsg = called_emsg;
+
+    /* When called recursively return.  This can happen when the statusline
+     * contains an expression that triggers a redraw. */
+    if (entered)
+	return;
+    entered = TRUE;
 
     called_emsg = FALSE;
     win_redr_custom(wp, FALSE);
     if (called_emsg)
+    {
+	/* When there is an error disable the statusline, otherwise the
+	 * display is messed up with errors and a redraw triggers the problem
+	 * again and again. */
 	set_string_option_direct((char_u *)"statusline", -1,
 		(char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL
 					? OPT_LOCAL : OPT_GLOBAL), SID_ERROR);
+    }
     called_emsg |= save_called_emsg;
+    entered = FALSE;
 }
 #endif
 
 # ifdef FEAT_VERTSPLIT
 /*
@@ -5986,20 +6064,21 @@ win_redr_custom(wp, draw_ruler)
     int		width;
     int		n;
     int		len;
     int		fillchar;
     char_u	buf[MAXPATHL];
+    char_u	*stl;
     char_u	*p;
     struct	stl_hlrec hltab[STL_MAX_ITEM];
     struct	stl_hlrec tabtab[STL_MAX_ITEM];
     int		use_sandbox = FALSE;
 
     /* setup environment for the task at hand */
     if (wp == NULL)
     {
 	/* Use 'tabline'.  Always at the first line of the screen. */
-	p = p_tal;
+	stl = p_tal;
 	row = 0;
 	fillchar = ' ';
 	attr = hl_attr(HLF_TPF);
 	maxwidth = Columns;
 # ifdef FEAT_EVAL
@@ -6012,21 +6091,21 @@ win_redr_custom(wp, draw_ruler)
 	fillchar = fillchar_status(&attr, wp == curwin);
 	maxwidth = W_WIDTH(wp);
 
 	if (draw_ruler)
 	{
-	    p = p_ruf;
+	    stl = p_ruf;
 	    /* advance past any leading group spec - implicit in ru_col */
-	    if (*p == '%')
+	    if (*stl == '%')
 	    {
-		if (*++p == '-')
-		    p++;
-		if (atoi((char *) p))
-		    while (VIM_ISDIGIT(*p))
-			p++;
-		if (*p++ != '(')
-		    p = p_ruf;
+		if (*++stl == '-')
+		    stl++;
+		if (atoi((char *)stl))
+		    while (VIM_ISDIGIT(*stl))
+			stl++;
+		if (*stl++ != '(')
+		    stl = p_ruf;
 	    }
 #ifdef FEAT_VERTSPLIT
 	    col = ru_col - (Columns - W_WIDTH(wp));
 	    if (col < (W_WIDTH(wp) + 1) / 2)
 		col = (W_WIDTH(wp) + 1) / 2;
@@ -6051,13 +6130,13 @@ win_redr_custom(wp, draw_ruler)
 # endif
 	}
 	else
 	{
 	    if (*wp->w_p_stl != NUL)
-		p = wp->w_p_stl;
+		stl = wp->w_p_stl;
 	    else
-		p = p_stl;
+		stl = p_stl;
 # ifdef FEAT_EVAL
 	    use_sandbox = was_set_insecurely((char_u *)"statusline",
 					 *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
 # endif
 	}
@@ -6068,17 +6147,21 @@ win_redr_custom(wp, draw_ruler)
     }
 
     if (maxwidth <= 0)
 	return;
 
+    /* Make a copy, because the statusline may include a function call that
+     * might change the option value and free the memory. */
+    stl = vim_strsave(stl);
     width = build_stl_str_hl(wp == NULL ? curwin : wp,
 				buf, sizeof(buf),
-				p, use_sandbox,
+				stl, use_sandbox,
 				fillchar, maxwidth, hltab, tabtab);
+    vim_free(stl);
     len = (int)STRLEN(buf);
 
-    while (width < maxwidth && len < sizeof(buf) - 1)
+    while (width < maxwidth && len < (int)sizeof(buf) - 1)
     {
 #ifdef FEAT_MBYTE
 	len += (*mb_char2bytes)(fillchar, buf + len);
 #else
 	buf[len++] = fillchar;
@@ -6198,10 +6281,11 @@ screen_getbytes(row, col, bytes, attrp)
 static int screen_comp_differs __ARGS((int, int*));
 
 /*
  * Return TRUE if composing characters for screen posn "off" differs from
  * composing characters in "u8cc".
+ * Only to be used when ScreenLinesUC[off] != 0.
  */
     static int
 screen_comp_differs(off, u8cc)
     int	    off;
     int	    *u8cc;
@@ -6261,26 +6345,43 @@ screen_puts_len(text, len, row, col, att
     int		prev_c = 0;		/* previous Arabic character */
     int		pc, nc, nc1;
     int		pcc[MAX_MCO];
 # endif
 #endif
+#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
+    int		force_redraw_this;
+    int		force_redraw_next = FALSE;
+#endif
+    int		need_redraw;
 
     if (ScreenLines == NULL || row >= screen_Rows)	/* safety check */
 	return;
+    off = LineOffset[row] + col;
 
 #ifdef FEAT_MBYTE
     /* When drawing over the right halve of a double-wide char clear out the
      * left halve.  Only needed in a terminal. */
     if (has_mbyte && col > 0 && col < screen_Columns
 # ifdef FEAT_GUI
 	    && !gui.in_use
 # endif
 	    && mb_fix_col(col, row) != col)
-	screen_puts_len((char_u *)" ", 1, row, col - 1, 0);
+    {
+	ScreenLines[off - 1] = ' ';
+	ScreenAttrs[off - 1] = 0;
+	if (enc_utf8)
+	{
+	    ScreenLinesUC[off - 1] = 0;
+	    ScreenLinesC[0][off - 1] = 0;
+	}
+	/* redraw the previous cell, make it empty */
+	screen_char(off - 1, row, col - 1);
+	/* force the cell at "col" to be redrawn */
+	force_redraw_next = TRUE;
+    }
 #endif
 
-    off = LineOffset[row] + col;
 #ifdef FEAT_MBYTE
     max_off = LineOffset[row] + screen_Columns;
 #endif
     while (col < screen_Columns
 	    && (len < 0 || (int)(ptr - text) < len)
@@ -6326,76 +6427,82 @@ screen_puts_len(text, len, row, col, att
 			nc = NUL;
 			nc1 = NUL;
 		    }
 		    else
 		    {
-			nc = utfc_ptr2char(ptr + mbyte_blen, pcc);
+			nc = utfc_ptr2char_len(ptr + mbyte_blen, pcc,
+				      (int)((text + len) - ptr - mbyte_blen));
 			nc1 = pcc[0];
 		    }
 		    pc = prev_c;
 		    prev_c = u8c;
 		    u8c = arabic_shape(u8c, &c, &u8cc[0], nc, nc1, pc);
 		}
 		else
 		    prev_c = u8c;
 # endif
+		if (col + mbyte_cells > screen_Columns)
+		{
+		    /* Only 1 cell left, but character requires 2 cells:
+		     * display a '>' in the last column to avoid wrapping. */
+		    c = '>';
+		    mbyte_cells = 1;
+		}
 	    }
 	}
 #endif
 
-	if (ScreenLines[off] != c
+#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
+	force_redraw_this = force_redraw_next;
+	force_redraw_next = FALSE;
+#endif
+
+	need_redraw = ScreenLines[off] != c
 #ifdef FEAT_MBYTE
 		|| (mbyte_cells == 2
 		    && ScreenLines[off + 1] != (enc_dbcs ? ptr[1] : 0))
 		|| (enc_dbcs == DBCS_JPNU
 		    && c == 0x8e
 		    && ScreenLines2[off] != ptr[1])
 		|| (enc_utf8
-		    && (ScreenLinesUC[off] != (u8char_T)u8c
-			|| screen_comp_differs(off, u8cc)))
+		    && (ScreenLinesUC[off] !=
+				(u8char_T)(c < 0x80 && u8cc[0] == 0 ? 0 : u8c)
+			|| (ScreenLinesUC[off] != 0
+					  && screen_comp_differs(off, u8cc))))
 #endif
 		|| ScreenAttrs[off] != attr
-		|| exmode_active
+		|| exmode_active;
+
+	if (need_redraw
+#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
+		|| force_redraw_this
+#endif
 		)
 	{
 #if defined(FEAT_GUI) || defined(UNIX)
 	    /* The bold trick makes a single row of pixels appear in the next
 	     * character.  When a bold character is removed, the next
 	     * character should be redrawn too.  This happens for our own GUI
-	     * and for some xterms.
-	     * Force the redraw by setting the attribute to a different value
-	     * than "attr", the contents of ScreenLines[] may be needed by
-	     * mb_off2cells() further on.
-	     * Don't do this for the last drawn character, because the next
-	     * character may not be redrawn. */
-	    if (
+	     * and for some xterms. */
+	    if (need_redraw && ScreenLines[off] != ' ' && (
 # ifdef FEAT_GUI
 		    gui.in_use
 # endif
 # if defined(FEAT_GUI) && defined(UNIX)
 		    ||
 # endif
 # ifdef UNIX
 		    term_is_xterm
 # endif
-	       )
+		    ))
 	    {
-		int		n;
+		int	n = ScreenAttrs[off];
 
-		n = ScreenAttrs[off];
-# ifdef FEAT_MBYTE
-		if (col + mbyte_cells < screen_Columns
-			&& (n > HL_ALL || (n & HL_BOLD))
-			&& (len < 0 ? ptr[mbyte_blen] != NUL
-					     : ptr + mbyte_blen < text + len))
-		    ScreenAttrs[off + mbyte_cells] = attr + 1;
-# else
-		if (col + 1 < screen_Columns
-			&& (n > HL_ALL || (n & HL_BOLD))
-			&& (len < 0 ? ptr[1] != NUL : ptr + 1 < text + len))
-		    ScreenLines[off + 1] = 0;
-# endif
+		if (n > HL_ALL)
+		    n = syn_attr2attr(n);
+		if (n & HL_BOLD)
+		    force_redraw_next = TRUE;
 	    }
 #endif
 #ifdef FEAT_MBYTE
 	    /* When at the end of the text and overwriting a two-cell
 	     * character with a one-cell character, need to clear the next
@@ -6478,10 +6585,24 @@ screen_puts_len(text, len, row, col, att
 	    ++off;
 	    ++col;
 	    ++ptr;
 	}
     }
+
+#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
+    /* If we detected the next character needs to be redrawn, but the text
+     * doesn't extend up to there, update the character here. */
+    if (force_redraw_next && col < screen_Columns)
+    {
+# ifdef FEAT_MBYTE
+	if (enc_dbcs != 0 && dbcs_off2cells(off, max_off) > 1)
+	    screen_char_2(off, row, col);
+	else
+# endif
+	    screen_char(off, row, col);
+    }
+#endif
 }
 
 #ifdef FEAT_SEARCH_EXTRA
 /*
  * Prepare for 'hlsearch' highlighting.
@@ -7354,11 +7475,15 @@ screenalloc(clear)
     short	    *new_TabPageIdxs;
     tabpage_T	    *tp;
 #endif
     static int	    entered = FALSE;		/* avoid recursiveness */
     static int	    done_outofmem_msg = FALSE;	/* did outofmem message */
+#ifdef FEAT_AUTOCMD
+    int		    retry_count = 0;
 
+retry:
+#endif
     /*
      * Allocation of the screen buffers is done only when the size changes and
      * when Rows and Columns have been set and we have started doing full
      * screen stuff.
      */
@@ -7406,21 +7531,25 @@ screenalloc(clear)
      * Continuing with the old ScreenLines may result in a crash, because the
      * size is wrong.
      */
     FOR_ALL_TAB_WINDOWS(tp, wp)
 	win_free_lsize(wp);
+#ifdef FEAT_AUTOCMD
+    if (aucmd_win != NULL)
+	win_free_lsize(aucmd_win);
+#endif
 
     new_ScreenLines = (schar_T *)lalloc((long_u)(
 			      (Rows + 1) * Columns * sizeof(schar_T)), FALSE);
 #ifdef FEAT_MBYTE
-    vim_memset(new_ScreenLinesC, 0, sizeof(u8char_T) * MAX_MCO);
+    vim_memset(new_ScreenLinesC, 0, sizeof(u8char_T *) * MAX_MCO);
     if (enc_utf8)
     {
 	new_ScreenLinesUC = (u8char_T *)lalloc((long_u)(
 			     (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
 	for (i = 0; i < p_mco; ++i)
-	    new_ScreenLinesC[i] = (u8char_T *)lalloc((long_u)(
+	    new_ScreenLinesC[i] = (u8char_T *)lalloc_clear((long_u)(
 			     (Rows + 1) * Columns * sizeof(u8char_T)), FALSE);
     }
     if (enc_dbcs == DBCS_JPNU)
 	new_ScreenLines2 = (schar_T *)lalloc((long_u)(
 			     (Rows + 1) * Columns * sizeof(schar_T)), FALSE);
@@ -7438,14 +7567,22 @@ screenalloc(clear)
     {
 	if (win_alloc_lines(wp) == FAIL)
 	{
 	    outofmem = TRUE;
 #ifdef FEAT_WINDOWS
-	    break;
+	    goto give_up;
 #endif
 	}
     }
+#ifdef FEAT_AUTOCMD
+    if (aucmd_win != NULL && aucmd_win->w_lines == NULL
+					&& win_alloc_lines(aucmd_win) == FAIL)
+	outofmem = TRUE;
+#endif
+#ifdef FEAT_WINDOWS
+give_up:
+#endif
 
 #ifdef FEAT_MBYTE
     for (i = 0; i < p_mco; ++i)
 	if (new_ScreenLinesC[i] == NULL)
 	    break;
@@ -7626,12 +7763,21 @@ screenalloc(clear)
 
     entered = FALSE;
     --RedrawingDisabled;
 
 #ifdef FEAT_AUTOCMD
-    if (starting == 0)
+    /*
+     * Do not apply autocommands more than 3 times to avoid an endless loop
+     * in case applying autocommands always changes Rows or Columns.
+     */
+    if (starting == 0 && ++retry_count <= 3)
+    {
 	apply_autocmds(EVENT_VIMRESIZED, NULL, NULL, FALSE, curbuf);
+	/* In rare cases, autocommands may have altered Rows or Columns,
+	 * jump back to check if we need to allocate the screen again. */
+	goto retry;
+    }
 #endif
 }
 
     void
 free_screenlines()
@@ -8588,19 +8734,18 @@ screen_ins_lines(off, row, line_count, e
  * When scrolling region used 'off' is the offset from the top for the region.
  * 'row' and 'end' are relative to the start of the region.
  *
  * Return OK for success, FAIL if the lines are not deleted.
  */
-/*ARGSUSED*/
     int
 screen_del_lines(off, row, line_count, end, force, wp)
     int		off;
     int		row;
     int		line_count;
     int		end;
     int		force;		/* even when line_count > p_ttyscroll */
-    win_T	*wp;		/* NULL or window to use width from */
+    win_T	*wp UNUSED;	/* NULL or window to use width from */
 {
     int		j;
     int		i;
     unsigned	temp;
     int		cursor_row;
@@ -9078,11 +9223,11 @@ msg_pos_mode()
     void
 unshowmode(force)
     int	    force;
 {
     /*
-     * Don't delete it right now, when not redrawing or insided a mapping.
+     * Don't delete it right now, when not redrawing or inside a mapping.
      */
     if (!redrawing() || (!force && char_avail() && !KeyTyped))
 	redraw_cmdline = TRUE;		/* delete mode later */
     else
     {
@@ -9384,11 +9529,11 @@ showruler(always)
     }
 #endif
 #if defined(FEAT_STL_OPT) && defined(FEAT_WINDOWS)
     if ((*p_stl != NUL || *curwin->w_p_stl != NUL) && curwin->w_status_height)
     {
-	redraw_custum_statusline(curwin);
+	redraw_custom_statusline(curwin);
     }
     else
 #endif
 #ifdef FEAT_CMDL_INFO
 	win_redr_ruler(curwin, always);
@@ -9414,17 +9559,19 @@ showruler(always)
     static void
 win_redr_ruler(wp, always)
     win_T	*wp;
     int		always;
 {
-    char_u	buffer[70];
+#define RULER_BUF_LEN 70
+    char_u	buffer[RULER_BUF_LEN];
     int		row;
     int		fillchar;
     int		attr;
     int		empty_line = FALSE;
     colnr_T	virtcol;
     int		i;
+    size_t	len;
     int		o;
 #ifdef FEAT_VERTSPLIT
     int		this_ru_col;
     int		off = 0;
     int		width = Columns;
@@ -9535,25 +9682,26 @@ win_redr_ruler(wp, always)
 
 	/*
 	 * Some sprintfs return the length, some return a pointer.
 	 * To avoid portability problems we use strlen() here.
 	 */
-	sprintf((char *)buffer, "%ld,",
+	vim_snprintf((char *)buffer, RULER_BUF_LEN, "%ld,",
 		(wp->w_buffer->b_ml.ml_flags & ML_EMPTY)
 		    ? 0L
 		    : (long)(wp->w_cursor.lnum));
-	col_print(buffer + STRLEN(buffer),
+	len = STRLEN(buffer);
+	col_print(buffer + len, RULER_BUF_LEN - len,
 			empty_line ? 0 : (int)wp->w_cursor.col + 1,
 			(int)virtcol + 1);
 
 	/*
 	 * Add a "50%" if there is room for it.
 	 * On the last line, don't print in the last column (scrolls the
 	 * screen up on some terminals).
 	 */
 	i = (int)STRLEN(buffer);
-	get_rel_pos(wp, buffer + i + 1);
+	get_rel_pos(wp, buffer + i + 1, RULER_BUF_LEN - i - 1);
 	o = i + vim_strsize(buffer + i + 1);
 #ifdef FEAT_WINDOWS
 	if (wp->w_status_height == 0)	/* can't use last char of screen */
 #endif
 	    ++o;
@@ -9576,11 +9724,11 @@ win_redr_ruler(wp, always)
 		else
 #endif
 		    buffer[i++] = fillchar;
 		++o;
 	    }
-	    get_rel_pos(wp, buffer + i);
+	    get_rel_pos(wp, buffer + i, RULER_BUF_LEN - i);
 	}
 	/* Truncate at window boundary. */
 #ifdef FEAT_MBYTE
 	if (has_mbyte)
 	{
--- vim72.orig/src/search.c
+++ vim72/src/search.c
@@ -343,10 +343,19 @@ restore_search_patterns()
     void
 free_search_patterns()
 {
     vim_free(spats[0].pat);
     vim_free(spats[1].pat);
+
+# ifdef FEAT_RIGHTLEFT
+    if (mr_pattern_alloced)
+    {
+        vim_free(mr_pattern);
+        mr_pattern_alloced = FALSE;
+        mr_pattern = NULL;
+    }
+# endif
 }
 #endif
 
 /*
  * Return TRUE when case should be ignored for search pattern "pat".
@@ -511,11 +520,10 @@ last_pat_prog(regmatch)
  *
  * Return FAIL (zero) for failure, non-zero for success.
  * When FEAT_EVAL is defined, returns the index of the first matching
  * subpattern plus one; one if there was none.
  */
-/*ARGSUSED*/
     int
 searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm)
     win_T	*win;		/* window to search in; can be NULL for a
 				   buffer without a window! */
     buf_T	*buf;
@@ -524,11 +532,11 @@ searchit(win, buf, pos, dir, pat, count,
     char_u	*pat;
     long	count;
     int		options;
     int		pat_use;	/* which pattern to use when "pat" is empty */
     linenr_T	stop_lnum;	/* stop after this line number when != 0 */
-    proftime_T	*tm;		/* timeout limit or NULL */
+    proftime_T	*tm UNUSED;	/* timeout limit or NULL */
 {
     int		found;
     linenr_T	lnum;		/* no init to shut up Apollo cc */
     regmmatch_T	regmatch;
     char_u	*ptr;
@@ -543,12 +551,10 @@ searchit(win, buf, pos, dir, pat, count,
     long	nmatched;
     int		submatch = 0;
     int		save_called_emsg = called_emsg;
 #ifdef FEAT_SEARCH_EXTRA
     int		break_loop = FALSE;
-#else
-# define break_loop FALSE
 #endif
 
     if (search_regcomp(pat, RE_SEARCH, pat_use,
 		   (options & (SEARCH_HIS + SEARCH_KEEP)), &regmatch) == FAIL)
     {
@@ -929,11 +935,14 @@ searchit(win, buf, pos, dir, pat, count,
 	     * Stop the search if wrapscan isn't set, "stop_lnum" is
 	     * specified, after an interrupt, after a match and after looping
 	     * twice.
 	     */
 	    if (!p_ws || stop_lnum != 0 || got_int || called_emsg
-					       || break_loop || found || loop)
+#ifdef FEAT_SEARCH_EXTRA
+					       || break_loop
+#endif
+					       || found || loop)
 		break;
 
 	    /*
 	     * If 'wrapscan' is set we continue at the other end of the file.
 	     * If 'shortmess' does not contain 's', we give a message.
@@ -947,11 +956,15 @@ searchit(win, buf, pos, dir, pat, count,
 		lnum = 1;
 	    if (!shortmess(SHM_SEARCH) && (options & SEARCH_MSG))
 		give_warning((char_u *)_(dir == BACKWARD
 					  ? top_bot_msg : bot_top_msg), TRUE);
 	}
-	if (got_int || called_emsg || break_loop)
+	if (got_int || called_emsg
+#ifdef FEAT_SEARCH_EXTRA
+		|| break_loop
+#endif
+		)
 	    break;
     }
     while (--count > 0 && found);   /* stop after count matches or no match */
 
     vim_free(regmatch.regprog);
@@ -2325,12 +2338,12 @@ findmatchlimit(oap, initc, flags, maxtra
 		if (!cpo_bsl)
 		{
 		    for (col = pos.col; check_prevcol(linep, col, '\\', &col);)
 			bslcnt++;
 		}
-		/* Only accept a match when 'M' is in 'cpo' or when ecaping is
-		 * what we expect. */
+		/* Only accept a match when 'M' is in 'cpo' or when escaping
+		 * is what we expect. */
 		if (cpo_bsl || (bslcnt & 1) == match_escaped)
 		{
 		    if (c == initc)
 			count++;
 		    else
@@ -4512,16 +4525,15 @@ linewhite(lnum)
 #if defined(FEAT_FIND_ID) || defined(PROTO)
 /*
  * Find identifiers or defines in included files.
  * if p_ic && (compl_cont_status & CONT_SOL) then ptr must be in lowercase.
  */
-/*ARGSUSED*/
     void
 find_pattern_in_path(ptr, dir, len, whole, skip_comments,
 				    type, count, action, start_lnum, end_lnum)
     char_u	*ptr;		/* pointer to search pattern */
-    int		dir;		/* direction of expansion */
+    int		dir UNUSED;	/* direction of expansion */
     int		len;		/* length of search pattern */
     int		whole;		/* match whole words only */
     int		skip_comments;	/* don't match inside comments */
     int		type;		/* Type of search; are we looking for a type?
 				   a macro? */
@@ -4661,11 +4673,11 @@ find_pattern_in_path(ptr, dir, len, whol
 				action == ACTION_SHOW_ALL && files[i].matched)
 			{
 			    msg_putchar('\n');	    /* cursor below last one */
 			    if (!got_int)	    /* don't display if 'q'
 						       typed at "--more--"
-						       mesage */
+						       message */
 			    {
 				msg_home_replace_hl(new_fname);
 				MSG_PUTS(_(" (includes previously listed match)"));
 				prev_fname = NULL;
 			    }
@@ -4973,11 +4985,11 @@ search_line:
 				    || (vim_strchr(p_cpo, CPO_JOINSP) == NULL
 					&& (IObuff[i-2] == '?'
 					    || IObuff[i-2] == '!'))))
 				IObuff[i++] = ' ';
 			}
-			/* copy as much as posible of the new word */
+			/* copy as much as possible of the new word */
 			if (p - aux >= IOSIZE - i)
 			    p = aux + IOSIZE - i - 1;
 			STRNCPY(IObuff + i, aux, p - aux);
 			i += (int)(p - aux);
 			reuse |= CONT_S_IPOS;
@@ -5008,11 +5020,11 @@ search_line:
 		if (curr_fname != prev_fname)
 		{
 		    if (did_show)
 			msg_putchar('\n');	/* cursor below last one */
 		    if (!got_int)		/* don't display if 'q' typed
-						    at "--more--" mesage */
+						    at "--more--" message */
 			msg_home_replace_hl(curr_fname);
 		    prev_fname = curr_fname;
 		}
 		did_show = TRUE;
 		if (!got_int)
@@ -5090,11 +5102,11 @@ search_line:
 			curwin->w_cursor.lnum = files[depth].lnum;
 		    }
 		}
 		if (action != ACTION_SHOW)
 		{
-		    curwin->w_cursor.col = (colnr_T) (startp - line);
+		    curwin->w_cursor.col = (colnr_T)(startp - line);
 		    curwin->w_set_curswant = TRUE;
 		}
 
 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
 		if (g_do_tagpreview != 0
@@ -5117,11 +5129,12 @@ exit_matched:
 	    if (def_regmatch.regprog == NULL
 #ifdef FEAT_INS_EXPAND
 		    && action == ACTION_EXPAND
 		    && !(compl_cont_status & CONT_SOL)
 #endif
-		    && *(p = startp + 1))
+		    && *startp != NUL
+		    && *(p = startp + 1) != NUL)
 		goto search_line;
 	}
 	line_breakcheck();
 #ifdef FEAT_INS_EXPAND
 	if (action == ACTION_EXPAND)
--- vim72.orig/src/spell.c
+++ vim72/src/spell.c
@@ -75,11 +75,11 @@
  */
 #define RESCORE(word_score, sound_score) ((3 * word_score + sound_score) / 4)
 
 /*
  * Do the opposite: based on a maximum end score and a known sound score,
- * compute the the maximum word score that can be used.
+ * compute the maximum word score that can be used.
  */
 #define MAXSCORE(word_score, sound_score) ((4 * word_score - sound_score) / 3)
 
 /*
  * Vim spell file format: <HEADER>
@@ -467,10 +467,11 @@ struct slang_S
     int		sl_compsylmax;	/* COMPOUNDSYLMAX (default: MAXWLEN) */
     int		sl_compoptions;	/* COMP_* flags */
     garray_T	sl_comppat;	/* CHECKCOMPOUNDPATTERN items */
     regprog_T	*sl_compprog;	/* COMPOUNDRULE turned into a regexp progrm
 				 * (NULL when no compounding) */
+    char_u	*sl_comprules;	/* all COMPOUNDRULE concatenated (or NULL) */
     char_u	*sl_compstartflags; /* flags for first compound word */
     char_u	*sl_compallflags; /* all flags for compound words */
     char_u	sl_nobreak;	/* When TRUE: no spaces between words */
     char_u	*sl_syllable;	/* SYLLABLE repeatable chars or NULL */
     garray_T	sl_syl_items;	/* syllable items */
@@ -623,11 +624,11 @@ typedef struct suggest_S
 #define SUG(ga, i) (((suggest_T *)(ga).ga_data)[i])
 
 /* TRUE if a word appears in the list of banned words.  */
 #define WAS_BANNED(su, word) (!HASHITEM_EMPTY(hash_find(&su->su_banned, word)))
 
-/* Number of suggestions kept when cleaning up.  we need to keep more than
+/* Number of suggestions kept when cleaning up.  We need to keep more than
  * what is displayed, because when rescore_suggestions() is called the score
  * may change and wrong suggestions may be removed later. */
 #define SUG_CLEAN_COUNT(su)    ((su)->su_maxcount < 130 ? 150 : (su)->su_maxcount + 20)
 
 /* Threshold for sorting and cleaning up suggestions.  Don't want to keep lots
@@ -837,11 +838,14 @@ typedef struct trystate_S
 static slang_T *slang_alloc __ARGS((char_u *lang));
 static void slang_free __ARGS((slang_T *lp));
 static void slang_clear __ARGS((slang_T *lp));
 static void slang_clear_sug __ARGS((slang_T *lp));
 static void find_word __ARGS((matchinf_T *mip, int mode));
+static int match_checkcompoundpattern __ARGS((char_u *ptr, int wlen, garray_T *gap));
 static int can_compound __ARGS((slang_T *slang, char_u *word, char_u *flags));
+static int can_be_compound __ARGS((trystate_T *sp, slang_T *slang, char_u *compflags, int flag));
+static int match_compoundrule __ARGS((slang_T *slang, char_u *compflags));
 static int valid_word_prefix __ARGS((int totprefcnt, int arridx, int flags, char_u *word, slang_T *slang, int cond_req));
 static void find_prefix __ARGS((matchinf_T *mip, int mode));
 static int fold_more __ARGS((matchinf_T *mip));
 static int spell_valid_case __ARGS((int wordflags, int treeflags));
 static int no_spell_checking __ARGS((win_T *wp));
@@ -944,34 +948,34 @@ static void close_spellbuf __ARGS((buf_T
  * differ from what the .spl file uses.
  * These must not be called with negative number!
  */
 #ifndef FEAT_MBYTE
 /* Non-multi-byte implementation. */
-# define SPELL_TOFOLD(c) ((c) < 256 ? spelltab.st_fold[c] : (c))
-# define SPELL_TOUPPER(c) ((c) < 256 ? spelltab.st_upper[c] : (c))
+# define SPELL_TOFOLD(c) ((c) < 256 ? (int)spelltab.st_fold[c] : (c))
+# define SPELL_TOUPPER(c) ((c) < 256 ? (int)spelltab.st_upper[c] : (c))
 # define SPELL_ISUPPER(c) ((c) < 256 ? spelltab.st_isu[c] : FALSE)
 #else
 # if defined(HAVE_WCHAR_H)
 #  include <wchar.h>	    /* for towupper() and towlower() */
 # endif
 /* Multi-byte implementation.  For Unicode we can call utf_*(), but don't do
  * that for ASCII, because we don't want to use 'casemap' here.  Otherwise use
  * the "w" library function for characters above 255 if available. */
 # ifdef HAVE_TOWLOWER
 #  define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \
-	    : (c) < 256 ? spelltab.st_fold[c] : towlower(c))
+	    : (c) < 256 ? (int)spelltab.st_fold[c] : (int)towlower(c))
 # else
 #  define SPELL_TOFOLD(c) (enc_utf8 && (c) >= 128 ? utf_fold(c) \
-	    : (c) < 256 ? spelltab.st_fold[c] : (c))
+	    : (c) < 256 ? (int)spelltab.st_fold[c] : (c))
 # endif
 
 # ifdef HAVE_TOWUPPER
 #  define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \
-	    : (c) < 256 ? spelltab.st_upper[c] : towupper(c))
+	    : (c) < 256 ? (int)spelltab.st_upper[c] : (int)towupper(c))
 # else
 #  define SPELL_TOUPPER(c) (enc_utf8 && (c) >= 128 ? utf_toupper(c) \
-	    : (c) < 256 ? spelltab.st_upper[c] : (c))
+	    : (c) < 256 ? (int)spelltab.st_upper[c] : (c))
 # endif
 
 # ifdef HAVE_ISWUPPER
 #  define SPELL_ISUPPER(c) (enc_utf8 && (c) >= 128 ? utf_isupper(c) \
 	    : (c) < 256 ? spelltab.st_isu[c] : iswupper(c))
@@ -1517,10 +1521,15 @@ find_word(mip, mode)
 					? slang->sl_compstartflags
 					: slang->sl_compallflags,
 					    ((unsigned)flags >> 24)))
 		    continue;
 
+		/* If there is a match with a CHECKCOMPOUNDPATTERN rule
+		 * discard the compound word. */
+		if (match_checkcompoundpattern(ptr, wlen, &slang->sl_comppat))
+		    continue;
+
 		if (mode == FIND_COMPOUND)
 		{
 		    int	    capflags;
 
 		    /* Need to check the caps type of the appended compound
@@ -1575,10 +1584,15 @@ find_word(mip, mode)
 			    vim_strncpy(fword, ptr, endlen[endidxcnt]);
 		    }
 		    if (!can_compound(slang, fword, mip->mi_compflags))
 			continue;
 		}
+		else if (slang->sl_comprules != NULL
+			     && !match_compoundrule(slang, mip->mi_compflags))
+		    /* The compound flags collected so far do not match any
+		     * COMPOUNDRULE, discard the compounded word. */
+		    continue;
 	    }
 
 	    /* Check NEEDCOMPOUND: can't use word without compounding. */
 	    else if (flags & WF_NEEDCOMP)
 		continue;
@@ -1725,10 +1739,43 @@ find_word(mip, mode)
 	    break;
     }
 }
 
 /*
+ * Return TRUE if there is a match between the word ptr[wlen] and
+ * CHECKCOMPOUNDPATTERN rules, assuming that we will concatenate with another
+ * word.
+ * A match means that the first part of CHECKCOMPOUNDPATTERN matches at the
+ * end of ptr[wlen] and the second part matches after it.
+ */
+    static int
+match_checkcompoundpattern(ptr, wlen, gap)
+    char_u	*ptr;
+    int		wlen;
+    garray_T	*gap;  /* &sl_comppat */
+{
+    int		i;
+    char_u	*p;
+    int		len;
+
+    for (i = 0; i + 1 < gap->ga_len; i += 2)
+    {
+	p = ((char_u **)gap->ga_data)[i + 1];
+	if (STRNCMP(ptr + wlen, p, STRLEN(p)) == 0)
+	{
+	    /* Second part matches at start of following compound word, now
+	     * check if first part matches at end of previous word. */
+	    p = ((char_u **)gap->ga_data)[i];
+	    len = (int)STRLEN(p);
+	    if (len <= wlen && STRNCMP(ptr + wlen - len, p, len) == 0)
+		return TRUE;
+	}
+    }
+    return FALSE;
+}
+
+/*
  * Return TRUE if "flags" is a valid sequence of compound flags and "word"
  * does not have too many syllables.
  */
     static int
 can_compound(slang, word, flags)
@@ -1771,10 +1818,102 @@ can_compound(slang, word, flags)
 	return (int)STRLEN(flags) < slang->sl_compmax;
     return TRUE;
 }
 
 /*
+ * Return TRUE when the sequence of flags in "compflags" plus "flag" can
+ * possibly form a valid compounded word.  This also checks the COMPOUNDRULE
+ * lines if they don't contain wildcards.
+ */
+    static int
+can_be_compound(sp, slang, compflags, flag)
+    trystate_T	*sp;
+    slang_T	*slang;
+    char_u	*compflags;
+    int		flag;
+{
+    /* If the flag doesn't appear in sl_compstartflags or sl_compallflags
+     * then it can't possibly compound. */
+    if (!byte_in_str(sp->ts_complen == sp->ts_compsplit
+		? slang->sl_compstartflags : slang->sl_compallflags, flag))
+	return FALSE;
+
+    /* If there are no wildcards, we can check if the flags collected so far
+     * possibly can form a match with COMPOUNDRULE patterns.  This only
+     * makes sense when we have two or more words. */
+    if (slang->sl_comprules != NULL && sp->ts_complen > sp->ts_compsplit)
+    {
+	int v;
+
+	compflags[sp->ts_complen] = flag;
+	compflags[sp->ts_complen + 1] = NUL;
+	v = match_compoundrule(slang, compflags + sp->ts_compsplit);
+	compflags[sp->ts_complen] = NUL;
+	return v;
+    }
+
+    return TRUE;
+}
+
+
+/*
+ * Return TRUE if the compound flags in compflags[] match the start of any
+ * compound rule.  This is used to stop trying a compound if the flags
+ * collected so far can't possibly match any compound rule.
+ * Caller must check that slang->sl_comprules is not NULL.
+ */
+    static int
+match_compoundrule(slang, compflags)
+    slang_T	*slang;
+    char_u	*compflags;
+{
+    char_u	*p;
+    int		i;
+    int		c;
+
+    /* loop over all the COMPOUNDRULE entries */
+    for (p = slang->sl_comprules; *p != NUL; ++p)
+    {
+	/* loop over the flags in the compound word we have made, match
+	 * them against the current rule entry */
+	for (i = 0; ; ++i)
+	{
+	    c = compflags[i];
+	    if (c == NUL)
+		/* found a rule that matches for the flags we have so far */
+		return TRUE;
+	    if (*p == '/' || *p == NUL)
+		break;  /* end of rule, it's too short */
+	    if (*p == '[')
+	    {
+		int match = FALSE;
+
+		/* compare against all the flags in [] */
+		++p;
+		while (*p != ']' && *p != NUL)
+		    if (*p++ == c)
+			match = TRUE;
+		if (!match)
+		    break;  /* none matches */
+	    }
+	    else if (*p != c)
+		break;  /* flag of word doesn't match flag in pattern */
+	    ++p;
+	}
+
+	/* Skip to the next "/", where the next pattern starts. */
+	p = vim_strchr(p, '/');
+	if (p == NULL)
+	    break;
+    }
+
+    /* Checked all the rules and none of them match the flags, so there
+     * can't possibly be a compound starting with these flags. */
+    return FALSE;
+}
+
+/*
  * Return non-zero if the prefix indicated by "arridx" matches with the prefix
  * ID in "flags" for the word "word".
  * The WF_RAREPFX flag is included in the return value for a rare prefix.
  */
     static int
@@ -2235,11 +2374,11 @@ spell_move_to(wp, dir, allwords, curline
 		    give_warning((char_u *)_(bot_top_msg), TRUE);
 	    }
 
 	    /* If we are back at the starting line and there is no match then
 	     * give up. */
-	    if (lnum == wp->w_cursor.lnum && !found_one)
+	    if (lnum == wp->w_cursor.lnum && (!found_one || wrapped))
 		break;
 
 	    /* Skip the characters at the start of the next line that were
 	     * included in a match crossing line boundaries. */
 	    if (attr == HLF_COUNT)
@@ -2511,13 +2650,15 @@ slang_clear(lp)
 
     vim_free(lp->sl_midword);
     lp->sl_midword = NULL;
 
     vim_free(lp->sl_compprog);
+    vim_free(lp->sl_comprules);
     vim_free(lp->sl_compstartflags);
     vim_free(lp->sl_compallflags);
     lp->sl_compprog = NULL;
+    lp->sl_comprules = NULL;
     lp->sl_compstartflags = NULL;
     lp->sl_compallflags = NULL;
 
     vim_free(lp->sl_syllable);
     lp->sl_syllable = NULL;
@@ -3458,10 +3599,11 @@ read_compound(fd, slang, len)
     int		atstart;
     char_u	*pat;
     char_u	*pp;
     char_u	*cp;
     char_u	*ap;
+    char_u	*crp;
     int		cnt;
     garray_T	*gap;
 
     if (todo < 2)
 	return SP_FORMERROR;	/* need at least two bytes */
@@ -3543,10 +3685,16 @@ read_compound(fd, slang, len)
 	return SP_OTHERERROR;
     }
     slang->sl_compallflags = ap;
     *ap = NUL;
 
+    /* And a list of all patterns in their original form, for checking whether
+     * compounding may work in match_compoundrule().  This is freed when we
+     * encounter a wildcard, the check doesn't work then. */
+    crp = alloc(todo + 1);
+    slang->sl_comprules = crp;
+
     pp = pat;
     *pp++ = '^';
     *pp++ = '\\';
     *pp++ = '(';
 
@@ -3585,10 +3733,24 @@ read_compound(fd, slang, len)
 		}
 		if (atstart == 1)
 		    atstart = 0;
 	    }
 	}
+
+	/* Copy flag to "sl_comprules", unless we run into a wildcard. */
+	if (crp != NULL)
+	{
+	    if (c == '+' || c == '*')
+	    {
+		vim_free(slang->sl_comprules);
+		slang->sl_comprules = NULL;
+		crp = NULL;
+	    }
+	    else
+		*crp++ = c;
+	}
+
 	if (c == '/')	    /* slash separates two items */
 	{
 	    *pp++ = '\\';
 	    *pp++ = '|';
 	    atstart = 1;
@@ -3609,10 +3771,13 @@ read_compound(fd, slang, len)
     *pp++ = '\\';
     *pp++ = ')';
     *pp++ = '$';
     *pp = NUL;
 
+    if (crp != NULL)
+	*crp = NUL;
+
     slang->sl_compprog = vim_regcomp(pat, RE_MAGIC + RE_STRING + RE_STRICT);
     vim_free(pat);
     if (slang->sl_compprog == NULL)
 	return SP_FORMERROR;
 
@@ -4789,17 +4954,20 @@ typedef struct compitem_S
 
 /*
  * Structure that is used to store the items in the word tree.  This avoids
  * the need to keep track of each allocated thing, everything is freed all at
  * once after ":mkspell" is done.
+ * Note: "sb_next" must be just before "sb_data" to make sure the alignment of
+ * "sb_data" is correct for systems where pointers must be aligned on
+ * pointer-size boundaries and sizeof(pointer) > sizeof(int) (e.g., Sparc).
  */
 #define  SBLOCKSIZE 16000	/* size of sb_data */
 typedef struct sblock_S sblock_T;
 struct sblock_S
 {
-    sblock_T	*sb_next;	/* next block in list */
     int		sb_used;	/* nr of bytes already in use */
+    sblock_T	*sb_next;	/* next block in list */
     char_u	sb_data[1];	/* data, actually longer */
 };
 
 /*
  * A node in the tree.
@@ -4913,10 +5081,11 @@ typedef struct spellinfo_S
     int		si_newprefID;	/* current value for ah_newID */
     int		si_newcompID;	/* current value for compound ID */
 } spellinfo_T;
 
 static afffile_T *spell_read_aff __ARGS((spellinfo_T *spin, char_u *fname));
+static int is_aff_rule __ARGS((char_u **items, int itemcnt, char *rulename, int	 mincount));
 static void aff_process_flags __ARGS((afffile_T *affile, affentry_T *entry));
 static int spell_info_item __ARGS((char_u *s));
 static unsigned affitem2flag __ARGS((int flagtype, char_u *item, char_u	*fname, int lnum));
 static unsigned get_affitem __ARGS((int flagtype, char_u **pp));
 static void process_compflags __ARGS((spellinfo_T *spin, afffile_T *aff, char_u *compflags));
@@ -4948,11 +5117,11 @@ static void wordtree_compress __ARGS((sp
 static int node_compress __ARGS((spellinfo_T *spin, wordnode_T *node, hashtab_T *ht, int *tot));
 static int node_equal __ARGS((wordnode_T *n1, wordnode_T *n2));
 static void put_sugtime __ARGS((spellinfo_T *spin, FILE *fd));
 static int write_vim_spell __ARGS((spellinfo_T *spin, char_u *fname));
 static void clear_node __ARGS((wordnode_T *node));
-static int put_node __ARGS((FILE *fd, wordnode_T *node, int index, int regionmask, int prefixtree));
+static int put_node __ARGS((FILE *fd, wordnode_T *node, int idx, int regionmask, int prefixtree));
 static void spell_make_sugfile __ARGS((spellinfo_T *spin, char_u *wfname));
 static int sug_filltree __ARGS((spellinfo_T *spin, slang_T *slang));
 static int sug_maketable __ARGS((spellinfo_T *spin));
 static int sug_filltable __ARGS((spellinfo_T *spin, wordnode_T *node, int startwordnr, garray_T *gap));
 static int offset2bytes __ARGS((int nr, char_u *buf));
@@ -5221,12 +5390,11 @@ spell_read_aff(spin, fname)
 	}
 
 	/* Handle non-empty lines. */
 	if (itemcnt > 0)
 	{
-	    if (STRCMP(items[0], "SET") == 0 && itemcnt == 2
-						       && aff->af_enc == NULL)
+	    if (is_aff_rule(items, itemcnt, "SET", 2) && aff->af_enc == NULL)
 	    {
 #ifdef FEAT_MBYTE
 		/* Setup for conversion from "ENC" to 'encoding'. */
 		aff->af_enc = enc_canonize(items[1]);
 		if (aff->af_enc != NULL && !spin->si_ascii
@@ -5237,11 +5405,11 @@ spell_read_aff(spin, fname)
 		spin->si_conv.vc_fail = TRUE;
 #else
 		    smsg((char_u *)_("Conversion in %s not supported"), fname);
 #endif
 	    }
-	    else if (STRCMP(items[0], "FLAG") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "FLAG", 2)
 					      && aff->af_flagtype == AFT_CHAR)
 	    {
 		if (STRCMP(items[1], "long") == 0)
 		    aff->af_flagtype = AFT_LONG;
 		else if (STRCMP(items[1], "num") == 0)
@@ -5282,90 +5450,92 @@ spell_read_aff(spin, fname)
 			STRCAT(p, " ");
 			STRCAT(p, items[1]);
 			spin->si_info = p;
 		    }
 	    }
-	    else if (STRCMP(items[0], "MIDWORD") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "MIDWORD", 2)
 							   && midword == NULL)
 	    {
 		midword = getroom_save(spin, items[1]);
 	    }
-	    else if (STRCMP(items[0], "TRY") == 0 && itemcnt == 2)
+	    else if (is_aff_rule(items, itemcnt, "TRY", 2))
 	    {
 		/* ignored, we look in the tree for what chars may appear */
 	    }
 	    /* TODO: remove "RAR" later */
-	    else if ((STRCMP(items[0], "RAR") == 0
-			|| STRCMP(items[0], "RARE") == 0) && itemcnt == 2
-						       && aff->af_rare == 0)
+	    else if ((is_aff_rule(items, itemcnt, "RAR", 2)
+			|| is_aff_rule(items, itemcnt, "RARE", 2))
+							 && aff->af_rare == 0)
 	    {
 		aff->af_rare = affitem2flag(aff->af_flagtype, items[1],
 								 fname, lnum);
 	    }
 	    /* TODO: remove "KEP" later */
-	    else if ((STRCMP(items[0], "KEP") == 0
-		    || STRCMP(items[0], "KEEPCASE") == 0) && itemcnt == 2
+	    else if ((is_aff_rule(items, itemcnt, "KEP", 2)
+			|| is_aff_rule(items, itemcnt, "KEEPCASE", 2))
 						     && aff->af_keepcase == 0)
 	    {
 		aff->af_keepcase = affitem2flag(aff->af_flagtype, items[1],
 								 fname, lnum);
 	    }
-	    else if (STRCMP(items[0], "BAD") == 0 && itemcnt == 2
-						       && aff->af_bad == 0)
+	    else if ((is_aff_rule(items, itemcnt, "BAD", 2)
+			|| is_aff_rule(items, itemcnt, "FORBIDDENWORD", 2))
+							  && aff->af_bad == 0)
 	    {
 		aff->af_bad = affitem2flag(aff->af_flagtype, items[1],
 								 fname, lnum);
 	    }
-	    else if (STRCMP(items[0], "NEEDAFFIX") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "NEEDAFFIX", 2)
 						    && aff->af_needaffix == 0)
 	    {
 		aff->af_needaffix = affitem2flag(aff->af_flagtype, items[1],
 								 fname, lnum);
 	    }
-	    else if (STRCMP(items[0], "CIRCUMFIX") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "CIRCUMFIX", 2)
 						    && aff->af_circumfix == 0)
 	    {
 		aff->af_circumfix = affitem2flag(aff->af_flagtype, items[1],
 								 fname, lnum);
 	    }
-	    else if (STRCMP(items[0], "NOSUGGEST") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "NOSUGGEST", 2)
 						    && aff->af_nosuggest == 0)
 	    {
 		aff->af_nosuggest = affitem2flag(aff->af_flagtype, items[1],
 								 fname, lnum);
 	    }
-	    else if (STRCMP(items[0], "NEEDCOMPOUND") == 0 && itemcnt == 2
+	    else if ((is_aff_rule(items, itemcnt, "NEEDCOMPOUND", 2)
+			|| is_aff_rule(items, itemcnt, "ONLYINCOMPOUND", 2))
 						     && aff->af_needcomp == 0)
 	    {
 		aff->af_needcomp = affitem2flag(aff->af_flagtype, items[1],
 								 fname, lnum);
 	    }
-	    else if (STRCMP(items[0], "COMPOUNDROOT") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "COMPOUNDROOT", 2)
 						     && aff->af_comproot == 0)
 	    {
 		aff->af_comproot = affitem2flag(aff->af_flagtype, items[1],
 								 fname, lnum);
 	    }
-	    else if (STRCMP(items[0], "COMPOUNDFORBIDFLAG") == 0
-				   && itemcnt == 2 && aff->af_compforbid == 0)
+	    else if (is_aff_rule(items, itemcnt, "COMPOUNDFORBIDFLAG", 2)
+						   && aff->af_compforbid == 0)
 	    {
 		aff->af_compforbid = affitem2flag(aff->af_flagtype, items[1],
 								 fname, lnum);
 		if (aff->af_pref.ht_used > 0)
 		    smsg((char_u *)_("Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line %d"),
 			    fname, lnum);
 	    }
-	    else if (STRCMP(items[0], "COMPOUNDPERMITFLAG") == 0
-				   && itemcnt == 2 && aff->af_comppermit == 0)
+	    else if (is_aff_rule(items, itemcnt, "COMPOUNDPERMITFLAG", 2)
+						   && aff->af_comppermit == 0)
 	    {
 		aff->af_comppermit = affitem2flag(aff->af_flagtype, items[1],
 								 fname, lnum);
 		if (aff->af_pref.ht_used > 0)
 		    smsg((char_u *)_("Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line %d"),
 			    fname, lnum);
 	    }
-	    else if (STRCMP(items[0], "COMPOUNDFLAG") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "COMPOUNDFLAG", 2)
 							 && compflags == NULL)
 	    {
 		/* Turn flag "c" into COMPOUNDRULE compatible string "c+",
 		 * "Na" into "Na+", "1234" into "1234+". */
 		p = getroom(spin, STRLEN(items[1]) + 2, FALSE);
@@ -5374,11 +5544,19 @@ spell_read_aff(spin, fname)
 		    STRCPY(p, items[1]);
 		    STRCAT(p, "+");
 		    compflags = p;
 		}
 	    }
-	    else if (STRCMP(items[0], "COMPOUNDRULE") == 0 && itemcnt == 2)
+	    else if (is_aff_rule(items, itemcnt, "COMPOUNDRULES", 2))
+	    {
+		/* We don't use the count, but do check that it's a number and
+		 * not COMPOUNDRULE mistyped. */
+		if (atoi((char *)items[1]) == 0)
+		    smsg((char_u *)_("Wrong COMPOUNDRULES value in %s line %d: %s"),
+						       fname, lnum, items[1]);
+	    }
+	    else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2))
 	    {
 		/* Concatenate this string to previously defined ones, using a
 		 * slash to separate them. */
 		l = (int)STRLEN(items[1]) + 1;
 		if (compflags != NULL)
@@ -5393,60 +5571,57 @@ spell_read_aff(spin, fname)
 		    }
 		    STRCAT(p, items[1]);
 		    compflags = p;
 		}
 	    }
-	    else if (STRCMP(items[0], "COMPOUNDWORDMAX") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
 							      && compmax == 0)
 	    {
 		compmax = atoi((char *)items[1]);
 		if (compmax == 0)
 		    smsg((char_u *)_("Wrong COMPOUNDWORDMAX value in %s line %d: %s"),
 						       fname, lnum, items[1]);
 	    }
-	    else if (STRCMP(items[0], "COMPOUNDMIN") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "COMPOUNDMIN", 2)
 							   && compminlen == 0)
 	    {
 		compminlen = atoi((char *)items[1]);
 		if (compminlen == 0)
 		    smsg((char_u *)_("Wrong COMPOUNDMIN value in %s line %d: %s"),
 						       fname, lnum, items[1]);
 	    }
-	    else if (STRCMP(items[0], "COMPOUNDSYLMAX") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "COMPOUNDSYLMAX", 2)
 							   && compsylmax == 0)
 	    {
 		compsylmax = atoi((char *)items[1]);
 		if (compsylmax == 0)
 		    smsg((char_u *)_("Wrong COMPOUNDSYLMAX value in %s line %d: %s"),
 						       fname, lnum, items[1]);
 	    }
-	    else if (STRCMP(items[0], "CHECKCOMPOUNDDUP") == 0 && itemcnt == 1)
+	    else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDDUP", 1))
 	    {
 		compoptions |= COMP_CHECKDUP;
 	    }
-	    else if (STRCMP(items[0], "CHECKCOMPOUNDREP") == 0 && itemcnt == 1)
+	    else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDREP", 1))
 	    {
 		compoptions |= COMP_CHECKREP;
 	    }
-	    else if (STRCMP(items[0], "CHECKCOMPOUNDCASE") == 0 && itemcnt == 1)
+	    else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDCASE", 1))
 	    {
 		compoptions |= COMP_CHECKCASE;
 	    }
-	    else if (STRCMP(items[0], "CHECKCOMPOUNDTRIPLE") == 0
-							      && itemcnt == 1)
+	    else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDTRIPLE", 1))
 	    {
 		compoptions |= COMP_CHECKTRIPLE;
 	    }
-	    else if (STRCMP(items[0], "CHECKCOMPOUNDPATTERN") == 0
-							      && itemcnt == 2)
+	    else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 2))
 	    {
 		if (atoi((char *)items[1]) == 0)
 		    smsg((char_u *)_("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"),
 						       fname, lnum, items[1]);
 	    }
-	    else if (STRCMP(items[0], "CHECKCOMPOUNDPATTERN") == 0
-							      && itemcnt == 3)
+	    else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 3))
 	    {
 		garray_T    *gap = &spin->si_comppat;
 		int	    i;
 
 		/* Only add the couple if it isn't already there. */
@@ -5461,28 +5636,28 @@ spell_read_aff(spin, fname)
 					       = getroom_save(spin, items[1]);
 		    ((char_u **)(gap->ga_data))[gap->ga_len++]
 					       = getroom_save(spin, items[2]);
 		}
 	    }
-	    else if (STRCMP(items[0], "SYLLABLE") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "SYLLABLE", 2)
 							  && syllable == NULL)
 	    {
 		syllable = getroom_save(spin, items[1]);
 	    }
-	    else if (STRCMP(items[0], "NOBREAK") == 0 && itemcnt == 1)
+	    else if (is_aff_rule(items, itemcnt, "NOBREAK", 1))
 	    {
 		spin->si_nobreak = TRUE;
 	    }
-	    else if (STRCMP(items[0], "NOSPLITSUGS") == 0 && itemcnt == 1)
+	    else if (is_aff_rule(items, itemcnt, "NOSPLITSUGS", 1))
 	    {
 		spin->si_nosplitsugs = TRUE;
 	    }
-	    else if (STRCMP(items[0], "NOSUGFILE") == 0 && itemcnt == 1)
+	    else if (is_aff_rule(items, itemcnt, "NOSUGFILE", 1))
 	    {
 		spin->si_nosugfile = TRUE;
 	    }
-	    else if (STRCMP(items[0], "PFXPOSTPONE") == 0 && itemcnt == 1)
+	    else if (is_aff_rule(items, itemcnt, "PFXPOSTPONE", 1))
 	    {
 		aff->af_pfxpostpone = TRUE;
 	    }
 	    else if ((STRCMP(items[0], "PFX") == 0
 					      || STRCMP(items[0], "SFX") == 0)
@@ -5769,28 +5944,24 @@ spell_read_aff(spin, fname)
 			    cur_aff->ah_newID = 0;
 			}
 		    }
 		}
 	    }
-	    else if (STRCMP(items[0], "FOL") == 0 && itemcnt == 2
-							       && fol == NULL)
+	    else if (is_aff_rule(items, itemcnt, "FOL", 2) && fol == NULL)
 	    {
 		fol = vim_strsave(items[1]);
 	    }
-	    else if (STRCMP(items[0], "LOW") == 0 && itemcnt == 2
-							       && low == NULL)
+	    else if (is_aff_rule(items, itemcnt, "LOW", 2) && low == NULL)
 	    {
 		low = vim_strsave(items[1]);
 	    }
-	    else if (STRCMP(items[0], "UPP") == 0 && itemcnt == 2
-							       && upp == NULL)
+	    else if (is_aff_rule(items, itemcnt, "UPP", 2) && upp == NULL)
 	    {
 		upp = vim_strsave(items[1]);
 	    }
-	    else if ((STRCMP(items[0], "REP") == 0
-			|| STRCMP(items[0], "REPSAL") == 0)
-		    && itemcnt == 2)
+	    else if (is_aff_rule(items, itemcnt, "REP", 2)
+		     || is_aff_rule(items, itemcnt, "REPSAL", 2))
 	    {
 		/* Ignore REP/REPSAL count */;
 		if (!isdigit(*items[1]))
 		    smsg((char_u *)_("Expected REP(SAL) count in %s line %d"),
 								 fname, lnum);
@@ -5817,11 +5988,11 @@ spell_read_aff(spin, fname)
 		    add_fromto(spin, items[0][3] == 'S'
 					 ? &spin->si_repsal
 					 : &spin->si_rep, items[1], items[2]);
 		}
 	    }
-	    else if (STRCMP(items[0], "MAP") == 0 && itemcnt == 2)
+	    else if (is_aff_rule(items, itemcnt, "MAP", 2))
 	    {
 		/* MAP item or count */
 		if (!found_map)
 		{
 		    /* First line contains the count. */
@@ -5854,13 +6025,12 @@ spell_read_aff(spin, fname)
 		     * slashes. */
 		    ga_concat(&spin->si_map, items[1]);
 		    ga_append(&spin->si_map, '/');
 		}
 	    }
-	    /* Accept "SAL from to" and "SAL from to # comment". */
-	    else if (STRCMP(items[0], "SAL") == 0
-		    && (itemcnt == 3 || (itemcnt > 3 && items[3][0] == '#')))
+	    /* Accept "SAL from to" and "SAL from to  #comment". */
+	    else if (is_aff_rule(items, itemcnt, "SAL", 3))
 	    {
 		if (do_sal)
 		{
 		    /* SAL item (sounds-a-like)
 		     * Either one of the known keys or a from-to pair. */
@@ -5875,16 +6045,16 @@ spell_read_aff(spin, fname)
 			add_fromto(spin, &spin->si_sal, items[1],
 				     STRCMP(items[2], "_") == 0 ? (char_u *)""
 								: items[2]);
 		}
 	    }
-	    else if (STRCMP(items[0], "SOFOFROM") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "SOFOFROM", 2)
 							  && sofofrom == NULL)
 	    {
 		sofofrom = getroom_save(spin, items[1]);
 	    }
-	    else if (STRCMP(items[0], "SOFOTO") == 0 && itemcnt == 2
+	    else if (is_aff_rule(items, itemcnt, "SOFOTO", 2)
 							    && sofoto == NULL)
 	    {
 		sofoto = getroom_save(spin, items[1]);
 	    }
 	    else if (STRCMP(items[0], "COMMON") == 0)
@@ -5978,11 +6148,11 @@ spell_read_aff(spin, fname)
 	if (spin->si_newcompID == 127 || spin->si_newcompID == 255)
 	    MSG(_("Too many postponed prefixes"));
 	else if (spin->si_newprefID == 0 || spin->si_newprefID == 127)
 	    MSG(_("Too many compound flags"));
 	else
-	    MSG(_("Too many posponed prefixes and/or compound flags"));
+	    MSG(_("Too many postponed prefixes and/or compound flags"));
     }
 
     if (syllable != NULL)
     {
 	aff_check_string(spin->si_syllable, syllable, "SYLLABLE");
@@ -6015,10 +6185,26 @@ spell_read_aff(spin, fname)
     fclose(fd);
     return aff;
 }
 
 /*
+ * Return TRUE when items[0] equals "rulename", there are "mincount" items or
+ * a comment is following after item "mincount".
+ */
+    static int
+is_aff_rule(items, itemcnt, rulename, mincount)
+    char_u	**items;
+    int		itemcnt;
+    char	*rulename;
+    int		mincount;
+{
+    return (STRCMP(items[0], rulename) == 0
+	    && (itemcnt == mincount
+		|| (itemcnt > mincount && items[mincount][0] == '#')));
+}
+
+/*
  * For affix "entry" move COMPOUNDFORBIDFLAG and COMPOUNDPERMITFLAG from
  * ae_flags to ae_comppermit and ae_compforbid.
  */
     static void
 aff_process_flags(affile, entry)
@@ -7864,11 +8050,11 @@ put_sugtime(spin, fd)
     int		i;
 
     /* time_t can be up to 8 bytes in size, more than long_u, thus we
      * can't use put_bytes() here. */
     for (i = 7; i >= 0; --i)
-	if (i + 1 > sizeof(time_t))
+	if (i + 1 > (int)sizeof(time_t))
 	    /* ">>" doesn't work well when shifting more bits than avail */
 	    putc(0, fd);
 	else
 	{
 	    c = (unsigned)spin->si_sugtime >> (i * 8);
@@ -7924,25 +8110,27 @@ write_vim_spell(spin, fname)
     garray_T	*gap;
     fromto_T	*ftp;
     char_u	*p;
     int		rr;
     int		retval = OK;
+    size_t	fwv = 1;  /* collect return value of fwrite() to avoid
+			     warnings from picky compiler */
 
     fd = mch_fopen((char *)fname, "w");
     if (fd == NULL)
     {
 	EMSG2(_(e_notopen), fname);
 	return FAIL;
     }
 
     /* <HEADER>: <fileID> <versionnr> */
 							    /* <fileID> */
-    if (fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd) != 1)
-    {
-	EMSG(_(e_write));
-	retval = FAIL;
-    }
+    fwv &= fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd);
+    if (fwv != (size_t)1)
+	/* Catch first write error, don't try writing more. */
+	goto theend;
+
     putc(VIMSPELLVERSION, fd);				    /* <versionnr> */
 
     /*
      * <SECTIONS>: <section> ... <sectionend>
      */
@@ -7953,22 +8141,22 @@ write_vim_spell(spin, fname)
 	putc(SN_INFO, fd);				/* <sectionID> */
 	putc(0, fd);					/* <sectionflags> */
 
 	i = (int)STRLEN(spin->si_info);
 	put_bytes(fd, (long_u)i, 4);			/* <sectionlen> */
-	fwrite(spin->si_info, (size_t)i, (size_t)1, fd); /* <infotext> */
+	fwv &= fwrite(spin->si_info, (size_t)i, (size_t)1, fd); /* <infotext> */
     }
 
     /* SN_REGION: <regionname> ...
      * Write the region names only if there is more than one. */
     if (spin->si_region_count > 1)
     {
 	putc(SN_REGION, fd);				/* <sectionID> */
 	putc(SNF_REQUIRED, fd);				/* <sectionflags> */
 	l = spin->si_region_count * 2;
 	put_bytes(fd, (long_u)l, 4);			/* <sectionlen> */
-	fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd);
+	fwv &= fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd);
 							/* <regionname> ... */
 	regionmask = (1 << spin->si_region_count) - 1;
     }
     else
 	regionmask = 0;
@@ -8014,22 +8202,23 @@ write_vim_spell(spin, fname)
 		flags |= CF_UPPER;
 	    fputc(flags, fd);				/* <charflags> */
 	}
 
 	put_bytes(fd, (long_u)l, 2);			/* <folcharslen> */
-	fwrite(folchars, (size_t)l, (size_t)1, fd);	/* <folchars> */
+	fwv &= fwrite(folchars, (size_t)l, (size_t)1, fd); /* <folchars> */
     }
 
     /* SN_MIDWORD: <midword> */
     if (spin->si_midword != NULL)
     {
 	putc(SN_MIDWORD, fd);				/* <sectionID> */
 	putc(SNF_REQUIRED, fd);				/* <sectionflags> */
 
 	i = (int)STRLEN(spin->si_midword);
 	put_bytes(fd, (long_u)i, 4);			/* <sectionlen> */
-	fwrite(spin->si_midword, (size_t)i, (size_t)1, fd); /* <midword> */
+	fwv &= fwrite(spin->si_midword, (size_t)i, (size_t)1, fd);
+							/* <midword> */
     }
 
     /* SN_PREFCOND: <prefcondcnt> <prefcond> ... */
     if (spin->si_prefcond.ga_len > 0)
     {
@@ -8111,11 +8300,12 @@ write_vim_spell(spin, fname)
 	    for (rr = 1; rr <= 2; ++rr)
 	    {
 		p = rr == 1 ? ftp->ft_from : ftp->ft_to;
 		l = (int)STRLEN(p);
 		putc(l, fd);
-		fwrite(p, l, (size_t)1, fd);
+		if (l > 0)
+		    fwv &= fwrite(p, l, (size_t)1, fd);
 	    }
 	}
 
     }
 
@@ -8129,15 +8319,15 @@ write_vim_spell(spin, fname)
 	l = (int)STRLEN(spin->si_sofofr);
 	put_bytes(fd, (long_u)(l + STRLEN(spin->si_sofoto) + 4), 4);
 							/* <sectionlen> */
 
 	put_bytes(fd, (long_u)l, 2);			/* <sofofromlen> */
-	fwrite(spin->si_sofofr, l, (size_t)1, fd);	/* <sofofrom> */
+	fwv &= fwrite(spin->si_sofofr, l, (size_t)1, fd); /* <sofofrom> */
 
 	l = (int)STRLEN(spin->si_sofoto);
 	put_bytes(fd, (long_u)l, 2);			/* <sofotolen> */
-	fwrite(spin->si_sofoto, l, (size_t)1, fd);	/* <sofoto> */
+	fwv &= fwrite(spin->si_sofoto, l, (size_t)1, fd); /* <sofoto> */
     }
 
     /* SN_WORDS: <word> ...
      * This is for making suggestions, section is not required. */
     if (spin->si_commonwords.ht_used > 0)
@@ -8158,11 +8348,11 @@ write_vim_spell(spin, fname)
 		if (!HASHITEM_EMPTY(hi))
 		{
 		    l = (int)STRLEN(hi->hi_key) + 1;
 		    len += l;
 		    if (round == 2)			/* <word> */
-			fwrite(hi->hi_key, (size_t)l, (size_t)1, fd);
+			fwv &= fwrite(hi->hi_key, (size_t)l, (size_t)1, fd);
 		    --todo;
 		}
 	    if (round == 1)
 		put_bytes(fd, (long_u)len, 4);		/* <sectionlen> */
 	}
@@ -8174,11 +8364,11 @@ write_vim_spell(spin, fname)
     {
 	putc(SN_MAP, fd);				/* <sectionID> */
 	putc(0, fd);					/* <sectionflags> */
 	l = spin->si_map.ga_len;
 	put_bytes(fd, (long_u)l, 4);			/* <sectionlen> */
-	fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd);
+	fwv &= fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd);
 							/* <mapstr> */
     }
 
     /* SN_SUGFILE: <timestamp>
      * This is used to notify that a .sug file may be available and at the
@@ -8230,14 +8420,15 @@ write_vim_spell(spin, fname)
 							/* <comppatcount> */
 	for (i = 0; i < spin->si_comppat.ga_len; ++i)
 	{
 	    p = ((char_u **)(spin->si_comppat.ga_data))[i];
 	    putc((int)STRLEN(p), fd);			/* <comppatlen> */
-	    fwrite(p, (size_t)STRLEN(p), (size_t)1, fd);/* <comppattext> */
+	    fwv &= fwrite(p, (size_t)STRLEN(p), (size_t)1, fd);
+							/* <comppattext> */
 	}
 							/* <compflags> */
-	fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags),
+	fwv &= fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags),
 							       (size_t)1, fd);
     }
 
     /* SN_NOBREAK: NOBREAK flag */
     if (spin->si_nobreak)
@@ -8257,11 +8448,12 @@ write_vim_spell(spin, fname)
 	putc(SN_SYLLABLE, fd);				/* <sectionID> */
 	putc(0, fd);					/* <sectionflags> */
 
 	l = (int)STRLEN(spin->si_syllable);
 	put_bytes(fd, (long_u)l, 4);			/* <sectionlen> */
-	fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd); /* <syllable> */
+	fwv &= fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd);
+							/* <syllable> */
     }
 
     /* end of <SECTIONS> */
     putc(SN_END, fd);					/* <sectionend> */
 
@@ -8293,17 +8485,22 @@ write_vim_spell(spin, fname)
 
 	/* Write the nodes. */
 	(void)put_node(fd, tree, 0, regionmask, round == 3);
     }
 
-    /* Write another byte to check for errors. */
+    /* Write another byte to check for errors (file system full). */
     if (putc(0, fd) == EOF)
 	retval = FAIL;
-
+theend:
     if (fclose(fd) == EOF)
 	retval = FAIL;
 
+    if (fwv != (size_t)1)
+	retval = FAIL;
+    if (retval == FAIL)
+	EMSG(_(e_write));
+
     return retval;
 }
 
 /*
  * Clear the index and wnode fields of "node", it siblings and its
@@ -9888,10 +10085,11 @@ write_spell_prefcond(fd, gap)
 {
     int		i;
     char_u	*p;
     int		len;
     int		totlen;
+    size_t	x = 1;  /* collect return value of fwrite() */
 
     if (fd != NULL)
 	put_bytes(fd, (long_u)gap->ga_len, 2);	    /* <prefcondcnt> */
 
     totlen = 2 + gap->ga_len; /* length of <prefcondcnt> and <condlen> bytes */
@@ -9904,11 +10102,11 @@ write_spell_prefcond(fd, gap)
 	{
 	    len = (int)STRLEN(p);
 	    if (fd != NULL)
 	    {
 		fputc(len, fd);
-		fwrite(p, (size_t)len, (size_t)1, fd);
+		x &= fwrite(p, (size_t)len, (size_t)1, fd);
 	    }
 	    totlen += len;
 	}
 	else if (fd != NULL)
 	    fputc(0, fd);
@@ -10052,10 +10250,11 @@ spell_suggest(count)
     int		mouse_used;
     int		need_cap;
     int		limit;
     int		selected = count;
     int		badlen = 0;
+    int		msg_scroll_save = msg_scroll;
 
     if (no_spell_checking(curwin))
 	return;
 
 #ifdef FEAT_VISUAL
@@ -10105,11 +10304,14 @@ spell_suggest(count)
     /* Get the word and its length. */
 
     /* Figure out if the word should be capitalised. */
     need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col);
 
-    line = ml_get_curline();
+    /* Make a copy of current line since autocommands may free the line. */
+    line = vim_strsave(ml_get_curline());
+    if (line == NULL)
+	goto skip;
 
     /* Get the list of suggestions.  Limit to 'lines' - 2 or the number in
      * 'spellsuggest', whatever is smaller. */
     if (sps_limit > (int)Rows - 2)
 	limit = (int)Rows - 2;
@@ -10216,11 +10418,13 @@ spell_suggest(count)
 #endif
 	/* Ask for choice. */
 	selected = prompt_for_number(&mouse_used);
 	if (mouse_used)
 	    selected -= lines_left;
-	lines_left = Rows;	/* avoid more prompt */
+	lines_left = Rows;		/* avoid more prompt */
+	/* don't delay for 'smd' in normal_cmd() */
+	msg_scroll = msg_scroll_save;
     }
 
     if (selected > 0 && selected <= sug.su_ga.ga_len && u_save_cursor() == OK)
     {
 	/* Save the from and to text for :spellrepall. */
@@ -10241,11 +10445,12 @@ spell_suggest(count)
 	    repl_from = vim_strnsave(sug.su_badptr, stp->st_orglen);
 	    repl_to = vim_strsave(stp->st_word);
 	}
 
 	/* Replace the word. */
-	p = alloc((unsigned)STRLEN(line) - stp->st_orglen + stp->st_wordlen + 1);
+	p = alloc((unsigned)STRLEN(line) - stp->st_orglen
+						       + stp->st_wordlen + 1);
 	if (p != NULL)
 	{
 	    c = (int)(sug.su_badptr - line);
 	    mch_memmove(p, line, c);
 	    STRCPY(p + c, stp->st_word);
@@ -10266,10 +10471,12 @@ spell_suggest(count)
     }
     else
 	curwin->w_cursor = prev_cursor;
 
     spell_find_cleanup(&sug);
+skip:
+    vim_free(line);
 }
 
 /*
  * Check if the word at line "lnum" column "col" is required to start with a
  * capital.  This uses 'spellcapcheck' of the current buffer.
@@ -10341,14 +10548,13 @@ check_need_cap(lnum, col)
 
 
 /*
  * ":spellrepall"
  */
-/*ARGSUSED*/
     void
 ex_spellrepall(eap)
-    exarg_T *eap;
+    exarg_T *eap UNUSED;
 {
     pos_T	pos = curwin->w_cursor;
     char_u	*frompat;
     int		addlen;
     char_u	*line;
@@ -10728,11 +10934,11 @@ spell_suggest_intern(su, interactive)
 	    /* Adjust the word score for the suggestions found so far for how
 	     * they sounds like. */
 	    rescore_suggestions(su);
 
 	/*
-	 * While going throught the soundfold tree "su_maxscore" is the score
+	 * While going through the soundfold tree "su_maxscore" is the score
 	 * for the soundfold word, limits the changes that are being tried,
 	 * and "su_sfmaxscore" the rescored score, which is set by
 	 * cleanup_suggestions().
 	 * First find words with a small edit distance, because this is much
 	 * faster and often already finds the top-N suggestions.  If we didn't
@@ -11212,11 +11418,11 @@ suggest_trie_walk(su, lp, fword, soundfo
     int		soundfold;
 {
     char_u	tword[MAXWLEN];	    /* good word collected so far */
     trystate_T	stack[MAXWLEN];
     char_u	preword[MAXWLEN * 3]; /* word found with proper case;
-				       * concatanation of prefix compound
+				       * concatenation of prefix compound
 				       * words and split word.  NUL terminated
 				       * when going deeper but not when coming
 				       * back. */
     char_u	compflags[MAXWLEN];	/* compound flags, one for each word */
     trystate_T	*sp;
@@ -11478,19 +11684,28 @@ suggest_trie_walk(su, lp, fword, soundfo
 		    compflags[sp->ts_complen] = ((unsigned)flags >> 24);
 		    compflags[sp->ts_complen + 1] = NUL;
 		    vim_strncpy(preword + sp->ts_prewordlen,
 			    tword + sp->ts_splitoff,
 			    sp->ts_twordlen - sp->ts_splitoff);
-		    p = preword;
-		    while (*skiptowhite(p) != NUL)
-			p = skipwhite(skiptowhite(p));
-		    if (fword_ends && !can_compound(slang, p,
-						compflags + sp->ts_compsplit))
-			/* Compound is not allowed.  But it may still be
-			 * possible if we add another (short) word. */
+
+		    /* Verify CHECKCOMPOUNDPATTERN  rules. */
+		    if (match_checkcompoundpattern(preword,  sp->ts_prewordlen,
+							  &slang->sl_comppat))
 			compound_ok = FALSE;
 
+		    if (compound_ok)
+		    {
+			p = preword;
+			while (*skiptowhite(p) != NUL)
+			    p = skipwhite(skiptowhite(p));
+			if (fword_ends && !can_compound(slang, p,
+						compflags + sp->ts_compsplit))
+			    /* Compound is not allowed.  But it may still be
+			     * possible if we add another (short) word. */
+			    compound_ok = FALSE;
+		    }
+
 		    /* Get pointer to last char of previous word. */
 		    p = preword + sp->ts_prewordlen;
 		    mb_ptr_back(preword, p);
 		}
 	    }
@@ -11683,14 +11898,13 @@ suggest_trie_walk(su, lp, fword, soundfo
 						      >= slang->sl_compminlen)
 #endif
 			&& (slang->sl_compsylmax < MAXWLEN
 			    || sp->ts_complen + 1 - sp->ts_compsplit
 							  < slang->sl_compmax)
-			&& (byte_in_str(sp->ts_complen == sp->ts_compsplit
-					    ? slang->sl_compstartflags
-					    : slang->sl_compallflags,
-						    ((unsigned)flags >> 24))))
+			&& (can_be_compound(sp, slang,
+					 compflags, ((unsigned)flags >> 24))))
+
 		{
 		    try_compound = TRUE;
 		    compflags[sp->ts_complen] = ((unsigned)flags >> 24);
 		    compflags[sp->ts_complen + 1] = NUL;
 		}
@@ -14806,11 +15020,11 @@ soundalike_score(goodstart, badstart)
 	    /* Failed to compare. */
 	    break;
 
 	case 0:
 	    /*
-	     * Lenghts are equal, thus changes must result in same length: An
+	     * Lengths are equal, thus changes must result in same length: An
 	     * insert is only possible in combination with a delete.
 	     * 1: check if for identical strings
 	     */
 	    if (*pl == NUL)
 		return score;
@@ -15396,14 +15610,13 @@ pop:
 #endif
 
 /*
  * ":spellinfo"
  */
-/*ARGSUSED*/
     void
 ex_spellinfo(eap)
-    exarg_T *eap;
+    exarg_T *eap UNUSED;
 {
     int		lpi;
     langp_T	*lp;
     char_u	*p;
 
@@ -15943,15 +16156,13 @@ spell_expand_check_cap(col)
  * Get list of spelling suggestions.
  * Used for Insert mode completion CTRL-X ?.
  * Returns the number of matches.  The matches are in "matchp[]", array of
  * allocated strings.
  */
-/*ARGSUSED*/
     int
-expand_spelling(lnum, col, pat, matchp)
-    linenr_T	lnum;
-    int		col;
+expand_spelling(lnum, pat, matchp)
+    linenr_T	lnum UNUSED;
     char_u	*pat;
     char_u	***matchp;
 {
     garray_T	ga;
 
--- vim72.orig/src/structs.h
+++ vim72/src/structs.h
@@ -14,11 +14,11 @@
  * There is something wrong in the SAS compiler that makes typedefs not
  * valid in include files.  Has been fixed in version 6.58.
  */
 #if defined(SASC) && SASC < 658
 typedef long		linenr_T;
-typedef unsigned	colnr_T;
+typedef int		colnr_T;
 typedef unsigned short	short_u;
 #endif
 
 /*
  * position in file or buffer
@@ -31,13 +31,13 @@ typedef struct
     colnr_T	coladd;
 #endif
 } pos_T;
 
 #ifdef FEAT_VIRTUALEDIT
-# define INIT_POS_T {0, 0, 0}
+# define INIT_POS_T(l, c, ca) {l, c, ca}
 #else
-# define INIT_POS_T {0, 0}
+# define INIT_POS_T(l, c, ca) {l, c}
 #endif
 
 /*
  * Same, but without coladd.
  */
@@ -430,10 +430,11 @@ struct buffheader
  */
 typedef struct expand
 {
     int		xp_context;		/* type of expansion */
     char_u	*xp_pattern;		/* start of item to expand */
+    int		xp_pattern_len;		/* bytes in xp_pattern before cursor */
 #if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
     char_u	*xp_arg;		/* completion function */
     int		xp_scriptID;		/* SID for completion function */
 #endif
     int		xp_backslash;		/* one of the XP_BS_ values */
@@ -457,11 +458,11 @@ typedef struct expand
  * easy manipulation.
  */
 typedef struct
 {
     int		hide;			/* TRUE when ":hide" was used */
-# ifdef FEAT_BROWSE
+# ifdef FEAT_BROWSE_CMD
     int		browse;			/* TRUE to invoke file dialog */
 # endif
 # ifdef FEAT_WINDOWS
     int		split;			/* flags for win_split() */
     int		tab;			/* > 0 when ":tab" was used */
@@ -880,10 +881,12 @@ typedef struct
 /* Struct to hold the saved typeahead for save_typeahead(). */
 typedef struct
 {
     typebuf_T		save_typebuf;
     int			typebuf_valid;	    /* TRUE when save_typebuf valid */
+    int			old_char;
+    int			old_mod_mask;
     struct buffheader	save_stuffbuff;
 #ifdef USE_INPUT_BUF
     char_u		*save_inputbuf;
 #endif
 } tasave_T;
@@ -1164,11 +1167,12 @@ struct file_buffer
     char_u	*b_ffname;	/* full path file name */
     char_u	*b_sfname;	/* short file name */
     char_u	*b_fname;	/* current file name */
 
 #ifdef UNIX
-    int		b_dev;		/* device number (-1 if not set) */
+    int		b_dev_valid;	/* TRUE when b_dev has a valid number */
+    dev_t	b_dev;		/* device number */
     ino_t	b_ino;		/* inode number */
 #endif
 #ifdef FEAT_CW_EDITOR
     FSSpec	b_FSSpec;	/* MacOS File Identification */
 #endif
@@ -1618,10 +1622,18 @@ struct diffblock_S
     linenr_T	df_lnum[DB_COUNT];	/* line number in buffer */
     linenr_T	df_count[DB_COUNT];	/* nr of inserted/changed lines */
 };
 #endif
 
+#define SNAP_HELP_IDX	0
+#ifdef FEAT_AUTOCMD
+# define SNAP_AUCMD_IDX 1
+# define SNAP_COUNT	2
+#else
+# define SNAP_COUNT	1
+#endif
+
 /*
  * Tab pages point to the top frame of each tab page.
  * Note: Most values are NOT valid for the current tab page!  Use "curwin",
  * "firstwin", etc. for that.  "tp_topframe" is always valid and can be
  * compared against "topframe" to find the current tab page.
@@ -1646,11 +1658,11 @@ struct tabpage_S
 #ifdef FEAT_DIFF
     diff_T	    *tp_first_diff;
     buf_T	    *(tp_diffbuf[DB_COUNT]);
     int		    tp_diff_invalid;	/* list of diffs is outdated */
 #endif
-    frame_T	    *tp_snapshot;    /* window layout snapshot */
+    frame_T	    *(tp_snapshot[SNAP_COUNT]);  /* window layout snapshots */
 #ifdef FEAT_EVAL
     dictitem_T	    tp_winvar;	    /* variable for "t:" Dictionary */
     dict_T	    tp_vars;	    /* internal variables, local to tab page */
 #endif
 };
@@ -1782,14 +1794,19 @@ struct window_S
     colnr_T	w_old_visual_col;   /* last known start of visual part */
     colnr_T	w_old_curswant;	    /* last known value of Curswant */
 #endif
 
     /*
-     * The next three specify the offsets for displaying the buffer:
+     * "w_topline", "w_leftcol" and "w_skipcol" specify the offsets for
+     * displaying the buffer.
      */
     linenr_T	w_topline;	    /* buffer line number of the line at the
 				       top of the window */
+#ifdef FEAT_AUTOCMD
+    char	w_topline_was_set;  /* flag set to TRUE when topline is set,
+				       e.g. by winrestview() */
+#endif
 #ifdef FEAT_DIFF
     int		w_topfill;	    /* number of filler lines above w_topline */
     int		w_old_topfill;	    /* w_topfill at last redraw */
     int		w_botfill;	    /* TRUE when filler lines are actually
 				       below w_topline (at end of file) */
@@ -2268,20 +2285,17 @@ typedef int vimmenu_T;
  * Struct to save values in before executing autocommands for a buffer that is
  * not the current buffer.  Without FEAT_AUTOCMD only "curbuf" is remembered.
  */
 typedef struct
 {
-    buf_T	*save_buf;	/* saved curbuf */
+    buf_T	*save_curbuf;	/* saved curbuf */
 #ifdef FEAT_AUTOCMD
-    buf_T	*new_curbuf;	/* buffer to be used */
-    win_T	*save_curwin;	/* saved curwin, NULL if it didn't change */
-    win_T	*new_curwin;	/* new curwin if save_curwin != NULL */
-    pos_T	save_cursor;	/* saved cursor pos of save_curwin */
-    linenr_T	save_topline;	/* saved topline of save_curwin */
-# ifdef FEAT_DIFF
-    int		save_topfill;	/* saved topfill of save_curwin */
-# endif
+    int		use_aucmd_win;	/* using aucmd_win */
+    win_T	*save_curwin;	/* saved curwin */
+    win_T	*new_curwin;	/* new curwin */
+    buf_T	*new_curbuf;	/* new curbuf */
+    char_u	*globaldir;	/* saved value of globaldir */
 #endif
 } aco_save_T;
 
 /*
  * Generic option table item, only used for printer at the moment.
--- vim72.orig/src/syntax.c
+++ vim72/src/syntax.c
@@ -204,11 +204,11 @@ typedef struct syn_pattern
  * The attributes of the syntax item that has been recognized.
  */
 static int current_attr = 0;	    /* attr of current syntax word */
 #ifdef FEAT_EVAL
 static int current_id = 0;	    /* ID of current char for syn_get_id() */
-static int current_trans_id = 0;    /* idem, transparancy removed */
+static int current_trans_id = 0;    /* idem, transparency removed */
 #endif
 
 typedef struct syn_cluster_S
 {
     char_u	    *scl_name;	    /* syntax cluster name */
@@ -280,11 +280,11 @@ static int keepend_level = -1;
 typedef struct state_item
 {
     int		si_idx;			/* index of syntax pattern or
 					   KEYWORD_IDX */
     int		si_id;			/* highlight group ID for keywords */
-    int		si_trans_id;		/* idem, transparancy removed */
+    int		si_trans_id;		/* idem, transparency removed */
     int		si_m_lnum;		/* lnum of the match */
     int		si_m_startcol;		/* starting column of the match */
     lpos_T	si_m_endpos;		/* just after end posn of the match */
     lpos_T	si_h_startpos;		/* start position of the highlighting */
     lpos_T	si_h_endpos;		/* end position of the highlighting */
@@ -1272,11 +1272,11 @@ syn_stack_cleanup()
 	dist = 999999;
     else
 	dist = syn_buf->b_ml.ml_line_count / (syn_buf->b_sst_len - Rows) + 1;
 
     /*
-     * Go throught the list to find the "tick" for the oldest entry that can
+     * Go through the list to find the "tick" for the oldest entry that can
      * be removed.  Set "above" when the "tick" for the oldest entry is above
      * "b_sst_lasttick" (the display tick wraps around).
      */
     tick = syn_buf->b_sst_lasttick;
     above = FALSE;
@@ -2317,11 +2317,11 @@ syn_current_attr(syncing, displaying, ca
 	 * ":syn spell toplevel" was used. */
 	*can_spell = syn_buf->b_syn_spell == SYNSPL_DEFAULT
 		    ? (syn_buf->b_spell_cluster_id == 0)
 		    : (syn_buf->b_syn_spell == SYNSPL_TOP);
 
-    /* nextgroup ends at end of line, unless "skipnl" or "skipemtpy" present */
+    /* nextgroup ends at end of line, unless "skipnl" or "skipempty" present */
     if (current_next_list != NULL
 	    && syn_getcurline()[current_col + 1] == NUL
 	    && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)))
 	current_next_list = NULL;
 
@@ -3084,10 +3084,16 @@ syn_add_start_off(result, regmatch, spp,
     {
 	result->lnum = regmatch->startpos[0].lnum;
 	col = regmatch->startpos[0].col;
 	off = spp->sp_offsets[idx];
     }
+    if (result->lnum > syn_buf->b_ml.ml_line_count)
+    {
+	/* a "\n" at the end of the pattern may take us below the last line */
+	result->lnum = syn_buf->b_ml.ml_line_count;
+	col = (int)STRLEN(ml_get_buf(syn_buf, result->lnum, FALSE));
+    }
     if (off != 0)
     {
 	base = ml_get_buf(syn_buf, result->lnum, FALSE);
 	p = base + col;
 	if (off > 0)
@@ -3222,15 +3228,14 @@ check_keyword_id(line, startcol, endcolp
 }
 
 /*
  * Handle ":syntax case" command.
  */
-/* ARGSUSED */
     static void
 syn_cmd_case(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	    /* not used */
+    int		syncing UNUSED;
 {
     char_u	*arg = eap->arg;
     char_u	*next;
 
     eap->nextcmd = find_nextcmd(arg);
@@ -3247,15 +3252,14 @@ syn_cmd_case(eap, syncing)
 }
 
 /*
  * Handle ":syntax spell" command.
  */
-/* ARGSUSED */
     static void
 syn_cmd_spell(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	    /* not used */
+    int		syncing UNUSED;
 {
     char_u	*arg = eap->arg;
     char_u	*next;
 
     eap->nextcmd = find_nextcmd(arg);
@@ -3515,41 +3519,38 @@ syn_clear_one(id, syncing)
 }
 
 /*
  * Handle ":syntax on" command.
  */
-/* ARGSUSED */
     static void
 syn_cmd_on(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	/* not used */
+    int		syncing UNUSED;
 {
     syn_cmd_onoff(eap, "syntax");
 }
 
 /*
  * Handle ":syntax enable" command.
  */
-/* ARGSUSED */
     static void
 syn_cmd_enable(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	/* not used */
+    int		syncing UNUSED;
 {
     set_internal_string_var((char_u *)"syntax_cmd", (char_u *)"enable");
     syn_cmd_onoff(eap, "syntax");
     do_unlet((char_u *)"g:syntax_cmd", TRUE);
 }
 
 /*
  * Handle ":syntax reset" command.
  */
-/* ARGSUSED */
     static void
 syn_cmd_reset(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	/* not used */
+    int		syncing UNUSED;
 {
     eap->nextcmd = check_nextcmd(eap->arg);
     if (!eap->skip)
     {
 	set_internal_string_var((char_u *)"syntax_cmd", (char_u *)"reset");
@@ -3559,27 +3560,25 @@ syn_cmd_reset(eap, syncing)
 }
 
 /*
  * Handle ":syntax manual" command.
  */
-/* ARGSUSED */
     static void
 syn_cmd_manual(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	/* not used */
+    int		syncing UNUSED;
 {
     syn_cmd_onoff(eap, "manual");
 }
 
 /*
  * Handle ":syntax off" command.
  */
-/* ARGSUSED */
     static void
 syn_cmd_off(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	/* not used */
+    int		syncing UNUSED;
 {
     syn_cmd_onoff(eap, "nosyntax");
 }
 
     static void
@@ -4172,11 +4171,10 @@ clear_keywtab(ht)
     for (hi = ht->ht_array; todo > 0; ++hi)
     {
 	if (!HASHITEM_EMPTY(hi))
 	{
 	    --todo;
-	    kp = HI2KE(hi);
 	    for (kp = HI2KE(hi); kp != NULL; kp = kp_next)
 	    {
 		kp_next = kp->ke_next;
 		vim_free(kp->next_list);
 		vim_free(kp->k_syn.cont_in_list);
@@ -4459,15 +4457,14 @@ syn_incl_toplevel(id, flagsp)
 }
 
 /*
  * Handle ":syntax include [@{group-name}] filename" command.
  */
-/* ARGSUSED */
     static void
 syn_cmd_include(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	    /* not used */
+    int		syncing UNUSED;
 {
     char_u	*arg = eap->arg;
     int		sgl_id = 1;
     char_u	*group_name_end;
     char_u	*rest;
@@ -4530,15 +4527,14 @@ syn_cmd_include(eap, syncing)
 }
 
 /*
  * Handle ":syntax keyword {group-name} [{option}] keyword .." command.
  */
-/* ARGSUSED */
     static void
 syn_cmd_keyword(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	    /* not used */
+    int		syncing UNUSED;
 {
     char_u	*arg = eap->arg;
     char_u	*group_name_end;
     int		syn_id;
     char_u	*rest;
@@ -5273,15 +5269,14 @@ syn_add_cluster(name)
 
 /*
  * Handle ":syntax cluster {cluster-name} [contains={groupname},..]
  *		[add={groupname},..] [remove={groupname},..]".
  */
-/* ARGSUSED */
     static void
 syn_cmd_cluster(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	    /* not used */
+    int		syncing UNUSED;
 {
     char_u	*arg = eap->arg;
     char_u	*group_name_end;
     char_u	*rest;
     int		scl_id;
@@ -5462,15 +5457,14 @@ get_syn_pattern(arg, ci)
 }
 
 /*
  * Handle ":syntax sync .." command.
  */
-/* ARGSUSED */
     static void
 syn_cmd_sync(eap, syncing)
     exarg_T	*eap;
-    int		syncing;	    /* not used */
+    int		syncing UNUSED;
 {
     char_u	*arg_start = eap->arg;
     char_u	*arg_end;
     char_u	*key = NULL;
     char_u	*next_arg;
@@ -6097,14 +6091,13 @@ static char *(case_args[]) = {"match", "
 
 /*
  * Function given to ExpandGeneric() to obtain the list syntax names for
  * expansion.
  */
-/*ARGSUSED*/
     char_u *
 get_syntax_name(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
     if (expand_what == EXP_SUBCMD)
 	return (char_u *)subcommands[idx].name;
     return (char_u *)case_args[idx];
@@ -6118,11 +6111,11 @@ get_syntax_name(xp, idx)
     int
 syn_get_id(wp, lnum, col, trans, spellp, keep_state)
     win_T	*wp;
     long	lnum;
     colnr_T	col;
-    int		trans;	     /* remove transparancy */
+    int		trans;	     /* remove transparency */
     int		*spellp;     /* return: can do spell checking */
     int		keep_state;  /* keep state of char at "col" */
 {
     /* When the position is not after the current position and in the same
      * line of the same buffer, need to restart parsing. */
@@ -6210,14 +6203,12 @@ syn_get_foldlevel(wp, lnum)
 #endif
 static char *(highlight_init_both[]) =
     {
 	CENT("ErrorMsg term=standout ctermbg=DarkRed ctermfg=White",
 	     "ErrorMsg term=standout ctermbg=DarkRed ctermfg=White guibg=Red guifg=White"),
-#ifdef FEAT_SEARCH_EXTRA
 	CENT("IncSearch term=reverse cterm=reverse",
 	     "IncSearch term=reverse cterm=reverse gui=reverse"),
-#endif
 	CENT("ModeMsg term=bold cterm=bold",
 	     "ModeMsg term=bold cterm=bold gui=bold"),
 	CENT("NonText term=bold ctermfg=Blue",
 	     "NonText term=bold ctermfg=Blue gui=bold guifg=Blue"),
 	CENT("StatusLine term=reverse,bold cterm=reverse,bold",
@@ -7533,11 +7524,11 @@ highlight_clear(idx)
 }
 
 #if defined(FEAT_GUI) || defined(PROTO)
 /*
  * Set the normal foreground and background colors according to the "Normal"
- * highlighighting group.  For X11 also set "Menu", "Scrollbar", and
+ * highlighting group.  For X11 also set "Menu", "Scrollbar", and
  * "Tooltip" colors.
  */
     void
 set_normal_colors()
 {
@@ -7742,18 +7733,17 @@ fontset_name2handle(name, fixed_width)
 # endif
 
 /*
  * Get the font or fontset for one highlight group.
  */
-/*ARGSUSED*/
     static void
 hl_do_font(idx, arg, do_normal, do_menu, do_tooltip)
     int		idx;
     char_u	*arg;
-    int		do_normal;	/* set normal font */
-    int		do_menu;	/* set menu font */
-    int		do_tooltip;	/* set tooltip font */
+    int		do_normal;		/* set normal font */
+    int		do_menu UNUSED;		/* set menu font */
+    int		do_tooltip UNUSED;	/* set tooltip font */
 {
 # ifdef FEAT_XFONTSET
     /* If 'guifontset' is not empty, first try using the name as a
      * fontset.  If that doesn't work, use it as a font name. */
     if (*p_guifontset != NUL
@@ -8332,32 +8322,42 @@ highlight_has_attr(id, flag, modec)
  * Return color name of highlight group "id".
  */
     char_u *
 highlight_color(id, what, modec)
     int		id;
-    char_u	*what;	/* "fg", "bg", "sp", "fg#", "bg#" or "sp#" */
+    char_u	*what;	/* "font", "fg", "bg", "sp", "fg#", "bg#" or "sp#" */
     int		modec;	/* 'g' for GUI, 'c' for cterm, 't' for term */
 {
     static char_u	name[20];
     int			n;
     int			fg = FALSE;
 # ifdef FEAT_GUI
     int			sp = FALSE;
+    int			font = FALSE;
 # endif
 
     if (id <= 0 || id > highlight_ga.ga_len)
 	return NULL;
 
-    if (TOLOWER_ASC(what[0]) == 'f')
+    if (TOLOWER_ASC(what[0]) == 'f' && TOLOWER_ASC(what[1]) == 'g')
 	fg = TRUE;
 # ifdef FEAT_GUI
-    else if (TOLOWER_ASC(what[0]) == 's')
+    else if (TOLOWER_ASC(what[0]) == 'f' && TOLOWER_ASC(what[1]) == 'o'
+             && TOLOWER_ASC(what[2]) == 'n' && TOLOWER_ASC(what[3]) == 't')
+	font = TRUE;
+    else if (TOLOWER_ASC(what[0]) == 's' && TOLOWER_ASC(what[1]) == 'p')
 	sp = TRUE;
+    else if (!(TOLOWER_ASC(what[0]) == 'b' && TOLOWER_ASC(what[1]) == 'g'))
+	return NULL;
     if (modec == 'g')
     {
+	/* return font name */
+	if (font)
+	    return HL_TABLE()[id - 1].sg_font_name;
+
 	/* return #RRGGBB form (only possible when GUI is running) */
-	if (gui.in_use && what[1] && what[2] == '#')
+	if (gui.in_use && what[2] == '#')
 	{
 	    guicolor_T		color;
 	    long_u		rgb;
 	    static char_u	buf[10];
 
@@ -8380,10 +8380,12 @@ highlight_color(id, what, modec)
 	    return (HL_TABLE()[id - 1].sg_gui_fg_name);
 	if (sp)
 	    return (HL_TABLE()[id - 1].sg_gui_sp_name);
 	return (HL_TABLE()[id - 1].sg_gui_bg_name);
     }
+    if (font || sp)
+	return NULL;
 # endif
     if (modec == 'c')
     {
 	if (fg)
 	    n = HL_TABLE()[id - 1].sg_cterm_fg - 1;
@@ -8658,10 +8660,11 @@ syn_add_group(name)
     for (p = name; *p != NUL; ++p)
     {
 	if (!vim_isprintc(*p))
 	{
 	    EMSG(_("E669: Unprintable character in group name"));
+	    vim_free(name);
 	    return 0;
 	}
 	else if (!ASCII_ISALNUM(*p) && *p != '_')
 	{
 	    /* This is an error, but since there previously was no check only
@@ -9148,14 +9151,13 @@ highlight_list_two(cnt, attr)
     || defined(FEAT_SIGNS) || defined(PROTO)
 /*
  * Function given to ExpandGeneric() to obtain the list of group names.
  * Also used for synIDattr() function.
  */
-/*ARGSUSED*/
     char_u *
 get_highlight_name(xp, idx)
-    expand_T	*xp;
+    expand_T	*xp UNUSED;
     int		idx;
 {
 #ifdef FEAT_CMDL_COMPL
     if (idx == highlight_ga.ga_len && include_none != 0)
 	return (char_u *)"none";
--- vim72.orig/src/tag.c
+++ vim72/src/tag.c
@@ -88,21 +88,22 @@ static char_u *topmsg = (char_u *)N_("E5
 static char_u	*tagmatchname = NULL;	/* name of last used tag */
 
 /*
  * We use ftello() here, if available.  It returns off_t instead of long,
  * which helps if long is 32 bit and off_t is 64 bit.
+ * We assume that when fseeko() is available then ftello() is too.
  */
-#ifdef HAVE_FTELLO
+#ifdef HAVE_FSEEKO
 # define ftell ftello
 #endif
 
 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
 /*
  * Tag for preview window is remembered separately, to avoid messing up the
  * normal tagstack.
  */
-static taggy_T ptag_entry = {NULL};
+static taggy_T ptag_entry = {NULL, {INIT_POS_T(0, 0, 0), 0}, 0, 0};
 #endif
 
 /*
  * Jump to tag; handling of tag commands and tag stack
  *
@@ -513,11 +514,11 @@ do_tag(tag, type, count, forceit, verbos
 
 	    /*
 	     * If a count is supplied to the ":tag <name>" command, then
 	     * jump to count'th matching tag.
 	     */
-	    if (type == DT_TAG && count > 0)
+	    if (type == DT_TAG && *tag != NUL && count > 0)
 		cur_match = count - 1;
 
 	    if (type == DT_SELECT || type == DT_JUMP
 #if defined(FEAT_QUICKFIX)
 		|| type == DT_LTAG
@@ -616,11 +617,11 @@ do_tag(tag, type, count, forceit, verbos
 		MSG_PUTS_ATTR(_("  # pri kind tag"), hl_attr(HLF_T));
 		msg_clr_eos();
 		taglen_advance(taglen);
 		MSG_PUTS_ATTR(_("file\n"), hl_attr(HLF_T));
 
-		for (i = 0; i < num_matches; ++i)
+		for (i = 0; i < num_matches && !got_int; ++i)
 		{
 		    parse_match(matches[i], &tagp);
 		    if (!new_tag && (
 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
 				(g_do_tagpreview
@@ -653,10 +654,12 @@ do_tag(tag, type, count, forceit, verbos
 			msg_puts_long_attr(p, hl_attr(HLF_D));
 			vim_free(p);
 		    }
 		    if (msg_col > 0)
 			msg_putchar('\n');
+		    if (got_int)
+			break;
 		    msg_advance(15);
 
 		    /* print any extra fields */
 		    command_end = tagp.command_end;
 		    if (command_end != NULL)
@@ -687,10 +690,12 @@ do_tag(tag, type, count, forceit, verbos
 			    while (*p && *p != '\r' && *p != '\n')
 			    {
 				if (msg_col + ptr2cells(p) >= Columns)
 				{
 				    msg_putchar('\n');
+				    if (got_int)
+					break;
 				    msg_advance(15);
 				}
 				p = msg_outtrans_one(p, attr);
 				if (*p == TAB)
 				{
@@ -702,10 +707,12 @@ do_tag(tag, type, count, forceit, verbos
 			    }
 			}
 			if (msg_col > 15)
 			{
 			    msg_putchar('\n');
+			    if (got_int)
+				break;
 			    msg_advance(15);
 			}
 		    }
 		    else
 		    {
@@ -732,10 +739,12 @@ do_tag(tag, type, count, forceit, verbos
 
 		    while (p != command_end)
 		    {
 			if (msg_col + (*p == TAB ? 1 : ptr2cells(p)) > Columns)
 			    msg_putchar('\n');
+			if (got_int)
+			    break;
 			msg_advance(15);
 
 			/* skip backslash used for escaping command char */
 			if (*p == '\\' && *(p + 1) == *tagp.command)
 			    ++p;
@@ -758,16 +767,13 @@ do_tag(tag, type, count, forceit, verbos
 			    break;
 		    }
 		    if (msg_col)
 			msg_putchar('\n');
 		    ui_breakcheck();
-		    if (got_int)
-		    {
-			got_int = FALSE;	/* only stop the listing */
-			break;
-		    }
 		}
+		if (got_int)
+		    got_int = FALSE;	/* only stop the listing */
 		ask_for_selection = TRUE;
 	    }
 #if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL)
 	    else if (type == DT_LTAG)
 	    {
@@ -1098,14 +1104,13 @@ taglen_advance(l)
 }
 
 /*
  * Print the tag stack
  */
-/*ARGSUSED*/
     void
 do_tags(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     int		i;
     char_u	*name;
     taggy_T	*tagstack = curwin->w_tagstack;
     int		tagstackidx = curwin->w_tagstackidx;
@@ -2523,15 +2528,14 @@ static void found_tagfile_cb __ARGS((cha
 
 /*
  * Callback function for finding all "tags" and "tags-??" files in
  * 'runtimepath' doc directories.
  */
-/*ARGSUSED*/
     static void
 found_tagfile_cb(fname, cookie)
     char_u	*fname;
-    void	*cookie;
+    void	*cookie UNUSED;
 {
     if (ga_grow(&tag_fnames, 1) == OK)
 	((char_u **)(tag_fnames.ga_data))[tag_fnames.ga_len++] =
 							   vim_strsave(fname);
 }
@@ -2540,10 +2544,19 @@ found_tagfile_cb(fname, cookie)
     void
 free_tag_stuff()
 {
     ga_clear_strings(&tag_fnames);
     do_tag(NULL, DT_FREE, 0, 0, 0);
+    tag_freematch();
+
+# if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
+    if (ptag_entry.tagname)
+    {
+        vim_free(ptag_entry.tagname);
+        ptag_entry.tagname = NULL;
+    }
+# endif
 }
 #endif
 
 /*
  * Get the next name of a tag file from the tag file list.
@@ -2723,21 +2736,38 @@ parse_tag_line(lbuf,
 	 * 1:  struct EnvBase ^?EnvBase^A139,4627
 	 * 2: #define	ARPB_WILD_WORLD ^?153,5194
 	 */
 	p_7f = vim_strchr(lbuf, 0x7f);
 	if (p_7f == NULL)
+	{
+etag_fail:
+	    if (vim_strchr(lbuf, '\n') == NULL)
+	    {
+		/* Truncated line.  Ignore it. */
+		if (p_verbose >= 5)
+		{
+		    verbose_enter();
+		    MSG(_("Ignoring long line in tags file"));
+		    verbose_leave();
+		}
+		tagp->command = lbuf;
+		tagp->tagname = lbuf;
+		tagp->tagname_end = lbuf;
+		return OK;
+	    }
 	    return FAIL;
+	}
 
 	/* Find ^A.  If not found the line number is after the 0x7f */
 	p = vim_strchr(p_7f, Ctrl_A);
 	if (p == NULL)
 	    p = p_7f + 1;
 	else
 	    ++p;
 
 	if (!VIM_ISDIGIT(*p))	    /* check for start of line number */
-	    return FAIL;
+	    goto etag_fail;
 	tagp->command = p;
 
 
 	if (p[-1] == Ctrl_A)	    /* first format: explicit tagname given */
 	{
@@ -2747,11 +2777,11 @@ parse_tag_line(lbuf,
 	else			    /* second format: isolate tagname */
 	{
 	    /* find end of tagname */
 	    for (p = p_7f - 1; !vim_iswordc(*p); --p)
 		if (p == lbuf)
-		    return FAIL;
+		    goto etag_fail;
 	    tagp->tagname_end = p + 1;
 	    while (p >= lbuf && vim_iswordc(*p))
 		--p;
 	    tagp->tagname = p + 1;
 	}
@@ -3760,11 +3790,11 @@ add_tag_field(dict, field_name, start, e
 	    end = start + STRLEN(start);
 	    while (end > start && (end[-1] == '\r' || end[-1] == '\n'))
 		--end;
 	}
 	len = (int)(end - start);
-	if (len > sizeof(buf) - 1)
+	if (len > (int)sizeof(buf) - 1)
 	    len = sizeof(buf) - 1;
 	vim_strncpy(buf, start, len);
     }
     buf[len] = NUL;
     return dict_add_nr_str(dict, field_name, 0L, buf);
--- vim72.orig/src/term.c
+++ vim72/src/term.c
@@ -2879,11 +2879,11 @@ ttest(pairs)
 	    T_CAF = empty_option;
 	}
 
 	/* if 'Sb' and 'AB' are not defined, reset "Co" */
 	if (*T_CSB == NUL && *T_CAB == NUL)
-	    T_CCO = empty_option;
+	    free_one_termoption(T_CCO);
 
 	/* Set 'weirdinvert' according to value of 't_xs' */
 	p_wiv = (*T_XS != NUL);
     }
     need_gather = TRUE;
@@ -2904,11 +2904,11 @@ add_long_to_buf(val, dst)
     char_u  *dst;
 {
     int	    i;
     int	    shift;
 
-    for (i = 1; i <= sizeof(long_u); i++)
+    for (i = 1; i <= (int)sizeof(long_u); i++)
     {
 	shift = 8 * (sizeof(long_u) - i);
 	dst[i - 1] = (char_u) ((val >> shift) & 0xff);
     }
 }
@@ -2935,11 +2935,11 @@ get_long_from_buf(buf, val)
 
     *val = 0;
     len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u));
     if (len != -1)
     {
-	for (i = 0; i < sizeof(long_u); i++)
+	for (i = 0; i < (int)sizeof(long_u); i++)
 	{
 	    shift = 8 * (sizeof(long_u) - 1 - i);
 	    *val += (long_u)bytes[i] << shift;
 	}
     }
@@ -4918,11 +4918,19 @@ check_termcode(max_offset, buf, buflen)
 
 	/* Finally, add the special key code to our string */
 	key_name[0] = KEY2TERMCAP0(key);
 	key_name[1] = KEY2TERMCAP1(key);
 	if (key_name[0] == KS_KEY)
-	    string[new_slen++] = key_name[1];	/* from ":set <M-b>=xx" */
+	{
+	    /* from ":set <M-b>=xx" */
+#ifdef FEAT_MBYTE
+	    if (has_mbyte)
+		new_slen += (*mb_char2bytes)(key_name[1], string + new_slen);
+	    else
+#endif
+		string[new_slen++] = key_name[1];
+	}
 	else
 	{
 	    string[new_slen++] = K_SPECIAL;
 	    string[new_slen++] = key_name[0];
 	    string[new_slen++] = key_name[1];
@@ -5545,11 +5553,11 @@ check_for_codes_from_term()
  * Translate an internal mapping/abbreviation representation into the
  * corresponding external one recognized by :map/:abbrev commands;
  * respects the current B/k/< settings of 'cpoption'.
  *
  * This function is called when expanding mappings/abbreviations on the
- * command-line, and for building the "Ambiguous mapping..." error messge.
+ * command-line, and for building the "Ambiguous mapping..." error message.
  *
  * It uses a growarray to build the translation string since the
  * latter can be wider than the original description. The caller has to
  * free the string afterwards.
  *
--- vim72.orig/src/testdir/Make_amiga.mak
+++ vim72/src/testdir/Make_amiga.mak
@@ -23,11 +23,12 @@ SCRIPTS = test1.out test3.out test4.out
 		test33.out test34.out test35.out test36.out test37.out \
 		test38.out test39.out test40.out test41.out test42.out \
 		test43.out test44.out test45.out test46.out test47.out \
 		test48.out test51.out test53.out test54.out test55.out \
 		test56.out test57.out test58.out test59.out test60.out \
-		test61.out test62.out test63.out test64.out test65.out
+		test61.out test62.out test63.out test64.out test65.out \
+		test66.out test67.out test68.out test69.out
 
 .SUFFIXES: .in .out
 
 nongui:	/tmp $(SCRIPTS)
 	csh -c echo ALL DONE
@@ -108,5 +109,9 @@ test60.out: test60.in
 test61.out: test61.in
 test62.out: test62.in
 test63.out: test63.in
 test64.out: test64.in
 test65.out: test65.in
+test66.out: test66.in
+test67.out: test67.in
+test68.out: test68.in
+test69.out: test69.in
--- vim72.orig/src/testdir/Make_dos.mak
+++ vim72/src/testdir/Make_dos.mak
@@ -24,13 +24,14 @@ SCRIPTS16 =	test1.out test19.out test20.
 SCRIPTS =	test3.out test4.out test5.out test6.out test7.out \
 		test8.out test9.out test11.out test13.out test14.out \
 		test15.out test17.out test18.out test21.out test26.out \
 		test30.out test31.out test32.out test33.out test34.out \
 		test37.out test38.out test39.out test40.out test41.out \
-		test42.out test52.out test65.out
+		test42.out test52.out test65.out test66.out test67.out \
+		test68.out test69.out
 
-SCRIPTS32 =	test50.out
+SCRIPTS32 =	test50.out test70.out
 
 SCRIPTS_GUI = test16.out
 
 .SUFFIXES: .in .out
 
@@ -53,10 +54,11 @@ clean:
 	-del *.out
 	-if exist test.ok del test.ok
 	-if exist small.vim del small.vim
 	-if exist tiny.vim del tiny.vim
 	-if exist mbyte.vim del mbyte.vim
+	-if exist mzscheme.vim del mzscheme.vim
 	-del X*
 	-if exist viminfo del viminfo
 
 .in.out:
 	copy $*.ok test.ok
--- /dev/null
+++ vim72/src/testdir/Make_ming.mak
@@ -0,0 +1,93 @@
+# Makefile to run tests for Vim, on Dos-like machines
+# with sh.exe or zsh.exe in the path or not.
+#
+# Author: Bill McCarthy
+#
+# Note that test54 has been removed until it is fixed.
+#
+# Requires a set of Unix tools: echo, diff, etc.
+
+ifneq (sh.exe, $(SHELL))
+DEL = rm -f
+MV = mv
+CP = cp
+DIRSLASH = /
+else
+DEL = del
+MV = rename
+CP = copy
+DIRSLASH = \\
+endif
+
+VIMPROG = ..$(DIRSLASH)vim
+
+# Omitted:
+# test2		"\\tmp" doesn't work.
+# test10	'errorformat' is different
+# test12	can't unlink a swap file
+# test25	uses symbolic link
+# test27	can't edit file with "*" in file name
+# test31	16 bit version runs out of memory...
+
+SCRIPTS16 =	test1.out test19.out test20.out test22.out \
+		test23.out test24.out test28.out test29.out \
+		test35.out test36.out test43.out \
+		test44.out test45.out test46.out test47.out \
+		test48.out test51.out test53.out            \
+		test55.out test56.out test57.out test58.out test59.out \
+		test60.out test61.out test62.out test63.out test64.out
+
+# Had to remove test54 which doesn't work yet.
+#		                                 test54.out
+
+SCRIPTS =	test3.out test4.out test5.out test6.out test7.out \
+		test8.out test9.out test11.out test13.out test14.out \
+		test15.out test17.out test18.out test21.out test26.out \
+		test30.out test31.out test32.out test33.out test34.out \
+		test37.out test38.out test39.out test40.out test41.out \
+		test42.out test52.out test65.out test66.out test67.out \
+		test68.out test69.out
+
+SCRIPTS32 =	test50.out test70.out
+
+SCRIPTS_GUI = test16.out
+
+.SUFFIXES: .in .out
+
+vimall:	fixff $(SCRIPTS16) $(SCRIPTS) $(SCRIPTS_GUI) $(SCRIPTS32)
+	echo ALL DONE
+
+nongui:	fixff $(SCRIPTS16) $(SCRIPTS)
+	echo ALL DONE
+
+small:
+	echo ALL DONE
+
+gui:	fixff $(SCRIPTS16) $(SCRIPTS) $(SCRIPTS_GUI)
+	echo ALL DONE
+
+win32:	fixff $(SCRIPTS16) $(SCRIPTS) $(SCRIPTS32)
+	echo ALL DONE
+
+fixff:
+	-$(VIMPROG) -u dos.vim --noplugin "+argdo set ff=dos|upd" +q *.in *.ok
+
+clean:
+	-$(DEL) *.out
+	-$(DEL) test.ok
+	-$(DEL) small.vim
+	-$(DEL) tiny.vim
+	-$(DEL) mbyte.vim
+	-$(DEL) mzscheme.vim
+	-$(DEL) X*
+	-$(DEL) viminfo
+
+.in.out:
+	$(CP) $*.ok test.ok
+	$(VIMPROG) -u dos.vim -U NONE --noplugin -s dotest.in $*.in
+	diff test.out $*.ok
+	-$(DEL) $*.out
+	$(MV) test.out $*.out
+	-$(DEL) X*
+	-$(DEL) test.ok
+	-$(DEL) viminfo
--- vim72.orig/src/testdir/Make_os2.mak
+++ vim72/src/testdir/Make_os2.mak
@@ -23,11 +23,12 @@ SCRIPTS = test1.out test3.out test4.out
 		test33.out test34.out test35.out test36.out test37.out \
 		test38.out test39.out test40.out test41.out test42.out \
 		test43.out test44.out test45.out test46.out test47.out \
 		test48.out test51.out test53.out test54.out test55.out \
 		test56.out test57.out test58.out test59.out test60.out \
-		test61.out test62.out test63.out test64.out test65.out
+		test61.out test62.out test63.out test64.out test65.out \
+		test66.out test67.out test68.out test69.out
 
 .SUFFIXES: .in .out
 
 all:	/tmp $(SCRIPTS)
 	@echo ALL DONE
--- vim72.orig/src/testdir/Make_vms.mms
+++ vim72/src/testdir/Make_vms.mms
@@ -2,13 +2,13 @@
 # Makefile to run all tests for Vim on VMS
 #
 # Authors:	Zoltan Arpadffy, <arpadffy@polarhome.com>
 #		Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
 #
-# Last change:  2008 Jun 19
+# Last change:  2009 Sep 11
 #
-# This has been tested on VMS 6.2 to 7.2 on DEC Alpha and VAX.
+# This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
 # Edit the lines in the Configuration section below to select.
 #
 # Execute with:
 #		mms/descrip=Make_vms.mms
 # Cleanup with:
@@ -30,10 +30,19 @@
 # Comment out if you want to run Unix specific tests as well, but please
 # be aware, that on OpenVMS will fail, because of cat, rm, etc commands
 # and directory handling.
 # WANT_UNIX = YES
 
+# Comment out if you want to run Win32 specific tests as well, but please
+# be aware, that on OpenVMS will fail, because of cat, rm, etc commands
+# and directory handling.
+# WANT_WIN = YES
+
+# Comment out if you want to run spell checker tests.
+# They fail because VMS does not support file names.
+# WANT_SPELL = YES
+
 # Comment out if you have gzip on your system
 # HAVE_GZIP = YES
 
 # Comment out if you have GNU compatible diff on your system
 # HAVE_GDIFF = YES
@@ -51,25 +60,34 @@ VIMPROG = <->vim.exe
 SCRIPT = test1.out  test2.out  test3.out  test4.out  test5.out  \
 	 test6.out  test7.out  test8.out  test9.out  test10a.out\
 	 test13.out test14.out test15.out test17.out \
 	 test18.out test19.out test20.out test21.out test22.out \
 	 test23.out test24.out test26.out \
-	 test28.out test29.out test31.out test32.out \
+	 test28.out test29.out test30.out test31.out test32.out \
 	 test33.out test34.out test35.out test36.out test37.out \
 	 test38.out test39.out test40.out test41.out test42.out \
 	 test43.out test44.out test45.out test46.out \
 	 test48.out test51.out test53.out test54.out test55.out \
-	 test56.out test57.out test58.out test59.out test60.out \
-	 test61.out test62.out test63.out test64.out test65.out
+	 test56.out test57.out test60.out \
+	 test61.out test62.out test63.out test64.out test65.out \
+	 test66.out test67.out test68.out test69.out
 
 .IFDEF WANT_GUI
 SCRIPT_GUI = test16.out
 GUI_OPTION = -g
 .ENDIF
 
 .IFDEF WANT_UNIX
-SCRIPT_UNIX = test10.out test12.out test25.out test27.out test30.out test49.out
+SCRIPT_UNIX = test10.out test12.out test25.out test27.out test49.out
+.ENDIF
+
+.IFDEF WANT_WIN
+SCRIPT_WIN = test50.out test52.out
+.ENDIF
+
+.IFDEF WANT_SPELL
+SCRIPT_SPELL = test58.out test59.out
 .ENDIF
 
 .IFDEF HAVE_GZIP
 SCRIPT_GZIP = test11.out
 .ENDIF
@@ -82,15 +100,15 @@ SCRIPT_GDIFF = test47.out
 	-@ write sys$output " "
 	-@ write sys$output "-----------------------------------------------"
 	-@ write sys$output "                "$*" "
 	-@ write sys$output "-----------------------------------------------"
 	-@ create/term/wait mcr $(VIMPROG) $(GUI_OPTION) -u vms.vim --noplugin -s dotest.in $*.in
-	-@ if "''F$SEARCH("test.out.*")'" .NES. "" then differences test.out $*.ok;
+	-@ if "''F$SEARCH("test.out.*")'" .NES. "" then differences /par test.out $*.ok;
 	-@ if "''F$SEARCH("test.out.*")'" .NES. "" then rename test.out $*.out
 	-@ if "''F$SEARCH("Xdotest.*")'"  .NES. "" then delete/noconfirm/nolog Xdotest.*.*
 
-all : clean nolog $(SCRIPT) $(SCRIPT_GUI) $(SCRIPT_UNIX) $(SCRIPT_GZIP) $(SCRIPT_GDIFF)
+all : clean nolog $(SCRIPT) $(SCRIPT_GUI) $(SCRIPT_UNIX) $(SCRIPT_WIN) $(SCRIPT_SPELL) $(SCRIPT_GZIP) $(SCRIPT_GDIFF)
 	-@ write sys$output " "
 	-@ write sys$output "-----------------------------------------------"
 	-@ write sys$output "                All done"
 	-@ write sys$output "-----------------------------------------------"
 	-@ deassign sys$output
@@ -111,16 +129,26 @@ nolog :
 	-@ write sys$output "                Test results:"
 	-@ write sys$output "-----------------------------------------------"
 	-@ write sys$output "MAKE_VMS.MMS options:"
 	-@ write sys$output "   WANT_GUI  = ""$(WANT_GUI)"" "
 	-@ write sys$output "   WANT_UNIX = ""$(WANT_UNIX)"" "
+	-@ write sys$output "   WANT_WIN  = ""$(WANT_WIN)"" "
+	-@ write sys$output "   WANT_SPELL= ""$(WANT_SPELL)"" "
 	-@ write sys$output "   HAVE_GZIP = ""$(HAVE_GZIP)"" "
 	-@ write sys$output "   HAVE_GDIFF= ""$(HAVE_GDIFF)"" "
 	-@ write sys$output "Default vimrc file is VMS.VIM:
 	-@ write sys$output "-----------------------------------------------"
 	-@ type VMS.VIM
 
 clean :
 	-@ if "''F$SEARCH("*.out")'"     .NES. "" then delete/noconfirm/nolog *.out.*
 	-@ if "''F$SEARCH("test.log")'"  .NES. "" then delete/noconfirm/nolog test.log.*
+	-@ if "''F$SEARCH("test.ok")'"   .NES. "" then delete/noconfirm/nolog test.ok.*
 	-@ if "''F$SEARCH("Xdotest.*")'" .NES. "" then delete/noconfirm/nolog Xdotest.*.*
 	-@ if "''F$SEARCH("*.*_sw*")'"   .NES. "" then delete/noconfirm/nolog *.*_sw*.*
+	-@ if "''F$SEARCH("*.failed")'"  .NES. "" then delete/noconfirm/nolog *.failed.*
+	-@ if "''F$SEARCH("*.rej")'"     .NES. "" then delete/noconfirm/nolog *.rej.*
+	-@ if "''F$SEARCH("tiny.vim")'"  .NES. "" then delete/noconfirm/nolog tiny.vim.*
+	-@ if "''F$SEARCH("small.vim")'" .NES. "" then delete/noconfirm/nolog small.vim.*
+	-@ if "''F$SEARCH("mbyte.vim")'" .NES. "" then delete/noconfirm/nolog mbyte.vim.*
+	-@ if "''F$SEARCH("viminfo.*")'" .NES. "" then delete/noconfirm/nolog viminfo.*.*
+
--- vim72.orig/src/testdir/Makefile
+++ vim72/src/testdir/Makefile
@@ -2,13 +2,15 @@
 # Makefile to run all tests for Vim
 #
 
 VIMPROG = ../vim
 
-# Uncomment this line for using valgrind.
-# The output goes into a file "valgrind.$PID" (sorry, no test number).
-# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --logfile=valgrind
+# Uncomment this line to use valgrind for memory leaks and extra warnings.
+#   The output goes into a file "valgrind.testN"
+#   Vim should be compiled with EXITFREE to avoid false warnings.
+#   This will make testing about 10 times as slow.
+# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --log-file=valgrind.$*
 
 SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
 		test7.out test8.out test9.out test10.out test11.out \
 		test12.out  test13.out test14.out test15.out test17.out \
 		test18.out test19.out test20.out test21.out test22.out \
@@ -18,33 +20,36 @@ SCRIPTS = test1.out test2.out test3.out
 		test38.out test39.out test40.out test41.out test42.out \
 		test43.out test44.out test45.out test46.out test47.out \
 		test48.out test49.out test51.out test52.out test53.out \
 		test54.out test55.out test56.out test57.out test58.out \
 		test59.out test60.out test61.out test62.out test63.out \
-		test64.out test65.out
+		test64.out test65.out test66.out test67.out test68.out \
+		test69.out test70.out
 
 SCRIPTS_GUI = test16.out
 
 .SUFFIXES: .in .out
 
-nongui:	nolog $(SCRIPTS)
-	@echo
-	@cat test.log
-	@echo ALL DONE
+nongui:	nolog $(SCRIPTS) report
+
+gui:	nolog $(SCRIPTS) $(SCRIPTS_GUI) report
 
-gui:	nolog $(SCRIPTS) $(SCRIPTS_GUI)
+report:
 	@echo
-	@cat test.log
-	@echo ALL DONE
+	@echo 'Test results:'
+	@/bin/sh -c "if test -f test.log; \
+		then cat test.log; echo TEST FAILURE; exit 1; \
+		else echo ALL DONE; \
+		fi"
 
 $(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG)
 
 clean:
-	-rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim test.ok X* valgrind.pid* viminfo
+	-rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X* valgrind.pid* viminfo
 
 test1.out: test1.in
-	-rm -f $*.failed tiny.vim small.vim mbyte.vim test.ok X* viminfo
+	-rm -f $*.failed tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X* viminfo
 	$(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
 	@/bin/sh -c "if diff test.out $*.ok; \
 		then mv -f test.out $*.out; \
 		else echo; \
 		echo test1 FAILED - Something basic is wrong; \
@@ -69,6 +74,6 @@ test1.out: test1.in
 test49.out: test49.vim
 
 test60.out: test60.vim
 
 nolog:
-	-echo Test results: >test.log
+	-rm -f test.log
--- vim72.orig/src/testdir/main.aap
+++ vim72/src/testdir/main.aap
@@ -30,15 +30,15 @@ gui:	newlog $Scripts $ScriptsGUI
 	:print ALL DONE
 
 $Scripts $ScriptsGUI: $VimProg
 
 clean:
-	:del {r}{force} *.out test.log tiny.vim small.vim mbyte.vim test.ok X*
+	:del {r}{force} *.out test.log tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X*
 
 # test1 is special, it checks for features
 test1.out: test1.in
-	:del {force} test1.failed tiny.vim small.vim mbyte.vim
+	:del {force} test1.failed tiny.vim small.vim mbyte.vim mzscheme.vim
 	:sys {i} $VimProg -u unix.vim -U NONE --noplugin -s dotest.in test1.in
 	@if os.system("diff test.out test1.ok") != 0:
 		:error test1 FAILED - Something basic is wrong
 	:move {force} test.out test1.out
 	:del {r}{force} X*
--- vim72.orig/src/testdir/test1.in
+++ vim72/src/testdir/test1.in
@@ -11,10 +11,11 @@ If Vim was not compiled with the +window
 set like small.vim above.  tiny.vim is sourced by tests that require the
 +windows feature or other features that are missing in the tiny version.
 
 If Vim was not compiled with the +multi_byte feature, the mbyte.vim script will be set like small.vim above.  mbyte.vim is sourced by tests that require the
 +multi_byte feature.
+Similar logic is applied to the +mzscheme feature, using mzscheme.vim.
 
 STARTTEST
 :" Write a single line to test.out to check if testing works at all.
 :%d
 athis is a test:w! test.out
@@ -23,12 +24,15 @@ athis is a test:w! test.out
 :w! tiny.vim
 ae! test.ok
 w! test.out
 qa!
 :w! mbyte.vim
+:w! mzscheme.vim
 :" If +multi_byte feature supported, make mbyte.vim empty.
 :if has("multi_byte") | sp another | w! mbyte.vim | q | endif
+:" If +mzscheme feature supported, make mzscheme.vim empty.
+:if has("mzscheme") | sp another | w! mzscheme.vim | q | endif
 :" If +eval feature supported quit here, leaving tiny.vim and small.vim empty.
 :" Otherwise write small.vim to skip the test.
 :if 1 | q! | endif
 :w! small.vim
 :" If +windows feature not supported :sp will fail and tiny.vim will be
--- vim72.orig/src/testdir/test30.in
+++ vim72/src/testdir/test30.in
@@ -22,14 +22,21 @@ STARTTEST
 :set bin noeol
 :$w! XXMac
 :set nobin eol
 :bwipe XXUnix XXDos XXMac
 :" create mixed format files
-:!cat XXUnix XXDos >XXUxDs
-:!cat XXUnix XXMac >XXUxMac
-:!cat XXDos XXMac >XXDosMac
-:!cat XXUnix XXDos XXMac >XXUxDsMc
+:if has("vms")
+: !copy XXUnix,XXDos XXUxDs.
+: !copy XXUnix,XXMac XXUxMac.
+: !copy XXDos,XXMac  XXDosMac.
+: !copy XXUnix,XXDos,XXMac XXUxDsMc.
+:else
+: !cat XXUnix XXDos >XXUxDs
+: !cat XXUnix XXMac >XXUxMac
+: !cat XXDos XXMac >XXDosMac
+: !cat XXUnix XXDos XXMac >XXUxDsMc
+:endif
 :"
 :" try reading and writing with 'fileformats' empty
 :set fileformat=unix
 :e! XXUnix
 :w! test.out
--- vim72.orig/src/testdir/test45.in
+++ vim72/src/testdir/test45.in
@@ -26,13 +26,20 @@ kYpj:call append("$", foldlevel("."))
 /^2 b
 i  jI    :call append("$", "indent " . foldlevel("."))
 k:call append("$", foldlevel("."))
 :" test syntax folding
 :set fdm=syntax fdl=0
-:syn region Hup start="dd" end="hh" fold
+:syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3
+:syn region Fd1 start="ee" end="ff" fold contained
+:syn region Fd2 start="gg" end="hh" fold contained
+:syn region Fd3 start="commentstart" end="commentend" fold contained
 Gzk:call append("$", "folding " . getline("."))
 k:call append("$", getline("."))
+jAcommentstart  Acommentend:set fdl=1
+3j:call append("$", getline("."))
+:set fdl=0
+zOj:call append("$", getline("."))
 :" test expression folding
 :fun Flvl()
   let l = getline(v:lnum)
   if l =~ "bb$"
     return 2
--- vim72.orig/src/testdir/test45.ok
+++ vim72/src/testdir/test45.ok
@@ -6,11 +6,13 @@ marker 2
 1
 1
 0
 indent 2
 1
-folding 8 hh
+folding 9 ii
     3 cc
+7 gg
+8 hh
 expr 2
 1
 2
 0
--- vim72.orig/src/testdir/test54.in
+++ vim72/src/testdir/test54.in
@@ -1,12 +1,17 @@
 Some tests for buffer-local autocommands
 
 STARTTEST
 :so small.vim
 :e xx
-:!rm -f test.out
-:au BufLeave <buffer> :!echo buffer-local autommand in %>> test.out
+:if has("vms")
+: !del test.out.*
+: au BufLeave <buffer> :!write sys$output "buffer-local autommand in %" > test.out
+:else
+: !rm -f test.out
+: au BufLeave <buffer> :!echo buffer-local autommand in %>> test.out
+:endif
 :e somefile           " here, autocommand for xx shall write test.out 
 :                     " but autocommand shall not apply to buffer named <buffer>
 :bwipe xx             " here, autocommand shall be auto-deleted
 :e xx                 " nothing shall be written
 :e somefile           " nothing shall be written
--- /dev/null
+++ vim72/src/testdir/test66.in
@@ -0,0 +1,25 @@
+
+Test for visual block shift and tab characters.
+
+STARTTEST
+:so small.vim
+/^abcdefgh
+4jI    j<<11|D
+7|a		
+7|a		   
+7|a	       	4k13|4j<
+:$-4,$w! test.out
+:$-4,$s/\s\+//g
+4kI    j<<
+7|a		
+7|a					
+7|a	       		4k13|4j3<
+:$-4,$w >> test.out
+:qa!
+ENDTEST
+
+abcdefghijklmnopqrstuvwxyz
+abcdefghijklmnopqrstuvwxyz
+abcdefghijklmnopqrstuvwxyz
+abcdefghijklmnopqrstuvwxyz
+abcdefghijklmnopqrstuvwxyz
--- /dev/null
+++ vim72/src/testdir/test66.ok
@@ -0,0 +1,10 @@
+    abcdefghijklmnopqrstuvwxyz
+abcdefghij
+    abc	    defghijklmnopqrstuvwxyz
+    abc	    defghijklmnopqrstuvwxyz
+    abc	    defghijklmnopqrstuvwxyz
+    abcdefghijklmnopqrstuvwxyz
+abcdefghij
+    abc	    defghijklmnopqrstuvwxyz
+    abc		defghijklmnopqrstuvwxyz
+    abc	    defghijklmnopqrstuvwxyz
--- /dev/null
+++ vim72/src/testdir/test67.in
@@ -0,0 +1,33 @@
+Test that groups and patterns are tested correctly when calling exists() for
+autocommands.
+
+STARTTEST
+:so small.vim
+:let results=[]
+:augroup auexists
+:augroup END
+:call add(results, "##BufEnter: " . exists("##BufEnter"))
+:call add(results, "#BufEnter: " . exists("#BufEnter"))
+:au BufEnter * let g:entered=1
+:call add(results, "#BufEnter: " . exists("#BufEnter"))
+:call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))
+:augroup auexists
+:au BufEnter * let g:entered=1
+:augroup END
+:call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))
+:call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))
+:au BufEnter *.test let g:entered=1
+:call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))
+:edit testfile.test
+:call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))
+:au BufEnter <buffer> let g:entered=1
+:call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))
+:edit testfile2.test
+:call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))
+:e test.out
+:call append(0, results)
+:$d
+:w
+:qa!
+ENDTEST
+
--- /dev/null
+++ vim72/src/testdir/test67.ok
@@ -0,0 +1,10 @@
+##BufEnter: 1
+#BufEnter: 0
+#BufEnter: 1
+#auexists#BufEnter: 0
+#auexists#BufEnter: 1
+#BufEnter#*.test: 0
+#BufEnter#*.test: 1
+#BufEnter#<buffer>: 0
+#BufEnter#<buffer>: 1
+#BufEnter#<buffer>: 0
--- /dev/null
+++ vim72/src/testdir/test68.in
@@ -0,0 +1,56 @@
+Test for text formatting.
+
+Results of test68:
+
+STARTTEST
+:so small.vim
+/^{/+1
+:set noai tw=2 fo=t
+gRa b
+ENDTEST
+
+{
+
+
+}
+
+STARTTEST
+/^{/+1
+:set ai tw=2 fo=tw
+gqgqjjllab
+ENDTEST
+
+{
+a  b
+
+a
+}
+
+STARTTEST
+/^{/+1
+:set tw=3 fo=t
+gqgqo
+a 
+ENDTEST
+
+{
+a 
+}
+
+STARTTEST
+/^{/+1
+:set tw=2 fo=tcq1 comments=:#
+gqgqjgqgqo
+a b
+#a b
+ENDTEST
+
+{
+a b
+#a b
+}
+
+STARTTEST
+:g/^STARTTEST/.,/^ENDTEST/d
+:1;/^Results/,$wq! test.out
+ENDTEST
--- /dev/null
+++ vim72/src/testdir/test68.ok
@@ -0,0 +1,35 @@
+Results of test68:
+
+
+{
+a
+b
+}
+
+
+{
+a
+b
+
+a
+b
+}
+
+
+{
+a
+
+
+a
+
+}
+
+
+{
+a b
+#a b
+
+a b
+#a b
+}
+
--- /dev/null
+++ vim72/src/testdir/test69.in
@@ -0,0 +1,139 @@
+Test for multi-byte text formatting.
+
+STARTTEST
+:so mbyte.vim
+:set encoding=utf-8
+ENDTEST
+
+Results of test69:
+
+STARTTEST
+/^{/+1
+:set tw=2 fo=t
+gqgqjgqgqo
+XYZ
+abc XYZ
+ENDTEST
+
+{
+XYZ
+abc XYZ
+}
+
+STARTTEST
+/^{/+1
+:set tw=1 fo=tm
+gqgqjgqgqjgqgqjgqgqjgqgqo
+X
+Xa
+X a
+XY
+X Y
+ENDTEST
+
+{
+X
+Xa
+X a
+XY
+X Y
+}
+
+STARTTEST
+/^{/+1
+:set tw=2 fo=tm
+gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo
+X
+Xa
+X a
+XY
+X Y
+aX
+abX
+abcX
+abX c
+abXY
+ENDTEST
+
+{
+X
+Xa
+X a
+XY
+X Y
+aX
+abX
+abcX
+abX c
+abXY
+}
+
+STARTTEST
+/^{/+1
+:set ai tw=2 fo=tm
+gqgqjgqgqo
+X
+Xa
+ENDTEST
+
+{
+  X
+  Xa
+}
+
+STARTTEST
+/^{/+1
+:set noai tw=2 fo=tm
+gqgqjgqgqo
+  X
+  Xa
+ENDTEST
+
+{
+  X
+  Xa
+}
+
+STARTTEST
+/^{/+1
+:set tw=2 fo=cqm comments=n:X
+gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo
+X
+Xa
+XaY
+XY
+XYZ
+X Y
+X YZ
+XX
+XXa
+XXY
+ENDTEST
+
+{
+X
+Xa
+XaY
+XY
+XYZ
+X Y
+X YZ
+XX
+XXa
+XXY
+}
+
+STARTTEST
+/^{/+1
+:set tw=2 fo=tm
+RXa
+ENDTEST
+
+{
+
+}
+
+STARTTEST
+:g/^STARTTEST/.,/^ENDTEST/d
+:1;/^Results/,$wq! test.out
+ENDTEST
--- /dev/null
+++ vim72/src/testdir/test69.ok
@@ -0,0 +1,142 @@
+Results of test69:
+
+
+{
+XYZ
+abc
+XYZ
+
+XYZ
+abc
+XYZ
+}
+
+
+{
+X
+X
+a
+X
+a
+X
+Y
+X
+Y
+
+X
+X
+a
+X
+a
+X
+Y
+X
+Y
+}
+
+
+{
+X
+X
+a
+X
+a
+X
+Y
+X
+Y
+a
+X
+ab
+X
+abc
+X
+ab
+X
+c
+ab
+X
+Y
+
+X
+X
+a
+X
+a
+X
+Y
+X
+Y
+a
+X
+ab
+X
+abc
+X
+ab
+X
+c
+ab
+X
+Y
+}
+
+
+{
+  X
+  X
+  a
+
+  X
+  X
+  a
+}
+
+
+{
+  X
+  X
+a
+
+  X
+  X
+a
+}
+
+
+{
+X
+Xa
+Xa
+XY
+XY
+XY
+XZ
+X Y
+X Y
+X Z
+XX
+XXa
+XXY
+
+X
+Xa
+Xa
+XY
+XY
+XY
+XZ
+X Y
+X Y
+X Z
+XX
+XXa
+XXY
+}
+
+
+{
+X
+a
+}
+
--- /dev/null
+++ vim72/src/testdir/test70.in
@@ -0,0 +1,53 @@
+Smoke test for MzScheme interface and mzeval() function
+
+STARTTEST
+:so mzscheme.vim
+:set nocompatible viminfo+=nviminfo
+:function! MzRequire()
+:redir => l:mzversion
+:mz (version)
+:redir END
+:if strpart(l:mzversion, 1, 1) < "4"
+:" MzScheme versions < 4.x:
+:mz (require (prefix vim- vimext))
+:else
+:" newer versions:
+:mz (require (prefix-in vim- 'vimext))
+:mz (require r5rs)
+:endif
+:endfunction
+:silent call MzRequire()
+:mz (define l '("item0" "dictionary with list OK" "item2"))
+:mz (define h (make-hash))
+:mz (hash-set! h "list" l)
+/^1
+:" change buffer contents
+:mz (vim-set-buff-line (vim-eval "line('.')") "1 changed line 1")
+:" scalar test
+:let tmp_string = mzeval('"string"')
+:let tmp_1000 = mzeval('1000')
+:if tmp_string . tmp_1000 == "string1000"
+:let scalar_res = "OK"
+:else
+:let scalar_res = "FAILED"
+:endif
+:call append(search("^1"), "scalar test " . scalar_res)
+:" dictionary containing a list
+:let tmp = mzeval("h")["list"][1]
+:/^2/put =tmp
+:" circular list (at the same time test lists containing lists)
+:mz (set-car! (cddr l) l)
+:let l2 = mzeval("h")["list"]
+:if l2[2] == l2
+:let res = "OK"
+:else
+:let res = "FAILED"
+:endif
+:call setline(search("^3"), "circular test " . res)
+:?^1?,$w! test.out
+:qa!
+ENDTEST
+
+1 line 1
+2 line 2
+3 line 3
--- /dev/null
+++ vim72/src/testdir/test70.ok
@@ -0,0 +1,5 @@
+1 changed line 1
+scalar test OK
+2 line 2
+dictionary with list OK
+circular test OK
--- vim72.orig/src/ui.c
+++ vim72/src/ui.c
@@ -318,14 +318,13 @@ ui_get_shellsize()
 /*
  * Set the size of the Vim shell according to Rows and Columns, if possible.
  * The gui_set_shellsize() or mch_set_shellsize() function will try to set the
  * new size.  If this is not possible, it will adjust Rows and Columns.
  */
-/*ARGSUSED*/
     void
 ui_set_shellsize(mustset)
-    int		mustset;	/* set by the user */
+    int		mustset UNUSED;	/* set by the user */
 {
 #ifdef FEAT_GUI
     if (gui.in_use)
 	gui_set_shellsize(mustset,
 # ifdef WIN3264
@@ -1125,14 +1124,13 @@ clip_invert_rectangle(row, col, height,
 /*
  * Copy the currently selected area into the '*' register so it will be
  * available for pasting.
  * When "both" is TRUE also copy to the '+' register.
  */
-/*ARGSUSED*/
     void
 clip_copy_modeless_selection(both)
-    int		both;
+    int		both UNUSED;
 {
     char_u	*buffer;
     char_u	*bufp;
     int		row;
     int		start_col;
@@ -1699,14 +1697,13 @@ read_from_input_buf(buf, maxlen)
     if (inbufcount)
 	mch_memmove(inbuf, inbuf + maxlen, (size_t)inbufcount);
     return (int)maxlen;
 }
 
-/*ARGSUSED*/
     void
 fill_input_buf(exit_on_error)
-    int	exit_on_error;
+    int	exit_on_error UNUSED;
 {
 #if defined(UNIX) || defined(OS2) || defined(VMS) || defined(MACOS_X_UNIX)
     int		len;
     int		try;
     static int	did_read_something = FALSE;
@@ -1818,11 +1815,11 @@ fill_input_buf(exit_on_error)
 	     * what it was. */
 	    settmode(TMODE_COOK);
 #ifdef HAVE_DUP
 	    /* Use stderr for stdin, also works for shell commands. */
 	    close(0);
-	    dup(2);
+	    ignored = dup(2);
 #else
 	    read_cmd_fd = 2;	/* read from stderr instead of stdin */
 #endif
 	    settmode(m);
 	}
@@ -1990,15 +1987,14 @@ x11_setup_atoms(dpy)
  * X Selection stuff, for cutting and pasting text to other windows.
  */
 
 static void  clip_x11_request_selection_cb __ARGS((Widget, XtPointer, Atom *, Atom *, XtPointer, long_u *, int *));
 
-/* ARGSUSED */
     static void
 clip_x11_request_selection_cb(w, success, sel_atom, type, value, length,
 			      format)
-    Widget	w;
+    Widget	w UNUSED;
     XtPointer	success;
     Atom	*sel_atom;
     Atom	*type;
     XtPointer	value;
     long_u	*length;
@@ -2018,11 +2014,11 @@ clip_x11_request_selection_cb(w, success
     else
 	cbd = &clip_star;
 
     if (value == NULL || *length == 0)
     {
-	clip_free_selection(cbd);	/* ???  [what's the query?] */
+	clip_free_selection(cbd);	/* nothing received, clear register */
 	*(int *)success = FALSE;
 	return;
     }
     motion_type = MCHAR;
     p = (char_u *)value;
@@ -2074,11 +2070,11 @@ clip_x11_request_selection_cb(w, success
 	int		status;
 
 	text_prop.value = (unsigned char *)value;
 	text_prop.encoding = *type;
 	text_prop.format = *format;
-	text_prop.nitems = STRLEN(value);
+	text_prop.nitems = len;
 	status = XmbTextPropertyToTextList(X_DISPLAY, &text_prop,
 							 &text_list, &n_text);
 	if (status != Success || n_text < 1)
 	{
 	    *(int *)success = FALSE;
@@ -2106,12 +2102,12 @@ clip_x11_request_selection(myShell, dpy,
 {
     XEvent	event;
     Atom	type;
     static int	success;
     int		i;
-    int		nbytes = 0;
-    char_u	*buffer;
+    time_t	start_time;
+    int		timed_out = FALSE;
 
     for (i =
 #ifdef FEAT_MBYTE
 	    0
 #else
@@ -2127,10 +2123,11 @@ clip_x11_request_selection(myShell, dpy,
 	    case 1:  type = vim_atom;		break;
 	    case 2:  type = compound_text_atom; break;
 	    case 3:  type = text_atom;		break;
 	    default: type = XA_STRING;
 	}
+	success = MAYBE;
 	XtGetSelectionValue(myShell, cbd->sel_atom, type,
 	    clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
 
 	/* Make sure the request for the selection goes out before waiting for
 	 * a response. */
@@ -2139,51 +2136,63 @@ clip_x11_request_selection(myShell, dpy,
 	/*
 	 * Wait for result of selection request, otherwise if we type more
 	 * characters, then they will appear before the one that requested the
 	 * paste!  Don't worry, we will catch up with any other events later.
 	 */
-	for (;;)
+	start_time = time(NULL);
+	while (success == MAYBE)
 	{
-	    if (XCheckTypedEvent(dpy, SelectionNotify, &event))
-		break;
-	    if (XCheckTypedEvent(dpy, SelectionRequest, &event))
-		/* We may get a SelectionRequest here and if we don't handle
-		 * it we hang.  KDE klipper does this, for example. */
+	    if (XCheckTypedEvent(dpy, SelectionNotify, &event)
+		    || XCheckTypedEvent(dpy, SelectionRequest, &event)
+		    || XCheckTypedEvent(dpy, PropertyNotify, &event))
+	    {
+		/* This is where clip_x11_request_selection_cb() should be
+		 * called.  It may actually happen a bit later, so we loop
+		 * until "success" changes.
+		 * We may get a SelectionRequest here and if we don't handle
+		 * it we hang.  KDE klipper does this, for example.
+		 * We need to handle a PropertyNotify for large selections. */
 		XtDispatchEvent(&event);
+		continue;
+	    }
+
+	    /* Time out after 2 to 3 seconds to avoid that we hang when the
+	     * other process doesn't respond.  Note that the SelectionNotify
+	     * event may still come later when the selection owner comes back
+	     * to life and the text gets inserted unexpectedly.  Don't know
+	     * why that happens or how to avoid that :-(. */
+	    if (time(NULL) > start_time + 2)
+	    {
+		timed_out = TRUE;
+		break;
+	    }
 
 	    /* Do we need this?  Probably not. */
 	    XSync(dpy, False);
 
-	    /* Bernhard Walle solved a slow paste response in an X terminal by
-	     * adding: usleep(10000); here. */
+	    /* Wait for 1 msec to avoid that we eat up all CPU time. */
+	    ui_delay(1L, TRUE);
 	}
 
-	/* this is where clip_x11_request_selection_cb() is actually called */
-	XtDispatchEvent(&event);
-
-	if (success)
+	if (success == TRUE)
 	    return;
+
+	/* don't do a retry with another type after timing out, otherwise we
+	 * hang for 15 seconds. */
+	if (timed_out)
+	    break;
     }
 
     /* Final fallback position - use the X CUT_BUFFER0 store */
-    buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0);
-    if (nbytes > 0)
-    {
-	/* Got something */
-	clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
-	XFree((void *)buffer);
-	if (p_verbose > 0)
-	    verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty selection"));
-    }
+    yank_cut_buffer0(dpy, cbd);
 }
 
 static Boolean	clip_x11_convert_selection_cb __ARGS((Widget, Atom *, Atom *, Atom *, XtPointer *, long_u *, int *));
 
-/* ARGSUSED */
     static Boolean
 clip_x11_convert_selection_cb(w, sel_atom, target, type, value, length, format)
-    Widget	w;
+    Widget	w UNUSED;
     Atom	*sel_atom;
     Atom	*target;
     Atom	*type;
     XtPointer	*value;
     long_u	*length;
@@ -2306,14 +2315,13 @@ clip_x11_convert_selection_cb(w, sel_ato
     return True;
 }
 
 static void  clip_x11_lose_ownership_cb __ARGS((Widget, Atom *));
 
-/* ARGSUSED */
     static void
 clip_x11_lose_ownership_cb(w, sel_atom)
-    Widget  w;
+    Widget  w UNUSED;
     Atom    *sel_atom;
 {
     if (*sel_atom == clip_plus.sel_atom)
 	clip_lose_selection(&clip_plus);
     else
@@ -2342,18 +2350,71 @@ clip_x11_own_selection(myShell, cbd)
 
 /*
  * Send the current selection to the clipboard.  Do nothing for X because we
  * will fill in the selection only when requested by another app.
  */
-/*ARGSUSED*/
     void
 clip_x11_set_selection(cbd)
-    VimClipboard *cbd;
+    VimClipboard *cbd UNUSED;
 {
 }
 #endif
 
+#if defined(FEAT_XCLIPBOARD) || defined(FEAT_GUI_X11) \
+    || defined(FEAT_GUI_GTK) || defined(PROTO)
+/*
+ * Get the contents of the X CUT_BUFFER0 and put it in "cbd".
+ */
+    void
+yank_cut_buffer0(dpy, cbd)
+    Display		*dpy;
+    VimClipboard	*cbd;
+{
+    int		nbytes = 0;
+    char_u	*buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0);
+
+    if (nbytes > 0)
+    {
+#ifdef FEAT_MBYTE
+	int  done = FALSE;
+
+	/* CUT_BUFFER0 is supposed to be always latin1.  Convert to 'enc' when
+	 * using a multi-byte encoding.  Conversion between two 8-bit
+	 * character sets usually fails and the text might actually be in
+	 * 'enc' anyway. */
+	if (has_mbyte)
+	{
+	    char_u	*conv_buf;
+	    vimconv_T	vc;
+
+	    vc.vc_type = CONV_NONE;
+	    if (convert_setup(&vc, (char_u *)"latin1", p_enc) == OK)
+	    {
+		conv_buf = string_convert(&vc, buffer, &nbytes);
+		if (conv_buf != NULL)
+		{
+		    clip_yank_selection(MCHAR, conv_buf, (long)nbytes, cbd);
+		    vim_free(conv_buf);
+		    done = TRUE;
+		}
+		convert_setup(&vc, NULL, NULL);
+	    }
+	}
+	if (!done)  /* use the text without conversion */
+#endif
+	    clip_yank_selection(MCHAR, buffer, (long)nbytes, cbd);
+	XFree((void *)buffer);
+	if (p_verbose > 0)
+	{
+	    verbose_enter();
+	    verb_msg((char_u *)_("Used CUT_BUFFER0 instead of empty selection"));
+	    verbose_leave();
+	}
+    }
+}
+#endif
+
 #if defined(FEAT_MOUSE) || defined(PROTO)
 
 /*
  * Move the cursor to the specified row and column on the screen.
  * Change current window if necessary.	Returns an integer with the
@@ -2535,18 +2596,11 @@ retnomove:
 #endif
 #ifdef FEAT_CMDWIN
 	if (cmdwin_type != 0 && wp != curwin)
 	{
 	    /* A click outside the command-line window: Use modeless
-	     * selection if possible.  Allow dragging the status line of
-	     * windows just above the command-line window. */
-	    if (wp->w_winrow + wp->w_height
-		       != curwin->w_prev->w_winrow + curwin->w_prev->w_height)
-	    {
-		on_status_line = 0;
-		dragwin = NULL;
-	    }
+	     * selection if possible.  Allow dragging the status lines. */
 # ifdef FEAT_VERTSPLIT
 	    on_sep_line = 0;
 # endif
 # ifdef FEAT_CLIPBOARD
 	    if (on_status_line)
@@ -2896,15 +2950,14 @@ mouse_comp_pos(win, rowp, colp, lnump)
 #if defined(FEAT_WINDOWS) || defined(PROTO)
 /*
  * Find the window at screen position "*rowp" and "*colp".  The positions are
  * updated to become relative to the top-left of the window.
  */
-/*ARGSUSED*/
     win_T *
 mouse_find_win(rowp, colp)
     int		*rowp;
-    int		*colp;
+    int		*colp UNUSED;
 {
     frame_T	*fp;
 
     fp = topframe;
     *rowp -= firstwin->w_winrow;
@@ -2993,22 +3046,21 @@ vcol2col(wp, lnum, vcol)
     win_T	*wp;
     linenr_T	lnum;
     int		vcol;
 {
     /* try to advance to the specified column */
-    int		col = 0;
     int		count = 0;
     char_u	*ptr;
+    char_u	*start;
 
-    ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
+    start = ptr = ml_get_buf(wp->w_buffer, lnum, FALSE);
     while (count <= vcol && *ptr != NUL)
     {
-	++col;
 	count += win_lbr_chartabsize(wp, ptr, count, NULL);
 	mb_ptr_adv(ptr);
     }
-    return col;
+    return (int)(ptr - start);
 }
 #endif
 
 #endif /* FEAT_MOUSE */
 
--- vim72.orig/src/version.c
+++ vim72/src/version.c
@@ -492,10 +492,15 @@ static char *(features[]) =
 #ifdef FEAT_SNIFF
 	"+sniff",
 #else
 	"-sniff",
 #endif
+#ifdef STARTUPTIME
+	"+startuptime",
+#else
+	"-startuptime",
+#endif
 #ifdef FEAT_STL_OPT
 	"+statusline",
 #else
 	"-statusline",
 #endif
@@ -675,13 +680,848 @@ static char *(features[]) =
 };
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    411,
+/**/
+    410,
+/**/
+    409,
+/**/
+    408,
+/**/
+    407,
+/**/
+    406,
+/**/
+    405,
+/**/
+    404,
+/**/
+    403,
+/**/
+    402,
+/**/
+    401,
+/**/
+    400,
+/**/
+    399,
+/**/
+    398,
+/**/
+    397,
+/**/
+    396,
+/**/
+    395,
+/**/
+    394,
+/**/
+    393,
+/**/
+    392,
+/**/
+    391,
+/**/
+    390,
+/**/
+    389,
+/**/
+    388,
+/**/
+    387,
+/**/
+    386,
+/**/
+    385,
+/**/
+    384,
+/**/
+    383,
+/**/
+    382,
+/**/
+    381,
+/**/
+    380,
+/**/
+    379,
+/**/
+    378,
+/**/
+    377,
+/**/
+    376,
+/**/
+    375,
+/**/
+    374,
+/**/
+    373,
+/**/
+    372,
+/**/
+    371,
+/**/
+    370,
+/**/
+    369,
+/**/
+    368,
+/**/
+    367,
+/**/
+    366,
+/**/
+    365,
+/**/
+    364,
+/**/
+    363,
+/**/
+    362,
+/**/
+    361,
+/**/
+    360,
+/**/
+    359,
+/**/
+    358,
+/**/
+    357,
+/**/
+    356,
+/**/
+    355,
+/**/
+    354,
+/**/
+    353,
+/**/
+    352,
+/**/
+    351,
+/**/
+    350,
+/**/
+    349,
+/**/
+    348,
+/**/
+    347,
+/**/
+    346,
+/**/
+    345,
+/**/
+    344,
+/**/
+    343,
+/**/
+    342,
+/**/
+    341,
+/**/
+    340,
+/**/
+    339,
+/**/
+    338,
+/**/
+    337,
+/**/
+    336,
+/**/
+    335,
+/**/
+    334,
+/**/
+    333,
+/**/
+    332,
+/**/
+    331,
+/**/
+    330,
+/**/
+    329,
+/**/
+    328,
+/**/
+    327,
+/**/
+    326,
+/**/
+    325,
+/**/
+    324,
+/**/
+    323,
+/**/
+    322,
+/**/
+    321,
+/**/
+    320,
+/**/
+    319,
+/**/
+    318,
+/**/
+    317,
+/**/
+    316,
+/**/
+    315,
+/**/
+    314,
+/**/
+    313,
+/**/
+    312,
+/**/
+    311,
+/**/
+    310,
+/**/
+    309,
+/**/
+    308,
+/**/
+    307,
+/**/
+    306,
+/**/
+    305,
+/**/
+    304,
+/**/
+    303,
+/**/
+    302,
+/**/
+    301,
+/**/
+    300,
+/**/
+    299,
+/**/
+    298,
+/**/
+    297,
+/**/
+    296,
+/**/
+    295,
+/**/
+    294,
+/**/
+    293,
+/**/
+    292,
+/**/
+    291,
+/**/
+    290,
+/**/
+    289,
+/**/
+    288,
+/**/
+    287,
+/**/
+    286,
+/**/
+    285,
+/**/
+    284,
+/**/
+    283,
+/**/
+    282,
+/**/
+    281,
+/**/
+    280,
+/**/
+    279,
+/**/
+    278,
+/**/
+    277,
+/**/
+    276,
+/**/
+    275,
+/**/
+    274,
+/**/
+    273,
+/**/
+    272,
+/**/
+    271,
+/**/
+    270,
+/**/
+    269,
+/**/
+    268,
+/**/
+    267,
+/**/
+    266,
+/**/
+    265,
+/**/
+    264,
+/**/
+    263,
+/**/
+    262,
+/**/
+    261,
+/**/
+    260,
+/**/
+    259,
+/**/
+    258,
+/**/
+    257,
+/**/
+    256,
+/**/
+    255,
+/**/
+    254,
+/**/
+    253,
+/**/
+    252,
+/**/
+    251,
+/**/
+    250,
+/**/
+    249,
+/**/
+    248,
+/**/
+    247,
+/**/
+    246,
+/**/
+    245,
+/**/
+    244,
+/**/
+    243,
+/**/
+    242,
+/**/
+    241,
+/**/
+    240,
+/**/
+    239,
+/**/
+    238,
+/**/
+    237,
+/**/
+    236,
+/**/
+    235,
+/**/
+    234,
+/**/
+    233,
+/**/
+    232,
+/**/
+    231,
+/**/
+    230,
+/**/
+    229,
+/**/
+    228,
+/**/
+    227,
+/**/
+    226,
+/**/
+    225,
+/**/
+    224,
+/**/
+    223,
+/**/
+    222,
+/**/
+    221,
+/**/
+    220,
+/**/
+    219,
+/**/
+    218,
+/**/
+    217,
+/**/
+    216,
+/**/
+    215,
+/**/
+    214,
+/**/
+    213,
+/**/
+    212,
+/**/
+    211,
+/**/
+    210,
+/**/
+    209,
+/**/
+    208,
+/**/
+    207,
+/**/
+    206,
+/**/
+    205,
+/**/
+    204,
+/**/
+    203,
+/**/
+    202,
+/**/
+    201,
+/**/
+    200,
+/**/
+    199,
+/**/
+    198,
+/**/
+    197,
+/**/
+    196,
+/**/
+    195,
+/**/
+    194,
+/**/
+    193,
+/**/
+    192,
+/**/
+    191,
+/**/
+    190,
+/**/
+    189,
+/**/
+    188,
+/**/
+    187,
+/**/
+    186,
+/**/
+    185,
+/**/
+    184,
+/**/
+    183,
+/**/
+    182,
+/**/
+    181,
+/**/
+    180,
+/**/
+    179,
+/**/
+    178,
+/**/
+    177,
+/**/
+    176,
+/**/
+    175,
+/**/
+    174,
+/**/
+    173,
+/**/
+    172,
+/**/
+    171,
+/**/
+    170,
+/**/
+    169,
+/**/
+    168,
+/**/
+    167,
+/**/
+    166,
+/**/
+    165,
+/**/
+    164,
+/**/
+    163,
+/**/
+    162,
+/**/
+    161,
+/**/
+    160,
+/**/
+    159,
+/**/
+    158,
+/**/
+    157,
+/**/
+    156,
+/**/
+    155,
+/**/
+    154,
+/**/
+    153,
+/**/
+    152,
+/**/
+    151,
+/**/
+    150,
+/**/
+    149,
+/**/
+    148,
+/**/
+    147,
+/**/
+    146,
+/**/
+    145,
+/**/
+    144,
+/**/
+    143,
+/**/
+    142,
+/**/
+    141,
+/**/
+    140,
+/**/
+    139,
+/**/
+    138,
+/**/
+    137,
+/**/
+    136,
+/**/
+    135,
+/**/
+    134,
+/**/
+    133,
+/**/
+    132,
+/**/
+    131,
+/**/
+    130,
+/**/
+    129,
+/**/
+    128,
+/**/
+    127,
+/**/
+    126,
+/**/
+    125,
+/**/
+    124,
+/**/
+    123,
+/**/
+    122,
+/**/
+    121,
+/**/
+    120,
+/**/
+    119,
+/**/
+    118,
+/**/
+    117,
+/**/
+    116,
+/**/
+    115,
+/**/
+    114,
+/**/
+    113,
+/**/
+    112,
+/**/
+    111,
+/**/
+    110,
+/**/
+    109,
+/**/
+    108,
+/**/
+    107,
+/**/
+    106,
+/**/
+    105,
+/**/
+    104,
+/**/
+    103,
+/**/
+    102,
+/**/
+    101,
+/**/
+    100,
+/**/
+    99,
+/**/
+    98,
+/**/
+    97,
+/**/
+    96,
+/**/
+    95,
+/**/
+    94,
+/**/
+    93,
+/**/
+    92,
+/**/
+    91,
+/**/
+    90,
+/**/
+    89,
+/**/
+    88,
+/**/
+    87,
+/**/
+    86,
+/**/
+    85,
+/**/
+    84,
+/**/
+    83,
+/**/
+    82,
+/**/
+    81,
+/**/
+    80,
+/**/
+    79,
+/**/
+    78,
+/**/
+    77,
+/**/
+    76,
+/**/
+    75,
+/**/
+    74,
+/**/
+    73,
+/**/
+    72,
+/**/
+    71,
+/**/
+    70,
+/**/
+    69,
+/**/
+    68,
+/**/
+    67,
+/**/
+    66,
+/**/
+    65,
+/**/
+    64,
+/**/
+    63,
+/**/
+    62,
+/**/
+    61,
+/**/
+    60,
+/**/
+    59,
+/**/
+    58,
+/**/
+    57,
+/**/
+    56,
+/**/
+    55,
+/**/
+    54,
+/**/
+    53,
+/**/
+    52,
+/**/
+    51,
+/**/
+    50,
+/**/
+    49,
+/**/
+    48,
+/**/
+    47,
+/**/
+    46,
+/**/
+    45,
+/**/
+    44,
+/**/
+    43,
+/**/
+    42,
+/**/
+    41,
+/**/
+    40,
+/**/
+    39,
+/**/
+    38,
+/**/
+    37,
+/**/
+    36,
+/**/
+    35,
+/**/
+    34,
+/**/
+    33,
+/**/
+    32,
+/**/
+    31,
+/**/
+    30,
+/**/
+    29,
+/**/
+    28,
+/**/
+    27,
+/**/
+    26,
+/**/
+    25,
+/**/
+    24,
+/**/
+    23,
+/**/
+    22,
+/**/
+    21,
+/**/
+    20,
+/**/
+    19,
+/**/
+    18,
+/**/
+    17,
+/**/
+    16,
+/**/
+    15,
+/**/
+    14,
+/**/
+    13,
+/**/
+    12,
+/**/
+    11,
+/**/
+    10,
+/**/
+    9,
+/**/
+    8,
+/**/
+    7,
+/**/
+    6,
+/**/
+    5,
+/**/
+    4,
+/**/
+    3,
+/**/
+    2,
+/**/
+    1,
+/**/
     0
 };
 
+/*
+ * Place to put a short description when adding a feature with a patch.
+ * Keep it short, e.g.,: "relative numbers", "persistent undo".
+ * Also add a comment marker to separate the lines.
+ * See the official Vim patches for the diff format: It must use a context of
+ * one line only.  Create it by hand or use "diff -C2" and edit the patch.
+ */
+static char *(extra_patches[]) =
+{   /* Add your patch description below this line */
+/**/
+    NULL
+};
+
     int
 highest_patch()
 {
     int		i;
     int		h = 0;
@@ -784,11 +1624,11 @@ list_version()
 
 #ifdef RISCOS
     MSG_PUTS(_("\nRISC OS version"));
 #endif
 #ifdef VMS
-    MSG_PUTS("\nOpenVMS version");
+    MSG_PUTS(_("\nOpenVMS version"));
 # ifdef HAVE_PATHDEF
     if (*compiled_arch != NUL)
     {
 	MSG_PUTS(" - ");
 	MSG_PUTS(compiled_arch);
@@ -823,10 +1663,23 @@ list_version()
 		first = -1;
 	    }
 	}
     }
 
+    /* Print the list of extra patch descriptions if there is at least one. */
+    if (extra_patches[0] != NULL)
+    {
+	MSG_PUTS(_("\nExtra patches: "));
+	s = "";
+	for (i = 0; extra_patches[i] != NULL; ++i)
+	{
+	    MSG_PUTS(s);
+	    s = ", ";
+	    MSG_PUTS(extra_patches[i]);
+	}
+    }
+
 #ifdef MODIFIED_BY
     MSG_PUTS("\n");
     MSG_PUTS(_("Modified by "));
     MSG_PUTS(MODIFIED_BY);
 #endif
@@ -1251,14 +2104,13 @@ do_intro_line(row, mesg, add_version, at
 }
 
 /*
  * ":intro": clear screen, display intro screen and wait for return.
  */
-/*ARGSUSED*/
     void
 ex_intro(eap)
-    exarg_T	*eap;
+    exarg_T	*eap UNUSED;
 {
     screenclear();
     intro_message(TRUE);
     wait_return(TRUE);
 }
--- vim72.orig/src/vim.h
+++ vim72/src/vim.h
@@ -50,11 +50,13 @@
 # endif
 #endif
 
 /* user ID of root is usually zero, but not for everybody */
 #ifdef __TANDEM
-# define _TANDEM_SOURCE
+# ifndef _TANDEM_SOURCE
+#  define _TANDEM_SOURCE
+# endif
 # include <floss.h>
 # define ROOT_UID 65535
 #else
 # define ROOT_UID 0
 #endif
@@ -260,10 +262,18 @@
 /* __ARGS and __PARMS are the same thing. */
 #ifndef __PARMS
 # define __PARMS(x) __ARGS(x)
 #endif
 
+/* Mark unused function arguments with UNUSED, so that gcc -Wunused-parameter
+ * can be used to check for mistakes. */
+#ifdef HAVE_ATTRIBUTE_UNUSED
+# define UNUSED __attribute__((unused))
+#else
+# define UNUSED
+#endif
+
 /* if we're compiling in C++ (currently only KVim), the system
  * headers must have the correct prototypes or nothing will build.
  * conversely, our prototypes might clash due to throw() specifiers and
  * cause compilation failures even though the headers are correct.  For
  * a concrete example, gcc-3.2 enforces exception specifications, and
@@ -339,12 +349,18 @@
 # endif
 #endif
 #ifdef BACKSLASH_IN_FILENAME
 # define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`%#'\"|!<")
 #else
-# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
-# define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
+# ifdef VMS
+    /* VMS allows a lot of characters in the file name */
+#  define PATH_ESC_CHARS ((char_u *)" \t\n*?{`\\%#'\"|!")
+#  define SHELL_ESC_CHARS ((char_u *)" \t\n*?{`\\%#'|!()&")
+# else
+#  define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
+#  define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
+# endif
 #endif
 
 #define NUMBUFLEN 30	    /* length of a buffer to store a number in ASCII */
 
 /*
@@ -368,11 +384,11 @@ typedef		 __int64        long_i;
    * that change size between 32-bit and 64-bit platforms.  For any such type,
    * __w64 should appear only on the 32-bit definition of the typedef.
    * Define __w64 as an empty token for everything but MSVC 7.x or later.
    */
 # if !defined(_MSC_VER)	|| (_MSC_VER < 1300)
-#  define __w64 
+#  define __w64
 # endif
 typedef unsigned long __w64	long_u;
 typedef		 long __w64     long_i;
 # define SCANF_HEX_LONG_U       "%lx"
 # define SCANF_DECIMAL_LONG_U   "%lu"
@@ -459,10 +475,27 @@ typedef unsigned long u8char_T;	    /* l
 #endif
 #ifdef HAVE_STDARG_H
 # include <stdarg.h>
 #endif
 
+# if defined(HAVE_SYS_SELECT_H) && \
+	(!defined(HAVE_SYS_TIME_H) || defined(SYS_SELECT_WITH_SYS_TIME))
+#  include <sys/select.h>
+# endif
+
+# ifndef HAVE_SELECT
+#  ifdef HAVE_SYS_POLL_H
+#   include <sys/poll.h>
+#   define HAVE_POLL
+#  else
+#   ifdef HAVE_POLL_H
+#    include <poll.h>
+#    define HAVE_POLL
+#   endif
+#  endif
+# endif
+
 /* ================ end of the header file puzzle =============== */
 
 /*
  * For dynamically loaded imm library. Currently, only for Win32.
  */
@@ -577,11 +610,11 @@ extern char *(*dyn_libintl_textdomain)(c
 #define VALID_BOTLINE_AP 0x40	/* w_botine is approximated */
 #define VALID_TOPLINE	0x80	/* w_topline is valid (for cursor position) */
 
 /*
  * Terminal highlighting attribute bits.
- * Attibutes above HL_ALL are used for syntax highlighting.
+ * Attributes above HL_ALL are used for syntax highlighting.
  */
 #define HL_NORMAL		0x00
 #define HL_INVERSE		0x01
 #define HL_BOLD			0x02
 #define HL_ITALIC		0x04
@@ -700,10 +733,14 @@ extern char *(*dyn_libintl_textdomain)(c
 #define EXPAND_COLORS		28
 #define EXPAND_COMPILER		29
 #define EXPAND_USER_DEFINED	30
 #define EXPAND_USER_LIST	31
 #define EXPAND_SHELLCMD		32
+#define EXPAND_CSCOPE		33
+#define EXPAND_SIGN		34
+#define EXPAND_PROFILE		35
+#define EXPAND_BEHAVE		36
 
 /* Values for exmode_active (0 is no exmode) */
 #define EXMODE_NORMAL		1
 #define EXMODE_VIM		2
 
@@ -1049,10 +1086,11 @@ extern char *(*dyn_libintl_textdomain)(c
 #define WSP_TOP		4	/* window at top-left of shell */
 #define WSP_BOT		8	/* window at bottom-right of shell */
 #define WSP_HELP	16	/* creating the help window */
 #define WSP_BELOW	32	/* put new window below/right */
 #define WSP_ABOVE	64	/* put new window above/left */
+#define WSP_NEWLOC	128	/* don't copy location list */
 
 /*
  * arguments for gui_set_shellsize()
  */
 #define RESIZE_VERT	1	/* resize vertically */
@@ -1240,11 +1278,11 @@ typedef enum
     , HLF_CUL	    /* 'cursurline' */
     , HLF_COUNT	    /* MUST be the last one */
 } hlf_T;
 
 /* The HL_FLAGS must be in the same order as the HLF_ enums!
- * When chainging this also adjust the default for 'highlight'. */
+ * When changing this also adjust the default for 'highlight'. */
 #define HL_FLAGS {'8', '@', 'd', 'e', 'h', 'i', 'l', 'm', 'M', \
 		  'n', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', \
 		  'f', 'F', 'A', 'C', 'D', 'T', '>', \
 		  'B', 'P', 'R', 'L', \
 		  '+', '=', 'x', 'X', '*', '#', '_', '!', '.'}
@@ -1326,15 +1364,15 @@ typedef enum
 #else
 # define MSG_BUF_LEN 80		/* length of buffer for small messages */
 # define MSG_BUF_CLEN  MSG_BUF_LEN	    /* cell length */
 #endif
 
-#if defined(AMIGA) || defined(__linux__) || defined(__QNX__) || defined(__CYGWIN32__) || defined(_AIX)
-# define TBUFSZ 2048		/* buffer size for termcap entry */
-#else
-# define TBUFSZ 1024		/* buffer size for termcap entry */
-#endif
+/* Size of the buffer used for tgetent().  Unfortunately this is largely
+ * undocumented, some systems use 1024.  Using a buffer that is too small
+ * causes a buffer overrun and a crash.  Use the maximum known value to stay
+ * on the safe side. */
+#define TBUFSZ 2048		/* buffer size for termcap entry */
 
 /*
  * Maximum length of key sequence to be mapped.
  * Must be able to hold an Amiga resize report.
  */
@@ -1408,11 +1446,11 @@ typedef enum
 #endif
 
 #ifdef FEAT_MBYTE
 /* We need to call mb_stricmp() even when we aren't dealing with a multi-byte
  * encoding because mb_stricmp() takes care of all ascii and non-ascii
- * encodings, including characters with umluats in latin1, etc., while
+ * encodings, including characters with umlauts in latin1, etc., while
  * STRICMP() only handles the system locale version, which often does not
  * handle non-ascii properly. */
 
 # define MB_STRICMP(d, s)	mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL)
 # define MB_STRNICMP(d, s, n)	mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n))
@@ -1449,12 +1487,12 @@ typedef enum
 # define PERROR(msg)		    (void)emsg3((char_u *)"%s: %s", (char_u *)msg, (char_u *)strerror(errno))
 #else
 # define PERROR(msg)		    perror(msg)
 #endif
 
-typedef long	    linenr_T;		/* line number type */
-typedef unsigned    colnr_T;		/* column number type */
+typedef long	linenr_T;		/* line number type */
+typedef int	colnr_T;		/* column number type */
 typedef unsigned short disptick_T;	/* display tick type */
 
 #define MAXLNUM (0x7fffffffL)		/* maximum (invalid) line number */
 
 /*
@@ -1726,11 +1764,12 @@ typedef int proftime_T;	    /* dummy for
 #define VV_MOUSE_WIN	49
 #define VV_MOUSE_LNUM   50
 #define VV_MOUSE_COL	51
 #define VV_OP		52
 #define VV_SEARCHFORWARD 53
-#define VV_LEN		54	/* number of v: vars */
+#define VV_OLDFILES	54
+#define VV_LEN		55	/* number of v: vars */
 
 #ifdef FEAT_CLIPBOARD
 
 /* VIM_ATOM_NAME is the older Vim-specific selection type for X11.  Still
  * supported for when a mix of Vim versions is used. VIMENC_ATOM_NAME includes
@@ -1977,10 +2016,13 @@ typedef int VimClipboard;	/* This is req
 # else
 #  define X_DISPLAY	xterm_dpy
 # endif
 #endif
 
+#ifndef FEAT_NETBEANS_INTG
+# undef NBDEBUG
+#endif
 #ifdef NBDEBUG /* Netbeans debugging. */
 # include "nbdebug.h"
 #else
 # define nbdebug(a)
 #endif
@@ -2052,6 +2094,12 @@ typedef int VimClipboard;	/* This is req
 /* last argument for do_source() */
 #define DOSO_NONE	0
 #define DOSO_VIMRC	1	/* loading vimrc file */
 #define DOSO_GVIMRC	2	/* loading gvimrc file */
 
+/* flags for read_viminfo() and children */
+#define VIF_WANT_INFO		1	/* load non-mark info */
+#define VIF_WANT_MARKS		2	/* load file marks */
+#define VIF_FORCEIT		4	/* overwrite info already read */
+#define VIF_GET_OLDFILES	8	/* load v:oldfiles */
+
 #endif /* VIM__H */
--- vim72.orig/src/window.c
+++ vim72/src/window.c
@@ -9,24 +9,24 @@
 
 #include "vim.h"
 
 static int path_is_url __ARGS((char_u *p));
 #if defined(FEAT_WINDOWS) || defined(PROTO)
-static int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
-static void win_init __ARGS((win_T *newp, win_T *oldp));
+static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
+static void win_init_some __ARGS((win_T *newp, win_T *oldp));
 static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
 static void frame_setheight __ARGS((frame_T *curfrp, int height));
 #ifdef FEAT_VERTSPLIT
 static void frame_setwidth __ARGS((frame_T *curfrp, int width));
 #endif
 static void win_exchange __ARGS((long));
 static void win_rotate __ARGS((int, int));
 static void win_totop __ARGS((int size, int flags));
 static void win_equal_rec __ARGS((win_T *next_curwin, int current, frame_T *topfr, int dir, int col, int row, int width, int height));
 static int last_window __ARGS((void));
+static int one_window __ARGS((void));
 static win_T *win_free_mem __ARGS((win_T *win, int *dirp, tabpage_T *tp));
-static win_T *winframe_remove __ARGS((win_T *win, int *dirp, tabpage_T *tp));
 static frame_T *win_altframe __ARGS((win_T *win, tabpage_T *tp));
 static tabpage_T *alt_tabpage __ARGS((void));
 static win_T *frame2win __ARGS((frame_T *frp));
 static int frame_has_win __ARGS((frame_T *frp, win_T *wp));
 static void frame_new_height __ARGS((frame_T *topfrp, int height, int topfirst, int wfh));
@@ -39,20 +39,19 @@ static void frame_add_vsep __ARGS((frame
 static int frame_minwidth __ARGS((frame_T *topfrp, win_T *next_curwin));
 static void frame_fix_width __ARGS((win_T *wp));
 #endif
 #endif
 static int win_alloc_firstwin __ARGS((win_T *oldwin));
+static void new_frame __ARGS((win_T *wp));
 #if defined(FEAT_WINDOWS) || defined(PROTO)
 static tabpage_T *alloc_tabpage __ARGS((void));
 static int leave_tabpage __ARGS((buf_T *new_curbuf));
 static void enter_tabpage __ARGS((tabpage_T *tp, buf_T *old_curbuf));
 static void frame_fix_height __ARGS((win_T *wp));
 static int frame_minheight __ARGS((frame_T *topfrp, win_T *next_curwin));
 static void win_enter_ext __ARGS((win_T *wp, int undo_sync, int no_curwin));
 static void win_free __ARGS((win_T *wp, tabpage_T *tp));
-static void win_append __ARGS((win_T *, win_T *));
-static void win_remove __ARGS((win_T *, tabpage_T *tp));
 static void frame_append __ARGS((frame_T *after, frame_T *frp));
 static void frame_insert __ARGS((frame_T *before, frame_T *frp));
 static void frame_remove __ARGS((frame_T *frp));
 #ifdef FEAT_VERTSPLIT
 static void win_new_width __ARGS((win_T *wp, int width));
@@ -60,21 +59,19 @@ static void win_goto_ver __ARGS((int up,
 static void win_goto_hor __ARGS((int left, long count));
 #endif
 static void frame_add_height __ARGS((frame_T *frp, int n));
 static void last_status_rec __ARGS((frame_T *fr, int statusline));
 
-static void make_snapshot __ARGS((void));
 static void make_snapshot_rec __ARGS((frame_T *fr, frame_T **frp));
-static void clear_snapshot __ARGS((tabpage_T *tp));
+static void clear_snapshot __ARGS((tabpage_T *tp, int idx));
 static void clear_snapshot_rec __ARGS((frame_T *fr));
-static void restore_snapshot __ARGS((int close_curwin));
 static int check_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
 static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
 
 #endif /* FEAT_WINDOWS */
 
-static win_T *win_alloc __ARGS((win_T *after));
+static win_T *win_alloc __ARGS((win_T *after, int hidden));
 static void win_new_height __ARGS((win_T *, int));
 
 #define URL_SLASH	1		/* path_is_url() has found "://" */
 #define URL_BACKSLASH	2		/* path_is_url() has found ":\\" */
 
@@ -257,11 +254,11 @@ newwindow:
     case Ctrl_W:
     case 'w':
 /* cursor to previous window with wrap around */
     case 'W':
 		CHECK_CMDWIN
-		if (lastwin == firstwin && Prenum != 1)	/* just one window */
+		if (firstwin == lastwin && Prenum != 1)	/* just one window */
 		    beep_flush();
 		else
 		{
 		    if (Prenum)			/* go to specified window */
 		    {
@@ -341,11 +338,11 @@ newwindow:
 		break;
 #endif
 
 /* move window to new tab page */
     case 'T':
-		if (firstwin == lastwin)
+		if (one_window())
 		    MSG(_(m_onlyone));
 		else
 		{
 		    tabpage_T	*oldtab = curtab;
 		    tabpage_T	*newtab;
@@ -529,11 +526,12 @@ wingotofile:
 		    if (win_split(0, 0) == OK)
 		    {
 # ifdef FEAT_SCROLLBIND
 			curwin->w_p_scb = FALSE;
 # endif
-			(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, ECMD_HIDE);
+			(void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL,
+							   ECMD_HIDE, NULL);
 			if (nchar == 'F' && lnum >= 0)
 			{
 			    curwin->w_cursor.lnum = lnum;
 			    check_cursor_lnum();
 			    beginline(BL_SOL | BL_FIX);
@@ -591,13 +589,11 @@ wingotofile:
 #endif
 		++no_mapping;
 		++allow_keys;   /* no mapping for xchar, but allow key codes */
 		if (xchar == NUL)
 		    xchar = plain_vgetc();
-#ifdef FEAT_LANGMAP
 		LANGMAP_ADJUST(xchar, TRUE);
-#endif
 		--no_mapping;
 		--allow_keys;
 #ifdef FEAT_CMDL_INFO
 		(void)add_to_showcmd(xchar);
 #endif
@@ -628,11 +624,11 @@ wingotofile:
 			break;
 
 #ifdef FEAT_SEARCHPATH
 		    case 'f':	    /* CTRL-W gf: "gf" in a new tab page */
 		    case 'F':	    /* CTRL-W gF: "gF" in a new tab page */
-			cmdmod.tab = TRUE;
+			cmdmod.tab = tabpage_index(curtab) + 1;
 			nchar = xchar;
 			goto wingotofile;
 #endif
 		    default:
 			beep_flush();
@@ -678,24 +674,24 @@ win_split(size, flags)
     }
 
     /* When creating the help window make a snapshot of the window layout.
      * Otherwise clear the snapshot, it's now invalid. */
     if (flags & WSP_HELP)
-	make_snapshot();
+	make_snapshot(SNAP_HELP_IDX);
     else
-	clear_snapshot(curtab);
+	clear_snapshot(curtab, SNAP_HELP_IDX);
 
     return win_split_ins(size, flags, NULL, 0);
 }
 
 /*
  * When "newwin" is NULL: split the current window in two.
  * When "newwin" is not NULL: insert this window at the far
  * top/left/right/bottom.
  * return FAIL for failure, OK otherwise
  */
-    static int
+    int
 win_split_ins(size, flags, newwin, dir)
     int		size;
     int		flags;
     win_T	*newwin;
     int		dir;
@@ -892,29 +888,36 @@ win_split_ins(size, flags, newwin, dir)
 #endif
 			p_sb))))
     {
 	/* new window below/right of current one */
 	if (newwin == NULL)
-	    wp = win_alloc(oldwin);
+	    wp = win_alloc(oldwin, FALSE);
 	else
 	    win_append(oldwin, wp);
     }
     else
     {
 	if (newwin == NULL)
-	    wp = win_alloc(oldwin->w_prev);
+	    wp = win_alloc(oldwin->w_prev, FALSE);
 	else
 	    win_append(oldwin->w_prev, wp);
     }
 
     if (newwin == NULL)
     {
 	if (wp == NULL)
 	    return FAIL;
 
+	new_frame(wp);
+	if (wp->w_frame == NULL)
+	{
+	    win_free(wp, NULL);
+	    return FAIL;
+	}
+
 	/* make the contents of the new window the same as the current one */
-	win_init(wp, curwin);
+	win_init(wp, curwin, flags);
     }
 
     /*
      * Reorganise the tree of frames to insert the new window.
      */
@@ -969,17 +972,11 @@ win_split_ins(size, flags, newwin, dir)
 	    for (frp = frp->fr_child; frp != NULL; frp = frp->fr_next)
 		frp->fr_parent = curfrp;
     }
 
     if (newwin == NULL)
-    {
-	/* Create a frame for the new window. */
-	frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
-	frp->fr_layout = FR_LEAF;
-	frp->fr_win = wp;
-	wp->w_frame = frp;
-    }
+	frp = wp->w_frame;
     else
 	frp = newwin->w_frame;
     frp->fr_parent = curfrp->fr_parent;
 
     /* Insert the new frame at the right place in the frame list. */
@@ -992,32 +989,32 @@ win_split_ins(size, flags, newwin, dir)
     if (flags & WSP_VERT)
     {
 	wp->w_p_scr = curwin->w_p_scr;
 	if (need_status)
 	{
-	    --oldwin->w_height;
+	    win_new_height(oldwin, oldwin->w_height - 1);
 	    oldwin->w_status_height = need_status;
 	}
 	if (flags & (WSP_TOP | WSP_BOT))
 	{
 	    /* set height and row of new window to full height */
 	    wp->w_winrow = tabline_height();
-	    wp->w_height = curfrp->fr_height - (p_ls > 0);
+	    win_new_height(wp, curfrp->fr_height - (p_ls > 0));
 	    wp->w_status_height = (p_ls > 0);
 	}
 	else
 	{
 	    /* height and row of new window is same as current window */
 	    wp->w_winrow = oldwin->w_winrow;
-	    wp->w_height = oldwin->w_height;
+	    win_new_height(wp, oldwin->w_height);
 	    wp->w_status_height = oldwin->w_status_height;
 	}
 	frp->fr_height = curfrp->fr_height;
 
 	/* "new_size" of the current window goes to the new window, use
 	 * one column for the vertical separator */
-	wp->w_width = new_size;
+	win_new_width(wp, new_size);
 	if (before)
 	    wp->w_vsep_width = 1;
 	else
 	{
 	    wp->w_vsep_width = oldwin->w_vsep_width;
@@ -1050,17 +1047,17 @@ win_split_ins(size, flags, newwin, dir)
 	/* width and column of new window is same as current window */
 #ifdef FEAT_VERTSPLIT
 	if (flags & (WSP_TOP | WSP_BOT))
 	{
 	    wp->w_wincol = 0;
-	    wp->w_width = Columns;
+	    win_new_width(wp, Columns);
 	    wp->w_vsep_width = 0;
 	}
 	else
 	{
 	    wp->w_wincol = oldwin->w_wincol;
-	    wp->w_width = oldwin->w_width;
+	    win_new_width(wp, oldwin->w_width);
 	    wp->w_vsep_width = oldwin->w_vsep_width;
 	}
 	frp->fr_width = curfrp->fr_width;
 #endif
 
@@ -1112,11 +1109,11 @@ win_split_ins(size, flags, newwin, dir)
 	msg_row = Rows - 1;
 	msg_col = 0;	/* put position back at start of line */
     }
 
     /*
-     * make the new window the current window and redraw
+     * equalize the window sizes.
      */
     if (do_equal || dir != 0)
 	win_equal(wp, TRUE,
 #ifdef FEAT_VERTSPLIT
 		(flags & WSP_VERT) ? (dir == 'v' ? 'b' : 'h')
@@ -1144,10 +1141,14 @@ win_split_ins(size, flags, newwin, dir)
     {
 	i = p_wh;
 	if (size != 0)
 	    p_wh = size;
     }
+
+    /*
+     * make the new window the current window
+     */
     win_enter(wp, FALSE);
 #ifdef FEAT_VERTSPLIT
     if (flags & WSP_VERT)
 	p_wiw = i;
     else
@@ -1155,19 +1156,23 @@ win_split_ins(size, flags, newwin, dir)
 	p_wh = i;
 
     return OK;
 }
 
+
 /*
  * Initialize window "newp" from window "oldp".
  * Used when splitting a window and when creating a new tab page.
  * The windows will both edit the same buffer.
+ * WSP_NEWLOC may be specified in flags to prevent the location list from
+ * being copied.
  */
     static void
-win_init(newp, oldp)
+win_init(newp, oldp, flags)
     win_T	*newp;
     win_T	*oldp;
+    int		 flags UNUSED;
 {
     int		i;
 
     newp->w_buffer = oldp->w_buffer;
     oldp->w_buffer->b_nwindows++;
@@ -1188,36 +1193,55 @@ win_init(newp, oldp)
     newp->w_prev_fraction_row = oldp->w_prev_fraction_row;
 #ifdef FEAT_JUMPLIST
     copy_jumplist(oldp, newp);
 #endif
 #ifdef FEAT_QUICKFIX
-    copy_loclist(oldp, newp);
+    if (flags & WSP_NEWLOC)
+    {
+	/* Don't copy the location list.  */
+	newp->w_llist = NULL;
+	newp->w_llist_ref = NULL;
+    }
+    else
+	copy_loclist(oldp, newp);
 #endif
     if (oldp->w_localdir != NULL)
 	newp->w_localdir = vim_strsave(oldp->w_localdir);
 
-    /* Use the same argument list. */
-    newp->w_alist = oldp->w_alist;
-    ++newp->w_alist->al_refcount;
-    newp->w_arg_idx = oldp->w_arg_idx;
-
-    /*
-     * copy tagstack and options from existing window
-     */
+    /* copy tagstack and folds */
     for (i = 0; i < oldp->w_tagstacklen; i++)
     {
 	newp->w_tagstack[i] = oldp->w_tagstack[i];
 	if (newp->w_tagstack[i].tagname != NULL)
 	    newp->w_tagstack[i].tagname =
 				   vim_strsave(newp->w_tagstack[i].tagname);
     }
     newp->w_tagstackidx = oldp->w_tagstackidx;
     newp->w_tagstacklen = oldp->w_tagstacklen;
-    win_copy_options(oldp, newp);
 # ifdef FEAT_FOLDING
     copyFoldingState(oldp, newp);
 # endif
+
+    win_init_some(newp, oldp);
+}
+
+/*
+ * Initialize window "newp" from window"old".
+ * Only the essential things are copied.
+ */
+    static void
+win_init_some(newp, oldp)
+    win_T	*newp;
+    win_T	*oldp;
+{
+    /* Use the same argument list. */
+    newp->w_alist = oldp->w_alist;
+    ++newp->w_alist->al_refcount;
+    newp->w_arg_idx = oldp->w_arg_idx;
+
+    /* copy options from existing window */
+    win_copy_options(oldp, newp);
 }
 
 #endif /* FEAT_WINDOWS */
 
 #if defined(FEAT_WINDOWS) || defined(PROTO)
@@ -1256,15 +1280,14 @@ win_count()
  * Make "count" windows on the screen.
  * Return actual number of windows on the screen.
  * Must be called when there is just one window, filling the whole screen
  * (excluding the command line).
  */
-/*ARGSUSED*/
     int
 make_windows(count, vertical)
     int		count;
-    int		vertical;	/* split windows vertically if TRUE */
+    int		vertical UNUSED;  /* split windows vertically if TRUE */
 {
     int		maxcount;
     int		todo;
 
 #ifdef FEAT_VERTSPLIT
@@ -1555,19 +1578,12 @@ win_totop(size, flags)
     }
 
 #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
     /* When 'guioptions' includes 'L' or 'R' may have to remove or add
      * scrollbars.  Have to update them anyway. */
-    if (gui.in_use)
-    {
-	out_flush();
-	gui_init_which_components(NULL);
-	gui_update_scrollbars(TRUE);
-    }
-    need_mouse_correct = TRUE;
+    gui_may_update_scrollbars();
 #endif
-
 }
 
 /*
  * Move window "win1" to below/right of "win2" and make "win1" the current
  * window.  Only works within the same frame!
@@ -2038,17 +2054,44 @@ close_windows(buf, keep_curwin)
     if (h != tabline_height())
 	shell_new_rows();
 }
 
 /*
- * Return TRUE if the current window is the only window that exists.
+ * Return TRUE if the current window is the only window that exists (ignoring
+ * "aucmd_win").
  * Returns FALSE if there is a window, possibly in another tab page.
  */
     static int
 last_window()
 {
-    return (lastwin == firstwin && first_tabpage->tp_next == NULL);
+    return (one_window() && first_tabpage->tp_next == NULL);
+}
+
+/*
+ * Return TRUE if there is only one window other than "aucmd_win" in the
+ * current tab page.
+ */
+    static int
+one_window()
+{
+#ifdef FEAT_AUTOCMD
+    win_T	*wp;
+    int		seen_one = FALSE;
+
+    FOR_ALL_WINDOWS(wp)
+    {
+	if (wp != aucmd_win)
+	{
+	    if (seen_one)
+		return FALSE;
+	    seen_one = TRUE;
+	}
+    }
+    return TRUE;
+#else
+    return firstwin == lastwin;
+#endif
 }
 
 /*
  * Close window "win".  Only works for the current tab page.
  * If "free_buf" is TRUE related buffer may be unloaded.
@@ -2073,10 +2116,23 @@ win_close(win, free_buf)
     {
 	EMSG(_("E444: Cannot close last window"));
 	return;
     }
 
+#ifdef FEAT_AUTOCMD
+    if (win == aucmd_win)
+    {
+	EMSG(_("E813: Cannot close autocmd window"));
+	return;
+    }
+    if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())
+    {
+	EMSG(_("E814: Cannot close window, only autocmd window would remain"));
+	return;
+    }
+#endif
+
     /*
      * When closing the last window in a tab page first go to another tab
      * page and then close the window and the tab page.  This avoids that
      * curwin and curtab are not invalid while we are freeing memory, they may
      * be used in GUI events.
@@ -2102,11 +2158,11 @@ win_close(win, free_buf)
     /* When closing the help window, try restoring a snapshot after closing
      * the window.  Otherwise clear the snapshot, it's now invalid. */
     if (win->w_buffer->b_help)
 	help_window = TRUE;
     else
-	clear_snapshot(curtab);
+	clear_snapshot(curtab, SNAP_HELP_IDX);
 
 #ifdef FEAT_AUTOCMD
     if (win == curwin)
     {
 	/*
@@ -2219,11 +2275,11 @@ win_close(win, free_buf)
     last_status(FALSE);
 
     /* After closing the help window, try restoring the window layout from
      * before it was opened. */
     if (help_window)
-	restore_snapshot(close_curwin);
+	restore_snapshot(SNAP_HELP_IDX, close_curwin);
 
 #if defined(FEAT_GUI) && defined(FEAT_VERTSPLIT)
     /* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */
     if (gui.in_use && !win_hasvertsplit())
 	gui_init_which_components(NULL);
@@ -2300,17 +2356,10 @@ win_free_mem(win, dirp, tp)
     tabpage_T	*tp;		/* tab page "win" is in, NULL for current */
 {
     frame_T	*frp;
     win_T	*wp;
 
-#ifdef FEAT_FOLDING
-    clearFolding(win);
-#endif
-
-    /* reduce the reference count to the argument list. */
-    alist_unlink(win->w_alist);
-
     /* Remove the window and its frame from the tree of frames. */
     frp = win->w_frame;
     wp = winframe_remove(win, dirp, tp);
     vim_free(frp);
     win_free(win, tp);
@@ -2332,24 +2381,31 @@ win_free_all()
 # ifdef FEAT_WINDOWS
     while (first_tabpage->tp_next != NULL)
 	tabpage_close(TRUE);
 # endif
 
+# ifdef FEAT_AUTOCMD
+    if (aucmd_win != NULL)
+    {
+	(void)win_free_mem(aucmd_win, &dummy, NULL);
+	aucmd_win = NULL;
+    }
+# endif
+
     while (firstwin != NULL)
 	(void)win_free_mem(firstwin, &dummy, NULL);
 }
 #endif
 
 /*
  * Remove a window and its frame from the tree of frames.
  * Returns a pointer to the window that got the freed up space.
  */
-/*ARGSUSED*/
-    static win_T *
+    win_T *
 winframe_remove(win, dirp, tp)
     win_T	*win;
-    int		*dirp;		/* set to 'v' or 'h' for direction if 'ea' */
+    int		*dirp UNUSED;	/* set to 'v' or 'h' for direction if 'ea' */
     tabpage_T	*tp;		/* tab page "win" is in, NULL for current */
 {
     frame_T	*frp, *frp2, *frp3;
     frame_T	*frp_close = win->w_frame;
     win_T	*wp;
@@ -3081,11 +3137,11 @@ close_others(message, forceit)
 {
     win_T	*wp;
     win_T	*nextwp;
     int		r;
 
-    if (lastwin == firstwin)
+    if (one_window())
     {
 	if (message
 #ifdef FEAT_AUTOCMD
 		    && !autocmd_busy
 #endif
@@ -3143,31 +3199,38 @@ close_others(message, forceit)
  * Called when a new file is being edited.
  */
     void
 curwin_init()
 {
-    redraw_win_later(curwin, NOT_VALID);
-    curwin->w_lines_valid = 0;
-    curwin->w_cursor.lnum = 1;
-    curwin->w_curswant = curwin->w_cursor.col = 0;
+    win_init_empty(curwin);
+}
+
+    void
+win_init_empty(wp)
+    win_T *wp;
+{
+    redraw_win_later(wp, NOT_VALID);
+    wp->w_lines_valid = 0;
+    wp->w_cursor.lnum = 1;
+    wp->w_curswant = wp->w_cursor.col = 0;
 #ifdef FEAT_VIRTUALEDIT
-    curwin->w_cursor.coladd = 0;
+    wp->w_cursor.coladd = 0;
 #endif
-    curwin->w_pcmark.lnum = 1;	/* pcmark not cleared but set to line 1 */
-    curwin->w_pcmark.col = 0;
-    curwin->w_prev_pcmark.lnum = 0;
-    curwin->w_prev_pcmark.col = 0;
-    curwin->w_topline = 1;
+    wp->w_pcmark.lnum = 1;	/* pcmark not cleared but set to line 1 */
+    wp->w_pcmark.col = 0;
+    wp->w_prev_pcmark.lnum = 0;
+    wp->w_prev_pcmark.col = 0;
+    wp->w_topline = 1;
 #ifdef FEAT_DIFF
-    curwin->w_topfill = 0;
+    wp->w_topfill = 0;
 #endif
-    curwin->w_botline = 2;
+    wp->w_botline = 2;
 #ifdef FEAT_FKMAP
-    if (curwin->w_p_rl)
-	curwin->w_farsi = W_CONV + W_R_L;
+    if (wp->w_p_rl)
+	wp->w_farsi = W_CONV + W_R_L;
     else
-	curwin->w_farsi = W_CONV;
+	wp->w_farsi = W_CONV;
 #endif
 }
 
 /*
  * Allocate the first window and put an empty buffer in it.
@@ -3185,13 +3248,34 @@ win_alloc_first()
     if (first_tabpage == NULL)
 	return FAIL;
     first_tabpage->tp_topframe = topframe;
     curtab = first_tabpage;
 #endif
+
     return OK;
 }
 
+#if defined(FEAT_AUTOCMD) || defined(PROTO)
+/*
+ * Init "aucmd_win".  This can only be done after the first
+ * window is fully initialized, thus it can't be in win_alloc_first().
+ */
+    void
+win_alloc_aucmd_win()
+{
+    aucmd_win = win_alloc(NULL, TRUE);
+    if (aucmd_win != NULL)
+    {
+	win_init_some(aucmd_win, curwin);
+# ifdef FEAT_SCROLLBIND
+	aucmd_win->w_p_scb = FALSE;
+# endif
+	new_frame(aucmd_win);
+    }
+}
+#endif
+
 /*
  * Allocate the first window or the first window in a new tab page.
  * When "oldwin" is NULL create an empty buffer for it.
  * When "oldwin" is not NULL copy info from it to the new window (only with
  * FEAT_WINDOWS).
@@ -3199,11 +3283,11 @@ win_alloc_first()
  */
     static int
 win_alloc_firstwin(oldwin)
     win_T	*oldwin;
 {
-    curwin = win_alloc(NULL);
+    curwin = win_alloc(NULL, FALSE);
     if (oldwin == NULL)
     {
 	/* Very first window, need to create an empty buffer for it and
 	 * initialize from scratch. */
 	curbuf = buflist_new(NULL, NULL, 1L, BLN_LISTED);
@@ -3218,34 +3302,49 @@ win_alloc_firstwin(oldwin)
     }
 #ifdef FEAT_WINDOWS
     else
     {
 	/* First window in new tab page, initialize it from "oldwin". */
-	win_init(curwin, oldwin);
+	win_init(curwin, oldwin, 0);
 
 # ifdef FEAT_SCROLLBIND
 	/* We don't want scroll-binding in the first window. */
 	curwin->w_p_scb = FALSE;
 # endif
     }
 #endif
 
-    topframe = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
-    if (topframe == NULL)
+    new_frame(curwin);
+    if (curwin->w_frame == NULL)
 	return FAIL;
-    topframe->fr_layout = FR_LEAF;
+    topframe = curwin->w_frame;
 #ifdef FEAT_VERTSPLIT
     topframe->fr_width = Columns;
 #endif
     topframe->fr_height = Rows - p_ch;
     topframe->fr_win = curwin;
-    curwin->w_frame = topframe;
 
     return OK;
 }
 
 /*
+ * Create a frame for window "wp".
+ */
+    static void
+new_frame(win_T *wp)
+{
+    frame_T *frp = (frame_T *)alloc_clear((unsigned)sizeof(frame_T));
+
+    wp->w_frame = frp;
+    if (frp != NULL)
+    {
+	frp->fr_layout = FR_LEAF;
+	frp->fr_win = wp;
+    }
+}
+
+/*
  * Initialize the window and frame size to the maximum.
  */
     void
 win_init_size()
 {
@@ -3291,14 +3390,17 @@ alloc_tabpage()
 
     void
 free_tabpage(tp)
     tabpage_T	*tp;
 {
+    int idx;
+
 # ifdef FEAT_DIFF
     diff_clear(tp);
 # endif
-    clear_snapshot(tp);
+    for (idx = 0; idx < SNAP_COUNT; ++idx)
+	clear_snapshot(tp, idx);
 #ifdef FEAT_EVAL
     vars_clear(&tp->tp_vars.dv_hashtab);	/* free all t: variables */
 #endif
     vim_free(tp);
 }
@@ -3361,16 +3463,11 @@ win_new_tabpage(after)
 	last_status(FALSE);
 
 #if defined(FEAT_GUI)
 	/* When 'guioptions' includes 'L' or 'R' may have to remove or add
 	 * scrollbars.  Have to update them anyway. */
-	if (gui.in_use && starting == 0)
-	{
-	    gui_init_which_components(NULL);
-	    gui_update_scrollbars(TRUE);
-	}
-	need_mouse_correct = TRUE;
+	gui_may_update_scrollbars();
 #endif
 
 	redraw_all_later(CLEAR);
 #ifdef FEAT_AUTOCMD
 	apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf);
@@ -3488,14 +3585,13 @@ tabpage_index(ftp)
  * Prepare for leaving the current tab page.
  * When autocomands change "curtab" we don't leave the tab page and return
  * FAIL.
  * Careful: When OK is returned need to get a new tab page very very soon!
  */
-/*ARGSUSED*/
     static int
 leave_tabpage(new_curbuf)
-    buf_T	*new_curbuf;	    /* what is going to be the new curbuf,
+    buf_T	*new_curbuf UNUSED;    /* what is going to be the new curbuf,
 				       NULL if unknown */
 {
     tabpage_T	*tp = curtab;
 
 #ifdef FEAT_VISUAL
@@ -3533,15 +3629,14 @@ leave_tabpage(new_curbuf)
 
 /*
  * Start using tab page "tp".
  * Only to be used after leave_tabpage() or freeing the current tab page.
  */
-/*ARGSUSED*/
     static void
 enter_tabpage(tp, old_curbuf)
     tabpage_T	*tp;
-    buf_T	*old_curbuf;
+    buf_T	*old_curbuf UNUSED;
 {
     int		old_off = tp->tp_firstwin->w_winrow;
     win_T	*next_prevwin = tp->tp_prevwin;
 
     curtab = tp;
@@ -3586,16 +3681,11 @@ enter_tabpage(tp, old_curbuf)
 #endif
 
 #if defined(FEAT_GUI)
     /* When 'guioptions' includes 'L' or 'R' may have to remove or add
      * scrollbars.  Have to update them anyway. */
-    if (gui.in_use && starting == 0)
-    {
-	gui_init_which_components(NULL);
-	gui_update_scrollbars(TRUE);
-    }
-    need_mouse_correct = TRUE;
+    gui_may_update_scrollbars();
 #endif
 
     redraw_all_later(CLEAR);
 }
 
@@ -4026,18 +4116,18 @@ win_enter_ext(wp, undo_sync, curwin_inva
 	    char_u	cwd[MAXPATHL];
 
 	    if (mch_dirname(cwd, MAXPATHL) == OK)
 		globaldir = vim_strsave(cwd);
 	}
-	mch_chdir((char *)curwin->w_localdir);
-	shorten_fnames(TRUE);
+	if (mch_chdir((char *)curwin->w_localdir) == 0)
+	    shorten_fnames(TRUE);
     }
     else if (globaldir != NULL)
     {
 	/* Window doesn't have a local directory and we are not in the global
 	 * directory: Change to the global directory. */
-	mch_chdir((char *)globaldir);
+	ignored = mch_chdir((char *)globaldir);
 	vim_free(globaldir);
 	globaldir = NULL;
 	shorten_fnames(TRUE);
     }
 
@@ -4143,16 +4233,17 @@ buf_jump_open_tab(buf)
 # endif
 }
 #endif
 
 /*
- * allocate a window structure and link it in the window list
+ * Allocate a window structure and link it in the window list when "hidden" is
+ * FALSE.
  */
-/*ARGSUSED*/
     static win_T *
-win_alloc(after)
-    win_T	*after;
+win_alloc(after, hidden)
+    win_T	*after UNUSED;
+    int		hidden UNUSED;
 {
     win_T	*newwin;
 
     /*
      * allocate window structure and linesizes arrays
@@ -4174,11 +4265,12 @@ win_alloc(after)
 #endif
 	/*
 	 * link the window in the window list
 	 */
 #ifdef FEAT_WINDOWS
-	win_append(after, newwin);
+	if (!hidden)
+	    win_append(after, newwin);
 #endif
 #ifdef FEAT_VERTSPLIT
 	newwin->w_wincol = 0;
 	newwin->w_width = Columns;
 #endif
@@ -4235,10 +4327,17 @@ win_free(wp, tp)
     win_T	*wp;
     tabpage_T	*tp;		/* tab page "win" is in, NULL for current */
 {
     int		i;
 
+#ifdef FEAT_FOLDING
+    clearFolding(wp);
+#endif
+
+    /* reduce the reference count to the argument list. */
+    alist_unlink(wp->w_alist);
+
 #ifdef FEAT_AUTOCMD
     /* Don't execute autocommands while the window is halfway being deleted.
      * gui_mch_destroy_scrollbar() may trigger a FocusGained event. */
     block_autocmds();
 #endif
@@ -4297,22 +4396,25 @@ win_free(wp, tp)
 	gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_LEFT]);
 	gui_mch_destroy_scrollbar(&wp->w_scrollbars[SBAR_RIGHT]);
     }
 #endif /* FEAT_GUI */
 
-    win_remove(wp, tp);
+#ifdef FEAT_AUTOCMD
+    if (wp != aucmd_win)
+#endif
+	win_remove(wp, tp);
     vim_free(wp);
 
 #ifdef FEAT_AUTOCMD
     unblock_autocmds();
 #endif
 }
 
 /*
  * Append window "wp" in the window list after window "after".
  */
-    static void
+    void
 win_append(after, wp)
     win_T	*after, *wp;
 {
     win_T	*before;
 
@@ -4334,11 +4436,11 @@ win_append(after, wp)
 }
 
 /*
  * Remove a window from the window list.
  */
-    static void
+    void
 win_remove(wp, tp)
     win_T	*wp;
     tabpage_T	*tp;		/* tab page "win" is in, NULL for current */
 {
     if (wp->w_prev != NULL)
@@ -6034,10 +6136,11 @@ min_rows()
 }
 
 /*
  * Return TRUE if there is only one window (in the current tab page), not
  * counting a help or preview window, unless it is the current window.
+ * Does not count "aucmd_win".
  */
     int
 only_one_window()
 {
 #ifdef FEAT_WINDOWS
@@ -6047,15 +6150,19 @@ only_one_window()
     /* If there is another tab page there always is another window. */
     if (first_tabpage->tp_next != NULL)
 	return FALSE;
 
     for (wp = firstwin; wp != NULL; wp = wp->w_next)
-	if (!((wp->w_buffer->b_help && !curbuf->b_help)
+	if ((!((wp->w_buffer->b_help && !curbuf->b_help)
 # ifdef FEAT_QUICKFIX
 		    || wp->w_p_pvw
 # endif
 	     ) || wp == curwin)
+# ifdef FEAT_AUTOCMD
+		&& wp != aucmd_win
+# endif
+	   )
 	    ++count;
     return (count <= 1);
 #else
     return TRUE;
 #endif
@@ -6106,15 +6213,16 @@ check_lnums(do_curwin)
  */
 
 /*
  * Create a snapshot of the current frame sizes.
  */
-    static void
-make_snapshot()
+    void
+make_snapshot(idx)
+    int idx;
 {
-    clear_snapshot(curtab);
-    make_snapshot_rec(topframe, &curtab->tp_snapshot);
+    clear_snapshot(curtab, idx);
+    make_snapshot_rec(topframe, &curtab->tp_snapshot[idx]);
 }
 
     static void
 make_snapshot_rec(fr, frp)
     frame_T	*fr;
@@ -6138,15 +6246,16 @@ make_snapshot_rec(fr, frp)
 
 /*
  * Remove any existing snapshot.
  */
     static void
-clear_snapshot(tp)
+clear_snapshot(tp, idx)
     tabpage_T	*tp;
+    int		idx;
 {
-    clear_snapshot_rec(tp->tp_snapshot);
-    tp->tp_snapshot = NULL;
+    clear_snapshot_rec(tp->tp_snapshot[idx]);
+    tp->tp_snapshot[idx] = NULL;
 }
 
     static void
 clear_snapshot_rec(fr)
     frame_T	*fr;
@@ -6162,30 +6271,31 @@ clear_snapshot_rec(fr)
 /*
  * Restore a previously created snapshot, if there is any.
  * This is only done if the screen size didn't change and the window layout is
  * still the same.
  */
-    static void
-restore_snapshot(close_curwin)
+    void
+restore_snapshot(idx, close_curwin)
+    int		idx;
     int		close_curwin;	    /* closing current window */
 {
     win_T	*wp;
 
-    if (curtab->tp_snapshot != NULL
+    if (curtab->tp_snapshot[idx] != NULL
 # ifdef FEAT_VERTSPLIT
-	    && curtab->tp_snapshot->fr_width == topframe->fr_width
+	    && curtab->tp_snapshot[idx]->fr_width == topframe->fr_width
 # endif
-	    && curtab->tp_snapshot->fr_height == topframe->fr_height
-	    && check_snapshot_rec(curtab->tp_snapshot, topframe) == OK)
+	    && curtab->tp_snapshot[idx]->fr_height == topframe->fr_height
+	    && check_snapshot_rec(curtab->tp_snapshot[idx], topframe) == OK)
     {
-	wp = restore_snapshot_rec(curtab->tp_snapshot, topframe);
+	wp = restore_snapshot_rec(curtab->tp_snapshot[idx], topframe);
 	win_comp_pos();
 	if (wp != NULL && close_curwin)
 	    win_goto(wp);
 	redraw_all_later(CLEAR);
     }
-    clear_snapshot(curtab);
+    clear_snapshot(curtab, idx);
 }
 
 /*
  * Check if frames "sn" and "fr" have the same layout, same following frames
  * and same children.
--- vim72.orig/src/workshop.c
+++ vim72/src/workshop.c
@@ -54,16 +54,16 @@ static void	 load_buffer_by_name(char *,
 static void	 load_buffer_by_number(int, int);
 #endif
 static void	 load_window(char *, int lnum);
 static void	 warp_to_pc(int);
 #ifdef FEAT_BEVAL
-void		workshop_beval_cb(BalloonEval *, int);
+void		 workshop_beval_cb(BalloonEval *, int);
+static int	 computeIndex(int, char_u *, int);
 #endif
 static char	*fixAccelText(char *);
 static void	 addMenu(char *, char *, char *);
 static char	*lookupVerb(char *, int);
-static int	 computeIndex(int, char_u *, int);
 static void	 coloncmd(char *, Boolean);
 
 extern Widget	 vimShell;
 extern Widget	 textArea;
 extern XtAppContext app_context;
@@ -202,16 +202,15 @@ workshop_get_editor_version()
  *	workshop_load_file
  *
  * Function:
  *	Load a given file into the WorkShop buffer.
  */
-/*ARGSUSED*/
     void
 workshop_load_file(
 	char	*filename,		/* the file to load */
 	int	 line,			/* an optional line number (or 0) */
-	char	*frameid)		/* used for multi-frame support */
+	char	*frameid UNUSED)	/* used for multi-frame support */
 {
 #ifdef WSDEBUG_TRACE
     if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
 	wstrace("workshop_load_file(%s, %d)\n", filename, line);
 #endif
@@ -261,14 +260,13 @@ workshop_goto_line(
 #endif
 
     load_window(filename, lineno);
 }
 
-/*ARGSUSED*/
     void
 workshop_front_file(
-	char	*filename)
+	char	*filename UNUSED)
 {
 #ifdef WSDEBUG_TRACE
     if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
 	wstrace("workshop_front_file()\n");
 #endif
@@ -536,13 +534,12 @@ workshop_adjust_marks(Widget *window, in
  * Are there any moved marks? If so, call workshop_move_mark on
  * each of them now. This is how eserve can find out if for example
  * breakpoints have moved when a program has been recompiled and
  * reloaded into dbx.
  */
-/*ARGSUSED*/
     void
-workshop_moved_marks(char *filename)
+workshop_moved_marks(char *filename UNUSED)
 {
 #ifdef WSDEBUG_TRACE
     if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
 	wstrace("XXXworkshop_moved_marks(%s)\n", filename);
 #endif
@@ -573,15 +570,14 @@ workshop_get_font_height()
     }
 
     return (int)h;
 }
 
-/*ARGSUSED*/
     void
 workshop_footer_message(
-	char		*message,
-	int		 severity)	/* severity is currently unused */
+	char	*message,
+	int	severity UNUSED)	/* severity is currently unused */
 {
 #ifdef WSDEBUG_TRACE
     if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
 	wstrace("workshop_footer_message(%s, %d)\n", message, severity);
 #endif
@@ -685,19 +681,18 @@ workshop_submenu_end()
 /*
  * This is where menus are really made. Each item will generate an amenu vim
  * command. The globals curMenuName and curMenuPriority contain the name and
  * priority of the parent menu tree.
  */
-/*ARGSUSED*/
     void
 workshop_menu_item(
 	char		*label,
 	char		*verb,
-	char		*accelerator,
+	char		*accelerator UNUSED,
 	char		*acceleratorText,
-	char		*name,
-	char		*filepos,
+	char		*name UNUSED,
+	char		*filepos UNUSED,
 	char		*sensitive)
 {
     char		 cbuf[BUFSIZ];
     char		 namebuf[BUFSIZ];
     char		 accText[BUFSIZ];
@@ -808,17 +803,16 @@ workshop_toolbar_end()
 	set_option_value((char_u *)"go", 0L, buf, 0);
     }
     workshopInitDone = True;
 }
 
-/*ARGSUSED*/
     void
 workshop_toolbar_button(
 	char	*label,
 	char	*verb,
-	char	*senseVerb,
-	char	*filepos,
+	char	*senseVerb UNUSED,
+	char	*filepos UNUSED,
 	char	*help,
 	char	*sense,
 	char	*file,
 	char	*left)
 {
@@ -966,11 +960,13 @@ workshop_set_option(
     {
 	case 's':
 	    if (strcmp(option, "syntax") == 0)
 		vim_snprintf(cbuf, sizeof(cbuf), "syntax %s", value);
 	    else if (strcmp(option, "savefiles") == 0)
-		; /* XXX - Not yet implemented */
+	    {
+		/* XXX - Not yet implemented */
+	    }
 	    break;
 
 	case 'l':
 	    if (strcmp(option, "lineno") == 0)
 		sprintf(cbuf, "set %snu",
@@ -1096,14 +1092,13 @@ workshop_hotkeys(
 }
 
 /*
  * A button in the toolbar has been pushed.
  */
-/*ARGSUSED*/
     int
 workshop_get_positions(
-	void		*clientData,	/* unused */
+	void		*clientData UNUSED,
 	char	       **filename,	/* output data */
 	int		*curLine,	/* output data */
 	int		*curCol,	/* output data */
 	int		*selStartLine,	/* output data */
 	int		*selStartCol,	/* output data */
@@ -1119,12 +1114,16 @@ workshop_get_positions(
 	wstrace("workshop_get_positions(%#x, \"%s\", ...)\n",
 		clientData, (curbuf && curbuf->b_sfname != NULL)
 				      ? (char *)curbuf->b_sfname : "<None>");
 #endif
 
-    strcpy(ffname, (char *) curbuf->b_ffname);
-    *filename = ffname;		/* copy so nobody can change b_ffname */
+    if (curbuf->b_ffname == NULL)
+	ffname[0] = NUL;
+    else
+	/* copy so nobody can change b_ffname */
+	strcpy(ffname, (char *) curbuf->b_ffname);
+    *filename = ffname;
     *curLine = curwin->w_cursor.lnum;
     *curCol = curwin->w_cursor.col;
 
     if (curbuf->b_visual.vi_mode == 'v' &&
 	    equalpos(curwin->w_cursor, curbuf->b_visual.vi_end))
@@ -1520,13 +1519,12 @@ workshop_test_getselectedtext()
 	return selection;
     else
 	return NULL;
 }
 
-/*ARGSUSED*/
     void
-workshop_save_sensitivity(char *filename)
+workshop_save_sensitivity(char *filename UNUSED)
 {
 }
 
 #endif
 
@@ -1624,12 +1622,10 @@ workshop_beval_cb(
 		workshop_send_message(buf);
 	    }
 	}
     }
 }
-#endif
-
 
     static int
 computeIndex(
 	int		 wantedCol,
 	char_u		*line,
@@ -1649,10 +1645,11 @@ computeIndex(
 	    return idx;
     }
 
     return -1;
 }
+#endif
 
     static void
 addMenu(
 	char		*menu,		/* menu name */
 	char		*accel,		/* accelerator text (optional) */
--- vim72.orig/src/xxd/Make_cyg.mak
+++ vim72/src/xxd/Make_cyg.mak
@@ -10,18 +10,19 @@ LIBS    = -lc
 else
 DEFINES = -mno-cygwin
 LIBS    =
 endif
 
+CC = gcc
 CFLAGS = -O2 -Wall -DWIN32 $(DEFINES)
 
 ifneq (sh.exe, $(SHELL))
 DEL = rm
 else
 DEL = del
 endif
 
 xxd.exe: xxd.c
-	gcc $(CFLAGS) -s -o xxd.exe xxd.c $(LIBS)
+	$(CC) $(CFLAGS) -s -o xxd.exe xxd.c $(LIBS)
 
 clean:
 	-$(DEL) xxd.exe
--- vim72.orig/src/xxd/xxd.c
+++ vim72/src/xxd/xxd.c
@@ -62,10 +62,13 @@
 /* Visual Studio 2005 has 'deprecated' many of the standard CRT functions */
 #if _MSC_VER >= 1400
 # define _CRT_SECURE_NO_DEPRECATE
 # define _CRT_NONSTDC_NO_DEPRECATE
 #endif
+#if !defined(CYGWIN) && (defined(CYGWIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__))
+# define CYGWIN
+#endif
 
 #include <stdio.h>
 #ifdef VAXC
 # include <file.h>
 #else
@@ -75,11 +78,12 @@
 # define MSDOS
 #endif
 #if !defined(OS2) && defined(__EMX__)
 # define OS2
 #endif
-#if defined(MSDOS) || defined(WIN32) || defined(OS2) || defined(__BORLANDC__)
+#if defined(MSDOS) || defined(WIN32) || defined(OS2) || defined(__BORLANDC__) \
+  || defined(CYGWIN)
 # include <io.h>	/* for setmode() */
 #else
 # ifdef UNIX
 #  include <unistd.h>
 # endif
@@ -148,13 +152,10 @@ char osver[] = " (dos 16 bit)";
 char osver[] = "";
 #  endif
 # endif
 #endif
 
-#if !defined(CYGWIN) && (defined(CYGWIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__))
-# define CYGWIN
-#endif
 #if defined(MSDOS) || defined(WIN32) || defined(OS2)
 # define BIN_READ(yes)  ((yes) ? "rb" : "rt")
 # define BIN_WRITE(yes) ((yes) ? "wb" : "wt")
 # define BIN_CREAT(yes) ((yes) ? (O_CREAT|O_BINARY) : O_CREAT)
 # define BIN_ASSIGN(fp, yes) setmode(fileno(fp), (yes) ? O_BINARY : O_TEXT)
@@ -228,11 +229,11 @@ char *pname;
 {
   fprintf(stderr, "Usage:\n       %s [options] [infile [outfile]]\n", pname);
   fprintf(stderr, "    or\n       %s -r [-s [-]offset] [-c cols] [-ps] [infile [outfile]]\n", pname);
   fprintf(stderr, "Options:\n");
   fprintf(stderr, "    -a          toggle autoskip: A single '*' replaces nul-lines. Default off.\n");
-  fprintf(stderr, "    -b          binary digit dump (incompatible with -p,-i,-r). Default hex.\n");
+  fprintf(stderr, "    -b          binary digit dump (incompatible with -ps,-i,-r). Default hex.\n");
   fprintf(stderr, "    -c cols     format <cols> octets per line. Default 16 (-i: 12, -ps: 30).\n");
   fprintf(stderr, "    -E          show characters in EBCDIC. Default ASCII.\n");
   fprintf(stderr, "    -g          number of octets per group in normal output. Default 2.\n");
   fprintf(stderr, "    -h          print this summary.\n");
   fprintf(stderr, "    -i          output in C include file style.\n");
@@ -273,15 +274,15 @@ long base_off;
   while ((c = getc(fpi)) != EOF)
     {
       if (c == '\r')	/* Doze style input file? */
 	continue;
 
-#if 0	/* this doesn't work when there is normal text after the hex codes in
-	   the last line that looks like hex */
-      if (c == ' ' || c == '\n' || c == '\t')  /* allow multiple spaces */
+      /* Allow multiple spaces.  This doesn't work when there is normal text
+       * after the hex codes in the last line that looks like hex, thus only
+       * use it for PostScript format. */
+      if (hextype == HEX_POSTSCRIPT && (c == ' ' || c == '\n' || c == '\t'))
 	continue;
-#endif
 
       n3 = n2;
       n2 = n1;
 
       if (c >= '0' && c <= '9')