Changeset c2aa910 for patches


Ignore:
Timestamp:
Oct 16, 2007, 2:17:12 PM (17 years ago)
Author:
Jim Gifford <clfs@…>
Branches:
clfs-1.2, clfs-2.1, clfs-3.0.0-systemd, clfs-3.0.0-sysvinit, master, systemd, sysvinit
Children:
2978738
Parents:
531a4c1
Message:

Updated vim patch

File:
1 moved

Legend:

Unmodified
Added
Removed
  • patches/vim-7.1-fixes-4.patch

    r531a4c1 rc2aa910  
    11Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
    2 Date: 09-03-2007
     2Date: 10-16-2007
    33Initial Package Version: 7.1
    44Origin: Upstream
    55Upstream Status: Applied
    6 Description: Contains all upstream patches up to 7.1.094
     6Description: Contains all upstream patches up to 7.1.140
    77             The following patches were skipped
    8             0 003 007 041 065 070 072 080 088 091 092
     8             003 007 041 065 070 072 080 088 091 092 124 126 128 129 134
    99
    1010diff -Naur vim71.orig/runtime/doc/change.txt vim71/runtime/doc/change.txt
    1111--- vim71.orig/runtime/doc/change.txt   2007-05-12 03:18:46.000000000 -0700
    12 +++ vim71/runtime/doc/change.txt        2007-09-03 22:13:15.000000000 -0700
     12+++ vim71/runtime/doc/change.txt        2007-10-16 14:14:06.000000000 -0700
    1313@@ -1571,6 +1571,10 @@
    1414                        in their original order, right before the sorted
     
    2424diff -Naur vim71.orig/runtime/doc/eval.txt vim71/runtime/doc/eval.txt
    2525--- vim71.orig/runtime/doc/eval.txt     2007-05-12 03:18:46.000000000 -0700
    26 +++ vim71/runtime/doc/eval.txt  2007-09-03 22:13:43.000000000 -0700
     26+++ vim71/runtime/doc/eval.txt  2007-10-16 14:14:28.000000000 -0700
    2727@@ -1,4 +1,4 @@
    2828-*eval.txt*      For Vim version 7.1.  Last change: 2007 May 11
    29 +*eval.txt*      For Vim version 7.1.  Last change: 2007 Jul 25
     29+*eval.txt*      For Vim version 7.1.  Last change: 2007 Sep 25
    3030 
    3131 
     
    3939 complete({startcol}, {matches})        String  set Insert mode completion
    4040 complete_add( {expr})          Number  add completion match
     41@@ -1602,7 +1603,7 @@
     42 foldtextresult( {lnum})                String  text for closed fold at {lnum}
     43 foreground( )                  Number  bring the Vim window to the foreground
     44 function( {name})              Funcref reference to function {name}
     45-garbagecollect()               none    free memory, breaking cyclic references
     46+garbagecollect( [at_exit])     none    free memory, breaking cyclic references
     47 get( {list}, {idx} [, {def}])  any     get item {idx} from {list} or {def}
     48 get( {dict}, {key} [, {def}])  any     get item {key} from {dict} or {def}
     49 getbufline( {expr}, {lnum} [, {end}])
    4150@@ -1622,6 +1623,7 @@
    4251 getline( {lnum})               String  line {lnum} of current buffer
     
    8897                |getpos()|.
    8998                For the screen column position use |virtcol()|.
    90 @@ -2824,6 +2838,8 @@
     99@@ -2659,7 +2673,7 @@
     100                {name} can be a user defined function or an internal function.
     101 
     102 
     103-garbagecollect()                                       *garbagecollect()*
     104+garbagecollect([at_exit])                              *garbagecollect()*
     105                Cleanup unused |Lists| and |Dictionaries| that have circular
     106                references.  There is hardly ever a need to invoke this
     107                function, as it is automatically done when Vim runs out of
     108@@ -2669,6 +2683,9 @@
     109                This is useful if you have deleted a very big |List| and/or
     110                |Dictionary| with circular references in a script that runs
     111                for a long time.
     112+               When the optional "at_exit" argument is one, garbage
     113+               collection will also be done when exiting Vim, if it wasn't
     114+               done before.  This is useful when checking for memory leaks.
     115 
     116 get({list}, {idx} [, {default}])                       *get()*
     117                Get item {idx} from |List| {list}.  When this item is not
     118@@ -2824,6 +2841,8 @@
    91119                given file {fname}.
    92120                If {fname} is a directory, 0 is returned.
     
    97125 getfontname([{name}])                                  *getfontname()*
    98126                Without an argument returns the name of the normal font being
    99 @@ -2912,6 +2928,28 @@
     127@@ -2912,6 +2931,28 @@
    100128                returned.  For an invalid window number {nr}, an empty list is
    101129                returned. Otherwise, same as getqflist().
     
    126154                Returns a list with all the current quickfix errors.  Each
    127155                list item is a dictionary with these entries:
    128 @@ -3616,6 +3654,44 @@
     156@@ -3616,6 +3657,44 @@
    129157                the pattern.  'smartcase' is NOT used.  The matching is always
    130158                done like 'magic' is set and 'cpoptions' is empty.
     
    171199 matcharg({nr})                                                 *matcharg()*
    172200                Selects the {nr} match item, as set with a |:match|,
    173 @@ -3625,8 +3701,15 @@
     201@@ -3625,8 +3704,15 @@
    174202                        The pattern used.
    175203                When {nr} is not 1, 2 or 3 returns an empty |List|.
     
    189217 matchend({expr}, {pat}[, {start}[, {count}]])                  *matchend()*
    190218                Same as match(), but return the index of first character after
    191 @@ -4379,7 +4462,13 @@
     219@@ -4379,7 +4465,13 @@
    192220                When {nr} is zero the current window is used. For a location
    193221                list window, the displayed location list is modified.  For an
     
    204232                                                        *setpos()*
    205233 setpos({expr}, {list})
    206 @@ -5022,14 +5111,12 @@
     234@@ -5022,14 +5114,12 @@
    207235                position, the returned Number will be the column at the end of
    208236                the <Tab>.  For example, for a <Tab> in column 1, with 'ts'
     
    224252diff -Naur vim71.orig/runtime/doc/options.txt vim71/runtime/doc/options.txt
    225253--- vim71.orig/runtime/doc/options.txt  2007-05-12 03:18:47.000000000 -0700
    226 +++ vim71/runtime/doc/options.txt       2007-09-03 22:14:47.000000000 -0700
     254+++ vim71/runtime/doc/options.txt       2007-10-16 14:14:12.000000000 -0700
    227255@@ -1,4 +1,4 @@
    228256-*options.txt*  For Vim version 7.1.  Last change: 2007 May 11
     
    244272diff -Naur vim71.orig/runtime/doc/pattern.txt vim71/runtime/doc/pattern.txt
    245273--- vim71.orig/runtime/doc/pattern.txt  2007-05-12 03:18:47.000000000 -0700
    246 +++ vim71/runtime/doc/pattern.txt       2007-09-03 22:13:43.000000000 -0700
     274+++ vim71/runtime/doc/pattern.txt       2007-10-16 14:14:07.000000000 -0700
    247275@@ -1212,7 +1212,10 @@
    248276                {group} must exist at the moment this command is executed.
     
    277305diff -Naur vim71.orig/runtime/doc/pi_paren.txt vim71/runtime/doc/pi_paren.txt
    278306--- vim71.orig/runtime/doc/pi_paren.txt 2007-05-12 03:18:47.000000000 -0700
    279 +++ vim71/runtime/doc/pi_paren.txt      2007-09-03 22:15:20.000000000 -0700
     307+++ vim71/runtime/doc/pi_paren.txt      2007-10-16 14:14:20.000000000 -0700
    280308@@ -12,8 +12,8 @@
    281309 You can avoid loading this plugin by setting the "loaded_matchparen" variable: >
     
    291319diff -Naur vim71.orig/runtime/doc/usr_41.txt vim71/runtime/doc/usr_41.txt
    292320--- vim71.orig/runtime/doc/usr_41.txt   2007-05-12 03:18:48.000000000 -0700
    293 +++ vim71/runtime/doc/usr_41.txt        2007-09-03 22:13:43.000000000 -0700
     321+++ vim71/runtime/doc/usr_41.txt        2007-10-16 14:14:07.000000000 -0700
    294322@@ -763,13 +763,22 @@
    295323        foldtextresult()        get the text displayed for a closed fold
     
    317345diff -Naur vim71.orig/runtime/doc/windows.txt vim71/runtime/doc/windows.txt
    318346--- vim71.orig/runtime/doc/windows.txt  2007-05-12 03:18:49.000000000 -0700
    319 +++ vim71/runtime/doc/windows.txt       2007-09-03 22:14:47.000000000 -0700
     347+++ vim71/runtime/doc/windows.txt       2007-10-16 14:14:12.000000000 -0700
    320348@@ -132,7 +132,8 @@
    321349                the same file.  Make new window N high (default is to use half
     
    347375diff -Naur vim71.orig/runtime/filetype.vim vim71/runtime/filetype.vim
    348376--- vim71.orig/runtime/filetype.vim     2007-05-10 08:14:37.000000000 -0700
    349 +++ vim71/runtime/filetype.vim  2007-09-03 22:12:17.000000000 -0700
     377+++ vim71/runtime/filetype.vim  2007-10-16 14:14:01.000000000 -0700
    350378@@ -1,7 +1,7 @@
    351379 " Vim support file to detect file types
     
    368396diff -Naur vim71.orig/runtime/plugin/matchparen.vim vim71/runtime/plugin/matchparen.vim
    369397--- vim71.orig/runtime/plugin/matchparen.vim    2006-10-12 13:05:05.000000000 -0700
    370 +++ vim71/runtime/plugin/matchparen.vim 2007-09-03 22:15:20.000000000 -0700
     398+++ vim71/runtime/plugin/matchparen.vim 2007-10-16 14:14:20.000000000 -0700
    371399@@ -1,6 +1,6 @@
    372400 " Vim plugin for showing matching parens
     
    450478diff -Naur vim71.orig/src/auto/configure vim71/src/auto/configure
    451479--- vim71.orig/src/auto/configure       2007-05-12 04:49:09.000000000 -0700
    452 +++ vim71/src/auto/configure    2007-09-03 22:12:46.000000000 -0700
     480+++ vim71/src/auto/configure    2007-10-16 14:14:06.000000000 -0700
    453481@@ -3843,7 +3843,9 @@
    454482   fi
     
    464492diff -Naur vim71.orig/src/buffer.c vim71/src/buffer.c
    465493--- vim71.orig/src/buffer.c     2007-05-10 08:25:59.000000000 -0700
    466 +++ vim71/src/buffer.c  2007-09-03 22:14:43.000000000 -0700
     494+++ vim71/src/buffer.c  2007-10-16 14:14:41.000000000 -0700
    467495@@ -171,6 +171,13 @@
    468496            /* Put the cursor on the first line. */
     
    507535     buf->b_ml.ml_mfp = NULL;
    508536     buf->b_ml.ml_flags = ML_EMPTY;             /* empty buffer */
    509 @@ -4853,7 +4861,7 @@
     537@@ -4167,29 +4175,35 @@
     538      * mess up the full path name, even though it starts with a '/'.
     539      * Also expand when there is ".." in the file name, try to remove it,
     540      * because "c:/src/../README" is equal to "c:/README".
     541+     * Similarly "c:/src//file" is equal to "c:/src/file".
     542      * For MS-Windows also expand names like "longna~1" to "longname".
     543      */
     544 #ifdef UNIX
     545     return FullName_save(fname, TRUE);
     546 #else
     547-    if (!vim_isAbsName(fname) || strstr((char *)fname, "..") != NULL
     548-#if defined(MSWIN) || defined(DJGPP)
     549+    if (!vim_isAbsName(fname)
     550+           || strstr((char *)fname, "..") != NULL
     551+           || strstr((char *)fname, "//") != NULL
     552+# ifdef BACKSLASH_IN_FILENAME
     553+           || strstr((char *)fname, "\\\\") != NULL
     554+# endif
     555+# if defined(MSWIN) || defined(DJGPP)
     556            || vim_strchr(fname, '~') != NULL
     557-#endif
     558+# endif
     559            )
     560        return FullName_save(fname, FALSE);
     561 
     562     fname = vim_strsave(fname);
     563 
     564-#ifdef USE_FNAME_CASE
     565-# ifdef USE_LONG_FNAME
     566+# ifdef USE_FNAME_CASE
     567+#  ifdef USE_LONG_FNAME
     568     if (USE_LONG_FNAME)
     569-# endif
     570+#  endif
     571     {
     572        if (fname != NULL)
     573            fname_case(fname, 0);       /* set correct case for file name */
     574     }
     575-#endif
     576+# endif
     577 
     578     return fname;
     579 #endif
     580@@ -4853,7 +4867,7 @@
    510581             */
    511582            for (e = s; *e != ':' && *e != NUL; ++e)
     
    516587                end = TRUE;
    517588 
     589@@ -5507,11 +5521,11 @@
     590 
     591 #ifdef FEAT_AUTOCMD
     592     if (!aucmd)                    /* Don't trigger BufDelete autocommands here. */
     593-       ++autocmd_block;
     594+       block_autocmds();
     595 #endif
     596     close_buffer(NULL, buf, DOBUF_WIPE);
     597 #ifdef FEAT_AUTOCMD
     598     if (!aucmd)
     599-       --autocmd_block;
     600+       unblock_autocmds();
     601 #endif
     602 }
    518603diff -Naur vim71.orig/src/charset.c vim71/src/charset.c
    519604--- vim71.orig/src/charset.c    2007-03-24 13:10:37.000000000 -0700
    520 +++ vim71/src/charset.c 2007-09-03 22:15:22.000000000 -0700
     605+++ vim71/src/charset.c 2007-10-16 14:14:20.000000000 -0700
    521606@@ -207,7 +207,10 @@
    522607            }
     
    566651diff -Naur vim71.orig/src/configure.in vim71/src/configure.in
    567652--- vim71.orig/src/configure.in 2007-05-12 02:19:27.000000000 -0700
    568 +++ vim71/src/configure.in      2007-09-03 22:12:46.000000000 -0700
     653+++ vim71/src/configure.in      2007-10-16 14:14:06.000000000 -0700
    569654@@ -423,7 +423,9 @@
    570655   fi
     
    578663     else
    579664       MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
     665diff -Naur vim71.orig/src/diff.c vim71/src/diff.c
     666--- vim71.orig/src/diff.c       2007-02-15 16:18:41.000000000 -0800
     667+++ vim71/src/diff.c    2007-10-16 14:14:31.000000000 -0700
     668@@ -840,11 +840,11 @@
     669                    tmp_orig, tmp_new);
     670            append_redir(cmd, p_srr, tmp_diff);
     671 #ifdef FEAT_AUTOCMD
     672-           ++autocmd_block;    /* Avoid ShellCmdPost stuff */
     673+           block_autocmds();   /* Avoid ShellCmdPost stuff */
     674 #endif
     675            (void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT);
     676 #ifdef FEAT_AUTOCMD
     677-           --autocmd_block;
     678+           unblock_autocmds();
     679 #endif
     680            vim_free(cmd);
     681        }
     682@@ -949,11 +949,11 @@
     683 # endif
     684                eap->arg);
     685 #ifdef FEAT_AUTOCMD
     686-       ++autocmd_block;        /* Avoid ShellCmdPost stuff */
     687+       block_autocmds();       /* Avoid ShellCmdPost stuff */
     688 #endif
     689        (void)call_shell(buf, SHELL_FILTER | SHELL_COOKED);
     690 #ifdef FEAT_AUTOCMD
     691-       --autocmd_block;
     692+       unblock_autocmds();
     693 #endif
     694     }
     695 
    580696diff -Naur vim71.orig/src/digraph.c vim71/src/digraph.c
    581697--- vim71.orig/src/digraph.c    2006-05-02 11:24:04.000000000 -0700
    582 +++ vim71/src/digraph.c 2007-09-03 22:13:01.000000000 -0700
     698+++ vim71/src/digraph.c 2007-10-16 14:14:28.000000000 -0700
     699@@ -2028,7 +2028,7 @@
     700 
     701     ++no_mapping;
     702     ++allow_keys;
     703-    c = safe_vgetc();
     704+    c = plain_vgetc();
     705     --no_mapping;
     706     --allow_keys;
     707     if (c != ESC)              /* ESC cancels CTRL-K */
     708@@ -2050,7 +2050,7 @@
     709 #endif
     710        ++no_mapping;
     711        ++allow_keys;
     712-       cc = safe_vgetc();
     713+       cc = plain_vgetc();
     714        --no_mapping;
     715        --allow_keys;
     716        if (cc != ESC)      /* ESC cancels CTRL-K */
    583717@@ -2349,8 +2349,10 @@
    584718 
     
    587721-       /* Stop any active keymap and clear the table. */
    588722+       /* Stop any active keymap and clear the table.  Also remove
    589 +        * b:keymap_unload, as no keymap is active now. */
     723+        * b:keymap_name, as no keymap is active now. */
    590724        keymap_unload();
    591725+       do_cmdline_cmd((char_u *)"unlet! b:keymap_name");
     
    603737diff -Naur vim71.orig/src/edit.c vim71/src/edit.c
    604738--- vim71.orig/src/edit.c       2007-05-07 12:43:55.000000000 -0700
    605 +++ vim71/src/edit.c    2007-09-03 22:14:45.000000000 -0700
     739+++ vim71/src/edit.c    2007-10-16 14:14:28.000000000 -0700
     740@@ -788,7 +788,7 @@
     741            ins_redraw(FALSE);
     742            ++no_mapping;
     743            ++allow_keys;
     744-           c = safe_vgetc();
     745+           c = plain_vgetc();
     746            --no_mapping;
     747            --allow_keys;
     748            if (c != Ctrl_N && c != Ctrl_G && c != Ctrl_O)
     749@@ -981,7 +981,7 @@
     750 #ifdef FEAT_NETBEANS_INTG
     751        case K_F21:     /* NetBeans command */
     752            ++no_mapping;               /* don't map the next key hits */
     753-           i = safe_vgetc();
     754+           i = plain_vgetc();
     755            --no_mapping;
     756            netbeans_keycommand(i);
     757            break;
    606758@@ -2057,7 +2057,6 @@
    607759  * case of the originally typed text is used, and the case of the completed
     
    668820+#ifdef FEAT_MBYTE
    669821+       if (has_mbyte)
    670 +       {
     822        {
     823-           for (idx = 0; idx < compl_length; ++idx)
    671824+           p = compl_orig_text;
    672825+           actual_compl_length = 0;
    673826+           while (*p != NUL)
    674 +           {
     827            {
     828-               if (was_letter && isupper(compl_orig_text[idx])
     829-                                                     && islower(IObuff[idx]))
    675830+               mb_ptr_adv(p);
    676831+               ++actual_compl_length;
     
    684839+       wca = (int *)alloc(actual_len * sizeof(int));
    685840+       if (wca != NULL)
    686         {
    687 -           for (idx = 0; idx < compl_length; ++idx)
     841+       {
    688842+           p = str;
    689843+           for (i = 0; i < actual_len; ++i)
     
    698852+           p = compl_orig_text;
    699853+           for (i = 0; i < actual_compl_length; ++i)
    700             {
    701 -               if (was_letter && isupper(compl_orig_text[idx])
    702 -                                                     && islower(IObuff[idx]))
     854+           {
    703855+#ifdef FEAT_MBYTE
    704856+               if (has_mbyte)
     
    825977                    }
    826978                    if (add_r == OK)
    827 @@ -7215,6 +7311,8 @@
     979@@ -5128,10 +5224,7 @@
     980     i = 0;
     981     for (;;)
     982     {
     983-       do
     984-           nc = safe_vgetc();
     985-       while (nc == K_IGNORE || nc == K_VER_SCROLLBAR
     986-                                                   || nc == K_HOR_SCROLLBAR);
     987+       nc = plain_vgetc();
     988 #ifdef FEAT_CMDL_INFO
     989        if (!(State & CMDLINE)
     990 # ifdef FEAT_MBYTE
     991@@ -7215,6 +7308,8 @@
    828992                p = ml_get_curline();
    829993                if (cin_iscase(p) || cin_isscopedecl(p) || cin_islabel(30))
     
    834998                        && p[curwin->w_cursor.col - 1] == ':'
    835999                        && p[curwin->w_cursor.col - 2] == ':')
    836 @@ -7998,7 +8096,8 @@
     1000@@ -7477,7 +7572,7 @@
     1001      * deleted when ESC is hit.
     1002      */
     1003     ++no_mapping;
     1004-    regname = safe_vgetc();
     1005+    regname = plain_vgetc();
     1006 #ifdef FEAT_LANGMAP
     1007     LANGMAP_ADJUST(regname, TRUE);
     1008 #endif
     1009@@ -7488,7 +7583,7 @@
     1010 #ifdef FEAT_CMDL_INFO
     1011        add_to_showcmd_c(literally);
     1012 #endif
     1013-       regname = safe_vgetc();
     1014+       regname = plain_vgetc();
     1015 #ifdef FEAT_LANGMAP
     1016        LANGMAP_ADJUST(regname, TRUE);
     1017 #endif
     1018@@ -7579,7 +7674,7 @@
     1019      * deleted when ESC is hit.
     1020      */
     1021     ++no_mapping;
     1022-    c = safe_vgetc();
     1023+    c = plain_vgetc();
     1024     --no_mapping;
     1025     switch (c)
     1026     {
     1027@@ -7998,7 +8093,8 @@
    8371028     /*
    8381029      * 0^D and ^^D: remove all indent.
     
    8441035        --curwin->w_cursor.col;
    8451036        (void)del_char(FALSE);          /* delete the '^' or '0' */
     1037@@ -9257,7 +9353,7 @@
     1038      * mode message to be deleted when ESC is hit */
     1039     ++no_mapping;
     1040     ++allow_keys;
     1041-    c = safe_vgetc();
     1042+    c = plain_vgetc();
     1043     --no_mapping;
     1044     --allow_keys;
     1045     if (IS_SPECIAL(c) || mod_mask)         /* special key */
     1046@@ -9289,7 +9385,7 @@
     1047        }
     1048        ++no_mapping;
     1049        ++allow_keys;
     1050-       cc = safe_vgetc();
     1051+       cc = plain_vgetc();
     1052        --no_mapping;
     1053        --allow_keys;
     1054        if (cc != ESC)
    8461055diff -Naur vim71.orig/src/eval.c vim71/src/eval.c
    8471056--- vim71.orig/src/eval.c       2007-05-07 12:47:32.000000000 -0700
    848 +++ vim71/src/eval.c    2007-09-03 22:15:36.000000000 -0700
     1057+++ vim71/src/eval.c    2007-10-16 14:14:38.000000000 -0700
    8491058@@ -369,17 +369,17 @@
    8501059 static int ex_let_vars __ARGS((char_u *arg, typval_T *tv, int copy, int semicolon, int var_count, char_u *nextchars));
     
    9541163     else
    9551164        var_redir_stop();
    956 @@ -1411,7 +1416,8 @@
     1165@@ -1313,7 +1318,6 @@
     1166 {
     1167     hashitem_T *hi;
     1168 
     1169-    clear_tv(&vimvars[idx].vv_tv);
     1170     vimvars[idx].vv_tv = *save_tv;
     1171     if (vimvars[idx].vv_type == VAR_UNKNOWN)
     1172     {
     1173@@ -1357,7 +1361,6 @@
     1174 
     1175     if (p_verbose == 0)
     1176        --emsg_off;
     1177-    vimvars[VV_VAL].vv_str = NULL;
     1178     restore_vimvar(VV_VAL, &save_val);
     1179 
     1180     return list;
     1181@@ -1411,7 +1414,8 @@
    9571182 }
    9581183 
     
    9641189  * Call some vimL function and return the result in "*rettv".
    9651190  * Uses argv[argc] for the function arguments.
    966 @@ -1484,6 +1490,7 @@
     1191@@ -1484,6 +1488,7 @@
    9671192     return ret;
    9681193 }
     
    9721197  * Call vimL function "func" and return the result as a string.
    9731198  * Returns NULL when calling the function fails.
    974 @@ -1506,8 +1513,9 @@
     1199@@ -1506,8 +1511,9 @@
    9751200     clear_tv(&rettv);
    9761201     return retval;
     
    9831208  * Call vimL function "func" and return the result as a number.
    9841209  * Returns -1 when calling the function fails.
    985 @@ -1530,7 +1538,7 @@
     1210@@ -1530,7 +1536,7 @@
    9861211     clear_tv(&rettv);
    9871212     return retval;
     
    9921217 /*
    9931218  * Call vimL function "func" and return the result as a list
    994 @@ -1556,9 +1564,9 @@
     1219@@ -1556,9 +1562,9 @@
    9951220 
    9961221     return rettv.vval.v_list;
     
    10031228  * Save the current function call pointer, and set it to NULL.
    10041229  * Used when executing autocommands and for ":source".
    1005 @@ -1691,6 +1699,7 @@
     1230@@ -1691,6 +1697,7 @@
    10061231     int                semicolon = 0;
    10071232     char_u     op[2];
     
    10111236     argend = skip_var_list(arg, &var_count, &semicolon);
    10121237     if (argend == NULL)
    1013 @@ -1707,19 +1716,19 @@
     1238@@ -1707,19 +1714,19 @@
    10141239            EMSG(_(e_invarg));
    10151240        else if (!ends_excmd(*arg))
     
    10391264        eap->nextcmd = check_nextcmd(arg);
    10401265     }
    1041 @@ -1924,10 +1933,11 @@
     1266@@ -1924,10 +1931,11 @@
    10421267  * If "empty" is TRUE also list NULL strings as empty strings.
    10431268  */
     
    10521277     hashitem_T *hi;
    10531278     dictitem_T *di;
    1054 @@ -1942,7 +1952,7 @@
     1279@@ -1942,7 +1950,7 @@
    10551280            di = HI2DI(hi);
    10561281            if (empty || di->di_tv.v_type != VAR_STRING
     
    10611286     }
    10621287 }
    1063 @@ -1951,32 +1961,38 @@
     1288@@ -1951,32 +1959,38 @@
    10641289  * List global variables.
    10651290  */
     
    11071332 
    11081333 #ifdef FEAT_WINDOWS
    1109 @@ -1984,9 +2000,11 @@
     1334@@ -1984,9 +1998,11 @@
    11101335  * List tab page variables.
    11111336  */
     
    11211346 #endif
    11221347 
    1123 @@ -1994,39 +2012,44 @@
     1348@@ -1994,39 +2010,44 @@
    11241349  * List Vim variables.
    11251350  */
     
    11731398     int                error = FALSE;
    11741399     int                len;
    1175 @@ -2083,15 +2106,15 @@
     1400@@ -2083,15 +2104,15 @@
    11761401                        {
    11771402                            switch (*name)
     
    11961421                                          EMSG2(_("E738: Can't list variables for %s"), name);
    11971422                            }
    1198 @@ -2108,7 +2131,9 @@
     1423@@ -2108,7 +2129,9 @@
    11991424                            *arg = NUL;
    12001425                            list_one_var_a((char_u *)"",
     
    12071432                            vim_free(tf);
    12081433                        }
    1209 @@ -6794,7 +6819,7 @@
     1434@@ -6105,6 +6128,7 @@
     1435     /* Only do this once. */
     1436     want_garbage_collect = FALSE;
     1437     may_garbage_collect = FALSE;
     1438+    garbage_collect_at_exit = FALSE;
     1439 
     1440     /*
     1441      * 1. Go through all accessible variables and mark all lists and dicts
     1442@@ -6681,7 +6705,7 @@
     1443     dict_T     *d = NULL;
     1444     typval_T   tvkey;
     1445     typval_T   tv;
     1446-    char_u     *key;
     1447+    char_u     *key = NULL;
     1448     dictitem_T *item;
     1449     char_u     *start = skipwhite(*arg + 1);
     1450     char_u     buf[NUMBUFLEN];
     1451@@ -6721,20 +6745,24 @@
     1452            clear_tv(&tvkey);
     1453            goto failret;
     1454        }
     1455-       key = get_tv_string_buf_chk(&tvkey, buf);
     1456-       if (key == NULL || *key == NUL)
     1457+       if (evaluate)
     1458        {
     1459-           /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */
     1460-           if (key != NULL)
     1461-               EMSG(_(e_emptykey));
     1462-           clear_tv(&tvkey);
     1463-           goto failret;
     1464+           key = get_tv_string_buf_chk(&tvkey, buf);
     1465+           if (key == NULL || *key == NUL)
     1466+           {
     1467+               /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */
     1468+               if (key != NULL)
     1469+                   EMSG(_(e_emptykey));
     1470+               clear_tv(&tvkey);
     1471+               goto failret;
     1472+           }
     1473        }
     1474 
     1475        *arg = skipwhite(*arg + 1);
     1476        if (eval1(arg, &tv, evaluate) == FAIL)  /* recursive! */
     1477        {
     1478-           clear_tv(&tvkey);
     1479+           if (evaluate)
     1480+               clear_tv(&tvkey);
     1481            goto failret;
     1482        }
     1483        if (evaluate)
     1484@@ -6794,7 +6822,7 @@
    12101485  * "numbuf" is used for a number.
    12111486  * Does not put quotes around strings, as ":echo" displays values.
     
    12161491     static char_u *
    12171492 echo_string(tv, tofree, numbuf, copyID)
    1218 @@ -6879,7 +6904,7 @@
     1493@@ -6879,7 +6907,7 @@
    12191494  * If the memory is allocated "tofree" is set to it, otherwise NULL.
    12201495  * "numbuf" is used for a number.
     
    12251500     static char_u *
    12261501 tv2string(tv, tofree, numbuf, copyID)
    1227 @@ -7043,6 +7068,7 @@
     1502@@ -7043,6 +7071,7 @@
    12281503     {"changenr",       0, 0, f_changenr},
    12291504     {"char2nr",                1, 1, f_char2nr},
     
    12331508 #if defined(FEAT_INS_EXPAND)
    12341509     {"complete",       2, 2, f_complete},
    1235 @@ -7099,6 +7125,7 @@
     1510@@ -7082,7 +7111,7 @@
     1511     {"foldtextresult", 1, 1, f_foldtextresult},
     1512     {"foreground",     0, 0, f_foreground},
     1513     {"function",       1, 1, f_function},
     1514-    {"garbagecollect", 0, 0, f_garbagecollect},
     1515+    {"garbagecollect", 0, 1, f_garbagecollect},
     1516     {"get",            2, 3, f_get},
     1517     {"getbufline",     2, 3, f_getbufline},
     1518     {"getbufvar",      2, 2, f_getbufvar},
     1519@@ -7099,6 +7128,7 @@
    12361520     {"getftype",       1, 1, f_getftype},
    12371521     {"getline",                1, 2, f_getline},
     
    12411525     {"getqflist",      0, 0, f_getqflist},
    12421526     {"getreg",         0, 2, f_getreg},
    1243 @@ -7149,7 +7176,9 @@
     1527@@ -7149,7 +7179,9 @@
    12441528     {"maparg",         1, 3, f_maparg},
    12451529     {"mapcheck",       1, 3, f_mapcheck},
     
    12511535     {"matchlist",      2, 4, f_matchlist},
    12521536     {"matchstr",       2, 4, f_matchstr},
    1253 @@ -7190,6 +7219,7 @@
     1537@@ -7190,6 +7222,7 @@
    12541538     {"setcmdpos",      1, 1, f_setcmdpos},
    12551539     {"setline",                2, 2, f_setline},
     
    12591543     {"setqflist",      1, 2, f_setqflist},
    12601544     {"setreg",         2, 3, f_setreg},
    1261 @@ -8240,6 +8270,20 @@
     1545@@ -8240,6 +8273,20 @@
    12621546 }
    12631547 
     
    12801564  */
    12811565     static void
    1282 @@ -10136,7 +10180,13 @@
     1566@@ -9339,15 +9386,16 @@
     1567 {
     1568     typval_T   rettv;
     1569     char_u     *s;
     1570+    int                retval = FAIL;
     1571 
     1572     copy_tv(tv, &vimvars[VV_VAL].vv_tv);
     1573     s = expr;
     1574     if (eval1(&s, &rettv, TRUE) == FAIL)
     1575-       return FAIL;
     1576+       goto theend;
     1577     if (*s != NUL)  /* check for trailing chars after expr */
     1578     {
     1579        EMSG2(_(e_invexpr2), s);
     1580-       return FAIL;
     1581+       goto theend;
     1582     }
     1583     if (map)
     1584     {
     1585@@ -9366,10 +9414,12 @@
     1586        /* On type error, nothing has been removed; return FAIL to stop the
     1587         * loop.  The error message was given by get_tv_number_chk(). */
     1588        if (error)
     1589-           return FAIL;
     1590+           goto theend;
     1591     }
     1592+    retval = OK;
     1593+theend:
     1594     clear_tv(&vimvars[VV_VAL].vv_tv);
     1595-    return OK;
     1596+    return retval;
     1597 }
     1598 
     1599 /*
     1600@@ -9670,6 +9720,9 @@
     1601     /* This is postponed until we are back at the toplevel, because we may be
     1602      * using Lists and Dicts internally.  E.g.: ":echo [garbagecollect()]". */
     1603     want_garbage_collect = TRUE;
     1604+
     1605+    if (argvars[0].v_type != VAR_UNKNOWN && get_tv_number(&argvars[0]) == 1)
     1606+       garbage_collect_at_exit = TRUE;
     1607 }
     1608 
     1609 /*
     1610@@ -9868,18 +9921,24 @@
     1611 
     1612     ++no_mapping;
     1613     ++allow_keys;
     1614-    if (argvars[0].v_type == VAR_UNKNOWN)
     1615-       /* getchar(): blocking wait. */
     1616-       n = safe_vgetc();
     1617-    else if (get_tv_number_chk(&argvars[0], &error) == 1)
     1618-       /* getchar(1): only check if char avail */
     1619-       n = vpeekc();
     1620-    else if (error || vpeekc() == NUL)
     1621-       /* illegal argument or getchar(0) and no char avail: return zero */
     1622-       n = 0;
     1623-    else
     1624-       /* getchar(0) and char avail: return char */
     1625-       n = safe_vgetc();
     1626+    for (;;)
     1627+    {
     1628+       if (argvars[0].v_type == VAR_UNKNOWN)
     1629+           /* getchar(): blocking wait. */
     1630+           n = safe_vgetc();
     1631+       else if (get_tv_number_chk(&argvars[0], &error) == 1)
     1632+           /* getchar(1): only check if char avail */
     1633+           n = vpeekc();
     1634+       else if (error || vpeekc() == NUL)
     1635+           /* illegal argument or getchar(0) and no char avail: return zero */
     1636+           n = 0;
     1637+       else
     1638+           /* getchar(0) and char avail: return char */
     1639+           n = safe_vgetc();
     1640+       if (n == K_IGNORE)
     1641+           continue;
     1642+       break;
     1643+    }
     1644     --no_mapping;
     1645     --allow_keys;
     1646 
     1647@@ -10136,7 +10195,13 @@
    12831648        if (mch_isdir(fname))
    12841649            rettv->vval.v_number = 0;
     
    12941659     else
    12951660          rettv->vval.v_number = -1;
    1296 @@ -10269,6 +10319,40 @@
     1661@@ -10269,6 +10334,39 @@
    12971662 }
    12981663 
     
    13191684+           if (dict == NULL)
    13201685+               return;
    1321 +           ++dict->dv_refcount;
    13221686+           dict_add_nr_str(dict, "group", 0L, syn_id2name(cur->hlg_id));
    13231687+           dict_add_nr_str(dict, "pattern", 0L, cur->pattern);
     
    13351699  */
    13361700     static void
    1337 @@ -12439,6 +12523,44 @@
     1701@@ -10290,7 +10388,8 @@
     1702            list_append_number(l, (varnumber_T)0);
     1703        list_append_number(l, (fp != NULL) ? (varnumber_T)fp->lnum
     1704                                                            : (varnumber_T)0);
     1705-       list_append_number(l, (fp != NULL) ? (varnumber_T)fp->col + 1
     1706+       list_append_number(l, (fp != NULL)
     1707+                    ? (varnumber_T)(fp->col == MAXCOL ? MAXCOL : fp->col + 1)
     1708                                                            : (varnumber_T)0);
     1709        list_append_number(l,
     1710 #ifdef FEAT_VIRTUALEDIT
     1711@@ -10785,6 +10884,9 @@
     1712        "gui_gtk2",
     1713 # endif
     1714 #endif
     1715+#ifdef FEAT_GUI_GNOME
     1716+       "gui_gnome",
     1717+#endif
     1718 #ifdef FEAT_GUI_MAC
     1719        "gui_mac",
     1720 #endif
     1721@@ -11471,14 +11573,12 @@
     1722     char_u     *xp_arg = NULL;
     1723 
     1724     rettv->v_type = VAR_STRING;
     1725+    rettv->vval.v_string = NULL;
     1726 
     1727 #ifdef NO_CONSOLE_INPUT
     1728     /* While starting up, there is no place to enter text. */
     1729     if (no_console_input())
     1730-    {
     1731-       rettv->vval.v_string = NULL;
     1732        return;
     1733-    }
     1734 #endif
     1735 
     1736     cmd_silent = FALSE;                /* Want to see the prompt. */
     1737@@ -12439,6 +12539,44 @@
    13381738 }
    13391739 
     
    13801780  */
    13811781     static void
    1382 @@ -12449,20 +12571,42 @@
     1782@@ -12449,20 +12587,42 @@
    13831783     if (rettv_list_alloc(rettv) == OK)
    13841784     {
     
    14291829  */
    14301830     static void
    1431 @@ -13680,7 +13824,7 @@
     1831@@ -13680,7 +13840,7 @@
    14321832            }
    14331833            /* Shorten "remain". */
     
    14381838            {
    14391839                vim_free(remain);
    1440 @@ -13919,6 +14063,8 @@
     1840@@ -13919,6 +14079,8 @@
    14411841     /* If 'n' flag is used: restore cursor position. */
    14421842     if (flags & SP_NOMOVE)
     
    14471847     p_ws = save_p_ws;
    14481848 
    1449 @@ -14498,6 +14644,66 @@
     1849@@ -14498,6 +14660,66 @@
    14501850 }
    14511851 
     
    15141914  */
    15151915 /*ARGSUSED*/
    1516 @@ -14785,6 +14991,10 @@
     1916@@ -14785,6 +15007,10 @@
    15171917 
    15181918     p1 = tv2string(&(*(listitem_T **)s1)->li_tv, &tofree1, numbuf1, 0);
     
    15251925        res = STRICMP(p1, p2);
    15261926     else
    1527 @@ -15274,7 +15484,8 @@
     1927@@ -15274,7 +15500,8 @@
    15281928 
    15291929     rettv->v_type = VAR_STRING;
     
    15351935 }
    15361936 
    1537 @@ -16497,9 +16708,9 @@
     1937@@ -16497,9 +16724,9 @@
    15381938  * Returns NULL when there is an error.
    15391939  */
     
    15471947 {
    15481948     char_u             *name;
    1549 @@ -16512,6 +16723,7 @@
     1949@@ -16512,6 +16739,7 @@
    15501950        list_T          *l;
    15511951        int             len;
     
    15551955        l = varp->vval.v_list;
    15561956        if (l == NULL)
    1557 @@ -16527,6 +16739,14 @@
     1957@@ -16527,6 +16755,14 @@
    15581958        if (error)
    15591959            return NULL;
     
    15701970        if (pos.col == 0 || (int)pos.col > len + 1)
    15711971            return NULL;        /* invalid column number */
    1572 @@ -16559,7 +16779,7 @@
     1972@@ -16559,7 +16795,7 @@
    15731973     pos.coladd = 0;
    15741974 #endif
     
    15791979        pos.col = 0;
    15801980        if (name[1] == '0')             /* "w0": first visible line */
    1581 @@ -16577,7 +16797,7 @@
     1981@@ -16577,7 +16813,7 @@
    15821982     }
    15831983     else if (name[0] == '$')           /* last column or line */
     
    15881988            pos.lnum = curbuf->b_ml.ml_line_count;
    15891989            pos.col = 0;
    1590 @@ -17798,9 +18018,10 @@
     1990@@ -17798,9 +18034,10 @@
    15911991  * List the value of one internal variable.
    15921992  */
     
    16002000     char_u     *tofree;
    16012001     char_u     *s;
    1602 @@ -17808,18 +18029,21 @@
     2002@@ -17808,18 +18045,21 @@
    16032003 
    16042004     s = echo_string(&v->di_tv, &tofree, numbuf, ++current_copyID);
     
    16252025        msg_puts(name);
    16262026     msg_putchar(' ');
    1627 @@ -17847,6 +18071,11 @@
     2027@@ -17847,6 +18087,11 @@
    16282028 
    16292029     if (type == VAR_FUNC)
     
    16372037 
    16382038 /*
    1639 @@ -19969,6 +20198,7 @@
     2039@@ -19136,6 +19381,28 @@
     2040        goto theend;
     2041     }
     2042 
     2043+    /* Check if the name is a Funcref.  If so, use the value. */
     2044+    if (lv.ll_exp_name != NULL)
     2045+    {
     2046+       len = (int)STRLEN(lv.ll_exp_name);
     2047+       name = deref_func_name(lv.ll_exp_name, &len);
     2048+       if (name == lv.ll_exp_name)
     2049+           name = NULL;
     2050+    }
     2051+    else
     2052+    {
     2053+       len = (int)(end - *pp);
     2054+       name = deref_func_name(*pp, &len);
     2055+       if (name == *pp)
     2056+           name = NULL;
     2057+    }
     2058+    if (name != NULL)
     2059+    {
     2060+       name = vim_strsave(name);
     2061+       *pp = end;
     2062+       goto theend;
     2063+    }
     2064+
     2065     if (lv.ll_exp_name != NULL)
     2066     {
     2067        len = (int)STRLEN(lv.ll_exp_name);
     2068@@ -19969,6 +20236,7 @@
    16402069                char_u  buf[MSG_BUF_LEN];
    16412070                char_u  numbuf2[NUMBUFLEN];
     
    16452074                msg_puts((char_u *)"(");
    16462075                for (i = 0; i < argcount; ++i)
    1647 @@ -19979,10 +20209,13 @@
     2076@@ -19979,10 +20247,13 @@
    16482077                        msg_outnum((long)argvars[i].vval.v_number);
    16492078                    else
     
    16632092                }
    16642093                msg_puts((char_u *)")");
    1665 @@ -20060,14 +20293,18 @@
     2094@@ -20060,14 +20331,18 @@
    16662095            char_u      buf[MSG_BUF_LEN];
    16672096            char_u      numbuf2[NUMBUFLEN];
     
    16862115        msg_puts((char_u *)"\n");   /* don't overwrite this either */
    16872116 
     2117@@ -21034,14 +21309,27 @@
     2118        *usedlen += 2;
     2119        s = get_past_head(*fnamep);
     2120        while (tail > s && after_pathsep(s, tail))
     2121-           --tail;
     2122+           mb_ptr_back(*fnamep, tail);
     2123        *fnamelen = (int)(tail - *fnamep);
     2124 #ifdef VMS
     2125        if (*fnamelen > 0)
     2126            *fnamelen += 1; /* the path separator is part of the path */
     2127 #endif
     2128-       while (tail > s && !after_pathsep(s, tail))
     2129-           mb_ptr_back(*fnamep, tail);
     2130+       if (*fnamelen == 0)
     2131+       {
     2132+           /* Result is empty.  Turn it into "." to make ":cd %:h" work. */
     2133+           p = vim_strsave((char_u *)".");
     2134+           if (p == NULL)
     2135+               return -1;
     2136+           vim_free(*bufp);
     2137+           *bufp = *fnamep = tail = p;
     2138+           *fnamelen = 1;
     2139+       }
     2140+       else
     2141+       {
     2142+           while (tail > s && !after_pathsep(s, tail))
     2143+               mb_ptr_back(*fnamep, tail);
     2144+       }
     2145     }
     2146 
     2147     /* ":8" - shortname  */
    16882148diff -Naur vim71.orig/src/ex_cmds.c vim71/src/ex_cmds.c
    16892149--- vim71.orig/src/ex_cmds.c    2007-05-07 12:41:01.000000000 -0700
    1690 +++ vim71/src/ex_cmds.c 2007-09-03 22:15:26.000000000 -0700
     2150+++ vim71/src/ex_cmds.c 2007-10-16 14:14:28.000000000 -0700
    16912151@@ -408,7 +408,11 @@
    16922152                goto sortend;
     
    18262286     }
    18272287     while (*cmd)
     2288@@ -4464,7 +4498,7 @@
     2289             *
     2290             * The new text is built up in new_start[].  It has some extra
     2291             * room to avoid using alloc()/free() too often.  new_start_len is
     2292-            * the lenght of the allocated memory at new_start.
     2293+            * the length of the allocated memory at new_start.
     2294             *
     2295             * Make a copy of the old line, so it won't be taken away when
     2296             * updating the screen or handling a multi-line match.  The "old_"
     2297@@ -4635,7 +4669,7 @@
     2298 #endif
     2299                            ++no_mapping;       /* don't map this key */
     2300                            ++allow_keys;       /* allow special keys */
     2301-                           i = safe_vgetc();
     2302+                           i = plain_vgetc();
     2303                            --allow_keys;
     2304                            --no_mapping;
     2305 
    18282306@@ -6351,9 +6385,9 @@
    18292307        for (i = 0; i < ga.ga_len; ++i)
     
    18402318diff -Naur vim71.orig/src/ex_docmd.c vim71/src/ex_docmd.c
    18412319--- vim71.orig/src/ex_docmd.c   2007-05-07 12:49:38.000000000 -0700
    1842 +++ vim71/src/ex_docmd.c        2007-09-03 22:15:22.000000000 -0700
     2320+++ vim71/src/ex_docmd.c        2007-10-16 14:14:28.000000000 -0700
    18432321@@ -133,6 +133,7 @@
    18442322 static void    get_flags __ARGS((exarg_T *eap));
     
    19952473  * Function called for script command which is Not Implemented.  NI!
    19962474  * Skips over ":perl <<EOF" constructs.
     2475@@ -4376,7 +4403,7 @@
     2476                            || vim_strchr(eap->arg, '~') != NULL)
     2477                    {
     2478                        expand_env_esc(eap->arg, NameBuff, MAXPATHL,
     2479-                                                                TRUE, NULL);
     2480+                                                           TRUE, TRUE, NULL);
     2481                        has_wildcards = mch_has_wildcard(NameBuff);
     2482                        p = NameBuff;
     2483                    }
    19972484@@ -4492,7 +4519,8 @@
    19982485            if (eap->argt & (USECTRLV | XFILE))
     
    20722559diff -Naur vim71.orig/src/ex_eval.c vim71/src/ex_eval.c
    20732560--- vim71.orig/src/ex_eval.c    2007-05-07 12:47:50.000000000 -0700
    2074 +++ vim71/src/ex_eval.c 2007-09-03 22:13:59.000000000 -0700
     2561+++ vim71/src/ex_eval.c 2007-10-16 14:14:09.000000000 -0700
    20752562@@ -1551,7 +1551,7 @@
    20762563                }
     
    20842571diff -Naur vim71.orig/src/ex_getln.c vim71/src/ex_getln.c
    20852572--- vim71.orig/src/ex_getln.c   2007-05-07 12:47:23.000000000 -0700
    2086 +++ vim71/src/ex_getln.c        2007-09-03 22:14:17.000000000 -0700
     2573+++ vim71/src/ex_getln.c        2007-10-16 14:14:34.000000000 -0700
    20872574@@ -268,7 +268,9 @@
    20882575     {
     
    21202607            {
    21212608                /* go down a directory */
     2609@@ -636,7 +641,7 @@
     2610        {
     2611            ++no_mapping;
     2612            ++allow_keys;
     2613-           c = safe_vgetc();
     2614+           c = plain_vgetc();
     2615            --no_mapping;
     2616            --allow_keys;
     2617            /* CTRL-\ e doesn't work when obtaining an expression. */
    21222618@@ -730,8 +735,8 @@
    21232619            /* In Ex mode a backslash escapes a newline. */
     
    21302626            {
    21312627                if (c == K_KENTER)
     2628@@ -1086,11 +1091,11 @@
     2629 #endif
     2630                putcmdline('"', TRUE);
     2631                ++no_mapping;
     2632-               i = c = safe_vgetc();   /* CTRL-R <char> */
     2633+               i = c = plain_vgetc();  /* CTRL-R <char> */
     2634                if (i == Ctrl_O)
     2635                    i = Ctrl_R;         /* CTRL-R CTRL-O == CTRL-R CTRL-R */
     2636                if (i == Ctrl_R)
     2637-                   c = safe_vgetc();   /* CTRL-R CTRL-R <char> */
     2638+                   c = plain_vgetc();  /* CTRL-R CTRL-R <char> */
     2639                --no_mapping;
     2640 #ifdef FEAT_EVAL
     2641                /*
    21322642@@ -2090,11 +2095,11 @@
    21332643     garray_T   line_ga;
     
    21762686            msg_putchar('\n');
    21772687        else if (c1 == TAB)
    2178 @@ -4148,13 +4153,19 @@
     2688@@ -3311,6 +3316,10 @@
     2689  * Return a pointer to alloced memory containing the new string.
     2690  * Return NULL for failure.
     2691  *
     2692+ * "orig" is the originally expanded string, copied to allocated memory.  It
     2693+ * should either be kept in orig_save or freed.  When "mode" is WILD_NEXT or
     2694+ * WILD_PREV "orig" should be NULL.
     2695+ *
     2696  * Results are cached in xp->xp_files and xp->xp_numfiles, except when "mode"
     2697  * is WILD_EXPAND_FREE or WILD_ALL.
     2698  *
     2699@@ -3395,7 +3404,7 @@
     2700            return NULL;
     2701     }
     2702 
     2703-/* free old names */
     2704+    /* free old names */
     2705     if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
     2706     {
     2707        FreeWild(xp->xp_numfiles, xp->xp_files);
     2708@@ -3536,6 +3545,10 @@
     2709     if (mode == WILD_EXPAND_FREE || mode == WILD_ALL)
     2710        ExpandCleanup(xp);
     2711 
     2712+    /* Free "orig" if it wasn't stored in "orig_save". */
     2713+    if (orig != orig_save)
     2714+       vim_free(orig);
     2715+
     2716     return ss;
     2717 }
     2718 
     2719@@ -4148,13 +4161,19 @@
    21792720 
    21802721 #ifdef FEAT_EVAL
     
    21962737     else
    21972738 #endif
    2198 @@ -4295,10 +4306,11 @@
     2739@@ -4295,10 +4314,11 @@
    21992740                            && pat[i + 1] == '\\'
    22002741                            && pat[i + 2] == '\\'
     
    22102751        }
    22112752 
    2212 @@ -4502,6 +4514,12 @@
     2753@@ -4502,6 +4522,12 @@
    22132754     if (xp->xp_context != EXPAND_MENUNAMES && xp->xp_context != EXPAND_MENUS)
    22142755        sort_strings(*file, *num_file);
     
    22232764 }
    22242765 
    2225 @@ -4535,7 +4553,7 @@
     2766@@ -4535,7 +4561,7 @@
    22262767     pat = vim_strsave(filepat);
    22272768     for (i = 0; pat[i]; ++i)
     
    22322773     flags |= EW_FILE | EW_EXEC;
    22332774 
     2775@@ -5907,7 +5933,7 @@
     2776 
     2777 # ifdef FEAT_AUTOCMD
     2778     /* Don't execute autocommands while creating the window. */
     2779-    ++autocmd_block;
     2780+    block_autocmds();
     2781 # endif
     2782     /* don't use a new tab page */
     2783     cmdmod.tab = 0;
     2784@@ -5916,6 +5942,9 @@
     2785     if (win_split((int)p_cwh, WSP_BOT) == FAIL)
     2786     {
     2787        beep_flush();
     2788+# ifdef FEAT_AUTOCMD
     2789+       unblock_autocmds();
     2790+# endif
     2791        return K_IGNORE;
     2792     }
     2793     cmdwin_type = ccline.cmdfirstc;
     2794@@ -5938,7 +5967,7 @@
     2795 
     2796 # ifdef FEAT_AUTOCMD
     2797     /* Do execute autocommands for setting the filetype (load syntax). */
     2798-    --autocmd_block;
     2799+    unblock_autocmds();
     2800 # endif
     2801 
     2802     /* Showing the prompt may have set need_wait_return, reset it. */
     2803@@ -6092,7 +6121,7 @@
     2804 
     2805 # ifdef FEAT_AUTOCMD
     2806        /* Don't execute autocommands while deleting the window. */
     2807-       ++autocmd_block;
     2808+       block_autocmds();
     2809 # endif
     2810        wp = curwin;
     2811        bp = curbuf;
     2812@@ -6104,7 +6133,7 @@
     2813        win_size_restore(&winsizes);
     2814 
     2815 # ifdef FEAT_AUTOCMD
     2816-       --autocmd_block;
     2817+       unblock_autocmds();
     2818 # endif
     2819     }
     2820 
    22342821diff -Naur vim71.orig/src/feature.h vim71/src/feature.h
    22352822--- vim71.orig/src/feature.h    2007-05-07 12:33:19.000000000 -0700
    2236 +++ vim71/src/feature.h 2007-09-03 22:14:03.000000000 -0700
     2823+++ vim71/src/feature.h 2007-10-16 14:14:09.000000000 -0700
    22372824@@ -673,7 +673,7 @@
    22382825 # define ESC_CHG_TO_ENG_MODE           /* if defined, when ESC pressed,
     
    22462833diff -Naur vim71.orig/src/fileio.c vim71/src/fileio.c
    22472834--- vim71.orig/src/fileio.c     2007-05-10 04:29:44.000000000 -0700
    2248 +++ vim71/src/fileio.c  2007-09-03 22:14:43.000000000 -0700
     2835+++ vim71/src/fileio.c  2007-10-16 14:14:38.000000000 -0700
    22492836@@ -44,6 +44,10 @@
    22502837 /* Is there any system that doesn't have access()? */
     
    24012988        {
    24022989            if (vim_strchr(p_cpo, CPO_FWRITE) != NULL)
     2990@@ -5495,6 +5553,8 @@
     2991 }
     2992 #endif
     2993 
     2994+#if defined(FEAT_VIMINFO) || defined(FEAT_BROWSE) || \
     2995+    defined(FEAT_QUICKFIX) || defined(PROTO)
     2996 /*
     2997  * Try to find a shortname by comparing the fullname with the current
     2998  * directory.
     2999@@ -5548,6 +5608,7 @@
     3000        p = NULL;
     3001     return p;
     3002 }
     3003+#endif
     3004 
     3005 /*
     3006  * Shorten filenames for all buffers.
     3007@@ -7107,6 +7168,7 @@
     3008 
     3009 static event_T last_event;
     3010 static int     last_group;
     3011+static int     autocmd_blocked = 0;    /* block all autocmds */
     3012 
     3013 /*
     3014  * Show the autocommands for one AutoPat.
     3015@@ -8396,7 +8458,7 @@
     3016      * Quickly return if there are no autocommands for this event or
     3017      * autocommands are blocked.
     3018      */
     3019-    if (first_autopat[(int)event] == NULL || autocmd_block > 0)
     3020+    if (first_autopat[(int)event] == NULL || autocmd_blocked > 0)
     3021        goto BYPASS_AU;
     3022 
     3023     /*
     3024@@ -8710,6 +8772,40 @@
     3025     return retval;
     3026 }
     3027 
     3028+# ifdef FEAT_EVAL
     3029+static char_u  *old_termresponse = NULL;
     3030+# endif
     3031+
     3032+/*
     3033+ * Block triggering autocommands until unblock_autocmd() is called.
     3034+ * Can be used recursively, so long as it's symmetric.
     3035+ */
     3036+    void
     3037+block_autocmds()
     3038+{
     3039+# ifdef FEAT_EVAL
     3040+    /* Remember the value of v:termresponse. */
     3041+    if (autocmd_blocked == 0)
     3042+       old_termresponse = get_vim_var_str(VV_TERMRESPONSE);
     3043+# endif
     3044+    ++autocmd_blocked;
     3045+}
     3046+
     3047+    void
     3048+unblock_autocmds()
     3049+{
     3050+    --autocmd_blocked;
     3051+
     3052+# ifdef FEAT_EVAL
     3053+    /* When v:termresponse was set while autocommands were blocked, trigger
     3054+     * the autocommands now.  Esp. useful when executing a shell command
     3055+     * during startup (vimdiff). */
     3056+    if (autocmd_blocked == 0
     3057+                     && get_vim_var_str(VV_TERMRESPONSE) != old_termresponse)
     3058+       apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf);
     3059+# endif
     3060+}
     3061+
     3062 /*
     3063  * Find next autocommand pattern that matches.
     3064  */
     3065diff -Naur vim71.orig/src/fold.c vim71/src/fold.c
     3066--- vim71.orig/src/fold.c       2007-05-07 12:46:32.000000000 -0700
     3067+++ vim71/src/fold.c    2007-10-16 14:14:41.000000000 -0700
     3068@@ -858,7 +858,14 @@
     3069            || foldmethodIsDiff(wp)
     3070 #endif
     3071            || foldmethodIsSyntax(wp))
     3072+    {
     3073+       int save_got_int = got_int;
     3074+
     3075+       /* reset got_int here, otherwise it won't work */
     3076+       got_int = FALSE;
     3077        foldUpdateIEMS(wp, top, bot);
     3078+       got_int |= save_got_int;
     3079+    }
     3080 }
     3081 
     3082 /* foldUpdateAll() {{{2 */
     3083diff -Naur vim71.orig/src/getchar.c vim71/src/getchar.c
     3084--- vim71.orig/src/getchar.c    2007-05-07 12:18:20.000000000 -0700
     3085+++ vim71/src/getchar.c 2007-10-16 14:14:28.000000000 -0700
     3086@@ -1596,8 +1596,16 @@
     3087                continue;
     3088            }
     3089 #endif
     3090-
     3091 #ifdef FEAT_GUI
     3092+           /* Handle focus event here, so that the caller doesn't need to
     3093+            * know about it.  Return K_IGNORE so that we loop once (needed if
     3094+            * 'lazyredraw' is set). */
     3095+           if (c == K_FOCUSGAINED || c == K_FOCUSLOST)
     3096+           {
     3097+               ui_focus_change(c == K_FOCUSGAINED);
     3098+               c = K_IGNORE;
     3099+           }
     3100+
     3101            /* Translate K_CSI to CSI.  The special key is only used to avoid
     3102             * it being recognized as the start of a special key. */
     3103            if (c == K_CSI)
     3104@@ -1741,6 +1749,22 @@
     3105 }
     3106 
     3107 /*
     3108+ * Like safe_vgetc(), but loop to handle K_IGNORE.
     3109+ * Also ignore scrollbar events.
     3110+ */
     3111+    int
     3112+plain_vgetc()
     3113+{
     3114+    int c;
     3115+
     3116+    do
     3117+    {
     3118+       c = safe_vgetc();
     3119+    } while (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR);
     3120+    return c;
     3121+}
     3122+
     3123+/*
     3124  * Check if a character is available, such that vgetc() will not block.
     3125  * If the next character is a special character or multi-byte, the returned
     3126  * character is not valid!.
    24033127diff -Naur vim71.orig/src/globals.h vim71/src/globals.h
    24043128--- vim71.orig/src/globals.h    2007-05-07 12:44:26.000000000 -0700
    2405 +++ vim71/src/globals.h 2007-09-03 22:15:45.000000000 -0700
    2406 @@ -801,7 +801,7 @@
     3129+++ vim71/src/globals.h 2007-10-16 14:14:31.000000000 -0700
     3130@@ -301,13 +301,17 @@
     3131 #endif
     3132 
     3133 #ifdef FEAT_EVAL
     3134-/* Garbage collection can only take place when we are sure there are no Lists
     3135+/*
     3136+ * Garbage collection can only take place when we are sure there are no Lists
     3137  * or Dictionaries being used internally.  This is flagged with
     3138  * "may_garbage_collect" when we are at the toplevel.
     3139  * "want_garbage_collect" is set by the garbagecollect() function, which means
     3140- * we do garbage collection before waiting for a char at the toplevel. */
     3141+ * we do garbage collection before waiting for a char at the toplevel.
     3142+ * "garbage_collect_at_exit" indicates garbagecollect(1) was called.
     3143+ */
     3144 EXTERN int     may_garbage_collect INIT(= FALSE);
     3145 EXTERN int     want_garbage_collect INIT(= FALSE);
     3146+EXTERN int     garbage_collect_at_exit INIT(= FALSE);
     3147 
     3148 /* ID of script being sourced or was sourced to define the current function. */
     3149 EXTERN scid_T  current_SID INIT(= 0);
     3150@@ -362,7 +366,6 @@
     3151 EXTERN int     autocmd_busy INIT(= FALSE);     /* Is apply_autocmds() busy? */
     3152 EXTERN int     autocmd_no_enter INIT(= FALSE); /* *Enter autocmds disabled */
     3153 EXTERN int     autocmd_no_leave INIT(= FALSE); /* *Leave autocmds disabled */
     3154-EXTERN int     autocmd_block INIT(= 0);        /* block all autocmds */
     3155 EXTERN int     modified_was_set;               /* did ":set modified" */
     3156 EXTERN int     did_filetype INIT(= FALSE);     /* FileType event found */
     3157 EXTERN int     keep_filetype INIT(= FALSE);    /* value for did_filetype when
     3158@@ -801,7 +804,7 @@
    24073159 EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
    24083160 EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
     
    24153167diff -Naur vim71.orig/src/gui.c vim71/src/gui.c
    24163168--- vim71.orig/src/gui.c        2007-05-07 12:50:55.000000000 -0700
    2417 +++ vim71/src/gui.c     2007-09-03 22:15:45.000000000 -0700
     3169+++ vim71/src/gui.c     2007-10-16 14:14:28.000000000 -0700
    24183170@@ -1080,7 +1080,8 @@
    24193171                cur_width = gui.char_width;
     
    24353187        text_area_y += gui.tabline_height;
    24363188 #endif
    2437 @@ -5117,7 +5118,7 @@
     3189@@ -4518,7 +4519,18 @@
     3190     xim_set_focus(in_focus);
     3191 # endif
     3192 
     3193-    ui_focus_change(in_focus);
     3194+    /* Put events in the input queue only when allowed.
     3195+     * ui_focus_change() isn't called directly, because it invokes
     3196+     * autocommands and that must not happen asynchronously. */
     3197+    if (!hold_gui_events)
     3198+    {
     3199+       char_u  bytes[3];
     3200+
     3201+       bytes[0] = CSI;
     3202+       bytes[1] = KS_EXTRA;
     3203+       bytes[2] = in_focus ? (int)KE_FOCUSGAINED : (int)KE_FOCUSLOST;
     3204+       add_to_input_buf(bytes, 3);
     3205+    }
     3206 #endif
     3207 }
     3208 
     3209@@ -5117,7 +5129,7 @@
    24383210                p = vim_strsave_escaped(fnames[i], (char_u *)"\\ \t\"|");
    24393211 # endif
     
    24463218diff -Naur vim71.orig/src/gui_gtk.c vim71/src/gui_gtk.c
    24473219--- vim71.orig/src/gui_gtk.c    2007-05-10 01:37:37.000000000 -0700
    2448 +++ vim71/src/gui_gtk.c 2007-09-03 22:14:50.000000000 -0700
     3220+++ vim71/src/gui_gtk.c 2007-10-16 14:14:12.000000000 -0700
    24493221@@ -53,8 +53,8 @@
    24503222 # ifdef bindtextdomain
     
    24923264diff -Naur vim71.orig/src/gui_gtk_x11.c vim71/src/gui_gtk_x11.c
    24933265--- vim71.orig/src/gui_gtk_x11.c        2007-05-10 01:37:49.000000000 -0700
    2494 +++ vim71/src/gui_gtk_x11.c     2007-09-03 22:12:35.000000000 -0700
     3266+++ vim71/src/gui_gtk_x11.c     2007-10-16 14:14:28.000000000 -0700
    24953267@@ -36,8 +36,8 @@
    24963268 # ifdef bindtextdomain
     
    25043276 # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS)
    25053277 #  define ENABLE_NLS   /* so the texts in the dialog boxes are translated */
    2506 @@ -2188,8 +2188,10 @@
     3278@@ -813,10 +813,15 @@
     3279     if (blink_state == BLINK_NONE)
     3280        gui_mch_start_blink();
     3281 
     3282-    /* make sure keyboard input goes to the draw area (if this is focus for a window) */
     3283+    /* make sure keyboard input goes to the draw area (if this is focus for a
     3284+     * window) */
     3285     if (widget != gui.drawarea)
     3286        gtk_widget_grab_focus(gui.drawarea);
     3287 
     3288+    /* make sure the input buffer is read */
     3289+    if (gtk_main_level() > 0)
     3290+       gtk_main_quit();
     3291+
     3292     return TRUE;
     3293 }
     3294 
     3295@@ -829,6 +834,10 @@
     3296     if (blink_state != BLINK_NONE)
     3297        gui_mch_stop_blink();
     3298 
     3299+    /* make sure the input buffer is read */
     3300+    if (gtk_main_level() > 0)
     3301+       gtk_main_quit();
     3302+
     3303     return TRUE;
     3304 }
     3305 
     3306@@ -2188,8 +2197,10 @@
    25073307     escaped_filename = vim_strsave_escaped(filename, escape_chars);
    25083308     if (escaped_filename == NULL)
     
    25163316      * Use a reasonable hardcoded set of 'sessionoptions' flags to avoid
    25173317      * unpredictable effects when the session is saved automatically.  Also,
    2518 @@ -2199,7 +2201,7 @@
     3318@@ -2199,7 +2210,7 @@
    25193319      */
    25203320     save_ssop_flags = ssop_flags;
     
    25253325     do_cmdline_cmd((char_u *)"let Save_VV_this_session = v:this_session");
    25263326     failed = (do_cmdline_cmd((char_u *)mksession_cmdline) == FAIL);
     3327@@ -3212,8 +3223,9 @@
     3328        {
     3329            if (clicked_page == 0)
     3330            {
     3331-               /* Click after all tabs moves to next tab page. */
     3332-               if (send_tabline_event(0) && gtk_main_level() > 0)
     3333+               /* Click after all tabs moves to next tab page.  When "x" is
     3334+                * small guess it's the left button. */
     3335+               if (send_tabline_event(x < 50 ? -1 : 0) && gtk_main_level() > 0)
     3336                    gtk_main_quit();
     3337            }
     3338 #ifndef HAVE_GTK2
    25273339diff -Naur vim71.orig/src/if_cscope.c vim71/src/if_cscope.c
    25283340--- vim71.orig/src/if_cscope.c  2007-03-11 07:29:57.000000000 -0700
    2529 +++ vim71/src/if_cscope.c       2007-09-03 22:15:31.000000000 -0700
    2530 @@ -73,6 +73,8 @@
     3341+++ vim71/src/if_cscope.c       2007-10-16 14:14:28.000000000 -0700
     3342@@ -24,11 +24,6 @@
     3343     /* not UNIX, must be WIN32 */
     3344 # include "vimio.h"
     3345 # include <fcntl.h>
     3346-# include <process.h>
     3347-# define STDIN_FILENO    0
     3348-# define STDOUT_FILENO   1
     3349-# define STDERR_FILENO   2
     3350-# define pipe(fds) _pipe(fds, 256, O_TEXT|O_NOINHERIT)
     3351 #endif
     3352 #include "if_cscope.h"
     3353 
     3354@@ -65,7 +60,7 @@
     3355 static char *      cs_parse_results __ARGS((int cnumber, char *buf, int bufsize, char **context, char **linenumber, char **search));
     3356 static char *      cs_pathcomponents __ARGS((char *path));
     3357 static void        cs_print_tags_priv __ARGS((char **, char **, int));
     3358-static int         cs_read_prompt __ARGS((int ));
     3359+static int         cs_read_prompt __ARGS((int));
     3360 static void        cs_release_csp __ARGS((int, int freefnpp));
     3361 static int         cs_reset __ARGS((exarg_T *eap));
     3362 static char *      cs_resolve_file __ARGS((int, char *));
     3363@@ -73,6 +68,8 @@
    25313364 
    25323365 
     
    25373370 {
    25383371     { "add",   cs_add,
    2539 @@ -260,14 +262,7 @@
     3372@@ -260,14 +257,7 @@
    25403373 
    25413374     if ((p = cs_manage_matches(NULL, NULL, -1, Get)) == NULL)
     
    25533386     return FALSE;
    25543387 } /* cs_fgets */
    2555 @@ -386,7 +381,7 @@
     3388@@ -386,7 +376,7 @@
    25563389  * PRIVATE: cs_add
    25573390  *
     
    25623395  * MAXPATHL 256
    25633396  */
    2564 @@ -966,7 +961,7 @@
     3397@@ -509,7 +499,7 @@
     3398 #if defined(UNIX)
     3399     else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode))
     3400 #else
     3401-       /* substitute define S_ISREG from os_unix.h */
     3402+       /* WIN32 - substitute define S_ISREG from os_unix.h */
     3403     else if (((statbuf.st_mode) & S_IFMT) == S_IFREG)
     3404 #endif
     3405     {
     3406@@ -722,17 +712,32 @@
     3407 cs_create_connection(i)
     3408     int i;
     3409 {
     3410-    int to_cs[2], from_cs[2], len;
     3411-    char *prog, *cmd, *ppath = NULL;
     3412-#ifndef UNIX
     3413-    int in_save, out_save, err_save;
     3414-    long_i ph;
     3415-# ifdef FEAT_GUI
     3416-    HWND activewnd = NULL;
     3417-    HWND consolewnd = NULL;
     3418+#ifdef UNIX
     3419+    int                to_cs[2], from_cs[2];
     3420+#endif
     3421+    int                len;
     3422+    char       *prog, *cmd, *ppath = NULL;
     3423+#ifdef WIN32
     3424+    int                fd;
     3425+    SECURITY_ATTRIBUTES sa;
     3426+    PROCESS_INFORMATION pi;
     3427+    STARTUPINFO si;
     3428+    BOOL       pipe_stdin = FALSE, pipe_stdout = FALSE;
     3429+    HANDLE     stdin_rd, stdout_rd;
     3430+    HANDLE     stdout_wr, stdin_wr;
     3431+    BOOL       created;
     3432+# ifdef __BORLANDC__
     3433+#  define OPEN_OH_ARGTYPE long
     3434+# else
     3435+#  if (_MSC_VER >= 1300)
     3436+#   define OPEN_OH_ARGTYPE intptr_t
     3437+#  else
     3438+#   define OPEN_OH_ARGTYPE long
     3439+#  endif
     3440 # endif
     3441 #endif
     3442 
     3443+#if defined(UNIX)
     3444     /*
     3445      * Cscope reads from to_cs[0] and writes to from_cs[1]; vi reads from
     3446      * from_cs[0] and writes to to_cs[1].
     3447@@ -753,18 +758,12 @@
     3448        return CSCOPE_FAILURE;
     3449     }
     3450 
     3451-#if defined(UNIX)
     3452     switch (csinfo[i].pid = fork())
     3453     {
     3454     case -1:
     3455        (void)EMSG(_("E622: Could not fork for cscope"));
     3456        goto err_closing;
     3457     case 0:                            /* child: run cscope. */
     3458-#else
     3459-       in_save = dup(STDIN_FILENO);
     3460-       out_save = dup(STDOUT_FILENO);
     3461-       err_save = dup(STDERR_FILENO);
     3462-#endif
     3463        if (dup2(to_cs[0], STDIN_FILENO) == -1)
     3464            PERROR("cs_create_connection 1");
     3465        if (dup2(from_cs[1], STDOUT_FILENO) == -1)
     3466@@ -773,15 +772,32 @@
     3467            PERROR("cs_create_connection 3");
     3468 
     3469        /* close unused */
     3470-#if defined(UNIX)
     3471        (void)close(to_cs[1]);
     3472        (void)close(from_cs[0]);
     3473 #else
     3474-       /* On win32 we must close opposite ends because we are the parent */
     3475-       (void)close(to_cs[0]);
     3476-       to_cs[0] = -1;
     3477-       (void)close(from_cs[1]);
     3478-       from_cs[1] = -1;
     3479+       /* WIN32 */
     3480+       /* Create pipes to communicate with cscope */
     3481+       sa.nLength = sizeof(SECURITY_ATTRIBUTES);
     3482+       sa.bInheritHandle = TRUE;
     3483+       sa.lpSecurityDescriptor = NULL;
     3484+
     3485+       if (!(pipe_stdin = CreatePipe(&stdin_rd, &stdin_wr, &sa, 0))
     3486+               || !(pipe_stdout = CreatePipe(&stdout_rd, &stdout_wr, &sa, 0)))
     3487+       {
     3488+           (void)EMSG(_("E566: Could not create cscope pipes"));
     3489+err_closing:
     3490+           if (pipe_stdin)
     3491+           {
     3492+               CloseHandle(stdin_rd);
     3493+               CloseHandle(stdin_wr);
     3494+           }
     3495+           if (pipe_stdout)
     3496+           {
     3497+               CloseHandle(stdout_rd);
     3498+               CloseHandle(stdout_wr);
     3499+           }
     3500+           return CSCOPE_FAILURE;
     3501+       }
     3502 #endif
     3503        /* expand the cscope exec for env var's */
     3504        if ((prog = (char *)alloc(MAXPATHL + 1)) == NULL)
     3505@@ -789,6 +805,7 @@
     3506 #ifdef UNIX
     3507            return CSCOPE_FAILURE;
     3508 #else
     3509+           /* WIN32 */
     3510            goto err_closing;
     3511 #endif
     3512        }
     3513@@ -805,6 +822,7 @@
     3514 #ifdef UNIX
     3515                return CSCOPE_FAILURE;
     3516 #else
     3517+               /* WIN32 */
     3518                goto err_closing;
     3519 #endif
     3520            }
     3521@@ -823,6 +841,7 @@
     3522 #ifdef UNIX
     3523            return CSCOPE_FAILURE;
     3524 #else
     3525+           /* WIN32 */
     3526            goto err_closing;
     3527 #endif
     3528        }
     3529@@ -831,6 +850,7 @@
     3530 #if defined(UNIX)
     3531        (void)sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname);
     3532 #else
     3533+       /* WIN32 */
     3534        (void)sprintf(cmd, "%s -dl -f %s", prog, csinfo[i].fname);
     3535 #endif
     3536        if (csinfo[i].ppath != NULL)
     3537@@ -856,60 +876,6 @@
     3538        exit(127);
     3539        /* NOTREACHED */
     3540     default:   /* parent. */
     3541-#else
     3542-# ifdef FEAT_GUI
     3543-       activewnd = GetForegroundWindow(); /* on win9x cscope steals focus */
     3544-       /* Dirty hack to hide annoying console window */
     3545-       if (AllocConsole())
     3546-       {
     3547-           char *title;
     3548-           title = (char *)alloc(1024);
     3549-           if (title == NULL)
     3550-               FreeConsole();
     3551-           else
     3552-           {
     3553-               GetConsoleTitle(title, 1024); /* save for future restore */
     3554-               SetConsoleTitle(
     3555-                   "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
     3556-               Sleep(40); /* as stated in MS KB we must wait 40 ms */
     3557-               consolewnd = FindWindow(NULL,
     3558-                       "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
     3559-               if (consolewnd != NULL)
     3560-                   ShowWindow(consolewnd, SW_HIDE);
     3561-               SetConsoleTitle(title);
     3562-               vim_free(title);
     3563-           }
     3564-       }
     3565-# endif
     3566-       /* May be use &shell, &shellquote etc */
     3567-# ifdef __BORLANDC__
     3568-       /* BCC 5.5 uses a different function name for spawnlp */
     3569-       ph = (long_i)spawnlp(P_NOWAIT, prog, cmd, NULL);
     3570-# else
     3571-       ph = (long_i)_spawnlp(_P_NOWAIT, prog, cmd, NULL);
     3572-# endif
     3573-       vim_free(prog);
     3574-       vim_free(cmd);
     3575-# ifdef FEAT_GUI
     3576-       /* Dirty hack part two */
     3577-       if (activewnd != NULL)
     3578-           /* restoring focus */
     3579-           SetForegroundWindow(activewnd);
     3580-       if (consolewnd != NULL)
     3581-           FreeConsole();
     3582-
     3583-# endif
     3584-       if (ph == -1)
     3585-       {
     3586-           PERROR(_("cs_create_connection exec failed"));
     3587-           (void)EMSG(_("E623: Could not spawn cscope process"));
     3588-           goto err_closing;
     3589-       }
     3590-       /* else */
     3591-       csinfo[i].pid = 0;
     3592-       csinfo[i].hProc = (HANDLE)ph;
     3593-
     3594-#endif /* !UNIX */
     3595        /*
     3596         * Save the file descriptors for later duplication, and
     3597         * reopen as streams.
     3598@@ -919,22 +885,54 @@
     3599        if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL)
     3600            PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
     3601 
     3602-#if defined(UNIX)
     3603        /* close unused */
     3604        (void)close(to_cs[0]);
     3605        (void)close(from_cs[1]);
     3606 
     3607        break;
     3608     }
     3609+
     3610 #else
     3611-       /* restore stdhandles */
     3612-    dup2(in_save, STDIN_FILENO);
     3613-    dup2(out_save, STDOUT_FILENO);
     3614-    dup2(err_save, STDERR_FILENO);
     3615-    close(in_save);
     3616-    close(out_save);
     3617-    close(err_save);
     3618-#endif
     3619+    /* WIN32 */
     3620+    /* Create a new process to run cscope and use pipes to talk with it */
     3621+    GetStartupInfo(&si);
     3622+    si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
     3623+    si.wShowWindow = SW_HIDE;  /* Hide child application window */
     3624+    si.hStdOutput = stdout_wr;
     3625+    si.hStdError  = stdout_wr;
     3626+    si.hStdInput  = stdin_rd;
     3627+    created = CreateProcess(NULL, cmd, NULL, NULL, TRUE, CREATE_NEW_CONSOLE,
     3628+                                                       NULL, NULL, &si, &pi);
     3629+    vim_free(prog);
     3630+    vim_free(cmd);
     3631+
     3632+    if (!created)
     3633+    {
     3634+       PERROR(_("cs_create_connection exec failed"));
     3635+       (void)EMSG(_("E623: Could not spawn cscope process"));
     3636+       goto err_closing;
     3637+    }
     3638+    /* else */
     3639+    csinfo[i].pid = pi.dwProcessId;
     3640+    csinfo[i].hProc = pi.hProcess;
     3641+    CloseHandle(pi.hThread);
     3642+
     3643+    /* TODO - tidy up after failure to create files on pipe handles. */
     3644+    if (((fd = _open_osfhandle((OPEN_OH_ARGTYPE)stdin_wr,
     3645+                                                     _O_TEXT|_O_APPEND)) < 0)
     3646+           || ((csinfo[i].to_fp = _fdopen(fd, "w")) == NULL))
     3647+       PERROR(_("cs_create_connection: fdopen for to_fp failed"));
     3648+    if (((fd = _open_osfhandle((OPEN_OH_ARGTYPE)stdout_rd,
     3649+                                                     _O_TEXT|_O_RDONLY)) < 0)
     3650+           || ((csinfo[i].fr_fp = _fdopen(fd, "r")) == NULL))
     3651+       PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
     3652+
     3653+    /* Close handles for file descriptors inherited by the cscope process */
     3654+    CloseHandle(stdin_rd);
     3655+    CloseHandle(stdout_wr);
     3656+
     3657+#endif /* !UNIX */
     3658+
     3659     return CSCOPE_SUCCESS;
     3660 } /* cs_create_connection */
     3661 
     3662@@ -966,7 +964,7 @@
    25653663     }
    25663664 
     
    25713669        cs_usage_msg(Find);
    25723670        return FALSE;
    2573 @@ -1317,7 +1312,7 @@
     3671@@ -1317,7 +1315,7 @@
    25743672 #else
    25753673            /* compare pathnames first */
     
    25803678                    && csinfo[j].nVolume == bhfi.dwVolumeSerialNumber
    25813679                    && csinfo[j].nIndexHigh == bhfi.nFileIndexHigh
    2582 @@ -1401,6 +1396,9 @@
     3680@@ -1401,6 +1399,9 @@
    25833681     if (eap->arg == NULL)
    25843682        return NULL;
     
    25903688        return NULL;
    25913689 
    2592 @@ -2195,7 +2193,7 @@
     3690@@ -2099,8 +2100,8 @@
     3691 /*
     3692  * PRIVATE: cs_release_csp
     3693  *
     3694- * does the actual free'ing for the cs ptr with an optional flag of whether
     3695- * or not to free the filename.  called by cs_kill and cs_reset.
     3696+ * Does the actual free'ing for the cs ptr with an optional flag of whether
     3697+ * or not to free the filename.  Called by cs_kill and cs_reset.
     3698  */
     3699     static void
     3700 cs_release_csp(i, freefnpp)
     3701@@ -2118,10 +2119,13 @@
     3702        (void)fputs("q\n", csinfo[i].to_fp);
     3703        (void)fflush(csinfo[i].to_fp);
     3704     }
     3705-    /* give cscope chance to exit normally */
     3706-    if (csinfo[i].hProc != NULL
     3707-           && WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT)
     3708-       TerminateProcess(csinfo[i].hProc, 0);
     3709+    if (csinfo[i].hProc != NULL)
     3710+    {
     3711+       /* Give cscope a chance to exit normally */
     3712+       if (WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT)
     3713+           TerminateProcess(csinfo[i].hProc, 0);
     3714+       CloseHandle(csinfo[i].hProc);
     3715+    }
     3716 #endif
     3717 
     3718     if (csinfo[i].fr_fp != NULL)
     3719@@ -2195,7 +2199,7 @@
    25933720            cs_add_common(dblist[i], pplist[i], fllist[i]);
    25943721            if (p_csverbose)
     
    25993726                 * "Added cscope database..."
    26003727                 */
     3728@@ -2304,6 +2308,21 @@
     3729     return CSCOPE_SUCCESS;
     3730 } /* cs_show */
     3731 
     3732+
     3733+/*
     3734+ * PUBLIC: cs_end
     3735+ *
     3736+ * Only called when VIM exits to quit any cscope sessions.
     3737+ */
     3738+    void
     3739+cs_end()
     3740+{
     3741+    int i;
     3742+
     3743+    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
     3744+       cs_release_csp(i, TRUE);
     3745+}
     3746+
     3747 #endif /* FEAT_CSCOPE */
     3748 
     3749 /* the end */
     3750diff -Naur vim71.orig/src/if_cscope.h vim71/src/if_cscope.h
     3751--- vim71.orig/src/if_cscope.h  2005-06-30 10:14:22.000000000 -0700
     3752+++ vim71/src/if_cscope.h       2007-10-16 14:14:28.000000000 -0700
     3753@@ -72,7 +72,7 @@
     3754     ino_t          st_ino;     /* inode number of cscope db */
     3755 #else
     3756 # if defined(WIN32)
     3757-    int            pid;        /* Can't get pid so set it to 0 ;) */
     3758+    DWORD          pid;        /* PID of the connected cscope process. */
     3759     HANDLE         hProc;      /* cscope process handle */
     3760     DWORD          nVolume;    /* Volume serial number, instead of st_dev */
     3761     DWORD          nIndexHigh; /* st_ino has no meaning in the Windows */
    26013762diff -Naur vim71.orig/src/if_mzsch.c vim71/src/if_mzsch.c
    26023763--- vim71.orig/src/if_mzsch.c   2007-05-12 04:13:47.000000000 -0700
    2603 +++ vim71/src/if_mzsch.c        2007-09-03 22:12:59.000000000 -0700
     3764+++ vim71/src/if_mzsch.c        2007-10-16 14:14:06.000000000 -0700
    26043765@@ -308,6 +308,8 @@
    26053766 static Scheme_Config *(*dll_scheme_current_config)(void);
     
    26453806 #endif
    26463807 #ifdef HAVE_SANDBOX
     3808diff -Naur vim71.orig/src/if_perl.xs vim71/src/if_perl.xs
     3809--- vim71.orig/src/if_perl.xs   2006-08-16 05:45:15.000000000 -0700
     3810+++ vim71/src/if_perl.xs        2007-10-16 14:14:41.000000000 -0700
     3811@@ -40,6 +40,28 @@
     3812 #    define PERL_SUBVERSION SUBVERSION
     3813 #endif
     3814 
     3815+/*
     3816+ * Quoting Jan Dubois of Active State:
     3817+ *    ActivePerl build 822 still identifies itself as 5.8.8 but already
     3818+ *    contains many of the changes from the upcoming Perl 5.8.9 release.
     3819+ *
     3820+ * The changes include addition of two symbols (Perl_sv_2iv_flags,
     3821+ * Perl_newXS_flags) not present in earlier releases.
     3822+ *
     3823+ * Jan Dubois suggested the following guarding scheme.
     3824+ *
     3825+ * Active State defined ACTIVEPERL_VERSION as a string in versions before
     3826+ * 5.8.8; and so the comparison to 822 below needs to be guarded.
     3827+ */
     3828+#if (PERL_REVISION == 5) && (PERL_VERSION == 8) && (PERL_SUBVERSION >= 8)
     3829+# if (ACTIVEPERL_VERSION >= 822) || (PERL_SUBVERSION >= 9)
     3830+#  define PERL589_OR_LATER
     3831+# endif
     3832+#endif
     3833+#if (PERL_REVISION == 5) && (PERL_VERSION >= 9)
     3834+# define PERL589_OR_LATER
     3835+#endif
     3836+
     3837 #ifndef pTHX
     3838 #    define pTHX void
     3839 #    define pTHX_
     3840@@ -109,6 +131,10 @@
     3841 # else
     3842 #  define Perl_sv_catpvn dll_Perl_sv_catpvn
     3843 # endif
     3844+#ifdef PERL589_OR_LATER
     3845+#  define Perl_sv_2iv_flags dll_Perl_sv_2iv_flags
     3846+#  define Perl_newXS_flags dll_Perl_newXS_flags
     3847+#endif
     3848 # define Perl_sv_free dll_Perl_sv_free
     3849 # define Perl_sv_isa dll_Perl_sv_isa
     3850 # define Perl_sv_magic dll_Perl_sv_magic
     3851@@ -192,6 +218,10 @@
     3852 #else
     3853 static void (*Perl_sv_catpvn)(pTHX_ SV*, const char*, STRLEN);
     3854 #endif
     3855+#ifdef PERL589_OR_LATER
     3856+static IV (*Perl_sv_2iv_flags)(pTHX_ SV* sv, I32 flags);
     3857+static CV * (*Perl_newXS_flags)(pTHX_ const char *name, XSUBADDR_t subaddr, const char *const filename, const char *const proto, U32 flags);
     3858+#endif
     3859 static void (*Perl_sv_free)(pTHX_ SV*);
     3860 static int (*Perl_sv_isa)(pTHX_ SV*, const char*);
     3861 static void (*Perl_sv_magic)(pTHX_ SV*, SV*, int, const char*, I32);
     3862@@ -267,6 +297,10 @@
     3863 #else
     3864     {"Perl_sv_2pv", (PERL_PROC*)&Perl_sv_2pv},
     3865 #endif
     3866+#ifdef PERL589_OR_LATER
     3867+    {"Perl_sv_2iv_flags", (PERL_PROC*)&Perl_sv_2iv_flags},
     3868+    {"Perl_newXS_flags", (PERL_PROC*)&Perl_newXS_flags},
     3869+#endif
     3870     {"Perl_sv_bless", (PERL_PROC*)&Perl_sv_bless},
     3871 #if (PERL_REVISION == 5) && (PERL_VERSION >= 8)
     3872     {"Perl_sv_catpvn_flags", (PERL_PROC*)&Perl_sv_catpvn_flags},
     3873@@ -411,13 +445,13 @@
     3874     char *next;
     3875     char *token = (char *)s;
     3876 
     3877-    while ((next = strchr(token, '\n')))
     3878+    while ((next = strchr(token, '\n')) && !got_int)
     3879     {
     3880        *next++ = '\0';                 /* replace \n with \0 */
     3881        msg_attr((char_u *)token, attr);
     3882        token = next;
     3883     }
     3884-    if (*token)
     3885+    if (*token && !got_int)
     3886        msg_attr((char_u *)token, attr);
     3887 }
     3888 
     3889diff -Naur vim71.orig/src/if_ruby.c vim71/src/if_ruby.c
     3890--- vim71.orig/src/if_ruby.c    2007-05-12 02:54:12.000000000 -0700
     3891+++ vim71/src/if_ruby.c 2007-10-16 14:14:28.000000000 -0700
     3892@@ -789,7 +789,7 @@
     3893     return get_buffer_line(curbuf, curwin->w_cursor.lnum);
     3894 }
     3895 
     3896-static VALUE set_current_line(VALUE str)
     3897+static VALUE set_current_line(VALUE self, VALUE str)
     3898 {
     3899     return set_buffer_line(curbuf, curwin->w_cursor.lnum, str);
     3900 }
     3901diff -Naur vim71.orig/src/keymap.h vim71/src/keymap.h
     3902--- vim71.orig/src/keymap.h     2006-08-22 04:38:38.000000000 -0700
     3903+++ vim71/src/keymap.h  2007-10-16 14:14:28.000000000 -0700
     3904@@ -254,6 +254,8 @@
     3905     , KE_DROP          /* DnD data is available */
     3906     , KE_CURSORHOLD    /* CursorHold event */
     3907     , KE_NOP           /* doesn't do something */
     3908+    , KE_FOCUSGAINED   /* focus gained */
     3909+    , KE_FOCUSLOST     /* focus lost */
     3910 };
     3911 
     3912 /*
     3913@@ -445,6 +447,8 @@
     3914 #define K_CMDWIN       TERMCAP2KEY(KS_EXTRA, KE_CMDWIN)
     3915 
     3916 #define K_DROP         TERMCAP2KEY(KS_EXTRA, KE_DROP)
     3917+#define K_FOCUSGAINED  TERMCAP2KEY(KS_EXTRA, KE_FOCUSGAINED)
     3918+#define K_FOCUSLOST    TERMCAP2KEY(KS_EXTRA, KE_FOCUSLOST)
     3919 
     3920 #define K_CURSORHOLD   TERMCAP2KEY(KS_EXTRA, KE_CURSORHOLD)
     3921 
    26473922diff -Naur vim71.orig/src/macros.h vim71/src/macros.h
    26483923--- vim71.orig/src/macros.h     2007-05-07 12:38:22.000000000 -0700
    2649 +++ vim71/src/macros.h  2007-09-03 22:15:12.000000000 -0700
     3924+++ vim71/src/macros.h  2007-10-16 14:14:17.000000000 -0700
    26503925@@ -54,10 +54,12 @@
    26513926 
     
    26633938 #ifdef MSWIN
    26643939 #  define TOUPPER_LOC(c)       toupper_tab[(c) & 255]
     3940diff -Naur vim71.orig/src/main.aap vim71/src/main.aap
     3941--- vim71.orig/src/main.aap     2007-05-07 12:46:43.000000000 -0700
     3942+++ vim71/src/main.aap  2007-10-16 14:14:28.000000000 -0700
     3943@@ -56,9 +56,16 @@
     3944     config {virtual} auto/config.h auto/config.aap :
     3945                          auto/configure.aap configure.aap
     3946                          config.arg config.h.in config.aap.in
     3947+        # Use "uname -a" to detect the architecture of the system.
     3948+        @ok, uname = redir_system('uname -a', 0)
     3949+        @if string.find(uname, "i386") >= 0:
     3950+        @   arch = "i386"
     3951+        @else:
     3952+        @   arch = "ppc"
     3953+        :print Building for $arch system
     3954         :sys CONFIG_STATUS=auto/config.status
     3955                 ./configure.aap `file2string("config.arg")`
     3956-                    --with-mac-arch=ppc
     3957+                    --with-mac-arch=$arch
     3958                     --cache-file=auto/config.cache
     3959 
     3960     # Configure arguments: create an empty "config.arg" file when its missing
     3961@@ -1167,7 +1174,7 @@
     3962         :symlink `os.getcwd()`/../runtime $RESDIR/vim/runtime
     3963 # TODO: Create the vimtutor application.
     3964 
     3965-gui_bundle {virtual}: $(RESDIR) bundle-dir bundle-executable bundle-info
     3966+gui_bundle {virtual}: $(RESDIR) bundle-dir bundle-executable bundle-info \
     3967                         bundle-resource bundle-language
     3968 
     3969 bundle-dir {virtual}: $(APPDIR)/Contents $(VIMTARGET)
     3970@@ -1187,7 +1194,7 @@
     3971         :sys m4 $(M4FLAGSX) infplist.xml > $(APPDIR)/Contents/Info.plist
     3972 
     3973 bundle-resource {virtual}: bundle-dir bundle-rsrc
     3974-    :copy {force} $(RSRC_DIR)/*.icns $(RESDIR)
     3975+        :copy {force} $(RSRC_DIR)/*.icns $(RESDIR)
     3976 
     3977 ### Classic resources
     3978 # Resource fork (in the form of a .rsrc file) for Classic Vim (Mac OS 9)
    26653979diff -Naur vim71.orig/src/main.c vim71/src/main.c
    26663980--- vim71.orig/src/main.c       2007-05-07 12:38:44.000000000 -0700
    2667 +++ vim71/src/main.c    2007-09-03 22:14:26.000000000 -0700
     3981+++ vim71/src/main.c    2007-10-16 14:14:28.000000000 -0700
    26683982@@ -954,7 +954,8 @@
    26693983     int                cmdwin;     /* TRUE when working in the command-line window */
     
    27134027            msg_scroll = FALSE;
    27144028        quit_more = FALSE;
    2715 @@ -1360,8 +1381,7 @@
     4029@@ -1309,6 +1330,13 @@
     4030 #ifdef FEAT_NETBEANS_INTG
     4031     netbeans_end();
     4032 #endif
     4033+#ifdef FEAT_CSCOPE
     4034+    cs_end();
     4035+#endif
     4036+#ifdef FEAT_EVAL
     4037+    if (garbage_collect_at_exit)
     4038+       garbage_collect();
     4039+#endif
     4040 
     4041     mch_exit(exitval);
     4042 }
     4043@@ -1360,8 +1388,7 @@
    27164044        p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
    27174045        if (p != NULL && *p != NUL)
     
    27234051        }
    27244052        if (mustfree)
     4053@@ -3632,7 +3659,13 @@
     4054        mainerr_arg_missing((char_u *)filev[-1]);
     4055     if (mch_dirname(cwd, MAXPATHL) != OK)
     4056        return NULL;
     4057-    if ((p = vim_strsave_escaped_ext(cwd, PATH_ESC_CHARS, '\\', TRUE)) == NULL)
     4058+    if ((p = vim_strsave_escaped_ext(cwd,
     4059+#ifdef BACKSLASH_IN_FILENAME
     4060+                   "",  /* rem_backslash() will tell what chars to escape */
     4061+#else
     4062+                   PATH_ESC_CHARS,
     4063+#endif
     4064+                   '\\', TRUE)) == NULL)
     4065        return NULL;
     4066     ga_init2(&ga, 1, 100);
     4067     ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd ");
    27254068diff -Naur vim71.orig/src/mbyte.c vim71/src/mbyte.c
    27264069--- vim71.orig/src/mbyte.c      2007-05-07 12:47:09.000000000 -0700
    2727 +++ vim71/src/mbyte.c   2007-09-03 22:15:45.000000000 -0700
     4070+++ vim71/src/mbyte.c   2007-10-16 14:14:28.000000000 -0700
    27284071@@ -1310,20 +1310,26 @@
    27294072 /*
     
    27964139diff -Naur vim71.orig/src/message.c vim71/src/message.c
    27974140--- vim71.orig/src/message.c    2007-05-07 12:31:59.000000000 -0700
    2798 +++ vim71/src/message.c 2007-09-03 22:14:19.000000000 -0700
    2799 @@ -1842,7 +1842,7 @@
     4141+++ vim71/src/message.c 2007-10-16 14:14:28.000000000 -0700
     4142@@ -828,7 +828,7 @@
     4143                _("Messages maintainer: Bram Moolenaar <Bram@vim.org>"),
     4144                hl_attr(HLF_T));
     4145 
     4146-    for (p = first_msg_hist; p != NULL; p = p->next)
     4147+    for (p = first_msg_hist; p != NULL && !got_int; p = p->next)
     4148        if (p->msg != NULL)
     4149            msg_attr(p->msg, p->attr);
     4150 
     4151@@ -944,6 +944,7 @@
     4152                c = K_IGNORE;
     4153            }
     4154 #endif
     4155+
     4156            /*
     4157             * Allow scrolling back in the messages.
     4158             * Also accept scroll-down commands when messages fill the screen,
     4159@@ -1840,9 +1841,10 @@
     4160     char_u     *sb_str = str;
     4161     int                sb_col = msg_col;
    28004162     int                wrap;
     4163+    int                did_last_char;
    28014164 
    28024165     did_wait_return = FALSE;
     
    28064169        /*
    28074170         * We are at the end of the screen line when:
    2808 @@ -1878,7 +1878,7 @@
     4171@@ -1878,7 +1880,7 @@
    28094172                /* output postponed text */
    28104173                t_puts(&t_col, t_s, s, attr);
     
    28154178                break;
    28164179 
    2817 @@ -1927,7 +1927,8 @@
     4180@@ -1909,7 +1911,10 @@
     4181                else
     4182 #endif
     4183                    msg_screen_putchar(*s++, attr);
     4184+               did_last_char = TRUE;
     4185            }
     4186+           else
     4187+               did_last_char = FALSE;
     4188 
     4189            if (p_more)
     4190                /* store text for scrolling back */
     4191@@ -1927,7 +1932,8 @@
    28184192             * If screen is completely filled and 'more' is set then wait
    28194193             * for a character.
     
    28254199                                            && !msg_no_more && !exmode_active)
    28264200            {
    2827 @@ -2234,7 +2235,7 @@
     4201@@ -1943,11 +1949,7 @@
     4202 
     4203            /* When we displayed a char in last column need to check if there
     4204             * is still more. */
     4205-           if (*s >= ' '
     4206-#ifdef FEAT_RIGHTLEFT
     4207-                   && !cmdmsg_rl
     4208-#endif
     4209-              )
     4210+           if (did_last_char)
     4211                continue;
     4212        }
     4213 
     4214@@ -2234,7 +2236,7 @@
    28284215 {
    28294216     msgchunk_T *mp;
     
    28344221     mp = msg_sb_start(last_msgchunk);
    28354222     if (mp == NULL || mp->sb_prev == NULL)
    2836 @@ -2622,7 +2623,7 @@
     4223@@ -2622,7 +2624,7 @@
    28374224                }
    28384225            }
     
    28434230                /* displayed the requested text, more prompt again */
    28444231                screen_fill((int)Rows - 1, (int)Rows, 0,
    2845 @@ -3456,11 +3457,11 @@
     4232@@ -3456,11 +3458,11 @@
    28464233                    /* advance to next hotkey and set default hotkey */
    28474234 #ifdef FEAT_MBYTE
     
    28574244                        --dfltbutton;
    28584245 
    2859 @@ -3493,7 +3494,7 @@
     4246@@ -3493,7 +3495,7 @@
    28604247                        *msgp++ = (dfltbutton == 1) ? ']' : ')';
    28614248 
     
    28664253                }
    28674254                else
    2868 @@ -3519,8 +3520,6 @@
     4255@@ -3519,8 +3521,6 @@
    28694256            *msgp++ = ':';
    28704257            *msgp++ = ' ';
     
    28754262        else
    28764263        {
    2877 @@ -3555,8 +3554,9 @@
     4264@@ -3555,8 +3555,9 @@
    28784265            msgp = confirm_msg + 1 + STRLEN(message);
    28794266            hotkp = hotk;
     
    28894276diff -Naur vim71.orig/src/misc1.c vim71/src/misc1.c
    28904277--- vim71.orig/src/misc1.c      2007-05-07 12:49:03.000000000 -0700
    2891 +++ vim71/src/misc1.c   2007-09-03 22:14:59.000000000 -0700
     4278+++ vim71/src/misc1.c   2007-10-16 14:14:28.000000000 -0700
    28924279@@ -90,7 +90,7 @@
    28934280  */
     
    30044391            (void)copy_indent(newindent, saved_line);
    30054392 
    3006 @@ -4786,7 +4824,7 @@
     4393@@ -3468,9 +3506,38 @@
     4394 #endif
     4395 
     4396 /*
     4397+ * Call expand_env() and store the result in an allocated string.
     4398+ * This is not very memory efficient, this expects the result to be freed
     4399+ * again soon.
     4400+ */
     4401+    char_u *
     4402+expand_env_save(src)
     4403+    char_u     *src;
     4404+{
     4405+    return expand_env_save_opt(src, FALSE);
     4406+}
     4407+
     4408+/*
     4409+ * Idem, but when "one" is TRUE handle the string as one file name, only
     4410+ * expand "~" at the start.
     4411+ */
     4412+    char_u *
     4413+expand_env_save_opt(src, one)
     4414+    char_u     *src;
     4415+    int                one;
     4416+{
     4417+    char_u     *p;
     4418+
     4419+    p = alloc(MAXPATHL);
     4420+    if (p != NULL)
     4421+       expand_env_esc(src, p, MAXPATHL, FALSE, one, NULL);
     4422+    return p;
     4423+}
     4424+
     4425+/*
     4426  * Expand environment variable with path name.
     4427  * "~/" is also expanded, using $HOME. For Unix "~user/" is expanded.
     4428- * Skips over "\ ", "\~" and "\$".
     4429+ * Skips over "\ ", "\~" and "\$" (not for Win32 though).
     4430  * If anything fails no expansion is done and dst equals src.
     4431  */
     4432     void
     4433@@ -3479,15 +3546,16 @@
     4434     char_u     *dst;           /* where to put the result */
     4435     int                dstlen;         /* maximum length of the result */
     4436 {
     4437-    expand_env_esc(src, dst, dstlen, FALSE, NULL);
     4438+    expand_env_esc(src, dst, dstlen, FALSE, FALSE, NULL);
     4439 }
     4440 
     4441     void
     4442-expand_env_esc(srcp, dst, dstlen, esc, startstr)
     4443+expand_env_esc(srcp, dst, dstlen, esc, one, startstr)
     4444     char_u     *srcp;          /* input string e.g. "$HOME/vim.hlp" */
     4445     char_u     *dst;           /* where to put the result */
     4446     int                dstlen;         /* maximum length of the result */
     4447     int                esc;            /* escape spaces in expanded variables */
     4448+    int                one;            /* "srcp" is one file name */
     4449     char_u     *startstr;      /* start again after this (can be NULL) */
     4450 {
     4451     char_u     *src;
     4452@@ -3728,6 +3796,8 @@
     4453        {
     4454            /*
     4455             * Recognize the start of a new name, for '~'.
     4456+            * Don't do this when "one" is TRUE, to avoid expanding "~" in
     4457+            * ":edit foo ~ foo".
     4458             */
     4459            at_start = FALSE;
     4460            if (src[0] == '\\' && src[1] != NUL)
     4461@@ -3735,7 +3805,7 @@
     4462                *dst++ = *src++;
     4463                --dstlen;
     4464            }
     4465-           else if (src[0] == ' ' || src[0] == ',')
     4466+           else if ((src[0] == ' ' || src[0] == ',') && !one)
     4467                at_start = TRUE;
     4468            *dst++ = *src++;
     4469            --dstlen;
     4470@@ -4032,23 +4102,6 @@
     4471 }
     4472 
     4473 /*
     4474- * Call expand_env() and store the result in an allocated string.
     4475- * This is not very memory efficient, this expects the result to be freed
     4476- * again soon.
     4477- */
     4478-    char_u *
     4479-expand_env_save(src)
     4480-    char_u     *src;
     4481-{
     4482-    char_u     *p;
     4483-
     4484-    p = alloc(MAXPATHL);
     4485-    if (p != NULL)
     4486-       expand_env(src, p, MAXPATHL);
     4487-    return p;
     4488-}
     4489-
     4490-/*
     4491  * Our portable version of setenv.
     4492  */
     4493     void
     4494@@ -4786,7 +4839,7 @@
    30074495 static int     cin_iswhileofdo __ARGS((char_u *, linenr_T, int));
    30084496 static int     cin_iswhileofdo_end __ARGS((int terminated, int ind_maxparen, int ind_maxcomment));
     
    30134501 static int     cin_ends_in __ARGS((char_u *, char_u *, char_u *));
    30144502 static int     cin_skip2pos __ARGS((pos_T *trypos));
    3015 @@ -5551,13 +5589,13 @@
     4503@@ -5551,13 +5604,13 @@
    30164504  * This is a lot of guessing.  Watch out for "cond ? func() : foo".
    30174505  */
     
    30294517     *col = 0;
    30304518 
    3031 @@ -5585,7 +5623,8 @@
     4519@@ -5585,7 +5638,8 @@
    30324520      */
    30334521     while (lnum > 1)
     
    30394527            break;
    30404528        while (*s != NUL)
    3041 @@ -5602,7 +5641,8 @@
     4529@@ -5602,7 +5656,8 @@
    30424530        --lnum;
    30434531     }
     
    30494537     {
    30504538        if (*s == NUL)
    3051 @@ -5610,7 +5650,10 @@
     4539@@ -5610,7 +5665,10 @@
    30524540            if (lnum == curwin->w_cursor.lnum)
    30534541                break;
     
    30614549 
    30624550        if (s[0] == ':')
    3063 @@ -7079,7 +7122,7 @@
     4551@@ -7079,7 +7137,7 @@
    30644552                n = FALSE;
    30654553                if (lookfor != LOOKFOR_TERM && ind_cpp_baseclass > 0)
     
    30704558                }
    30714559                if (n)
    3072 @@ -7670,7 +7713,7 @@
     4560@@ -7670,7 +7728,7 @@
    30734561                n = FALSE;
    30744562                if (ind_cpp_baseclass != 0 && theline[0] != '{')
     
    30794567                }
    30804568                if (n)
    3081 @@ -8596,7 +8639,7 @@
     4569@@ -8596,7 +8654,7 @@
    30824570     for (p = buf + wildoff; p < s; ++p)
    30834571        if (rem_backslash(p))
     
    30884576            --s;
    30894577        }
    3090 @@ -8897,7 +8940,7 @@
     4578@@ -8897,7 +8955,7 @@
    30914579     for (p = buf + wildoff; p < s; ++p)
    30924580        if (rem_backslash(p))
     
    30974585            --s;
    30984586        }
     4587@@ -9096,7 +9154,7 @@
     4588             */
     4589            if (vim_strpbrk(p, (char_u *)"$~") != NULL)
     4590            {
     4591-               p = expand_env_save(p);
     4592+               p = expand_env_save_opt(p, TRUE);
     4593                if (p == NULL)
     4594                    p = pat[i];
     4595 #ifdef UNIX
     4596diff -Naur vim71.orig/src/misc2.c vim71/src/misc2.c
     4597--- vim71.orig/src/misc2.c      2007-05-07 12:49:26.000000000 -0700
     4598+++ vim71/src/misc2.c   2007-10-16 14:14:41.000000000 -0700
     4599@@ -972,7 +972,7 @@
     4600        return;
     4601     entered = TRUE;
     4602 
     4603-    ++autocmd_block;       /* don't want to trigger autocommands here */
     4604+    block_autocmds();      /* don't want to trigger autocommands here */
     4605 
     4606 #ifdef FEAT_WINDOWS
     4607     /* close all tabs and windows */
     4608@@ -1037,7 +1037,9 @@
     4609 
     4610     /* Free some global vars. */
     4611     vim_free(username);
     4612+# ifdef FEAT_CLIPBOARD
     4613     vim_free(clip_exclude_prog);
     4614+# endif
     4615     vim_free(last_cmdline);
     4616     vim_free(new_last_cmdline);
     4617     set_keep_msg(NULL, 0);
    30994618diff -Naur vim71.orig/src/normal.c vim71/src/normal.c
    31004619--- vim71.orig/src/normal.c     2007-05-07 12:34:39.000000000 -0700
    3101 +++ vim71/src/normal.c  2007-09-03 22:15:06.000000000 -0700
    3102 @@ -889,6 +889,11 @@
     4620+++ vim71/src/normal.c  2007-10-16 14:14:41.000000000 -0700
     4621@@ -690,13 +690,20 @@
     4622                ca.count0 = ca.count0 * 10 + (c - '0');
     4623            if (ca.count0 < 0)      /* got too large! */
     4624                ca.count0 = 999999999L;
     4625+#ifdef FEAT_EVAL
     4626+           /* Set v:count here, when called from main() and not a stuffed
     4627+            * command, so that v:count can be used in an expression mapping
     4628+            * right after the count. */
     4629+           if (toplevel && stuff_empty())
     4630+               set_vcount(ca.count0, ca.count0 == 0 ? 1 : ca.count0);
     4631+#endif
     4632            if (ctrl_w)
     4633            {
     4634                ++no_mapping;
     4635                ++allow_keys;           /* no mapping for nchar, but keys */
     4636            }
     4637            ++no_zero_mapping;          /* don't map zero here */
     4638-           c = safe_vgetc();
     4639+           c = plain_vgetc();
     4640 #ifdef FEAT_LANGMAP
     4641            LANGMAP_ADJUST(c, TRUE);
     4642 #endif
     4643@@ -721,7 +728,7 @@
     4644            ca.count0 = 0;
     4645            ++no_mapping;
     4646            ++allow_keys;               /* no mapping for nchar, but keys */
     4647-           c = safe_vgetc();           /* get next character */
     4648+           c = plain_vgetc();          /* get next character */
     4649 #ifdef FEAT_LANGMAP
     4650            LANGMAP_ADJUST(c, TRUE);
     4651 #endif
     4652@@ -889,13 +896,18 @@
    31034653 
    31044654        ++no_mapping;
     
    31124662        {
    31134663            /*
    3114 @@ -3755,7 +3760,8 @@
     4664             * For 'g' get the next character now, so that we can check for
     4665             * "gr", "g'" and "g`".
     4666             */
     4667-           ca.nchar = safe_vgetc();
     4668+           ca.nchar = plain_vgetc();
     4669 #ifdef FEAT_LANGMAP
     4670            LANGMAP_ADJUST(ca.nchar, TRUE);
     4671 #endif
     4672@@ -952,7 +964,7 @@
     4673                im_set_active(TRUE);
     4674 #endif
     4675 
     4676-           *cp = safe_vgetc();
     4677+           *cp = plain_vgetc();
     4678 
     4679            if (langmap_active)
     4680            {
     4681@@ -1040,7 +1052,7 @@
     4682                }
     4683                if (c > 0)
     4684                {
     4685-                   c = safe_vgetc();
     4686+                   c = plain_vgetc();
     4687                    if (c != Ctrl_N && c != Ctrl_G)
     4688                        vungetc(c);
     4689                    else
     4690@@ -1059,7 +1071,7 @@
     4691            while (enc_utf8 && lang && (c = vpeekc()) > 0
     4692                                 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1))
     4693            {
     4694-               c = safe_vgetc();
     4695+               c = plain_vgetc();
     4696                if (!utf_iscomposing(c))
     4697                {
     4698                    vungetc(c);         /* it wasn't, put it back */
     4699@@ -3755,7 +3767,8 @@
    31154700     extra_len = (int)STRLEN(p);
    31164701     overflow = old_len + extra_len - SHOWCMD_COLS;
     
    31224707 
    31234708     if (char_avail())
    3124 @@ -6379,7 +6385,7 @@
     4709@@ -4558,7 +4571,7 @@
     4710 #endif
     4711            ++no_mapping;
     4712            ++allow_keys;   /* no mapping for nchar, but allow key codes */
     4713-           nchar = safe_vgetc();
     4714+           nchar = plain_vgetc();
     4715 #ifdef FEAT_LANGMAP
     4716            LANGMAP_ADJUST(nchar, TRUE);
     4717 #endif
     4718@@ -4916,7 +4929,7 @@
     4719     case 'u':  /* "zug" and "zuw": undo "zg" and "zw" */
     4720                ++no_mapping;
     4721                ++allow_keys;   /* no mapping for nchar, but allow key codes */
     4722-               nchar = safe_vgetc();
     4723+               nchar = plain_vgetc();
     4724 #ifdef FEAT_LANGMAP
     4725                LANGMAP_ADJUST(nchar, TRUE);
     4726 #endif
     4727@@ -6379,7 +6392,7 @@
    31254728      */
    31264729     else if (cap->nchar == 'p' || cap->nchar == 'P')
     
    31314734            prep_redo_cmd(cap);
    31324735            do_put(cap->oap->regname,
    3133 @@ -6662,6 +6668,13 @@
     4736@@ -6662,6 +6675,13 @@
    31344737     else
    31354738        had_ctrl_v = NUL;
     
    31454748     /* Visual mode "r" */
    31464749     if (VIsual_active)
    3147 @@ -6688,11 +6701,9 @@
     4750@@ -6688,11 +6708,9 @@
    31484751     }
    31494752 #endif
     
    31594762            || (has_mbyte && mb_charlen(ptr) < cap->count1)
    31604763 #endif
     4764@@ -8353,7 +8371,7 @@
     4765        n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP);
     4766 
     4767     /* Don't leave the cursor on the NUL past a line */
     4768-    if (curwin->w_cursor.col && gchar_cursor() == NUL)
     4769+    if (n != FAIL && curwin->w_cursor.col > 0 && gchar_cursor() == NUL)
     4770     {
     4771        --curwin->w_cursor.col;
     4772        cap->oap->inclusive = TRUE;
    31614773diff -Naur vim71.orig/src/ops.c vim71/src/ops.c
    31624774--- vim71.orig/src/ops.c        2007-05-07 12:33:47.000000000 -0700
    3163 +++ vim71/src/ops.c     2007-09-03 22:12:53.000000000 -0700
    3164 @@ -3404,7 +3404,9 @@
     4775+++ vim71/src/ops.c     2007-10-16 14:14:28.000000000 -0700
     4776@@ -2477,7 +2477,7 @@
     4777 
     4778        /*
     4779         * Spaces and tabs in the indent may have changed to other spaces and
     4780-        * tabs.  Get the starting column again and correct the lenght.
     4781+        * tabs.  Get the starting column again and correct the length.
     4782         * Don't do this when "$" used, end-of-line will have changed.
     4783         */
     4784        block_prep(oap, &bd2, oap->start.lnum, TRUE);
     4785@@ -2534,7 +2534,9 @@
     4786 #ifdef FEAT_VISUALEXTRA
     4787     long               offset;
     4788     linenr_T           linenr;
     4789-    long               ins_len, pre_textlen = 0;
     4790+    long               ins_len;
     4791+    long               pre_textlen = 0;
     4792+    long               pre_indent = 0;
     4793     char_u             *firstline;
     4794     char_u             *ins_text, *newp, *oldp;
     4795     struct block_def   bd;
     4796@@ -2579,7 +2581,9 @@
     4797                                                    || gchar_cursor() == NUL))
     4798            coladvance_force(getviscol());
     4799 # endif
     4800-       pre_textlen = (long)STRLEN(ml_get(oap->start.lnum));
     4801+       firstline = ml_get(oap->start.lnum);
     4802+       pre_textlen = (long)STRLEN(firstline);
     4803+       pre_indent = (long)(skipwhite(firstline) - firstline);
     4804        bd.textcol = curwin->w_cursor.col;
     4805     }
     4806 #endif
     4807@@ -2598,13 +2602,22 @@
     4808      */
     4809     if (oap->block_mode && oap->start.lnum != oap->end.lnum)
     4810     {
     4811+       /* Auto-indenting may have changed the indent.  If the cursor was past
     4812+        * the indent, exclude that indent change from the inserted text. */
     4813        firstline = ml_get(oap->start.lnum);
     4814-       /*
     4815-        * Subsequent calls to ml_get() flush the firstline data - take a
     4816-        * copy of the required bit.
     4817-        */
     4818-       if ((ins_len = (long)STRLEN(firstline) - pre_textlen) > 0)
     4819+       if (bd.textcol > (colnr_T)pre_indent)
     4820+       {
     4821+           long new_indent = (long)(skipwhite(firstline) - firstline);
     4822+
     4823+           pre_textlen += new_indent - pre_indent;
     4824+           bd.textcol += new_indent - pre_indent;
     4825+       }
     4826+
     4827+       ins_len = (long)STRLEN(firstline) - pre_textlen;
     4828+       if (ins_len > 0)
     4829        {
     4830+           /* Subsequent calls to ml_get() flush the firstline data - take a
     4831+            * copy of the inserted text.  */
     4832            if ((ins_text = alloc_check((unsigned)(ins_len + 1))) != NULL)
     4833            {
     4834                vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len);
     4835@@ -3404,7 +3417,9 @@
    31654836 
    31664837 #ifdef FEAT_VIRTUALEDIT
     
    31754846diff -Naur vim71.orig/src/option.c vim71/src/option.c
    31764847--- vim71.orig/src/option.c     2007-05-01 04:26:10.000000000 -0700
    3177 +++ vim71/src/option.c  2007-09-03 22:14:43.000000000 -0700
    3178 @@ -4628,7 +4628,7 @@
     4848+++ vim71/src/option.c  2007-10-16 14:14:38.000000000 -0700
     4849@@ -427,6 +427,8 @@
     4850 #define P_NOGLOB       0x100000L/* do not use local value for global vimrc */
     4851 #define P_NFNAME       0x200000L/* only normal file name chars allowed */
     4852 #define P_INSECURE     0x400000L/* option was set from a modeline */
     4853+#define P_PRI_MKRC     0x800000L/* priority for :mkvimrc (setting option has
     4854+                                  side effects) */
     4855 
     4856 #define ISK_LATIN1  (char_u *)"@,48-57,_,192-255"
     4857 
     4858@@ -773,6 +775,8 @@
     4859                            {(char_u *)0L, (char_u *)0L}
     4860 #endif
     4861                            },
     4862+                           /* P_PRI_MKRC isn't needed here, optval_default()
     4863+                            * always returns TRUE for 'compatible' */
     4864     {"compatible",  "cp",   P_BOOL|P_RALL,
     4865                            (char_u *)&p_cp, PV_NONE,
     4866                            {(char_u *)TRUE, (char_u *)FALSE}},
     4867@@ -1515,7 +1519,7 @@
     4868                            {(char_u *)0L, (char_u *)0L}
     4869 #endif
     4870                            },
     4871-    {"keymap",     "kmp",  P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME,
     4872+    {"keymap",     "kmp",  P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
     4873 #ifdef FEAT_KEYMAP
     4874                            (char_u *)&p_keymap, PV_KMAP,
     4875                            {(char_u *)"", (char_u *)0L}
     4876@@ -1836,7 +1840,7 @@
     4877     {"paragraphs",  "para", P_STRING|P_VI_DEF,
     4878                            (char_u *)&p_para, PV_NONE,
     4879                            {(char_u *)"IPLPPPQPP LIpplpipbp", (char_u *)0L}},
     4880-    {"paste",      NULL,   P_BOOL|P_VI_DEF,
     4881+    {"paste",      NULL,   P_BOOL|P_VI_DEF|P_PRI_MKRC,
     4882                            (char_u *)&p_paste, PV_NONE,
     4883                            {(char_u *)FALSE, (char_u *)0L}},
     4884     {"pastetoggle", "pt",   P_STRING|P_VI_DEF,
     4885@@ -4628,7 +4632,7 @@
    31794886                                    if ((!(flags & P_COMMA) || *s != ',')
    31804887                                            && vim_strchr(s + 1, *s) != NULL)
     
    31854892                                    }
    31864893                            }
    3187 @@ -7118,6 +7118,11 @@
     4894@@ -4992,7 +4996,7 @@
     4895      * For 'spellsuggest' expand after "file:".
     4896      */
     4897     expand_env_esc(val, NameBuff, MAXPATHL,
     4898-           (char_u **)options[opt_idx].var == &p_tags,
     4899+           (char_u **)options[opt_idx].var == &p_tags, FALSE,
     4900 #ifdef FEAT_SPELL
     4901            (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
     4902 #endif
     4903@@ -6348,7 +6352,7 @@
     4904                errmsg = check_stl_option(p_ruf);
     4905        }
     4906        /* check 'statusline' only if it doesn't start with "%!" */
     4907-       else if (varp != &p_stl || s[0] != '%' || s[1] != '!')
     4908+       else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
     4909            errmsg = check_stl_option(s);
     4910        if (varp == &p_ruf && errmsg == NULL)
     4911            comp_col();
     4912@@ -7118,6 +7122,11 @@
    31884913     /* when 'endofline' is changed, redraw the window title */
    31894914     else if ((int *)varp == &curbuf->b_p_eol)
     
    31974922 
    31984923     /* when 'bin' is set also set some other options */
    3199 @@ -8219,6 +8224,25 @@
     4924@@ -7815,6 +7824,8 @@
     4925            errmsg = e_positive;
     4926            p_ch = 1;
     4927        }
     4928+       if (p_ch > Rows - min_rows() + 1)
     4929+           p_ch = Rows - min_rows() + 1;
     4930 
     4931        /* Only compute the new window layout when startup has been
     4932         * completed. Otherwise the frame sizes may be wrong. */
     4933@@ -8219,6 +8230,25 @@
    32004934            varp = get_varp(&options[opt_idx]);
    32014935            if (varp != NULL)   /* hidden option is not changed */
     
    32234957                    (void)set_num_option(opt_idx, varp, number,
    32244958                                                          NULL, 0, opt_flags);
    3225 @@ -10585,6 +10609,8 @@
     4959@@ -8511,13 +8541,20 @@
     4960     char_u             *varp_local = NULL;     /* fresh value */
     4961     char               *cmd;
     4962     int                        round;
     4963+    int                        pri;
     4964 
     4965     /*
     4966      * The options that don't have a default (terminal name, columns, lines)
     4967      * are never written.  Terminal options are also not written.
     4968+     * Do the loop over "options[]" twice: once for options with the
     4969+     * P_PRI_MKRC flag and once without.
     4970      */
     4971-    for (p = &options[0]; !istermoption(p); p++)
     4972-       if (!(p->flags & P_NO_MKRC) && !istermoption(p))
     4973+    for (pri = 1; pri >= 0; --pri)
     4974+    {
     4975+      for (p = &options[0]; !istermoption(p); p++)
     4976+       if (!(p->flags & P_NO_MKRC)
     4977+               && !istermoption(p)
     4978+               && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
     4979        {
     4980            /* skip global option when only doing locals */
     4981            if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
     4982@@ -8613,6 +8650,7 @@
     4983                }
     4984            }
     4985        }
     4986+    }
     4987     return OK;
     4988 }
     4989 
     4990@@ -8715,6 +8753,8 @@
     4991     char       *name;
     4992     int                value;
     4993 {
     4994+    if (value < 0)     /* global/local option using global value */
     4995+       return OK;
     4996     if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
     4997            || put_eol(fd) < 0)
     4998        return FAIL;
     4999@@ -10585,6 +10625,8 @@
    32265000     buf->b_start_ffc = *buf->b_p_ff;
    32275001     buf->b_start_eol = buf->b_p_eol;
     
    32325006     if (buf->b_start_fenc == NULL
    32335007                             || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
    3234 @@ -10598,13 +10624,17 @@
     5008@@ -10598,13 +10640,17 @@
    32355009 /*
    32365010  * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
     
    32515025            && buf->b_ml.ml_line_count == 1
    32525026            && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
    3253 @@ -10614,6 +10644,8 @@
     5027@@ -10614,6 +10660,8 @@
    32545028     if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
    32555029        return TRUE;
     
    32625036diff -Naur vim71.orig/src/os_unix.c vim71/src/os_unix.c
    32635037--- vim71.orig/src/os_unix.c    2007-05-09 12:41:58.000000000 -0700
    3264 +++ vim71/src/os_unix.c 2007-09-03 22:15:38.000000000 -0700
     5038+++ vim71/src/os_unix.c 2007-10-16 14:14:22.000000000 -0700
    32655039@@ -753,7 +753,8 @@
    32665040     if (signal_stack != NULL)
     
    32985072diff -Naur vim71.orig/src/os_unix.h vim71/src/os_unix.h
    32995073--- vim71.orig/src/os_unix.h    2007-05-07 12:35:05.000000000 -0700
    3300 +++ vim71/src/os_unix.h 2007-09-03 22:13:13.000000000 -0700
     5074+++ vim71/src/os_unix.h 2007-10-16 14:14:06.000000000 -0700
    33015075@@ -508,6 +508,9 @@
    33025076 #if !defined(S_ISFIFO) && defined(S_IFIFO)
     
    33115085diff -Naur vim71.orig/src/popupmnu.c vim71/src/popupmnu.c
    33125086--- vim71.orig/src/popupmnu.c   2007-03-24 13:07:39.000000000 -0700
    3313 +++ vim71/src/popupmnu.c        2007-09-03 22:14:24.000000000 -0700
     5087+++ vim71/src/popupmnu.c        2007-10-16 14:14:09.000000000 -0700
    33145088@@ -75,7 +75,6 @@
    33155089 
     
    35455319diff -Naur vim71.orig/src/proto/charset.pro vim71/src/proto/charset.pro
    35465320--- vim71.orig/src/proto/charset.pro    2007-05-12 03:39:01.000000000 -0700
    3547 +++ vim71/src/proto/charset.pro 2007-09-03 22:15:22.000000000 -0700
     5321+++ vim71/src/proto/charset.pro 2007-10-16 14:14:20.000000000 -0700
    35485322@@ -21,6 +21,7 @@
    35495323 int vim_iswordp __ARGS((char_u *p));
     
    35565330diff -Naur vim71.orig/src/proto/fileio.pro vim71/src/proto/fileio.pro
    35575331--- vim71.orig/src/proto/fileio.pro     2007-05-12 03:39:14.000000000 -0700
    3558 +++ vim71/src/proto/fileio.pro  2007-09-03 22:12:50.000000000 -0700
     5332+++ vim71/src/proto/fileio.pro  2007-10-16 14:14:31.000000000 -0700
    35595333@@ -2,6 +2,7 @@
    35605334 void filemess __ARGS((buf_T *buf, char_u *name, char_u *s, int attr));
     
    35655339 void msg_add_fname __ARGS((buf_T *buf, char_u *fname));
    35665340 void msg_add_lines __ARGS((int insert_space, long lnum, long nchars));
     5341@@ -39,6 +40,8 @@
     5342 int trigger_cursorhold __ARGS((void));
     5343 int has_cursormoved __ARGS((void));
     5344 int has_cursormovedI __ARGS((void));
     5345+void block_autocmds __ARGS((void));
     5346+void unblock_autocmds __ARGS((void));
     5347 int has_autocmd __ARGS((event_T event, char_u *sfname, buf_T *buf));
     5348 char_u *get_augroup_name __ARGS((expand_T *xp, int idx));
     5349 char_u *set_context_in_autocmd __ARGS((expand_T *xp, char_u *arg, int doautocmd));
     5350diff -Naur vim71.orig/src/proto/getchar.pro vim71/src/proto/getchar.pro
     5351--- vim71.orig/src/proto/getchar.pro    2007-05-12 03:39:16.000000000 -0700
     5352+++ vim71/src/proto/getchar.pro 2007-10-16 14:14:28.000000000 -0700
     5353@@ -38,6 +38,7 @@
     5354 void updatescript __ARGS((int c));
     5355 int vgetc __ARGS((void));
     5356 int safe_vgetc __ARGS((void));
     5357+int plain_vgetc __ARGS((void));
     5358 int vpeekc __ARGS((void));
     5359 int vpeekc_nomap __ARGS((void));
     5360 int vpeekc_any __ARGS((void));
     5361diff -Naur vim71.orig/src/proto/if_cscope.pro vim71/src/proto/if_cscope.pro
     5362--- vim71.orig/src/proto/if_cscope.pro  2007-05-12 03:39:21.000000000 -0700
     5363+++ vim71/src/proto/if_cscope.pro       2007-10-16 14:14:28.000000000 -0700
     5364@@ -6,4 +6,5 @@
     5365 void cs_free_tags __ARGS((void));
     5366 void cs_print_tags __ARGS((void));
     5367 int cs_connection __ARGS((int num, char_u *dbpath, char_u *ppath));
     5368+void cs_end __ARGS((void));
     5369 /* vim: set ft=c : */
    35675370diff -Naur vim71.orig/src/proto/mbyte.pro vim71/src/proto/mbyte.pro
    35685371--- vim71.orig/src/proto/mbyte.pro      2007-05-12 03:39:38.000000000 -0700
    3569 +++ vim71/src/proto/mbyte.pro   2007-09-03 22:15:45.000000000 -0700
     5372+++ vim71/src/proto/mbyte.pro   2007-10-16 14:14:28.000000000 -0700
    35705373@@ -12,9 +12,9 @@
    35715374 int utf_ptr2cells __ARGS((char_u *p));
     
    35815384 int utf_ptr2char __ARGS((char_u *p));
    35825385 int mb_ptr2char_adv __ARGS((char_u **pp));
     5386diff -Naur vim71.orig/src/proto/misc1.pro vim71/src/proto/misc1.pro
     5387--- vim71.orig/src/proto/misc1.pro      2007-05-12 03:39:34.000000000 -0700
     5388+++ vim71/src/proto/misc1.pro   2007-10-16 14:14:28.000000000 -0700
     5389@@ -48,10 +48,11 @@
     5390 void vim_beep __ARGS((void));
     5391 void init_homedir __ARGS((void));
     5392 void free_homedir __ARGS((void));
     5393+char_u *expand_env_save __ARGS((char_u *src));
     5394+char_u *expand_env_save_opt __ARGS((char_u *src, int one));
     5395 void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
     5396-void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, char_u *startstr));
     5397+void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, int one, char_u *startstr));
     5398 char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
     5399-char_u *expand_env_save __ARGS((char_u *src));
     5400 void vim_setenv __ARGS((char_u *name, char_u *val));
     5401 char_u *get_env_name __ARGS((expand_T *xp, int idx));
     5402 void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
    35835403diff -Naur vim71.orig/src/proto/search.pro vim71/src/proto/search.pro
    35845404--- vim71.orig/src/proto/search.pro     2007-05-12 03:39:50.000000000 -0700
    3585 +++ vim71/src/proto/search.pro  2007-09-03 22:14:24.000000000 -0700
     5405+++ vim71/src/proto/search.pro  2007-10-16 14:14:09.000000000 -0700
    35865406@@ -1,6 +1,7 @@
    35875407 /* search.c */
     
    35945414diff -Naur vim71.orig/src/proto/syntax.pro vim71/src/proto/syntax.pro
    35955415--- vim71.orig/src/proto/syntax.pro     2007-05-12 03:39:52.000000000 -0700
    3596 +++ vim71/src/proto/syntax.pro  2007-09-03 22:13:33.000000000 -0700
     5416+++ vim71/src/proto/syntax.pro  2007-10-16 14:14:07.000000000 -0700
    35975417@@ -8,6 +8,8 @@
    35985418 void syntax_clear __ARGS((buf_T *buf));
     
    36065426diff -Naur vim71.orig/src/proto/window.pro vim71/src/proto/window.pro
    36075427--- vim71.orig/src/proto/window.pro     2007-05-12 03:40:00.000000000 -0700
    3608 +++ vim71/src/proto/window.pro  2007-09-03 22:13:43.000000000 -0700
     5428+++ vim71/src/proto/window.pro  2007-10-16 14:14:07.000000000 -0700
    36095429@@ -59,4 +59,8 @@
    36105430 int only_one_window __ARGS((void));
     
    36185438diff -Naur vim71.orig/src/quickfix.c vim71/src/quickfix.c
    36195439--- vim71.orig/src/quickfix.c   2007-02-03 16:50:17.000000000 -0800
    3620 +++ vim71/src/quickfix.c        2007-09-03 22:12:48.000000000 -0700
     5440+++ vim71/src/quickfix.c        2007-10-16 14:14:28.000000000 -0700
     5441@@ -1612,8 +1612,8 @@
     5442        }
     5443 
     5444        /*
     5445-        * If there is only one window and is the quickfix window, create a new
     5446-        * one above the quickfix window.
     5447+        * If there is only one window and it is the quickfix window, create a
     5448+        * new one above the quickfix window.
     5449         */
     5450        if (((firstwin == lastwin) && bt_quickfix(curbuf)) || !usable_win)
     5451        {
    36215452@@ -2331,7 +2331,7 @@
    36225453            set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
     
    36285459 
    36295460        /* Only set the height when still in the same tab page and there is no
     5461@@ -2981,6 +2981,7 @@
     5462     buf_T      *buf;
     5463     int                duplicate_name = FALSE;
     5464     int                using_dummy;
     5465+    int                redraw_for_dummy = FALSE;
     5466     int                found_match;
     5467     buf_T      *first_match_buf = NULL;
     5468     time_t     seconds = 0;
     5469@@ -3097,6 +3098,7 @@
     5470            /* Remember that a buffer with this name already exists. */
     5471            duplicate_name = (buf != NULL);
     5472            using_dummy = TRUE;
     5473+           redraw_for_dummy = TRUE;
     5474 
     5475 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
     5476            /* Don't do Filetype autocommands to avoid loading syntax and
     5477@@ -3243,11 +3245,29 @@
     5478     if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
     5479     {
     5480        if ((flags & VGR_NOJUMP) == 0)
     5481+       {
     5482+           buf = curbuf;
     5483            qf_jump(qi, 0, 0, eap->forceit);
     5484+           if (buf != curbuf)
     5485+               /* If we jumped to another buffer redrawing will already be
     5486+                * taken care of. */
     5487+               redraw_for_dummy = FALSE;
     5488+       }
     5489     }
     5490     else
     5491        EMSG2(_(e_nomatch2), s);
     5492 
     5493+    /* If we loaded a dummy buffer into the current window, the autocommands
     5494+     * may have messed up things, need to redraw and recompute folds. */
     5495+    if (redraw_for_dummy)
     5496+    {
     5497+#ifdef FEAT_FOLDING
     5498+       foldUpdateAll(curwin);
     5499+#else
     5500+       redraw_later(NOT_VALID);
     5501+#endif
     5502+    }
     5503+
     5504 theend:
     5505     vim_free(regmatch.regprog);
     5506 }
    36305507diff -Naur vim71.orig/src/regexp.c vim71/src/regexp.c
    36315508--- vim71.orig/src/regexp.c     2007-05-07 12:50:03.000000000 -0700
    3632 +++ vim71/src/regexp.c  2007-09-03 22:14:31.000000000 -0700
     5509+++ vim71/src/regexp.c  2007-10-16 14:14:09.000000000 -0700
    36335510@@ -2220,7 +2220,7 @@
    36345511                                break;
     
    37425619diff -Naur vim71.orig/src/screen.c vim71/src/screen.c
    37435620--- vim71.orig/src/screen.c     2007-05-07 12:27:53.000000000 -0700
    3744 +++ vim71/src/screen.c  2007-09-03 22:15:45.000000000 -0700
     5621+++ vim71/src/screen.c  2007-10-16 14:14:28.000000000 -0700
    37455622@@ -100,27 +100,7 @@
    37465623 static int     screen_cur_row, screen_cur_col; /* last known cursor position */
     
    39015778     else
    39025779     {
    3903 @@ -2542,7 +2555,7 @@
     5780@@ -2292,9 +2305,11 @@
     5781                        prev_c = u8c;
     5782 #endif
     5783                    /* Non-BMP character: display as ? or fullwidth ?. */
     5784+#ifdef UNICODE16
     5785                    if (u8c >= 0x10000)
     5786                        ScreenLinesUC[idx] = (cells == 2) ? 0xff1f : (int)'?';
     5787                    else
     5788+#endif
     5789                        ScreenLinesUC[idx] = u8c;
     5790                    for (i = 0; i < Screen_mco; ++i)
     5791                    {
     5792@@ -2542,7 +2557,7 @@
    39045793 
    39055794     char_u     extra[18];              /* "%ld" and 'fdc' must fit in here */
     
    39105799     int                extra_attr = 0;         /* attributes when n_extra != 0 */
    39115800     static char_u *at_end_str = (char_u *)""; /* used for p_extra when
    3912 @@ -2626,10 +2639,13 @@
     5801@@ -2626,10 +2641,13 @@
    39135802     int                line_attr = 0;          /* atrribute for the whole line */
    39145803 #endif
     
    39285817 #ifdef FEAT_ARABIC
    39295818     int                prev_c = 0;             /* previous Arabic character */
    3930 @@ -3074,12 +3090,20 @@
     5819@@ -3074,12 +3092,20 @@
    39315820 
    39325821 #ifdef FEAT_SEARCH_EXTRA
     
    39535842        shl->endcol = MAXCOL;
    39545843        shl->attr_cur = 0;
    3955 @@ -3122,6 +3146,8 @@
     5844@@ -3122,6 +3148,8 @@
    39565845                area_highlighting = TRUE;
    39575846            }
     
    39625851 #endif
    39635852 
    3964 @@ -3163,10 +3189,8 @@
     5853@@ -3163,10 +3191,8 @@
    39655854                if (cmdwin_type != 0 && wp == curwin)
    39665855                {
     
    39745863                }
    39755864            }
    3976 @@ -3182,6 +3206,7 @@
     5865@@ -3182,6 +3208,7 @@
    39775866                    fill_foldcolumn(extra, wp, FALSE, lnum);
    39785867                    n_extra = wp->w_p_fdc;
     
    39825871                    char_attr = hl_attr(HLF_FC);
    39835872                }
    3984 @@ -3388,13 +3413,24 @@
     5873@@ -3388,13 +3415,24 @@
    39855874                 * After end, check for start/end of next match.
    39865875                 * When another match, have to check for start again.
     
    40125901                    {
    40135902                        if (shl->startcol != MAXCOL
    4014 @@ -3442,26 +3478,43 @@
     5903@@ -3442,26 +3480,43 @@
    40155904                        }
    40165905                        break;
     
    40655954                line_attr = hl_attr(diff_hlf);
    40665955            }
    4067 @@ -3496,9 +3549,11 @@
     5956@@ -3496,9 +3551,11 @@
    40685957         * Get the next character to put on the screen.
    40695958         */
     
    40805969         */
    40815970        if (n_extra > 0)
    4082 @@ -3611,6 +3666,8 @@
     5971@@ -3611,6 +3668,8 @@
    40835972                         * Draw it as a space with a composing char. */
    40845973                        if (utf_iscomposing(mb_c))
     
    40895978                                u8cc[i] = u8cc[i - 1];
    40905979                            u8cc[0] = mb_c;
    4091 @@ -3752,10 +3809,8 @@
     5980@@ -3621,13 +3680,18 @@
     5981                    if ((mb_l == 1 && c >= 0x80)
     5982                            || (mb_l >= 1 && mb_c == 0)
     5983                            || (mb_l > 1 && (!vim_isprintc(mb_c)
     5984-                                                        || mb_c >= 0x10000)))
     5985+# ifdef UNICODE16
     5986+                                                        || mb_c >= 0x10000
     5987+# endif
     5988+                                                        )))
     5989                    {
     5990                        /*
     5991                         * Illegal UTF-8 byte: display as <xx>.
     5992                         * Non-BMP character : display as ? or fullwidth ?.
     5993                         */
     5994+# ifdef UNICODE16
     5995                        if (mb_c < 0x10000)
     5996+# endif
     5997                        {
     5998                            transchar_hex(extra, mb_c);
     5999 # ifdef FEAT_RIGHTLEFT
     6000@@ -3635,11 +3699,13 @@
     6001                                rl_mirror(extra);
     6002 # endif
     6003                        }
     6004+# ifdef UNICODE16
     6005                        else if (utf_char2cells(mb_c) != 2)
     6006                            STRCPY(extra, "?");
     6007                        else
     6008                            /* 0xff1f in UTF-8: full-width '?' */
     6009                            STRCPY(extra, "\357\274\237");
     6010+# endif
     6011 
     6012                        p_extra = extra;
     6013                        c = *p_extra;
     6014@@ -3752,10 +3818,8 @@
    40926015                 * a '<' in the first column. */
    40936016                if (n_skip > 0 && mb_l > 1)
     
    41016024                    if (area_attr == 0 && search_attr == 0)
    41026025                    {
    4103 @@ -4254,14 +4309,29 @@
     6026@@ -4254,14 +4318,29 @@
    41046027             * highlight match at end of line. If it's beyond the last
    41056028             * char on the screen, just overwrite that one (tricky!)  Not
     
    41356058                            && did_line_attr <= 1
    41366059 # endif
    4137 @@ -4302,15 +4372,27 @@
     6060@@ -4302,15 +4381,27 @@
    41386061 #ifdef FEAT_SEARCH_EXTRA
    41396062                if (area_attr == 0)
     
    41706093                }
    41716094 #endif
    4172 @@ -4460,6 +4542,8 @@
     6095@@ -4460,6 +4551,8 @@
    41736096            {
    41746097                if (mb_utf8)
     
    41796102                    if ((c & 0xff) == 0)
    41806103                        ScreenLines[off] = 0x80;   /* avoid storing zero */
    4181 @@ -4548,7 +4632,7 @@
     6104@@ -4548,7 +4641,7 @@
    41826105 
    41836106        /*
     
    41886111        if ((
    41896112 #ifdef FEAT_RIGHTLEFT
    4190 @@ -4625,9 +4709,13 @@
     6113@@ -4625,9 +4718,13 @@
    41916114 #endif
    41926115 #ifdef FEAT_MBYTE
     
    42046127                   )
    42056128                {
    4206 @@ -4787,6 +4875,10 @@
     6129@@ -4787,6 +4884,10 @@
    42076130 {
    42086131     unsigned       off_from;
     
    42156138 #if defined(FEAT_GUI) || defined(UNIX) || defined(FEAT_VERTSPLIT)
    42166139     int                    hl;
    4217 @@ -4813,6 +4905,10 @@
     6140@@ -4813,6 +4914,10 @@
    42186141 
    42196142     off_from = (unsigned)(current_ScreenLine - ScreenLines);
     
    42266149 #ifdef FEAT_RIGHTLEFT
    42276150     if (rlflag)
    4228 @@ -4847,7 +4943,7 @@
     6151@@ -4847,7 +4952,7 @@
    42296152     {
    42306153 #ifdef FEAT_MBYTE
     
    42356158            char_cells = 1;
    42366159 #endif
    4237 @@ -4924,7 +5020,7 @@
     6160@@ -4924,7 +5029,7 @@
    42386161                 * ScreenLinesUC[] is sufficient. */
    42396162                if (char_cells == 1
     
    42446167                    /* Writing a single-cell character over a double-cell
    42456168                     * character: need to redraw the next cell. */
    4246 @@ -4933,8 +5029,8 @@
     6169@@ -4933,8 +5038,8 @@
    42476170                }
    42486171                else if (char_cells == 2
     
    42556178                    /* Writing the second half of a double-cell character over
    42566179                     * a double-cell character: need to redraw the second
    4257 @@ -4953,10 +5049,10 @@
     6180@@ -4953,10 +5058,10 @@
    42586181             * char over the left halve of an existing one. */
    42596182            if (has_mbyte && col + char_cells == endcol
     
    42696192 #endif
    42706193 
    4271 @@ -5096,10 +5192,11 @@
     6194@@ -5096,10 +5201,11 @@
    42726195                        /* find previous character by counting from first
    42736196                         * column and get its width. */
     
    42826205                        }
    42836206                    }
    4284 @@ -5285,7 +5382,7 @@
     6207@@ -5285,7 +5391,7 @@
    42856208 static int skip_status_match_char __ARGS((expand_T *xp, char_u *s));
    42866209 
     
    42916214     static int
    42926215 status_match_len(xp, s)
    4293 @@ -5351,7 +5448,7 @@
     6216@@ -5351,7 +5457,7 @@
    42946217     int                row;
    42956218     char_u     *buf;
     
    43006223     int                attr;
    43016224     int                i;
    4302 @@ -6103,6 +6200,7 @@
     6225@@ -6103,6 +6209,7 @@
    43036226     char_u     *ptr = text;
    43046227     int                c;
     
    43086231     int                mbyte_cells = 1;
    43096232     int                u8c = 0;
    4310 @@ -6119,8 +6217,12 @@
     6233@@ -6119,8 +6226,12 @@
    43116234        return;
    43126235 
     
    43236246        c = *ptr;
    43246247 #ifdef FEAT_MBYTE
    4325 @@ -6241,19 +6343,19 @@
     6248@@ -6143,6 +6254,7 @@
     6249                else
     6250                    u8c = utfc_ptr2char(ptr, u8cc);
     6251                mbyte_cells = utf_char2cells(u8c);
     6252+# ifdef UNICODE16
     6253                /* Non-BMP character: display as ? or fullwidth ?. */
     6254                if (u8c >= 0x10000)
     6255                {
     6256@@ -6150,6 +6262,7 @@
     6257                    if (attr == 0)
     6258                        attr = hl_attr(HLF_8);
     6259                }
     6260+# endif
     6261 # ifdef FEAT_ARABIC
     6262                if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c))
     6263                {
     6264@@ -6241,19 +6354,19 @@
    43266265            else if (has_mbyte
    43276266                    && (len < 0 ? ptr[mbyte_blen] == NUL
     
    43496288 #endif
    43506289            ScreenLines[off] = c;
    4351 @@ -6318,7 +6420,7 @@
     6290@@ -6318,7 +6431,7 @@
    43526291 
    43536292 #ifdef FEAT_SEARCH_EXTRA
     
    43586297     static void
    43596298 start_search_hl()
    4360 @@ -6331,7 +6433,7 @@
     6299@@ -6331,7 +6444,7 @@
    43616300 }
    43626301 
     
    43676306     static void
    43686307 end_search_hl()
    4369 @@ -6351,18 +6453,28 @@
     6308@@ -6351,18 +6464,28 @@
    43706309     win_T      *wp;
    43716310     linenr_T   lnum;
     
    44016340                && shl->lnum == 0
    44026341                && re_multiline(shl->rm.regprog))
    4403 @@ -6397,11 +6509,13 @@
     6342@@ -6397,11 +6520,13 @@
    44046343                }
    44056344            }
     
    44166355  * Sets shl->lnum and shl->rm contents.
    44176356  * Note: Assumes a previous match is always before "lnum", unless
    4418 @@ -6411,7 +6525,7 @@
     6357@@ -6411,7 +6536,7 @@
    44196358     static void
    44206359 next_search_hl(win, shl, lnum, mincol)
     
    44256364     colnr_T    mincol;         /* minimal column for a match */
    44266365 {
    4427 @@ -6479,7 +6593,7 @@
     6366@@ -6479,7 +6604,7 @@
    44286367            /* Error while handling regexp: stop using this regexp. */
    44296368            if (shl == &search_hl)
     
    44346373                no_hlsearch = TRUE;
    44356374            }
    4436 @@ -6827,6 +6941,9 @@
     6375@@ -6827,6 +6952,9 @@
    44376376 {
    44386377     int                r, c;
     
    44446383     /* Can't use ScreenLines unless initialized */
    44456384     if (ScreenLines == NULL)
    4446 @@ -6837,10 +6954,13 @@
     6385@@ -6837,10 +6965,13 @@
    44476386     for (r = row; r < row + height; ++r)
    44486387     {
     
    44596398                screen_char_2(off + c, r, c);
    44606399                ++c;
    4461 @@ -6850,7 +6970,7 @@
     6400@@ -6850,7 +6981,7 @@
    44626401            {
    44636402                screen_char(off + c, r, c);
     
    44706409diff -Naur vim71.orig/src/search.c vim71/src/search.c
    44716410--- vim71.orig/src/search.c     2007-05-07 12:42:02.000000000 -0700
    4472 +++ vim71/src/search.c  2007-09-03 22:14:24.000000000 -0700
     6411+++ vim71/src/search.c  2007-10-16 14:14:09.000000000 -0700
    44736412@@ -101,7 +101,6 @@
    44746413 static char_u      *mr_pattern = NULL; /* pattern used by search_regcomp() */
     
    46076546diff -Naur vim71.orig/src/spell.c vim71/src/spell.c
    46086547--- vim71.orig/src/spell.c      2007-05-07 12:48:38.000000000 -0700
    4609 +++ vim71/src/spell.c   2007-09-03 22:14:08.000000000 -0700
     6548+++ vim71/src/spell.c   2007-10-16 14:14:09.000000000 -0700
    46106549@@ -7829,7 +7829,7 @@
    46116550 # if (_MSC_VER <= 1200)
     
    46626601diff -Naur vim71.orig/src/structs.h vim71/src/structs.h
    46636602--- vim71.orig/src/structs.h    2007-05-07 12:50:49.000000000 -0700
    4664 +++ vim71/src/structs.h 2007-09-03 22:14:43.000000000 -0700
    4665 @@ -1453,6 +1453,7 @@
     6603+++ vim71/src/structs.h 2007-10-16 14:14:38.000000000 -0700
     6604@@ -278,6 +278,9 @@
     6605     linenr_T   ue_lcount;      /* linecount when u_save called */
     6606     char_u     **ue_array;     /* array of lines in undo block */
     6607     long       ue_size;        /* number of lines in ue_array */
     6608+#ifdef U_DEBUG
     6609+    int                ue_magic;       /* magic number to check allocation */
     6610+#endif
     6611 };
     6612 
     6613 struct u_header
     6614@@ -300,6 +303,9 @@
     6615     visualinfo_T uh_visual;    /* Visual areas before undo/after redo */
     6616 #endif
     6617     time_t     uh_time;        /* timestamp when the change was made */
     6618+#ifdef U_DEBUG
     6619+    int                uh_magic;       /* magic number to check allocation */
     6620+#endif
     6621 };
     6622 
     6623 /* values for uh_flags */
     6624@@ -1453,6 +1459,7 @@
    46666625 #ifdef FEAT_MBYTE
    46676626     char_u     *b_start_fenc;  /* 'fileencoding' when edit started or NULL */
     
    46716630 
    46726631 #ifdef FEAT_EVAL
    4673 @@ -1694,6 +1695,41 @@
     6632@@ -1694,6 +1701,41 @@
    46746633 #define FR_COL 2       /* frame with a column of windows */
    46756634 
     
    47136672  *
    47146673  * All row numbers are relative to the start of the window, except w_winrow.
    4715 @@ -1934,9 +1970,8 @@
     6674@@ -1934,9 +1976,8 @@
    47166675 #endif
    47176676 
     
    47276686diff -Naur vim71.orig/src/syntax.c vim71/src/syntax.c
    47286687--- vim71.orig/src/syntax.c     2007-05-07 12:42:55.000000000 -0700
    4729 +++ vim71/src/syntax.c  2007-09-03 22:15:47.000000000 -0700
     6688+++ vim71/src/syntax.c  2007-10-16 14:14:41.000000000 -0700
    47306689@@ -66,8 +66,10 @@
    47316690 #define HL_TABLE() ((struct hl_group *)((highlight_ga.ga_data)))
     
    48206779      * Check for being called with a START pattern.
    48216780      * Can happen with a match that continues to the next line, because it
    4822 @@ -4460,8 +4491,8 @@
     6781@@ -3323,6 +3354,7 @@
     6782     {
     6783        vim_free(SYN_ITEMS(buf)[i].sp_cont_list);
     6784        vim_free(SYN_ITEMS(buf)[i].sp_next_list);
     6785+       vim_free(SYN_ITEMS(buf)[i].sp_syn.cont_in_list);
     6786     }
     6787 }
     6788 
     6789@@ -4460,8 +4492,8 @@
    48236790     current_syn_inc_tag = ++running_syn_inc_tag;
    48246791     prev_toplvl_grp = curbuf->b_syn_topgrp;
     
    48316798     curbuf->b_syn_topgrp = prev_toplvl_grp;
    48326799     current_syn_inc_tag = prev_syn_inc_tag;
    4833 @@ -5956,8 +5987,8 @@
     6800@@ -5956,8 +5988,8 @@
    48346801 {
    48356802     return (buf->b_syn_patterns.ga_len != 0
     
    48426809 
    48436810 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
    4844 @@ -5968,6 +5999,29 @@
     6811@@ -5968,6 +6000,29 @@
    48456812     EXP_CASE       /* expand ":syn case" arguments */
    48466813 } expand_what;
     
    48726839 /*
    48736840  * Handle command line completion for :syntax command.
    4874 @@ -5983,8 +6037,8 @@
     6841@@ -5983,8 +6038,8 @@
    48756842     xp->xp_context = EXPAND_SYNTAX;
    48766843     expand_what = EXP_SUBCMD;
     
    48836850     /* (part of) subcommand already typed */
    48846851     if (*arg != NUL)
    4885 @@ -8479,7 +8533,7 @@
     6852@@ -8479,7 +8534,7 @@
    48866853 syn_id2name(id)
    48876854     int                id;
     
    48926859     return HL_TABLE()[id - 1].sg_name;
    48936860 }
    4894 @@ -8949,7 +9003,7 @@
     6861@@ -8949,7 +9004,7 @@
    48956862     return OK;
    48966863 }
     
    49016868 static void highlight_list __ARGS((void));
    49026869 static void highlight_list_two __ARGS((int cnt, int attr));
    4903 @@ -8967,8 +9021,8 @@
     6870@@ -8967,8 +9022,8 @@
    49046871     /* Default: expand group names */
    49056872     xp->xp_context = EXPAND_HIGHLIGHT;
     
    49126879     /* (part of) subcommand already typed */
    49136880     if (*arg != NUL)
    4914 @@ -8976,7 +9030,7 @@
     6881@@ -8976,7 +9031,7 @@
    49156882        p = skiptowhite(arg);
    49166883        if (*p != NUL)                  /* past "default" or group name */
     
    49216888            {
    49226889                arg = skipwhite(p);
    4923 @@ -8985,7 +9039,7 @@
     6890@@ -8985,7 +9040,7 @@
    49246891            }
    49256892            if (*p != NUL)                      /* past group name */
     
    49306897                    highlight_list();
    49316898                if (STRNCMP("link", arg, p - arg) == 0
    4932 @@ -9045,31 +9099,25 @@
     6899@@ -9045,31 +9100,25 @@
    49336900     expand_T   *xp;
    49346901     int                idx;
     
    49716938  * Free all the highlight group fonts.
    49726939  * Used when quitting for systems which need it.
     6940diff -Naur vim71.orig/src/term.c vim71/src/term.c
     6941--- vim71.orig/src/term.c       2007-05-07 12:39:11.000000000 -0700
     6942+++ vim71/src/term.c    2007-10-16 14:14:28.000000000 -0700
     6943@@ -4809,6 +4809,8 @@
     6944            if (num_bytes == -1)
     6945                return -1;
     6946            current_tab = (int)bytes[0];
     6947+           if (current_tab == 255)     /* -1 in a byte gives 255 */
     6948+               current_tab = -1;
     6949            slen += num_bytes;
     6950        }
     6951        else if (key_name[0] == (int)KS_TABMENU)
    49736952diff -Naur vim71.orig/src/termlib.c vim71/src/termlib.c
    49746953--- vim71.orig/src/termlib.c    2007-05-07 12:39:49.000000000 -0700
    4975 +++ vim71/src/termlib.c 2007-09-03 22:14:17.000000000 -0700
     6954+++ vim71/src/termlib.c 2007-10-16 14:14:09.000000000 -0700
    49766955@@ -191,7 +191,7 @@
    49776956            lbuf[0] == '\t' &&
     
    49856964diff -Naur vim71.orig/src/testdir/Makefile vim71/src/testdir/Makefile
    49866965--- vim71.orig/src/testdir/Makefile     2006-04-30 04:08:01.000000000 -0700
    4987 +++ vim71/src/testdir/Makefile  2007-09-03 22:14:54.000000000 -0700
     6966+++ vim71/src/testdir/Makefile  2007-10-16 14:14:28.000000000 -0700
    49886967@@ -1,9 +1,13 @@
    49896968 #
     
    49966975+# Uncomment this line for using valgrind.
    49976976+# The output goes into a file "valgrind.$PID" (sorry, no test number).
    4998 +# VALGRIND = valgrind --tool=memcheck --num-callers=15 --logfile=valgrind
     6977+# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --logfile=valgrind
    49996978+
    50006979 SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
     
    50116990 SCRIPTS_GUI = test16.out
    50126991 
    5013 @@ -38,7 +43,7 @@
     6992@@ -34,11 +39,11 @@
     6993 $(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG)
     6994 
     6995 clean:
     6996-       -rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim test.ok X* viminfo
     6997+       -rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim test.ok X* valgrind.pid* viminfo
    50146998 
    50156999 test1.out: test1.in
     
    50297013                  if diff test.out $*.ok; \
    50307014                  then mv -f test.out $*.out; \
     7015@@ -61,5 +66,9 @@
     7016                fi"
     7017        -rm -rf X* test.ok viminfo
     7018 
     7019+test49.out: test49.vim
     7020+
     7021+test60.out: test60.vim
     7022+
     7023 nolog:
     7024        -echo Test results: >test.log
     7025diff -Naur vim71.orig/src/testdir/test14.in vim71/src/testdir/test14.in
     7026--- vim71.orig/src/testdir/test14.in    2004-06-07 07:32:05.000000000 -0700
     7027+++ vim71/src/testdir/test14.in 2007-10-16 14:14:28.000000000 -0700
     7028@@ -18,6 +18,7 @@
     7029 : let tt = "o\<C-V>65\<C-V>x42\<C-V>o103 \<C-V>33a\<C-V>xfg\<C-V>o78\<Esc>"
     7030 :endif
     7031 :exe "normal " . tt
     7032+:unlet tt
     7033 :.w >>test.out
     7034 :set vb
     7035 /^Piece
     7036diff -Naur vim71.orig/src/testdir/test26.in vim71/src/testdir/test26.in
     7037--- vim71.orig/src/testdir/test26.in    2004-06-07 07:32:05.000000000 -0700
     7038+++ vim71/src/testdir/test26.in 2007-10-16 14:14:28.000000000 -0700
     7039@@ -37,6 +37,7 @@
     7040 :    endif
     7041 :  endif
     7042 :endwhile
     7043+:unlet i j
     7044 :'t,$w! test.out
     7045 :qa!
     7046 ENDTEST
     7047diff -Naur vim71.orig/src/testdir/test34.in vim71/src/testdir/test34.in
     7048--- vim71.orig/src/testdir/test34.in    2006-04-30 06:33:24.000000000 -0700
     7049+++ vim71/src/testdir/test34.in 2007-10-16 14:14:28.000000000 -0700
     7050@@ -52,7 +52,15 @@
     7051 ---*---
     7052 (one
     7053 (two
     7054-[(one again:$-5,$wq! test.out
     7055+[(one again:$-5,$w! test.out
     7056+:delfunc Table
     7057+:delfunc Compute
     7058+:delfunc Expr1
     7059+:delfunc Expr2
     7060+:delfunc ListItem
     7061+:delfunc ListReset
     7062+:unlet retval counter
     7063+:q!
     7064 ENDTEST
     7065 
     7066 here
     7067diff -Naur vim71.orig/src/testdir/test45.in vim71/src/testdir/test45.in
     7068--- vim71.orig/src/testdir/test45.in    2004-06-07 07:32:05.000000000 -0700
     7069+++ vim71/src/testdir/test45.in 2007-10-16 14:14:28.000000000 -0700
     7070@@ -55,6 +55,7 @@
     7071 /kk$
     7072 :call append("$", foldlevel("."))
     7073 :/^last/+1,$w! test.out
     7074+:delfun Flvl
     7075 :qa!
     7076 ENDTEST
     7077 
     7078diff -Naur vim71.orig/src/testdir/test47.in vim71/src/testdir/test47.in
     7079--- vim71.orig/src/testdir/test47.in    2004-06-07 07:32:05.000000000 -0700
     7080+++ vim71/src/testdir/test47.in 2007-10-16 14:14:28.000000000 -0700
     7081@@ -34,6 +34,7 @@
     7082 :call append("$", two)
     7083 :call append("$", three)
     7084 :$-2,$w! test.out
     7085+:unlet one two three
     7086 :qa!
     7087 ENDTEST
     7088 
     7089diff -Naur vim71.orig/src/testdir/test49.in vim71/src/testdir/test49.in
     7090--- vim71.orig/src/testdir/test49.in    2006-04-28 02:29:54.000000000 -0700
     7091+++ vim71/src/testdir/test49.in 2007-10-16 14:14:28.000000000 -0700
     7092@@ -1,13 +1,29 @@
     7093 This is a test of the script language.
     7094 
     7095 If after adding a new test, the test output doesn't appear properly in
     7096-test49.failed, try to add one ore more "G"s at the line before ENDTEST.
     7097+test49.failed, try to add one ore more "G"s at the line ending in "test.out"
     7098 
     7099 STARTTEST
     7100 :so small.vim
     7101 :se nocp nomore viminfo+=nviminfo
     7102 :so test49.vim
     7103-GGGGGGGGGG"rp:.-,$wq! test.out
     7104+GGGGGGGGGGGGGG"rp:.-,$w! test.out
     7105+:"
     7106+:" make valgrind happy
     7107+:redir => funclist
     7108+:silent func
     7109+:redir END
     7110+:for line in split(funclist, "\n")
     7111+:  let name = matchstr(line, 'function \zs[A-Z]\w*\ze(')
     7112+:  if name != ''
     7113+:    exe "delfunc " . name
     7114+:  endif
     7115+:endfor
     7116+:for v in keys(g:)
     7117+:  silent! exe "unlet " . v
     7118+:endfor
     7119+:unlet v
     7120+:qa!
     7121 ENDTEST
     7122 
     7123 Results of test49.vim:
     7124diff -Naur vim71.orig/src/testdir/test55.in vim71/src/testdir/test55.in
     7125--- vim71.orig/src/testdir/test55.in    2006-10-15 07:07:05.000000000 -0700
     7126+++ vim71/src/testdir/test55.in 2007-10-16 14:14:28.000000000 -0700
     7127@@ -345,6 +345,10 @@
     7128 :endfun
     7129 :call Test(1, 2, [3, 4], {5: 6})  " This may take a while
     7130 :"
     7131+:delfunc Test
     7132+:unlet dict
     7133+:call garbagecollect(1)
     7134+:"
     7135 :/^start:/,$wq! test.out
     7136 ENDTEST
     7137 
     7138diff -Naur vim71.orig/src/testdir/test56.in vim71/src/testdir/test56.in
     7139--- vim71.orig/src/testdir/test56.in    2006-09-03 07:28:41.000000000 -0700
     7140+++ vim71/src/testdir/test56.in 2007-10-16 14:14:28.000000000 -0700
     7141@@ -17,5 +17,5 @@
     7142 fun s:DoNothing()
     7143   call append(line('$'), "nothing line")
     7144 endfun
     7145-nnoremap <buffer> _x   :call <SID>DoNothing()<bar>call <SID>DoLast()<cr>
     7146+nnoremap <buffer> _x   :call <SID>DoNothing()<bar>call <SID>DoLast()<bar>delfunc <SID>DoNothing<bar>delfunc <SID>DoLast<cr>
     7147 end:
     7148diff -Naur vim71.orig/src/testdir/test58.in vim71/src/testdir/test58.in
     7149--- vim71.orig/src/testdir/test58.in    2006-04-03 11:24:04.000000000 -0700
     7150+++ vim71/src/testdir/test58.in 2007-10-16 14:14:28.000000000 -0700
     7151@@ -86,6 +86,7 @@
     7152 :$put =str
     7153 `m]s:let [str, a] = spellbadword()
     7154 :$put =str
     7155+:unlet str a
     7156 :"
     7157 :" Postponed prefixes
     7158 :call TestOne('2', '1')
     7159@@ -100,6 +101,10 @@
     7160 :" NOSLITSUGS
     7161 :call TestOne('8', '8')
     7162 :"
     7163+:" clean up for valgrind
     7164+:delfunc TestOne
     7165+:set spl= enc=latin1
     7166+:"
     7167 gg:/^test output:/,$wq! test.out
     7168 ENDTEST
     7169 
     7170diff -Naur vim71.orig/src/testdir/test59.in vim71/src/testdir/test59.in
     7171--- vim71.orig/src/testdir/test59.in    2006-04-03 11:29:24.000000000 -0700
     7172+++ vim71/src/testdir/test59.in 2007-10-16 14:14:28.000000000 -0700
     7173@@ -90,6 +90,7 @@
     7174 :$put =str
     7175 `m]s:let [str, a] = spellbadword()
     7176 :$put =str
     7177+:unlet str a
     7178 :"
     7179 :" Postponed prefixes
     7180 :call TestOne('2', '1')
     7181@@ -101,6 +102,10 @@
     7182 :call TestOne('6', '6')
     7183 :call TestOne('7', '7')
     7184 :"
     7185+:" clean up for valgrind
     7186+:delfunc TestOne
     7187+:set spl= enc=latin1
     7188+:"
     7189 gg:/^test output:/,$wq! test.out
     7190 ENDTEST
     7191 
     7192diff -Naur vim71.orig/src/testdir/test60.in vim71/src/testdir/test60.in
     7193--- vim71.orig/src/testdir/test60.in    2006-05-05 11:41:18.000000000 -0700
     7194+++ vim71/src/testdir/test60.in 2007-10-16 14:14:28.000000000 -0700
     7195@@ -569,6 +569,9 @@
     7196     redir END
     7197 endfunction
     7198 :call TestExists()
     7199+:delfunc TestExists
     7200+:delfunc RunTest
     7201+:delfunc TestFuncArg
     7202 :edit! test.out
     7203 :set ff=unix
     7204 :w
     7205diff -Naur vim71.orig/src/testdir/test60.vim vim71/src/testdir/test60.vim
     7206--- vim71.orig/src/testdir/test60.vim   2006-01-12 11:45:59.000000000 -0800
     7207+++ vim71/src/testdir/test60.vim        2007-10-16 14:14:28.000000000 -0700
     7208@@ -94,4 +94,5 @@
     7209 else
     7210     echo "FAILED"
     7211 endif
     7212+unlet str
     7213 
     7214diff -Naur vim71.orig/src/testdir/test62.in vim71/src/testdir/test62.in
     7215--- vim71.orig/src/testdir/test62.in    2006-04-30 04:29:15.000000000 -0700
     7216+++ vim71/src/testdir/test62.in 2007-10-16 14:14:28.000000000 -0700
     7217@@ -7,6 +7,7 @@
     7218 :let nr = tabpagenr()
     7219 :q
     7220 :call append(line('$'), 'tab page ' . nr)
     7221+:unlet nr
     7222 :"
     7223 :" Open three tab pages and use ":tabdo"
     7224 :0tabnew
     7225@@ -23,6 +24,7 @@
     7226 :q!
     7227 :call append(line('$'), line1)
     7228 :call append(line('$'), line2)
     7229+:unlet line1 line2
     7230 :"
     7231 :"
     7232 :/^Results/,$w! test.out
    50317233diff -Naur vim71.orig/src/testdir/test63.in vim71/src/testdir/test63.in
    50327234--- vim71.orig/src/testdir/test63.in    1969-12-31 16:00:00.000000000 -0800
    5033 +++ vim71/src/testdir/test63.in 2007-09-03 22:13:43.000000000 -0700
     7235+++ vim71/src/testdir/test63.in 2007-10-16 14:14:28.000000000 -0700
    50347236@@ -0,0 +1,157 @@
    50357237+Test for ":match", ":2match", ":3match", "clearmatches()", "getmatches()",
     
    50957297+:  let @r .= "FAILED\n"
    50967298+:endif
    5097 +:" --- Check that "matchdelete()" returns 0 if succesfull and otherwise -1.
     7299+:" --- Check that "matchdelete()" returns 0 if successful and otherwise -1.
    50987300+:let @r .= "*** Test 6: "
    50997301+:let m = matchadd("MyGroup1", "TODO")
     
    51527354+:" --- expected behaviour (for now) is to add the first match but not the
    51537355+:" --- second and to return 0 (even though it is a matter of debate whether
    5154 +:" --- this can be considered succesfull behaviour).
     7356+:" --- this can be considered successful behaviour).
    51557357+:let @r .= "*** Test 9: "
    51567358+:let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])
     
    51627364+:call clearmatches()
    51637365+:unlet r1
    5164 +:" --- Check that "setmatches()" returns 0 if succesfull and otherwise -1.
     7366+:" --- Check that "setmatches()" returns 0 if successful and otherwise -1.
    51657367+:" --- (A range of valid and invalid input values are tried out to generate the
    51667368+:" --- return values.)
     
    51927394diff -Naur vim71.orig/src/testdir/test63.ok vim71/src/testdir/test63.ok
    51937395--- vim71.orig/src/testdir/test63.ok    1969-12-31 16:00:00.000000000 -0800
    5194 +++ vim71/src/testdir/test63.ok 2007-09-03 22:13:43.000000000 -0700
     7396+++ vim71/src/testdir/test63.ok 2007-10-16 14:14:07.000000000 -0700
    51957397@@ -0,0 +1,11 @@
    51967398+Results of test63:
     
    52077409diff -Naur vim71.orig/src/testdir/test64.in vim71/src/testdir/test64.in
    52087410--- vim71.orig/src/testdir/test64.in    1969-12-31 16:00:00.000000000 -0800
    5209 +++ vim71/src/testdir/test64.in 2007-09-03 22:14:54.000000000 -0700
    5210 @@ -0,0 +1,52 @@
     7411+++ vim71/src/testdir/test64.in 2007-10-16 14:14:28.000000000 -0700
     7412@@ -0,0 +1,54 @@
    52117413+Test for regexp patterns.
    52127414+
     
    52557457+:      endif
    52567458+:    endfor
     7459+:    unlet i
    52577460+:  endif
    52587461+:endfor
     7462+:unlet t tl e l
    52597463+:/^Results/,$wq! test.out
    52607464+ENDTEST
     
    52637467diff -Naur vim71.orig/src/testdir/test64.ok vim71/src/testdir/test64.ok
    52647468--- vim71.orig/src/testdir/test64.ok    1969-12-31 16:00:00.000000000 -0800
    5265 +++ vim71/src/testdir/test64.ok 2007-09-03 22:14:54.000000000 -0700
     7469+++ vim71/src/testdir/test64.ok 2007-10-16 14:14:14.000000000 -0700
    52667470@@ -0,0 +1,6 @@
    52677471+Results of test64:
     
    52737477diff -Naur vim71.orig/src/ui.c vim71/src/ui.c
    52747478--- vim71.orig/src/ui.c 2007-05-07 12:49:09.000000000 -0700
    5275 +++ vim71/src/ui.c      2007-09-03 22:15:10.000000000 -0700
     7479+++ vim71/src/ui.c      2007-10-16 14:14:17.000000000 -0700
    52767480@@ -1603,8 +1603,6 @@
    52777481 #if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM) \
     
    52947498        || (defined(FEAT_GUI) && (!defined(USE_ON_FLY_SCROLL) \
    52957499                || defined(FEAT_MENU))) \
     7500diff -Naur vim71.orig/src/undo.c vim71/src/undo.c
     7501--- vim71.orig/src/undo.c       2007-05-07 12:21:14.000000000 -0700
     7502+++ vim71/src/undo.c    2007-10-16 14:14:38.000000000 -0700
     7503@@ -76,6 +76,12 @@
     7504  * buffer is unloaded.
     7505  */
     7506 
     7507+/* Uncomment the next line for including the u_check() function.  This warns
     7508+ * for errors in the debug information. */
     7509+/* #define U_DEBUG 1 */
     7510+#define UH_MAGIC 0x18dade      /* value for uh_magic when in use */
     7511+#define UE_MAGIC 0xabc123      /* value for ue_magic when in use */
     7512+
     7513 #include "vim.h"
     7514 
     7515 /* See below: use malloc()/free() for memory management. */
     7516@@ -113,6 +119,95 @@
     7517  */
     7518 static int     undo_undoes = FALSE;
     7519 
     7520+#ifdef U_DEBUG
     7521+/*
     7522+ * Check the undo structures for being valid.  Print a warning when something
     7523+ * looks wrong.
     7524+ */
     7525+static int seen_b_u_curhead;
     7526+static int seen_b_u_newhead;
     7527+static int header_count;
     7528+
     7529+    static void
     7530+u_check_tree(u_header_T *uhp,
     7531+       u_header_T *exp_uh_next,
     7532+       u_header_T *exp_uh_alt_prev)
     7533+{
     7534+    u_entry_T *uep;
     7535+
     7536+    if (uhp == NULL)
     7537+       return;
     7538+    ++header_count;
     7539+    if (uhp == curbuf->b_u_curhead && ++seen_b_u_curhead > 1)
     7540+    {
     7541+       EMSG("b_u_curhead found twice (looping?)");
     7542+       return;
     7543+    }
     7544+    if (uhp == curbuf->b_u_newhead && ++seen_b_u_newhead > 1)
     7545+    {
     7546+       EMSG("b_u_newhead found twice (looping?)");
     7547+       return;
     7548+    }
     7549+
     7550+    if (uhp->uh_magic != UH_MAGIC)
     7551+       EMSG("uh_magic wrong (may be using freed memory)");
     7552+    else
     7553+    {
     7554+       /* Check pointers back are correct. */
     7555+       if (uhp->uh_next != exp_uh_next)
     7556+       {
     7557+           EMSG("uh_next wrong");
     7558+           smsg((char_u *)"expected: 0x%x, actual: 0x%x",
     7559+                                                  exp_uh_next, uhp->uh_next);
     7560+       }
     7561+       if (uhp->uh_alt_prev != exp_uh_alt_prev)
     7562+       {
     7563+           EMSG("uh_alt_prev wrong");
     7564+           smsg((char_u *)"expected: 0x%x, actual: 0x%x",
     7565+                                          exp_uh_alt_prev, uhp->uh_alt_prev);
     7566+       }
     7567+
     7568+       /* Check the undo tree at this header. */
     7569+       for (uep = uhp->uh_entry; uep != NULL; uep = uep->ue_next)
     7570+       {
     7571+           if (uep->ue_magic != UE_MAGIC)
     7572+           {
     7573+               EMSG("ue_magic wrong (may be using freed memory)");
     7574+               break;
     7575+           }
     7576+       }
     7577+
     7578+       /* Check the next alt tree. */
     7579+       u_check_tree(uhp->uh_alt_next, uhp->uh_next, uhp);
     7580+
     7581+       /* Check the next header in this branch. */
     7582+       u_check_tree(uhp->uh_prev, uhp, NULL);
     7583+    }
     7584+}
     7585+
     7586+    void
     7587+u_check(int newhead_may_be_NULL)
     7588+{
     7589+    seen_b_u_newhead = 0;
     7590+    seen_b_u_curhead = 0;
     7591+    header_count = 0;
     7592+
     7593+    u_check_tree(curbuf->b_u_oldhead, NULL, NULL);
     7594+
     7595+    if (seen_b_u_newhead == 0 && curbuf->b_u_oldhead != NULL
     7596+           && !(newhead_may_be_NULL && curbuf->b_u_newhead == NULL))
     7597+       EMSGN("b_u_newhead invalid: 0x%x", curbuf->b_u_newhead);
     7598+    if (curbuf->b_u_curhead != NULL && seen_b_u_curhead == 0)
     7599+       EMSGN("b_u_curhead invalid: 0x%x", curbuf->b_u_curhead);
     7600+    if (header_count != curbuf->b_u_numhead)
     7601+    {
     7602+       EMSG("b_u_numhead invalid");
     7603+       smsg((char_u *)"expected: %ld, actual: %ld",
     7604+                              (long)header_count, (long)curbuf->b_u_numhead);
     7605+    }
     7606+}
     7607+#endif
     7608+
     7609 /*
     7610  * Save the current line for both the "u" and "U" command.
     7611  * Returns OK or FAIL.
     7612@@ -243,6 +338,9 @@
     7613     if (!undo_allowed())
     7614        return FAIL;
     7615 
     7616+#ifdef U_DEBUG
     7617+    u_check(FALSE);
     7618+#endif
     7619 #ifdef FEAT_NETBEANS_INTG
     7620     /*
     7621      * Netbeans defines areas that cannot be modified.  Bail out here when
     7622@@ -294,6 +392,9 @@
     7623            uhp = (u_header_T *)U_ALLOC_LINE((unsigned)sizeof(u_header_T));
     7624            if (uhp == NULL)
     7625                goto nomem;
     7626+#ifdef U_DEBUG
     7627+           uhp->uh_magic = UH_MAGIC;
     7628+#endif
     7629        }
     7630        else
     7631            uhp = NULL;
     7632@@ -316,8 +417,11 @@
     7633        {
     7634            u_header_T      *uhfree = curbuf->b_u_oldhead;
     7635 
     7636-           /* If there is no branch only free one header. */
     7637-           if (uhfree->uh_alt_next == NULL)
     7638+           if (uhfree == old_curhead)
     7639+               /* Can't reconnect the branch, delete all of it. */
     7640+               u_freebranch(curbuf, uhfree, &old_curhead);
     7641+           else if (uhfree->uh_alt_next == NULL)
     7642+               /* There is no branch, only free one header. */
     7643                u_freeheader(curbuf, uhfree, &old_curhead);
     7644            else
     7645            {
     7646@@ -326,6 +430,9 @@
     7647                    uhfree = uhfree->uh_alt_next;
     7648                u_freebranch(curbuf, uhfree, &old_curhead);
     7649            }
     7650+#ifdef U_DEBUG
     7651+           u_check(TRUE);
     7652+#endif
     7653        }
     7654 
     7655        if (uhp == NULL)                /* no undo at all */
     7656@@ -478,6 +585,9 @@
     7657     uep = (u_entry_T *)U_ALLOC_LINE((unsigned)sizeof(u_entry_T));
     7658     if (uep == NULL)
     7659        goto nomem;
     7660+#ifdef U_DEBUG
     7661+    uep->ue_magic = UE_MAGIC;
     7662+#endif
     7663 
     7664     uep->ue_size = size;
     7665     uep->ue_top = top;
     7666@@ -525,6 +635,9 @@
     7667     curbuf->b_u_synced = FALSE;
     7668     undo_undoes = FALSE;
     7669 
     7670+#ifdef U_DEBUG
     7671+    u_check(FALSE);
     7672+#endif
     7673     return OK;
     7674 
     7675 nomem:
     7676@@ -955,6 +1068,9 @@
     7677     int                empty_buffer;               /* buffer became empty */
     7678     u_header_T *curhead = curbuf->b_u_curhead;
     7679 
     7680+#ifdef U_DEBUG
     7681+    u_check(FALSE);
     7682+#endif
     7683     old_flags = curhead->uh_flags;
     7684     new_flags = (curbuf->b_changed ? UH_CHANGED : 0) +
     7685               ((curbuf->b_ml.ml_flags & ML_EMPTY) ? UH_EMPTYBUF : 0);
     7686@@ -1186,6 +1302,9 @@
     7687     /* The timestamp can be the same for multiple changes, just use the one of
     7688      * the undone/redone change. */
     7689     curbuf->b_u_seq_time = curhead->uh_time;
     7690+#ifdef U_DEBUG
     7691+    u_check(FALSE);
     7692+#endif
     7693 }
     7694 
     7695 /*
     7696@@ -1515,7 +1634,7 @@
     7697 }
     7698 
     7699 /*
     7700- * Free one header and its entry list and adjust the pointers.
     7701+ * Free one header "uhp" and its entry list and adjust the pointers.
     7702  */
     7703     static void
     7704 u_freeheader(buf, uhp, uhpp)
     7705@@ -1523,6 +1642,8 @@
     7706     u_header_T     *uhp;
     7707     u_header_T     **uhpp;     /* if not NULL reset when freeing this header */
     7708 {
     7709+    u_header_T     *uhap;
     7710+
     7711     /* When there is an alternate redo list free that branch completely,
     7712      * because we can never go there. */
     7713     if (uhp->uh_alt_next != NULL)
     7714@@ -1540,7 +1661,8 @@
     7715     if (uhp->uh_prev == NULL)
     7716        buf->b_u_newhead = uhp->uh_next;
     7717     else
     7718-       uhp->uh_prev->uh_next = uhp->uh_next;
     7719+       for (uhap = uhp->uh_prev; uhap != NULL; uhap = uhap->uh_alt_next)
     7720+           uhap->uh_next = uhp->uh_next;
     7721 
     7722     u_freeentries(buf, uhp, uhpp);
     7723 }
     7724@@ -1585,6 +1707,8 @@
     7725     /* Check for pointers to the header that become invalid now. */
     7726     if (buf->b_u_curhead == uhp)
     7727        buf->b_u_curhead = NULL;
     7728+    if (buf->b_u_newhead == uhp)
     7729+       buf->b_u_newhead = NULL;  /* freeing the newest entry */
     7730     if (uhpp != NULL && uhp == *uhpp)
     7731        *uhpp = NULL;
     7732 
     7733@@ -1594,6 +1718,9 @@
     7734        u_freeentry(uep, uep->ue_size);
     7735     }
     7736 
     7737+#ifdef U_DEBUG
     7738+    uhp->uh_magic = 0;
     7739+#endif
     7740     U_FREE_LINE((char_u *)uhp);
     7741     --buf->b_u_numhead;
     7742 }
     7743@@ -1609,6 +1736,9 @@
     7744     while (n > 0)
     7745        U_FREE_LINE(uep->ue_array[--n]);
     7746     U_FREE_LINE((char_u *)uep->ue_array);
     7747+#ifdef U_DEBUG
     7748+    uep->ue_magic = 0;
     7749+#endif
     7750     U_FREE_LINE((char_u *)uep);
     7751 }
     7752 
    52967753diff -Naur vim71.orig/src/version.c vim71/src/version.c
    52977754--- vim71.orig/src/version.c    2007-05-12 03:23:44.000000000 -0700
    5298 +++ vim71/src/version.c 2007-09-03 22:15:47.000000000 -0700
    5299 @@ -667,6 +667,174 @@
     7755+++ vim71/src/version.c 2007-10-16 14:14:41.000000000 -0700
     7756@@ -667,6 +667,256 @@
    53007757 static int included_patches[] =
    53017758 {   /* Add new patch number below this line */
    53027759 /**/
     7760+    140,
     7761+/**/
     7762+    139,
     7763+/**/
     7764+    138,
     7765+/**/
     7766+    137,
     7767+/**/
     7768+    136,
     7769+/**/
     7770+    135,
     7771+/**/
     7772+    133,
     7773+/**/
     7774+    132,
     7775+/**/
     7776+    131,
     7777+/**/
     7778+    130,
     7779+/**/
     7780+    127,
     7781+/**/
     7782+    125,
     7783+/**/
     7784+    123,
     7785+/**/
     7786+    122,
     7787+/**/
     7788+    121,
     7789+/**/
     7790+    120,
     7791+/**/
     7792+    119,
     7793+/**/
     7794+    118,
     7795+/**/
     7796+    117,
     7797+/**/
     7798+    116,
     7799+/**/
     7800+    115,
     7801+/**/
     7802+    114,
     7803+/**/
     7804+    113,
     7805+/**/
     7806+    112,
     7807+/**/
     7808+    111,
     7809+/**/
     7810+    110,
     7811+/**/
     7812+    109,
     7813+/**/
     7814+    108,
     7815+/**/
     7816+    107,
     7817+/**/
     7818+    106,
     7819+/**/
     7820+    105,
     7821+/**/
     7822+    104,
     7823+/**/
     7824+    103,
     7825+/**/
     7826+    102,
     7827+/**/
     7828+    101,
     7829+/**/
     7830+    100,
     7831+/**/
     7832+    99,
     7833+/**/
     7834+    98,
     7835+/**/
     7836+    97,
     7837+/**/
     7838+    96,
     7839+/**/
     7840+    95,
     7841+/**/
    53037842+    94,
    53047843+/**/
     
    54748013diff -Naur vim71.orig/src/vim.h vim71/src/vim.h
    54758014--- vim71.orig/src/vim.h        2007-05-12 02:53:29.000000000 -0700
    5476 +++ vim71/src/vim.h     2007-09-03 22:14:31.000000000 -0700
     8015+++ vim71/src/vim.h     2007-10-16 14:14:09.000000000 -0700
    54778016@@ -1380,8 +1380,14 @@
    54788017 #endif
     
    54948033diff -Naur vim71.orig/src/vimtutor vim71/src/vimtutor
    54958034--- vim71.orig/src/vimtutor     2004-06-07 07:32:27.000000000 -0700
    5496 +++ vim71/src/vimtutor  2007-09-03 22:13:19.000000000 -0700
     8035+++ vim71/src/vimtutor  2007-10-16 14:14:06.000000000 -0700
    54978036@@ -39,18 +39,22 @@
    54988037 # remove the copy of the tutor on exit
     
    55308069diff -Naur vim71.orig/src/window.c vim71/src/window.c
    55318070--- vim71.orig/src/window.c     2007-05-07 12:25:30.000000000 -0700
    5532 +++ vim71/src/window.c  2007-09-03 22:14:47.000000000 -0700
     8071+++ vim71/src/window.c  2007-10-16 14:14:31.000000000 -0700
    55338072@@ -75,6 +75,7 @@
    55348073 static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
     
    55398078 static void win_new_height __ARGS((win_T *, int));
    55408079 
     8080@@ -583,7 +584,7 @@
     8081                ++no_mapping;
     8082                ++allow_keys;   /* no mapping for xchar, but allow key codes */
     8083                if (xchar == NUL)
     8084-                   xchar = safe_vgetc();
     8085+                   xchar = plain_vgetc();
     8086 #ifdef FEAT_LANGMAP
     8087                LANGMAP_ADJUST(xchar, TRUE);
     8088 #endif
    55418089@@ -732,7 +733,6 @@
    55428090     if (flags & WSP_VERT)
     
    56148162 
    56158163     /*
     8164@@ -1253,7 +1291,7 @@
     8165      * Don't execute autocommands while creating the windows.  Must do that
     8166      * when putting the buffers in the windows.
     8167      */
     8168-    ++autocmd_block;
     8169+    block_autocmds();
     8170 #endif
     8171 
     8172     /* todo is number of windows left to create */
     8173@@ -1275,7 +1313,7 @@
     8174        }
     8175 
     8176 #ifdef FEAT_AUTOCMD
     8177-    --autocmd_block;
     8178+    unblock_autocmds();
     8179 #endif
     8180 
     8181     /* return actual number of windows */
    56168182@@ -2120,7 +2158,7 @@
    56178183        if (wp->w_p_pvw || bt_quickfix(wp->w_buffer))
     
    57278293     }
    57288294 #endif
    5729 @@ -4128,6 +4209,10 @@
     8295@@ -3334,7 +3415,7 @@
     8296      * Don't execute autocommands while creating the tab pages.  Must do that
     8297      * when putting the buffers in the windows.
     8298      */
     8299-    ++autocmd_block;
     8300+    block_autocmds();
     8301 #endif
     8302 
     8303     for (todo = count - 1; todo > 0; --todo)
     8304@@ -3342,7 +3423,7 @@
     8305            break;
     8306 
    57308307 #ifdef FEAT_AUTOCMD
    5731         --autocmd_block;
    5732  #endif
     8308-    --autocmd_block;
     8309+    unblock_autocmds();
     8310 #endif
     8311 
     8312     /* return actual number of tab pages */
     8313@@ -4081,7 +4162,7 @@
     8314        /* Don't execute autocommands while the window is not properly
     8315         * initialized yet.  gui_create_scrollbar() may trigger a FocusGained
     8316         * event. */
     8317-       ++autocmd_block;
     8318+       block_autocmds();
     8319 #endif
     8320        /*
     8321         * link the window in the window list
     8322@@ -4126,7 +4207,11 @@
     8323        foldInitWin(newwin);
     8324 #endif
     8325 #ifdef FEAT_AUTOCMD
     8326-       --autocmd_block;
     8327+       unblock_autocmds();
     8328+#endif
    57338329+#ifdef FEAT_SEARCH_EXTRA
    57348330+       newwin->w_match_head = NULL;
    57358331+       newwin->w_next_match_id = 4;
    5736 +#endif
     8332 #endif
    57378333     }
    57388334     return newwin;
    5739  }
     8335@@ -4147,7 +4232,7 @@
     8336 #ifdef FEAT_AUTOCMD
     8337     /* Don't execute autocommands while the window is halfway being deleted.
     8338      * gui_mch_destroy_scrollbar() may trigger a FocusGained event. */
     8339-    ++autocmd_block;
     8340+    block_autocmds();
     8341 #endif
     8342 
     8343 #ifdef FEAT_MZSCHEME
    57408344@@ -4185,11 +4270,11 @@
    57418345        vim_free(wp->w_tagstack[i].tagname);
     
    57538357     free_jumplist(wp);
    57548358 #endif
    5755 @@ -6174,3 +6259,175 @@
     8359@@ -4210,7 +4295,7 @@
     8360     vim_free(wp);
     8361 
     8362 #ifdef FEAT_AUTOCMD
     8363-    --autocmd_block;
     8364+    unblock_autocmds();
     8365 #endif
     8366 }
     8367 
     8368@@ -5438,6 +5523,7 @@
     8369                {
     8370                    EMSG(_(e_noroom));
     8371                    p_ch = old_p_ch;
     8372+                   curtab->tp_ch_used = p_ch;
     8373                    cmdline_row = Rows - p_ch;
     8374                    break;
     8375                }
     8376@@ -6174,3 +6260,175 @@
    57568377     return FALSE;
    57578378 }
Note: See TracChangeset for help on using the changeset viewer.