source: clfs-sysroot/patches/vim-7.2-branch_update-11.patch @ 2893698

Last change on this file since 2893698 was 2893698, checked in by Joe Ciccone <jciccone@…>, 15 years ago

Update VIM Branch Update Patch.

  • Property mode set to 100644
File size: 253.5 KB
  • Filelist

    Submitted By: Jim Gifford (jim at cross-lfs dot org)
    Date: 03-12-2009
    Initial Package Version: 7.2
    Origin: Upstream
    Upstream Status: Applied
    Description: Contains all upstream patches up to 7.2.141
                 The following patches were skipped
                 007 036 041 049 071 072 074 088 089 093 101 138
    
    diff -Naur vim72.orig/Filelist vim72/Filelist
    old new  
    285285                src/proto/os_win32.pro \
    286286                src/proto/os_mswin.pro \
    287287                src/testdir/Make_dos.mak \
     288                src/testdir/Make_ming.mak \
    288289                src/testdir/dos.vim \
    289290                src/uninstal.c \
    290291                src/vim.def \
  • runtime/doc/cmdline.txt

    diff -Naur vim72.orig/runtime/doc/cmdline.txt vim72/runtime/doc/cmdline.txt
    old new  
    1 *cmdline.txt*   For Vim version 7.2.  Last change: 2008 Jul 29
     1*cmdline.txt*   For Vim version 7.2.  Last change: 2008 Sep 18
    22
    33
    44                  VIM REFERENCE MANUAL    by Bram Moolenaar
     
    157157                                (doesn't work at the expression prompt; some
    158158                                things such as changing the buffer or current
    159159                                window are not allowed to avoid side effects)
     160                                When the result is a |List| the items are used
     161                                as lines.  They can have line breaks inside
     162                                too.
     163                                When the result is a Float it's automatically
     164                                converted to a String.
    160165                See |registers| about registers.  {not in Vi}
    161166                Implementation detail: When using the |expression| register
    162167                and invoking setcmdpos(), this sets the position before
     
    730735In Ex commands, at places where a file name can be used, the following
    731736characters have a special meaning.  These can also be used in the expression
    732737function expand() |expand()|.
    733         %       is replaced with the current file name                  *:_%*
    734         #       is replaced with the alternate file name                *:_#*
     738        %       Is replaced with the current file name.           *:_%* *c_%*
     739        #       Is replaced with the alternate file name.         *:_#* *c_#*
    735740        #n      (where n is a number) is replaced with the file name of
    736                 buffer n.  "#0" is the same as "#"
    737         ##      is replaced with all names in the argument list         *:_##*
     741                buffer n.  "#0" is the same as "#".
     742        ##      Is replaced with all names in the argument list   *:_##* *c_##*
    738743                concatenated, separated by spaces.  Each space in a name
    739744                is preceded with a backslash.
    740 Note that these give the file name as it was typed.  If an absolute path is
    741 needed (when using the file name from a different directory), you need to add
    742 ":p".  See |filename-modifiers|.
     745        #<n     (where n is a number > 0) is replaced with old    *:_#<* *c_#<*
     746                file name n.  See |:oldfiles| or |v:oldfiles| to get the
     747                number.                                                 *E809*
     748                {only when compiled with the +eval and +viminfo features}
     749
     750Note that these, except "#<n", give the file name as it was typed.  If an
     751absolute path is needed (when using the file name from a different directory),
     752you need to add ":p".  See |filename-modifiers|.
     753
     754The "#<n" item returns an absolute path, but it will start with "~/" for files
     755below your home directory.
     756
    743757Note that backslashes are inserted before spaces, so that the command will
    744758correctly interpret the file name.  But this doesn't happen for shell
    745 commands.  For those you probably have to use quotes: >
     759commands.  For those you probably have to use quotes (this fails for files
     760that contain a quote and wildcards): >
    746761        :!ls "%"
    747762        :r !spell "%"
    748763
  • runtime/doc/eval.txt

    diff -Naur vim72.orig/runtime/doc/eval.txt vim72/runtime/doc/eval.txt
    old new  
    1 *eval.txt*      For Vim version 7.2.  Last change: 2008 Aug 09
     1*eval.txt*      For Vim version 7.2.  Last change: 2008 Nov 27
    22
    33
    44                  VIM REFERENCE MANUAL    by Bram Moolenaar
     
    14841484                This is the screen column number, like with |virtcol()|.  The
    14851485                value is zero when there was no mouse button click.
    14861486
     1487                                        *v:oldfiles* *oldfiles-variable*
     1488v:oldfiles      List of file names that is loaded from the |viminfo| file on
     1489                startup.  These are the files that Vim remembers marks for.
     1490                The length of the List is limited by the ' argument of the
     1491                'viminfo' option (default is 100).
     1492                Also see |:oldfiles| and |c_#<|.
     1493                The List can be modified, but this has no effect on what is
     1494                stored in the |viminfo| file later.  If you use values other
     1495                than String this will cause trouble.
     1496                {only when compiled with the +viminfo feature}
     1497
    14871498                                        *v:operator* *operator-variable*
    14881499v:operator      The last operator given in Normal mode.  This is a single
    14891500                character except for commands starting with <g> or <z>,
     
    16951706exists( {expr})                 Number  TRUE if {expr} exists
    16961707extend({expr1}, {expr2} [, {expr3}])
    16971708                                List/Dict insert items of {expr2} into {expr1}
    1698 expand( {expr})                 String  expand special keywords in {expr}
     1709expand( {expr} [, {flag}])      String  expand special keywords in {expr}
    16991710feedkeys( {string} [, {mode}])  Number  add key sequence to typeahead buffer
    17001711filereadable( {file})           Number  TRUE if {file} is a readable file
    17011712filewritable( {file})           Number  TRUE if {file} is a writable file
     
    17471758getwinposx()                    Number  X coord in pixels of GUI Vim window
    17481759getwinposy()                    Number  Y coord in pixels of GUI Vim window
    17491760getwinvar( {nr}, {varname})     any     variable {varname} in window {nr}
    1750 glob( {expr})                   String  expand file wildcards in {expr}
    1751 globpath( {path}, {expr})       String  do glob({expr}) for all dirs in {path}
     1761glob( {expr} [, {flag}])        String  expand file wildcards in {expr}
     1762globpath( {path}, {expr} [, {flag}])
     1763                                String  do glob({expr}) for all dirs in {path}
    17521764has( {feature})                 Number  TRUE if feature {feature} supported
    17531765has_key( {dict}, {key})         Number  TRUE if {dict} has entry {key}
    17541766haslocaldir()                   Number  TRUE if current window executed |:lcd|
     
    32753287                        :let list_is_on = getwinvar(2, '&list')
    32763288                        :echo "myvar = " . getwinvar(1, 'myvar')
    32773289<
    3278                                                         *glob()*
    3279 glob({expr})    Expand the file wildcards in {expr}.  See |wildcards| for the
     3290glob({expr} [, {flag}])                                 *glob()*
     3291                Expand the file wildcards in {expr}.  See |wildcards| for the
    32803292                use of special characters.
    32813293                The result is a String.
    32823294                When there are several matches, they are separated by <NL>
    32833295                characters.
    3284                 The 'wildignore' option applies: Names matching one of the
    3285                 patterns in 'wildignore' will be skipped.
     3296                Unless the optional {flag} argument is given and is non-zero,
     3297                the 'suffixes' and 'wildignore' options apply: Names matching
     3298                one of the patterns in 'wildignore' will be skipped and
     3299                'suffixes' affect the ordering of matches.
    32863300                If the expansion fails, the result is an empty string.
    32873301                A name for a non-existing file is not included.
    32883302
     
    32963310                See |expand()| for expanding special Vim variables.  See
    32973311                |system()| for getting the raw output of an external command.
    32983312
    3299 globpath({path}, {expr})                                *globpath()*
     3313globpath({path}, {expr} [, {flag}])                     *globpath()*
    33003314                Perform glob() on all directories in {path} and concatenate
    33013315                the results.  Example: >
    33023316                        :echo globpath(&rtp, "syntax/c.vim")
    33033317<               {path} is a comma-separated list of directory names.  Each
    33043318                directory name is prepended to {expr} and expanded like with
    3305                 glob().  A path separator is inserted when needed.
     3319                |glob()|.  A path separator is inserted when needed.
    33063320                To add a comma inside a directory name escape it with a
    33073321                backslash.  Note that on MS-Windows a directory may have a
    33083322                trailing backslash, remove it if you put a comma after it.
    33093323                If the expansion fails for one of the directories, there is no
    33103324                error message.
    3311                 The 'wildignore' option applies: Names matching one of the
    3312                 patterns in 'wildignore' will be skipped.
     3325                Unless the optional {flag} argument is given and is non-zero,
     3326                the 'suffixes' and 'wildignore' options apply: Names matching
     3327                one of the patterns in 'wildignore' will be skipped and
     3328                'suffixes' affect the ordering of matches.
    33133329
    33143330                The "**" item can be used to search in a directory tree.
    33153331                For example, to find all "README.txt" files in the directories
     
    53325348                "fg"            foreground color (GUI: color name used to set
    53335349                                the color, cterm: color number as a string,
    53345350                                term: empty string)
    5335                 "bg"            background color (like "fg")
     5351                "bg"            background color (as with "fg")
     5352                "sp"            special color (as with "fg") |highlight-guisp|
    53365353                "fg#"           like "fg", but for the GUI and the GUI is
    53375354                                running the name in "#RRGGBB" form
    53385355                "bg#"           like "fg#" for "bg"
     5356                "sp#"           like "fg#" for "sp"
    53395357                "bold"          "1" if bold
    53405358                "italic"        "1" if italic
    53415359                "reverse"       "1" if reverse
     
    58235841mouse_pterm             Compiled with support for qnx pterm mouse.
    58245842mouse_sysmouse          Compiled with support for sysmouse (*BSD console mouse)
    58255843mouse_xterm             Compiled with support for xterm mouse.
    5826 multi_byte              Compiled with support for editing Korean et al.
     5844multi_byte              Compiled with support for 'encoding'
     5845multi_byte_encoding     'encoding' is set to a multi-byte encoding.
    58275846multi_byte_ime          Compiled with support for IME input method.
    58285847multi_lang              Compiled with support for multiple languages.
    58295848mzscheme                Compiled with MzScheme interface |mzscheme|.
  • runtime/doc/netbeans.txt

    diff -Naur vim72.orig/runtime/doc/netbeans.txt vim72/runtime/doc/netbeans.txt
    old new  
    1 *netbeans.txt*  For Vim version 7.2.  Last change: 2008 Jun 28
     1*netbeans.txt*  For Vim version 7.2.  Last change: 2009 Jan 06
    22
    33
    44                  VIM REFERENCE MANUAL    by Gordon Prieur et al.
     
    722722                of the cursor.
    723723                New in version 2.1.
    724724
    725 killed          A file was closed by the user.  Only for files that have been
    726                 assigned a number by the IDE.
     725killed          A file was deleted or wiped out by the user and the buffer
     726                annotations have been removed.  The bufID number for this
     727                buffer has become invalid.  Only for files that have been
     728                assigned a bufID number by the IDE.
    727729
    728730newDotAndMark off off
    729731                Reports the position of the cursor being at "off" bytes into
  • runtime/doc/options.txt

    diff -Naur vim72.orig/runtime/doc/options.txt vim72/runtime/doc/options.txt
    old new  
    1 *options.txt*   For Vim version 7.2.  Last change: 2008 Aug 06
     1*options.txt*   For Vim version 7.2.  Last change: 2008 Nov 25
    22
    33
    44                  VIM REFERENCE MANUAL    by Bram Moolenaar
     
    41754175        be able to execute Normal mode commands.
    41764176        This is the opposite of the 'keymap' option, where characters are
    41774177        mapped in Insert mode.
    4178         This only works for 8-bit characters.  The value of 'langmap' may be
    4179         specified with multi-byte characters (e.g., UTF-8), but only the lower
    4180         8 bits of each character will be used.
    41814178
    41824179        Example (for Greek, in UTF-8):                          *greek*  >
    41834180            :set langmap=ΑA,ΒB,ΚC,ΔD,ΕE,ΊF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR,ΣS,΀T,ΘU,ΩV,WW,ΧX,Î¥Y,ΖZ,αa,βb,ψc,ÎŽd,εe,φf,γg,ηh,ιi,Οj,κk,λl,ÎŒm,Îœn,οo,πp,qq,ρr,σs,τt,Ξu,ωv,ςw,χx,Ï
  • runtime/doc/spell.txt

    y,ζz
    @@ -7472,7 +7469,9 @@
     			{not available when compiled without the |+wildignore|
     			feature}
     	A list of file patterns.  A file that matches with one of these
    -	patterns is ignored when completing file or directory names.
    +	patterns is ignored when completing file or directory names, and
    +	influences the result of |expand()|, |glob()| and |globpath()| unless
    +	a flag is passed to disable this.
     	The pattern is used like with |:autocmd|, see |autocmd-patterns|.
     	Also see 'suffixes'.
     	Example: >
    diff -Naur vim72.orig/runtime/doc/spell.txt vim72/runtime/doc/spell.txt
    old new  
    1 *spell.txt*     For Vim version 7.2.  Last change: 2008 Jun 21
     1*spell.txt*     For Vim version 7.2.  Last change: 2008 Nov 30
    22
    33
    44                  VIM REFERENCE MANUAL    by Bram Moolenaar
     
    831831
    832832        # comment line ~
    833833
    834 With some items it's also possible to put a comment after it, but this isn't
    835 supported in general.
     834Items with a fixed number of arguments can be followed by a comment.  But only
     835if none of the arguments can contain white space.  The comment must start with
     836a "#" character.  Example:
     837
     838        KEEPCASE =  # fix case for words with this flag ~
    836839
    837840
    838841ENCODING                                                        *spell-SET*
     
    965968
    966969Note: When using utf-8 only characters up to 65000 may be used for flags.
    967970
     971Note: even when using "num" or "long" the number of flags available to
     972compounding and prefixes is limited to about 250.
     973
    968974
    969975AFFIXES
    970976                                            *spell-PFX* *spell-SFX*
     
    11781184The flag also applies to the word with affixes, thus this can be used to mark
    11791185a whole bunch of related words as bad.
    11801186
     1187                                                        *spell-FORBIDDENWORD*
     1188FORBIDDENWORD can be used just like BAD.  For compatibility with Hunspell.
     1189
    11811190                                                        *spell-NEEDAFFIX*
    11821191The NEEDAFFIX flag is used to require that a word is used with an affix.  The
    11831192word itself is not a good word (unless there is an empty affix).  Example:
     
    12681277
    12691278        NEEDCOMPOUND & ~
    12701279
     1280                                                        *spell-ONLYINCOMPOUND*
     1281The ONLYINCOMPOUND does exactly the same as NEEDCOMPOUND.  Supported for
     1282compatiblity with Hunspell.
     1283
    12711284                                                        *spell-COMPOUNDMIN*
    12721285The minimal character length of a word used for compounding is specified with
    12731286COMPOUNDMIN.  Example:
     
    13281341rules.  Can also be used for an affix to count the affix as a compounding
    13291342word.
    13301343
     1344                                                *spell-CHECKCOMPOUNDPATTERN*
     1345CHECKCOMPOUNDPATTERN is used to define patterns that, when matching at the
     1346position where two words are compounded together forbids the compound.
     1347For example:
     1348        CHECKCOMPOUNDPATTERN o e ~
     1349
     1350This forbids compounding if the first word ends in "o" and the second word
     1351starts with "e".
     1352
     1353The arguments must be plain text, no patterns are actually supported, despite
     1354the item name.  Case is always ignored.
     1355
     1356The Hunspell feature to use three arguments and flags is not supported.
     1357
    13311358                                                        *spell-SYLLABLE*
    13321359The SYLLABLE item defines characters or character sequences that are used to
    13331360count the number of syllables in a word.  Example:
     
    14961523ACCENT          (Hunspell)                              *spell-ACCENT*
    14971524                Use MAP instead. |spell-MAP|
    14981525
     1526BREAK           (Hunspell)                              *spell-BREAK*
     1527                Define break points.  Unclear how it works exactly.
     1528                Not supported.
     1529
    14991530CHECKCOMPOUNDCASE  (Hunspell)                   *spell-CHECKCOMPOUNDCASE*
    15001531                Disallow uppercase letters at compound word boundaries.
    15011532                Not supported.
     
    15121543                Forbid three identical characters when compounding.  Not
    15131544                supported.
    15141545
    1515 CHECKCOMPOUNDPATTERN  (Hunspell)                *spell-CHECKCOMPOUNDPATTERN*
    1516                 Forbid compounding when patterns match.  Not supported.
    1517 
    15181546COMPLEXPREFIXES  (Hunspell)                             *spell-COMPLEXPREFIXES*
    15191547                Enables using two prefixes.  Not supported.
    15201548
     
    15361564COMPOUNDMIDDLE  (Hunspell)                              *spell-COMPOUNDMIDDLE*
    15371565                Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
    15381566
     1567COMPOUNDRULES   (Hunspell)                              *spell-COMPOUNDRULES*
     1568                Number of COMPOUNDRULE lines following.  Ignored, but the
     1569                argument must be a number.
     1570
    15391571COMPOUNDSYLLABLE  (Hunspell)                    *spell-COMPOUNDSYLLABLE*
    15401572                Use SYLLABLE and COMPOUNDSYLMAX instead. |spell-SYLLABLE|
    15411573                |spell-COMPOUNDSYLMAX|
    15421574
    1543 FORBIDDENWORD   (Hunspell)                              *spell-FORBIDDENWORD*
    1544                 Use BAD instead. |spell-BAD|
    1545 
     1575KEY             (Hunspell)                              *spell-KEY*
     1576                Define characters that are close together on the keyboard.
     1577                Used to give better suggestions.  Not supported.
     1578               
    15461579LANG            (Hunspell)                              *spell-LANG*
    15471580                This specifies language-specific behavior.  This actually
    15481581                moves part of the language knowledge into the program,
     
    15531586                Only needed for morphological analysis.
    15541587
    15551588MAXNGRAMSUGS    (Hunspell)                              *spell-MAXNGRAMSUGS*
    1556                 Not supported.
    1557 
    1558 ONLYINCOMPOUND  (Hunspell)                              *spell-ONLYINCOMPOUND*
    1559                 Use NEEDCOMPOUND instead. |spell-NEEDCOMPOUND|
     1589                Set number of n-gram suggestions.  Not supported.
    15601590
    15611591PSEUDOROOT      (Hunspell)                              *spell-PSEUDOROOT*
    15621592                Use NEEDAFFIX instead. |spell-NEEDAFFIX|
  • runtime/doc/starting.txt

    diff -Naur vim72.orig/runtime/doc/starting.txt vim72/runtime/doc/starting.txt
    old new  
    1 *starting.txt*  For Vim version 7.2.  Last change: 2008 Jun 21
     1*starting.txt*  For Vim version 7.2.  Last change: 2008 Nov 09
    22
    33
    44                  VIM REFERENCE MANUAL    by Bram Moolenaar
     
    13371337                                                        *viminfo-read*
    13381338When Vim is started and the 'viminfo' option is non-empty, the contents of
    13391339the viminfo file are read and the info can be used in the appropriate places.
    1340 The marks are not read in at startup (but file marks are).  See
    1341 |initialization| for how to set the 'viminfo' option upon startup.
     1340The |v:oldfiles| variable is filled.  The marks are not read in at startup
     1341(but file marks are).  See |initialization| for how to set the 'viminfo'
     1342option upon startup.
    13421343
    13431344                                                        *viminfo-write*
    13441345When Vim exits and 'viminfo' is non-empty, the info is stored in the viminfo
     
    13721373that start with any string given with the "r" flag in 'viminfo'.  This can be
    13731374used to avoid saving marks for files on removable media (for MS-DOS you would
    13741375use "ra:,rb:", for Amiga "rdf0:,rdf1:,rdf2:").
     1376The |v:oldfiles| variable is filled with the file names that the viminfo file
     1377has marks for.
    13751378
    13761379                                                        *viminfo-file-marks*
    13771380Uppercase marks ('A to 'Z) are stored when writing the viminfo file.  The
     
    14631466                                                   *:rv* *:rviminfo* *E195*
    14641467:rv[iminfo][!] [file]   Read from viminfo file [file] (default: see above).
    14651468                        If [!] is given, then any information that is
    1466                         already set (registers, marks, etc.) will be
    1467                         overwritten.  {not in Vi}
     1469                        already set (registers, marks, |v:oldfiles|, etc.)
     1470                        will be overwritten   {not in Vi}
    14681471
    14691472                                        *:wv* *:wviminfo* *E137* *E138* *E574*
    14701473:wv[iminfo][!] [file]   Write to viminfo file [file] (default: see above).
     
    14791482                        the .viminfo file.
    14801483                        {not in Vi}
    14811484
     1485                                                *:ol* *:oldfiles*
     1486:ol[dfiles]             List the files that have marks stored in the viminfo
     1487                        file.  This list is read on startup and only changes
     1488                        afterwards with ":rviminfo!".  Also see |v:oldfiles|.
     1489                        The number can be used with |c_#<|.
     1490                        {not in Vi, only when compiled with the +eval feature}
     1491
     1492:bro[wse] ol[dfiles][!]
     1493                        List file names as with |:oldfiles|, and then prompt
     1494                        for a number.  When the number is valid that file from
     1495                        the list is edited.
     1496                        If you get the |press-enter| prompt you can press "q"
     1497                        and still get the prompt to enter a file number.
     1498                        Use ! to abondon a modified buffer. |abandon|
     1499                        {not when compiled with tiny or small features}
     1500
    14821501 vim:tw=78:ts=8:ft=help:norl:
  • runtime/doc/usr_21.txt

    diff -Naur vim72.orig/runtime/doc/usr_21.txt vim72/runtime/doc/usr_21.txt
    old new  
    1 *usr_21.txt*    For Vim version 7.2.  Last change: 2007 May 01
     1*usr_21.txt*    For Vim version 7.2.  Last change: 2008 Nov 09
    22
    33                     VIM USER MANUAL - by Bram Moolenaar
    44
     
    153153to be lost.  Each item can be remembered only once.
    154154
    155155
    156 GETTING BACK TO WHERE YOU WERE
     156GETTING BACK TO WHERE YOU STOPPED VIM
    157157
    158158You are halfway editing a file and it's time to leave for holidays.  You exit
    159159Vim and go enjoy yourselves, forgetting all about your work.  After a couple
     
    168168   The |:marks| command is useful to find out where '0 to '9 will take you.
    169169
    170170
     171GETTING BACK TO SOME FILE
     172
     173If you want to go back to a file that you edited recently, but not when
     174exiting Vim, there is a slightly more complicated way.  You can see a list of
     175files by typing the command: >
     176
     177        :oldfiles
     178<       1: ~/.viminfo ~
     179        2: ~/text/resume.txt ~
     180        3: /tmp/draft ~
     181
     182Now you would like to edit the second file, which is in the list preceded by
     183"2:".  You type: >
     184
     185        :e #<2
     186
     187Instead of ":e" you can use any command that has a file name argument, the
     188"#<2" item works in the same place as "%" (current file name) and "#"
     189(alternate file name).  So you can also split the window to edit the third
     190file: >
     191
     192        :split #<3
     193
     194That #<123 thing is a bit complicated when you just want to edit a file.
     195Fortunately there is a simpler way: >
     196
     197        :browse oldfiles
     198<       1: ~/.viminfo ~
     199        2: ~/text/resume.txt ~
     200        3: /tmp/draft ~
     201        -- More --
     202
     203You get the same list of files as with |:oldfiles|.  If you want to edit
     204"resume.txt" first press "q" to stop the listing.  You will get a prompt:
     205
     206        Type number and <Enter> (empty cancels): ~
     207
     208Type "2" and press <Enter> to edit the second file.
     209
     210More info at |:oldfiles|, |v:oldfiles| and |c_#<|.
     211
     212
    171213MOVE INFO FROM ONE VIM TO ANOTHER
    172214
    173215You can use the ":wviminfo" and ":rviminfo" commands to save and restore the
  • runtime/scripts.vim

    diff -Naur vim72.orig/runtime/scripts.vim vim72/runtime/scripts.vim
    old new  
    234234  elseif s:line1 =~ '\<DTD\s\+XHTML\s'
    235235    set ft=xhtml
    236236
     237    " HTML (e.g.: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN")
     238  elseif s:line1 =~? '\<DOCTYPE\s\+html\>'
     239    set ft=html
     240
    237241    " PDF
    238242  elseif s:line1 =~ '^%PDF-'
    239243    set ft=pdf
  • src/auto/configure

    diff -Naur vim72.orig/src/auto/configure vim72/src/auto/configure
    old new  
    1156511565
    1156611566fi
    1156711567
     11568{ $as_echo "$as_me:$LINENO: checking for working volatile" >&5
     11569$as_echo_n "checking for working volatile... " >&6; }
     11570if test "${ac_cv_c_volatile+set}" = set; then
     11571  $as_echo_n "(cached) " >&6
     11572else
     11573  cat >conftest.$ac_ext <<_ACEOF
     11574/* confdefs.h.  */
     11575_ACEOF
     11576cat confdefs.h >>conftest.$ac_ext
     11577cat >>conftest.$ac_ext <<_ACEOF
     11578/* end confdefs.h.  */
     11579
     11580int
     11581main ()
     11582{
     11583
     11584volatile int x;
     11585int * volatile y = (int *) 0;
     11586return !x && !y;
     11587  ;
     11588  return 0;
     11589}
     11590_ACEOF
     11591rm -f conftest.$ac_objext
     11592if { (ac_try="$ac_compile"
     11593case "(($ac_try" in
     11594  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
     11595  *) ac_try_echo=$ac_try;;
     11596esac
     11597eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
     11598$as_echo "$ac_try_echo") >&5
     11599  (eval "$ac_compile") 2>conftest.er1
     11600  ac_status=$?
     11601  grep -v '^ *+' conftest.er1 >conftest.err
     11602  rm -f conftest.er1
     11603  cat conftest.err >&5
     11604  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
     11605  (exit $ac_status); } && {
     11606         test -z "$ac_c_werror_flag" ||
     11607         test ! -s conftest.err
     11608       } && test -s conftest.$ac_objext; then
     11609  ac_cv_c_volatile=yes
     11610else
     11611  $as_echo "$as_me: failed program was:" >&5
     11612sed 's/^/| /' conftest.$ac_ext >&5
     11613
     11614        ac_cv_c_volatile=no
     11615fi
     11616
     11617rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     11618fi
     11619{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_volatile" >&5
     11620$as_echo "$ac_cv_c_volatile" >&6; }
     11621if test $ac_cv_c_volatile = no; then
     11622
     11623cat >>confdefs.h <<\_ACEOF
     11624#define volatile /**/
     11625_ACEOF
     11626
     11627fi
     11628
    1156811629{ $as_echo "$as_me:$LINENO: checking for mode_t" >&5
    1156911630$as_echo_n "checking for mode_t... " >&6; }
    1157011631if test "${ac_cv_type_mode_t+set}" = set; then
     
    1681916880  LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
    1682016881fi
    1682116882
    16822 { $as_echo "$as_me:$LINENO: checking for GCC 3 or later" >&5
    16823 $as_echo_n "checking for GCC 3 or later... " >&6; }
    1682416883DEPEND_CFLAGS_FILTER=
    1682516884if test "$GCC" = yes; then
     16885  { $as_echo "$as_me:$LINENO: checking for GCC 3 or later" >&5
     16886$as_echo_n "checking for GCC 3 or later... " >&6; }
    1682616887  gccmajor=`echo "$gccversion" | sed -e 's/^\([1-9]\)\..*$/\1/g'`
    1682716888  if test "$gccmajor" -gt "2"; then
    1682816889    DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
    16829   fi
    16830 fi
    16831 if test "$DEPEND_CFLAGS_FILTER" = ""; then
    16832   { $as_echo "$as_me:$LINENO: result: no" >&5
     16890    { $as_echo "$as_me:$LINENO: result: yes" >&5
     16891$as_echo "yes" >&6; }
     16892  else
     16893    { $as_echo "$as_me:$LINENO: result: no" >&5
    1683316894$as_echo "no" >&6; }
    16834 else
    16835   { $as_echo "$as_me:$LINENO: result: yes" >&5
     16895  fi
     16896      { $as_echo "$as_me:$LINENO: checking whether we need -D_FORTIFY_SOURCE=1" >&5
     16897$as_echo_n "checking whether we need -D_FORTIFY_SOURCE=1... " >&6; }
     16898  if test "$gccmajor" -gt "3"; then
     16899    CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=1"
     16900    { $as_echo "$as_me:$LINENO: result: yes" >&5
    1683616901$as_echo "yes" >&6; }
     16902  else
     16903    { $as_echo "$as_me:$LINENO: result: no" >&5
     16904$as_echo "no" >&6; }
     16905  fi
    1683716906fi
    1683816907
    1683916908
  • src/buffer.c

    diff -Naur vim72.orig/src/buffer.c vim72/src/buffer.c
    old new  
    437437        return;
    438438#endif
    439439
    440 #ifdef FEAT_NETBEANS_INTG
    441     if (usingNetbeans)
    442         netbeans_file_closed(buf);
    443 #endif
    444440    /* Change directories when the 'acd' option is set. */
    445441    DO_AUTOCHDIR
    446442
     
    639635#ifdef FEAT_SIGNS
    640636    buf_delete_signs(buf);              /* delete any signs */
    641637#endif
     638#ifdef FEAT_NETBEANS_INTG
     639    if (usingNetbeans)
     640        netbeans_file_killed(buf);
     641#endif
    642642#ifdef FEAT_LOCALMAP
    643643    map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE);  /* clear local mappings */
    644644    map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE);   /* clear local abbrevs */
     
    647647    vim_free(buf->b_start_fenc);
    648648    buf->b_start_fenc = NULL;
    649649#endif
     650#ifdef FEAT_SPELL
     651    ga_clear(&buf->b_langp);
     652#endif
    650653}
    651654
    652655/*
     
    812815    int         bnr;            /* buffer number */
    813816    char_u      *p;
    814817
    815 #ifdef FEAT_NETBEANS_INTG
    816     netbeansCloseFile = 1;
    817 #endif
    818818    if (addr_count == 0)
    819819    {
    820820        (void)do_buffer(command, DOBUF_CURRENT, FORWARD, 0, forceit);
     
    909909        }
    910910    }
    911911
    912 #ifdef FEAT_NETBEANS_INTG
    913     netbeansCloseFile = 0;
    914 #endif
    915912
    916913    return errormsg;
    917914}
     
    12371234         * "buf" if one exists */
    12381235        if ((swb_flags & SWB_USEOPEN) && buf_jump_open_win(buf))
    12391236            return OK;
    1240         /* If 'switchbuf' contians "usetab": jump to first window in any tab
     1237        /* If 'switchbuf' contains "usetab": jump to first window in any tab
    12411238         * page containing "buf" if one exists */
    12421239        if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf))
    12431240            return OK;
     
    13511348        }
    13521349    }
    13531350#ifdef FEAT_AUTOCMD
     1351    /* An autocommand may have deleted "buf", already entered it (e.g., when
     1352     * it did ":bunload") or aborted the script processing! */
    13541353# ifdef FEAT_EVAL
    1355     /* An autocommand may have deleted buf or aborted the script processing! */
    1356     if (buf_valid(buf) && !aborting())
     1354    if (buf_valid(buf) && buf != curbuf && !aborting())
    13571355# else
    1358     if (buf_valid(buf))     /* an autocommand may have deleted buf! */
     1356    if (buf_valid(buf) && buf != curbuf)
    13591357# endif
    13601358#endif
    13611359        enter_buffer(buf);
     
    13971395    curwin->w_cursor.coladd = 0;
    13981396#endif
    13991397    curwin->w_set_curswant = TRUE;
     1398#ifdef FEAT_AUTOCMD
     1399    curwin->w_topline_was_set = FALSE;
     1400#endif
    14001401
    14011402    /* Make sure the buffer is loaded. */
    14021403    if (curbuf->b_ml.ml_mfp == NULL)    /* need to load the file */
     
    14361437    maketitle();
    14371438#endif
    14381439#ifdef FEAT_AUTOCMD
    1439     if (curwin->w_topline == 1)         /* when autocmds didn't change it */
     1440        /* when autocmds didn't change it */
     1441    if (curwin->w_topline == 1 && !curwin->w_topline_was_set)
    14401442#endif
    14411443        scroll_cursor_halfway(FALSE);   /* redisplay at correct position */
    14421444
     
    39633965    width = vim_strsize(out);
    39643966    if (maxwidth > 0 && width > maxwidth)
    39653967    {
    3966         /* Result is too long, must trunctate somewhere. */
     3968        /* Result is too long, must truncate somewhere. */
    39673969        l = 0;
    39683970        if (itemcnt == 0)
    39693971            s = out;
     
    50485050         */
    50495051        FOR_ALL_TAB_WINDOWS(tp, win)
    50505052            if (win->w_buffer == buf)
    5051                 break;
     5053                goto win_found;
     5054win_found:
    50525055        if (win != NULL && win->w_llist_ref != NULL)
    50535056            return _("[Location List]");
    50545057        else
     
    50625065    {
    50635066        if (buf->b_sfname != NULL)
    50645067            return (char *)buf->b_sfname;
    5065         return "[Scratch]";
     5068        return _("[Scratch]");
    50665069    }
    50675070#endif
    50685071    if (buf->b_fname == NULL)
  • src/config.h.in

    diff -Naur vim72.orig/src/config.h.in vim72/src/config.h.in
    old new  
    5050/* Define to empty if the keyword does not work.  */
    5151#undef const
    5252
     53/* Define to empty if the keyword does not work.  */
     54#undef volatile
     55
    5356/* Define to `int' if <sys/types.h> doesn't define.  */
    5457#undef mode_t
    5558
  • src/configure.in

    diff -Naur vim72.orig/src/configure.in vim72/src/configure.in
    old new  
    21482148dnl Checks for typedefs, structures, and compiler characteristics.
    21492149AC_PROG_GCC_TRADITIONAL
    21502150AC_C_CONST
     2151AC_C_VOLATILE
    21512152AC_TYPE_MODE_T
    21522153AC_TYPE_OFF_T
    21532154AC_TYPE_PID_T
     
    31523153dnl But only when making dependencies, cproto and lint don't take "-isystem".
    31533154dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow
    31543155dnl the number before the version number.
    3155 AC_MSG_CHECKING(for GCC 3 or later)
    31563156DEPEND_CFLAGS_FILTER=
    31573157if test "$GCC" = yes; then
     3158  AC_MSG_CHECKING(for GCC 3 or later)
    31583159  gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'`
    31593160  if test "$gccmajor" -gt "2"; then
    31603161    DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'"
     3162    AC_MSG_RESULT(yes)
     3163  else
     3164    AC_MSG_RESULT(no)
     3165  fi
     3166  dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
     3167  dnl declared as char x[1] but actually longer.  Introduced in gcc 4.0.
     3168  AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
     3169  if test "$gccmajor" -gt "3"; then
     3170    CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=1"
     3171    AC_MSG_RESULT(yes)
     3172  else
     3173    AC_MSG_RESULT(no)
    31613174  fi
    3162 fi
    3163 if test "$DEPEND_CFLAGS_FILTER" = ""; then
    3164   AC_MSG_RESULT(no)
    3165 else
    3166   AC_MSG_RESULT(yes)
    31673175fi
    31683176AC_SUBST(DEPEND_CFLAGS_FILTER)
    31693177
  • src/diff.c

    diff -Naur vim72.orig/src/diff.c vim72/src/diff.c
    old new  
    88 */
    99
    1010/*
    11  * diff.c: code for diff'ing two or three buffers.
     11 * diff.c: code for diff'ing two, three or four buffers.
    1212 */
    1313
    1414#include "vim.h"
     
    7373        {
    7474            tp->tp_diffbuf[i] = NULL;
    7575            tp->tp_diff_invalid = TRUE;
     76            if (tp == curtab)
     77                diff_redraw(TRUE);
    7678        }
    7779    }
    7880}
     
    102104            {
    103105                curtab->tp_diffbuf[i] = NULL;
    104106                curtab->tp_diff_invalid = TRUE;
     107                diff_redraw(TRUE);
    105108            }
    106109        }
    107110    }
     
    113116 * Add a buffer to make diffs for.
    114117 * Call this when a new buffer is being edited in the current window where
    115118 * 'diff' is set.
    116  * Marks the current buffer as being part of the diff and requireing updating.
     119 * Marks the current buffer as being part of the diff and requiring updating.
    117120 * This must be done before any autocmd, because a command may use info
    118121 * about the screen contents.
    119122 */
     
    131134        {
    132135            curtab->tp_diffbuf[i] = buf;
    133136            curtab->tp_diff_invalid = TRUE;
     137            diff_redraw(TRUE);
    134138            return;
    135139        }
    136140
     
    661665    char_u      *tmp_diff;
    662666    FILE        *fd;
    663667    int         ok;
     668    int         io_error = FALSE;
    664669
    665670    /* Delete all diffblocks. */
    666671    diff_clear(curtab);
     
    697702    {
    698703        ok = FALSE;
    699704        fd = mch_fopen((char *)tmp_orig, "w");
    700         if (fd != NULL)
     705        if (fd == NULL)
     706            io_error = TRUE;
     707        else
    701708        {
    702             fwrite("line1\n", (size_t)6, (size_t)1, fd);
     709            if (fwrite("line1\n", (size_t)6, (size_t)1, fd) != 1)
     710                io_error = TRUE;
    703711            fclose(fd);
    704712            fd = mch_fopen((char *)tmp_new, "w");
    705             if (fd != NULL)
     713            if (fd == NULL)
     714                io_error = TRUE;
     715            else
    706716            {
    707                 fwrite("line2\n", (size_t)6, (size_t)1, fd);
     717                if (fwrite("line2\n", (size_t)6, (size_t)1, fd) != 1)
     718                    io_error = TRUE;
    708719                fclose(fd);
    709720                diff_file(tmp_orig, tmp_new, tmp_diff);
    710721                fd = mch_fopen((char *)tmp_diff, "r");
    711                 if (fd != NULL)
     722                if (fd == NULL)
     723                    io_error = TRUE;
     724                else
    712725                {
    713726                    char_u      linebuf[LBUFLEN];
    714727
     
    761774    }
    762775    if (!ok)
    763776    {
     777        if (io_error)
     778            EMSG(_("E810: Cannot read or write temp files"));
    764779        EMSG(_("E97: Cannot create diffs"));
    765780        diff_a_works = MAYBE;
    766781#if defined(MSWIN) || defined(MSDOS)
     
    914929        goto theend;
    915930
    916931#ifdef UNIX
    917     /* Temporaraly chdir to /tmp, to avoid patching files in the current
     932    /* Temporarily chdir to /tmp, to avoid patching files in the current
    918933     * directory when the patch file contains more than one patch.  When we
    919934     * have our own temp dir use that instead, it will be cleaned up when we
    920935     * exit (any .rej files created).  Don't change directory if we can't
     
    925940    {
    926941# ifdef TEMPDIRNAMES
    927942        if (vim_tempdir != NULL)
    928             mch_chdir((char *)vim_tempdir);
     943            ignored = mch_chdir((char *)vim_tempdir);
    929944        else
    930945# endif
    931             mch_chdir("/tmp");
     946            ignored = mch_chdir("/tmp");
    932947        shorten_fnames(TRUE);
    933948    }
    934949#endif
     
    11381153
    11391154    for (wp = firstwin; wp != NULL; wp = wp->w_next)
    11401155    {
    1141         if (wp == curwin || eap->forceit)
     1156        if (wp == curwin || (eap->forceit && wp->w_p_diff))
    11421157        {
    11431158            /* Set 'diff', 'scrollbind' off and 'wrap' on. */
    11441159            wp->w_p_diff = FALSE;
     
    21142129            EMSG2(_("E102: Can't find buffer \"%s\""), eap->arg);
    21152130            return;
    21162131        }
     2132        if (buf == curbuf)
     2133            return;             /* nothing to do */
    21172134        idx_other = diff_buf_idx(buf);
    21182135        if (idx_other == DB_COUNT)
    21192136        {
  • src/edit.c

    diff -Naur vim72.orig/src/edit.c vim72/src/edit.c
    old new  
    147147static int  ins_compl_bs __ARGS((void));
    148148static void ins_compl_new_leader __ARGS((void));
    149149static void ins_compl_addleader __ARGS((int c));
     150static int ins_compl_len __ARGS((void));
    150151static void ins_compl_restart __ARGS((void));
    151152static void ins_compl_set_original_text __ARGS((char_u *str));
    152153static void ins_compl_addfrommatch __ARGS((void));
     
    197198static void mb_replace_pop_ins __ARGS((int cc));
    198199#endif
    199200static void replace_flush __ARGS((void));
    200 static void replace_do_bs __ARGS((void));
     201static void replace_do_bs __ARGS((int limit_col));
     202static int del_char_after_col __ARGS((int limit_col));
    201203#ifdef FEAT_CINDENT
    202204static int cindent_on __ARGS((void));
    203205#endif
     
    19331935/*
    19341936 * Backspace the cursor until the given column.  Handles REPLACE and VREPLACE
    19351937 * modes correctly.  May also be used when not in insert mode at all.
     1938 * Will attempt not to go before "col" even when there is a composing
     1939 * character.
    19361940 */
    19371941    void
    19381942backspace_until_column(col)
     
    19421946    {
    19431947        curwin->w_cursor.col--;
    19441948        if (State & REPLACE_FLAG)
    1945             replace_do_bs();
    1946         else
    1947             (void)del_char(FALSE);
     1949            replace_do_bs(col);
     1950        else if (!del_char_after_col(col))
     1951            break;
    19481952    }
    19491953}
    19501954#endif
    19511955
     1956/*
     1957 * Like del_char(), but make sure not to go before column "limit_col".
     1958 * Only matters when there are composing characters.
     1959 * Return TRUE when something was deleted.
     1960 */
     1961/*ARGSUSED*/
     1962   static int
     1963del_char_after_col(limit_col)
     1964    int limit_col;
     1965{
     1966#ifdef FEAT_MBYTE
     1967    if (enc_utf8 && limit_col >= 0)
     1968    {
     1969        int ecol = curwin->w_cursor.col + 1;
     1970
     1971        /* Make sure the cursor is at the start of a character, but
     1972         * skip forward again when going too far back because of a
     1973         * composing character. */
     1974        mb_adjust_cursor();
     1975        while (curwin->w_cursor.col < (colnr_T)limit_col)
     1976        {
     1977            int l = utf_ptr2len(ml_get_cursor());
     1978
     1979            if (l == 0)  /* end of line */
     1980                break;
     1981            curwin->w_cursor.col += l;
     1982        }
     1983        if (*ml_get_cursor() == NUL || curwin->w_cursor.col == ecol)
     1984            return FALSE;
     1985        del_bytes((long)(ecol - curwin->w_cursor.col), FALSE, TRUE);
     1986    }
     1987    else
     1988#endif
     1989        (void)del_char(FALSE);
     1990    return TRUE;
     1991}
     1992
    19521993#if defined(FEAT_INS_EXPAND) || defined(PROTO)
    19531994/*
    19541995 * CTRL-X pressed in Insert mode.
     
    24182459        {
    24192460            had_match = (curwin->w_cursor.col > compl_col);
    24202461            ins_compl_delete();
    2421             ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
     2462            ins_bytes(compl_leader + ins_compl_len());
    24222463            ins_redraw(FALSE);
    24232464
    24242465            /* When the match isn't there (to avoid matching itself) remove it
     
    24702511            *p = NUL;
    24712512            had_match = (curwin->w_cursor.col > compl_col);
    24722513            ins_compl_delete();
    2473             ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
     2514            ins_bytes(compl_leader + ins_compl_len());
    24742515            ins_redraw(FALSE);
    24752516
    24762517            /* When the match isn't there (to avoid matching itself) remove it
     
    32093250{
    32103251    ins_compl_del_pum();
    32113252    ins_compl_delete();
    3212     ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
     3253    ins_bytes(compl_leader + ins_compl_len());
    32133254    compl_used_match = FALSE;
    32143255
    32153256    if (compl_started)
     
    32643305}
    32653306
    32663307/*
     3308 * Return the length of the completion, from the completion start column to
     3309 * the cursor column.  Making sure it never goes below zero.
     3310 */
     3311    static int
     3312ins_compl_len()
     3313{
     3314    int off = curwin->w_cursor.col - compl_col;
     3315
     3316    if (off < 0)
     3317        return 0;
     3318    return off;
     3319}
     3320
     3321/*
    32673322 * Append one character to the match leader.  May reduce the number of
    32683323 * matches.
    32693324 */
     
    36213676            {
    36223677                ins_compl_delete();
    36233678                if (compl_leader != NULL)
    3624                     ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
     3679                    ins_bytes(compl_leader + ins_compl_len());
    36253680                else if (compl_first_match != NULL)
    3626                     ins_bytes(compl_orig_text
    3627                                           + curwin->w_cursor.col - compl_col);
     3681                    ins_bytes(compl_orig_text + ins_compl_len());
    36283682                retval = TRUE;
    36293683            }
    36303684
     
    41874241        }
    41884242
    41894243        /* check if compl_curr_match has changed, (e.g. other type of
    4190          * expansion added somenthing) */
     4244         * expansion added something) */
    41914245        if (type != 0 && compl_curr_match != old_match)
    41924246            found_new_match = OK;
    41934247
     
    42564310    static void
    42574311ins_compl_insert()
    42584312{
    4259     ins_bytes(compl_shown_match->cp_str + curwin->w_cursor.col - compl_col);
     4313    ins_bytes(compl_shown_match->cp_str + ins_compl_len());
    42604314    if (compl_shown_match->cp_flags & ORIGINAL_TEXT)
    42614315        compl_used_match = FALSE;
    42624316    else
     
    44254479        if (!compl_get_longest || compl_used_match)
    44264480            ins_compl_insert();
    44274481        else
    4428             ins_bytes(compl_leader + curwin->w_cursor.col - compl_col);
     4482            ins_bytes(compl_leader + ins_compl_len());
    44294483    }
    44304484    else
    44314485        compl_used_match = FALSE;
     
    46884742                }
    46894743                compl_length = curwin->w_cursor.col - (int)compl_col;
    46904744                /* IObuff is used to add a "word from the next line" would we
    4691                  * have enough space?  just being paranoic */
     4745                 * have enough space?  just being paranoid */
    46924746#define MIN_SPACE 75
    46934747                if (compl_length > (IOSIZE - MIN_SPACE))
    46944748                {
     
    71237177 * cc == 0: character was inserted, delete it
    71247178 * cc > 0: character was replaced, put cc (first byte of original char) back
    71257179 * and check for more characters to be put back
     7180 * When "limit_col" is >= 0, don't delete before this column.  Matters when
     7181 * using composing characters, use del_char_after_col() instead of del_char().
    71267182 */
    71277183    static void
    7128 replace_do_bs()
     7184replace_do_bs(limit_col)
     7185    int         limit_col;
    71297186{
    71307187    int         cc;
    71317188#ifdef FEAT_VREPLACE
     
    71537210#ifdef FEAT_MBYTE
    71547211        if (has_mbyte)
    71557212        {
    7156             del_char(FALSE);
     7213            (void)del_char_after_col(limit_col);
    71577214# ifdef FEAT_VREPLACE
    71587215            if (State & VREPLACE_FLAG)
    71597216                orig_len = (int)STRLEN(ml_get_cursor());
     
    72037260        changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col);
    72047261    }
    72057262    else if (cc == 0)
    7206         (void)del_char(FALSE);
     7263        (void)del_char_after_col(limit_col);
    72077264}
    72087265
    72097266#ifdef FEAT_CINDENT
     
    76467703     */
    76477704    ++no_mapping;
    76487705    regname = plain_vgetc();
    7649 #ifdef FEAT_LANGMAP
    76507706    LANGMAP_ADJUST(regname, TRUE);
    7651 #endif
    76527707    if (regname == Ctrl_R || regname == Ctrl_O || regname == Ctrl_P)
    76537708    {
    76547709        /* Get a third key for literal register insertion */
     
    76577712        add_to_showcmd_c(literally);
    76587713#endif
    76597714        regname = plain_vgetc();
    7660 #ifdef FEAT_LANGMAP
    76617715        LANGMAP_ADJUST(regname, TRUE);
    7662 #endif
    76637716    }
    76647717    --no_mapping;
    76657718
     
    81508203/*
    81518204 * If the cursor is on an indent, ^T/^D insert/delete one
    81528205 * shiftwidth.  Otherwise ^T/^D behave like a "<<" or ">>".
    8153  * Always round the indent to 'shiftwith', this is compatible
     8206 * Always round the indent to 'shiftwidth', this is compatible
    81548207 * with vi.  But vi only supports ^T and ^D after an
    81558208 * autoindent, we support it everywhere.
    81568209 */
     
    82398292         * Replace mode */
    82408293        if (curwin->w_cursor.lnum != Insstart.lnum
    82418294                || curwin->w_cursor.col >= Insstart.col)
    8242             replace_do_bs();
     8295            replace_do_bs(-1);
    82438296    }
    82448297    else
    82458298        (void)del_char(FALSE);
     
    85568609                break;
    85578610            }
    85588611            if (State & REPLACE_FLAG)
    8559                 replace_do_bs();
     8612                replace_do_bs(-1);
    85608613            else
    85618614            {
    85628615#ifdef FEAT_MBYTE
  • src/eval.c

    diff -Naur vim72.orig/src/eval.c vim72/src/eval.c
    old new  
    3232
    3333#define DICT_MAXNEST 100        /* maximum nesting of lists and dicts */
    3434
     35#define DO_NOT_FREE_CNT 99999   /* refcount for dict or list that should not
     36                                   be freed. */
     37
    3538/*
    3639 * In a hashtab item "hi_key" points to "di_key" in a dictitem.
    3740 * This avoids adding a pointer to the hashtab item.
     
    348351    {VV_NAME("mouse_col",        VAR_NUMBER), 0},
    349352    {VV_NAME("operator",         VAR_STRING), VV_RO},
    350353    {VV_NAME("searchforward",    VAR_NUMBER), 0},
     354    {VV_NAME("oldfiles",         VAR_LIST), 0},
    351355};
    352356
    353357/* shorthand */
     
    355359#define vv_nr           vv_di.di_tv.vval.v_number
    356360#define vv_float        vv_di.di_tv.vval.v_float
    357361#define vv_str          vv_di.di_tv.vval.v_string
     362#define vv_list         vv_di.di_tv.vval.v_list
    358363#define vv_tv           vv_di.di_tv
    359364
    360365/*
     
    426431static long list_idx_of_item __ARGS((list_T *l, listitem_T *item));
    427432static void list_append __ARGS((list_T *l, listitem_T *item));
    428433static int list_append_tv __ARGS((list_T *l, typval_T *tv));
    429 static int list_append_string __ARGS((list_T *l, char_u *str, int len));
    430434static int list_append_number __ARGS((list_T *l, varnumber_T n));
    431435static int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item));
    432436static int list_extend __ARGS((list_T   *l1, list_T *l2, listitem_T *bef));
     
    788792static void func_unref __ARGS((char_u *name));
    789793static void func_ref __ARGS((char_u *name));
    790794static void call_user_func __ARGS((ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rettv, linenr_T firstline, linenr_T lastline, dict_T *selfdict));
     795static int can_free_funccal __ARGS((funccall_T *fc, int copyID)) ;
     796static void free_funccal __ARGS((funccall_T *fc, int free_val));
    791797static void add_nr_var __ARGS((dict_T *dp, dictitem_T *v, char *name, varnumber_T nr));
    792798static win_T *find_win_by_nr __ARGS((typval_T *vp, tabpage_T *tp));
    793799static void getwinvar __ARGS((typval_T *argvars, typval_T *rettv, int off));
     
    845851        p = &vimvars[i];
    846852        if (p->vv_di.di_tv.v_type == VAR_STRING)
    847853        {
    848             vim_free(p->vv_di.di_tv.vval.v_string);
    849             p->vv_di.di_tv.vval.v_string = NULL;
     854            vim_free(p->vv_str);
     855            p->vv_str = NULL;
     856        }
     857        else if (p->vv_di.di_tv.v_type == VAR_LIST)
     858        {
     859            list_unref(p->vv_list);
     860            p->vv_list = NULL;
    850861        }
    851862    }
    852863    hash_clear(&vimvarht);
     864    hash_init(&vimvarht);  /* garbage_collect() will access it */
    853865    hash_clear(&compat_hashtab);
    854866
    855867    /* script-local variables */
     
    916928/* pointer to funccal for currently active function */
    917929funccall_T *current_funccal = NULL;
    918930
     931/* pointer to list of previously used funccal, still around because some
     932 * item in it is still being used. */
     933funccall_T *previous_funccal = NULL;
     934
    919935/*
    920936 * Return TRUE when a function was ended by a ":return" command.
    921937 */
     
    12561272
    12571273/*
    12581274 * Top level evaluation function, returning a string.
     1275 * When "convert" is TRUE convert a List into a sequence of lines and convert
     1276 * a Float to a String.
    12591277 * Return pointer to allocated memory, or NULL for failure.
    12601278 */
    12611279    char_u *
    1262 eval_to_string(arg, nextcmd, dolist)
     1280eval_to_string(arg, nextcmd, convert)
    12631281    char_u      *arg;
    12641282    char_u      **nextcmd;
    1265     int         dolist;         /* turn List into sequence of lines */
     1283    int         convert;
    12661284{
    12671285    typval_T    tv;
    12681286    char_u      *retval;
    12691287    garray_T    ga;
     1288    char_u      numbuf[NUMBUFLEN];
    12701289
    12711290    if (eval0(arg, &tv, nextcmd, TRUE) == FAIL)
    12721291        retval = NULL;
    12731292    else
    12741293    {
    1275         if (dolist && tv.v_type == VAR_LIST)
     1294        if (convert && tv.v_type == VAR_LIST)
    12761295        {
    12771296            ga_init2(&ga, (int)sizeof(char), 80);
    12781297            if (tv.vval.v_list != NULL)
     
    12801299            ga_append(&ga, NUL);
    12811300            retval = (char_u *)ga.ga_data;
    12821301        }
     1302#ifdef FEAT_FLOAT
     1303        else if (convert && tv.v_type == VAR_FLOAT)
     1304        {
     1305            vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv.vval.v_float);
     1306            retval = vim_strsave(numbuf);
     1307        }
     1308#endif
    12831309        else
    12841310            retval = vim_strsave(get_tv_string(&tv));
    12851311        clear_tv(&tv);
     
    32773303
    32783304    if (*startarg != '(')
    32793305    {
    3280         EMSG2(_("E107: Missing braces: %s"), eap->arg);
     3306        EMSG2(_("E107: Missing parentheses: %s"), eap->arg);
    32813307        goto end;
    32823308    }
    32833309
     
    36573683}
    36583684
    36593685/*
    3660  * Return TRUE if typeval "tv" is locked: Either tha value is locked itself or
    3661  * it refers to a List or Dictionary that is locked.
     3686 * Return TRUE if typeval "tv" is locked: Either that value is locked itself
     3687 * or it refers to a List or Dictionary that is locked.
    36623688 */
    36633689    static int
    36643690tv_islocked(tv)
     
    39023928
    39033929/*
    39043930 * Handle top level expression:
    3905  *      expr1 ? expr0 : expr0
     3931 *      expr2 ? expr1 : expr1
    39063932 *
    39073933 * "arg" must point to the first non-white of the expression.
    39083934 * "arg" is advanced to the next non-white after the recognized expression.
     
    60476073}
    60486074
    60496075/*
     6076 * Get list item "l[idx - 1]" as a string.  Returns NULL for failure.
     6077 */
     6078    char_u *
     6079list_find_str(l, idx)
     6080    list_T      *l;
     6081    long        idx;
     6082{
     6083    listitem_T  *li;
     6084
     6085    li = list_find(l, idx - 1);
     6086    if (li == NULL)
     6087    {
     6088        EMSGN(_(e_listidx), idx);
     6089        return NULL;
     6090    }
     6091    return get_tv_string(&li->li_tv);
     6092}
     6093
     6094/*
    60506095 * Locate "item" list "l" and return its index.
    60516096 * Returns -1 when "item" is not in the list.
    60526097 */
     
    61376182 * When "len" >= 0 use "str[len]".
    61386183 * Returns FAIL when out of memory.
    61396184 */
    6140     static int
     6185    int
    61416186list_append_string(l, str, len)
    61426187    list_T      *l;
    61436188    char_u      *str;
     
    64546499    buf_T       *buf;
    64556500    win_T       *wp;
    64566501    int         i;
    6457     funccall_T  *fc;
     6502    funccall_T  *fc, **pfc;
    64586503    int         did_free = FALSE;
    64596504#ifdef FEAT_WINDOWS
    64606505    tabpage_T   *tp;
     
    64976542        set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID);
    64986543    }
    64996544
     6545    /* v: vars */
     6546    set_ref_in_ht(&vimvarht, copyID);
     6547
    65006548    /*
    65016549     * 2. Go through the list of dicts and free items without the copyID.
    65026550     */
     
    65356583        else
    65366584            ll = ll->lv_used_next;
    65376585
     6586    /* check if any funccal can be freed now */
     6587    for (pfc = &previous_funccal; *pfc != NULL; )
     6588    {
     6589        if (can_free_funccal(*pfc, copyID))
     6590        {
     6591            fc = *pfc;
     6592            *pfc = fc->caller;
     6593            free_funccal(fc, TRUE);
     6594            did_free = TRUE;
     6595        }
     6596        else
     6597            pfc = &(*pfc)->caller;
     6598    }
     6599
    65386600    return did_free;
    65396601}
    65406602
     
    65876649    {
    65886650        case VAR_DICT:
    65896651            dd = tv->vval.v_dict;
    6590             if (dd->dv_copyID != copyID)
     6652            if (dd != NULL && dd->dv_copyID != copyID)
    65916653            {
    65926654                /* Didn't see this dict yet. */
    65936655                dd->dv_copyID = copyID;
     
    65976659
    65986660        case VAR_LIST:
    65996661            ll = tv->vval.v_list;
    6600             if (ll->lv_copyID != copyID)
     6662            if (ll != NULL && ll->lv_copyID != copyID)
    66016663            {
    66026664                /* Didn't see this list yet. */
    66036665                ll->lv_copyID = copyID;
     
    75257587    {"getwinposx",      0, 0, f_getwinposx},
    75267588    {"getwinposy",      0, 0, f_getwinposy},
    75277589    {"getwinvar",       2, 2, f_getwinvar},
    7528     {"glob",            1, 1, f_glob},
    7529     {"globpath",        2, 2, f_globpath},
     7590    {"glob",            1, 2, f_glob},
     7591    {"globpath",        2, 3, f_globpath},
    75307592    {"has",             1, 1, f_has},
    75317593    {"has_key",         2, 2, f_has_key},
    75327594    {"haslocaldir",     0, 0, f_haslocaldir},
     
    78567918    else if (!aborting())
    78577919    {
    78587920        if (argcount == MAX_FUNC_ARGS)
    7859             emsg_funcname("E740: Too many arguments for function %s", name);
     7921            emsg_funcname(N_("E740: Too many arguments for function %s"), name);
    78607922        else
    7861             emsg_funcname("E116: Invalid arguments for function %s", name);
     7923            emsg_funcname(N_("E116: Invalid arguments for function %s"), name);
    78627924    }
    78637925
    78647926    while (--argcount >= 0)
     
    80918153
    80928154/*
    80938155 * Give an error message with a function name.  Handle <SNR> things.
     8156 * "ermsg" is to be passed without translation, use N_() instead of _().
    80948157 */
    80958158    static void
    80968159emsg_funcname(ermsg, name)
     
    95189581    else
    95199582    {
    95209583        /* When the optional second argument is non-zero, don't remove matches
    9521          * for 'suffixes' and 'wildignore' */
     9584         * for 'wildignore' and don't put matches for 'suffixes' at the end. */
    95229585        if (argvars[1].v_type != VAR_UNKNOWN
    95239586                                    && get_tv_number_chk(&argvars[1], &error))
    95249587            flags |= WILD_KEEP_ALL;
     
    1030010363    s = get_tv_string(&argvars[0]);
    1030110364    if (s == NULL || *s == NUL || VIM_ISDIGIT(*s))
    1030210365        EMSG2(_(e_invarg2), s);
    10303     else if (!function_exists(s))
     10366    /* Don't check an autoload name for existence here. */
     10367    else if (vim_strchr(s, AUTOLOAD_CHAR) == NULL && !function_exists(s))
    1030410368        EMSG2(_("E700: Unknown function: %s"), s);
    1030510369    else
    1030610370    {
     
    1060210666# ifdef FEAT_WINDOWS
    1060310667            win_T       *wp;
    1060410668# endif
    10605             int         n = 1;
     10669            int         winnr = 1;
    1060610670
    1060710671            if (row >= 0 && col >= 0)
    1060810672            {
     
    1061210676                (void)mouse_comp_pos(win, &row, &col, &lnum);
    1061310677# ifdef FEAT_WINDOWS
    1061410678                for (wp = firstwin; wp != win; wp = wp->w_next)
    10615                     ++n;
     10679                    ++winnr;
    1061610680# endif
    10617                 vimvars[VV_MOUSE_WIN].vv_nr = n;
     10681                vimvars[VV_MOUSE_WIN].vv_nr = winnr;
    1061810682                vimvars[VV_MOUSE_LNUM].vv_nr = lnum;
    1061910683                vimvars[VV_MOUSE_COL].vv_nr = col + 1;
    1062010684            }
     
    1128411348    typval_T    *argvars;
    1128511349    typval_T    *rettv;
    1128611350{
     11351    int         flags = WILD_SILENT|WILD_USE_NL;
    1128711352    expand_T    xpc;
     11353    int         error = FALSE;
    1128811354
    11289     ExpandInit(&xpc);
    11290     xpc.xp_context = EXPAND_FILES;
     11355    /* When the optional second argument is non-zero, don't remove matches
     11356    * for 'wildignore' and don't put matches for 'suffixes' at the end. */
     11357    if (argvars[1].v_type != VAR_UNKNOWN
     11358                                && get_tv_number_chk(&argvars[1], &error))
     11359        flags |= WILD_KEEP_ALL;
    1129111360    rettv->v_type = VAR_STRING;
    11292     rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
    11293                                      NULL, WILD_USE_NL|WILD_SILENT, WILD_ALL);
     11361    if (!error)
     11362    {
     11363        ExpandInit(&xpc);
     11364        xpc.xp_context = EXPAND_FILES;
     11365        rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]),
     11366                                                       NULL, flags, WILD_ALL);
     11367    }
     11368    else
     11369        rettv->vval.v_string = NULL;
    1129411370}
    1129511371
    1129611372/*
     
    1130111377    typval_T    *argvars;
    1130211378    typval_T    *rettv;
    1130311379{
     11380    int         flags = 0;
    1130411381    char_u      buf1[NUMBUFLEN];
    1130511382    char_u      *file = get_tv_string_buf_chk(&argvars[1], buf1);
     11383    int         error = FALSE;
    1130611384
     11385    /* When the optional second argument is non-zero, don't remove matches
     11386    * for 'wildignore' and don't put matches for 'suffixes' at the end. */
     11387    if (argvars[2].v_type != VAR_UNKNOWN
     11388                                && get_tv_number_chk(&argvars[2], &error))
     11389        flags |= WILD_KEEP_ALL;
    1130711390    rettv->v_type = VAR_STRING;
    11308     if (file == NULL)
     11391    if (file == NULL || error)
    1130911392        rettv->vval.v_string = NULL;
    1131011393    else
    11311         rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file);
     11394        rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file,
     11395                                                                       flags);
    1131211396}
    1131311397
    1131411398/*
     
    1178211866            n = has_patch(atoi((char *)name + 5));
    1178311867        else if (STRICMP(name, "vim_starting") == 0)
    1178411868            n = (starting != 0);
     11869#ifdef FEAT_MBYTE
     11870        else if (STRICMP(name, "multi_byte_encoding") == 0)
     11871            n = has_mbyte;
     11872#endif
    1178511873#if defined(FEAT_BEVAL) && defined(FEAT_GUI_W32)
    1178611874        else if (STRICMP(name, "balloon_multiline") == 0)
    1178711875            n = multiline_balloon_available();
     
    1583815926    if (res == FAIL)
    1583915927        res = ITEM_COMPARE_FAIL;
    1584015928    else
    15841         /* return value has wrong type */
    1584215929        res = get_tv_number_chk(&rettv, &item_compare_func_err);
    1584315930    if (item_compare_func_err)
    15844         res = ITEM_COMPARE_FAIL;
     15931        res = ITEM_COMPARE_FAIL;  /* return value has wrong type */
    1584515932    clear_tv(&rettv);
    1584615933    return res;
    1584715934}
     
    1659016677                p = highlight_has_attr(id, HL_INVERSE, modec);
    1659116678                break;
    1659216679
    16593         case 's':                                       /* standout */
    16594                 p = highlight_has_attr(id, HL_STANDOUT, modec);
     16680        case 's':
     16681                if (TOLOWER_ASC(what[1]) == 'p')        /* sp[#] */
     16682                    p = highlight_color(id, what, modec);
     16683                else                                    /* standout */
     16684                    p = highlight_has_attr(id, HL_STANDOUT, modec);
    1659516685                break;
    1659616686
    1659716687        case 'u':
     
    1665816748    col = get_tv_number(&argvars[1]) - 1;       /* -1 on type error */
    1665916749
    1666016750    if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count
    16661             && col >= 0 && col < (long)STRLEN(ml_get(lnum))
     16751            && col >= 0 && (col == 0 || col < (long)STRLEN(ml_get(lnum)))
    1666216752            && rettv_list_alloc(rettv) != FAIL)
    1666316753    {
    1666416754        (void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL, TRUE);
     
    1809718187}
    1809818188
    1809918189/*
    18100  * Set v:count, v:count1 and v:prevcount.
     18190 * Get List v: variable value.  Caller must take care of reference count when
     18191 * needed.
     18192 */
     18193    list_T *
     18194get_vim_var_list(idx)
     18195    int         idx;
     18196{
     18197    return vimvars[idx].vv_list;
     18198}
     18199
     18200/*
     18201 * Set v:count to "count" and v:count1 to "count1".
     18202 * When "set_prevcount" is TRUE first set v:prevcount from v:count.
    1810118203 */
    1810218204    void
    18103 set_vcount(count, count1)
     18205set_vcount(count, count1, set_prevcount)
    1810418206    long        count;
    1810518207    long        count1;
     18208    int         set_prevcount;
    1810618209{
    18107     vimvars[VV_PREVCOUNT].vv_nr = vimvars[VV_COUNT].vv_nr;
     18210    if (set_prevcount)
     18211        vimvars[VV_PREVCOUNT].vv_nr = vimvars[VV_COUNT].vv_nr;
    1810818212    vimvars[VV_COUNT].vv_nr = count;
    1810918213    vimvars[VV_COUNT1].vv_nr = count1;
    1811018214}
     
    1813218236}
    1813318237
    1813418238/*
     18239 * Set List v: variable to "val".
     18240 */
     18241    void
     18242set_vim_var_list(idx, val)
     18243    int         idx;
     18244    list_T      *val;
     18245{
     18246    list_unref(vimvars[idx].vv_list);
     18247    vimvars[idx].vv_list = val;
     18248    if (val != NULL)
     18249        ++val->lv_refcount;
     18250}
     18251
     18252/*
    1813518253 * Set v:register if needed.
    1813618254 */
    1813718255    void
     
    1886818986    dictitem_T  *dict_var;
    1886918987{
    1887018988    hash_init(&dict->dv_hashtab);
    18871     dict->dv_refcount = 99999;
     18989    dict->dv_refcount = DO_NOT_FREE_CNT;
    1887218990    dict_var->di_tv.vval.v_dict = dict;
    1887318991    dict_var->di_tv.v_type = VAR_DICT;
    1887418992    dict_var->di_tv.v_lock = VAR_FIXED;
     
    1920519323 * Copy the values from typval_T "from" to typval_T "to".
    1920619324 * When needed allocates string or increases reference count.
    1920719325 * Does not make a copy of a list or dict but copies the reference!
     19326 * It is OK for "from" and "to" to point to the same item.  This is used to
     19327 * make a copy later.
    1920819328 */
    1920919329    static void
    1921019330copy_tv(from, to)
     
    1974819868                }
    1974919869            }
    1975019870            else
    19751                 emsg_funcname("E123: Undefined function: %s", name);
     19871                emsg_funcname(N_("E123: Undefined function: %s"), name);
    1975219872        }
    1975319873        goto ret_free;
    1975419874    }
     
    1979219912                                                      : eval_isnamec(arg[j])))
    1979319913                ++j;
    1979419914            if (arg[j] != NUL)
    19795                 emsg_funcname(_(e_invarg2), arg);
     19915                emsg_funcname((char *)e_invarg2, arg);
    1979619916        }
    1979719917    }
    1979819918
     
    2006420184        v = find_var(name, &ht);
    2006520185        if (v != NULL && v->di_tv.v_type == VAR_FUNC)
    2006620186        {
    20067             emsg_funcname("E707: Function name conflicts with variable: %s",
     20187            emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
    2006820188                                                                        name);
    2006920189            goto erret;
    2007020190        }
     
    2007920199            }
    2008020200            if (fp->uf_calls > 0)
    2008120201            {
    20082                 emsg_funcname("E127: Cannot redefine function %s: It is in use",
     20202                emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"),
    2008320203                                                                        name);
    2008420204                goto erret;
    2008520205            }
     
    2059020710    int         st_len = 0;
    2059120711
    2059220712    todo = (int)func_hashtab.ht_used;
     20713    if (todo == 0)
     20714        return;     /* nothing to dump */
     20715
    2059320716    sorttab = (ufunc_T **)alloc((unsigned)(sizeof(ufunc_T) * todo));
    2059420717
    2059520718    for (hi = func_hashtab.ht_array; todo > 0; ++hi)
     
    2063820761                                                              prof_self_cmp);
    2063920762        prof_sort_list(fd, sorttab, st_len, "SELF", TRUE);
    2064020763    }
     20764
     20765    vim_free(sorttab);
    2064120766}
    2064220767
    2064320768    static void
     
    2101221137    char_u      *save_sourcing_name;
    2101321138    linenr_T    save_sourcing_lnum;
    2101421139    scid_T      save_current_SID;
    21015     funccall_T  fc;
     21140    funccall_T  *fc;
    2101621141    int         save_did_emsg;
    2101721142    static int  depth = 0;
    2101821143    dictitem_T  *v;
     
    2103821163
    2103921164    line_breakcheck();          /* check for CTRL-C hit */
    2104021165
    21041     fc.caller = current_funccal;
    21042     current_funccal = &fc;
    21043     fc.func = fp;
    21044     fc.rettv = rettv;
     21166    fc = (funccall_T *)alloc(sizeof(funccall_T));
     21167    fc->caller = current_funccal;
     21168    current_funccal = fc;
     21169    fc->func = fp;
     21170    fc->rettv = rettv;
    2104521171    rettv->vval.v_number = 0;
    21046     fc.linenr = 0;
    21047     fc.returned = FALSE;
    21048     fc.level = ex_nesting_level;
     21172    fc->linenr = 0;
     21173    fc->returned = FALSE;
     21174    fc->level = ex_nesting_level;
    2104921175    /* Check if this function has a breakpoint. */
    21050     fc.breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name, (linenr_T)0);
    21051     fc.dbg_tick = debug_tick;
     21176    fc->breakpoint = dbg_find_breakpoint(FALSE, fp->uf_name, (linenr_T)0);
     21177    fc->dbg_tick = debug_tick;
    2105221178
    2105321179    /*
    21054      * Note about using fc.fixvar[]: This is an array of FIXVAR_CNT variables
     21180     * Note about using fc->fixvar[]: This is an array of FIXVAR_CNT variables
    2105521181     * with names up to VAR_SHORT_LEN long.  This avoids having to alloc/free
    2105621182     * each argument variable and saves a lot of time.
    2105721183     */
    2105821184    /*
    2105921185     * Init l: variables.
    2106021186     */
    21061     init_var_dict(&fc.l_vars, &fc.l_vars_var);
     21187    init_var_dict(&fc->l_vars, &fc->l_vars_var);
    2106221188    if (selfdict != NULL)
    2106321189    {
    2106421190        /* Set l:self to "selfdict".  Use "name" to avoid a warning from
    2106521191         * some compiler that checks the destination size. */
    21066         v = &fc.fixvar[fixvar_idx++].var;
     21192        v = &fc->fixvar[fixvar_idx++].var;
    2106721193        name = v->di_key;
    2106821194        STRCPY(name, "self");
    2106921195        v->di_flags = DI_FLAGS_RO + DI_FLAGS_FIX;
    21070         hash_add(&fc.l_vars.dv_hashtab, DI2HIKEY(v));
     21196        hash_add(&fc->l_vars.dv_hashtab, DI2HIKEY(v));
    2107121197        v->di_tv.v_type = VAR_DICT;
    2107221198        v->di_tv.v_lock = 0;
    2107321199        v->di_tv.vval.v_dict = selfdict;
     
    2107921205     * Set a:0 to "argcount".
    2108021206     * Set a:000 to a list with room for the "..." arguments.
    2108121207     */
    21082     init_var_dict(&fc.l_avars, &fc.l_avars_var);
    21083     add_nr_var(&fc.l_avars, &fc.fixvar[fixvar_idx++].var, "0",
     21208    init_var_dict(&fc->l_avars, &fc->l_avars_var);
     21209    add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "0",
    2108421210                                (varnumber_T)(argcount - fp->uf_args.ga_len));
    21085     v = &fc.fixvar[fixvar_idx++].var;
    21086     STRCPY(v->di_key, "000");
     21211    /* Use "name" to avoid a warning from some compiler that checks the
     21212     * destination size. */
     21213    v = &fc->fixvar[fixvar_idx++].var;
     21214    name = v->di_key;
     21215    STRCPY(name, "000");
    2108721216    v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
    21088     hash_add(&fc.l_avars.dv_hashtab, DI2HIKEY(v));
     21217    hash_add(&fc->l_avars.dv_hashtab, DI2HIKEY(v));
    2108921218    v->di_tv.v_type = VAR_LIST;
    2109021219    v->di_tv.v_lock = VAR_FIXED;
    21091     v->di_tv.vval.v_list = &fc.l_varlist;
    21092     vim_memset(&fc.l_varlist, 0, sizeof(list_T));
    21093     fc.l_varlist.lv_refcount = 99999;
    21094     fc.l_varlist.lv_lock = VAR_FIXED;
     21220    v->di_tv.vval.v_list = &fc->l_varlist;
     21221    vim_memset(&fc->l_varlist, 0, sizeof(list_T));
     21222    fc->l_varlist.lv_refcount = DO_NOT_FREE_CNT;
     21223    fc->l_varlist.lv_lock = VAR_FIXED;
    2109521224
    2109621225    /*
    2109721226     * Set a:firstline to "firstline" and a:lastline to "lastline".
    2109821227     * Set a:name to named arguments.
    2109921228     * Set a:N to the "..." arguments.
    2110021229     */
    21101     add_nr_var(&fc.l_avars, &fc.fixvar[fixvar_idx++].var, "firstline",
     21230    add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "firstline",
    2110221231                                                      (varnumber_T)firstline);
    21103     add_nr_var(&fc.l_avars, &fc.fixvar[fixvar_idx++].var, "lastline",
     21232    add_nr_var(&fc->l_avars, &fc->fixvar[fixvar_idx++].var, "lastline",
    2110421233                                                       (varnumber_T)lastline);
    2110521234    for (i = 0; i < argcount; ++i)
    2110621235    {
     
    2111621245        }
    2111721246        if (fixvar_idx < FIXVAR_CNT && STRLEN(name) <= VAR_SHORT_LEN)
    2111821247        {
    21119             v = &fc.fixvar[fixvar_idx++].var;
     21248            v = &fc->fixvar[fixvar_idx++].var;
    2112021249            v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
    2112121250        }
    2112221251        else
     
    2112821257            v->di_flags = DI_FLAGS_RO;
    2112921258        }
    2113021259        STRCPY(v->di_key, name);
    21131         hash_add(&fc.l_avars.dv_hashtab, DI2HIKEY(v));
     21260        hash_add(&fc->l_avars.dv_hashtab, DI2HIKEY(v));
    2113221261
    2113321262        /* Note: the values are copied directly to avoid alloc/free.
    2113421263         * "argvars" must have VAR_FIXED for v_lock. */
     
    2113721266
    2113821267        if (ai >= 0 && ai < MAX_FUNC_ARGS)
    2113921268        {
    21140             list_append(&fc.l_varlist, &fc.l_listitems[ai]);
    21141             fc.l_listitems[ai].li_tv = argvars[i];
    21142             fc.l_listitems[ai].li_tv.v_lock = VAR_FIXED;
     21269            list_append(&fc->l_varlist, &fc->l_listitems[ai]);
     21270            fc->l_listitems[ai].li_tv = argvars[i];
     21271            fc->l_listitems[ai].li_tv.v_lock = VAR_FIXED;
    2114321272        }
    2114421273    }
    2114521274
     
    2120421333        if (!fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL))
    2120521334            func_do_profile(fp);
    2120621335        if (fp->uf_profiling
    21207                        || (fc.caller != NULL && &fc.caller->func->uf_profiling))
     21336                    || (fc->caller != NULL && fc->caller->func->uf_profiling))
    2120821337        {
    2120921338            ++fp->uf_tm_count;
    2121021339            profile_start(&call_start);
     
    2122021349    did_emsg = FALSE;
    2122121350
    2122221351    /* call do_cmdline() to execute the lines */
    21223     do_cmdline(NULL, get_func_line, (void *)&fc,
     21352    do_cmdline(NULL, get_func_line, (void *)fc,
    2122421353                                     DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT);
    2122521354
    2122621355    --RedrawingDisabled;
     
    2123521364
    2123621365#ifdef FEAT_PROFILE
    2123721366    if (do_profiling == PROF_YES && (fp->uf_profiling
    21238                     || (fc.caller != NULL && &fc.caller->func->uf_profiling)))
     21367                    || (fc->caller != NULL && fc->caller->func->uf_profiling)))
    2123921368    {
    2124021369        profile_end(&call_start);
    2124121370        profile_sub_wait(&wait_start, &call_start);
    2124221371        profile_add(&fp->uf_tm_total, &call_start);
    2124321372        profile_self(&fp->uf_tm_self, &call_start, &fp->uf_tm_children);
    21244         if (fc.caller != NULL && &fc.caller->func->uf_profiling)
     21373        if (fc->caller != NULL && fc->caller->func->uf_profiling)
    2124521374        {
    21246             profile_add(&fc.caller->func->uf_tm_children, &call_start);
    21247             profile_add(&fc.caller->func->uf_tml_children, &call_start);
     21375            profile_add(&fc->caller->func->uf_tm_children, &call_start);
     21376            profile_add(&fc->caller->func->uf_tml_children, &call_start);
    2124821377        }
    2124921378    }
    2125021379#endif
     
    2125721386
    2125821387        if (aborting())
    2125921388            smsg((char_u *)_("%s aborted"), sourcing_name);
    21260         else if (fc.rettv->v_type == VAR_NUMBER)
     21389        else if (fc->rettv->v_type == VAR_NUMBER)
    2126121390            smsg((char_u *)_("%s returning #%ld"), sourcing_name,
    21262                                                (long)fc.rettv->vval.v_number);
     21391                                               (long)fc->rettv->vval.v_number);
    2126321392        else
    2126421393        {
    2126521394            char_u      buf[MSG_BUF_LEN];
     
    2127021399            /* The value may be very long.  Skip the middle part, so that we
    2127121400             * have some idea how it starts and ends. smsg() would always
    2127221401             * truncate it at the end. */
    21273             s = tv2string(fc.rettv, &tofree, numbuf2, 0);
     21402            s = tv2string(fc->rettv, &tofree, numbuf2, 0);
    2127421403            if (s != NULL)
    2127521404            {
    2127621405                trunc_string(s, buf, MSG_BUF_CLEN);
     
    2130621435    }
    2130721436
    2130821437    did_emsg |= save_did_emsg;
    21309     current_funccal = fc.caller;
     21438    current_funccal = fc->caller;
     21439    --depth;
    2131021440
    21311     /* The a: variables typevals were not allocated, only free the allocated
    21312      * variables. */
    21313     vars_clear_ext(&fc.l_avars.dv_hashtab, FALSE);
     21441    /* if the a:000 list and the a: dict are not referenced we can free the
     21442     * funccall_T and what's in it. */
     21443    if (fc->l_varlist.lv_refcount == DO_NOT_FREE_CNT
     21444            && fc->l_vars.dv_refcount == DO_NOT_FREE_CNT
     21445            && fc->l_avars.dv_refcount == DO_NOT_FREE_CNT)
     21446    {
     21447        free_funccal(fc, FALSE);
     21448    }
     21449    else
     21450    {
     21451        hashitem_T      *hi;
     21452        listitem_T      *li;
     21453        int             todo;
    2131421454
    21315     vars_clear(&fc.l_vars.dv_hashtab);          /* free all l: variables */
    21316     --depth;
     21455        /* "fc" is still in use.  This can happen when returning "a:000" or
     21456         * assigning "l:" to a global variable.
     21457         * Link "fc" in the list for garbage collection later. */
     21458        fc->caller = previous_funccal;
     21459        previous_funccal = fc;
     21460
     21461        /* Make a copy of the a: variables, since we didn't do that above. */
     21462        todo = (int)fc->l_avars.dv_hashtab.ht_used;
     21463        for (hi = fc->l_avars.dv_hashtab.ht_array; todo > 0; ++hi)
     21464        {
     21465            if (!HASHITEM_EMPTY(hi))
     21466            {
     21467                --todo;
     21468                v = HI2DI(hi);
     21469                copy_tv(&v->di_tv, &v->di_tv);
     21470            }
     21471        }
     21472
     21473        /* Make a copy of the a:000 items, since we didn't do that above. */
     21474        for (li = fc->l_varlist.lv_first; li != NULL; li = li->li_next)
     21475            copy_tv(&li->li_tv, &li->li_tv);
     21476    }
     21477}
     21478
     21479/*
     21480 * Return TRUE if items in "fc" do not have "copyID".  That means they are not
     21481 * referenced from anywhere.
     21482 */
     21483    static int
     21484can_free_funccal(fc, copyID)
     21485    funccall_T  *fc;
     21486    int         copyID;
     21487{
     21488    return (fc->l_varlist.lv_copyID != copyID
     21489            && fc->l_vars.dv_copyID != copyID
     21490            && fc->l_avars.dv_copyID != copyID);
     21491}
     21492
     21493/*
     21494 * Free "fc" and what it contains.
     21495 */
     21496   static void
     21497free_funccal(fc, free_val)
     21498    funccall_T  *fc;
     21499    int         free_val;  /* a: vars were allocated */
     21500{
     21501    listitem_T  *li;
     21502
     21503    /* The a: variables typevals may not have been allocated, only free the
     21504     * allocated variables. */
     21505    vars_clear_ext(&fc->l_avars.dv_hashtab, free_val);
     21506
     21507    /* free all l: variables */
     21508    vars_clear(&fc->l_vars.dv_hashtab);
     21509
     21510    /* Free the a:000 variables if they were allocated. */
     21511    if (free_val)
     21512        for (li = fc->l_varlist.lv_first; li != NULL; li = li->li_next)
     21513            clear_tv(&li->li_tv);
     21514
     21515    vim_free(fc);
    2131721516}
    2131821517
    2131921518/*
     
    2188622085    }
    2188722086}
    2188822087
     22088/*
     22089 * List v:oldfiles in a nice way.
     22090 */
     22091/*ARGSUSED*/
     22092    void
     22093ex_oldfiles(eap)
     22094    exarg_T     *eap;
     22095{
     22096    list_T      *l = vimvars[VV_OLDFILES].vv_list;
     22097    listitem_T  *li;
     22098    int         nr = 0;
     22099
     22100    if (l == NULL)
     22101        msg((char_u *)_("No old files"));
     22102    else
     22103    {
     22104        msg_start();
     22105        msg_scroll = TRUE;
     22106        for (li = l->lv_first; li != NULL && !got_int; li = li->li_next)
     22107        {
     22108            msg_outnum((long)++nr);
     22109            MSG_PUTS(": ");
     22110            msg_outtrans(get_tv_string(&li->li_tv));
     22111            msg_putchar('\n');
     22112            out_flush();            /* output one line at a time */
     22113            ui_breakcheck();
     22114        }
     22115        /* Assume "got_int" was set to truncate the listing. */
     22116        got_int = FALSE;
     22117
     22118#ifdef FEAT_BROWSE_CMD
     22119        if (cmdmod.browse)
     22120        {
     22121            quit_more = FALSE;
     22122            nr = prompt_for_number(FALSE);
     22123            msg_starthere();
     22124            if (nr > 0)
     22125            {
     22126                char_u *p = list_find_str(get_vim_var_list(VV_OLDFILES),
     22127                                                                    (long)nr);
     22128
     22129                if (p != NULL)
     22130                {
     22131                    p = expand_env_save(p);
     22132                    eap->arg = p;
     22133                    eap->cmdidx = CMD_edit;
     22134                    cmdmod.browse = FALSE;
     22135                    do_exedit(eap, NULL);
     22136                    vim_free(p);
     22137                }
     22138            }
     22139        }
     22140#endif
     22141    }
     22142}
     22143
    2188922144#endif /* FEAT_EVAL */
    2189022145
    2189122146
  • src/ex_cmds2.c

    diff -Naur vim72.orig/src/ex_cmds2.c vim72/src/ex_cmds2.c
    old new  
    28422842    linenr_T                save_sourcing_lnum;
    28432843    char_u                  *p;
    28442844    char_u                  *fname_exp;
     2845    char_u                  *firstline = NULL;
    28452846    int                     retval = FAIL;
    28462847#ifdef FEAT_EVAL
    28472848    scid_T                  save_current_SID;
     
    29922993
    29932994    cookie.level = ex_nesting_level;
    29942995#endif
    2995 #ifdef FEAT_MBYTE
    2996     cookie.conv.vc_type = CONV_NONE;            /* no conversion */
    2997 
    2998     /* Try reading the first few bytes to check for a UTF-8 BOM. */
    2999     {
    3000         char_u      buf[3];
    3001 
    3002         if (fread((char *)buf, sizeof(char_u), (size_t)3, cookie.fp)
    3003                                                                   == (size_t)3
    3004                 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf)
    3005             /* Found BOM, setup conversion and skip over it. */
    3006             convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
    3007         else
    3008             /* No BOM found, rewind. */
    3009             fseek(cookie.fp, 0L, SEEK_SET);
    3010     }
    3011 #endif
    30122996
    30132997    /*
    30142998     * Keep the sourcing name/lnum, for recursive calls.
     
    30183002    save_sourcing_lnum = sourcing_lnum;
    30193003    sourcing_lnum = 0;
    30203004
     3005#ifdef FEAT_MBYTE
     3006    cookie.conv.vc_type = CONV_NONE;            /* no conversion */
     3007
     3008    /* Read the first line so we can check for a UTF-8 BOM. */
     3009    firstline = getsourceline(0, (void *)&cookie, 0);
     3010    if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef
     3011                              && firstline[1] == 0xbb && firstline[2] == 0xbf)
     3012    {
     3013        /* Found BOM; setup conversion, skip over BOM and recode the line. */
     3014        convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
     3015        p = string_convert(&cookie.conv, firstline + 3, NULL);
     3016        if (p == NULL)
     3017            p = vim_strsave(firstline + 3);
     3018        if (p != NULL)
     3019        {
     3020            vim_free(firstline);
     3021            firstline = p;
     3022        }
     3023    }
     3024#endif
     3025
    30213026#ifdef STARTUPTIME
    30223027    time_push(&tv_rel, &tv_start);
    30233028#endif
     
    31113116    /*
    31123117     * Call do_cmdline, which will call getsourceline() to get the lines.
    31133118     */
    3114     do_cmdline(NULL, getsourceline, (void *)&cookie,
     3119    do_cmdline(firstline, getsourceline, (void *)&cookie,
    31153120                                     DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);
    3116 
    31173121    retval = OK;
    31183122
    31193123#ifdef FEAT_PROFILE
     
    31453149        verbose_leave();
    31463150    }
    31473151#ifdef STARTUPTIME
    3148     vim_snprintf(IObuff, IOSIZE, "sourcing %s", fname);
    3149     time_msg(IObuff, &tv_start);
     3152    vim_snprintf((char *)IObuff, IOSIZE, "sourcing %s", fname);
     3153    time_msg((char *)IObuff, &tv_start);
    31503154    time_pop(&tv_rel);
    31513155#endif
    31523156
     
    31713175#endif
    31723176    fclose(cookie.fp);
    31733177    vim_free(cookie.nextline);
     3178    vim_free(firstline);
    31743179#ifdef FEAT_MBYTE
    31753180    convert_setup(&cookie.conv, NULL, NULL);
    31763181#endif
  • src/ex_cmds.c

    diff -Naur vim72.orig/src/ex_cmds.c vim72/src/ex_cmds.c
    old new  
    2424static void do_filter __ARGS((linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd, int do_in, int do_out));
    2525#ifdef FEAT_VIMINFO
    2626static char_u *viminfo_filename __ARGS((char_u  *));
    27 static void do_viminfo __ARGS((FILE *fp_in, FILE *fp_out, int want_info, int want_marks, int force_read));
     27static void do_viminfo __ARGS((FILE *fp_in, FILE *fp_out, int flags));
    2828static int viminfo_encoding __ARGS((vir_T *virp));
    2929static int read_viminfo_up_to_marks __ARGS((vir_T *virp, int forceit, int writing));
    3030#endif
     
    4949    exarg_T     *eap;
    5050{
    5151    int         c;
     52    int         cval;
    5253    char        buf1[20];
    5354    char        buf2[20];
    5455    char_u      buf3[7];
     
    7576    {
    7677        if (c == NL)        /* NUL is stored as NL */
    7778            c = NUL;
     79        if (c == CAR && get_fileformat(curbuf) == EOL_MAC)
     80            cval = NL;      /* NL is stored as CR */
     81        else
     82            cval = c;
    7883        if (vim_isprintc_strict(c) && (c < ' '
    7984#ifndef EBCDIC
    8085                    || c > '~'
     
    9499            buf2[0] = NUL;
    95100        vim_snprintf((char *)IObuff, IOSIZE,
    96101                _("<%s>%s%s  %d,  Hex %02x,  Octal %03o"),
    97                                            transchar(c), buf1, buf2, c, c, c);
     102                                  transchar(c), buf1, buf2, cval, cval, cval);
    98103#ifdef FEAT_MBYTE
    99104        if (enc_utf8)
    100105            c = cc[ci++];
     
    16761681
    16771682/*
    16781683 * read_viminfo() -- Read the viminfo file.  Registers etc. which are already
    1679  * set are not over-written unless force is TRUE. -- webb
     1684 * set are not over-written unless "flags" includes VIF_FORCEIT. -- webb
    16801685 */
    16811686    int
    1682 read_viminfo(file, want_info, want_marks, forceit)
    1683     char_u      *file;
    1684     int         want_info;
    1685     int         want_marks;
    1686     int         forceit;
     1687read_viminfo(file, flags)
     1688    char_u      *file;      /* file name or NULL to use default name */
     1689    int         flags;      /* VIF_WANT_INFO et al. */
    16871690{
    16881691    FILE        *fp;
    16891692    char_u      *fname;
     
    16911694    if (no_viminfo())
    16921695        return FAIL;
    16931696
    1694     fname = viminfo_filename(file);         /* may set to default if NULL */
     1697    fname = viminfo_filename(file);     /* get file name in allocated buffer */
    16951698    if (fname == NULL)
    16961699        return FAIL;
    16971700    fp = mch_fopen((char *)fname, READBIN);
     
    17011704        verbose_enter();
    17021705        smsg((char_u *)_("Reading viminfo file \"%s\"%s%s%s"),
    17031706                fname,
    1704                 want_info ? _(" info") : "",
    1705                 want_marks ? _(" marks") : "",
     1707                (flags & VIF_WANT_INFO) ? _(" info") : "",
     1708                (flags & VIF_WANT_MARKS) ? _(" marks") : "",
     1709                (flags & VIF_GET_OLDFILES) ? _(" oldfiles") : "",
    17061710                fp == NULL ? _(" FAILED") : "");
    17071711        verbose_leave();
    17081712    }
     
    17121716        return FAIL;
    17131717
    17141718    viminfo_errcnt = 0;
    1715     do_viminfo(fp, NULL, want_info, want_marks, forceit);
     1719    do_viminfo(fp, NULL, flags);
    17161720
    17171721    fclose(fp);
    1718 
    17191722    return OK;
    17201723}
    17211724
     
    19431946             * root.
    19441947             */
    19451948            if (fp_out != NULL)
    1946                 (void)fchown(fileno(fp_out), st_old.st_uid, st_old.st_gid);
     1949                ignored = fchown(fileno(fp_out), st_old.st_uid, st_old.st_gid);
    19471950#endif
    19481951        }
    19491952    }
     
    19681971    }
    19691972
    19701973    viminfo_errcnt = 0;
    1971     do_viminfo(fp_in, fp_out, !forceit, !forceit, FALSE);
     1974    do_viminfo(fp_in, fp_out, forceit ? 0 : (VIF_WANT_INFO | VIF_WANT_MARKS));
    19721975
    19731976    fclose(fp_out);         /* errors are ignored !? */
    19741977    if (fp_in != NULL)
     
    20412044 * do_viminfo() -- Should only be called from read_viminfo() & write_viminfo().
    20422045 */
    20432046    static void
    2044 do_viminfo(fp_in, fp_out, want_info, want_marks, force_read)
     2047do_viminfo(fp_in, fp_out, flags)
    20452048    FILE        *fp_in;
    20462049    FILE        *fp_out;
    2047     int         want_info;
    2048     int         want_marks;
    2049     int         force_read;
     2050    int         flags;
    20502051{
    20512052    int         count = 0;
    20522053    int         eof = FALSE;
     
    20612062
    20622063    if (fp_in != NULL)
    20632064    {
    2064         if (want_info)
    2065             eof = read_viminfo_up_to_marks(&vir, force_read, fp_out != NULL);
     2065        if (flags & VIF_WANT_INFO)
     2066            eof = read_viminfo_up_to_marks(&vir,
     2067                                         flags & VIF_FORCEIT, fp_out != NULL);
    20662068        else
    20672069            /* Skip info, find start of marks */
    20682070            while (!(eof = viminfo_readline(&vir))
     
    20922094        write_viminfo_bufferlist(fp_out);
    20932095        count = write_viminfo_marks(fp_out);
    20942096    }
    2095     if (fp_in != NULL && want_marks)
    2096         copy_viminfo_marks(&vir, fp_out, count, eof);
     2097    if (fp_in != NULL
     2098            && (flags & (VIF_WANT_MARKS | VIF_GET_OLDFILES | VIF_FORCEIT)))
     2099        copy_viminfo_marks(&vir, fp_out, count, eof, flags);
    20972100
    20982101    vim_free(vir.vir_line);
    20992102#ifdef FEAT_MBYTE
     
    24142417        cursor_on();            /* msg_start() switches it off */
    24152418        out_flush();
    24162419        silent_mode = save_silent;
    2417         info_message = FALSE;
    24182420    }
     2421    info_message = FALSE;
    24192422}
    24202423
    24212424/*
     
    27042707        if (eap->cmdidx == CMD_saveas)
    27052708        {
    27062709            if (retval == OK)
     2710            {
    27072711                curbuf->b_p_ro = FALSE;
     2712#ifdef FEAT_WINDOWS
     2713                redraw_tabline = TRUE;
     2714#endif
     2715            }
    27082716            /* Change directories when the 'acd' option is set. */
    27092717            DO_AUTOCHDIR
    27102718        }
     
    50595067
    50605068            if (did_sub)
    50615069                ++sub_nlines;
     5070            vim_free(new_start);        /* for when substitute was cancelled */
    50625071            vim_free(sub_firstline);    /* free the copy of the original line */
    50635072            sub_firstline = NULL;
    50645073        }
     
    65206529static int      last_sign_typenr = MAX_TYPENR;  /* is decremented */
    65216530
    65226531static void sign_list_defined __ARGS((sign_T *sp));
     6532static void sign_undefine __ARGS((sign_T *sp, sign_T *sp_prev));
    65236533
    65246534/*
    65256535 * ":sign" command
     
    67286738                /* ":sign list {name}" */
    67296739                sign_list_defined(sp);
    67306740            else
    6731             {
    67326741                /* ":sign undefine {name}" */
    6733                 vim_free(sp->sn_name);
    6734                 vim_free(sp->sn_icon);
    6735 #ifdef FEAT_SIGN_ICONS
    6736                 if (sp->sn_image != NULL)
    6737                 {
    6738                     out_flush();
    6739                     gui_mch_destroy_sign(sp->sn_image);
    6740                 }
    6741 #endif
    6742                 vim_free(sp->sn_text);
    6743                 if (sp_prev == NULL)
    6744                     first_sign = sp->sn_next;
    6745                 else
    6746                     sp_prev->sn_next = sp->sn_next;
    6747                 vim_free(sp);
    6748             }
     6742                sign_undefine(sp, sp_prev);
    67496743        }
    67506744    }
    67516745    else
     
    69946988}
    69956989
    69966990/*
     6991 * Undefine a sign and free its memory.
     6992 */
     6993    static void
     6994sign_undefine(sp, sp_prev)
     6995    sign_T      *sp;
     6996    sign_T      *sp_prev;
     6997{
     6998    vim_free(sp->sn_name);
     6999    vim_free(sp->sn_icon);
     7000#ifdef FEAT_SIGN_ICONS
     7001    if (sp->sn_image != NULL)
     7002    {
     7003        out_flush();
     7004        gui_mch_destroy_sign(sp->sn_image);
     7005    }
     7006#endif
     7007    vim_free(sp->sn_text);
     7008    if (sp_prev == NULL)
     7009        first_sign = sp->sn_next;
     7010    else
     7011        sp_prev->sn_next = sp->sn_next;
     7012    vim_free(sp);
     7013}
     7014
     7015/*
    69977016 * Get highlighting attribute for sign "typenr".
    69987017 * If "line" is TRUE: line highl, if FALSE: text highl.
    69997018 */
     
    70677086    return (char_u *)_("[Deleted]");
    70687087}
    70697088
     7089#if defined(EXITFREE) || defined(PROTO)
     7090/*
     7091 * Undefine/free all signs.
     7092 */
     7093    void
     7094free_signs()
     7095{
     7096    while (first_sign != NULL)
     7097        sign_undefine(first_sign, NULL);
     7098}
     7099#endif
     7100
    70707101#endif
    70717102
    70727103#if defined(FEAT_GUI) || defined(FEAT_CLIENTSERVER) || defined(PROTO)
  • src/ex_cmds.h

    diff -Naur vim72.orig/src/ex_cmds.h vim72/src/ex_cmds.h
    old new  
    278278EX(CMD_crewind,         "crewind",      ex_cc,
    279279                        RANGE|NOTADR|COUNT|TRLBAR|BANG),
    280280EX(CMD_cscope,          "cscope",       do_cscope,
    281                         EXTRA|NOTRLCOM|SBOXOK|XFILE),
     281                        EXTRA|NOTRLCOM|XFILE),
    282282EX(CMD_cstag,           "cstag",        do_cstag,
    283283                        BANG|TRLBAR|WORD1),
    284284EX(CMD_cunmap,          "cunmap",       ex_unmap,
     
    506506EX(CMD_lclose,          "lclose",       ex_cclose,
    507507                        RANGE|NOTADR|COUNT|TRLBAR),
    508508EX(CMD_lcscope,         "lcscope",      do_cscope,
    509                         EXTRA|NOTRLCOM|SBOXOK|XFILE),
     509                        EXTRA|NOTRLCOM|XFILE),
    510510EX(CMD_left,            "left",         ex_align,
    511511                        TRLBAR|RANGE|WHOLEFOLD|EXTRA|CMDWIN|MODIFY),
    512512EX(CMD_leftabove,       "leftabove",    ex_wrongmodifier,
     
    635635                        RANGE|NOTADR|ZEROR|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
    636636EX(CMD_noremap,         "noremap",      ex_map,
    637637                        BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
     638EX(CMD_noautocmd,       "noautocmd",    ex_wrongmodifier,
     639                        NEEDARG|EXTRA|NOTRLCOM),
    638640EX(CMD_nohlsearch,      "nohlsearch",   ex_nohlsearch,
    639641                        TRLBAR|SBOXOK|CMDWIN),
    640642EX(CMD_noreabbrev,      "noreabbrev",   ex_abbreviate,
     
    651653                        EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
    652654EX(CMD_open,            "open",         ex_open,
    653655                        RANGE|EXTRA),
     656EX(CMD_oldfiles,        "oldfiles",     ex_oldfiles,
     657                        BANG|TRLBAR|SBOXOK|CMDWIN),
    654658EX(CMD_omap,            "omap",         ex_map,
    655659                        EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
    656660EX(CMD_omapclear,       "omapclear",    ex_mapclear,
     
    802806EX(CMD_scriptencoding,  "scriptencoding", ex_scriptencoding,
    803807                        WORD1|TRLBAR|CMDWIN),
    804808EX(CMD_scscope,         "scscope",      do_scscope,
    805                         EXTRA|NOTRLCOM|SBOXOK),
     809                        EXTRA|NOTRLCOM),
    806810EX(CMD_set,             "set",          ex_set,
    807811                        TRLBAR|EXTRA|CMDWIN|SBOXOK),
    808812EX(CMD_setfiletype,     "setfiletype",  ex_setfiletype,
  • src/ex_docmd.c

    diff -Naur vim72.orig/src/ex_docmd.c vim72/src/ex_docmd.c
    old new  
    364364# define ex_function            ex_ni
    365365# define ex_delfunction         ex_ni
    366366# define ex_return              ex_ni
     367# define ex_oldfiles            ex_ni
    367368#endif
    368369static char_u   *arg_all __ARGS((void));
    369370#ifdef FEAT_SESSION
     
    17701771                        }
    17711772                        if (checkforcmd(&ea.cmd, "browse", 3))
    17721773                        {
    1773 #ifdef FEAT_BROWSE
     1774#ifdef FEAT_BROWSE_CMD
    17741775                            cmdmod.browse = TRUE;
    17751776#endif
    17761777                            continue;
     
    29782979    {"keepmarks", 3, FALSE},
    29792980    {"leftabove", 5, FALSE},
    29802981    {"lockmarks", 3, FALSE},
     2982    {"noautocmd", 3, FALSE},
    29812983    {"rightbelow", 6, FALSE},
    29822984    {"sandbox", 3, FALSE},
    29832985    {"silent", 3, FALSE},
     
    36083610            return set_context_in_autocmd(xp, arg, FALSE);
    36093611
    36103612        case CMD_doautocmd:
     3613        case CMD_doautoall:
    36113614            return set_context_in_autocmd(xp, arg, TRUE);
    36123615#endif
    36133616        case CMD_set:
     
    51215124            }
    51225125
    51235126            vim_free(cmd->uc_rep);
    5124             cmd->uc_rep = 0;
     5127            cmd->uc_rep = NULL;
     5128#if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL)
     5129            vim_free(cmd->uc_compl_arg);
     5130            cmd->uc_compl_arg = NULL;
     5131#endif
    51255132            break;
    51265133        }
    51275134
     
    54795486    return OK;
    54805487}
    54815488
     5489/*
     5490 * ":command ..."
     5491 */
    54825492    static void
    54835493ex_command(eap)
    54845494    exarg_T   *eap;
     
    59105920    char_u      *q;
    59115921
    59125922    char_u      *start;
    5913     char_u      *end;
     5923    char_u      *end = NULL;
     5924    char_u      *ksp;
    59145925    size_t      len, totlen;
    59155926
    59165927    size_t      split_len = 0;
     
    59275938
    59285939    /*
    59295940     * Replace <> in the command by the arguments.
     5941     * First round: "buf" is NULL, compute length, allocate "buf".
     5942     * Second round: copy result into "buf".
    59305943     */
    59315944    buf = NULL;
    59325945    for (;;)
    59335946    {
    5934         p = cmd->uc_rep;
    5935         q = buf;
     5947        p = cmd->uc_rep;    /* source */
     5948        q = buf;            /* destination */
    59365949        totlen = 0;
    5937         while ((start = vim_strchr(p, '<')) != NULL
    5938                && (end = vim_strchr(start + 1, '>')) != NULL)
     5950
     5951        for (;;)
    59395952        {
     5953            start = vim_strchr(p, '<');
     5954            if (start != NULL)
     5955                end = vim_strchr(start + 1, '>');
     5956            if (buf != NULL)
     5957            {
     5958                ksp = vim_strchr(p, K_SPECIAL);
     5959                if (ksp != NULL && (start == NULL || ksp < start || end == NULL)
     5960                        && ((ksp[1] == KS_SPECIAL && ksp[2] == KE_FILLER)
     5961# ifdef FEAT_GUI
     5962                            || (ksp[1] == KS_EXTRA && ksp[2] == (int)KE_CSI)
     5963# endif
     5964                            ))
     5965                {
     5966                    /* K_SPECIAL han been put in the buffer as K_SPECIAL
     5967                     * KS_SPECIAL KE_FILLER, like for mappings, but
     5968                     * do_cmdline() doesn't handle that, so convert it back.
     5969                     * Also change K_SPECIAL KS_EXTRA KE_CSI into CSI. */
     5970                    len = ksp - p;
     5971                    if (len > 0)
     5972                    {
     5973                        mch_memmove(q, p, len);
     5974                        q += len;
     5975                    }
     5976                    *q++ = ksp[1] == KS_SPECIAL ? K_SPECIAL : CSI;
     5977                    p = ksp + 3;
     5978                    continue;
     5979                }
     5980            }
     5981
     5982            /* break if there no <item> is found */
     5983            if (start == NULL || end == NULL)
     5984                break;
     5985
    59405986            /* Include the '>' */
    59415987            ++end;
    59425988
     
    78037849{
    78047850    vim_free(prev_dir);
    78057851    prev_dir = NULL;
     7852
     7853    vim_free(globaldir);
     7854    globaldir = NULL;
    78067855}
    78077856#endif
    78087857
     
    78257874    else
    78267875#endif
    78277876    {
     7877#ifdef FEAT_AUTOCMD
     7878        if (allbuf_locked())
     7879            return;
     7880#endif
    78287881        if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged()
    78297882                                                             && !eap->forceit)
    78307883        {
     
    87498802                else if (*dirnow != NUL
    87508803                        && (ssop_flags & SSOP_CURDIR) && globaldir != NULL)
    87518804                {
    8752                     (void)mch_chdir((char *)globaldir);
    8753                     shorten_fnames(TRUE);
     8805                    if (mch_chdir((char *)globaldir) == 0)
     8806                        shorten_fnames(TRUE);
    87548807                }
    87558808
    87568809                failed |= (makeopens(fd, dirnow) == FAIL);
     
    95069559                    break;
    95079560                }
    95089561                s = src + 1;
     9562                if (*s == '<')          /* "#<99" uses v:oldfiles */
     9563                    ++s;
    95099564                i = (int)getdigits(&s);
    95109565                *usedlen = (int)(s - src); /* length of what we expand */
    95119566
    9512                 buf = buflist_findnr(i);
    9513                 if (buf == NULL)
     9567                if (src[1] == '<')
    95149568                {
    9515                     *errormsg = (char_u *)_("E194: No alternate file name to substitute for '#'");
     9569                    if (*usedlen < 2)
     9570                    {
     9571                        /* Should we give an error message for #<text? */
     9572                        *usedlen = 1;
     9573                        return NULL;
     9574                    }
     9575#ifdef FEAT_EVAL
     9576                    result = list_find_str(get_vim_var_list(VV_OLDFILES),
     9577                                                                     (long)i);
     9578                    if (result == NULL)
     9579                    {
     9580                        *errormsg = (char_u *)"";
     9581                        return NULL;
     9582                    }
     9583#else
     9584                    *errormsg = (char_u *)_("E809: #< is not available without the +eval feature");
    95169585                    return NULL;
     9586#endif
    95179587                }
    9518                 if (lnump != NULL)
    9519                     *lnump = ECMD_LAST;
    9520                 if (buf->b_fname == NULL)
     9588                else
    95219589                {
    9522                     result = (char_u *)"";
    9523                     valid = 0;      /* Must have ":p:h" to be valid */
     9590                    buf = buflist_findnr(i);
     9591                    if (buf == NULL)
     9592                    {
     9593                        *errormsg = (char_u *)_("E194: No alternate file name to substitute for '#'");
     9594                        return NULL;
     9595                    }
     9596                    if (lnump != NULL)
     9597                        *lnump = ECMD_LAST;
     9598                    if (buf->b_fname == NULL)
     9599                    {
     9600                        result = (char_u *)"";
     9601                        valid = 0;          /* Must have ":p:h" to be valid */
     9602                    }
     9603                    else
     9604                        result = buf->b_fname;
    95249605                }
    9525                 else
    9526                     result = buf->b_fname;
    95279606                break;
    95289607
    95299608#ifdef FEAT_SEARCHPATH
     
    95419620#ifdef FEAT_AUTOCMD
    95429621        case SPEC_AFILE:        /* file name for autocommand */
    95439622                result = autocmd_fname;
     9623                if (result != NULL && !autocmd_fname_full)
     9624                {
     9625                    /* Still need to turn the fname into a full path.  It is
     9626                     * postponed to avoid a delay when <afile> is not used. */
     9627                    autocmd_fname_full = TRUE;
     9628                    result = FullName_save(autocmd_fname, FALSE);
     9629                    vim_free(autocmd_fname);
     9630                    autocmd_fname = result;
     9631                }
    95449632                if (result == NULL)
    95459633                {
    95469634                    *errormsg = (char_u *)_("E495: no autocommand file name to substitute for \"<afile>\"");
     
    1006710155     */
    1006810156    if (put_line(fd, "let s:sx = expand(\"<sfile>:p:r\").\"x.vim\"") == FAIL
    1006910157            || put_line(fd, "if file_readable(s:sx)") == FAIL
    10070             || put_line(fd, "  exe \"source \" . s:sx") == FAIL
     10158            || put_line(fd, "  exe \"source \" . fnameescape(s:sx)") == FAIL
    1007110159            || put_line(fd, "endif") == FAIL)
    1007210160        return FAIL;
    1007310161
     
    1068910777        p_viminfo = (char_u *)"'100";
    1069010778    if (eap->cmdidx == CMD_rviminfo)
    1069110779    {
    10692         if (read_viminfo(eap->arg, TRUE, TRUE, eap->forceit) == FAIL)
     10780        if (read_viminfo(eap->arg, VIF_WANT_INFO | VIF_WANT_MARKS
     10781                                  | (eap->forceit ? VIF_FORCEIT : 0)) == FAIL)
    1069310782            EMSG(_("E195: Cannot open viminfo file for reading"));
    1069410783    }
    1069510784    else
  • src/ex_getln.c

    diff -Naur vim72.orig/src/ex_getln.c vim72/src/ex_getln.c
    old new  
    3131    int         cmdattr;        /* attributes for prompt */
    3232    int         overstrike;     /* Typing mode on the command line.  Shared by
    3333                                   getcmdline() and put_on_cmdline(). */
     34    expand_T    *xpc;           /* struct being used for expansion, xp_pattern
     35                                   may point into cmdbuff */
    3436    int         xp_context;     /* type of expansion */
    3537# ifdef FEAT_EVAL
    3638    char_u      *xp_arg;        /* user-defined expansion arg */
     
    3840# endif
    3941};
    4042
    41 static struct cmdline_info ccline;      /* current cmdline_info */
     43/* The current cmdline_info.  It is initialized in getcmdline() and after that
     44 * used by other functions.  When invoking getcmdline() recursively it needs
     45 * to be saved with save_cmdline() and restored with restore_cmdline().
     46 * TODO: make it local to getcmdline() and pass it around. */
     47static struct cmdline_info ccline;
    4248
    4349static int      cmd_showtail;           /* Only show path tail in lists ? */
    4450
     
    238244    }
    239245
    240246    ExpandInit(&xpc);
     247    ccline.xpc = &xpc;
    241248
    242249#ifdef FEAT_RIGHTLEFT
    243250    if (curwin->w_p_rl && *curwin->w_p_rlc == 's'
     
    408415#endif
    409416
    410417        /*
    411          * <S-Tab> works like CTRL-P (unless 'wc' is <S-Tab>).
     418         * When there are matching completions to select <S-Tab> works like
     419         * CTRL-P (unless 'wc' is <S-Tab>).
    412420         */
    413         if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles != -1)
     421        if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles > 0)
    414422            c = Ctrl_P;
    415423
    416424#ifdef FEAT_WILDMENU
     
    15131521                    int         old_firstc;
    15141522
    15151523                    vim_free(ccline.cmdbuff);
     1524                    xpc.xp_context = EXPAND_NOTHING;
    15161525                    if (hiscnt == hislen)
    15171526                        p = lookfor;    /* back to the old one */
    15181527                    else
     
    18391848#endif
    18401849
    18411850    ExpandCleanup(&xpc);
     1851    ccline.xpc = NULL;
    18421852
    18431853#ifdef FEAT_SEARCH_EXTRA
    18441854    if (did_incsearch)
     
    19902000
    19912001#if defined(FEAT_AUTOCMD) || defined(PROTO)
    19922002/*
    1993  * Check if "curbuf_lock" is set and return TRUE when it is and give an error
    1994  * message.
     2003 * Check if "curbuf_lock" or "allbuf_lock" is set and return TRUE when it is
     2004 * and give an error message.
    19952005 */
    19962006    int
    19972007curbuf_locked()
     
    20012011        EMSG(_("E788: Not allowed to edit another buffer now"));
    20022012        return TRUE;
    20032013    }
     2014    return allbuf_locked();
     2015}
     2016
     2017/*
     2018 * Check if "allbuf_lock" is set and return TRUE when it is and give an error
     2019 * message.
     2020 */
     2021    int
     2022allbuf_locked()
     2023{
     2024    if (allbuf_lock > 0)
     2025    {
     2026        EMSG(_("E811: Not allowed to change buffer information now"));
     2027        return TRUE;
     2028    }
    20042029    return FALSE;
    20052030}
    20062031#endif
     
    25082533    }
    25092534    mch_memmove(ccline.cmdbuff, p, (size_t)ccline.cmdlen + 1);
    25102535    vim_free(p);
     2536
     2537    if (ccline.xpc != NULL
     2538            && ccline.xpc->xp_pattern != NULL
     2539            && ccline.xpc->xp_context != EXPAND_NOTHING
     2540            && ccline.xpc->xp_context != EXPAND_UNSUCCESSFUL)
     2541    {
     2542        int i = (int)(ccline.xpc->xp_pattern - p);
     2543
     2544        /* If xp_pattern points inside the old cmdbuff it needs to be adjusted
     2545         * to point into the newly allocated memory. */
     2546        if (i >= 0 && i <= ccline.cmdlen)
     2547            ccline.xpc->xp_pattern = ccline.cmdbuff + i;
     2548    }
     2549
    25112550    return OK;
    25122551}
    25132552
     
    28752914    prev_ccline = ccline;
    28762915    ccline.cmdbuff = NULL;
    28772916    ccline.cmdprompt = NULL;
     2917    ccline.xpc = NULL;
    28782918}
    28792919
    28802920/*
     
    35823622ExpandInit(xp)
    35833623    expand_T    *xp;
    35843624{
     3625    xp->xp_pattern = NULL;
    35853626    xp->xp_backslash = XP_BS_NONE;
    35863627#ifndef BACKSLASH_IN_FILENAME
    35873628    xp->xp_shell = FALSE;
     
    48714912    if (s == NULL)
    48724913        return FAIL;
    48734914    sprintf((char *)s, "%s/%s*.vim", dirname, pat);
    4874     all = globpath(p_rtp, s);
     4915    all = globpath(p_rtp, s, 0);
    48754916    vim_free(s);
    48764917    if (all == NULL)
    48774918        return FAIL;
     
    49124953 * newlines.  Returns NULL for an error or no matches.
    49134954 */
    49144955    char_u *
    4915 globpath(path, file)
     4956globpath(path, file, expand_options)
    49164957    char_u      *path;
    49174958    char_u      *file;
     4959    int         expand_options;
    49184960{
    49194961    expand_T    xpc;
    49204962    char_u      *buf;
     
    49434985        {
    49444986            add_pathsep(buf);
    49454987            STRCAT(buf, file);
    4946             if (ExpandFromContext(&xpc, buf, &num_p, &p, WILD_SILENT) != FAIL
    4947                                                                 && num_p > 0)
     4988            if (ExpandFromContext(&xpc, buf, &num_p, &p,
     4989                             WILD_SILENT|expand_options) != FAIL && num_p > 0)
    49484990            {
    4949                 ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT);
     4991                ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT|expand_options);
    49504992                for (len = 0, i = 0; i < num_p; ++i)
    49514993                    len += (int)STRLEN(p[i]) + 1;
    49524994
     
    60206062# endif
    60216063        return K_IGNORE;
    60226064    }
    6023     cmdwin_type = ccline.cmdfirstc;
    6024     if (cmdwin_type == NUL)
    6025         cmdwin_type = '-';
     6065    cmdwin_type = get_cmdline_type();
    60266066
    60276067    /* Create the command-line buffer empty. */
    60286068    (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE);
     
    60466086    /* Showing the prompt may have set need_wait_return, reset it. */
    60476087    need_wait_return = FALSE;
    60486088
    6049     histtype = hist_char2type(ccline.cmdfirstc);
     6089    histtype = hist_char2type(cmdwin_type);
    60506090    if (histtype == HIST_CMD || histtype == HIST_DEBUG)
    60516091    {
    60526092        if (p_wc == TAB)
  • src/feature.h

    diff -Naur vim72.orig/src/feature.h vim72/src/feature.h
    old new  
    767767
    768768/*
    769769 * +browse              ":browse" command.
     770 *                      or just the ":browse" command modifier
    770771 */
    771 #if defined(FEAT_NORMAL) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC))
    772 # define FEAT_BROWSE
     772#if defined(FEAT_NORMAL)
     773# define FEAT_BROWSE_CMD
     774# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)
     775#  define FEAT_BROWSE
     776# endif
    773777#endif
    774778
    775779/*
  • src/fileio.c

    diff -Naur vim72.orig/src/fileio.c vim72/src/fileio.c
    old new  
    6969static int au_find_group __ARGS((char_u *name));
    7070
    7171# define AUGROUP_DEFAULT    -1      /* default autocmd group */
    72 # define AUGROUP_ERROR      -2      /* errornouse autocmd group */
     72# define AUGROUP_ERROR      -2      /* erroneous autocmd group */
    7373# define AUGROUP_ALL        -3      /* all autocmd groups */
    7474#endif
    7575
     
    144144# endif
    145145#endif
    146146static int move_lines __ARGS((buf_T *frombuf, buf_T *tobuf));
    147 
     147#ifdef FEAT_AUTOCMD
     148static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name");
     149#endif
    148150
    149151    void
    150152filemess(buf, name, s, attr)
     
    295297    int         conv_restlen = 0;       /* nr of bytes in conv_rest[] */
    296298#endif
    297299
     300#ifdef FEAT_AUTOCMD
     301    /* Remember the initial values of curbuf, curbuf->b_ffname and
     302     * curbuf->b_fname to detect whether they are altered as a result of
     303     * executing nasty autocommands.  Also check if "fname" and "sfname"
     304     * point to one of these values. */
     305    buf_T   *old_curbuf = curbuf;
     306    char_u  *old_b_ffname = curbuf->b_ffname;
     307    char_u  *old_b_fname = curbuf->b_fname;
     308    int     using_b_ffname = (fname == curbuf->b_ffname)
     309                                              || (sfname == curbuf->b_ffname);
     310    int     using_b_fname = (fname == curbuf->b_fname)
     311                                               || (sfname == curbuf->b_fname);
     312#endif
    298313    write_no_eol_lnum = 0;      /* in case it was set by the previous read */
    299314
    300315    /*
     
    589604#ifdef FEAT_QUICKFIX
    590605                    if (!bt_dontwrite(curbuf))
    591606#endif
     607                    {
    592608                        check_need_swap(newfile);
     609#ifdef FEAT_AUTOCMD
     610                        /* SwapExists autocommand may mess things up */
     611                        if (curbuf != old_curbuf
     612                                || (using_b_ffname
     613                                        && (old_b_ffname != curbuf->b_ffname))
     614                                || (using_b_fname
     615                                         && (old_b_fname != curbuf->b_fname)))
     616                        {
     617                            EMSG(_(e_auchangedbuf));
     618                            return FAIL;
     619                        }
     620#endif
     621                    }
    593622                    if (dir_of_file_exists(fname))
    594623                        filemess(curbuf, sfname, (char_u *)_("[New File]"), 0);
    595624                    else
     
    668697#endif
    669698    {
    670699        check_need_swap(newfile);
     700#ifdef FEAT_AUTOCMD
     701        if (!read_stdin && (curbuf != old_curbuf
     702                || (using_b_ffname && (old_b_ffname != curbuf->b_ffname))
     703                || (using_b_fname && (old_b_fname != curbuf->b_fname))))
     704        {
     705            EMSG(_(e_auchangedbuf));
     706            if (!read_buffer)
     707                close(fd);
     708            return FAIL;
     709        }
     710#endif
    671711#ifdef UNIX
    672712        /* Set swap file protection bits after creating it. */
    673713        if (swap_mode > 0 && curbuf->b_ml.ml_mfp->mf_fname != NULL)
     
    698738    {
    699739        int     m = msg_scroll;
    700740        int     n = msg_scrolled;
    701         buf_T   *old_curbuf = curbuf;
    702741
    703742        /*
    704743         * The file must be closed again, the autocommands may want to change
     
    740779        /*
    741780         * Don't allow the autocommands to change the current buffer.
    742781         * Try to re-open the file.
     782         *
     783         * Don't allow the autocommands to change the buffer name either
     784         * (cd for example) if it invalidates fname or sfname.
    743785         */
    744786        if (!read_stdin && (curbuf != old_curbuf
     787                || (using_b_ffname && (old_b_ffname != curbuf->b_ffname))
     788                || (using_b_fname && (old_b_fname != curbuf->b_fname))
    745789                || (fd = mch_open((char *)fname, O_RDONLY | O_EXTRA, 0)) < 0))
    746790        {
    747791            --no_wait_return;
     
    932976    else
    933977    {
    934978        if (eap != NULL && eap->force_ff != 0)
     979        {
    935980            fileformat = get_fileformat_force(curbuf, eap);
     981            try_unix = try_dos = try_mac = FALSE;
     982        }
    936983        else if (curbuf->b_p_bin)
    937984            fileformat = EOL_UNIX;              /* binary: use Unix format */
    938985        else if (*p_ffs == NUL)
     
    22112258    {
    22122259        /* Use stderr for stdin, makes shell commands work. */
    22132260        close(0);
    2214         dup(2);
     2261        ignored = dup(2);
    22152262    }
    22162263#endif
    22172264
     
    23412388                STRCAT(IObuff, _("[CR missing]"));
    23422389                c = TRUE;
    23432390            }
    2344             if (ff_error == EOL_MAC)
    2345             {
    2346                 STRCAT(IObuff, _("[NL found]"));
    2347                 c = TRUE;
    2348             }
    23492391            if (split)
    23502392            {
    23512393                STRCAT(IObuff, _("[long lines split]"));
     
    27112753{
    27122754    if (!curbuf->b_marks_read && get_viminfo_parameter('\'') > 0
    27132755                                                  && curbuf->b_ffname != NULL)
    2714         read_viminfo(NULL, FALSE, TRUE, FALSE);
     2756        read_viminfo(NULL, VIF_WANT_MARKS);
    27152757
    27162758    /* Always set b_marks_read; needed when 'viminfo' is changed to include
    27172759     * the ' parameter after opening a buffer. */
     
    34513493                {
    34523494# ifdef UNIX
    34533495#  ifdef HAVE_FCHOWN
    3454                     fchown(fd, st_old.st_uid, st_old.st_gid);
     3496                    ignored = fchown(fd, st_old.st_uid, st_old.st_gid);
    34553497#  endif
    34563498                    if (mch_stat((char *)IObuff, &st) < 0
    34573499                            || st.st_uid != st_old.st_uid
     
    43674409                || st.st_uid != st_old.st_uid
    43684410                || st.st_gid != st_old.st_gid)
    43694411        {
    4370             fchown(fd, st_old.st_uid, st_old.st_gid);
     4412            ignored = fchown(fd, st_old.st_uid, st_old.st_gid);
    43714413            if (perm >= 0)      /* set permission again, may have changed */
    43724414                (void)mch_setperm(wfname, perm);
    43734415        }
     
    52465288            /* Convert with iconv(). */
    52475289            if (ip->bw_restlen > 0)
    52485290            {
     5291                char *fp;
     5292
    52495293                /* Need to concatenate the remainder of the previous call and
    52505294                 * the bytes of the current call.  Use the end of the
    52515295                 * conversion buffer for this. */
    52525296                fromlen = len + ip->bw_restlen;
    5253                 from = (char *)ip->bw_conv_buf + ip->bw_conv_buflen - fromlen;
    5254                 mch_memmove((void *)from, ip->bw_rest, (size_t)ip->bw_restlen);
    5255                 mch_memmove((void *)(from + ip->bw_restlen), buf, (size_t)len);
     5297                fp = (char *)ip->bw_conv_buf + ip->bw_conv_buflen - fromlen;
     5298                mch_memmove(fp, ip->bw_rest, (size_t)ip->bw_restlen);
     5299                mch_memmove(fp + ip->bw_restlen, buf, (size_t)len);
     5300                from = fp;
    52565301                tolen = ip->bw_conv_buflen - fromlen;
    52575302            }
    52585303            else
     
    55505595            name = "ucs-4le";   /* FF FE 00 00 */
    55515596            len = 4;
    55525597        }
    5553         else if (flags == FIO_ALL || flags == (FIO_UCS2 | FIO_ENDIAN_L))
     5598        else if (flags == (FIO_UCS2 | FIO_ENDIAN_L))
    55545599            name = "ucs-2le";   /* FF FE */
    5555         else if (flags == (FIO_UTF16 | FIO_ENDIAN_L))
     5600        else if (flags == FIO_ALL || flags == (FIO_UTF16 | FIO_ENDIAN_L))
     5601            /* utf-16le is preferred, it also works for ucs-2le text */
    55565602            name = "utf-16le";  /* FF FE */
    55575603    }
    55585604    else if (p[0] == 0xfe && p[1] == 0xff
     
    60316077        {
    60326078            tbuf[FGETS_SIZE - 2] = NUL;
    60336079#ifdef USE_CR
    6034             fgets_cr((char *)tbuf, FGETS_SIZE, fp);
     6080            ignoredp = fgets_cr((char *)tbuf, FGETS_SIZE, fp);
    60356081#else
    6036             fgets((char *)tbuf, FGETS_SIZE, fp);
     6082            ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp);
    60376083#endif
    60386084        } while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n');
    60396085    }
     
    61076153#ifdef HAVE_ACL
    61086154    vim_acl_T   acl;            /* ACL from original file */
    61096155#endif
     6156#if defined(UNIX) || defined(CASE_INSENSITIVE_FILENAME)
     6157    int         use_tmp_file = FALSE;
     6158#endif
    61106159
    61116160    /*
    6112      * When the names are identical, there is nothing to do.
     6161     * When the names are identical, there is nothing to do.  When they refer
     6162     * to the same file (ignoring case and slash/backslash differences) but
     6163     * the file name differs we need to go through a temp file.
    61136164     */
    61146165    if (fnamecmp(from, to) == 0)
    6115         return 0;
     6166    {
     6167#ifdef CASE_INSENSITIVE_FILENAME
     6168        if (STRCMP(gettail(from), gettail(to)) != 0)
     6169            use_tmp_file = TRUE;
     6170        else
     6171#endif
     6172            return 0;
     6173    }
    61166174
    61176175    /*
    61186176     * Fail if the "from" file doesn't exist.  Avoids that "to" is deleted.
     
    61206178    if (mch_stat((char *)from, &st) < 0)
    61216179        return -1;
    61226180
     6181#ifdef UNIX
     6182    {
     6183        struct stat     st_to;
     6184
     6185        /* It's possible for the source and destination to be the same file.
     6186         * This happens when "from" and "to" differ in case and are on a FAT32
     6187         * filesystem.  In that case go through a temp file name. */
     6188        if (mch_stat((char *)to, &st_to) >= 0
     6189                && st.st_dev == st_to.st_dev
     6190                && st.st_ino == st_to.st_ino)
     6191            use_tmp_file = TRUE;
     6192    }
     6193#endif
     6194
     6195#if defined(UNIX) || defined(CASE_INSENSITIVE_FILENAME)
     6196    if (use_tmp_file)
     6197    {
     6198        char    tempname[MAXPATHL + 1];
     6199
     6200        /*
     6201         * Find a name that doesn't exist and is in the same directory.
     6202         * Rename "from" to "tempname" and then rename "tempname" to "to".
     6203         */
     6204        if (STRLEN(from) >= MAXPATHL - 5)
     6205            return -1;
     6206        STRCPY(tempname, from);
     6207        for (n = 123; n < 99999; ++n)
     6208        {
     6209            sprintf((char *)gettail((char_u *)tempname), "%d", n);
     6210            if (mch_stat(tempname, &st) < 0)
     6211            {
     6212                if (mch_rename((char *)from, tempname) == 0)
     6213                {
     6214                    if (mch_rename(tempname, (char *)to) == 0)
     6215                        return 0;
     6216                    /* Strange, the second step failed.  Try moving the
     6217                     * file back and return failure. */
     6218                    mch_rename(tempname, (char *)from);
     6219                    return -1;
     6220                }
     6221                /* If it fails for one temp name it will most likely fail
     6222                 * for any temp name, give up. */
     6223                return -1;
     6224            }
     6225        }
     6226        return -1;
     6227    }
     6228#endif
     6229
    61236230    /*
    61246231     * Delete the "to" file, this is required on some systems to make the
    61256232     * mch_rename() work, on other systems it makes sure that we don't have
     
    62606367
    62616368    if (!stuff_empty() || global_busy || !typebuf_typed()
    62626369#ifdef FEAT_AUTOCMD
    6263                         || autocmd_busy || curbuf_lock > 0
     6370                        || autocmd_busy || curbuf_lock > 0 || allbuf_lock > 0
    62646371#endif
    62656372                                        )
    62666373        need_check_timestamps = TRUE;           /* check later */
     
    64626569            set_vim_var_string(VV_FCS_REASON, (char_u *)reason, -1);
    64636570            set_vim_var_string(VV_FCS_CHOICE, (char_u *)"", -1);
    64646571# endif
     6572            ++allbuf_lock;
    64656573            n = apply_autocmds(EVENT_FILECHANGEDSHELL,
    64666574                                      buf->b_fname, buf->b_fname, FALSE, buf);
     6575            --allbuf_lock;
    64676576            busy = FALSE;
    64686577            if (n)
    64696578            {
     
    85238632    char_u      *save_sourcing_name;
    85248633    linenr_T    save_sourcing_lnum;
    85258634    char_u      *save_autocmd_fname;
     8635    int         save_autocmd_fname_full;
    85268636    int         save_autocmd_bufnr;
    85278637    char_u      *save_autocmd_match;
    85288638    int         save_autocmd_busy;
     
    86018711     * Save the autocmd_* variables and info about the current buffer.
    86028712     */
    86038713    save_autocmd_fname = autocmd_fname;
     8714    save_autocmd_fname_full = autocmd_fname_full;
    86048715    save_autocmd_bufnr = autocmd_bufnr;
    86058716    save_autocmd_match = autocmd_match;
    86068717    save_autocmd_busy = autocmd_busy;
     
    86188729        if (fname != NULL && *fname != NUL)
    86198730            autocmd_fname = fname;
    86208731        else if (buf != NULL)
    8621             autocmd_fname = buf->b_fname;
     8732            autocmd_fname = buf->b_ffname;
    86228733        else
    86238734            autocmd_fname = NULL;
    86248735    }
    86258736    else
    86268737        autocmd_fname = fname_io;
    86278738    if (autocmd_fname != NULL)
    8628         autocmd_fname = FullName_save(autocmd_fname, FALSE);
     8739        autocmd_fname = vim_strsave(autocmd_fname);
     8740    autocmd_fname_full = FALSE; /* call FullName_save() later */
    86298741
    86308742    /*
    86318743     * Set the buffer number to be used for <abuf>.
     
    88108922    sourcing_lnum = save_sourcing_lnum;
    88118923    vim_free(autocmd_fname);
    88128924    autocmd_fname = save_autocmd_fname;
     8925    autocmd_fname_full = save_autocmd_fname_full;
    88138926    autocmd_bufnr = save_autocmd_bufnr;
    88148927    autocmd_match = save_autocmd_match;
    88158928#ifdef FEAT_EVAL
     
    89189031    {
    89199032        apc->curpat = NULL;
    89209033
    8921         /* only use a pattern when it has not been removed, has commands and
     9034        /* Only use a pattern when it has not been removed, has commands and
    89229035         * the group matches. For buffer-local autocommands only check the
    89239036         * buffer number. */
    89249037        if (ap->pat != NULL && ap->cmds != NULL
     
    91049217set_context_in_autocmd(xp, arg, doautocmd)
    91059218    expand_T    *xp;
    91069219    char_u      *arg;
    9107     int         doautocmd;      /* TRUE for :doautocmd, FALSE for :autocmd */
     9220    int         doautocmd;      /* TRUE for :doauto*, FALSE for :autocmd */
    91089221{
    91099222    char_u      *p;
    91109223    int         group;
  • src/fold.c

    diff -Naur vim72.orig/src/fold.c vim72/src/fold.c
    old new  
    4848static int foldFind __ARGS((garray_T *gap, linenr_T lnum, fold_T **fpp));
    4949static int foldLevelWin __ARGS((win_T *wp, linenr_T lnum));
    5050static void checkupdate __ARGS((win_T *wp));
    51 static void setFoldRepeat __ARGS((linenr_T lnum, long count, int open));
     51static void setFoldRepeat __ARGS((linenr_T lnum, long count, int do_open));
    5252static linenr_T setManualFold __ARGS((linenr_T lnum, int opening, int recurse, int *donep));
    5353static linenr_T setManualFoldWin __ARGS((win_T *wp, linenr_T lnum, int opening, int recurse, int *donep));
    5454static void foldOpenNested __ARGS((fold_T *fpr));
     
    740740    garray_T    *found_ga;
    741741    fold_T      *found_fp = NULL;
    742742    linenr_T    found_off = 0;
    743     int         use_level = FALSE;
     743    int         use_level;
    744744    int         maybe_small = FALSE;
    745745    int         level = 0;
    746746    linenr_T    lnum = start;
     
    757757        gap = &curwin->w_folds;
    758758        found_ga = NULL;
    759759        lnum_off = 0;
     760        use_level = FALSE;
    760761        for (;;)
    761762        {
    762763            if (!foldFind(gap, lnum - lnum_off, &fp))
     
    783784        else
    784785        {
    785786            lnum = found_fp->fd_top + found_fp->fd_len + found_off;
    786             did_one = TRUE;
    787787
    788788            if (foldmethodIsManual(curwin))
    789789                deleteFoldEntry(found_ga,
    790790                    (int)(found_fp - (fold_T *)found_ga->ga_data), recursive);
    791791            else
    792792            {
    793                 if (found_fp->fd_top + found_off < first_lnum)
    794                     first_lnum = found_fp->fd_top;
    795                 if (lnum > last_lnum)
     793                if (first_lnum > found_fp->fd_top + found_off)
     794                    first_lnum = found_fp->fd_top + found_off;
     795                if (last_lnum < lnum)
    796796                    last_lnum = lnum;
    797                 parseMarker(curwin);
     797                if (!did_one)
     798                    parseMarker(curwin);
    798799                deleteFoldMarkers(found_fp, recursive, found_off);
    799800            }
     801            did_one = TRUE;
    800802
    801803            /* redraw window */
    802804            changed_window_setting();
     
    811813            redraw_curbuf_later(INVERTED);
    812814#endif
    813815    }
     816    else
     817        /* Deleting markers may make cursor column invalid. */
     818        check_cursor_col();
     819
    814820    if (last_lnum > 0)
    815821        changed_lines(first_lnum, (colnr_T)0, last_lnum, 0L);
    816822}
     
    12411247 * Repeat "count" times.
    12421248 */
    12431249    static void
    1244 setFoldRepeat(lnum, count, open)
     1250setFoldRepeat(lnum, count, do_open)
    12451251    linenr_T    lnum;
    12461252    long        count;
    1247     int         open;
     1253    int         do_open;
    12481254{
    12491255    int         done;
    12501256    long        n;
     
    12521258    for (n = 0; n < count; ++n)
    12531259    {
    12541260        done = DONE_NOTHING;
    1255         (void)setManualFold(lnum, open, FALSE, &done);
     1261        (void)setManualFold(lnum, do_open, FALSE, &done);
    12561262        if (!(done & DONE_ACTION))
    12571263        {
    12581264            /* Only give an error message when no fold could be opened. */
  • src/getchar.c

    diff -Naur vim72.orig/src/getchar.c vim72/src/getchar.c
    old new  
    38163816    int len = 1;
    38173817
    38183818    if (msg_didout || msg_silent != 0)
     3819    {
    38193820        msg_putchar('\n');
     3821        if (got_int)        /* 'q' typed at MORE prompt */
     3822            return;
     3823    }
    38203824    if ((mp->m_mode & (INSERT + CMDLINE)) == INSERT + CMDLINE)
    38213825        msg_putchar('!');                       /* :map! */
    38223826    else if (mp->m_mode & INSERT)
     
    47024706                        return FAIL;
    47034707                    if (mp->m_noremap != REMAP_YES && fprintf(fd, "nore") < 0)
    47044708                        return FAIL;
    4705                     if (fprintf(fd, cmd) < 0)
     4709                    if (fputs(cmd, fd) < 0)
    47064710                        return FAIL;
    47074711                    if (buf != NULL && fputs(" <buffer>", fd) < 0)
    47084712                        return FAIL;
     
    48014805            }
    48024806            if (IS_SPECIAL(c) || modifiers)     /* special key */
    48034807            {
    4804                 if (fprintf(fd, (char *)get_special_key_name(c, modifiers)) < 0)
     4808                if (fputs((char *)get_special_key_name(c, modifiers), fd) < 0)
    48054809                    return FAIL;
    48064810                continue;
    48074811            }
  • src/globals.h

    diff -Naur vim72.orig/src/globals.h vim72/src/globals.h
    old new  
    482482/*
    483483 * While executing external commands or in Ex mode, should not insert GUI
    484484 * events in the input buffer: Set hold_gui_events to non-zero.
     485 *
     486 * volatile because it is used in signal handler sig_sysmouse().
    485487 */
    486 EXTERN int      hold_gui_events INIT(= 0);
     488EXTERN volatile int hold_gui_events INIT(= 0);
    487489
    488490/*
    489491 * When resizing the shell is postponed, remember the new size, and call
     
    597599EXTERN int      really_exiting INIT(= FALSE);
    598600                                /* TRUE when we are sure to exit, e.g., after
    599601                                 * a deadly signal */
    600 EXTERN int      full_screen INIT(= FALSE);
     602/* volatile because it is used in signal handler deathtrap(). */
     603EXTERN volatile int full_screen INIT(= FALSE);
    601604                                /* TRUE when doing full-screen output
    602605                                 * otherwise only writing some messages */
    603606
     
    616619EXTERN int      curbuf_lock INIT(= 0);
    617620                                /* non-zero when the current buffer can't be
    618621                                 * changed.  Used for FileChangedRO. */
     622EXTERN int      allbuf_lock INIT(= 0);
     623                                /* non-zero when no buffer name can be
     624                                 * changed, no buffer can be deleted and
     625                                 * current directory can't be changed.
     626                                 * Used for SwapExists et al. */
    619627#endif
    620628#ifdef FEAT_EVAL
    621629# define HAVE_SANDBOX
     
    739747 */
    740748EXTERN JMP_BUF lc_jump_env;     /* argument to SETJMP() */
    741749# ifdef SIGHASARG
    742 EXTERN int lc_signal;           /* catched signal number, 0 when no was signal
    743                                    catched; used for mch_libcall() */
     750/* volatile because it is used in signal handlers. */
     751EXTERN volatile int lc_signal;  /* caught signal number, 0 when no was signal
     752                                   caught; used for mch_libcall() */
    744753# endif
    745 EXTERN int lc_active INIT(= FALSE); /* TRUE when lc_jump_env is valid. */
     754/* volatile because it is used in signal handler deathtrap(). */
     755EXTERN volatile int lc_active INIT(= FALSE); /* TRUE when lc_jump_env is valid. */
    746756#endif
    747757
    748758#if defined(FEAT_MBYTE) || defined(FEAT_POSTSCRIPT)
     
    986996EXTERN FILE     *scriptout  INIT(= NULL);   /* stream to write script to */
    987997EXTERN int      read_cmd_fd INIT(= 0);      /* fd to read commands from */
    988998
    989 EXTERN int      got_int INIT(= FALSE);      /* set to TRUE when interrupt
     999/* volatile because it is used in signal handler catch_sigint(). */
     1000EXTERN volatile int got_int INIT(= FALSE);    /* set to TRUE when interrupt
    9901001                                                signal occurred */
    9911002#ifdef USE_TERM_CONSOLE
    9921003EXTERN int      term_console INIT(= FALSE); /* set to TRUE when console used */
     
    10221033#endif
    10231034#ifdef FEAT_AUTOCMD
    10241035EXTERN char_u   *autocmd_fname INIT(= NULL); /* fname for <afile> on cmdline */
     1036EXTERN int      autocmd_fname_full;          /* autocmd_fname is full path */
    10251037EXTERN int      autocmd_bufnr INIT(= 0);     /* fnum for <abuf> on cmdline */
    10261038EXTERN char_u   *autocmd_match INIT(= NULL); /* name for <amatch> on cmdline */
    10271039EXTERN int      did_cursorhold INIT(= FALSE); /* set when CursorHold t'gerd */
     
    13391351
    13401352#ifdef FEAT_NETBEANS_INTG
    13411353EXTERN char *netbeansArg INIT(= NULL);  /* the -nb[:host:port:passwd] arg */
    1342 EXTERN int netbeansCloseFile INIT(= 0); /* send killed if != 0 */
    13431354EXTERN int netbeansFireChanges INIT(= 1); /* send buffer changes if != 0 */
    13441355EXTERN int netbeansForcedQuit INIT(= 0);/* don't write modified files */
    13451356EXTERN int netbeansReadFile INIT(= 1);  /* OK to read from disk if != 0 */
     
    15481559EXTERN time_t starttime;
    15491560
    15501561/*
     1562 * Some compilers warn for not using a return value, but in some situations we
     1563 * can't do anything useful with the value.  Assign to this variable to avoid
     1564 * the warning.
     1565 */
     1566EXTERN int ignored;
     1567EXTERN char *ignoredp;
     1568
     1569/*
    15511570 * Optional Farsi support.  Include it here, so EXTERN and INIT are defined.
    15521571 */
    15531572#ifdef FEAT_FKMAP
  • src/gui_at_sb.c

    diff -Naur vim72.orig/src/gui_at_sb.c vim72/src/gui_at_sb.c
    old new  
    10781078    Cardinal    *num_params;    /* unused */
    10791079{
    10801080    ScrollbarWidget sbw = (ScrollbarWidget)w;
     1081    /* Use a union to avoid a warning for the weird conversion from float to
     1082     * XtPointer.  Comes from Xaw/Scrollbar.c. */
     1083    union {
     1084        XtPointer xtp;
     1085        float xtf;
     1086    } xtpf;
    10811087
    10821088    if (LookAhead(w, event))
    10831089        return;
     
    10851091    /* thumbProc is not pretty, but is necessary for backwards
    10861092       compatibility on those architectures for which it work{s,ed};
    10871093       the intent is to pass a (truncated) float by value. */
    1088     XtCallCallbacks(w, XtNthumbProc, *(XtPointer*)&sbw->scrollbar.top);
     1094    xtpf.xtf = sbw->scrollbar.top;
     1095    XtCallCallbacks(w, XtNthumbProc, xtpf.xtp);
    10891096    XtCallCallbacks(w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top);
    10901097}
    10911098
  • src/gui.c

    diff -Naur vim72.orig/src/gui.c vim72/src/gui.c
    old new  
    139139                /* The read returns when the child closes the pipe (or when
    140140                 * the child dies for some reason). */
    141141                close(pipefd[1]);
    142                 (void)read(pipefd[0], &dummy, (size_t)1);
     142                ignored = (int)read(pipefd[0], &dummy, (size_t)1);
    143143                close(pipefd[0]);
    144144            }
    145145
     
    32413241            i = Rows;
    32423242            gui_update_tabline();
    32433243            Rows = i;
    3244             need_set_size = RESIZE_VERT;
     3244            need_set_size |= RESIZE_VERT;
    32453245            if (using_tabline)
    32463246                fix_size = TRUE;
    32473247            if (!gui_use_tabline())
     
    32753275                if (gui.which_scrollbars[i] != prev_which_scrollbars[i])
    32763276                {
    32773277                    if (i == SBAR_BOTTOM)
    3278                         need_set_size = RESIZE_VERT;
     3278                        need_set_size |= RESIZE_VERT;
    32793279                    else
    3280                         need_set_size = RESIZE_HOR;
     3280                        need_set_size |= RESIZE_HOR;
    32813281                    if (gui.which_scrollbars[i])
    32823282                        fix_size = TRUE;
    32833283                }
     
    32973297            gui_mch_enable_menu(gui.menu_is_active);
    32983298            Rows = i;
    32993299            prev_menu_is_active = gui.menu_is_active;
    3300             need_set_size = RESIZE_VERT;
     3300            need_set_size |= RESIZE_VERT;
    33013301            if (gui.menu_is_active)
    33023302                fix_size = TRUE;
    33033303        }
     
    33083308        {
    33093309            gui_mch_show_toolbar(using_toolbar);
    33103310            prev_toolbar = using_toolbar;
    3311             need_set_size = RESIZE_VERT;
     3311            need_set_size |= RESIZE_VERT;
    33123312            if (using_toolbar)
    33133313                fix_size = TRUE;
    33143314        }
     
    33183318        {
    33193319            gui_mch_enable_footer(using_footer);
    33203320            prev_footer = using_footer;
    3321             need_set_size = RESIZE_VERT;
     3321            need_set_size |= RESIZE_VERT;
    33223322            if (using_footer)
    33233323                fix_size = TRUE;
    33243324        }
     
    33303330            prev_tearoff = using_tearoff;
    33313331        }
    33323332#endif
    3333         if (need_set_size)
     3333        if (need_set_size != 0)
    33343334        {
    33353335#ifdef FEAT_GUI_GTK
    3336             long    c = Columns;
     3336            long    prev_Columns = Columns;
     3337            long    prev_Rows = Rows;
    33373338#endif
    33383339            /* Adjust the size of the window to make the text area keep the
    33393340             * same size and to avoid that part of our window is off-screen
     
    33493350             * If you remove this, please test this command for resizing
    33503351             * effects (with optional left scrollbar): ":vsp|q|vsp|q|vsp|q".
    33513352             * Don't do this while starting up though.
    3352              * And don't change Rows, it may have be reduced intentionally
    3353              * when adding menu/toolbar/tabline. */
    3354             if (!gui.starting)
     3353             * Don't change Rows when adding menu/toolbar/tabline.
     3354             * Don't change Columns when adding vertical toolbar. */
     3355            if (!gui.starting && need_set_size != (RESIZE_VERT | RESIZE_HOR))
    33553356                (void)char_avail();
    3356             Columns = c;
     3357            if ((need_set_size & RESIZE_VERT) == 0)
     3358                Rows = prev_Rows;
     3359            if ((need_set_size & RESIZE_HOR) == 0)
     3360                Columns = prev_Columns;
    33573361#endif
    33583362        }
    33593363#ifdef FEAT_WINDOWS
  • src/gui_gtk_x11.c

    diff -Naur vim72.orig/src/gui_gtk_x11.c vim72/src/gui_gtk_x11.c
    old new  
    40704070
    40714071        if (mask & (XValue | YValue))
    40724072        {
    4073             int w, h;
    4074             gui_mch_get_screen_dimensions(&w, &h);
    4075             h += p_ghr + get_menu_tool_height();
    4076             w += get_menu_tool_width();
     4073            int ww, hh;
     4074            gui_mch_get_screen_dimensions(&ww, &hh);
     4075            hh += p_ghr + get_menu_tool_height();
     4076            ww += get_menu_tool_width();
    40774077            if (mask & XNegative)
    4078                 x += w - pixel_width;
     4078                x += ww - pixel_width;
    40794079            if (mask & YNegative)
    4080                 y += h - pixel_height;
     4080                y += hh - pixel_height;
    40814081#ifdef HAVE_GTK2
    40824082            gtk_window_move(GTK_WINDOW(gui.mainwin), x, y);
    40834083#else
  • src/gui_x11.c

    diff -Naur vim72.orig/src/gui_x11.c vim72/src/gui_x11.c
    old new  
    15871587    XtCloseDisplay(gui.dpy);
    15881588    gui.dpy = NULL;
    15891589    vimShell = (Widget)0;
     1590    vim_free(gui_argv);
     1591    gui_argv = NULL;
    15901592}
    15911593
    15921594/*
     
    17611763     * says that this isn't needed when exiting, so just skip it. */
    17621764    XtCloseDisplay(gui.dpy);
    17631765#endif
     1766    vim_free(gui_argv);
     1767    gui_argv = NULL;
    17641768}
    17651769
    17661770/*
     
    24502454        *colorPtr = colortable[closest];
    24512455    }
    24522456
    2453     free(colortable);
     2457    vim_free(colortable);
    24542458    return OK;
    24552459}
    24562460
     
    34393443    char_u          *signfile;
    34403444{
    34413445    XpmAttributes   attrs;
    3442     XImage          *sign;
     3446    XImage          *sign = NULL;
    34433447    int             status;
    34443448
    34453449    /*
    34463450     * Setup the color substitution table.
    34473451     */
    3448     sign = NULL;
    34493452    if (signfile[0] != NUL && signfile[0] != '-')
    34503453    {
    3451         sign = (XImage *)alloc(sizeof(XImage));
    3452         if (sign != NULL)
     3454        XpmColorSymbol color[5] =
    34533455        {
    3454             XpmColorSymbol color[5] =
    3455             {
    3456                 {"none", NULL, 0},
    3457                 {"iconColor1", NULL, 0},
    3458                 {"bottomShadowColor", NULL, 0},
    3459                 {"topShadowColor", NULL, 0},
    3460                 {"selectColor", NULL, 0}
    3461             };
    3462             attrs.valuemask = XpmColorSymbols;
    3463             attrs.numsymbols = 2;
    3464             attrs.colorsymbols = color;
    3465             attrs.colorsymbols[0].pixel = gui.back_pixel;
    3466             attrs.colorsymbols[1].pixel = gui.norm_pixel;
    3467             status = XpmReadFileToImage(gui.dpy, (char *)signfile,
     3456            {"none", NULL, 0},
     3457            {"iconColor1", NULL, 0},
     3458            {"bottomShadowColor", NULL, 0},
     3459            {"topShadowColor", NULL, 0},
     3460            {"selectColor", NULL, 0}
     3461        };
     3462        attrs.valuemask = XpmColorSymbols;
     3463        attrs.numsymbols = 2;
     3464        attrs.colorsymbols = color;
     3465        attrs.colorsymbols[0].pixel = gui.back_pixel;
     3466        attrs.colorsymbols[1].pixel = gui.norm_pixel;
     3467        status = XpmReadFileToImage(gui.dpy, (char *)signfile,
    34683468                                                         &sign, NULL, &attrs);
    3469 
    3470             if (status == 0)
    3471             {
    3472                 /* Sign width is fixed at two columns now.
    3473                 if (sign->width > gui.sign_width)
    3474                     gui.sign_width = sign->width + 8; */
    3475             }
    3476             else
    3477             {
    3478                 vim_free(sign);
    3479                 sign = NULL;
    3480                 EMSG(_(e_signdata));
    3481             }
     3469        if (status == 0)
     3470        {
     3471            /* Sign width is fixed at two columns now.
     3472            if (sign->width > gui.sign_width)
     3473                gui.sign_width = sign->width + 8; */
    34823474        }
     3475        else
     3476            EMSG(_(e_signdata));
    34833477    }
    34843478
    34853479    return (void *)sign;
     
    34893483gui_mch_destroy_sign(sign)
    34903484    void *sign;
    34913485{
    3492     XFree(((XImage *)sign)->data);
    3493     vim_free(sign);
     3486    XDestroyImage((XImage*)sign);
    34943487}
    34953488#endif
    34963489
  • src/gui_xmdlg.c

    diff -Naur vim72.orig/src/gui_xmdlg.c vim72/src/gui_xmdlg.c
    old new  
    369369    char        buf[TEMP_BUF_SIZE];
    370370    XmString    items[MAX_ENTRIES_IN_LIST];
    371371    int         i;
    372     int         index;
     372    int         idx;
    373373
    374     for (index = (int)ENCODING; index < (int)NONE; ++index)
    375         count[index] = 0;
     374    for (idx = (int)ENCODING; idx < (int)NONE; ++idx)
     375        count[idx] = 0;
    376376
    377377    /* First we insert the wild char into every single list. */
    378378    if (fix != ENCODING)
     
    503503    /*
    504504     * Now loop trough the remaining lists and set them up.
    505505     */
    506     for (index = (int)NAME; index < (int)NONE; ++index)
     506    for (idx = (int)NAME; idx < (int)NONE; ++idx)
    507507    {
    508508        Widget w;
    509509
    510         if (fix == (enum ListSpecifier)index)
     510        if (fix == (enum ListSpecifier)idx)
    511511            continue;
    512512
    513         switch ((enum ListSpecifier)index)
     513        switch ((enum ListSpecifier)idx)
    514514        {
    515515            case NAME:
    516516                w = data->list[NAME];
     
    525525                w = (Widget)0;  /* for lint */
    526526        }
    527527
    528         for (i = 0; i < count[index]; ++i)
     528        for (i = 0; i < count[idx]; ++i)
    529529        {
    530             items[i] = XmStringCreateLocalized(list[index][i]);
    531             XtFree(list[index][i]);
     530            items[i] = XmStringCreateLocalized(list[idx][i]);
     531            XtFree(list[idx][i]);
    532532        }
    533533        XmListDeleteAllItems(w);
    534         XmListAddItems(w, items, count[index], 1);
    535         if (data->sel[index])
     534        XmListAddItems(w, items, count[idx], 1);
     535        if (data->sel[idx])
    536536        {
    537537            XmStringFree(items[0]);
    538             items[0] = XmStringCreateLocalized(data->sel[index]);
     538            items[0] = XmStringCreateLocalized(data->sel[idx]);
    539539            XmListSelectItem(w, items[0], False);
    540540            XmListSetBottomItem(w, items[0]);
    541541        }
    542         for (i = 0; i < count[index]; ++i)
     542        for (i = 0; i < count[idx]; ++i)
    543543            XmStringFree(items[i]);
    544544    }
    545545}
     
    695695        int         n;
    696696        XmString    str;
    697697        Arg         args[4];
    698         char        *msg = _("no specific match");
     698        char        *nomatch_msg = _("no specific match");
    699699
    700700        n = 0;
    701         str = XmStringCreateLocalized(msg);
     701        str = XmStringCreateLocalized(nomatch_msg);
    702702        XtSetArg(args[n], XmNlabelString, str); ++n;
    703703        XtSetValues(data->sample, args, n);
    704704        apply_fontlist(data->sample);
    705         XmTextSetString(data->name, msg);
     705        XmTextSetString(data->name, nomatch_msg);
    706706        XmStringFree(str);
    707707
    708708        return False;
     
    886886    {
    887887        int     i;
    888888        int     max;
    889         int     index = 0;
     889        int     idx = 0;
    890890        int     size;
    891         char    str[128];
     891        char    buf[128];
    892892
    893893        for (i = 0, max = 0; i < data->num; i++)
    894894        {
    895             get_part(fn(data, i), 7, str);
    896             size = atoi(str);
     895            get_part(fn(data, i), 7, buf);
     896            size = atoi(buf);
    897897            if ((size > max) && (size < MAX_DISPLAY_SIZE))
    898898            {
    899                 index = i;
     899                idx = i;
    900900                max = size;
    901901            }
    902902        }
    903         strcpy(big_font, fn(data, index));
     903        strcpy(big_font, fn(data, idx));
    904904    }
    905905    data->old = XLoadQueryFont(XtDisplay(parent), big_font);
    906906    data->old_list = gui_motif_create_fontlist(data->old);
     
    12171217
    12181218        if (i != 0)
    12191219        {
    1220             char name[TEMP_BUF_SIZE];
    1221             char style[TEMP_BUF_SIZE];
    1222             char size[TEMP_BUF_SIZE];
    1223             char encoding[TEMP_BUF_SIZE];
     1220            char namebuf[TEMP_BUF_SIZE];
     1221            char stylebuf[TEMP_BUF_SIZE];
     1222            char sizebuf[TEMP_BUF_SIZE];
     1223            char encodingbuf[TEMP_BUF_SIZE];
    12241224            char *found;
    12251225
    12261226            found = names[0];
    12271227
    1228             name_part(found, name);
    1229             style_part(found, style);
    1230             size_part(found, size, data->in_pixels);
    1231             encoding_part(found, encoding);
    1232 
    1233             if (strlen(name) > 0
    1234                     && strlen(style) > 0
    1235                     && strlen(size) > 0
    1236                     && strlen(encoding) > 0)
     1228            name_part(found, namebuf);
     1229            style_part(found, stylebuf);
     1230            size_part(found, sizebuf, data->in_pixels);
     1231            encoding_part(found, encodingbuf);
     1232
     1233            if (strlen(namebuf) > 0
     1234                    && strlen(stylebuf) > 0
     1235                    && strlen(sizebuf) > 0
     1236                    && strlen(encodingbuf) > 0)
    12371237            {
    1238                 data->sel[NAME] = XtNewString(name);
    1239                 data->sel[STYLE] = XtNewString(style);
    1240                 data->sel[SIZE] = XtNewString(size);
    1241                 data->sel[ENCODING] = XtNewString(encoding);
     1238                data->sel[NAME] = XtNewString(namebuf);
     1239                data->sel[STYLE] = XtNewString(stylebuf);
     1240                data->sel[SIZE] = XtNewString(sizebuf);
     1241                data->sel[ENCODING] = XtNewString(encodingbuf);
    12421242                data->font_name = XtNewString(names[0]);
    12431243                display_sample(data);
    12441244                XmTextSetString(data->name, data->font_name);
  • src/gui_xmebw.c

    diff -Naur vim72.orig/src/gui_xmebw.c vim72/src/gui_xmebw.c
    old new  
    12561256    }
    12571257    else
    12581258    {
    1259         int adjust = 0;
     1259        adjust = 0;
    12601260
    12611261#if !defined(LESSTIF_VERSION) && (XmVersion > 1002)
    12621262        /*
     
    12681268        {
    12691269            case XmEXTERNAL_HIGHLIGHT:
    12701270                adjust = (eb->primitive.highlight_thickness -
    1271                         (eb->pushbutton.default_button_shadow_thickness ?
    1272                          Xm3D_ENHANCE_PIXEL : 0));
     1271                         (eb->pushbutton.default_button_shadow_thickness
     1272                          ?  Xm3D_ENHANCE_PIXEL : 0));
    12731273                break;
    12741274
    12751275            case XmINTERNAL_HIGHLIGHT:
    1276                 adjust = 0;
    12771276                break;
    12781277
    12791278            default:
  • src/if_cscope.c

    diff -Naur vim72.orig/src/if_cscope.c vim72/src/if_cscope.c
    old new  
    7474    { "add",    cs_add,
    7575                N_("Add a new database"),     "add file|dir [pre-path] [flags]", 0 },
    7676    { "find",   cs_find,
    77                 N_("Query for a pattern"),    FIND_USAGE, 1 },
     77                N_("Query for a pattern"),    "find c|d|e|f|g|i|s|t name", 1 },
    7878    { "help",   cs_help,
    7979                N_("Show this message"),      "help", 0 },
    8080    { "kill",   cs_kill,
     
    11771177    (void)MSG_PUTS(_("cscope commands:\n"));
    11781178    while (cmdp->name != NULL)
    11791179    {
    1180         (void)smsg((char_u *)_("%-5s: %-30s (Usage: %s)"),
    1181                                       cmdp->name, _(cmdp->help), cmdp->usage);
     1180        char *help = _(cmdp->help);
     1181        int  space_cnt = 30 - vim_strsize((char_u *)help);
     1182
     1183        /* Use %*s rather than %30s to ensure proper alignment in utf-8 */
     1184        if (space_cnt < 0)
     1185            space_cnt = 0;
     1186        (void)smsg((char_u *)_("%-5s: %s%*s (Usage: %s)"),
     1187                                      cmdp->name,
     1188                                      help, space_cnt, " ",
     1189                                      cmdp->usage);
    11821190        if (strcmp(cmdp->name, "find") == 0)
    1183             MSG_PUTS(FIND_HELP);
     1191            MSG_PUTS(_("\n"
     1192                       "       c: Find functions calling this function\n"
     1193                       "       d: Find functions called by this function\n"
     1194                       "       e: Find this egrep pattern\n"
     1195                       "       f: Find this file\n"
     1196                       "       g: Find this definition\n"
     1197                       "       i: Find files #including this file\n"
     1198                       "       s: Find this C symbol\n"
     1199                       "       t: Find assignments to\n"));
     1200
    11841201        cmdp++;
    11851202    }
    11861203
  • src/if_cscope.h

    diff -Naur vim72.orig/src/if_cscope.h vim72/src/if_cscope.h
    old new  
    4242 * f 7name      Find this file
    4343 * i 8name      Find files #including this file
    4444 */
    45 #define FIND_USAGE "find c|d|e|f|g|i|s|t name"
    46 #define FIND_HELP "\n\
    47        c: Find functions calling this function\n\
    48        d: Find functions called by this function\n\
    49        e: Find this egrep pattern\n\
    50        f: Find this file\n\
    51        g: Find this definition\n\
    52        i: Find files #including this file\n\
    53        s: Find this C symbol\n\
    54        t: Find assignments to\n"
    55 
    5645
    5746typedef struct {
    5847    char *  name;
  • src/if_perl.xs

    diff -Naur vim72.orig/src/if_perl.xs vim72/src/if_perl.xs
    old new  
    136136#  define Perl_newXS_flags dll_Perl_newXS_flags
    137137#endif
    138138# define Perl_sv_free dll_Perl_sv_free
     139# if (PERL_REVISION == 5) && (PERL_VERSION >= 10)
     140#  define Perl_sv_free2 dll_Perl_sv_free2
     141# endif
    139142# define Perl_sv_isa dll_Perl_sv_isa
    140143# define Perl_sv_magic dll_Perl_sv_magic
    141144# define Perl_sv_setiv dll_Perl_sv_setiv
     
    163166# define Perl_Isv_yes_ptr dll_Perl_Isv_yes_ptr
    164167# define boot_DynaLoader dll_boot_DynaLoader
    165168
    166 # define Perl_sys_init3 dll_Perl_sys_init3
     169# define Perl_sys_init dll_Perl_sys_init
    167170# define Perl_sys_term dll_Perl_sys_term
    168171# define Perl_ISv_ptr dll_Perl_ISv_ptr
    169172# define Perl_Istack_max_ptr dll_Perl_Istack_max_ptr
     
    268271static void (*boot_DynaLoader)_((pTHX_ CV*));
    269272
    270273#if (PERL_REVISION == 5) && (PERL_VERSION >= 10)
    271 static void (*Perl_sys_init3)(int* argc, char*** argv, char*** env);
     274static void (*Perl_sv_free2)(pTHX_ SV*);
     275static void (*Perl_sys_init)(int* argc, char*** argv);
    272276static void (*Perl_sys_term)(void);
    273277static SV** (*Perl_ISv_ptr)(register PerlInterpreter*);
    274278static SV*** (*Perl_Istack_max_ptr)(register PerlInterpreter*);
     
    367371    {"Perl_TXpv_ptr", (PERL_PROC*)&Perl_TXpv_ptr},
    368372    {"Perl_Tna_ptr", (PERL_PROC*)&Perl_Tna_ptr},
    369373#else
    370     {"Perl_sys_init3", (PERL_PROC*)&Perl_sys_init3},
     374    {"Perl_sv_free2", (PERL_PROC*)&Perl_sv_free2},
     375    {"Perl_sys_init", (PERL_PROC*)&Perl_sys_init},
    371376    {"Perl_sys_term", (PERL_PROC*)&Perl_sys_term},
    372377    {"Perl_ISv_ptr", (PERL_PROC*)&Perl_ISv_ptr},
    373378    {"Perl_Istack_sp_ptr", (PERL_PROC*)&Perl_Istack_sp_ptr},
     
    455460    static char *argv[] = { "", "-e", "" };
    456461
    457462#if (PERL_REVISION == 5) && (PERL_VERSION >= 10)
    458     Perl_sys_init3(&argc, (char***)&argv, NULL);
     463    Perl_sys_init(&argc, (char***)&argv);
    459464#endif
    460465    perl_interp = perl_alloc();
    461466    perl_construct(perl_interp);
  • src/if_python.c

    diff -Naur vim72.orig/src/if_python.c vim72/src/if_python.c
    old new  
    531531        if (PythonMod_Init())
    532532            goto fail;
    533533
     534        /* Remove the element from sys.path that was added because of our
     535         * argv[0] value in PythonMod_Init().  Previously we used an empty
     536         * string, but dependinding on the OS we then get an empty entry or
     537         * the current directory in sys.path. */
     538        PyRun_SimpleString("import sys; sys.path = filter(lambda x: x != '/must>not&exist', sys.path)");
     539
    534540        /* the first python thread is vim's, release the lock */
    535541        Python_SaveThread();
    536542
     
    11451151
    11461152    /* Check if we run into a recursive loop.  The item must be in lookupDict
    11471153     * then and we can use it again. */
    1148     sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U, (long_u)our_tv);
    1149     result = PyDict_GetItemString(lookupDict, ptrBuf);
    1150     if (result != NULL)
    1151         Py_INCREF(result);
    1152     else if (our_tv->v_type == VAR_STRING)
     1154    if ((our_tv->v_type == VAR_LIST && our_tv->vval.v_list != NULL)
     1155            || (our_tv->v_type == VAR_DICT && our_tv->vval.v_dict != NULL))
     1156    {
     1157        sprintf(ptrBuf, PRINTF_DECIMAL_LONG_U,
     1158                our_tv->v_type == VAR_LIST ? (long_u)our_tv->vval.v_list
     1159                                           : (long_u)our_tv->vval.v_dict);
     1160        result = PyDict_GetItemString(lookupDict, ptrBuf);
     1161        if (result != NULL)
     1162        {
     1163            Py_INCREF(result);
     1164            return result;
     1165        }
     1166    }
     1167
     1168    if (our_tv->v_type == VAR_STRING)
    11531169    {
    11541170        result = Py_BuildValue("s", our_tv->vval.v_string);
    1155         PyDict_SetItemString(lookupDict, ptrBuf, result);
    11561171    }
    11571172    else if (our_tv->v_type == VAR_NUMBER)
    11581173    {
     
    11611176        /* For backwards compatibility numbers are stored as strings. */
    11621177        sprintf(buf, "%ld", (long)our_tv->vval.v_number);
    11631178        result = Py_BuildValue("s", buf);
    1164         PyDict_SetItemString(lookupDict, ptrBuf, result);
    11651179    }
    11661180# ifdef FEAT_FLOAT
    11671181    else if (our_tv->v_type == VAR_FLOAT)
     
    11701184
    11711185        sprintf(buf, "%f", our_tv->vval.v_float);
    11721186        result = Py_BuildValue("s", buf);
    1173         PyDict_SetItemString(lookupDict, ptrBuf, result);
    11741187    }
    11751188# endif
    11761189    else if (our_tv->v_type == VAR_LIST)
     
    11791192        listitem_T      *curr;
    11801193
    11811194        result = PyList_New(0);
    1182         PyDict_SetItemString(lookupDict, ptrBuf, result);
    11831195
    11841196        if (list != NULL)
    11851197        {
     1198            PyDict_SetItemString(lookupDict, ptrBuf, result);
     1199
    11861200            for (curr = list->lv_first; curr != NULL; curr = curr->li_next)
    11871201            {
    11881202                newObj = VimToPython(&curr->li_tv, depth + 1, lookupDict);
     
    11941208    else if (our_tv->v_type == VAR_DICT)
    11951209    {
    11961210        result = PyDict_New();
    1197         PyDict_SetItemString(lookupDict, ptrBuf, result);
    11981211
    11991212        if (our_tv->vval.v_dict != NULL)
    12001213        {
     
    12031216            hashitem_T  *hi;
    12041217            dictitem_T  *di;
    12051218
     1219            PyDict_SetItemString(lookupDict, ptrBuf, result);
     1220
    12061221            for (hi = ht->ht_array; todo > 0; ++hi)
    12071222            {
    12081223                if (!HASHITEM_EMPTY(hi))
     
    23452360{
    23462361    PyObject *mod;
    23472362    PyObject *dict;
    2348     static char *(argv[2]) = {"", NULL};
     2363    /* The special value is removed from sys.path in Python_Init(). */
     2364    static char *(argv[2]) = {"/must>not&exist/foo", NULL};
    23492365
    23502366    /* Fixups... */
    23512367    BufferType.ob_type = &PyType_Type;
  • src/if_xcmdsrv.c

    diff -Naur vim72.orig/src/if_xcmdsrv.c vim72/src/if_xcmdsrv.c
    old new  
    736736                + serverReply.ga_len;
    737737            e.id = w;
    738738            ga_init2(&e.strings, 1, 100);
    739             memcpy(p, &e, sizeof(e));
     739            mch_memmove(p, &e, sizeof(e));
    740740            serverReply.ga_len++;
    741741        }
    742742    }
     
    10181018        p++;
    10191019        count = numItems - (p - regProp);
    10201020        if (count > 0)
    1021             memcpy(entry, p, count);
     1021            mch_memmove(entry, p, count);
    10221022        XChangeProperty(dpy, RootWindow(dpy, 0), registryProperty, XA_STRING,
    10231023                        8, PropModeReplace, regProp,
    10241024                        (int)(numItems - (p - entry)));
     
    10721072                p++;
    10731073                lastHalf = numItems - (p - regProp);
    10741074                if (lastHalf > 0)
    1075                     memcpy(entry, p, lastHalf);
     1075                    mch_memmove(entry, p, lastHalf);
    10761076                numItems = (entry - regProp) + lastHalf;
    10771077                p = entry;
    10781078                continue;
  • src/macros.h

    diff -Naur vim72.orig/src/macros.h vim72/src/macros.h
    old new  
    127127#ifdef FEAT_LANGMAP
    128128/*
    129129 * Adjust chars in a language according to 'langmap' option.
    130  * NOTE that there is NO overhead if 'langmap' is not set; but even
    131  * when set we only have to do 2 ifs and an array lookup.
     130 * NOTE that there is no noticeable overhead if 'langmap' is not set.
     131 * When set the overhead for characters < 256 is small.
    132132 * Don't apply 'langmap' if the character comes from the Stuff buffer.
    133133 * The do-while is just to ignore a ';' after the macro.
    134134 */
    135 # define LANGMAP_ADJUST(c, condition) do { \
    136         if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0 && (c) < 256) \
    137             c = langmap_mapchar[c]; \
     135# ifdef FEAT_MBYTE
     136#  define LANGMAP_ADJUST(c, condition) \
     137    do { \
     138        if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0) \
     139        { \
     140            if ((c) < 256) \
     141                c = langmap_mapchar[c]; \
     142            else \
     143                c = langmap_adjust_mb(c); \
     144        } \
    138145    } while (0)
     146# else
     147#  define LANGMAP_ADJUST(c, condition) \
     148    do { \
     149        if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0 && (c) < 256) \
     150            c = langmap_mapchar[c]; \
     151    } while (0)
     152# endif
     153#else
     154# define LANGMAP_ADJUST(c, condition) /* nop */
    139155#endif
    140156
    141157/*
  • src/main.c

    diff -Naur vim72.orig/src/main.c vim72/src/main.c
    old new  
    645645
    646646#ifdef FEAT_VIMINFO
    647647    /*
    648      * Read in registers, history etc, but not marks, from the viminfo file
     648     * Read in registers, history etc, but not marks, from the viminfo file.
     649     * This is where v:oldfiles gets filled.
    649650     */
    650651    if (*p_viminfo != NUL)
    651652    {
    652         read_viminfo(NULL, TRUE, FALSE, FALSE);
     653        read_viminfo(NULL, VIF_WANT_INFO | VIF_GET_OLDFILES);
    653654        TIME_MSG("reading viminfo");
    654655    }
    655656#endif
     
    14571458        ++initstr;
    14581459    }
    14591460
    1460     if (TOLOWER_ASC(initstr[0]) == 'g' || initstr[0] == 'k')
     1461    /* "gvim" starts the GUI.  Also accept "Gvim" for MS-Windows. */
     1462    if (TOLOWER_ASC(initstr[0]) == 'g')
    14611463    {
    14621464        main_start_gui();
    14631465#ifdef FEAT_GUI
     
    15081510early_arg_scan(parmp)
    15091511    mparm_T     *parmp;
    15101512{
    1511 #if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER)
     1513#if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER) \
     1514        || !defined(FEAT_NETBEANS_INTG)
    15121515    int         argc = parmp->argc;
    15131516    char        **argv = parmp->argv;
    15141517    int         i;
     
    15801583        else if (STRICMP(argv[i], "--echo-wid") == 0)
    15811584            echo_wid_arg = TRUE;
    15821585# endif
     1586# ifndef FEAT_NETBEANS_INTG
     1587        else if (strncmp(argv[i], "-nb", (size_t)3) == 0)
     1588        {
     1589            mch_errmsg(_("'-nb' cannot be used: not enabled at compile time\n"));
     1590            mch_exit(2);
     1591        }
     1592# endif
     1593
    15831594    }
    15841595#endif
    15851596}
     
    23612372     * Is there any other system that cannot do this?
    23622373     */
    23632374    close(0);
    2364     dup(2);
     2375    ignored = dup(2);
    23652376#endif
    23662377}
    23672378
  • src/mark.c

    diff -Naur vim72.orig/src/mark.c vim72/src/mark.c
    old new  
    16271627
    16281628/*
    16291629 * Handle marks in the viminfo file:
    1630  * fp_out == NULL   read marks for current buffer only
    1631  * fp_out != NULL   copy marks for buffers not in buffer list
     1630 * fp_out != NULL: copy marks for buffers not in buffer list
     1631 * fp_out == NULL && (flags & VIF_WANT_MARKS): read marks for curbuf only
     1632 * fp_out == NULL && (flags & VIF_GET_OLDFILES | VIF_FORCEIT): fill v:oldfiles
    16321633 */
    16331634    void
    1634 copy_viminfo_marks(virp, fp_out, count, eof)
     1635copy_viminfo_marks(virp, fp_out, count, eof, flags)
    16351636    vir_T       *virp;
    16361637    FILE        *fp_out;
    16371638    int         count;
    16381639    int         eof;
     1640    int         flags;
    16391641{
    16401642    char_u      *line = virp->vir_line;
    16411643    buf_T       *buf;
     
    16471649    char_u      *p;
    16481650    char_u      *name_buf;
    16491651    pos_T       pos;
     1652#ifdef FEAT_EVAL
     1653    list_T      *list = NULL;
     1654#endif
    16501655
    16511656    if ((name_buf = alloc(LSIZE)) == NULL)
    16521657        return;
    16531658    *name_buf = NUL;
     1659
     1660#ifdef FEAT_EVAL
     1661    if (fp_out == NULL && (flags & (VIF_GET_OLDFILES | VIF_FORCEIT)))
     1662    {
     1663        list = list_alloc();
     1664        if (list != NULL)
     1665            set_vim_var_list(VV_OLDFILES, list);
     1666    }
     1667#endif
     1668
    16541669    num_marked_files = get_viminfo_parameter('\'');
    16551670    while (!eof && (count < num_marked_files || fp_out == NULL))
    16561671    {
     
    16811696            p++;
    16821697        *p = NUL;
    16831698
     1699#ifdef FEAT_EVAL
     1700        if (list != NULL)
     1701            list_append_string(list, str, -1);
     1702#endif
     1703
    16841704        /*
    16851705         * If fp_out == NULL, load marks for current buffer.
    16861706         * If fp_out != NULL, copy marks for buffers not in buflist.
     
    16881708        load_marks = copy_marks_out = FALSE;
    16891709        if (fp_out == NULL)
    16901710        {
    1691             if (curbuf->b_ffname != NULL)
     1711            if ((flags & VIF_WANT_MARKS) && curbuf->b_ffname != NULL)
    16921712            {
    16931713                if (*name_buf == NUL)       /* only need to do this once */
    16941714                    home_replace(NULL, curbuf->b_ffname, name_buf, LSIZE, TRUE);
  • src/mbyte.c

    diff -Naur vim72.orig/src/mbyte.c vim72/src/mbyte.c
    old new  
    717717                     * where mblen() returns 0 for invalid character.
    718718                     * Therefore, following condition includes 0.
    719719                     */
    720                     (void)mblen(NULL, 0);       /* First reset the state. */
     720                    ignored = mblen(NULL, 0);   /* First reset the state. */
    721721                    if (mblen(buf, (size_t)1) <= 0)
    722722                        n = 2;
    723723                    else
     
    25402540    return (int)(p - q);
    25412541}
    25422542
    2543 #if defined(FEAT_EVAL) || defined(PROTO)
    25442543/*
    25452544 * Copy a character from "*fp" to "*tp" and advance the pointers.
    25462545 */
     
    25552554    *tp += l;
    25562555    *fp += l;
    25572556}
    2558 #endif
    25592557
    25602558/*
    25612559 * Return the offset from "p" to the first byte of a character.  When "p" is
     
    31333131        else
    31343132            s = p + 1;
    31353133    }
    3136     for (i = 0; s[i] != NUL && s + i < buf + sizeof(buf) - 1; ++i)
     3134    for (i = 0; s[i] != NUL && i < sizeof(buf) - 1; ++i)
    31373135    {
    31383136        if (s[i] == '_' || s[i] == '-')
    31393137            buf[i] = '-';
     
    52805278
    52815279/*ARGSUSED*/
    52825280    static void
    5283 preedit_start_cbproc(XIC xic, XPointer client_data, XPointer call_data)
     5281preedit_start_cbproc(XIC thexic, XPointer client_data, XPointer call_data)
    52845282{
    52855283#ifdef XIM_DEBUG
    52865284    xim_log("xim_decide_input_style()\n");
     
    53145312
    53155313/*ARGSUSED*/
    53165314    static void
    5317 preedit_draw_cbproc(XIC xic, XPointer client_data, XPointer call_data)
     5315preedit_draw_cbproc(XIC thexic, XPointer client_data, XPointer call_data)
    53185316{
    53195317    XIMPreeditDrawCallbackStruct *draw_data;
    53205318    XIMText     *text;
     
    53865384                        draw_feedback = (char *)alloc(draw_data->chg_first
    53875385                                                              + text->length);
    53885386                    else
    5389                         draw_feedback = realloc(draw_feedback,
     5387                        draw_feedback = vim_realloc(draw_feedback,
    53905388                                         draw_data->chg_first + text->length);
    53915389                    if (draw_feedback != NULL)
    53925390                    {
     
    54555453
    54565454/*ARGSUSED*/
    54575455    static void
    5458 preedit_caret_cbproc(XIC xic, XPointer client_data, XPointer call_data)
     5456preedit_caret_cbproc(XIC thexic, XPointer client_data, XPointer call_data)
    54595457{
    54605458#ifdef XIM_DEBUG
    54615459    xim_log("preedit_caret_cbproc()\n");
     
    54645462
    54655463/*ARGSUSED*/
    54665464    static void
    5467 preedit_done_cbproc(XIC xic, XPointer client_data, XPointer call_data)
     5465preedit_done_cbproc(XIC thexic, XPointer client_data, XPointer call_data)
    54685466{
    54695467#ifdef XIM_DEBUG
    54705468    xim_log("preedit_done_cbproc()\n");
  • src/menu.c

    diff -Naur vim72.orig/src/menu.c vim72/src/menu.c
    old new  
    11201120        parent = menu;
    11211121        menu = menu->children;
    11221122    }
     1123    vim_free(path_name);
    11231124
    11241125    /* Now we have found the matching menu, and we list the mappings */
    11251126                                                    /* Highlight title */
  • src/message.c

    diff -Naur vim72.orig/src/message.c vim72/src/message.c
    old new  
    976976                    }
    977977                }
    978978                else if (msg_scrolled > Rows - 2
    979                                      && (c == 'j' || c == K_DOWN || c == 'd'))
     979                         && (c == 'j' || c == K_DOWN || c == 'd' || c == 'f'))
    980980                    c = K_IGNORE;
    981981            }
    982982        } while ((had_got_int && c == Ctrl_C)
     
    25042504            break;
    25052505
    25062506        case 'u':               /* Up half a page */
    2507         case K_PAGEUP:
    25082507            scroll = -(Rows / 2);
    25092508            break;
    25102509
     
    25132512            break;
    25142513
    25152514        case 'b':               /* one page back */
     2515        case K_PAGEUP:
    25162516            scroll = -(Rows - 1);
    25172517            break;
    25182518
    25192519        case ' ':               /* one extra page */
     2520        case 'f':
    25202521        case K_PAGEDOWN:
    25212522        case K_LEFTMOUSE:
    25222523            scroll = Rows - 1;
     
    25522553            {
    25532554                /* Jump to the choices of the dialog. */
    25542555                retval = TRUE;
    2555                 lines_left = Rows - 1;
    25562556            }
    25572557            else
    25582558#endif
     
    25602560                got_int = TRUE;
    25612561                quit_more = TRUE;
    25622562            }
     2563            /* When there is some more output (wrapping line) display that
     2564             * without another prompt. */
     2565            lines_left = Rows - 1;
    25632566            break;
    25642567
    25652568#ifdef FEAT_CLIPBOARD
     
    33093312    {
    33103313        c = gui_mch_dialog(type, title, message, buttons, dfltbutton,
    33113314                                                                   textfield);
    3312         msg_end_prompt();
     3315        /* avoid a hit-enter prompt without clearing the cmdline */
     3316        need_wait_return = FALSE;
     3317        emsg_on_display = FALSE;
     3318        cmdline_row = msg_row;
    33133319
    33143320        /* Flush output to avoid that further messages and redrawing is done
    33153321         * in the wrong order. */
     
    45564562                        remove_trailing_zeroes = TRUE;
    45574563                    }
    45584564
    4559                     if (fmt_spec == 'f' && abs_f > 1.0e307)
     4565                    if (fmt_spec == 'f' &&
     4566#ifdef VAX
     4567                            abs_f > 1.0e38
     4568#else
     4569                            abs_f > 1.0e307
     4570#endif
     4571                            )
    45604572                    {
    45614573                        /* Avoid a buffer overflow */
    45624574                        strcpy(tmp, "inf");
     
    45854597                        if (remove_trailing_zeroes)
    45864598                        {
    45874599                            int i;
    4588                             char *p;
     4600                            char *tp;
    45894601
    45904602                            /* Using %g or %G: remove superfluous zeroes. */
    45914603                            if (fmt_spec == 'f')
    4592                                 p = tmp + str_arg_l - 1;
     4604                                tp = tmp + str_arg_l - 1;
    45934605                            else
    45944606                            {
    4595                                 p = (char *)vim_strchr((char_u *)tmp,
     4607                                tp = (char *)vim_strchr((char_u *)tmp,
    45964608                                                 fmt_spec == 'e' ? 'e' : 'E');
    4597                                 if (p != NULL)
     4609                                if (tp != NULL)
    45984610                                {
    45994611                                    /* Remove superfluous '+' and leading
    46004612                                     * zeroes from the exponent. */
    4601                                     if (p[1] == '+')
     4613                                    if (tp[1] == '+')
    46024614                                    {
    46034615                                        /* Change "1.0e+07" to "1.0e07" */
    4604                                         STRMOVE(p + 1, p + 2);
     4616                                        STRMOVE(tp + 1, tp + 2);
    46054617                                        --str_arg_l;
    46064618                                    }
    4607                                     i = (p[1] == '-') ? 2 : 1;
    4608                                     while (p[i] == '0')
     4619                                    i = (tp[1] == '-') ? 2 : 1;
     4620                                    while (tp[i] == '0')
    46094621                                    {
    46104622                                        /* Change "1.0e07" to "1.0e7" */
    4611                                         STRMOVE(p + i, p + i + 1);
     4623                                        STRMOVE(tp + i, tp + i + 1);
    46124624                                        --str_arg_l;
    46134625                                    }
    4614                                     --p;
     4626                                    --tp;
    46154627                                }
    46164628                            }
    46174629
    4618                             if (p != NULL && !precision_specified)
     4630                            if (tp != NULL && !precision_specified)
    46194631                                /* Remove trailing zeroes, but keep the one
    46204632                                 * just after a dot. */
    4621                                 while (p > tmp + 2 && *p == '0' && p[-1] != '.')
     4633                                while (tp > tmp + 2 && *tp == '0'
     4634                                                             && tp[-1] != '.')
    46224635                                {
    4623                                     STRMOVE(p, p + 1);
    4624                                     --p;
     4636                                    STRMOVE(tp, tp + 1);
     4637                                    --tp;
    46254638                                    --str_arg_l;
    46264639                                }
    46274640                        }
    46284641                        else
    46294642                        {
    4630                             char *p;
     4643                            char *tp;
    46314644
    46324645                            /* Be consistent: some printf("%e") use 1.0e+12
    46334646                             * and some 1.0e+012.  Remove one zero in the last
    46344647                             * case. */
    4635                             p = (char *)vim_strchr((char_u *)tmp,
     4648                            tp = (char *)vim_strchr((char_u *)tmp,
    46364649                                                 fmt_spec == 'e' ? 'e' : 'E');
    4637                             if (p != NULL && (p[1] == '+' || p[1] == '-')
    4638                                           && p[2] == '0'
    4639                                           && vim_isdigit(p[3])
    4640                                           && vim_isdigit(p[4]))
     4650                            if (tp != NULL && (tp[1] == '+' || tp[1] == '-')
     4651                                          && tp[2] == '0'
     4652                                          && vim_isdigit(tp[3])
     4653                                          && vim_isdigit(tp[4]))
    46414654                            {
    4642                                 STRMOVE(p + 2, p + 3);
     4655                                STRMOVE(tp + 2, tp + 3);
    46434656                                --str_arg_l;
    46444657                            }
    46454658                        }
  • src/misc1.c

    diff -Naur vim72.orig/src/misc1.c vim72/src/misc1.c
    old new  
    32453245
    32463246    /* When using ":silent" assume that <CR> was entered. */
    32473247    if (mouse_used != NULL)
    3248         MSG_PUTS(_("Type number or click with mouse (<Enter> cancels): "));
     3248        MSG_PUTS(_("Type number and <Enter> or click with mouse (empty cancels): "));
    32493249    else
    3250         MSG_PUTS(_("Choice number (<Enter> cancels): "));
     3250        MSG_PUTS(_("Type number and <Enter> (empty cancels): "));
    32513251
    32523252    /* Set the state such that text can be selected/copied/pasted and we still
    32533253     * get mouse events. */
  • src/misc2.c

    diff -Naur vim72.orig/src/misc2.c vim72/src/misc2.c
    old new  
    496496{
    497497    colnr_T len;
    498498#ifdef FEAT_VIRTUALEDIT
    499     colnr_T oldcol = curwin->w_cursor.col + curwin->w_cursor.coladd;
     499    colnr_T oldcol = curwin->w_cursor.col;
     500    colnr_T oldcoladd = curwin->w_cursor.col + curwin->w_cursor.coladd;
    500501#endif
    501502
    502503    len = (colnr_T)STRLEN(ml_get_curline());
     
    535536    if (oldcol == MAXCOL)
    536537        curwin->w_cursor.coladd = 0;
    537538    else if (ve_flags == VE_ALL)
    538         curwin->w_cursor.coladd = oldcol - curwin->w_cursor.col;
     539    {
     540        if (oldcoladd > curwin->w_cursor.col)
     541            curwin->w_cursor.coladd = oldcoladd - curwin->w_cursor.col;
     542        else
     543            /* avoid weird number when there is a miscalculation or overflow */
     544            curwin->w_cursor.coladd = 0;
     545    }
    539546#endif
    540547}
    541548
     
    873880            /* 3. check for available memory: call mch_avail_mem() */
    874881            if (mch_avail_mem(TRUE) < KEEP_ROOM && !releasing)
    875882            {
    876                 vim_free((char *)p);    /* System is low... no go! */
     883                free((char *)p);        /* System is low... no go! */
    877884                p = NULL;
    878885            }
    879886            else
     
    10101017# if defined(FEAT_PROFILE)
    10111018    do_cmdline_cmd((char_u *)"profdel *");
    10121019# endif
     1020# if defined(FEAT_KEYMAP)
     1021    do_cmdline_cmd((char_u *)"set keymap=");
     1022#endif
    10131023
    10141024# ifdef FEAT_TITLE
    10151025    free_titles();
     
    10341044    free_regexp_stuff();
    10351045    free_tag_stuff();
    10361046    free_cd_dir();
     1047# ifdef FEAT_SIGNS
     1048    free_signs();
     1049# endif
    10371050# ifdef FEAT_EVAL
    10381051    set_expr_line(NULL);
    10391052# endif
     
    12571270    return escaped_string;
    12581271}
    12591272
    1260 #if !defined(BACKSLASH_IN_FILENAME) || defined(FEAT_EVAL) || defined(PROTO)
    12611273/*
    12621274 * Return TRUE when 'shell' has "csh" in the tail.
    12631275 */
     
    12661278{
    12671279    return (strstr((char *)gettail(p_sh), "csh") != NULL);
    12681280}
    1269 #endif
    12701281
    1271 #if defined(FEAT_EVAL) || defined(PROTO)
    12721282/*
    12731283 * Escape "string" for use as a shell argument with system().
    12741284 * This uses single quotes, except when we know we need to use double qoutes
     
    13911401
    13921402    return escaped_string;
    13931403}
    1394 #endif
    13951404
    13961405/*
    13971406 * Like vim_strsave(), but make all characters uppercase.
     
    25652574    int         key;
    25662575    int         dlen = 0;
    25672576
    2568     key = find_special_key(srcp, &modifiers, keycode);
     2577    key = find_special_key(srcp, &modifiers, keycode, FALSE);
    25692578    if (key == 0)
    25702579        return 0;
    25712580
     
    26012610 * returns 0 if there is no match.
    26022611 */
    26032612    int
    2604 find_special_key(srcp, modp, keycode)
     2613find_special_key(srcp, modp, keycode, keep_x_key)
    26052614    char_u      **srcp;
    26062615    int         *modp;
    2607     int         keycode; /* prefer key code, e.g. K_DEL instead of DEL */
     2616    int         keycode;     /* prefer key code, e.g. K_DEL instead of DEL */
     2617    int         keep_x_key;  /* don't translate xHome to Home key */
    26082618{
    26092619    char_u      *last_dash;
    26102620    char_u      *end_of_name;
     
    26722682            else
    26732683            {
    26742684                key = get_special_key_code(last_dash + 1);
    2675                 key = handle_x_keys(key);
     2685                if (!keep_x_key)
     2686                    key = handle_x_keys(key);
    26762687            }
    26772688
    26782689            /*
     
    46984709                                stackp->ffs_filearray_cur = i + 1;
    46994710                                ff_push(search_ctx, stackp);
    47004711
    4701                                 simplify_filename(file_path);
     4712                                if (!path_with_url(file_path))
     4713                                    simplify_filename(file_path);
    47024714                                if (mch_dirname(ff_expand_buffer, MAXPATHL)
    47034715                                                                        == OK)
    47044716                                {
  • src/move.c

    diff -Naur vim72.orig/src/move.c vim72/src/move.c
    old new  
    280280
    281281        if (curwin->w_botline <= curbuf->b_ml.ml_line_count)
    282282        {
    283             if (curwin->w_cursor.lnum < curwin->w_botline
    284                     && ((long)curwin->w_cursor.lnum
     283            if (curwin->w_cursor.lnum < curwin->w_botline)
     284            {
     285              if (((long)curwin->w_cursor.lnum
    285286                                             >= (long)curwin->w_botline - p_so
    286287#ifdef FEAT_FOLDING
    287288                        || hasAnyFolding(curwin)
    288289#endif
    289290                        ))
    290             {
     291              {
    291292                lineoff_T       loff;
    292293
    293                 /* Cursor is above botline, check if there are 'scrolloff'
    294                  * window lines below the cursor.  If not, need to scroll. */
     294                /* Cursor is (a few lines) above botline, check if there are
     295                 * 'scrolloff' window lines below the cursor.  If not, need to
     296                 * scroll. */
    295297                n = curwin->w_empty_rows;
    296298                loff.lnum = curwin->w_cursor.lnum;
    297299#ifdef FEAT_FOLDING
     
    317319                if (n >= p_so)
    318320                    /* sufficient context, no need to scroll */
    319321                    check_botline = FALSE;
     322              }
     323              else
     324                  /* sufficient context, no need to scroll */
     325                  check_botline = FALSE;
    320326            }
    321327            if (check_botline)
    322328            {
     
    509515    /* Approximate the value of w_botline */
    510516    wp->w_botline += lnum - wp->w_topline;
    511517    wp->w_topline = lnum;
     518#ifdef FEAT_AUTOCMD
     519    wp->w_topline_was_set = TRUE;
     520#endif
    512521#ifdef FEAT_DIFF
    513522    wp->w_topfill = 0;
    514523#endif
  • src/nbdebug.c

    diff -Naur vim72.orig/src/nbdebug.c vim72/src/nbdebug.c
    old new  
    3333u_int            nb_dlevel = 0;         /* nb_debug verbosity level */
    3434
    3535void             nbdb(char *, ...);
    36 void             nbtrace(char *, ...);
    3736
    3837static int       lookup(char *);
    3938#ifdef USE_NB_ERRORHANDLER
     
    10099}    /* end nbdebug_log_init */
    101100
    102101
    103 
    104 
    105 void
    106 nbtrace(
    107         char            *fmt,
    108         ...)
    109 {
    110         va_list          ap;
    111 
    112         if (nb_debug!= NULL && (nb_dlevel & (NB_TRACE | NB_TRACE_VERBOSE))) {
    113                 va_start(ap, fmt);
    114                 vfprintf(nb_debug, fmt, ap);
    115                 va_end(ap);
    116                 fflush(nb_debug);
    117         }
    118 
    119 }    /* end nbtrace */
    120 
    121 
    122102void
    123103nbdbg(
    124104        char            *fmt,
     
    136116}    /* end nbdbg */
    137117
    138118
    139 void
    140 nbprt(
    141         char            *fmt,
    142         ...)
    143 {
    144         va_list          ap;
    145 
    146         if (nb_debug != NULL && nb_dlevel & NB_PRINT) {
    147                 va_start(ap, fmt);
    148                 vfprintf(nb_debug, fmt, ap);
    149                 va_end(ap);
    150                 fflush(nb_debug);
    151         }
    152 
    153 }    /* end nbprt */
    154 
    155 
    156119static int
    157120lookup(
    158121        char            *file)
  • src/nbdebug.h

    diff -Naur vim72.orig/src/nbdebug.h vim72/src/nbdebug.h
    old new  
    4343
    4444
    4545void             nbdbg(char *, ...);
    46 void             nbprt(char *, ...);
    47 void             nbtrace(char *, ...);
    4846
    4947void nbdebug_wait __ARGS((u_int wait_flags, char *wait_var, u_int wait_secs));
    5048void nbdebug_log_init __ARGS((char *log_var, char *level_var));
     
    7068{
    7169}
    7270
    73 void
    74 nbprt(
    75         char            *fmt,
    76         ...)
    77 {
    78 }
    79 
    80 void
    81 nbtrace(
    82         char            *fmt,
    83         ...)
    84 {
    85 }
    86 
    8771#endif /* NBDEBUG */
    8872#endif /* NBDEBUG_H */
  • src/netbeans.c

    diff -Naur vim72.orig/src/netbeans.c vim72/src/netbeans.c
    old new  
    10431043        nbdebug(("EVT: %s", buf));
    10441044/*      nb_send(buf, "netbeans_end");    avoid "write failed" messages */
    10451045        if (sd >= 0)
    1046             sock_write(sd, buf, (int)STRLEN(buf));  /* ignore errors */
     1046            ignored = sock_write(sd, buf, (int)STRLEN(buf));
    10471047    }
    10481048}
    10491049
     
    19211921            vim_free(path);
    19221922            if (bufp == NULL)
    19231923            {
    1924                 nbdebug(("    File %s not found in setBufferNumber\n", args));
     1924                nbdebug(("    File %s not found in setBufferNumber\n", args));
    19251925                EMSG2("E642: File %s not found in setBufferNumber", args);
    19261926                return FAIL;
    19271927            }
     
    22772277            int serNum;
    22782278            int localTypeNum;
    22792279            int typeNum;
    2280 # ifdef NBDEBUG
    2281             int len;
    2282 # endif
    22832280            pos_T *pos;
    22842281
    22852282            if (buf == NULL || buf->bufp == NULL)
     
    23032300            pos = get_off_or_lnum(buf->bufp, &args);
    23042301
    23052302            cp = (char *)args;
    2306 # ifdef NBDEBUG
    2307             len =
    2308 # endif
    2309                 strtol(cp, &cp, 10);
     2303            ignored = (int)strtol(cp, &cp, 10);
    23102304            args = (char_u *)cp;
    23112305# ifdef NBDEBUG
    2312             if (len != -1)
     2306            if (ignored != -1)
    23132307            {
    23142308                nbdebug(("    partial line annotation -- Not Yet Implemented!\n"));
    23152309            }
     
    23212315            }
    23222316            if (pos)
    23232317            {
    2324                 coloncmd(":sign place %d line=%d name=%d buffer=%d",
     2318                coloncmd(":sign place %d line=%ld name=%d buffer=%d",
    23252319                           serNum, pos->lnum, typeNum, buf->bufp->b_fnum);
    23262320                if (typeNum == curPCtype)
    23272321                    coloncmd(":sign jump %d buffer=%d", serNum,
     
    24252419                                GUARDED) == 0)
    24262420                            {
    24272421                                coloncmd(
    2428                                     ":sign place %d line=%d name=%d buffer=%d",
     2422                                    ":sign place %d line=%ld name=%d buffer=%d",
    24292423                                     guardId++, lnum, GUARDED,
    24302424                                     buf->bufp->b_fnum);
    24312425                            }
     
    29242918}
    29252919
    29262920/*
    2927  * Tell netbeans a file was closed.
     2921 * Tell netbeans that a file was deleted or wiped out.
    29282922 */
    29292923    void
    2930 netbeans_file_closed(buf_T *bufp)
     2924netbeans_file_killed(buf_T *bufp)
    29312925{
    29322926    int         bufno = nb_getbufno(bufp);
    29332927    nbbuf_T     *nbbuf = nb_get_buf(bufno);
    29342928    char        buffer[2*MAXPATHL];
    29352929
    2936     if (!haveConnection || bufno < 0)
    2937         return;
    2938 
    2939     if (!netbeansCloseFile)
    2940     {
    2941         nbdebug(("Ignoring file_closed for %s. File was closed from IDE\n",
    2942                     bufp->b_ffname));
     2930    if (!haveConnection || bufno == -1)
    29432931        return;
    2944     }
    2945 
    2946     nbdebug(("netbeans_file_closed:\n"));
    2947     nbdebug(("    Closing bufno: %d", bufno));
    2948     if (curbuf != NULL && curbuf != bufp)
    2949     {
    2950         nbdebug(("    Curbuf bufno:  %d\n", nb_getbufno(curbuf)));
    2951     }
    2952     else if (curbuf == bufp)
    2953     {
    2954         nbdebug(("    curbuf == bufp\n"));
    2955     }
    29562932
    2957     if (bufno <= 0)
    2958         return;
     2933    nbdebug(("netbeans_file_killed:\n"));
     2934    nbdebug(("    Killing bufno: %d", bufno));
    29592935
    29602936    sprintf(buffer, "%d:killed=%d\n", bufno, r_cmdno);
    29612937
    29622938    nbdebug(("EVT: %s", buffer));
    29632939
    2964     nb_send(buffer, "netbeans_file_closed");
     2940    nb_send(buffer, "netbeans_file_killed");
    29652941
    29662942    if (nbbuf != NULL)
    29672943        nbbuf->bufp = NULL;
  • src/normal.c

    diff -Naur vim72.orig/src/normal.c vim72/src/normal.c
    old new  
    183183static void     nv_cursorhold __ARGS((cmdarg_T *cap));
    184184#endif
    185185
     186static char *e_noident = N_("E349: No identifier under cursor");
     187
    186188/*
    187189 * Function to be called for a Normal or Visual mode command.
    188190 * The argument is a cmdarg_T.
     
    578580    static int  old_mapped_len = 0;
    579581#endif
    580582    int         idx;
     583#ifdef FEAT_EVAL
     584    int         set_prevcount = FALSE;
     585#endif
    581586
    582587    vim_memset(&ca, 0, sizeof(ca));     /* also resets ca.retval */
    583588    ca.oap = oap;
     
    613618    /* When not finishing an operator and no register name typed, reset the
    614619     * count. */
    615620    if (!finish_op && !oap->regname)
     621    {
    616622        ca.opcount = 0;
     623#ifdef FEAT_EVAL
     624        set_prevcount = TRUE;
     625#endif
     626    }
    617627
    618628#ifdef FEAT_AUTOCMD
    619629    /* Restore counts from before receiving K_CURSORHOLD.  This means after
     
    641651     * Get the command character from the user.
    642652     */
    643653    c = safe_vgetc();
    644 
    645 #ifdef FEAT_LANGMAP
    646654    LANGMAP_ADJUST(c, TRUE);
    647 #endif
    648655
    649656#ifdef FEAT_VISUAL
    650657    /*
     
    717724             * command, so that v:count can be used in an expression mapping
    718725             * right after the count. */
    719726            if (toplevel && stuff_empty())
    720                 set_vcount(ca.count0, ca.count0 == 0 ? 1 : ca.count0);
     727            {
     728                long count = ca.count0;
     729
     730                /* multiply with ca.opcount the same way as below */
     731                if (ca.opcount != 0)
     732                    count = ca.opcount * (count == 0 ? 1 : count);
     733                set_vcount(count, count == 0 ? 1 : count, set_prevcount);
     734                set_prevcount = FALSE;  /* only set v:prevcount once */
     735            }
    721736#endif
    722737            if (ctrl_w)
    723738            {
     
    726741            }
    727742            ++no_zero_mapping;          /* don't map zero here */
    728743            c = plain_vgetc();
    729 #ifdef FEAT_LANGMAP
    730744            LANGMAP_ADJUST(c, TRUE);
    731 #endif
    732745            --no_zero_mapping;
    733746            if (ctrl_w)
    734747            {
     
    751764            ++no_mapping;
    752765            ++allow_keys;               /* no mapping for nchar, but keys */
    753766            c = plain_vgetc();          /* get next character */
    754 #ifdef FEAT_LANGMAP
    755767            LANGMAP_ADJUST(c, TRUE);
    756 #endif
    757768            --no_mapping;
    758769            --allow_keys;
    759770#ifdef FEAT_CMDL_INFO
     
    804815     * Only set v:count when called from main() and not a stuffed command.
    805816     */
    806817    if (toplevel && stuff_empty())
    807         set_vcount(ca.count0, ca.count1);
     818        set_vcount(ca.count0, ca.count1, set_prevcount);
    808819#endif
    809820
    810821    /*
     
    941952             * "gr", "g'" and "g`".
    942953             */
    943954            ca.nchar = plain_vgetc();
    944 #ifdef FEAT_LANGMAP
    945955            LANGMAP_ADJUST(ca.nchar, TRUE);
    946 #endif
    947956#ifdef FEAT_CMDL_INFO
    948957            need_flushbuf |= add_to_showcmd(ca.nchar);
    949958#endif
     
    10441053                }
    10451054#endif
    10461055
    1047 #ifdef FEAT_LANGMAP
    10481056                /* adjust chars > 127, except after "tTfFr" commands */
    10491057                LANGMAP_ADJUST(*cp, !lang);
    1050 #endif
    10511058#ifdef FEAT_RIGHTLEFT
    10521059                /* adjust Hebrew mapped char */
    10531060                if (p_hkmap && lang && KeyTyped)
     
    11321139        out_flush();
    11331140#endif
    11341141#ifdef FEAT_AUTOCMD
    1135     did_cursorhold = FALSE;
     1142    if (ca.cmdchar != K_IGNORE)
     1143        did_cursorhold = FALSE;
    11361144#endif
    11371145
    11381146    State = NORMAL;
     
    35093517        if (find_type & FIND_STRING)
    35103518            EMSG(_("E348: No string under cursor"));
    35113519        else
    3512             EMSG(_("E349: No identifier under cursor"));
     3520            EMSG(_(e_noident));
    35133521        return 0;
    35143522    }
    35153523    ptr += col;
     
    46114619            ++no_mapping;
    46124620            ++allow_keys;   /* no mapping for nchar, but allow key codes */
    46134621            nchar = plain_vgetc();
    4614 #ifdef FEAT_LANGMAP
    46154622            LANGMAP_ADJUST(nchar, TRUE);
    4616 #endif
    46174623            --no_mapping;
    46184624            --allow_keys;
    46194625#ifdef FEAT_CMDL_INFO
     
    49694975                ++no_mapping;
    49704976                ++allow_keys;   /* no mapping for nchar, but allow key codes */
    49714977                nchar = plain_vgetc();
    4972 #ifdef FEAT_LANGMAP
    49734978                LANGMAP_ADJUST(nchar, TRUE);
    4974 #endif
    49754979                --no_mapping;
    49764980                --allow_keys;
    49774981#ifdef FEAT_CMDL_INFO
     
    54695473                STRCPY(buf, "he! ");
    54705474            else
    54715475            {
     5476                /* An external command will probably use an argument starting
     5477                 * with "-" as an option.  To avoid trouble we skip the "-". */
     5478                while (*ptr == '-' && n > 0)
     5479                {
     5480                    ++ptr;
     5481                    --n;
     5482                }
     5483                if (n == 0)
     5484                {
     5485                    EMSG(_(e_noident));  /* found dashes only */
     5486                    vim_free(buf);
     5487                    return;
     5488                }
     5489
    54725490                /* When a count is given, turn it into a range.  Is this
    54735491                 * really what we want? */
    54745492                isman = (STRCMP(kp, "man") == 0);
     
    55115529    /*
    55125530     * Now grab the chars in the identifier
    55135531     */
    5514     if (cmdchar == '*')
    5515         aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
    5516     else if (cmdchar == '#')
    5517         aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
    5518     else if (cmdchar == 'K' && !kp_help)
    5519         aux_ptr = (char_u *)" \t\\\"|!";
    5520     else
    5521         /* Don't escape spaces and Tabs in a tag with a backslash */
    5522         aux_ptr = (char_u *)"\\|\"";
    5523 
    5524     p = buf + STRLEN(buf);
    5525     while (n-- > 0)
    5526     {
    5527         /* put a backslash before \ and some others */
    5528         if (vim_strchr(aux_ptr, *ptr) != NULL)
    5529             *p++ = '\\';
    5530 #ifdef FEAT_MBYTE
    5531         /* When current byte is a part of multibyte character, copy all bytes
    5532          * of that character. */
    5533         if (has_mbyte)
     5532    if (cmdchar == 'K' && !kp_help)
     5533    {
     5534        /* Escape the argument properly for a shell command */
     5535        ptr = vim_strnsave(ptr, n);
     5536        p = vim_strsave_shellescape(ptr, TRUE);
     5537        vim_free(ptr);
     5538        if (p == NULL)
    55345539        {
    5535             int i;
    5536             int len = (*mb_ptr2len)(ptr) - 1;
    5537 
    5538             for (i = 0; i < len && n >= 1; ++i, --n)
    5539                 *p++ = *ptr++;
     5540            vim_free(buf);
     5541            return;
     5542        }
     5543        buf = (char_u *)vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
     5544        if (buf == NULL)
     5545        {
     5546            vim_free(buf);
     5547            vim_free(p);
     5548            return;
    55405549        }
     5550        STRCAT(buf, p);
     5551        vim_free(p);
     5552    }
     5553    else
     5554    {
     5555        if (cmdchar == '*')
     5556            aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\");
     5557        else if (cmdchar == '#')
     5558            aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\");
     5559        else
     5560            /* Don't escape spaces and Tabs in a tag with a backslash */
     5561            aux_ptr = (char_u *)"\\|\"\n*?[";
     5562
     5563        p = buf + STRLEN(buf);
     5564        while (n-- > 0)
     5565        {
     5566            /* put a backslash before \ and some others */
     5567            if (vim_strchr(aux_ptr, *ptr) != NULL)
     5568                *p++ = '\\';
     5569#ifdef FEAT_MBYTE
     5570            /* When current byte is a part of multibyte character, copy all
     5571             * bytes of that character. */
     5572            if (has_mbyte)
     5573            {
     5574                int i;
     5575                int len = (*mb_ptr2len)(ptr) - 1;
     5576
     5577                for (i = 0; i < len && n >= 1; ++i, --n)
     5578                    *p++ = *ptr++;
     5579            }
    55415580#endif
    5542         *p++ = *ptr++;
     5581            *p++ = *ptr++;
     5582        }
     5583        *p = NUL;
    55435584    }
    5544     *p = NUL;
    55455585
    55465586    /*
    55475587     * Execute the command.
     
    67286768    /* Visual mode "r" */
    67296769    if (VIsual_active)
    67306770    {
     6771        if (got_int)
     6772            reset_VIsual();
    67316773        nv_operator(cap);
    67326774        return;
    67336775    }
     
    77847826        else
    77857827            i = curwin->w_leftcol;
    77867828        /* Go to the middle of the screen line.  When 'number' is on and lines
    7787          * are wrapping the middle can be more to the left.*/
     7829         * are wrapping the middle can be more to the left. */
    77887830        if (cap->nchar == 'm')
    77897831            i += (W_WIDTH(curwin) - curwin_col_off()
    77907832                    + ((curwin->w_p_wrap && i > 0)
  • src/ops.c

    diff -Naur vim72.orig/src/ops.c vim72/src/ops.c
    old new  
    7272 */
    7373struct block_def
    7474{
    75     int         startspaces;    /* 'extra' cols of first char */
    76     int         endspaces;      /* 'extra' cols of first char */
     75    int         startspaces;    /* 'extra' cols before first char */
     76    int         endspaces;      /* 'extra' cols after last char */
    7777    int         textlen;        /* chars in block */
    78     char_u      *textstart;     /* pointer to 1st char in block */
    79     colnr_T     textcol;        /* cols of chars (at least part.) in block */
     78    char_u      *textstart;     /* pointer to 1st char (partially) in block */
     79    colnr_T     textcol;        /* index of chars (partially) in block */
    8080    colnr_T     start_vcol;     /* start col of 1st char wholly inside block */
    8181    colnr_T     end_vcol;       /* start col of 1st char wholly after block */
    8282#ifdef FEAT_VISUALEXTRA
     
    382382{
    383383    int                 left = (oap->op_type == OP_LSHIFT);
    384384    int                 oldstate = State;
    385     int                 total, split;
    386     char_u              *newp, *oldp, *midp, *ptr;
     385    int                 total;
     386    char_u              *newp, *oldp;
    387387    int                 oldcol = curwin->w_cursor.col;
    388388    int                 p_sw = (int)curbuf->b_p_sw;
    389389    int                 p_ts = (int)curbuf->b_p_ts;
    390390    struct block_def    bd;
    391     int                 internal = 0;
    392391    int                 incr;
    393     colnr_T             vcol, col = 0, ws_vcol;
     392    colnr_T             ws_vcol;
    394393    int                 i = 0, j = 0;
    395394    int                 len;
    396395
     
    456455    }
    457456    else /* left */
    458457    {
    459         vcol = oap->start_vcol;
    460         /* walk vcol past ws to be removed */
    461         for (midp = oldp + bd.textcol;
    462               vcol < (oap->start_vcol + total) && vim_iswhite(*midp); )
    463         {
    464             incr = lbr_chartabsize_adv(&midp, (colnr_T)vcol);
    465             vcol += incr;
    466         }
    467         /* internal is the block-internal ws replacing a split TAB */
    468         if (vcol > (oap->start_vcol + total))
    469         {
    470             /* we have to split the TAB *(midp-1) */
    471             internal = vcol - (oap->start_vcol + total);
    472         }
    473         /* if 'expandtab' is not set, use TABs */
     458        colnr_T     destination_col;    /* column to which text in block will
     459                                           be shifted */
     460        char_u      *verbatim_copy_end; /* end of the part of the line which is
     461                                           copied verbatim */
     462        colnr_T     verbatim_copy_width;/* the (displayed) width of this part
     463                                           of line */
     464        unsigned    fill;               /* nr of spaces that replace a TAB */
     465        unsigned    new_line_len;       /* the length of the line after the
     466                                           block shift */
     467        size_t      block_space_width;
     468        size_t      shift_amount;
     469        char_u      *non_white = bd.textstart;
     470        colnr_T     non_white_col;
    474471
    475         split = bd.startspaces + internal;
    476         if (split > 0)
    477         {
    478             if (!curbuf->b_p_et)
    479             {
    480                 for (ptr = oldp, col = 0; ptr < oldp+bd.textcol; )
    481                     col += lbr_chartabsize_adv(&ptr, (colnr_T)col);
     472        /*
     473         * Firstly, let's find the first non-whitespace character that is
     474         * displayed after the block's start column and the character's column
     475         * number. Also, let's calculate the width of all the whitespace
     476         * characters that are displayed in the block and precede the searched
     477         * non-whitespace character.
     478         */
    482479
    483                 /* col+1 now equals the start col of the first char of the
    484                  * block (may be < oap.start_vcol if we're splitting a TAB) */
    485                 i = ((col % p_ts) + split) / p_ts; /* number of tabs */
    486             }
    487             if (i)
    488                 j = ((col % p_ts) + split) % p_ts; /* number of spp */
    489             else
    490                 j = split;
    491         }
     480        /* If "bd.startspaces" is set, "bd.textstart" points to the character,
     481         * the part of which is displayed at the block's beginning. Let's start
     482         * searching from the next character. */
     483        if (bd.startspaces)
     484            mb_ptr_adv(non_white);
    492485
    493         newp = alloc_check(bd.textcol + i + j + (unsigned)STRLEN(midp) + 1);
    494         if (newp == NULL)
    495             return;
    496         vim_memset(newp, NUL, (size_t)(bd.textcol + i + j + STRLEN(midp) + 1));
     486        /* The character's column is in "bd.start_vcol".  */
     487        non_white_col = bd.start_vcol;
    497488
    498         /* copy first part we want to keep */
    499         mch_memmove(newp, oldp, (size_t)bd.textcol);
    500         /* Now copy any TABS and spp to ensure correct alignment! */
    501         while (vim_iswhite(*midp))
     489        while (vim_iswhite(*non_white))
    502490        {
    503             if (*midp == TAB)
    504                 i++;
    505             else /*space */
    506                 j++;
    507             midp++;
     491            incr = lbr_chartabsize_adv(&non_white, non_white_col);
     492            non_white_col += incr;
    508493        }
    509         /* We might have an extra TAB worth of spp now! */
    510         if (j / p_ts && !curbuf->b_p_et)
     494
     495        block_space_width = non_white_col - oap->start_vcol;
     496        /* We will shift by "total" or "block_space_width", whichever is less.
     497         */
     498        shift_amount = (block_space_width < total? block_space_width: total);
     499
     500        /* The column to which we will shift the text.  */
     501        destination_col = non_white_col - shift_amount;
     502
     503        /* Now let's find out how much of the beginning of the line we can
     504         * reuse without modification.  */
     505        verbatim_copy_end = bd.textstart;
     506        verbatim_copy_width = bd.start_vcol;
     507
     508        /* If "bd.startspaces" is set, "bd.textstart" points to the character
     509         * preceding the block. We have to subtract its width to obtain its
     510         * column number.  */
     511        if (bd.startspaces)
     512            verbatim_copy_width -= bd.start_char_vcols;
     513        while (verbatim_copy_width < destination_col)
    511514        {
    512             i++;
    513             j -= p_ts;
     515            incr = lbr_chartabsize(verbatim_copy_end, verbatim_copy_width);
     516            if (verbatim_copy_width + incr > destination_col)
     517                break;
     518            verbatim_copy_width += incr;
     519            mb_ptr_adv(verbatim_copy_end);
    514520        }
    515         copy_chars(newp + bd.textcol, (size_t)i, TAB);
    516         copy_spaces(newp + bd.textcol + i, (size_t)j);
    517521
    518         /* the end */
    519         STRMOVE(newp + STRLEN(newp), midp);
     522        /* If "destination_col" is different from the width of the initial
     523         * part of the line that will be copied, it means we encountered a tab
     524         * character, which we will have to partly replace with spaces.  */
     525        fill = destination_col - verbatim_copy_width;
     526
     527        /* The replacement line will consist of:
     528         * - the beginning of the original line up to "verbatim_copy_end",
     529         * - "fill" number of spaces,
     530         * - the rest of the line, pointed to by non_white.  */
     531        new_line_len = (unsigned)(verbatim_copy_end - oldp)
     532                       + fill
     533                       + (unsigned)STRLEN(non_white) + 1;
     534
     535        newp = alloc_check(new_line_len);
     536        if (newp == NULL)
     537            return;
     538        mch_memmove(newp, oldp, (size_t)(verbatim_copy_end - oldp));
     539        copy_spaces(newp + (verbatim_copy_end - oldp), (size_t)fill);
     540        STRMOVE(newp + (verbatim_copy_end - oldp) + fill, non_white);
    520541    }
    521542    /* replace the line */
    522543    ml_replace(curwin->w_cursor.lnum, newp, FALSE);
     
    22092230    {
    22102231        for (; pos.lnum <= oap->end.lnum; ++pos.lnum)
    22112232        {
     2233            int one_change;
     2234
    22122235            block_prep(oap, &bd, pos.lnum, FALSE);
    22132236            pos.col = bd.textcol;
    2214             did_change = swapchars(oap->op_type, &pos, bd.textlen);
     2237            one_change = swapchars(oap->op_type, &pos, bd.textlen);
     2238            did_change |= one_change;
    22152239
    22162240# ifdef FEAT_NETBEANS_INTG
    2217             if (usingNetbeans && did_change)
     2241            if (usingNetbeans && one_change)
    22182242            {
    22192243                char_u *ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
    22202244
     
    48484872 * - textlen includes the first/last char to be (partly) deleted
    48494873 * - start/endspaces is the number of columns that are taken by the
    48504874 *   first/last deleted char minus the number of columns that have to be
    4851  *   deleted.  for yank and tilde:
     4875 *   deleted.
     4876 * for yank and tilde:
    48524877 * - textlen includes the first/last char to be wholly yanked
    48534878 * - start/endspaces is the number of columns of the first/last yanked char
    48544879 *   that are to be yanked.
  • src/option.c

    diff -Naur vim72.orig/src/option.c vim72/src/option.c
    old new  
    25932593#ifdef FEAT_VIMINFO
    25942594                            (char_u *)&p_viminfo, PV_NONE,
    25952595#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
    2596                             {(char_u *)"", (char_u *)"'20,<50,s10,h,rA:,rB:"}
     2596                            {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
    25972597#else
    25982598# ifdef AMIGA
    25992599                            {(char_u *)"",
    2600                                  (char_u *)"'20,<50,s10,h,rdf0:,rdf1:,rdf2:"}
     2600                                 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
    26012601# else
    2602                             {(char_u *)"", (char_u *)"'20,<50,s10,h"}
     2602                            {(char_u *)"", (char_u *)"'100,<50,s10,h"}
    26032603# endif
    26042604#endif
    26052605#else
     
    41194119                                           && options[opt_idx].var == VAR_WIN)
    41204120                goto skip;
    41214121
    4122             /* Disallow changing some options from modelines */
    4123             if ((opt_flags & OPT_MODELINE) && (flags & P_SECURE))
     4122            /* Disallow changing some options from modelines. */
     4123            if (opt_flags & OPT_MODELINE)
    41244124            {
    4125                 errmsg = (char_u *)_("E520: Not allowed in a modeline");
    4126                 goto skip;
     4125                if (flags & P_SECURE)
     4126                {
     4127                    errmsg = (char_u *)_("E520: Not allowed in a modeline");
     4128                    goto skip;
     4129                }
     4130#ifdef FEAT_DIFF
     4131                /* In diff mode some options are overruled.  This avoids that
     4132                 * 'foldmethod' becomes "marker" instead of "diff" and that
     4133                 * "wrap" gets set. */
     4134                if (curwin->w_p_diff
     4135                        && (options[opt_idx].indir == PV_FDM
     4136                            || options[opt_idx].indir == PV_WRAP))
     4137                    goto skip;
     4138#endif
    41274139            }
    41284140
    41294141#ifdef HAVE_SANDBOX
     
    52685280}
    52695281#endif
    52705282
     5283#ifdef FEAT_TITLE
     5284static void redraw_titles __ARGS((void));
     5285
     5286/*
     5287 * Redraw the window title and/or tab page text later.
     5288 */
     5289static void redraw_titles()
     5290{
     5291    need_maketitle = TRUE;
     5292# ifdef FEAT_WINDOWS
     5293    redraw_tabline = TRUE;
     5294# endif
     5295}
     5296#endif
     5297
    52715298/*
    52725299 * Set a string option to a new value (without checking the effect).
    52735300 * The string is copied into allocated memory.
     
    54075434    int         did_chartab = FALSE;
    54085435    char_u      **gvarp;
    54095436    long_u      free_oldval = (options[opt_idx].flags & P_ALLOCED);
     5437#ifdef FEAT_GUI
     5438    /* set when changing an option that only requires a redraw in the GUI */
     5439    int         redraw_gui_only = FALSE;
     5440#endif
    54105441
    54115442    /* Get the global option to compare with, otherwise we would have to check
    54125443     * two values for all local options. */
     
    56685699            {
    56695700# ifdef FEAT_TITLE
    56705701                /* May show a "+" in the title now. */
    5671                 need_maketitle = TRUE;
     5702                redraw_titles();
    56725703# endif
    56735704                /* Add 'fileencoding' to the swap file. */
    56745705                ml_setflags(curbuf);
     
    56875718            {
    56885719                errmsg = mb_init();
    56895720# ifdef FEAT_TITLE
    5690                 need_maketitle = TRUE;
     5721                redraw_titles();
    56915722# endif
    56925723            }
    56935724        }
     
    57665797        /* load or unload key mapping tables */
    57675798        errmsg = keymap_init();
    57685799
    5769         /* When successfully installed a new keymap switch on using it. */
    5770         if (*curbuf->b_p_keymap != NUL && errmsg == NULL)
     5800        if (errmsg == NULL)
    57715801        {
    5772             curbuf->b_p_iminsert = B_IMODE_LMAP;
    5773             if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
    5774                 curbuf->b_p_imsearch = B_IMODE_LMAP;
    5775             set_iminsert_global();
    5776             set_imsearch_global();
     5802            if (*curbuf->b_p_keymap != NUL)
     5803            {
     5804                /* Installed a new keymap, switch on using it. */
     5805                curbuf->b_p_iminsert = B_IMODE_LMAP;
     5806                if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
     5807                    curbuf->b_p_imsearch = B_IMODE_LMAP;
     5808            }
     5809            else
     5810            {
     5811                /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
     5812                if (curbuf->b_p_iminsert == B_IMODE_LMAP)
     5813                    curbuf->b_p_iminsert = B_IMODE_NONE;
     5814                if (curbuf->b_p_imsearch == B_IMODE_LMAP)
     5815                    curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
     5816            }
     5817            if ((opt_flags & OPT_LOCAL) == 0)
     5818            {
     5819                set_iminsert_global();
     5820                set_imsearch_global();
     5821            }
    57775822# ifdef FEAT_WINDOWS
    57785823            status_redraw_curbuf();
    57795824# endif
     
    57965841            else
    57975842                curbuf->b_p_tx = FALSE;
    57985843#ifdef FEAT_TITLE
    5799             need_maketitle = TRUE;
     5844            redraw_titles();
    58005845#endif
    58015846            /* update flag in swap file */
    58025847            ml_setflags(curbuf);
     
    60556100                    errmsg = (char_u *)N_("E596: Invalid font(s)");
    60566101            }
    60576102        }
     6103        redraw_gui_only = TRUE;
    60586104    }
    60596105# ifdef FEAT_XFONTSET
    60606106    else if (varp == &p_guifontset)
     
    60636109            errmsg = (char_u *)N_("E597: can't select fontset");
    60646110        else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
    60656111            errmsg = (char_u *)N_("E598: Invalid fontset");
     6112        redraw_gui_only = TRUE;
    60666113    }
    60676114# endif
    60686115# ifdef FEAT_MBYTE
     
    60726119            errmsg = (char_u *)N_("E533: can't select wide font");
    60736120        else if (gui_get_wide_font() == FAIL)
    60746121            errmsg = (char_u *)N_("E534: Invalid wide font");
     6122        redraw_gui_only = TRUE;
    60756123    }
    60766124# endif
    60776125#endif
     
    61336181#ifdef FEAT_GUI
    61346182    /* 'guioptions' */
    61356183    else if (varp == &p_go)
     6184    {
    61366185        gui_init_which_components(oldval);
     6186        redraw_gui_only = TRUE;
     6187    }
    61376188#endif
    61386189
    61396190#if defined(FEAT_GUI_TABLINE)
    61406191    /* 'guitablabel' */
    61416192    else if (varp == &p_gtl)
     6193    {
    61426194        redraw_tabline = TRUE;
     6195        redraw_gui_only = TRUE;
     6196    }
     6197    /* 'guitabtooltip' */
     6198    else if (varp == &p_gtt)
     6199    {
     6200        redraw_gui_only = TRUE;
     6201    }
    61436202#endif
    61446203
    61456204#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
     
    67176776
    67186777    if (curwin->w_curswant != MAXCOL)
    67196778        curwin->w_set_curswant = TRUE;  /* in case 'showbreak' changed */
    6720     check_redraw(options[opt_idx].flags);
     6779#ifdef FEAT_GUI
     6780    /* check redraw when it's not a GUI option or the GUI is active. */
     6781    if (!redraw_gui_only || gui.in_use)
     6782#endif
     6783        check_redraw(options[opt_idx].flags);
    67216784
    67226785    return errmsg;
    67236786}
     
    71057168            curbuf->b_did_warn = FALSE;
    71067169
    71077170#ifdef FEAT_TITLE
    7108         need_maketitle = TRUE;
     7171        redraw_titles();
    71097172#endif
    71107173    }
    71117174
    71127175#ifdef FEAT_TITLE
    71137176    /* when 'modifiable' is changed, redraw the window title */
    71147177    else if ((int *)varp == &curbuf->b_p_ma)
    7115         need_maketitle = TRUE;
     7178    {
     7179        redraw_titles();
     7180    }
    71167181    /* when 'endofline' is changed, redraw the window title */
    71177182    else if ((int *)varp == &curbuf->b_p_eol)
    7118         need_maketitle = TRUE;
    7119 #ifdef FEAT_MBYTE
    7120     /* when 'bomb' is changed, redraw the window title */
     7183    {
     7184        redraw_titles();
     7185    }
     7186# ifdef FEAT_MBYTE
     7187    /* when 'bomb' is changed, redraw the window title and tab page text */
    71217188    else if ((int *)varp == &curbuf->b_p_bomb)
    7122         need_maketitle = TRUE;
    7123 #endif
     7189    {
     7190        redraw_titles();
     7191    }
     7192# endif
    71247193#endif
    71257194
    71267195    /* when 'bin' is set also set some other options */
     
    71287197    {
    71297198        set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
    71307199#ifdef FEAT_TITLE
    7131         need_maketitle = TRUE;
     7200        redraw_titles();
    71327201#endif
    71337202    }
    71347203
     
    72797348        if (!value)
    72807349            save_file_ff(curbuf);       /* Buffer is unchanged */
    72817350#ifdef FEAT_TITLE
    7282         need_maketitle = TRUE;
     7351        redraw_titles();
    72837352#endif
    72847353#ifdef FEAT_AUTOCMD
    72857354        modified_was_set = value;
     
    77147783        newFoldLevel();
    77157784    }
    77167785
    7717     /* 'foldminlevel' */
     7786    /* 'foldminlines' */
    77187787    else if (pp == &curwin->w_p_fml)
    77197788    {
    77207789        foldUpdateAll(curwin);
     
    79748043        else /* curwin->w_p_scr > curwin->w_height */
    79758044            curwin->w_p_scr = curwin->w_height;
    79768045    }
     8046    if (p_hi < 0)
     8047    {
     8048        errmsg = e_positive;
     8049        p_hi = 0;
     8050    }
    79778051    if (p_report < 0)
    79788052    {
    79798053        errmsg = e_positive;
     
    82278301            {
    82288302                if (number == 0 && string != NULL)
    82298303                {
    8230                     int index;
     8304                    int idx;
    82318305
    82328306                    /* Either we are given a string or we are setting option
    82338307                     * to zero. */
    8234                     for (index = 0; string[index] == '0'; ++index)
     8308                    for (idx = 0; string[idx] == '0'; ++idx)
    82358309                        ;
    8236                     if (string[index] != NUL || index == 0)
     8310                    if (string[idx] != NUL || idx == 0)
    82378311                    {
    82388312                        /* There's another character after zeros or the string
    82398313                         * is empty.  In both cases, we are trying to set a
     
    83238397    {
    83248398        --arg;                      /* put arg at the '<' */
    83258399        modifiers = 0;
    8326         key = find_special_key(&arg, &modifiers, TRUE);
     8400        key = find_special_key(&arg, &modifiers, TRUE, TRUE);
    83278401        if (modifiers)              /* can't handle modifiers here */
    83288402            key = 0;
    83298403    }
     
    1009310167
    1009410168#ifdef FEAT_LANGMAP
    1009510169/*
    10096  * Any character has an equivalent character.  This is used for keyboards that
    10097  * have a special language mode that sends characters above 128 (although
    10098  * other characters can be translated too).
     10170 * Any character has an equivalent 'langmap' character.  This is used for
     10171 * keyboards that have a special language mode that sends characters above
     10172 * 128 (although other characters can be translated too).  The "to" field is a
     10173 * Vim command character.  This avoids having to switch the keyboard back to
     10174 * ASCII mode when leaving Insert mode.
     10175 *
     10176 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
     10177 * commands.
     10178 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
     10179 * langmap_entry_T.  This does the same as langmap_mapchar[] for characters >=
     10180 * 256.
    1009910181 */
     10182# ifdef FEAT_MBYTE
     10183/*
     10184 * With multi-byte support use growarray for 'langmap' chars >= 256
     10185 */
     10186typedef struct
     10187{
     10188    int     from;
     10189    int     to;
     10190} langmap_entry_T;
     10191
     10192static garray_T langmap_mapga;
     10193static void langmap_set_entry __ARGS((int from, int to));
    1010010194
    1010110195/*
    10102  * char_u langmap_mapchar[256];
    10103  * Normally maps each of the 128 upper chars to an <128 ascii char; used to
    10104  * "translate" native lang chars in normal mode or some cases of
    10105  * insert mode without having to tediously switch lang mode back&forth.
     10196 * Search for an entry in "langmap_mapga" for "from".  If found set the "to"
     10197 * field.  If not found insert a new entry at the appropriate location.
    1010610198 */
     10199    static void
     10200langmap_set_entry(from, to)
     10201    int    from;
     10202    int    to;
     10203{
     10204    langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
     10205    int             a = 0;
     10206    int             b = langmap_mapga.ga_len;
     10207
     10208    /* Do a binary search for an existing entry. */
     10209    while (a != b)
     10210    {
     10211        int i = (a + b) / 2;
     10212        int d = entries[i].from - from;
     10213
     10214        if (d == 0)
     10215        {
     10216            entries[i].to = to;
     10217            return;
     10218        }
     10219        if (d < 0)
     10220            a = i + 1;
     10221        else
     10222            b = i;
     10223    }
     10224
     10225    if (ga_grow(&langmap_mapga, 1) != OK)
     10226        return;  /* out of memory */
     10227
     10228    /* insert new entry at position "a" */
     10229    entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
     10230    mch_memmove(entries + 1, entries,
     10231                        (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
     10232    ++langmap_mapga.ga_len;
     10233    entries[0].from = from;
     10234    entries[0].to = to;
     10235}
     10236
     10237/*
     10238 * Apply 'langmap' to multi-byte character "c" and return the result.
     10239 */
     10240    int
     10241langmap_adjust_mb(c)
     10242    int c;
     10243{
     10244    langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
     10245    int a = 0;
     10246    int b = langmap_mapga.ga_len;
     10247
     10248    while (a != b)
     10249    {
     10250        int i = (a + b) / 2;
     10251        int d = entries[i].from - c;
     10252
     10253        if (d == 0)
     10254            return entries[i].to;  /* found matching entry */
     10255        if (d < 0)
     10256            a = i + 1;
     10257        else
     10258            b = i;
     10259    }
     10260    return c;  /* no entry found, return "c" unmodified */
     10261}
     10262# endif
    1010710263
    1010810264    static void
    1010910265langmap_init()
    1011010266{
    1011110267    int i;
    1011210268
    10113     for (i = 0; i < 256; i++)           /* we init with a-one-to one map */
    10114         langmap_mapchar[i] = i;
     10269    for (i = 0; i < 256; i++)
     10270        langmap_mapchar[i] = i;  /* we init with a one-to-one map */
     10271# ifdef FEAT_MBYTE
     10272    ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
     10273# endif
    1011510274}
    1011610275
    1011710276/*
     
    1012510284    char_u  *p2;
    1012610285    int     from, to;
    1012710286
    10128     langmap_init();                         /* back to one-to-one map first */
     10287#ifdef FEAT_MBYTE
     10288    ga_clear(&langmap_mapga);               /* clear the previous map first */
     10289#endif
     10290    langmap_init();                         /* back to one-to-one map */
    1012910291
    1013010292    for (p = p_langmap; p[0] != NUL; )
    1013110293    {
     
    1017510337                                                             transchar(from));
    1017610338                return;
    1017710339            }
    10178             langmap_mapchar[from & 255] = to;
     10340
     10341#ifdef FEAT_MBYTE
     10342            if (from >= 256)
     10343                langmap_set_entry(from, to);
     10344            else
     10345#endif
     10346                langmap_mapchar[from & 255] = to;
    1017910347
    1018010348            /* Advance to next pair */
    1018110349            mb_ptr_adv(p);
  • src/os_unix.c

    diff -Naur vim72.orig/src/os_unix.c vim72/src/os_unix.c
    old new  
    181181        && defined(FEAT_TITLE) && !defined(FEAT_GUI_GTK)
    182182# define SET_SIG_ALARM
    183183static RETSIGTYPE sig_alarm __ARGS(SIGPROTOARG);
    184 static int sig_alarm_called;
     184/* volatile because it is used in signal handler sig_alarm(). */
     185static volatile int sig_alarm_called;
    185186#endif
    186187static RETSIGTYPE deathtrap __ARGS(SIGPROTOARG);
    187188
     
    201202# define SIG_ERR        ((RETSIGTYPE (*)())-1)
    202203#endif
    203204
    204 static int      do_resize = FALSE;
     205/* volatile because it is used in signal handler sig_winch(). */
     206static volatile int do_resize = FALSE;
    205207#ifndef __EMX__
    206208static char_u   *extra_shell_arg = NULL;
    207209static int      show_shell_mess = TRUE;
    208210#endif
    209 static int      deadly_signal = 0;          /* The signal we caught */
    210 static int      in_mch_delay = FALSE;       /* sleeping in mch_delay() */
     211/* volatile because it is used in signal handler deathtrap(). */
     212static volatile int deadly_signal = 0;      /* The signal we caught */
     213/* volatile because it is used in signal handler deathtrap(). */
     214static volatile int in_mch_delay = FALSE;    /* sleeping in mch_delay() */
    211215
    212216static int curr_tmode = TMODE_COOK;     /* contains current terminal mode */
    213217
     
    315319    {-1,            "Unknown!", FALSE}
    316320};
    317321
     322/*
     323 * Write s[len] to the screen.
     324 */
    318325    void
    319326mch_write(s, len)
    320327    char_u      *s;
    321328    int         len;
    322329{
    323     write(1, (char *)s, len);
     330    ignored = (int)write(1, (char *)s, len);
    324331    if (p_wd)           /* Unix is too fast, slow down a bit more */
    325332        RealWaitForChar(read_cmd_fd, p_wd, NULL);
    326333}
     
    799806#endif
    800807
    801808/*
    802  * We need correct potatotypes for a signal function, otherwise mean compilers
     809 * We need correct prototypes for a signal function, otherwise mean compilers
    803810 * will barf when the second argument to signal() is ``wrong''.
    804811 * Let me try it with a few tricky defines from my own osdef.h  (jw).
    805812 */
     
    10651072    SIGRETURN;
    10661073}
    10671074
    1068 #ifdef _REENTRANT
     1075#if defined(_REENTRANT) && defined(SIGCONT)
    10691076/*
    10701077 * On Solaris with multi-threading, suspending might not work immediately.
    10711078 * Catch the SIGCONT signal, which will be used as an indication whether the
    10721079 * suspending has been done or not.
     1080 *
     1081 * On Linux, signal is not always handled immediately either.
     1082 * See https://bugs.launchpad.net/bugs/291373
     1083 *
     1084 * volatile because it is used in in signal handler sigcont_handler().
    10731085 */
    1074 static int sigcont_received;
     1086static volatile int sigcont_received;
    10751087static RETSIGTYPE sigcont_handler __ARGS(SIGPROTOARG);
    10761088
    10771089/*
     
    11151127    }
    11161128# endif
    11171129
    1118 # ifdef _REENTRANT
     1130# if defined(_REENTRANT) && defined(SIGCONT)
    11191131    sigcont_received = FALSE;
    11201132# endif
    11211133    kill(0, SIGTSTP);       /* send ourselves a STOP signal */
    1122 # ifdef _REENTRANT
    1123     /* When we didn't suspend immediately in the kill(), do it now.  Happens
    1124      * on multi-threaded Solaris. */
    1125     if (!sigcont_received)
    1126         pause();
     1134# if defined(_REENTRANT) && defined(SIGCONT)
     1135    /*
     1136     * Wait for the SIGCONT signal to be handled. It generally happens
     1137     * immediately, but somehow not all the time. Do not call pause()
     1138     * because there would be race condition which would hang Vim if
     1139     * signal happened in between the test of sigcont_received and the
     1140     * call to pause(). If signal is not yet received, call sleep(0)
     1141     * to just yield CPU. Signal should then be received. If somehow
     1142     * it's still not received, sleep 1, 2, 3 ms. Don't bother waiting
     1143     * further if signal is not received after 1+2+3+4 ms (not expected
     1144     * to happen).
     1145     */
     1146    {
     1147        long wait;
     1148        for (wait = 0; !sigcont_received && wait <= 3L; wait++)
     1149            /* Loop is not entered most of the time */
     1150            mch_delay(wait, FALSE);
     1151    }
    11271152# endif
    11281153
    11291154# ifdef FEAT_TITLE
     
    11721197#ifdef SIGTSTP
    11731198    signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
    11741199#endif
    1175 #ifdef _REENTRANT
     1200#if defined(_REENTRANT) && defined(SIGCONT)
    11761201    signal(SIGCONT, sigcont_handler);
    11771202#endif
    11781203
     
    12311256reset_signals()
    12321257{
    12331258    catch_signals(SIG_DFL, SIG_DFL);
    1234 #ifdef _REENTRANT
     1259#if defined(_REENTRANT) && defined(SIGCONT)
    12351260    /* SIGCONT isn't in the list, because its default action is ignore */
    12361261    signal(SIGCONT, SIG_DFL);
    12371262#endif
     
    29052930     * Ignore any errors.
    29062931     */
    29072932#if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
    2908     signal_stack = malloc(SIGSTKSZ);
     2933    signal_stack = (char *)alloc(SIGSTKSZ);
    29092934    init_signal_stack();
    29102935#endif
    29112936}
     
    29362961    }
    29372962#  endif
    29382963# endif
    2939 # ifdef FEAT_X11
     2964    /* Don't close the display for GTK 1, it is done in exit(). */
     2965# if defined(FEAT_X11) && (!defined(FEAT_GUI_GTK) || defined(HAVE_GTK2))
    29402966    if (x11_display != NULL
    29412967#  ifdef FEAT_XCLIPBOARD
    29422968            && x11_display != xterm_dpy
     
    39263952                 */
    39273953                if (fd >= 0)
    39283954                {
    3929                     dup(fd); /* To replace stdin  (file descriptor 0) */
    3930                     dup(fd); /* To replace stdout (file descriptor 1) */
    3931                     dup(fd); /* To replace stderr (file descriptor 2) */
     3955                    ignored = dup(fd); /* To replace stdin  (fd 0) */
     3956                    ignored = dup(fd); /* To replace stdout (fd 1) */
     3957                    ignored = dup(fd); /* To replace stderr (fd 2) */
    39323958
    39333959                    /* Don't need this now that we've duplicated it */
    39343960                    close(fd);
     
    39463972                 * children can be kill()ed.  Don't do this when using pipes,
    39473973                 * because stdin is not a tty, we would lose /dev/tty. */
    39483974                if (p_stmp)
     3975                {
    39493976                    (void)setsid();
     3977#  if defined(SIGHUP)
     3978                    /* When doing "!xterm&" and 'shell' is bash: the shell
     3979                     * will exit and send SIGHUP to all processes in its
     3980                     * group, killing the just started process.  Ignore SIGHUP
     3981                     * to avoid that. (suggested by Simon Schubert)
     3982                     */
     3983                    signal(SIGHUP, SIG_IGN);
     3984#  endif
     3985                }
    39503986# endif
    39513987# ifdef FEAT_GUI
    39523988                if (pty_slave_fd >= 0)
     
    39964032
    39974033                    /* set up stdin/stdout/stderr for the child */
    39984034                    close(0);
    3999                     dup(pty_slave_fd);
     4035                    ignored = dup(pty_slave_fd);
    40004036                    close(1);
    4001                     dup(pty_slave_fd);
     4037                    ignored = dup(pty_slave_fd);
    40024038                    if (gui.in_use)
    40034039                    {
    40044040                        close(2);
    4005                         dup(pty_slave_fd);
     4041                        ignored = dup(pty_slave_fd);
    40064042                    }
    40074043
    40084044                    close(pty_slave_fd);    /* has been dupped, close it now */
     
    40134049                    /* set up stdin for the child */
    40144050                    close(fd_toshell[1]);
    40154051                    close(0);
    4016                     dup(fd_toshell[0]);
     4052                    ignored = dup(fd_toshell[0]);
    40174053                    close(fd_toshell[0]);
    40184054
    40194055                    /* set up stdout for the child */
    40204056                    close(fd_fromshell[0]);
    40214057                    close(1);
    4022                     dup(fd_fromshell[1]);
     4058                    ignored = dup(fd_fromshell[1]);
    40234059                    close(fd_fromshell[1]);
    40244060
    40254061# ifdef FEAT_GUI
     
    40274063                    {
    40284064                        /* set up stderr for the child */
    40294065                        close(2);
    4030                         dup(1);
     4066                        ignored = dup(1);
    40314067                    }
    40324068# endif
    40334069                }
     
    40784114                int         fromshell_fd;
    40794115                garray_T    ga;
    40804116                int         noread_cnt;
     4117# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
     4118                struct timeval  start_tv;
     4119# endif
    40814120
    40824121# ifdef FEAT_GUI
    40834122                if (pty_master_fd >= 0)
     
    41584197                                            && (lnum !=
    41594198                                                    curbuf->b_ml.ml_line_count
    41604199                                                    || curbuf->b_p_eol)))
    4161                                     write(toshell_fd, "\n", (size_t)1);
     4200                                    ignored = write(toshell_fd, "\n",
     4201                                                                   (size_t)1);
    41624202                                ++lnum;
    41634203                                if (lnum > curbuf->b_op_end.lnum)
    41644204                                {
     
    41864226                    ga_init2(&ga, 1, BUFLEN);
    41874227
    41884228                noread_cnt = 0;
    4189 
     4229# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
     4230                gettimeofday(&start_tv, NULL);
     4231# endif
    41904232                for (;;)
    41914233                {
    41924234                    /*
     
    41994241                     * that a typed password is echoed for ssh or gpg command.
    42004242                     * Don't get characters when the child has already
    42014243                     * finished (wait_pid == 0).
    4202                      * Don't get extra characters when we already have one.
    42034244                     * Don't read characters unless we didn't get output for a
    4204                      * while, avoids that ":r !ls" eats typeahead.
     4245                     * while (noread_cnt > 4), avoids that ":r !ls" eats
     4246                     * typeahead.
    42054247                     */
    42064248                    len = 0;
    42074249                    if (!(options & SHELL_EXPAND)
    42084250                            && ((options &
    42094251                                         (SHELL_READ|SHELL_WRITE|SHELL_COOKED))
    42104252                                      != (SHELL_READ|SHELL_WRITE|SHELL_COOKED)
    4211 #ifdef FEAT_GUI
     4253# ifdef FEAT_GUI
    42124254                                                    || gui.in_use
    4213 #endif
     4255# endif
    42144256                                                    )
    42154257                            && wait_pid == 0
    4216                             && (ta_len > 0
    4217                                 || (noread_cnt > 4
    4218                                     && (len = ui_inchar(ta_buf,
    4219                                                        BUFLEN, 10L, 0)) > 0)))
     4258                            && (ta_len > 0 || noread_cnt > 4))
    42204259                    {
     4260                      if (ta_len == 0)
     4261                      {
     4262                          /* Get extra characters when we don't have any.
     4263                           * Reset the counter and timer. */
     4264                          noread_cnt = 0;
     4265# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
     4266                          gettimeofday(&start_tv, NULL);
     4267# endif
     4268                          len = ui_inchar(ta_buf, BUFLEN, 10L, 0);
     4269                      }
     4270                      if (ta_len > 0 || len > 0)
     4271                      {
    42214272                        /*
    42224273                         * For pipes:
    42234274                         * Check for CTRL-C: send interrupt signal to child.
     
    43194370                            {
    43204371                                ta_len -= len;
    43214372                                mch_memmove(ta_buf, ta_buf + len, ta_len);
    4322                                 noread_cnt = 0;
    43234373                            }
    43244374                        }
     4375                      }
    43254376                    }
    43264377
    43274378                    if (got_int)
     
    44294480                        out_flush();
    44304481                        if (got_int)
    44314482                            break;
     4483
     4484# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H)
     4485                        {
     4486                            struct timeval  now_tv;
     4487                            long            msec;
     4488
     4489                            /* Avoid that we keep looping here without
     4490                             * checking for a CTRL-C for a long time.  Don't
     4491                             * break out too often to avoid losing typeahead. */
     4492                            gettimeofday(&now_tv, NULL);
     4493                            msec = (now_tv.tv_sec - start_tv.tv_sec) * 1000L
     4494                                + (now_tv.tv_usec - start_tv.tv_usec) / 1000L;
     4495                            if (msec > 2000)
     4496                            {
     4497                                noread_cnt = 5;
     4498                                break;
     4499                            }
     4500                        }
     4501# endif
    44324502                    }
    44334503
    44344504                    /* If we already detected the child has finished break the
     
    58515921             * we are going to suspend or starting an external process
    58525922             * so we shouldn't  have problem with this
    58535923             */
     5924# ifdef SIGTSTP
    58545925            signal(SIGTSTP, restricted ? SIG_IGN : SIG_DFL);
     5926# endif
    58555927            return 1; /* succeed */
    58565928        }
    58575929        if (gpm_fd == -2)
     
    68146886    if (xsmp_icefd != -1)
    68156887    {
    68166888        SmcCloseConnection(xsmp.smcconn, 0, NULL);
    6817         vim_free(xsmp.clientid);
     6889        if (xsmp.clientid != NULL)
     6890            free(xsmp.clientid);
    68186891        xsmp.clientid = NULL;
    68196892        xsmp_icefd = -1;
    68206893    }
  • src/proto/eval.pro

    diff -Naur vim72.orig/src/proto/eval.pro vim72/src/proto/eval.pro
    old new  
    1717int eval_to_bool __ARGS((char_u *arg, int *error, char_u **nextcmd, int skip));
    1818char_u *eval_to_string_skip __ARGS((char_u *arg, char_u **nextcmd, int skip));
    1919int skip_expr __ARGS((char_u **pp));
    20 char_u *eval_to_string __ARGS((char_u *arg, char_u **nextcmd, int dolist));
     20char_u *eval_to_string __ARGS((char_u *arg, char_u **nextcmd, int convert));
    2121char_u *eval_to_string_safe __ARGS((char_u *arg, char_u **nextcmd, int use_sandbox));
    2222int eval_to_number __ARGS((char_u *expr));
    2323list_T *eval_spell_expr __ARGS((char_u *badword, char_u *expr));
     
    4646void list_unref __ARGS((list_T *l));
    4747void list_free __ARGS((list_T *l, int recurse));
    4848dictitem_T *dict_lookup __ARGS((hashitem_T *hi));
     49char_u *list_find_str __ARGS((list_T *l, long idx));
    4950int list_append_dict __ARGS((list_T *list, dict_T *dict));
     51int list_append_string __ARGS((list_T *l, char_u *str, int len));
    5052int garbage_collect __ARGS((void));
    5153dict_T *dict_alloc __ARGS((void));
    5254int dict_add_nr_str __ARGS((dict_T *d, char *key, long nr, char_u *str));
     
    5860void set_vim_var_nr __ARGS((int idx, long val));
    5961long get_vim_var_nr __ARGS((int idx));
    6062char_u *get_vim_var_str __ARGS((int idx));
    61 void set_vcount __ARGS((long count, long count1));
     63list_T *get_vim_var_list __ARGS((int idx));
     64void set_vcount __ARGS((long count, long count1, int set_prevcount));
    6265void set_vim_var_string __ARGS((int idx, char_u *val, int len));
     66void set_vim_var_list __ARGS((int idx, list_T *val));
    6367void set_reg_var __ARGS((int c));
    6468char_u *v_exception __ARGS((char_u *oldval));
    6569char_u *v_throwpoint __ARGS((char_u *oldval));
     
    9498void write_viminfo_varlist __ARGS((FILE *fp));
    9599int store_session_globals __ARGS((FILE *fd));
    96100void last_set_msg __ARGS((scid_T scriptID));
     101void ex_oldfiles __ARGS((exarg_T *eap));
    97102int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen));
    98103char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));
    99104/* vim: set ft=c : */
  • src/proto/ex_cmds.pro

    diff -Naur vim72.orig/src/proto/ex_cmds.pro vim72/src/proto/ex_cmds.pro
    old new  
    1111char_u *make_filter_cmd __ARGS((char_u *cmd, char_u *itmp, char_u *otmp));
    1212void append_redir __ARGS((char_u *buf, char_u *opt, char_u *fname));
    1313int viminfo_error __ARGS((char *errnum, char *message, char_u *line));
    14 int read_viminfo __ARGS((char_u *file, int want_info, int want_marks, int forceit));
     14int read_viminfo __ARGS((char_u *file, int flags));
    1515void write_viminfo __ARGS((char_u *file, int forceit));
    1616int viminfo_readline __ARGS((vir_T *virp));
    1717char_u *viminfo_readstring __ARGS((vir_T *virp, int off, int convert));
     
    4040int read_viminfo_sub_string __ARGS((vir_T *virp, int force));
    4141void write_viminfo_sub_string __ARGS((FILE *fp));
    4242void free_old_sub __ARGS((void));
     43void free_signs __ARGS((void));
    4344int prepare_tagpreview __ARGS((int undo_sync));
    4445void ex_help __ARGS((exarg_T *eap));
    4546char_u *check_help_lang __ARGS((char_u *arg));
  • src/proto/ex_getln.pro

    diff -Naur vim72.orig/src/proto/ex_getln.pro vim72/src/proto/ex_getln.pro
    old new  
    44int text_locked __ARGS((void));
    55void text_locked_msg __ARGS((void));
    66int curbuf_locked __ARGS((void));
     7int allbuf_locked __ARGS((void));
    78char_u *getexline __ARGS((int c, void *dummy, int indent));
    89char_u *getexmodeline __ARGS((int promptc, void *dummy, int indent));
    910int cmdline_overstrike __ARGS((void));
     
    3132void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col));
    3233int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches));
    3334int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int))));
    34 char_u *globpath __ARGS((char_u *path, char_u *file));
     35char_u *globpath __ARGS((char_u *path, char_u *file, int expand_options));
    3536void init_history __ARGS((void));
    3637int get_histtype __ARGS((char_u *name));
    3738void add_to_history __ARGS((int histype, char_u *new_entry, int in_map, int sep));
  • src/proto/mark.pro

    diff -Naur vim72.orig/src/proto/mark.pro vim72/src/proto/mark.pro
    old new  
    2626void write_viminfo_filemarks __ARGS((FILE *fp));
    2727int removable __ARGS((char_u *name));
    2828int write_viminfo_marks __ARGS((FILE *fp_out));
    29 void copy_viminfo_marks __ARGS((vir_T *virp, FILE *fp_out, int count, int eof));
     29void copy_viminfo_marks __ARGS((vir_T *virp, FILE *fp_out, int count, int eof, int flags));
    3030/* vim: set ft=c : */
  • src/proto/misc2.pro

    diff -Naur vim72.orig/src/proto/misc2.pro vim72/src/proto/misc2.pro
    old new  
    5959int handle_x_keys __ARGS((int key));
    6060char_u *get_special_key_name __ARGS((int c, int modifiers));
    6161int trans_special __ARGS((char_u **srcp, char_u *dst, int keycode));
    62 int find_special_key __ARGS((char_u **srcp, int *modp, int keycode));
     62int find_special_key __ARGS((char_u **srcp, int *modp, int keycode, int keep_x_key));
    6363int extract_modifiers __ARGS((int key, int *modp));
    6464int find_special_key_in_table __ARGS((int c));
    6565int get_special_key_code __ARGS((char_u *name));
  • src/proto/netbeans.pro

    diff -Naur vim72.orig/src/proto/netbeans.pro vim72/src/proto/netbeans.pro
    old new  
    1111void netbeans_frame_moved __ARGS((int new_x, int new_y));
    1212void netbeans_file_activated __ARGS((buf_T *bufp));
    1313void netbeans_file_opened __ARGS((buf_T *bufp));
    14 void netbeans_file_closed __ARGS((buf_T *bufp));
     14void netbeans_file_killed __ARGS((buf_T *bufp));
    1515void netbeans_inserted __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, char_u *txt, int newlen));
    1616void netbeans_removed __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, long len));
    1717void netbeans_unmodified __ARGS((buf_T *bufp));
  • src/proto/option.pro

    diff -Naur vim72.orig/src/proto/option.pro vim72/src/proto/option.pro
    old new  
    4444void set_context_in_set_cmd __ARGS((expand_T *xp, char_u *arg, int opt_flags));
    4545int ExpandSettings __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
    4646int ExpandOldSetting __ARGS((int *num_file, char_u ***file));
     47int langmap_adjust_mb __ARGS((int c));
    4748int has_format_option __ARGS((int x));
    4849int shortmess __ARGS((int x));
    4950void vimrc_found __ARGS((char_u *fname, char_u *envname));
  • src/pty.c

    diff -Naur vim72.orig/src/pty.c vim72/src/pty.c
    old new  
    270270}
    271271#endif
    272272
    273 #if defined(HAVE_SVR4_PTYS) && !defined(PTY_DONE) && !defined(hpux)
     273#if defined(HAVE_SVR4_PTYS) && !defined(PTY_DONE) && !defined(hpux) && !defined(MACOS_X)
    274274
    275 /* NOTE: Even though HPUX can have /dev/ptmx, the code below doesn't work! */
     275/* NOTE: Even though HPUX can have /dev/ptmx, the code below doesn't work!
     276 * Same for Mac OS X Leopard. */
    276277#define PTY_DONE
    277278    int
    278279OpenPTY(ttyn)
  • src/quickfix.c

    diff -Naur vim72.orig/src/quickfix.c vim72/src/quickfix.c
    old new  
    14191419    int                 opened_window = FALSE;
    14201420    win_T               *win;
    14211421    win_T               *altwin;
     1422    int                 flags;
    14221423#endif
    14231424    int                 print_message = TRUE;
    14241425    int                 len;
     
    15301531    if (qf_ptr->qf_type == 1 && (!curwin->w_buffer->b_help || cmdmod.tab != 0))
    15311532    {
    15321533        win_T   *wp;
    1533         int     n;
    15341534
    15351535        if (cmdmod.tab != 0)
    15361536            wp = NULL;
     
    15461546             * Split off help window; put it at far top if no position
    15471547             * specified, the current window is vertically split and narrow.
    15481548             */
    1549             n = WSP_HELP;
     1549            flags = WSP_HELP;
    15501550# ifdef FEAT_VERTSPLIT
    15511551            if (cmdmod.split == 0 && curwin->w_width != Columns
    15521552                                                      && curwin->w_width < 80)
    1553                 n |= WSP_TOP;
     1553                flags |= WSP_TOP;
    15541554# endif
    1555             if (win_split(0, n) == FAIL)
     1555            if (qi != &ql_info)
     1556                flags |= WSP_NEWLOC;  /* don't copy the location list */
     1557
     1558            if (win_split(0, flags) == FAIL)
    15561559                goto theend;
    15571560            opened_window = TRUE;       /* close it when fail */
    15581561
     
    15621565            if (qi != &ql_info)     /* not a quickfix list */
    15631566            {
    15641567                /* The new window should use the supplied location list */
    1565                 qf_free_all(curwin);
    15661568                curwin->w_llist = qi;
    15671569                qi->qf_refcount++;
    15681570            }
     
    16091611                {
    16101612                    goto_tabpage_win(tp, wp);
    16111613                    usable_win = 1;
    1612                     break;
     1614                    goto win_found;
    16131615                }
    16141616            }
    16151617        }
     1618win_found:
    16161619
    16171620        /*
    16181621         * If there is only one window and it is the quickfix window, create a
     
    16221625        {
    16231626            ll_ref = curwin->w_llist_ref;
    16241627
    1625             if (win_split(0, WSP_ABOVE) == FAIL)
     1628            flags = WSP_ABOVE;
     1629            if (ll_ref != NULL)
     1630                flags |= WSP_NEWLOC;
     1631            if (win_split(0, flags) == FAIL)
    16261632                goto failed;            /* not enough room for window */
    16271633            opened_window = TRUE;       /* close it when fail */
    16281634            p_swb = empty_option;       /* don't split again */
     
    16341640            {
    16351641                /* The new window should use the location list from the
    16361642                 * location list window */
    1637                 qf_free_all(curwin);
    16381643                curwin->w_llist = ll_ref;
    16391644                ll_ref->qf_refcount++;
    16401645            }
     
    23072312        if (eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow)
    23082313            /* Create the new window at the very bottom. */
    23092314            win_goto(lastwin);
    2310         if (win_split(height, WSP_BELOW) == FAIL)
     2315        if (win_split(height, WSP_BELOW | WSP_NEWLOC) == FAIL)
    23112316            return;             /* not enough room for window */
    23122317#ifdef FEAT_SCROLLBIND
    23132318        curwin->w_p_scb = FALSE;
    23142319#endif
    23152320
    2316         /* Remove the location list for the quickfix window */
    2317         qf_free_all(curwin);
    2318 
    23192321        if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
    23202322        {
    23212323            /*
  • src/regexp.c

    diff -Naur vim72.orig/src/regexp.c vim72/src/regexp.c
    old new  
    45324532                cleanup_subexpr();
    45334533                if (!REG_MULTI)         /* Single-line regexp */
    45344534                {
    4535                     if (reg_endp[no] == NULL)
     4535                    if (reg_startp[no] == NULL || reg_endp[no] == NULL)
    45364536                    {
    45374537                        /* Backref was not set: Match an empty string. */
    45384538                        len = 0;
     
    45484548                }
    45494549                else                            /* Multi-line regexp */
    45504550                {
    4551                     if (reg_endpos[no].lnum < 0)
     4551                    if (reg_startpos[no].lnum < 0 || reg_endpos[no].lnum < 0)
    45524552                    {
    45534553                        /* Backref was not set: Match an empty string. */
    45544554                        len = 0;
     
    72797279    }
    72807280    else
    72817281    {
    7282         if (submatch_match->endp[no] == NULL)
     7282        s = submatch_match->startp[no];
     7283        if (s == NULL || submatch_match->endp[no] == NULL)
    72837284            retval = NULL;
    72847285        else
    7285         {
    7286             s = submatch_match->startp[no];
    72877286            retval = vim_strnsave(s, (int)(submatch_match->endp[no] - s));
    7288         }
    72897287    }
    72907288
    72917289    return retval;
  • src/screen.c

    diff -Naur vim72.orig/src/screen.c vim72/src/screen.c
    old new  
    24392439
    24402440#ifdef FEAT_SYN_HL
    24412441    /* Show 'cursorcolumn' in the fold line. */
    2442     if (wp->w_p_cuc && (int)wp->w_virtcol + txtcol < W_WIDTH(wp))
    2443         ScreenAttrs[off + wp->w_virtcol + txtcol] = hl_combine_attr(
    2444                  ScreenAttrs[off + wp->w_virtcol + txtcol], hl_attr(HLF_CUC));
     2442    if (wp->w_p_cuc)
     2443    {
     2444        txtcol += wp->w_virtcol;
     2445        if (wp->w_p_wrap)
     2446            txtcol -= wp->w_skipcol;
     2447        else
     2448            txtcol -= wp->w_leftcol;
     2449        if (txtcol >= 0 && txtcol < W_WIDTH(wp))
     2450            ScreenAttrs[off + txtcol] = hl_combine_attr(
     2451                                 ScreenAttrs[off + txtcol], hl_attr(HLF_CUC));
     2452    }
    24452453#endif
    24462454
    24472455    SCREEN_LINE(row + W_WINROW(wp), W_WINCOL(wp), (int)W_WIDTH(wp),
     
    25882596    int         noinvcur = FALSE;       /* don't invert the cursor */
    25892597#ifdef FEAT_VISUAL
    25902598    pos_T       *top, *bot;
     2599    int         lnum_in_visual_area = FALSE;
    25912600#endif
    25922601    pos_T       pos;
    25932602    long        v;
     
    27842793            top = &VIsual;
    27852794            bot = &curwin->w_cursor;
    27862795        }
     2796        lnum_in_visual_area = (lnum >= top->lnum && lnum <= bot->lnum);
    27872797        if (VIsual_mode == Ctrl_V)      /* block mode */
    27882798        {
    2789             if (lnum >= top->lnum && lnum <= bot->lnum)
     2799            if (lnum_in_visual_area)
    27902800            {
    27912801                fromcol = wp->w_old_cursor_fcol;
    27922802                tocol = wp->w_old_cursor_lcol;
     
    34123422                        && (*mb_ptr2cells)(ptr) > 1)
    34133423#endif
    34143424                    || ((int)vcol_prev == fromcol_prev
     3425                        && vcol_prev < vcol     /* not at margin */
    34153426                        && vcol < tocol))
    34163427                area_attr = attr;               /* start highlighting */
    34173428            else if (area_attr != 0
     
    35443555                /* Use line_attr when not in the Visual or 'incsearch' area
    35453556                 * (area_attr may be 0 when "noinvcur" is set). */
    35463557            else if (line_attr != 0 && ((fromcol == -10 && tocol == MAXCOL)
    3547                                         || (vcol < fromcol || vcol >= tocol)))
     3558                                || vcol < fromcol || vcol_prev < fromcol_prev
     3559                                || vcol >= tocol))
    35483560                char_attr = line_attr;
    35493561#endif
    35503562            else
     
    45494561         * highlight the cursor position itself. */
    45504562        if (wp->w_p_cuc && vcol == (long)wp->w_virtcol
    45514563                && lnum != wp->w_cursor.lnum
    4552                 && draw_state == WL_LINE)
     4564                && draw_state == WL_LINE
     4565                && !lnum_in_visual_area)
    45534566        {
    45544567            vcol_save_attr = char_attr;
    45554568            char_attr = hl_combine_attr(char_attr, hl_attr(HLF_CUC));
     
    51195132#endif
    51205133
    51215134#if defined(FEAT_GUI) || defined(UNIX)
    5122             /* The bold trick makes a single row of pixels appear in the next
    5123              * character.  When a bold character is removed, the next
     5135            /* The bold trick makes a single column of pixels appear in the
     5136             * next character.  When a bold character is removed, the next
    51245137             * character should be redrawn too.  This happens for our own GUI
    51255138             * and for some xterms. */
    51265139            if (
     
    62636276    int         pcc[MAX_MCO];
    62646277# endif
    62656278#endif
     6279#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
     6280    int         force_redraw_this;
     6281    int         force_redraw_next = FALSE;
     6282#endif
     6283    int         need_redraw;
    62666284
    62676285    if (ScreenLines == NULL || row >= screen_Rows)      /* safety check */
    62686286        return;
     6287    off = LineOffset[row] + col;
    62696288
    62706289#ifdef FEAT_MBYTE
    62716290    /* When drawing over the right halve of a double-wide char clear out the
     
    62756294            && !gui.in_use
    62766295# endif
    62776296            && mb_fix_col(col, row) != col)
    6278         screen_puts_len((char_u *)" ", 1, row, col - 1, 0);
     6297    {
     6298        ScreenLines[off - 1] = ' ';
     6299        ScreenAttrs[off - 1] = 0;
     6300        if (enc_utf8)
     6301        {
     6302            ScreenLinesUC[off - 1] = 0;
     6303            ScreenLinesC[0][off - 1] = 0;
     6304        }
     6305        /* redraw the previous cell, make it empty */
     6306        screen_char(off - 1, row, col - 1);
     6307        /* force the cell at "col" to be redrawn */
     6308        force_redraw_next = TRUE;
     6309    }
    62796310#endif
    62806311
    6281     off = LineOffset[row] + col;
    62826312#ifdef FEAT_MBYTE
    62836313    max_off = LineOffset[row] + screen_Columns;
    62846314#endif
     
    63426372        }
    63436373#endif
    63446374
    6345         if (ScreenLines[off] != c
     6375#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
     6376        force_redraw_this = force_redraw_next;
     6377        force_redraw_next = FALSE;
     6378#endif
     6379
     6380        need_redraw = ScreenLines[off] != c
    63466381#ifdef FEAT_MBYTE
    63476382                || (mbyte_cells == 2
    63486383                    && ScreenLines[off + 1] != (enc_dbcs ? ptr[1] : 0))
     
    63506385                    && c == 0x8e
    63516386                    && ScreenLines2[off] != ptr[1])
    63526387                || (enc_utf8
    6353                     && (ScreenLinesUC[off] != (u8char_T)u8c
     6388                    && (ScreenLinesUC[off] != (u8char_T)(c >= 0x80 ? u8c : 0)
    63546389                        || screen_comp_differs(off, u8cc)))
    63556390#endif
    63566391                || ScreenAttrs[off] != attr
    6357                 || exmode_active
     6392                || exmode_active;
     6393
     6394        if (need_redraw
     6395#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
     6396                || force_redraw_this
     6397#endif
    63586398                )
    63596399        {
    63606400#if defined(FEAT_GUI) || defined(UNIX)
    63616401            /* The bold trick makes a single row of pixels appear in the next
    63626402             * character.  When a bold character is removed, the next
    63636403             * character should be redrawn too.  This happens for our own GUI
    6364              * and for some xterms.
    6365              * Force the redraw by setting the attribute to a different value
    6366              * than "attr", the contents of ScreenLines[] may be needed by
    6367              * mb_off2cells() further on.
    6368              * Don't do this for the last drawn character, because the next
    6369              * character may not be redrawn. */
    6370             if (
     6404             * and for some xterms. */
     6405            if (need_redraw && ScreenLines[off] != ' ' && (
    63716406# ifdef FEAT_GUI
    63726407                    gui.in_use
    63736408# endif
     
    63776412# ifdef UNIX
    63786413                    term_is_xterm
    63796414# endif
    6380                )
     6415                    ))
    63816416            {
    6382                 int             n;
     6417                int     n = ScreenAttrs[off];
    63836418
    6384                 n = ScreenAttrs[off];
    6385 # ifdef FEAT_MBYTE
    6386                 if (col + mbyte_cells < screen_Columns
    6387                         && (n > HL_ALL || (n & HL_BOLD))
    6388                         && (len < 0 ? ptr[mbyte_blen] != NUL
    6389                                              : ptr + mbyte_blen < text + len))
    6390                     ScreenAttrs[off + mbyte_cells] = attr + 1;
    6391 # else
    6392                 if (col + 1 < screen_Columns
    6393                         && (n > HL_ALL || (n & HL_BOLD))
    6394                         && (len < 0 ? ptr[1] != NUL : ptr + 1 < text + len))
    6395                     ScreenLines[off + 1] = 0;
    6396 # endif
     6419                if (n > HL_ALL)
     6420                    n = syn_attr2attr(n);
     6421                if (n & HL_BOLD)
     6422                    force_redraw_next = TRUE;
    63976423            }
    63986424#endif
    63996425#ifdef FEAT_MBYTE
     
    64806506            ++ptr;
    64816507        }
    64826508    }
     6509
     6510#if defined(FEAT_MBYTE) || defined(FEAT_GUI) || defined(UNIX)
     6511    /* If we detected the next character needs to be redrawn, but the text
     6512     * doesn't extend up to there, update the character here. */
     6513    if (force_redraw_next && col < screen_Columns)
     6514    {
     6515# ifdef FEAT_MBYTE
     6516        if (enc_dbcs != 0 && dbcs_off2cells(off, max_off) > 1)
     6517            screen_char_2(off, row, col);
     6518        else
     6519# endif
     6520            screen_char(off, row, col);
     6521    }
     6522#endif
    64836523}
    64846524
    64856525#ifdef FEAT_SEARCH_EXTRA
     
    73567396#endif
    73577397    static int      entered = FALSE;            /* avoid recursiveness */
    73587398    static int      done_outofmem_msg = FALSE;  /* did outofmem message */
     7399#ifdef FEAT_AUTOCMD
     7400    int             retry_count = 0;
    73597401
     7402retry:
     7403#endif
    73607404    /*
    73617405     * Allocation of the screen buffers is done only when the size changes and
    73627406     * when Rows and Columns have been set and we have started doing full
     
    74407484        {
    74417485            outofmem = TRUE;
    74427486#ifdef FEAT_WINDOWS
    7443             break;
     7487            goto give_up;
    74447488#endif
    74457489        }
    74467490    }
     7491#ifdef FEAT_WINDOWS
     7492give_up:
     7493#endif
    74477494
    74487495#ifdef FEAT_MBYTE
    74497496    for (i = 0; i < p_mco; ++i)
     
    76287675    --RedrawingDisabled;
    76297676
    76307677#ifdef FEAT_AUTOCMD
    7631     if (starting == 0)
     7678    /*
     7679     * Do not apply autocommands more than 3 times to avoid an endless loop
     7680     * in case applying autocommands always changes Rows or Columns.
     7681     */
     7682    if (starting == 0 && ++retry_count <= 3)
     7683    {
    76327684        apply_autocmds(EVENT_VIMRESIZED, NULL, NULL, FALSE, curbuf);
     7685        /* In rare cases, autocommands may have altered Rows or Columns,
     7686         * jump back to check if we need to allocate the screen again. */
     7687        goto retry;
     7688    }
    76337689#endif
    76347690}
    76357691
  • src/spell.c

    diff -Naur vim72.orig/src/spell.c vim72/src/spell.c
    old new  
    7777
    7878/*
    7979 * Do the opposite: based on a maximum end score and a known sound score,
    80  * compute the the maximum word score that can be used.
     80 * compute the maximum word score that can be used.
    8181 */
    8282#define MAXSCORE(word_score, sound_score) ((4 * word_score - sound_score) / 3)
    8383
     
    469469    garray_T    sl_comppat;     /* CHECKCOMPOUNDPATTERN items */
    470470    regprog_T   *sl_compprog;   /* COMPOUNDRULE turned into a regexp progrm
    471471                                 * (NULL when no compounding) */
     472    char_u      *sl_comprules;  /* all COMPOUNDRULE concatenated (or NULL) */
    472473    char_u      *sl_compstartflags; /* flags for first compound word */
    473474    char_u      *sl_compallflags; /* all flags for compound words */
    474475    char_u      sl_nobreak;     /* When TRUE: no spaces between words */
     
    625626/* TRUE if a word appears in the list of banned words.  */
    626627#define WAS_BANNED(su, word) (!HASHITEM_EMPTY(hash_find(&su->su_banned, word)))
    627628
    628 /* Number of suggestions kept when cleaning up.  we need to keep more than
     629/* Number of suggestions kept when cleaning up.  We need to keep more than
    629630 * what is displayed, because when rescore_suggestions() is called the score
    630631 * may change and wrong suggestions may be removed later. */
    631632#define SUG_CLEAN_COUNT(su)    ((su)->su_maxcount < 130 ? 150 : (su)->su_maxcount + 20)
     
    839840static void slang_clear __ARGS((slang_T *lp));
    840841static void slang_clear_sug __ARGS((slang_T *lp));
    841842static void find_word __ARGS((matchinf_T *mip, int mode));
     843static int match_checkcompoundpattern __ARGS((char_u *ptr, int wlen, garray_T *gap));
    842844static int can_compound __ARGS((slang_T *slang, char_u *word, char_u *flags));
     845static int can_be_compound __ARGS((trystate_T *sp, slang_T *slang, char_u *compflags, int flag));
     846static int match_compoundrule __ARGS((slang_T *slang, char_u *compflags));
    843847static int valid_word_prefix __ARGS((int totprefcnt, int arridx, int flags, char_u *word, slang_T *slang, int cond_req));
    844848static void find_prefix __ARGS((matchinf_T *mip, int mode));
    845849static int fold_more __ARGS((matchinf_T *mip));
     
    15191523                                            ((unsigned)flags >> 24)))
    15201524                    continue;
    15211525
     1526                /* If there is a match with a CHECKCOMPOUNDPATTERN rule
     1527                 * discard the compound word. */
     1528                if (match_checkcompoundpattern(ptr, wlen, &slang->sl_comppat))
     1529                    continue;
     1530
    15221531                if (mode == FIND_COMPOUND)
    15231532                {
    15241533                    int     capflags;
     
    15771586                    if (!can_compound(slang, fword, mip->mi_compflags))
    15781587                        continue;
    15791588                }
     1589                else if (slang->sl_comprules != NULL
     1590                             && !match_compoundrule(slang, mip->mi_compflags))
     1591                    /* The compound flags collected so far do not match any
     1592                     * COMPOUNDRULE, discard the compounded word. */
     1593                    continue;
    15801594            }
    15811595
    15821596            /* Check NEEDCOMPOUND: can't use word without compounding. */
     
    17271741}
    17281742
    17291743/*
     1744 * Return TRUE if there is a match between the word ptr[wlen] and
     1745 * CHECKCOMPOUNDPATTERN rules, assuming that we will concatenate with another
     1746 * word.
     1747 * A match means that the first part of CHECKCOMPOUNDPATTERN matches at the
     1748 * end of ptr[wlen] and the second part matches after it.
     1749 */
     1750    static int
     1751match_checkcompoundpattern(ptr, wlen, gap)
     1752    char_u      *ptr;
     1753    int         wlen;
     1754    garray_T    *gap;  /* &sl_comppat */
     1755{
     1756    int         i;
     1757    char_u      *p;
     1758    int         len;
     1759
     1760    for (i = 0; i + 1 < gap->ga_len; i += 2)
     1761    {
     1762        p = ((char_u **)gap->ga_data)[i + 1];
     1763        if (STRNCMP(ptr + wlen, p, STRLEN(p)) == 0)
     1764        {
     1765            /* Second part matches at start of following compound word, now
     1766             * check if first part matches at end of previous word. */
     1767            p = ((char_u **)gap->ga_data)[i];
     1768            len = (int)STRLEN(p);
     1769            if (len <= wlen && STRNCMP(ptr + wlen - len, p, len) == 0)
     1770                return TRUE;
     1771        }
     1772    }
     1773    return FALSE;
     1774}
     1775
     1776/*
    17301777 * Return TRUE if "flags" is a valid sequence of compound flags and "word"
    17311778 * does not have too many syllables.
    17321779 */
     
    17731820}
    17741821
    17751822/*
     1823 * Return TRUE when the sequence of flags in "compflags" plus "flag" can
     1824 * possibly form a valid compounded word.  This also checks the COMPOUNDRULE
     1825 * lines if they don't contain wildcards.
     1826 */
     1827    static int
     1828can_be_compound(sp, slang, compflags, flag)
     1829    trystate_T  *sp;
     1830    slang_T     *slang;
     1831    char_u      *compflags;
     1832    int         flag;
     1833{
     1834    /* If the flag doesn't appear in sl_compstartflags or sl_compallflags
     1835     * then it can't possibly compound. */
     1836    if (!byte_in_str(sp->ts_complen == sp->ts_compsplit
     1837                ? slang->sl_compstartflags : slang->sl_compallflags, flag))
     1838        return FALSE;
     1839
     1840    /* If there are no wildcards, we can check if the flags collected so far
     1841     * possibly can form a match with COMPOUNDRULE patterns.  This only
     1842     * makes sense when we have two or more words. */
     1843    if (slang->sl_comprules != NULL && sp->ts_complen > sp->ts_compsplit)
     1844    {
     1845        int v;
     1846
     1847        compflags[sp->ts_complen] = flag;
     1848        compflags[sp->ts_complen + 1] = NUL;
     1849        v = match_compoundrule(slang, compflags + sp->ts_compsplit);
     1850        compflags[sp->ts_complen] = NUL;
     1851        return v;
     1852    }
     1853
     1854    return TRUE;
     1855}
     1856
     1857
     1858/*
     1859 * Return TRUE if the compound flags in compflags[] match the start of any
     1860 * compound rule.  This is used to stop trying a compound if the flags
     1861 * collected so far can't possibly match any compound rule.
     1862 * Caller must check that slang->sl_comprules is not NULL.
     1863 */
     1864    static int
     1865match_compoundrule(slang, compflags)
     1866    slang_T     *slang;
     1867    char_u      *compflags;
     1868{
     1869    char_u      *p;
     1870    int         i;
     1871    int         c;
     1872
     1873    /* loop over all the COMPOUNDRULE entries */
     1874    for (p = slang->sl_comprules; *p != NUL; ++p)
     1875    {
     1876        /* loop over the flags in the compound word we have made, match
     1877         * them against the current rule entry */
     1878        for (i = 0; ; ++i)
     1879        {
     1880            c = compflags[i];
     1881            if (c == NUL)
     1882                /* found a rule that matches for the flags we have so far */
     1883                return TRUE;
     1884            if (*p == '/' || *p == NUL)
     1885                break;  /* end of rule, it's too short */
     1886            if (*p == '[')
     1887            {
     1888                int match = FALSE;
     1889
     1890                /* compare against all the flags in [] */
     1891                ++p;
     1892                while (*p != ']' && *p != NUL)
     1893                    if (*p++ == c)
     1894                        match = TRUE;
     1895                if (!match)
     1896                    break;  /* none matches */
     1897            }
     1898            else if (*p != c)
     1899                break;  /* flag of word doesn't match flag in pattern */
     1900            ++p;
     1901        }
     1902
     1903        /* Skip to the next "/", where the next pattern starts. */
     1904        p = vim_strchr(p, '/');
     1905        if (p == NULL)
     1906            break;
     1907    }
     1908
     1909    /* Checked all the rules and none of them match the flags, so there
     1910     * can't possibly be a compound starting with these flags. */
     1911    return FALSE;
     1912}
     1913
     1914/*
    17761915 * Return non-zero if the prefix indicated by "arridx" matches with the prefix
    17771916 * ID in "flags" for the word "word".
    17781917 * The WF_RAREPFX flag is included in the return value for a rare prefix.
     
    22372376
    22382377            /* If we are back at the starting line and there is no match then
    22392378             * give up. */
    2240             if (lnum == wp->w_cursor.lnum && !found_one)
     2379            if (lnum == wp->w_cursor.lnum && (!found_one || wrapped))
    22412380                break;
    22422381
    22432382            /* Skip the characters at the start of the next line that were
     
    25132652    lp->sl_midword = NULL;
    25142653
    25152654    vim_free(lp->sl_compprog);
     2655    vim_free(lp->sl_comprules);
    25162656    vim_free(lp->sl_compstartflags);
    25172657    vim_free(lp->sl_compallflags);
    25182658    lp->sl_compprog = NULL;
     2659    lp->sl_comprules = NULL;
    25192660    lp->sl_compstartflags = NULL;
    25202661    lp->sl_compallflags = NULL;
    25212662
     
    34603601    char_u      *pp;
    34613602    char_u      *cp;
    34623603    char_u      *ap;
     3604    char_u      *crp;
    34633605    int         cnt;
    34643606    garray_T    *gap;
    34653607
     
    35453687    slang->sl_compallflags = ap;
    35463688    *ap = NUL;
    35473689
     3690    /* And a list of all patterns in their original form, for checking whether
     3691     * compounding may work in match_compoundrule().  This is freed when we
     3692     * encounter a wildcard, the check doesn't work then. */
     3693    crp = alloc(todo + 1);
     3694    slang->sl_comprules = crp;
     3695
    35483696    pp = pat;
    35493697    *pp++ = '^';
    35503698    *pp++ = '\\';
     
    35873735                    atstart = 0;
    35883736            }
    35893737        }
     3738
     3739        /* Copy flag to "sl_comprules", unless we run into a wildcard. */
     3740        if (crp != NULL)
     3741        {
     3742            if (c == '+' || c == '*')
     3743            {
     3744                vim_free(slang->sl_comprules);
     3745                slang->sl_comprules = NULL;
     3746                crp = NULL;
     3747            }
     3748            else
     3749                *crp++ = c;
     3750        }
     3751
    35903752        if (c == '/')       /* slash separates two items */
    35913753        {
    35923754            *pp++ = '\\';
     
    36113773    *pp++ = '$';
    36123774    *pp = NUL;
    36133775
     3776    if (crp != NULL)
     3777        *crp = NUL;
     3778
    36143779    slang->sl_compprog = vim_regcomp(pat, RE_MAGIC + RE_STRING + RE_STRICT);
    36153780    vim_free(pat);
    36163781    if (slang->sl_compprog == NULL)
     
    47914956 * Structure that is used to store the items in the word tree.  This avoids
    47924957 * the need to keep track of each allocated thing, everything is freed all at
    47934958 * once after ":mkspell" is done.
     4959 * Note: "sb_next" must be just before "sb_data" to make sure the alignment of
     4960 * "sb_data" is correct for systems where pointers must be aligned on
     4961 * pointer-size boundaries and sizeof(pointer) > sizeof(int) (e.g., Sparc).
    47944962 */
    47954963#define  SBLOCKSIZE 16000       /* size of sb_data */
    47964964typedef struct sblock_S sblock_T;
    47974965struct sblock_S
    47984966{
    4799     sblock_T    *sb_next;       /* next block in list */
    48004967    int         sb_used;        /* nr of bytes already in use */
     4968    sblock_T    *sb_next;       /* next block in list */
    48014969    char_u      sb_data[1];     /* data, actually longer */
    48024970};
    48034971
     
    49155083} spellinfo_T;
    49165084
    49175085static afffile_T *spell_read_aff __ARGS((spellinfo_T *spin, char_u *fname));
     5086static int is_aff_rule __ARGS((char_u **items, int itemcnt, char *rulename, int  mincount));
    49185087static void aff_process_flags __ARGS((afffile_T *affile, affentry_T *entry));
    49195088static int spell_info_item __ARGS((char_u *s));
    49205089static unsigned affitem2flag __ARGS((int flagtype, char_u *item, char_u *fname, int lnum));
     
    49505119static void put_sugtime __ARGS((spellinfo_T *spin, FILE *fd));
    49515120static int write_vim_spell __ARGS((spellinfo_T *spin, char_u *fname));
    49525121static void clear_node __ARGS((wordnode_T *node));
    4953 static int put_node __ARGS((FILE *fd, wordnode_T *node, int index, int regionmask, int prefixtree));
     5122static int put_node __ARGS((FILE *fd, wordnode_T *node, int idx, int regionmask, int prefixtree));
    49545123static void spell_make_sugfile __ARGS((spellinfo_T *spin, char_u *wfname));
    49555124static int sug_filltree __ARGS((spellinfo_T *spin, slang_T *slang));
    49565125static int sug_maketable __ARGS((spellinfo_T *spin));
     
    52235392        /* Handle non-empty lines. */
    52245393        if (itemcnt > 0)
    52255394        {
    5226             if (STRCMP(items[0], "SET") == 0 && itemcnt == 2
    5227                                                        && aff->af_enc == NULL)
     5395            if (is_aff_rule(items, itemcnt, "SET", 2) && aff->af_enc == NULL)
    52285396            {
    52295397#ifdef FEAT_MBYTE
    52305398                /* Setup for conversion from "ENC" to 'encoding'. */
     
    52395407                    smsg((char_u *)_("Conversion in %s not supported"), fname);
    52405408#endif
    52415409            }
    5242             else if (STRCMP(items[0], "FLAG") == 0 && itemcnt == 2
     5410            else if (is_aff_rule(items, itemcnt, "FLAG", 2)
    52435411                                              && aff->af_flagtype == AFT_CHAR)
    52445412            {
    52455413                if (STRCMP(items[1], "long") == 0)
     
    52845452                        spin->si_info = p;
    52855453                    }
    52865454            }
    5287             else if (STRCMP(items[0], "MIDWORD") == 0 && itemcnt == 2
     5455            else if (is_aff_rule(items, itemcnt, "MIDWORD", 2)
    52885456                                                           && midword == NULL)
    52895457            {
    52905458                midword = getroom_save(spin, items[1]);
    52915459            }
    5292             else if (STRCMP(items[0], "TRY") == 0 && itemcnt == 2)
     5460            else if (is_aff_rule(items, itemcnt, "TRY", 2))
    52935461            {
    52945462                /* ignored, we look in the tree for what chars may appear */
    52955463            }
    52965464            /* TODO: remove "RAR" later */
    5297             else if ((STRCMP(items[0], "RAR") == 0
    5298                         || STRCMP(items[0], "RARE") == 0) && itemcnt == 2
    5299                                                       && aff->af_rare == 0)
     5465            else if ((is_aff_rule(items, itemcnt, "RAR", 2)
     5466                        || is_aff_rule(items, itemcnt, "RARE", 2))
     5467                                                        && aff->af_rare == 0)
    53005468            {
    53015469                aff->af_rare = affitem2flag(aff->af_flagtype, items[1],
    53025470                                                                 fname, lnum);
    53035471            }
    53045472            /* TODO: remove "KEP" later */
    5305             else if ((STRCMP(items[0], "KEP") == 0
    5306                     || STRCMP(items[0], "KEEPCASE") == 0) && itemcnt == 2
     5473            else if ((is_aff_rule(items, itemcnt, "KEP", 2)
     5474                        || is_aff_rule(items, itemcnt, "KEEPCASE", 2))
    53075475                                                     && aff->af_keepcase == 0)
    53085476            {
    53095477                aff->af_keepcase = affitem2flag(aff->af_flagtype, items[1],
    53105478                                                                 fname, lnum);
    53115479            }
    5312             else if (STRCMP(items[0], "BAD") == 0 && itemcnt == 2
    5313                                                        && aff->af_bad == 0)
     5480            else if ((is_aff_rule(items, itemcnt, "BAD", 2)
     5481                        || is_aff_rule(items, itemcnt, "FORBIDDENWORD", 2))
     5482                                                          && aff->af_bad == 0)
    53145483            {
    53155484                aff->af_bad = affitem2flag(aff->af_flagtype, items[1],
    53165485                                                                 fname, lnum);
    53175486            }
    5318             else if (STRCMP(items[0], "NEEDAFFIX") == 0 && itemcnt == 2
     5487            else if (is_aff_rule(items, itemcnt, "NEEDAFFIX", 2)
    53195488                                                    && aff->af_needaffix == 0)
    53205489            {
    53215490                aff->af_needaffix = affitem2flag(aff->af_flagtype, items[1],
    53225491                                                                 fname, lnum);
    53235492            }
    5324             else if (STRCMP(items[0], "CIRCUMFIX") == 0 && itemcnt == 2
     5493            else if (is_aff_rule(items, itemcnt, "CIRCUMFIX", 2)
    53255494                                                    && aff->af_circumfix == 0)
    53265495            {
    53275496                aff->af_circumfix = affitem2flag(aff->af_flagtype, items[1],
    53285497                                                                 fname, lnum);
    53295498            }
    5330             else if (STRCMP(items[0], "NOSUGGEST") == 0 && itemcnt == 2
     5499            else if (is_aff_rule(items, itemcnt, "NOSUGGEST", 2)
    53315500                                                    && aff->af_nosuggest == 0)
    53325501            {
    53335502                aff->af_nosuggest = affitem2flag(aff->af_flagtype, items[1],
    53345503                                                                 fname, lnum);
    53355504            }
    5336             else if (STRCMP(items[0], "NEEDCOMPOUND") == 0 && itemcnt == 2
     5505            else if ((is_aff_rule(items, itemcnt, "NEEDCOMPOUND", 2)
     5506                        || is_aff_rule(items, itemcnt, "ONLYINCOMPOUND", 2))
    53375507                                                     && aff->af_needcomp == 0)
    53385508            {
    53395509                aff->af_needcomp = affitem2flag(aff->af_flagtype, items[1],
    53405510                                                                 fname, lnum);
    53415511            }
    5342             else if (STRCMP(items[0], "COMPOUNDROOT") == 0 && itemcnt == 2
     5512            else if (is_aff_rule(items, itemcnt, "COMPOUNDROOT", 2)
    53435513                                                     && aff->af_comproot == 0)
    53445514            {
    53455515                aff->af_comproot = affitem2flag(aff->af_flagtype, items[1],
    53465516                                                                 fname, lnum);
    53475517            }
    5348             else if (STRCMP(items[0], "COMPOUNDFORBIDFLAG") == 0
    5349                                    && itemcnt == 2 && aff->af_compforbid == 0)
     5518            else if (is_aff_rule(items, itemcnt, "COMPOUNDFORBIDFLAG", 2)
     5519                                                  && aff->af_compforbid == 0)
    53505520            {
    53515521                aff->af_compforbid = affitem2flag(aff->af_flagtype, items[1],
    53525522                                                                 fname, lnum);
     
    53545524                    smsg((char_u *)_("Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line %d"),
    53555525                            fname, lnum);
    53565526            }
    5357             else if (STRCMP(items[0], "COMPOUNDPERMITFLAG") == 0
    5358                                    && itemcnt == 2 && aff->af_comppermit == 0)
     5527            else if (is_aff_rule(items, itemcnt, "COMPOUNDPERMITFLAG", 2)
     5528                                                  && aff->af_comppermit == 0)
    53595529            {
    53605530                aff->af_comppermit = affitem2flag(aff->af_flagtype, items[1],
    53615531                                                                 fname, lnum);
     
    53635533                    smsg((char_u *)_("Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line %d"),
    53645534                            fname, lnum);
    53655535            }
    5366             else if (STRCMP(items[0], "COMPOUNDFLAG") == 0 && itemcnt == 2
     5536            else if (is_aff_rule(items, itemcnt, "COMPOUNDFLAG", 2)
    53675537                                                         && compflags == NULL)
    53685538            {
    53695539                /* Turn flag "c" into COMPOUNDRULE compatible string "c+",
     
    53765546                    compflags = p;
    53775547                }
    53785548            }
    5379             else if (STRCMP(items[0], "COMPOUNDRULE") == 0 && itemcnt == 2)
     5549            else if (is_aff_rule(items, itemcnt, "COMPOUNDRULES", 2))
     5550            {
     5551                /* We don't use the count, but do check that it's a number and
     5552                 * not COMPOUNDRULE mistyped. */
     5553                if (atoi((char *)items[1]) == 0)
     5554                    smsg((char_u *)_("Wrong COMPOUNDRULES value in %s line %d: %s"),
     5555                                                       fname, lnum, items[1]);
     5556            }
     5557            else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2))
    53805558            {
    53815559                /* Concatenate this string to previously defined ones, using a
    53825560                 * slash to separate them. */
     
    53955573                    compflags = p;
    53965574                }
    53975575            }
    5398             else if (STRCMP(items[0], "COMPOUNDWORDMAX") == 0 && itemcnt == 2
     5576            else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
    53995577                                                              && compmax == 0)
    54005578            {
    54015579                compmax = atoi((char *)items[1]);
     
    54035581                    smsg((char_u *)_("Wrong COMPOUNDWORDMAX value in %s line %d: %s"),
    54045582                                                       fname, lnum, items[1]);
    54055583            }
    5406             else if (STRCMP(items[0], "COMPOUNDMIN") == 0 && itemcnt == 2
     5584            else if (is_aff_rule(items, itemcnt, "COMPOUNDMIN", 2)
    54075585                                                           && compminlen == 0)
    54085586            {
    54095587                compminlen = atoi((char *)items[1]);
     
    54115589                    smsg((char_u *)_("Wrong COMPOUNDMIN value in %s line %d: %s"),
    54125590                                                       fname, lnum, items[1]);
    54135591            }
    5414             else if (STRCMP(items[0], "COMPOUNDSYLMAX") == 0 && itemcnt == 2
     5592            else if (is_aff_rule(items, itemcnt, "COMPOUNDSYLMAX", 2)
    54155593                                                           && compsylmax == 0)
    54165594            {
    54175595                compsylmax = atoi((char *)items[1]);
     
    54195597                    smsg((char_u *)_("Wrong COMPOUNDSYLMAX value in %s line %d: %s"),
    54205598                                                       fname, lnum, items[1]);
    54215599            }
    5422             else if (STRCMP(items[0], "CHECKCOMPOUNDDUP") == 0 && itemcnt == 1)
     5600            else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDDUP", 1))
    54235601            {
    54245602                compoptions |= COMP_CHECKDUP;
    54255603            }
    5426             else if (STRCMP(items[0], "CHECKCOMPOUNDREP") == 0 && itemcnt == 1)
     5604            else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDREP", 1))
    54275605            {
    54285606                compoptions |= COMP_CHECKREP;
    54295607            }
    5430             else if (STRCMP(items[0], "CHECKCOMPOUNDCASE") == 0 && itemcnt == 1)
     5608            else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDCASE", 1))
    54315609            {
    54325610                compoptions |= COMP_CHECKCASE;
    54335611            }
    5434             else if (STRCMP(items[0], "CHECKCOMPOUNDTRIPLE") == 0
    5435                                                               && itemcnt == 1)
     5612            else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDTRIPLE", 1))
    54365613            {
    54375614                compoptions |= COMP_CHECKTRIPLE;
    54385615            }
    5439             else if (STRCMP(items[0], "CHECKCOMPOUNDPATTERN") == 0
    5440                                                               && itemcnt == 2)
     5616            else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 2))
    54415617            {
    54425618                if (atoi((char *)items[1]) == 0)
    54435619                    smsg((char_u *)_("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"),
    54445620                                                       fname, lnum, items[1]);
    54455621            }
    5446             else if (STRCMP(items[0], "CHECKCOMPOUNDPATTERN") == 0
    5447                                                               && itemcnt == 3)
     5622            else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 3))
    54485623            {
    54495624                garray_T    *gap = &spin->si_comppat;
    54505625                int         i;
     
    54635638                                               = getroom_save(spin, items[2]);
    54645639                }
    54655640            }
    5466             else if (STRCMP(items[0], "SYLLABLE") == 0 && itemcnt == 2
     5641            else if (is_aff_rule(items, itemcnt, "SYLLABLE", 2)
    54675642                                                          && syllable == NULL)
    54685643            {
    54695644                syllable = getroom_save(spin, items[1]);
    54705645            }
    5471             else if (STRCMP(items[0], "NOBREAK") == 0 && itemcnt == 1)
     5646            else if (is_aff_rule(items, itemcnt, "NOBREAK", 1))
    54725647            {
    54735648                spin->si_nobreak = TRUE;
    54745649            }
    5475             else if (STRCMP(items[0], "NOSPLITSUGS") == 0 && itemcnt == 1)
     5650            else if (is_aff_rule(items, itemcnt, "NOSPLITSUGS", 1))
    54765651            {
    54775652                spin->si_nosplitsugs = TRUE;
    54785653            }
    5479             else if (STRCMP(items[0], "NOSUGFILE") == 0 && itemcnt == 1)
     5654            else if (is_aff_rule(items, itemcnt, "NOSUGFILE", 1))
    54805655            {
    54815656                spin->si_nosugfile = TRUE;
    54825657            }
    5483             else if (STRCMP(items[0], "PFXPOSTPONE") == 0 && itemcnt == 1)
     5658            else if (is_aff_rule(items, itemcnt, "PFXPOSTPONE", 1))
    54845659            {
    54855660                aff->af_pfxpostpone = TRUE;
    54865661            }
     
    57715946                    }
    57725947                }
    57735948            }
    5774             else if (STRCMP(items[0], "FOL") == 0 && itemcnt == 2
    5775                                                                && fol == NULL)
     5949            else if (is_aff_rule(items, itemcnt, "FOL", 2) && fol == NULL)
    57765950            {
    57775951                fol = vim_strsave(items[1]);
    57785952            }
    5779             else if (STRCMP(items[0], "LOW") == 0 && itemcnt == 2
    5780                                                                && low == NULL)
     5953            else if (is_aff_rule(items, itemcnt, "LOW", 2) && low == NULL)
    57815954            {
    57825955                low = vim_strsave(items[1]);
    57835956            }
    5784             else if (STRCMP(items[0], "UPP") == 0 && itemcnt == 2
    5785                                                                && upp == NULL)
     5957            else if (is_aff_rule(items, itemcnt, "UPP", 2) && upp == NULL)
    57865958            {
    57875959                upp = vim_strsave(items[1]);
    57885960            }
    5789             else if ((STRCMP(items[0], "REP") == 0
    5790                         || STRCMP(items[0], "REPSAL") == 0)
    5791                     && itemcnt == 2)
     5961            else if (is_aff_rule(items, itemcnt, "REP", 2)
     5962                     || is_aff_rule(items, itemcnt, "REPSAL", 2))
    57925963            {
    57935964                /* Ignore REP/REPSAL count */;
    57945965                if (!isdigit(*items[1]))
     
    58195990                                         : &spin->si_rep, items[1], items[2]);
    58205991                }
    58215992            }
    5822             else if (STRCMP(items[0], "MAP") == 0 && itemcnt == 2)
     5993            else if (is_aff_rule(items, itemcnt, "MAP", 2))
    58235994            {
    58245995                /* MAP item or count */
    58255996                if (!found_map)
     
    58566027                    ga_append(&spin->si_map, '/');
    58576028                }
    58586029            }
    5859             /* Accept "SAL from to" and "SAL from to # comment". */
    5860             else if (STRCMP(items[0], "SAL") == 0
    5861                     && (itemcnt == 3 || (itemcnt > 3 && items[3][0] == '#')))
     6030            /* Accept "SAL from to" and "SAL from to  #comment". */
     6031            else if (is_aff_rule(items, itemcnt, "SAL", 3))
    58626032            {
    58636033                if (do_sal)
    58646034                {
     
    58776047                                                                : items[2]);
    58786048                }
    58796049            }
    5880             else if (STRCMP(items[0], "SOFOFROM") == 0 && itemcnt == 2
     6050            else if (is_aff_rule(items, itemcnt, "SOFOFROM", 2)
    58816051                                                          && sofofrom == NULL)
    58826052            {
    58836053                sofofrom = getroom_save(spin, items[1]);
    58846054            }
    5885             else if (STRCMP(items[0], "SOFOTO") == 0 && itemcnt == 2
     6055            else if (is_aff_rule(items, itemcnt, "SOFOTO", 2)
    58866056                                                            && sofoto == NULL)
    58876057            {
    58886058                sofoto = getroom_save(spin, items[1]);
     
    59806150        else if (spin->si_newprefID == 0 || spin->si_newprefID == 127)
    59816151            MSG(_("Too many compound flags"));
    59826152        else
    5983             MSG(_("Too many posponed prefixes and/or compound flags"));
     6153            MSG(_("Too many postponed prefixes and/or compound flags"));
    59846154    }
    59856155
    59866156    if (syllable != NULL)
     
    60176187}
    60186188
    60196189/*
     6190 * Return TRUE when items[0] equals "rulename", there are "mincount" items or
     6191 * a comment is following after item "mincount".
     6192 */
     6193    static int
     6194is_aff_rule(items, itemcnt, rulename, mincount)
     6195    char_u      **items;
     6196    int         itemcnt;
     6197    char        *rulename;
     6198    int         mincount;
     6199{
     6200    return (STRCMP(items[0], rulename) == 0
     6201            && (itemcnt == mincount
     6202                || (itemcnt > mincount && items[mincount][0] == '#')));
     6203}
     6204
     6205/*
    60206206 * For affix "entry" move COMPOUNDFORBIDFLAG and COMPOUNDPERMITFLAG from
    60216207 * ae_flags to ae_comppermit and ae_compforbid.
    60226208 */
     
    79268112    char_u      *p;
    79278113    int         rr;
    79288114    int         retval = OK;
     8115    size_t      fwv = 1;  /* collect return value of fwrite() to avoid
     8116                             warnings from picky compiler */
    79298117
    79308118    fd = mch_fopen((char *)fname, "w");
    79318119    if (fd == NULL)
     
    79368124
    79378125    /* <HEADER>: <fileID> <versionnr> */
    79388126                                                            /* <fileID> */
    7939     if (fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd) != 1)
    7940     {
    7941         EMSG(_(e_write));
    7942         retval = FAIL;
    7943     }
     8127    fwv &= fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd);
     8128    if (fwv != (size_t)1)
     8129        /* Catch first write error, don't try writing more. */
     8130        goto theend;
     8131
    79448132    putc(VIMSPELLVERSION, fd);                              /* <versionnr> */
    79458133
    79468134    /*
     
    79558143
    79568144        i = (int)STRLEN(spin->si_info);
    79578145        put_bytes(fd, (long_u)i, 4);                    /* <sectionlen> */
    7958         fwrite(spin->si_info, (size_t)i, (size_t)1, fd); /* <infotext> */
     8146        fwv &= fwrite(spin->si_info, (size_t)i, (size_t)1, fd); /* <infotext> */
    79598147    }
    79608148
    79618149    /* SN_REGION: <regionname> ...
     
    79668154        putc(SNF_REQUIRED, fd);                         /* <sectionflags> */
    79678155        l = spin->si_region_count * 2;
    79688156        put_bytes(fd, (long_u)l, 4);                    /* <sectionlen> */
    7969         fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd);
     8157        fwv &= fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd);
    79708158                                                        /* <regionname> ... */
    79718159        regionmask = (1 << spin->si_region_count) - 1;
    79728160    }
     
    80168204        }
    80178205
    80188206        put_bytes(fd, (long_u)l, 2);                    /* <folcharslen> */
    8019         fwrite(folchars, (size_t)l, (size_t)1, fd);     /* <folchars> */
     8207        fwv &= fwrite(folchars, (size_t)l, (size_t)1, fd); /* <folchars> */
    80208208    }
    80218209
    80228210    /* SN_MIDWORD: <midword> */
     
    80278215
    80288216        i = (int)STRLEN(spin->si_midword);
    80298217        put_bytes(fd, (long_u)i, 4);                    /* <sectionlen> */
    8030         fwrite(spin->si_midword, (size_t)i, (size_t)1, fd); /* <midword> */
     8218        fwv &= fwrite(spin->si_midword, (size_t)i, (size_t)1, fd);
     8219                                                        /* <midword> */
    80318220    }
    80328221
    80338222    /* SN_PREFCOND: <prefcondcnt> <prefcond> ... */
     
    81138302                p = rr == 1 ? ftp->ft_from : ftp->ft_to;
    81148303                l = (int)STRLEN(p);
    81158304                putc(l, fd);
    8116                 fwrite(p, l, (size_t)1, fd);
     8305                if (l > 0)
     8306                    fwv &= fwrite(p, l, (size_t)1, fd);
    81178307            }
    81188308        }
    81198309
     
    81318321                                                        /* <sectionlen> */
    81328322
    81338323        put_bytes(fd, (long_u)l, 2);                    /* <sofofromlen> */
    8134         fwrite(spin->si_sofofr, l, (size_t)1, fd);      /* <sofofrom> */
     8324        fwv &= fwrite(spin->si_sofofr, l, (size_t)1, fd); /* <sofofrom> */
    81358325
    81368326        l = (int)STRLEN(spin->si_sofoto);
    81378327        put_bytes(fd, (long_u)l, 2);                    /* <sofotolen> */
    8138         fwrite(spin->si_sofoto, l, (size_t)1, fd);      /* <sofoto> */
     8328        fwv &= fwrite(spin->si_sofoto, l, (size_t)1, fd); /* <sofoto> */
    81398329    }
    81408330
    81418331    /* SN_WORDS: <word> ...
     
    81608350                    l = (int)STRLEN(hi->hi_key) + 1;
    81618351                    len += l;
    81628352                    if (round == 2)                     /* <word> */
    8163                         fwrite(hi->hi_key, (size_t)l, (size_t)1, fd);
     8353                        fwv &= fwrite(hi->hi_key, (size_t)l, (size_t)1, fd);
    81648354                    --todo;
    81658355                }
    81668356            if (round == 1)
     
    81768366        putc(0, fd);                                    /* <sectionflags> */
    81778367        l = spin->si_map.ga_len;
    81788368        put_bytes(fd, (long_u)l, 4);                    /* <sectionlen> */
    8179         fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd);
     8369        fwv &= fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd);
    81808370                                                        /* <mapstr> */
    81818371    }
    81828372
     
    82328422        {
    82338423            p = ((char_u **)(spin->si_comppat.ga_data))[i];
    82348424            putc((int)STRLEN(p), fd);                   /* <comppatlen> */
    8235             fwrite(p, (size_t)STRLEN(p), (size_t)1, fd);/* <comppattext> */
     8425            fwv &= fwrite(p, (size_t)STRLEN(p), (size_t)1, fd);
     8426                                                        /* <comppattext> */
    82368427        }
    82378428                                                        /* <compflags> */
    8238         fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags),
     8429        fwv &= fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags),
    82398430                                                               (size_t)1, fd);
    82408431    }
    82418432
     
    82598450
    82608451        l = (int)STRLEN(spin->si_syllable);
    82618452        put_bytes(fd, (long_u)l, 4);                    /* <sectionlen> */
    8262         fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd); /* <syllable> */
     8453        fwv &= fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd);
     8454                                                        /* <syllable> */
    82638455    }
    82648456
    82658457    /* end of <SECTIONS> */
     
    82958487        (void)put_node(fd, tree, 0, regionmask, round == 3);
    82968488    }
    82978489
    8298     /* Write another byte to check for errors. */
     8490    /* Write another byte to check for errors (file system full). */
    82998491    if (putc(0, fd) == EOF)
    83008492        retval = FAIL;
    8301 
     8493theend:
    83028494    if (fclose(fd) == EOF)
    83038495        retval = FAIL;
    83048496
     8497    if (fwv != (size_t)1)
     8498        retval = FAIL;
     8499    if (retval == FAIL)
     8500        EMSG(_(e_write));
     8501
    83058502    return retval;
    83068503}
    83078504
     
    989010087    char_u      *p;
    989110088    int         len;
    989210089    int         totlen;
     10090    size_t      x = 1;  /* collect return value of fwrite() */
    989310091
    989410092    if (fd != NULL)
    989510093        put_bytes(fd, (long_u)gap->ga_len, 2);      /* <prefcondcnt> */
     
    990610104            if (fd != NULL)
    990710105            {
    990810106                fputc(len, fd);
    9909                 fwrite(p, (size_t)len, (size_t)1, fd);
     10107                x &= fwrite(p, (size_t)len, (size_t)1, fd);
    991010108            }
    991110109            totlen += len;
    991210110        }
     
    1148011678                    vim_strncpy(preword + sp->ts_prewordlen,
    1148111679                            tword + sp->ts_splitoff,
    1148211680                            sp->ts_twordlen - sp->ts_splitoff);
    11483                     p = preword;
    11484                     while (*skiptowhite(p) != NUL)
    11485                         p = skipwhite(skiptowhite(p));
    11486                     if (fword_ends && !can_compound(slang, p,
    11487                                                 compflags + sp->ts_compsplit))
    11488                         /* Compound is not allowed.  But it may still be
    11489                          * possible if we add another (short) word. */
     11681
     11682                    /* Verify CHECKCOMPOUNDPATTERN  rules. */
     11683                    if (match_checkcompoundpattern(preword,  sp->ts_prewordlen,
     11684                                                          &slang->sl_comppat))
    1149011685                        compound_ok = FALSE;
    1149111686
     11687                    if (compound_ok)
     11688                    {
     11689                        p = preword;
     11690                        while (*skiptowhite(p) != NUL)
     11691                            p = skipwhite(skiptowhite(p));
     11692                        if (fword_ends && !can_compound(slang, p,
     11693                                                compflags + sp->ts_compsplit))
     11694                            /* Compound is not allowed.  But it may still be
     11695                             * possible if we add another (short) word. */
     11696                            compound_ok = FALSE;
     11697                    }
     11698
    1149211699                    /* Get pointer to last char of previous word. */
    1149311700                    p = preword + sp->ts_prewordlen;
    1149411701                    mb_ptr_back(preword, p);
     
    1168511892                        && (slang->sl_compsylmax < MAXWLEN
    1168611893                            || sp->ts_complen + 1 - sp->ts_compsplit
    1168711894                                                          < slang->sl_compmax)
    11688                         && (byte_in_str(sp->ts_complen == sp->ts_compsplit
    11689                                             ? slang->sl_compstartflags
    11690                                             : slang->sl_compallflags,
    11691                                                     ((unsigned)flags >> 24))))
     11895                        && (can_be_compound(sp, slang,
     11896                                         compflags, ((unsigned)flags >> 24))))
     11897
    1169211898                {
    1169311899                    try_compound = TRUE;
    1169411900                    compflags[sp->ts_complen] = ((unsigned)flags >> 24);
     
    1480815014
    1480915015        case 0:
    1481015016            /*
    14811              * Lenghts are equal, thus changes must result in same length: An
     15017             * Lengths are equal, thus changes must result in same length: An
    1481215018             * insert is only possible in combination with a delete.
    1481315019             * 1: check if for identical strings
    1481415020             */
  • src/structs.h

    diff -Naur vim72.orig/src/structs.h vim72/src/structs.h
    old new  
    459459typedef struct
    460460{
    461461    int         hide;                   /* TRUE when ":hide" was used */
    462 # ifdef FEAT_BROWSE
     462# ifdef FEAT_BROWSE_CMD
    463463    int         browse;                 /* TRUE to invoke file dialog */
    464464# endif
    465465# ifdef FEAT_WINDOWS
     
    17841784#endif
    17851785
    17861786    /*
    1787      * The next three specify the offsets for displaying the buffer:
     1787     * "w_topline", "w_leftcol" and "w_skipcol" specify the offsets for
     1788     * displaying the buffer.
    17881789     */
    17891790    linenr_T    w_topline;          /* buffer line number of the line at the
    17901791                                       top of the window */
     1792#ifdef FEAT_AUTOCMD
     1793    char        w_topline_was_set;  /* flag set to TRUE when topline is set,
     1794                                       e.g. by winrestview() */
     1795#endif
    17911796#ifdef FEAT_DIFF
    17921797    int         w_topfill;          /* number of filler lines above w_topline */
    17931798    int         w_old_topfill;      /* w_topfill at last redraw */
  • src/tag.c

    diff -Naur vim72.orig/src/tag.c vim72/src/tag.c
    old new  
    515515             * If a count is supplied to the ":tag <name>" command, then
    516516             * jump to count'th matching tag.
    517517             */
    518             if (type == DT_TAG && count > 0)
     518            if (type == DT_TAG && *tag != NUL && count > 0)
    519519                cur_match = count - 1;
    520520
    521521            if (type == DT_SELECT || type == DT_JUMP
     
    618618                taglen_advance(taglen);
    619619                MSG_PUTS_ATTR(_("file\n"), hl_attr(HLF_T));
    620620
    621                 for (i = 0; i < num_matches; ++i)
     621                for (i = 0; i < num_matches && !got_int; ++i)
    622622                {
    623623                    parse_match(matches[i], &tagp);
    624624                    if (!new_tag && (
     
    655655                    }
    656656                    if (msg_col > 0)
    657657                        msg_putchar('\n');
     658                    if (got_int)
     659                        break;
    658660                    msg_advance(15);
    659661
    660662                    /* print any extra fields */
     
    689691                                if (msg_col + ptr2cells(p) >= Columns)
    690692                                {
    691693                                    msg_putchar('\n');
     694                                    if (got_int)
     695                                        break;
    692696                                    msg_advance(15);
    693697                                }
    694698                                p = msg_outtrans_one(p, attr);
     
    704708                        if (msg_col > 15)
    705709                        {
    706710                            msg_putchar('\n');
     711                            if (got_int)
     712                                break;
    707713                            msg_advance(15);
    708714                        }
    709715                    }
     
    734740                    {
    735741                        if (msg_col + (*p == TAB ? 1 : ptr2cells(p)) > Columns)
    736742                            msg_putchar('\n');
     743                        if (got_int)
     744                            break;
    737745                        msg_advance(15);
    738746
    739747                        /* skip backslash used for escaping command char */
     
    760768                    if (msg_col)
    761769                        msg_putchar('\n');
    762770                    ui_breakcheck();
    763                     if (got_int)
    764                     {
    765                         got_int = FALSE;        /* only stop the listing */
    766                         break;
    767                     }
    768771                }
     772                if (got_int)
     773                    got_int = FALSE;    /* only stop the listing */
    769774                ask_for_selection = TRUE;
    770775            }
    771776#if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL)
     
    25422547{
    25432548    ga_clear_strings(&tag_fnames);
    25442549    do_tag(NULL, DT_FREE, 0, 0, 0);
     2550    tag_freematch();
     2551
     2552# if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
     2553    if (ptag_entry.tagname)
     2554    {
     2555        vim_free(ptag_entry.tagname);
     2556        ptag_entry.tagname = NULL;
     2557    }
     2558# endif
    25452559}
    25462560#endif
    25472561
     
    27252739         */
    27262740        p_7f = vim_strchr(lbuf, 0x7f);
    27272741        if (p_7f == NULL)
     2742        {
     2743etag_fail:
     2744            if (vim_strchr(lbuf, '\n') == NULL)
     2745            {
     2746                /* Truncated line.  Ignore it. */
     2747                if (p_verbose >= 5)
     2748                {
     2749                    verbose_enter();
     2750                    MSG(_("Ignoring long line in tags file"));
     2751                    verbose_leave();
     2752                }
     2753                tagp->command = lbuf;
     2754                tagp->tagname = lbuf;
     2755                tagp->tagname_end = lbuf;
     2756                return OK;
     2757            }
    27282758            return FAIL;
     2759        }
    27292760
    27302761        /* Find ^A.  If not found the line number is after the 0x7f */
    27312762        p = vim_strchr(p_7f, Ctrl_A);
     
    27352766            ++p;
    27362767
    27372768        if (!VIM_ISDIGIT(*p))       /* check for start of line number */
    2738             return FAIL;
     2769            goto etag_fail;
    27392770        tagp->command = p;
    27402771
    27412772
     
    27492780            /* find end of tagname */
    27502781            for (p = p_7f - 1; !vim_iswordc(*p); --p)
    27512782                if (p == lbuf)
    2752                     return FAIL;
     2783                    goto etag_fail;
    27532784            tagp->tagname_end = p + 1;
    27542785            while (p >= lbuf && vim_iswordc(*p))
    27552786                --p;
  • src/term.c

    diff -Naur vim72.orig/src/term.c vim72/src/term.c
    old new  
    49204920        key_name[0] = KEY2TERMCAP0(key);
    49214921        key_name[1] = KEY2TERMCAP1(key);
    49224922        if (key_name[0] == KS_KEY)
    4923             string[new_slen++] = key_name[1];   /* from ":set <M-b>=xx" */
     4923        {
     4924            /* from ":set <M-b>=xx" */
     4925#ifdef FEAT_MBYTE
     4926            if (has_mbyte)
     4927                new_slen += (*mb_char2bytes)(key_name[1], string + new_slen);
     4928            else
     4929#endif
     4930                string[new_slen++] = key_name[1];
     4931        }
    49244932        else
    49254933        {
    49264934            string[new_slen++] = K_SPECIAL;
  • src/testdir/Makefile

    diff -Naur vim72.orig/src/testdir/Makefile vim72/src/testdir/Makefile
    old new  
    2020                test48.out test49.out test51.out test52.out test53.out \
    2121                test54.out test55.out test56.out test57.out test58.out \
    2222                test59.out test60.out test61.out test62.out test63.out \
    23                 test64.out test65.out
     23                test64.out test65.out test66.out
    2424
    2525SCRIPTS_GUI = test16.out
    2626
    2727.SUFFIXES: .in .out
    2828
    29 nongui: nolog $(SCRIPTS)
    30         @echo
    31         @cat test.log
    32         @echo ALL DONE
     29nongui: nolog $(SCRIPTS) report
     30
     31gui:    nolog $(SCRIPTS) $(SCRIPTS_GUI) report
    3332
    34 gui:    nolog $(SCRIPTS) $(SCRIPTS_GUI)
     33report:
    3534        @echo
    36         @cat test.log
    37         @echo ALL DONE
     35        @echo 'Test results:'
     36        @/bin/sh -c "if test -f test.log; \
     37                then cat test.log; echo TEST FAILURE; exit 1; \
     38                else echo ALL DONE; \
     39                fi"
    3840
    3941$(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG)
    4042
     
    7173test60.out: test60.vim
    7274
    7375nolog:
    74         -echo Test results: >test.log
     76        -rm -f test.log
  • src/testdir/Make_ming.mak

    diff -Naur vim72.orig/src/testdir/Make_ming.mak vim72/src/testdir/Make_ming.mak
    old new  
     1# Makefile to run tests for Vim, on Dos-like machines
     2# with sh.exe or zsh.exe in the path or not.
     3#
     4# Author: Bill McCarthy
     5#
     6# Note that test54 has been removed until it is fixed.
     7#
     8# Requires a set of Unix tools: echo, diff, etc.
     9
     10ifneq (sh.exe, $(SHELL))
     11DEL = rm -f
     12MV = mv
     13CP = cp
     14DIRSLASH = /
     15else
     16DEL = del
     17MV = rename
     18CP = copy
     19DIRSLASH = \\
     20endif
     21
     22VIMPROG = ..$(DIRSLASH)vim
     23
     24# Omitted:
     25# test2         "\\tmp" doesn't work.
     26# test10        'errorformat' is different
     27# test12        can't unlink a swap file
     28# test25        uses symbolic link
     29# test27        can't edit file with "*" in file name
     30# test31        16 bit version runs out of memory...
     31
     32SCRIPTS16 =     test1.out test19.out test20.out test22.out \
     33                test23.out test24.out test28.out test29.out \
     34                test35.out test36.out test43.out \
     35                test44.out test45.out test46.out test47.out \
     36                test48.out test51.out test53.out            \
     37                test55.out test56.out test57.out test58.out test59.out \
     38                test60.out test61.out test62.out test63.out test64.out
     39
     40# Had to remove test54 which doesn't work yet.
     41#                                                test54.out
     42
     43SCRIPTS =       test3.out test4.out test5.out test6.out test7.out \
     44                test8.out test9.out test11.out test13.out test14.out \
     45                test15.out test17.out test18.out test21.out test26.out \
     46                test30.out test31.out test32.out test33.out test34.out \
     47                test37.out test38.out test39.out test40.out test41.out \
     48                test42.out test52.out test65.out
     49
     50SCRIPTS32 =     test50.out
     51
     52SCRIPTS_GUI = test16.out
     53
     54.SUFFIXES: .in .out
     55
     56vimall: fixff $(SCRIPTS16) $(SCRIPTS) $(SCRIPTS_GUI) $(SCRIPTS32)
     57        echo ALL DONE
     58
     59nongui: fixff $(SCRIPTS16) $(SCRIPTS)
     60        echo ALL DONE
     61
     62small:
     63        echo ALL DONE
     64
     65gui:    fixff $(SCRIPTS16) $(SCRIPTS) $(SCRIPTS_GUI)
     66        echo ALL DONE
     67
     68win32:  fixff $(SCRIPTS16) $(SCRIPTS) $(SCRIPTS32)
     69        echo ALL DONE
     70
     71fixff:
     72        -$(VIMPROG) -u dos.vim --noplugin "+argdo set ff=dos|upd" +q *.in *.ok
     73
     74clean:
     75        -$(DEL) *.out
     76        -$(DEL) test.ok
     77        -$(DEL) small.vim
     78        -$(DEL) tiny.vim
     79        -$(DEL) mbyte.vim
     80        -$(DEL) X*
     81        -$(DEL) viminfo
     82
     83.in.out:
     84        $(CP) $*.ok test.ok
     85        $(VIMPROG) -u dos.vim -U NONE --noplugin -s dotest.in $*.in
     86        diff test.out $*.ok
     87        -$(DEL) $*.out
     88        $(MV) test.out $*.out
     89        -$(DEL) X*
     90        -$(DEL) test.ok
     91        -$(DEL) viminfo
  • src/testdir/test42.ok

    diff -Naur vim72.orig/src/testdir/test42.ok vim72/src/testdir/test42.ok
    old new  
    2020ucs-2
    2121
    2222
    23   fileencoding=ucs-2le
     23  fileencoding=utf-16le
    2424  bomb
    2525ucs-2le
    2626
  • src/testdir/test66.in

    diff -Naur vim72.orig/src/testdir/test66.in vim72/src/testdir/test66.in
    old new  
     1
     2Test for visual block shift and tab characters.
     3
     4STARTTEST
     5:so small.vim
     6/^abcdefgh
     74jI    j<<11|D
     87|a             
     97|a               
     107|a             4k13|4j<
     11:$-4,$w! test.out
     12:$-4,$s/\s\+//g
     134kI    j<<
     147|a             
     157|a                                     
     167|a                     4k13|4j3<
     17:$-4,$w >> test.out
     18:qa!
     19ENDTEST
     20
     21abcdefghijklmnopqrstuvwxyz
     22abcdefghijklmnopqrstuvwxyz
     23abcdefghijklmnopqrstuvwxyz
     24abcdefghijklmnopqrstuvwxyz
     25abcdefghijklmnopqrstuvwxyz
  • src/testdir/test66.ok

    diff -Naur vim72.orig/src/testdir/test66.ok vim72/src/testdir/test66.ok
    old new  
     1    abcdefghijklmnopqrstuvwxyz
     2abcdefghij
     3    abc     defghijklmnopqrstuvwxyz
     4    abc     defghijklmnopqrstuvwxyz
     5    abc     defghijklmnopqrstuvwxyz
     6    abcdefghijklmnopqrstuvwxyz
     7abcdefghij
     8    abc     defghijklmnopqrstuvwxyz
     9    abc         defghijklmnopqrstuvwxyz
     10    abc     defghijklmnopqrstuvwxyz
  • src/ui.c

    diff -Naur vim72.orig/src/ui.c vim72/src/ui.c
    old new  
    18201820#ifdef HAVE_DUP
    18211821            /* Use stderr for stdin, also works for shell commands. */
    18221822            close(0);
    1823             dup(2);
     1823            ignored = dup(2);
    18241824#else
    18251825            read_cmd_fd = 2;    /* read from stderr instead of stdin */
    18261826#endif
     
    20202020
    20212021    if (value == NULL || *length == 0)
    20222022    {
    2023         clip_free_selection(cbd);       /* ???  [what's the query?] */
     2023        clip_free_selection(cbd);       /* nothing received, clear register */
    20242024        *(int *)success = FALSE;
    20252025        return;
    20262026    }
     
    20762076        text_prop.value = (unsigned char *)value;
    20772077        text_prop.encoding = *type;
    20782078        text_prop.format = *format;
    2079         text_prop.nitems = STRLEN(value);
     2079        text_prop.nitems = len;
    20802080        status = XmbTextPropertyToTextList(X_DISPLAY, &text_prop,
    20812081                                                         &text_list, &n_text);
    20822082        if (status != Success || n_text < 1)
     
    21102110    int         i;
    21112111    int         nbytes = 0;
    21122112    char_u      *buffer;
     2113    time_t      start_time;
     2114    int         timed_out = FALSE;
    21132115
    21142116    for (i =
    21152117#ifdef FEAT_MBYTE
     
    21292131            case 3:  type = text_atom;          break;
    21302132            default: type = XA_STRING;
    21312133        }
     2134        success = MAYBE;
    21322135        XtGetSelectionValue(myShell, cbd->sel_atom, type,
    21332136            clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
    21342137
     
    21412144         * characters, then they will appear before the one that requested the
    21422145         * paste!  Don't worry, we will catch up with any other events later.
    21432146         */
    2144         for (;;)
     2147        start_time = time(NULL);
     2148        while (success == MAYBE)
    21452149        {
    2146             if (XCheckTypedEvent(dpy, SelectionNotify, &event))
    2147                 break;
    2148             if (XCheckTypedEvent(dpy, SelectionRequest, &event))
    2149                 /* We may get a SelectionRequest here and if we don't handle
    2150                  * it we hang.  KDE klipper does this, for example. */
     2150            if (XCheckTypedEvent(dpy, SelectionNotify, &event)
     2151                    || XCheckTypedEvent(dpy, SelectionRequest, &event)
     2152                    || XCheckTypedEvent(dpy, PropertyNotify, &event))
     2153            {
     2154                /* This is where clip_x11_request_selection_cb() should be
     2155                 * called.  It may actually happen a bit later, so we loop
     2156                 * until "success" changes.
     2157                 * We may get a SelectionRequest here and if we don't handle
     2158                 * it we hang.  KDE klipper does this, for example.
     2159                 * We need to handle a PropertyNotify for large selections. */
    21512160                XtDispatchEvent(&event);
     2161                continue;
     2162            }
     2163
     2164            /* Time out after 2 to 3 seconds to avoid that we hang when the
     2165             * other process doesn't respond.  Note that the SelectionNotify
     2166             * event may still come later when the selection owner comes back
     2167             * to life and the text gets inserted unexpectedly.  Don't know
     2168             * why that happens or how to avoid that :-(. */
     2169            if (time(NULL) > start_time + 2)
     2170            {
     2171                timed_out = TRUE;
     2172                break;
     2173            }
    21522174
    21532175            /* Do we need this?  Probably not. */
    21542176            XSync(dpy, False);
    21552177
    2156             /* Bernhard Walle solved a slow paste response in an X terminal by
    2157              * adding: usleep(10000); here. */
     2178            /* Wait for 1 msec to avoid that we eat up all CPU time. */
     2179            ui_delay(1L, TRUE);
    21582180        }
    21592181
    2160         /* this is where clip_x11_request_selection_cb() is actually called */
    2161         XtDispatchEvent(&event);
    2162 
    2163         if (success)
     2182        if (success == TRUE)
    21642183            return;
     2184
     2185        /* don't do a retry with another type after timing out, otherwise we
     2186         * hang for 15 seconds. */
     2187        if (timed_out)
     2188            break;
    21652189    }
    21662190
    21672191    /* Final fallback position - use the X CUT_BUFFER0 store */
  • src/version.c

    diff -Naur vim72.orig/src/version.c vim72/src/version.c
    old new  
    677677static int included_patches[] =
    678678{   /* Add new patch number below this line */
    679679/**/
     680    141,
     681/**/
     682    140,
     683/**/
     684    139,
     685/**/
     686    137,
     687/**/
     688    136,
     689/**/
     690    135,
     691/**/
     692    134,
     693/**/
     694    133,
     695/**/
     696    132,
     697/**/
     698    131,
     699/**/
     700    130,
     701/**/
     702    129,
     703/**/
     704    128,
     705/**/
     706    127,
     707/**/
     708    126,
     709/**/
     710    125,
     711/**/
     712    124,
     713/**/
     714    123,
     715/**/
     716    122,
     717/**/
     718    121,
     719/**/
     720    120,
     721/**/
     722    119,
     723/**/
     724    118,
     725/**/
     726    117,
     727/**/
     728    116,
     729/**/
     730    115,
     731/**/
     732    114,
     733/**/
     734    113,
     735/**/
     736    112,
     737/**/
     738    111,
     739/**/
     740    110,
     741/**/
     742    109,
     743/**/
     744    108,
     745/**/
     746    107,
     747/**/
     748    106,
     749/**/
     750    105,
     751/**/
     752    104,
     753/**/
     754    103,
     755/**/
     756    102,
     757/**/
     758    100,
     759/**/
     760    99,
     761/**/
     762    98,
     763/**/
     764    97,
     765/**/
     766    96,
     767/**/
     768    95,
     769/**/
     770    94,
     771/**/
     772    92,
     773/**/
     774    91,
     775/**/
     776    90,
     777/**/
     778    87,
     779/**/
     780    86,
     781/**/
     782    85,
     783/**/
     784    84,
     785/**/
     786    83,
     787/**/
     788    82,
     789/**/
     790    81,
     791/**/
     792    80,
     793/**/
     794    79,
     795/**/
     796    78,
     797/**/
     798    77,
     799/**/
     800    76,
     801/**/
     802    75,
     803/**/
     804    73,
     805/**/
     806    70,
     807/**/
     808    69,
     809/**/
     810    68,
     811/**/
     812    67,
     813/**/
     814    66,
     815/**/
     816    65,
     817/**/
     818    64,
     819/**/
     820    63,
     821/**/
     822    62,
     823/**/
     824    61,
     825/**/
     826    60,
     827/**/
     828    59,
     829/**/
     830    58,
     831/**/
     832    57,
     833/**/
     834    56,
     835/**/
     836    55,
     837/**/
     838    54,
     839/**/
     840    53,
     841/**/
     842    52,
     843/**/
     844    51,
     845/**/
     846    50,
     847/**/
     848    48,
     849/**/
     850    47,
     851/**/
     852    46,
     853/**/
     854    45,
     855/**/
     856    44,
     857/**/
     858    43,
     859/**/
     860    42,
     861/**/
     862    40,
     863/**/
     864    39,
     865/**/
     866    38,
     867/**/
     868    37,
     869/**/
     870    35,
     871/**/
     872    34,
     873/**/
     874    33,
     875/**/
     876    32,
     877/**/
     878    31,
     879/**/
     880    30,
     881/**/
     882    29,
     883/**/
     884    28,
     885/**/
     886    27,
     887/**/
     888    26,
     889/**/
     890    25,
     891/**/
     892    24,
     893/**/
     894    23,
     895/**/
     896    22,
     897/**/
     898    21,
     899/**/
     900    20,
     901/**/
     902    19,
     903/**/
     904    18,
     905/**/
     906    17,
     907/**/
     908    16,
     909/**/
     910    15,
     911/**/
     912    14,
     913/**/
     914    13,
     915/**/
     916    12,
     917/**/
     918    11,
     919/**/
     920    10,
     921/**/
     922    9,
     923/**/
     924    8,
     925/**/
     926    6,
     927/**/
     928    5,
     929/**/
     930    4,
     931/**/
     932    3,
     933/**/
     934    2,
     935/**/
     936    1,
     937/**/
    680938    0
    681939};
    682940
     941/*
     942 * Place to put a short description when adding a feature with a patch.
     943 * Keep it short, e.g.,: "relative numbers", "persistent undo".
     944 * Also add a comment marker to separate the lines.
     945 * See the official Vim patches for the diff format: It must use a context of
     946 * one line only.  Create it by hand or use "diff -C2" and edit the patch.
     947 */
     948static char *(extra_patches[]) =
     949{   /* Add your patch description below this line */
     950/**/
     951    NULL
     952};
     953
    683954    int
    684955highest_patch()
    685956{
     
    7861057    MSG_PUTS(_("\nRISC OS version"));
    7871058#endif
    7881059#ifdef VMS
    789     MSG_PUTS("\nOpenVMS version");
     1060    MSG_PUTS(_("\nOpenVMS version"));
    7901061# ifdef HAVE_PATHDEF
    7911062    if (*compiled_arch != NUL)
    7921063    {
     
    8251096        }
    8261097    }
    8271098
     1099    /* Print the list of extra patch descriptions if there is at least one. */
     1100    if (extra_patches[0] != NULL)
     1101    {
     1102        MSG_PUTS(_("\nExtra patches: "));
     1103        s = "";
     1104        for (i = 0; extra_patches[i] != NULL; ++i)
     1105        {
     1106            MSG_PUTS(s);
     1107            s = ", ";
     1108            MSG_PUTS(extra_patches[i]);
     1109        }
     1110    }
     1111
    8281112#ifdef MODIFIED_BY
    8291113    MSG_PUTS("\n");
    8301114    MSG_PUTS(_("Modified by "));
  • src/vim.h

    diff -Naur vim72.orig/src/vim.h vim72/src/vim.h
    old new  
    341341#ifdef BACKSLASH_IN_FILENAME
    342342# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`%#'\"|!<")
    343343#else
    344 # define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
    345 # define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
     344# ifdef VMS
     345    /* VMS allows a lot of characters in the file name */
     346#  define PATH_ESC_CHARS ((char_u *)" \t\n*?{`\\%#'\"|!")
     347#  define SHELL_ESC_CHARS ((char_u *)" \t\n*?{`\\%#'|!()&")
     348# else
     349#  define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
     350#  define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
     351# endif
    346352#endif
    347353
    348354#define NUMBUFLEN 30        /* length of a buffer to store a number in ASCII */
     
    370376   * Define __w64 as an empty token for everything but MSVC 7.x or later.
    371377   */
    372378# if !defined(_MSC_VER) || (_MSC_VER < 1300)
    373 #  define __w64 
     379#  define __w64
    374380# endif
    375381typedef unsigned long __w64     long_u;
    376382typedef          long __w64     long_i;
     
    10511057#define WSP_HELP        16      /* creating the help window */
    10521058#define WSP_BELOW       32      /* put new window below/right */
    10531059#define WSP_ABOVE       64      /* put new window above/left */
     1060#define WSP_NEWLOC      128     /* don't copy location list */
    10541061
    10551062/*
    10561063 * arguments for gui_set_shellsize()
     
    17281735#define VV_MOUSE_COL    51
    17291736#define VV_OP           52
    17301737#define VV_SEARCHFORWARD 53
    1731 #define VV_LEN          54      /* number of v: vars */
     1738#define VV_OLDFILES     54
     1739#define VV_LEN          55      /* number of v: vars */
    17321740
    17331741#ifdef FEAT_CLIPBOARD
    17341742
     
    19791987# endif
    19801988#endif
    19811989
     1990#ifndef FEAT_NETBEANS_INTG
     1991# undef NBDEBUG
     1992#endif
    19821993#ifdef NBDEBUG /* Netbeans debugging. */
    19831994# include "nbdebug.h"
    19841995#else
     
    20542065#define DOSO_VIMRC      1       /* loading vimrc file */
    20552066#define DOSO_GVIMRC     2       /* loading gvimrc file */
    20562067
     2068/* flags for read_viminfo() and children */
     2069#define VIF_WANT_INFO           1       /* load non-mark info */
     2070#define VIF_WANT_MARKS          2       /* load file marks */
     2071#define VIF_FORCEIT             4       /* overwrite info already read */
     2072#define VIF_GET_OLDFILES        8       /* load v:oldfiles */
     2073
    20572074#endif /* VIM__H */
  • src/window.c

    diff -Naur vim72.orig/src/window.c vim72/src/window.c
    old new  
    1212static int path_is_url __ARGS((char_u *p));
    1313#if defined(FEAT_WINDOWS) || defined(PROTO)
    1414static int win_split_ins __ARGS((int size, int flags, win_T *newwin, int dir));
    15 static void win_init __ARGS((win_T *newp, win_T *oldp));
     15static void win_init __ARGS((win_T *newp, win_T *oldp, int flags));
    1616static void frame_comp_pos __ARGS((frame_T *topfrp, int *row, int *col));
    1717static void frame_setheight __ARGS((frame_T *curfrp, int height));
    1818#ifdef FEAT_VERTSPLIT
     
    593593                ++allow_keys;   /* no mapping for xchar, but allow key codes */
    594594                if (xchar == NUL)
    595595                    xchar = plain_vgetc();
    596 #ifdef FEAT_LANGMAP
    597596                LANGMAP_ADJUST(xchar, TRUE);
    598 #endif
    599597                --no_mapping;
    600598                --allow_keys;
    601599#ifdef FEAT_CMDL_INFO
     
    912910            return FAIL;
    913911
    914912        /* make the contents of the new window the same as the current one */
    915         win_init(wp, curwin);
     913        win_init(wp, curwin, flags);
    916914    }
    917915
    918916    /*
     
    11611159 * Initialize window "newp" from window "oldp".
    11621160 * Used when splitting a window and when creating a new tab page.
    11631161 * The windows will both edit the same buffer.
     1162 * WSP_NEWLOC may be specified in flags to prevent the location list from
     1163 * being copied.
    11641164 */
     1165/*ARGSUSED*/
    11651166    static void
    1166 win_init(newp, oldp)
     1167win_init(newp, oldp, flags)
    11671168    win_T       *newp;
    11681169    win_T       *oldp;
     1170    int          flags;
    11691171{
    11701172    int         i;
    11711173
     
    11901192    copy_jumplist(oldp, newp);
    11911193#endif
    11921194#ifdef FEAT_QUICKFIX
    1193     copy_loclist(oldp, newp);
     1195    if (flags & WSP_NEWLOC)
     1196    {
     1197        /* Don't copy the location list.  */
     1198        newp->w_llist = NULL;
     1199        newp->w_llist_ref = NULL;
     1200    }
     1201    else
     1202        copy_loclist(oldp, newp);
    11941203#endif
    11951204    if (oldp->w_localdir != NULL)
    11961205        newp->w_localdir = vim_strsave(oldp->w_localdir);
     
    32203229    else
    32213230    {
    32223231        /* First window in new tab page, initialize it from "oldwin". */
    3223         win_init(curwin, oldwin);
     3232        win_init(curwin, oldwin, 0);
    32243233
    32253234# ifdef FEAT_SCROLLBIND
    32263235        /* We don't want scroll-binding in the first window. */
     
    40284037            if (mch_dirname(cwd, MAXPATHL) == OK)
    40294038                globaldir = vim_strsave(cwd);
    40304039        }
    4031         mch_chdir((char *)curwin->w_localdir);
    4032         shorten_fnames(TRUE);
     4040        if (mch_chdir((char *)curwin->w_localdir) == 0)
     4041            shorten_fnames(TRUE);
    40334042    }
    40344043    else if (globaldir != NULL)
    40354044    {
    40364045        /* Window doesn't have a local directory and we are not in the global
    40374046         * directory: Change to the global directory. */
    4038         mch_chdir((char *)globaldir);
     4047        ignored = mch_chdir((char *)globaldir);
    40394048        vim_free(globaldir);
    40404049        globaldir = NULL;
    40414050        shorten_fnames(TRUE);
  • src/workshop.c

    diff -Naur vim72.orig/src/workshop.c vim72/src/workshop.c
    old new  
    11211121                                      ? (char *)curbuf->b_sfname : "<None>");
    11221122#endif
    11231123
    1124     strcpy(ffname, (char *) curbuf->b_ffname);
    1125     *filename = ffname;         /* copy so nobody can change b_ffname */
     1124    if (curbuf->b_ffname == NULL)
     1125        ffname[0] = NUL;
     1126    else
     1127        /* copy so nobody can change b_ffname */
     1128        strcpy(ffname, (char *) curbuf->b_ffname);
     1129    *filename = ffname;
    11261130    *curLine = curwin->w_cursor.lnum;
    11271131    *curCol = curwin->w_cursor.col;
    11281132
Note: See TracBrowser for help on using the repository browser.