source: patches/vim-7.1-fixes-3.patch@ 07d4825

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 07d4825 was ba61c16, checked in by Jim Gifford <clfs@…>, 17 years ago

Updated Vim 3.1 Patch to -3.

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

    Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
    Date: 09-03-2007
    Initial Package Version: 7.1
    Origin: Upstream
    Upstream Status: Applied
    Description: Contains all upstream patches up to 7.1.094
                 The following patches were skipped
                0 003 007 041 065 070 072 080 088 091 092
    
    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 Jul 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
     
    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()|.
     
    28242838                given file {fname}.
    28252839                If {fname} is a directory, 0 is returned.
    28262840                If the file {fname} can't be found, -1 is returned.
     2841                If the size of {fname} is too big to fit in a Number then -2
     2842                is returned.
    28272843
    28282844getfontname([{name}])                                   *getfontname()*
    28292845                Without an argument returns the name of the normal font being
     
    29122928                returned.  For an invalid window number {nr}, an empty list is
    29132929                returned. Otherwise, same as getqflist().
    29142930
     2931getmatches()                                            *getmatches()*
     2932                Returns a |List| with all matches previously defined by
     2933                |matchadd()| and the |:match| commands.  |getmatches()| is
     2934                useful in combination with |setmatches()|, as |setmatches()|
     2935                can restore a list of matches saved by |getmatches()|.
     2936                Example: >
     2937                        :echo getmatches()
     2938<                       [{'group': 'MyGroup1', 'pattern': 'TODO',
     2939                        'priority': 10, 'id': 1}, {'group': 'MyGroup2',
     2940                        'pattern': 'FIXME', 'priority': 10, 'id': 2}] >
     2941                        :let m = getmatches()
     2942                        :call clearmatches()
     2943                        :echo getmatches()
     2944<                       [] >
     2945                        :call setmatches(m)
     2946                        :echo getmatches()
     2947<                       [{'group': 'MyGroup1', 'pattern': 'TODO',
     2948                        'priority': 10, 'id': 1}, {'group': 'MyGroup2',
     2949                        'pattern': 'FIXME', 'priority': 10, 'id': 2}] >
     2950                        :unlet m
     2951<
     2952
    29152953getqflist()                                             *getqflist()*
    29162954                Returns a list with all the current quickfix errors.  Each
    29172955                list item is a dictionary with these entries:
     
    36163654                the pattern.  'smartcase' is NOT used.  The matching is always
    36173655                done like 'magic' is set and 'cpoptions' is empty.
    36183656
     3657                                        *matchadd()* *E798* *E799* *E801*
     3658matchadd({group}, {pattern}[, {priority}[, {id}]])
     3659                Defines a pattern to be highlighted in the current window (a
     3660                "match").  It will be highlighted with {group}.  Returns an
     3661                identification number (ID), which can be used to delete the
     3662                match using |matchdelete()|.
     3663
     3664                The optional {priority} argument assigns a priority to the
     3665                match.  A match with a high priority will have its
     3666                highlighting overrule that of a match with a lower priority.
     3667                A priority is specified as an integer (negative numbers are no
     3668                exception).  If the {priority} argument is not specified, the
     3669                default priority is 10.  The priority of 'hlsearch' is zero,
     3670                hence all matches with a priority greater than zero will
     3671                overrule it.  Syntax highlighting (see 'syntax') is a separate
     3672                mechanism, and regardless of the chosen priority a match will
     3673                always overrule syntax highlighting.
     3674
     3675                The optional {id} argument allows the request for a specific
     3676                match ID.  If a specified ID is already taken, an error
     3677                message will appear and the match will not be added.  An ID
     3678                is specified as a positive integer (zero excluded).  IDs 1, 2
     3679                and 3 are reserved for |:match|, |:2match| and |:3match|,
     3680                respectively.  If the {id} argument is not specified,
     3681                |matchadd()| automatically chooses a free ID.
     3682
     3683                The number of matches is not limited, as it is the case with
     3684                the |:match| commands.
     3685
     3686                Example: >
     3687                        :highlight MyGroup ctermbg=green guibg=green
     3688                        :let m = matchadd("MyGroup", "TODO")
     3689<               Deletion of the pattern: >
     3690                        :call matchdelete(m)
     3691
     3692<               A list of matches defined by |matchadd()| and |:match| are
     3693                available from |getmatches()|.  All matches can be deleted in
     3694                one operation by |clearmatches()|.
    36193695
    36203696matcharg({nr})                                                  *matcharg()*
    36213697                Selects the {nr} match item, as set with a |:match|,
     
    36253701                        The pattern used.
    36263702                When {nr} is not 1, 2 or 3 returns an empty |List|.
    36273703                When there is no match item set returns ['', ''].
    3628                 This is usef to save and restore a |:match|.
    3629 
     3704                This is useful to save and restore a |:match|.
     3705                Highlighting matches using the |:match| commands are limited
     3706                to three matches. |matchadd()| does not have this limitation.
     3707
     3708matchdelete({id})                              *matchdelete()* *E802* *E803*
     3709                Deletes a match with ID {id} previously defined by |matchadd()|
     3710                or one of the |:match| commands.  Returns 0 if succesfull,
     3711                otherwise -1.  See example for |matchadd()|.  All matches can
     3712                be deleted in one operation by |clearmatches()|.
    36303713
    36313714matchend({expr}, {pat}[, {start}[, {count}]])                   *matchend()*
    36323715                Same as match(), but return the index of first character after
     
    43794462                When {nr} is zero the current window is used. For a location
    43804463                list window, the displayed location list is modified.  For an
    43814464                invalid window number {nr}, -1 is returned.
    4382                 Otherwise, same as setqflist().
     4465                Otherwise, same as |setqflist()|.
     4466                Also see |location-list|.
     4467
     4468setmatches({list})                                      *setmatches()*
     4469                Restores a list of matches saved by |getmatches()|.  Returns 0
     4470                if succesfull, otherwise -1.  All current matches are cleared
     4471                before the list is restored.  See example for |getmatches()|.
    43834472
    43844473                                                        *setpos()*
    43854474setpos({expr}, {list})
     
    50225111                position, the returned Number will be the column at the end of
    50235112                the <Tab>.  For example, for a <Tab> in column 1, with 'ts'
    50245113                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
     5114                For the byte position use |col()|.
     5115                For the use of {expr} see |col()|.
     5116                When 'virtualedit' is used {expr} can be [lnum, col, off], where
    50295117                "off" is the offset in screen columns from the start of the
    50305118                character.  E.g., a position within a <Tab> or after the last
    50315119                character.
    5032                 For the byte position use |col()|.
    50335120                When Virtual editing is active in the current mode, a position
    50345121                beyond the end of the line can be returned. |'virtualedit'|
    50355122                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 */
     
    48534861             */
    48544862            for (e = s; *e != ':' && *e != NUL; ++e)
    48554863                if (e[0] == '\\' && e[1] == ':')
    4856                     STRCPY(e, e + 1);
     4864                    mch_memmove(e, e + 1, STRLEN(e));
    48574865            if (*e == NUL)
    48584866                end = TRUE;
    48594867
  • 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/digraph.c

    diff -Naur vim71.orig/src/digraph.c vim71/src/digraph.c
    old new  
    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_unload, 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  
    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)
     2101        {
     2102            p = compl_orig_text;
     2103            actual_compl_length = 0;
     2104            while (*p != NUL)
     2105            {
     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)
    21022117        {
    2103             for (idx = 0; idx < compl_length; ++idx)
     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)
    21042130            {
    2105                 if (was_letter && isupper(compl_orig_text[idx])
    2106                                                       && islower(IObuff[idx]))
     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)
     
    72157311                p = ml_get_curline();
    72167312                if (cin_iscase(p) || cin_isscopedecl(p) || cin_islabel(30))
    72177313                    return TRUE;
     7314                /* Need to get the line again after cin_islabel(). */
     7315                p = ml_get_curline();
    72187316                if (curwin->w_cursor.col > 2
    72197317                        && p[curwin->w_cursor.col - 1] == ':'
    72207318                        && p[curwin->w_cursor.col - 2] == ':')
     
    79988096    /*
    79998097     * 0^D and ^^D: remove all indent.
    80008098     */
    8001     if ((lastc == '0' || lastc == '^') && curwin->w_cursor.col)
     8099    if (c == Ctrl_D && (lastc == '0' || lastc == '^')
     8100                                                  && curwin->w_cursor.col > 0)
    80028101    {
    80038102        --curwin->w_cursor.col;
    80048103        (void)del_char(FALSE);          /* delete the '^' or '0' */
  • 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();
     
    14111416}
    14121417
    14131418
    1414 #if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO)
     1419#if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) \
     1420        || defined(FEAT_COMPL_FUNC) || defined(PROTO)
    14151421/*
    14161422 * Call some vimL function and return the result in "*rettv".
    14171423 * Uses argv[argc] for the function arguments.
     
    14841490    return ret;
    14851491}
    14861492
     1493# if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO)
    14871494/*
    14881495 * Call vimL function "func" and return the result as a string.
    14891496 * Returns NULL when calling the function fails.
     
    15061513    clear_tv(&rettv);
    15071514    return retval;
    15081515}
     1516# endif
    15091517
    1510 #if defined(FEAT_COMPL_FUNC) || defined(PROTO)
     1518# if defined(FEAT_COMPL_FUNC) || defined(PROTO)
    15111519/*
    15121520 * Call vimL function "func" and return the result as a number.
    15131521 * Returns -1 when calling the function fails.
     
    15301538    clear_tv(&rettv);
    15311539    return retval;
    15321540}
    1533 #endif
     1541# endif
    15341542
    15351543/*
    15361544 * Call vimL function "func" and return the result as a list
     
    15561564
    15571565    return rettv.vval.v_list;
    15581566}
    1559 
    15601567#endif
    15611568
     1569
    15621570/*
    15631571 * Save the current function call pointer, and set it to NULL.
    15641572 * Used when executing autocommands and for ":source".
     
    16911699    int         semicolon = 0;
    16921700    char_u      op[2];
    16931701    char_u      *argend;
     1702    int         first = TRUE;
    16941703
    16951704    argend = skip_var_list(arg, &var_count, &semicolon);
    16961705    if (argend == NULL)
     
    17071716            EMSG(_(e_invarg));
    17081717        else if (!ends_excmd(*arg))
    17091718            /* ":let var1 var2" */
    1710             arg = list_arg_vars(eap, arg);
     1719            arg = list_arg_vars(eap, arg, &first);
    17111720        else if (!eap->skip)
    17121721        {
    17131722            /* ":let" */
    1714             list_glob_vars();
    1715             list_buf_vars();
    1716             list_win_vars();
     1723            list_glob_vars(&first);
     1724            list_buf_vars(&first);
     1725            list_win_vars(&first);
    17171726#ifdef FEAT_WINDOWS
    1718             list_tab_vars();
     1727            list_tab_vars(&first);
    17191728#endif
    1720             list_script_vars();
    1721             list_func_vars();
    1722             list_vim_vars();
     1729            list_script_vars(&first);
     1730            list_func_vars(&first);
     1731            list_vim_vars(&first);
    17231732        }
    17241733        eap->nextcmd = check_nextcmd(arg);
    17251734    }
     
    19241933 * If "empty" is TRUE also list NULL strings as empty strings.
    19251934 */
    19261935    static void
    1927 list_hashtable_vars(ht, prefix, empty)
     1936list_hashtable_vars(ht, prefix, empty, first)
    19281937    hashtab_T   *ht;
    19291938    char_u      *prefix;
    19301939    int         empty;
     1940    int         *first;
    19311941{
    19321942    hashitem_T  *hi;
    19331943    dictitem_T  *di;
     
    19421952            di = HI2DI(hi);
    19431953            if (empty || di->di_tv.v_type != VAR_STRING
    19441954                                           || di->di_tv.vval.v_string != NULL)
    1945                 list_one_var(di, prefix);
     1955                list_one_var(di, prefix, first);
    19461956        }
    19471957    }
    19481958}
     
    19511961 * List global variables.
    19521962 */
    19531963    static void
    1954 list_glob_vars()
     1964list_glob_vars(first)
     1965    int *first;
    19551966{
    1956     list_hashtable_vars(&globvarht, (char_u *)"", TRUE);
     1967    list_hashtable_vars(&globvarht, (char_u *)"", TRUE, first);
    19571968}
    19581969
    19591970/*
    19601971 * List buffer variables.
    19611972 */
    19621973    static void
    1963 list_buf_vars()
     1974list_buf_vars(first)
     1975    int *first;
    19641976{
    19651977    char_u      numbuf[NUMBUFLEN];
    19661978
    1967     list_hashtable_vars(&curbuf->b_vars.dv_hashtab, (char_u *)"b:", TRUE);
     1979    list_hashtable_vars(&curbuf->b_vars.dv_hashtab, (char_u *)"b:",
     1980                                                                 TRUE, first);
    19681981
    19691982    sprintf((char *)numbuf, "%ld", (long)curbuf->b_changedtick);
    1970     list_one_var_a((char_u *)"b:", (char_u *)"changedtick", VAR_NUMBER, numbuf);
     1983    list_one_var_a((char_u *)"b:", (char_u *)"changedtick", VAR_NUMBER,
     1984                                                               numbuf, first);
    19711985}
    19721986
    19731987/*
    19741988 * List window variables.
    19751989 */
    19761990    static void
    1977 list_win_vars()
     1991list_win_vars(first)
     1992    int *first;
    19781993{
    1979     list_hashtable_vars(&curwin->w_vars.dv_hashtab, (char_u *)"w:", TRUE);
     1994    list_hashtable_vars(&curwin->w_vars.dv_hashtab,
     1995                                                 (char_u *)"w:", TRUE, first);
    19801996}
    19811997
    19821998#ifdef FEAT_WINDOWS
     
    19842000 * List tab page variables.
    19852001 */
    19862002    static void
    1987 list_tab_vars()
     2003list_tab_vars(first)
     2004    int *first;
    19882005{
    1989     list_hashtable_vars(&curtab->tp_vars.dv_hashtab, (char_u *)"t:", TRUE);
     2006    list_hashtable_vars(&curtab->tp_vars.dv_hashtab,
     2007                                                 (char_u *)"t:", TRUE, first);
    19902008}
    19912009#endif
    19922010
     
    19942012 * List Vim variables.
    19952013 */
    19962014    static void
    1997 list_vim_vars()
     2015list_vim_vars(first)
     2016    int *first;
    19982017{
    1999     list_hashtable_vars(&vimvarht, (char_u *)"v:", FALSE);
     2018    list_hashtable_vars(&vimvarht, (char_u *)"v:", FALSE, first);
    20002019}
    20012020
    20022021/*
    20032022 * List script-local variables, if there is a script.
    20042023 */
    20052024    static void
    2006 list_script_vars()
     2025list_script_vars(first)
     2026    int *first;
    20072027{
    20082028    if (current_SID > 0 && current_SID <= ga_scripts.ga_len)
    2009         list_hashtable_vars(&SCRIPT_VARS(current_SID), (char_u *)"s:", FALSE);
     2029        list_hashtable_vars(&SCRIPT_VARS(current_SID),
     2030                                                (char_u *)"s:", FALSE, first);
    20102031}
    20112032
    20122033/*
    20132034 * List function variables, if there is a function.
    20142035 */
    20152036    static void
    2016 list_func_vars()
     2037list_func_vars(first)
     2038    int *first;
    20172039{
    20182040    if (current_funccal != NULL)
    20192041        list_hashtable_vars(&current_funccal->l_vars.dv_hashtab,
    2020                                                        (char_u *)"l:", FALSE);
     2042                                                (char_u *)"l:", FALSE, first);
    20212043}
    20222044
    20232045/*
    20242046 * List variables in "arg".
    20252047 */
    20262048    static char_u *
    2027 list_arg_vars(eap, arg)
     2049list_arg_vars(eap, arg, first)
    20282050    exarg_T     *eap;
    20292051    char_u      *arg;
     2052    int         *first;
    20302053{
    20312054    int         error = FALSE;
    20322055    int         len;
     
    20832106                        {
    20842107                            switch (*name)
    20852108                            {
    2086                                 case 'g': list_glob_vars(); break;
    2087                                 case 'b': list_buf_vars(); break;
    2088                                 case 'w': list_win_vars(); break;
     2109                                case 'g': list_glob_vars(first); break;
     2110                                case 'b': list_buf_vars(first); break;
     2111                                case 'w': list_win_vars(first); break;
    20892112#ifdef FEAT_WINDOWS
    2090                                 case 't': list_tab_vars(); break;
     2113                                case 't': list_tab_vars(first); break;
    20912114#endif
    2092                                 case 'v': list_vim_vars(); break;
    2093                                 case 's': list_script_vars(); break;
    2094                                 case 'l': list_func_vars(); break;
     2115                                case 'v': list_vim_vars(first); break;
     2116                                case 's': list_script_vars(first); break;
     2117                                case 'l': list_func_vars(first); break;
    20952118                                default:
    20962119                                          EMSG2(_("E738: Can't list variables for %s"), name);
    20972120                            }
     
    21082131                            *arg = NUL;
    21092132                            list_one_var_a((char_u *)"",
    21102133                                    arg == arg_subsc ? name : name_start,
    2111                                     tv.v_type, s == NULL ? (char_u *)"" : s);
     2134                                    tv.v_type,
     2135                                    s == NULL ? (char_u *)"" : s,
     2136                                    first);
    21122137                            *arg = c;
    21132138                            vim_free(tf);
    21142139                        }
     
    67946819 * "numbuf" is used for a number.
    67956820 * Does not put quotes around strings, as ":echo" displays values.
    67966821 * When "copyID" is not NULL replace recursive lists and dicts with "...".
    6797  * May return NULL;
     6822 * May return NULL.
    67986823 */
    67996824    static char_u *
    68006825echo_string(tv, tofree, numbuf, copyID)
     
    68796904 * If the memory is allocated "tofree" is set to it, otherwise NULL.
    68806905 * "numbuf" is used for a number.
    68816906 * Puts quotes around strings, so that they can be parsed back by eval().
    6882  * May return NULL;
     6907 * May return NULL.
    68836908 */
    68846909    static char_u *
    68856910tv2string(tv, tofree, numbuf, copyID)
     
    70437068    {"changenr",        0, 0, f_changenr},
    70447069    {"char2nr",         1, 1, f_char2nr},
    70457070    {"cindent",         1, 1, f_cindent},
     7071    {"clearmatches",    0, 0, f_clearmatches},
    70467072    {"col",             1, 1, f_col},
    70477073#if defined(FEAT_INS_EXPAND)
    70487074    {"complete",        2, 2, f_complete},
     
    70997125    {"getftype",        1, 1, f_getftype},
    71007126    {"getline",         1, 2, f_getline},
    71017127    {"getloclist",      1, 1, f_getqflist},
     7128    {"getmatches",      0, 0, f_getmatches},
    71027129    {"getpos",          1, 1, f_getpos},
    71037130    {"getqflist",       0, 0, f_getqflist},
    71047131    {"getreg",          0, 2, f_getreg},
     
    71497176    {"maparg",          1, 3, f_maparg},
    71507177    {"mapcheck",        1, 3, f_mapcheck},
    71517178    {"match",           2, 4, f_match},
     7179    {"matchadd",        2, 4, f_matchadd},
    71527180    {"matcharg",        1, 1, f_matcharg},
     7181    {"matchdelete",     1, 1, f_matchdelete},
    71537182    {"matchend",        2, 4, f_matchend},
    71547183    {"matchlist",       2, 4, f_matchlist},
    71557184    {"matchstr",        2, 4, f_matchstr},
     
    71907219    {"setcmdpos",       1, 1, f_setcmdpos},
    71917220    {"setline",         2, 2, f_setline},
    71927221    {"setloclist",      2, 3, f_setloclist},
     7222    {"setmatches",      1, 1, f_setmatches},
    71937223    {"setpos",          2, 2, f_setpos},
    71947224    {"setqflist",       1, 2, f_setqflist},
    71957225    {"setreg",          2, 3, f_setreg},
     
    82408270}
    82418271
    82428272/*
     8273 * "clearmatches()" function
     8274 */
     8275/*ARGSUSED*/
     8276    static void
     8277f_clearmatches(argvars, rettv)
     8278    typval_T    *argvars;
     8279    typval_T    *rettv;
     8280{
     8281#ifdef FEAT_SEARCH_EXTRA
     8282    clear_matches(curwin);
     8283#endif
     8284}
     8285
     8286/*
    82438287 * "col(string)" function
    82448288 */
    82458289    static void
     
    1013610180        if (mch_isdir(fname))
    1013710181            rettv->vval.v_number = 0;
    1013810182        else
     10183        {
    1013910184            rettv->vval.v_number = (varnumber_T)st.st_size;
     10185
     10186            /* non-perfect check for overflow */
     10187            if ((off_t)rettv->vval.v_number != (off_t)st.st_size)
     10188                rettv->vval.v_number = -2;
     10189        }
    1014010190    }
    1014110191    else
    1014210192          rettv->vval.v_number = -1;
     
    1026910319}
    1027010320
    1027110321/*
     10322 * "getmatches()" function
     10323 */
     10324/*ARGSUSED*/
     10325    static void
     10326f_getmatches(argvars, rettv)
     10327    typval_T    *argvars;
     10328    typval_T    *rettv;
     10329{
     10330#ifdef FEAT_SEARCH_EXTRA
     10331    dict_T      *dict;
     10332    matchitem_T *cur = curwin->w_match_head;
     10333
     10334    rettv->vval.v_number = 0;
     10335
     10336    if (rettv_list_alloc(rettv) == OK)
     10337    {
     10338        while (cur != NULL)
     10339        {
     10340            dict = dict_alloc();
     10341            if (dict == NULL)
     10342                return;
     10343            ++dict->dv_refcount;
     10344            dict_add_nr_str(dict, "group", 0L, syn_id2name(cur->hlg_id));
     10345            dict_add_nr_str(dict, "pattern", 0L, cur->pattern);
     10346            dict_add_nr_str(dict, "priority", (long)cur->priority, NULL);
     10347            dict_add_nr_str(dict, "id", (long)cur->id, NULL);
     10348            list_append_dict(rettv->vval.v_list, dict);
     10349            cur = cur->next;
     10350        }
     10351    }
     10352#endif
     10353}
     10354
     10355/*
    1027210356 * "getpos(string)" function
    1027310357 */
    1027410358    static void
     
    1243912523}
    1244012524
    1244112525/*
     12526 * "matchadd()" function
     12527 */
     12528    static void
     12529f_matchadd(argvars, rettv)
     12530    typval_T    *argvars;
     12531    typval_T    *rettv;
     12532{
     12533#ifdef FEAT_SEARCH_EXTRA
     12534    char_u      buf[NUMBUFLEN];
     12535    char_u      *grp = get_tv_string_buf_chk(&argvars[0], buf); /* group */
     12536    char_u      *pat = get_tv_string_buf_chk(&argvars[1], buf); /* pattern */
     12537    int         prio = 10;      /* default priority */
     12538    int         id = -1;
     12539    int         error = FALSE;
     12540
     12541    rettv->vval.v_number = -1;
     12542
     12543    if (grp == NULL || pat == NULL)
     12544        return;
     12545    if (argvars[2].v_type != VAR_UNKNOWN)
     12546    {
     12547        prio = get_tv_number_chk(&argvars[2], &error);
     12548        if (argvars[3].v_type != VAR_UNKNOWN)
     12549            id = get_tv_number_chk(&argvars[3], &error);
     12550    }
     12551    if (error == TRUE)
     12552        return;
     12553    if (id >= 1 && id <= 3)
     12554    {
     12555        EMSGN("E798: ID is reserved for \":match\": %ld", id);
     12556        return;
     12557    }
     12558
     12559    rettv->vval.v_number = match_add(curwin, grp, pat, prio, id);
     12560#endif
     12561}
     12562
     12563/*
    1244212564 * "matcharg()" function
    1244312565 */
    1244412566    static void
     
    1244912571    if (rettv_list_alloc(rettv) == OK)
    1245012572    {
    1245112573#ifdef FEAT_SEARCH_EXTRA
    12452         int     mi = get_tv_number(&argvars[0]);
     12574        int         id = get_tv_number(&argvars[0]);
     12575        matchitem_T *m;
    1245312576
    12454         if (mi >= 1 && mi <= 3)
     12577        if (id >= 1 && id <= 3)
    1245512578        {
    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);
     12579            if ((m = (matchitem_T *)get_match(curwin, id)) != NULL)
     12580            {
     12581                list_append_string(rettv->vval.v_list,
     12582                                                syn_id2name(m->hlg_id), -1);
     12583                list_append_string(rettv->vval.v_list, m->pattern, -1);
     12584            }
     12585            else
     12586            {
     12587                list_append_string(rettv->vval.v_list, NUL, -1);
     12588                list_append_string(rettv->vval.v_list, NUL, -1);
     12589            }
    1246012590        }
    1246112591#endif
    1246212592    }
    1246312593}
    1246412594
    1246512595/*
     12596 * "matchdelete()" function
     12597 */
     12598    static void
     12599f_matchdelete(argvars, rettv)
     12600    typval_T    *argvars;
     12601    typval_T    *rettv;
     12602{
     12603#ifdef FEAT_SEARCH_EXTRA
     12604    rettv->vval.v_number = match_delete(curwin,
     12605                                       (int)get_tv_number(&argvars[0]), TRUE);
     12606#endif
     12607}
     12608
     12609/*
    1246612610 * "matchend()" function
    1246712611 */
    1246812612    static void
     
    1368013824            }
    1368113825            /* Shorten "remain". */
    1368213826            if (*q != NUL)
    13683                 STRCPY(remain, q - 1);
     13827                mch_memmove(remain, q - 1, STRLEN(q - 1) + 1);
    1368413828            else
    1368513829            {
    1368613830                vim_free(remain);
     
    1391914063    /* If 'n' flag is used: restore cursor position. */
    1392014064    if (flags & SP_NOMOVE)
    1392114065        curwin->w_cursor = save_cursor;
     14066    else
     14067        curwin->w_set_curswant = TRUE;
    1392214068theend:
    1392314069    p_ws = save_p_ws;
    1392414070
     
    1449814644}
    1449914645
    1450014646/*
     14647 * "setmatches()" function
     14648 */
     14649    static void
     14650f_setmatches(argvars, rettv)
     14651    typval_T    *argvars;
     14652    typval_T    *rettv;
     14653{
     14654#ifdef FEAT_SEARCH_EXTRA
     14655    list_T      *l;
     14656    listitem_T  *li;
     14657    dict_T      *d;
     14658
     14659    rettv->vval.v_number = -1;
     14660    if (argvars[0].v_type != VAR_LIST)
     14661    {
     14662        EMSG(_(e_listreq));
     14663        return;
     14664    }
     14665    if ((l = argvars[0].vval.v_list) != NULL)
     14666    {
     14667
     14668        /* To some extent make sure that we are dealing with a list from
     14669         * "getmatches()". */
     14670        li = l->lv_first;
     14671        while (li != NULL)
     14672        {
     14673            if (li->li_tv.v_type != VAR_DICT
     14674                    || (d = li->li_tv.vval.v_dict) == NULL)
     14675            {
     14676                EMSG(_(e_invarg));
     14677                return;
     14678            }
     14679            if (!(dict_find(d, (char_u *)"group", -1) != NULL
     14680                        && dict_find(d, (char_u *)"pattern", -1) != NULL
     14681                        && dict_find(d, (char_u *)"priority", -1) != NULL
     14682                        && dict_find(d, (char_u *)"id", -1) != NULL))
     14683            {
     14684                EMSG(_(e_invarg));
     14685                return;
     14686            }
     14687            li = li->li_next;
     14688        }
     14689
     14690        clear_matches(curwin);
     14691        li = l->lv_first;
     14692        while (li != NULL)
     14693        {
     14694            d = li->li_tv.vval.v_dict;
     14695            match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
     14696                    get_dict_string(d, (char_u *)"pattern", FALSE),
     14697                    (int)get_dict_number(d, (char_u *)"priority"),
     14698                    (int)get_dict_number(d, (char_u *)"id"));
     14699            li = li->li_next;
     14700        }
     14701        rettv->vval.v_number = 0;
     14702    }
     14703#endif
     14704}
     14705
     14706/*
    1450114707 * "setpos()" function
    1450214708 */
    1450314709/*ARGSUSED*/
     
    1478514991
    1478614992    p1 = tv2string(&(*(listitem_T **)s1)->li_tv, &tofree1, numbuf1, 0);
    1478714993    p2 = tv2string(&(*(listitem_T **)s2)->li_tv, &tofree2, numbuf2, 0);
     14994    if (p1 == NULL)
     14995        p1 = (char_u *)"";
     14996    if (p2 == NULL)
     14997        p2 = (char_u *)"";
    1478814998    if (item_compare_ic)
    1478914999        res = STRICMP(p1, p2);
    1479015000    else
     
    1527415484
    1527515485    rettv->v_type = VAR_STRING;
    1527615486    rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0);
    15277     if (tofree == NULL)
     15487    /* Make a copy if we have a value but it's not in allocate memory. */
     15488    if (rettv->vval.v_string != NULL && tofree == NULL)
    1527815489        rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
    1527915490}
    1528015491
     
    1649716708 * Returns NULL when there is an error.
    1649816709 */
    1649916710    static pos_T *
    16500 var2fpos(varp, lnum, fnum)
     16711var2fpos(varp, dollar_lnum, fnum)
    1650116712    typval_T    *varp;
    16502     int         lnum;           /* TRUE when $ is last line */
     16713    int         dollar_lnum;    /* TRUE when $ is last line */
    1650316714    int         *fnum;          /* set to fnum for '0, 'A, etc. */
    1650416715{
    1650516716    char_u              *name;
     
    1651216723        list_T          *l;
    1651316724        int             len;
    1651416725        int             error = FALSE;
     16726        listitem_T      *li;
    1651516727
    1651616728        l = varp->vval.v_list;
    1651716729        if (l == NULL)
     
    1652716739        if (error)
    1652816740            return NULL;
    1652916741        len = (long)STRLEN(ml_get(pos.lnum));
     16742
     16743        /* We accept "$" for the column number: last column. */
     16744        li = list_find(l, 1L);
     16745        if (li != NULL && li->li_tv.v_type == VAR_STRING
     16746                && li->li_tv.vval.v_string != NULL
     16747                && STRCMP(li->li_tv.vval.v_string, "$") == 0)
     16748            pos.col = len + 1;
     16749
    1653016750        /* Accept a position up to the NUL after the line. */
    1653116751        if (pos.col == 0 || (int)pos.col > len + 1)
    1653216752            return NULL;        /* invalid column number */
     
    1655916779    pos.coladd = 0;
    1656016780#endif
    1656116781
    16562     if (name[0] == 'w' && lnum)
     16782    if (name[0] == 'w' && dollar_lnum)
    1656316783    {
    1656416784        pos.col = 0;
    1656516785        if (name[1] == '0')             /* "w0": first visible line */
     
    1657716797    }
    1657816798    else if (name[0] == '$')            /* last column or line */
    1657916799    {
    16580         if (lnum)
     16800        if (dollar_lnum)
    1658116801        {
    1658216802            pos.lnum = curbuf->b_ml.ml_line_count;
    1658316803            pos.col = 0;
     
    1779818018 * List the value of one internal variable.
    1779918019 */
    1780018020    static void
    17801 list_one_var(v, prefix)
     18021list_one_var(v, prefix, first)
    1780218022    dictitem_T  *v;
    1780318023    char_u      *prefix;
     18024    int         *first;
    1780418025{
    1780518026    char_u      *tofree;
    1780618027    char_u      *s;
     
    1780818029
    1780918030    s = echo_string(&v->di_tv, &tofree, numbuf, ++current_copyID);
    1781018031    list_one_var_a(prefix, v->di_key, v->di_tv.v_type,
    17811                                                 s == NULL ? (char_u *)"" : s);
     18032                                         s == NULL ? (char_u *)"" : s, first);
    1781218033    vim_free(tofree);
    1781318034}
    1781418035
    1781518036    static void
    17816 list_one_var_a(prefix, name, type, string)
     18037list_one_var_a(prefix, name, type, string, first)
    1781718038    char_u      *prefix;
    1781818039    char_u      *name;
    1781918040    int         type;
    1782018041    char_u      *string;
     18042    int         *first;  /* when TRUE clear rest of screen and set to FALSE */
    1782118043{
    17822     msg_attr(prefix, 0);    /* don't use msg(), it overwrites "v:statusmsg" */
     18044    /* don't use msg() or msg_attr() to avoid overwriting "v:statusmsg" */
     18045    msg_start();
     18046    msg_puts(prefix);
    1782318047    if (name != NULL)   /* "a:" vars don't have a name stored */
    1782418048        msg_puts(name);
    1782518049    msg_putchar(' ');
     
    1784718071
    1784818072    if (type == VAR_FUNC)
    1784918073        msg_puts((char_u *)"()");
     18074    if (*first)
     18075    {
     18076        msg_clr_eos();
     18077        *first = FALSE;
     18078    }
    1785018079}
    1785118080
    1785218081/*
     
    1996920198                char_u  buf[MSG_BUF_LEN];
    1997020199                char_u  numbuf2[NUMBUFLEN];
    1997120200                char_u  *tofree;
     20201                char_u  *s;
    1997220202
    1997320203                msg_puts((char_u *)"(");
    1997420204                for (i = 0; i < argcount; ++i)
     
    1997920209                        msg_outnum((long)argvars[i].vval.v_number);
    1998020210                    else
    1998120211                    {
    19982                         trunc_string(tv2string(&argvars[i], &tofree,
    19983                                               numbuf2, 0), buf, MSG_BUF_CLEN);
    19984                         msg_puts(buf);
    19985                         vim_free(tofree);
     20212                        s = tv2string(&argvars[i], &tofree, numbuf2, 0);
     20213                        if (s != NULL)
     20214                        {
     20215                            trunc_string(s, buf, MSG_BUF_CLEN);
     20216                            msg_puts(buf);
     20217                            vim_free(tofree);
     20218                        }
    1998620219                    }
    1998720220                }
    1998820221                msg_puts((char_u *)")");
     
    2006020293            char_u      buf[MSG_BUF_LEN];
    2006120294            char_u      numbuf2[NUMBUFLEN];
    2006220295            char_u      *tofree;
     20296            char_u      *s;
    2006320297
    2006420298            /* The value may be very long.  Skip the middle part, so that we
    2006520299             * have some idea how it starts and ends. smsg() would always
    2006620300             * 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);
     20301            s = tv2string(fc.rettv, &tofree, numbuf2, 0);
     20302            if (s != NULL)
     20303            {
     20304                trunc_string(s, buf, MSG_BUF_CLEN);
     20305                smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
     20306                vim_free(tofree);
     20307            }
    2007120308        }
    2007220309        msg_puts((char_u *)"\n");   /* don't overwrite this either */
    2007320310
  • 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)
     
    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.
     
    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 */
     
    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)
     
    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)
     
    41484153
    41494154#ifdef FEAT_EVAL
    41504155    if (ccline.cmdfirstc == '=')
     4156    {
     4157# ifdef FEAT_CMDL_COMPL
    41514158        /* pass CMD_SIZE because there is no real command */
    41524159        set_context_for_expression(xp, str, CMD_SIZE);
     4160# endif
     4161    }
    41534162    else if (ccline.input_fn)
    41544163    {
    41554164        xp->xp_context = ccline.xp_context;
    41564165        xp->xp_pattern = ccline.cmdbuff;
     4166# if defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)
    41574167        xp->xp_arg = ccline.xp_arg;
     4168# endif
    41584169    }
    41594170    else
    41604171#endif
     
    42954306                            && pat[i + 1] == '\\'
    42964307                            && pat[i + 2] == '\\'
    42974308                            && pat[i + 3] == ' ')
    4298                         STRCPY(pat + i, pat + i + 3);
     4309                        mch_memmove(pat + i, pat + i + 3,
     4310                                                     STRLEN(pat + i + 3) + 1);
    42994311                    if (xp->xp_backslash == XP_BS_ONE
    43004312                            && pat[i + 1] == ' ')
    4301                         STRCPY(pat + i, pat + i + 1);
     4313                        mch_memmove(pat + i, pat + i + 1, STRLEN(pat + i));
    43024314                }
    43034315        }
    43044316
     
    45024514    if (xp->xp_context != EXPAND_MENUNAMES && xp->xp_context != EXPAND_MENUS)
    45034515        sort_strings(*file, *num_file);
    45044516
     4517#ifdef FEAT_CMDL_COMPL
     4518    /* Reset the variables used for special highlight names expansion, so that
     4519     * they don't show up when getting normal highlight names by ID. */
     4520    reset_expand_highlight();
     4521#endif
     4522
    45054523    return OK;
    45064524}
    45074525
     
    45354553    pat = vim_strsave(filepat);
    45364554    for (i = 0; pat[i]; ++i)
    45374555        if (pat[i] == '\\' && pat[i + 1] == ' ')
    4538             STRCPY(pat + i, pat + i + 1);
     4556            mch_memmove(pat + i, pat + i + 1, STRLEN(pat + i));
    45394557
    45404558    flags |= EW_FILE | EW_EXEC;
    45414559
  • 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)
  • src/globals.h

    diff -Naur vim71.orig/src/globals.h vim71/src/globals.h
    old new  
    801801EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
    802802EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
    803803EXTERN int (*mb_char2cells) __ARGS((int c)) INIT(= latin_char2cells);
    804 EXTERN int (*mb_off2cells) __ARGS((unsigned off)) INIT(= latin_off2cells);
     804EXTERN int (*mb_off2cells) __ARGS((unsigned off, unsigned max_off)) INIT(= latin_off2cells);
    805805EXTERN int (*mb_ptr2char) __ARGS((char_u *p)) INIT(= latin_ptr2char);
    806806EXTERN int (*mb_head_off) __ARGS((char_u *base, char_u *p)) INIT(= latin_head_off);
    807807
  • 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
     
    51175118                p = vim_strsave_escaped(fnames[i], (char_u *)"\\ \t\"|");
    51185119# endif
    51195120                if (p != NULL)
    5120                     add_to_input_buf(p, (int)STRLEN(p));
     5121                    add_to_input_buf_csi(p, (int)STRLEN(p));
    51215122                vim_free(p);
    51225123                vim_free(fnames[i]);
    51235124            }
  • 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 */
     
    21882188    escaped_filename = vim_strsave_escaped(filename, escape_chars);
    21892189    if (escaped_filename == NULL)
    21902190        return FALSE;
    2191     mksession_cmdline = g_strconcat("mksession ", (char *)escaped_filename, NULL);
     2191    mksession_cmdline = g_strconcat("mksession ", (char *)escaped_filename,
     2192                                                                        NULL);
    21922193    vim_free(escaped_filename);
     2194
    21932195    /*
    21942196     * Use a reasonable hardcoded set of 'sessionoptions' flags to avoid
    21952197     * unpredictable effects when the session is saved automatically.  Also,
     
    21992201     */
    22002202    save_ssop_flags = ssop_flags;
    22012203    ssop_flags = (SSOP_BLANK|SSOP_CURDIR|SSOP_FOLDS|SSOP_GLOBALS
    2202                   |SSOP_HELP|SSOP_OPTIONS|SSOP_WINSIZE);
     2204                  |SSOP_HELP|SSOP_OPTIONS|SSOP_WINSIZE|SSOP_TABPAGES);
    22032205
    22042206    do_cmdline_cmd((char_u *)"let Save_VV_this_session = v:this_session");
    22052207    failed = (do_cmdline_cmd((char_u *)mksession_cmdline) == FAIL);
  • src/if_cscope.c

    diff -Naur vim71.orig/src/if_cscope.c vim71/src/if_cscope.c
    old new  
    7373
    7474
    7575static csinfo_T     csinfo[CSCOPE_MAX_CONNECTIONS];
     76static int          eap_arg_len;    /* length of eap->arg, set in
     77                                       cs_lookup_cmd() */
    7678static cscmd_T      cs_cmds[] =
    7779{
    7880    { "add",    cs_add,
     
    260262
    261263    if ((p = cs_manage_matches(NULL, NULL, -1, Get)) == NULL)
    262264        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);
     265    vim_strncpy(buf, (char_u *)p, size - 1);
    271266
    272267    return FALSE;
    273268} /* cs_fgets */
     
    386381 * PRIVATE: cs_add
    387382 *
    388383 * add cscope database or a directory name (to look for cscope.out)
    389  * the the cscope connection list
     384 * to the cscope connection list
    390385 *
    391386 * MAXPATHL 256
    392387 */
     
    966961    }
    967962
    968963    pat = opt + strlen(opt) + 1;
    969     if (pat == NULL || (pat != NULL && pat[0] == '\0'))
     964    if (pat >= (char *)eap->arg + eap_arg_len)
    970965    {
    971966        cs_usage_msg(Find);
    972967        return FALSE;
     
    13171312#else
    13181313            /* compare pathnames first */
    13191314            && ((fullpathcmp(csinfo[j].fname, fname, FALSE) & FPC_SAME)
    1320                 /* if not Windows 9x, test index file atributes too */
     1315                /* if not Windows 9x, test index file attributes too */
    13211316                || (!mch_windows95()
    13221317                    && csinfo[j].nVolume == bhfi.dwVolumeSerialNumber
    13231318                    && csinfo[j].nIndexHigh == bhfi.nFileIndexHigh
     
    14011396    if (eap->arg == NULL)
    14021397        return NULL;
    14031398
     1399    /* Store length of eap->arg before it gets modified by strtok(). */
     1400    eap_arg_len = STRLEN(eap->arg);
     1401
    14041402    if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL)
    14051403        return NULL;
    14061404
     
    21952193            cs_add_common(dblist[i], pplist[i], fllist[i]);
    21962194            if (p_csverbose)
    21972195            {
    2198                 /* dont' use smsg_attr because want to display
     2196                /* don't use smsg_attr() because we want to display the
    21992197                 * connection number in the same line as
    22002198                 * "Added cscope database..."
    22012199                 */
  • 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/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.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;
     
    13601381        p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
    13611382        if (p != NULL && *p != NUL)
    13621383        {
    1363             STRCPY(NameBuff, p);
    1364             STRCAT(NameBuff, "/lang");
     1384            vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p);
    13651385            bindtextdomain(VIMPACKAGE, (char *)NameBuff);
    13661386        }
    13671387        if (mustfree)
  • 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  
    18421842    int         wrap;
    18431843
    18441844    did_wait_return = FALSE;
    1845     while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
     1845    while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)
    18461846    {
    18471847        /*
    18481848         * We are at the end of the screen line when:
     
    18781878                /* output postponed text */
    18791879                t_puts(&t_col, t_s, s, attr);
    18801880
    1881             /* When no more prompt an no more room, truncate here */
     1881            /* When no more prompt and no more room, truncate here */
    18821882            if (msg_no_more && lines_left == 0)
    18831883                break;
    18841884
     
    19271927             * If screen is completely filled and 'more' is set then wait
    19281928             * for a character.
    19291929             */
    1930             --lines_left;
     1930            if (lines_left > 0)
     1931                --lines_left;
    19311932            if (p_more && lines_left == 0 && State != HITRETURN
    19321933                                            && !msg_no_more && !exmode_active)
    19331934            {
     
    22342235{
    22352236    msgchunk_T  *mp;
    22362237
    2237     /* Only show somethign if there is more than one line, otherwise it looks
     2238    /* Only show something if there is more than one line, otherwise it looks
    22382239     * weird, typing a command without output results in one line. */
    22392240    mp = msg_sb_start(last_msgchunk);
    22402241    if (mp == NULL || mp->sb_prev == NULL)
     
    26222623                }
    26232624            }
    26242625
    2625             if (scroll < 0 || (scroll == 0 && mp_last != NULL))
     2626            if (scroll <= 0)
    26262627            {
    26272628                /* displayed the requested text, more prompt again */
    26282629                screen_fill((int)Rows - 1, (int)Rows, 0,
     
    34563457                    /* advance to next hotkey and set default hotkey */
    34573458#ifdef FEAT_MBYTE
    34583459                    if (has_mbyte)
    3459                         hotkp += (*mb_ptr2len)(hotkp);
     3460                        hotkp += STRLEN(hotkp);
    34603461                    else
    34613462#endif
    34623463                        ++hotkp;
    3463                     (void)copy_char(r + 1, hotkp, TRUE);
     3464                    hotkp[copy_char(r + 1, hotkp, TRUE)] = NUL;
    34643465                    if (dfltbutton)
    34653466                        --dfltbutton;
    34663467
     
    34933494                        *msgp++ = (dfltbutton == 1) ? ']' : ')';
    34943495
    34953496                        /* redefine hotkey */
    3496                         (void)copy_char(r, hotkp, TRUE);
     3497                        hotkp[copy_char(r, hotkp, TRUE)] = NUL;
    34973498                    }
    34983499                }
    34993500                else
     
    35193520            *msgp++ = ':';
    35203521            *msgp++ = ' ';
    35213522            *msgp = NUL;
    3522             mb_ptr_adv(hotkp);
    3523             *hotkp = NUL;
    35243523        }
    35253524        else
    35263525        {
     
    35553554            msgp = confirm_msg + 1 + STRLEN(message);
    35563555            hotkp = hotk;
    35573556
    3558             /* define first default hotkey */
    3559             (void)copy_char(buttons, hotkp, TRUE);
     3557            /* Define first default hotkey.  Keep the hotkey string NUL
     3558             * terminated to avoid reading past the end. */
     3559            hotkp[copy_char(buttons, hotkp, TRUE)] = NUL;
    35603560
    35613561            /* Remember where the choices start, displaying starts here when
    35623562             * "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
     
    47864824static int      cin_iswhileofdo __ARGS((char_u *, linenr_T, int));
    47874825static int      cin_iswhileofdo_end __ARGS((int terminated, int ind_maxparen, int ind_maxcomment));
    47884826static int      cin_isbreak __ARGS((char_u *));
    4789 static int      cin_is_cpp_baseclass __ARGS((char_u *line, colnr_T *col));
     4827static int      cin_is_cpp_baseclass __ARGS((colnr_T *col));
    47904828static int      get_baseclass_amount __ARGS((int col, int ind_maxparen, int ind_maxcomment, int ind_cpp_baseclass));
    47914829static int      cin_ends_in __ARGS((char_u *, char_u *, char_u *));
    47924830static int      cin_skip2pos __ARGS((pos_T *trypos));
     
    55515589 * This is a lot of guessing.  Watch out for "cond ? func() : foo".
    55525590 */
    55535591    static int
    5554 cin_is_cpp_baseclass(line, col)
    5555     char_u      *line;
     5592cin_is_cpp_baseclass(col)
    55565593    colnr_T     *col;       /* return: column to align with */
    55575594{
    55585595    char_u      *s;
    55595596    int         class_or_struct, lookfor_ctor_init, cpp_base_class;
    55605597    linenr_T    lnum = curwin->w_cursor.lnum;
     5598    char_u      *line = ml_get_curline();
    55615599
    55625600    *col = 0;
    55635601
     
    55855623     */
    55865624    while (lnum > 1)
    55875625    {
    5588         s = skipwhite(ml_get(lnum - 1));
     5626        line = ml_get(lnum - 1);
     5627        s = skipwhite(line);
    55895628        if (*s == '#' || *s == NUL)
    55905629            break;
    55915630        while (*s != NUL)
     
    56025641        --lnum;
    56035642    }
    56045643
    5605     s = cin_skipcomment(ml_get(lnum));
     5644    line = ml_get(lnum);
     5645    s = cin_skipcomment(line);
    56065646    for (;;)
    56075647    {
    56085648        if (*s == NUL)
     
    56105650            if (lnum == curwin->w_cursor.lnum)
    56115651                break;
    56125652            /* Continue in the cursor line. */
    5613             s = cin_skipcomment(ml_get(++lnum));
     5653            line = ml_get(++lnum);
     5654            s = cin_skipcomment(line);
     5655            if (*s == NUL)
     5656                continue;
    56145657        }
    56155658
    56165659        if (s[0] == ':')
     
    70797122                n = FALSE;
    70807123                if (lookfor != LOOKFOR_TERM && ind_cpp_baseclass > 0)
    70817124                {
    7082                     n = cin_is_cpp_baseclass(l, &col);
     7125                    n = cin_is_cpp_baseclass(&col);
    70837126                    l = ml_get_curline();
    70847127                }
    70857128                if (n)
     
    76707713                n = FALSE;
    76717714                if (ind_cpp_baseclass != 0 && theline[0] != '{')
    76727715                {
    7673                     n = cin_is_cpp_baseclass(l, &col);
     7716                    n = cin_is_cpp_baseclass(&col);
    76747717                    l = ml_get_curline();
    76757718                }
    76767719                if (n)
     
    85968639    for (p = buf + wildoff; p < s; ++p)
    85978640        if (rem_backslash(p))
    85988641        {
    8599             STRCPY(p, p + 1);
     8642            mch_memmove(p, p + 1, STRLEN(p));
    86008643            --e;
    86018644            --s;
    86028645        }
     
    88978940    for (p = buf + wildoff; p < s; ++p)
    88988941        if (rem_backslash(p))
    88998942        {
    8900             STRCPY(p, p + 1);
     8943            mch_memmove(p, p + 1, STRLEN(p));
    89018944            --e;
    89028945            --s;
    89038946        }
  • src/normal.c

    diff -Naur vim71.orig/src/normal.c vim71/src/normal.c
    old new  
    889889
    890890        ++no_mapping;
    891891        ++allow_keys;           /* no mapping for nchar, but allow key codes */
     892#ifdef FEAT_AUTOCMD
     893        /* Don't generate a CursorHold event here, most commands can't handle
     894         * it, e.g., nv_replace(), nv_csearch(). */
     895        did_cursorhold = TRUE;
     896#endif
    892897        if (ca.cmdchar == 'g')
    893898        {
    894899            /*
     
    37553760    extra_len = (int)STRLEN(p);
    37563761    overflow = old_len + extra_len - SHOWCMD_COLS;
    37573762    if (overflow > 0)
    3758         STRCPY(showcmd_buf, showcmd_buf + overflow);
     3763        mch_memmove(showcmd_buf, showcmd_buf + overflow,
     3764                                                      old_len - overflow + 1);
    37593765    STRCAT(showcmd_buf, p);
    37603766
    37613767    if (char_avail())
     
    63796385     */
    63806386    else if (cap->nchar == 'p' || cap->nchar == 'P')
    63816387    {
    6382         if (!checkclearopq(cap->oap))
     6388        if (!checkclearop(cap->oap))
    63836389        {
    63846390            prep_redo_cmd(cap);
    63856391            do_put(cap->oap->regname,
     
    66626668    else
    66636669        had_ctrl_v = NUL;
    66646670
     6671    /* Abort if the character is a special key. */
     6672    if (IS_SPECIAL(cap->nchar))
     6673    {
     6674        clearopbeep(cap->oap);
     6675        return;
     6676    }
     6677
    66656678#ifdef FEAT_VISUAL
    66666679    /* Visual mode "r" */
    66676680    if (VIsual_active)
     
    66886701    }
    66896702#endif
    66906703
    6691     /*
    6692      * Check for a special key or not enough characters to replace.
    6693      */
     6704    /* Abort if not enough characters to replace. */
    66946705    ptr = ml_get_cursor();
    6695     if (IS_SPECIAL(cap->nchar) || STRLEN(ptr) < (unsigned)cap->count1
     6706    if (STRLEN(ptr) < (unsigned)cap->count1
    66966707#ifdef FEAT_MBYTE
    66976708            || (has_mbyte && mb_charlen(ptr) < cap->count1)
    66986709#endif
  • src/ops.c

    diff -Naur vim71.orig/src/ops.c vim71/src/ops.c
    old new  
    34043404
    34053405#ifdef FEAT_VIRTUALEDIT
    34063406        col += curwin->w_cursor.coladd;
    3407         if (ve_flags == VE_ALL && curwin->w_cursor.coladd > 0)
     3407        if (ve_flags == VE_ALL
     3408                && (curwin->w_cursor.coladd > 0
     3409                    || endcol2 == curwin->w_cursor.col))
    34083410        {
    34093411            if (dir == FORWARD && c == NUL)
    34103412                ++col;
  • src/option.c

    diff -Naur vim71.orig/src/option.c vim71/src/option.c
    old new  
    46284628                                    if ((!(flags & P_COMMA) || *s != ',')
    46294629                                            && vim_strchr(s + 1, *s) != NULL)
    46304630                                    {
    4631                                         STRCPY(s, s + 1);
     4631                                        mch_memmove(s, s + 1, STRLEN(s));
    46324632                                        --s;
    46334633                                    }
    46344634                            }
     
    71187118    /* when 'endofline' is changed, redraw the window title */
    71197119    else if ((int *)varp == &curbuf->b_p_eol)
    71207120        need_maketitle = TRUE;
     7121#ifdef FEAT_MBYTE
     7122    /* when 'bomb' is changed, redraw the window title */
     7123    else if ((int *)varp == &curbuf->b_p_bomb)
     7124        need_maketitle = TRUE;
     7125#endif
    71217126#endif
    71227127
    71237128    /* when 'bin' is set also set some other options */
     
    82198224            varp = get_varp(&options[opt_idx]);
    82208225            if (varp != NULL)   /* hidden option is not changed */
    82218226            {
     8227                if (number == 0 && string != NULL)
     8228                {
     8229                    int index;
     8230
     8231                    /* Either we are given a string or we are setting option
     8232                     * to zero. */
     8233                    for (index = 0; string[index] == '0'; ++index)
     8234                        ;
     8235                    if (string[index] != NUL || index == 0)
     8236                    {
     8237                        /* There's another character after zeros or the string
     8238                         * is empty.  In both cases, we are trying to set a
     8239                         * num option using a string. */
     8240                        EMSG3(_("E521: Number required: &%s = '%s'"),
     8241                                                                name, string);
     8242                        return;     /* do nothing as we hit an error */
     8243
     8244                    }
     8245                }
    82228246                if (flags & P_NUM)
    82238247                    (void)set_num_option(opt_idx, varp, number,
    82248248                                                          NULL, 0, opt_flags);
     
    1058510609    buf->b_start_ffc = *buf->b_p_ff;
    1058610610    buf->b_start_eol = buf->b_p_eol;
    1058710611#ifdef FEAT_MBYTE
     10612    buf->b_start_bomb = buf->b_p_bomb;
     10613
    1058810614    /* Only use free/alloc when necessary, they take time. */
    1058910615    if (buf->b_start_fenc == NULL
    1059010616                             || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
     
    1059810624/*
    1059910625 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
    1060010626 * from when editing started (save_file_ff() called).
    10601  * Also when 'endofline' was changed and 'binary' is set.
     10627 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
     10628 * changed and 'binary' is not set.
    1060210629 * Don't consider a new, empty buffer to be changed.
    1060310630 */
    1060410631    int
    1060510632file_ff_differs(buf)
    1060610633    buf_T       *buf;
    1060710634{
     10635    /* In a buffer that was never loaded the options are not valid. */
     10636    if (buf->b_flags & BF_NEVERLOADED)
     10637        return FALSE;
    1060810638    if ((buf->b_flags & BF_NEW)
    1060910639            && buf->b_ml.ml_line_count == 1
    1061010640            && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
     
    1061410644    if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
    1061510645        return TRUE;
    1061610646#ifdef FEAT_MBYTE
     10647    if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
     10648        return TRUE;
    1061710649    if (buf->b_start_fenc == NULL)
    1061810650        return (*buf->b_p_fenc != NUL);
    1061910651    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));
  • 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/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  
    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
  • 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    {
     
    25422555
    25432556    char_u      extra[18];              /* "%ld" and 'fdc' must fit in here */
    25442557    int         n_extra = 0;            /* number of extra chars */
    2545     char_u      *p_extra = NULL;        /* string of extra chars */
     2558    char_u      *p_extra = NULL;        /* string of extra chars, plus NUL */
    25462559    int         c_extra = NUL;          /* extra chars, all the same */
    25472560    int         extra_attr = 0;         /* attributes when n_extra != 0 */
    25482561    static char_u *at_end_str = (char_u *)""; /* used for p_extra when
     
    26262639    int         line_attr = 0;          /* atrribute for the whole line */
    26272640#endif
    26282641#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;
     2642    matchitem_T *cur;                   /* points to the match list */
     2643    match_T     *shl;                   /* points to search_hl or a match */
     2644    int         shl_flag;               /* flag to indicate whether search_hl
     2645                                           has been processed or not */
     2646    int         prevcol_hl_flag;        /* flag to indicate whether prevcol
     2647                                           equals startcol of search_hl or one
     2648                                           of the matches */
    26332649#endif
    26342650#ifdef FEAT_ARABIC
    26352651    int         prev_c = 0;             /* previous Arabic character */
     
    30743090
    30753091#ifdef FEAT_SEARCH_EXTRA
    30763092    /*
    3077      * Handle highlighting the last used search pattern and ":match".
    3078      * Do this for both search_hl and match_hl[3].
     3093     * Handle highlighting the last used search pattern and matches.
     3094     * Do this for both search_hl and the match list.
    30793095     */
    3080     for (i = 3; i >= 0; --i)
     3096    cur = wp->w_match_head;
     3097    shl_flag = FALSE;
     3098    while (cur != NULL || shl_flag == FALSE)
    30813099    {
    3082         shl = (i == 3) ? &search_hl : &match_hl[i];
     3100        if (shl_flag == FALSE)
     3101        {
     3102            shl = &search_hl;
     3103            shl_flag = TRUE;
     3104        }
     3105        else
     3106            shl = &cur->hl;
    30833107        shl->startcol = MAXCOL;
    30843108        shl->endcol = MAXCOL;
    30853109        shl->attr_cur = 0;
     
    31223146                area_highlighting = TRUE;
    31233147            }
    31243148        }
     3149        if (shl != &search_hl && cur != NULL)
     3150            cur = cur->next;
    31253151    }
    31263152#endif
    31273153
     
    31633189                if (cmdwin_type != 0 && wp == curwin)
    31643190                {
    31653191                    /* Draw the cmdline character. */
    3166                     *extra = cmdwin_type;
    31673192                    n_extra = 1;
    3168                     p_extra = extra;
    3169                     c_extra = NUL;
     3193                    c_extra = cmdwin_type;
    31703194                    char_attr = hl_attr(HLF_AT);
    31713195                }
    31723196            }
     
    31823206                    fill_foldcolumn(extra, wp, FALSE, lnum);
    31833207                    n_extra = wp->w_p_fdc;
    31843208                    p_extra = extra;
     3209                    p_extra[n_extra] = NUL;
    31853210                    c_extra = NUL;
    31863211                    char_attr = hl_attr(HLF_FC);
    31873212                }
     
    33883413                 * After end, check for start/end of next match.
    33893414                 * When another match, have to check for start again.
    33903415                 * Watch out for matching an empty string!
    3391                  * Do this first for search_hl, then for match_hl, so that
    3392                  * ":match" overrules 'hlsearch'.
     3416                 * Do this for 'search_hl' and the match list (ordered by
     3417                 * priority).
    33933418                 */
    33943419                v = (long)(ptr - line);
    3395                 for (i = 3; i >= 0; --i)
    3396                 {
    3397                     shl = (i == 3) ? &search_hl : &match_hl[i];
     3420                cur = wp->w_match_head;
     3421                shl_flag = FALSE;
     3422                while (cur != NULL || shl_flag == FALSE)
     3423                {
     3424                    if (shl_flag == FALSE
     3425                            && ((cur != NULL
     3426                                    && cur->priority > SEARCH_HL_PRIORITY)
     3427                                || cur == NULL))
     3428                    {
     3429                        shl = &search_hl;
     3430                        shl_flag = TRUE;
     3431                    }
     3432                    else
     3433                        shl = &cur->hl;
    33983434                    while (shl->rm.regprog != NULL)
    33993435                    {
    34003436                        if (shl->startcol != MAXCOL
     
    34423478                        }
    34433479                        break;
    34443480                    }
     3481                    if (shl != &search_hl && cur != NULL)
     3482                        cur = cur->next;
    34453483                }
    34463484
    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)
     3485                /* Use attributes from match with highest priority among
     3486                 * 'search_hl' and the match list. */
     3487                search_attr = search_hl.attr_cur;
     3488                cur = wp->w_match_head;
     3489                shl_flag = FALSE;
     3490                while (cur != NULL || shl_flag == FALSE)
     3491                {
     3492                    if (shl_flag == FALSE
     3493                            && ((cur != NULL
     3494                                    && cur->priority > SEARCH_HL_PRIORITY)
     3495                                || cur == NULL))
    34523496                    {
    3453                         search_attr = match_hl[i].attr_cur;
    3454                         break;
     3497                        shl = &search_hl;
     3498                        shl_flag = TRUE;
    34553499                    }
     3500                    else
     3501                        shl = &cur->hl;
     3502                    if (shl->attr_cur != 0)
     3503                        search_attr = shl->attr_cur;
     3504                    if (shl != &search_hl && cur != NULL)
     3505                        cur = cur->next;
     3506                }
    34563507            }
    34573508#endif
    34583509
    34593510#ifdef FEAT_DIFF
    34603511            if (diff_hlf != (hlf_T)0)
    34613512            {
    3462                 if (diff_hlf == HLF_CHD && ptr - line >= change_start)
     3513                if (diff_hlf == HLF_CHD && ptr - line >= change_start
     3514                                                              && n_extra == 0)
    34633515                    diff_hlf = HLF_TXD;         /* changed text */
    3464                 if (diff_hlf == HLF_TXD && ptr - line > change_end)
     3516                if (diff_hlf == HLF_TXD && ptr - line > change_end
     3517                                                              && n_extra == 0)
    34653518                    diff_hlf = HLF_CHD;         /* changed line */
    34663519                line_attr = hl_attr(diff_hlf);
    34673520            }
     
    34963549         * Get the next character to put on the screen.
    34973550         */
    34983551        /*
    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.
     3552         * The "p_extra" points to the extra stuff that is inserted to
     3553         * represent special characters (non-printable stuff) and other
     3554         * things.  When all characters are the same, c_extra is used.
     3555         * "p_extra" must end in a NUL to avoid mb_ptr2len() reads past
     3556         * "p_extra[n_extra]".
    35023557         * For the '$' of the 'list' option, n_extra == 1, p_extra == "".
    35033558         */
    35043559        if (n_extra > 0)
     
    36113666                         * Draw it as a space with a composing char. */
    36123667                        if (utf_iscomposing(mb_c))
    36133668                        {
     3669                            int i;
     3670
    36143671                            for (i = Screen_mco - 1; i > 0; --i)
    36153672                                u8cc[i] = u8cc[i - 1];
    36163673                            u8cc[0] = mb_c;
     
    37523809                 * a '<' in the first column. */
    37533810                if (n_skip > 0 && mb_l > 1)
    37543811                {
    3755                     extra[0] = '<';
    3756                     p_extra = extra;
    37573812                    n_extra = 1;
    3758                     c_extra = NUL;
     3813                    c_extra = '<';
    37593814                    c = ' ';
    37603815                    if (area_attr == 0 && search_attr == 0)
    37613816                    {
     
    42544309             * highlight match at end of line. If it's beyond the last
    42554310             * char on the screen, just overwrite that one (tricky!)  Not
    42564311             * needed when a '$' was displayed for 'list'. */
     4312#ifdef FEAT_SEARCH_EXTRA
     4313            prevcol_hl_flag = FALSE;
     4314            if (prevcol == (long)search_hl.startcol)
     4315                prevcol_hl_flag = TRUE;
     4316            else
     4317            {
     4318                cur = wp->w_match_head;
     4319                while (cur != NULL)
     4320                {
     4321                    if (prevcol == (long)cur->hl.startcol)
     4322                    {
     4323                        prevcol_hl_flag = TRUE;
     4324                        break;
     4325                    }
     4326                    cur = cur->next;
     4327                }
     4328            }
     4329#endif
    42574330            if (lcs_eol == lcs_eol_one
    42584331                    && ((area_attr != 0 && vcol == fromcol && c == NUL)
    42594332#ifdef FEAT_SEARCH_EXTRA
    42604333                        /* 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)
     4334                        || (prevcol_hl_flag == TRUE
    42654335# if defined(LINE_ATTR)
    42664336                            && did_line_attr <= 1
    42674337# endif
     
    43024372#ifdef FEAT_SEARCH_EXTRA
    43034373                if (area_attr == 0)
    43044374                {
    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)
     4375                    /* Use attributes from match with highest priority among
     4376                     * 'search_hl' and the match list. */
     4377                    char_attr = search_hl.attr;
     4378                    cur = wp->w_match_head;
     4379                    shl_flag = FALSE;
     4380                    while (cur != NULL || shl_flag == FALSE)
     4381                    {
     4382                        if (shl_flag == FALSE
     4383                                && ((cur != NULL
     4384                                        && cur->priority > SEARCH_HL_PRIORITY)
     4385                                    || cur == NULL))
    43104386                        {
    4311                             char_attr = match_hl[i].attr;
    4312                             break;
     4387                            shl = &search_hl;
     4388                            shl_flag = TRUE;
    43134389                        }
     4390                        else
     4391                            shl = &cur->hl;
     4392                        if ((ptr - line) - 1 == (long)shl->startcol)
     4393                            char_attr = shl->attr;
     4394                        if (shl != &search_hl && cur != NULL)
     4395                            cur = cur->next;
    43144396                    }
    43154397                }
    43164398#endif
     
    44604542            {
    44614543                if (mb_utf8)
    44624544                {
     4545                    int i;
     4546
    44634547                    ScreenLinesUC[off] = mb_c;
    44644548                    if ((c & 0xff) == 0)
    44654549                        ScreenLines[off] = 0x80;   /* avoid storing zero */
     
    45484632
    45494633        /*
    45504634         * 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.
     4635         * so far.  If there is no more to display it is caught above.
    45524636         */
    45534637        if ((
    45544638#ifdef FEAT_RIGHTLEFT
     
    46254709#endif
    46264710#ifdef FEAT_MBYTE
    46274711                         && !(has_mbyte
    4628                              && ((*mb_off2cells)(LineOffset[screen_row]) == 2
     4712                             && ((*mb_off2cells)(LineOffset[screen_row],
     4713                                     LineOffset[screen_row] + screen_Columns)
     4714                                                                          == 2
    46294715                                 || (*mb_off2cells)(LineOffset[screen_row - 1]
    4630                                                         + (int)Columns - 2) == 2))
     4716                                                        + (int)Columns - 2,
     4717                                     LineOffset[screen_row] + screen_Columns)
     4718                                                                        == 2))
    46314719#endif
    46324720                   )
    46334721                {
     
    47874875{
    47884876    unsigned        off_from;
    47894877    unsigned        off_to;
     4878#ifdef FEAT_MBYTE
     4879    unsigned        max_off_from;
     4880    unsigned        max_off_to;
     4881#endif
    47904882    int             col = 0;
    47914883#if defined(FEAT_GUI) || defined(UNIX) || defined(FEAT_VERTSPLIT)
    47924884    int             hl;
     
    48134905
    48144906    off_from = (unsigned)(current_ScreenLine - ScreenLines);
    48154907    off_to = LineOffset[row] + coloff;
     4908#ifdef FEAT_MBYTE
     4909    max_off_from = off_from + screen_Columns;
     4910    max_off_to = LineOffset[row] + screen_Columns;
     4911#endif
    48164912
    48174913#ifdef FEAT_RIGHTLEFT
    48184914    if (rlflag)
     
    48474943    {
    48484944#ifdef FEAT_MBYTE
    48494945        if (has_mbyte && (col + 1 < endcol))
    4850             char_cells = (*mb_off2cells)(off_from);
     4946            char_cells = (*mb_off2cells)(off_from, max_off_from);
    48514947        else
    48524948            char_cells = 1;
    48534949#endif
     
    49245020                 * ScreenLinesUC[] is sufficient. */
    49255021                if (char_cells == 1
    49265022                        && col + 1 < endcol
    4927                         && (*mb_off2cells)(off_to) > 1)
     5023                        && (*mb_off2cells)(off_to, max_off_to) > 1)
    49285024                {
    49295025                    /* Writing a single-cell character over a double-cell
    49305026                     * character: need to redraw the next cell. */
     
    49335029                }
    49345030                else if (char_cells == 2
    49355031                        && col + 2 < endcol
    4936                         && (*mb_off2cells)(off_to) == 1
    4937                         && (*mb_off2cells)(off_to + 1) > 1)
     5032                        && (*mb_off2cells)(off_to, max_off_to) == 1
     5033                        && (*mb_off2cells)(off_to + 1, max_off_to) > 1)
    49385034                {
    49395035                    /* Writing the second half of a double-cell character over
    49405036                     * a double-cell character: need to redraw the second
     
    49535049             * char over the left halve of an existing one. */
    49545050            if (has_mbyte && col + char_cells == endcol
    49555051                    && ((char_cells == 1
    4956                             && (*mb_off2cells)(off_to) > 1)
     5052                            && (*mb_off2cells)(off_to, max_off_to) > 1)
    49575053                        || (char_cells == 2
    4958                             && (*mb_off2cells)(off_to) == 1
    4959                             && (*mb_off2cells)(off_to + 1) > 1)))
     5054                            && (*mb_off2cells)(off_to, max_off_to) == 1
     5055                            && (*mb_off2cells)(off_to + 1, max_off_to) > 1)))
    49605056                clear_next = TRUE;
    49615057#endif
    49625058
     
    50965192                        /* find previous character by counting from first
    50975193                         * column and get its width. */
    50985194                        unsigned off = LineOffset[row];
     5195                        unsigned max_off = LineOffset[row] + screen_Columns;
    50995196
    51005197                        while (off < off_to)
    51015198                        {
    5102                             prev_cells = (*mb_off2cells)(off);
     5199                            prev_cells = (*mb_off2cells)(off, max_off);
    51035200                            off += prev_cells;
    51045201                        }
    51055202                    }
     
    52855382static int skip_status_match_char __ARGS((expand_T *xp, char_u *s));
    52865383
    52875384/*
    5288  * Get the lenght of an item as it will be shown in the status line.
     5385 * Get the length of an item as it will be shown in the status line.
    52895386 */
    52905387    static int
    52915388status_match_len(xp, s)
     
    53515448    int         row;
    53525449    char_u      *buf;
    53535450    int         len;
    5354     int         clen;           /* lenght in screen cells */
     5451    int         clen;           /* length in screen cells */
    53555452    int         fillchar;
    53565453    int         attr;
    53575454    int         i;
     
    61036200    char_u      *ptr = text;
    61046201    int         c;
    61056202#ifdef FEAT_MBYTE
     6203    unsigned    max_off;
    61066204    int         mbyte_blen = 1;
    61076205    int         mbyte_cells = 1;
    61086206    int         u8c = 0;
     
    61196217        return;
    61206218
    61216219    off = LineOffset[row] + col;
    6122     while (*ptr != NUL && col < screen_Columns
    6123                                       && (len < 0 || (int)(ptr - text) < len))
     6220#ifdef FEAT_MBYTE
     6221    max_off = LineOffset[row] + screen_Columns;
     6222#endif
     6223    while (col < screen_Columns
     6224            && (len < 0 || (int)(ptr - text) < len)
     6225            && *ptr != NUL)
    61246226    {
    61256227        c = *ptr;
    61266228#ifdef FEAT_MBYTE
     
    62416343            else if (has_mbyte
    62426344                    && (len < 0 ? ptr[mbyte_blen] == NUL
    62436345                                             : ptr + mbyte_blen >= text + len)
    6244                     && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
     6346                    && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
    62456347                        || (mbyte_cells == 2
    6246                             && (*mb_off2cells)(off) == 1
    6247                             && (*mb_off2cells)(off + 1) > 1)))
     6348                            && (*mb_off2cells)(off, max_off) == 1
     6349                            && (*mb_off2cells)(off + 1, max_off) > 1)))
    62486350                clear_next_cell = TRUE;
    62496351
    62506352            /* Make sure we never leave a second byte of a double-byte behind,
    62516353             * it confuses mb_off2cells(). */
    62526354            if (enc_dbcs
    6253                     && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
     6355                    && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
    62546356                        || (mbyte_cells == 2
    6255                             && (*mb_off2cells)(off) == 1
    6256                             && (*mb_off2cells)(off + 1) > 1)))
     6357                            && (*mb_off2cells)(off, max_off) == 1
     6358                            && (*mb_off2cells)(off + 1, max_off) > 1)))
    62576359                ScreenLines[off + mbyte_blen] = 0;
    62586360#endif
    62596361            ScreenLines[off] = c;
     
    63186420
    63196421#ifdef FEAT_SEARCH_EXTRA
    63206422/*
    6321  * Prepare for 'searchhl' highlighting.
     6423 * Prepare for 'hlsearch' highlighting.
    63226424 */
    63236425    static void
    63246426start_search_hl()
     
    63316433}
    63326434
    63336435/*
    6334  * Clean up for 'searchhl' highlighting.
     6436 * Clean up for 'hlsearch' highlighting.
    63356437 */
    63366438    static void
    63376439end_search_hl()
     
    63516453    win_T       *wp;
    63526454    linenr_T    lnum;
    63536455{
    6354     match_T     *shl;           /* points to search_hl or match_hl */
     6456    matchitem_T *cur;           /* points to the match list */
     6457    match_T     *shl;           /* points to search_hl or a match */
     6458    int         shl_flag;       /* flag to indicate whether search_hl
     6459                                   has been processed or not */
    63556460    int         n;
    6356     int         i;
    63576461
    63586462    /*
    63596463     * When using a multi-line pattern, start searching at the top
    63606464     * of the window or just after a closed fold.
    6361      * Do this both for search_hl and match_hl[3].
     6465     * Do this both for search_hl and the match list.
    63626466     */
    6363     for (i = 3; i >= 0; --i)
     6467    cur = wp->w_match_head;
     6468    shl_flag = FALSE;
     6469    while (cur != NULL || shl_flag == FALSE)
    63646470    {
    6365         shl = (i == 3) ? &search_hl : &match_hl[i];
     6471        if (shl_flag == FALSE)
     6472        {
     6473            shl = &search_hl;
     6474            shl_flag = TRUE;
     6475        }
     6476        else
     6477            shl = &cur->hl;
    63666478        if (shl->rm.regprog != NULL
    63676479                && shl->lnum == 0
    63686480                && re_multiline(shl->rm.regprog))
     
    63976509                }
    63986510            }
    63996511        }
     6512        if (shl != &search_hl && cur != NULL)
     6513            cur = cur->next;
    64006514    }
    64016515}
    64026516
    64036517/*
    6404  * Search for a next 'searchl' or ":match" match.
     6518 * Search for a next 'hlsearch' or match.
    64056519 * Uses shl->buf.
    64066520 * Sets shl->lnum and shl->rm contents.
    64076521 * Note: Assumes a previous match is always before "lnum", unless
     
    64116525    static void
    64126526next_search_hl(win, shl, lnum, mincol)
    64136527    win_T       *win;
    6414     match_T     *shl;           /* points to search_hl or match_hl */
     6528    match_T     *shl;           /* points to search_hl or a match */
    64156529    linenr_T    lnum;
    64166530    colnr_T     mincol;         /* minimal column for a match */
    64176531{
     
    64796593            /* Error while handling regexp: stop using this regexp. */
    64806594            if (shl == &search_hl)
    64816595            {
    6482                 /* don't free the regprog in match_hl[], it's a copy */
     6596                /* don't free regprog in the match list, it's a copy */
    64836597                vim_free(shl->rm.regprog);
    64846598                no_hlsearch = TRUE;
    64856599            }
     
    68276941{
    68286942    int         r, c;
    68296943    int         off;
     6944#ifdef FEAT_MBYTE
     6945    int         max_off;
     6946#endif
    68306947
    68316948    /* Can't use ScreenLines unless initialized */
    68326949    if (ScreenLines == NULL)
     
    68376954    for (r = row; r < row + height; ++r)
    68386955    {
    68396956        off = LineOffset[r];
     6957#ifdef FEAT_MBYTE
     6958        max_off = off + screen_Columns;
     6959#endif
    68406960        for (c = col; c < col + width; ++c)
    68416961        {
    68426962#ifdef FEAT_MBYTE
    6843             if (enc_dbcs != 0 && dbcs_off2cells(off + c) > 1)
     6963            if (enc_dbcs != 0 && dbcs_off2cells(off + c, max_off) > 1)
    68446964            {
    68456965                screen_char_2(off + c, r, c);
    68466966                ++c;
     
    68506970            {
    68516971                screen_char(off + c, r, c);
    68526972#ifdef FEAT_MBYTE
    6853                 if (utf_off2cells(off + c) > 1)
     6973                if (utf_off2cells(off + c, max_off) > 1)
    68546974                    ++c;
    68556975#endif
    68566976            }
  • 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  
    14531453#ifdef FEAT_MBYTE
    14541454    char_u      *b_start_fenc;  /* 'fileencoding' when edit started or NULL */
    14551455    int         b_bad_char;     /* "++bad=" argument when edit started or 0 */
     1456    int         b_start_bomb;   /* 'bomb' when it was read */
    14561457#endif
    14571458
    14581459#ifdef FEAT_EVAL
     
    16941695#define FR_COL  2       /* frame with a column of windows */
    16951696
    16961697/*
     1698 * Struct used for highlighting 'hlsearch' matches, matches defined by
     1699 * ":match" and matches defined by match functions.
     1700 * For 'hlsearch' there is one pattern for all windows.  For ":match" and the
     1701 * match functions there is a different pattern for each window.
     1702 */
     1703typedef struct
     1704{
     1705    regmmatch_T rm;     /* points to the regexp program; contains last found
     1706                           match (may continue in next line) */
     1707    buf_T       *buf;   /* the buffer to search for a match */
     1708    linenr_T    lnum;   /* the line to search for a match */
     1709    int         attr;   /* attributes to be used for a match */
     1710    int         attr_cur; /* attributes currently active in win_line() */
     1711    linenr_T    first_lnum;     /* first lnum to search for multi-line pat */
     1712    colnr_T     startcol; /* in win_line() points to char where HL starts */
     1713    colnr_T     endcol;  /* in win_line() points to char where HL ends */
     1714} match_T;
     1715
     1716/*
     1717 * matchitem_T provides a linked list for storing match items for ":match" and
     1718 * the match functions.
     1719 */
     1720typedef struct matchitem matchitem_T;
     1721struct matchitem
     1722{
     1723    matchitem_T *next;
     1724    int         id;         /* match ID */
     1725    int         priority;   /* match priority */
     1726    char_u      *pattern;   /* pattern to highlight */
     1727    int         hlg_id;     /* highlight group ID */
     1728    regmmatch_T match;      /* regexp program for pattern */
     1729    match_T     hl;         /* struct for doing the actual highlighting */
     1730};
     1731
     1732/*
    16971733 * Structure which contains all information that belongs to a window
    16981734 *
    16991735 * All row numbers are relative to the start of the window, except w_winrow.
     
    19341970#endif
    19351971
    19361972#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" */
     1973    matchitem_T *w_match_head;          /* head of match list */
     1974    int         w_next_match_id;        /* next match ID */
    19401975#endif
    19411976
    19421977    /*
  • 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
     
    44604491    current_syn_inc_tag = ++running_syn_inc_tag;
    44614492    prev_toplvl_grp = curbuf->b_syn_topgrp;
    44624493    curbuf->b_syn_topgrp = sgl_id;
    4463     if (source ? do_source(eap->arg, FALSE, FALSE) == FAIL
    4464                                 : source_runtime(eap->arg, DOSO_NONE) == FAIL)
     4494    if (source ? do_source(eap->arg, FALSE, DOSO_NONE) == FAIL
     4495                                : source_runtime(eap->arg, TRUE) == FAIL)
    44654496        EMSG2(_(e_notopen), eap->arg);
    44664497    curbuf->b_syn_topgrp = prev_toplvl_grp;
    44674498    current_syn_inc_tag = prev_syn_inc_tag;
     
    59565987{
    59575988    return (buf->b_syn_patterns.ga_len != 0
    59585989            || buf->b_syn_clusters.ga_len != 0
    5959             || curbuf->b_keywtab.ht_used > 0
    5960             || curbuf->b_keywtab_ic.ht_used > 0);
     5990            || buf->b_keywtab.ht_used > 0
     5991            || buf->b_keywtab_ic.ht_used > 0);
    59615992}
    59625993
    59635994#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
     
    59685999    EXP_CASE        /* expand ":syn case" arguments */
    59696000} expand_what;
    59706001
     6002/*
     6003 * Reset include_link, include_default, include_none to 0.
     6004 * Called when we are done expanding.
     6005 */
     6006    void
     6007reset_expand_highlight()
     6008{
     6009    include_link = include_default = include_none = 0;
     6010}
     6011
     6012/*
     6013 * Handle command line completion for :match and :echohl command: Add "None"
     6014 * as highlight group.
     6015 */
     6016    void
     6017set_context_in_echohl_cmd(xp, arg)
     6018    expand_T    *xp;
     6019    char_u      *arg;
     6020{
     6021    xp->xp_context = EXPAND_HIGHLIGHT;
     6022    xp->xp_pattern = arg;
     6023    include_none = 1;
     6024}
    59716025
    59726026/*
    59736027 * Handle command line completion for :syntax command.
     
    59836037    xp->xp_context = EXPAND_SYNTAX;
    59846038    expand_what = EXP_SUBCMD;
    59856039    xp->xp_pattern = arg;
    5986     include_link = FALSE;
    5987     include_default = FALSE;
     6040    include_link = 0;
     6041    include_default = 0;
    59886042
    59896043    /* (part of) subcommand already typed */
    59906044    if (*arg != NUL)
     
    84798533syn_id2name(id)
    84808534    int         id;
    84818535{
    8482     if (id <= 0 || id >= highlight_ga.ga_len)
     8536    if (id <= 0 || id > highlight_ga.ga_len)
    84838537        return (char_u *)"";
    84848538    return HL_TABLE()[id - 1].sg_name;
    84858539}
     
    89499003    return OK;
    89509004}
    89519005
    8952 #ifdef FEAT_CMDL_COMPL
     9006#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
    89539007
    89549008static void highlight_list __ARGS((void));
    89559009static void highlight_list_two __ARGS((int cnt, int attr));
     
    89679021    /* Default: expand group names */
    89689022    xp->xp_context = EXPAND_HIGHLIGHT;
    89699023    xp->xp_pattern = arg;
    8970     include_link = TRUE;
    8971     include_default = TRUE;
     9024    include_link = 2;
     9025    include_default = 1;
    89729026
    89739027    /* (part of) subcommand already typed */
    89749028    if (*arg != NUL)
     
    89769030        p = skiptowhite(arg);
    89779031        if (*p != NUL)                  /* past "default" or group name */
    89789032        {
    8979             include_default = FALSE;
     9033            include_default = 0;
    89809034            if (STRNCMP("default", arg, p - arg) == 0)
    89819035            {
    89829036                arg = skipwhite(p);
     
    89859039            }
    89869040            if (*p != NUL)                      /* past group name */
    89879041            {
    8988                 include_link = FALSE;
     9042                include_link = 0;
    89899043                if (arg[1] == 'i' && arg[0] == 'N')
    89909044                    highlight_list();
    89919045                if (STRNCMP("link", arg, p - arg) == 0
     
    90459099    expand_T    *xp;
    90469100    int         idx;
    90479101{
    9048     if (idx == highlight_ga.ga_len
    90499102#ifdef FEAT_CMDL_COMPL
    9050             && include_link
    9051 #endif
    9052             )
     9103    if (idx == highlight_ga.ga_len && include_none != 0)
     9104        return (char_u *)"none";
     9105    if (idx == highlight_ga.ga_len + include_none && include_default != 0)
     9106        return (char_u *)"default";
     9107    if (idx == highlight_ga.ga_len + include_none + include_default
     9108                                                         && include_link != 0)
    90539109        return (char_u *)"link";
    9054     if (idx == highlight_ga.ga_len + 1
    9055 #ifdef FEAT_CMDL_COMPL
    9056             && include_link
    9057 #endif
    9058             )
     9110    if (idx == highlight_ga.ga_len + include_none + include_default + 1
     9111                                                         && include_link != 0)
    90599112        return (char_u *)"clear";
    9060     if (idx == highlight_ga.ga_len + 2
    9061 #ifdef FEAT_CMDL_COMPL
    9062             && include_default
    90639113#endif
    9064             )
    9065         return (char_u *)"default";
    90669114    if (idx < 0 || idx >= highlight_ga.ga_len)
    90679115        return NULL;
    90689116    return HL_TABLE()[idx].sg_name;
    90699117}
    90709118#endif
    90719119
    9072 #ifdef FEAT_GUI
     9120#if defined(FEAT_GUI) || defined(PROTO)
    90739121/*
    90749122 * Free all the highlight group fonts.
    90759123 * Used when quitting for systems which need it.
  • 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 --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
     
    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; \
  • 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 succesfull 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 succesfull 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 succesfull 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:  endif
     48:endfor
     49:/^Results/,$wq! test.out
     50ENDTEST
     51
     52Results 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/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    94,
     671/**/
     672    93,
     673/**/
     674    90,
     675/**/
     676    89,
     677/**/
     678    87,
     679/**/
     680    86,
     681/**/
     682    85,
     683/**/
     684    84,
     685/**/
     686    83,
     687/**/
     688    82,
     689/**/
     690    81,
     691/**/
     692    79,
     693/**/
     694    78,
     695/**/
     696    77,
     697/**/
     698    76,
     699/**/
     700    75,
     701/**/
     702    74,
     703/**/
     704    73,
     705/**/
     706    71,
     707/**/
     708    69,
     709/**/
     710    68,
     711/**/
     712    67,
     713/**/
     714    66,
     715/**/
     716    64,
     717/**/
     718    63,
     719/**/
     720    62,
     721/**/
     722    61,
     723/**/
     724    60,
     725/**/
     726    59,
     727/**/
     728    58,
     729/**/
     730    57,
     731/**/
     732    56,
     733/**/
     734    55,
     735/**/
     736    54,
     737/**/
     738    53,
     739/**/
     740    52,
     741/**/
     742    51,
     743/**/
     744    50,
     745/**/
     746    49,
     747/**/
     748    48,
     749/**/
     750    47,
     751/**/
     752    46,
     753/**/
     754    45,
     755/**/
     756    44,
     757/**/
     758    43,
     759/**/
     760    42,
     761/**/
     762    40,
     763/**/
     764    39,
     765/**/
     766    38,
     767/**/
     768    37,
     769/**/
     770    36,
     771/**/
     772    35,
     773/**/
     774    34,
     775/**/
     776    33,
     777/**/
     778    32,
     779/**/
     780    31,
     781/**/
     782    30,
     783/**/
     784    29,
     785/**/
     786    28,
     787/**/
     788    27,
     789/**/
     790    26,
     791/**/
     792    25,
     793/**/
     794    24,
     795/**/
     796    23,
     797/**/
     798    22,
     799/**/
     800    21,
     801/**/
     802    20,
     803/**/
     804    19,
     805/**/
     806    18,
     807/**/
     808    17,
     809/**/
     810    16,
     811/**/
     812    15,
     813/**/
     814    14,
     815/**/
     816    13,
     817/**/
     818    12,
     819/**/
     820    11,
     821/**/
     822    10,
     823/**/
     824    9,
     825/**/
     826    8,
     827/**/
     828    6,
     829/**/
     830    5,
     831/**/
     832    4,
     833/**/
     834    2,
     835/**/
     836    1,
     837/**/
    670838    0
    671839};
    672840
  • 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
     
    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    /*
     
    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
     
    41284209#ifdef FEAT_AUTOCMD
    41294210        --autocmd_block;
    41304211#endif
     4212#ifdef FEAT_SEARCH_EXTRA
     4213        newwin->w_match_head = NULL;
     4214        newwin->w_next_match_id = 4;
     4215#endif
    41314216    }
    41324217    return newwin;
    41334218}
     
    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
     
    61746259    return FALSE;
    61756260}
    61766261#endif
     6262
     6263#if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
     6264/*
     6265 * Add match to the match list of window 'wp'.  The pattern 'pat' will be
     6266 * highligted with the group 'grp' with priority 'prio'.
     6267 * Optionally, a desired ID 'id' can be specified (greater than or equal to 1).
     6268 * If no particular ID is desired, -1 must be specified for 'id'.
     6269 * Return ID of added match, -1 on failure.
     6270 */
     6271    int
     6272match_add(wp, grp, pat, prio, id)
     6273    win_T       *wp;
     6274    char_u      *grp;
     6275    char_u      *pat;
     6276    int         prio;
     6277    int         id;
     6278{
     6279    matchitem_T *cur;
     6280    matchitem_T *prev;
     6281    matchitem_T *m;
     6282    int         hlg_id;
     6283    regprog_T   *regprog;
     6284
     6285    if (*grp == NUL || *pat == NUL)
     6286        return -1;
     6287    if (id < -1 || id == 0)
     6288    {
     6289        EMSGN("E799: Invalid ID: %ld (must be greater than or equal to 1)", id);
     6290        return -1;
     6291    }
     6292    if (id != -1)
     6293    {
     6294        cur = wp->w_match_head;
     6295        while (cur != NULL)
     6296        {
     6297            if (cur->id == id)
     6298            {
     6299                EMSGN("E801: ID already taken: %ld", id);
     6300                return -1;
     6301            }
     6302            cur = cur->next;
     6303        }
     6304    }
     6305    if ((hlg_id = syn_namen2id(grp, STRLEN(grp))) == 0)
     6306    {
     6307        EMSG2(_(e_nogroup), grp);
     6308        return -1;
     6309    }
     6310    if ((regprog = vim_regcomp(pat, RE_MAGIC)) == NULL)
     6311    {
     6312        EMSG2(_(e_invarg2), pat);
     6313        return -1;
     6314    }
     6315
     6316    /* Find available match ID. */
     6317    while (id == -1)
     6318    {
     6319        cur = wp->w_match_head;
     6320        while (cur != NULL && cur->id != wp->w_next_match_id)
     6321            cur = cur->next;
     6322        if (cur == NULL)
     6323            id = wp->w_next_match_id;
     6324        wp->w_next_match_id++;
     6325    }
     6326
     6327    /* Build new match. */
     6328    m = (matchitem_T *)alloc(sizeof(matchitem_T));
     6329    m->id = id;
     6330    m->priority = prio;
     6331    m->pattern = vim_strsave(pat);
     6332    m->hlg_id = hlg_id;
     6333    m->match.regprog = regprog;
     6334    m->match.rmm_ic = FALSE;
     6335    m->match.rmm_maxcol = 0;
     6336
     6337    /* Insert new match.  The match list is in ascending order with regard to
     6338     * the match priorities. */
     6339    cur = wp->w_match_head;
     6340    prev = cur;
     6341    while (cur != NULL && prio >= cur->priority)
     6342    {
     6343        prev = cur;
     6344        cur = cur->next;
     6345    }
     6346    if (cur == prev)
     6347        wp->w_match_head = m;
     6348    else
     6349        prev->next = m;
     6350    m->next = cur;
     6351
     6352    redraw_later(SOME_VALID);
     6353    return id;
     6354}
     6355
     6356/*
     6357 * Delete match with ID 'id' in the match list of window 'wp'.
     6358 * Print error messages if 'perr' is TRUE.
     6359 */
     6360    int
     6361match_delete(wp, id, perr)
     6362    win_T       *wp;
     6363    int         id;
     6364    int         perr;
     6365{
     6366    matchitem_T *cur = wp->w_match_head;
     6367    matchitem_T *prev = cur;
     6368
     6369    if (id < 1)
     6370    {
     6371        if (perr == TRUE)
     6372            EMSGN("E802: Invalid ID: %ld (must be greater than or equal to 1)",
     6373                                                                          id);
     6374        return -1;
     6375    }
     6376    while (cur != NULL && cur->id != id)
     6377    {
     6378        prev = cur;
     6379        cur = cur->next;
     6380    }
     6381    if (cur == NULL)
     6382    {
     6383        if (perr == TRUE)
     6384            EMSGN("E803: ID not found: %ld", id);
     6385        return -1;
     6386    }
     6387    if (cur == prev)
     6388        wp->w_match_head = cur->next;
     6389    else
     6390        prev->next = cur->next;
     6391    vim_free(cur->match.regprog);
     6392    vim_free(cur->pattern);
     6393    vim_free(cur);
     6394    redraw_later(SOME_VALID);
     6395    return 0;
     6396}
     6397
     6398/*
     6399 * Delete all matches in the match list of window 'wp'.
     6400 */
     6401    void
     6402clear_matches(wp)
     6403    win_T       *wp;
     6404{
     6405    matchitem_T *m;
     6406
     6407    while (wp->w_match_head != NULL)
     6408    {
     6409        m = wp->w_match_head->next;
     6410        vim_free(wp->w_match_head->match.regprog);
     6411        vim_free(wp->w_match_head->pattern);
     6412        vim_free(wp->w_match_head);
     6413        wp->w_match_head = m;
     6414    }
     6415    redraw_later(SOME_VALID);
     6416}
     6417
     6418/*
     6419 * Get match from ID 'id' in window 'wp'.
     6420 * Return NULL if match not found.
     6421 */
     6422    matchitem_T *
     6423get_match(wp, id)
     6424    win_T       *wp;
     6425    int         id;
     6426{
     6427    matchitem_T *cur = wp->w_match_head;
     6428
     6429    while (cur != NULL && cur->id != id)
     6430        cur = cur->next;
     6431    return cur;
     6432}
     6433#endif
Note: See TracBrowser for help on using the repository browser.