source: patches/vim-7.1-fixes-4.patch @ c2aa910

clfs-1.2clfs-2.1clfs-3.0.0-systemdclfs-3.0.0-sysvinitsystemdsysvinit
Last change on this file since c2aa910 was c2aa910, checked in by Jim Gifford <clfs@…>, 17 years ago

Updated vim patch

  • Property mode set to 100644
File size: 243.7 KB
  • runtime/doc/change.txt

    Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
    Date: 10-16-2007
    Initial Package Version: 7.1
    Origin: Upstream
    Upstream Status: Applied
    Description: Contains all upstream patches up to 7.1.140
                 The following patches were skipped
                 003 007 041 065 070 072 080 088 091 092 124 126 128 129 134
    
    diff -Naur vim71.orig/runtime/doc/change.txt vim71/runtime/doc/change.txt
    old new  
    15711571                        in their original order, right before the sorted
    15721572                        lines.
    15731573
     1574                        If {pattern} is empty (e.g. // is specified), the
     1575                        last search pattern is used.  This allows trying out
     1576                        a pattern first.
     1577
    15741578Note that using ":sort" with ":global" doesn't sort the matching lines, it's
    15751579quite useless.
    15761580
  • runtime/doc/eval.txt

    diff -Naur vim71.orig/runtime/doc/eval.txt vim71/runtime/doc/eval.txt
    old new  
    1 *eval.txt*      For Vim version 7.1.  Last change: 2007 May 11
     1*eval.txt*      For Vim version 7.1.  Last change: 2007 Sep 25
    22
    33
    44                  VIM REFERENCE MANUAL    by Bram Moolenaar
     
    15571557changenr()                      Number  current change number
    15581558char2nr( {expr})                Number  ASCII value of first char in {expr}
    15591559cindent( {lnum})                Number  C indent for line {lnum}
     1560clearmatches()                  None    clear all matches
    15601561col( {expr})                    Number  column nr of cursor or mark
    15611562complete({startcol}, {matches}) String  set Insert mode completion
    15621563complete_add( {expr})           Number  add completion match
     
    16021603foldtextresult( {lnum})         String  text for closed fold at {lnum}
    16031604foreground( )                   Number  bring the Vim window to the foreground
    16041605function( {name})               Funcref reference to function {name}
    1605 garbagecollect()                none    free memory, breaking cyclic references
     1606garbagecollect( [at_exit])      none    free memory, breaking cyclic references
    16061607get( {list}, {idx} [, {def}])   any     get item {idx} from {list} or {def}
    16071608get( {dict}, {key} [, {def}])   any     get item {key} from {dict} or {def}
    16081609getbufline( {expr}, {lnum} [, {end}])
     
    16221623getline( {lnum})                String  line {lnum} of current buffer
    16231624getline( {lnum}, {end})         List    lines {lnum} to {end} of current buffer
    16241625getloclist({nr})                List    list of location list items
     1626getmatches()                    List    list of current matches
    16251627getpos( {expr})                 List    position of cursor, mark, etc.
    16261628getqflist()                     List    list of quickfix items
    16271629getreg( [{regname} [, 1]])      String  contents of register
     
    16761678                                String  check for mappings matching {name}
    16771679match( {expr}, {pat}[, {start}[, {count}]])
    16781680                                Number  position where {pat} matches in {expr}
     1681matchadd( {group}, {pattern}[, {priority}[, {id}]])
     1682                                Number  highlight {pattern} with {group}
    16791683matcharg( {nr})                 List    arguments of |:match|
     1684matchdelete( {id})              Number  delete match identified by {id}
    16801685matchend( {expr}, {pat}[, {start}[, {count}]])
    16811686                                Number  position where {pat} ends in {expr}
    16821687matchlist( {expr}, {pat}[, {start}[, {count}]])
     
    17311736setline( {lnum}, {line})        Number  set line {lnum} to {line}
    17321737setloclist( {nr}, {list}[, {action}])
    17331738                                Number  modify location list using {list}
     1739setmatches( {list})             Number  restore a list of matches
    17341740setpos( {expr}, {list})         none    set the {expr} position to {list}
    17351741setqflist( {list}[, {action}])  Number  modify quickfix list using {list}
    17361742setreg( {n}, {v}[, {opt}])      Number  set register to value and type
     
    20122018                feature, -1 is returned.
    20132019                See |C-indenting|.
    20142020
     2021clearmatches()                                          *clearmatches()*
     2022                Clears all matches previously defined by |matchadd()| and the
     2023                |:match| commands.
     2024
    20152025                                                        *col()*
    20162026col({expr})     The result is a Number, which is the byte index of the column
    20172027                position given with {expr}.  The accepted positions are:
     
    20202030                            number of characters in the cursor line plus one)
    20212031                    'x      position of mark x (if the mark is not set, 0 is
    20222032                            returned)
     2033                Additionally {expr} can be [lnum, col]: a |List| with the line
     2034                and column number. Most useful when the column is "$", to get
     2035                the las column of a specific line.  When "lnum" or "col" is
     2036                out of range then col() returns zero.
    20232037                To get the line number use |line()|.  To get both use
    20242038                |getpos()|.
    20252039                For the screen column position use |virtcol()|.
     
    26592673                {name} can be a user defined function or an internal function.
    26602674
    26612675
    2662 garbagecollect()                                        *garbagecollect()*
     2676garbagecollect([at_exit])                               *garbagecollect()*
    26632677                Cleanup unused |Lists| and |Dictionaries| that have circular
    26642678                references.  There is hardly ever a need to invoke this
    26652679                function, as it is automatically done when Vim runs out of
     
    26692683                This is useful if you have deleted a very big |List| and/or
    26702684                |Dictionary| with circular references in a script that runs
    26712685                for a long time.
     2686                When the optional "at_exit" argument is one, garbage
     2687                collection will also be done when exiting Vim, if it wasn't
     2688                done before.  This is useful when checking for memory leaks.
    26722689
    26732690get({list}, {idx} [, {default}])                        *get()*
    26742691                Get item {idx} from |List| {list}.  When this item is not
     
    28242841                given file {fname}.
    28252842                If {fname} is a directory, 0 is returned.
    28262843                If the file {fname} can't be found, -1 is returned.
     2844                If the size of {fname} is too big to fit in a Number then -2
     2845                is returned.
    28272846
    28282847getfontname([{name}])                                   *getfontname()*
    28292848                Without an argument returns the name of the normal font being
     
    29122931                returned.  For an invalid window number {nr}, an empty list is
    29132932                returned. Otherwise, same as getqflist().
    29142933
     2934getmatches()                                            *getmatches()*
     2935                Returns a |List| with all matches previously defined by
     2936                |matchadd()| and the |:match| commands.  |getmatches()| is
     2937                useful in combination with |setmatches()|, as |setmatches()|
     2938                can restore a list of matches saved by |getmatches()|.
     2939                Example: >
     2940                        :echo getmatches()
     2941<                       [{'group': 'MyGroup1', 'pattern': 'TODO',
     2942                        'priority': 10, 'id': 1}, {'group': 'MyGroup2',
     2943                        'pattern': 'FIXME', 'priority': 10, 'id': 2}] >
     2944                        :let m = getmatches()
     2945                        :call clearmatches()
     2946                        :echo getmatches()
     2947<                       [] >
     2948                        :call setmatches(m)
     2949                        :echo getmatches()
     2950<                       [{'group': 'MyGroup1', 'pattern': 'TODO',
     2951                        'priority': 10, 'id': 1}, {'group': 'MyGroup2',
     2952                        'pattern': 'FIXME', 'priority': 10, 'id': 2}] >
     2953                        :unlet m
     2954<
     2955
    29152956getqflist()                                             *getqflist()*
    29162957                Returns a list with all the current quickfix errors.  Each
    29172958                list item is a dictionary with these entries:
     
    36163657                the pattern.  'smartcase' is NOT used.  The matching is always
    36173658                done like 'magic' is set and 'cpoptions' is empty.
    36183659
     3660                                        *matchadd()* *E798* *E799* *E801*
     3661matchadd({group}, {pattern}[, {priority}[, {id}]])
     3662                Defines a pattern to be highlighted in the current window (a
     3663                "match").  It will be highlighted with {group}.  Returns an
     3664                identification number (ID), which can be used to delete the
     3665                match using |matchdelete()|.
     3666
     3667                The optional {priority} argument assigns a priority to the
     3668                match.  A match with a high priority will have its
     3669                highlighting overrule that of a match with a lower priority.
     3670                A priority is specified as an integer (negative numbers are no
     3671                exception).  If the {priority} argument is not specified, the
     3672                default priority is 10.  The priority of 'hlsearch' is zero,
     3673                hence all matches with a priority greater than zero will
     3674                overrule it.  Syntax highlighting (see 'syntax') is a separate
     3675                mechanism, and regardless of the chosen priority a match will
     3676                always overrule syntax highlighting.
     3677
     3678                The optional {id} argument allows the request for a specific
     3679                match ID.  If a specified ID is already taken, an error
     3680                message will appear and the match will not be added.  An ID
     3681                is specified as a positive integer (zero excluded).  IDs 1, 2
     3682                and 3 are reserved for |:match|, |:2match| and |:3match|,
     3683                respectively.  If the {id} argument is not specified,
     3684                |matchadd()| automatically chooses a free ID.
     3685
     3686                The number of matches is not limited, as it is the case with
     3687                the |:match| commands.
     3688
     3689                Example: >
     3690                        :highlight MyGroup ctermbg=green guibg=green
     3691                        :let m = matchadd("MyGroup", "TODO")
     3692<               Deletion of the pattern: >
     3693                        :call matchdelete(m)
     3694
     3695<               A list of matches defined by |matchadd()| and |:match| are
     3696                available from |getmatches()|.  All matches can be deleted in
     3697                one operation by |clearmatches()|.
    36193698
    36203699matcharg({nr})                                                  *matcharg()*
    36213700                Selects the {nr} match item, as set with a |:match|,
     
    36253704                        The pattern used.
    36263705                When {nr} is not 1, 2 or 3 returns an empty |List|.
    36273706                When there is no match item set returns ['', ''].
    3628                 This is usef to save and restore a |:match|.
    3629 
     3707                This is useful to save and restore a |:match|.
     3708                Highlighting matches using the |:match| commands are limited
     3709                to three matches. |matchadd()| does not have this limitation.
     3710
     3711matchdelete({id})                              *matchdelete()* *E802* *E803*
     3712                Deletes a match with ID {id} previously defined by |matchadd()|
     3713                or one of the |:match| commands.  Returns 0 if succesfull,
     3714                otherwise -1.  See example for |matchadd()|.  All matches can
     3715                be deleted in one operation by |clearmatches()|.
    36303716
    36313717matchend({expr}, {pat}[, {start}[, {count}]])                   *matchend()*
    36323718                Same as match(), but return the index of first character after
     
    43794465                When {nr} is zero the current window is used. For a location
    43804466                list window, the displayed location list is modified.  For an
    43814467                invalid window number {nr}, -1 is returned.
    4382                 Otherwise, same as setqflist().
     4468                Otherwise, same as |setqflist()|.
     4469                Also see |location-list|.
     4470
     4471setmatches({list})                                      *setmatches()*
     4472                Restores a list of matches saved by |getmatches()|.  Returns 0
     4473                if succesfull, otherwise -1.  All current matches are cleared
     4474                before the list is restored.  See example for |getmatches()|.
    43834475
    43844476                                                        *setpos()*
    43854477setpos({expr}, {list})
     
    50225114                position, the returned Number will be the column at the end of
    50235115                the <Tab>.  For example, for a <Tab> in column 1, with 'ts'
    50245116                set to 8, it returns 8.
    5025                 For the use of {expr} see |col()|.  Additionally you can use
    5026                 [lnum, col]: a |List| with the line and column number.  When
    5027                 "lnum" or "col" is out of range then virtcol() returns zero.
    5028                 When 'virtualedit' is used it can be [lnum, col, off], where
     5117                For the byte position use |col()|.
     5118                For the use of {expr} see |col()|.
     5119                When 'virtualedit' is used {expr} can be [lnum, col, off], where
    50295120                "off" is the offset in screen columns from the start of the
    50305121                character.  E.g., a position within a <Tab> or after the last
    50315122                character.
    5032                 For the byte position use |col()|.
    50335123                When Virtual editing is active in the current mode, a position
    50345124                beyond the end of the line can be returned. |'virtualedit'|
    50355125                The accepted positions are:
  • runtime/doc/options.txt

    diff -Naur vim71.orig/runtime/doc/options.txt vim71/runtime/doc/options.txt
    old new  
    1 *options.txt*   For Vim version 7.1.  Last change: 2007 May 11
     1*options.txt*   For Vim version 7.1.  Last change: 2007 Aug 10
    22
    33
    44                  VIM REFERENCE MANUAL    by Bram Moolenaar
     
    24152415        When mixing vertically and horizontally split windows, a minimal size
    24162416        is computed and some windows may be larger if there is room.  The
    24172417        'eadirection' option tells in which direction the size is affected.
    2418         Changing the height of a window can be avoided by setting
    2419         'winfixheight'.
     2418        Changing the height and width of a window can be avoided by setting
     2419        'winfixheight' and 'winfixwidth', respectively.
    24202420
    24212421                                                *'equalprg'* *'ep'*
    24222422'equalprg' 'ep'         string  (default "")
  • runtime/doc/pattern.txt

    diff -Naur vim71.orig/runtime/doc/pattern.txt vim71/runtime/doc/pattern.txt
    old new  
    12121212                {group} must exist at the moment this command is executed.
    12131213
    12141214                The {group} highlighting still applies when a character is
    1215                 to be highlighted for 'hlsearch'.
     1215                to be highlighted for 'hlsearch', as the highlighting for
     1216                matches is given higher priority than that of 'hlsearch'.
     1217                Syntax highlighting (see 'syntax') is also overruled by
     1218                matches.
    12161219
    12171220                Note that highlighting the last used search pattern with
    12181221                'hlsearch' is used in all windows, while the pattern defined
     
    12261229                display you may get unexpected results.  That is because Vim
    12271230                looks for a match in the line where redrawing starts.
    12281231
    1229                 Also see |matcharg()|, it returns the highlight group and
    1230                 pattern of a previous :match command.
     1232                Also see |matcharg()|and |getmatches()|. The former returns
     1233                the highlight group and pattern of a previous |:match|
     1234                command.  The latter returns a list with highlight groups and
     1235                patterns defined by both |matchadd()| and |:match|.
     1236
     1237                Highlighting matches using |:match| are limited to three
     1238                matches (aside from |:match|, |:2match| and |:3match|are
     1239                available). |matchadd()| does not have this limitation and in
     1240                addition makes it possible to prioritize matches.
    12311241
    12321242                Another example, which highlights all characters in virtual
    12331243                column 72 and more: >
  • runtime/doc/pi_paren.txt

    diff -Naur vim71.orig/runtime/doc/pi_paren.txt vim71/runtime/doc/pi_paren.txt
    old new  
    1212You can avoid loading this plugin by setting the "loaded_matchparen" variable: >
    1313        :let loaded_matchparen = 1
    1414
    15 The plugin installs CursorMoved autocommands to redefine the match
    16 highlighting.
     15The plugin installs CursorMoved, CursorMovedI and WinEnter autocommands to
     16redefine the match highlighting.
    1717
    1818To disable the plugin after it was loaded use this command: >
    1919
  • runtime/doc/usr_41.txt

    diff -Naur vim71.orig/runtime/doc/usr_41.txt vim71/runtime/doc/usr_41.txt
    old new  
    763763        foldtextresult()        get the text displayed for a closed fold
    764764
    765765Syntax and highlighting:
     766        clearmatches()          clear all matches defined by |matchadd()| and
     767                                the |:match| commands
     768        getmatches()            get all matches defined by |matchadd()| and
     769                                the |:match| commands
    766770        hlexists()              check if a highlight group exists
    767771        hlID()                  get ID of a highlight group
    768772        synID()                 get syntax ID at a specific position
    769773        synIDattr()             get a specific attribute of a syntax ID
    770774        synIDtrans()            get translated syntax ID
    771775        diff_hlID()             get highlight ID for diff mode at a position
     776        matchadd()              define a pattern to highlight (a "match")
    772777        matcharg()              get info about |:match| arguments
     778        matchdelete()           delete a match defined by |matchadd()| or a
     779                                |:match| command
     780        setmatches()            restore a list of matches saved by
     781                                |getmatches()|
    773782
    774783Spelling:
    775784        spellbadword()          locate badly spelled word at or after cursor
  • runtime/doc/windows.txt

    diff -Naur vim71.orig/runtime/doc/windows.txt vim71/runtime/doc/windows.txt
    old new  
    132132                the same file.  Make new window N high (default is to use half
    133133                the height of the current window).  Reduces the current window
    134134                height to create room (and others, if the 'equalalways' option
    135                 is set and 'eadirection' isn't "hor").
     135                is set, 'eadirection' isn't "hor", and one of them is higher
     136                than the current or the new window).
    136137                Note: CTRL-S does not work on all terminals and might block
    137138                further input, use CTRL-Q to get going again.
    138139                Also see |++opt| and |+cmd|.
     
    140141CTRL-W CTRL-V                                           *CTRL-W_CTRL-V*
    141142CTRL-W v                                                *CTRL-W_v*
    142143:[N]vs[plit] [++opt] [+cmd] [file]                      *:vs* *:vsplit*
    143                 Like |:split|, but split vertically.  If 'equalalways' is set
    144                 and 'eadirection' isn't "ver" the windows will be spread out
    145                 horizontally, unless a width was specified.
     144                Like |:split|, but split vertically.  The windows will be
     145                spread out horizontally if
     146                1. a width was not specified,
     147                2. 'equalalways' is set,
     148                3. 'eadirection' isn't "ver", and
     149                4. one of the other windows are wider than the current or new
     150                   window.
    146151                Note: In other places CTRL-Q does the same as CTRL-V, but here
    147152                it doesn't!
    148153
  • runtime/filetype.vim

    diff -Naur vim71.orig/runtime/filetype.vim vim71/runtime/filetype.vim
    old new  
    11" Vim support file to detect file types
    22"
    33" Maintainer:   Bram Moolenaar <Bram@vim.org>
    4 " Last Change:  2007 May 10
     4" Last Change:  2007 May 15
    55
    66" Listen very carefully, I will say this only once
    77if exists("did_load_filetypes")
     
    12861286au BufNewFile,BufRead *.it,*.ih                 setf ppwiz
    12871287
    12881288" Oracle Pro*C/C++
    1289 au BufNewFile,BufRead .pc                       setf proc
     1289au BufNewFile,BufRead *.pc                      setf proc
    12901290
    12911291" Privoxy actions file
    12921292au BufNewFile,BufRead *.action                  setf privoxy
  • runtime/plugin/matchparen.vim

    diff -Naur vim71.orig/runtime/plugin/matchparen.vim vim71/runtime/plugin/matchparen.vim
    old new  
    11" Vim plugin for showing matching parens
    22" Maintainer:  Bram Moolenaar <Bram@vim.org>
    3 " Last Change: 2006 Oct 12
     3" Last Change: 2007 Aug 8
    44
    55" Exit quickly when:
    66" - this plugin was already loaded (or disabled)
     
    1313
    1414augroup matchparen
    1515  " Replace all matchparen autocommands
    16   autocmd! CursorMoved,CursorMovedI * call s:Highlight_Matching_Pair()
     16  autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair()
    1717augroup END
    1818
    1919" Skip the rest if it was already done.
     
    6262  " Figure out the arguments for searchpairpos().
    6363  " Restrict the search to visible lines with "stopline".
    6464  " And avoid searching very far (e.g., for closed folds and long lines)
     65  " The "viewable" variables give a range in which we can scroll while keeping
     66  " the cursor at the same position
     67  " adjustedScrolloff accounts for very large numbers of scrolloff
     68  let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2])
     69  let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2])
     70  let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2])
     71  " one of these stoplines will be adjusted below, but the current values are
     72  " minimal boundaries within the current window
     73  let stoplinebottom = line('w$')
     74  let stoplinetop = line('w0')
    6575  if i % 2 == 0
    6676    let s_flags = 'nW'
    6777    let c2 = plist[i + 1]
    6878    if has("byte_offset") && has("syntax_items") && &smc > 0
    6979      let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2])
    70       let stopline = min([line('w$'), byte2line(stopbyte)])
     80      let stopline = min([bottom_viewable, byte2line(stopbyte)])
    7181    else
    72       let stopline = min([line('w$'), c_lnum + 100])
     82      let stopline = min([bottom_viewable, c_lnum + 100])
    7383    endif
     84    let stoplinebottom = stopline
    7485  else
    7586    let s_flags = 'nbW'
    7687    let c2 = c
    7788    let c = plist[i - 1]
    7889    if has("byte_offset") && has("syntax_items") && &smc > 0
    7990      let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2])
    80       let stopline = max([line('w0'), byte2line(stopbyte)])
     91      let stopline = max([top_viewable, byte2line(stopbyte)])
    8192    else
    82       let stopline = max([line('w0'), c_lnum - 100])
     93      let stopline = max([top_viewable, c_lnum - 100])
    8394    endif
     95    let stoplinetop = stopline
    8496  endif
    8597  if c == '['
    8698    let c = '\['
     
    106118  endif
    107119
    108120  " If a match is found setup match highlighting.
    109   if m_lnum > 0 && m_lnum >= line('w0') && m_lnum <= line('w$')
     121  if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom
    110122    exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) .
    111123          \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
    112124    let w:paren_hl_on = 1
     
    114126endfunction
    115127
    116128" Define commands that will disable and enable the plugin.
    117 command! NoMatchParen 3match none | unlet! g:loaded_matchparen | au! matchparen
    118 command! DoMatchParen runtime plugin/matchparen.vim | doau CursorMoved
     129command! NoMatchParen windo 3match none | unlet! g:loaded_matchparen |
     130          \ au! matchparen
     131command! DoMatchParen runtime plugin/matchparen.vim | windo doau CursorMoved
    119132
    120133let &cpo = cpo_save
  • src/auto/configure

    diff -Naur vim71.orig/src/auto/configure vim71/src/auto/configure
    old new  
    38433843  fi
    38443844
    38453845  if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
    3846     if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
     3846    if test "x$MACOSX" = "xyes"; then
     3847      MZSCHEME_LIBS="-framework PLT_MzScheme"
     3848    elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
    38473849      MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
    38483850    else
    38493851      MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
  • src/buffer.c

    diff -Naur vim71.orig/src/buffer.c vim71/src/buffer.c
    old new  
    171171            /* Put the cursor on the first line. */
    172172            curwin->w_cursor.lnum = 1;
    173173            curwin->w_cursor.col = 0;
     174
     175            /* Set or reset 'modified' before executing autocommands, so that
     176             * it can be changed there. */
     177            if (!readonlymode && !bufempty())
     178                changed();
     179            else if (retval != FAIL)
     180                unchanged(curbuf, FALSE);
    174181#ifdef FEAT_AUTOCMD
    175182# ifdef FEAT_EVAL
    176183            apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE,
     
    194201    /* When reading stdin, the buffer contents always needs writing, so set
    195202     * the changed flag.  Unless in readonly mode: "ls | gview -".
    196203     * When interrupted and 'cpoptions' contains 'i' set changed flag. */
    197     if ((read_stdin && !readonlymode && !bufempty())
     204    if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
    198205#ifdef FEAT_AUTOCMD
    199206                || modified_was_set     /* ":set modified" used in autocmd */
    200207# ifdef FEAT_EVAL
    201208                || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
    202209# endif
    203210#endif
    204                 || (got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL))
     211       )
    205212        changed();
    206     else if (retval != FAIL)
     213    else if (retval != FAIL && !read_stdin)
    207214        unchanged(curbuf, FALSE);
    208215    save_file_ff(curbuf);               /* keep this fileformat */
    209216
     
    495502    buf->b_start_eol = TRUE;
    496503#ifdef FEAT_MBYTE
    497504    buf->b_p_bomb = FALSE;
     505    buf->b_start_bomb = FALSE;
    498506#endif
    499507    buf->b_ml.ml_mfp = NULL;
    500508    buf->b_ml.ml_flags = ML_EMPTY;              /* empty buffer */
     
    41674175     * mess up the full path name, even though it starts with a '/'.
    41684176     * Also expand when there is ".." in the file name, try to remove it,
    41694177     * because "c:/src/../README" is equal to "c:/README".
     4178     * Similarly "c:/src//file" is equal to "c:/src/file".
    41704179     * For MS-Windows also expand names like "longna~1" to "longname".
    41714180     */
    41724181#ifdef UNIX
    41734182    return FullName_save(fname, TRUE);
    41744183#else
    4175     if (!vim_isAbsName(fname) || strstr((char *)fname, "..") != NULL
    4176 #if defined(MSWIN) || defined(DJGPP)
     4184    if (!vim_isAbsName(fname)
     4185            || strstr((char *)fname, "..") != NULL
     4186            || strstr((char *)fname, "//") != NULL
     4187# ifdef BACKSLASH_IN_FILENAME
     4188            || strstr((char *)fname, "\\\\") != NULL
     4189# endif
     4190# if defined(MSWIN) || defined(DJGPP)
    41774191            || vim_strchr(fname, '~') != NULL
    4178 #endif
     4192# endif
    41794193            )
    41804194        return FullName_save(fname, FALSE);
    41814195
    41824196    fname = vim_strsave(fname);
    41834197
    4184 #ifdef USE_FNAME_CASE
    4185 # ifdef USE_LONG_FNAME
     4198# ifdef USE_FNAME_CASE
     4199#  ifdef USE_LONG_FNAME
    41864200    if (USE_LONG_FNAME)
    4187 # endif
     4201#  endif
    41884202    {
    41894203        if (fname != NULL)
    41904204            fname_case(fname, 0);       /* set correct case for file name */
    41914205    }
    4192 #endif
     4206# endif
    41934207
    41944208    return fname;
    41954209#endif
     
    48534867             */
    48544868            for (e = s; *e != ':' && *e != NUL; ++e)
    48554869                if (e[0] == '\\' && e[1] == ':')
    4856                     STRCPY(e, e + 1);
     4870                    mch_memmove(e, e + 1, STRLEN(e));
    48574871            if (*e == NUL)
    48584872                end = TRUE;
    48594873
     
    55075521
    55085522#ifdef FEAT_AUTOCMD
    55095523    if (!aucmd)             /* Don't trigger BufDelete autocommands here. */
    5510         ++autocmd_block;
     5524        block_autocmds();
    55115525#endif
    55125526    close_buffer(NULL, buf, DOBUF_WIPE);
    55135527#ifdef FEAT_AUTOCMD
    55145528    if (!aucmd)
    5515         --autocmd_block;
     5529        unblock_autocmds();
    55165530#endif
    55175531}
  • src/charset.c

    diff -Naur vim71.orig/src/charset.c vim71/src/charset.c
    old new  
    207207            }
    208208            while (c <= c2)
    209209            {
    210                 if (!do_isalpha || isalpha(c)
     210                /* Use the MB_ functions here, because isalpha() doesn't
     211                 * work properly when 'encoding' is "latin1" and the locale is
     212                 * "C".  */
     213                if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c)
    211214#ifdef FEAT_FKMAP
    212215                        || (p_altkeymap && (F_isalpha(c) || F_isdigit(c)))
    213216#endif
     
    929932}
    930933
    931934/*
     935 * return TRUE if 'c' is a valid file-name character or a wildcard character
     936 * Assume characters above 0x100 are valid (multi-byte).
     937 * Explicitly interpret ']' as a wildcard character as mch_has_wildcard("]")
     938 * returns false.
     939 */
     940    int
     941vim_isfilec_or_wc(c)
     942    int c;
     943{
     944    char_u buf[2];
     945
     946    buf[0] = (char_u)c;
     947    buf[1] = NUL;
     948    return vim_isfilec(c) || c == ']' || mch_has_wildcard(buf);
     949}
     950
     951/*
    932952 * return TRUE if 'c' is a printable character
    933953 * Assume characters above 0x100 are printable (multi-byte), except for
    934954 * Unicode.
     
    18981918{
    18991919    for ( ; *p; ++p)
    19001920        if (rem_backslash(p))
    1901             STRCPY(p, p + 1);
     1921            mch_memmove(p, p + 1, STRLEN(p));
    19021922}
    19031923
    19041924/*
  • src/configure.in

    diff -Naur vim71.orig/src/configure.in vim71/src/configure.in
    old new  
    423423  fi
    424424
    425425  if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
    426     if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
     426    if test "x$MACOSX" = "xyes"; then
     427      MZSCHEME_LIBS="-framework PLT_MzScheme"
     428    elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
    427429      MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
    428430    else
    429431      MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
  • src/diff.c

    diff -Naur vim71.orig/src/diff.c vim71/src/diff.c
    old new  
    840840                    tmp_orig, tmp_new);
    841841            append_redir(cmd, p_srr, tmp_diff);
    842842#ifdef FEAT_AUTOCMD
    843             ++autocmd_block;    /* Avoid ShellCmdPost stuff */
     843            block_autocmds();   /* Avoid ShellCmdPost stuff */
    844844#endif
    845845            (void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT);
    846846#ifdef FEAT_AUTOCMD
    847             --autocmd_block;
     847            unblock_autocmds();
    848848#endif
    849849            vim_free(cmd);
    850850        }
     
    949949# endif
    950950                eap->arg);
    951951#ifdef FEAT_AUTOCMD
    952         ++autocmd_block;        /* Avoid ShellCmdPost stuff */
     952        block_autocmds();       /* Avoid ShellCmdPost stuff */
    953953#endif
    954954        (void)call_shell(buf, SHELL_FILTER | SHELL_COOKED);
    955955#ifdef FEAT_AUTOCMD
    956         --autocmd_block;
     956        unblock_autocmds();
    957957#endif
    958958    }
    959959
  • src/digraph.c

    diff -Naur vim71.orig/src/digraph.c vim71/src/digraph.c
    old new  
    20282028
    20292029    ++no_mapping;
    20302030    ++allow_keys;
    2031     c = safe_vgetc();
     2031    c = plain_vgetc();
    20322032    --no_mapping;
    20332033    --allow_keys;
    20342034    if (c != ESC)               /* ESC cancels CTRL-K */
     
    20502050#endif
    20512051        ++no_mapping;
    20522052        ++allow_keys;
    2053         cc = safe_vgetc();
     2053        cc = plain_vgetc();
    20542054        --no_mapping;
    20552055        --allow_keys;
    20562056        if (cc != ESC)      /* ESC cancels CTRL-K */
     
    23492349
    23502350    if (*curbuf->b_p_keymap == NUL)
    23512351    {
    2352         /* Stop any active keymap and clear the table. */
     2352        /* Stop any active keymap and clear the table.  Also remove
     2353         * b:keymap_name, as no keymap is active now. */
    23532354        keymap_unload();
     2355        do_cmdline_cmd((char_u *)"unlet! b:keymap_name");
    23542356    }
    23552357    else
    23562358    {
     
    25002502
    25012503    ga_clear(&curbuf->b_kmap_ga);
    25022504    curbuf->b_kmap_state &= ~KEYMAP_LOADED;
    2503     do_cmdline_cmd((char_u *)"unlet! b:keymap_name");
    25042505#ifdef FEAT_WINDOWS
    25052506    status_redraw_curbuf();
    25062507#endif
  • src/edit.c

    diff -Naur vim71.orig/src/edit.c vim71/src/edit.c
    old new  
    788788            ins_redraw(FALSE);
    789789            ++no_mapping;
    790790            ++allow_keys;
    791             c = safe_vgetc();
     791            c = plain_vgetc();
    792792            --no_mapping;
    793793            --allow_keys;
    794794            if (c != Ctrl_N && c != Ctrl_G && c != Ctrl_O)
     
    981981#ifdef FEAT_NETBEANS_INTG
    982982        case K_F21:     /* NetBeans command */
    983983            ++no_mapping;               /* don't map the next key hits */
    984             i = safe_vgetc();
     984            i = plain_vgetc();
    985985            --no_mapping;
    986986            netbeans_keycommand(i);
    987987            break;
     
    20572057 * case of the originally typed text is used, and the case of the completed
    20582058 * text is inferred, ie this tries to work out what case you probably wanted
    20592059 * the rest of the word to be in -- webb
    2060  * TODO: make this work for multi-byte characters.
    20612060 */
    20622061    int
    20632062ins_compl_add_infercase(str, len, icase, fname, dir, flags)
     
    20682067    int         dir;
    20692068    int         flags;
    20702069{
     2070    char_u      *p;
     2071    int         i, c;
     2072    int         actual_len;             /* Take multi-byte characters */
     2073    int         actual_compl_length;    /* into account. */
     2074    int         *wca;                   /* Wide character array. */
    20712075    int         has_lower = FALSE;
    20722076    int         was_letter = FALSE;
    2073     int         idx;
    20742077
    2075     if (p_ic && curbuf->b_p_inf && len < IOSIZE)
     2078    if (p_ic && curbuf->b_p_inf)
    20762079    {
    2077         /* Infer case of completed part -- webb */
    2078         /* Use IObuff, str would change text in buffer! */
    2079         vim_strncpy(IObuff, str, len);
     2080        /* Infer case of completed part. */
    20802081
    2081         /* Rule 1: Were any chars converted to lower? */
    2082         for (idx = 0; idx < compl_length; ++idx)
     2082        /* Find actual length of completion. */
     2083#ifdef FEAT_MBYTE
     2084        if (has_mbyte)
    20832085        {
    2084             if (islower(compl_orig_text[idx]))
     2086            p = str;
     2087            actual_len = 0;
     2088            while (*p != NUL)
    20852089            {
    2086                 has_lower = TRUE;
    2087                 if (isupper(IObuff[idx]))
    2088                 {
    2089                     /* Rule 1 is satisfied */
    2090                     for (idx = compl_length; idx < len; ++idx)
    2091                         IObuff[idx] = TOLOWER_LOC(IObuff[idx]);
    2092                     break;
    2093                 }
     2090                mb_ptr_adv(p);
     2091                ++actual_len;
    20942092            }
    20952093        }
     2094        else
     2095#endif
     2096            actual_len = len;
    20962097
    2097         /*
    2098          * Rule 2: No lower case, 2nd consecutive letter converted to
    2099          * upper case.
    2100          */
    2101         if (!has_lower)
     2098        /* Find actual length of original text. */
     2099#ifdef FEAT_MBYTE
     2100        if (has_mbyte)
    21022101        {
    2103             for (idx = 0; idx < compl_length; ++idx)
     2102            p = compl_orig_text;
     2103            actual_compl_length = 0;
     2104            while (*p != NUL)
    21042105            {
    2105                 if (was_letter && isupper(compl_orig_text[idx])
    2106                                                       && islower(IObuff[idx]))
     2106                mb_ptr_adv(p);
     2107                ++actual_compl_length;
     2108            }
     2109        }
     2110        else
     2111#endif
     2112            actual_compl_length = compl_length;
     2113
     2114        /* Allocate wide character array for the completion and fill it. */
     2115        wca = (int *)alloc(actual_len * sizeof(int));
     2116        if (wca != NULL)
     2117        {
     2118            p = str;
     2119            for (i = 0; i < actual_len; ++i)
     2120#ifdef FEAT_MBYTE
     2121                if (has_mbyte)
     2122                    wca[i] = mb_ptr2char_adv(&p);
     2123                else
     2124#endif
     2125                    wca[i] = *(p++);
     2126
     2127            /* Rule 1: Were any chars converted to lower? */
     2128            p = compl_orig_text;
     2129            for (i = 0; i < actual_compl_length; ++i)
     2130            {
     2131#ifdef FEAT_MBYTE
     2132                if (has_mbyte)
     2133                    c = mb_ptr2char_adv(&p);
     2134                else
     2135#endif
     2136                    c = *(p++);
     2137                if (MB_ISLOWER(c))
    21072138                {
    2108                     /* Rule 2 is satisfied */
    2109                     for (idx = compl_length; idx < len; ++idx)
    2110                         IObuff[idx] = TOUPPER_LOC(IObuff[idx]);
    2111                     break;
     2139                    has_lower = TRUE;
     2140                    if (MB_ISUPPER(wca[i]))
     2141                    {
     2142                        /* Rule 1 is satisfied. */
     2143                        for (i = actual_compl_length; i < actual_len; ++i)
     2144                            wca[i] = MB_TOLOWER(wca[i]);
     2145                        break;
     2146                    }
    21122147                }
    2113                 was_letter = isalpha(compl_orig_text[idx]);
    21142148            }
    2115         }
    21162149
    2117         /* Copy the original case of the part we typed */
    2118         STRNCPY(IObuff, compl_orig_text, compl_length);
     2150            /*
     2151             * Rule 2: No lower case, 2nd consecutive letter converted to
     2152             * upper case.
     2153             */
     2154            if (!has_lower)
     2155            {
     2156                p = compl_orig_text;
     2157                for (i = 0; i < actual_compl_length; ++i)
     2158                {
     2159#ifdef FEAT_MBYTE
     2160                    if (has_mbyte)
     2161                        c = mb_ptr2char_adv(&p);
     2162                    else
     2163#endif
     2164                        c = *(p++);
     2165                    if (was_letter && MB_ISUPPER(c) && MB_ISLOWER(wca[i]))
     2166                    {
     2167                        /* Rule 2 is satisfied. */
     2168                        for (i = actual_compl_length; i < actual_len; ++i)
     2169                            wca[i] = MB_TOUPPER(wca[i]);
     2170                        break;
     2171                    }
     2172                    was_letter = MB_ISLOWER(c) || MB_ISUPPER(c);
     2173                }
     2174            }
     2175
     2176            /* Copy the original case of the part we typed. */
     2177            p = compl_orig_text;
     2178            for (i = 0; i < actual_compl_length; ++i)
     2179            {
     2180#ifdef FEAT_MBYTE
     2181                if (has_mbyte)
     2182                    c = mb_ptr2char_adv(&p);
     2183                else
     2184#endif
     2185                    c = *(p++);
     2186                if (MB_ISLOWER(c))
     2187                    wca[i] = MB_TOLOWER(wca[i]);
     2188                else if (MB_ISUPPER(c))
     2189                    wca[i] = MB_TOUPPER(wca[i]);
     2190            }
     2191
     2192            /*
     2193             * Generate encoding specific output from wide character array.
     2194             * Multi-byte characters can occupy up to five bytes more than
     2195             * ASCII characters, and we also need one byte for NUL, so stay
     2196             * six bytes away from the edge of IObuff.
     2197             */
     2198            p = IObuff;
     2199            i = 0;
     2200            while (i < actual_len && (p - IObuff + 6) < IOSIZE)
     2201#ifdef FEAT_MBYTE
     2202                if (has_mbyte)
     2203                    p += mb_char2bytes(wca[i++], p);
     2204                else
     2205#endif
     2206                    *(p++) = wca[i++];
     2207            *p = NUL;
     2208
     2209            vim_free(wca);
     2210        }
    21192211
    21202212        return ins_compl_add(IObuff, len, icase, fname, NULL, dir,
    21212213                                                                flags, FALSE);
     
    28422934                        /*
    28432935                         * Add the other matches on the line
    28442936                         */
     2937                        ptr = buf;
    28452938                        while (!got_int)
    28462939                        {
    28472940                            /* Find start of the next word.  Skip white
     
    28512944                                break;
    28522945                            wstart = ptr;
    28532946
    2854                             /* Find end of the word and add it. */
     2947                            /* Find end of the word. */
    28552948#ifdef FEAT_MBYTE
    28562949                            if (has_mbyte)
    28572950                                /* Japanese words may have characters in
     
    28682961                            else
    28692962#endif
    28702963                                ptr = find_word_end(ptr);
    2871                             add_r = ins_compl_add_infercase(wstart,
    2872                                     (int)(ptr - wstart),
    2873                                     p_ic, files[i], *dir, 0);
     2964
     2965                            /* Add the word. Skip the regexp match. */
     2966                            if (wstart != regmatch->startp[0])
     2967                                add_r = ins_compl_add_infercase(wstart,
     2968                                        (int)(ptr - wstart),
     2969                                        p_ic, files[i], *dir, 0);
    28742970                        }
    28752971                    }
    28762972                    if (add_r == OK)
     
    51285224    i = 0;
    51295225    for (;;)
    51305226    {
    5131         do
    5132             nc = safe_vgetc();
    5133         while (nc == K_IGNORE || nc == K_VER_SCROLLBAR
    5134                                                     || nc == K_HOR_SCROLLBAR);
     5227        nc = plain_vgetc();
    51355228#ifdef FEAT_CMDL_INFO
    51365229        if (!(State & CMDLINE)
    51375230# ifdef FEAT_MBYTE
     
    72157308                p = ml_get_curline();
    72167309                if (cin_iscase(p) || cin_isscopedecl(p) || cin_islabel(30))
    72177310                    return TRUE;
     7311                /* Need to get the line again after cin_islabel(). */
     7312                p = ml_get_curline();
    72187313                if (curwin->w_cursor.col > 2
    72197314                        && p[curwin->w_cursor.col - 1] == ':'
    72207315                        && p[curwin->w_cursor.col - 2] == ':')
     
    74777572     * deleted when ESC is hit.
    74787573     */
    74797574    ++no_mapping;
    7480     regname = safe_vgetc();
     7575    regname = plain_vgetc();
    74817576#ifdef FEAT_LANGMAP
    74827577    LANGMAP_ADJUST(regname, TRUE);
    74837578#endif
     
    74887583#ifdef FEAT_CMDL_INFO
    74897584        add_to_showcmd_c(literally);
    74907585#endif
    7491         regname = safe_vgetc();
     7586        regname = plain_vgetc();
    74927587#ifdef FEAT_LANGMAP
    74937588        LANGMAP_ADJUST(regname, TRUE);
    74947589#endif
     
    75797674     * deleted when ESC is hit.
    75807675     */
    75817676    ++no_mapping;
    7582     c = safe_vgetc();
     7677    c = plain_vgetc();
    75837678    --no_mapping;
    75847679    switch (c)
    75857680    {
     
    79988093    /*
    79998094     * 0^D and ^^D: remove all indent.
    80008095     */
    8001     if ((lastc == '0' || lastc == '^') && curwin->w_cursor.col)
     8096    if (c == Ctrl_D && (lastc == '0' || lastc == '^')
     8097                                                  && curwin->w_cursor.col > 0)
    80028098    {
    80038099        --curwin->w_cursor.col;
    80048100        (void)del_char(FALSE);          /* delete the '^' or '0' */
     
    92579353     * mode message to be deleted when ESC is hit */
    92589354    ++no_mapping;
    92599355    ++allow_keys;
    9260     c = safe_vgetc();
     9356    c = plain_vgetc();
    92619357    --no_mapping;
    92629358    --allow_keys;
    92639359    if (IS_SPECIAL(c) || mod_mask)          /* special key */
     
    92899385        }
    92909386        ++no_mapping;
    92919387        ++allow_keys;
    9292         cc = safe_vgetc();
     9388        cc = plain_vgetc();
    92939389        --no_mapping;
    92949390        --allow_keys;
    92959391        if (cc != ESC)
  • src/eval.c

    diff -Naur vim71.orig/src/eval.c vim71/src/eval.c
    old new  
    369369static int ex_let_vars __ARGS((char_u *arg, typval_T *tv, int copy, int semicolon, int var_count, char_u *nextchars));
    370370static char_u *skip_var_list __ARGS((char_u *arg, int *var_count, int *semicolon));
    371371static char_u *skip_var_one __ARGS((char_u *arg));
    372 static void list_hashtable_vars __ARGS((hashtab_T *ht, char_u *prefix, int empty));
    373 static void list_glob_vars __ARGS((void));
    374 static void list_buf_vars __ARGS((void));
    375 static void list_win_vars __ARGS((void));
     372static void list_hashtable_vars __ARGS((hashtab_T *ht, char_u *prefix, int empty, int *first));
     373static void list_glob_vars __ARGS((int *first));
     374static void list_buf_vars __ARGS((int *first));
     375static void list_win_vars __ARGS((int *first));
    376376#ifdef FEAT_WINDOWS
    377 static void list_tab_vars __ARGS((void));
     377static void list_tab_vars __ARGS((int *first));
    378378#endif
    379 static void list_vim_vars __ARGS((void));
    380 static void list_script_vars __ARGS((void));
    381 static void list_func_vars __ARGS((void));
    382 static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg));
     379static void list_vim_vars __ARGS((int *first));
     380static void list_script_vars __ARGS((int *first));
     381static void list_func_vars __ARGS((int *first));
     382static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg, int *first));
    383383static char_u *ex_let_one __ARGS((char_u *arg, typval_T *tv, int copy, char_u *endchars, char_u *op));
    384384static int check_changedtick __ARGS((char_u *arg));
    385385static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int unlet, int skip, int quiet, int fne_flags));
     
    475475static void f_changenr __ARGS((typval_T *argvars, typval_T *rettv));
    476476static void f_char2nr __ARGS((typval_T *argvars, typval_T *rettv));
    477477static void f_cindent __ARGS((typval_T *argvars, typval_T *rettv));
     478static void f_clearmatches __ARGS((typval_T *argvars, typval_T *rettv));
    478479static void f_col __ARGS((typval_T *argvars, typval_T *rettv));
    479480#if defined(FEAT_INS_EXPAND)
    480481static void f_complete __ARGS((typval_T *argvars, typval_T *rettv));
     
    529530static void f_getftime __ARGS((typval_T *argvars, typval_T *rettv));
    530531static void f_getftype __ARGS((typval_T *argvars, typval_T *rettv));
    531532static void f_getline __ARGS((typval_T *argvars, typval_T *rettv));
     533static void f_getmatches __ARGS((typval_T *argvars, typval_T *rettv));
    532534static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv));
    533535static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv));
    534536static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv));
     
    577579static void f_maparg __ARGS((typval_T *argvars, typval_T *rettv));
    578580static void f_mapcheck __ARGS((typval_T *argvars, typval_T *rettv));
    579581static void f_match __ARGS((typval_T *argvars, typval_T *rettv));
     582static void f_matchadd __ARGS((typval_T *argvars, typval_T *rettv));
    580583static void f_matcharg __ARGS((typval_T *argvars, typval_T *rettv));
     584static void f_matchdelete __ARGS((typval_T *argvars, typval_T *rettv));
    581585static void f_matchend __ARGS((typval_T *argvars, typval_T *rettv));
    582586static void f_matchlist __ARGS((typval_T *argvars, typval_T *rettv));
    583587static void f_matchstr __ARGS((typval_T *argvars, typval_T *rettv));
     
    618622static void f_setcmdpos __ARGS((typval_T *argvars, typval_T *rettv));
    619623static void f_setline __ARGS((typval_T *argvars, typval_T *rettv));
    620624static void f_setloclist __ARGS((typval_T *argvars, typval_T *rettv));
     625static void f_setmatches __ARGS((typval_T *argvars, typval_T *rettv));
    621626static void f_setpos __ARGS((typval_T *argvars, typval_T *rettv));
    622627static void f_setqflist __ARGS((typval_T *argvars, typval_T *rettv));
    623628static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv));
     
    672677static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
    673678
    674679static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump));
    675 static pos_T *var2fpos __ARGS((typval_T *varp, int lnum, int *fnum));
     680static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
    676681static int get_env_len __ARGS((char_u **arg));
    677682static int get_id_len __ARGS((char_u **arg));
    678683static int get_name_len __ARGS((char_u **arg, char_u **alias, int evaluate, int verbose));
     
    699704static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname));
    700705static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val));
    701706static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi));
    702 static void list_one_var __ARGS((dictitem_T *v, char_u *prefix));
    703 static void list_one_var_a __ARGS((char_u *prefix, char_u *name, int type, char_u *string));
     707static void list_one_var __ARGS((dictitem_T *v, char_u *prefix, int *first));
     708static void list_one_var_a __ARGS((char_u *prefix, char_u *name, int type, char_u *string, int *first));
    704709static void set_var __ARGS((char_u *name, typval_T *varp, int copy));
    705710static int var_check_ro __ARGS((int flags, char_u *name));
    706711static int var_check_fixed __ARGS((int flags, char_u *name));
     
    992997    char_u      *value;
    993998    int         value_len;
    994999{
    995     size_t      len;
     1000    int         len;
    9961001
    9971002    if (redir_lval == NULL)
    9981003        return;
    9991004
    10001005    if (value_len == -1)
    1001         len = STRLEN(value);    /* Append the entire string */
     1006        len = (int)STRLEN(value);       /* Append the entire string */
    10021007    else
    1003         len = value_len;        /* Append only "value_len" characters */
     1008        len = value_len;                /* Append only "value_len" characters */
    10041009
    1005     if (ga_grow(&redir_ga, (int)len) == OK)
     1010    if (ga_grow(&redir_ga, len) == OK)
    10061011    {
    10071012        mch_memmove((char *)redir_ga.ga_data + redir_ga.ga_len, value, len);
    1008         redir_ga.ga_len += (int)len;
     1013        redir_ga.ga_len += len;
    10091014    }
    10101015    else
    10111016        var_redir_stop();
     
    13131318{
    13141319    hashitem_T  *hi;
    13151320
    1316     clear_tv(&vimvars[idx].vv_tv);
    13171321    vimvars[idx].vv_tv = *save_tv;
    13181322    if (vimvars[idx].vv_type == VAR_UNKNOWN)
    13191323    {
     
    13571361
    13581362    if (p_verbose == 0)
    13591363        --emsg_off;
    1360     vimvars[VV_VAL].vv_str = NULL;
    13611364    restore_vimvar(VV_VAL, &save_val);
    13621365
    13631366    return list;
     
    14111414}
    14121415
    14131416
    1414 #if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO)
     1417#if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) \
     1418        || defined(FEAT_COMPL_FUNC) || defined(PROTO)
    14151419/*
    14161420 * Call some vimL function and return the result in "*rettv".
    14171421 * Uses argv[argc] for the function arguments.
     
    14841488    return ret;
    14851489}
    14861490
     1491# if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO)
    14871492/*
    14881493 * Call vimL function "func" and return the result as a string.
    14891494 * Returns NULL when calling the function fails.
     
    15061511    clear_tv(&rettv);
    15071512    return retval;
    15081513}
     1514# endif
    15091515
    1510 #if defined(FEAT_COMPL_FUNC) || defined(PROTO)
     1516# if defined(FEAT_COMPL_FUNC) || defined(PROTO)
    15111517/*
    15121518 * Call vimL function "func" and return the result as a number.
    15131519 * Returns -1 when calling the function fails.
     
    15301536    clear_tv(&rettv);
    15311537    return retval;
    15321538}
    1533 #endif
     1539# endif
    15341540
    15351541/*
    15361542 * Call vimL function "func" and return the result as a list
     
    15561562
    15571563    return rettv.vval.v_list;
    15581564}
    1559 
    15601565#endif
    15611566
     1567
    15621568/*
    15631569 * Save the current function call pointer, and set it to NULL.
    15641570 * Used when executing autocommands and for ":source".
     
    16911697    int         semicolon = 0;
    16921698    char_u      op[2];
    16931699    char_u      *argend;
     1700    int         first = TRUE;
    16941701
    16951702    argend = skip_var_list(arg, &var_count, &semicolon);
    16961703    if (argend == NULL)
     
    17071714            EMSG(_(e_invarg));
    17081715        else if (!ends_excmd(*arg))
    17091716            /* ":let var1 var2" */
    1710             arg = list_arg_vars(eap, arg);
     1717            arg = list_arg_vars(eap, arg, &first);
    17111718        else if (!eap->skip)
    17121719        {
    17131720            /* ":let" */
    1714             list_glob_vars();
    1715             list_buf_vars();
    1716             list_win_vars();
     1721            list_glob_vars(&first);
     1722            list_buf_vars(&first);
     1723            list_win_vars(&first);
    17171724#ifdef FEAT_WINDOWS
    1718             list_tab_vars();
     1725            list_tab_vars(&first);
    17191726#endif
    1720             list_script_vars();
    1721             list_func_vars();
    1722             list_vim_vars();
     1727            list_script_vars(&first);
     1728            list_func_vars(&first);
     1729            list_vim_vars(&first);
    17231730        }
    17241731        eap->nextcmd = check_nextcmd(arg);
    17251732    }
     
    19241931 * If "empty" is TRUE also list NULL strings as empty strings.
    19251932 */
    19261933    static void
    1927 list_hashtable_vars(ht, prefix, empty)
     1934list_hashtable_vars(ht, prefix, empty, first)
    19281935    hashtab_T   *ht;
    19291936    char_u      *prefix;
    19301937    int         empty;
     1938    int         *first;
    19311939{
    19321940    hashitem_T  *hi;
    19331941    dictitem_T  *di;
     
    19421950            di = HI2DI(hi);
    19431951            if (empty || di->di_tv.v_type != VAR_STRING
    19441952                                           || di->di_tv.vval.v_string != NULL)
    1945                 list_one_var(di, prefix);
     1953                list_one_var(di, prefix, first);
    19461954        }
    19471955    }
    19481956}
     
    19511959 * List global variables.
    19521960 */
    19531961    static void
    1954 list_glob_vars()
     1962list_glob_vars(first)
     1963    int *first;
    19551964{
    1956     list_hashtable_vars(&globvarht, (char_u *)"", TRUE);
     1965    list_hashtable_vars(&globvarht, (char_u *)"", TRUE, first);
    19571966}
    19581967
    19591968/*
    19601969 * List buffer variables.
    19611970 */
    19621971    static void
    1963 list_buf_vars()
     1972list_buf_vars(first)
     1973    int *first;
    19641974{
    19651975    char_u      numbuf[NUMBUFLEN];
    19661976
    1967     list_hashtable_vars(&curbuf->b_vars.dv_hashtab, (char_u *)"b:", TRUE);
     1977    list_hashtable_vars(&curbuf->b_vars.dv_hashtab, (char_u *)"b:",
     1978                                                                 TRUE, first);
    19681979
    19691980    sprintf((char *)numbuf, "%ld", (long)curbuf->b_changedtick);
    1970     list_one_var_a((char_u *)"b:", (char_u *)"changedtick", VAR_NUMBER, numbuf);
     1981    list_one_var_a((char_u *)"b:", (char_u *)"changedtick", VAR_NUMBER,
     1982                                                               numbuf, first);
    19711983}
    19721984
    19731985/*
    19741986 * List window variables.
    19751987 */
    19761988    static void
    1977 list_win_vars()
     1989list_win_vars(first)
     1990    int *first;
    19781991{
    1979     list_hashtable_vars(&curwin->w_vars.dv_hashtab, (char_u *)"w:", TRUE);
     1992    list_hashtable_vars(&curwin->w_vars.dv_hashtab,
     1993                                                 (char_u *)"w:", TRUE, first);
    19801994}
    19811995
    19821996#ifdef FEAT_WINDOWS
     
    19841998 * List tab page variables.
    19851999 */
    19862000    static void
    1987 list_tab_vars()
     2001list_tab_vars(first)
     2002    int *first;
    19882003{
    1989     list_hashtable_vars(&curtab->tp_vars.dv_hashtab, (char_u *)"t:", TRUE);
     2004    list_hashtable_vars(&curtab->tp_vars.dv_hashtab,
     2005                                                 (char_u *)"t:", TRUE, first);
    19902006}
    19912007#endif
    19922008
     
    19942010 * List Vim variables.
    19952011 */
    19962012    static void
    1997 list_vim_vars()
     2013list_vim_vars(first)
     2014    int *first;
    19982015{
    1999     list_hashtable_vars(&vimvarht, (char_u *)"v:", FALSE);
     2016    list_hashtable_vars(&vimvarht, (char_u *)"v:", FALSE, first);
    20002017}
    20012018
    20022019/*
    20032020 * List script-local variables, if there is a script.
    20042021 */
    20052022    static void
    2006 list_script_vars()
     2023list_script_vars(first)
     2024    int *first;
    20072025{
    20082026    if (current_SID > 0 && current_SID <= ga_scripts.ga_len)
    2009         list_hashtable_vars(&SCRIPT_VARS(current_SID), (char_u *)"s:", FALSE);
     2027        list_hashtable_vars(&SCRIPT_VARS(current_SID),
     2028                                                (char_u *)"s:", FALSE, first);
    20102029}
    20112030
    20122031/*
    20132032 * List function variables, if there is a function.
    20142033 */
    20152034    static void
    2016 list_func_vars()
     2035list_func_vars(first)
     2036    int *first;
    20172037{
    20182038    if (current_funccal != NULL)
    20192039        list_hashtable_vars(&current_funccal->l_vars.dv_hashtab,
    2020                                                        (char_u *)"l:", FALSE);
     2040                                                (char_u *)"l:", FALSE, first);
    20212041}
    20222042
    20232043/*
    20242044 * List variables in "arg".
    20252045 */
    20262046    static char_u *
    2027 list_arg_vars(eap, arg)
     2047list_arg_vars(eap, arg, first)
    20282048    exarg_T     *eap;
    20292049    char_u      *arg;
     2050    int         *first;
    20302051{
    20312052    int         error = FALSE;
    20322053    int         len;
     
    20832104                        {
    20842105                            switch (*name)
    20852106                            {
    2086                                 case 'g': list_glob_vars(); break;
    2087                                 case 'b': list_buf_vars(); break;
    2088                                 case 'w': list_win_vars(); break;
     2107                                case 'g': list_glob_vars(first); break;
     2108                                case 'b': list_buf_vars(first); break;
     2109                                case 'w': list_win_vars(first); break;
    20892110#ifdef FEAT_WINDOWS
    2090                                 case 't': list_tab_vars(); break;
     2111                                case 't': list_tab_vars(first); break;
    20912112#endif
    2092                                 case 'v': list_vim_vars(); break;
    2093                                 case 's': list_script_vars(); break;
    2094                                 case 'l': list_func_vars(); break;
     2113                                case 'v': list_vim_vars(first); break;
     2114                                case 's': list_script_vars(first); break;
     2115                                case 'l': list_func_vars(first); break;
    20952116                                default:
    20962117                                          EMSG2(_("E738: Can't list variables for %s"), name);
    20972118                            }
     
    21082129                            *arg = NUL;
    21092130                            list_one_var_a((char_u *)"",
    21102131                                    arg == arg_subsc ? name : name_start,
    2111                                     tv.v_type, s == NULL ? (char_u *)"" : s);
     2132                                    tv.v_type,
     2133                                    s == NULL ? (char_u *)"" : s,
     2134                                    first);
    21122135                            *arg = c;
    21132136                            vim_free(tf);
    21142137                        }
     
    61056128    /* Only do this once. */
    61066129    want_garbage_collect = FALSE;
    61076130    may_garbage_collect = FALSE;
     6131    garbage_collect_at_exit = FALSE;
    61086132
    61096133    /*
    61106134     * 1. Go through all accessible variables and mark all lists and dicts
     
    66816705    dict_T      *d = NULL;
    66826706    typval_T    tvkey;
    66836707    typval_T    tv;
    6684     char_u      *key;
     6708    char_u      *key = NULL;
    66856709    dictitem_T  *item;
    66866710    char_u      *start = skipwhite(*arg + 1);
    66876711    char_u      buf[NUMBUFLEN];
     
    67216745            clear_tv(&tvkey);
    67226746            goto failret;
    67236747        }
    6724         key = get_tv_string_buf_chk(&tvkey, buf);
    6725         if (key == NULL || *key == NUL)
     6748        if (evaluate)
    67266749        {
    6727             /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */
    6728             if (key != NULL)
    6729                 EMSG(_(e_emptykey));
    6730             clear_tv(&tvkey);
    6731             goto failret;
     6750            key = get_tv_string_buf_chk(&tvkey, buf);
     6751            if (key == NULL || *key == NUL)
     6752            {
     6753                /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */
     6754                if (key != NULL)
     6755                    EMSG(_(e_emptykey));
     6756                clear_tv(&tvkey);
     6757                goto failret;
     6758            }
    67326759        }
    67336760
    67346761        *arg = skipwhite(*arg + 1);
    67356762        if (eval1(arg, &tv, evaluate) == FAIL)  /* recursive! */
    67366763        {
    6737             clear_tv(&tvkey);
     6764            if (evaluate)
     6765                clear_tv(&tvkey);
    67386766            goto failret;
    67396767        }
    67406768        if (evaluate)
     
    67946822 * "numbuf" is used for a number.
    67956823 * Does not put quotes around strings, as ":echo" displays values.
    67966824 * When "copyID" is not NULL replace recursive lists and dicts with "...".
    6797  * May return NULL;
     6825 * May return NULL.
    67986826 */
    67996827    static char_u *
    68006828echo_string(tv, tofree, numbuf, copyID)
     
    68796907 * If the memory is allocated "tofree" is set to it, otherwise NULL.
    68806908 * "numbuf" is used for a number.
    68816909 * Puts quotes around strings, so that they can be parsed back by eval().
    6882  * May return NULL;
     6910 * May return NULL.
    68836911 */
    68846912    static char_u *
    68856913tv2string(tv, tofree, numbuf, copyID)
     
    70437071    {"changenr",        0, 0, f_changenr},
    70447072    {"char2nr",         1, 1, f_char2nr},
    70457073    {"cindent",         1, 1, f_cindent},
     7074    {"clearmatches",    0, 0, f_clearmatches},
    70467075    {"col",             1, 1, f_col},
    70477076#if defined(FEAT_INS_EXPAND)
    70487077    {"complete",        2, 2, f_complete},
     
    70827111    {"foldtextresult",  1, 1, f_foldtextresult},
    70837112    {"foreground",      0, 0, f_foreground},
    70847113    {"function",        1, 1, f_function},
    7085     {"garbagecollect",  0, 0, f_garbagecollect},
     7114    {"garbagecollect",  0, 1, f_garbagecollect},
    70867115    {"get",             2, 3, f_get},
    70877116    {"getbufline",      2, 3, f_getbufline},
    70887117    {"getbufvar",       2, 2, f_getbufvar},
     
    70997128    {"getftype",        1, 1, f_getftype},
    71007129    {"getline",         1, 2, f_getline},
    71017130    {"getloclist",      1, 1, f_getqflist},
     7131    {"getmatches",      0, 0, f_getmatches},
    71027132    {"getpos",          1, 1, f_getpos},
    71037133    {"getqflist",       0, 0, f_getqflist},
    71047134    {"getreg",          0, 2, f_getreg},
     
    71497179    {"maparg",          1, 3, f_maparg},
    71507180    {"mapcheck",        1, 3, f_mapcheck},
    71517181    {"match",           2, 4, f_match},
     7182    {"matchadd",        2, 4, f_matchadd},
    71527183    {"matcharg",        1, 1, f_matcharg},
     7184    {"matchdelete",     1, 1, f_matchdelete},
    71537185    {"matchend",        2, 4, f_matchend},
    71547186    {"matchlist",       2, 4, f_matchlist},
    71557187    {"matchstr",        2, 4, f_matchstr},
     
    71907222    {"setcmdpos",       1, 1, f_setcmdpos},
    71917223    {"setline",         2, 2, f_setline},
    71927224    {"setloclist",      2, 3, f_setloclist},
     7225    {"setmatches",      1, 1, f_setmatches},
    71937226    {"setpos",          2, 2, f_setpos},
    71947227    {"setqflist",       1, 2, f_setqflist},
    71957228    {"setreg",          2, 3, f_setreg},
     
    82408273}
    82418274
    82428275/*
     8276 * "clearmatches()" function
     8277 */
     8278/*ARGSUSED*/
     8279    static void
     8280f_clearmatches(argvars, rettv)
     8281    typval_T    *argvars;
     8282    typval_T    *rettv;
     8283{
     8284#ifdef FEAT_SEARCH_EXTRA
     8285    clear_matches(curwin);
     8286#endif
     8287}
     8288
     8289/*
    82438290 * "col(string)" function
    82448291 */
    82458292    static void
     
    93399386{
    93409387    typval_T    rettv;
    93419388    char_u      *s;
     9389    int         retval = FAIL;
    93429390
    93439391    copy_tv(tv, &vimvars[VV_VAL].vv_tv);
    93449392    s = expr;
    93459393    if (eval1(&s, &rettv, TRUE) == FAIL)
    9346         return FAIL;
     9394        goto theend;
    93479395    if (*s != NUL)  /* check for trailing chars after expr */
    93489396    {
    93499397        EMSG2(_(e_invexpr2), s);
    9350         return FAIL;
     9398        goto theend;
    93519399    }
    93529400    if (map)
    93539401    {
     
    93669414        /* On type error, nothing has been removed; return FAIL to stop the
    93679415         * loop.  The error message was given by get_tv_number_chk(). */
    93689416        if (error)
    9369             return FAIL;
     9417            goto theend;
    93709418    }
     9419    retval = OK;
     9420theend:
    93719421    clear_tv(&vimvars[VV_VAL].vv_tv);
    9372     return OK;
     9422    return retval;
    93739423}
    93749424
    93759425/*
     
    96709720    /* This is postponed until we are back at the toplevel, because we may be
    96719721     * using Lists and Dicts internally.  E.g.: ":echo [garbagecollect()]". */
    96729722    want_garbage_collect = TRUE;
     9723
     9724    if (argvars[0].v_type != VAR_UNKNOWN && get_tv_number(&argvars[0]) == 1)
     9725        garbage_collect_at_exit = TRUE;
    96739726}
    96749727
    96759728/*
     
    98689921
    98699922    ++no_mapping;
    98709923    ++allow_keys;
    9871     if (argvars[0].v_type == VAR_UNKNOWN)
    9872         /* getchar(): blocking wait. */
    9873         n = safe_vgetc();
    9874     else if (get_tv_number_chk(&argvars[0], &error) == 1)
    9875         /* getchar(1): only check if char avail */
    9876         n = vpeekc();
    9877     else if (error || vpeekc() == NUL)
    9878         /* illegal argument or getchar(0) and no char avail: return zero */
    9879         n = 0;
    9880     else
    9881         /* getchar(0) and char avail: return char */
    9882         n = safe_vgetc();
     9924    for (;;)
     9925    {
     9926        if (argvars[0].v_type == VAR_UNKNOWN)
     9927            /* getchar(): blocking wait. */
     9928            n = safe_vgetc();
     9929        else if (get_tv_number_chk(&argvars[0], &error) == 1)
     9930            /* getchar(1): only check if char avail */
     9931            n = vpeekc();
     9932        else if (error || vpeekc() == NUL)
     9933            /* illegal argument or getchar(0) and no char avail: return zero */
     9934            n = 0;
     9935        else
     9936            /* getchar(0) and char avail: return char */
     9937            n = safe_vgetc();
     9938        if (n == K_IGNORE)
     9939            continue;
     9940        break;
     9941    }
    98839942    --no_mapping;
    98849943    --allow_keys;
    98859944
     
    1013610195        if (mch_isdir(fname))
    1013710196            rettv->vval.v_number = 0;
    1013810197        else
     10198        {
    1013910199            rettv->vval.v_number = (varnumber_T)st.st_size;
     10200
     10201            /* non-perfect check for overflow */
     10202            if ((off_t)rettv->vval.v_number != (off_t)st.st_size)
     10203                rettv->vval.v_number = -2;
     10204        }
    1014010205    }
    1014110206    else
    1014210207          rettv->vval.v_number = -1;
     
    1026910334}
    1027010335
    1027110336/*
     10337 * "getmatches()" function
     10338 */
     10339/*ARGSUSED*/
     10340    static void
     10341f_getmatches(argvars, rettv)
     10342    typval_T    *argvars;
     10343    typval_T    *rettv;
     10344{
     10345#ifdef FEAT_SEARCH_EXTRA
     10346    dict_T      *dict;
     10347    matchitem_T *cur = curwin->w_match_head;
     10348
     10349    rettv->vval.v_number = 0;
     10350
     10351    if (rettv_list_alloc(rettv) == OK)
     10352    {
     10353        while (cur != NULL)
     10354        {
     10355            dict = dict_alloc();
     10356            if (dict == NULL)
     10357                return;
     10358            dict_add_nr_str(dict, "group", 0L, syn_id2name(cur->hlg_id));
     10359            dict_add_nr_str(dict, "pattern", 0L, cur->pattern);
     10360            dict_add_nr_str(dict, "priority", (long)cur->priority, NULL);
     10361            dict_add_nr_str(dict, "id", (long)cur->id, NULL);
     10362            list_append_dict(rettv->vval.v_list, dict);
     10363            cur = cur->next;
     10364        }
     10365    }
     10366#endif
     10367}
     10368
     10369/*
    1027210370 * "getpos(string)" function
    1027310371 */
    1027410372    static void
     
    1029010388            list_append_number(l, (varnumber_T)0);
    1029110389        list_append_number(l, (fp != NULL) ? (varnumber_T)fp->lnum
    1029210390                                                            : (varnumber_T)0);
    10293         list_append_number(l, (fp != NULL) ? (varnumber_T)fp->col + 1
     10391        list_append_number(l, (fp != NULL)
     10392                     ? (varnumber_T)(fp->col == MAXCOL ? MAXCOL : fp->col + 1)
    1029410393                                                            : (varnumber_T)0);
    1029510394        list_append_number(l,
    1029610395#ifdef FEAT_VIRTUALEDIT
     
    1078510884        "gui_gtk2",
    1078610885# endif
    1078710886#endif
     10887#ifdef FEAT_GUI_GNOME
     10888        "gui_gnome",
     10889#endif
    1078810890#ifdef FEAT_GUI_MAC
    1078910891        "gui_mac",
    1079010892#endif
     
    1147111573    char_u      *xp_arg = NULL;
    1147211574
    1147311575    rettv->v_type = VAR_STRING;
     11576    rettv->vval.v_string = NULL;
    1147411577
    1147511578#ifdef NO_CONSOLE_INPUT
    1147611579    /* While starting up, there is no place to enter text. */
    1147711580    if (no_console_input())
    11478     {
    11479         rettv->vval.v_string = NULL;
    1148011581        return;
    11481     }
    1148211582#endif
    1148311583
    1148411584    cmd_silent = FALSE;         /* Want to see the prompt. */
     
    1243912539}
    1244012540
    1244112541/*
     12542 * "matchadd()" function
     12543 */
     12544    static void
     12545f_matchadd(argvars, rettv)
     12546    typval_T    *argvars;
     12547    typval_T    *rettv;
     12548{
     12549#ifdef FEAT_SEARCH_EXTRA
     12550    char_u      buf[NUMBUFLEN];
     12551    char_u      *grp = get_tv_string_buf_chk(&argvars[0], buf); /* group */
     12552    char_u      *pat = get_tv_string_buf_chk(&argvars[1], buf); /* pattern */
     12553    int         prio = 10;      /* default priority */
     12554    int         id = -1;
     12555    int         error = FALSE;
     12556
     12557    rettv->vval.v_number = -1;
     12558
     12559    if (grp == NULL || pat == NULL)
     12560        return;
     12561    if (argvars[2].v_type != VAR_UNKNOWN)
     12562    {
     12563        prio = get_tv_number_chk(&argvars[2], &error);
     12564        if (argvars[3].v_type != VAR_UNKNOWN)
     12565            id = get_tv_number_chk(&argvars[3], &error);
     12566    }
     12567    if (error == TRUE)
     12568        return;
     12569    if (id >= 1 && id <= 3)
     12570    {
     12571        EMSGN("E798: ID is reserved for \":match\": %ld", id);
     12572        return;
     12573    }
     12574
     12575    rettv->vval.v_number = match_add(curwin, grp, pat, prio, id);
     12576#endif
     12577}
     12578
     12579/*
    1244212580 * "matcharg()" function
    1244312581 */
    1244412582    static void
     
    1244912587    if (rettv_list_alloc(rettv) == OK)
    1245012588    {
    1245112589#ifdef FEAT_SEARCH_EXTRA
    12452         int     mi = get_tv_number(&argvars[0]);
     12590        int         id = get_tv_number(&argvars[0]);
     12591        matchitem_T *m;
    1245312592
    12454         if (mi >= 1 && mi <= 3)
     12593        if (id >= 1 && id <= 3)
    1245512594        {
    12456             list_append_string(rettv->vval.v_list,
    12457                                  syn_id2name(curwin->w_match_id[mi - 1]), -1);
    12458             list_append_string(rettv->vval.v_list,
    12459                                              curwin->w_match_pat[mi - 1], -1);
     12595            if ((m = (matchitem_T *)get_match(curwin, id)) != NULL)
     12596            {
     12597                list_append_string(rettv->vval.v_list,
     12598                                                syn_id2name(m->hlg_id), -1);
     12599                list_append_string(rettv->vval.v_list, m->pattern, -1);
     12600            }
     12601            else
     12602            {
     12603                list_append_string(rettv->vval.v_list, NUL, -1);
     12604                list_append_string(rettv->vval.v_list, NUL, -1);
     12605            }
    1246012606        }
    1246112607#endif
    1246212608    }
    1246312609}
    1246412610
    1246512611/*
     12612 * "matchdelete()" function
     12613 */
     12614    static void
     12615f_matchdelete(argvars, rettv)
     12616    typval_T    *argvars;
     12617    typval_T    *rettv;
     12618{
     12619#ifdef FEAT_SEARCH_EXTRA
     12620    rettv->vval.v_number = match_delete(curwin,
     12621                                       (int)get_tv_number(&argvars[0]), TRUE);
     12622#endif
     12623}
     12624
     12625/*
    1246612626 * "matchend()" function
    1246712627 */
    1246812628    static void
     
    1368013840            }
    1368113841            /* Shorten "remain". */
    1368213842            if (*q != NUL)
    13683                 STRCPY(remain, q - 1);
     13843                mch_memmove(remain, q - 1, STRLEN(q - 1) + 1);
    1368413844            else
    1368513845            {
    1368613846                vim_free(remain);
     
    1391914079    /* If 'n' flag is used: restore cursor position. */
    1392014080    if (flags & SP_NOMOVE)
    1392114081        curwin->w_cursor = save_cursor;
     14082    else
     14083        curwin->w_set_curswant = TRUE;
    1392214084theend:
    1392314085    p_ws = save_p_ws;
    1392414086
     
    1449814660}
    1449914661
    1450014662/*
     14663 * "setmatches()" function
     14664 */
     14665    static void
     14666f_setmatches(argvars, rettv)
     14667    typval_T    *argvars;
     14668    typval_T    *rettv;
     14669{
     14670#ifdef FEAT_SEARCH_EXTRA
     14671    list_T      *l;
     14672    listitem_T  *li;
     14673    dict_T      *d;
     14674
     14675    rettv->vval.v_number = -1;
     14676    if (argvars[0].v_type != VAR_LIST)
     14677    {
     14678        EMSG(_(e_listreq));
     14679        return;
     14680    }
     14681    if ((l = argvars[0].vval.v_list) != NULL)
     14682    {
     14683
     14684        /* To some extent make sure that we are dealing with a list from
     14685         * "getmatches()". */
     14686        li = l->lv_first;
     14687        while (li != NULL)
     14688        {
     14689            if (li->li_tv.v_type != VAR_DICT
     14690                    || (d = li->li_tv.vval.v_dict) == NULL)
     14691            {
     14692                EMSG(_(e_invarg));
     14693                return;
     14694            }
     14695            if (!(dict_find(d, (char_u *)"group", -1) != NULL
     14696                        && dict_find(d, (char_u *)"pattern", -1) != NULL
     14697                        && dict_find(d, (char_u *)"priority", -1) != NULL
     14698                        && dict_find(d, (char_u *)"id", -1) != NULL))
     14699            {
     14700                EMSG(_(e_invarg));
     14701                return;
     14702            }
     14703            li = li->li_next;
     14704        }
     14705
     14706        clear_matches(curwin);
     14707        li = l->lv_first;
     14708        while (li != NULL)
     14709        {
     14710            d = li->li_tv.vval.v_dict;
     14711            match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
     14712                    get_dict_string(d, (char_u *)"pattern", FALSE),
     14713                    (int)get_dict_number(d, (char_u *)"priority"),
     14714                    (int)get_dict_number(d, (char_u *)"id"));
     14715            li = li->li_next;
     14716        }
     14717        rettv->vval.v_number = 0;
     14718    }
     14719#endif
     14720}
     14721
     14722/*
    1450114723 * "setpos()" function
    1450214724 */
    1450314725/*ARGSUSED*/
     
    1478515007
    1478615008    p1 = tv2string(&(*(listitem_T **)s1)->li_tv, &tofree1, numbuf1, 0);
    1478715009    p2 = tv2string(&(*(listitem_T **)s2)->li_tv, &tofree2, numbuf2, 0);
     15010    if (p1 == NULL)
     15011        p1 = (char_u *)"";
     15012    if (p2 == NULL)
     15013        p2 = (char_u *)"";
    1478815014    if (item_compare_ic)
    1478915015        res = STRICMP(p1, p2);
    1479015016    else
     
    1527415500
    1527515501    rettv->v_type = VAR_STRING;
    1527615502    rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0);
    15277     if (tofree == NULL)
     15503    /* Make a copy if we have a value but it's not in allocate memory. */
     15504    if (rettv->vval.v_string != NULL && tofree == NULL)
    1527815505        rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
    1527915506}
    1528015507
     
    1649716724 * Returns NULL when there is an error.
    1649816725 */
    1649916726    static pos_T *
    16500 var2fpos(varp, lnum, fnum)
     16727var2fpos(varp, dollar_lnum, fnum)
    1650116728    typval_T    *varp;
    16502     int         lnum;           /* TRUE when $ is last line */
     16729    int         dollar_lnum;    /* TRUE when $ is last line */
    1650316730    int         *fnum;          /* set to fnum for '0, 'A, etc. */
    1650416731{
    1650516732    char_u              *name;
     
    1651216739        list_T          *l;
    1651316740        int             len;
    1651416741        int             error = FALSE;
     16742        listitem_T      *li;
    1651516743
    1651616744        l = varp->vval.v_list;
    1651716745        if (l == NULL)
     
    1652716755        if (error)
    1652816756            return NULL;
    1652916757        len = (long)STRLEN(ml_get(pos.lnum));
     16758
     16759        /* We accept "$" for the column number: last column. */
     16760        li = list_find(l, 1L);
     16761        if (li != NULL && li->li_tv.v_type == VAR_STRING
     16762                && li->li_tv.vval.v_string != NULL
     16763                && STRCMP(li->li_tv.vval.v_string, "$") == 0)
     16764            pos.col = len + 1;
     16765
    1653016766        /* Accept a position up to the NUL after the line. */
    1653116767        if (pos.col == 0 || (int)pos.col > len + 1)
    1653216768            return NULL;        /* invalid column number */
     
    1655916795    pos.coladd = 0;
    1656016796#endif
    1656116797
    16562     if (name[0] == 'w' && lnum)
     16798    if (name[0] == 'w' && dollar_lnum)
    1656316799    {
    1656416800        pos.col = 0;
    1656516801        if (name[1] == '0')             /* "w0": first visible line */
     
    1657716813    }
    1657816814    else if (name[0] == '$')            /* last column or line */
    1657916815    {
    16580         if (lnum)
     16816        if (dollar_lnum)
    1658116817        {
    1658216818            pos.lnum = curbuf->b_ml.ml_line_count;
    1658316819            pos.col = 0;
     
    1779818034 * List the value of one internal variable.
    1779918035 */
    1780018036    static void
    17801 list_one_var(v, prefix)
     18037list_one_var(v, prefix, first)
    1780218038    dictitem_T  *v;
    1780318039    char_u      *prefix;
     18040    int         *first;
    1780418041{
    1780518042    char_u      *tofree;
    1780618043    char_u      *s;
     
    1780818045
    1780918046    s = echo_string(&v->di_tv, &tofree, numbuf, ++current_copyID);
    1781018047    list_one_var_a(prefix, v->di_key, v->di_tv.v_type,
    17811                                                 s == NULL ? (char_u *)"" : s);
     18048                                         s == NULL ? (char_u *)"" : s, first);
    1781218049    vim_free(tofree);
    1781318050}
    1781418051
    1781518052    static void
    17816 list_one_var_a(prefix, name, type, string)
     18053list_one_var_a(prefix, name, type, string, first)
    1781718054    char_u      *prefix;
    1781818055    char_u      *name;
    1781918056    int         type;
    1782018057    char_u      *string;
     18058    int         *first;  /* when TRUE clear rest of screen and set to FALSE */
    1782118059{
    17822     msg_attr(prefix, 0);    /* don't use msg(), it overwrites "v:statusmsg" */
     18060    /* don't use msg() or msg_attr() to avoid overwriting "v:statusmsg" */
     18061    msg_start();
     18062    msg_puts(prefix);
    1782318063    if (name != NULL)   /* "a:" vars don't have a name stored */
    1782418064        msg_puts(name);
    1782518065    msg_putchar(' ');
     
    1784718087
    1784818088    if (type == VAR_FUNC)
    1784918089        msg_puts((char_u *)"()");
     18090    if (*first)
     18091    {
     18092        msg_clr_eos();
     18093        *first = FALSE;
     18094    }
    1785018095}
    1785118096
    1785218097/*
     
    1913619381        goto theend;
    1913719382    }
    1913819383
     19384    /* Check if the name is a Funcref.  If so, use the value. */
     19385    if (lv.ll_exp_name != NULL)
     19386    {
     19387        len = (int)STRLEN(lv.ll_exp_name);
     19388        name = deref_func_name(lv.ll_exp_name, &len);
     19389        if (name == lv.ll_exp_name)
     19390            name = NULL;
     19391    }
     19392    else
     19393    {
     19394        len = (int)(end - *pp);
     19395        name = deref_func_name(*pp, &len);
     19396        if (name == *pp)
     19397            name = NULL;
     19398    }
     19399    if (name != NULL)
     19400    {
     19401        name = vim_strsave(name);
     19402        *pp = end;
     19403        goto theend;
     19404    }
     19405
    1913919406    if (lv.ll_exp_name != NULL)
    1914019407    {
    1914119408        len = (int)STRLEN(lv.ll_exp_name);
     
    1996920236                char_u  buf[MSG_BUF_LEN];
    1997020237                char_u  numbuf2[NUMBUFLEN];
    1997120238                char_u  *tofree;
     20239                char_u  *s;
    1997220240
    1997320241                msg_puts((char_u *)"(");
    1997420242                for (i = 0; i < argcount; ++i)
     
    1997920247                        msg_outnum((long)argvars[i].vval.v_number);
    1998020248                    else
    1998120249                    {
    19982                         trunc_string(tv2string(&argvars[i], &tofree,
    19983                                               numbuf2, 0), buf, MSG_BUF_CLEN);
    19984                         msg_puts(buf);
    19985                         vim_free(tofree);
     20250                        s = tv2string(&argvars[i], &tofree, numbuf2, 0);
     20251                        if (s != NULL)
     20252                        {
     20253                            trunc_string(s, buf, MSG_BUF_CLEN);
     20254                            msg_puts(buf);
     20255                            vim_free(tofree);
     20256                        }
    1998620257                    }
    1998720258                }
    1998820259                msg_puts((char_u *)")");
     
    2006020331            char_u      buf[MSG_BUF_LEN];
    2006120332            char_u      numbuf2[NUMBUFLEN];
    2006220333            char_u      *tofree;
     20334            char_u      *s;
    2006320335
    2006420336            /* The value may be very long.  Skip the middle part, so that we
    2006520337             * have some idea how it starts and ends. smsg() would always
    2006620338             * truncate it at the end. */
    20067             trunc_string(tv2string(fc.rettv, &tofree, numbuf2, 0),
    20068                                                            buf, MSG_BUF_CLEN);
    20069             smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
    20070             vim_free(tofree);
     20339            s = tv2string(fc.rettv, &tofree, numbuf2, 0);
     20340            if (s != NULL)
     20341            {
     20342                trunc_string(s, buf, MSG_BUF_CLEN);
     20343                smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
     20344                vim_free(tofree);
     20345            }
    2007120346        }
    2007220347        msg_puts((char_u *)"\n");   /* don't overwrite this either */
    2007320348
     
    2103421309        *usedlen += 2;
    2103521310        s = get_past_head(*fnamep);
    2103621311        while (tail > s && after_pathsep(s, tail))
    21037             --tail;
     21312            mb_ptr_back(*fnamep, tail);
    2103821313        *fnamelen = (int)(tail - *fnamep);
    2103921314#ifdef VMS
    2104021315        if (*fnamelen > 0)
    2104121316            *fnamelen += 1; /* the path separator is part of the path */
    2104221317#endif
    21043         while (tail > s && !after_pathsep(s, tail))
    21044             mb_ptr_back(*fnamep, tail);
     21318        if (*fnamelen == 0)
     21319        {
     21320            /* Result is empty.  Turn it into "." to make ":cd %:h" work. */
     21321            p = vim_strsave((char_u *)".");
     21322            if (p == NULL)
     21323                return -1;
     21324            vim_free(*bufp);
     21325            *bufp = *fnamep = tail = p;
     21326            *fnamelen = 1;
     21327        }
     21328        else
     21329        {
     21330            while (tail > s && !after_pathsep(s, tail))
     21331                mb_ptr_back(*fnamep, tail);
     21332        }
    2104521333    }
    2104621334
    2104721335    /* ":8" - shortname  */
  • src/ex_cmds.c

    diff -Naur vim71.orig/src/ex_cmds.c vim71/src/ex_cmds.c
    old new  
    408408                goto sortend;
    409409            }
    410410            *s = NUL;
    411             regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC);
     411            /* Use last search pattern if sort pattern is empty. */
     412            if (s == p + 1 && last_search_pat() != NULL)
     413                regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
     414            else
     415                regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC);
    412416            if (regmatch.regprog == NULL)
    413417                goto sortend;
    414418            p = s;              /* continue after the regexp */
     
    29122916}
    29132917
    29142918/*
    2915  * Check if a buffer is read-only.  Ask for overruling in a dialog.
    2916  * Return TRUE and give an error message when the buffer is readonly.
     2919 * Check if a buffer is read-only (either 'readonly' option is set or file is
     2920 * read-only). Ask for overruling in a dialog. Return TRUE and give an error
     2921 * message when the buffer is readonly.
    29172922 */
    29182923    static int
    29192924check_readonly(forceit, buf)
    29202925    int         *forceit;
    29212926    buf_T       *buf;
    29222927{
    2923     if (!*forceit && buf->b_p_ro)
     2928    struct stat st;
     2929
     2930    /* Handle a file being readonly when the 'readonly' option is set or when
     2931     * the file exists and permissions are read-only.
     2932     * We will send 0777 to check_file_readonly(), as the "perm" variable is
     2933     * important for device checks but not here. */
     2934    if (!*forceit && (buf->b_p_ro
     2935                || (mch_stat((char *)buf->b_ffname, &st) >= 0
     2936                    && check_file_readonly(buf->b_ffname, 0777))))
    29242937    {
    29252938#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
    29262939        if ((p_confirm || cmdmod.confirm) && buf->b_fname != NULL)
    29272940        {
    29282941            char_u      buff[IOSIZE];
    29292942
    2930             dialog_msg(buff, _("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"),
     2943            if (buf->b_p_ro)
     2944                dialog_msg(buff, _("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"),
     2945                    buf->b_fname);
     2946            else
     2947                dialog_msg(buff, _("File permissions of \"%s\" are read-only.\nIt may still be possible to write it.\nDo you wish to try?"),
    29312948                    buf->b_fname);
    29322949
    29332950            if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) == VIM_YES)
     
    29412958        }
    29422959        else
    29432960#endif
     2961        if (buf->b_p_ro)
    29442962            EMSG(_(e_readonly));
     2963        else
     2964            EMSG2(_("E505: \"%s\" is read-only (add ! to override)"),
     2965                    buf->b_fname);
    29452966        return TRUE;
    29462967    }
     2968
    29472969    return FALSE;
    29482970}
    29492971
     
    29522974 * 'fnum' is the number of the file, if zero use ffname/sfname.
    29532975 *
    29542976 * Return 1 for "normal" error, 2 for "not written" error, 0 for success
    2955  * -1 for succesfully opening another file.
     2977 * -1 for successfully opening another file.
    29562978 * 'lnum' is the line number for the cursor in the new file (if non-zero).
    29572979 */
    29582980    int
     
    33673389                 * was in this window (or another window).  If not used
    33683390                 * before, reset the local window options to the global
    33693391                 * values.  Also restores old folding stuff. */
    3370                 get_winopts(buf);
     3392                get_winopts(curbuf);
    33713393#ifdef FEAT_SPELL
    33723394                did_get_winopts = TRUE;
    33733395#endif
     
    35623584        curwin_init();
    35633585
    35643586#ifdef FEAT_FOLDING
    3565         /* It's like all lines in the buffer changed.  Need to update
    3566          * automatic folding. */
     3587        /* It's possible that all lines in the buffer changed.  Need to update
     3588         * automatic folding for all windows where it's used. */
     3589# ifdef FEAT_WINDOWS
     3590        {
     3591            win_T           *win;
     3592            tabpage_T       *tp;
     3593
     3594            FOR_ALL_TAB_WINDOWS(tp, win)
     3595                if (win->w_buffer == curbuf)
     3596                    foldUpdateAll(win);
     3597        }
     3598# else
    35673599        foldUpdateAll(curwin);
     3600# endif
    35683601#endif
    35693602
    35703603        /* Change directories when the 'acd' option is set. */
     
    36493682#ifdef FEAT_SPELL
    36503683    /* If the window options were changed may need to set the spell language.
    36513684     * Can only do this after the buffer has been properly setup. */
    3652     if (did_get_winopts && curwin->w_p_spell && *buf->b_p_spl != NUL)
    3653         did_set_spelllang(buf);
     3685    if (did_get_winopts && curwin->w_p_spell && *curbuf->b_p_spl != NUL)
     3686        did_set_spelllang(curbuf);
    36543687#endif
    36553688
    36563689    if (command == NULL)
     
    37543787            workshop_file_opened((char *)curbuf->b_ffname, curbuf->b_p_ro);
    37553788# endif
    37563789# ifdef FEAT_NETBEANS_INTG
    3757         if (usingNetbeans & ((flags & ECMD_SET_HELP) != ECMD_SET_HELP))
     3790        if (usingNetbeans && ((flags & ECMD_SET_HELP) != ECMD_SET_HELP))
    37583791            netbeans_file_opened(curbuf);
    37593792# endif
    37603793    }
     
    42944327        do_error = TRUE;
    42954328        do_print = FALSE;
    42964329        do_count = FALSE;
     4330        do_number = FALSE;
    42974331        do_ic = 0;
    42984332    }
    42994333    while (*cmd)
     
    44644498             *
    44654499             * The new text is built up in new_start[].  It has some extra
    44664500             * room to avoid using alloc()/free() too often.  new_start_len is
    4467              * the lenght of the allocated memory at new_start.
     4501             * the length of the allocated memory at new_start.
    44684502             *
    44694503             * Make a copy of the old line, so it won't be taken away when
    44704504             * updating the screen or handling a multi-line match.  The "old_"
     
    46354669#endif
    46364670                            ++no_mapping;       /* don't map this key */
    46374671                            ++allow_keys;       /* allow special keys */
    4638                             i = safe_vgetc();
     4672                            i = plain_vgetc();
    46394673                            --allow_keys;
    46404674                            --no_mapping;
    46414675
     
    63516385        for (i = 0; i < ga.ga_len; ++i)
    63526386        {
    63536387            s = ((char_u **)ga.ga_data)[i];
    6354             if (STRNCMP(s, "help-tags", 9) == 0)
     6388            if (STRNCMP(s, "help-tags\t", 10) == 0)
    63556389                /* help-tags entry was added in formatted form */
    6356                 fprintf(fd_tags, (char *)s);
     6390                fputs((char *)s, fd_tags);
    63576391            else
    63586392            {
    63596393                fprintf(fd_tags, "%s\t/*", s);
  • src/ex_docmd.c

    diff -Naur vim71.orig/src/ex_docmd.c vim71/src/ex_docmd.c
    old new  
    133133static void     get_flags __ARGS((exarg_T *eap));
    134134#if !defined(FEAT_PERL) || !defined(FEAT_PYTHON) || !defined(FEAT_TCL) \
    135135        || !defined(FEAT_RUBY) || !defined(FEAT_MZSCHEME)
     136# define HAVE_EX_SCRIPT_NI
    136137static void     ex_script_ni __ARGS((exarg_T *eap));
    137138#endif
    138139static char_u   *invalid_range __ARGS((exarg_T *eap));
     
    21182119#ifdef FEAT_USR_CMDS
    21192120            !USER_CMDIDX(ea.cmdidx) &&
    21202121#endif
    2121             cmdnames[ea.cmdidx].cmd_func == ex_ni);
     2122            (cmdnames[ea.cmdidx].cmd_func == ex_ni
     2123#ifdef HAVE_EX_SCRIPT_NI
     2124             || cmdnames[ea.cmdidx].cmd_func == ex_script_ni
     2125#endif
     2126             ));
    21222127
    21232128#ifndef FEAT_EVAL
    21242129    /*
     
    32763281
    32773282    if (ea.argt & XFILE)
    32783283    {
    3279         int in_quote = FALSE;
    3280         char_u *bow = NULL;     /* Beginning of word */
     3284        int     c;
     3285        int     in_quote = FALSE;
     3286        char_u  *bow = NULL;    /* Beginning of word */
    32813287
    32823288        /*
    32833289         * Allow spaces within back-quotes to count as part of the argument
    32843290         * being expanded.
    32853291         */
    32863292        xp->xp_pattern = skipwhite(arg);
    3287         for (p = xp->xp_pattern; *p; )
     3293        p = xp->xp_pattern;
     3294        while (*p != NUL)
    32883295        {
    3289             if (*p == '\\' && p[1] != NUL)
     3296#ifdef FEAT_MBYTE
     3297            if (has_mbyte)
     3298                c = mb_ptr2char(p);
     3299            else
     3300#endif
     3301                c = *p;
     3302            if (c == '\\' && p[1] != NUL)
    32903303                ++p;
     3304            else if (c == '`')
     3305            {
     3306                if (!in_quote)
     3307                {
     3308                    xp->xp_pattern = p;
     3309                    bow = p + 1;
     3310                }
     3311                in_quote = !in_quote;
     3312            }
    32913313#ifdef SPACE_IN_FILENAME
    3292             else if (vim_iswhite(*p) && (!(ea.argt & NOSPC) || usefilter))
     3314            else if (!vim_isfilec_or_wc(c)
     3315                                         && (!(ea.argt & NOSPC) || usefilter))
    32933316#else
    3294             else if (vim_iswhite(*p))
     3317            else if (!vim_isfilec_or_wc(c))
    32953318#endif
    32963319            {
    3297                 p = skipwhite(p);
     3320                while (*p != NUL)
     3321                {
     3322#ifdef FEAT_MBYTE
     3323                    if (has_mbyte)
     3324                        c = mb_ptr2char(p);
     3325                    else
     3326#endif
     3327                        c = *p;
     3328                    if (c == '`' || vim_isfilec_or_wc(c))
     3329                        break;
     3330#ifdef FEAT_MBYTE
     3331                    if (has_mbyte)
     3332                        len = (*mb_ptr2len)(p);
     3333                    else
     3334#endif
     3335                        len = 1;
     3336                    mb_ptr_adv(p);
     3337                }
    32983338                if (in_quote)
    32993339                    bow = p;
    33003340                else
    33013341                    xp->xp_pattern = p;
    3302                 --p;
    3303             }
    3304             else if (*p == '`')
    3305             {
    3306                 if (!in_quote)
    3307                 {
    3308                     xp->xp_pattern = p;
    3309                     bow = p + 1;
    3310                 }
    3311                 in_quote = !in_quote;
     3342                p -= len;
    33123343            }
    33133344            mb_ptr_adv(p);
    33143345        }
     
    34013432        case CMD_windo:
    34023433            return arg;
    34033434
    3404 #ifdef FEAT_SEARCH_EXTRA
     3435#ifdef FEAT_CMDL_COMPL
     3436# ifdef FEAT_SEARCH_EXTRA
    34053437        case CMD_match:
    34063438            if (*arg == NUL || !ends_excmd(*arg))
    34073439            {
    3408                 /* Dummy call to clear variables. */
    3409                 set_context_in_highlight_cmd(xp, (char_u *)"link n");
    3410                 xp->xp_context = EXPAND_HIGHLIGHT;
    3411                 xp->xp_pattern = arg;
     3440                /* also complete "None" */
     3441                set_context_in_echohl_cmd(xp, arg);
    34123442                arg = skipwhite(skiptowhite(arg));
    34133443                if (*arg != NUL)
    34143444                {
     
    34173447                }
    34183448            }
    34193449            return find_nextcmd(arg);
    3420 #endif
     3450# endif
    34213451
    3422 #ifdef FEAT_CMDL_COMPL
    34233452/*
    34243453 * All completion for the +cmdline_compl feature goes here.
    34253454 */
     
    36173646            break;
    36183647
    36193648        case CMD_echohl:
    3620             xp->xp_context = EXPAND_HIGHLIGHT;
    3621             xp->xp_pattern = arg;
     3649            set_context_in_echohl_cmd(xp, arg);
    36223650            break;
    36233651#endif
    36243652        case CMD_highlight:
     
    39974025        eap->errmsg = (char_u *)N_("E319: Sorry, the command is not available in this version");
    39984026}
    39994027
    4000 #if !defined(FEAT_PERL) || !defined(FEAT_PYTHON) || !defined(FEAT_TCL) \
    4001         || !defined(FEAT_RUBY) || !defined(FEAT_MZSCHEME)
     4028#ifdef HAVE_EX_SCRIPT_NI
    40024029/*
    40034030 * Function called for script command which is Not Implemented.  NI!
    40044031 * Skips over ":perl <<EOF" constructs.
     
    43764403                            || vim_strchr(eap->arg, '~') != NULL)
    43774404                    {
    43784405                        expand_env_esc(eap->arg, NameBuff, MAXPATHL,
    4379                                                                 TRUE, NULL);
     4406                                                            TRUE, TRUE, NULL);
    43804407                        has_wildcards = mch_has_wildcard(NameBuff);
    43814408                        p = NameBuff;
    43824409                    }
     
    44924519            if (eap->argt & (USECTRLV | XFILE))
    44934520                ++p;            /* skip CTRL-V and next char */
    44944521            else
    4495                 STRCPY(p, p + 1);       /* remove CTRL-V and skip next char */
     4522                                /* remove CTRL-V and skip next char */
     4523                mch_memmove(p, p + 1, STRLEN(p));
    44964524            if (*p == NUL)              /* stop at NUL after CTRL-V */
    44974525                break;
    44984526        }
     
    1081610844    exarg_T     *eap;
    1081710845{
    1081810846    char_u      *p;
     10847    char_u      *g = NULL;
    1081910848    char_u      *end;
    1082010849    int         c;
    10821     int         mi;
     10850    int         id;
    1082210851
    1082310852    if (eap->line2 <= 3)
    10824         mi = eap->line2 - 1;
     10853        id = eap->line2;
    1082510854    else
    1082610855    {
    1082710856        EMSG(e_invcmd);
     
    1083010859
    1083110860    /* First clear any old pattern. */
    1083210861    if (!eap->skip)
    10833     {
    10834         vim_free(curwin->w_match[mi].regprog);
    10835         curwin->w_match[mi].regprog = NULL;
    10836         vim_free(curwin->w_match_pat[mi]);
    10837         curwin->w_match_pat[mi] = NULL;
    10838         redraw_later(SOME_VALID);       /* always need a redraw */
    10839     }
     10862        match_delete(curwin, id, FALSE);
    1084010863
    1084110864    if (ends_excmd(*eap->arg))
    1084210865        end = eap->arg;
     
    1084710870    {
    1084810871        p = skiptowhite(eap->arg);
    1084910872        if (!eap->skip)
    10850         {
    10851             curwin->w_match_id[mi] = syn_namen2id(eap->arg,
    10852                                                          (int)(p - eap->arg));
    10853             if (curwin->w_match_id[mi] == 0)
    10854             {
    10855                 EMSG2(_(e_nogroup), eap->arg);
    10856                 return;
    10857             }
    10858         }
     10873            g = vim_strnsave(eap->arg, (int)(p - eap->arg));
    1085910874        p = skipwhite(p);
    1086010875        if (*p == NUL)
    1086110876        {
     
    1087910894
    1088010895            c = *end;
    1088110896            *end = NUL;
    10882             curwin->w_match[mi].regprog = vim_regcomp(p + 1, RE_MAGIC);
    10883             if (curwin->w_match[mi].regprog == NULL)
    10884             {
    10885                 EMSG2(_(e_invarg2), p);
    10886                 *end = c;
    10887                 return;
    10888             }
    10889             curwin->w_match_pat[mi] = vim_strsave(p + 1);
     10897            match_add(curwin, g, p + 1, 10, id);
     10898            vim_free(g);
    1089010899            *end = c;
    1089110900        }
    1089210901    }
  • src/ex_eval.c

    diff -Naur vim71.orig/src/ex_eval.c vim71/src/ex_eval.c
    old new  
    15511551                }
    15521552                save_cpo  = p_cpo;
    15531553                p_cpo = (char_u *)"";
    1554                 regmatch.regprog = vim_regcomp(pat, TRUE);
     1554                regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
    15551555                regmatch.rm_ic = FALSE;
    15561556                if (end != NULL)
    15571557                    *end = save_char;
  • src/ex_getln.c

    diff -Naur vim71.orig/src/ex_getln.c vim71/src/ex_getln.c
    old new  
    268268    {
    269269        xpc.xp_context = ccline.xp_context;
    270270        xpc.xp_pattern = ccline.cmdbuff;
     271# if defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)
    271272        xpc.xp_arg = ccline.xp_arg;
     273# endif
    272274    }
    273275#endif
    274276
     
    484486        if (xpc.xp_context == EXPAND_MENUNAMES && p_wmnu)
    485487        {
    486488            /* Hitting <Down> after "emenu Name.": complete submenu */
    487             if (ccline.cmdbuff[ccline.cmdpos - 1] == '.' && c == K_DOWN)
     489            if (c == K_DOWN && ccline.cmdpos > 0
     490                                  && ccline.cmdbuff[ccline.cmdpos - 1] == '.')
    488491                c = p_wc;
    489492            else if (c == K_UP)
    490493            {
     
    533536            upseg[3] = PATHSEP;
    534537            upseg[4] = NUL;
    535538
    536             if (ccline.cmdbuff[ccline.cmdpos - 1] == PATHSEP
    537                     && c == K_DOWN
    538                     && (ccline.cmdbuff[ccline.cmdpos - 2] != '.'
     539            if (c == K_DOWN
     540                    && ccline.cmdpos > 0
     541                    && ccline.cmdbuff[ccline.cmdpos - 1] == PATHSEP
     542                    && (ccline.cmdpos < 3
     543                        || ccline.cmdbuff[ccline.cmdpos - 2] != '.'
    539544                        || ccline.cmdbuff[ccline.cmdpos - 3] != '.'))
    540545            {
    541546                /* go down a directory */
     
    636641        {
    637642            ++no_mapping;
    638643            ++allow_keys;
    639             c = safe_vgetc();
     644            c = plain_vgetc();
    640645            --no_mapping;
    641646            --allow_keys;
    642647            /* CTRL-\ e doesn't work when obtaining an expression. */
     
    730735            /* In Ex mode a backslash escapes a newline. */
    731736            if (exmode_active
    732737                    && c != ESC
    733                     && ccline.cmdpos > 0
    734738                    && ccline.cmdpos == ccline.cmdlen
     739                    && ccline.cmdpos > 0
    735740                    && ccline.cmdbuff[ccline.cmdpos - 1] == '\\')
    736741            {
    737742                if (c == K_KENTER)
     
    10861091#endif
    10871092                putcmdline('"', TRUE);
    10881093                ++no_mapping;
    1089                 i = c = safe_vgetc();   /* CTRL-R <char> */
     1094                i = c = plain_vgetc();  /* CTRL-R <char> */
    10901095                if (i == Ctrl_O)
    10911096                    i = Ctrl_R;         /* CTRL-R CTRL-O == CTRL-R CTRL-R */
    10921097                if (i == Ctrl_R)
    1093                     c = safe_vgetc();   /* CTRL-R CTRL-R <char> */
     1098                    c = plain_vgetc();  /* CTRL-R CTRL-R <char> */
    10941099                --no_mapping;
    10951100#ifdef FEAT_EVAL
    10961101                /*
     
    20902095    garray_T    line_ga;
    20912096    char_u      *pend;
    20922097    int         startcol = 0;
    2093     int         c1;
     2098    int         c1 = 0;
    20942099    int         escaped = FALSE;        /* CTRL-V typed */
    20952100    int         vcol = 0;
    20962101    char_u      *p;
    2097     int         prev_char = 0;
     2102    int         prev_char;
    20982103
    20992104    /* Switch cursor on now.  This avoids that it happens after the "\n", which
    21002105     * confuses the system function that computes tabstops. */
     
    21472152
    21482153        /* Get one character at a time.  Don't use inchar(), it can't handle
    21492154         * special characters. */
     2155        prev_char = c1;
    21502156        c1 = vgetc();
    21512157
    21522158        /*
     
    22042210redraw:
    22052211                /* redraw the line */
    22062212                msg_col = startcol;
    2207                 windgoto(msg_row, msg_col);
    22082213                vcol = 0;
    22092214                for (p = (char_u *)line_ga.ga_data;
    22102215                          p < (char_u *)line_ga.ga_data + line_ga.ga_len; ++p)
     
    22232228                    }
    22242229                }
    22252230                msg_clr_eos();
     2231                windgoto(msg_row, msg_col);
    22262232                continue;
    22272233            }
    22282234
     
    22682274        if (IS_SPECIAL(c1))
    22692275            c1 = '?';
    22702276        ((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1;
    2271         prev_char = c1;
    22722277        if (c1 == '\n')
    22732278            msg_putchar('\n');
    22742279        else if (c1 == TAB)
     
    33113316 * Return a pointer to alloced memory containing the new string.
    33123317 * Return NULL for failure.
    33133318 *
     3319 * "orig" is the originally expanded string, copied to allocated memory.  It
     3320 * should either be kept in orig_save or freed.  When "mode" is WILD_NEXT or
     3321 * WILD_PREV "orig" should be NULL.
     3322 *
    33143323 * Results are cached in xp->xp_files and xp->xp_numfiles, except when "mode"
    33153324 * is WILD_EXPAND_FREE or WILD_ALL.
    33163325 *
     
    33953404            return NULL;
    33963405    }
    33973406
    3398 /* free old names */
     3407    /* free old names */
    33993408    if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
    34003409    {
    34013410        FreeWild(xp->xp_numfiles, xp->xp_files);
     
    35363545    if (mode == WILD_EXPAND_FREE || mode == WILD_ALL)
    35373546        ExpandCleanup(xp);
    35383547
     3548    /* Free "orig" if it wasn't stored in "orig_save". */
     3549    if (orig != orig_save)
     3550        vim_free(orig);
     3551
    35393552    return ss;
    35403553}
    35413554
     
    41484161
    41494162#ifdef FEAT_EVAL
    41504163    if (ccline.cmdfirstc == '=')
     4164    {
     4165# ifdef FEAT_CMDL_COMPL
    41514166        /* pass CMD_SIZE because there is no real command */
    41524167        set_context_for_expression(xp, str, CMD_SIZE);
     4168# endif
     4169    }
    41534170    else if (ccline.input_fn)
    41544171    {
    41554172        xp->xp_context = ccline.xp_context;
    41564173        xp->xp_pattern = ccline.cmdbuff;
     4174# if defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)
    41574175        xp->xp_arg = ccline.xp_arg;
     4176# endif
    41584177    }
    41594178    else
    41604179#endif
     
    42954314                            && pat[i + 1] == '\\'
    42964315                            && pat[i + 2] == '\\'
    42974316                            && pat[i + 3] == ' ')
    4298                         STRCPY(pat + i, pat + i + 3);
     4317                        mch_memmove(pat + i, pat + i + 3,
     4318                                                     STRLEN(pat + i + 3) + 1);
    42994319                    if (xp->xp_backslash == XP_BS_ONE
    43004320                            && pat[i + 1] == ' ')
    4301                         STRCPY(pat + i, pat + i + 1);
     4321                        mch_memmove(pat + i, pat + i + 1, STRLEN(pat + i));
    43024322                }
    43034323        }
    43044324
     
    45024522    if (xp->xp_context != EXPAND_MENUNAMES && xp->xp_context != EXPAND_MENUS)
    45034523        sort_strings(*file, *num_file);
    45044524
     4525#ifdef FEAT_CMDL_COMPL
     4526    /* Reset the variables used for special highlight names expansion, so that
     4527     * they don't show up when getting normal highlight names by ID. */
     4528    reset_expand_highlight();
     4529#endif
     4530
    45054531    return OK;
    45064532}
    45074533
     
    45354561    pat = vim_strsave(filepat);
    45364562    for (i = 0; pat[i]; ++i)
    45374563        if (pat[i] == '\\' && pat[i + 1] == ' ')
    4538             STRCPY(pat + i, pat + i + 1);
     4564            mch_memmove(pat + i, pat + i + 1, STRLEN(pat + i));
    45394565
    45404566    flags |= EW_FILE | EW_EXEC;
    45414567
     
    59075933
    59085934# ifdef FEAT_AUTOCMD
    59095935    /* Don't execute autocommands while creating the window. */
    5910     ++autocmd_block;
     5936    block_autocmds();
    59115937# endif
    59125938    /* don't use a new tab page */
    59135939    cmdmod.tab = 0;
     
    59165942    if (win_split((int)p_cwh, WSP_BOT) == FAIL)
    59175943    {
    59185944        beep_flush();
     5945# ifdef FEAT_AUTOCMD
     5946        unblock_autocmds();
     5947# endif
    59195948        return K_IGNORE;
    59205949    }
    59215950    cmdwin_type = ccline.cmdfirstc;
     
    59385967
    59395968# ifdef FEAT_AUTOCMD
    59405969    /* Do execute autocommands for setting the filetype (load syntax). */
    5941     --autocmd_block;
     5970    unblock_autocmds();
    59425971# endif
    59435972
    59445973    /* Showing the prompt may have set need_wait_return, reset it. */
     
    60926121
    60936122# ifdef FEAT_AUTOCMD
    60946123        /* Don't execute autocommands while deleting the window. */
    6095         ++autocmd_block;
     6124        block_autocmds();
    60966125# endif
    60976126        wp = curwin;
    60986127        bp = curbuf;
     
    61046133        win_size_restore(&winsizes);
    61056134
    61066135# ifdef FEAT_AUTOCMD
    6107         --autocmd_block;
     6136        unblock_autocmds();
    61086137# endif
    61096138    }
    61106139
  • src/feature.h

    diff -Naur vim71.orig/src/feature.h vim71/src/feature.h
    old new  
    673673# define ESC_CHG_TO_ENG_MODE            /* if defined, when ESC pressed,
    674674                                         * turn to english mode
    675675                                         */
    676 # if !defined(FEAT_XFONTSET) && defined(HAVE_X11)
     676# if !defined(FEAT_XFONTSET) && defined(HAVE_X11) && !defined(HAVE_GTK2)
    677677#  define FEAT_XFONTSET                 /* Hangul input requires xfontset */
    678678# endif
    679679# if defined(FEAT_XIM) && !defined(LINT)
  • src/fileio.c

    diff -Naur vim71.orig/src/fileio.c vim71/src/fileio.c
    old new  
    4444/* Is there any system that doesn't have access()? */
    4545#define USE_MCH_ACCESS
    4646
     47#if defined(sun) && defined(S_ISCHR)
     48# define OPEN_CHR_FILES
     49static int is_dev_fd_file(char_u *fname);
     50#endif
    4751#ifdef FEAT_MBYTE
    4852static char_u *next_fenc __ARGS((char_u **pp));
    4953# ifdef FEAT_EVAL
     
    406410# ifdef S_ISSOCK
    407411                      && !S_ISSOCK(perm)            /* ... or socket */
    408412# endif
     413# ifdef OPEN_CHR_FILES
     414                      && !(S_ISCHR(perm) && is_dev_fd_file(fname))
     415                        /* ... or a character special file named /dev/fd/<n> */
     416# endif
    409417                                                )
    410418        {
    411419            if (S_ISDIR(perm))
     
    424432         */
    425433        if (!p_odev && mch_nodetype(fname) == NODE_WRITABLE)
    426434        {
    427             filemess(curbuf, fname, (char_u *)_("is a device (disabled with 'opendevice' option"), 0);
     435            filemess(curbuf, fname, (char_u *)_("is a device (disabled with 'opendevice' option)"), 0);
    428436            msg_end();
    429437            msg_scroll = msg_save;
    430438            return FAIL;
     
    646654        curbuf->b_start_eol = TRUE;
    647655#ifdef FEAT_MBYTE
    648656        curbuf->b_p_bomb = FALSE;
     657        curbuf->b_start_bomb = FALSE;
    649658#endif
    650659    }
    651660
     
    904913        file_rewind = FALSE;
    905914#ifdef FEAT_MBYTE
    906915        if (set_options)
     916        {
    907917            curbuf->b_p_bomb = FALSE;
     918            curbuf->b_start_bomb = FALSE;
     919        }
    908920        conv_error = 0;
    909921#endif
    910922    }
     
    13531365                    size -= blen;
    13541366                    mch_memmove(ptr, ptr + blen, (size_t)size);
    13551367                    if (set_options)
     1368                    {
    13561369                        curbuf->b_p_bomb = TRUE;
     1370                        curbuf->b_start_bomb = TRUE;
     1371                    }
    13571372                }
    13581373
    13591374                if (fio_flags == FIO_UCSBOM)
     
    22652280            }
    22662281#  endif
    22672282# endif
     2283# ifdef OPEN_CHR_FILES
     2284            if (S_ISCHR(perm))                      /* or character special */
     2285            {
     2286                STRCAT(IObuff, _("[character special]"));
     2287                c = TRUE;
     2288            }
     2289# endif
    22682290#endif
    22692291            if (curbuf->b_p_ro)
    22702292            {
     
    24642486    return OK;
    24652487}
    24662488
     2489#ifdef OPEN_CHR_FILES
     2490/*
     2491 * Returns TRUE if the file name argument is of the form "/dev/fd/\d\+",
     2492 * which is the name of files used for process substitution output by
     2493 * some shells on some operating systems, e.g., bash on SunOS.
     2494 * Do not accept "/dev/fd/[012]", opening these may hang Vim.
     2495 */
     2496    static int
     2497is_dev_fd_file(fname)
     2498    char_u      *fname;
     2499{
     2500    return (STRNCMP(fname, "/dev/fd/", 8) == 0
     2501            && VIM_ISDIGIT(fname[8])
     2502            && *skipdigits(fname + 9) == NUL
     2503            && (fname[9] != NUL
     2504                || (fname[8] != '0' && fname[8] != '1' && fname[8] != '2')));
     2505}
     2506#endif
     2507
    24672508#ifdef FEAT_MBYTE
    24682509
    24692510/*
     
    27342775#endif
    27352776
    27362777/*
     2778 * Return TRUE if a file appears to be read-only from the file permissions.
     2779 */
     2780    int
     2781check_file_readonly(fname, perm)
     2782    char_u      *fname;         /* full path to file */
     2783    int         perm;           /* known permissions on file */
     2784{
     2785#ifndef USE_MCH_ACCESS
     2786    int     fd = 0;
     2787#endif
     2788
     2789    return (
     2790#ifdef USE_MCH_ACCESS
     2791# ifdef UNIX
     2792        (perm & 0222) == 0 ||
     2793# endif
     2794        mch_access((char *)fname, W_OK)
     2795#else
     2796        (fd = mch_open((char *)fname, O_RDWR | O_EXTRA, 0)) < 0
     2797                                        ? TRUE : (close(fd), FALSE)
     2798#endif
     2799        );
     2800}
     2801
     2802
     2803/*
    27372804 * buf_write() - write to file "fname" lines "start" through "end"
    27382805 *
    27392806 * We do our own buffering here because fwrite() is so slow.
     
    32193286         * Check if the file is really writable (when renaming the file to
    32203287         * make a backup we won't discover it later).
    32213288         */
    3222         file_readonly = (
    3223 # ifdef USE_MCH_ACCESS
    3224 #  ifdef UNIX
    3225                     (perm & 0222) == 0 ||
    3226 #  endif
    3227                     mch_access((char *)fname, W_OK)
    3228 # else
    3229                     (fd = mch_open((char *)fname, O_RDWR | O_EXTRA, 0)) < 0
    3230                                                    ? TRUE : (close(fd), FALSE)
    3231 # endif
    3232                     );
     3289        file_readonly = check_file_readonly(fname, (int)perm);
     3290
    32333291        if (!forceit && file_readonly)
    32343292        {
    32353293            if (vim_strchr(p_cpo, CPO_FWRITE) != NULL)
     
    54955553}
    54965554#endif
    54975555
     5556#if defined(FEAT_VIMINFO) || defined(FEAT_BROWSE) || \
     5557    defined(FEAT_QUICKFIX) || defined(PROTO)
    54985558/*
    54995559 * Try to find a shortname by comparing the fullname with the current
    55005560 * directory.
     
    55485608        p = NULL;
    55495609    return p;
    55505610}
     5611#endif
    55515612
    55525613/*
    55535614 * Shorten filenames for all buffers.
     
    71077168
    71087169static event_T  last_event;
    71097170static int      last_group;
     7171static int      autocmd_blocked = 0;    /* block all autocmds */
    71107172
    71117173/*
    71127174 * Show the autocommands for one AutoPat.
     
    83968458     * Quickly return if there are no autocommands for this event or
    83978459     * autocommands are blocked.
    83988460     */
    8399     if (first_autopat[(int)event] == NULL || autocmd_block > 0)
     8461    if (first_autopat[(int)event] == NULL || autocmd_blocked > 0)
    84008462        goto BYPASS_AU;
    84018463
    84028464    /*
     
    87108772    return retval;
    87118773}
    87128774
     8775# ifdef FEAT_EVAL
     8776static char_u   *old_termresponse = NULL;
     8777# endif
     8778
     8779/*
     8780 * Block triggering autocommands until unblock_autocmd() is called.
     8781 * Can be used recursively, so long as it's symmetric.
     8782 */
     8783    void
     8784block_autocmds()
     8785{
     8786# ifdef FEAT_EVAL
     8787    /* Remember the value of v:termresponse. */
     8788    if (autocmd_blocked == 0)
     8789        old_termresponse = get_vim_var_str(VV_TERMRESPONSE);
     8790# endif
     8791    ++autocmd_blocked;
     8792}
     8793
     8794    void
     8795unblock_autocmds()
     8796{
     8797    --autocmd_blocked;
     8798
     8799# ifdef FEAT_EVAL
     8800    /* When v:termresponse was set while autocommands were blocked, trigger
     8801     * the autocommands now.  Esp. useful when executing a shell command
     8802     * during startup (vimdiff). */
     8803    if (autocmd_blocked == 0
     8804                      && get_vim_var_str(VV_TERMRESPONSE) != old_termresponse)
     8805        apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf);
     8806# endif
     8807}
     8808
    87138809/*
    87148810 * Find next autocommand pattern that matches.
    87158811 */
  • src/fold.c

    diff -Naur vim71.orig/src/fold.c vim71/src/fold.c
    old new  
    858858            || foldmethodIsDiff(wp)
    859859#endif
    860860            || foldmethodIsSyntax(wp))
     861    {
     862        int save_got_int = got_int;
     863
     864        /* reset got_int here, otherwise it won't work */
     865        got_int = FALSE;
    861866        foldUpdateIEMS(wp, top, bot);
     867        got_int |= save_got_int;
     868    }
    862869}
    863870
    864871/* foldUpdateAll() {{{2 */
  • src/getchar.c

    diff -Naur vim71.orig/src/getchar.c vim71/src/getchar.c
    old new  
    15961596                continue;
    15971597            }
    15981598#endif
    1599 
    16001599#ifdef FEAT_GUI
     1600            /* Handle focus event here, so that the caller doesn't need to
     1601             * know about it.  Return K_IGNORE so that we loop once (needed if
     1602             * 'lazyredraw' is set). */
     1603            if (c == K_FOCUSGAINED || c == K_FOCUSLOST)
     1604            {
     1605                ui_focus_change(c == K_FOCUSGAINED);
     1606                c = K_IGNORE;
     1607            }
     1608
    16011609            /* Translate K_CSI to CSI.  The special key is only used to avoid
    16021610             * it being recognized as the start of a special key. */
    16031611            if (c == K_CSI)
     
    17411749}
    17421750
    17431751/*
     1752 * Like safe_vgetc(), but loop to handle K_IGNORE.
     1753 * Also ignore scrollbar events.
     1754 */
     1755    int
     1756plain_vgetc()
     1757{
     1758    int c;
     1759
     1760    do
     1761    {
     1762        c = safe_vgetc();
     1763    } while (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR);
     1764    return c;
     1765}
     1766
     1767/*
    17441768 * Check if a character is available, such that vgetc() will not block.
    17451769 * If the next character is a special character or multi-byte, the returned
    17461770 * character is not valid!.
  • src/globals.h

    diff -Naur vim71.orig/src/globals.h vim71/src/globals.h
    old new  
    301301#endif
    302302
    303303#ifdef FEAT_EVAL
    304 /* Garbage collection can only take place when we are sure there are no Lists
     304/*
     305 * Garbage collection can only take place when we are sure there are no Lists
    305306 * or Dictionaries being used internally.  This is flagged with
    306307 * "may_garbage_collect" when we are at the toplevel.
    307308 * "want_garbage_collect" is set by the garbagecollect() function, which means
    308  * we do garbage collection before waiting for a char at the toplevel. */
     309 * we do garbage collection before waiting for a char at the toplevel.
     310 * "garbage_collect_at_exit" indicates garbagecollect(1) was called.
     311 */
    309312EXTERN int      may_garbage_collect INIT(= FALSE);
    310313EXTERN int      want_garbage_collect INIT(= FALSE);
     314EXTERN int      garbage_collect_at_exit INIT(= FALSE);
    311315
    312316/* ID of script being sourced or was sourced to define the current function. */
    313317EXTERN scid_T   current_SID INIT(= 0);
     
    362366EXTERN int      autocmd_busy INIT(= FALSE);     /* Is apply_autocmds() busy? */
    363367EXTERN int      autocmd_no_enter INIT(= FALSE); /* *Enter autocmds disabled */
    364368EXTERN int      autocmd_no_leave INIT(= FALSE); /* *Leave autocmds disabled */
    365 EXTERN int      autocmd_block INIT(= 0);        /* block all autocmds */
    366369EXTERN int      modified_was_set;               /* did ":set modified" */
    367370EXTERN int      did_filetype INIT(= FALSE);     /* FileType event found */
    368371EXTERN int      keep_filetype INIT(= FALSE);    /* value for did_filetype when
     
    801804EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
    802805EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
    803806EXTERN int (*mb_char2cells) __ARGS((int c)) INIT(= latin_char2cells);
    804 EXTERN int (*mb_off2cells) __ARGS((unsigned off)) INIT(= latin_off2cells);
     807EXTERN int (*mb_off2cells) __ARGS((unsigned off, unsigned max_off)) INIT(= latin_off2cells);
    805808EXTERN int (*mb_ptr2char) __ARGS((char_u *p)) INIT(= latin_ptr2char);
    806809EXTERN int (*mb_head_off) __ARGS((char_u *base, char_u *p)) INIT(= latin_head_off);
    807810
  • src/gui.c

    diff -Naur vim71.orig/src/gui.c vim71/src/gui.c
    old new  
    10801080                cur_width = gui.char_width;
    10811081            }
    10821082#ifdef FEAT_MBYTE
    1083             if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col) > 1)
     1083            if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col,
     1084                                    LineOffset[gui.row] + screen_Columns) > 1)
    10841085            {
    10851086                /* Double wide character. */
    10861087                if (shape_table[idx].shape != SHAPE_VER)
     
    11591160#endif
    11601161
    11611162# if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_MSWIN) \
    1162         || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_MAC))
     1163        || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_MAC))
    11631164    if (gui_has_tabline())
    11641165        text_area_y += gui.tabline_height;
    11651166#endif
     
    45184519    xim_set_focus(in_focus);
    45194520# endif
    45204521
    4521     ui_focus_change(in_focus);
     4522    /* Put events in the input queue only when allowed.
     4523     * ui_focus_change() isn't called directly, because it invokes
     4524     * autocommands and that must not happen asynchronously. */
     4525    if (!hold_gui_events)
     4526    {
     4527        char_u  bytes[3];
     4528
     4529        bytes[0] = CSI;
     4530        bytes[1] = KS_EXTRA;
     4531        bytes[2] = in_focus ? (int)KE_FOCUSGAINED : (int)KE_FOCUSLOST;
     4532        add_to_input_buf(bytes, 3);
     4533    }
    45224534#endif
    45234535}
    45244536
     
    51175129                p = vim_strsave_escaped(fnames[i], (char_u *)"\\ \t\"|");
    51185130# endif
    51195131                if (p != NULL)
    5120                     add_to_input_buf(p, (int)STRLEN(p));
     5132                    add_to_input_buf_csi(p, (int)STRLEN(p));
    51215133                vim_free(p);
    51225134                vim_free(fnames[i]);
    51235135            }
  • src/gui_gtk.c

    diff -Naur vim71.orig/src/gui_gtk.c vim71/src/gui_gtk.c
    old new  
    5353# ifdef bindtextdomain
    5454#  undef bindtextdomain
    5555# endif
    56 # ifdef bindtextdomain_codeset
    57 #  undef bindtextdomain_codeset
     56# ifdef bind_textdomain_codeset
     57#  undef bind_textdomain_codeset
    5858# endif
    5959# if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS)
    6060#  define ENABLE_NLS    /* so the texts in the dialog boxes are translated */
     
    16301630 */
    16311631/*ARGSUSED*/
    16321632    static int
    1633 dlg_key_press_event(GtkWidget * widget, GdkEventKey * event, CancelData *data)
     1633dlg_key_press_event(GtkWidget *widget, GdkEventKey *event, CancelData *data)
    16341634{
    1635     /* Ignore hitting Enter when there is no default button. */
    1636     if (data->ignore_enter && event->keyval == GDK_Return)
     1635    /* Ignore hitting Enter (or Space) when there is no default button. */
     1636    if (data->ignore_enter && (event->keyval == GDK_Return
     1637                                                     || event->keyval == ' '))
    16371638        return TRUE;
     1639    else    /* A different key was pressed, return to normal behavior */
     1640        data->ignore_enter = FALSE;
    16381641
    16391642    if (event->keyval != GDK_Escape && event->keyval != GDK_Return)
    16401643        return FALSE;
     
    22242227{
    22252228    DialogInfo *di = (DialogInfo *)data;
    22262229
     2230    /* Ignore hitting Enter (or Space) when there is no default button. */
     2231    if (di->ignore_enter && (event->keyval == GDK_Return
     2232                                                     || event->keyval == ' '))
     2233        return TRUE;
     2234    else    /* A different key was pressed, return to normal behavior */
     2235        di->ignore_enter = FALSE;
     2236
    22272237    /* Close the dialog when hitting "Esc". */
    22282238    if (event->keyval == GDK_Escape)
    22292239    {
  • src/gui_gtk_x11.c

    diff -Naur vim71.orig/src/gui_gtk_x11.c vim71/src/gui_gtk_x11.c
    old new  
    3636# ifdef bindtextdomain
    3737#  undef bindtextdomain
    3838# endif
    39 # ifdef bindtextdomain_codeset
    40 #  undef bindtextdomain_codeset
     39# ifdef bind_textdomain_codeset
     40#  undef bind_textdomain_codeset
    4141# endif
    4242# if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS)
    4343#  define ENABLE_NLS    /* so the texts in the dialog boxes are translated */
     
    813813    if (blink_state == BLINK_NONE)
    814814        gui_mch_start_blink();
    815815
    816     /* make sure keyboard input goes to the draw area (if this is focus for a window) */
     816    /* make sure keyboard input goes to the draw area (if this is focus for a
     817     * window) */
    817818    if (widget != gui.drawarea)
    818819        gtk_widget_grab_focus(gui.drawarea);
    819820
     821    /* make sure the input buffer is read */
     822    if (gtk_main_level() > 0)
     823        gtk_main_quit();
     824
    820825    return TRUE;
    821826}
    822827
     
    829834    if (blink_state != BLINK_NONE)
    830835        gui_mch_stop_blink();
    831836
     837    /* make sure the input buffer is read */
     838    if (gtk_main_level() > 0)
     839        gtk_main_quit();
     840
    832841    return TRUE;
    833842}
    834843
     
    21882197    escaped_filename = vim_strsave_escaped(filename, escape_chars);
    21892198    if (escaped_filename == NULL)
    21902199        return FALSE;
    2191     mksession_cmdline = g_strconcat("mksession ", (char *)escaped_filename, NULL);
     2200    mksession_cmdline = g_strconcat("mksession ", (char *)escaped_filename,
     2201                                                                        NULL);
    21922202    vim_free(escaped_filename);
     2203
    21932204    /*
    21942205     * Use a reasonable hardcoded set of 'sessionoptions' flags to avoid
    21952206     * unpredictable effects when the session is saved automatically.  Also,
     
    21992210     */
    22002211    save_ssop_flags = ssop_flags;
    22012212    ssop_flags = (SSOP_BLANK|SSOP_CURDIR|SSOP_FOLDS|SSOP_GLOBALS
    2202                   |SSOP_HELP|SSOP_OPTIONS|SSOP_WINSIZE);
     2213                  |SSOP_HELP|SSOP_OPTIONS|SSOP_WINSIZE|SSOP_TABPAGES);
    22032214
    22042215    do_cmdline_cmd((char_u *)"let Save_VV_this_session = v:this_session");
    22052216    failed = (do_cmdline_cmd((char_u *)mksession_cmdline) == FAIL);
     
    32123223        {
    32133224            if (clicked_page == 0)
    32143225            {
    3215                 /* Click after all tabs moves to next tab page. */
    3216                 if (send_tabline_event(0) && gtk_main_level() > 0)
     3226                /* Click after all tabs moves to next tab page.  When "x" is
     3227                 * small guess it's the left button. */
     3228                if (send_tabline_event(x < 50 ? -1 : 0) && gtk_main_level() > 0)
    32173229                    gtk_main_quit();
    32183230            }
    32193231#ifndef HAVE_GTK2
  • src/if_cscope.c

    diff -Naur vim71.orig/src/if_cscope.c vim71/src/if_cscope.c
    old new  
    2424    /* not UNIX, must be WIN32 */
    2525# include "vimio.h"
    2626# include <fcntl.h>
    27 # include <process.h>
    28 # define STDIN_FILENO    0
    29 # define STDOUT_FILENO   1
    30 # define STDERR_FILENO   2
    31 # define pipe(fds) _pipe(fds, 256, O_TEXT|O_NOINHERIT)
    3227#endif
    3328#include "if_cscope.h"
    3429
     
    6560static char *       cs_parse_results __ARGS((int cnumber, char *buf, int bufsize, char **context, char **linenumber, char **search));
    6661static char *       cs_pathcomponents __ARGS((char *path));
    6762static void         cs_print_tags_priv __ARGS((char **, char **, int));
    68 static int          cs_read_prompt __ARGS((int ));
     63static int          cs_read_prompt __ARGS((int));
    6964static void         cs_release_csp __ARGS((int, int freefnpp));
    7065static int          cs_reset __ARGS((exarg_T *eap));
    7166static char *       cs_resolve_file __ARGS((int, char *));
     
    7368
    7469
    7570static csinfo_T     csinfo[CSCOPE_MAX_CONNECTIONS];
     71static int          eap_arg_len;    /* length of eap->arg, set in
     72                                       cs_lookup_cmd() */
    7673static cscmd_T      cs_cmds[] =
    7774{
    7875    { "add",    cs_add,
     
    260257
    261258    if ((p = cs_manage_matches(NULL, NULL, -1, Get)) == NULL)
    262259        return TRUE;
    263 
    264     if ((int)strlen(p) > size)
    265     {
    266         strncpy((char *)buf, p, size - 1);
    267         buf[size] = '\0';
    268     }
    269     else
    270         (void)strcpy((char *)buf, p);
     260    vim_strncpy(buf, (char_u *)p, size - 1);
    271261
    272262    return FALSE;
    273263} /* cs_fgets */
     
    386376 * PRIVATE: cs_add
    387377 *
    388378 * add cscope database or a directory name (to look for cscope.out)
    389  * the the cscope connection list
     379 * to the cscope connection list
    390380 *
    391381 * MAXPATHL 256
    392382 */
     
    509499#if defined(UNIX)
    510500    else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode))
    511501#else
    512         /* substitute define S_ISREG from os_unix.h */
     502        /* WIN32 - substitute define S_ISREG from os_unix.h */
    513503    else if (((statbuf.st_mode) & S_IFMT) == S_IFREG)
    514504#endif
    515505    {
     
    722712cs_create_connection(i)
    723713    int i;
    724714{
    725     int to_cs[2], from_cs[2], len;
    726     char *prog, *cmd, *ppath = NULL;
    727 #ifndef UNIX
    728     int in_save, out_save, err_save;
    729     long_i ph;
    730 # ifdef FEAT_GUI
    731     HWND activewnd = NULL;
    732     HWND consolewnd = NULL;
     715#ifdef UNIX
     716    int         to_cs[2], from_cs[2];
     717#endif
     718    int         len;
     719    char        *prog, *cmd, *ppath = NULL;
     720#ifdef WIN32
     721    int         fd;
     722    SECURITY_ATTRIBUTES sa;
     723    PROCESS_INFORMATION pi;
     724    STARTUPINFO si;
     725    BOOL        pipe_stdin = FALSE, pipe_stdout = FALSE;
     726    HANDLE      stdin_rd, stdout_rd;
     727    HANDLE      stdout_wr, stdin_wr;
     728    BOOL        created;
     729# ifdef __BORLANDC__
     730#  define OPEN_OH_ARGTYPE long
     731# else
     732#  if (_MSC_VER >= 1300)
     733#   define OPEN_OH_ARGTYPE intptr_t
     734#  else
     735#   define OPEN_OH_ARGTYPE long
     736#  endif
    733737# endif
    734738#endif
    735739
     740#if defined(UNIX)
    736741    /*
    737742     * Cscope reads from to_cs[0] and writes to from_cs[1]; vi reads from
    738743     * from_cs[0] and writes to to_cs[1].
     
    753758        return CSCOPE_FAILURE;
    754759    }
    755760
    756 #if defined(UNIX)
    757761    switch (csinfo[i].pid = fork())
    758762    {
    759763    case -1:
    760764        (void)EMSG(_("E622: Could not fork for cscope"));
    761765        goto err_closing;
    762766    case 0:                             /* child: run cscope. */
    763 #else
    764         in_save = dup(STDIN_FILENO);
    765         out_save = dup(STDOUT_FILENO);
    766         err_save = dup(STDERR_FILENO);
    767 #endif
    768767        if (dup2(to_cs[0], STDIN_FILENO) == -1)
    769768            PERROR("cs_create_connection 1");
    770769        if (dup2(from_cs[1], STDOUT_FILENO) == -1)
     
    773772            PERROR("cs_create_connection 3");
    774773
    775774        /* close unused */
    776 #if defined(UNIX)
    777775        (void)close(to_cs[1]);
    778776        (void)close(from_cs[0]);
    779777#else
    780         /* On win32 we must close opposite ends because we are the parent */
    781         (void)close(to_cs[0]);
    782         to_cs[0] = -1;
    783         (void)close(from_cs[1]);
    784         from_cs[1] = -1;
     778        /* WIN32 */
     779        /* Create pipes to communicate with cscope */
     780        sa.nLength = sizeof(SECURITY_ATTRIBUTES);
     781        sa.bInheritHandle = TRUE;
     782        sa.lpSecurityDescriptor = NULL;
     783
     784        if (!(pipe_stdin = CreatePipe(&stdin_rd, &stdin_wr, &sa, 0))
     785                || !(pipe_stdout = CreatePipe(&stdout_rd, &stdout_wr, &sa, 0)))
     786        {
     787            (void)EMSG(_("E566: Could not create cscope pipes"));
     788err_closing:
     789            if (pipe_stdin)
     790            {
     791                CloseHandle(stdin_rd);
     792                CloseHandle(stdin_wr);
     793            }
     794            if (pipe_stdout)
     795            {
     796                CloseHandle(stdout_rd);
     797                CloseHandle(stdout_wr);
     798            }
     799            return CSCOPE_FAILURE;
     800        }
    785801#endif
    786802        /* expand the cscope exec for env var's */
    787803        if ((prog = (char *)alloc(MAXPATHL + 1)) == NULL)
     
    789805#ifdef UNIX
    790806            return CSCOPE_FAILURE;
    791807#else
     808            /* WIN32 */
    792809            goto err_closing;
    793810#endif
    794811        }
     
    805822#ifdef UNIX
    806823                return CSCOPE_FAILURE;
    807824#else
     825                /* WIN32 */
    808826                goto err_closing;
    809827#endif
    810828            }
     
    823841#ifdef UNIX
    824842            return CSCOPE_FAILURE;
    825843#else
     844            /* WIN32 */
    826845            goto err_closing;
    827846#endif
    828847        }
     
    831850#if defined(UNIX)
    832851        (void)sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname);
    833852#else
     853        /* WIN32 */
    834854        (void)sprintf(cmd, "%s -dl -f %s", prog, csinfo[i].fname);
    835855#endif
    836856        if (csinfo[i].ppath != NULL)
     
    856876        exit(127);
    857877        /* NOTREACHED */
    858878    default:    /* parent. */
    859 #else
    860 # ifdef FEAT_GUI
    861         activewnd = GetForegroundWindow(); /* on win9x cscope steals focus */
    862         /* Dirty hack to hide annoying console window */
    863         if (AllocConsole())
    864         {
    865             char *title;
    866             title = (char *)alloc(1024);
    867             if (title == NULL)
    868                 FreeConsole();
    869             else
    870             {
    871                 GetConsoleTitle(title, 1024); /* save for future restore */
    872                 SetConsoleTitle(
    873                     "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
    874                 Sleep(40); /* as stated in MS KB we must wait 40 ms */
    875                 consolewnd = FindWindow(NULL,
    876                         "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
    877                 if (consolewnd != NULL)
    878                     ShowWindow(consolewnd, SW_HIDE);
    879                 SetConsoleTitle(title);
    880                 vim_free(title);
    881             }
    882         }
    883 # endif
    884         /* May be use &shell, &shellquote etc */
    885 # ifdef __BORLANDC__
    886         /* BCC 5.5 uses a different function name for spawnlp */
    887         ph = (long_i)spawnlp(P_NOWAIT, prog, cmd, NULL);
    888 # else
    889         ph = (long_i)_spawnlp(_P_NOWAIT, prog, cmd, NULL);
    890 # endif
    891         vim_free(prog);
    892         vim_free(cmd);
    893 # ifdef FEAT_GUI
    894         /* Dirty hack part two */
    895         if (activewnd != NULL)
    896             /* restoring focus */
    897             SetForegroundWindow(activewnd);
    898         if (consolewnd != NULL)
    899             FreeConsole();
    900 
    901 # endif
    902         if (ph == -1)
    903         {
    904             PERROR(_("cs_create_connection exec failed"));
    905             (void)EMSG(_("E623: Could not spawn cscope process"));
    906             goto err_closing;
    907         }
    908         /* else */
    909         csinfo[i].pid = 0;
    910         csinfo[i].hProc = (HANDLE)ph;
    911 
    912 #endif /* !UNIX */
    913879        /*
    914880         * Save the file descriptors for later duplication, and
    915881         * reopen as streams.
     
    919885        if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL)
    920886            PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
    921887
    922 #if defined(UNIX)
    923888        /* close unused */
    924889        (void)close(to_cs[0]);
    925890        (void)close(from_cs[1]);
    926891
    927892        break;
    928893    }
     894
    929895#else
    930         /* restore stdhandles */
    931     dup2(in_save, STDIN_FILENO);
    932     dup2(out_save, STDOUT_FILENO);
    933     dup2(err_save, STDERR_FILENO);
    934     close(in_save);
    935     close(out_save);
    936     close(err_save);
    937 #endif
     896    /* WIN32 */
     897    /* Create a new process to run cscope and use pipes to talk with it */
     898    GetStartupInfo(&si);
     899    si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
     900    si.wShowWindow = SW_HIDE;  /* Hide child application window */
     901    si.hStdOutput = stdout_wr;
     902    si.hStdError  = stdout_wr;
     903    si.hStdInput  = stdin_rd;
     904    created = CreateProcess(NULL, cmd, NULL, NULL, TRUE, CREATE_NEW_CONSOLE,
     905                                                        NULL, NULL, &si, &pi);
     906    vim_free(prog);
     907    vim_free(cmd);
     908
     909    if (!created)
     910    {
     911        PERROR(_("cs_create_connection exec failed"));
     912        (void)EMSG(_("E623: Could not spawn cscope process"));
     913        goto err_closing;
     914    }
     915    /* else */
     916    csinfo[i].pid = pi.dwProcessId;
     917    csinfo[i].hProc = pi.hProcess;
     918    CloseHandle(pi.hThread);
     919
     920    /* TODO - tidy up after failure to create files on pipe handles. */
     921    if (((fd = _open_osfhandle((OPEN_OH_ARGTYPE)stdin_wr,
     922                                                      _O_TEXT|_O_APPEND)) < 0)
     923            || ((csinfo[i].to_fp = _fdopen(fd, "w")) == NULL))
     924        PERROR(_("cs_create_connection: fdopen for to_fp failed"));
     925    if (((fd = _open_osfhandle((OPEN_OH_ARGTYPE)stdout_rd,
     926                                                      _O_TEXT|_O_RDONLY)) < 0)
     927            || ((csinfo[i].fr_fp = _fdopen(fd, "r")) == NULL))
     928        PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
     929
     930    /* Close handles for file descriptors inherited by the cscope process */
     931    CloseHandle(stdin_rd);
     932    CloseHandle(stdout_wr);
     933
     934#endif /* !UNIX */
     935
    938936    return CSCOPE_SUCCESS;
    939937} /* cs_create_connection */
    940938
     
    966964    }
    967965
    968966    pat = opt + strlen(opt) + 1;
    969     if (pat == NULL || (pat != NULL && pat[0] == '\0'))
     967    if (pat >= (char *)eap->arg + eap_arg_len)
    970968    {
    971969        cs_usage_msg(Find);
    972970        return FALSE;
     
    13171315#else
    13181316            /* compare pathnames first */
    13191317            && ((fullpathcmp(csinfo[j].fname, fname, FALSE) & FPC_SAME)
    1320                 /* if not Windows 9x, test index file atributes too */
     1318                /* if not Windows 9x, test index file attributes too */
    13211319                || (!mch_windows95()
    13221320                    && csinfo[j].nVolume == bhfi.dwVolumeSerialNumber
    13231321                    && csinfo[j].nIndexHigh == bhfi.nFileIndexHigh
     
    14011399    if (eap->arg == NULL)
    14021400        return NULL;
    14031401
     1402    /* Store length of eap->arg before it gets modified by strtok(). */
     1403    eap_arg_len = STRLEN(eap->arg);
     1404
    14041405    if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL)
    14051406        return NULL;
    14061407
     
    20992100/*
    21002101 * PRIVATE: cs_release_csp
    21012102 *
    2102  * does the actual free'ing for the cs ptr with an optional flag of whether
    2103  * or not to free the filename.  called by cs_kill and cs_reset.
     2103 * Does the actual free'ing for the cs ptr with an optional flag of whether
     2104 * or not to free the filename.  Called by cs_kill and cs_reset.
    21042105 */
    21052106    static void
    21062107cs_release_csp(i, freefnpp)
     
    21182119        (void)fputs("q\n", csinfo[i].to_fp);
    21192120        (void)fflush(csinfo[i].to_fp);
    21202121    }
    2121     /* give cscope chance to exit normally */
    2122     if (csinfo[i].hProc != NULL
    2123             && WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT)
    2124         TerminateProcess(csinfo[i].hProc, 0);
     2122    if (csinfo[i].hProc != NULL)
     2123    {
     2124        /* Give cscope a chance to exit normally */
     2125        if (WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT)
     2126            TerminateProcess(csinfo[i].hProc, 0);
     2127        CloseHandle(csinfo[i].hProc);
     2128    }
    21252129#endif
    21262130
    21272131    if (csinfo[i].fr_fp != NULL)
     
    21952199            cs_add_common(dblist[i], pplist[i], fllist[i]);
    21962200            if (p_csverbose)
    21972201            {
    2198                 /* dont' use smsg_attr because want to display
     2202                /* don't use smsg_attr() because we want to display the
    21992203                 * connection number in the same line as
    22002204                 * "Added cscope database..."
    22012205                 */
     
    23042308    return CSCOPE_SUCCESS;
    23052309} /* cs_show */
    23062310
     2311
     2312/*
     2313 * PUBLIC: cs_end
     2314 *
     2315 * Only called when VIM exits to quit any cscope sessions.
     2316 */
     2317    void
     2318cs_end()
     2319{
     2320    int i;
     2321
     2322    for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
     2323        cs_release_csp(i, TRUE);
     2324}
     2325
    23072326#endif  /* FEAT_CSCOPE */
    23082327
    23092328/* the end */
  • src/if_cscope.h

    diff -Naur vim71.orig/src/if_cscope.h vim71/src/if_cscope.h
    old new  
    7272    ino_t           st_ino;     /* inode number of cscope db */
    7373#else
    7474# if defined(WIN32)
    75     int     pid;        /* Can't get pid so set it to 0 ;) */
     75    DWORD           pid;        /* PID of the connected cscope process. */
    7676    HANDLE          hProc;      /* cscope process handle */
    7777    DWORD           nVolume;    /* Volume serial number, instead of st_dev */
    7878    DWORD           nIndexHigh; /* st_ino has no meaning in the Windows */
  • src/if_mzsch.c

    diff -Naur vim71.orig/src/if_mzsch.c vim71/src/if_mzsch.c
    old new  
    308308static Scheme_Config *(*dll_scheme_current_config)(void);
    309309static Scheme_Object *(*dll_scheme_char_string_to_byte_string)
    310310    (Scheme_Object *s);
     311static Scheme_Object *(*dll_scheme_char_string_to_path)
     312    (Scheme_Object *s);
    311313# endif
    312314
    313315/* arrays are imported directly */
     
    398400#  define scheme_current_config dll_scheme_current_config
    399401#  define scheme_char_string_to_byte_string \
    400402    dll_scheme_char_string_to_byte_string
     403#  define scheme_char_string_to_path \
     404    dll_scheme_char_string_to_path
    401405# endif
    402406
    403407typedef struct
     
    498502    {"scheme_current_config", (void **)&dll_scheme_current_config},
    499503    {"scheme_char_string_to_byte_string",
    500504        (void **)&dll_scheme_char_string_to_byte_string},
     505    {"scheme_char_string_to_path",
     506        (void **)&dll_scheme_char_string_to_path},
    501507# endif
    502508    {NULL, NULL}};
    503509
     
    773779#ifdef MZSCHEME_COLLECTS
    774780    /* setup 'current-library-collection-paths' parameter */
    775781    scheme_set_param(scheme_config, MZCONFIG_COLLECTION_PATHS,
    776             scheme_make_pair(scheme_make_string(MZSCHEME_COLLECTS),
     782            scheme_make_pair(
     783# if MZSCHEME_VERSION_MAJOR >= 299
     784                scheme_char_string_to_path(
     785                    scheme_byte_string_to_char_string(
     786                        scheme_make_byte_string(MZSCHEME_COLLECTS))),
     787# else
     788                scheme_make_string(MZSCHEME_COLLECTS),
     789# endif
    777790                scheme_null));
    778791#endif
    779792#ifdef HAVE_SANDBOX
  • src/if_perl.xs

    diff -Naur vim71.orig/src/if_perl.xs vim71/src/if_perl.xs
    old new  
    4040#    define PERL_SUBVERSION SUBVERSION
    4141#endif
    4242
     43/*
     44 * Quoting Jan Dubois of Active State:
     45 *    ActivePerl build 822 still identifies itself as 5.8.8 but already
     46 *    contains many of the changes from the upcoming Perl 5.8.9 release.
     47 *
     48 * The changes include addition of two symbols (Perl_sv_2iv_flags,
     49 * Perl_newXS_flags) not present in earlier releases.
     50 *
     51 * Jan Dubois suggested the following guarding scheme.
     52 *
     53 * Active State defined ACTIVEPERL_VERSION as a string in versions before
     54 * 5.8.8; and so the comparison to 822 below needs to be guarded.
     55 */
     56#if (PERL_REVISION == 5) && (PERL_VERSION == 8) && (PERL_SUBVERSION >= 8)
     57# if (ACTIVEPERL_VERSION >= 822) || (PERL_SUBVERSION >= 9)
     58#  define PERL589_OR_LATER
     59# endif
     60#endif
     61#if (PERL_REVISION == 5) && (PERL_VERSION >= 9)
     62# define PERL589_OR_LATER
     63#endif
     64
    4365#ifndef pTHX
    4466#    define pTHX void
    4567#    define pTHX_
     
    109131# else
    110132#  define Perl_sv_catpvn dll_Perl_sv_catpvn
    111133# endif
     134#ifdef PERL589_OR_LATER
     135#  define Perl_sv_2iv_flags dll_Perl_sv_2iv_flags
     136#  define Perl_newXS_flags dll_Perl_newXS_flags
     137#endif
    112138# define Perl_sv_free dll_Perl_sv_free
    113139# define Perl_sv_isa dll_Perl_sv_isa
    114140# define Perl_sv_magic dll_Perl_sv_magic
     
    192218#else
    193219static void (*Perl_sv_catpvn)(pTHX_ SV*, const char*, STRLEN);
    194220#endif
     221#ifdef PERL589_OR_LATER
     222static IV (*Perl_sv_2iv_flags)(pTHX_ SV* sv, I32 flags);
     223static CV * (*Perl_newXS_flags)(pTHX_ const char *name, XSUBADDR_t subaddr, const char *const filename, const char *const proto, U32 flags);
     224#endif
    195225static void (*Perl_sv_free)(pTHX_ SV*);
    196226static int (*Perl_sv_isa)(pTHX_ SV*, const char*);
    197227static void (*Perl_sv_magic)(pTHX_ SV*, SV*, int, const char*, I32);
     
    267297#else
    268298    {"Perl_sv_2pv", (PERL_PROC*)&Perl_sv_2pv},
    269299#endif
     300#ifdef PERL589_OR_LATER
     301    {"Perl_sv_2iv_flags", (PERL_PROC*)&Perl_sv_2iv_flags},
     302    {"Perl_newXS_flags", (PERL_PROC*)&Perl_newXS_flags},
     303#endif
    270304    {"Perl_sv_bless", (PERL_PROC*)&Perl_sv_bless},
    271305#if (PERL_REVISION == 5) && (PERL_VERSION >= 8)
    272306    {"Perl_sv_catpvn_flags", (PERL_PROC*)&Perl_sv_catpvn_flags},
     
    411445    char *next;
    412446    char *token = (char *)s;
    413447
    414     while ((next = strchr(token, '\n')))
     448    while ((next = strchr(token, '\n')) && !got_int)
    415449    {
    416450        *next++ = '\0';                 /* replace \n with \0 */
    417451        msg_attr((char_u *)token, attr);
    418452        token = next;
    419453    }
    420     if (*token)
     454    if (*token && !got_int)
    421455        msg_attr((char_u *)token, attr);
    422456}
    423457
  • src/if_ruby.c

    diff -Naur vim71.orig/src/if_ruby.c vim71/src/if_ruby.c
    old new  
    789789    return get_buffer_line(curbuf, curwin->w_cursor.lnum);
    790790}
    791791
    792 static VALUE set_current_line(VALUE str)
     792static VALUE set_current_line(VALUE self, VALUE str)
    793793{
    794794    return set_buffer_line(curbuf, curwin->w_cursor.lnum, str);
    795795}
  • src/keymap.h

    diff -Naur vim71.orig/src/keymap.h vim71/src/keymap.h
    old new  
    254254    , KE_DROP           /* DnD data is available */
    255255    , KE_CURSORHOLD     /* CursorHold event */
    256256    , KE_NOP            /* doesn't do something */
     257    , KE_FOCUSGAINED    /* focus gained */
     258    , KE_FOCUSLOST      /* focus lost */
    257259};
    258260
    259261/*
     
    445447#define K_CMDWIN        TERMCAP2KEY(KS_EXTRA, KE_CMDWIN)
    446448
    447449#define K_DROP          TERMCAP2KEY(KS_EXTRA, KE_DROP)
     450#define K_FOCUSGAINED   TERMCAP2KEY(KS_EXTRA, KE_FOCUSGAINED)
     451#define K_FOCUSLOST     TERMCAP2KEY(KS_EXTRA, KE_FOCUSLOST)
    448452
    449453#define K_CURSORHOLD    TERMCAP2KEY(KS_EXTRA, KE_CURSORHOLD)
    450454
  • src/macros.h

    diff -Naur vim71.orig/src/macros.h vim71/src/macros.h
    old new  
    5454
    5555/*
    5656 * toupper() and tolower() that use the current locale.
    57  * On some systems toupper()/tolower() only work on lower/uppercase characters
     57 * On some systems toupper()/tolower() only work on lower/uppercase
     58 * characters, first use islower() or isupper() then.
    5859 * Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the
    5960 * range 0 - 255.  toupper()/tolower() on some systems can't handle others.
    60  * Note: for UTF-8 use utf_toupper() and utf_tolower().
     61 * Note: It is often better to use MB_TOLOWER() and MB_TOUPPER(), because many
     62 * toupper() and tolower() implementations only work for ASCII.
    6163 */
    6264#ifdef MSWIN
    6365#  define TOUPPER_LOC(c)        toupper_tab[(c) & 255]
  • src/main.aap

    diff -Naur vim71.orig/src/main.aap vim71/src/main.aap
    old new  
    5656    config {virtual} auto/config.h auto/config.aap :
    5757                         auto/configure.aap configure.aap
    5858                         config.arg config.h.in config.aap.in
     59        # Use "uname -a" to detect the architecture of the system.
     60        @ok, uname = redir_system('uname -a', 0)
     61        @if string.find(uname, "i386") >= 0:
     62        @   arch = "i386"
     63        @else:
     64        @   arch = "ppc"
     65        :print Building for $arch system
    5966        :sys CONFIG_STATUS=auto/config.status
    6067                ./configure.aap `file2string("config.arg")`
    61                     --with-mac-arch=ppc
     68                    --with-mac-arch=$arch
    6269                    --cache-file=auto/config.cache
    6370
    6471    # Configure arguments: create an empty "config.arg" file when its missing
     
    11671174        :symlink `os.getcwd()`/../runtime $RESDIR/vim/runtime
    11681175# TODO: Create the vimtutor application.
    11691176
    1170 gui_bundle {virtual}: $(RESDIR) bundle-dir bundle-executable bundle-info
     1177gui_bundle {virtual}: $(RESDIR) bundle-dir bundle-executable bundle-info \
    11711178                        bundle-resource bundle-language
    11721179
    11731180bundle-dir {virtual}: $(APPDIR)/Contents $(VIMTARGET)
     
    11871194        :sys m4 $(M4FLAGSX) infplist.xml > $(APPDIR)/Contents/Info.plist
    11881195
    11891196bundle-resource {virtual}: bundle-dir bundle-rsrc
    1190     :copy {force} $(RSRC_DIR)/*.icns $(RESDIR)
     1197        :copy {force} $(RSRC_DIR)/*.icns $(RESDIR)
    11911198
    11921199### Classic resources
    11931200# Resource fork (in the form of a .rsrc file) for Classic Vim (Mac OS 9)
  • src/main.c

    diff -Naur vim71.orig/src/main.c vim71/src/main.c
    old new  
    954954    int         cmdwin;     /* TRUE when working in the command-line window */
    955955    int         noexmode;   /* TRUE when return on entering Ex mode */
    956956{
    957     oparg_T     oa;     /* operator arguments */
     957    oparg_T     oa;                             /* operator arguments */
     958    int         previous_got_int = FALSE;       /* "got_int" was TRUE */
    958959
    959960#if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
    960961    /* Setup to catch a terminating error from the X server.  Just ignore
     
    10151016                need_fileinfo = FALSE;
    10161017            }
    10171018        }
    1018         if (got_int && !global_busy)
     1019
     1020        /* Reset "got_int" now that we got back to the main loop.  Except when
     1021         * inside a ":g/pat/cmd" command, then the "got_int" needs to abort
     1022         * the ":g" command.
     1023         * For ":g/pat/vi" we reset "got_int" when used once.  When used
     1024         * a second time we go back to Ex mode and abort the ":g" command. */
     1025        if (got_int)
    10191026        {
    1020             if (!quit_more)
    1021                 (void)vgetc();          /* flush all buffers */
    1022             got_int = FALSE;
     1027            if (noexmode && global_busy && !exmode_active && previous_got_int)
     1028            {
     1029                /* Typed two CTRL-C in a row: go back to ex mode as if "Q" was
     1030                 * used and keep "got_int" set, so that it aborts ":g". */
     1031                exmode_active = EXMODE_NORMAL;
     1032                State = NORMAL;
     1033            }
     1034            else if (!global_busy || !exmode_active)
     1035            {
     1036                if (!quit_more)
     1037                    (void)vgetc();              /* flush all buffers */
     1038                got_int = FALSE;
     1039            }
     1040            previous_got_int = TRUE;
    10231041        }
     1042        else
     1043            previous_got_int = FALSE;
     1044
    10241045        if (!exmode_active)
    10251046            msg_scroll = FALSE;
    10261047        quit_more = FALSE;
     
    13091330#ifdef FEAT_NETBEANS_INTG
    13101331    netbeans_end();
    13111332#endif
     1333#ifdef FEAT_CSCOPE
     1334    cs_end();
     1335#endif
     1336#ifdef FEAT_EVAL
     1337    if (garbage_collect_at_exit)
     1338        garbage_collect();
     1339#endif
    13121340
    13131341    mch_exit(exitval);
    13141342}
     
    13601388        p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
    13611389        if (p != NULL && *p != NUL)
    13621390        {
    1363             STRCPY(NameBuff, p);
    1364             STRCAT(NameBuff, "/lang");
     1391            vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p);
    13651392            bindtextdomain(VIMPACKAGE, (char *)NameBuff);
    13661393        }
    13671394        if (mustfree)
     
    36323659        mainerr_arg_missing((char_u *)filev[-1]);
    36333660    if (mch_dirname(cwd, MAXPATHL) != OK)
    36343661        return NULL;
    3635     if ((p = vim_strsave_escaped_ext(cwd, PATH_ESC_CHARS, '\\', TRUE)) == NULL)
     3662    if ((p = vim_strsave_escaped_ext(cwd,
     3663#ifdef BACKSLASH_IN_FILENAME
     3664                    "",  /* rem_backslash() will tell what chars to escape */
     3665#else
     3666                    PATH_ESC_CHARS,
     3667#endif
     3668                    '\\', TRUE)) == NULL)
    36363669        return NULL;
    36373670    ga_init2(&ga, 1, 100);
    36383671    ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd ");
  • src/mbyte.c

    diff -Naur vim71.orig/src/mbyte.c vim71/src/mbyte.c
    old new  
    13101310/*
    13111311 * mb_off2cells() function pointer.
    13121312 * Return number of display cells for char at ScreenLines[off].
    1313  * Caller must make sure "off" and "off + 1" are valid!
     1313 * We make sure that the offset used is less than "max_off".
    13141314 */
    13151315/*ARGSUSED*/
    13161316    int
    1317 latin_off2cells(off)
     1317latin_off2cells(off, max_off)
    13181318    unsigned    off;
     1319    unsigned    max_off;
    13191320{
    13201321    return 1;
    13211322}
    13221323
    13231324    int
    1324 dbcs_off2cells(off)
     1325dbcs_off2cells(off, max_off)
    13251326    unsigned    off;
     1327    unsigned    max_off;
    13261328{
     1329    /* never check beyond end of the line */
     1330    if (off >= max_off)
     1331        return 1;
     1332
    13271333    /* Number of cells is equal to number of bytes, except for euc-jp when
    13281334     * the first byte is 0x8e. */
    13291335    if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
     
    13321338}
    13331339
    13341340    int
    1335 utf_off2cells(off)
     1341utf_off2cells(off, max_off)
    13361342    unsigned    off;
     1343    unsigned    max_off;
    13371344{
    1338     return ScreenLines[off + 1] == 0 ? 2 : 1;
     1345    return (off + 1 < max_off && ScreenLines[off + 1] == 0) ? 2 : 1;
    13391346}
    13401347
    13411348/*
     
    23202327                /* Single byte: first check normally, then with ignore case. */
    23212328                if (s1[i] != s2[i])
    23222329                {
    2323                     cdiff = TOLOWER_LOC(s1[i]) - TOLOWER_LOC(s2[i]);
     2330                    cdiff = MB_TOLOWER(s1[i]) - MB_TOLOWER(s2[i]);
    23242331                    if (cdiff != 0)
    23252332                        return cdiff;
    23262333                }
     
    28992906    if (composing_hangul)
    29002907        return TRUE;
    29012908#endif
    2902     if (enc_dbcs != 0)
    2903         return dbcs_off2cells(LineOffset[row] + col) > 1;
    2904     if (enc_utf8)
    2905         return (col + 1 < Columns
    2906                 && ScreenLines[LineOffset[row] + col + 1] == 0);
    2907     return FALSE;
     2909    return (*mb_off2cells)(LineOffset[row] + col,
     2910                                        LineOffset[row] + screen_Columns) > 1;
    29082911}
    29092912
    29102913# if defined(FEAT_CLIPBOARD) || defined(FEAT_GUI) || defined(FEAT_RIGHTLEFT) \
  • src/message.c

    diff -Naur vim71.orig/src/message.c vim71/src/message.c
    old new  
    828828                _("Messages maintainer: Bram Moolenaar <Bram@vim.org>"),
    829829                hl_attr(HLF_T));
    830830
    831     for (p = first_msg_hist; p != NULL; p = p->next)
     831    for (p = first_msg_hist; p != NULL && !got_int; p = p->next)
    832832        if (p->msg != NULL)
    833833            msg_attr(p->msg, p->attr);
    834834
     
    944944                c = K_IGNORE;
    945945            }
    946946#endif
     947
    947948            /*
    948949             * Allow scrolling back in the messages.
    949950             * Also accept scroll-down commands when messages fill the screen,
     
    18401841    char_u      *sb_str = str;
    18411842    int         sb_col = msg_col;
    18421843    int         wrap;
     1844    int         did_last_char;
    18431845
    18441846    did_wait_return = FALSE;
    1845     while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
     1847    while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)
    18461848    {
    18471849        /*
    18481850         * We are at the end of the screen line when:
     
    18781880                /* output postponed text */
    18791881                t_puts(&t_col, t_s, s, attr);
    18801882
    1881             /* When no more prompt an no more room, truncate here */
     1883            /* When no more prompt and no more room, truncate here */
    18821884            if (msg_no_more && lines_left == 0)
    18831885                break;
    18841886
     
    19091911                else
    19101912#endif
    19111913                    msg_screen_putchar(*s++, attr);
     1914                did_last_char = TRUE;
    19121915            }
     1916            else
     1917                did_last_char = FALSE;
    19131918
    19141919            if (p_more)
    19151920                /* store text for scrolling back */
     
    19271932             * If screen is completely filled and 'more' is set then wait
    19281933             * for a character.
    19291934             */
    1930             --lines_left;
     1935            if (lines_left > 0)
     1936                --lines_left;
    19311937            if (p_more && lines_left == 0 && State != HITRETURN
    19321938                                            && !msg_no_more && !exmode_active)
    19331939            {
     
    19431949
    19441950            /* When we displayed a char in last column need to check if there
    19451951             * is still more. */
    1946             if (*s >= ' '
    1947 #ifdef FEAT_RIGHTLEFT
    1948                     && !cmdmsg_rl
    1949 #endif
    1950                )
     1952            if (did_last_char)
    19511953                continue;
    19521954        }
    19531955
     
    22342236{
    22352237    msgchunk_T  *mp;
    22362238
    2237     /* Only show somethign if there is more than one line, otherwise it looks
     2239    /* Only show something if there is more than one line, otherwise it looks
    22382240     * weird, typing a command without output results in one line. */
    22392241    mp = msg_sb_start(last_msgchunk);
    22402242    if (mp == NULL || mp->sb_prev == NULL)
     
    26222624                }
    26232625            }
    26242626
    2625             if (scroll < 0 || (scroll == 0 && mp_last != NULL))
     2627            if (scroll <= 0)
    26262628            {
    26272629                /* displayed the requested text, more prompt again */
    26282630                screen_fill((int)Rows - 1, (int)Rows, 0,
     
    34563458                    /* advance to next hotkey and set default hotkey */
    34573459#ifdef FEAT_MBYTE
    34583460                    if (has_mbyte)
    3459                         hotkp += (*mb_ptr2len)(hotkp);
     3461                        hotkp += STRLEN(hotkp);
    34603462                    else
    34613463#endif
    34623464                        ++hotkp;
    3463                     (void)copy_char(r + 1, hotkp, TRUE);
     3465                    hotkp[copy_char(r + 1, hotkp, TRUE)] = NUL;
    34643466                    if (dfltbutton)
    34653467                        --dfltbutton;
    34663468
     
    34933495                        *msgp++ = (dfltbutton == 1) ? ']' : ')';
    34943496
    34953497                        /* redefine hotkey */
    3496                         (void)copy_char(r, hotkp, TRUE);
     3498                        hotkp[copy_char(r, hotkp, TRUE)] = NUL;
    34973499                    }
    34983500                }
    34993501                else
     
    35193521            *msgp++ = ':';
    35203522            *msgp++ = ' ';
    35213523            *msgp = NUL;
    3522             mb_ptr_adv(hotkp);
    3523             *hotkp = NUL;
    35243524        }
    35253525        else
    35263526        {
     
    35553555            msgp = confirm_msg + 1 + STRLEN(message);
    35563556            hotkp = hotk;
    35573557
    3558             /* define first default hotkey */
    3559             (void)copy_char(buttons, hotkp, TRUE);
     3558            /* Define first default hotkey.  Keep the hotkey string NUL
     3559             * terminated to avoid reading past the end. */
     3560            hotkp[copy_char(buttons, hotkp, TRUE)] = NUL;
    35603561
    35613562            /* Remember where the choices start, displaying starts here when
    35623563             * "hotkp" typed at the more prompt. */
  • src/misc1.c

    diff -Naur vim71.orig/src/misc1.c vim71/src/misc1.c
    old new  
    9090 */
    9191    int
    9292set_indent(size, flags)
    93     int         size;
     93    int         size;               /* measured in spaces */
    9494    int         flags;
    9595{
    9696    char_u      *p;
     
    9898    char_u      *oldline;
    9999    char_u      *s;
    100100    int         todo;
    101     int         ind_len;
     101    int         ind_len;            /* measured in characters */
    102102    int         line_len;
    103103    int         doit = FALSE;
    104     int         ind_done;
     104    int         ind_done = 0;       /* measured in spaces */
    105105    int         tab_pad;
    106106    int         retval = FALSE;
     107    int         orig_char_len = -1; /* number of initial whitespace chars when
     108                                       'et' and 'pi' are both set */
    107109
    108110    /*
    109111     * First check if there is anything to do and compute the number of
     
    116118    /* Calculate the buffer size for the new indent, and check to see if it
    117119     * isn't already set */
    118120
    119     /* if 'expandtab' isn't set: use TABs */
    120     if (!curbuf->b_p_et)
     121    /* if 'expandtab' isn't set: use TABs; if both 'expandtab' and
     122     * 'preserveindent' are set count the number of characters at the
     123     * beginning of the line to be copied */
     124    if (!curbuf->b_p_et || (!(flags & SIN_INSERT) && curbuf->b_p_pi))
    121125    {
    122126        /* If 'preserveindent' is set then reuse as much as possible of
    123127         * the existing indent structure for the new indent */
     
    148152                ++p;
    149153            }
    150154
     155            /* Set initial number of whitespace chars to copy if we are
     156             * preserving indent but expandtab is set */
     157            if (curbuf->b_p_et)
     158                orig_char_len = ind_len;
     159
    151160            /* Fill to next tabstop with a tab, if possible */
    152161            tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
    153             if (todo >= tab_pad)
     162            if (todo >= tab_pad && orig_char_len == -1)
    154163            {
    155164                doit = TRUE;
    156165                todo -= tab_pad;
     
    193202    else
    194203        p = skipwhite(p);
    195204    line_len = (int)STRLEN(p) + 1;
    196     newline = alloc(ind_len + line_len);
    197     if (newline == NULL)
    198         return FALSE;
     205
     206    /* If 'preserveindent' and 'expandtab' are both set keep the original
     207     * characters and allocate accordingly.  We will fill the rest with spaces
     208     * after the if (!curbuf->b_p_et) below. */
     209    if (orig_char_len != -1)
     210    {
     211        newline = alloc(orig_char_len + size - ind_done + line_len);
     212        if (newline == NULL)
     213            return FALSE;
     214        todo = size - ind_done;
     215        ind_len = orig_char_len + todo;    /* Set total length of indent in
     216                                            * characters, which may have been
     217                                            * undercounted until now  */
     218        p = oldline;
     219        s = newline;
     220        while (orig_char_len > 0)
     221        {
     222            *s++ = *p++;
     223            orig_char_len--;
     224        }
     225        /* Skip over any additional white space (useful when newindent is less
     226         * than old) */
     227        while (vim_iswhite(*p))
     228            (void)*p++;
     229
     230    }
     231    else
     232    {
     233        todo = size;
     234        newline = alloc(ind_len + line_len);
     235        if (newline == NULL)
     236            return FALSE;
     237        s = newline;
     238    }
    199239
    200240    /* Put the characters in the new line. */
    201     s = newline;
    202     todo = size;
    203241    /* if 'expandtab' isn't set: use TABs */
    204242    if (!curbuf->b_p_et)
    205243    {
     
    13201358            newindent += (int)curbuf->b_p_sw;
    13211359        }
    13221360#endif
    1323         /* Copy the indent only if expand tab is disabled */
    1324         if (curbuf->b_p_ci && !curbuf->b_p_et)
     1361        /* Copy the indent */
     1362        if (curbuf->b_p_ci)
    13251363        {
    13261364            (void)copy_indent(newindent, saved_line);
    13271365
     
    34683506#endif
    34693507
    34703508/*
     3509 * Call expand_env() and store the result in an allocated string.
     3510 * This is not very memory efficient, this expects the result to be freed
     3511 * again soon.
     3512 */
     3513    char_u *
     3514expand_env_save(src)
     3515    char_u      *src;
     3516{
     3517    return expand_env_save_opt(src, FALSE);
     3518}
     3519
     3520/*
     3521 * Idem, but when "one" is TRUE handle the string as one file name, only
     3522 * expand "~" at the start.
     3523 */
     3524    char_u *
     3525expand_env_save_opt(src, one)
     3526    char_u      *src;
     3527    int         one;
     3528{
     3529    char_u      *p;
     3530
     3531    p = alloc(MAXPATHL);
     3532    if (p != NULL)
     3533        expand_env_esc(src, p, MAXPATHL, FALSE, one, NULL);
     3534    return p;
     3535}
     3536
     3537/*
    34713538 * Expand environment variable with path name.
    34723539 * "~/" is also expanded, using $HOME.  For Unix "~user/" is expanded.
    3473  * Skips over "\ ", "\~" and "\$".
     3540 * Skips over "\ ", "\~" and "\$" (not for Win32 though).
    34743541 * If anything fails no expansion is done and dst equals src.
    34753542 */
    34763543    void
     
    34793546    char_u      *dst;           /* where to put the result */
    34803547    int         dstlen;         /* maximum length of the result */
    34813548{
    3482     expand_env_esc(src, dst, dstlen, FALSE, NULL);
     3549    expand_env_esc(src, dst, dstlen, FALSE, FALSE, NULL);
    34833550}
    34843551
    34853552    void
    3486 expand_env_esc(srcp, dst, dstlen, esc, startstr)
     3553expand_env_esc(srcp, dst, dstlen, esc, one, startstr)
    34873554    char_u      *srcp;          /* input string e.g. "$HOME/vim.hlp" */
    34883555    char_u      *dst;           /* where to put the result */
    34893556    int         dstlen;         /* maximum length of the result */
    34903557    int         esc;            /* escape spaces in expanded variables */
     3558    int         one;            /* "srcp" is one file name */
    34913559    char_u      *startstr;      /* start again after this (can be NULL) */
    34923560{
    34933561    char_u      *src;
     
    37283796        {
    37293797            /*
    37303798             * Recognize the start of a new name, for '~'.
     3799             * Don't do this when "one" is TRUE, to avoid expanding "~" in
     3800             * ":edit foo ~ foo".
    37313801             */
    37323802            at_start = FALSE;
    37333803            if (src[0] == '\\' && src[1] != NUL)
     
    37353805                *dst++ = *src++;
    37363806                --dstlen;
    37373807            }
    3738             else if (src[0] == ' ' || src[0] == ',')
     3808            else if ((src[0] == ' ' || src[0] == ',') && !one)
    37393809                at_start = TRUE;
    37403810            *dst++ = *src++;
    37413811            --dstlen;
     
    40324102}
    40334103
    40344104/*
    4035  * Call expand_env() and store the result in an allocated string.
    4036  * This is not very memory efficient, this expects the result to be freed
    4037  * again soon.
    4038  */
    4039     char_u *
    4040 expand_env_save(src)
    4041     char_u      *src;
    4042 {
    4043     char_u      *p;
    4044 
    4045     p = alloc(MAXPATHL);
    4046     if (p != NULL)
    4047         expand_env(src, p, MAXPATHL);
    4048     return p;
    4049 }
    4050 
    4051 /*
    40524105 * Our portable version of setenv.
    40534106 */
    40544107    void
     
    47864839static int      cin_iswhileofdo __ARGS((char_u *, linenr_T, int));
    47874840static int      cin_iswhileofdo_end __ARGS((int terminated, int ind_maxparen, int ind_maxcomment));
    47884841static int      cin_isbreak __ARGS((char_u *));
    4789 static int      cin_is_cpp_baseclass __ARGS((char_u *line, colnr_T *col));
     4842static int      cin_is_cpp_baseclass __ARGS((colnr_T *col));
    47904843static int      get_baseclass_amount __ARGS((int col, int ind_maxparen, int ind_maxcomment, int ind_cpp_baseclass));
    47914844static int      cin_ends_in __ARGS((char_u *, char_u *, char_u *));
    47924845static int      cin_skip2pos __ARGS((pos_T *trypos));
     
    55515604 * This is a lot of guessing.  Watch out for "cond ? func() : foo".
    55525605 */
    55535606    static int
    5554 cin_is_cpp_baseclass(line, col)
    5555     char_u      *line;
     5607cin_is_cpp_baseclass(col)
    55565608    colnr_T     *col;       /* return: column to align with */
    55575609{
    55585610    char_u      *s;
    55595611    int         class_or_struct, lookfor_ctor_init, cpp_base_class;
    55605612    linenr_T    lnum = curwin->w_cursor.lnum;
     5613    char_u      *line = ml_get_curline();
    55615614
    55625615    *col = 0;
    55635616
     
    55855638     */
    55865639    while (lnum > 1)
    55875640    {
    5588         s = skipwhite(ml_get(lnum - 1));
     5641        line = ml_get(lnum - 1);
     5642        s = skipwhite(line);
    55895643        if (*s == '#' || *s == NUL)
    55905644            break;
    55915645        while (*s != NUL)
     
    56025656        --lnum;
    56035657    }
    56045658
    5605     s = cin_skipcomment(ml_get(lnum));
     5659    line = ml_get(lnum);
     5660    s = cin_skipcomment(line);
    56065661    for (;;)
    56075662    {
    56085663        if (*s == NUL)
     
    56105665            if (lnum == curwin->w_cursor.lnum)
    56115666                break;
    56125667            /* Continue in the cursor line. */
    5613             s = cin_skipcomment(ml_get(++lnum));
     5668            line = ml_get(++lnum);
     5669            s = cin_skipcomment(line);
     5670            if (*s == NUL)
     5671                continue;
    56145672        }
    56155673
    56165674        if (s[0] == ':')
     
    70797137                n = FALSE;
    70807138                if (lookfor != LOOKFOR_TERM && ind_cpp_baseclass > 0)
    70817139                {
    7082                     n = cin_is_cpp_baseclass(l, &col);
     7140                    n = cin_is_cpp_baseclass(&col);
    70837141                    l = ml_get_curline();
    70847142                }
    70857143                if (n)
     
    76707728                n = FALSE;
    76717729                if (ind_cpp_baseclass != 0 && theline[0] != '{')
    76727730                {
    7673                     n = cin_is_cpp_baseclass(l, &col);
     7731                    n = cin_is_cpp_baseclass(&col);
    76747732                    l = ml_get_curline();
    76757733                }
    76767734                if (n)
     
    85968654    for (p = buf + wildoff; p < s; ++p)
    85978655        if (rem_backslash(p))
    85988656        {
    8599             STRCPY(p, p + 1);
     8657            mch_memmove(p, p + 1, STRLEN(p));
    86008658            --e;
    86018659            --s;
    86028660        }
     
    88978955    for (p = buf + wildoff; p < s; ++p)
    88988956        if (rem_backslash(p))
    88998957        {
    8900             STRCPY(p, p + 1);
     8958            mch_memmove(p, p + 1, STRLEN(p));
    89018959            --e;
    89028960            --s;
    89038961        }
     
    90969154             */
    90979155            if (vim_strpbrk(p, (char_u *)"$~") != NULL)
    90989156            {
    9099                 p = expand_env_save(p);
     9157                p = expand_env_save_opt(p, TRUE);
    91009158                if (p == NULL)
    91019159                    p = pat[i];
    91029160#ifdef UNIX
  • src/misc2.c

    diff -Naur vim71.orig/src/misc2.c vim71/src/misc2.c
    old new  
    972972        return;
    973973    entered = TRUE;
    974974
    975     ++autocmd_block;        /* don't want to trigger autocommands here */
     975    block_autocmds();       /* don't want to trigger autocommands here */
    976976
    977977#ifdef FEAT_WINDOWS
    978978    /* close all tabs and windows */
     
    10371037
    10381038    /* Free some global vars. */
    10391039    vim_free(username);
     1040# ifdef FEAT_CLIPBOARD
    10401041    vim_free(clip_exclude_prog);
     1042# endif
    10411043    vim_free(last_cmdline);
    10421044    vim_free(new_last_cmdline);
    10431045    set_keep_msg(NULL, 0);
  • src/normal.c

    diff -Naur vim71.orig/src/normal.c vim71/src/normal.c
    old new  
    690690                ca.count0 = ca.count0 * 10 + (c - '0');
    691691            if (ca.count0 < 0)      /* got too large! */
    692692                ca.count0 = 999999999L;
     693#ifdef FEAT_EVAL
     694            /* Set v:count here, when called from main() and not a stuffed
     695             * command, so that v:count can be used in an expression mapping
     696             * right after the count. */
     697            if (toplevel && stuff_empty())
     698                set_vcount(ca.count0, ca.count0 == 0 ? 1 : ca.count0);
     699#endif
    693700            if (ctrl_w)
    694701            {
    695702                ++no_mapping;
    696703                ++allow_keys;           /* no mapping for nchar, but keys */
    697704            }
    698705            ++no_zero_mapping;          /* don't map zero here */
    699             c = safe_vgetc();
     706            c = plain_vgetc();
    700707#ifdef FEAT_LANGMAP
    701708            LANGMAP_ADJUST(c, TRUE);
    702709#endif
     
    721728            ca.count0 = 0;
    722729            ++no_mapping;
    723730            ++allow_keys;               /* no mapping for nchar, but keys */
    724             c = safe_vgetc();           /* get next character */
     731            c = plain_vgetc();          /* get next character */
    725732#ifdef FEAT_LANGMAP
    726733            LANGMAP_ADJUST(c, TRUE);
    727734#endif
     
    889896
    890897        ++no_mapping;
    891898        ++allow_keys;           /* no mapping for nchar, but allow key codes */
     899#ifdef FEAT_AUTOCMD
     900        /* Don't generate a CursorHold event here, most commands can't handle
     901         * it, e.g., nv_replace(), nv_csearch(). */
     902        did_cursorhold = TRUE;
     903#endif
    892904        if (ca.cmdchar == 'g')
    893905        {
    894906            /*
    895907             * For 'g' get the next character now, so that we can check for
    896908             * "gr", "g'" and "g`".
    897909             */
    898             ca.nchar = safe_vgetc();
     910            ca.nchar = plain_vgetc();
    899911#ifdef FEAT_LANGMAP
    900912            LANGMAP_ADJUST(ca.nchar, TRUE);
    901913#endif
     
    952964                im_set_active(TRUE);
    953965#endif
    954966
    955             *cp = safe_vgetc();
     967            *cp = plain_vgetc();
    956968
    957969            if (langmap_active)
    958970            {
     
    10401052                }
    10411053                if (c > 0)
    10421054                {
    1043                     c = safe_vgetc();
     1055                    c = plain_vgetc();
    10441056                    if (c != Ctrl_N && c != Ctrl_G)
    10451057                        vungetc(c);
    10461058                    else
     
    10591071            while (enc_utf8 && lang && (c = vpeekc()) > 0
    10601072                                 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1))
    10611073            {
    1062                 c = safe_vgetc();
     1074                c = plain_vgetc();
    10631075                if (!utf_iscomposing(c))
    10641076                {
    10651077                    vungetc(c);         /* it wasn't, put it back */
     
    37553767    extra_len = (int)STRLEN(p);
    37563768    overflow = old_len + extra_len - SHOWCMD_COLS;
    37573769    if (overflow > 0)
    3758         STRCPY(showcmd_buf, showcmd_buf + overflow);
     3770        mch_memmove(showcmd_buf, showcmd_buf + overflow,
     3771                                                      old_len - overflow + 1);
    37593772    STRCAT(showcmd_buf, p);
    37603773
    37613774    if (char_avail())
     
    45584571#endif
    45594572            ++no_mapping;
    45604573            ++allow_keys;   /* no mapping for nchar, but allow key codes */
    4561             nchar = safe_vgetc();
     4574            nchar = plain_vgetc();
    45624575#ifdef FEAT_LANGMAP
    45634576            LANGMAP_ADJUST(nchar, TRUE);
    45644577#endif
     
    49164929    case 'u':   /* "zug" and "zuw": undo "zg" and "zw" */
    49174930                ++no_mapping;
    49184931                ++allow_keys;   /* no mapping for nchar, but allow key codes */
    4919                 nchar = safe_vgetc();
     4932                nchar = plain_vgetc();
    49204933#ifdef FEAT_LANGMAP
    49214934                LANGMAP_ADJUST(nchar, TRUE);
    49224935#endif
     
    63796392     */
    63806393    else if (cap->nchar == 'p' || cap->nchar == 'P')
    63816394    {
    6382         if (!checkclearopq(cap->oap))
     6395        if (!checkclearop(cap->oap))
    63836396        {
    63846397            prep_redo_cmd(cap);
    63856398            do_put(cap->oap->regname,
     
    66626675    else
    66636676        had_ctrl_v = NUL;
    66646677
     6678    /* Abort if the character is a special key. */
     6679    if (IS_SPECIAL(cap->nchar))
     6680    {
     6681        clearopbeep(cap->oap);
     6682        return;
     6683    }
     6684
    66656685#ifdef FEAT_VISUAL
    66666686    /* Visual mode "r" */
    66676687    if (VIsual_active)
     
    66886708    }
    66896709#endif
    66906710
    6691     /*
    6692      * Check for a special key or not enough characters to replace.
    6693      */
     6711    /* Abort if not enough characters to replace. */
    66946712    ptr = ml_get_cursor();
    6695     if (IS_SPECIAL(cap->nchar) || STRLEN(ptr) < (unsigned)cap->count1
     6713    if (STRLEN(ptr) < (unsigned)cap->count1
    66966714#ifdef FEAT_MBYTE
    66976715            || (has_mbyte && mb_charlen(ptr) < cap->count1)
    66986716#endif
     
    83538371        n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP);
    83548372
    83558373    /* Don't leave the cursor on the NUL past a line */
    8356     if (curwin->w_cursor.col && gchar_cursor() == NUL)
     8374    if (n != FAIL && curwin->w_cursor.col > 0 && gchar_cursor() == NUL)
    83578375    {
    83588376        --curwin->w_cursor.col;
    83598377        cap->oap->inclusive = TRUE;
  • src/ops.c

    diff -Naur vim71.orig/src/ops.c vim71/src/ops.c
    old new  
    24772477
    24782478        /*
    24792479         * Spaces and tabs in the indent may have changed to other spaces and
    2480          * tabs.  Get the starting column again and correct the lenght.
     2480         * tabs.  Get the starting column again and correct the length.
    24812481         * Don't do this when "$" used, end-of-line will have changed.
    24822482         */
    24832483        block_prep(oap, &bd2, oap->start.lnum, TRUE);
     
    25342534#ifdef FEAT_VISUALEXTRA
    25352535    long                offset;
    25362536    linenr_T            linenr;
    2537     long                ins_len, pre_textlen = 0;
     2537    long                ins_len;
     2538    long                pre_textlen = 0;
     2539    long                pre_indent = 0;
    25382540    char_u              *firstline;
    25392541    char_u              *ins_text, *newp, *oldp;
    25402542    struct block_def    bd;
     
    25792581                                                    || gchar_cursor() == NUL))
    25802582            coladvance_force(getviscol());
    25812583# endif
    2582         pre_textlen = (long)STRLEN(ml_get(oap->start.lnum));
     2584        firstline = ml_get(oap->start.lnum);
     2585        pre_textlen = (long)STRLEN(firstline);
     2586        pre_indent = (long)(skipwhite(firstline) - firstline);
    25832587        bd.textcol = curwin->w_cursor.col;
    25842588    }
    25852589#endif
     
    25982602     */
    25992603    if (oap->block_mode && oap->start.lnum != oap->end.lnum)
    26002604    {
     2605        /* Auto-indenting may have changed the indent.  If the cursor was past
     2606         * the indent, exclude that indent change from the inserted text. */
    26012607        firstline = ml_get(oap->start.lnum);
    2602         /*
    2603          * Subsequent calls to ml_get() flush the firstline data - take a
    2604          * copy of the required bit.
    2605          */
    2606         if ((ins_len = (long)STRLEN(firstline) - pre_textlen) > 0)
     2608        if (bd.textcol > (colnr_T)pre_indent)
     2609        {
     2610            long new_indent = (long)(skipwhite(firstline) - firstline);
     2611
     2612            pre_textlen += new_indent - pre_indent;
     2613            bd.textcol += new_indent - pre_indent;
     2614        }
     2615
     2616        ins_len = (long)STRLEN(firstline) - pre_textlen;
     2617        if (ins_len > 0)
    26072618        {
     2619            /* Subsequent calls to ml_get() flush the firstline data - take a
     2620             * copy of the inserted text.  */
    26082621            if ((ins_text = alloc_check((unsigned)(ins_len + 1))) != NULL)
    26092622            {
    26102623                vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len);
     
    34043417
    34053418#ifdef FEAT_VIRTUALEDIT
    34063419        col += curwin->w_cursor.coladd;
    3407         if (ve_flags == VE_ALL && curwin->w_cursor.coladd > 0)
     3420        if (ve_flags == VE_ALL
     3421                && (curwin->w_cursor.coladd > 0
     3422                    || endcol2 == curwin->w_cursor.col))
    34083423        {
    34093424            if (dir == FORWARD && c == NUL)
    34103425                ++col;
  • src/option.c

    diff -Naur vim71.orig/src/option.c vim71/src/option.c
    old new  
    427427#define P_NOGLOB       0x100000L/* do not use local value for global vimrc */
    428428#define P_NFNAME       0x200000L/* only normal file name chars allowed */
    429429#define P_INSECURE     0x400000L/* option was set from a modeline */
     430#define P_PRI_MKRC     0x800000L/* priority for :mkvimrc (setting option has
     431                                   side effects) */
    430432
    431433#define ISK_LATIN1  (char_u *)"@,48-57,_,192-255"
    432434
     
    773775                            {(char_u *)0L, (char_u *)0L}
    774776#endif
    775777                            },
     778                            /* P_PRI_MKRC isn't needed here, optval_default()
     779                             * always returns TRUE for 'compatible' */
    776780    {"compatible",  "cp",   P_BOOL|P_RALL,
    777781                            (char_u *)&p_cp, PV_NONE,
    778782                            {(char_u *)TRUE, (char_u *)FALSE}},
     
    15151519                            {(char_u *)0L, (char_u *)0L}
    15161520#endif
    15171521                            },
    1518     {"keymap",      "kmp",  P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME,
     1522    {"keymap",      "kmp",  P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
    15191523#ifdef FEAT_KEYMAP
    15201524                            (char_u *)&p_keymap, PV_KMAP,
    15211525                            {(char_u *)"", (char_u *)0L}
     
    18361840    {"paragraphs",  "para", P_STRING|P_VI_DEF,
    18371841                            (char_u *)&p_para, PV_NONE,
    18381842                            {(char_u *)"IPLPPPQPP LIpplpipbp", (char_u *)0L}},
    1839     {"paste",       NULL,   P_BOOL|P_VI_DEF,
     1843    {"paste",       NULL,   P_BOOL|P_VI_DEF|P_PRI_MKRC,
    18401844                            (char_u *)&p_paste, PV_NONE,
    18411845                            {(char_u *)FALSE, (char_u *)0L}},
    18421846    {"pastetoggle", "pt",   P_STRING|P_VI_DEF,
     
    46284632                                    if ((!(flags & P_COMMA) || *s != ',')
    46294633                                            && vim_strchr(s + 1, *s) != NULL)
    46304634                                    {
    4631                                         STRCPY(s, s + 1);
     4635                                        mch_memmove(s, s + 1, STRLEN(s));
    46324636                                        --s;
    46334637                                    }
    46344638                            }
     
    49924996     * For 'spellsuggest' expand after "file:".
    49934997     */
    49944998    expand_env_esc(val, NameBuff, MAXPATHL,
    4995             (char_u **)options[opt_idx].var == &p_tags,
     4999            (char_u **)options[opt_idx].var == &p_tags, FALSE,
    49965000#ifdef FEAT_SPELL
    49975001            (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
    49985002#endif
     
    63486352                errmsg = check_stl_option(p_ruf);
    63496353        }
    63506354        /* check 'statusline' only if it doesn't start with "%!" */
    6351         else if (varp != &p_stl || s[0] != '%' || s[1] != '!')
     6355        else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
    63526356            errmsg = check_stl_option(s);
    63536357        if (varp == &p_ruf && errmsg == NULL)
    63546358            comp_col();
     
    71187122    /* when 'endofline' is changed, redraw the window title */
    71197123    else if ((int *)varp == &curbuf->b_p_eol)
    71207124        need_maketitle = TRUE;
     7125#ifdef FEAT_MBYTE
     7126    /* when 'bomb' is changed, redraw the window title */
     7127    else if ((int *)varp == &curbuf->b_p_bomb)
     7128        need_maketitle = TRUE;
     7129#endif
    71217130#endif
    71227131
    71237132    /* when 'bin' is set also set some other options */
     
    78157824            errmsg = e_positive;
    78167825            p_ch = 1;
    78177826        }
     7827        if (p_ch > Rows - min_rows() + 1)
     7828            p_ch = Rows - min_rows() + 1;
    78187829
    78197830        /* Only compute the new window layout when startup has been
    78207831         * completed. Otherwise the frame sizes may be wrong. */
     
    82198230            varp = get_varp(&options[opt_idx]);
    82208231            if (varp != NULL)   /* hidden option is not changed */
    82218232            {
     8233                if (number == 0 && string != NULL)
     8234                {
     8235                    int index;
     8236
     8237                    /* Either we are given a string or we are setting option
     8238                     * to zero. */
     8239                    for (index = 0; string[index] == '0'; ++index)
     8240                        ;
     8241                    if (string[index] != NUL || index == 0)
     8242                    {
     8243                        /* There's another character after zeros or the string
     8244                         * is empty.  In both cases, we are trying to set a
     8245                         * num option using a string. */
     8246                        EMSG3(_("E521: Number required: &%s = '%s'"),
     8247                                                                name, string);
     8248                        return;     /* do nothing as we hit an error */
     8249
     8250                    }
     8251                }
    82228252                if (flags & P_NUM)
    82238253                    (void)set_num_option(opt_idx, varp, number,
    82248254                                                          NULL, 0, opt_flags);
     
    85118541    char_u              *varp_local = NULL;     /* fresh value */
    85128542    char                *cmd;
    85138543    int                 round;
     8544    int                 pri;
    85148545
    85158546    /*
    85168547     * The options that don't have a default (terminal name, columns, lines)
    85178548     * are never written.  Terminal options are also not written.
     8549     * Do the loop over "options[]" twice: once for options with the
     8550     * P_PRI_MKRC flag and once without.
    85188551     */
    8519     for (p = &options[0]; !istermoption(p); p++)
    8520         if (!(p->flags & P_NO_MKRC) && !istermoption(p))
     8552    for (pri = 1; pri >= 0; --pri)
     8553    {
     8554      for (p = &options[0]; !istermoption(p); p++)
     8555        if (!(p->flags & P_NO_MKRC)
     8556                && !istermoption(p)
     8557                && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
    85218558        {
    85228559            /* skip global option when only doing locals */
    85238560            if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
     
    86138650                }
    86148651            }
    86158652        }
     8653    }
    86168654    return OK;
    86178655}
    86188656
     
    87158753    char        *name;
    87168754    int         value;
    87178755{
     8756    if (value < 0)      /* global/local option using global value */
     8757        return OK;
    87188758    if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
    87198759            || put_eol(fd) < 0)
    87208760        return FAIL;
     
    1058510625    buf->b_start_ffc = *buf->b_p_ff;
    1058610626    buf->b_start_eol = buf->b_p_eol;
    1058710627#ifdef FEAT_MBYTE
     10628    buf->b_start_bomb = buf->b_p_bomb;
     10629
    1058810630    /* Only use free/alloc when necessary, they take time. */
    1058910631    if (buf->b_start_fenc == NULL
    1059010632                             || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
     
    1059810640/*
    1059910641 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
    1060010642 * from when editing started (save_file_ff() called).
    10601  * Also when 'endofline' was changed and 'binary' is set.
     10643 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
     10644 * changed and 'binary' is not set.
    1060210645 * Don't consider a new, empty buffer to be changed.
    1060310646 */
    1060410647    int
    1060510648file_ff_differs(buf)
    1060610649    buf_T       *buf;
    1060710650{
     10651    /* In a buffer that was never loaded the options are not valid. */
     10652    if (buf->b_flags & BF_NEVERLOADED)
     10653        return FALSE;
    1060810654    if ((buf->b_flags & BF_NEW)
    1060910655            && buf->b_ml.ml_line_count == 1
    1061010656            && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
     
    1061410660    if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
    1061510661        return TRUE;
    1061610662#ifdef FEAT_MBYTE
     10663    if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
     10664        return TRUE;
    1061710665    if (buf->b_start_fenc == NULL)
    1061810666        return (*buf->b_p_fenc != NUL);
    1061910667    return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
  • src/os_unix.c

    diff -Naur vim71.orig/src/os_unix.c vim71/src/os_unix.c
    old new  
    753753    if (signal_stack != NULL)
    754754    {
    755755# ifdef HAVE_SIGALTSTACK
    756 #  ifdef __APPLE__
     756#  if defined(__APPLE__) && (!defined(MAC_OS_X_VERSION_MAX_ALLOWED) \
     757                || MAC_OS_X_VERSION_MAX_ALLOWED <= 1040)
    757758        /* missing prototype.  Adding it to osdef?.h.in doesn't work, because
    758759         * "struct sigaltstack" needs to be declared. */
    759760        extern int sigaltstack __ARGS((const struct sigaltstack *ss, struct sigaltstack *oss));
     
    24992500    if (stat((char *)name, &statb))
    25002501#endif
    25012502        return -1;
     2503#ifdef __INTERIX
     2504    /* The top bit makes the value negative, which means the file doesn't
     2505     * exist.  Remove the bit, we don't use it. */
     2506    return statb.st_mode & ~S_ADDACE;
     2507#else
    25022508    return statb.st_mode;
     2509#endif
    25032510}
    25042511
    25052512/*
     
    56825689
    56835690/*
    56845691 * Closes connection to gpm
    5685  * returns non-zero if connection succesfully closed
     5692 * returns non-zero if connection successfully closed
    56865693 */
    56875694    static void
    56885695gpm_close()
  • src/os_unix.h

    diff -Naur vim71.orig/src/os_unix.h vim71/src/os_unix.h
    old new  
    508508#if !defined(S_ISFIFO) && defined(S_IFIFO)
    509509# define        S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
    510510#endif
     511#if !defined(S_ISCHR) && defined(S_IFCHR)
     512# define        S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
     513#endif
    511514
    512515/* Note: Some systems need both string.h and strings.h (Savage).  However,
    513516 * some systems can't handle both, only use string.h in that case. */
  • src/popupmnu.c

    diff -Naur vim71.orig/src/popupmnu.c vim71/src/popupmnu.c
    old new  
    7575
    7676    row = curwin->w_cline_row + W_WINROW(curwin);
    7777    height = curwin->w_cline_height;
    78     col = curwin->w_wcol + W_WINCOL(curwin) - curwin->w_leftcol;
    7978
    8079    if (firstwin->w_p_pvw)
    8180        top_clear = firstwin->w_height;
     
    167166    pum_base_width = max_width;
    168167    pum_kind_width = kind_width;
    169168
     169    /* Calculate column */
     170#ifdef FEAT_RIGHTLEFT
     171    if (curwin->w_p_rl)
     172        col = W_WINCOL(curwin) + W_WIDTH(curwin) - curwin->w_wcol -
     173                                                        curwin->w_leftcol - 1;
     174    else
     175#endif
     176        col = W_WINCOL(curwin) + curwin->w_wcol - curwin->w_leftcol;
     177
    170178    /* if there are more items than room we need a scrollbar */
    171179    if (pum_height < size)
    172180    {
     
    179187    if (def_width < max_width)
    180188        def_width = max_width;
    181189
    182     if (col < Columns - PUM_DEF_WIDTH || col < Columns - max_width)
     190    if (((col < Columns - PUM_DEF_WIDTH || col < Columns - max_width)
     191#ifdef FEAT_RIGHTLEFT
     192                && !curwin->w_p_rl)
     193            || (curwin->w_p_rl && (col > PUM_DEF_WIDTH || col > max_width)
     194#endif
     195       ))
    183196    {
    184197        /* align pum column with "col" */
    185198        pum_col = col;
    186         pum_width = Columns - pum_col - pum_scrollbar;
     199
     200#ifdef FEAT_RIGHTLEFT
     201        if (curwin->w_p_rl)
     202            pum_width = pum_col - pum_scrollbar + 1;
     203        else
     204#endif
     205            pum_width = Columns - pum_col - pum_scrollbar;
     206
    187207        if (pum_width > max_width + kind_width + extra_width + 1
    188208                                                 && pum_width > PUM_DEF_WIDTH)
    189209        {
     
    195215    else if (Columns < def_width)
    196216    {
    197217        /* not enough room, will use what we have */
    198         pum_col = 0;
     218#ifdef FEAT_RIGHTLEFT
     219        if (curwin->w_p_rl)
     220            pum_col = Columns - 1;
     221        else
     222#endif
     223            pum_col = 0;
    199224        pum_width = Columns - 1;
    200225    }
    201226    else
    202227    {
    203228        if (max_width > PUM_DEF_WIDTH)
    204229            max_width = PUM_DEF_WIDTH;  /* truncate */
    205         pum_col = Columns - max_width;
     230#ifdef FEAT_RIGHTLEFT
     231        if (curwin->w_p_rl)
     232            pum_col = max_width - 1;
     233        else
     234#endif
     235            pum_col = Columns - max_width;
    206236        pum_width = max_width - pum_scrollbar;
    207237    }
    208238
     
    255285        attr = (idx == pum_selected) ? attr_select : attr_norm;
    256286
    257287        /* prepend a space if there is room */
    258         if (pum_col > 0)
    259             screen_putchar(' ', row, pum_col - 1, attr);
     288#ifdef FEAT_RIGHTLEFT
     289        if (curwin->w_p_rl)
     290        {
     291            if (pum_col < W_WINCOL(curwin) + W_WIDTH(curwin) - 1)
     292                screen_putchar(' ', row, pum_col + 1, attr);
     293        }
     294        else
     295#endif
     296            if (pum_col > 0)
     297                screen_putchar(' ', row, pum_col - 1, attr);
    260298
    261299        /* Display each entry, use two spaces for a Tab.
    262300         * Do this 3 times: For the main text, kind and extra info */
     
    282320                    {
    283321                        /* Display the text that fits or comes before a Tab.
    284322                         * First convert it to printable characters. */
    285                         char_u *st;
    286                         int  saved = *p;
     323                        char_u  *st;
     324                        int     saved = *p;
    287325
    288326                        *p = NUL;
    289327                        st = transstr(s);
    290328                        *p = saved;
    291                         if (st != NULL)
     329#ifdef FEAT_RIGHTLEFT
     330                        if (curwin->w_p_rl)
    292331                        {
    293                             screen_puts_len(st, (int)STRLEN(st), row, col,
     332                            if (st != NULL)
     333                            {
     334                                char_u  *rt = reverse_text(st);
     335                                char_u  *rt_saved = rt;
     336                                int     len, j;
     337
     338                                if (rt != NULL)
     339                                {
     340                                    len = STRLEN(rt);
     341                                    if (len > pum_width)
     342                                    {
     343                                        for (j = pum_width; j < len; ++j)
     344                                            mb_ptr_adv(rt);
     345                                        len = pum_width;
     346                                    }
     347                                    screen_puts_len(rt, len, row,
     348                                                        col - len + 1, attr);
     349                                    vim_free(rt_saved);
     350                                }
     351                                vim_free(st);
     352                            }
     353                            col -= width;
     354                        }
     355                        else
     356#endif
     357                        {
     358                            if (st != NULL)
     359                            {
     360                                screen_puts_len(st, (int)STRLEN(st), row, col,
    294361                                                                        attr);
    295                             vim_free(st);
     362                                vim_free(st);
     363                            }
     364                            col += width;
    296365                        }
    297                         col += width;
    298366
    299367                        if (*p != TAB)
    300368                            break;
    301369
    302370                        /* Display two spaces for a Tab. */
    303                         screen_puts_len((char_u *)"  ", 2, row, col, attr);
    304                         col += 2;
     371#ifdef FEAT_RIGHTLEFT
     372                        if (curwin->w_p_rl)
     373                        {
     374                            screen_puts_len((char_u *)"  ", 2, row, col - 1,
     375                                                                        attr);
     376                            col -= 2;
     377                        }
     378                        else
     379#endif
     380                        {
     381                            screen_puts_len((char_u *)"  ", 2, row, col, attr);
     382                            col += 2;
     383                        }
    305384                        totwidth += 2;
    306385                        s = NULL;           /* start text at next char */
    307386                        width = 0;
     
    322401                                          && pum_array[idx].pum_extra == NULL)
    323402                    || pum_base_width + n >= pum_width)
    324403                break;
    325             screen_fill(row, row + 1, col, pum_col + pum_base_width + n,
     404#ifdef FEAT_RIGHTLEFT
     405            if (curwin->w_p_rl)
     406            {
     407                screen_fill(row, row + 1, pum_col - pum_base_width - n + 1,
     408                                                    col + 1, ' ', ' ', attr);
     409                col = pum_col - pum_base_width - n + 1;
     410            }
     411            else
     412#endif
     413            {
     414                screen_fill(row, row + 1, col, pum_col + pum_base_width + n,
    326415                                                              ' ', ' ', attr);
    327             col = pum_col + pum_base_width + n;
     416                col = pum_col + pum_base_width + n;
     417            }
    328418            totwidth = pum_base_width + n;
    329419        }
    330420
    331         screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ', attr);
     421#ifdef FEAT_RIGHTLEFT
     422        if (curwin->w_p_rl)
     423            screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ',
     424                                                                    ' ', attr);
     425        else
     426#endif
     427            screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ',
     428                                                                        attr);
    332429        if (pum_scrollbar > 0)
    333             screen_putchar(' ', row, pum_col + pum_width,
    334                     i >= thumb_pos && i < thumb_pos + thumb_heigth
     430        {
     431#ifdef FEAT_RIGHTLEFT
     432            if (curwin->w_p_rl)
     433                screen_putchar(' ', row, pum_col - pum_width,
     434                        i >= thumb_pos && i < thumb_pos + thumb_heigth
    335435                                                  ? attr_thumb : attr_scroll);
     436            else
     437#endif
     438                screen_putchar(' ', row, pum_col + pum_width,
     439                        i >= thumb_pos && i < thumb_pos + thumb_heigth
     440                                                  ? attr_thumb : attr_scroll);
     441        }
    336442
    337443        ++row;
    338444    }
     
    466572                        set_option_value((char_u *)"bh", 0L,
    467573                                                 (char_u *)"wipe", OPT_LOCAL);
    468574                        set_option_value((char_u *)"diff", 0L,
    469                                                      (char_u *)"", OPT_LOCAL);
     575                                                             NULL, OPT_LOCAL);
    470576                    }
    471577                }
    472578                if (res == OK)
  • src/proto/charset.pro

    diff -Naur vim71.orig/src/proto/charset.pro vim71/src/proto/charset.pro
    old new  
    2121int vim_iswordp __ARGS((char_u *p));
    2222int vim_iswordc_buf __ARGS((char_u *p, buf_T *buf));
    2323int vim_isfilec __ARGS((int c));
     24int vim_isfilec_or_wc __ARGS((int c));
    2425int vim_isprintc __ARGS((int c));
    2526int vim_isprintc_strict __ARGS((int c));
    2627int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col));
  • src/proto/fileio.pro

    diff -Naur vim71.orig/src/proto/fileio.pro vim71/src/proto/fileio.pro
    old new  
    22void filemess __ARGS((buf_T *buf, char_u *name, char_u *s, int attr));
    33int readfile __ARGS((char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_skip, linenr_T lines_to_read, exarg_T *eap, int flags));
    44int prep_exarg __ARGS((exarg_T *eap, buf_T *buf));
     5int check_file_readonly __ARGS((char_u *fname, int perm));
    56int buf_write __ARGS((buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_T end, exarg_T *eap, int append, int forceit, int reset_changed, int filtering));
    67void msg_add_fname __ARGS((buf_T *buf, char_u *fname));
    78void msg_add_lines __ARGS((int insert_space, long lnum, long nchars));
     
    3940int trigger_cursorhold __ARGS((void));
    4041int has_cursormoved __ARGS((void));
    4142int has_cursormovedI __ARGS((void));
     43void block_autocmds __ARGS((void));
     44void unblock_autocmds __ARGS((void));
    4245int has_autocmd __ARGS((event_T event, char_u *sfname, buf_T *buf));
    4346char_u *get_augroup_name __ARGS((expand_T *xp, int idx));
    4447char_u *set_context_in_autocmd __ARGS((expand_T *xp, char_u *arg, int doautocmd));
  • src/proto/getchar.pro

    diff -Naur vim71.orig/src/proto/getchar.pro vim71/src/proto/getchar.pro
    old new  
    3838void updatescript __ARGS((int c));
    3939int vgetc __ARGS((void));
    4040int safe_vgetc __ARGS((void));
     41int plain_vgetc __ARGS((void));
    4142int vpeekc __ARGS((void));
    4243int vpeekc_nomap __ARGS((void));
    4344int vpeekc_any __ARGS((void));
  • src/proto/if_cscope.pro

    diff -Naur vim71.orig/src/proto/if_cscope.pro vim71/src/proto/if_cscope.pro
    old new  
    66void cs_free_tags __ARGS((void));
    77void cs_print_tags __ARGS((void));
    88int cs_connection __ARGS((int num, char_u *dbpath, char_u *ppath));
     9void cs_end __ARGS((void));
    910/* vim: set ft=c : */
  • src/proto/mbyte.pro

    diff -Naur vim71.orig/src/proto/mbyte.pro vim71/src/proto/mbyte.pro
    old new  
    1212int utf_ptr2cells __ARGS((char_u *p));
    1313int dbcs_ptr2cells __ARGS((char_u *p));
    1414int latin_char2cells __ARGS((int c));
    15 int latin_off2cells __ARGS((unsigned off));
    16 int dbcs_off2cells __ARGS((unsigned off));
    17 int utf_off2cells __ARGS((unsigned off));
     15int latin_off2cells __ARGS((unsigned off, unsigned max_off));
     16int dbcs_off2cells __ARGS((unsigned off, unsigned max_off));
     17int utf_off2cells __ARGS((unsigned off, unsigned max_off));
    1818int latin_ptr2char __ARGS((char_u *p));
    1919int utf_ptr2char __ARGS((char_u *p));
    2020int mb_ptr2char_adv __ARGS((char_u **pp));
  • src/proto/misc1.pro

    diff -Naur vim71.orig/src/proto/misc1.pro vim71/src/proto/misc1.pro
    old new  
    4848void vim_beep __ARGS((void));
    4949void init_homedir __ARGS((void));
    5050void free_homedir __ARGS((void));
     51char_u *expand_env_save __ARGS((char_u *src));
     52char_u *expand_env_save_opt __ARGS((char_u *src, int one));
    5153void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
    52 void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, char_u *startstr));
     54void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, int one, char_u *startstr));
    5355char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
    54 char_u *expand_env_save __ARGS((char_u *src));
    5556void vim_setenv __ARGS((char_u *name, char_u *val));
    5657char_u *get_env_name __ARGS((expand_T *xp, int idx));
    5758void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
  • src/proto/search.pro

    diff -Naur vim71.orig/src/proto/search.pro vim71/src/proto/search.pro
    old new  
    11/* search.c */
    22int search_regcomp __ARGS((char_u *pat, int pat_save, int pat_use, int options, regmmatch_T *regmatch));
    33char_u *get_search_pat __ARGS((void));
     4char_u *reverse_text __ARGS((char_u *s));
    45void save_search_patterns __ARGS((void));
    56void restore_search_patterns __ARGS((void));
    67void free_search_patterns __ARGS((void));
  • src/proto/syntax.pro

    diff -Naur vim71.orig/src/proto/syntax.pro vim71/src/proto/syntax.pro
    old new  
    88void syntax_clear __ARGS((buf_T *buf));
    99void ex_syntax __ARGS((exarg_T *eap));
    1010int syntax_present __ARGS((buf_T *buf));
     11void reset_expand_highlight __ARGS((void));
     12void set_context_in_echohl_cmd __ARGS((expand_T *xp, char_u *arg));
    1113void set_context_in_syntax_cmd __ARGS((expand_T *xp, char_u *arg));
    1214char_u *get_syntax_name __ARGS((expand_T *xp, int idx));
    1315int syn_get_id __ARGS((win_T *wp, long lnum, colnr_T col, int trans, int *spellp));
  • src/proto/window.pro

    diff -Naur vim71.orig/src/proto/window.pro vim71/src/proto/window.pro
    old new  
    5959int only_one_window __ARGS((void));
    6060void check_lnums __ARGS((int do_curwin));
    6161int win_hasvertsplit __ARGS((void));
     62int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
     63int match_delete __ARGS((win_T *wp, int id, int perr));
     64void clear_matches __ARGS((win_T *wp));
     65matchitem_T *get_match __ARGS((win_T *wp, int id));
    6266/* vim: set ft=c : */
  • src/quickfix.c

    diff -Naur vim71.orig/src/quickfix.c vim71/src/quickfix.c
    old new  
    16121612        }
    16131613
    16141614        /*
    1615          * If there is only one window and is the quickfix window, create a new
    1616          * one above the quickfix window.
     1615         * If there is only one window and it is the quickfix window, create a
     1616         * new one above the quickfix window.
    16171617         */
    16181618        if (((firstwin == lastwin) && bt_quickfix(curbuf)) || !usable_win)
    16191619        {
     
    23312331            set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
    23322332                                                                   OPT_LOCAL);
    23332333            set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL);
    2334             set_option_value((char_u *)"diff", 0L, (char_u *)"", OPT_LOCAL);
     2334            set_option_value((char_u *)"diff", 0L, NULL, OPT_LOCAL);
    23352335        }
    23362336
    23372337        /* Only set the height when still in the same tab page and there is no
     
    29812981    buf_T       *buf;
    29822982    int         duplicate_name = FALSE;
    29832983    int         using_dummy;
     2984    int         redraw_for_dummy = FALSE;
    29842985    int         found_match;
    29852986    buf_T       *first_match_buf = NULL;
    29862987    time_t      seconds = 0;
     
    30973098            /* Remember that a buffer with this name already exists. */
    30983099            duplicate_name = (buf != NULL);
    30993100            using_dummy = TRUE;
     3101            redraw_for_dummy = TRUE;
    31003102
    31013103#if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
    31023104            /* Don't do Filetype autocommands to avoid loading syntax and
     
    32433245    if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
    32443246    {
    32453247        if ((flags & VGR_NOJUMP) == 0)
     3248        {
     3249            buf = curbuf;
    32463250            qf_jump(qi, 0, 0, eap->forceit);
     3251            if (buf != curbuf)
     3252                /* If we jumped to another buffer redrawing will already be
     3253                 * taken care of. */
     3254                redraw_for_dummy = FALSE;
     3255        }
    32473256    }
    32483257    else
    32493258        EMSG2(_(e_nomatch2), s);
    32503259
     3260    /* If we loaded a dummy buffer into the current window, the autocommands
     3261     * may have messed up things, need to redraw and recompute folds. */
     3262    if (redraw_for_dummy)
     3263    {
     3264#ifdef FEAT_FOLDING
     3265        foldUpdateAll(curwin);
     3266#else
     3267        redraw_later(NOT_VALID);
     3268#endif
     3269    }
     3270
    32513271theend:
    32523272    vim_free(regmatch.regprog);
    32533273}
  • src/regexp.c

    diff -Naur vim71.orig/src/regexp.c vim71/src/regexp.c
    old new  
    22202220                                break;
    22212221                            case CLASS_LOWER:
    22222222                                for (cu = 1; cu <= 255; cu++)
    2223                                     if (islower(cu))
     2223                                    if (MB_ISLOWER(cu))
    22242224                                        regc(cu);
    22252225                                break;
    22262226                            case CLASS_PRINT:
     
    22402240                                break;
    22412241                            case CLASS_UPPER:
    22422242                                for (cu = 1; cu <= 255; cu++)
    2243                                     if (isupper(cu))
     2243                                    if (MB_ISUPPER(cu))
    22442244                                        regc(cu);
    22452245                                break;
    22462246                            case CLASS_XDIGIT:
     
    34653465                        (enc_utf8 && utf_fold(prog->regstart) == utf_fold(c)))
    34663466                        || (c < 255 && prog->regstart < 255 &&
    34673467#endif
    3468                             TOLOWER_LOC(prog->regstart) == TOLOWER_LOC(c)))))
     3468                            MB_TOLOWER(prog->regstart) == MB_TOLOWER(c)))))
    34693469            retval = regtry(prog, col);
    34703470        else
    34713471            retval = 0;
     
    42004200#ifdef FEAT_MBYTE
    42014201                            !enc_utf8 &&
    42024202#endif
    4203                             TOLOWER_LOC(*opnd) != TOLOWER_LOC(*reginput))))
     4203                            MB_TOLOWER(*opnd) != MB_TOLOWER(*reginput))))
    42044204                    status = RA_NOMATCH;
    42054205                else if (*opnd == NUL)
    42064206                {
     
    47334733                    rst.nextb = *OPERAND(next);
    47344734                    if (ireg_ic)
    47354735                    {
    4736                         if (isupper(rst.nextb))
    4737                             rst.nextb_ic = TOLOWER_LOC(rst.nextb);
     4736                        if (MB_ISUPPER(rst.nextb))
     4737                            rst.nextb_ic = MB_TOLOWER(rst.nextb);
    47384738                        else
    4739                             rst.nextb_ic = TOUPPER_LOC(rst.nextb);
     4739                            rst.nextb_ic = MB_TOUPPER(rst.nextb);
    47404740                    }
    47414741                    else
    47424742                        rst.nextb_ic = rst.nextb;
     
    55585558            int     cu, cl;
    55595559
    55605560            /* This doesn't do a multi-byte character, because a MULTIBYTECODE
    5561              * would have been used for it. */
     5561             * would have been used for it.  It does handle single-byte
     5562             * characters, such as latin1. */
    55625563            if (ireg_ic)
    55635564            {
    5564                 cu = TOUPPER_LOC(*opnd);
    5565                 cl = TOLOWER_LOC(*opnd);
     5565                cu = MB_TOUPPER(*opnd);
     5566                cl = MB_TOLOWER(*opnd);
    55665567                while (count < maxcount && (*scan == cu || *scan == cl))
    55675568                {
    55685569                    count++;
     
    64906491        cc = utf_fold(c);
    64916492    else
    64926493#endif
    6493          if (isupper(c))
    6494         cc = TOLOWER_LOC(c);
    6495     else if (islower(c))
    6496         cc = TOUPPER_LOC(c);
     6494         if (MB_ISUPPER(c))
     6495        cc = MB_TOLOWER(c);
     6496    else if (MB_ISLOWER(c))
     6497        cc = MB_TOUPPER(c);
    64976498    else
    64986499        return vim_strchr(s, c);
    64996500
     
    66376638                }
    66386639            }
    66396640            else if (magic)
    6640                 STRCPY(p, p + 1);               /* remove '~' */
     6641                mch_memmove(p, p + 1, STRLEN(p));       /* remove '~' */
    66416642            else
    6642                 STRCPY(p, p + 2);               /* remove '\~' */
     6643                mch_memmove(p, p + 2, STRLEN(p) - 1);   /* remove '\~' */
    66436644            --p;
    66446645        }
    66456646        else
     
    70147015#ifdef FEAT_MBYTE
    70157016                            if (has_mbyte)
    70167017                            {
    7017                                 int l = mb_ptr2len(s) - 1;
     7018                                int l;
     7019
     7020                                /* Copy composing characters separately, one
     7021                                 * at a time. */
     7022                                if (enc_utf8)
     7023                                    l = utf_ptr2len(s) - 1;
     7024                                else
     7025                                    l = mb_ptr2len(s) - 1;
    70187026
    70197027                                s += l;
    70207028                                len -= l;
  • src/screen.c

    diff -Naur vim71.orig/src/screen.c vim71/src/screen.c
    old new  
    100100static int      screen_cur_row, screen_cur_col; /* last known cursor position */
    101101
    102102#ifdef FEAT_SEARCH_EXTRA
    103 /*
    104  * Struct used for highlighting 'hlsearch' matches for the last use search
    105  * pattern or a ":match" item.
    106  * For 'hlsearch' there is one pattern for all windows.  For ":match" there is
    107  * a different pattern for each window.
    108  */
    109 typedef struct
    110 {
    111     regmmatch_T rm;     /* points to the regexp program; contains last found
    112                            match (may continue in next line) */
    113     buf_T       *buf;   /* the buffer to search for a match */
    114     linenr_T    lnum;   /* the line to search for a match */
    115     int         attr;   /* attributes to be used for a match */
    116     int         attr_cur; /* attributes currently active in win_line() */
    117     linenr_T    first_lnum;     /* first lnum to search for multi-line pat */
    118     colnr_T     startcol; /* in win_line() points to char where HL starts */
    119     colnr_T     endcol;  /* in win_line() points to char where HL ends */
    120 } match_T;
    121 
    122103static match_T search_hl;       /* used for 'hlsearch' highlight matching */
    123 static match_T match_hl[3];     /* used for ":match" highlight matching */
    124104#endif
    125105
    126106#ifdef FEAT_FOLDING
     
    155135static void redraw_custum_statusline __ARGS((win_T *wp));
    156136#endif
    157137#ifdef FEAT_SEARCH_EXTRA
     138#define SEARCH_HL_PRIORITY 0
    158139static void start_search_hl __ARGS((void));
    159140static void end_search_hl __ARGS((void));
    160141static void prepare_search_hl __ARGS((win_T *wp, linenr_T lnum));
     
    350331    {
    351332        if (type < must_redraw)     /* use maximal type */
    352333            type = must_redraw;
     334
     335        /* must_redraw is reset here, so that when we run into some weird
     336         * reason to redraw while busy redrawing (e.g., asynchronous
     337         * scrolling), or update_topline() in win_update() will cause a
     338         * scroll, the screen will be redrawn later or in win_update(). */
    353339        must_redraw = 0;
    354340    }
    355341
     
    787773                                           w_topline got smaller a bit */
    788774#endif
    789775#ifdef FEAT_SEARCH_EXTRA
     776    matchitem_T *cur;           /* points to the match list */
    790777    int         top_to_mod = FALSE;    /* redraw above mod_top */
    791778#endif
    792779
     
    848835#endif
    849836
    850837#ifdef FEAT_SEARCH_EXTRA
    851     /* Setup for ":match" and 'hlsearch' highlighting.  Disable any previous
     838    /* Setup for match and 'hlsearch' highlighting.  Disable any previous
    852839     * match */
    853     for (i = 0; i < 3; ++i)
     840    cur = wp->w_match_head;
     841    while (cur != NULL)
    854842    {
    855         match_hl[i].rm = wp->w_match[i];
    856         if (wp->w_match_id[i] == 0)
    857             match_hl[i].attr = 0;
    858         else
    859             match_hl[i].attr = syn_id2attr(wp->w_match_id[i]);
    860         match_hl[i].buf = buf;
    861         match_hl[i].lnum = 0;
    862         match_hl[i].first_lnum = 0;
     843        cur->hl.rm = cur->match;
     844        if (cur->hlg_id == 0)
     845            cur->hl.attr = 0;
     846        else
     847            cur->hl.attr = syn_id2attr(cur->hlg_id);
     848        cur->hl.buf = buf;
     849        cur->hl.lnum = 0;
     850        cur->hl.first_lnum = 0;
     851        cur = cur->next;
    863852    }
    864853    search_hl.buf = buf;
    865854    search_hl.lnum = 0;
     
    923912             * change in one line may make the Search highlighting in a
    924913             * previous line invalid.  Simple solution: redraw all visible
    925914             * lines above the change.
    926              * Same for a ":match" pattern.
     915             * Same for a match pattern.
    927916             */
    928917            if (search_hl.rm.regprog != NULL
    929918                                        && re_multiline(search_hl.rm.regprog))
    930919                top_to_mod = TRUE;
    931920            else
    932                 for (i = 0; i < 3; ++i)
    933                     if (match_hl[i].rm.regprog != NULL
    934                                       && re_multiline(match_hl[i].rm.regprog))
     921            {
     922                cur = wp->w_match_head;
     923                while (cur != NULL)
     924                {
     925                    if (cur->match.regprog != NULL
     926                                           && re_multiline(cur->match.regprog))
    935927                    {
    936928                        top_to_mod = TRUE;
    937929                        break;
    938930                    }
     931                    cur = cur->next;
     932                }
     933            }
    939934#endif
    940935        }
    941936#ifdef FEAT_FOLDING
     
    10291024            type = VALID;
    10301025    }
    10311026
     1027    /* Trick: we want to avoid clearing the screen twice.  screenclear() will
     1028     * set "screen_cleared" to TRUE.  The special value MAYBE (which is still
     1029     * non-zero and thus not FALSE) will indicate that screenclear() was not
     1030     * called. */
     1031    if (screen_cleared)
     1032        screen_cleared = MAYBE;
     1033
    10321034    /*
    10331035     * If there are no changes on the screen that require a complete redraw,
    10341036     * handle three cases:
     
    12301232            mid_end = wp->w_height;
    12311233            if (lastwin == firstwin)
    12321234            {
    1233                 screenclear();
     1235                /* Clear the screen when it was not done by win_del_lines() or
     1236                 * win_ins_lines() above, "screen_cleared" is FALSE or MAYBE
     1237                 * then. */
     1238                if (screen_cleared != TRUE)
     1239                    screenclear();
    12341240#ifdef FEAT_WINDOWS
    12351241                /* The screen was cleared, redraw the tab pages line. */
    12361242                if (redraw_tabline)
     
    12381244#endif
    12391245            }
    12401246        }
     1247
     1248        /* When win_del_lines() or win_ins_lines() caused the screen to be
     1249         * cleared (only happens for the first window) or when screenclear()
     1250         * was called directly above, "must_redraw" will have been set to
     1251         * NOT_VALID, need to reset it here to avoid redrawing twice. */
     1252        if (screen_cleared == TRUE)
     1253            must_redraw = 0;
    12411254    }
    12421255    else
    12431256    {
     
    22922305                        prev_c = u8c;
    22932306#endif
    22942307                    /* Non-BMP character: display as ? or fullwidth ?. */
     2308#ifdef UNICODE16
    22952309                    if (u8c >= 0x10000)
    22962310                        ScreenLinesUC[idx] = (cells == 2) ? 0xff1f : (int)'?';
    22972311                    else
     2312#endif
    22982313                        ScreenLinesUC[idx] = u8c;
    22992314                    for (i = 0; i < Screen_mco; ++i)
    23002315                    {
     
    25422557
    25432558    char_u      extra[18];              /* "%ld" and 'fdc' must fit in here */
    25442559    int         n_extra = 0;            /* number of extra chars */
    2545     char_u      *p_extra = NULL;        /* string of extra chars */
     2560    char_u      *p_extra = NULL;        /* string of extra chars, plus NUL */
    25462561    int         c_extra = NUL;          /* extra chars, all the same */
    25472562    int         extra_attr = 0;         /* attributes when n_extra != 0 */
    25482563    static char_u *at_end_str = (char_u *)""; /* used for p_extra when
     
    26262641    int         line_attr = 0;          /* atrribute for the whole line */
    26272642#endif
    26282643#ifdef FEAT_SEARCH_EXTRA
    2629     match_T     *shl;                   /* points to search_hl or match_hl */
    2630 #endif
    2631 #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_MBYTE)
    2632     int         i;
     2644    matchitem_T *cur;                   /* points to the match list */
     2645    match_T     *shl;                   /* points to search_hl or a match */
     2646    int         shl_flag;               /* flag to indicate whether search_hl
     2647                                           has been processed or not */
     2648    int         prevcol_hl_flag;        /* flag to indicate whether prevcol
     2649                                           equals startcol of search_hl or one
     2650                                           of the matches */
    26332651#endif
    26342652#ifdef FEAT_ARABIC
    26352653    int         prev_c = 0;             /* previous Arabic character */
     
    30743092
    30753093#ifdef FEAT_SEARCH_EXTRA
    30763094    /*
    3077      * Handle highlighting the last used search pattern and ":match".
    3078      * Do this for both search_hl and match_hl[3].
     3095     * Handle highlighting the last used search pattern and matches.
     3096     * Do this for both search_hl and the match list.
    30793097     */
    3080     for (i = 3; i >= 0; --i)
     3098    cur = wp->w_match_head;
     3099    shl_flag = FALSE;
     3100    while (cur != NULL || shl_flag == FALSE)
    30813101    {
    3082         shl = (i == 3) ? &search_hl : &match_hl[i];
     3102        if (shl_flag == FALSE)
     3103        {
     3104            shl = &search_hl;
     3105            shl_flag = TRUE;
     3106        }
     3107        else
     3108            shl = &cur->hl;
    30833109        shl->startcol = MAXCOL;
    30843110        shl->endcol = MAXCOL;
    30853111        shl->attr_cur = 0;
     
    31223148                area_highlighting = TRUE;
    31233149            }
    31243150        }
     3151        if (shl != &search_hl && cur != NULL)
     3152            cur = cur->next;
    31253153    }
    31263154#endif
    31273155
     
    31633191                if (cmdwin_type != 0 && wp == curwin)
    31643192                {
    31653193                    /* Draw the cmdline character. */
    3166                     *extra = cmdwin_type;
    31673194                    n_extra = 1;
    3168                     p_extra = extra;
    3169                     c_extra = NUL;
     3195                    c_extra = cmdwin_type;
    31703196                    char_attr = hl_attr(HLF_AT);
    31713197                }
    31723198            }
     
    31823208                    fill_foldcolumn(extra, wp, FALSE, lnum);
    31833209                    n_extra = wp->w_p_fdc;
    31843210                    p_extra = extra;
     3211                    p_extra[n_extra] = NUL;
    31853212                    c_extra = NUL;
    31863213                    char_attr = hl_attr(HLF_FC);
    31873214                }
     
    33883415                 * After end, check for start/end of next match.
    33893416                 * When another match, have to check for start again.
    33903417                 * Watch out for matching an empty string!
    3391                  * Do this first for search_hl, then for match_hl, so that
    3392                  * ":match" overrules 'hlsearch'.
     3418                 * Do this for 'search_hl' and the match list (ordered by
     3419                 * priority).
    33933420                 */
    33943421                v = (long)(ptr - line);
    3395                 for (i = 3; i >= 0; --i)
    3396                 {
    3397                     shl = (i == 3) ? &search_hl : &match_hl[i];
     3422                cur = wp->w_match_head;
     3423                shl_flag = FALSE;
     3424                while (cur != NULL || shl_flag == FALSE)
     3425                {
     3426                    if (shl_flag == FALSE
     3427                            && ((cur != NULL
     3428                                    && cur->priority > SEARCH_HL_PRIORITY)
     3429                                || cur == NULL))
     3430                    {
     3431                        shl = &search_hl;
     3432                        shl_flag = TRUE;
     3433                    }
     3434                    else
     3435                        shl = &cur->hl;
    33983436                    while (shl->rm.regprog != NULL)
    33993437                    {
    34003438                        if (shl->startcol != MAXCOL
     
    34423480                        }
    34433481                        break;
    34443482                    }
     3483                    if (shl != &search_hl && cur != NULL)
     3484                        cur = cur->next;
    34453485                }
    34463486
    3447                 /* ":match" highlighting overrules 'hlsearch' */
    3448                 for (i = 0; i <= 3; ++i)
    3449                     if (i == 3)
    3450                         search_attr = search_hl.attr_cur;
    3451                     else if (match_hl[i].attr_cur != 0)
     3487                /* Use attributes from match with highest priority among
     3488                 * 'search_hl' and the match list. */
     3489                search_attr = search_hl.attr_cur;
     3490                cur = wp->w_match_head;
     3491                shl_flag = FALSE;
     3492                while (cur != NULL || shl_flag == FALSE)
     3493                {
     3494                    if (shl_flag == FALSE
     3495                            && ((cur != NULL
     3496                                    && cur->priority > SEARCH_HL_PRIORITY)
     3497                                || cur == NULL))
    34523498                    {
    3453                         search_attr = match_hl[i].attr_cur;
    3454                         break;
     3499                        shl = &search_hl;
     3500                        shl_flag = TRUE;
    34553501                    }
     3502                    else
     3503                        shl = &cur->hl;
     3504                    if (shl->attr_cur != 0)
     3505                        search_attr = shl->attr_cur;
     3506                    if (shl != &search_hl && cur != NULL)
     3507                        cur = cur->next;
     3508                }
    34563509            }
    34573510#endif
    34583511
    34593512#ifdef FEAT_DIFF
    34603513            if (diff_hlf != (hlf_T)0)
    34613514            {
    3462                 if (diff_hlf == HLF_CHD && ptr - line >= change_start)
     3515                if (diff_hlf == HLF_CHD && ptr - line >= change_start
     3516                                                              && n_extra == 0)
    34633517                    diff_hlf = HLF_TXD;         /* changed text */
    3464                 if (diff_hlf == HLF_TXD && ptr - line > change_end)
     3518                if (diff_hlf == HLF_TXD && ptr - line > change_end
     3519                                                              && n_extra == 0)
    34653520                    diff_hlf = HLF_CHD;         /* changed line */
    34663521                line_attr = hl_attr(diff_hlf);
    34673522            }
     
    34963551         * Get the next character to put on the screen.
    34973552         */
    34983553        /*
    3499          * The 'extra' array contains the extra stuff that is inserted to
    3500          * represent special characters (non-printable stuff).  When all
    3501          * characters are the same, c_extra is used.
     3554         * The "p_extra" points to the extra stuff that is inserted to
     3555         * represent special characters (non-printable stuff) and other
     3556         * things.  When all characters are the same, c_extra is used.
     3557         * "p_extra" must end in a NUL to avoid mb_ptr2len() reads past
     3558         * "p_extra[n_extra]".
    35023559         * For the '$' of the 'list' option, n_extra == 1, p_extra == "".
    35033560         */
    35043561        if (n_extra > 0)
     
    36113668                         * Draw it as a space with a composing char. */
    36123669                        if (utf_iscomposing(mb_c))
    36133670                        {
     3671                            int i;
     3672
    36143673                            for (i = Screen_mco - 1; i > 0; --i)
    36153674                                u8cc[i] = u8cc[i - 1];
    36163675                            u8cc[0] = mb_c;
     
    36213680                    if ((mb_l == 1 && c >= 0x80)
    36223681                            || (mb_l >= 1 && mb_c == 0)
    36233682                            || (mb_l > 1 && (!vim_isprintc(mb_c)
    3624                                                          || mb_c >= 0x10000)))
     3683# ifdef UNICODE16
     3684                                                         || mb_c >= 0x10000
     3685# endif
     3686                                                         )))
    36253687                    {
    36263688                        /*
    36273689                         * Illegal UTF-8 byte: display as <xx>.
    36283690                         * Non-BMP character : display as ? or fullwidth ?.
    36293691                         */
     3692# ifdef UNICODE16
    36303693                        if (mb_c < 0x10000)
     3694# endif
    36313695                        {
    36323696                            transchar_hex(extra, mb_c);
    36333697# ifdef FEAT_RIGHTLEFT
     
    36353699                                rl_mirror(extra);
    36363700# endif
    36373701                        }
     3702# ifdef UNICODE16
    36383703                        else if (utf_char2cells(mb_c) != 2)
    36393704                            STRCPY(extra, "?");
    36403705                        else
    36413706                            /* 0xff1f in UTF-8: full-width '?' */
    36423707                            STRCPY(extra, "\357\274\237");
     3708# endif
    36433709
    36443710                        p_extra = extra;
    36453711                        c = *p_extra;
     
    37523818                 * a '<' in the first column. */
    37533819                if (n_skip > 0 && mb_l > 1)
    37543820                {
    3755                     extra[0] = '<';
    3756                     p_extra = extra;
    37573821                    n_extra = 1;
    3758                     c_extra = NUL;
     3822                    c_extra = '<';
    37593823                    c = ' ';
    37603824                    if (area_attr == 0 && search_attr == 0)
    37613825                    {
     
    42544318             * highlight match at end of line. If it's beyond the last
    42554319             * char on the screen, just overwrite that one (tricky!)  Not
    42564320             * needed when a '$' was displayed for 'list'. */
     4321#ifdef FEAT_SEARCH_EXTRA
     4322            prevcol_hl_flag = FALSE;
     4323            if (prevcol == (long)search_hl.startcol)
     4324                prevcol_hl_flag = TRUE;
     4325            else
     4326            {
     4327                cur = wp->w_match_head;
     4328                while (cur != NULL)
     4329                {
     4330                    if (prevcol == (long)cur->hl.startcol)
     4331                    {
     4332                        prevcol_hl_flag = TRUE;
     4333                        break;
     4334                    }
     4335                    cur = cur->next;
     4336                }
     4337            }
     4338#endif
    42574339            if (lcs_eol == lcs_eol_one
    42584340                    && ((area_attr != 0 && vcol == fromcol && c == NUL)
    42594341#ifdef FEAT_SEARCH_EXTRA
    42604342                        /* highlight 'hlsearch' match at end of line */
    4261                         || ((prevcol == (long)search_hl.startcol
    4262                                 || prevcol == (long)match_hl[0].startcol
    4263                                 || prevcol == (long)match_hl[1].startcol
    4264                                 || prevcol == (long)match_hl[2].startcol)
     4343                        || (prevcol_hl_flag == TRUE
    42654344# if defined(LINE_ATTR)
    42664345                            && did_line_attr <= 1
    42674346# endif
     
    43024381#ifdef FEAT_SEARCH_EXTRA
    43034382                if (area_attr == 0)
    43044383                {
    4305                     for (i = 0; i <= 3; ++i)
    4306                     {
    4307                         if (i == 3)
    4308                             char_attr = search_hl.attr;
    4309                         else if ((ptr - line) - 1 == (long)match_hl[i].startcol)
     4384                    /* Use attributes from match with highest priority among
     4385                     * 'search_hl' and the match list. */
     4386                    char_attr = search_hl.attr;
     4387                    cur = wp->w_match_head;
     4388                    shl_flag = FALSE;
     4389                    while (cur != NULL || shl_flag == FALSE)
     4390                    {
     4391                        if (shl_flag == FALSE
     4392                                && ((cur != NULL
     4393                                        && cur->priority > SEARCH_HL_PRIORITY)
     4394                                    || cur == NULL))
    43104395                        {
    4311                             char_attr = match_hl[i].attr;
    4312                             break;
     4396                            shl = &search_hl;
     4397                            shl_flag = TRUE;
    43134398                        }
     4399                        else
     4400                            shl = &cur->hl;
     4401                        if ((ptr - line) - 1 == (long)shl->startcol)
     4402                            char_attr = shl->attr;
     4403                        if (shl != &search_hl && cur != NULL)
     4404                            cur = cur->next;
    43144405                    }
    43154406                }
    43164407#endif
     
    44604551            {
    44614552                if (mb_utf8)
    44624553                {
     4554                    int i;
     4555
    44634556                    ScreenLinesUC[off] = mb_c;
    44644557                    if ((c & 0xff) == 0)
    44654558                        ScreenLines[off] = 0x80;   /* avoid storing zero */
     
    45484641
    45494642        /*
    45504643         * At end of screen line and there is more to come: Display the line
    4551          * so far.  If there is no more to display it is catched above.
     4644         * so far.  If there is no more to display it is caught above.
    45524645         */
    45534646        if ((
    45544647#ifdef FEAT_RIGHTLEFT
     
    46254718#endif
    46264719#ifdef FEAT_MBYTE
    46274720                         && !(has_mbyte
    4628                              && ((*mb_off2cells)(LineOffset[screen_row]) == 2
     4721                             && ((*mb_off2cells)(LineOffset[screen_row],
     4722                                     LineOffset[screen_row] + screen_Columns)
     4723                                                                          == 2
    46294724                                 || (*mb_off2cells)(LineOffset[screen_row - 1]
    4630                                                         + (int)Columns - 2) == 2))
     4725                                                        + (int)Columns - 2,
     4726                                     LineOffset[screen_row] + screen_Columns)
     4727                                                                        == 2))
    46314728#endif
    46324729                   )
    46334730                {
     
    47874884{
    47884885    unsigned        off_from;
    47894886    unsigned        off_to;
     4887#ifdef FEAT_MBYTE
     4888    unsigned        max_off_from;
     4889    unsigned        max_off_to;
     4890#endif
    47904891    int             col = 0;
    47914892#if defined(FEAT_GUI) || defined(UNIX) || defined(FEAT_VERTSPLIT)
    47924893    int             hl;
     
    48134914
    48144915    off_from = (unsigned)(current_ScreenLine - ScreenLines);
    48154916    off_to = LineOffset[row] + coloff;
     4917#ifdef FEAT_MBYTE
     4918    max_off_from = off_from + screen_Columns;
     4919    max_off_to = LineOffset[row] + screen_Columns;
     4920#endif
    48164921
    48174922#ifdef FEAT_RIGHTLEFT
    48184923    if (rlflag)
     
    48474952    {
    48484953#ifdef FEAT_MBYTE
    48494954        if (has_mbyte && (col + 1 < endcol))
    4850             char_cells = (*mb_off2cells)(off_from);
     4955            char_cells = (*mb_off2cells)(off_from, max_off_from);
    48514956        else
    48524957            char_cells = 1;
    48534958#endif
     
    49245029                 * ScreenLinesUC[] is sufficient. */
    49255030                if (char_cells == 1
    49265031                        && col + 1 < endcol
    4927                         && (*mb_off2cells)(off_to) > 1)
     5032                        && (*mb_off2cells)(off_to, max_off_to) > 1)
    49285033                {
    49295034                    /* Writing a single-cell character over a double-cell
    49305035                     * character: need to redraw the next cell. */
     
    49335038                }
    49345039                else if (char_cells == 2
    49355040                        && col + 2 < endcol
    4936                         && (*mb_off2cells)(off_to) == 1
    4937                         && (*mb_off2cells)(off_to + 1) > 1)
     5041                        && (*mb_off2cells)(off_to, max_off_to) == 1
     5042                        && (*mb_off2cells)(off_to + 1, max_off_to) > 1)
    49385043                {
    49395044                    /* Writing the second half of a double-cell character over
    49405045                     * a double-cell character: need to redraw the second
     
    49535058             * char over the left halve of an existing one. */
    49545059            if (has_mbyte && col + char_cells == endcol
    49555060                    && ((char_cells == 1
    4956                             && (*mb_off2cells)(off_to) > 1)
     5061                            && (*mb_off2cells)(off_to, max_off_to) > 1)
    49575062                        || (char_cells == 2
    4958                             && (*mb_off2cells)(off_to) == 1
    4959                             && (*mb_off2cells)(off_to + 1) > 1)))
     5063                            && (*mb_off2cells)(off_to, max_off_to) == 1
     5064                            && (*mb_off2cells)(off_to + 1, max_off_to) > 1)))
    49605065                clear_next = TRUE;
    49615066#endif
    49625067
     
    50965201                        /* find previous character by counting from first
    50975202                         * column and get its width. */
    50985203                        unsigned off = LineOffset[row];
     5204                        unsigned max_off = LineOffset[row] + screen_Columns;
    50995205
    51005206                        while (off < off_to)
    51015207                        {
    5102                             prev_cells = (*mb_off2cells)(off);
     5208                            prev_cells = (*mb_off2cells)(off, max_off);
    51035209                            off += prev_cells;
    51045210                        }
    51055211                    }
     
    52855391static int skip_status_match_char __ARGS((expand_T *xp, char_u *s));
    52865392
    52875393/*
    5288  * Get the lenght of an item as it will be shown in the status line.
     5394 * Get the length of an item as it will be shown in the status line.
    52895395 */
    52905396    static int
    52915397status_match_len(xp, s)
     
    53515457    int         row;
    53525458    char_u      *buf;
    53535459    int         len;
    5354     int         clen;           /* lenght in screen cells */
     5460    int         clen;           /* length in screen cells */
    53555461    int         fillchar;
    53565462    int         attr;
    53575463    int         i;
     
    61036209    char_u      *ptr = text;
    61046210    int         c;
    61056211#ifdef FEAT_MBYTE
     6212    unsigned    max_off;
    61066213    int         mbyte_blen = 1;
    61076214    int         mbyte_cells = 1;
    61086215    int         u8c = 0;
     
    61196226        return;
    61206227
    61216228    off = LineOffset[row] + col;
    6122     while (*ptr != NUL && col < screen_Columns
    6123                                       && (len < 0 || (int)(ptr - text) < len))
     6229#ifdef FEAT_MBYTE
     6230    max_off = LineOffset[row] + screen_Columns;
     6231#endif
     6232    while (col < screen_Columns
     6233            && (len < 0 || (int)(ptr - text) < len)
     6234            && *ptr != NUL)
    61246235    {
    61256236        c = *ptr;
    61266237#ifdef FEAT_MBYTE
     
    61436254                else
    61446255                    u8c = utfc_ptr2char(ptr, u8cc);
    61456256                mbyte_cells = utf_char2cells(u8c);
     6257# ifdef UNICODE16
    61466258                /* Non-BMP character: display as ? or fullwidth ?. */
    61476259                if (u8c >= 0x10000)
    61486260                {
     
    61506262                    if (attr == 0)
    61516263                        attr = hl_attr(HLF_8);
    61526264                }
     6265# endif
    61536266# ifdef FEAT_ARABIC
    61546267                if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c))
    61556268                {
     
    62416354            else if (has_mbyte
    62426355                    && (len < 0 ? ptr[mbyte_blen] == NUL
    62436356                                             : ptr + mbyte_blen >= text + len)
    6244                     && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
     6357                    && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
    62456358                        || (mbyte_cells == 2
    6246                             && (*mb_off2cells)(off) == 1
    6247                             && (*mb_off2cells)(off + 1) > 1)))
     6359                            && (*mb_off2cells)(off, max_off) == 1
     6360                            && (*mb_off2cells)(off + 1, max_off) > 1)))
    62486361                clear_next_cell = TRUE;
    62496362
    62506363            /* Make sure we never leave a second byte of a double-byte behind,
    62516364             * it confuses mb_off2cells(). */
    62526365            if (enc_dbcs
    6253                     && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
     6366                    && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
    62546367                        || (mbyte_cells == 2
    6255                             && (*mb_off2cells)(off) == 1
    6256                             && (*mb_off2cells)(off + 1) > 1)))
     6368                            && (*mb_off2cells)(off, max_off) == 1
     6369                            && (*mb_off2cells)(off + 1, max_off) > 1)))
    62576370                ScreenLines[off + mbyte_blen] = 0;
    62586371#endif
    62596372            ScreenLines[off] = c;
     
    63186431
    63196432#ifdef FEAT_SEARCH_EXTRA
    63206433/*
    6321  * Prepare for 'searchhl' highlighting.
     6434 * Prepare for 'hlsearch' highlighting.
    63226435 */
    63236436    static void
    63246437start_search_hl()
     
    63316444}
    63326445
    63336446/*
    6334  * Clean up for 'searchhl' highlighting.
     6447 * Clean up for 'hlsearch' highlighting.
    63356448 */
    63366449    static void
    63376450end_search_hl()
     
    63516464    win_T       *wp;
    63526465    linenr_T    lnum;
    63536466{
    6354     match_T     *shl;           /* points to search_hl or match_hl */
     6467    matchitem_T *cur;           /* points to the match list */
     6468    match_T     *shl;           /* points to search_hl or a match */
     6469    int         shl_flag;       /* flag to indicate whether search_hl
     6470                                   has been processed or not */
    63556471    int         n;
    6356     int         i;
    63576472
    63586473    /*
    63596474     * When using a multi-line pattern, start searching at the top
    63606475     * of the window or just after a closed fold.
    6361      * Do this both for search_hl and match_hl[3].
     6476     * Do this both for search_hl and the match list.
    63626477     */
    6363     for (i = 3; i >= 0; --i)
     6478    cur = wp->w_match_head;
     6479    shl_flag = FALSE;
     6480    while (cur != NULL || shl_flag == FALSE)
    63646481    {
    6365         shl = (i == 3) ? &search_hl : &match_hl[i];
     6482        if (shl_flag == FALSE)
     6483        {
     6484            shl = &search_hl;
     6485            shl_flag = TRUE;
     6486        }
     6487        else
     6488            shl = &cur->hl;
    63666489        if (shl->rm.regprog != NULL
    63676490                && shl->lnum == 0
    63686491                && re_multiline(shl->rm.regprog))
     
    63976520                }
    63986521            }
    63996522        }
     6523        if (shl != &search_hl && cur != NULL)
     6524            cur = cur->next;
    64006525    }
    64016526}
    64026527
    64036528/*
    6404  * Search for a next 'searchl' or ":match" match.
     6529 * Search for a next 'hlsearch' or match.
    64056530 * Uses shl->buf.
    64066531 * Sets shl->lnum and shl->rm contents.
    64076532 * Note: Assumes a previous match is always before "lnum", unless
     
    64116536    static void
    64126537next_search_hl(win, shl, lnum, mincol)
    64136538    win_T       *win;
    6414     match_T     *shl;           /* points to search_hl or match_hl */
     6539    match_T     *shl;           /* points to search_hl or a match */
    64156540    linenr_T    lnum;
    64166541    colnr_T     mincol;         /* minimal column for a match */
    64176542{
     
    64796604            /* Error while handling regexp: stop using this regexp. */
    64806605            if (shl == &search_hl)
    64816606            {
    6482                 /* don't free the regprog in match_hl[], it's a copy */
     6607                /* don't free regprog in the match list, it's a copy */
    64836608                vim_free(shl->rm.regprog);
    64846609                no_hlsearch = TRUE;
    64856610            }
     
    68276952{
    68286953    int         r, c;
    68296954    int         off;
     6955#ifdef FEAT_MBYTE
     6956    int         max_off;
     6957#endif
    68306958
    68316959    /* Can't use ScreenLines unless initialized */
    68326960    if (ScreenLines == NULL)
     
    68376965    for (r = row; r < row + height; ++r)
    68386966    {
    68396967        off = LineOffset[r];
     6968#ifdef FEAT_MBYTE
     6969        max_off = off + screen_Columns;
     6970#endif
    68406971        for (c = col; c < col + width; ++c)
    68416972        {
    68426973#ifdef FEAT_MBYTE
    6843             if (enc_dbcs != 0 && dbcs_off2cells(off + c) > 1)
     6974            if (enc_dbcs != 0 && dbcs_off2cells(off + c, max_off) > 1)
    68446975            {
    68456976                screen_char_2(off + c, r, c);
    68466977                ++c;
     
    68506981            {
    68516982                screen_char(off + c, r, c);
    68526983#ifdef FEAT_MBYTE
    6853                 if (utf_off2cells(off + c) > 1)
     6984                if (utf_off2cells(off + c, max_off) > 1)
    68546985                    ++c;
    68556986#endif
    68566987            }
  • src/search.c

    diff -Naur vim71.orig/src/search.c vim71/src/search.c
    old new  
    101101static char_u       *mr_pattern = NULL; /* pattern used by search_regcomp() */
    102102#ifdef FEAT_RIGHTLEFT
    103103static int          mr_pattern_alloced = FALSE; /* mr_pattern was allocated */
    104 static char_u       *reverse_text __ARGS((char_u *s));
    105104#endif
    106105
    107106#ifdef FEAT_FIND_ID
     
    228227    return mr_pattern;
    229228}
    230229
    231 #ifdef FEAT_RIGHTLEFT
     230#if defined(FEAT_RIGHTLEFT) || defined(PROTO)
    232231/*
    233232 * Reverse text into allocated memory.
    234233 * Returns the allocated string, NULL when out of memory.
    235234 */
    236     static char_u *
     235    char_u *
    237236reverse_text(s)
    238237    char_u *s;
    239238{
     
    573572        /*
    574573         * Start searching in current line, unless searching backwards and
    575574         * we're in column 0.
     575         * If we are searching backwards, in column 0, and not including the
     576         * current position, gain some efficiency by skipping back a line.
     577         * Otherwise begin the search in the current line.
    576578         */
    577         if (dir == BACKWARD && start_pos.col == 0)
     579        if (dir == BACKWARD && start_pos.col == 0
     580                                             && (options & SEARCH_START) == 0)
    578581        {
    579582            lnum = pos->lnum - 1;
    580583            at_first_line = FALSE;
     
    18941897    }
    18951898
    18961899#ifdef FEAT_RIGHTLEFT
    1897     /* This is just guessing: when 'rightleft' is set, search for a maching
     1900    /* This is just guessing: when 'rightleft' is set, search for a matching
    18981901     * paren/brace in the other direction. */
    18991902    if (curwin->w_p_rl && vim_strchr((char_u *)"()[]{}<>", initc) != NULL)
    19001903        backwards = !backwards;
     
    21242127                        else if (!backwards)
    21252128                            inquote = TRUE;
    21262129                    }
     2130
     2131                    /* ml_get() only keeps one line, need to get linep again */
     2132                    linep = ml_get(pos.lnum);
    21272133                }
    21282134            }
    21292135        }
     
    27952801        i = inc_cursor();
    27962802        if (i == -1 || (i >= 1 && last_line)) /* started at last char in file */
    27972803            return FAIL;
    2798         if (i == 1 && eol && count == 0)      /* started at last char in line */
     2804        if (i >= 1 && eol && count == 0)      /* started at last char in line */
    27992805            return OK;
    28002806
    28012807        /*
     
    36003606    {
    36013607        oap->start = start_pos;
    36023608        oap->motion_type = MCHAR;
     3609        oap->inclusive = FALSE;
    36033610        if (sol)
    3604         {
    36053611            incl(&curwin->w_cursor);
    3606             oap->inclusive = FALSE;
    3607         }
    3608         else
     3612        else if (lt(start_pos, curwin->w_cursor))
     3613            /* Include the character under the cursor. */
    36093614            oap->inclusive = TRUE;
     3615        else
     3616            /* End is before the start (no text in between <>, [], etc.): don't
     3617             * operate on any text. */
     3618            curwin->w_cursor = start_pos;
    36103619    }
    36113620
    36123621    return OK;
     
    37343743
    37353744        if (in_html_tag(FALSE))
    37363745        {
    3737             /* cursor on start tag, move to just after it */
     3746            /* cursor on start tag, move to its '>' */
    37383747            while (*ml_get_cursor() != '>')
    37393748                if (inc_cursor() < 0)
    37403749                    break;
     
    38383847        /* Exclude the start tag. */
    38393848        curwin->w_cursor = start_pos;
    38403849        while (inc_cursor() >= 0)
    3841             if (*ml_get_cursor() == '>' && lt(curwin->w_cursor, end_pos))
     3850            if (*ml_get_cursor() == '>')
    38423851            {
    38433852                inc_cursor();
    38443853                start_pos = curwin->w_cursor;
     
    38603869#ifdef FEAT_VISUAL
    38613870    if (VIsual_active)
    38623871    {
    3863         if (*p_sel == 'e')
     3872        /* If the end is before the start there is no text between tags, select
     3873         * the char under the cursor. */
     3874        if (lt(end_pos, start_pos))
     3875            curwin->w_cursor = start_pos;
     3876        else if (*p_sel == 'e')
    38643877            ++curwin->w_cursor.col;
    38653878        VIsual = start_pos;
    38663879        VIsual_mode = 'v';
     
    38723885    {
    38733886        oap->start = start_pos;
    38743887        oap->motion_type = MCHAR;
    3875         oap->inclusive = TRUE;
     3888        if (lt(end_pos, start_pos))
     3889        {
     3890            /* End is before the start: there is no text between tags; operate
     3891             * on an empty area. */
     3892            curwin->w_cursor = start_pos;
     3893            oap->inclusive = FALSE;
     3894        }
     3895        else
     3896            oap->inclusive = TRUE;
    38763897    }
    38773898    retval = OK;
    38783899
  • src/spell.c

    diff -Naur vim71.orig/src/spell.c vim71/src/spell.c
    old new  
    78297829# if (_MSC_VER <= 1200)
    78307830/* This line is required for VC6 without the service pack.  Also see the
    78317831 * matching #pragma below. */
    7832 /* # pragma optimize("", off) */
     7832 #  pragma optimize("", off)
    78337833# endif
    78347834#endif
    78357835
     
    78597859
    78607860#ifdef _MSC_VER
    78617861# if (_MSC_VER <= 1200)
    7862 /* # pragma optimize("", on) */
     7862 #  pragma optimize("", on)
    78637863# endif
    78647864#endif
    78657865
     
    1218212182            {
    1218312183                n = mb_cptr2len(p);
    1218412184                c = mb_ptr2char(p);
    12185                 if (!soundfold && !spell_iswordp(p + n, curbuf))
     12185                if (p[n] == NUL)
     12186                    c2 = NUL;
     12187                else if (!soundfold && !spell_iswordp(p + n, curbuf))
    1218612188                    c2 = c; /* don't swap non-word char */
    1218712189                else
    1218812190                    c2 = mb_ptr2char(p + n);
     
    1219012192            else
    1219112193#endif
    1219212194            {
    12193                 if (!soundfold && !spell_iswordp(p + 1, curbuf))
     12195                if (p[1] == NUL)
     12196                    c2 = NUL;
     12197                else if (!soundfold && !spell_iswordp(p + 1, curbuf))
    1219412198                    c2 = c; /* don't swap non-word char */
    1219512199                else
    1219612200                    c2 = p[1];
    1219712201            }
    1219812202
     12203            /* When the second character is NUL we can't swap. */
     12204            if (c2 == NUL)
     12205            {
     12206                sp->ts_state = STATE_REP_INI;
     12207                break;
     12208            }
     12209
    1219912210            /* When characters are identical, swap won't do anything.
    1220012211             * Also get here if the second char is not a word character. */
    1220112212            if (c == c2)
  • src/structs.h

    diff -Naur vim71.orig/src/structs.h vim71/src/structs.h
    old new  
    278278    linenr_T    ue_lcount;      /* linecount when u_save called */
    279279    char_u      **ue_array;     /* array of lines in undo block */
    280280    long        ue_size;        /* number of lines in ue_array */
     281#ifdef U_DEBUG
     282    int         ue_magic;       /* magic number to check allocation */
     283#endif
    281284};
    282285
    283286struct u_header
     
    300303    visualinfo_T uh_visual;     /* Visual areas before undo/after redo */
    301304#endif
    302305    time_t      uh_time;        /* timestamp when the change was made */
     306#ifdef U_DEBUG
     307    int         uh_magic;       /* magic number to check allocation */
     308#endif
    303309};
    304310
    305311/* values for uh_flags */
     
    14531459#ifdef FEAT_MBYTE
    14541460    char_u      *b_start_fenc;  /* 'fileencoding' when edit started or NULL */
    14551461    int         b_bad_char;     /* "++bad=" argument when edit started or 0 */
     1462    int         b_start_bomb;   /* 'bomb' when it was read */
    14561463#endif
    14571464
    14581465#ifdef FEAT_EVAL
     
    16941701#define FR_COL  2       /* frame with a column of windows */
    16951702
    16961703/*
     1704 * Struct used for highlighting 'hlsearch' matches, matches defined by
     1705 * ":match" and matches defined by match functions.
     1706 * For 'hlsearch' there is one pattern for all windows.  For ":match" and the
     1707 * match functions there is a different pattern for each window.
     1708 */
     1709typedef struct
     1710{
     1711    regmmatch_T rm;     /* points to the regexp program; contains last found
     1712                           match (may continue in next line) */
     1713    buf_T       *buf;   /* the buffer to search for a match */
     1714    linenr_T    lnum;   /* the line to search for a match */
     1715    int         attr;   /* attributes to be used for a match */
     1716    int         attr_cur; /* attributes currently active in win_line() */
     1717    linenr_T    first_lnum;     /* first lnum to search for multi-line pat */
     1718    colnr_T     startcol; /* in win_line() points to char where HL starts */
     1719    colnr_T     endcol;  /* in win_line() points to char where HL ends */
     1720} match_T;
     1721
     1722/*
     1723 * matchitem_T provides a linked list for storing match items for ":match" and
     1724 * the match functions.
     1725 */
     1726typedef struct matchitem matchitem_T;
     1727struct matchitem
     1728{
     1729    matchitem_T *next;
     1730    int         id;         /* match ID */
     1731    int         priority;   /* match priority */
     1732    char_u      *pattern;   /* pattern to highlight */
     1733    int         hlg_id;     /* highlight group ID */
     1734    regmmatch_T match;      /* regexp program for pattern */
     1735    match_T     hl;         /* struct for doing the actual highlighting */
     1736};
     1737
     1738/*
    16971739 * Structure which contains all information that belongs to a window
    16981740 *
    16991741 * All row numbers are relative to the start of the window, except w_winrow.
     
    19341976#endif
    19351977
    19361978#ifdef FEAT_SEARCH_EXTRA
    1937     regmmatch_T w_match[3];         /* regexp programs for ":match" */
    1938     char_u      *(w_match_pat[3]);  /* patterns for ":match" */
    1939     int         w_match_id[3];      /* highlight IDs for ":match" */
     1979    matchitem_T *w_match_head;          /* head of match list */
     1980    int         w_next_match_id;        /* next match ID */
    19401981#endif
    19411982
    19421983    /*
  • src/syntax.c

    diff -Naur vim71.orig/src/syntax.c vim71/src/syntax.c
    old new  
    6666#define HL_TABLE() ((struct hl_group *)((highlight_ga.ga_data)))
    6767
    6868#ifdef FEAT_CMDL_COMPL
    69 static int include_default = FALSE;     /* include "default" for expansion */
    70 static int include_link = FALSE;        /* include "link" for expansion */
     69/* Flags to indicate an additional string for highlight name completion. */
     70static int include_none = 0;    /* when 1 include "None" */
     71static int include_default = 0; /* when 1 include "default" */
     72static int include_link = 0;    /* when 2 include "link" and "clear" */
    7173#endif
    7274
    7375/*
     
    277279 */
    278280typedef struct state_item
    279281{
    280     int         si_idx;                 /* index of syntax pattern */
     282    int         si_idx;                 /* index of syntax pattern or
     283                                           KEYWORD_IDX */
    281284    int         si_id;                  /* highlight group ID for keywords */
    282285    int         si_trans_id;            /* idem, transparancy removed */
    283286    int         si_m_lnum;              /* lnum of the match */
     
    835838                            current_lnum = end_lnum;
    836839                            break;
    837840                        }
    838                         spp = &(SYN_ITEMS(syn_buf)[cur_si->si_idx]);
    839                         found_flags = spp->sp_flags;
    840                         found_match_idx = spp->sp_sync_idx;
     841                        if (cur_si->si_idx < 0)
     842                        {
     843                            /* Cannot happen? */
     844                            found_flags = 0;
     845                            found_match_idx = KEYWORD_IDX;
     846                        }
     847                        else
     848                        {
     849                            spp = &(SYN_ITEMS(syn_buf)[cur_si->si_idx]);
     850                            found_flags = spp->sp_flags;
     851                            found_match_idx = spp->sp_sync_idx;
     852                        }
    841853                        found_current_lnum = current_lnum;
    842854                        found_current_col = current_col;
    843855                        found_m_endpos = cur_si->si_m_endpos;
     
    17251737{
    17261738    int     attr = 0;
    17271739
     1740    if (can_spell != NULL)
     1741        /* Default: Only do spelling when there is no @Spell cluster or when
     1742         * ":syn spell toplevel" was used. */
     1743        *can_spell = syn_buf->b_syn_spell == SYNSPL_DEFAULT
     1744                    ? (syn_buf->b_spell_cluster_id == 0)
     1745                    : (syn_buf->b_syn_spell == SYNSPL_TOP);
     1746
    17281747    /* check for out of memory situation */
    17291748    if (syn_buf->b_sst_array == NULL)
    17301749        return 0;
     
    25242543    stateitem_T *sip = &CUR_STATE(idx);
    25252544    synpat_T    *spp;
    25262545
     2546    /* This should not happen... */
     2547    if (sip->si_idx < 0)
     2548        return;
     2549
    25272550    spp = &(SYN_ITEMS(syn_buf)[sip->si_idx]);
    25282551    if (sip->si_flags & HL_MATCH)
    25292552        sip->si_id = spp->sp_syn_match_id;
     
    26392662    lpos_T      end_endpos;
    26402663    int         end_idx;
    26412664
     2665    /* return quickly for a keyword */
     2666    if (sip->si_idx < 0)
     2667        return;
     2668
    26422669    /* Don't update when it's already done.  Can be a match of an end pattern
    26432670     * that started in a previous line.  Watch out: can also be a "keepend"
    26442671     * from a containing item. */
     
    27512778    char_u      *line;
    27522779    int         had_match = FALSE;
    27532780
     2781    /* just in case we are invoked for a keyword */
     2782    if (idx < 0)
     2783        return;
     2784
    27542785    /*
    27552786     * Check for being called with a START pattern.
    27562787     * Can happen with a match that continues to the next line, because it
     
    33233354    {
    33243355        vim_free(SYN_ITEMS(buf)[i].sp_cont_list);
    33253356        vim_free(SYN_ITEMS(buf)[i].sp_next_list);
     3357        vim_free(SYN_ITEMS(buf)[i].sp_syn.cont_in_list);
    33263358    }
    33273359}
    33283360
     
    44604492    current_syn_inc_tag = ++running_syn_inc_tag;
    44614493    prev_toplvl_grp = curbuf->b_syn_topgrp;
    44624494    curbuf->b_syn_topgrp = sgl_id;
    4463     if (source ? do_source(eap->arg, FALSE, FALSE) == FAIL
    4464                                 : source_runtime(eap->arg, DOSO_NONE) == FAIL)
     4495    if (source ? do_source(eap->arg, FALSE, DOSO_NONE) == FAIL
     4496                                : source_runtime(eap->arg, TRUE) == FAIL)
    44654497        EMSG2(_(e_notopen), eap->arg);
    44664498    curbuf->b_syn_topgrp = prev_toplvl_grp;
    44674499    current_syn_inc_tag = prev_syn_inc_tag;
     
    59565988{
    59575989    return (buf->b_syn_patterns.ga_len != 0
    59585990            || buf->b_syn_clusters.ga_len != 0
    5959             || curbuf->b_keywtab.ht_used > 0
    5960             || curbuf->b_keywtab_ic.ht_used > 0);
     5991            || buf->b_keywtab.ht_used > 0
     5992            || buf->b_keywtab_ic.ht_used > 0);
    59615993}
    59625994
    59635995#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
     
    59686000    EXP_CASE        /* expand ":syn case" arguments */
    59696001} expand_what;
    59706002
     6003/*
     6004 * Reset include_link, include_default, include_none to 0.
     6005 * Called when we are done expanding.
     6006 */
     6007    void
     6008reset_expand_highlight()
     6009{
     6010    include_link = include_default = include_none = 0;
     6011}
     6012
     6013/*
     6014 * Handle command line completion for :match and :echohl command: Add "None"
     6015 * as highlight group.
     6016 */
     6017    void
     6018set_context_in_echohl_cmd(xp, arg)
     6019    expand_T    *xp;
     6020    char_u      *arg;
     6021{
     6022    xp->xp_context = EXPAND_HIGHLIGHT;
     6023    xp->xp_pattern = arg;
     6024    include_none = 1;
     6025}
    59716026
    59726027/*
    59736028 * Handle command line completion for :syntax command.
     
    59836038    xp->xp_context = EXPAND_SYNTAX;
    59846039    expand_what = EXP_SUBCMD;
    59856040    xp->xp_pattern = arg;
    5986     include_link = FALSE;
    5987     include_default = FALSE;
     6041    include_link = 0;
     6042    include_default = 0;
    59886043
    59896044    /* (part of) subcommand already typed */
    59906045    if (*arg != NUL)
     
    84798534syn_id2name(id)
    84808535    int         id;
    84818536{
    8482     if (id <= 0 || id >= highlight_ga.ga_len)
     8537    if (id <= 0 || id > highlight_ga.ga_len)
    84838538        return (char_u *)"";
    84848539    return HL_TABLE()[id - 1].sg_name;
    84858540}
     
    89499004    return OK;
    89509005}
    89519006
    8952 #ifdef FEAT_CMDL_COMPL
     9007#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
    89539008
    89549009static void highlight_list __ARGS((void));
    89559010static void highlight_list_two __ARGS((int cnt, int attr));
     
    89679022    /* Default: expand group names */
    89689023    xp->xp_context = EXPAND_HIGHLIGHT;
    89699024    xp->xp_pattern = arg;
    8970     include_link = TRUE;
    8971     include_default = TRUE;
     9025    include_link = 2;
     9026    include_default = 1;
    89729027
    89739028    /* (part of) subcommand already typed */
    89749029    if (*arg != NUL)
     
    89769031        p = skiptowhite(arg);
    89779032        if (*p != NUL)                  /* past "default" or group name */
    89789033        {
    8979             include_default = FALSE;
     9034            include_default = 0;
    89809035            if (STRNCMP("default", arg, p - arg) == 0)
    89819036            {
    89829037                arg = skipwhite(p);
     
    89859040            }
    89869041            if (*p != NUL)                      /* past group name */
    89879042            {
    8988                 include_link = FALSE;
     9043                include_link = 0;
    89899044                if (arg[1] == 'i' && arg[0] == 'N')
    89909045                    highlight_list();
    89919046                if (STRNCMP("link", arg, p - arg) == 0
     
    90459100    expand_T    *xp;
    90469101    int         idx;
    90479102{
    9048     if (idx == highlight_ga.ga_len
    90499103#ifdef FEAT_CMDL_COMPL
    9050             && include_link
    9051 #endif
    9052             )
     9104    if (idx == highlight_ga.ga_len && include_none != 0)
     9105        return (char_u *)"none";
     9106    if (idx == highlight_ga.ga_len + include_none && include_default != 0)
     9107        return (char_u *)"default";
     9108    if (idx == highlight_ga.ga_len + include_none + include_default
     9109                                                         && include_link != 0)
    90539110        return (char_u *)"link";
    9054     if (idx == highlight_ga.ga_len + 1
    9055 #ifdef FEAT_CMDL_COMPL
    9056             && include_link
    9057 #endif
    9058             )
     9111    if (idx == highlight_ga.ga_len + include_none + include_default + 1
     9112                                                         && include_link != 0)
    90599113        return (char_u *)"clear";
    9060     if (idx == highlight_ga.ga_len + 2
    9061 #ifdef FEAT_CMDL_COMPL
    9062             && include_default
    90639114#endif
    9064             )
    9065         return (char_u *)"default";
    90669115    if (idx < 0 || idx >= highlight_ga.ga_len)
    90679116        return NULL;
    90689117    return HL_TABLE()[idx].sg_name;
    90699118}
    90709119#endif
    90719120
    9072 #ifdef FEAT_GUI
     9121#if defined(FEAT_GUI) || defined(PROTO)
    90739122/*
    90749123 * Free all the highlight group fonts.
    90759124 * Used when quitting for systems which need it.
  • src/term.c

    diff -Naur vim71.orig/src/term.c vim71/src/term.c
    old new  
    48094809            if (num_bytes == -1)
    48104810                return -1;
    48114811            current_tab = (int)bytes[0];
     4812            if (current_tab == 255)     /* -1 in a byte gives 255 */
     4813                current_tab = -1;
    48124814            slen += num_bytes;
    48134815        }
    48144816        else if (key_name[0] == (int)KS_TABMENU)
  • src/termlib.c

    diff -Naur vim71.orig/src/termlib.c vim71/src/termlib.c
    old new  
    191191            lbuf[0] == '\t' &&
    192192            lbuf[1] == ':')
    193193        {
    194             strcpy(lbuf, lbuf+2);
     194            mch_memmove(lbuf, lbuf + 2, strlen(lbuf + 2) + 1);
    195195            llen -= 2;
    196196        }
    197197        if (lbuf[llen-2] == '\\')               /* and continuations */
  • src/testdir/Makefile

    diff -Naur vim71.orig/src/testdir/Makefile vim71/src/testdir/Makefile
    old new  
    11#
    2 # Makefile to run al tests for Vim
     2# Makefile to run all tests for Vim
    33#
    44
    55VIMPROG = ../vim
    66
     7# Uncomment this line for using valgrind.
     8# The output goes into a file "valgrind.$PID" (sorry, no test number).
     9# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --logfile=valgrind
     10
    711SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
    812                test7.out test8.out test9.out test10.out test11.out \
    913                test12.out  test13.out test14.out test15.out test17.out \
     
    1519                test43.out test44.out test45.out test46.out test47.out \
    1620                test48.out test49.out test51.out test52.out test53.out \
    1721                test54.out test55.out test56.out test57.out test58.out \
    18                 test59.out test60.out test61.out test62.out
     22                test59.out test60.out test61.out test62.out test63.out \
     23                test64.out
    1924
    2025SCRIPTS_GUI = test16.out
    2126
     
    3439$(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG)
    3540
    3641clean:
    37         -rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim test.ok X* viminfo
     42        -rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim test.ok X* valgrind.pid* viminfo
    3843
    3944test1.out: test1.in
    4045        -rm -f $*.failed tiny.vim small.vim mbyte.vim test.ok X* viminfo
    41         $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
     46        $(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
    4247        @/bin/sh -c "if diff test.out $*.ok; \
    4348                then mv -f test.out $*.out; \
    4449                else echo; \
     
    5156        cp $*.ok test.ok
    5257        # Sleep a moment to avoid that the xterm title is messed up
    5358        @-sleep .2
    54         -$(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
     59        -$(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
    5560        @/bin/sh -c "if test -f test.out; then\
    5661                  if diff test.out $*.ok; \
    5762                  then mv -f test.out $*.out; \
     
    6166                fi"
    6267        -rm -rf X* test.ok viminfo
    6368
     69test49.out: test49.vim
     70
     71test60.out: test60.vim
     72
    6473nolog:
    6574        -echo Test results: >test.log
  • src/testdir/test14.in

    diff -Naur vim71.orig/src/testdir/test14.in vim71/src/testdir/test14.in
    old new  
    1818: let tt = "o\<C-V>65\<C-V>x42\<C-V>o103 \<C-V>33a\<C-V>xfg\<C-V>o78\<Esc>"
    1919:endif
    2020:exe "normal " . tt
     21:unlet tt
    2122:.w >>test.out
    2223:set vb
    2324/^Piece
  • src/testdir/test26.in

    diff -Naur vim71.orig/src/testdir/test26.in vim71/src/testdir/test26.in
    old new  
    3737:    endif
    3838:  endif
    3939:endwhile
     40:unlet i j
    4041:'t,$w! test.out
    4142:qa!
    4243ENDTEST
  • src/testdir/test34.in

    diff -Naur vim71.orig/src/testdir/test34.in vim71/src/testdir/test34.in
    old new  
    5252---*---
    5353(one
    5454(two
    55 [(one again:$-5,$wq! test.out
     55[(one again:$-5,$w! test.out
     56:delfunc Table
     57:delfunc Compute
     58:delfunc Expr1
     59:delfunc Expr2
     60:delfunc ListItem
     61:delfunc ListReset
     62:unlet retval counter
     63:q!
    5664ENDTEST
    5765
    5866here
  • src/testdir/test45.in

    diff -Naur vim71.orig/src/testdir/test45.in vim71/src/testdir/test45.in
    old new  
    5555/kk$
    5656:call append("$", foldlevel("."))
    5757:/^last/+1,$w! test.out
     58:delfun Flvl
    5859:qa!
    5960ENDTEST
    6061
  • src/testdir/test47.in

    diff -Naur vim71.orig/src/testdir/test47.in vim71/src/testdir/test47.in
    old new  
    3434:call append("$", two)
    3535:call append("$", three)
    3636:$-2,$w! test.out
     37:unlet one two three
    3738:qa!
    3839ENDTEST
    3940
  • src/testdir/test49.in

    diff -Naur vim71.orig/src/testdir/test49.in vim71/src/testdir/test49.in
    old new  
    11This is a test of the script language.
    22
    33If after adding a new test, the test output doesn't appear properly in
    4 test49.failed, try to add one ore more "G"s at the line before ENDTEST.
     4test49.failed, try to add one ore more "G"s at the line ending in "test.out"
    55
    66STARTTEST
    77:so small.vim
    88:se nocp nomore viminfo+=nviminfo
    99:so test49.vim
    10 GGGGGGGGGG"rp:.-,$wq! test.out
     10GGGGGGGGGGGGGG"rp:.-,$w! test.out
     11:"
     12:" make valgrind happy
     13:redir => funclist
     14:silent func
     15:redir END
     16:for line in split(funclist, "\n")
     17:  let name = matchstr(line, 'function \zs[A-Z]\w*\ze(')
     18:  if name != ''
     19:    exe "delfunc " . name
     20:  endif
     21:endfor
     22:for v in keys(g:)
     23:  silent! exe "unlet " . v
     24:endfor
     25:unlet v
     26:qa!
    1127ENDTEST
    1228
    1329Results of test49.vim:
  • src/testdir/test55.in

    diff -Naur vim71.orig/src/testdir/test55.in vim71/src/testdir/test55.in
    old new  
    345345:endfun
    346346:call Test(1, 2, [3, 4], {5: 6})  " This may take a while
    347347:"
     348:delfunc Test
     349:unlet dict
     350:call garbagecollect(1)
     351:"
    348352:/^start:/,$wq! test.out
    349353ENDTEST
    350354
  • src/testdir/test56.in

    diff -Naur vim71.orig/src/testdir/test56.in vim71/src/testdir/test56.in
    old new  
    1717fun s:DoNothing()
    1818  call append(line('$'), "nothing line")
    1919endfun
    20 nnoremap <buffer> _x    :call <SID>DoNothing()<bar>call <SID>DoLast()<cr>
     20nnoremap <buffer> _x    :call <SID>DoNothing()<bar>call <SID>DoLast()<bar>delfunc <SID>DoNothing<bar>delfunc <SID>DoLast<cr>
    2121end:
  • src/testdir/test58.in

    diff -Naur vim71.orig/src/testdir/test58.in vim71/src/testdir/test58.in
    old new  
    8686:$put =str
    8787`m]s:let [str, a] = spellbadword()
    8888:$put =str
     89:unlet str a
    8990:"
    9091:" Postponed prefixes
    9192:call TestOne('2', '1')
     
    100101:" NOSLITSUGS
    101102:call TestOne('8', '8')
    102103:"
     104:" clean up for valgrind
     105:delfunc TestOne
     106:set spl= enc=latin1
     107:"
    103108gg:/^test output:/,$wq! test.out
    104109ENDTEST
    105110
  • src/testdir/test59.in

    diff -Naur vim71.orig/src/testdir/test59.in vim71/src/testdir/test59.in
    old new  
    9090:$put =str
    9191`m]s:let [str, a] = spellbadword()
    9292:$put =str
     93:unlet str a
    9394:"
    9495:" Postponed prefixes
    9596:call TestOne('2', '1')
     
    101102:call TestOne('6', '6')
    102103:call TestOne('7', '7')
    103104:"
     105:" clean up for valgrind
     106:delfunc TestOne
     107:set spl= enc=latin1
     108:"
    104109gg:/^test output:/,$wq! test.out
    105110ENDTEST
    106111
  • src/testdir/test60.in

    diff -Naur vim71.orig/src/testdir/test60.in vim71/src/testdir/test60.in
    old new  
    569569    redir END
    570570endfunction
    571571:call TestExists()
     572:delfunc TestExists
     573:delfunc RunTest
     574:delfunc TestFuncArg
    572575:edit! test.out
    573576:set ff=unix
    574577:w
  • src/testdir/test60.vim

    diff -Naur vim71.orig/src/testdir/test60.vim vim71/src/testdir/test60.vim
    old new  
    9494else
    9595    echo "FAILED"
    9696endif
     97unlet str
    9798
  • src/testdir/test62.in

    diff -Naur vim71.orig/src/testdir/test62.in vim71/src/testdir/test62.in
    old new  
    77:let nr = tabpagenr()
    88:q
    99:call append(line('$'), 'tab page ' . nr)
     10:unlet nr
    1011:"
    1112:" Open three tab pages and use ":tabdo"
    1213:0tabnew
     
    2324:q!
    2425:call append(line('$'), line1)
    2526:call append(line('$'), line2)
     27:unlet line1 line2
    2628:"
    2729:"
    2830:/^Results/,$w! test.out
  • src/testdir/test63.in

    diff -Naur vim71.orig/src/testdir/test63.in vim71/src/testdir/test63.in
    old new  
     1Test for ":match", ":2match", ":3match", "clearmatches()", "getmatches()",
     2"matchadd()", "matcharg()", "matchdelete()", and "setmatches()".
     3
     4STARTTEST
     5:so small.vim
     6:" --- Check that "matcharg()" returns the correct group and pattern if a match
     7:" --- is defined.
     8:let @r = "*** Test 1: "
     9:highlight MyGroup1 ctermbg=red
     10:highlight MyGroup2 ctermbg=green
     11:highlight MyGroup3 ctermbg=blue
     12:match MyGroup1 /TODO/
     13:2match MyGroup2 /FIXME/
     14:3match MyGroup3 /XXX/
     15:if matcharg(1) == ['MyGroup1', 'TODO'] && matcharg(2) == ['MyGroup2', 'FIXME'] && matcharg(3) == ['MyGroup3', 'XXX']
     16:  let @r .= "OK\n"
     17:else
     18:  let @r .= "FAILED\n"
     19:endif
     20:" --- Check that "matcharg()" returns an empty list if the argument is not 1,
     21:" --- 2 or 3 (only 0 and 4 are tested).
     22:let @r .= "*** Test 2: "
     23:if matcharg(0) == [] && matcharg(4) == []
     24:  let @r .= "OK\n"
     25:else
     26:  let @r .= "FAILED\n"
     27:endif
     28:" --- Check that "matcharg()" returns ['', ''] if a match is not defined.
     29:let @r .= "*** Test 3: "
     30:match
     31:2match
     32:3match
     33:if matcharg(1) == ['', ''] && matcharg(2) == ['', ''] && matcharg(3) == ['', '']
     34:  let @r .= "OK\n"
     35:else
     36:  let @r .= "FAILED\n"
     37:endif
     38:" --- Check that "matchadd()" and "getmatches()" agree on added matches and
     39:" --- that default values apply.
     40:let @r .= "*** Test 4: "
     41:let m1 = matchadd("MyGroup1", "TODO")
     42:let m2 = matchadd("MyGroup2", "FIXME", 42)
     43:let m3 = matchadd("MyGroup3", "XXX", 60, 17)
     44:if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 4}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 42, 'id': 5}, {'group': 'MyGroup3', 'pattern': 'XXX', 'priority': 60, 'id': 17}]
     45:  let @r .= "OK\n"
     46:else
     47:  let @r .= "FAILED\n"
     48:endif
     49:" --- Check that "matchdelete()" deletes the matches defined in the previous
     50:" --- test correctly.
     51:let @r .= "*** Test 5: "
     52:call matchdelete(m1)
     53:call matchdelete(m2)
     54:call matchdelete(m3)
     55:unlet m1
     56:unlet m2
     57:unlet m3
     58:if getmatches() == []
     59:  let @r .= "OK\n"
     60:else
     61:  let @r .= "FAILED\n"
     62:endif
     63:" --- Check that "matchdelete()" returns 0 if successful and otherwise -1.
     64:let @r .= "*** Test 6: "
     65:let m = matchadd("MyGroup1", "TODO")
     66:let r1 = matchdelete(m)
     67:let r2 = matchdelete(42)
     68:if r1 == 0 && r2 == -1
     69:  let @r .= "OK\n"
     70:else
     71:  let @r .= "FAILED\n"
     72:endif
     73:unlet m
     74:unlet r1
     75:unlet r2
     76:" --- Check that "clearmatches()" clears all matches defined by ":match" and
     77:" --- "matchadd()".
     78:let @r .= "*** Test 7: "
     79:let m1 = matchadd("MyGroup1", "TODO")
     80:let m2 = matchadd("MyGroup2", "FIXME", 42)
     81:let m3 = matchadd("MyGroup3", "XXX", 60, 17)
     82:match MyGroup1 /COFFEE/
     83:2match MyGroup2 /HUMPPA/
     84:3match MyGroup3 /VIM/
     85:call clearmatches()
     86:if getmatches() == []
     87:  let @r .= "OK\n"
     88:else
     89:  let @r .= "FAILED\n"
     90:endif
     91:unlet m1
     92:unlet m2
     93:unlet m3
     94:" --- Check that "setmatches()" restores a list of matches saved by
     95:" --- "getmatches()" without changes. (Matches with equal priority must also
     96:" --- remain in the same order.)
     97:let @r .= "*** Test 8: "
     98:let m1 = matchadd("MyGroup1", "TODO")
     99:let m2 = matchadd("MyGroup2", "FIXME", 42)
     100:let m3 = matchadd("MyGroup3", "XXX", 60, 17)
     101:match MyGroup1 /COFFEE/
     102:2match MyGroup2 /HUMPPA/
     103:3match MyGroup3 /VIM/
     104:let ml = getmatches()
     105:call clearmatches()
     106:call setmatches(ml)
     107:if getmatches() == ml
     108:  let @r .= "OK\n"
     109:else
     110:  let @r .= "FAILED\n"
     111:endif
     112:call clearmatches()
     113:unlet m1
     114:unlet m2
     115:unlet m3
     116:unlet ml
     117:" --- Check that "setmatches()" will not add two matches with the same ID. The
     118:" --- expected behaviour (for now) is to add the first match but not the
     119:" --- second and to return 0 (even though it is a matter of debate whether
     120:" --- this can be considered successful behaviour).
     121:let @r .= "*** Test 9: "
     122:let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])
     123:if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}] && r1 == 0
     124:  let @r .= "OK\n"
     125:else
     126:  let @r .= "FAILED\n"
     127:endif
     128:call clearmatches()
     129:unlet r1
     130:" --- Check that "setmatches()" returns 0 if successful and otherwise -1.
     131:" --- (A range of valid and invalid input values are tried out to generate the
     132:" --- return values.)
     133:let @r .= "*** Test 10: "
     134:let rs1 = setmatches([])
     135:let rs2 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])
     136:call clearmatches()
     137:let rf1 = setmatches(0)
     138:let rf2 = setmatches([0])
     139:let rf3 = setmatches([{'wrong key': 'wrong value'}])
     140:if rs1 == 0 && rs2 == 0 && rf1 == -1 && rf2 == -1 && rf3 == -1
     141:  let @r .= "OK\n"
     142:else
     143:  let @r .= "FAILED\n"
     144:endif
     145:unlet rs1
     146:unlet rs2
     147:unlet rf1
     148:unlet rf2
     149:unlet rf3
     150:highlight clear MyGroup1
     151:highlight clear MyGroup2
     152:highlight clear MyGroup3
     153G"rp
     154:/^Results/,$wq! test.out
     155ENDTEST
     156
     157Results of test63:
  • src/testdir/test63.ok

    diff -Naur vim71.orig/src/testdir/test63.ok vim71/src/testdir/test63.ok
    old new  
     1Results of test63:
     2*** Test 1: OK
     3*** Test 2: OK
     4*** Test 3: OK
     5*** Test 4: OK
     6*** Test 5: OK
     7*** Test 6: OK
     8*** Test 7: OK
     9*** Test 8: OK
     10*** Test 9: OK
     11*** Test 10: OK
  • src/testdir/test64.in

    diff -Naur vim71.orig/src/testdir/test64.in vim71/src/testdir/test64.in
    old new  
     1Test for regexp patterns.
     2
     3A pattern that gives the expected result produces OK, so that we know it was
     4actually tried.
     5
     6STARTTEST
     7:so small.vim
     8:" tl is a List of Lists with:
     9:"    regexp pattern
     10:"    text to test the pattern on
     11:"    expected match (optional)
     12:"    expected submatch 1 (optional)
     13:"    expected submatch 2 (optional)
     14:"    etc.
     15:"  When there is no match use only the first two items.
     16:let tl = []
     17:call add(tl, ['b', 'abcdef', 'b'])
     18:call add(tl, ['bc*', 'abccccdef', 'bcccc'])
     19:call add(tl, ['bc\{-}', 'abccccdef', 'b'])
     20:call add(tl, ['bc\{-}\(d\)', 'abccccdef', 'bccccd', 'd'])
     21:call add(tl, ['x', 'abcdef'])
     22:"
     23:for t in tl
     24:  let l = matchlist(t[1], t[0])
     25:" check the match itself
     26:  if len(l) == 0 && len(t) > 2
     27:    $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", did not match, expected: \"' . t[2] . '\"'
     28:  elseif len(l) > 0 && len(t) == 2
     29:    $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected no match'
     30:  elseif len(t) > 2 && l[0] != t[2]
     31:    $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected: \"' . t[2] . '\"'
     32:  else
     33:    $put ='OK'
     34:  endif
     35:  if len(l) > 0
     36:"   check all the nine submatches
     37:    for i in range(1, 9)
     38:      if len(t) <= i + 2
     39:        let e = ''
     40:      else
     41:        let e = t[i + 2]
     42:      endif
     43:      if l[i] != e
     44:        $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
     45:      endif
     46:    endfor
     47:    unlet i
     48:  endif
     49:endfor
     50:unlet t tl e l
     51:/^Results/,$wq! test.out
     52ENDTEST
     53
     54Results of test64:
  • src/testdir/test64.ok

    diff -Naur vim71.orig/src/testdir/test64.ok vim71/src/testdir/test64.ok
    old new  
     1Results of test64:
     2OK
     3OK
     4OK
     5OK
     6OK
  • src/ui.c

    diff -Naur vim71.orig/src/ui.c vim71/src/ui.c
    old new  
    16031603#if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM) \
    16041604        || defined(FEAT_XCLIPBOARD) || defined(VMS) \
    16051605        || defined(FEAT_SNIFF) || defined(FEAT_CLIENTSERVER) \
    1606         || (defined(FEAT_GUI) && (!defined(USE_ON_FLY_SCROLL) \
    1607                 || defined(FEAT_MENU))) \
    16081606        || defined(PROTO)
    16091607/*
    16101608 * Add the given bytes to the input buffer
     
    16301628}
    16311629#endif
    16321630
    1633 #if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) \
     1631#if ((defined(FEAT_XIM) || defined(FEAT_DND)) && defined(FEAT_GUI_GTK)) \
     1632        || defined(FEAT_GUI_MSWIN) \
     1633        || defined(FEAT_GUI_MAC) \
    16341634        || (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) \
    16351635        || (defined(FEAT_GUI) && (!defined(USE_ON_FLY_SCROLL) \
    16361636                || defined(FEAT_MENU))) \
  • src/undo.c

    diff -Naur vim71.orig/src/undo.c vim71/src/undo.c
    old new  
    7676 * buffer is unloaded.
    7777 */
    7878
     79/* Uncomment the next line for including the u_check() function.  This warns
     80 * for errors in the debug information. */
     81/* #define U_DEBUG 1 */
     82#define UH_MAGIC 0x18dade       /* value for uh_magic when in use */
     83#define UE_MAGIC 0xabc123       /* value for ue_magic when in use */
     84
    7985#include "vim.h"
    8086
    8187/* See below: use malloc()/free() for memory management. */
     
    113119 */
    114120static int      undo_undoes = FALSE;
    115121
     122#ifdef U_DEBUG
     123/*
     124 * Check the undo structures for being valid.  Print a warning when something
     125 * looks wrong.
     126 */
     127static int seen_b_u_curhead;
     128static int seen_b_u_newhead;
     129static int header_count;
     130
     131    static void
     132u_check_tree(u_header_T *uhp,
     133        u_header_T *exp_uh_next,
     134        u_header_T *exp_uh_alt_prev)
     135{
     136    u_entry_T *uep;
     137
     138    if (uhp == NULL)
     139        return;
     140    ++header_count;
     141    if (uhp == curbuf->b_u_curhead && ++seen_b_u_curhead > 1)
     142    {
     143        EMSG("b_u_curhead found twice (looping?)");
     144        return;
     145    }
     146    if (uhp == curbuf->b_u_newhead && ++seen_b_u_newhead > 1)
     147    {
     148        EMSG("b_u_newhead found twice (looping?)");
     149        return;
     150    }
     151
     152    if (uhp->uh_magic != UH_MAGIC)
     153        EMSG("uh_magic wrong (may be using freed memory)");
     154    else
     155    {
     156        /* Check pointers back are correct. */
     157        if (uhp->uh_next != exp_uh_next)
     158        {
     159            EMSG("uh_next wrong");
     160            smsg((char_u *)"expected: 0x%x, actual: 0x%x",
     161                                                   exp_uh_next, uhp->uh_next);
     162        }
     163        if (uhp->uh_alt_prev != exp_uh_alt_prev)
     164        {
     165            EMSG("uh_alt_prev wrong");
     166            smsg((char_u *)"expected: 0x%x, actual: 0x%x",
     167                                           exp_uh_alt_prev, uhp->uh_alt_prev);
     168        }
     169
     170        /* Check the undo tree at this header. */
     171        for (uep = uhp->uh_entry; uep != NULL; uep = uep->ue_next)
     172        {
     173            if (uep->ue_magic != UE_MAGIC)
     174            {
     175                EMSG("ue_magic wrong (may be using freed memory)");
     176                break;
     177            }
     178        }
     179
     180        /* Check the next alt tree. */
     181        u_check_tree(uhp->uh_alt_next, uhp->uh_next, uhp);
     182
     183        /* Check the next header in this branch. */
     184        u_check_tree(uhp->uh_prev, uhp, NULL);
     185    }
     186}
     187
     188    void
     189u_check(int newhead_may_be_NULL)
     190{
     191    seen_b_u_newhead = 0;
     192    seen_b_u_curhead = 0;
     193    header_count = 0;
     194
     195    u_check_tree(curbuf->b_u_oldhead, NULL, NULL);
     196
     197    if (seen_b_u_newhead == 0 && curbuf->b_u_oldhead != NULL
     198            && !(newhead_may_be_NULL && curbuf->b_u_newhead == NULL))
     199        EMSGN("b_u_newhead invalid: 0x%x", curbuf->b_u_newhead);
     200    if (curbuf->b_u_curhead != NULL && seen_b_u_curhead == 0)
     201        EMSGN("b_u_curhead invalid: 0x%x", curbuf->b_u_curhead);
     202    if (header_count != curbuf->b_u_numhead)
     203    {
     204        EMSG("b_u_numhead invalid");
     205        smsg((char_u *)"expected: %ld, actual: %ld",
     206                               (long)header_count, (long)curbuf->b_u_numhead);
     207    }
     208}
     209#endif
     210
    116211/*
    117212 * Save the current line for both the "u" and "U" command.
    118213 * Returns OK or FAIL.
     
    243338    if (!undo_allowed())
    244339        return FAIL;
    245340
     341#ifdef U_DEBUG
     342    u_check(FALSE);
     343#endif
    246344#ifdef FEAT_NETBEANS_INTG
    247345    /*
    248346     * Netbeans defines areas that cannot be modified.  Bail out here when
     
    294392            uhp = (u_header_T *)U_ALLOC_LINE((unsigned)sizeof(u_header_T));
    295393            if (uhp == NULL)
    296394                goto nomem;
     395#ifdef U_DEBUG
     396            uhp->uh_magic = UH_MAGIC;
     397#endif
    297398        }
    298399        else
    299400            uhp = NULL;
     
    316417        {
    317418            u_header_T      *uhfree = curbuf->b_u_oldhead;
    318419
    319             /* If there is no branch only free one header. */
    320             if (uhfree->uh_alt_next == NULL)
     420            if (uhfree == old_curhead)
     421                /* Can't reconnect the branch, delete all of it. */
     422                u_freebranch(curbuf, uhfree, &old_curhead);
     423            else if (uhfree->uh_alt_next == NULL)
     424                /* There is no branch, only free one header. */
    321425                u_freeheader(curbuf, uhfree, &old_curhead);
    322426            else
    323427            {
     
    326430                    uhfree = uhfree->uh_alt_next;
    327431                u_freebranch(curbuf, uhfree, &old_curhead);
    328432            }
     433#ifdef U_DEBUG
     434            u_check(TRUE);
     435#endif
    329436        }
    330437
    331438        if (uhp == NULL)                /* no undo at all */
     
    478585    uep = (u_entry_T *)U_ALLOC_LINE((unsigned)sizeof(u_entry_T));
    479586    if (uep == NULL)
    480587        goto nomem;
     588#ifdef U_DEBUG
     589    uep->ue_magic = UE_MAGIC;
     590#endif
    481591
    482592    uep->ue_size = size;
    483593    uep->ue_top = top;
     
    525635    curbuf->b_u_synced = FALSE;
    526636    undo_undoes = FALSE;
    527637
     638#ifdef U_DEBUG
     639    u_check(FALSE);
     640#endif
    528641    return OK;
    529642
    530643nomem:
     
    9551068    int         empty_buffer;               /* buffer became empty */
    9561069    u_header_T  *curhead = curbuf->b_u_curhead;
    9571070
     1071#ifdef U_DEBUG
     1072    u_check(FALSE);
     1073#endif
    9581074    old_flags = curhead->uh_flags;
    9591075    new_flags = (curbuf->b_changed ? UH_CHANGED : 0) +
    9601076               ((curbuf->b_ml.ml_flags & ML_EMPTY) ? UH_EMPTYBUF : 0);
     
    11861302    /* The timestamp can be the same for multiple changes, just use the one of
    11871303     * the undone/redone change. */
    11881304    curbuf->b_u_seq_time = curhead->uh_time;
     1305#ifdef U_DEBUG
     1306    u_check(FALSE);
     1307#endif
    11891308}
    11901309
    11911310/*
     
    15151634}
    15161635
    15171636/*
    1518  * Free one header and its entry list and adjust the pointers.
     1637 * Free one header "uhp" and its entry list and adjust the pointers.
    15191638 */
    15201639    static void
    15211640u_freeheader(buf, uhp, uhpp)
     
    15231642    u_header_T      *uhp;
    15241643    u_header_T      **uhpp;     /* if not NULL reset when freeing this header */
    15251644{
     1645    u_header_T      *uhap;
     1646
    15261647    /* When there is an alternate redo list free that branch completely,
    15271648     * because we can never go there. */
    15281649    if (uhp->uh_alt_next != NULL)
     
    15401661    if (uhp->uh_prev == NULL)
    15411662        buf->b_u_newhead = uhp->uh_next;
    15421663    else
    1543         uhp->uh_prev->uh_next = uhp->uh_next;
     1664        for (uhap = uhp->uh_prev; uhap != NULL; uhap = uhap->uh_alt_next)
     1665            uhap->uh_next = uhp->uh_next;
    15441666
    15451667    u_freeentries(buf, uhp, uhpp);
    15461668}
     
    15851707    /* Check for pointers to the header that become invalid now. */
    15861708    if (buf->b_u_curhead == uhp)
    15871709        buf->b_u_curhead = NULL;
     1710    if (buf->b_u_newhead == uhp)
     1711        buf->b_u_newhead = NULL;  /* freeing the newest entry */
    15881712    if (uhpp != NULL && uhp == *uhpp)
    15891713        *uhpp = NULL;
    15901714
     
    15941718        u_freeentry(uep, uep->ue_size);
    15951719    }
    15961720
     1721#ifdef U_DEBUG
     1722    uhp->uh_magic = 0;
     1723#endif
    15971724    U_FREE_LINE((char_u *)uhp);
    15981725    --buf->b_u_numhead;
    15991726}
     
    16091736    while (n > 0)
    16101737        U_FREE_LINE(uep->ue_array[--n]);
    16111738    U_FREE_LINE((char_u *)uep->ue_array);
     1739#ifdef U_DEBUG
     1740    uep->ue_magic = 0;
     1741#endif
    16121742    U_FREE_LINE((char_u *)uep);
    16131743}
    16141744
  • src/version.c

    diff -Naur vim71.orig/src/version.c vim71/src/version.c
    old new  
    667667static int included_patches[] =
    668668{   /* Add new patch number below this line */
    669669/**/
     670    140,
     671/**/
     672    139,
     673/**/
     674    138,
     675/**/
     676    137,
     677/**/
     678    136,
     679/**/
     680    135,
     681/**/
     682    133,
     683/**/
     684    132,
     685/**/
     686    131,
     687/**/
     688    130,
     689/**/
     690    127,
     691/**/
     692    125,
     693/**/
     694    123,
     695/**/
     696    122,
     697/**/
     698    121,
     699/**/
     700    120,
     701/**/
     702    119,
     703/**/
     704    118,
     705/**/
     706    117,
     707/**/
     708    116,
     709/**/
     710    115,
     711/**/
     712    114,
     713/**/
     714    113,
     715/**/
     716    112,
     717/**/
     718    111,
     719/**/
     720    110,
     721/**/
     722    109,
     723/**/
     724    108,
     725/**/
     726    107,
     727/**/
     728    106,
     729/**/
     730    105,
     731/**/
     732    104,
     733/**/
     734    103,
     735/**/
     736    102,
     737/**/
     738    101,
     739/**/
     740    100,
     741/**/
     742    99,
     743/**/
     744    98,
     745/**/
     746    97,
     747/**/
     748    96,
     749/**/
     750    95,
     751/**/
     752    94,
     753/**/
     754    93,
     755/**/
     756    90,
     757/**/
     758    89,
     759/**/
     760    87,
     761/**/
     762    86,
     763/**/
     764    85,
     765/**/
     766    84,
     767/**/
     768    83,
     769/**/
     770    82,
     771/**/
     772    81,
     773/**/
     774    79,
     775/**/
     776    78,
     777/**/
     778    77,
     779/**/
     780    76,
     781/**/
     782    75,
     783/**/
     784    74,
     785/**/
     786    73,
     787/**/
     788    71,
     789/**/
     790    69,
     791/**/
     792    68,
     793/**/
     794    67,
     795/**/
     796    66,
     797/**/
     798    64,
     799/**/
     800    63,
     801/**/
     802    62,
     803/**/
     804    61,
     805/**/
     806    60,
     807/**/
     808    59,
     809/**/
     810    58,
     811/**/
     812    57,
     813/**/
     814    56,
     815/**/
     816    55,
     817/**/
     818    54,
     819/**/
     820    53,
     821/**/
     822    52,
     823/**/
     824    51,
     825/**/
     826    50,
     827/**/
     828    49,
     829/**/
     830    48,
     831/**/
     832    47,
     833/**/
     834    46,
     835/**/
     836    45,
     837/**/
     838    44,
     839/**/
     840    43,
     841/**/
     842    42,
     843/**/
     844    40,
     845/**/
     846    39,
     847/**/
     848    38,
     849/**/
     850    37,
     851/**/
     852    36,
     853/**/
     854    35,
     855/**/
     856    34,
     857/**/
     858    33,
     859/**/
     860    32,
     861/**/
     862    31,
     863/**/
     864    30,
     865/**/
     866    29,
     867/**/
     868    28,
     869/**/
     870    27,
     871/**/
     872    26,
     873/**/
     874    25,
     875/**/
     876    24,
     877/**/
     878    23,
     879/**/
     880    22,
     881/**/
     882    21,
     883/**/
     884    20,
     885/**/
     886    19,
     887/**/
     888    18,
     889/**/
     890    17,
     891/**/
     892    16,
     893/**/
     894    15,
     895/**/
     896    14,
     897/**/
     898    13,
     899/**/
     900    12,
     901/**/
     902    11,
     903/**/
     904    10,
     905/**/
     906    9,
     907/**/
     908    8,
     909/**/
     910    6,
     911/**/
     912    5,
     913/**/
     914    4,
     915/**/
     916    2,
     917/**/
     918    1,
     919/**/
    670920    0
    671921};
    672922
  • src/vim.h

    diff -Naur vim71.orig/src/vim.h vim71/src/vim.h
    old new  
    13801380#endif
    13811381
    13821382#ifdef FEAT_MBYTE
    1383 # define MB_STRICMP(d, s)       (has_mbyte ? mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL) : STRICMP((d), (s)))
    1384 # define MB_STRNICMP(d, s, n)   (has_mbyte ? mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n)) : STRNICMP((d), (s), (n)))
     1383/* We need to call mb_stricmp() even when we aren't dealing with a multi-byte
     1384 * encoding because mb_stricmp() takes care of all ascii and non-ascii
     1385 * encodings, including characters with umluats in latin1, etc., while
     1386 * STRICMP() only handles the system locale version, which often does not
     1387 * handle non-ascii properly. */
     1388
     1389# define MB_STRICMP(d, s)       mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL)
     1390# define MB_STRNICMP(d, s, n)   mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n))
    13851391#else
    13861392# define MB_STRICMP(d, s)       STRICMP((d), (s))
    13871393# define MB_STRNICMP(d, s, n)   STRNICMP((d), (s), (n))
  • src/vimtutor

    diff -Naur vim71.orig/src/vimtutor vim71/src/vimtutor
    old new  
    3939# remove the copy of the tutor on exit
    4040trap "rm -rf $TODELETE" 0 1 2 3 9 11 13 15
    4141
    42 # Vim could be called "vim" or "vi".  Also check for "vim6", for people who
    43 # have Vim 5.x installed as "vim" and Vim 6.0 as "vim6".
    44 testvim=`which vim6 2>/dev/null`
    45 if test -f "$testvim"; then
    46         VIM=vim6
    47 else
    48         testvim=`which vim`
     42# Vim could be called "vim" or "vi".  Also check for "vimN", for people who
     43# have Vim installed with its version number.
     44# We anticipate up to a future Vim 8 version :-).
     45seq="vim vim8 vim75 vim74 vim73 vim72 vim71 vim70 vim7 vim6 vi"
     46for i in $seq; do
     47        testvim=`which $i 2>/dev/null`
    4948        if test -f "$testvim"; then
    50                 VIM=vim
    51         else
    52                 VIM=vi
     49                VIM=$i
     50                break
    5351        fi
     52done
     53
     54# When no Vim version was found fall back to "vim", you'll get an error message
     55# below.
     56if test -z "$VIM"; then
     57        VIM=vim
    5458fi
    5559
    5660# Use Vim to copy the tutor, it knows the value of $VIMRUNTIME
  • src/window.c

    diff -Naur vim71.orig/src/window.c vim71/src/window.c
    old new  
    7575static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
    7676
    7777#endif /* FEAT_WINDOWS */
     78
    7879static win_T *win_alloc __ARGS((win_T *after));
    7980static void win_new_height __ARGS((win_T *, int));
    8081
     
    583584                ++no_mapping;
    584585                ++allow_keys;   /* no mapping for xchar, but allow key codes */
    585586                if (xchar == NUL)
    586                     xchar = safe_vgetc();
     587                    xchar = plain_vgetc();
    587588#ifdef FEAT_LANGMAP
    588589                LANGMAP_ADJUST(xchar, TRUE);
    589590#endif
     
    732733    if (flags & WSP_VERT)
    733734    {
    734735        layout = FR_ROW;
    735         do_equal = (p_ea && new_size == 0 && *p_ead != 'v');
    736736
    737737        /*
    738738         * Check if we are able to split the current window and compute its
     
    769769         * instead, if possible. */
    770770        if (oldwin->w_p_wfw)
    771771            win_setwidth_win(oldwin->w_width + new_size, oldwin);
     772
     773        /* Only make all windows the same width if one of them (except oldwin)
     774         * is wider than one of the split windows. */
     775        if (!do_equal && p_ea && size == 0 && *p_ead != 'v'
     776           && oldwin->w_frame->fr_parent != NULL)
     777        {
     778            frp = oldwin->w_frame->fr_parent->fr_child;
     779            while (frp != NULL)
     780            {
     781                if (frp->fr_win != oldwin && frp->fr_win != NULL
     782                        && (frp->fr_win->w_width > new_size
     783                            || frp->fr_win->w_width > oldwin->w_width
     784                                                   - new_size - STATUS_HEIGHT))
     785                {
     786                    do_equal = TRUE;
     787                    break;
     788                }
     789                frp = frp->fr_next;
     790            }
     791        }
    772792    }
    773793    else
    774794#endif
    775795    {
    776796        layout = FR_COL;
    777         do_equal = (p_ea && new_size == 0
    778 #ifdef FEAT_VERTSPLIT
    779                 && *p_ead != 'h'
    780 #endif
    781                 );
    782797
    783798        /*
    784799         * Check if we are able to split the current window and compute its
     
    831846            if (need_status)
    832847                oldwin_height -= STATUS_HEIGHT;
    833848        }
     849
     850        /* Only make all windows the same height if one of them (except oldwin)
     851         * is higher than one of the split windows. */
     852        if (!do_equal && p_ea && size == 0
     853#ifdef FEAT_VERTSPLIT
     854                && *p_ead != 'h'
     855#endif
     856           && oldwin->w_frame->fr_parent != NULL)
     857        {
     858            frp = oldwin->w_frame->fr_parent->fr_child;
     859            while (frp != NULL)
     860            {
     861                if (frp->fr_win != oldwin && frp->fr_win != NULL
     862                        && (frp->fr_win->w_height > new_size
     863                            || frp->fr_win->w_height > oldwin_height - new_size
     864                                                              - STATUS_HEIGHT))
     865                {
     866                    do_equal = TRUE;
     867                    break;
     868                }
     869                frp = frp->fr_next;
     870            }
     871        }
    834872    }
    835873
    836874    /*
     
    12531291     * Don't execute autocommands while creating the windows.  Must do that
    12541292     * when putting the buffers in the windows.
    12551293     */
    1256     ++autocmd_block;
     1294    block_autocmds();
    12571295#endif
    12581296
    12591297    /* todo is number of windows left to create */
     
    12751313        }
    12761314
    12771315#ifdef FEAT_AUTOCMD
    1278     --autocmd_block;
     1316    unblock_autocmds();
    12791317#endif
    12801318
    12811319    /* return actual number of windows */
     
    21202158        if (wp->w_p_pvw || bt_quickfix(wp->w_buffer))
    21212159        {
    21222160            /*
    2123              * The cursor goes to the preview or the quickfix window, try
     2161             * If the cursor goes to the preview or the quickfix window, try
    21242162             * finding another window to go to.
    21252163             */
    21262164            for (;;)
     
    23072345    frame_T     *frp, *frp2, *frp3;
    23082346    frame_T     *frp_close = win->w_frame;
    23092347    win_T       *wp;
    2310     int         old_size = 0;
    23112348
    23122349    /*
    23132350     * If there is only one window there is nothing to remove.
     
    23282365    if (frp_close->fr_parent->fr_layout == FR_COL)
    23292366    {
    23302367#endif
    2331         /* When 'winfixheight' is set, remember its old size and restore
    2332          * it later (it's a simplistic solution...).  Don't do this if the
    2333          * window will occupy the full height of the screen. */
    2334         if (frp2->fr_win != NULL
    2335                 && (frp2->fr_next != NULL || frp2->fr_prev != NULL)
    2336                 && frp2->fr_win->w_p_wfh)
    2337             old_size = frp2->fr_win->w_height;
     2368        /* When 'winfixheight' is set, try to find another frame in the column
     2369         * (as close to the closed frame as possible) to distribute the height
     2370         * to. */
     2371        if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfh)
     2372        {
     2373            frp = frp_close->fr_prev;
     2374            frp3 = frp_close->fr_next;
     2375            while (frp != NULL || frp3 != NULL)
     2376            {
     2377                if (frp != NULL)
     2378                {
     2379                    if (frp->fr_win != NULL && !frp->fr_win->w_p_wfh)
     2380                    {
     2381                        frp2 = frp;
     2382                        wp = frp->fr_win;
     2383                        break;
     2384                    }
     2385                    frp = frp->fr_prev;
     2386                }
     2387                if (frp3 != NULL)
     2388                {
     2389                    if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfh)
     2390                    {
     2391                        frp2 = frp3;
     2392                        wp = frp3->fr_win;
     2393                        break;
     2394                    }
     2395                    frp3 = frp3->fr_next;
     2396                }
     2397            }
     2398        }
    23382399        frame_new_height(frp2, frp2->fr_height + frp_close->fr_height,
    23392400                            frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE);
    2340         if (old_size != 0)
    2341             win_setheight_win(old_size, frp2->fr_win);
    23422401#ifdef FEAT_VERTSPLIT
    23432402        *dirp = 'v';
    23442403    }
    23452404    else
    23462405    {
    2347         /* When 'winfixwidth' is set, remember its old size and restore
    2348          * it later (it's a simplistic solution...).  Don't do this if the
    2349          * window will occupy the full width of the screen. */
    2350         if (frp2->fr_win != NULL
    2351                 && (frp2->fr_next != NULL || frp2->fr_prev != NULL)
    2352                 && frp2->fr_win->w_p_wfw)
    2353             old_size = frp2->fr_win->w_width;
     2406        /* When 'winfixwidth' is set, try to find another frame in the column
     2407         * (as close to the closed frame as possible) to distribute the width
     2408         * to. */
     2409        if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfw)
     2410        {
     2411            frp = frp_close->fr_prev;
     2412            frp3 = frp_close->fr_next;
     2413            while (frp != NULL || frp3 != NULL)
     2414            {
     2415                if (frp != NULL)
     2416                {
     2417                    if (frp->fr_win != NULL && !frp->fr_win->w_p_wfw)
     2418                    {
     2419                        frp2 = frp;
     2420                        wp = frp->fr_win;
     2421                        break;
     2422                    }
     2423                    frp = frp->fr_prev;
     2424                }
     2425                if (frp3 != NULL)
     2426                {
     2427                    if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfw)
     2428                    {
     2429                        frp2 = frp3;
     2430                        wp = frp3->fr_win;
     2431                        break;
     2432                    }
     2433                    frp3 = frp3->fr_next;
     2434                }
     2435            }
     2436        }
    23542437        frame_new_width(frp2, frp2->fr_width + frp_close->fr_width,
    23552438                            frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE);
    2356         if (old_size != 0)
    2357             win_setwidth_win(old_size, frp2->fr_win);
    23582439        *dirp = 'h';
    23592440    }
    23602441#endif
     
    33343415     * Don't execute autocommands while creating the tab pages.  Must do that
    33353416     * when putting the buffers in the windows.
    33363417     */
    3337     ++autocmd_block;
     3418    block_autocmds();
    33383419#endif
    33393420
    33403421    for (todo = count - 1; todo > 0; --todo)
     
    33423423            break;
    33433424
    33443425#ifdef FEAT_AUTOCMD
    3345     --autocmd_block;
     3426    unblock_autocmds();
    33463427#endif
    33473428
    33483429    /* return actual number of tab pages */
     
    40814162        /* Don't execute autocommands while the window is not properly
    40824163         * initialized yet.  gui_create_scrollbar() may trigger a FocusGained
    40834164         * event. */
    4084         ++autocmd_block;
     4165        block_autocmds();
    40854166#endif
    40864167        /*
    40874168         * link the window in the window list
     
    41264207        foldInitWin(newwin);
    41274208#endif
    41284209#ifdef FEAT_AUTOCMD
    4129         --autocmd_block;
     4210        unblock_autocmds();
     4211#endif
     4212#ifdef FEAT_SEARCH_EXTRA
     4213        newwin->w_match_head = NULL;
     4214        newwin->w_next_match_id = 4;
    41304215#endif
    41314216    }
    41324217    return newwin;
     
    41474232#ifdef FEAT_AUTOCMD
    41484233    /* Don't execute autocommands while the window is halfway being deleted.
    41494234     * gui_mch_destroy_scrollbar() may trigger a FocusGained event. */
    4150     ++autocmd_block;
     4235    block_autocmds();
    41514236#endif
    41524237
    41534238#ifdef FEAT_MZSCHEME
     
    41854270        vim_free(wp->w_tagstack[i].tagname);
    41864271
    41874272    vim_free(wp->w_localdir);
     4273
    41884274#ifdef FEAT_SEARCH_EXTRA
    4189     vim_free(wp->w_match[0].regprog);
    4190     vim_free(wp->w_match[1].regprog);
    4191     vim_free(wp->w_match[2].regprog);
     4275    clear_matches(wp);
    41924276#endif
     4277
    41934278#ifdef FEAT_JUMPLIST
    41944279    free_jumplist(wp);
    41954280#endif
     
    42104295    vim_free(wp);
    42114296
    42124297#ifdef FEAT_AUTOCMD
    4213     --autocmd_block;
     4298    unblock_autocmds();
    42144299#endif
    42154300}
    42164301
     
    54385523                {
    54395524                    EMSG(_(e_noroom));
    54405525                    p_ch = old_p_ch;
     5526                    curtab->tp_ch_used = p_ch;
    54415527                    cmdline_row = Rows - p_ch;
    54425528                    break;
    54435529                }
     
    61746260    return FALSE;
    61756261}
    61766262#endif
     6263
     6264#if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
     6265/*
     6266 * Add match to the match list of window 'wp'.  The pattern 'pat' will be
     6267 * highligted with the group 'grp' with priority 'prio'.
     6268 * Optionally, a desired ID 'id' can be specified (greater than or equal to 1).
     6269 * If no particular ID is desired, -1 must be specified for 'id'.
     6270 * Return ID of added match, -1 on failure.
     6271 */
     6272    int
     6273match_add(wp, grp, pat, prio, id)
     6274    win_T       *wp;
     6275    char_u      *grp;
     6276    char_u      *pat;
     6277    int         prio;
     6278    int         id;
     6279{
     6280    matchitem_T *cur;
     6281    matchitem_T *prev;
     6282    matchitem_T *m;
     6283    int         hlg_id;
     6284    regprog_T   *regprog;
     6285
     6286    if (*grp == NUL || *pat == NUL)
     6287        return -1;
     6288    if (id < -1 || id == 0)
     6289    {
     6290        EMSGN("E799: Invalid ID: %ld (must be greater than or equal to 1)", id);
     6291        return -1;
     6292    }
     6293    if (id != -1)
     6294    {
     6295        cur = wp->w_match_head;
     6296        while (cur != NULL)
     6297        {
     6298            if (cur->id == id)
     6299            {
     6300                EMSGN("E801: ID already taken: %ld", id);
     6301                return -1;
     6302            }
     6303            cur = cur->next;
     6304        }
     6305    }
     6306    if ((hlg_id = syn_namen2id(grp, STRLEN(grp))) == 0)
     6307    {
     6308        EMSG2(_(e_nogroup), grp);
     6309        return -1;
     6310    }
     6311    if ((regprog = vim_regcomp(pat, RE_MAGIC)) == NULL)
     6312    {
     6313        EMSG2(_(e_invarg2), pat);
     6314        return -1;
     6315    }
     6316
     6317    /* Find available match ID. */
     6318    while (id == -1)
     6319    {
     6320        cur = wp->w_match_head;
     6321        while (cur != NULL && cur->id != wp->w_next_match_id)
     6322            cur = cur->next;
     6323        if (cur == NULL)
     6324            id = wp->w_next_match_id;
     6325        wp->w_next_match_id++;
     6326    }
     6327
     6328    /* Build new match. */
     6329    m = (matchitem_T *)alloc(sizeof(matchitem_T));
     6330    m->id = id;
     6331    m->priority = prio;
     6332    m->pattern = vim_strsave(pat);
     6333    m->hlg_id = hlg_id;
     6334    m->match.regprog = regprog;
     6335    m->match.rmm_ic = FALSE;
     6336    m->match.rmm_maxcol = 0;
     6337
     6338    /* Insert new match.  The match list is in ascending order with regard to
     6339     * the match priorities. */
     6340    cur = wp->w_match_head;
     6341    prev = cur;
     6342    while (cur != NULL && prio >= cur->priority)
     6343    {
     6344        prev = cur;
     6345        cur = cur->next;
     6346    }
     6347    if (cur == prev)
     6348        wp->w_match_head = m;
     6349    else
     6350        prev->next = m;
     6351    m->next = cur;
     6352
     6353    redraw_later(SOME_VALID);
     6354    return id;
     6355}
     6356
     6357/*
     6358 * Delete match with ID 'id' in the match list of window 'wp'.
     6359 * Print error messages if 'perr' is TRUE.
     6360 */
     6361    int
     6362match_delete(wp, id, perr)
     6363    win_T       *wp;
     6364    int         id;
     6365    int         perr;
     6366{
     6367    matchitem_T *cur = wp->w_match_head;
     6368    matchitem_T *prev = cur;
     6369
     6370    if (id < 1)
     6371    {
     6372        if (perr == TRUE)
     6373            EMSGN("E802: Invalid ID: %ld (must be greater than or equal to 1)",
     6374                                                                          id);
     6375        return -1;
     6376    }
     6377    while (cur != NULL && cur->id != id)
     6378    {
     6379        prev = cur;
     6380        cur = cur->next;
     6381    }
     6382    if (cur == NULL)
     6383    {
     6384        if (perr == TRUE)
     6385            EMSGN("E803: ID not found: %ld", id);
     6386        return -1;
     6387    }
     6388    if (cur == prev)
     6389        wp->w_match_head = cur->next;
     6390    else
     6391        prev->next = cur->next;
     6392    vim_free(cur->match.regprog);
     6393    vim_free(cur->pattern);
     6394    vim_free(cur);
     6395    redraw_later(SOME_VALID);
     6396    return 0;
     6397}
     6398
     6399/*
     6400 * Delete all matches in the match list of window 'wp'.
     6401 */
     6402    void
     6403clear_matches(wp)
     6404    win_T       *wp;
     6405{
     6406    matchitem_T *m;
     6407
     6408    while (wp->w_match_head != NULL)
     6409    {
     6410        m = wp->w_match_head->next;
     6411        vim_free(wp->w_match_head->match.regprog);
     6412        vim_free(wp->w_match_head->pattern);
     6413        vim_free(wp->w_match_head);
     6414        wp->w_match_head = m;
     6415    }
     6416    redraw_later(SOME_VALID);
     6417}
     6418
     6419/*
     6420 * Get match from ID 'id' in window 'wp'.
     6421 * Return NULL if match not found.
     6422 */
     6423    matchitem_T *
     6424get_match(wp, id)
     6425    win_T       *wp;
     6426    int         id;
     6427{
     6428    matchitem_T *cur = wp->w_match_head;
     6429
     6430    while (cur != NULL && cur->id != id)
     6431        cur = cur->next;
     6432    return cur;
     6433}
     6434#endif
Note: See TracBrowser for help on using the repository browser.