source: patches/vim-7.1-branch_update-1.patch@ 0bf331c

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 0bf331c was 2830f42, checked in by Jim Gifford <clfs@…>, 17 years ago

Updated Vim Patch to Branch Update

  • Property mode set to 100644
File size: 250.0 KB
RevLine 
[ba61c16]1Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
[2830f42]2Date: 10-29-2007
[ba61c16]3Initial Package Version: 7.1
4Origin: Upstream
5Upstream Status: Applied
[2830f42]6Description: Contains all upstream patches up to 7.1.145
[ba61c16]7 The following patches were skipped
[c2aa910]8 003 007 041 065 070 072 080 088 091 092 124 126 128 129 134
[ba61c16]9
10diff -Naur vim71.orig/runtime/doc/change.txt vim71/runtime/doc/change.txt
11--- vim71.orig/runtime/doc/change.txt 2007-05-12 03:18:46.000000000 -0700
[2830f42]12+++ vim71/runtime/doc/change.txt 2007-10-29 08:09:16.000000000 -0700
[ba61c16]13@@ -1571,6 +1571,10 @@
14 in their original order, right before the sorted
15 lines.
16
17+ If {pattern} is empty (e.g. // is specified), the
18+ last search pattern is used. This allows trying out
19+ a pattern first.
20+
21 Note that using ":sort" with ":global" doesn't sort the matching lines, it's
22 quite useless.
23
24diff -Naur vim71.orig/runtime/doc/eval.txt vim71/runtime/doc/eval.txt
25--- vim71.orig/runtime/doc/eval.txt 2007-05-12 03:18:46.000000000 -0700
[2830f42]26+++ vim71/runtime/doc/eval.txt 2007-10-29 08:09:38.000000000 -0700
[ba61c16]27@@ -1,4 +1,4 @@
28-*eval.txt* For Vim version 7.1. Last change: 2007 May 11
[c2aa910]29+*eval.txt* For Vim version 7.1. Last change: 2007 Sep 25
[ba61c16]30
31
32 VIM REFERENCE MANUAL by Bram Moolenaar
33@@ -1557,6 +1557,7 @@
34 changenr() Number current change number
35 char2nr( {expr}) Number ASCII value of first char in {expr}
36 cindent( {lnum}) Number C indent for line {lnum}
37+clearmatches() None clear all matches
38 col( {expr}) Number column nr of cursor or mark
39 complete({startcol}, {matches}) String set Insert mode completion
40 complete_add( {expr}) Number add completion match
[c2aa910]41@@ -1602,7 +1603,7 @@
42 foldtextresult( {lnum}) String text for closed fold at {lnum}
43 foreground( ) Number bring the Vim window to the foreground
44 function( {name}) Funcref reference to function {name}
45-garbagecollect() none free memory, breaking cyclic references
46+garbagecollect( [at_exit]) none free memory, breaking cyclic references
47 get( {list}, {idx} [, {def}]) any get item {idx} from {list} or {def}
48 get( {dict}, {key} [, {def}]) any get item {key} from {dict} or {def}
49 getbufline( {expr}, {lnum} [, {end}])
[ba61c16]50@@ -1622,6 +1623,7 @@
51 getline( {lnum}) String line {lnum} of current buffer
52 getline( {lnum}, {end}) List lines {lnum} to {end} of current buffer
53 getloclist({nr}) List list of location list items
54+getmatches() List list of current matches
55 getpos( {expr}) List position of cursor, mark, etc.
56 getqflist() List list of quickfix items
57 getreg( [{regname} [, 1]]) String contents of register
58@@ -1676,7 +1678,10 @@
59 String check for mappings matching {name}
60 match( {expr}, {pat}[, {start}[, {count}]])
61 Number position where {pat} matches in {expr}
62+matchadd( {group}, {pattern}[, {priority}[, {id}]])
63+ Number highlight {pattern} with {group}
64 matcharg( {nr}) List arguments of |:match|
65+matchdelete( {id}) Number delete match identified by {id}
66 matchend( {expr}, {pat}[, {start}[, {count}]])
67 Number position where {pat} ends in {expr}
68 matchlist( {expr}, {pat}[, {start}[, {count}]])
69@@ -1731,6 +1736,7 @@
70 setline( {lnum}, {line}) Number set line {lnum} to {line}
71 setloclist( {nr}, {list}[, {action}])
72 Number modify location list using {list}
73+setmatches( {list}) Number restore a list of matches
74 setpos( {expr}, {list}) none set the {expr} position to {list}
75 setqflist( {list}[, {action}]) Number modify quickfix list using {list}
76 setreg( {n}, {v}[, {opt}]) Number set register to value and type
77@@ -2012,6 +2018,10 @@
78 feature, -1 is returned.
79 See |C-indenting|.
80
81+clearmatches() *clearmatches()*
82+ Clears all matches previously defined by |matchadd()| and the
83+ |:match| commands.
84+
85 *col()*
86 col({expr}) The result is a Number, which is the byte index of the column
87 position given with {expr}. The accepted positions are:
88@@ -2020,6 +2030,10 @@
89 number of characters in the cursor line plus one)
90 'x position of mark x (if the mark is not set, 0 is
91 returned)
92+ Additionally {expr} can be [lnum, col]: a |List| with the line
93+ and column number. Most useful when the column is "$", to get
94+ the las column of a specific line. When "lnum" or "col" is
95+ out of range then col() returns zero.
96 To get the line number use |line()|. To get both use
97 |getpos()|.
98 For the screen column position use |virtcol()|.
[c2aa910]99@@ -2659,7 +2673,7 @@
100 {name} can be a user defined function or an internal function.
101
102
103-garbagecollect() *garbagecollect()*
104+garbagecollect([at_exit]) *garbagecollect()*
105 Cleanup unused |Lists| and |Dictionaries| that have circular
106 references. There is hardly ever a need to invoke this
107 function, as it is automatically done when Vim runs out of
108@@ -2669,6 +2683,9 @@
109 This is useful if you have deleted a very big |List| and/or
110 |Dictionary| with circular references in a script that runs
111 for a long time.
112+ When the optional "at_exit" argument is one, garbage
113+ collection will also be done when exiting Vim, if it wasn't
114+ done before. This is useful when checking for memory leaks.
115
116 get({list}, {idx} [, {default}]) *get()*
117 Get item {idx} from |List| {list}. When this item is not
118@@ -2824,6 +2841,8 @@
[ba61c16]119 given file {fname}.
120 If {fname} is a directory, 0 is returned.
121 If the file {fname} can't be found, -1 is returned.
122+ If the size of {fname} is too big to fit in a Number then -2
123+ is returned.
124
125 getfontname([{name}]) *getfontname()*
126 Without an argument returns the name of the normal font being
[c2aa910]127@@ -2912,6 +2931,28 @@
[ba61c16]128 returned. For an invalid window number {nr}, an empty list is
129 returned. Otherwise, same as getqflist().
130
131+getmatches() *getmatches()*
132+ Returns a |List| with all matches previously defined by
133+ |matchadd()| and the |:match| commands. |getmatches()| is
134+ useful in combination with |setmatches()|, as |setmatches()|
135+ can restore a list of matches saved by |getmatches()|.
136+ Example: >
137+ :echo getmatches()
138+< [{'group': 'MyGroup1', 'pattern': 'TODO',
139+ 'priority': 10, 'id': 1}, {'group': 'MyGroup2',
140+ 'pattern': 'FIXME', 'priority': 10, 'id': 2}] >
141+ :let m = getmatches()
142+ :call clearmatches()
143+ :echo getmatches()
144+< [] >
145+ :call setmatches(m)
146+ :echo getmatches()
147+< [{'group': 'MyGroup1', 'pattern': 'TODO',
148+ 'priority': 10, 'id': 1}, {'group': 'MyGroup2',
149+ 'pattern': 'FIXME', 'priority': 10, 'id': 2}] >
150+ :unlet m
151+<
152+
153 getqflist() *getqflist()*
154 Returns a list with all the current quickfix errors. Each
155 list item is a dictionary with these entries:
[c2aa910]156@@ -3616,6 +3657,44 @@
[ba61c16]157 the pattern. 'smartcase' is NOT used. The matching is always
158 done like 'magic' is set and 'cpoptions' is empty.
159
160+ *matchadd()* *E798* *E799* *E801*
161+matchadd({group}, {pattern}[, {priority}[, {id}]])
162+ Defines a pattern to be highlighted in the current window (a
163+ "match"). It will be highlighted with {group}. Returns an
164+ identification number (ID), which can be used to delete the
165+ match using |matchdelete()|.
166+
167+ The optional {priority} argument assigns a priority to the
168+ match. A match with a high priority will have its
169+ highlighting overrule that of a match with a lower priority.
170+ A priority is specified as an integer (negative numbers are no
171+ exception). If the {priority} argument is not specified, the
172+ default priority is 10. The priority of 'hlsearch' is zero,
173+ hence all matches with a priority greater than zero will
174+ overrule it. Syntax highlighting (see 'syntax') is a separate
175+ mechanism, and regardless of the chosen priority a match will
176+ always overrule syntax highlighting.
177+
178+ The optional {id} argument allows the request for a specific
179+ match ID. If a specified ID is already taken, an error
180+ message will appear and the match will not be added. An ID
181+ is specified as a positive integer (zero excluded). IDs 1, 2
182+ and 3 are reserved for |:match|, |:2match| and |:3match|,
183+ respectively. If the {id} argument is not specified,
184+ |matchadd()| automatically chooses a free ID.
185+
186+ The number of matches is not limited, as it is the case with
187+ the |:match| commands.
188+
189+ Example: >
190+ :highlight MyGroup ctermbg=green guibg=green
191+ :let m = matchadd("MyGroup", "TODO")
192+< Deletion of the pattern: >
193+ :call matchdelete(m)
194+
195+< A list of matches defined by |matchadd()| and |:match| are
196+ available from |getmatches()|. All matches can be deleted in
197+ one operation by |clearmatches()|.
198
199 matcharg({nr}) *matcharg()*
200 Selects the {nr} match item, as set with a |:match|,
[c2aa910]201@@ -3625,8 +3704,15 @@
[ba61c16]202 The pattern used.
203 When {nr} is not 1, 2 or 3 returns an empty |List|.
204 When there is no match item set returns ['', ''].
205- This is usef to save and restore a |:match|.
206-
207+ This is useful to save and restore a |:match|.
208+ Highlighting matches using the |:match| commands are limited
209+ to three matches. |matchadd()| does not have this limitation.
210+
211+matchdelete({id}) *matchdelete()* *E802* *E803*
212+ Deletes a match with ID {id} previously defined by |matchadd()|
213+ or one of the |:match| commands. Returns 0 if succesfull,
214+ otherwise -1. See example for |matchadd()|. All matches can
215+ be deleted in one operation by |clearmatches()|.
216
217 matchend({expr}, {pat}[, {start}[, {count}]]) *matchend()*
218 Same as match(), but return the index of first character after
[c2aa910]219@@ -4379,7 +4465,13 @@
[ba61c16]220 When {nr} is zero the current window is used. For a location
221 list window, the displayed location list is modified. For an
222 invalid window number {nr}, -1 is returned.
223- Otherwise, same as setqflist().
224+ Otherwise, same as |setqflist()|.
225+ Also see |location-list|.
226+
227+setmatches({list}) *setmatches()*
228+ Restores a list of matches saved by |getmatches()|. Returns 0
229+ if succesfull, otherwise -1. All current matches are cleared
230+ before the list is restored. See example for |getmatches()|.
231
232 *setpos()*
233 setpos({expr}, {list})
[c2aa910]234@@ -5022,14 +5114,12 @@
[ba61c16]235 position, the returned Number will be the column at the end of
236 the <Tab>. For example, for a <Tab> in column 1, with 'ts'
237 set to 8, it returns 8.
238- For the use of {expr} see |col()|. Additionally you can use
239- [lnum, col]: a |List| with the line and column number. When
240- "lnum" or "col" is out of range then virtcol() returns zero.
241- When 'virtualedit' is used it can be [lnum, col, off], where
242+ For the byte position use |col()|.
243+ For the use of {expr} see |col()|.
244+ When 'virtualedit' is used {expr} can be [lnum, col, off], where
245 "off" is the offset in screen columns from the start of the
246 character. E.g., a position within a <Tab> or after the last
247 character.
248- For the byte position use |col()|.
249 When Virtual editing is active in the current mode, a position
250 beyond the end of the line can be returned. |'virtualedit'|
251 The accepted positions are:
252diff -Naur vim71.orig/runtime/doc/options.txt vim71/runtime/doc/options.txt
253--- vim71.orig/runtime/doc/options.txt 2007-05-12 03:18:47.000000000 -0700
[2830f42]254+++ vim71/runtime/doc/options.txt 2007-10-29 08:09:23.000000000 -0700
[ba61c16]255@@ -1,4 +1,4 @@
256-*options.txt* For Vim version 7.1. Last change: 2007 May 11
257+*options.txt* For Vim version 7.1. Last change: 2007 Aug 10
258
259
260 VIM REFERENCE MANUAL by Bram Moolenaar
261@@ -2415,8 +2415,8 @@
262 When mixing vertically and horizontally split windows, a minimal size
263 is computed and some windows may be larger if there is room. The
264 'eadirection' option tells in which direction the size is affected.
265- Changing the height of a window can be avoided by setting
266- 'winfixheight'.
267+ Changing the height and width of a window can be avoided by setting
268+ 'winfixheight' and 'winfixwidth', respectively.
269
270 *'equalprg'* *'ep'*
271 'equalprg' 'ep' string (default "")
272diff -Naur vim71.orig/runtime/doc/pattern.txt vim71/runtime/doc/pattern.txt
273--- vim71.orig/runtime/doc/pattern.txt 2007-05-12 03:18:47.000000000 -0700
[2830f42]274+++ vim71/runtime/doc/pattern.txt 2007-10-29 08:09:16.000000000 -0700
[ba61c16]275@@ -1212,7 +1212,10 @@
276 {group} must exist at the moment this command is executed.
277
278 The {group} highlighting still applies when a character is
279- to be highlighted for 'hlsearch'.
280+ to be highlighted for 'hlsearch', as the highlighting for
281+ matches is given higher priority than that of 'hlsearch'.
282+ Syntax highlighting (see 'syntax') is also overruled by
283+ matches.
284
285 Note that highlighting the last used search pattern with
286 'hlsearch' is used in all windows, while the pattern defined
287@@ -1226,8 +1229,15 @@
288 display you may get unexpected results. That is because Vim
289 looks for a match in the line where redrawing starts.
290
291- Also see |matcharg()|, it returns the highlight group and
292- pattern of a previous :match command.
293+ Also see |matcharg()|and |getmatches()|. The former returns
294+ the highlight group and pattern of a previous |:match|
295+ command. The latter returns a list with highlight groups and
296+ patterns defined by both |matchadd()| and |:match|.
297+
298+ Highlighting matches using |:match| are limited to three
299+ matches (aside from |:match|, |:2match| and |:3match|are
300+ available). |matchadd()| does not have this limitation and in
301+ addition makes it possible to prioritize matches.
302
303 Another example, which highlights all characters in virtual
304 column 72 and more: >
305diff -Naur vim71.orig/runtime/doc/pi_paren.txt vim71/runtime/doc/pi_paren.txt
306--- vim71.orig/runtime/doc/pi_paren.txt 2007-05-12 03:18:47.000000000 -0700
[2830f42]307+++ vim71/runtime/doc/pi_paren.txt 2007-10-29 08:09:30.000000000 -0700
[ba61c16]308@@ -12,8 +12,8 @@
309 You can avoid loading this plugin by setting the "loaded_matchparen" variable: >
310 :let loaded_matchparen = 1
311
312-The plugin installs CursorMoved autocommands to redefine the match
313-highlighting.
314+The plugin installs CursorMoved, CursorMovedI and WinEnter autocommands to
315+redefine the match highlighting.
316
317 To disable the plugin after it was loaded use this command: >
318
319diff -Naur vim71.orig/runtime/doc/usr_41.txt vim71/runtime/doc/usr_41.txt
320--- vim71.orig/runtime/doc/usr_41.txt 2007-05-12 03:18:48.000000000 -0700
[2830f42]321+++ vim71/runtime/doc/usr_41.txt 2007-10-29 08:09:16.000000000 -0700
[ba61c16]322@@ -763,13 +763,22 @@
323 foldtextresult() get the text displayed for a closed fold
324
325 Syntax and highlighting:
326+ clearmatches() clear all matches defined by |matchadd()| and
327+ the |:match| commands
328+ getmatches() get all matches defined by |matchadd()| and
329+ the |:match| commands
330 hlexists() check if a highlight group exists
331 hlID() get ID of a highlight group
332 synID() get syntax ID at a specific position
333 synIDattr() get a specific attribute of a syntax ID
334 synIDtrans() get translated syntax ID
335 diff_hlID() get highlight ID for diff mode at a position
336+ matchadd() define a pattern to highlight (a "match")
337 matcharg() get info about |:match| arguments
338+ matchdelete() delete a match defined by |matchadd()| or a
339+ |:match| command
340+ setmatches() restore a list of matches saved by
341+ |getmatches()|
342
343 Spelling:
344 spellbadword() locate badly spelled word at or after cursor
345diff -Naur vim71.orig/runtime/doc/windows.txt vim71/runtime/doc/windows.txt
346--- vim71.orig/runtime/doc/windows.txt 2007-05-12 03:18:49.000000000 -0700
[2830f42]347+++ vim71/runtime/doc/windows.txt 2007-10-29 08:09:23.000000000 -0700
[ba61c16]348@@ -132,7 +132,8 @@
349 the same file. Make new window N high (default is to use half
350 the height of the current window). Reduces the current window
351 height to create room (and others, if the 'equalalways' option
352- is set and 'eadirection' isn't "hor").
353+ is set, 'eadirection' isn't "hor", and one of them is higher
354+ than the current or the new window).
355 Note: CTRL-S does not work on all terminals and might block
356 further input, use CTRL-Q to get going again.
357 Also see |++opt| and |+cmd|.
358@@ -140,9 +141,13 @@
359 CTRL-W CTRL-V *CTRL-W_CTRL-V*
360 CTRL-W v *CTRL-W_v*
361 :[N]vs[plit] [++opt] [+cmd] [file] *:vs* *:vsplit*
362- Like |:split|, but split vertically. If 'equalalways' is set
363- and 'eadirection' isn't "ver" the windows will be spread out
364- horizontally, unless a width was specified.
365+ Like |:split|, but split vertically. The windows will be
366+ spread out horizontally if
367+ 1. a width was not specified,
368+ 2. 'equalalways' is set,
369+ 3. 'eadirection' isn't "ver", and
370+ 4. one of the other windows are wider than the current or new
371+ window.
372 Note: In other places CTRL-Q does the same as CTRL-V, but here
373 it doesn't!
374
375diff -Naur vim71.orig/runtime/filetype.vim vim71/runtime/filetype.vim
376--- vim71.orig/runtime/filetype.vim 2007-05-10 08:14:37.000000000 -0700
[2830f42]377+++ vim71/runtime/filetype.vim 2007-10-29 08:09:11.000000000 -0700
[ba61c16]378@@ -1,7 +1,7 @@
379 " Vim support file to detect file types
380 "
381 " Maintainer: Bram Moolenaar <Bram@vim.org>
382-" Last Change: 2007 May 10
383+" Last Change: 2007 May 15
384
385 " Listen very carefully, I will say this only once
386 if exists("did_load_filetypes")
387@@ -1286,7 +1286,7 @@
388 au BufNewFile,BufRead *.it,*.ih setf ppwiz
389
390 " Oracle Pro*C/C++
391-au BufNewFile,BufRead .pc setf proc
392+au BufNewFile,BufRead *.pc setf proc
393
394 " Privoxy actions file
395 au BufNewFile,BufRead *.action setf privoxy
396diff -Naur vim71.orig/runtime/plugin/matchparen.vim vim71/runtime/plugin/matchparen.vim
397--- vim71.orig/runtime/plugin/matchparen.vim 2006-10-12 13:05:05.000000000 -0700
[2830f42]398+++ vim71/runtime/plugin/matchparen.vim 2007-10-29 08:09:30.000000000 -0700
[ba61c16]399@@ -1,6 +1,6 @@
400 " Vim plugin for showing matching parens
401 " Maintainer: Bram Moolenaar <Bram@vim.org>
402-" Last Change: 2006 Oct 12
403+" Last Change: 2007 Aug 8
404
405 " Exit quickly when:
406 " - this plugin was already loaded (or disabled)
407@@ -13,7 +13,7 @@
408
409 augroup matchparen
410 " Replace all matchparen autocommands
411- autocmd! CursorMoved,CursorMovedI * call s:Highlight_Matching_Pair()
412+ autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair()
413 augroup END
414
415 " Skip the rest if it was already done.
416@@ -62,25 +62,37 @@
417 " Figure out the arguments for searchpairpos().
418 " Restrict the search to visible lines with "stopline".
419 " And avoid searching very far (e.g., for closed folds and long lines)
420+ " The "viewable" variables give a range in which we can scroll while keeping
421+ " the cursor at the same position
422+ " adjustedScrolloff accounts for very large numbers of scrolloff
423+ let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2])
424+ let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2])
425+ let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2])
426+ " one of these stoplines will be adjusted below, but the current values are
427+ " minimal boundaries within the current window
428+ let stoplinebottom = line('w$')
429+ let stoplinetop = line('w0')
430 if i % 2 == 0
431 let s_flags = 'nW'
432 let c2 = plist[i + 1]
433 if has("byte_offset") && has("syntax_items") && &smc > 0
434 let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2])
435- let stopline = min([line('w$'), byte2line(stopbyte)])
436+ let stopline = min([bottom_viewable, byte2line(stopbyte)])
437 else
438- let stopline = min([line('w$'), c_lnum + 100])
439+ let stopline = min([bottom_viewable, c_lnum + 100])
440 endif
441+ let stoplinebottom = stopline
442 else
443 let s_flags = 'nbW'
444 let c2 = c
445 let c = plist[i - 1]
446 if has("byte_offset") && has("syntax_items") && &smc > 0
447 let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2])
448- let stopline = max([line('w0'), byte2line(stopbyte)])
449+ let stopline = max([top_viewable, byte2line(stopbyte)])
450 else
451- let stopline = max([line('w0'), c_lnum - 100])
452+ let stopline = max([top_viewable, c_lnum - 100])
453 endif
454+ let stoplinetop = stopline
455 endif
456 if c == '['
457 let c = '\['
458@@ -106,7 +118,7 @@
459 endif
460
461 " If a match is found setup match highlighting.
462- if m_lnum > 0 && m_lnum >= line('w0') && m_lnum <= line('w$')
463+ if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom
464 exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) .
465 \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
466 let w:paren_hl_on = 1
467@@ -114,7 +126,8 @@
468 endfunction
469
470 " Define commands that will disable and enable the plugin.
471-command! NoMatchParen 3match none | unlet! g:loaded_matchparen | au! matchparen
472-command! DoMatchParen runtime plugin/matchparen.vim | doau CursorMoved
473+command! NoMatchParen windo 3match none | unlet! g:loaded_matchparen |
474+ \ au! matchparen
475+command! DoMatchParen runtime plugin/matchparen.vim | windo doau CursorMoved
476
477 let &cpo = cpo_save
478diff -Naur vim71.orig/src/auto/configure vim71/src/auto/configure
479--- vim71.orig/src/auto/configure 2007-05-12 04:49:09.000000000 -0700
[2830f42]480+++ vim71/src/auto/configure 2007-10-29 08:09:16.000000000 -0700
[ba61c16]481@@ -3843,7 +3843,9 @@
482 fi
483
484 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
485- if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
486+ if test "x$MACOSX" = "xyes"; then
487+ MZSCHEME_LIBS="-framework PLT_MzScheme"
488+ elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
489 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
490 else
491 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
492diff -Naur vim71.orig/src/buffer.c vim71/src/buffer.c
493--- vim71.orig/src/buffer.c 2007-05-10 08:25:59.000000000 -0700
[2830f42]494+++ vim71/src/buffer.c 2007-10-29 08:09:50.000000000 -0700
[ba61c16]495@@ -171,6 +171,13 @@
496 /* Put the cursor on the first line. */
497 curwin->w_cursor.lnum = 1;
498 curwin->w_cursor.col = 0;
499+
500+ /* Set or reset 'modified' before executing autocommands, so that
501+ * it can be changed there. */
502+ if (!readonlymode && !bufempty())
503+ changed();
504+ else if (retval != FAIL)
505+ unchanged(curbuf, FALSE);
506 #ifdef FEAT_AUTOCMD
507 # ifdef FEAT_EVAL
508 apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE,
509@@ -194,16 +201,16 @@
510 /* When reading stdin, the buffer contents always needs writing, so set
511 * the changed flag. Unless in readonly mode: "ls | gview -".
512 * When interrupted and 'cpoptions' contains 'i' set changed flag. */
513- if ((read_stdin && !readonlymode && !bufempty())
514+ if ((got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
515 #ifdef FEAT_AUTOCMD
516 || modified_was_set /* ":set modified" used in autocmd */
517 # ifdef FEAT_EVAL
518 || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)
519 # endif
520 #endif
521- || (got_int && vim_strchr(p_cpo, CPO_INTMOD) != NULL))
522+ )
523 changed();
524- else if (retval != FAIL)
525+ else if (retval != FAIL && !read_stdin)
526 unchanged(curbuf, FALSE);
527 save_file_ff(curbuf); /* keep this fileformat */
528
529@@ -495,6 +502,7 @@
530 buf->b_start_eol = TRUE;
531 #ifdef FEAT_MBYTE
532 buf->b_p_bomb = FALSE;
533+ buf->b_start_bomb = FALSE;
534 #endif
535 buf->b_ml.ml_mfp = NULL;
536 buf->b_ml.ml_flags = ML_EMPTY; /* empty buffer */
[c2aa910]537@@ -4167,29 +4175,35 @@
538 * mess up the full path name, even though it starts with a '/'.
539 * Also expand when there is ".." in the file name, try to remove it,
540 * because "c:/src/../README" is equal to "c:/README".
541+ * Similarly "c:/src//file" is equal to "c:/src/file".
542 * For MS-Windows also expand names like "longna~1" to "longname".
543 */
544 #ifdef UNIX
545 return FullName_save(fname, TRUE);
546 #else
547- if (!vim_isAbsName(fname) || strstr((char *)fname, "..") != NULL
548-#if defined(MSWIN) || defined(DJGPP)
549+ if (!vim_isAbsName(fname)
550+ || strstr((char *)fname, "..") != NULL
551+ || strstr((char *)fname, "//") != NULL
552+# ifdef BACKSLASH_IN_FILENAME
553+ || strstr((char *)fname, "\\\\") != NULL
554+# endif
555+# if defined(MSWIN) || defined(DJGPP)
556 || vim_strchr(fname, '~') != NULL
557-#endif
558+# endif
559 )
560 return FullName_save(fname, FALSE);
561
562 fname = vim_strsave(fname);
563
564-#ifdef USE_FNAME_CASE
565-# ifdef USE_LONG_FNAME
566+# ifdef USE_FNAME_CASE
567+# ifdef USE_LONG_FNAME
568 if (USE_LONG_FNAME)
569-# endif
570+# endif
571 {
572 if (fname != NULL)
573 fname_case(fname, 0); /* set correct case for file name */
574 }
575-#endif
576+# endif
577
578 return fname;
579 #endif
580@@ -4853,7 +4867,7 @@
[ba61c16]581 */
582 for (e = s; *e != ':' && *e != NUL; ++e)
583 if (e[0] == '\\' && e[1] == ':')
584- STRCPY(e, e + 1);
585+ mch_memmove(e, e + 1, STRLEN(e));
586 if (*e == NUL)
587 end = TRUE;
588
[c2aa910]589@@ -5507,11 +5521,11 @@
590
591 #ifdef FEAT_AUTOCMD
592 if (!aucmd) /* Don't trigger BufDelete autocommands here. */
593- ++autocmd_block;
594+ block_autocmds();
595 #endif
596 close_buffer(NULL, buf, DOBUF_WIPE);
597 #ifdef FEAT_AUTOCMD
598 if (!aucmd)
599- --autocmd_block;
600+ unblock_autocmds();
601 #endif
602 }
[ba61c16]603diff -Naur vim71.orig/src/charset.c vim71/src/charset.c
604--- vim71.orig/src/charset.c 2007-03-24 13:10:37.000000000 -0700
[2830f42]605+++ vim71/src/charset.c 2007-10-29 08:09:30.000000000 -0700
[ba61c16]606@@ -207,7 +207,10 @@
607 }
608 while (c <= c2)
609 {
610- if (!do_isalpha || isalpha(c)
611+ /* Use the MB_ functions here, because isalpha() doesn't
612+ * work properly when 'encoding' is "latin1" and the locale is
613+ * "C". */
614+ if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c)
615 #ifdef FEAT_FKMAP
616 || (p_altkeymap && (F_isalpha(c) || F_isdigit(c)))
617 #endif
618@@ -929,6 +932,23 @@
619 }
620
621 /*
622+ * return TRUE if 'c' is a valid file-name character or a wildcard character
623+ * Assume characters above 0x100 are valid (multi-byte).
624+ * Explicitly interpret ']' as a wildcard character as mch_has_wildcard("]")
625+ * returns false.
626+ */
627+ int
628+vim_isfilec_or_wc(c)
629+ int c;
630+{
631+ char_u buf[2];
632+
633+ buf[0] = (char_u)c;
634+ buf[1] = NUL;
635+ return vim_isfilec(c) || c == ']' || mch_has_wildcard(buf);
636+}
637+
638+/*
639 * return TRUE if 'c' is a printable character
640 * Assume characters above 0x100 are printable (multi-byte), except for
641 * Unicode.
642@@ -1898,7 +1918,7 @@
643 {
644 for ( ; *p; ++p)
645 if (rem_backslash(p))
646- STRCPY(p, p + 1);
647+ mch_memmove(p, p + 1, STRLEN(p));
648 }
649
650 /*
651diff -Naur vim71.orig/src/configure.in vim71/src/configure.in
652--- vim71.orig/src/configure.in 2007-05-12 02:19:27.000000000 -0700
[2830f42]653+++ vim71/src/configure.in 2007-10-29 08:09:16.000000000 -0700
[ba61c16]654@@ -423,7 +423,9 @@
655 fi
656
657 if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
658- if test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
659+ if test "x$MACOSX" = "xyes"; then
660+ MZSCHEME_LIBS="-framework PLT_MzScheme"
661+ elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"; then
662 MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme.a ${vi_cv_path_mzscheme_pfx}/lib/libmzgc.a"
663 else
664 MZSCHEME_LIBS="-L${vi_cv_path_mzscheme_pfx}/lib -lmzscheme -lmzgc"
[c2aa910]665diff -Naur vim71.orig/src/diff.c vim71/src/diff.c
666--- vim71.orig/src/diff.c 2007-02-15 16:18:41.000000000 -0800
[2830f42]667+++ vim71/src/diff.c 2007-10-29 08:09:51.000000000 -0700
668@@ -791,6 +791,9 @@
669 }
670 mch_remove(tmp_orig);
671
672+ /* force updating cursor position on screen */
673+ curwin->w_valid_cursor.lnum = 0;
674+
675 diff_redraw(TRUE);
676
677 theend:
678@@ -840,11 +843,11 @@
[c2aa910]679 tmp_orig, tmp_new);
680 append_redir(cmd, p_srr, tmp_diff);
681 #ifdef FEAT_AUTOCMD
682- ++autocmd_block; /* Avoid ShellCmdPost stuff */
683+ block_autocmds(); /* Avoid ShellCmdPost stuff */
684 #endif
685 (void)call_shell(cmd, SHELL_FILTER|SHELL_SILENT|SHELL_DOOUT);
686 #ifdef FEAT_AUTOCMD
687- --autocmd_block;
688+ unblock_autocmds();
689 #endif
690 vim_free(cmd);
691 }
[2830f42]692@@ -949,11 +952,11 @@
[c2aa910]693 # endif
694 eap->arg);
695 #ifdef FEAT_AUTOCMD
696- ++autocmd_block; /* Avoid ShellCmdPost stuff */
697+ block_autocmds(); /* Avoid ShellCmdPost stuff */
698 #endif
699 (void)call_shell(buf, SHELL_FILTER | SHELL_COOKED);
700 #ifdef FEAT_AUTOCMD
701- --autocmd_block;
702+ unblock_autocmds();
703 #endif
704 }
705
[2830f42]706@@ -1310,7 +1313,7 @@
707 dp->df_count[idx_new] += -off;
708 off = 0;
709 }
710- for (i = idx_orig; i < idx_new + !notset; ++i)
711+ for (i = idx_orig; i < idx_new; ++i)
712 if (curtab->tp_diffbuf[i] != NULL)
713 dp->df_count[i] = dpl->df_lnum[i] + dpl->df_count[i]
714 - dp->df_lnum[i] + off;
[ba61c16]715diff -Naur vim71.orig/src/digraph.c vim71/src/digraph.c
716--- vim71.orig/src/digraph.c 2006-05-02 11:24:04.000000000 -0700
[2830f42]717+++ vim71/src/digraph.c 2007-10-29 08:09:37.000000000 -0700
[c2aa910]718@@ -2028,7 +2028,7 @@
719
720 ++no_mapping;
721 ++allow_keys;
722- c = safe_vgetc();
723+ c = plain_vgetc();
724 --no_mapping;
725 --allow_keys;
726 if (c != ESC) /* ESC cancels CTRL-K */
727@@ -2050,7 +2050,7 @@
728 #endif
729 ++no_mapping;
730 ++allow_keys;
731- cc = safe_vgetc();
732+ cc = plain_vgetc();
733 --no_mapping;
734 --allow_keys;
735 if (cc != ESC) /* ESC cancels CTRL-K */
[ba61c16]736@@ -2349,8 +2349,10 @@
737
738 if (*curbuf->b_p_keymap == NUL)
739 {
740- /* Stop any active keymap and clear the table. */
741+ /* Stop any active keymap and clear the table. Also remove
[c2aa910]742+ * b:keymap_name, as no keymap is active now. */
[ba61c16]743 keymap_unload();
744+ do_cmdline_cmd((char_u *)"unlet! b:keymap_name");
745 }
746 else
747 {
748@@ -2500,7 +2502,6 @@
749
750 ga_clear(&curbuf->b_kmap_ga);
751 curbuf->b_kmap_state &= ~KEYMAP_LOADED;
752- do_cmdline_cmd((char_u *)"unlet! b:keymap_name");
753 #ifdef FEAT_WINDOWS
754 status_redraw_curbuf();
755 #endif
756diff -Naur vim71.orig/src/edit.c vim71/src/edit.c
757--- vim71.orig/src/edit.c 2007-05-07 12:43:55.000000000 -0700
[2830f42]758+++ vim71/src/edit.c 2007-10-29 08:09:51.000000000 -0700
759@@ -129,6 +129,7 @@
760
761 static void ins_ctrl_x __ARGS((void));
762 static int has_compl_option __ARGS((int dict_opt));
763+static int ins_compl_accept_char __ARGS((int c));
764 static int ins_compl_add __ARGS((char_u *str, int len, int icase, char_u *fname, char_u **cptext, int cdir, int flags, int adup));
765 static int ins_compl_equal __ARGS((compl_T *match, char_u *str, int len));
766 static void ins_compl_longest_match __ARGS((compl_T *match));
767@@ -754,8 +755,9 @@
768 continue;
769 }
770
771- /* A printable, non-white character: Add to "compl_leader". */
772- if (vim_isprintc(c) && !vim_iswhite(c))
773+ /* A non-white character that fits in with the current
774+ * completion: Add to "compl_leader". */
775+ if (ins_compl_accept_char(c))
776 {
777 ins_compl_addleader(c);
778 continue;
779@@ -788,7 +790,7 @@
[c2aa910]780 ins_redraw(FALSE);
781 ++no_mapping;
782 ++allow_keys;
783- c = safe_vgetc();
784+ c = plain_vgetc();
785 --no_mapping;
786 --allow_keys;
787 if (c != Ctrl_N && c != Ctrl_G && c != Ctrl_O)
[2830f42]788@@ -981,7 +983,7 @@
[c2aa910]789 #ifdef FEAT_NETBEANS_INTG
790 case K_F21: /* NetBeans command */
791 ++no_mapping; /* don't map the next key hits */
792- i = safe_vgetc();
793+ i = plain_vgetc();
794 --no_mapping;
795 netbeans_keycommand(i);
796 break;
[2830f42]797@@ -2053,11 +2055,44 @@
798 }
799
800 /*
801+ * Return TRUE when character "c" is part of the item currently being
802+ * completed. Used to decide whether to abandon complete mode when the menu
803+ * is visible.
804+ */
805+ static int
806+ins_compl_accept_char(c)
807+ int c;
808+{
809+ if (ctrl_x_mode & CTRL_X_WANT_IDENT)
810+ /* When expanding an identifier only accept identifier chars. */
811+ return vim_isIDc(c);
812+
813+ switch (ctrl_x_mode)
814+ {
815+ case CTRL_X_FILES:
816+ /* When expanding file name only accept file name chars. But not
817+ * path separators, so that "proto/<Tab>" expands files in
818+ * "proto", not "proto/" as a whole */
819+ return vim_isfilec(c) && !vim_ispathsep(c);
820+
821+ case CTRL_X_CMDLINE:
822+ case CTRL_X_OMNI:
823+ /* Command line and Omni completion can work with just about any
824+ * printable character, but do stop at white space. */
825+ return vim_isprintc(c) && !vim_iswhite(c);
826+
827+ case CTRL_X_WHOLE_LINE:
828+ /* For while line completion a space can be part of the line. */
829+ return vim_isprintc(c);
830+ }
831+ return vim_iswordc(c);
832+}
833+
834+/*
835 * This is like ins_compl_add(), but if 'ic' and 'inf' are set, then the
[ba61c16]836 * case of the originally typed text is used, and the case of the completed
837 * text is inferred, ie this tries to work out what case you probably wanted
838 * the rest of the word to be in -- webb
839- * TODO: make this work for multi-byte characters.
840 */
841 int
842 ins_compl_add_infercase(str, len, icase, fname, dir, flags)
[2830f42]843@@ -2068,54 +2103,147 @@
[ba61c16]844 int dir;
845 int flags;
846 {
847+ char_u *p;
848+ int i, c;
849+ int actual_len; /* Take multi-byte characters */
850+ int actual_compl_length; /* into account. */
851+ int *wca; /* Wide character array. */
852 int has_lower = FALSE;
853 int was_letter = FALSE;
854- int idx;
855
856- if (p_ic && curbuf->b_p_inf && len < IOSIZE)
857+ if (p_ic && curbuf->b_p_inf)
858 {
859- /* Infer case of completed part -- webb */
860- /* Use IObuff, str would change text in buffer! */
861- vim_strncpy(IObuff, str, len);
862+ /* Infer case of completed part. */
863
864- /* Rule 1: Were any chars converted to lower? */
865- for (idx = 0; idx < compl_length; ++idx)
866+ /* Find actual length of completion. */
867+#ifdef FEAT_MBYTE
868+ if (has_mbyte)
869 {
870- if (islower(compl_orig_text[idx]))
871+ p = str;
872+ actual_len = 0;
873+ while (*p != NUL)
874 {
875- has_lower = TRUE;
876- if (isupper(IObuff[idx]))
877- {
878- /* Rule 1 is satisfied */
879- for (idx = compl_length; idx < len; ++idx)
880- IObuff[idx] = TOLOWER_LOC(IObuff[idx]);
881- break;
882- }
883+ mb_ptr_adv(p);
884+ ++actual_len;
885 }
886 }
887+ else
888+#endif
889+ actual_len = len;
890
891- /*
892- * Rule 2: No lower case, 2nd consecutive letter converted to
893- * upper case.
894- */
895- if (!has_lower)
896+ /* Find actual length of original text. */
897+#ifdef FEAT_MBYTE
898+ if (has_mbyte)
[c2aa910]899 {
900- for (idx = 0; idx < compl_length; ++idx)
[ba61c16]901+ p = compl_orig_text;
902+ actual_compl_length = 0;
903+ while (*p != NUL)
[c2aa910]904 {
905- if (was_letter && isupper(compl_orig_text[idx])
906- && islower(IObuff[idx]))
[ba61c16]907+ mb_ptr_adv(p);
908+ ++actual_compl_length;
909+ }
910+ }
911+ else
912+#endif
913+ actual_compl_length = compl_length;
914+
915+ /* Allocate wide character array for the completion and fill it. */
916+ wca = (int *)alloc(actual_len * sizeof(int));
917+ if (wca != NULL)
[c2aa910]918+ {
[ba61c16]919+ p = str;
920+ for (i = 0; i < actual_len; ++i)
921+#ifdef FEAT_MBYTE
922+ if (has_mbyte)
923+ wca[i] = mb_ptr2char_adv(&p);
924+ else
925+#endif
926+ wca[i] = *(p++);
927+
928+ /* Rule 1: Were any chars converted to lower? */
929+ p = compl_orig_text;
930+ for (i = 0; i < actual_compl_length; ++i)
[c2aa910]931+ {
[ba61c16]932+#ifdef FEAT_MBYTE
933+ if (has_mbyte)
934+ c = mb_ptr2char_adv(&p);
935+ else
936+#endif
937+ c = *(p++);
938+ if (MB_ISLOWER(c))
939 {
940- /* Rule 2 is satisfied */
941- for (idx = compl_length; idx < len; ++idx)
942- IObuff[idx] = TOUPPER_LOC(IObuff[idx]);
943- break;
944+ has_lower = TRUE;
945+ if (MB_ISUPPER(wca[i]))
946+ {
947+ /* Rule 1 is satisfied. */
948+ for (i = actual_compl_length; i < actual_len; ++i)
949+ wca[i] = MB_TOLOWER(wca[i]);
950+ break;
951+ }
952 }
953- was_letter = isalpha(compl_orig_text[idx]);
954 }
955- }
956
957- /* Copy the original case of the part we typed */
958- STRNCPY(IObuff, compl_orig_text, compl_length);
959+ /*
960+ * Rule 2: No lower case, 2nd consecutive letter converted to
961+ * upper case.
962+ */
963+ if (!has_lower)
964+ {
965+ p = compl_orig_text;
966+ for (i = 0; i < actual_compl_length; ++i)
967+ {
968+#ifdef FEAT_MBYTE
969+ if (has_mbyte)
970+ c = mb_ptr2char_adv(&p);
971+ else
972+#endif
973+ c = *(p++);
974+ if (was_letter && MB_ISUPPER(c) && MB_ISLOWER(wca[i]))
975+ {
976+ /* Rule 2 is satisfied. */
977+ for (i = actual_compl_length; i < actual_len; ++i)
978+ wca[i] = MB_TOUPPER(wca[i]);
979+ break;
980+ }
981+ was_letter = MB_ISLOWER(c) || MB_ISUPPER(c);
982+ }
983+ }
984+
985+ /* Copy the original case of the part we typed. */
986+ p = compl_orig_text;
987+ for (i = 0; i < actual_compl_length; ++i)
988+ {
989+#ifdef FEAT_MBYTE
990+ if (has_mbyte)
991+ c = mb_ptr2char_adv(&p);
992+ else
993+#endif
994+ c = *(p++);
995+ if (MB_ISLOWER(c))
996+ wca[i] = MB_TOLOWER(wca[i]);
997+ else if (MB_ISUPPER(c))
998+ wca[i] = MB_TOUPPER(wca[i]);
999+ }
1000+
1001+ /*
1002+ * Generate encoding specific output from wide character array.
1003+ * Multi-byte characters can occupy up to five bytes more than
1004+ * ASCII characters, and we also need one byte for NUL, so stay
1005+ * six bytes away from the edge of IObuff.
1006+ */
1007+ p = IObuff;
1008+ i = 0;
1009+ while (i < actual_len && (p - IObuff + 6) < IOSIZE)
1010+#ifdef FEAT_MBYTE
1011+ if (has_mbyte)
1012+ p += mb_char2bytes(wca[i++], p);
1013+ else
1014+#endif
1015+ *(p++) = wca[i++];
1016+ *p = NUL;
1017+
1018+ vim_free(wca);
1019+ }
1020
1021 return ins_compl_add(IObuff, len, icase, fname, NULL, dir,
1022 flags, FALSE);
[2830f42]1023@@ -2842,6 +2970,7 @@
[ba61c16]1024 /*
1025 * Add the other matches on the line
1026 */
1027+ ptr = buf;
1028 while (!got_int)
1029 {
1030 /* Find start of the next word. Skip white
[2830f42]1031@@ -2851,7 +2980,7 @@
[ba61c16]1032 break;
1033 wstart = ptr;
1034
1035- /* Find end of the word and add it. */
1036+ /* Find end of the word. */
1037 #ifdef FEAT_MBYTE
1038 if (has_mbyte)
1039 /* Japanese words may have characters in
[2830f42]1040@@ -2868,9 +2997,12 @@
[ba61c16]1041 else
1042 #endif
1043 ptr = find_word_end(ptr);
1044- add_r = ins_compl_add_infercase(wstart,
1045- (int)(ptr - wstart),
1046- p_ic, files[i], *dir, 0);
1047+
1048+ /* Add the word. Skip the regexp match. */
1049+ if (wstart != regmatch->startp[0])
1050+ add_r = ins_compl_add_infercase(wstart,
1051+ (int)(ptr - wstart),
1052+ p_ic, files[i], *dir, 0);
1053 }
1054 }
1055 if (add_r == OK)
[2830f42]1056@@ -3032,8 +3164,11 @@
1057 p = line + curwin->w_cursor.col;
1058 mb_ptr_back(line, p);
1059
1060- /* Stop completion when the whole word was deleted. */
1061- if ((int)(p - line) - (int)compl_col <= 0)
1062+ /* Stop completion when the whole word was deleted. For Omni completion
1063+ * allow the word to be deleted, we won't match everything. */
1064+ if ((int)(p - line) - (int)compl_col < 0
1065+ || ((int)(p - line) - (int)compl_col == 0
1066+ && (ctrl_x_mode & CTRL_X_OMNI) == 0))
1067 return K_BS;
1068
1069 /* Deleted more than what was used to find matches or didn't finish
1070@@ -4495,14 +4630,13 @@
1071 curs_col = curwin->w_cursor.col;
1072 compl_pending = 0;
1073
1074- /* if this same ctrl_x_mode has been interrupted use the text from
1075+ /* If this same ctrl_x_mode has been interrupted use the text from
1076 * "compl_startpos" to the cursor as a pattern to add a new word
1077 * instead of expand the one before the cursor, in word-wise if
1078- * "compl_startpos"
1079- * is not in the same line as the cursor then fix it (the line has
1080- * been split because it was longer than 'tw'). if SOL is set then
1081- * skip the previous pattern, a word at the beginning of the line has
1082- * been inserted, we'll look for that -- Acevedo. */
1083+ * "compl_startpos" is not in the same line as the cursor then fix it
1084+ * (the line has been split because it was longer than 'tw'). if SOL
1085+ * is set then skip the previous pattern, a word at the beginning of
1086+ * the line has been inserted, we'll look for that -- Acevedo. */
1087 if ((compl_cont_status & CONT_INTRPT) == CONT_INTRPT
1088 && compl_cont_mode == ctrl_x_mode)
1089 {
1090@@ -5128,10 +5262,7 @@
[c2aa910]1091 i = 0;
1092 for (;;)
1093 {
1094- do
1095- nc = safe_vgetc();
1096- while (nc == K_IGNORE || nc == K_VER_SCROLLBAR
1097- || nc == K_HOR_SCROLLBAR);
1098+ nc = plain_vgetc();
1099 #ifdef FEAT_CMDL_INFO
1100 if (!(State & CMDLINE)
1101 # ifdef FEAT_MBYTE
[2830f42]1102@@ -7215,6 +7346,8 @@
[ba61c16]1103 p = ml_get_curline();
1104 if (cin_iscase(p) || cin_isscopedecl(p) || cin_islabel(30))
1105 return TRUE;
1106+ /* Need to get the line again after cin_islabel(). */
1107+ p = ml_get_curline();
1108 if (curwin->w_cursor.col > 2
1109 && p[curwin->w_cursor.col - 1] == ':'
1110 && p[curwin->w_cursor.col - 2] == ':')
[2830f42]1111@@ -7477,7 +7610,7 @@
[c2aa910]1112 * deleted when ESC is hit.
1113 */
1114 ++no_mapping;
1115- regname = safe_vgetc();
1116+ regname = plain_vgetc();
1117 #ifdef FEAT_LANGMAP
1118 LANGMAP_ADJUST(regname, TRUE);
1119 #endif
[2830f42]1120@@ -7488,7 +7621,7 @@
[c2aa910]1121 #ifdef FEAT_CMDL_INFO
1122 add_to_showcmd_c(literally);
1123 #endif
1124- regname = safe_vgetc();
1125+ regname = plain_vgetc();
1126 #ifdef FEAT_LANGMAP
1127 LANGMAP_ADJUST(regname, TRUE);
1128 #endif
[2830f42]1129@@ -7579,7 +7712,7 @@
[c2aa910]1130 * deleted when ESC is hit.
1131 */
1132 ++no_mapping;
1133- c = safe_vgetc();
1134+ c = plain_vgetc();
1135 --no_mapping;
1136 switch (c)
1137 {
[2830f42]1138@@ -7998,7 +8131,8 @@
[ba61c16]1139 /*
1140 * 0^D and ^^D: remove all indent.
1141 */
1142- if ((lastc == '0' || lastc == '^') && curwin->w_cursor.col)
1143+ if (c == Ctrl_D && (lastc == '0' || lastc == '^')
1144+ && curwin->w_cursor.col > 0)
1145 {
1146 --curwin->w_cursor.col;
1147 (void)del_char(FALSE); /* delete the '^' or '0' */
[2830f42]1148@@ -9257,7 +9391,7 @@
[c2aa910]1149 * mode message to be deleted when ESC is hit */
1150 ++no_mapping;
1151 ++allow_keys;
1152- c = safe_vgetc();
1153+ c = plain_vgetc();
1154 --no_mapping;
1155 --allow_keys;
1156 if (IS_SPECIAL(c) || mod_mask) /* special key */
[2830f42]1157@@ -9289,7 +9423,7 @@
[c2aa910]1158 }
1159 ++no_mapping;
1160 ++allow_keys;
1161- cc = safe_vgetc();
1162+ cc = plain_vgetc();
1163 --no_mapping;
1164 --allow_keys;
1165 if (cc != ESC)
[ba61c16]1166diff -Naur vim71.orig/src/eval.c vim71/src/eval.c
1167--- vim71.orig/src/eval.c 2007-05-07 12:47:32.000000000 -0700
[2830f42]1168+++ vim71/src/eval.c 2007-10-29 08:09:48.000000000 -0700
[ba61c16]1169@@ -369,17 +369,17 @@
1170 static int ex_let_vars __ARGS((char_u *arg, typval_T *tv, int copy, int semicolon, int var_count, char_u *nextchars));
1171 static char_u *skip_var_list __ARGS((char_u *arg, int *var_count, int *semicolon));
1172 static char_u *skip_var_one __ARGS((char_u *arg));
1173-static void list_hashtable_vars __ARGS((hashtab_T *ht, char_u *prefix, int empty));
1174-static void list_glob_vars __ARGS((void));
1175-static void list_buf_vars __ARGS((void));
1176-static void list_win_vars __ARGS((void));
1177+static void list_hashtable_vars __ARGS((hashtab_T *ht, char_u *prefix, int empty, int *first));
1178+static void list_glob_vars __ARGS((int *first));
1179+static void list_buf_vars __ARGS((int *first));
1180+static void list_win_vars __ARGS((int *first));
1181 #ifdef FEAT_WINDOWS
1182-static void list_tab_vars __ARGS((void));
1183+static void list_tab_vars __ARGS((int *first));
1184 #endif
1185-static void list_vim_vars __ARGS((void));
1186-static void list_script_vars __ARGS((void));
1187-static void list_func_vars __ARGS((void));
1188-static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg));
1189+static void list_vim_vars __ARGS((int *first));
1190+static void list_script_vars __ARGS((int *first));
1191+static void list_func_vars __ARGS((int *first));
1192+static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg, int *first));
1193 static char_u *ex_let_one __ARGS((char_u *arg, typval_T *tv, int copy, char_u *endchars, char_u *op));
1194 static int check_changedtick __ARGS((char_u *arg));
1195 static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int unlet, int skip, int quiet, int fne_flags));
1196@@ -475,6 +475,7 @@
1197 static void f_changenr __ARGS((typval_T *argvars, typval_T *rettv));
1198 static void f_char2nr __ARGS((typval_T *argvars, typval_T *rettv));
1199 static void f_cindent __ARGS((typval_T *argvars, typval_T *rettv));
1200+static void f_clearmatches __ARGS((typval_T *argvars, typval_T *rettv));
1201 static void f_col __ARGS((typval_T *argvars, typval_T *rettv));
1202 #if defined(FEAT_INS_EXPAND)
1203 static void f_complete __ARGS((typval_T *argvars, typval_T *rettv));
1204@@ -529,6 +530,7 @@
1205 static void f_getftime __ARGS((typval_T *argvars, typval_T *rettv));
1206 static void f_getftype __ARGS((typval_T *argvars, typval_T *rettv));
1207 static void f_getline __ARGS((typval_T *argvars, typval_T *rettv));
1208+static void f_getmatches __ARGS((typval_T *argvars, typval_T *rettv));
1209 static void f_getpos __ARGS((typval_T *argvars, typval_T *rettv));
1210 static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv));
1211 static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv));
1212@@ -577,7 +579,9 @@
1213 static void f_maparg __ARGS((typval_T *argvars, typval_T *rettv));
1214 static void f_mapcheck __ARGS((typval_T *argvars, typval_T *rettv));
1215 static void f_match __ARGS((typval_T *argvars, typval_T *rettv));
1216+static void f_matchadd __ARGS((typval_T *argvars, typval_T *rettv));
1217 static void f_matcharg __ARGS((typval_T *argvars, typval_T *rettv));
1218+static void f_matchdelete __ARGS((typval_T *argvars, typval_T *rettv));
1219 static void f_matchend __ARGS((typval_T *argvars, typval_T *rettv));
1220 static void f_matchlist __ARGS((typval_T *argvars, typval_T *rettv));
1221 static void f_matchstr __ARGS((typval_T *argvars, typval_T *rettv));
1222@@ -618,6 +622,7 @@
1223 static void f_setcmdpos __ARGS((typval_T *argvars, typval_T *rettv));
1224 static void f_setline __ARGS((typval_T *argvars, typval_T *rettv));
1225 static void f_setloclist __ARGS((typval_T *argvars, typval_T *rettv));
1226+static void f_setmatches __ARGS((typval_T *argvars, typval_T *rettv));
1227 static void f_setpos __ARGS((typval_T *argvars, typval_T *rettv));
1228 static void f_setqflist __ARGS((typval_T *argvars, typval_T *rettv));
1229 static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv));
1230@@ -672,7 +677,7 @@
1231 static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
1232
1233 static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump));
1234-static pos_T *var2fpos __ARGS((typval_T *varp, int lnum, int *fnum));
1235+static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
1236 static int get_env_len __ARGS((char_u **arg));
1237 static int get_id_len __ARGS((char_u **arg));
1238 static int get_name_len __ARGS((char_u **arg, char_u **alias, int evaluate, int verbose));
1239@@ -699,8 +704,8 @@
1240 static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname));
1241 static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val));
1242 static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi));
1243-static void list_one_var __ARGS((dictitem_T *v, char_u *prefix));
1244-static void list_one_var_a __ARGS((char_u *prefix, char_u *name, int type, char_u *string));
1245+static void list_one_var __ARGS((dictitem_T *v, char_u *prefix, int *first));
1246+static void list_one_var_a __ARGS((char_u *prefix, char_u *name, int type, char_u *string, int *first));
1247 static void set_var __ARGS((char_u *name, typval_T *varp, int copy));
1248 static int var_check_ro __ARGS((int flags, char_u *name));
1249 static int var_check_fixed __ARGS((int flags, char_u *name));
1250@@ -992,20 +997,20 @@
1251 char_u *value;
1252 int value_len;
1253 {
1254- size_t len;
1255+ int len;
1256
1257 if (redir_lval == NULL)
1258 return;
1259
1260 if (value_len == -1)
1261- len = STRLEN(value); /* Append the entire string */
1262+ len = (int)STRLEN(value); /* Append the entire string */
1263 else
1264- len = value_len; /* Append only "value_len" characters */
1265+ len = value_len; /* Append only "value_len" characters */
1266
1267- if (ga_grow(&redir_ga, (int)len) == OK)
1268+ if (ga_grow(&redir_ga, len) == OK)
1269 {
1270 mch_memmove((char *)redir_ga.ga_data + redir_ga.ga_len, value, len);
1271- redir_ga.ga_len += (int)len;
1272+ redir_ga.ga_len += len;
1273 }
1274 else
1275 var_redir_stop();
[c2aa910]1276@@ -1313,7 +1318,6 @@
1277 {
1278 hashitem_T *hi;
1279
1280- clear_tv(&vimvars[idx].vv_tv);
1281 vimvars[idx].vv_tv = *save_tv;
1282 if (vimvars[idx].vv_type == VAR_UNKNOWN)
1283 {
1284@@ -1357,7 +1361,6 @@
1285
1286 if (p_verbose == 0)
1287 --emsg_off;
1288- vimvars[VV_VAL].vv_str = NULL;
1289 restore_vimvar(VV_VAL, &save_val);
1290
1291 return list;
1292@@ -1411,7 +1414,8 @@
[ba61c16]1293 }
1294
1295
1296-#if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO)
1297+#if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) \
1298+ || defined(FEAT_COMPL_FUNC) || defined(PROTO)
1299 /*
1300 * Call some vimL function and return the result in "*rettv".
1301 * Uses argv[argc] for the function arguments.
[c2aa910]1302@@ -1484,6 +1488,7 @@
[ba61c16]1303 return ret;
1304 }
1305
1306+# if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO)
1307 /*
1308 * Call vimL function "func" and return the result as a string.
1309 * Returns NULL when calling the function fails.
[c2aa910]1310@@ -1506,8 +1511,9 @@
[ba61c16]1311 clear_tv(&rettv);
1312 return retval;
1313 }
1314+# endif
1315
1316-#if defined(FEAT_COMPL_FUNC) || defined(PROTO)
1317+# if defined(FEAT_COMPL_FUNC) || defined(PROTO)
1318 /*
1319 * Call vimL function "func" and return the result as a number.
1320 * Returns -1 when calling the function fails.
[c2aa910]1321@@ -1530,7 +1536,7 @@
[ba61c16]1322 clear_tv(&rettv);
1323 return retval;
1324 }
1325-#endif
1326+# endif
1327
1328 /*
1329 * Call vimL function "func" and return the result as a list
[c2aa910]1330@@ -1556,9 +1562,9 @@
[ba61c16]1331
1332 return rettv.vval.v_list;
1333 }
1334-
1335 #endif
1336
1337+
1338 /*
1339 * Save the current function call pointer, and set it to NULL.
1340 * Used when executing autocommands and for ":source".
[c2aa910]1341@@ -1691,6 +1697,7 @@
[ba61c16]1342 int semicolon = 0;
1343 char_u op[2];
1344 char_u *argend;
1345+ int first = TRUE;
1346
1347 argend = skip_var_list(arg, &var_count, &semicolon);
1348 if (argend == NULL)
[c2aa910]1349@@ -1707,19 +1714,19 @@
[ba61c16]1350 EMSG(_(e_invarg));
1351 else if (!ends_excmd(*arg))
1352 /* ":let var1 var2" */
1353- arg = list_arg_vars(eap, arg);
1354+ arg = list_arg_vars(eap, arg, &first);
1355 else if (!eap->skip)
1356 {
1357 /* ":let" */
1358- list_glob_vars();
1359- list_buf_vars();
1360- list_win_vars();
1361+ list_glob_vars(&first);
1362+ list_buf_vars(&first);
1363+ list_win_vars(&first);
1364 #ifdef FEAT_WINDOWS
1365- list_tab_vars();
1366+ list_tab_vars(&first);
1367 #endif
1368- list_script_vars();
1369- list_func_vars();
1370- list_vim_vars();
1371+ list_script_vars(&first);
1372+ list_func_vars(&first);
1373+ list_vim_vars(&first);
1374 }
1375 eap->nextcmd = check_nextcmd(arg);
1376 }
[c2aa910]1377@@ -1924,10 +1931,11 @@
[ba61c16]1378 * If "empty" is TRUE also list NULL strings as empty strings.
1379 */
1380 static void
1381-list_hashtable_vars(ht, prefix, empty)
1382+list_hashtable_vars(ht, prefix, empty, first)
1383 hashtab_T *ht;
1384 char_u *prefix;
1385 int empty;
1386+ int *first;
1387 {
1388 hashitem_T *hi;
1389 dictitem_T *di;
[c2aa910]1390@@ -1942,7 +1950,7 @@
[ba61c16]1391 di = HI2DI(hi);
1392 if (empty || di->di_tv.v_type != VAR_STRING
1393 || di->di_tv.vval.v_string != NULL)
1394- list_one_var(di, prefix);
1395+ list_one_var(di, prefix, first);
1396 }
1397 }
1398 }
[c2aa910]1399@@ -1951,32 +1959,38 @@
[ba61c16]1400 * List global variables.
1401 */
1402 static void
1403-list_glob_vars()
1404+list_glob_vars(first)
1405+ int *first;
1406 {
1407- list_hashtable_vars(&globvarht, (char_u *)"", TRUE);
1408+ list_hashtable_vars(&globvarht, (char_u *)"", TRUE, first);
1409 }
1410
1411 /*
1412 * List buffer variables.
1413 */
1414 static void
1415-list_buf_vars()
1416+list_buf_vars(first)
1417+ int *first;
1418 {
1419 char_u numbuf[NUMBUFLEN];
1420
1421- list_hashtable_vars(&curbuf->b_vars.dv_hashtab, (char_u *)"b:", TRUE);
1422+ list_hashtable_vars(&curbuf->b_vars.dv_hashtab, (char_u *)"b:",
1423+ TRUE, first);
1424
1425 sprintf((char *)numbuf, "%ld", (long)curbuf->b_changedtick);
1426- list_one_var_a((char_u *)"b:", (char_u *)"changedtick", VAR_NUMBER, numbuf);
1427+ list_one_var_a((char_u *)"b:", (char_u *)"changedtick", VAR_NUMBER,
1428+ numbuf, first);
1429 }
1430
1431 /*
1432 * List window variables.
1433 */
1434 static void
1435-list_win_vars()
1436+list_win_vars(first)
1437+ int *first;
1438 {
1439- list_hashtable_vars(&curwin->w_vars.dv_hashtab, (char_u *)"w:", TRUE);
1440+ list_hashtable_vars(&curwin->w_vars.dv_hashtab,
1441+ (char_u *)"w:", TRUE, first);
1442 }
1443
1444 #ifdef FEAT_WINDOWS
[c2aa910]1445@@ -1984,9 +1998,11 @@
[ba61c16]1446 * List tab page variables.
1447 */
1448 static void
1449-list_tab_vars()
1450+list_tab_vars(first)
1451+ int *first;
1452 {
1453- list_hashtable_vars(&curtab->tp_vars.dv_hashtab, (char_u *)"t:", TRUE);
1454+ list_hashtable_vars(&curtab->tp_vars.dv_hashtab,
1455+ (char_u *)"t:", TRUE, first);
1456 }
1457 #endif
1458
[c2aa910]1459@@ -1994,39 +2010,44 @@
[ba61c16]1460 * List Vim variables.
1461 */
1462 static void
1463-list_vim_vars()
1464+list_vim_vars(first)
1465+ int *first;
1466 {
1467- list_hashtable_vars(&vimvarht, (char_u *)"v:", FALSE);
1468+ list_hashtable_vars(&vimvarht, (char_u *)"v:", FALSE, first);
1469 }
1470
1471 /*
1472 * List script-local variables, if there is a script.
1473 */
1474 static void
1475-list_script_vars()
1476+list_script_vars(first)
1477+ int *first;
1478 {
1479 if (current_SID > 0 && current_SID <= ga_scripts.ga_len)
1480- list_hashtable_vars(&SCRIPT_VARS(current_SID), (char_u *)"s:", FALSE);
1481+ list_hashtable_vars(&SCRIPT_VARS(current_SID),
1482+ (char_u *)"s:", FALSE, first);
1483 }
1484
1485 /*
1486 * List function variables, if there is a function.
1487 */
1488 static void
1489-list_func_vars()
1490+list_func_vars(first)
1491+ int *first;
1492 {
1493 if (current_funccal != NULL)
1494 list_hashtable_vars(&current_funccal->l_vars.dv_hashtab,
1495- (char_u *)"l:", FALSE);
1496+ (char_u *)"l:", FALSE, first);
1497 }
1498
1499 /*
1500 * List variables in "arg".
1501 */
1502 static char_u *
1503-list_arg_vars(eap, arg)
1504+list_arg_vars(eap, arg, first)
1505 exarg_T *eap;
1506 char_u *arg;
1507+ int *first;
1508 {
1509 int error = FALSE;
1510 int len;
[c2aa910]1511@@ -2083,15 +2104,15 @@
[ba61c16]1512 {
1513 switch (*name)
1514 {
1515- case 'g': list_glob_vars(); break;
1516- case 'b': list_buf_vars(); break;
1517- case 'w': list_win_vars(); break;
1518+ case 'g': list_glob_vars(first); break;
1519+ case 'b': list_buf_vars(first); break;
1520+ case 'w': list_win_vars(first); break;
1521 #ifdef FEAT_WINDOWS
1522- case 't': list_tab_vars(); break;
1523+ case 't': list_tab_vars(first); break;
1524 #endif
1525- case 'v': list_vim_vars(); break;
1526- case 's': list_script_vars(); break;
1527- case 'l': list_func_vars(); break;
1528+ case 'v': list_vim_vars(first); break;
1529+ case 's': list_script_vars(first); break;
1530+ case 'l': list_func_vars(first); break;
1531 default:
1532 EMSG2(_("E738: Can't list variables for %s"), name);
1533 }
[c2aa910]1534@@ -2108,7 +2129,9 @@
[ba61c16]1535 *arg = NUL;
1536 list_one_var_a((char_u *)"",
1537 arg == arg_subsc ? name : name_start,
1538- tv.v_type, s == NULL ? (char_u *)"" : s);
1539+ tv.v_type,
1540+ s == NULL ? (char_u *)"" : s,
1541+ first);
1542 *arg = c;
1543 vim_free(tf);
1544 }
[c2aa910]1545@@ -6105,6 +6128,7 @@
1546 /* Only do this once. */
1547 want_garbage_collect = FALSE;
1548 may_garbage_collect = FALSE;
1549+ garbage_collect_at_exit = FALSE;
1550
1551 /*
1552 * 1. Go through all accessible variables and mark all lists and dicts
1553@@ -6681,7 +6705,7 @@
1554 dict_T *d = NULL;
1555 typval_T tvkey;
1556 typval_T tv;
1557- char_u *key;
1558+ char_u *key = NULL;
1559 dictitem_T *item;
1560 char_u *start = skipwhite(*arg + 1);
1561 char_u buf[NUMBUFLEN];
1562@@ -6721,20 +6745,24 @@
1563 clear_tv(&tvkey);
1564 goto failret;
1565 }
1566- key = get_tv_string_buf_chk(&tvkey, buf);
1567- if (key == NULL || *key == NUL)
1568+ if (evaluate)
1569 {
1570- /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */
1571- if (key != NULL)
1572- EMSG(_(e_emptykey));
1573- clear_tv(&tvkey);
1574- goto failret;
1575+ key = get_tv_string_buf_chk(&tvkey, buf);
1576+ if (key == NULL || *key == NUL)
1577+ {
1578+ /* "key" is NULL when get_tv_string_buf_chk() gave an errmsg */
1579+ if (key != NULL)
1580+ EMSG(_(e_emptykey));
1581+ clear_tv(&tvkey);
1582+ goto failret;
1583+ }
1584 }
1585
1586 *arg = skipwhite(*arg + 1);
1587 if (eval1(arg, &tv, evaluate) == FAIL) /* recursive! */
1588 {
1589- clear_tv(&tvkey);
1590+ if (evaluate)
1591+ clear_tv(&tvkey);
1592 goto failret;
1593 }
1594 if (evaluate)
1595@@ -6794,7 +6822,7 @@
[ba61c16]1596 * "numbuf" is used for a number.
1597 * Does not put quotes around strings, as ":echo" displays values.
1598 * When "copyID" is not NULL replace recursive lists and dicts with "...".
1599- * May return NULL;
1600+ * May return NULL.
1601 */
1602 static char_u *
1603 echo_string(tv, tofree, numbuf, copyID)
[c2aa910]1604@@ -6879,7 +6907,7 @@
[ba61c16]1605 * If the memory is allocated "tofree" is set to it, otherwise NULL.
1606 * "numbuf" is used for a number.
1607 * Puts quotes around strings, so that they can be parsed back by eval().
1608- * May return NULL;
1609+ * May return NULL.
1610 */
1611 static char_u *
1612 tv2string(tv, tofree, numbuf, copyID)
[c2aa910]1613@@ -7043,6 +7071,7 @@
[ba61c16]1614 {"changenr", 0, 0, f_changenr},
1615 {"char2nr", 1, 1, f_char2nr},
1616 {"cindent", 1, 1, f_cindent},
1617+ {"clearmatches", 0, 0, f_clearmatches},
1618 {"col", 1, 1, f_col},
1619 #if defined(FEAT_INS_EXPAND)
1620 {"complete", 2, 2, f_complete},
[c2aa910]1621@@ -7082,7 +7111,7 @@
1622 {"foldtextresult", 1, 1, f_foldtextresult},
1623 {"foreground", 0, 0, f_foreground},
1624 {"function", 1, 1, f_function},
1625- {"garbagecollect", 0, 0, f_garbagecollect},
1626+ {"garbagecollect", 0, 1, f_garbagecollect},
1627 {"get", 2, 3, f_get},
1628 {"getbufline", 2, 3, f_getbufline},
1629 {"getbufvar", 2, 2, f_getbufvar},
1630@@ -7099,6 +7128,7 @@
[ba61c16]1631 {"getftype", 1, 1, f_getftype},
1632 {"getline", 1, 2, f_getline},
1633 {"getloclist", 1, 1, f_getqflist},
1634+ {"getmatches", 0, 0, f_getmatches},
1635 {"getpos", 1, 1, f_getpos},
1636 {"getqflist", 0, 0, f_getqflist},
1637 {"getreg", 0, 2, f_getreg},
[c2aa910]1638@@ -7149,7 +7179,9 @@
[ba61c16]1639 {"maparg", 1, 3, f_maparg},
1640 {"mapcheck", 1, 3, f_mapcheck},
1641 {"match", 2, 4, f_match},
1642+ {"matchadd", 2, 4, f_matchadd},
1643 {"matcharg", 1, 1, f_matcharg},
1644+ {"matchdelete", 1, 1, f_matchdelete},
1645 {"matchend", 2, 4, f_matchend},
1646 {"matchlist", 2, 4, f_matchlist},
1647 {"matchstr", 2, 4, f_matchstr},
[c2aa910]1648@@ -7190,6 +7222,7 @@
[ba61c16]1649 {"setcmdpos", 1, 1, f_setcmdpos},
1650 {"setline", 2, 2, f_setline},
1651 {"setloclist", 2, 3, f_setloclist},
1652+ {"setmatches", 1, 1, f_setmatches},
1653 {"setpos", 2, 2, f_setpos},
1654 {"setqflist", 1, 2, f_setqflist},
1655 {"setreg", 2, 3, f_setreg},
[c2aa910]1656@@ -8240,6 +8273,20 @@
[ba61c16]1657 }
1658
1659 /*
1660+ * "clearmatches()" function
1661+ */
1662+/*ARGSUSED*/
1663+ static void
1664+f_clearmatches(argvars, rettv)
1665+ typval_T *argvars;
1666+ typval_T *rettv;
1667+{
1668+#ifdef FEAT_SEARCH_EXTRA
1669+ clear_matches(curwin);
1670+#endif
1671+}
1672+
1673+/*
1674 * "col(string)" function
1675 */
1676 static void
[c2aa910]1677@@ -9339,15 +9386,16 @@
1678 {
1679 typval_T rettv;
1680 char_u *s;
1681+ int retval = FAIL;
1682
1683 copy_tv(tv, &vimvars[VV_VAL].vv_tv);
1684 s = expr;
1685 if (eval1(&s, &rettv, TRUE) == FAIL)
1686- return FAIL;
1687+ goto theend;
1688 if (*s != NUL) /* check for trailing chars after expr */
1689 {
1690 EMSG2(_(e_invexpr2), s);
1691- return FAIL;
1692+ goto theend;
1693 }
1694 if (map)
1695 {
1696@@ -9366,10 +9414,12 @@
1697 /* On type error, nothing has been removed; return FAIL to stop the
1698 * loop. The error message was given by get_tv_number_chk(). */
1699 if (error)
1700- return FAIL;
1701+ goto theend;
1702 }
1703+ retval = OK;
1704+theend:
1705 clear_tv(&vimvars[VV_VAL].vv_tv);
1706- return OK;
1707+ return retval;
1708 }
1709
1710 /*
1711@@ -9670,6 +9720,9 @@
1712 /* This is postponed until we are back at the toplevel, because we may be
1713 * using Lists and Dicts internally. E.g.: ":echo [garbagecollect()]". */
1714 want_garbage_collect = TRUE;
1715+
1716+ if (argvars[0].v_type != VAR_UNKNOWN && get_tv_number(&argvars[0]) == 1)
1717+ garbage_collect_at_exit = TRUE;
1718 }
1719
1720 /*
1721@@ -9868,18 +9921,24 @@
1722
1723 ++no_mapping;
1724 ++allow_keys;
1725- if (argvars[0].v_type == VAR_UNKNOWN)
1726- /* getchar(): blocking wait. */
1727- n = safe_vgetc();
1728- else if (get_tv_number_chk(&argvars[0], &error) == 1)
1729- /* getchar(1): only check if char avail */
1730- n = vpeekc();
1731- else if (error || vpeekc() == NUL)
1732- /* illegal argument or getchar(0) and no char avail: return zero */
1733- n = 0;
1734- else
1735- /* getchar(0) and char avail: return char */
1736- n = safe_vgetc();
1737+ for (;;)
1738+ {
1739+ if (argvars[0].v_type == VAR_UNKNOWN)
1740+ /* getchar(): blocking wait. */
1741+ n = safe_vgetc();
1742+ else if (get_tv_number_chk(&argvars[0], &error) == 1)
1743+ /* getchar(1): only check if char avail */
1744+ n = vpeekc();
1745+ else if (error || vpeekc() == NUL)
1746+ /* illegal argument or getchar(0) and no char avail: return zero */
1747+ n = 0;
1748+ else
1749+ /* getchar(0) and char avail: return char */
1750+ n = safe_vgetc();
1751+ if (n == K_IGNORE)
1752+ continue;
1753+ break;
1754+ }
1755 --no_mapping;
1756 --allow_keys;
1757
1758@@ -10136,7 +10195,13 @@
[ba61c16]1759 if (mch_isdir(fname))
1760 rettv->vval.v_number = 0;
1761 else
1762+ {
1763 rettv->vval.v_number = (varnumber_T)st.st_size;
1764+
1765+ /* non-perfect check for overflow */
1766+ if ((off_t)rettv->vval.v_number != (off_t)st.st_size)
1767+ rettv->vval.v_number = -2;
1768+ }
1769 }
1770 else
1771 rettv->vval.v_number = -1;
[c2aa910]1772@@ -10269,6 +10334,39 @@
[ba61c16]1773 }
1774
1775 /*
1776+ * "getmatches()" function
1777+ */
1778+/*ARGSUSED*/
1779+ static void
1780+f_getmatches(argvars, rettv)
1781+ typval_T *argvars;
1782+ typval_T *rettv;
1783+{
1784+#ifdef FEAT_SEARCH_EXTRA
1785+ dict_T *dict;
1786+ matchitem_T *cur = curwin->w_match_head;
1787+
1788+ rettv->vval.v_number = 0;
1789+
1790+ if (rettv_list_alloc(rettv) == OK)
1791+ {
1792+ while (cur != NULL)
1793+ {
1794+ dict = dict_alloc();
1795+ if (dict == NULL)
1796+ return;
1797+ dict_add_nr_str(dict, "group", 0L, syn_id2name(cur->hlg_id));
1798+ dict_add_nr_str(dict, "pattern", 0L, cur->pattern);
1799+ dict_add_nr_str(dict, "priority", (long)cur->priority, NULL);
1800+ dict_add_nr_str(dict, "id", (long)cur->id, NULL);
1801+ list_append_dict(rettv->vval.v_list, dict);
1802+ cur = cur->next;
1803+ }
1804+ }
1805+#endif
1806+}
1807+
1808+/*
1809 * "getpos(string)" function
1810 */
1811 static void
[c2aa910]1812@@ -10290,7 +10388,8 @@
1813 list_append_number(l, (varnumber_T)0);
1814 list_append_number(l, (fp != NULL) ? (varnumber_T)fp->lnum
1815 : (varnumber_T)0);
1816- list_append_number(l, (fp != NULL) ? (varnumber_T)fp->col + 1
1817+ list_append_number(l, (fp != NULL)
1818+ ? (varnumber_T)(fp->col == MAXCOL ? MAXCOL : fp->col + 1)
1819 : (varnumber_T)0);
1820 list_append_number(l,
1821 #ifdef FEAT_VIRTUALEDIT
1822@@ -10785,6 +10884,9 @@
1823 "gui_gtk2",
1824 # endif
1825 #endif
1826+#ifdef FEAT_GUI_GNOME
1827+ "gui_gnome",
1828+#endif
1829 #ifdef FEAT_GUI_MAC
1830 "gui_mac",
1831 #endif
1832@@ -11471,14 +11573,12 @@
1833 char_u *xp_arg = NULL;
1834
1835 rettv->v_type = VAR_STRING;
1836+ rettv->vval.v_string = NULL;
1837
1838 #ifdef NO_CONSOLE_INPUT
1839 /* While starting up, there is no place to enter text. */
1840 if (no_console_input())
1841- {
1842- rettv->vval.v_string = NULL;
1843 return;
1844- }
1845 #endif
1846
1847 cmd_silent = FALSE; /* Want to see the prompt. */
1848@@ -12439,6 +12539,44 @@
[ba61c16]1849 }
1850
1851 /*
1852+ * "matchadd()" function
1853+ */
1854+ static void
1855+f_matchadd(argvars, rettv)
1856+ typval_T *argvars;
1857+ typval_T *rettv;
1858+{
1859+#ifdef FEAT_SEARCH_EXTRA
1860+ char_u buf[NUMBUFLEN];
1861+ char_u *grp = get_tv_string_buf_chk(&argvars[0], buf); /* group */
1862+ char_u *pat = get_tv_string_buf_chk(&argvars[1], buf); /* pattern */
1863+ int prio = 10; /* default priority */
1864+ int id = -1;
1865+ int error = FALSE;
1866+
1867+ rettv->vval.v_number = -1;
1868+
1869+ if (grp == NULL || pat == NULL)
1870+ return;
1871+ if (argvars[2].v_type != VAR_UNKNOWN)
1872+ {
1873+ prio = get_tv_number_chk(&argvars[2], &error);
1874+ if (argvars[3].v_type != VAR_UNKNOWN)
1875+ id = get_tv_number_chk(&argvars[3], &error);
1876+ }
1877+ if (error == TRUE)
1878+ return;
1879+ if (id >= 1 && id <= 3)
1880+ {
1881+ EMSGN("E798: ID is reserved for \":match\": %ld", id);
1882+ return;
1883+ }
1884+
1885+ rettv->vval.v_number = match_add(curwin, grp, pat, prio, id);
1886+#endif
1887+}
1888+
1889+/*
1890 * "matcharg()" function
1891 */
1892 static void
[c2aa910]1893@@ -12449,20 +12587,42 @@
[ba61c16]1894 if (rettv_list_alloc(rettv) == OK)
1895 {
1896 #ifdef FEAT_SEARCH_EXTRA
1897- int mi = get_tv_number(&argvars[0]);
1898+ int id = get_tv_number(&argvars[0]);
1899+ matchitem_T *m;
1900
1901- if (mi >= 1 && mi <= 3)
1902+ if (id >= 1 && id <= 3)
1903 {
1904- list_append_string(rettv->vval.v_list,
1905- syn_id2name(curwin->w_match_id[mi - 1]), -1);
1906- list_append_string(rettv->vval.v_list,
1907- curwin->w_match_pat[mi - 1], -1);
1908+ if ((m = (matchitem_T *)get_match(curwin, id)) != NULL)
1909+ {
1910+ list_append_string(rettv->vval.v_list,
1911+ syn_id2name(m->hlg_id), -1);
1912+ list_append_string(rettv->vval.v_list, m->pattern, -1);
1913+ }
1914+ else
1915+ {
1916+ list_append_string(rettv->vval.v_list, NUL, -1);
1917+ list_append_string(rettv->vval.v_list, NUL, -1);
1918+ }
1919 }
1920 #endif
1921 }
1922 }
1923
1924 /*
1925+ * "matchdelete()" function
1926+ */
1927+ static void
1928+f_matchdelete(argvars, rettv)
1929+ typval_T *argvars;
1930+ typval_T *rettv;
1931+{
1932+#ifdef FEAT_SEARCH_EXTRA
1933+ rettv->vval.v_number = match_delete(curwin,
1934+ (int)get_tv_number(&argvars[0]), TRUE);
1935+#endif
1936+}
1937+
1938+/*
1939 * "matchend()" function
1940 */
1941 static void
[c2aa910]1942@@ -13680,7 +13840,7 @@
[ba61c16]1943 }
1944 /* Shorten "remain". */
1945 if (*q != NUL)
1946- STRCPY(remain, q - 1);
1947+ mch_memmove(remain, q - 1, STRLEN(q - 1) + 1);
1948 else
1949 {
1950 vim_free(remain);
[c2aa910]1951@@ -13919,6 +14079,8 @@
[ba61c16]1952 /* If 'n' flag is used: restore cursor position. */
1953 if (flags & SP_NOMOVE)
1954 curwin->w_cursor = save_cursor;
1955+ else
1956+ curwin->w_set_curswant = TRUE;
1957 theend:
1958 p_ws = save_p_ws;
1959
[c2aa910]1960@@ -14498,6 +14660,66 @@
[ba61c16]1961 }
1962
1963 /*
1964+ * "setmatches()" function
1965+ */
1966+ static void
1967+f_setmatches(argvars, rettv)
1968+ typval_T *argvars;
1969+ typval_T *rettv;
1970+{
1971+#ifdef FEAT_SEARCH_EXTRA
1972+ list_T *l;
1973+ listitem_T *li;
1974+ dict_T *d;
1975+
1976+ rettv->vval.v_number = -1;
1977+ if (argvars[0].v_type != VAR_LIST)
1978+ {
1979+ EMSG(_(e_listreq));
1980+ return;
1981+ }
1982+ if ((l = argvars[0].vval.v_list) != NULL)
1983+ {
1984+
1985+ /* To some extent make sure that we are dealing with a list from
1986+ * "getmatches()". */
1987+ li = l->lv_first;
1988+ while (li != NULL)
1989+ {
1990+ if (li->li_tv.v_type != VAR_DICT
1991+ || (d = li->li_tv.vval.v_dict) == NULL)
1992+ {
1993+ EMSG(_(e_invarg));
1994+ return;
1995+ }
1996+ if (!(dict_find(d, (char_u *)"group", -1) != NULL
1997+ && dict_find(d, (char_u *)"pattern", -1) != NULL
1998+ && dict_find(d, (char_u *)"priority", -1) != NULL
1999+ && dict_find(d, (char_u *)"id", -1) != NULL))
2000+ {
2001+ EMSG(_(e_invarg));
2002+ return;
2003+ }
2004+ li = li->li_next;
2005+ }
2006+
2007+ clear_matches(curwin);
2008+ li = l->lv_first;
2009+ while (li != NULL)
2010+ {
2011+ d = li->li_tv.vval.v_dict;
2012+ match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
2013+ get_dict_string(d, (char_u *)"pattern", FALSE),
2014+ (int)get_dict_number(d, (char_u *)"priority"),
2015+ (int)get_dict_number(d, (char_u *)"id"));
2016+ li = li->li_next;
2017+ }
2018+ rettv->vval.v_number = 0;
2019+ }
2020+#endif
2021+}
2022+
2023+/*
2024 * "setpos()" function
2025 */
2026 /*ARGSUSED*/
[c2aa910]2027@@ -14785,6 +15007,10 @@
[ba61c16]2028
2029 p1 = tv2string(&(*(listitem_T **)s1)->li_tv, &tofree1, numbuf1, 0);
2030 p2 = tv2string(&(*(listitem_T **)s2)->li_tv, &tofree2, numbuf2, 0);
2031+ if (p1 == NULL)
2032+ p1 = (char_u *)"";
2033+ if (p2 == NULL)
2034+ p2 = (char_u *)"";
2035 if (item_compare_ic)
2036 res = STRICMP(p1, p2);
2037 else
[c2aa910]2038@@ -15274,7 +15500,8 @@
[ba61c16]2039
2040 rettv->v_type = VAR_STRING;
2041 rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0);
2042- if (tofree == NULL)
2043+ /* Make a copy if we have a value but it's not in allocate memory. */
2044+ if (rettv->vval.v_string != NULL && tofree == NULL)
2045 rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
2046 }
2047
[c2aa910]2048@@ -16497,9 +16724,9 @@
[ba61c16]2049 * Returns NULL when there is an error.
2050 */
2051 static pos_T *
2052-var2fpos(varp, lnum, fnum)
2053+var2fpos(varp, dollar_lnum, fnum)
2054 typval_T *varp;
2055- int lnum; /* TRUE when $ is last line */
2056+ int dollar_lnum; /* TRUE when $ is last line */
2057 int *fnum; /* set to fnum for '0, 'A, etc. */
2058 {
2059 char_u *name;
[c2aa910]2060@@ -16512,6 +16739,7 @@
[ba61c16]2061 list_T *l;
2062 int len;
2063 int error = FALSE;
2064+ listitem_T *li;
2065
2066 l = varp->vval.v_list;
2067 if (l == NULL)
[c2aa910]2068@@ -16527,6 +16755,14 @@
[ba61c16]2069 if (error)
2070 return NULL;
2071 len = (long)STRLEN(ml_get(pos.lnum));
2072+
2073+ /* We accept "$" for the column number: last column. */
2074+ li = list_find(l, 1L);
2075+ if (li != NULL && li->li_tv.v_type == VAR_STRING
2076+ && li->li_tv.vval.v_string != NULL
2077+ && STRCMP(li->li_tv.vval.v_string, "$") == 0)
2078+ pos.col = len + 1;
2079+
2080 /* Accept a position up to the NUL after the line. */
2081 if (pos.col == 0 || (int)pos.col > len + 1)
2082 return NULL; /* invalid column number */
[c2aa910]2083@@ -16559,7 +16795,7 @@
[ba61c16]2084 pos.coladd = 0;
2085 #endif
2086
2087- if (name[0] == 'w' && lnum)
2088+ if (name[0] == 'w' && dollar_lnum)
2089 {
2090 pos.col = 0;
2091 if (name[1] == '0') /* "w0": first visible line */
[c2aa910]2092@@ -16577,7 +16813,7 @@
[ba61c16]2093 }
2094 else if (name[0] == '$') /* last column or line */
2095 {
2096- if (lnum)
2097+ if (dollar_lnum)
2098 {
2099 pos.lnum = curbuf->b_ml.ml_line_count;
2100 pos.col = 0;
[c2aa910]2101@@ -17798,9 +18034,10 @@
[ba61c16]2102 * List the value of one internal variable.
2103 */
2104 static void
2105-list_one_var(v, prefix)
2106+list_one_var(v, prefix, first)
2107 dictitem_T *v;
2108 char_u *prefix;
2109+ int *first;
2110 {
2111 char_u *tofree;
2112 char_u *s;
[c2aa910]2113@@ -17808,18 +18045,21 @@
[ba61c16]2114
2115 s = echo_string(&v->di_tv, &tofree, numbuf, ++current_copyID);
2116 list_one_var_a(prefix, v->di_key, v->di_tv.v_type,
2117- s == NULL ? (char_u *)"" : s);
2118+ s == NULL ? (char_u *)"" : s, first);
2119 vim_free(tofree);
2120 }
2121
2122 static void
2123-list_one_var_a(prefix, name, type, string)
2124+list_one_var_a(prefix, name, type, string, first)
2125 char_u *prefix;
2126 char_u *name;
2127 int type;
2128 char_u *string;
2129+ int *first; /* when TRUE clear rest of screen and set to FALSE */
2130 {
2131- msg_attr(prefix, 0); /* don't use msg(), it overwrites "v:statusmsg" */
2132+ /* don't use msg() or msg_attr() to avoid overwriting "v:statusmsg" */
2133+ msg_start();
2134+ msg_puts(prefix);
2135 if (name != NULL) /* "a:" vars don't have a name stored */
2136 msg_puts(name);
2137 msg_putchar(' ');
[c2aa910]2138@@ -17847,6 +18087,11 @@
[ba61c16]2139
2140 if (type == VAR_FUNC)
2141 msg_puts((char_u *)"()");
2142+ if (*first)
2143+ {
2144+ msg_clr_eos();
2145+ *first = FALSE;
2146+ }
2147 }
2148
2149 /*
[c2aa910]2150@@ -19136,6 +19381,28 @@
2151 goto theend;
2152 }
2153
2154+ /* Check if the name is a Funcref. If so, use the value. */
2155+ if (lv.ll_exp_name != NULL)
2156+ {
2157+ len = (int)STRLEN(lv.ll_exp_name);
2158+ name = deref_func_name(lv.ll_exp_name, &len);
2159+ if (name == lv.ll_exp_name)
2160+ name = NULL;
2161+ }
2162+ else
2163+ {
2164+ len = (int)(end - *pp);
2165+ name = deref_func_name(*pp, &len);
2166+ if (name == *pp)
2167+ name = NULL;
2168+ }
2169+ if (name != NULL)
2170+ {
2171+ name = vim_strsave(name);
2172+ *pp = end;
2173+ goto theend;
2174+ }
2175+
2176 if (lv.ll_exp_name != NULL)
2177 {
2178 len = (int)STRLEN(lv.ll_exp_name);
2179@@ -19969,6 +20236,7 @@
[ba61c16]2180 char_u buf[MSG_BUF_LEN];
2181 char_u numbuf2[NUMBUFLEN];
2182 char_u *tofree;
2183+ char_u *s;
2184
2185 msg_puts((char_u *)"(");
2186 for (i = 0; i < argcount; ++i)
[c2aa910]2187@@ -19979,10 +20247,13 @@
[ba61c16]2188 msg_outnum((long)argvars[i].vval.v_number);
2189 else
2190 {
2191- trunc_string(tv2string(&argvars[i], &tofree,
2192- numbuf2, 0), buf, MSG_BUF_CLEN);
2193- msg_puts(buf);
2194- vim_free(tofree);
2195+ s = tv2string(&argvars[i], &tofree, numbuf2, 0);
2196+ if (s != NULL)
2197+ {
2198+ trunc_string(s, buf, MSG_BUF_CLEN);
2199+ msg_puts(buf);
2200+ vim_free(tofree);
2201+ }
2202 }
2203 }
2204 msg_puts((char_u *)")");
[c2aa910]2205@@ -20060,14 +20331,18 @@
[ba61c16]2206 char_u buf[MSG_BUF_LEN];
2207 char_u numbuf2[NUMBUFLEN];
2208 char_u *tofree;
2209+ char_u *s;
2210
2211 /* The value may be very long. Skip the middle part, so that we
2212 * have some idea how it starts and ends. smsg() would always
2213 * truncate it at the end. */
2214- trunc_string(tv2string(fc.rettv, &tofree, numbuf2, 0),
2215- buf, MSG_BUF_CLEN);
2216- smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
2217- vim_free(tofree);
2218+ s = tv2string(fc.rettv, &tofree, numbuf2, 0);
2219+ if (s != NULL)
2220+ {
2221+ trunc_string(s, buf, MSG_BUF_CLEN);
2222+ smsg((char_u *)_("%s returning %s"), sourcing_name, buf);
2223+ vim_free(tofree);
2224+ }
2225 }
2226 msg_puts((char_u *)"\n"); /* don't overwrite this either */
2227
[c2aa910]2228@@ -21034,14 +21309,27 @@
2229 *usedlen += 2;
2230 s = get_past_head(*fnamep);
2231 while (tail > s && after_pathsep(s, tail))
2232- --tail;
2233+ mb_ptr_back(*fnamep, tail);
2234 *fnamelen = (int)(tail - *fnamep);
2235 #ifdef VMS
2236 if (*fnamelen > 0)
2237 *fnamelen += 1; /* the path separator is part of the path */
2238 #endif
2239- while (tail > s && !after_pathsep(s, tail))
2240- mb_ptr_back(*fnamep, tail);
2241+ if (*fnamelen == 0)
2242+ {
2243+ /* Result is empty. Turn it into "." to make ":cd %:h" work. */
2244+ p = vim_strsave((char_u *)".");
2245+ if (p == NULL)
2246+ return -1;
2247+ vim_free(*bufp);
2248+ *bufp = *fnamep = tail = p;
2249+ *fnamelen = 1;
2250+ }
2251+ else
2252+ {
2253+ while (tail > s && !after_pathsep(s, tail))
2254+ mb_ptr_back(*fnamep, tail);
2255+ }
2256 }
2257
2258 /* ":8" - shortname */
[ba61c16]2259diff -Naur vim71.orig/src/ex_cmds.c vim71/src/ex_cmds.c
2260--- vim71.orig/src/ex_cmds.c 2007-05-07 12:41:01.000000000 -0700
[2830f42]2261+++ vim71/src/ex_cmds.c 2007-10-29 08:09:37.000000000 -0700
[ba61c16]2262@@ -408,7 +408,11 @@
2263 goto sortend;
2264 }
2265 *s = NUL;
2266- regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC);
2267+ /* Use last search pattern if sort pattern is empty. */
2268+ if (s == p + 1 && last_search_pat() != NULL)
2269+ regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
2270+ else
2271+ regmatch.regprog = vim_regcomp(p + 1, RE_MAGIC);
2272 if (regmatch.regprog == NULL)
2273 goto sortend;
2274 p = s; /* continue after the regexp */
2275@@ -2912,22 +2916,35 @@
2276 }
2277
2278 /*
2279- * Check if a buffer is read-only. Ask for overruling in a dialog.
2280- * Return TRUE and give an error message when the buffer is readonly.
2281+ * Check if a buffer is read-only (either 'readonly' option is set or file is
2282+ * read-only). Ask for overruling in a dialog. Return TRUE and give an error
2283+ * message when the buffer is readonly.
2284 */
2285 static int
2286 check_readonly(forceit, buf)
2287 int *forceit;
2288 buf_T *buf;
2289 {
2290- if (!*forceit && buf->b_p_ro)
2291+ struct stat st;
2292+
2293+ /* Handle a file being readonly when the 'readonly' option is set or when
2294+ * the file exists and permissions are read-only.
2295+ * We will send 0777 to check_file_readonly(), as the "perm" variable is
2296+ * important for device checks but not here. */
2297+ if (!*forceit && (buf->b_p_ro
2298+ || (mch_stat((char *)buf->b_ffname, &st) >= 0
2299+ && check_file_readonly(buf->b_ffname, 0777))))
2300 {
2301 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
2302 if ((p_confirm || cmdmod.confirm) && buf->b_fname != NULL)
2303 {
2304 char_u buff[IOSIZE];
2305
2306- dialog_msg(buff, _("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"),
2307+ if (buf->b_p_ro)
2308+ dialog_msg(buff, _("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"),
2309+ buf->b_fname);
2310+ else
2311+ dialog_msg(buff, _("File permissions of \"%s\" are read-only.\nIt may still be possible to write it.\nDo you wish to try?"),
2312 buf->b_fname);
2313
2314 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) == VIM_YES)
2315@@ -2941,9 +2958,14 @@
2316 }
2317 else
2318 #endif
2319+ if (buf->b_p_ro)
2320 EMSG(_(e_readonly));
2321+ else
2322+ EMSG2(_("E505: \"%s\" is read-only (add ! to override)"),
2323+ buf->b_fname);
2324 return TRUE;
2325 }
2326+
2327 return FALSE;
2328 }
2329
2330@@ -2952,7 +2974,7 @@
2331 * 'fnum' is the number of the file, if zero use ffname/sfname.
2332 *
2333 * Return 1 for "normal" error, 2 for "not written" error, 0 for success
2334- * -1 for succesfully opening another file.
2335+ * -1 for successfully opening another file.
2336 * 'lnum' is the line number for the cursor in the new file (if non-zero).
2337 */
2338 int
2339@@ -3367,7 +3389,7 @@
2340 * was in this window (or another window). If not used
2341 * before, reset the local window options to the global
2342 * values. Also restores old folding stuff. */
2343- get_winopts(buf);
2344+ get_winopts(curbuf);
2345 #ifdef FEAT_SPELL
2346 did_get_winopts = TRUE;
2347 #endif
2348@@ -3562,9 +3584,20 @@
2349 curwin_init();
2350
2351 #ifdef FEAT_FOLDING
2352- /* It's like all lines in the buffer changed. Need to update
2353- * automatic folding. */
2354+ /* It's possible that all lines in the buffer changed. Need to update
2355+ * automatic folding for all windows where it's used. */
2356+# ifdef FEAT_WINDOWS
2357+ {
2358+ win_T *win;
2359+ tabpage_T *tp;
2360+
2361+ FOR_ALL_TAB_WINDOWS(tp, win)
2362+ if (win->w_buffer == curbuf)
2363+ foldUpdateAll(win);
2364+ }
2365+# else
2366 foldUpdateAll(curwin);
2367+# endif
2368 #endif
2369
2370 /* Change directories when the 'acd' option is set. */
2371@@ -3649,8 +3682,8 @@
2372 #ifdef FEAT_SPELL
2373 /* If the window options were changed may need to set the spell language.
2374 * Can only do this after the buffer has been properly setup. */
2375- if (did_get_winopts && curwin->w_p_spell && *buf->b_p_spl != NUL)
2376- did_set_spelllang(buf);
2377+ if (did_get_winopts && curwin->w_p_spell && *curbuf->b_p_spl != NUL)
2378+ did_set_spelllang(curbuf);
2379 #endif
2380
2381 if (command == NULL)
2382@@ -3754,7 +3787,7 @@
2383 workshop_file_opened((char *)curbuf->b_ffname, curbuf->b_p_ro);
2384 # endif
2385 # ifdef FEAT_NETBEANS_INTG
2386- if (usingNetbeans & ((flags & ECMD_SET_HELP) != ECMD_SET_HELP))
2387+ if (usingNetbeans && ((flags & ECMD_SET_HELP) != ECMD_SET_HELP))
2388 netbeans_file_opened(curbuf);
2389 # endif
2390 }
2391@@ -4294,6 +4327,7 @@
2392 do_error = TRUE;
2393 do_print = FALSE;
2394 do_count = FALSE;
2395+ do_number = FALSE;
2396 do_ic = 0;
2397 }
2398 while (*cmd)
[c2aa910]2399@@ -4464,7 +4498,7 @@
2400 *
2401 * The new text is built up in new_start[]. It has some extra
2402 * room to avoid using alloc()/free() too often. new_start_len is
2403- * the lenght of the allocated memory at new_start.
2404+ * the length of the allocated memory at new_start.
2405 *
2406 * Make a copy of the old line, so it won't be taken away when
2407 * updating the screen or handling a multi-line match. The "old_"
2408@@ -4635,7 +4669,7 @@
2409 #endif
2410 ++no_mapping; /* don't map this key */
2411 ++allow_keys; /* allow special keys */
2412- i = safe_vgetc();
2413+ i = plain_vgetc();
2414 --allow_keys;
2415 --no_mapping;
2416
[ba61c16]2417@@ -6351,9 +6385,9 @@
2418 for (i = 0; i < ga.ga_len; ++i)
2419 {
2420 s = ((char_u **)ga.ga_data)[i];
2421- if (STRNCMP(s, "help-tags", 9) == 0)
2422+ if (STRNCMP(s, "help-tags\t", 10) == 0)
2423 /* help-tags entry was added in formatted form */
2424- fprintf(fd_tags, (char *)s);
2425+ fputs((char *)s, fd_tags);
2426 else
2427 {
2428 fprintf(fd_tags, "%s\t/*", s);
2429diff -Naur vim71.orig/src/ex_docmd.c vim71/src/ex_docmd.c
2430--- vim71.orig/src/ex_docmd.c 2007-05-07 12:49:38.000000000 -0700
[2830f42]2431+++ vim71/src/ex_docmd.c 2007-10-29 08:09:51.000000000 -0700
[ba61c16]2432@@ -133,6 +133,7 @@
2433 static void get_flags __ARGS((exarg_T *eap));
2434 #if !defined(FEAT_PERL) || !defined(FEAT_PYTHON) || !defined(FEAT_TCL) \
2435 || !defined(FEAT_RUBY) || !defined(FEAT_MZSCHEME)
2436+# define HAVE_EX_SCRIPT_NI
2437 static void ex_script_ni __ARGS((exarg_T *eap));
2438 #endif
2439 static char_u *invalid_range __ARGS((exarg_T *eap));
2440@@ -2118,7 +2119,11 @@
2441 #ifdef FEAT_USR_CMDS
2442 !USER_CMDIDX(ea.cmdidx) &&
2443 #endif
2444- cmdnames[ea.cmdidx].cmd_func == ex_ni);
2445+ (cmdnames[ea.cmdidx].cmd_func == ex_ni
2446+#ifdef HAVE_EX_SCRIPT_NI
2447+ || cmdnames[ea.cmdidx].cmd_func == ex_script_ni
2448+#endif
2449+ ));
2450
2451 #ifndef FEAT_EVAL
2452 /*
2453@@ -3276,39 +3281,65 @@
2454
2455 if (ea.argt & XFILE)
2456 {
2457- int in_quote = FALSE;
2458- char_u *bow = NULL; /* Beginning of word */
2459+ int c;
2460+ int in_quote = FALSE;
2461+ char_u *bow = NULL; /* Beginning of word */
2462
2463 /*
2464 * Allow spaces within back-quotes to count as part of the argument
2465 * being expanded.
2466 */
2467 xp->xp_pattern = skipwhite(arg);
2468- for (p = xp->xp_pattern; *p; )
2469+ p = xp->xp_pattern;
2470+ while (*p != NUL)
2471 {
2472- if (*p == '\\' && p[1] != NUL)
2473+#ifdef FEAT_MBYTE
2474+ if (has_mbyte)
2475+ c = mb_ptr2char(p);
2476+ else
2477+#endif
2478+ c = *p;
2479+ if (c == '\\' && p[1] != NUL)
2480 ++p;
2481+ else if (c == '`')
2482+ {
2483+ if (!in_quote)
2484+ {
2485+ xp->xp_pattern = p;
2486+ bow = p + 1;
2487+ }
2488+ in_quote = !in_quote;
2489+ }
2490 #ifdef SPACE_IN_FILENAME
2491- else if (vim_iswhite(*p) && (!(ea.argt & NOSPC) || usefilter))
2492+ else if (!vim_isfilec_or_wc(c)
2493+ && (!(ea.argt & NOSPC) || usefilter))
2494 #else
2495- else if (vim_iswhite(*p))
2496+ else if (!vim_isfilec_or_wc(c))
2497 #endif
2498 {
2499- p = skipwhite(p);
2500+ while (*p != NUL)
2501+ {
2502+#ifdef FEAT_MBYTE
2503+ if (has_mbyte)
2504+ c = mb_ptr2char(p);
2505+ else
2506+#endif
2507+ c = *p;
2508+ if (c == '`' || vim_isfilec_or_wc(c))
2509+ break;
2510+#ifdef FEAT_MBYTE
2511+ if (has_mbyte)
2512+ len = (*mb_ptr2len)(p);
2513+ else
2514+#endif
2515+ len = 1;
2516+ mb_ptr_adv(p);
2517+ }
2518 if (in_quote)
2519 bow = p;
2520 else
2521 xp->xp_pattern = p;
2522- --p;
2523- }
2524- else if (*p == '`')
2525- {
2526- if (!in_quote)
2527- {
2528- xp->xp_pattern = p;
2529- bow = p + 1;
2530- }
2531- in_quote = !in_quote;
2532+ p -= len;
2533 }
2534 mb_ptr_adv(p);
2535 }
2536@@ -3401,14 +3432,13 @@
2537 case CMD_windo:
2538 return arg;
2539
2540-#ifdef FEAT_SEARCH_EXTRA
2541+#ifdef FEAT_CMDL_COMPL
2542+# ifdef FEAT_SEARCH_EXTRA
2543 case CMD_match:
2544 if (*arg == NUL || !ends_excmd(*arg))
2545 {
2546- /* Dummy call to clear variables. */
2547- set_context_in_highlight_cmd(xp, (char_u *)"link n");
2548- xp->xp_context = EXPAND_HIGHLIGHT;
2549- xp->xp_pattern = arg;
2550+ /* also complete "None" */
2551+ set_context_in_echohl_cmd(xp, arg);
2552 arg = skipwhite(skiptowhite(arg));
2553 if (*arg != NUL)
2554 {
2555@@ -3417,9 +3447,8 @@
2556 }
2557 }
2558 return find_nextcmd(arg);
2559-#endif
2560+# endif
2561
2562-#ifdef FEAT_CMDL_COMPL
2563 /*
2564 * All completion for the +cmdline_compl feature goes here.
2565 */
2566@@ -3617,8 +3646,7 @@
2567 break;
2568
2569 case CMD_echohl:
2570- xp->xp_context = EXPAND_HIGHLIGHT;
2571- xp->xp_pattern = arg;
2572+ set_context_in_echohl_cmd(xp, arg);
2573 break;
2574 #endif
2575 case CMD_highlight:
2576@@ -3997,8 +4025,7 @@
2577 eap->errmsg = (char_u *)N_("E319: Sorry, the command is not available in this version");
2578 }
2579
2580-#if !defined(FEAT_PERL) || !defined(FEAT_PYTHON) || !defined(FEAT_TCL) \
2581- || !defined(FEAT_RUBY) || !defined(FEAT_MZSCHEME)
2582+#ifdef HAVE_EX_SCRIPT_NI
2583 /*
2584 * Function called for script command which is Not Implemented. NI!
2585 * Skips over ":perl <<EOF" constructs.
[c2aa910]2586@@ -4376,7 +4403,7 @@
2587 || vim_strchr(eap->arg, '~') != NULL)
2588 {
2589 expand_env_esc(eap->arg, NameBuff, MAXPATHL,
2590- TRUE, NULL);
2591+ TRUE, TRUE, NULL);
2592 has_wildcards = mch_has_wildcard(NameBuff);
2593 p = NameBuff;
2594 }
[ba61c16]2595@@ -4492,7 +4519,8 @@
2596 if (eap->argt & (USECTRLV | XFILE))
2597 ++p; /* skip CTRL-V and next char */
2598 else
2599- STRCPY(p, p + 1); /* remove CTRL-V and skip next char */
2600+ /* remove CTRL-V and skip next char */
2601+ mch_memmove(p, p + 1, STRLEN(p));
2602 if (*p == NUL) /* stop at NUL after CTRL-V */
2603 break;
2604 }
[2830f42]2605@@ -8399,21 +8427,17 @@
2606 || *arg == '"')
2607 {
2608 redir_reg = *arg++;
2609- if (*arg == '>' && arg[1] == '>')
2610+ if (*arg == '>' && arg[1] == '>') /* append */
2611 arg += 2;
2612- else if ((*arg == NUL || (*arg == '>' && arg[1] == NUL)) &&
2613- (islower(redir_reg)
2614-# ifdef FEAT_CLIPBOARD
2615- || redir_reg == '*'
2616- || redir_reg == '+'
2617-# endif
2618- || redir_reg == '"'))
2619+ else
2620 {
2621+ /* Can use both "@a" and "@a>". */
2622 if (*arg == '>')
2623 arg++;
2624-
2625- /* make register empty */
2626- write_reg_contents(redir_reg, (char_u *)"", -1, FALSE);
2627+ /* Make register empty when not using @A-@Z and the
2628+ * command is valid. */
2629+ if (*arg == NUL && !isupper(redir_reg))
2630+ write_reg_contents(redir_reg, (char_u *)"", -1, FALSE);
2631 }
2632 }
2633 if (*arg != NUL)
2634@@ -10816,12 +10840,13 @@
[ba61c16]2635 exarg_T *eap;
2636 {
2637 char_u *p;
2638+ char_u *g = NULL;
2639 char_u *end;
2640 int c;
2641- int mi;
2642+ int id;
2643
2644 if (eap->line2 <= 3)
2645- mi = eap->line2 - 1;
2646+ id = eap->line2;
2647 else
2648 {
2649 EMSG(e_invcmd);
[2830f42]2650@@ -10830,13 +10855,7 @@
[ba61c16]2651
2652 /* First clear any old pattern. */
2653 if (!eap->skip)
2654- {
2655- vim_free(curwin->w_match[mi].regprog);
2656- curwin->w_match[mi].regprog = NULL;
2657- vim_free(curwin->w_match_pat[mi]);
2658- curwin->w_match_pat[mi] = NULL;
2659- redraw_later(SOME_VALID); /* always need a redraw */
2660- }
2661+ match_delete(curwin, id, FALSE);
2662
2663 if (ends_excmd(*eap->arg))
2664 end = eap->arg;
[2830f42]2665@@ -10847,15 +10866,7 @@
[ba61c16]2666 {
2667 p = skiptowhite(eap->arg);
2668 if (!eap->skip)
2669- {
2670- curwin->w_match_id[mi] = syn_namen2id(eap->arg,
2671- (int)(p - eap->arg));
2672- if (curwin->w_match_id[mi] == 0)
2673- {
2674- EMSG2(_(e_nogroup), eap->arg);
2675- return;
2676- }
2677- }
2678+ g = vim_strnsave(eap->arg, (int)(p - eap->arg));
2679 p = skipwhite(p);
2680 if (*p == NUL)
2681 {
[2830f42]2682@@ -10879,14 +10890,8 @@
[ba61c16]2683
2684 c = *end;
2685 *end = NUL;
2686- curwin->w_match[mi].regprog = vim_regcomp(p + 1, RE_MAGIC);
2687- if (curwin->w_match[mi].regprog == NULL)
2688- {
2689- EMSG2(_(e_invarg2), p);
2690- *end = c;
2691- return;
2692- }
2693- curwin->w_match_pat[mi] = vim_strsave(p + 1);
2694+ match_add(curwin, g, p + 1, 10, id);
2695+ vim_free(g);
2696 *end = c;
2697 }
2698 }
2699diff -Naur vim71.orig/src/ex_eval.c vim71/src/ex_eval.c
2700--- vim71.orig/src/ex_eval.c 2007-05-07 12:47:50.000000000 -0700
[2830f42]2701+++ vim71/src/ex_eval.c 2007-10-29 08:09:18.000000000 -0700
[ba61c16]2702@@ -1551,7 +1551,7 @@
2703 }
2704 save_cpo = p_cpo;
2705 p_cpo = (char_u *)"";
2706- regmatch.regprog = vim_regcomp(pat, TRUE);
2707+ regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
2708 regmatch.rm_ic = FALSE;
2709 if (end != NULL)
2710 *end = save_char;
2711diff -Naur vim71.orig/src/ex_getln.c vim71/src/ex_getln.c
2712--- vim71.orig/src/ex_getln.c 2007-05-07 12:47:23.000000000 -0700
[2830f42]2713+++ vim71/src/ex_getln.c 2007-10-29 08:09:43.000000000 -0700
[ba61c16]2714@@ -268,7 +268,9 @@
2715 {
2716 xpc.xp_context = ccline.xp_context;
2717 xpc.xp_pattern = ccline.cmdbuff;
2718+# if defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)
2719 xpc.xp_arg = ccline.xp_arg;
2720+# endif
2721 }
2722 #endif
2723
2724@@ -484,7 +486,8 @@
2725 if (xpc.xp_context == EXPAND_MENUNAMES && p_wmnu)
2726 {
2727 /* Hitting <Down> after "emenu Name.": complete submenu */
2728- if (ccline.cmdbuff[ccline.cmdpos - 1] == '.' && c == K_DOWN)
2729+ if (c == K_DOWN && ccline.cmdpos > 0
2730+ && ccline.cmdbuff[ccline.cmdpos - 1] == '.')
2731 c = p_wc;
2732 else if (c == K_UP)
2733 {
2734@@ -533,9 +536,11 @@
2735 upseg[3] = PATHSEP;
2736 upseg[4] = NUL;
2737
2738- if (ccline.cmdbuff[ccline.cmdpos - 1] == PATHSEP
2739- && c == K_DOWN
2740- && (ccline.cmdbuff[ccline.cmdpos - 2] != '.'
2741+ if (c == K_DOWN
2742+ && ccline.cmdpos > 0
2743+ && ccline.cmdbuff[ccline.cmdpos - 1] == PATHSEP
2744+ && (ccline.cmdpos < 3
2745+ || ccline.cmdbuff[ccline.cmdpos - 2] != '.'
2746 || ccline.cmdbuff[ccline.cmdpos - 3] != '.'))
2747 {
2748 /* go down a directory */
[c2aa910]2749@@ -636,7 +641,7 @@
2750 {
2751 ++no_mapping;
2752 ++allow_keys;
2753- c = safe_vgetc();
2754+ c = plain_vgetc();
2755 --no_mapping;
2756 --allow_keys;
2757 /* CTRL-\ e doesn't work when obtaining an expression. */
[ba61c16]2758@@ -730,8 +735,8 @@
2759 /* In Ex mode a backslash escapes a newline. */
2760 if (exmode_active
2761 && c != ESC
2762- && ccline.cmdpos > 0
2763 && ccline.cmdpos == ccline.cmdlen
2764+ && ccline.cmdpos > 0
2765 && ccline.cmdbuff[ccline.cmdpos - 1] == '\\')
2766 {
2767 if (c == K_KENTER)
[c2aa910]2768@@ -1086,11 +1091,11 @@
2769 #endif
2770 putcmdline('"', TRUE);
2771 ++no_mapping;
2772- i = c = safe_vgetc(); /* CTRL-R <char> */
2773+ i = c = plain_vgetc(); /* CTRL-R <char> */
2774 if (i == Ctrl_O)
2775 i = Ctrl_R; /* CTRL-R CTRL-O == CTRL-R CTRL-R */
2776 if (i == Ctrl_R)
2777- c = safe_vgetc(); /* CTRL-R CTRL-R <char> */
2778+ c = plain_vgetc(); /* CTRL-R CTRL-R <char> */
2779 --no_mapping;
2780 #ifdef FEAT_EVAL
2781 /*
[ba61c16]2782@@ -2090,11 +2095,11 @@
2783 garray_T line_ga;
2784 char_u *pend;
2785 int startcol = 0;
2786- int c1;
2787+ int c1 = 0;
2788 int escaped = FALSE; /* CTRL-V typed */
2789 int vcol = 0;
2790 char_u *p;
2791- int prev_char = 0;
2792+ int prev_char;
2793
2794 /* Switch cursor on now. This avoids that it happens after the "\n", which
2795 * confuses the system function that computes tabstops. */
2796@@ -2147,6 +2152,7 @@
2797
2798 /* Get one character at a time. Don't use inchar(), it can't handle
2799 * special characters. */
2800+ prev_char = c1;
2801 c1 = vgetc();
2802
2803 /*
2804@@ -2204,7 +2210,6 @@
2805 redraw:
2806 /* redraw the line */
2807 msg_col = startcol;
2808- windgoto(msg_row, msg_col);
2809 vcol = 0;
2810 for (p = (char_u *)line_ga.ga_data;
2811 p < (char_u *)line_ga.ga_data + line_ga.ga_len; ++p)
2812@@ -2223,6 +2228,7 @@
2813 }
2814 }
2815 msg_clr_eos();
2816+ windgoto(msg_row, msg_col);
2817 continue;
2818 }
2819
2820@@ -2268,7 +2274,6 @@
2821 if (IS_SPECIAL(c1))
2822 c1 = '?';
2823 ((char_u *)line_ga.ga_data)[line_ga.ga_len] = c1;
2824- prev_char = c1;
2825 if (c1 == '\n')
2826 msg_putchar('\n');
2827 else if (c1 == TAB)
[c2aa910]2828@@ -3311,6 +3316,10 @@
2829 * Return a pointer to alloced memory containing the new string.
2830 * Return NULL for failure.
2831 *
2832+ * "orig" is the originally expanded string, copied to allocated memory. It
2833+ * should either be kept in orig_save or freed. When "mode" is WILD_NEXT or
2834+ * WILD_PREV "orig" should be NULL.
2835+ *
2836 * Results are cached in xp->xp_files and xp->xp_numfiles, except when "mode"
2837 * is WILD_EXPAND_FREE or WILD_ALL.
2838 *
2839@@ -3395,7 +3404,7 @@
2840 return NULL;
2841 }
2842
2843-/* free old names */
2844+ /* free old names */
2845 if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
2846 {
2847 FreeWild(xp->xp_numfiles, xp->xp_files);
2848@@ -3536,6 +3545,10 @@
2849 if (mode == WILD_EXPAND_FREE || mode == WILD_ALL)
2850 ExpandCleanup(xp);
2851
2852+ /* Free "orig" if it wasn't stored in "orig_save". */
2853+ if (orig != orig_save)
2854+ vim_free(orig);
2855+
2856 return ss;
2857 }
2858
2859@@ -4148,13 +4161,19 @@
[ba61c16]2860
2861 #ifdef FEAT_EVAL
2862 if (ccline.cmdfirstc == '=')
2863+ {
2864+# ifdef FEAT_CMDL_COMPL
2865 /* pass CMD_SIZE because there is no real command */
2866 set_context_for_expression(xp, str, CMD_SIZE);
2867+# endif
2868+ }
2869 else if (ccline.input_fn)
2870 {
2871 xp->xp_context = ccline.xp_context;
2872 xp->xp_pattern = ccline.cmdbuff;
2873+# if defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)
2874 xp->xp_arg = ccline.xp_arg;
2875+# endif
2876 }
2877 else
2878 #endif
[c2aa910]2879@@ -4295,10 +4314,11 @@
[ba61c16]2880 && pat[i + 1] == '\\'
2881 && pat[i + 2] == '\\'
2882 && pat[i + 3] == ' ')
2883- STRCPY(pat + i, pat + i + 3);
2884+ mch_memmove(pat + i, pat + i + 3,
2885+ STRLEN(pat + i + 3) + 1);
2886 if (xp->xp_backslash == XP_BS_ONE
2887 && pat[i + 1] == ' ')
2888- STRCPY(pat + i, pat + i + 1);
2889+ mch_memmove(pat + i, pat + i + 1, STRLEN(pat + i));
2890 }
2891 }
2892
[c2aa910]2893@@ -4502,6 +4522,12 @@
[ba61c16]2894 if (xp->xp_context != EXPAND_MENUNAMES && xp->xp_context != EXPAND_MENUS)
2895 sort_strings(*file, *num_file);
2896
2897+#ifdef FEAT_CMDL_COMPL
2898+ /* Reset the variables used for special highlight names expansion, so that
2899+ * they don't show up when getting normal highlight names by ID. */
2900+ reset_expand_highlight();
2901+#endif
2902+
2903 return OK;
2904 }
2905
[c2aa910]2906@@ -4535,7 +4561,7 @@
[ba61c16]2907 pat = vim_strsave(filepat);
2908 for (i = 0; pat[i]; ++i)
2909 if (pat[i] == '\\' && pat[i + 1] == ' ')
2910- STRCPY(pat + i, pat + i + 1);
2911+ mch_memmove(pat + i, pat + i + 1, STRLEN(pat + i));
2912
2913 flags |= EW_FILE | EW_EXEC;
2914
[c2aa910]2915@@ -5907,7 +5933,7 @@
2916
2917 # ifdef FEAT_AUTOCMD
2918 /* Don't execute autocommands while creating the window. */
2919- ++autocmd_block;
2920+ block_autocmds();
2921 # endif
2922 /* don't use a new tab page */
2923 cmdmod.tab = 0;
2924@@ -5916,6 +5942,9 @@
2925 if (win_split((int)p_cwh, WSP_BOT) == FAIL)
2926 {
2927 beep_flush();
2928+# ifdef FEAT_AUTOCMD
2929+ unblock_autocmds();
2930+# endif
2931 return K_IGNORE;
2932 }
2933 cmdwin_type = ccline.cmdfirstc;
2934@@ -5938,7 +5967,7 @@
2935
2936 # ifdef FEAT_AUTOCMD
2937 /* Do execute autocommands for setting the filetype (load syntax). */
2938- --autocmd_block;
2939+ unblock_autocmds();
2940 # endif
2941
2942 /* Showing the prompt may have set need_wait_return, reset it. */
2943@@ -6092,7 +6121,7 @@
2944
2945 # ifdef FEAT_AUTOCMD
2946 /* Don't execute autocommands while deleting the window. */
2947- ++autocmd_block;
2948+ block_autocmds();
2949 # endif
2950 wp = curwin;
2951 bp = curbuf;
2952@@ -6104,7 +6133,7 @@
2953 win_size_restore(&winsizes);
2954
2955 # ifdef FEAT_AUTOCMD
2956- --autocmd_block;
2957+ unblock_autocmds();
2958 # endif
2959 }
2960
[ba61c16]2961diff -Naur vim71.orig/src/feature.h vim71/src/feature.h
2962--- vim71.orig/src/feature.h 2007-05-07 12:33:19.000000000 -0700
[2830f42]2963+++ vim71/src/feature.h 2007-10-29 08:09:18.000000000 -0700
[ba61c16]2964@@ -673,7 +673,7 @@
2965 # define ESC_CHG_TO_ENG_MODE /* if defined, when ESC pressed,
2966 * turn to english mode
2967 */
2968-# if !defined(FEAT_XFONTSET) && defined(HAVE_X11)
2969+# if !defined(FEAT_XFONTSET) && defined(HAVE_X11) && !defined(HAVE_GTK2)
2970 # define FEAT_XFONTSET /* Hangul input requires xfontset */
2971 # endif
2972 # if defined(FEAT_XIM) && !defined(LINT)
2973diff -Naur vim71.orig/src/fileio.c vim71/src/fileio.c
2974--- vim71.orig/src/fileio.c 2007-05-10 04:29:44.000000000 -0700
[2830f42]2975+++ vim71/src/fileio.c 2007-10-29 08:09:48.000000000 -0700
[ba61c16]2976@@ -44,6 +44,10 @@
2977 /* Is there any system that doesn't have access()? */
2978 #define USE_MCH_ACCESS
2979
2980+#if defined(sun) && defined(S_ISCHR)
2981+# define OPEN_CHR_FILES
2982+static int is_dev_fd_file(char_u *fname);
2983+#endif
2984 #ifdef FEAT_MBYTE
2985 static char_u *next_fenc __ARGS((char_u **pp));
2986 # ifdef FEAT_EVAL
2987@@ -406,6 +410,10 @@
2988 # ifdef S_ISSOCK
2989 && !S_ISSOCK(perm) /* ... or socket */
2990 # endif
2991+# ifdef OPEN_CHR_FILES
2992+ && !(S_ISCHR(perm) && is_dev_fd_file(fname))
2993+ /* ... or a character special file named /dev/fd/<n> */
2994+# endif
2995 )
2996 {
2997 if (S_ISDIR(perm))
2998@@ -424,7 +432,7 @@
2999 */
3000 if (!p_odev && mch_nodetype(fname) == NODE_WRITABLE)
3001 {
3002- filemess(curbuf, fname, (char_u *)_("is a device (disabled with 'opendevice' option"), 0);
3003+ filemess(curbuf, fname, (char_u *)_("is a device (disabled with 'opendevice' option)"), 0);
3004 msg_end();
3005 msg_scroll = msg_save;
3006 return FAIL;
3007@@ -646,6 +654,7 @@
3008 curbuf->b_start_eol = TRUE;
3009 #ifdef FEAT_MBYTE
3010 curbuf->b_p_bomb = FALSE;
3011+ curbuf->b_start_bomb = FALSE;
3012 #endif
3013 }
3014
3015@@ -904,7 +913,10 @@
3016 file_rewind = FALSE;
3017 #ifdef FEAT_MBYTE
3018 if (set_options)
3019+ {
3020 curbuf->b_p_bomb = FALSE;
3021+ curbuf->b_start_bomb = FALSE;
3022+ }
3023 conv_error = 0;
3024 #endif
3025 }
3026@@ -1353,7 +1365,10 @@
3027 size -= blen;
3028 mch_memmove(ptr, ptr + blen, (size_t)size);
3029 if (set_options)
3030+ {
3031 curbuf->b_p_bomb = TRUE;
3032+ curbuf->b_start_bomb = TRUE;
3033+ }
3034 }
3035
3036 if (fio_flags == FIO_UCSBOM)
3037@@ -2265,6 +2280,13 @@
3038 }
3039 # endif
3040 # endif
3041+# ifdef OPEN_CHR_FILES
3042+ if (S_ISCHR(perm)) /* or character special */
3043+ {
3044+ STRCAT(IObuff, _("[character special]"));
3045+ c = TRUE;
3046+ }
3047+# endif
3048 #endif
3049 if (curbuf->b_p_ro)
3050 {
3051@@ -2464,6 +2486,25 @@
3052 return OK;
3053 }
3054
3055+#ifdef OPEN_CHR_FILES
3056+/*
3057+ * Returns TRUE if the file name argument is of the form "/dev/fd/\d\+",
3058+ * which is the name of files used for process substitution output by
3059+ * some shells on some operating systems, e.g., bash on SunOS.
3060+ * Do not accept "/dev/fd/[012]", opening these may hang Vim.
3061+ */
3062+ static int
3063+is_dev_fd_file(fname)
3064+ char_u *fname;
3065+{
3066+ return (STRNCMP(fname, "/dev/fd/", 8) == 0
3067+ && VIM_ISDIGIT(fname[8])
3068+ && *skipdigits(fname + 9) == NUL
3069+ && (fname[9] != NUL
3070+ || (fname[8] != '0' && fname[8] != '1' && fname[8] != '2')));
3071+}
3072+#endif
3073+
3074 #ifdef FEAT_MBYTE
3075
3076 /*
3077@@ -2734,6 +2775,32 @@
3078 #endif
3079
3080 /*
3081+ * Return TRUE if a file appears to be read-only from the file permissions.
3082+ */
3083+ int
3084+check_file_readonly(fname, perm)
3085+ char_u *fname; /* full path to file */
3086+ int perm; /* known permissions on file */
3087+{
3088+#ifndef USE_MCH_ACCESS
3089+ int fd = 0;
3090+#endif
3091+
3092+ return (
3093+#ifdef USE_MCH_ACCESS
3094+# ifdef UNIX
3095+ (perm & 0222) == 0 ||
3096+# endif
3097+ mch_access((char *)fname, W_OK)
3098+#else
3099+ (fd = mch_open((char *)fname, O_RDWR | O_EXTRA, 0)) < 0
3100+ ? TRUE : (close(fd), FALSE)
3101+#endif
3102+ );
3103+}
3104+
3105+
3106+/*
3107 * buf_write() - write to file "fname" lines "start" through "end"
3108 *
3109 * We do our own buffering here because fwrite() is so slow.
3110@@ -3219,17 +3286,8 @@
3111 * Check if the file is really writable (when renaming the file to
3112 * make a backup we won't discover it later).
3113 */
3114- file_readonly = (
3115-# ifdef USE_MCH_ACCESS
3116-# ifdef UNIX
3117- (perm & 0222) == 0 ||
3118-# endif
3119- mch_access((char *)fname, W_OK)
3120-# else
3121- (fd = mch_open((char *)fname, O_RDWR | O_EXTRA, 0)) < 0
3122- ? TRUE : (close(fd), FALSE)
3123-# endif
3124- );
3125+ file_readonly = check_file_readonly(fname, (int)perm);
3126+
3127 if (!forceit && file_readonly)
3128 {
3129 if (vim_strchr(p_cpo, CPO_FWRITE) != NULL)
[c2aa910]3130@@ -5495,6 +5553,8 @@
3131 }
3132 #endif
3133
3134+#if defined(FEAT_VIMINFO) || defined(FEAT_BROWSE) || \
3135+ defined(FEAT_QUICKFIX) || defined(PROTO)
3136 /*
3137 * Try to find a shortname by comparing the fullname with the current
3138 * directory.
3139@@ -5548,6 +5608,7 @@
3140 p = NULL;
3141 return p;
3142 }
3143+#endif
3144
3145 /*
3146 * Shorten filenames for all buffers.
3147@@ -7107,6 +7168,7 @@
3148
3149 static event_T last_event;
3150 static int last_group;
3151+static int autocmd_blocked = 0; /* block all autocmds */
3152
3153 /*
3154 * Show the autocommands for one AutoPat.
3155@@ -8396,7 +8458,7 @@
3156 * Quickly return if there are no autocommands for this event or
3157 * autocommands are blocked.
3158 */
3159- if (first_autopat[(int)event] == NULL || autocmd_block > 0)
3160+ if (first_autopat[(int)event] == NULL || autocmd_blocked > 0)
3161 goto BYPASS_AU;
3162
3163 /*
3164@@ -8710,6 +8772,40 @@
3165 return retval;
3166 }
3167
3168+# ifdef FEAT_EVAL
3169+static char_u *old_termresponse = NULL;
3170+# endif
3171+
3172+/*
3173+ * Block triggering autocommands until unblock_autocmd() is called.
3174+ * Can be used recursively, so long as it's symmetric.
3175+ */
3176+ void
3177+block_autocmds()
3178+{
3179+# ifdef FEAT_EVAL
3180+ /* Remember the value of v:termresponse. */
3181+ if (autocmd_blocked == 0)
3182+ old_termresponse = get_vim_var_str(VV_TERMRESPONSE);
3183+# endif
3184+ ++autocmd_blocked;
3185+}
3186+
3187+ void
3188+unblock_autocmds()
3189+{
3190+ --autocmd_blocked;
3191+
3192+# ifdef FEAT_EVAL
3193+ /* When v:termresponse was set while autocommands were blocked, trigger
3194+ * the autocommands now. Esp. useful when executing a shell command
3195+ * during startup (vimdiff). */
3196+ if (autocmd_blocked == 0
3197+ && get_vim_var_str(VV_TERMRESPONSE) != old_termresponse)
3198+ apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf);
3199+# endif
3200+}
3201+
3202 /*
3203 * Find next autocommand pattern that matches.
3204 */
3205diff -Naur vim71.orig/src/fold.c vim71/src/fold.c
3206--- vim71.orig/src/fold.c 2007-05-07 12:46:32.000000000 -0700
[2830f42]3207+++ vim71/src/fold.c 2007-10-29 08:09:51.000000000 -0700
[c2aa910]3208@@ -858,7 +858,14 @@
3209 || foldmethodIsDiff(wp)
3210 #endif
3211 || foldmethodIsSyntax(wp))
3212+ {
3213+ int save_got_int = got_int;
3214+
3215+ /* reset got_int here, otherwise it won't work */
3216+ got_int = FALSE;
3217 foldUpdateIEMS(wp, top, bot);
3218+ got_int |= save_got_int;
3219+ }
3220 }
3221
3222 /* foldUpdateAll() {{{2 */
3223diff -Naur vim71.orig/src/getchar.c vim71/src/getchar.c
3224--- vim71.orig/src/getchar.c 2007-05-07 12:18:20.000000000 -0700
[2830f42]3225+++ vim71/src/getchar.c 2007-10-29 08:09:37.000000000 -0700
[c2aa910]3226@@ -1596,8 +1596,16 @@
3227 continue;
3228 }
3229 #endif
3230-
3231 #ifdef FEAT_GUI
3232+ /* Handle focus event here, so that the caller doesn't need to
3233+ * know about it. Return K_IGNORE so that we loop once (needed if
3234+ * 'lazyredraw' is set). */
3235+ if (c == K_FOCUSGAINED || c == K_FOCUSLOST)
3236+ {
3237+ ui_focus_change(c == K_FOCUSGAINED);
3238+ c = K_IGNORE;
3239+ }
3240+
3241 /* Translate K_CSI to CSI. The special key is only used to avoid
3242 * it being recognized as the start of a special key. */
3243 if (c == K_CSI)
3244@@ -1741,6 +1749,22 @@
3245 }
3246
3247 /*
3248+ * Like safe_vgetc(), but loop to handle K_IGNORE.
3249+ * Also ignore scrollbar events.
3250+ */
3251+ int
3252+plain_vgetc()
3253+{
3254+ int c;
3255+
3256+ do
3257+ {
3258+ c = safe_vgetc();
3259+ } while (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR);
3260+ return c;
3261+}
3262+
3263+/*
3264 * Check if a character is available, such that vgetc() will not block.
3265 * If the next character is a special character or multi-byte, the returned
3266 * character is not valid!.
[ba61c16]3267diff -Naur vim71.orig/src/globals.h vim71/src/globals.h
3268--- vim71.orig/src/globals.h 2007-05-07 12:44:26.000000000 -0700
[2830f42]3269+++ vim71/src/globals.h 2007-10-29 08:09:40.000000000 -0700
[c2aa910]3270@@ -301,13 +301,17 @@
3271 #endif
3272
3273 #ifdef FEAT_EVAL
3274-/* Garbage collection can only take place when we are sure there are no Lists
3275+/*
3276+ * Garbage collection can only take place when we are sure there are no Lists
3277 * or Dictionaries being used internally. This is flagged with
3278 * "may_garbage_collect" when we are at the toplevel.
3279 * "want_garbage_collect" is set by the garbagecollect() function, which means
3280- * we do garbage collection before waiting for a char at the toplevel. */
3281+ * we do garbage collection before waiting for a char at the toplevel.
3282+ * "garbage_collect_at_exit" indicates garbagecollect(1) was called.
3283+ */
3284 EXTERN int may_garbage_collect INIT(= FALSE);
3285 EXTERN int want_garbage_collect INIT(= FALSE);
3286+EXTERN int garbage_collect_at_exit INIT(= FALSE);
3287
3288 /* ID of script being sourced or was sourced to define the current function. */
3289 EXTERN scid_T current_SID INIT(= 0);
3290@@ -362,7 +366,6 @@
3291 EXTERN int autocmd_busy INIT(= FALSE); /* Is apply_autocmds() busy? */
3292 EXTERN int autocmd_no_enter INIT(= FALSE); /* *Enter autocmds disabled */
3293 EXTERN int autocmd_no_leave INIT(= FALSE); /* *Leave autocmds disabled */
3294-EXTERN int autocmd_block INIT(= 0); /* block all autocmds */
3295 EXTERN int modified_was_set; /* did ":set modified" */
3296 EXTERN int did_filetype INIT(= FALSE); /* FileType event found */
3297 EXTERN int keep_filetype INIT(= FALSE); /* value for did_filetype when
3298@@ -801,7 +804,7 @@
[ba61c16]3299 EXTERN int (*mb_char2bytes) __ARGS((int c, char_u *buf)) INIT(= latin_char2bytes);
3300 EXTERN int (*mb_ptr2cells) __ARGS((char_u *p)) INIT(= latin_ptr2cells);
3301 EXTERN int (*mb_char2cells) __ARGS((int c)) INIT(= latin_char2cells);
3302-EXTERN int (*mb_off2cells) __ARGS((unsigned off)) INIT(= latin_off2cells);
3303+EXTERN int (*mb_off2cells) __ARGS((unsigned off, unsigned max_off)) INIT(= latin_off2cells);
3304 EXTERN int (*mb_ptr2char) __ARGS((char_u *p)) INIT(= latin_ptr2char);
3305 EXTERN int (*mb_head_off) __ARGS((char_u *base, char_u *p)) INIT(= latin_head_off);
3306
3307diff -Naur vim71.orig/src/gui.c vim71/src/gui.c
3308--- vim71.orig/src/gui.c 2007-05-07 12:50:55.000000000 -0700
[2830f42]3309+++ vim71/src/gui.c 2007-10-29 08:09:37.000000000 -0700
[ba61c16]3310@@ -1080,7 +1080,8 @@
3311 cur_width = gui.char_width;
3312 }
3313 #ifdef FEAT_MBYTE
3314- if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col) > 1)
3315+ if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col,
3316+ LineOffset[gui.row] + screen_Columns) > 1)
3317 {
3318 /* Double wide character. */
3319 if (shape_table[idx].shape != SHAPE_VER)
3320@@ -1159,7 +1160,7 @@
3321 #endif
3322
3323 # if defined(FEAT_GUI_TABLINE) && (defined(FEAT_GUI_MSWIN) \
3324- || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_MAC))
3325+ || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_MAC))
3326 if (gui_has_tabline())
3327 text_area_y += gui.tabline_height;
3328 #endif
[c2aa910]3329@@ -4518,7 +4519,18 @@
3330 xim_set_focus(in_focus);
3331 # endif
3332
3333- ui_focus_change(in_focus);
3334+ /* Put events in the input queue only when allowed.
3335+ * ui_focus_change() isn't called directly, because it invokes
3336+ * autocommands and that must not happen asynchronously. */
3337+ if (!hold_gui_events)
3338+ {
3339+ char_u bytes[3];
3340+
3341+ bytes[0] = CSI;
3342+ bytes[1] = KS_EXTRA;
3343+ bytes[2] = in_focus ? (int)KE_FOCUSGAINED : (int)KE_FOCUSLOST;
3344+ add_to_input_buf(bytes, 3);
3345+ }
3346 #endif
3347 }
3348
3349@@ -5117,7 +5129,7 @@
[ba61c16]3350 p = vim_strsave_escaped(fnames[i], (char_u *)"\\ \t\"|");
3351 # endif
3352 if (p != NULL)
3353- add_to_input_buf(p, (int)STRLEN(p));
3354+ add_to_input_buf_csi(p, (int)STRLEN(p));
3355 vim_free(p);
3356 vim_free(fnames[i]);
3357 }
3358diff -Naur vim71.orig/src/gui_gtk.c vim71/src/gui_gtk.c
3359--- vim71.orig/src/gui_gtk.c 2007-05-10 01:37:37.000000000 -0700
[2830f42]3360+++ vim71/src/gui_gtk.c 2007-10-29 08:09:23.000000000 -0700
[ba61c16]3361@@ -53,8 +53,8 @@
3362 # ifdef bindtextdomain
3363 # undef bindtextdomain
3364 # endif
3365-# ifdef bindtextdomain_codeset
3366-# undef bindtextdomain_codeset
3367+# ifdef bind_textdomain_codeset
3368+# undef bind_textdomain_codeset
3369 # endif
3370 # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS)
3371 # define ENABLE_NLS /* so the texts in the dialog boxes are translated */
3372@@ -1630,11 +1630,14 @@
3373 */
3374 /*ARGSUSED*/
3375 static int
3376-dlg_key_press_event(GtkWidget * widget, GdkEventKey * event, CancelData *data)
3377+dlg_key_press_event(GtkWidget *widget, GdkEventKey *event, CancelData *data)
3378 {
3379- /* Ignore hitting Enter when there is no default button. */
3380- if (data->ignore_enter && event->keyval == GDK_Return)
3381+ /* Ignore hitting Enter (or Space) when there is no default button. */
3382+ if (data->ignore_enter && (event->keyval == GDK_Return
3383+ || event->keyval == ' '))
3384 return TRUE;
3385+ else /* A different key was pressed, return to normal behavior */
3386+ data->ignore_enter = FALSE;
3387
3388 if (event->keyval != GDK_Escape && event->keyval != GDK_Return)
3389 return FALSE;
3390@@ -2224,6 +2227,13 @@
3391 {
3392 DialogInfo *di = (DialogInfo *)data;
3393
3394+ /* Ignore hitting Enter (or Space) when there is no default button. */
3395+ if (di->ignore_enter && (event->keyval == GDK_Return
3396+ || event->keyval == ' '))
3397+ return TRUE;
3398+ else /* A different key was pressed, return to normal behavior */
3399+ di->ignore_enter = FALSE;
3400+
3401 /* Close the dialog when hitting "Esc". */
3402 if (event->keyval == GDK_Escape)
3403 {
3404diff -Naur vim71.orig/src/gui_gtk_x11.c vim71/src/gui_gtk_x11.c
3405--- vim71.orig/src/gui_gtk_x11.c 2007-05-10 01:37:49.000000000 -0700
[2830f42]3406+++ vim71/src/gui_gtk_x11.c 2007-10-29 08:09:51.000000000 -0700
[ba61c16]3407@@ -36,8 +36,8 @@
3408 # ifdef bindtextdomain
3409 # undef bindtextdomain
3410 # endif
3411-# ifdef bindtextdomain_codeset
3412-# undef bindtextdomain_codeset
3413+# ifdef bind_textdomain_codeset
3414+# undef bind_textdomain_codeset
3415 # endif
3416 # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS)
3417 # define ENABLE_NLS /* so the texts in the dialog boxes are translated */
[c2aa910]3418@@ -813,10 +813,15 @@
3419 if (blink_state == BLINK_NONE)
3420 gui_mch_start_blink();
3421
3422- /* make sure keyboard input goes to the draw area (if this is focus for a window) */
3423+ /* make sure keyboard input goes to the draw area (if this is focus for a
3424+ * window) */
3425 if (widget != gui.drawarea)
3426 gtk_widget_grab_focus(gui.drawarea);
3427
3428+ /* make sure the input buffer is read */
3429+ if (gtk_main_level() > 0)
3430+ gtk_main_quit();
3431+
3432 return TRUE;
3433 }
3434
3435@@ -829,6 +834,10 @@
3436 if (blink_state != BLINK_NONE)
3437 gui_mch_stop_blink();
3438
3439+ /* make sure the input buffer is read */
3440+ if (gtk_main_level() > 0)
3441+ gtk_main_quit();
3442+
3443 return TRUE;
3444 }
3445
3446@@ -2188,8 +2197,10 @@
[ba61c16]3447 escaped_filename = vim_strsave_escaped(filename, escape_chars);
3448 if (escaped_filename == NULL)
3449 return FALSE;
3450- mksession_cmdline = g_strconcat("mksession ", (char *)escaped_filename, NULL);
3451+ mksession_cmdline = g_strconcat("mksession ", (char *)escaped_filename,
3452+ NULL);
3453 vim_free(escaped_filename);
3454+
3455 /*
3456 * Use a reasonable hardcoded set of 'sessionoptions' flags to avoid
3457 * unpredictable effects when the session is saved automatically. Also,
[c2aa910]3458@@ -2199,7 +2210,7 @@
[ba61c16]3459 */
3460 save_ssop_flags = ssop_flags;
3461 ssop_flags = (SSOP_BLANK|SSOP_CURDIR|SSOP_FOLDS|SSOP_GLOBALS
3462- |SSOP_HELP|SSOP_OPTIONS|SSOP_WINSIZE);
3463+ |SSOP_HELP|SSOP_OPTIONS|SSOP_WINSIZE|SSOP_TABPAGES);
3464
3465 do_cmdline_cmd((char_u *)"let Save_VV_this_session = v:this_session");
3466 failed = (do_cmdline_cmd((char_u *)mksession_cmdline) == FAIL);
[c2aa910]3467@@ -3212,8 +3223,9 @@
3468 {
3469 if (clicked_page == 0)
3470 {
3471- /* Click after all tabs moves to next tab page. */
3472- if (send_tabline_event(0) && gtk_main_level() > 0)
3473+ /* Click after all tabs moves to next tab page. When "x" is
3474+ * small guess it's the left button. */
3475+ if (send_tabline_event(x < 50 ? -1 : 0) && gtk_main_level() > 0)
3476 gtk_main_quit();
3477 }
3478 #ifndef HAVE_GTK2
[2830f42]3479@@ -4032,6 +4044,8 @@
3480 unsigned int w, h;
3481 int x = 0;
3482 int y = 0;
3483+ guint pixel_width;
3484+ guint pixel_height;
3485
3486 mask = XParseGeometry((char *)gui.geom, &x, &y, &w, &h);
3487
3488@@ -4043,12 +4057,31 @@
3489 p_window = h - 1;
3490 Rows = h;
3491 }
3492+
3493+ pixel_width = (guint)(gui_get_base_width() + Columns * gui.char_width);
3494+ pixel_height = (guint)(gui_get_base_height() + Rows * gui.char_height);
3495+
3496+#ifdef HAVE_GTK2
3497+ pixel_width += get_menu_tool_width();
3498+ pixel_height += get_menu_tool_height();
3499+#endif
3500+
3501 if (mask & (XValue | YValue))
3502+ {
3503+ int w, h;
3504+ gui_mch_get_screen_dimensions(&w, &h);
3505+ h += p_ghr + get_menu_tool_height();
3506+ w += get_menu_tool_width();
3507+ if (mask & XNegative)
3508+ x += w - pixel_width;
3509+ if (mask & YNegative)
3510+ y += h - pixel_height;
3511 #ifdef HAVE_GTK2
3512 gtk_window_move(GTK_WINDOW(gui.mainwin), x, y);
3513 #else
3514 gtk_widget_set_uposition(gui.mainwin, x, y);
3515 #endif
3516+ }
3517 vim_free(gui.geom);
3518 gui.geom = NULL;
3519
3520@@ -4059,14 +4092,6 @@
3521 */
3522 if (gtk_socket_id != 0 && (mask & WidthValue || mask & HeightValue))
3523 {
3524- guint pixel_width = (guint)(gui_get_base_width() + Columns * gui.char_width);
3525- guint pixel_height = (guint)(gui_get_base_height() + Rows * gui.char_height);
3526-
3527-#ifdef HAVE_GTK2
3528- pixel_width += get_menu_tool_width();
3529- pixel_height += get_menu_tool_height();
3530-#endif
3531-
3532 update_window_manager_hints(pixel_width, pixel_height);
3533 init_window_hints_state = 1;
3534 g_timeout_add(1000, check_startup_plug_hints, NULL);
[ba61c16]3535diff -Naur vim71.orig/src/if_cscope.c vim71/src/if_cscope.c
3536--- vim71.orig/src/if_cscope.c 2007-03-11 07:29:57.000000000 -0700
[2830f42]3537+++ vim71/src/if_cscope.c 2007-10-29 08:09:37.000000000 -0700
[c2aa910]3538@@ -24,11 +24,6 @@
3539 /* not UNIX, must be WIN32 */
3540 # include "vimio.h"
3541 # include <fcntl.h>
3542-# include <process.h>
3543-# define STDIN_FILENO 0
3544-# define STDOUT_FILENO 1
3545-# define STDERR_FILENO 2
3546-# define pipe(fds) _pipe(fds, 256, O_TEXT|O_NOINHERIT)
3547 #endif
3548 #include "if_cscope.h"
3549
3550@@ -65,7 +60,7 @@
3551 static char * cs_parse_results __ARGS((int cnumber, char *buf, int bufsize, char **context, char **linenumber, char **search));
3552 static char * cs_pathcomponents __ARGS((char *path));
3553 static void cs_print_tags_priv __ARGS((char **, char **, int));
3554-static int cs_read_prompt __ARGS((int ));
3555+static int cs_read_prompt __ARGS((int));
3556 static void cs_release_csp __ARGS((int, int freefnpp));
3557 static int cs_reset __ARGS((exarg_T *eap));
3558 static char * cs_resolve_file __ARGS((int, char *));
3559@@ -73,6 +68,8 @@
[ba61c16]3560
3561
3562 static csinfo_T csinfo[CSCOPE_MAX_CONNECTIONS];
3563+static int eap_arg_len; /* length of eap->arg, set in
3564+ cs_lookup_cmd() */
3565 static cscmd_T cs_cmds[] =
3566 {
3567 { "add", cs_add,
[c2aa910]3568@@ -260,14 +257,7 @@
[ba61c16]3569
3570 if ((p = cs_manage_matches(NULL, NULL, -1, Get)) == NULL)
3571 return TRUE;
3572-
3573- if ((int)strlen(p) > size)
3574- {
3575- strncpy((char *)buf, p, size - 1);
3576- buf[size] = '\0';
3577- }
3578- else
3579- (void)strcpy((char *)buf, p);
3580+ vim_strncpy(buf, (char_u *)p, size - 1);
3581
3582 return FALSE;
3583 } /* cs_fgets */
[c2aa910]3584@@ -386,7 +376,7 @@
[ba61c16]3585 * PRIVATE: cs_add
3586 *
3587 * add cscope database or a directory name (to look for cscope.out)
3588- * the the cscope connection list
3589+ * to the cscope connection list
3590 *
3591 * MAXPATHL 256
3592 */
[c2aa910]3593@@ -509,7 +499,7 @@
3594 #if defined(UNIX)
3595 else if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode))
3596 #else
3597- /* substitute define S_ISREG from os_unix.h */
3598+ /* WIN32 - substitute define S_ISREG from os_unix.h */
3599 else if (((statbuf.st_mode) & S_IFMT) == S_IFREG)
3600 #endif
3601 {
3602@@ -722,17 +712,32 @@
3603 cs_create_connection(i)
3604 int i;
3605 {
3606- int to_cs[2], from_cs[2], len;
3607- char *prog, *cmd, *ppath = NULL;
3608-#ifndef UNIX
3609- int in_save, out_save, err_save;
3610- long_i ph;
3611-# ifdef FEAT_GUI
3612- HWND activewnd = NULL;
3613- HWND consolewnd = NULL;
3614+#ifdef UNIX
3615+ int to_cs[2], from_cs[2];
3616+#endif
3617+ int len;
3618+ char *prog, *cmd, *ppath = NULL;
3619+#ifdef WIN32
3620+ int fd;
3621+ SECURITY_ATTRIBUTES sa;
3622+ PROCESS_INFORMATION pi;
3623+ STARTUPINFO si;
3624+ BOOL pipe_stdin = FALSE, pipe_stdout = FALSE;
3625+ HANDLE stdin_rd, stdout_rd;
3626+ HANDLE stdout_wr, stdin_wr;
3627+ BOOL created;
3628+# ifdef __BORLANDC__
3629+# define OPEN_OH_ARGTYPE long
3630+# else
3631+# if (_MSC_VER >= 1300)
3632+# define OPEN_OH_ARGTYPE intptr_t
3633+# else
3634+# define OPEN_OH_ARGTYPE long
3635+# endif
3636 # endif
3637 #endif
3638
3639+#if defined(UNIX)
3640 /*
3641 * Cscope reads from to_cs[0] and writes to from_cs[1]; vi reads from
3642 * from_cs[0] and writes to to_cs[1].
3643@@ -753,18 +758,12 @@
3644 return CSCOPE_FAILURE;
3645 }
3646
3647-#if defined(UNIX)
3648 switch (csinfo[i].pid = fork())
3649 {
3650 case -1:
3651 (void)EMSG(_("E622: Could not fork for cscope"));
3652 goto err_closing;
3653 case 0: /* child: run cscope. */
3654-#else
3655- in_save = dup(STDIN_FILENO);
3656- out_save = dup(STDOUT_FILENO);
3657- err_save = dup(STDERR_FILENO);
3658-#endif
3659 if (dup2(to_cs[0], STDIN_FILENO) == -1)
3660 PERROR("cs_create_connection 1");
3661 if (dup2(from_cs[1], STDOUT_FILENO) == -1)
3662@@ -773,15 +772,32 @@
3663 PERROR("cs_create_connection 3");
3664
3665 /* close unused */
3666-#if defined(UNIX)
3667 (void)close(to_cs[1]);
3668 (void)close(from_cs[0]);
3669 #else
3670- /* On win32 we must close opposite ends because we are the parent */
3671- (void)close(to_cs[0]);
3672- to_cs[0] = -1;
3673- (void)close(from_cs[1]);
3674- from_cs[1] = -1;
3675+ /* WIN32 */
3676+ /* Create pipes to communicate with cscope */
3677+ sa.nLength = sizeof(SECURITY_ATTRIBUTES);
3678+ sa.bInheritHandle = TRUE;
3679+ sa.lpSecurityDescriptor = NULL;
3680+
3681+ if (!(pipe_stdin = CreatePipe(&stdin_rd, &stdin_wr, &sa, 0))
3682+ || !(pipe_stdout = CreatePipe(&stdout_rd, &stdout_wr, &sa, 0)))
3683+ {
3684+ (void)EMSG(_("E566: Could not create cscope pipes"));
3685+err_closing:
3686+ if (pipe_stdin)
3687+ {
3688+ CloseHandle(stdin_rd);
3689+ CloseHandle(stdin_wr);
3690+ }
3691+ if (pipe_stdout)
3692+ {
3693+ CloseHandle(stdout_rd);
3694+ CloseHandle(stdout_wr);
3695+ }
3696+ return CSCOPE_FAILURE;
3697+ }
3698 #endif
3699 /* expand the cscope exec for env var's */
3700 if ((prog = (char *)alloc(MAXPATHL + 1)) == NULL)
3701@@ -789,6 +805,7 @@
3702 #ifdef UNIX
3703 return CSCOPE_FAILURE;
3704 #else
3705+ /* WIN32 */
3706 goto err_closing;
3707 #endif
3708 }
3709@@ -805,6 +822,7 @@
3710 #ifdef UNIX
3711 return CSCOPE_FAILURE;
3712 #else
3713+ /* WIN32 */
3714 goto err_closing;
3715 #endif
3716 }
3717@@ -823,6 +841,7 @@
3718 #ifdef UNIX
3719 return CSCOPE_FAILURE;
3720 #else
3721+ /* WIN32 */
3722 goto err_closing;
3723 #endif
3724 }
3725@@ -831,6 +850,7 @@
3726 #if defined(UNIX)
3727 (void)sprintf(cmd, "exec %s -dl -f %s", prog, csinfo[i].fname);
3728 #else
3729+ /* WIN32 */
3730 (void)sprintf(cmd, "%s -dl -f %s", prog, csinfo[i].fname);
3731 #endif
3732 if (csinfo[i].ppath != NULL)
3733@@ -856,60 +876,6 @@
3734 exit(127);
3735 /* NOTREACHED */
3736 default: /* parent. */
3737-#else
3738-# ifdef FEAT_GUI
3739- activewnd = GetForegroundWindow(); /* on win9x cscope steals focus */
3740- /* Dirty hack to hide annoying console window */
3741- if (AllocConsole())
3742- {
3743- char *title;
3744- title = (char *)alloc(1024);
3745- if (title == NULL)
3746- FreeConsole();
3747- else
3748- {
3749- GetConsoleTitle(title, 1024); /* save for future restore */
3750- SetConsoleTitle(
3751- "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
3752- Sleep(40); /* as stated in MS KB we must wait 40 ms */
3753- consolewnd = FindWindow(NULL,
3754- "GVIMCS{5499421B-CBEF-45b0-85EF-38167FDEA5C5}GVIMCS");
3755- if (consolewnd != NULL)
3756- ShowWindow(consolewnd, SW_HIDE);
3757- SetConsoleTitle(title);
3758- vim_free(title);
3759- }
3760- }
3761-# endif
3762- /* May be use &shell, &shellquote etc */
3763-# ifdef __BORLANDC__
3764- /* BCC 5.5 uses a different function name for spawnlp */
3765- ph = (long_i)spawnlp(P_NOWAIT, prog, cmd, NULL);
3766-# else
3767- ph = (long_i)_spawnlp(_P_NOWAIT, prog, cmd, NULL);
3768-# endif
3769- vim_free(prog);
3770- vim_free(cmd);
3771-# ifdef FEAT_GUI
3772- /* Dirty hack part two */
3773- if (activewnd != NULL)
3774- /* restoring focus */
3775- SetForegroundWindow(activewnd);
3776- if (consolewnd != NULL)
3777- FreeConsole();
3778-
3779-# endif
3780- if (ph == -1)
3781- {
3782- PERROR(_("cs_create_connection exec failed"));
3783- (void)EMSG(_("E623: Could not spawn cscope process"));
3784- goto err_closing;
3785- }
3786- /* else */
3787- csinfo[i].pid = 0;
3788- csinfo[i].hProc = (HANDLE)ph;
3789-
3790-#endif /* !UNIX */
3791 /*
3792 * Save the file descriptors for later duplication, and
3793 * reopen as streams.
3794@@ -919,22 +885,54 @@
3795 if ((csinfo[i].fr_fp = fdopen(from_cs[0], "r")) == NULL)
3796 PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
3797
3798-#if defined(UNIX)
3799 /* close unused */
3800 (void)close(to_cs[0]);
3801 (void)close(from_cs[1]);
3802
3803 break;
3804 }
3805+
3806 #else
3807- /* restore stdhandles */
3808- dup2(in_save, STDIN_FILENO);
3809- dup2(out_save, STDOUT_FILENO);
3810- dup2(err_save, STDERR_FILENO);
3811- close(in_save);
3812- close(out_save);
3813- close(err_save);
3814-#endif
3815+ /* WIN32 */
3816+ /* Create a new process to run cscope and use pipes to talk with it */
3817+ GetStartupInfo(&si);
3818+ si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
3819+ si.wShowWindow = SW_HIDE; /* Hide child application window */
3820+ si.hStdOutput = stdout_wr;
3821+ si.hStdError = stdout_wr;
3822+ si.hStdInput = stdin_rd;
3823+ created = CreateProcess(NULL, cmd, NULL, NULL, TRUE, CREATE_NEW_CONSOLE,
3824+ NULL, NULL, &si, &pi);
3825+ vim_free(prog);
3826+ vim_free(cmd);
3827+
3828+ if (!created)
3829+ {
3830+ PERROR(_("cs_create_connection exec failed"));
3831+ (void)EMSG(_("E623: Could not spawn cscope process"));
3832+ goto err_closing;
3833+ }
3834+ /* else */
3835+ csinfo[i].pid = pi.dwProcessId;
3836+ csinfo[i].hProc = pi.hProcess;
3837+ CloseHandle(pi.hThread);
3838+
3839+ /* TODO - tidy up after failure to create files on pipe handles. */
3840+ if (((fd = _open_osfhandle((OPEN_OH_ARGTYPE)stdin_wr,
3841+ _O_TEXT|_O_APPEND)) < 0)
3842+ || ((csinfo[i].to_fp = _fdopen(fd, "w")) == NULL))
3843+ PERROR(_("cs_create_connection: fdopen for to_fp failed"));
3844+ if (((fd = _open_osfhandle((OPEN_OH_ARGTYPE)stdout_rd,
3845+ _O_TEXT|_O_RDONLY)) < 0)
3846+ || ((csinfo[i].fr_fp = _fdopen(fd, "r")) == NULL))
3847+ PERROR(_("cs_create_connection: fdopen for fr_fp failed"));
3848+
3849+ /* Close handles for file descriptors inherited by the cscope process */
3850+ CloseHandle(stdin_rd);
3851+ CloseHandle(stdout_wr);
3852+
3853+#endif /* !UNIX */
3854+
3855 return CSCOPE_SUCCESS;
3856 } /* cs_create_connection */
3857
3858@@ -966,7 +964,7 @@
[ba61c16]3859 }
3860
3861 pat = opt + strlen(opt) + 1;
3862- if (pat == NULL || (pat != NULL && pat[0] == '\0'))
3863+ if (pat >= (char *)eap->arg + eap_arg_len)
3864 {
3865 cs_usage_msg(Find);
3866 return FALSE;
[c2aa910]3867@@ -1317,7 +1315,7 @@
[ba61c16]3868 #else
3869 /* compare pathnames first */
3870 && ((fullpathcmp(csinfo[j].fname, fname, FALSE) & FPC_SAME)
3871- /* if not Windows 9x, test index file atributes too */
3872+ /* if not Windows 9x, test index file attributes too */
3873 || (!mch_windows95()
3874 && csinfo[j].nVolume == bhfi.dwVolumeSerialNumber
3875 && csinfo[j].nIndexHigh == bhfi.nFileIndexHigh
[c2aa910]3876@@ -1401,6 +1399,9 @@
[ba61c16]3877 if (eap->arg == NULL)
3878 return NULL;
3879
3880+ /* Store length of eap->arg before it gets modified by strtok(). */
3881+ eap_arg_len = STRLEN(eap->arg);
3882+
3883 if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL)
3884 return NULL;
3885
[c2aa910]3886@@ -2099,8 +2100,8 @@
3887 /*
3888 * PRIVATE: cs_release_csp
3889 *
3890- * does the actual free'ing for the cs ptr with an optional flag of whether
3891- * or not to free the filename. called by cs_kill and cs_reset.
3892+ * Does the actual free'ing for the cs ptr with an optional flag of whether
3893+ * or not to free the filename. Called by cs_kill and cs_reset.
3894 */
3895 static void
3896 cs_release_csp(i, freefnpp)
3897@@ -2118,10 +2119,13 @@
3898 (void)fputs("q\n", csinfo[i].to_fp);
3899 (void)fflush(csinfo[i].to_fp);
3900 }
3901- /* give cscope chance to exit normally */
3902- if (csinfo[i].hProc != NULL
3903- && WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT)
3904- TerminateProcess(csinfo[i].hProc, 0);
3905+ if (csinfo[i].hProc != NULL)
3906+ {
3907+ /* Give cscope a chance to exit normally */
3908+ if (WaitForSingleObject(csinfo[i].hProc, 1000) == WAIT_TIMEOUT)
3909+ TerminateProcess(csinfo[i].hProc, 0);
3910+ CloseHandle(csinfo[i].hProc);
3911+ }
3912 #endif
3913
3914 if (csinfo[i].fr_fp != NULL)
3915@@ -2195,7 +2199,7 @@
[ba61c16]3916 cs_add_common(dblist[i], pplist[i], fllist[i]);
3917 if (p_csverbose)
3918 {
3919- /* dont' use smsg_attr because want to display
3920+ /* don't use smsg_attr() because we want to display the
3921 * connection number in the same line as
3922 * "Added cscope database..."
3923 */
[c2aa910]3924@@ -2304,6 +2308,21 @@
3925 return CSCOPE_SUCCESS;
3926 } /* cs_show */
3927
3928+
3929+/*
3930+ * PUBLIC: cs_end
3931+ *
3932+ * Only called when VIM exits to quit any cscope sessions.
3933+ */
3934+ void
3935+cs_end()
3936+{
3937+ int i;
3938+
3939+ for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
3940+ cs_release_csp(i, TRUE);
3941+}
3942+
3943 #endif /* FEAT_CSCOPE */
3944
3945 /* the end */
3946diff -Naur vim71.orig/src/if_cscope.h vim71/src/if_cscope.h
3947--- vim71.orig/src/if_cscope.h 2005-06-30 10:14:22.000000000 -0700
[2830f42]3948+++ vim71/src/if_cscope.h 2007-10-29 08:09:37.000000000 -0700
[c2aa910]3949@@ -72,7 +72,7 @@
3950 ino_t st_ino; /* inode number of cscope db */
3951 #else
3952 # if defined(WIN32)
3953- int pid; /* Can't get pid so set it to 0 ;) */
3954+ DWORD pid; /* PID of the connected cscope process. */
3955 HANDLE hProc; /* cscope process handle */
3956 DWORD nVolume; /* Volume serial number, instead of st_dev */
3957 DWORD nIndexHigh; /* st_ino has no meaning in the Windows */
[ba61c16]3958diff -Naur vim71.orig/src/if_mzsch.c vim71/src/if_mzsch.c
3959--- vim71.orig/src/if_mzsch.c 2007-05-12 04:13:47.000000000 -0700
[2830f42]3960+++ vim71/src/if_mzsch.c 2007-10-29 08:09:16.000000000 -0700
[ba61c16]3961@@ -308,6 +308,8 @@
3962 static Scheme_Config *(*dll_scheme_current_config)(void);
3963 static Scheme_Object *(*dll_scheme_char_string_to_byte_string)
3964 (Scheme_Object *s);
3965+static Scheme_Object *(*dll_scheme_char_string_to_path)
3966+ (Scheme_Object *s);
3967 # endif
3968
3969 /* arrays are imported directly */
3970@@ -398,6 +400,8 @@
3971 # define scheme_current_config dll_scheme_current_config
3972 # define scheme_char_string_to_byte_string \
3973 dll_scheme_char_string_to_byte_string
3974+# define scheme_char_string_to_path \
3975+ dll_scheme_char_string_to_path
3976 # endif
3977
3978 typedef struct
3979@@ -498,6 +502,8 @@
3980 {"scheme_current_config", (void **)&dll_scheme_current_config},
3981 {"scheme_char_string_to_byte_string",
3982 (void **)&dll_scheme_char_string_to_byte_string},
3983+ {"scheme_char_string_to_path",
3984+ (void **)&dll_scheme_char_string_to_path},
3985 # endif
3986 {NULL, NULL}};
3987
3988@@ -773,7 +779,14 @@
3989 #ifdef MZSCHEME_COLLECTS
3990 /* setup 'current-library-collection-paths' parameter */
3991 scheme_set_param(scheme_config, MZCONFIG_COLLECTION_PATHS,
3992- scheme_make_pair(scheme_make_string(MZSCHEME_COLLECTS),
3993+ scheme_make_pair(
3994+# if MZSCHEME_VERSION_MAJOR >= 299
3995+ scheme_char_string_to_path(
3996+ scheme_byte_string_to_char_string(
3997+ scheme_make_byte_string(MZSCHEME_COLLECTS))),
3998+# else
3999+ scheme_make_string(MZSCHEME_COLLECTS),
4000+# endif
4001 scheme_null));
4002 #endif
4003 #ifdef HAVE_SANDBOX
[c2aa910]4004diff -Naur vim71.orig/src/if_perl.xs vim71/src/if_perl.xs
4005--- vim71.orig/src/if_perl.xs 2006-08-16 05:45:15.000000000 -0700
[2830f42]4006+++ vim71/src/if_perl.xs 2007-10-29 08:09:51.000000000 -0700
[c2aa910]4007@@ -40,6 +40,28 @@
4008 # define PERL_SUBVERSION SUBVERSION
4009 #endif
4010
4011+/*
4012+ * Quoting Jan Dubois of Active State:
4013+ * ActivePerl build 822 still identifies itself as 5.8.8 but already
4014+ * contains many of the changes from the upcoming Perl 5.8.9 release.
4015+ *
4016+ * The changes include addition of two symbols (Perl_sv_2iv_flags,
4017+ * Perl_newXS_flags) not present in earlier releases.
4018+ *
4019+ * Jan Dubois suggested the following guarding scheme.
4020+ *
4021+ * Active State defined ACTIVEPERL_VERSION as a string in versions before
4022+ * 5.8.8; and so the comparison to 822 below needs to be guarded.
4023+ */
4024+#if (PERL_REVISION == 5) && (PERL_VERSION == 8) && (PERL_SUBVERSION >= 8)
4025+# if (ACTIVEPERL_VERSION >= 822) || (PERL_SUBVERSION >= 9)
4026+# define PERL589_OR_LATER
4027+# endif
4028+#endif
4029+#if (PERL_REVISION == 5) && (PERL_VERSION >= 9)
4030+# define PERL589_OR_LATER
4031+#endif
4032+
4033 #ifndef pTHX
4034 # define pTHX void
4035 # define pTHX_
4036@@ -109,6 +131,10 @@
4037 # else
4038 # define Perl_sv_catpvn dll_Perl_sv_catpvn
4039 # endif
4040+#ifdef PERL589_OR_LATER
4041+# define Perl_sv_2iv_flags dll_Perl_sv_2iv_flags
4042+# define Perl_newXS_flags dll_Perl_newXS_flags
4043+#endif
4044 # define Perl_sv_free dll_Perl_sv_free
4045 # define Perl_sv_isa dll_Perl_sv_isa
4046 # define Perl_sv_magic dll_Perl_sv_magic
4047@@ -192,6 +218,10 @@
4048 #else
4049 static void (*Perl_sv_catpvn)(pTHX_ SV*, const char*, STRLEN);
4050 #endif
4051+#ifdef PERL589_OR_LATER
4052+static IV (*Perl_sv_2iv_flags)(pTHX_ SV* sv, I32 flags);
4053+static CV * (*Perl_newXS_flags)(pTHX_ const char *name, XSUBADDR_t subaddr, const char *const filename, const char *const proto, U32 flags);
4054+#endif
4055 static void (*Perl_sv_free)(pTHX_ SV*);
4056 static int (*Perl_sv_isa)(pTHX_ SV*, const char*);
4057 static void (*Perl_sv_magic)(pTHX_ SV*, SV*, int, const char*, I32);
4058@@ -267,6 +297,10 @@
4059 #else
4060 {"Perl_sv_2pv", (PERL_PROC*)&Perl_sv_2pv},
4061 #endif
4062+#ifdef PERL589_OR_LATER
4063+ {"Perl_sv_2iv_flags", (PERL_PROC*)&Perl_sv_2iv_flags},
4064+ {"Perl_newXS_flags", (PERL_PROC*)&Perl_newXS_flags},
4065+#endif
4066 {"Perl_sv_bless", (PERL_PROC*)&Perl_sv_bless},
4067 #if (PERL_REVISION == 5) && (PERL_VERSION >= 8)
4068 {"Perl_sv_catpvn_flags", (PERL_PROC*)&Perl_sv_catpvn_flags},
4069@@ -411,13 +445,13 @@
4070 char *next;
4071 char *token = (char *)s;
4072
4073- while ((next = strchr(token, '\n')))
4074+ while ((next = strchr(token, '\n')) && !got_int)
4075 {
4076 *next++ = '\0'; /* replace \n with \0 */
4077 msg_attr((char_u *)token, attr);
4078 token = next;
4079 }
4080- if (*token)
4081+ if (*token && !got_int)
4082 msg_attr((char_u *)token, attr);
4083 }
4084
4085diff -Naur vim71.orig/src/if_ruby.c vim71/src/if_ruby.c
4086--- vim71.orig/src/if_ruby.c 2007-05-12 02:54:12.000000000 -0700
[2830f42]4087+++ vim71/src/if_ruby.c 2007-10-29 08:09:37.000000000 -0700
[c2aa910]4088@@ -789,7 +789,7 @@
4089 return get_buffer_line(curbuf, curwin->w_cursor.lnum);
4090 }
4091
4092-static VALUE set_current_line(VALUE str)
4093+static VALUE set_current_line(VALUE self, VALUE str)
4094 {
4095 return set_buffer_line(curbuf, curwin->w_cursor.lnum, str);
4096 }
4097diff -Naur vim71.orig/src/keymap.h vim71/src/keymap.h
4098--- vim71.orig/src/keymap.h 2006-08-22 04:38:38.000000000 -0700
[2830f42]4099+++ vim71/src/keymap.h 2007-10-29 08:09:37.000000000 -0700
[c2aa910]4100@@ -254,6 +254,8 @@
4101 , KE_DROP /* DnD data is available */
4102 , KE_CURSORHOLD /* CursorHold event */
4103 , KE_NOP /* doesn't do something */
4104+ , KE_FOCUSGAINED /* focus gained */
4105+ , KE_FOCUSLOST /* focus lost */
4106 };
4107
4108 /*
4109@@ -445,6 +447,8 @@
4110 #define K_CMDWIN TERMCAP2KEY(KS_EXTRA, KE_CMDWIN)
4111
4112 #define K_DROP TERMCAP2KEY(KS_EXTRA, KE_DROP)
4113+#define K_FOCUSGAINED TERMCAP2KEY(KS_EXTRA, KE_FOCUSGAINED)
4114+#define K_FOCUSLOST TERMCAP2KEY(KS_EXTRA, KE_FOCUSLOST)
4115
4116 #define K_CURSORHOLD TERMCAP2KEY(KS_EXTRA, KE_CURSORHOLD)
4117
[ba61c16]4118diff -Naur vim71.orig/src/macros.h vim71/src/macros.h
4119--- vim71.orig/src/macros.h 2007-05-07 12:38:22.000000000 -0700
[2830f42]4120+++ vim71/src/macros.h 2007-10-29 08:09:28.000000000 -0700
[ba61c16]4121@@ -54,10 +54,12 @@
4122
4123 /*
4124 * toupper() and tolower() that use the current locale.
4125- * On some systems toupper()/tolower() only work on lower/uppercase characters
4126+ * On some systems toupper()/tolower() only work on lower/uppercase
4127+ * characters, first use islower() or isupper() then.
4128 * Careful: Only call TOUPPER_LOC() and TOLOWER_LOC() with a character in the
4129 * range 0 - 255. toupper()/tolower() on some systems can't handle others.
4130- * Note: for UTF-8 use utf_toupper() and utf_tolower().
4131+ * Note: It is often better to use MB_TOLOWER() and MB_TOUPPER(), because many
4132+ * toupper() and tolower() implementations only work for ASCII.
4133 */
4134 #ifdef MSWIN
4135 # define TOUPPER_LOC(c) toupper_tab[(c) & 255]
[c2aa910]4136diff -Naur vim71.orig/src/main.aap vim71/src/main.aap
4137--- vim71.orig/src/main.aap 2007-05-07 12:46:43.000000000 -0700
[2830f42]4138+++ vim71/src/main.aap 2007-10-29 08:09:38.000000000 -0700
[c2aa910]4139@@ -56,9 +56,16 @@
4140 config {virtual} auto/config.h auto/config.aap :
4141 auto/configure.aap configure.aap
4142 config.arg config.h.in config.aap.in
4143+ # Use "uname -a" to detect the architecture of the system.
4144+ @ok, uname = redir_system('uname -a', 0)
4145+ @if string.find(uname, "i386") >= 0:
4146+ @ arch = "i386"
4147+ @else:
4148+ @ arch = "ppc"
4149+ :print Building for $arch system
4150 :sys CONFIG_STATUS=auto/config.status
4151 ./configure.aap `file2string("config.arg")`
4152- --with-mac-arch=ppc
4153+ --with-mac-arch=$arch
4154 --cache-file=auto/config.cache
4155
4156 # Configure arguments: create an empty "config.arg" file when its missing
4157@@ -1167,7 +1174,7 @@
4158 :symlink `os.getcwd()`/../runtime $RESDIR/vim/runtime
4159 # TODO: Create the vimtutor application.
4160
4161-gui_bundle {virtual}: $(RESDIR) bundle-dir bundle-executable bundle-info
4162+gui_bundle {virtual}: $(RESDIR) bundle-dir bundle-executable bundle-info \
4163 bundle-resource bundle-language
4164
4165 bundle-dir {virtual}: $(APPDIR)/Contents $(VIMTARGET)
4166@@ -1187,7 +1194,7 @@
4167 :sys m4 $(M4FLAGSX) infplist.xml > $(APPDIR)/Contents/Info.plist
4168
4169 bundle-resource {virtual}: bundle-dir bundle-rsrc
4170- :copy {force} $(RSRC_DIR)/*.icns $(RESDIR)
4171+ :copy {force} $(RSRC_DIR)/*.icns $(RESDIR)
4172
4173 ### Classic resources
4174 # Resource fork (in the form of a .rsrc file) for Classic Vim (Mac OS 9)
[ba61c16]4175diff -Naur vim71.orig/src/main.c vim71/src/main.c
4176--- vim71.orig/src/main.c 2007-05-07 12:38:44.000000000 -0700
[2830f42]4177+++ vim71/src/main.c 2007-10-29 08:09:38.000000000 -0700
[ba61c16]4178@@ -954,7 +954,8 @@
4179 int cmdwin; /* TRUE when working in the command-line window */
4180 int noexmode; /* TRUE when return on entering Ex mode */
4181 {
4182- oparg_T oa; /* operator arguments */
4183+ oparg_T oa; /* operator arguments */
4184+ int previous_got_int = FALSE; /* "got_int" was TRUE */
4185
4186 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
4187 /* Setup to catch a terminating error from the X server. Just ignore
4188@@ -1015,12 +1016,32 @@
4189 need_fileinfo = FALSE;
4190 }
4191 }
4192- if (got_int && !global_busy)
4193+
4194+ /* Reset "got_int" now that we got back to the main loop. Except when
4195+ * inside a ":g/pat/cmd" command, then the "got_int" needs to abort
4196+ * the ":g" command.
4197+ * For ":g/pat/vi" we reset "got_int" when used once. When used
4198+ * a second time we go back to Ex mode and abort the ":g" command. */
4199+ if (got_int)
4200 {
4201- if (!quit_more)
4202- (void)vgetc(); /* flush all buffers */
4203- got_int = FALSE;
4204+ if (noexmode && global_busy && !exmode_active && previous_got_int)
4205+ {
4206+ /* Typed two CTRL-C in a row: go back to ex mode as if "Q" was
4207+ * used and keep "got_int" set, so that it aborts ":g". */
4208+ exmode_active = EXMODE_NORMAL;
4209+ State = NORMAL;
4210+ }
4211+ else if (!global_busy || !exmode_active)
4212+ {
4213+ if (!quit_more)
4214+ (void)vgetc(); /* flush all buffers */
4215+ got_int = FALSE;
4216+ }
4217+ previous_got_int = TRUE;
4218 }
4219+ else
4220+ previous_got_int = FALSE;
4221+
4222 if (!exmode_active)
4223 msg_scroll = FALSE;
4224 quit_more = FALSE;
[c2aa910]4225@@ -1309,6 +1330,13 @@
4226 #ifdef FEAT_NETBEANS_INTG
4227 netbeans_end();
4228 #endif
4229+#ifdef FEAT_CSCOPE
4230+ cs_end();
4231+#endif
4232+#ifdef FEAT_EVAL
4233+ if (garbage_collect_at_exit)
4234+ garbage_collect();
4235+#endif
4236
4237 mch_exit(exitval);
4238 }
4239@@ -1360,8 +1388,7 @@
[ba61c16]4240 p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
4241 if (p != NULL && *p != NUL)
4242 {
4243- STRCPY(NameBuff, p);
4244- STRCAT(NameBuff, "/lang");
4245+ vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p);
4246 bindtextdomain(VIMPACKAGE, (char *)NameBuff);
4247 }
4248 if (mustfree)
[c2aa910]4249@@ -3632,7 +3659,13 @@
4250 mainerr_arg_missing((char_u *)filev[-1]);
4251 if (mch_dirname(cwd, MAXPATHL) != OK)
4252 return NULL;
4253- if ((p = vim_strsave_escaped_ext(cwd, PATH_ESC_CHARS, '\\', TRUE)) == NULL)
4254+ if ((p = vim_strsave_escaped_ext(cwd,
4255+#ifdef BACKSLASH_IN_FILENAME
4256+ "", /* rem_backslash() will tell what chars to escape */
4257+#else
4258+ PATH_ESC_CHARS,
4259+#endif
4260+ '\\', TRUE)) == NULL)
4261 return NULL;
4262 ga_init2(&ga, 1, 100);
4263 ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd ");
[ba61c16]4264diff -Naur vim71.orig/src/mbyte.c vim71/src/mbyte.c
4265--- vim71.orig/src/mbyte.c 2007-05-07 12:47:09.000000000 -0700
[2830f42]4266+++ vim71/src/mbyte.c 2007-10-29 08:09:37.000000000 -0700
[ba61c16]4267@@ -1310,20 +1310,26 @@
4268 /*
4269 * mb_off2cells() function pointer.
4270 * Return number of display cells for char at ScreenLines[off].
4271- * Caller must make sure "off" and "off + 1" are valid!
4272+ * We make sure that the offset used is less than "max_off".
4273 */
4274 /*ARGSUSED*/
4275 int
4276-latin_off2cells(off)
4277+latin_off2cells(off, max_off)
4278 unsigned off;
4279+ unsigned max_off;
4280 {
4281 return 1;
4282 }
4283
4284 int
4285-dbcs_off2cells(off)
4286+dbcs_off2cells(off, max_off)
4287 unsigned off;
4288+ unsigned max_off;
4289 {
4290+ /* never check beyond end of the line */
4291+ if (off >= max_off)
4292+ return 1;
4293+
4294 /* Number of cells is equal to number of bytes, except for euc-jp when
4295 * the first byte is 0x8e. */
4296 if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
4297@@ -1332,10 +1338,11 @@
4298 }
4299
4300 int
4301-utf_off2cells(off)
4302+utf_off2cells(off, max_off)
4303 unsigned off;
4304+ unsigned max_off;
4305 {
4306- return ScreenLines[off + 1] == 0 ? 2 : 1;
4307+ return (off + 1 < max_off && ScreenLines[off + 1] == 0) ? 2 : 1;
4308 }
4309
4310 /*
4311@@ -2320,7 +2327,7 @@
4312 /* Single byte: first check normally, then with ignore case. */
4313 if (s1[i] != s2[i])
4314 {
4315- cdiff = TOLOWER_LOC(s1[i]) - TOLOWER_LOC(s2[i]);
4316+ cdiff = MB_TOLOWER(s1[i]) - MB_TOLOWER(s2[i]);
4317 if (cdiff != 0)
4318 return cdiff;
4319 }
4320@@ -2899,12 +2906,8 @@
4321 if (composing_hangul)
4322 return TRUE;
4323 #endif
4324- if (enc_dbcs != 0)
4325- return dbcs_off2cells(LineOffset[row] + col) > 1;
4326- if (enc_utf8)
4327- return (col + 1 < Columns
4328- && ScreenLines[LineOffset[row] + col + 1] == 0);
4329- return FALSE;
4330+ return (*mb_off2cells)(LineOffset[row] + col,
4331+ LineOffset[row] + screen_Columns) > 1;
4332 }
4333
4334 # if defined(FEAT_CLIPBOARD) || defined(FEAT_GUI) || defined(FEAT_RIGHTLEFT) \
4335diff -Naur vim71.orig/src/message.c vim71/src/message.c
4336--- vim71.orig/src/message.c 2007-05-07 12:31:59.000000000 -0700
[2830f42]4337+++ vim71/src/message.c 2007-10-29 08:09:37.000000000 -0700
[c2aa910]4338@@ -828,7 +828,7 @@
4339 _("Messages maintainer: Bram Moolenaar <Bram@vim.org>"),
4340 hl_attr(HLF_T));
4341
4342- for (p = first_msg_hist; p != NULL; p = p->next)
4343+ for (p = first_msg_hist; p != NULL && !got_int; p = p->next)
4344 if (p->msg != NULL)
4345 msg_attr(p->msg, p->attr);
4346
4347@@ -944,6 +944,7 @@
4348 c = K_IGNORE;
4349 }
4350 #endif
4351+
4352 /*
4353 * Allow scrolling back in the messages.
4354 * Also accept scroll-down commands when messages fill the screen,
4355@@ -1840,9 +1841,10 @@
4356 char_u *sb_str = str;
4357 int sb_col = msg_col;
[ba61c16]4358 int wrap;
[c2aa910]4359+ int did_last_char;
[ba61c16]4360
4361 did_wait_return = FALSE;
4362- while (*s != NUL && (maxlen < 0 || (int)(s - str) < maxlen))
4363+ while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL)
4364 {
4365 /*
4366 * We are at the end of the screen line when:
[c2aa910]4367@@ -1878,7 +1880,7 @@
[ba61c16]4368 /* output postponed text */
4369 t_puts(&t_col, t_s, s, attr);
4370
4371- /* When no more prompt an no more room, truncate here */
4372+ /* When no more prompt and no more room, truncate here */
4373 if (msg_no_more && lines_left == 0)
4374 break;
4375
[c2aa910]4376@@ -1909,7 +1911,10 @@
4377 else
4378 #endif
4379 msg_screen_putchar(*s++, attr);
4380+ did_last_char = TRUE;
4381 }
4382+ else
4383+ did_last_char = FALSE;
4384
4385 if (p_more)
4386 /* store text for scrolling back */
4387@@ -1927,7 +1932,8 @@
[ba61c16]4388 * If screen is completely filled and 'more' is set then wait
4389 * for a character.
4390 */
4391- --lines_left;
4392+ if (lines_left > 0)
4393+ --lines_left;
4394 if (p_more && lines_left == 0 && State != HITRETURN
4395 && !msg_no_more && !exmode_active)
4396 {
[c2aa910]4397@@ -1943,11 +1949,7 @@
4398
4399 /* When we displayed a char in last column need to check if there
4400 * is still more. */
4401- if (*s >= ' '
4402-#ifdef FEAT_RIGHTLEFT
4403- && !cmdmsg_rl
4404-#endif
4405- )
4406+ if (did_last_char)
4407 continue;
4408 }
4409
4410@@ -2234,7 +2236,7 @@
[ba61c16]4411 {
4412 msgchunk_T *mp;
4413
4414- /* Only show somethign if there is more than one line, otherwise it looks
4415+ /* Only show something if there is more than one line, otherwise it looks
4416 * weird, typing a command without output results in one line. */
4417 mp = msg_sb_start(last_msgchunk);
4418 if (mp == NULL || mp->sb_prev == NULL)
[c2aa910]4419@@ -2622,7 +2624,7 @@
[ba61c16]4420 }
4421 }
4422
4423- if (scroll < 0 || (scroll == 0 && mp_last != NULL))
4424+ if (scroll <= 0)
4425 {
4426 /* displayed the requested text, more prompt again */
4427 screen_fill((int)Rows - 1, (int)Rows, 0,
[c2aa910]4428@@ -3456,11 +3458,11 @@
[ba61c16]4429 /* advance to next hotkey and set default hotkey */
4430 #ifdef FEAT_MBYTE
4431 if (has_mbyte)
4432- hotkp += (*mb_ptr2len)(hotkp);
4433+ hotkp += STRLEN(hotkp);
4434 else
4435 #endif
4436 ++hotkp;
4437- (void)copy_char(r + 1, hotkp, TRUE);
4438+ hotkp[copy_char(r + 1, hotkp, TRUE)] = NUL;
4439 if (dfltbutton)
4440 --dfltbutton;
4441
[c2aa910]4442@@ -3493,7 +3495,7 @@
[ba61c16]4443 *msgp++ = (dfltbutton == 1) ? ']' : ')';
4444
4445 /* redefine hotkey */
4446- (void)copy_char(r, hotkp, TRUE);
4447+ hotkp[copy_char(r, hotkp, TRUE)] = NUL;
4448 }
4449 }
4450 else
[c2aa910]4451@@ -3519,8 +3521,6 @@
[ba61c16]4452 *msgp++ = ':';
4453 *msgp++ = ' ';
4454 *msgp = NUL;
4455- mb_ptr_adv(hotkp);
4456- *hotkp = NUL;
4457 }
4458 else
4459 {
[c2aa910]4460@@ -3555,8 +3555,9 @@
[ba61c16]4461 msgp = confirm_msg + 1 + STRLEN(message);
4462 hotkp = hotk;
4463
4464- /* define first default hotkey */
4465- (void)copy_char(buttons, hotkp, TRUE);
4466+ /* Define first default hotkey. Keep the hotkey string NUL
4467+ * terminated to avoid reading past the end. */
4468+ hotkp[copy_char(buttons, hotkp, TRUE)] = NUL;
4469
4470 /* Remember where the choices start, displaying starts here when
4471 * "hotkp" typed at the more prompt. */
4472diff -Naur vim71.orig/src/misc1.c vim71/src/misc1.c
4473--- vim71.orig/src/misc1.c 2007-05-07 12:49:03.000000000 -0700
[2830f42]4474+++ vim71/src/misc1.c 2007-10-29 08:09:38.000000000 -0700
[ba61c16]4475@@ -90,7 +90,7 @@
4476 */
4477 int
4478 set_indent(size, flags)
4479- int size;
4480+ int size; /* measured in spaces */
4481 int flags;
4482 {
4483 char_u *p;
4484@@ -98,12 +98,14 @@
4485 char_u *oldline;
4486 char_u *s;
4487 int todo;
4488- int ind_len;
4489+ int ind_len; /* measured in characters */
4490 int line_len;
4491 int doit = FALSE;
4492- int ind_done;
4493+ int ind_done = 0; /* measured in spaces */
4494 int tab_pad;
4495 int retval = FALSE;
4496+ int orig_char_len = -1; /* number of initial whitespace chars when
4497+ 'et' and 'pi' are both set */
4498
4499 /*
4500 * First check if there is anything to do and compute the number of
4501@@ -116,8 +118,10 @@
4502 /* Calculate the buffer size for the new indent, and check to see if it
4503 * isn't already set */
4504
4505- /* if 'expandtab' isn't set: use TABs */
4506- if (!curbuf->b_p_et)
4507+ /* if 'expandtab' isn't set: use TABs; if both 'expandtab' and
4508+ * 'preserveindent' are set count the number of characters at the
4509+ * beginning of the line to be copied */
4510+ if (!curbuf->b_p_et || (!(flags & SIN_INSERT) && curbuf->b_p_pi))
4511 {
4512 /* If 'preserveindent' is set then reuse as much as possible of
4513 * the existing indent structure for the new indent */
4514@@ -148,9 +152,14 @@
4515 ++p;
4516 }
4517
4518+ /* Set initial number of whitespace chars to copy if we are
4519+ * preserving indent but expandtab is set */
4520+ if (curbuf->b_p_et)
4521+ orig_char_len = ind_len;
4522+
4523 /* Fill to next tabstop with a tab, if possible */
4524 tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts);
4525- if (todo >= tab_pad)
4526+ if (todo >= tab_pad && orig_char_len == -1)
4527 {
4528 doit = TRUE;
4529 todo -= tab_pad;
4530@@ -193,13 +202,42 @@
4531 else
4532 p = skipwhite(p);
4533 line_len = (int)STRLEN(p) + 1;
4534- newline = alloc(ind_len + line_len);
4535- if (newline == NULL)
4536- return FALSE;
4537+
4538+ /* If 'preserveindent' and 'expandtab' are both set keep the original
4539+ * characters and allocate accordingly. We will fill the rest with spaces
4540+ * after the if (!curbuf->b_p_et) below. */
4541+ if (orig_char_len != -1)
4542+ {
4543+ newline = alloc(orig_char_len + size - ind_done + line_len);
4544+ if (newline == NULL)
4545+ return FALSE;
4546+ todo = size - ind_done;
4547+ ind_len = orig_char_len + todo; /* Set total length of indent in
4548+ * characters, which may have been
4549+ * undercounted until now */
4550+ p = oldline;
4551+ s = newline;
4552+ while (orig_char_len > 0)
4553+ {
4554+ *s++ = *p++;
4555+ orig_char_len--;
4556+ }
4557+ /* Skip over any additional white space (useful when newindent is less
4558+ * than old) */
4559+ while (vim_iswhite(*p))
4560+ (void)*p++;
4561+
4562+ }
4563+ else
4564+ {
4565+ todo = size;
4566+ newline = alloc(ind_len + line_len);
4567+ if (newline == NULL)
4568+ return FALSE;
4569+ s = newline;
4570+ }
4571
4572 /* Put the characters in the new line. */
4573- s = newline;
4574- todo = size;
4575 /* if 'expandtab' isn't set: use TABs */
4576 if (!curbuf->b_p_et)
4577 {
4578@@ -1320,8 +1358,8 @@
4579 newindent += (int)curbuf->b_p_sw;
4580 }
4581 #endif
4582- /* Copy the indent only if expand tab is disabled */
4583- if (curbuf->b_p_ci && !curbuf->b_p_et)
4584+ /* Copy the indent */
4585+ if (curbuf->b_p_ci)
4586 {
4587 (void)copy_indent(newindent, saved_line);
4588
[c2aa910]4589@@ -3468,9 +3506,38 @@
4590 #endif
4591
4592 /*
4593+ * Call expand_env() and store the result in an allocated string.
4594+ * This is not very memory efficient, this expects the result to be freed
4595+ * again soon.
4596+ */
4597+ char_u *
4598+expand_env_save(src)
4599+ char_u *src;
4600+{
4601+ return expand_env_save_opt(src, FALSE);
4602+}
4603+
4604+/*
4605+ * Idem, but when "one" is TRUE handle the string as one file name, only
4606+ * expand "~" at the start.
4607+ */
4608+ char_u *
4609+expand_env_save_opt(src, one)
4610+ char_u *src;
4611+ int one;
4612+{
4613+ char_u *p;
4614+
4615+ p = alloc(MAXPATHL);
4616+ if (p != NULL)
4617+ expand_env_esc(src, p, MAXPATHL, FALSE, one, NULL);
4618+ return p;
4619+}
4620+
4621+/*
4622 * Expand environment variable with path name.
4623 * "~/" is also expanded, using $HOME. For Unix "~user/" is expanded.
4624- * Skips over "\ ", "\~" and "\$".
4625+ * Skips over "\ ", "\~" and "\$" (not for Win32 though).
4626 * If anything fails no expansion is done and dst equals src.
4627 */
4628 void
4629@@ -3479,15 +3546,16 @@
4630 char_u *dst; /* where to put the result */
4631 int dstlen; /* maximum length of the result */
4632 {
4633- expand_env_esc(src, dst, dstlen, FALSE, NULL);
4634+ expand_env_esc(src, dst, dstlen, FALSE, FALSE, NULL);
4635 }
4636
4637 void
4638-expand_env_esc(srcp, dst, dstlen, esc, startstr)
4639+expand_env_esc(srcp, dst, dstlen, esc, one, startstr)
4640 char_u *srcp; /* input string e.g. "$HOME/vim.hlp" */
4641 char_u *dst; /* where to put the result */
4642 int dstlen; /* maximum length of the result */
4643 int esc; /* escape spaces in expanded variables */
4644+ int one; /* "srcp" is one file name */
4645 char_u *startstr; /* start again after this (can be NULL) */
4646 {
4647 char_u *src;
4648@@ -3728,6 +3796,8 @@
4649 {
4650 /*
4651 * Recognize the start of a new name, for '~'.
4652+ * Don't do this when "one" is TRUE, to avoid expanding "~" in
4653+ * ":edit foo ~ foo".
4654 */
4655 at_start = FALSE;
4656 if (src[0] == '\\' && src[1] != NUL)
4657@@ -3735,7 +3805,7 @@
4658 *dst++ = *src++;
4659 --dstlen;
4660 }
4661- else if (src[0] == ' ' || src[0] == ',')
4662+ else if ((src[0] == ' ' || src[0] == ',') && !one)
4663 at_start = TRUE;
4664 *dst++ = *src++;
4665 --dstlen;
4666@@ -4032,23 +4102,6 @@
4667 }
4668
4669 /*
4670- * Call expand_env() and store the result in an allocated string.
4671- * This is not very memory efficient, this expects the result to be freed
4672- * again soon.
4673- */
4674- char_u *
4675-expand_env_save(src)
4676- char_u *src;
4677-{
4678- char_u *p;
4679-
4680- p = alloc(MAXPATHL);
4681- if (p != NULL)
4682- expand_env(src, p, MAXPATHL);
4683- return p;
4684-}
4685-
4686-/*
4687 * Our portable version of setenv.
4688 */
4689 void
4690@@ -4786,7 +4839,7 @@
[ba61c16]4691 static int cin_iswhileofdo __ARGS((char_u *, linenr_T, int));
4692 static int cin_iswhileofdo_end __ARGS((int terminated, int ind_maxparen, int ind_maxcomment));
4693 static int cin_isbreak __ARGS((char_u *));
4694-static int cin_is_cpp_baseclass __ARGS((char_u *line, colnr_T *col));
4695+static int cin_is_cpp_baseclass __ARGS((colnr_T *col));
4696 static int get_baseclass_amount __ARGS((int col, int ind_maxparen, int ind_maxcomment, int ind_cpp_baseclass));
4697 static int cin_ends_in __ARGS((char_u *, char_u *, char_u *));
4698 static int cin_skip2pos __ARGS((pos_T *trypos));
[c2aa910]4699@@ -5551,13 +5604,13 @@
[ba61c16]4700 * This is a lot of guessing. Watch out for "cond ? func() : foo".
4701 */
4702 static int
4703-cin_is_cpp_baseclass(line, col)
4704- char_u *line;
4705+cin_is_cpp_baseclass(col)
4706 colnr_T *col; /* return: column to align with */
4707 {
4708 char_u *s;
4709 int class_or_struct, lookfor_ctor_init, cpp_base_class;
4710 linenr_T lnum = curwin->w_cursor.lnum;
4711+ char_u *line = ml_get_curline();
4712
4713 *col = 0;
4714
[c2aa910]4715@@ -5585,7 +5638,8 @@
[ba61c16]4716 */
4717 while (lnum > 1)
4718 {
4719- s = skipwhite(ml_get(lnum - 1));
4720+ line = ml_get(lnum - 1);
4721+ s = skipwhite(line);
4722 if (*s == '#' || *s == NUL)
4723 break;
4724 while (*s != NUL)
[c2aa910]4725@@ -5602,7 +5656,8 @@
[ba61c16]4726 --lnum;
4727 }
4728
4729- s = cin_skipcomment(ml_get(lnum));
4730+ line = ml_get(lnum);
4731+ s = cin_skipcomment(line);
4732 for (;;)
4733 {
4734 if (*s == NUL)
[c2aa910]4735@@ -5610,7 +5665,10 @@
[ba61c16]4736 if (lnum == curwin->w_cursor.lnum)
4737 break;
4738 /* Continue in the cursor line. */
4739- s = cin_skipcomment(ml_get(++lnum));
4740+ line = ml_get(++lnum);
4741+ s = cin_skipcomment(line);
4742+ if (*s == NUL)
4743+ continue;
4744 }
4745
4746 if (s[0] == ':')
[c2aa910]4747@@ -7079,7 +7137,7 @@
[ba61c16]4748 n = FALSE;
4749 if (lookfor != LOOKFOR_TERM && ind_cpp_baseclass > 0)
4750 {
4751- n = cin_is_cpp_baseclass(l, &col);
4752+ n = cin_is_cpp_baseclass(&col);
4753 l = ml_get_curline();
4754 }
4755 if (n)
[c2aa910]4756@@ -7670,7 +7728,7 @@
[ba61c16]4757 n = FALSE;
4758 if (ind_cpp_baseclass != 0 && theline[0] != '{')
4759 {
4760- n = cin_is_cpp_baseclass(l, &col);
4761+ n = cin_is_cpp_baseclass(&col);
4762 l = ml_get_curline();
4763 }
4764 if (n)
[c2aa910]4765@@ -8596,7 +8654,7 @@
[ba61c16]4766 for (p = buf + wildoff; p < s; ++p)
4767 if (rem_backslash(p))
4768 {
4769- STRCPY(p, p + 1);
4770+ mch_memmove(p, p + 1, STRLEN(p));
4771 --e;
4772 --s;
4773 }
[c2aa910]4774@@ -8897,7 +8955,7 @@
[ba61c16]4775 for (p = buf + wildoff; p < s; ++p)
4776 if (rem_backslash(p))
4777 {
4778- STRCPY(p, p + 1);
4779+ mch_memmove(p, p + 1, STRLEN(p));
4780 --e;
4781 --s;
4782 }
[c2aa910]4783@@ -9096,7 +9154,7 @@
4784 */
4785 if (vim_strpbrk(p, (char_u *)"$~") != NULL)
4786 {
4787- p = expand_env_save(p);
4788+ p = expand_env_save_opt(p, TRUE);
4789 if (p == NULL)
4790 p = pat[i];
4791 #ifdef UNIX
4792diff -Naur vim71.orig/src/misc2.c vim71/src/misc2.c
4793--- vim71.orig/src/misc2.c 2007-05-07 12:49:26.000000000 -0700
[2830f42]4794+++ vim71/src/misc2.c 2007-10-29 08:09:51.000000000 -0700
[c2aa910]4795@@ -972,7 +972,7 @@
4796 return;
4797 entered = TRUE;
4798
4799- ++autocmd_block; /* don't want to trigger autocommands here */
4800+ block_autocmds(); /* don't want to trigger autocommands here */
4801
4802 #ifdef FEAT_WINDOWS
4803 /* close all tabs and windows */
4804@@ -1037,7 +1037,9 @@
4805
4806 /* Free some global vars. */
4807 vim_free(username);
4808+# ifdef FEAT_CLIPBOARD
4809 vim_free(clip_exclude_prog);
4810+# endif
4811 vim_free(last_cmdline);
4812 vim_free(new_last_cmdline);
4813 set_keep_msg(NULL, 0);
[ba61c16]4814diff -Naur vim71.orig/src/normal.c vim71/src/normal.c
4815--- vim71.orig/src/normal.c 2007-05-07 12:34:39.000000000 -0700
[2830f42]4816+++ vim71/src/normal.c 2007-10-29 08:09:51.000000000 -0700
[c2aa910]4817@@ -690,13 +690,20 @@
4818 ca.count0 = ca.count0 * 10 + (c - '0');
4819 if (ca.count0 < 0) /* got too large! */
4820 ca.count0 = 999999999L;
4821+#ifdef FEAT_EVAL
4822+ /* Set v:count here, when called from main() and not a stuffed
4823+ * command, so that v:count can be used in an expression mapping
4824+ * right after the count. */
4825+ if (toplevel && stuff_empty())
4826+ set_vcount(ca.count0, ca.count0 == 0 ? 1 : ca.count0);
4827+#endif
4828 if (ctrl_w)
4829 {
4830 ++no_mapping;
4831 ++allow_keys; /* no mapping for nchar, but keys */
4832 }
4833 ++no_zero_mapping; /* don't map zero here */
4834- c = safe_vgetc();
4835+ c = plain_vgetc();
4836 #ifdef FEAT_LANGMAP
4837 LANGMAP_ADJUST(c, TRUE);
4838 #endif
4839@@ -721,7 +728,7 @@
4840 ca.count0 = 0;
4841 ++no_mapping;
4842 ++allow_keys; /* no mapping for nchar, but keys */
4843- c = safe_vgetc(); /* get next character */
4844+ c = plain_vgetc(); /* get next character */
4845 #ifdef FEAT_LANGMAP
4846 LANGMAP_ADJUST(c, TRUE);
4847 #endif
4848@@ -889,13 +896,18 @@
[ba61c16]4849
4850 ++no_mapping;
4851 ++allow_keys; /* no mapping for nchar, but allow key codes */
4852+#ifdef FEAT_AUTOCMD
4853+ /* Don't generate a CursorHold event here, most commands can't handle
4854+ * it, e.g., nv_replace(), nv_csearch(). */
4855+ did_cursorhold = TRUE;
4856+#endif
4857 if (ca.cmdchar == 'g')
4858 {
4859 /*
[c2aa910]4860 * For 'g' get the next character now, so that we can check for
4861 * "gr", "g'" and "g`".
4862 */
4863- ca.nchar = safe_vgetc();
4864+ ca.nchar = plain_vgetc();
4865 #ifdef FEAT_LANGMAP
4866 LANGMAP_ADJUST(ca.nchar, TRUE);
4867 #endif
4868@@ -952,7 +964,7 @@
4869 im_set_active(TRUE);
4870 #endif
4871
4872- *cp = safe_vgetc();
4873+ *cp = plain_vgetc();
4874
4875 if (langmap_active)
4876 {
4877@@ -1040,7 +1052,7 @@
4878 }
4879 if (c > 0)
4880 {
4881- c = safe_vgetc();
4882+ c = plain_vgetc();
4883 if (c != Ctrl_N && c != Ctrl_G)
4884 vungetc(c);
4885 else
4886@@ -1059,7 +1071,7 @@
4887 while (enc_utf8 && lang && (c = vpeekc()) > 0
4888 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1))
4889 {
4890- c = safe_vgetc();
4891+ c = plain_vgetc();
4892 if (!utf_iscomposing(c))
4893 {
4894 vungetc(c); /* it wasn't, put it back */
4895@@ -3755,7 +3767,8 @@
[ba61c16]4896 extra_len = (int)STRLEN(p);
4897 overflow = old_len + extra_len - SHOWCMD_COLS;
4898 if (overflow > 0)
4899- STRCPY(showcmd_buf, showcmd_buf + overflow);
4900+ mch_memmove(showcmd_buf, showcmd_buf + overflow,
4901+ old_len - overflow + 1);
4902 STRCAT(showcmd_buf, p);
4903
4904 if (char_avail())
[c2aa910]4905@@ -4558,7 +4571,7 @@
4906 #endif
4907 ++no_mapping;
4908 ++allow_keys; /* no mapping for nchar, but allow key codes */
4909- nchar = safe_vgetc();
4910+ nchar = plain_vgetc();
4911 #ifdef FEAT_LANGMAP
4912 LANGMAP_ADJUST(nchar, TRUE);
4913 #endif
4914@@ -4916,7 +4929,7 @@
4915 case 'u': /* "zug" and "zuw": undo "zg" and "zw" */
4916 ++no_mapping;
4917 ++allow_keys; /* no mapping for nchar, but allow key codes */
4918- nchar = safe_vgetc();
4919+ nchar = plain_vgetc();
4920 #ifdef FEAT_LANGMAP
4921 LANGMAP_ADJUST(nchar, TRUE);
4922 #endif
4923@@ -6379,7 +6392,7 @@
[ba61c16]4924 */
4925 else if (cap->nchar == 'p' || cap->nchar == 'P')
4926 {
4927- if (!checkclearopq(cap->oap))
4928+ if (!checkclearop(cap->oap))
4929 {
4930 prep_redo_cmd(cap);
4931 do_put(cap->oap->regname,
[c2aa910]4932@@ -6662,6 +6675,13 @@
[ba61c16]4933 else
4934 had_ctrl_v = NUL;
4935
4936+ /* Abort if the character is a special key. */
4937+ if (IS_SPECIAL(cap->nchar))
4938+ {
4939+ clearopbeep(cap->oap);
4940+ return;
4941+ }
4942+
4943 #ifdef FEAT_VISUAL
4944 /* Visual mode "r" */
4945 if (VIsual_active)
[c2aa910]4946@@ -6688,11 +6708,9 @@
[ba61c16]4947 }
4948 #endif
4949
4950- /*
4951- * Check for a special key or not enough characters to replace.
4952- */
4953+ /* Abort if not enough characters to replace. */
4954 ptr = ml_get_cursor();
4955- if (IS_SPECIAL(cap->nchar) || STRLEN(ptr) < (unsigned)cap->count1
4956+ if (STRLEN(ptr) < (unsigned)cap->count1
4957 #ifdef FEAT_MBYTE
4958 || (has_mbyte && mb_charlen(ptr) < cap->count1)
4959 #endif
[c2aa910]4960@@ -8353,7 +8371,7 @@
4961 n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP);
4962
4963 /* Don't leave the cursor on the NUL past a line */
4964- if (curwin->w_cursor.col && gchar_cursor() == NUL)
4965+ if (n != FAIL && curwin->w_cursor.col > 0 && gchar_cursor() == NUL)
4966 {
4967 --curwin->w_cursor.col;
4968 cap->oap->inclusive = TRUE;
[ba61c16]4969diff -Naur vim71.orig/src/ops.c vim71/src/ops.c
4970--- vim71.orig/src/ops.c 2007-05-07 12:33:47.000000000 -0700
[2830f42]4971+++ vim71/src/ops.c 2007-10-29 08:09:38.000000000 -0700
[c2aa910]4972@@ -2477,7 +2477,7 @@
4973
4974 /*
4975 * Spaces and tabs in the indent may have changed to other spaces and
4976- * tabs. Get the starting column again and correct the lenght.
4977+ * tabs. Get the starting column again and correct the length.
4978 * Don't do this when "$" used, end-of-line will have changed.
4979 */
4980 block_prep(oap, &bd2, oap->start.lnum, TRUE);
4981@@ -2534,7 +2534,9 @@
4982 #ifdef FEAT_VISUALEXTRA
4983 long offset;
4984 linenr_T linenr;
4985- long ins_len, pre_textlen = 0;
4986+ long ins_len;
4987+ long pre_textlen = 0;
4988+ long pre_indent = 0;
4989 char_u *firstline;
4990 char_u *ins_text, *newp, *oldp;
4991 struct block_def bd;
4992@@ -2579,7 +2581,9 @@
4993 || gchar_cursor() == NUL))
4994 coladvance_force(getviscol());
4995 # endif
4996- pre_textlen = (long)STRLEN(ml_get(oap->start.lnum));
4997+ firstline = ml_get(oap->start.lnum);
4998+ pre_textlen = (long)STRLEN(firstline);
4999+ pre_indent = (long)(skipwhite(firstline) - firstline);
5000 bd.textcol = curwin->w_cursor.col;
5001 }
5002 #endif
5003@@ -2598,13 +2602,22 @@
5004 */
5005 if (oap->block_mode && oap->start.lnum != oap->end.lnum)
5006 {
5007+ /* Auto-indenting may have changed the indent. If the cursor was past
5008+ * the indent, exclude that indent change from the inserted text. */
5009 firstline = ml_get(oap->start.lnum);
5010- /*
5011- * Subsequent calls to ml_get() flush the firstline data - take a
5012- * copy of the required bit.
5013- */
5014- if ((ins_len = (long)STRLEN(firstline) - pre_textlen) > 0)
5015+ if (bd.textcol > (colnr_T)pre_indent)
5016+ {
5017+ long new_indent = (long)(skipwhite(firstline) - firstline);
5018+
5019+ pre_textlen += new_indent - pre_indent;
5020+ bd.textcol += new_indent - pre_indent;
5021+ }
5022+
5023+ ins_len = (long)STRLEN(firstline) - pre_textlen;
5024+ if (ins_len > 0)
5025 {
5026+ /* Subsequent calls to ml_get() flush the firstline data - take a
5027+ * copy of the inserted text. */
5028 if ((ins_text = alloc_check((unsigned)(ins_len + 1))) != NULL)
5029 {
5030 vim_strncpy(ins_text, firstline + bd.textcol, (size_t)ins_len);
5031@@ -3404,7 +3417,9 @@
[ba61c16]5032
5033 #ifdef FEAT_VIRTUALEDIT
5034 col += curwin->w_cursor.coladd;
5035- if (ve_flags == VE_ALL && curwin->w_cursor.coladd > 0)
5036+ if (ve_flags == VE_ALL
5037+ && (curwin->w_cursor.coladd > 0
5038+ || endcol2 == curwin->w_cursor.col))
5039 {
5040 if (dir == FORWARD && c == NUL)
5041 ++col;
5042diff -Naur vim71.orig/src/option.c vim71/src/option.c
5043--- vim71.orig/src/option.c 2007-05-01 04:26:10.000000000 -0700
[2830f42]5044+++ vim71/src/option.c 2007-10-29 08:09:48.000000000 -0700
[c2aa910]5045@@ -427,6 +427,8 @@
5046 #define P_NOGLOB 0x100000L/* do not use local value for global vimrc */
5047 #define P_NFNAME 0x200000L/* only normal file name chars allowed */
5048 #define P_INSECURE 0x400000L/* option was set from a modeline */
5049+#define P_PRI_MKRC 0x800000L/* priority for :mkvimrc (setting option has
5050+ side effects) */
5051
5052 #define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
5053
5054@@ -773,6 +775,8 @@
5055 {(char_u *)0L, (char_u *)0L}
5056 #endif
5057 },
5058+ /* P_PRI_MKRC isn't needed here, optval_default()
5059+ * always returns TRUE for 'compatible' */
5060 {"compatible", "cp", P_BOOL|P_RALL,
5061 (char_u *)&p_cp, PV_NONE,
5062 {(char_u *)TRUE, (char_u *)FALSE}},
5063@@ -1515,7 +1519,7 @@
5064 {(char_u *)0L, (char_u *)0L}
5065 #endif
5066 },
5067- {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME,
5068+ {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
5069 #ifdef FEAT_KEYMAP
5070 (char_u *)&p_keymap, PV_KMAP,
5071 {(char_u *)"", (char_u *)0L}
5072@@ -1836,7 +1840,7 @@
5073 {"paragraphs", "para", P_STRING|P_VI_DEF,
5074 (char_u *)&p_para, PV_NONE,
5075 {(char_u *)"IPLPPPQPP LIpplpipbp", (char_u *)0L}},
5076- {"paste", NULL, P_BOOL|P_VI_DEF,
5077+ {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
5078 (char_u *)&p_paste, PV_NONE,
5079 {(char_u *)FALSE, (char_u *)0L}},
5080 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
5081@@ -4628,7 +4632,7 @@
[ba61c16]5082 if ((!(flags & P_COMMA) || *s != ',')
5083 && vim_strchr(s + 1, *s) != NULL)
5084 {
5085- STRCPY(s, s + 1);
5086+ mch_memmove(s, s + 1, STRLEN(s));
5087 --s;
5088 }
5089 }
[c2aa910]5090@@ -4992,7 +4996,7 @@
5091 * For 'spellsuggest' expand after "file:".
5092 */
5093 expand_env_esc(val, NameBuff, MAXPATHL,
5094- (char_u **)options[opt_idx].var == &p_tags,
5095+ (char_u **)options[opt_idx].var == &p_tags, FALSE,
5096 #ifdef FEAT_SPELL
5097 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5098 #endif
5099@@ -6348,7 +6352,7 @@
5100 errmsg = check_stl_option(p_ruf);
5101 }
5102 /* check 'statusline' only if it doesn't start with "%!" */
5103- else if (varp != &p_stl || s[0] != '%' || s[1] != '!')
5104+ else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
5105 errmsg = check_stl_option(s);
5106 if (varp == &p_ruf && errmsg == NULL)
5107 comp_col();
5108@@ -7118,6 +7122,11 @@
[ba61c16]5109 /* when 'endofline' is changed, redraw the window title */
5110 else if ((int *)varp == &curbuf->b_p_eol)
5111 need_maketitle = TRUE;
5112+#ifdef FEAT_MBYTE
5113+ /* when 'bomb' is changed, redraw the window title */
5114+ else if ((int *)varp == &curbuf->b_p_bomb)
5115+ need_maketitle = TRUE;
5116+#endif
5117 #endif
5118
5119 /* when 'bin' is set also set some other options */
[c2aa910]5120@@ -7815,6 +7824,8 @@
5121 errmsg = e_positive;
5122 p_ch = 1;
5123 }
5124+ if (p_ch > Rows - min_rows() + 1)
5125+ p_ch = Rows - min_rows() + 1;
5126
5127 /* Only compute the new window layout when startup has been
5128 * completed. Otherwise the frame sizes may be wrong. */
5129@@ -8219,6 +8230,25 @@
[ba61c16]5130 varp = get_varp(&options[opt_idx]);
5131 if (varp != NULL) /* hidden option is not changed */
5132 {
5133+ if (number == 0 && string != NULL)
5134+ {
5135+ int index;
5136+
5137+ /* Either we are given a string or we are setting option
5138+ * to zero. */
5139+ for (index = 0; string[index] == '0'; ++index)
5140+ ;
5141+ if (string[index] != NUL || index == 0)
5142+ {
5143+ /* There's another character after zeros or the string
5144+ * is empty. In both cases, we are trying to set a
5145+ * num option using a string. */
5146+ EMSG3(_("E521: Number required: &%s = '%s'"),
5147+ name, string);
5148+ return; /* do nothing as we hit an error */
5149+
5150+ }
5151+ }
5152 if (flags & P_NUM)
5153 (void)set_num_option(opt_idx, varp, number,
5154 NULL, 0, opt_flags);
[c2aa910]5155@@ -8511,13 +8541,20 @@
5156 char_u *varp_local = NULL; /* fresh value */
5157 char *cmd;
5158 int round;
5159+ int pri;
5160
5161 /*
5162 * The options that don't have a default (terminal name, columns, lines)
5163 * are never written. Terminal options are also not written.
5164+ * Do the loop over "options[]" twice: once for options with the
5165+ * P_PRI_MKRC flag and once without.
5166 */
5167- for (p = &options[0]; !istermoption(p); p++)
5168- if (!(p->flags & P_NO_MKRC) && !istermoption(p))
5169+ for (pri = 1; pri >= 0; --pri)
5170+ {
5171+ for (p = &options[0]; !istermoption(p); p++)
5172+ if (!(p->flags & P_NO_MKRC)
5173+ && !istermoption(p)
5174+ && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
5175 {
5176 /* skip global option when only doing locals */
5177 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
5178@@ -8613,6 +8650,7 @@
5179 }
5180 }
5181 }
5182+ }
5183 return OK;
5184 }
5185
5186@@ -8715,6 +8753,8 @@
5187 char *name;
5188 int value;
5189 {
5190+ if (value < 0) /* global/local option using global value */
5191+ return OK;
5192 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
5193 || put_eol(fd) < 0)
5194 return FAIL;
5195@@ -10585,6 +10625,8 @@
[ba61c16]5196 buf->b_start_ffc = *buf->b_p_ff;
5197 buf->b_start_eol = buf->b_p_eol;
5198 #ifdef FEAT_MBYTE
5199+ buf->b_start_bomb = buf->b_p_bomb;
5200+
5201 /* Only use free/alloc when necessary, they take time. */
5202 if (buf->b_start_fenc == NULL
5203 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
[c2aa910]5204@@ -10598,13 +10640,17 @@
[ba61c16]5205 /*
5206 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
5207 * from when editing started (save_file_ff() called).
5208- * Also when 'endofline' was changed and 'binary' is set.
5209+ * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
5210+ * changed and 'binary' is not set.
5211 * Don't consider a new, empty buffer to be changed.
5212 */
5213 int
5214 file_ff_differs(buf)
5215 buf_T *buf;
5216 {
5217+ /* In a buffer that was never loaded the options are not valid. */
5218+ if (buf->b_flags & BF_NEVERLOADED)
5219+ return FALSE;
5220 if ((buf->b_flags & BF_NEW)
5221 && buf->b_ml.ml_line_count == 1
5222 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
[c2aa910]5223@@ -10614,6 +10660,8 @@
[ba61c16]5224 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
5225 return TRUE;
5226 #ifdef FEAT_MBYTE
5227+ if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
5228+ return TRUE;
5229 if (buf->b_start_fenc == NULL)
5230 return (*buf->b_p_fenc != NUL);
5231 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
5232diff -Naur vim71.orig/src/os_unix.c vim71/src/os_unix.c
5233--- vim71.orig/src/os_unix.c 2007-05-09 12:41:58.000000000 -0700
[2830f42]5234+++ vim71/src/os_unix.c 2007-10-29 08:09:32.000000000 -0700
[ba61c16]5235@@ -753,7 +753,8 @@
5236 if (signal_stack != NULL)
5237 {
5238 # ifdef HAVE_SIGALTSTACK
5239-# ifdef __APPLE__
5240+# if defined(__APPLE__) && (!defined(MAC_OS_X_VERSION_MAX_ALLOWED) \
5241+ || MAC_OS_X_VERSION_MAX_ALLOWED <= 1040)
5242 /* missing prototype. Adding it to osdef?.h.in doesn't work, because
5243 * "struct sigaltstack" needs to be declared. */
5244 extern int sigaltstack __ARGS((const struct sigaltstack *ss, struct sigaltstack *oss));
5245@@ -2499,7 +2500,13 @@
5246 if (stat((char *)name, &statb))
5247 #endif
5248 return -1;
5249+#ifdef __INTERIX
5250+ /* The top bit makes the value negative, which means the file doesn't
5251+ * exist. Remove the bit, we don't use it. */
5252+ return statb.st_mode & ~S_ADDACE;
5253+#else
5254 return statb.st_mode;
5255+#endif
5256 }
5257
5258 /*
5259@@ -5682,7 +5689,7 @@
5260
5261 /*
5262 * Closes connection to gpm
5263- * returns non-zero if connection succesfully closed
5264+ * returns non-zero if connection successfully closed
5265 */
5266 static void
5267 gpm_close()
5268diff -Naur vim71.orig/src/os_unix.h vim71/src/os_unix.h
5269--- vim71.orig/src/os_unix.h 2007-05-07 12:35:05.000000000 -0700
[2830f42]5270+++ vim71/src/os_unix.h 2007-10-29 08:09:16.000000000 -0700
[ba61c16]5271@@ -508,6 +508,9 @@
5272 #if !defined(S_ISFIFO) && defined(S_IFIFO)
5273 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
5274 #endif
5275+#if !defined(S_ISCHR) && defined(S_IFCHR)
5276+# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
5277+#endif
5278
5279 /* Note: Some systems need both string.h and strings.h (Savage). However,
5280 * some systems can't handle both, only use string.h in that case. */
5281diff -Naur vim71.orig/src/popupmnu.c vim71/src/popupmnu.c
5282--- vim71.orig/src/popupmnu.c 2007-03-24 13:07:39.000000000 -0700
[2830f42]5283+++ vim71/src/popupmnu.c 2007-10-29 08:09:18.000000000 -0700
[ba61c16]5284@@ -75,7 +75,6 @@
5285
5286 row = curwin->w_cline_row + W_WINROW(curwin);
5287 height = curwin->w_cline_height;
5288- col = curwin->w_wcol + W_WINCOL(curwin) - curwin->w_leftcol;
5289
5290 if (firstwin->w_p_pvw)
5291 top_clear = firstwin->w_height;
5292@@ -167,6 +166,15 @@
5293 pum_base_width = max_width;
5294 pum_kind_width = kind_width;
5295
5296+ /* Calculate column */
5297+#ifdef FEAT_RIGHTLEFT
5298+ if (curwin->w_p_rl)
5299+ col = W_WINCOL(curwin) + W_WIDTH(curwin) - curwin->w_wcol -
5300+ curwin->w_leftcol - 1;
5301+ else
5302+#endif
5303+ col = W_WINCOL(curwin) + curwin->w_wcol - curwin->w_leftcol;
5304+
5305 /* if there are more items than room we need a scrollbar */
5306 if (pum_height < size)
5307 {
5308@@ -179,11 +187,23 @@
5309 if (def_width < max_width)
5310 def_width = max_width;
5311
5312- if (col < Columns - PUM_DEF_WIDTH || col < Columns - max_width)
5313+ if (((col < Columns - PUM_DEF_WIDTH || col < Columns - max_width)
5314+#ifdef FEAT_RIGHTLEFT
5315+ && !curwin->w_p_rl)
5316+ || (curwin->w_p_rl && (col > PUM_DEF_WIDTH || col > max_width)
5317+#endif
5318+ ))
5319 {
5320 /* align pum column with "col" */
5321 pum_col = col;
5322- pum_width = Columns - pum_col - pum_scrollbar;
5323+
5324+#ifdef FEAT_RIGHTLEFT
5325+ if (curwin->w_p_rl)
5326+ pum_width = pum_col - pum_scrollbar + 1;
5327+ else
5328+#endif
5329+ pum_width = Columns - pum_col - pum_scrollbar;
5330+
5331 if (pum_width > max_width + kind_width + extra_width + 1
5332 && pum_width > PUM_DEF_WIDTH)
5333 {
5334@@ -195,14 +215,24 @@
5335 else if (Columns < def_width)
5336 {
5337 /* not enough room, will use what we have */
5338- pum_col = 0;
5339+#ifdef FEAT_RIGHTLEFT
5340+ if (curwin->w_p_rl)
5341+ pum_col = Columns - 1;
5342+ else
5343+#endif
5344+ pum_col = 0;
5345 pum_width = Columns - 1;
5346 }
5347 else
5348 {
5349 if (max_width > PUM_DEF_WIDTH)
5350 max_width = PUM_DEF_WIDTH; /* truncate */
5351- pum_col = Columns - max_width;
5352+#ifdef FEAT_RIGHTLEFT
5353+ if (curwin->w_p_rl)
5354+ pum_col = max_width - 1;
5355+ else
5356+#endif
5357+ pum_col = Columns - max_width;
5358 pum_width = max_width - pum_scrollbar;
5359 }
5360
5361@@ -255,8 +285,16 @@
5362 attr = (idx == pum_selected) ? attr_select : attr_norm;
5363
5364 /* prepend a space if there is room */
5365- if (pum_col > 0)
5366- screen_putchar(' ', row, pum_col - 1, attr);
5367+#ifdef FEAT_RIGHTLEFT
5368+ if (curwin->w_p_rl)
5369+ {
5370+ if (pum_col < W_WINCOL(curwin) + W_WIDTH(curwin) - 1)
5371+ screen_putchar(' ', row, pum_col + 1, attr);
5372+ }
5373+ else
5374+#endif
5375+ if (pum_col > 0)
5376+ screen_putchar(' ', row, pum_col - 1, attr);
5377
5378 /* Display each entry, use two spaces for a Tab.
5379 * Do this 3 times: For the main text, kind and extra info */
5380@@ -282,26 +320,67 @@
5381 {
5382 /* Display the text that fits or comes before a Tab.
5383 * First convert it to printable characters. */
5384- char_u *st;
5385- int saved = *p;
5386+ char_u *st;
5387+ int saved = *p;
5388
5389 *p = NUL;
5390 st = transstr(s);
5391 *p = saved;
5392- if (st != NULL)
5393+#ifdef FEAT_RIGHTLEFT
5394+ if (curwin->w_p_rl)
5395 {
5396- screen_puts_len(st, (int)STRLEN(st), row, col,
5397+ if (st != NULL)
5398+ {
5399+ char_u *rt = reverse_text(st);
5400+ char_u *rt_saved = rt;
5401+ int len, j;
5402+
5403+ if (rt != NULL)
5404+ {
5405+ len = STRLEN(rt);
5406+ if (len > pum_width)
5407+ {
5408+ for (j = pum_width; j < len; ++j)
5409+ mb_ptr_adv(rt);
5410+ len = pum_width;
5411+ }
5412+ screen_puts_len(rt, len, row,
5413+ col - len + 1, attr);
5414+ vim_free(rt_saved);
5415+ }
5416+ vim_free(st);
5417+ }
5418+ col -= width;
5419+ }
5420+ else
5421+#endif
5422+ {
5423+ if (st != NULL)
5424+ {
5425+ screen_puts_len(st, (int)STRLEN(st), row, col,
5426 attr);
5427- vim_free(st);
5428+ vim_free(st);
5429+ }
5430+ col += width;
5431 }
5432- col += width;
5433
5434 if (*p != TAB)
5435 break;
5436
5437 /* Display two spaces for a Tab. */
5438- screen_puts_len((char_u *)" ", 2, row, col, attr);
5439- col += 2;
5440+#ifdef FEAT_RIGHTLEFT
5441+ if (curwin->w_p_rl)
5442+ {
5443+ screen_puts_len((char_u *)" ", 2, row, col - 1,
5444+ attr);
5445+ col -= 2;
5446+ }
5447+ else
5448+#endif
5449+ {
5450+ screen_puts_len((char_u *)" ", 2, row, col, attr);
5451+ col += 2;
5452+ }
5453 totwidth += 2;
5454 s = NULL; /* start text at next char */
5455 width = 0;
5456@@ -322,17 +401,44 @@
5457 && pum_array[idx].pum_extra == NULL)
5458 || pum_base_width + n >= pum_width)
5459 break;
5460- screen_fill(row, row + 1, col, pum_col + pum_base_width + n,
5461+#ifdef FEAT_RIGHTLEFT
5462+ if (curwin->w_p_rl)
5463+ {
5464+ screen_fill(row, row + 1, pum_col - pum_base_width - n + 1,
5465+ col + 1, ' ', ' ', attr);
5466+ col = pum_col - pum_base_width - n + 1;
5467+ }
5468+ else
5469+#endif
5470+ {
5471+ screen_fill(row, row + 1, col, pum_col + pum_base_width + n,
5472 ' ', ' ', attr);
5473- col = pum_col + pum_base_width + n;
5474+ col = pum_col + pum_base_width + n;
5475+ }
5476 totwidth = pum_base_width + n;
5477 }
5478
5479- screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ', attr);
5480+#ifdef FEAT_RIGHTLEFT
5481+ if (curwin->w_p_rl)
5482+ screen_fill(row, row + 1, pum_col - pum_width + 1, col + 1, ' ',
5483+ ' ', attr);
5484+ else
5485+#endif
5486+ screen_fill(row, row + 1, col, pum_col + pum_width, ' ', ' ',
5487+ attr);
5488 if (pum_scrollbar > 0)
5489- screen_putchar(' ', row, pum_col + pum_width,
5490- i >= thumb_pos && i < thumb_pos + thumb_heigth
5491+ {
5492+#ifdef FEAT_RIGHTLEFT
5493+ if (curwin->w_p_rl)
5494+ screen_putchar(' ', row, pum_col - pum_width,
5495+ i >= thumb_pos && i < thumb_pos + thumb_heigth
5496 ? attr_thumb : attr_scroll);
5497+ else
5498+#endif
5499+ screen_putchar(' ', row, pum_col + pum_width,
5500+ i >= thumb_pos && i < thumb_pos + thumb_heigth
5501+ ? attr_thumb : attr_scroll);
5502+ }
5503
5504 ++row;
5505 }
5506@@ -466,7 +572,7 @@
5507 set_option_value((char_u *)"bh", 0L,
5508 (char_u *)"wipe", OPT_LOCAL);
5509 set_option_value((char_u *)"diff", 0L,
5510- (char_u *)"", OPT_LOCAL);
5511+ NULL, OPT_LOCAL);
5512 }
5513 }
5514 if (res == OK)
5515diff -Naur vim71.orig/src/proto/charset.pro vim71/src/proto/charset.pro
5516--- vim71.orig/src/proto/charset.pro 2007-05-12 03:39:01.000000000 -0700
[2830f42]5517+++ vim71/src/proto/charset.pro 2007-10-29 08:09:30.000000000 -0700
[ba61c16]5518@@ -21,6 +21,7 @@
5519 int vim_iswordp __ARGS((char_u *p));
5520 int vim_iswordc_buf __ARGS((char_u *p, buf_T *buf));
5521 int vim_isfilec __ARGS((int c));
5522+int vim_isfilec_or_wc __ARGS((int c));
5523 int vim_isprintc __ARGS((int c));
5524 int vim_isprintc_strict __ARGS((int c));
5525 int lbr_chartabsize __ARGS((unsigned char *s, colnr_T col));
5526diff -Naur vim71.orig/src/proto/fileio.pro vim71/src/proto/fileio.pro
5527--- vim71.orig/src/proto/fileio.pro 2007-05-12 03:39:14.000000000 -0700
[2830f42]5528+++ vim71/src/proto/fileio.pro 2007-10-29 08:09:40.000000000 -0700
[ba61c16]5529@@ -2,6 +2,7 @@
5530 void filemess __ARGS((buf_T *buf, char_u *name, char_u *s, int attr));
5531 int readfile __ARGS((char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_skip, linenr_T lines_to_read, exarg_T *eap, int flags));
5532 int prep_exarg __ARGS((exarg_T *eap, buf_T *buf));
5533+int check_file_readonly __ARGS((char_u *fname, int perm));
5534 int buf_write __ARGS((buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_T end, exarg_T *eap, int append, int forceit, int reset_changed, int filtering));
5535 void msg_add_fname __ARGS((buf_T *buf, char_u *fname));
5536 void msg_add_lines __ARGS((int insert_space, long lnum, long nchars));
[c2aa910]5537@@ -39,6 +40,8 @@
5538 int trigger_cursorhold __ARGS((void));
5539 int has_cursormoved __ARGS((void));
5540 int has_cursormovedI __ARGS((void));
5541+void block_autocmds __ARGS((void));
5542+void unblock_autocmds __ARGS((void));
5543 int has_autocmd __ARGS((event_T event, char_u *sfname, buf_T *buf));
5544 char_u *get_augroup_name __ARGS((expand_T *xp, int idx));
5545 char_u *set_context_in_autocmd __ARGS((expand_T *xp, char_u *arg, int doautocmd));
5546diff -Naur vim71.orig/src/proto/getchar.pro vim71/src/proto/getchar.pro
5547--- vim71.orig/src/proto/getchar.pro 2007-05-12 03:39:16.000000000 -0700
[2830f42]5548+++ vim71/src/proto/getchar.pro 2007-10-29 08:09:37.000000000 -0700
[c2aa910]5549@@ -38,6 +38,7 @@
5550 void updatescript __ARGS((int c));
5551 int vgetc __ARGS((void));
5552 int safe_vgetc __ARGS((void));
5553+int plain_vgetc __ARGS((void));
5554 int vpeekc __ARGS((void));
5555 int vpeekc_nomap __ARGS((void));
5556 int vpeekc_any __ARGS((void));
5557diff -Naur vim71.orig/src/proto/if_cscope.pro vim71/src/proto/if_cscope.pro
5558--- vim71.orig/src/proto/if_cscope.pro 2007-05-12 03:39:21.000000000 -0700
[2830f42]5559+++ vim71/src/proto/if_cscope.pro 2007-10-29 08:09:37.000000000 -0700
[c2aa910]5560@@ -6,4 +6,5 @@
5561 void cs_free_tags __ARGS((void));
5562 void cs_print_tags __ARGS((void));
5563 int cs_connection __ARGS((int num, char_u *dbpath, char_u *ppath));
5564+void cs_end __ARGS((void));
5565 /* vim: set ft=c : */
[ba61c16]5566diff -Naur vim71.orig/src/proto/mbyte.pro vim71/src/proto/mbyte.pro
5567--- vim71.orig/src/proto/mbyte.pro 2007-05-12 03:39:38.000000000 -0700
[2830f42]5568+++ vim71/src/proto/mbyte.pro 2007-10-29 08:09:37.000000000 -0700
[ba61c16]5569@@ -12,9 +12,9 @@
5570 int utf_ptr2cells __ARGS((char_u *p));
5571 int dbcs_ptr2cells __ARGS((char_u *p));
5572 int latin_char2cells __ARGS((int c));
5573-int latin_off2cells __ARGS((unsigned off));
5574-int dbcs_off2cells __ARGS((unsigned off));
5575-int utf_off2cells __ARGS((unsigned off));
5576+int latin_off2cells __ARGS((unsigned off, unsigned max_off));
5577+int dbcs_off2cells __ARGS((unsigned off, unsigned max_off));
5578+int utf_off2cells __ARGS((unsigned off, unsigned max_off));
5579 int latin_ptr2char __ARGS((char_u *p));
5580 int utf_ptr2char __ARGS((char_u *p));
5581 int mb_ptr2char_adv __ARGS((char_u **pp));
[c2aa910]5582diff -Naur vim71.orig/src/proto/misc1.pro vim71/src/proto/misc1.pro
5583--- vim71.orig/src/proto/misc1.pro 2007-05-12 03:39:34.000000000 -0700
[2830f42]5584+++ vim71/src/proto/misc1.pro 2007-10-29 08:09:38.000000000 -0700
[c2aa910]5585@@ -48,10 +48,11 @@
5586 void vim_beep __ARGS((void));
5587 void init_homedir __ARGS((void));
5588 void free_homedir __ARGS((void));
5589+char_u *expand_env_save __ARGS((char_u *src));
5590+char_u *expand_env_save_opt __ARGS((char_u *src, int one));
5591 void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
5592-void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, char_u *startstr));
5593+void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, int one, char_u *startstr));
5594 char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
5595-char_u *expand_env_save __ARGS((char_u *src));
5596 void vim_setenv __ARGS((char_u *name, char_u *val));
5597 char_u *get_env_name __ARGS((expand_T *xp, int idx));
5598 void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
[ba61c16]5599diff -Naur vim71.orig/src/proto/search.pro vim71/src/proto/search.pro
5600--- vim71.orig/src/proto/search.pro 2007-05-12 03:39:50.000000000 -0700
[2830f42]5601+++ vim71/src/proto/search.pro 2007-10-29 08:09:18.000000000 -0700
[ba61c16]5602@@ -1,6 +1,7 @@
5603 /* search.c */
5604 int search_regcomp __ARGS((char_u *pat, int pat_save, int pat_use, int options, regmmatch_T *regmatch));
5605 char_u *get_search_pat __ARGS((void));
5606+char_u *reverse_text __ARGS((char_u *s));
5607 void save_search_patterns __ARGS((void));
5608 void restore_search_patterns __ARGS((void));
5609 void free_search_patterns __ARGS((void));
5610diff -Naur vim71.orig/src/proto/syntax.pro vim71/src/proto/syntax.pro
5611--- vim71.orig/src/proto/syntax.pro 2007-05-12 03:39:52.000000000 -0700
[2830f42]5612+++ vim71/src/proto/syntax.pro 2007-10-29 08:09:16.000000000 -0700
[ba61c16]5613@@ -8,6 +8,8 @@
5614 void syntax_clear __ARGS((buf_T *buf));
5615 void ex_syntax __ARGS((exarg_T *eap));
5616 int syntax_present __ARGS((buf_T *buf));
5617+void reset_expand_highlight __ARGS((void));
5618+void set_context_in_echohl_cmd __ARGS((expand_T *xp, char_u *arg));
5619 void set_context_in_syntax_cmd __ARGS((expand_T *xp, char_u *arg));
5620 char_u *get_syntax_name __ARGS((expand_T *xp, int idx));
5621 int syn_get_id __ARGS((win_T *wp, long lnum, colnr_T col, int trans, int *spellp));
5622diff -Naur vim71.orig/src/proto/window.pro vim71/src/proto/window.pro
5623--- vim71.orig/src/proto/window.pro 2007-05-12 03:40:00.000000000 -0700
[2830f42]5624+++ vim71/src/proto/window.pro 2007-10-29 08:09:16.000000000 -0700
[ba61c16]5625@@ -59,4 +59,8 @@
5626 int only_one_window __ARGS((void));
5627 void check_lnums __ARGS((int do_curwin));
5628 int win_hasvertsplit __ARGS((void));
5629+int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
5630+int match_delete __ARGS((win_T *wp, int id, int perr));
5631+void clear_matches __ARGS((win_T *wp));
5632+matchitem_T *get_match __ARGS((win_T *wp, int id));
5633 /* vim: set ft=c : */
5634diff -Naur vim71.orig/src/quickfix.c vim71/src/quickfix.c
5635--- vim71.orig/src/quickfix.c 2007-02-03 16:50:17.000000000 -0800
[2830f42]5636+++ vim71/src/quickfix.c 2007-10-29 08:09:38.000000000 -0700
[c2aa910]5637@@ -1612,8 +1612,8 @@
5638 }
5639
5640 /*
5641- * If there is only one window and is the quickfix window, create a new
5642- * one above the quickfix window.
5643+ * If there is only one window and it is the quickfix window, create a
5644+ * new one above the quickfix window.
5645 */
5646 if (((firstwin == lastwin) && bt_quickfix(curbuf)) || !usable_win)
5647 {
[ba61c16]5648@@ -2331,7 +2331,7 @@
5649 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
5650 OPT_LOCAL);
5651 set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL);
5652- set_option_value((char_u *)"diff", 0L, (char_u *)"", OPT_LOCAL);
5653+ set_option_value((char_u *)"diff", 0L, NULL, OPT_LOCAL);
5654 }
5655
5656 /* Only set the height when still in the same tab page and there is no
[c2aa910]5657@@ -2981,6 +2981,7 @@
5658 buf_T *buf;
5659 int duplicate_name = FALSE;
5660 int using_dummy;
5661+ int redraw_for_dummy = FALSE;
5662 int found_match;
5663 buf_T *first_match_buf = NULL;
5664 time_t seconds = 0;
5665@@ -3097,6 +3098,7 @@
5666 /* Remember that a buffer with this name already exists. */
5667 duplicate_name = (buf != NULL);
5668 using_dummy = TRUE;
5669+ redraw_for_dummy = TRUE;
5670
5671 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
5672 /* Don't do Filetype autocommands to avoid loading syntax and
5673@@ -3243,11 +3245,29 @@
5674 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
5675 {
5676 if ((flags & VGR_NOJUMP) == 0)
5677+ {
5678+ buf = curbuf;
5679 qf_jump(qi, 0, 0, eap->forceit);
5680+ if (buf != curbuf)
5681+ /* If we jumped to another buffer redrawing will already be
5682+ * taken care of. */
5683+ redraw_for_dummy = FALSE;
5684+ }
5685 }
5686 else
5687 EMSG2(_(e_nomatch2), s);
5688
5689+ /* If we loaded a dummy buffer into the current window, the autocommands
5690+ * may have messed up things, need to redraw and recompute folds. */
5691+ if (redraw_for_dummy)
5692+ {
5693+#ifdef FEAT_FOLDING
5694+ foldUpdateAll(curwin);
5695+#else
5696+ redraw_later(NOT_VALID);
5697+#endif
5698+ }
5699+
5700 theend:
5701 vim_free(regmatch.regprog);
5702 }
[ba61c16]5703diff -Naur vim71.orig/src/regexp.c vim71/src/regexp.c
5704--- vim71.orig/src/regexp.c 2007-05-07 12:50:03.000000000 -0700
[2830f42]5705+++ vim71/src/regexp.c 2007-10-29 08:09:18.000000000 -0700
[ba61c16]5706@@ -2220,7 +2220,7 @@
5707 break;
5708 case CLASS_LOWER:
5709 for (cu = 1; cu <= 255; cu++)
5710- if (islower(cu))
5711+ if (MB_ISLOWER(cu))
5712 regc(cu);
5713 break;
5714 case CLASS_PRINT:
5715@@ -2240,7 +2240,7 @@
5716 break;
5717 case CLASS_UPPER:
5718 for (cu = 1; cu <= 255; cu++)
5719- if (isupper(cu))
5720+ if (MB_ISUPPER(cu))
5721 regc(cu);
5722 break;
5723 case CLASS_XDIGIT:
5724@@ -3465,7 +3465,7 @@
5725 (enc_utf8 && utf_fold(prog->regstart) == utf_fold(c)))
5726 || (c < 255 && prog->regstart < 255 &&
5727 #endif
5728- TOLOWER_LOC(prog->regstart) == TOLOWER_LOC(c)))))
5729+ MB_TOLOWER(prog->regstart) == MB_TOLOWER(c)))))
5730 retval = regtry(prog, col);
5731 else
5732 retval = 0;
5733@@ -4200,7 +4200,7 @@
5734 #ifdef FEAT_MBYTE
5735 !enc_utf8 &&
5736 #endif
5737- TOLOWER_LOC(*opnd) != TOLOWER_LOC(*reginput))))
5738+ MB_TOLOWER(*opnd) != MB_TOLOWER(*reginput))))
5739 status = RA_NOMATCH;
5740 else if (*opnd == NUL)
5741 {
5742@@ -4733,10 +4733,10 @@
5743 rst.nextb = *OPERAND(next);
5744 if (ireg_ic)
5745 {
5746- if (isupper(rst.nextb))
5747- rst.nextb_ic = TOLOWER_LOC(rst.nextb);
5748+ if (MB_ISUPPER(rst.nextb))
5749+ rst.nextb_ic = MB_TOLOWER(rst.nextb);
5750 else
5751- rst.nextb_ic = TOUPPER_LOC(rst.nextb);
5752+ rst.nextb_ic = MB_TOUPPER(rst.nextb);
5753 }
5754 else
5755 rst.nextb_ic = rst.nextb;
5756@@ -5558,11 +5558,12 @@
5757 int cu, cl;
5758
5759 /* This doesn't do a multi-byte character, because a MULTIBYTECODE
5760- * would have been used for it. */
5761+ * would have been used for it. It does handle single-byte
5762+ * characters, such as latin1. */
5763 if (ireg_ic)
5764 {
5765- cu = TOUPPER_LOC(*opnd);
5766- cl = TOLOWER_LOC(*opnd);
5767+ cu = MB_TOUPPER(*opnd);
5768+ cl = MB_TOLOWER(*opnd);
5769 while (count < maxcount && (*scan == cu || *scan == cl))
5770 {
5771 count++;
5772@@ -6490,10 +6491,10 @@
5773 cc = utf_fold(c);
5774 else
5775 #endif
5776- if (isupper(c))
5777- cc = TOLOWER_LOC(c);
5778- else if (islower(c))
5779- cc = TOUPPER_LOC(c);
5780+ if (MB_ISUPPER(c))
5781+ cc = MB_TOLOWER(c);
5782+ else if (MB_ISLOWER(c))
5783+ cc = MB_TOUPPER(c);
5784 else
5785 return vim_strchr(s, c);
5786
5787@@ -6637,9 +6638,9 @@
5788 }
5789 }
5790 else if (magic)
5791- STRCPY(p, p + 1); /* remove '~' */
5792+ mch_memmove(p, p + 1, STRLEN(p)); /* remove '~' */
5793 else
5794- STRCPY(p, p + 2); /* remove '\~' */
5795+ mch_memmove(p, p + 2, STRLEN(p) - 1); /* remove '\~' */
5796 --p;
5797 }
5798 else
5799@@ -7014,7 +7015,14 @@
5800 #ifdef FEAT_MBYTE
5801 if (has_mbyte)
5802 {
5803- int l = mb_ptr2len(s) - 1;
5804+ int l;
5805+
5806+ /* Copy composing characters separately, one
5807+ * at a time. */
5808+ if (enc_utf8)
5809+ l = utf_ptr2len(s) - 1;
5810+ else
5811+ l = mb_ptr2len(s) - 1;
5812
5813 s += l;
5814 len -= l;
5815diff -Naur vim71.orig/src/screen.c vim71/src/screen.c
5816--- vim71.orig/src/screen.c 2007-05-07 12:27:53.000000000 -0700
[2830f42]5817+++ vim71/src/screen.c 2007-10-29 08:09:38.000000000 -0700
[ba61c16]5818@@ -100,27 +100,7 @@
5819 static int screen_cur_row, screen_cur_col; /* last known cursor position */
5820
5821 #ifdef FEAT_SEARCH_EXTRA
5822-/*
5823- * Struct used for highlighting 'hlsearch' matches for the last use search
5824- * pattern or a ":match" item.
5825- * For 'hlsearch' there is one pattern for all windows. For ":match" there is
5826- * a different pattern for each window.
5827- */
5828-typedef struct
5829-{
5830- regmmatch_T rm; /* points to the regexp program; contains last found
5831- match (may continue in next line) */
5832- buf_T *buf; /* the buffer to search for a match */
5833- linenr_T lnum; /* the line to search for a match */
5834- int attr; /* attributes to be used for a match */
5835- int attr_cur; /* attributes currently active in win_line() */
5836- linenr_T first_lnum; /* first lnum to search for multi-line pat */
5837- colnr_T startcol; /* in win_line() points to char where HL starts */
5838- colnr_T endcol; /* in win_line() points to char where HL ends */
5839-} match_T;
5840-
5841 static match_T search_hl; /* used for 'hlsearch' highlight matching */
5842-static match_T match_hl[3]; /* used for ":match" highlight matching */
5843 #endif
5844
5845 #ifdef FEAT_FOLDING
5846@@ -155,6 +135,7 @@
5847 static void redraw_custum_statusline __ARGS((win_T *wp));
5848 #endif
5849 #ifdef FEAT_SEARCH_EXTRA
5850+#define SEARCH_HL_PRIORITY 0
5851 static void start_search_hl __ARGS((void));
5852 static void end_search_hl __ARGS((void));
5853 static void prepare_search_hl __ARGS((win_T *wp, linenr_T lnum));
5854@@ -350,6 +331,11 @@
5855 {
5856 if (type < must_redraw) /* use maximal type */
5857 type = must_redraw;
5858+
5859+ /* must_redraw is reset here, so that when we run into some weird
5860+ * reason to redraw while busy redrawing (e.g., asynchronous
5861+ * scrolling), or update_topline() in win_update() will cause a
5862+ * scroll, the screen will be redrawn later or in win_update(). */
5863 must_redraw = 0;
5864 }
5865
5866@@ -787,6 +773,7 @@
5867 w_topline got smaller a bit */
5868 #endif
5869 #ifdef FEAT_SEARCH_EXTRA
5870+ matchitem_T *cur; /* points to the match list */
5871 int top_to_mod = FALSE; /* redraw above mod_top */
5872 #endif
5873
5874@@ -848,18 +835,20 @@
5875 #endif
5876
5877 #ifdef FEAT_SEARCH_EXTRA
5878- /* Setup for ":match" and 'hlsearch' highlighting. Disable any previous
5879+ /* Setup for match and 'hlsearch' highlighting. Disable any previous
5880 * match */
5881- for (i = 0; i < 3; ++i)
5882+ cur = wp->w_match_head;
5883+ while (cur != NULL)
5884 {
5885- match_hl[i].rm = wp->w_match[i];
5886- if (wp->w_match_id[i] == 0)
5887- match_hl[i].attr = 0;
5888- else
5889- match_hl[i].attr = syn_id2attr(wp->w_match_id[i]);
5890- match_hl[i].buf = buf;
5891- match_hl[i].lnum = 0;
5892- match_hl[i].first_lnum = 0;
5893+ cur->hl.rm = cur->match;
5894+ if (cur->hlg_id == 0)
5895+ cur->hl.attr = 0;
5896+ else
5897+ cur->hl.attr = syn_id2attr(cur->hlg_id);
5898+ cur->hl.buf = buf;
5899+ cur->hl.lnum = 0;
5900+ cur->hl.first_lnum = 0;
5901+ cur = cur->next;
5902 }
5903 search_hl.buf = buf;
5904 search_hl.lnum = 0;
5905@@ -923,19 +912,25 @@
5906 * change in one line may make the Search highlighting in a
5907 * previous line invalid. Simple solution: redraw all visible
5908 * lines above the change.
5909- * Same for a ":match" pattern.
5910+ * Same for a match pattern.
5911 */
5912 if (search_hl.rm.regprog != NULL
5913 && re_multiline(search_hl.rm.regprog))
5914 top_to_mod = TRUE;
5915 else
5916- for (i = 0; i < 3; ++i)
5917- if (match_hl[i].rm.regprog != NULL
5918- && re_multiline(match_hl[i].rm.regprog))
5919+ {
5920+ cur = wp->w_match_head;
5921+ while (cur != NULL)
5922+ {
5923+ if (cur->match.regprog != NULL
5924+ && re_multiline(cur->match.regprog))
5925 {
5926 top_to_mod = TRUE;
5927 break;
5928 }
5929+ cur = cur->next;
5930+ }
5931+ }
5932 #endif
5933 }
5934 #ifdef FEAT_FOLDING
5935@@ -1029,6 +1024,13 @@
5936 type = VALID;
5937 }
5938
5939+ /* Trick: we want to avoid clearing the screen twice. screenclear() will
5940+ * set "screen_cleared" to TRUE. The special value MAYBE (which is still
5941+ * non-zero and thus not FALSE) will indicate that screenclear() was not
5942+ * called. */
5943+ if (screen_cleared)
5944+ screen_cleared = MAYBE;
5945+
5946 /*
5947 * If there are no changes on the screen that require a complete redraw,
5948 * handle three cases:
5949@@ -1230,7 +1232,11 @@
5950 mid_end = wp->w_height;
5951 if (lastwin == firstwin)
5952 {
5953- screenclear();
5954+ /* Clear the screen when it was not done by win_del_lines() or
5955+ * win_ins_lines() above, "screen_cleared" is FALSE or MAYBE
5956+ * then. */
5957+ if (screen_cleared != TRUE)
5958+ screenclear();
5959 #ifdef FEAT_WINDOWS
5960 /* The screen was cleared, redraw the tab pages line. */
5961 if (redraw_tabline)
5962@@ -1238,6 +1244,13 @@
5963 #endif
5964 }
5965 }
5966+
5967+ /* When win_del_lines() or win_ins_lines() caused the screen to be
5968+ * cleared (only happens for the first window) or when screenclear()
5969+ * was called directly above, "must_redraw" will have been set to
5970+ * NOT_VALID, need to reset it here to avoid redrawing twice. */
5971+ if (screen_cleared == TRUE)
5972+ must_redraw = 0;
5973 }
5974 else
5975 {
[c2aa910]5976@@ -2292,9 +2305,11 @@
5977 prev_c = u8c;
5978 #endif
5979 /* Non-BMP character: display as ? or fullwidth ?. */
5980+#ifdef UNICODE16
5981 if (u8c >= 0x10000)
5982 ScreenLinesUC[idx] = (cells == 2) ? 0xff1f : (int)'?';
5983 else
5984+#endif
5985 ScreenLinesUC[idx] = u8c;
5986 for (i = 0; i < Screen_mco; ++i)
5987 {
5988@@ -2542,7 +2557,7 @@
[ba61c16]5989
5990 char_u extra[18]; /* "%ld" and 'fdc' must fit in here */
5991 int n_extra = 0; /* number of extra chars */
5992- char_u *p_extra = NULL; /* string of extra chars */
5993+ char_u *p_extra = NULL; /* string of extra chars, plus NUL */
5994 int c_extra = NUL; /* extra chars, all the same */
5995 int extra_attr = 0; /* attributes when n_extra != 0 */
5996 static char_u *at_end_str = (char_u *)""; /* used for p_extra when
[c2aa910]5997@@ -2626,10 +2641,13 @@
[ba61c16]5998 int line_attr = 0; /* atrribute for the whole line */
5999 #endif
6000 #ifdef FEAT_SEARCH_EXTRA
6001- match_T *shl; /* points to search_hl or match_hl */
6002-#endif
6003-#if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_MBYTE)
6004- int i;
6005+ matchitem_T *cur; /* points to the match list */
6006+ match_T *shl; /* points to search_hl or a match */
6007+ int shl_flag; /* flag to indicate whether search_hl
6008+ has been processed or not */
6009+ int prevcol_hl_flag; /* flag to indicate whether prevcol
6010+ equals startcol of search_hl or one
6011+ of the matches */
6012 #endif
6013 #ifdef FEAT_ARABIC
6014 int prev_c = 0; /* previous Arabic character */
[c2aa910]6015@@ -3074,12 +3092,20 @@
[ba61c16]6016
6017 #ifdef FEAT_SEARCH_EXTRA
6018 /*
6019- * Handle highlighting the last used search pattern and ":match".
6020- * Do this for both search_hl and match_hl[3].
6021+ * Handle highlighting the last used search pattern and matches.
6022+ * Do this for both search_hl and the match list.
6023 */
6024- for (i = 3; i >= 0; --i)
6025+ cur = wp->w_match_head;
6026+ shl_flag = FALSE;
6027+ while (cur != NULL || shl_flag == FALSE)
6028 {
6029- shl = (i == 3) ? &search_hl : &match_hl[i];
6030+ if (shl_flag == FALSE)
6031+ {
6032+ shl = &search_hl;
6033+ shl_flag = TRUE;
6034+ }
6035+ else
6036+ shl = &cur->hl;
6037 shl->startcol = MAXCOL;
6038 shl->endcol = MAXCOL;
6039 shl->attr_cur = 0;
[c2aa910]6040@@ -3122,6 +3148,8 @@
[ba61c16]6041 area_highlighting = TRUE;
6042 }
6043 }
6044+ if (shl != &search_hl && cur != NULL)
6045+ cur = cur->next;
6046 }
6047 #endif
6048
[c2aa910]6049@@ -3163,10 +3191,8 @@
[ba61c16]6050 if (cmdwin_type != 0 && wp == curwin)
6051 {
6052 /* Draw the cmdline character. */
6053- *extra = cmdwin_type;
6054 n_extra = 1;
6055- p_extra = extra;
6056- c_extra = NUL;
6057+ c_extra = cmdwin_type;
6058 char_attr = hl_attr(HLF_AT);
6059 }
6060 }
[c2aa910]6061@@ -3182,6 +3208,7 @@
[ba61c16]6062 fill_foldcolumn(extra, wp, FALSE, lnum);
6063 n_extra = wp->w_p_fdc;
6064 p_extra = extra;
6065+ p_extra[n_extra] = NUL;
6066 c_extra = NUL;
6067 char_attr = hl_attr(HLF_FC);
6068 }
[c2aa910]6069@@ -3388,13 +3415,24 @@
[ba61c16]6070 * After end, check for start/end of next match.
6071 * When another match, have to check for start again.
6072 * Watch out for matching an empty string!
6073- * Do this first for search_hl, then for match_hl, so that
6074- * ":match" overrules 'hlsearch'.
6075+ * Do this for 'search_hl' and the match list (ordered by
6076+ * priority).
6077 */
6078 v = (long)(ptr - line);
6079- for (i = 3; i >= 0; --i)
6080- {
6081- shl = (i == 3) ? &search_hl : &match_hl[i];
6082+ cur = wp->w_match_head;
6083+ shl_flag = FALSE;
6084+ while (cur != NULL || shl_flag == FALSE)
6085+ {
6086+ if (shl_flag == FALSE
6087+ && ((cur != NULL
6088+ && cur->priority > SEARCH_HL_PRIORITY)
6089+ || cur == NULL))
6090+ {
6091+ shl = &search_hl;
6092+ shl_flag = TRUE;
6093+ }
6094+ else
6095+ shl = &cur->hl;
6096 while (shl->rm.regprog != NULL)
6097 {
6098 if (shl->startcol != MAXCOL
[c2aa910]6099@@ -3442,26 +3480,43 @@
[ba61c16]6100 }
6101 break;
6102 }
6103+ if (shl != &search_hl && cur != NULL)
6104+ cur = cur->next;
6105 }
6106
6107- /* ":match" highlighting overrules 'hlsearch' */
6108- for (i = 0; i <= 3; ++i)
6109- if (i == 3)
6110- search_attr = search_hl.attr_cur;
6111- else if (match_hl[i].attr_cur != 0)
6112+ /* Use attributes from match with highest priority among
6113+ * 'search_hl' and the match list. */
6114+ search_attr = search_hl.attr_cur;
6115+ cur = wp->w_match_head;
6116+ shl_flag = FALSE;
6117+ while (cur != NULL || shl_flag == FALSE)
6118+ {
6119+ if (shl_flag == FALSE
6120+ && ((cur != NULL
6121+ && cur->priority > SEARCH_HL_PRIORITY)
6122+ || cur == NULL))
6123 {
6124- search_attr = match_hl[i].attr_cur;
6125- break;
6126+ shl = &search_hl;
6127+ shl_flag = TRUE;
6128 }
6129+ else
6130+ shl = &cur->hl;
6131+ if (shl->attr_cur != 0)
6132+ search_attr = shl->attr_cur;
6133+ if (shl != &search_hl && cur != NULL)
6134+ cur = cur->next;
6135+ }
6136 }
6137 #endif
6138
6139 #ifdef FEAT_DIFF
6140 if (diff_hlf != (hlf_T)0)
6141 {
6142- if (diff_hlf == HLF_CHD && ptr - line >= change_start)
6143+ if (diff_hlf == HLF_CHD && ptr - line >= change_start
6144+ && n_extra == 0)
6145 diff_hlf = HLF_TXD; /* changed text */
6146- if (diff_hlf == HLF_TXD && ptr - line > change_end)
6147+ if (diff_hlf == HLF_TXD && ptr - line > change_end
6148+ && n_extra == 0)
6149 diff_hlf = HLF_CHD; /* changed line */
6150 line_attr = hl_attr(diff_hlf);
6151 }
[c2aa910]6152@@ -3496,9 +3551,11 @@
[ba61c16]6153 * Get the next character to put on the screen.
6154 */
6155 /*
6156- * The 'extra' array contains the extra stuff that is inserted to
6157- * represent special characters (non-printable stuff). When all
6158- * characters are the same, c_extra is used.
6159+ * The "p_extra" points to the extra stuff that is inserted to
6160+ * represent special characters (non-printable stuff) and other
6161+ * things. When all characters are the same, c_extra is used.
6162+ * "p_extra" must end in a NUL to avoid mb_ptr2len() reads past
6163+ * "p_extra[n_extra]".
6164 * For the '$' of the 'list' option, n_extra == 1, p_extra == "".
6165 */
6166 if (n_extra > 0)
[c2aa910]6167@@ -3611,6 +3668,8 @@
[ba61c16]6168 * Draw it as a space with a composing char. */
6169 if (utf_iscomposing(mb_c))
6170 {
6171+ int i;
6172+
6173 for (i = Screen_mco - 1; i > 0; --i)
6174 u8cc[i] = u8cc[i - 1];
6175 u8cc[0] = mb_c;
[c2aa910]6176@@ -3621,13 +3680,18 @@
6177 if ((mb_l == 1 && c >= 0x80)
6178 || (mb_l >= 1 && mb_c == 0)
6179 || (mb_l > 1 && (!vim_isprintc(mb_c)
6180- || mb_c >= 0x10000)))
6181+# ifdef UNICODE16
6182+ || mb_c >= 0x10000
6183+# endif
6184+ )))
6185 {
6186 /*
6187 * Illegal UTF-8 byte: display as <xx>.
6188 * Non-BMP character : display as ? or fullwidth ?.
6189 */
6190+# ifdef UNICODE16
6191 if (mb_c < 0x10000)
6192+# endif
6193 {
6194 transchar_hex(extra, mb_c);
6195 # ifdef FEAT_RIGHTLEFT
6196@@ -3635,11 +3699,13 @@
6197 rl_mirror(extra);
6198 # endif
6199 }
6200+# ifdef UNICODE16
6201 else if (utf_char2cells(mb_c) != 2)
6202 STRCPY(extra, "?");
6203 else
6204 /* 0xff1f in UTF-8: full-width '?' */
6205 STRCPY(extra, "\357\274\237");
6206+# endif
6207
6208 p_extra = extra;
6209 c = *p_extra;
6210@@ -3752,10 +3818,8 @@
[ba61c16]6211 * a '<' in the first column. */
6212 if (n_skip > 0 && mb_l > 1)
6213 {
6214- extra[0] = '<';
6215- p_extra = extra;
6216 n_extra = 1;
6217- c_extra = NUL;
6218+ c_extra = '<';
6219 c = ' ';
6220 if (area_attr == 0 && search_attr == 0)
6221 {
[c2aa910]6222@@ -4254,14 +4318,29 @@
[ba61c16]6223 * highlight match at end of line. If it's beyond the last
6224 * char on the screen, just overwrite that one (tricky!) Not
6225 * needed when a '$' was displayed for 'list'. */
6226+#ifdef FEAT_SEARCH_EXTRA
6227+ prevcol_hl_flag = FALSE;
6228+ if (prevcol == (long)search_hl.startcol)
6229+ prevcol_hl_flag = TRUE;
6230+ else
6231+ {
6232+ cur = wp->w_match_head;
6233+ while (cur != NULL)
6234+ {
6235+ if (prevcol == (long)cur->hl.startcol)
6236+ {
6237+ prevcol_hl_flag = TRUE;
6238+ break;
6239+ }
6240+ cur = cur->next;
6241+ }
6242+ }
6243+#endif
6244 if (lcs_eol == lcs_eol_one
6245 && ((area_attr != 0 && vcol == fromcol && c == NUL)
6246 #ifdef FEAT_SEARCH_EXTRA
6247 /* highlight 'hlsearch' match at end of line */
6248- || ((prevcol == (long)search_hl.startcol
6249- || prevcol == (long)match_hl[0].startcol
6250- || prevcol == (long)match_hl[1].startcol
6251- || prevcol == (long)match_hl[2].startcol)
6252+ || (prevcol_hl_flag == TRUE
6253 # if defined(LINE_ATTR)
6254 && did_line_attr <= 1
6255 # endif
[c2aa910]6256@@ -4302,15 +4381,27 @@
[ba61c16]6257 #ifdef FEAT_SEARCH_EXTRA
6258 if (area_attr == 0)
6259 {
6260- for (i = 0; i <= 3; ++i)
6261- {
6262- if (i == 3)
6263- char_attr = search_hl.attr;
6264- else if ((ptr - line) - 1 == (long)match_hl[i].startcol)
6265+ /* Use attributes from match with highest priority among
6266+ * 'search_hl' and the match list. */
6267+ char_attr = search_hl.attr;
6268+ cur = wp->w_match_head;
6269+ shl_flag = FALSE;
6270+ while (cur != NULL || shl_flag == FALSE)
6271+ {
6272+ if (shl_flag == FALSE
6273+ && ((cur != NULL
6274+ && cur->priority > SEARCH_HL_PRIORITY)
6275+ || cur == NULL))
6276 {
6277- char_attr = match_hl[i].attr;
6278- break;
6279+ shl = &search_hl;
6280+ shl_flag = TRUE;
6281 }
6282+ else
6283+ shl = &cur->hl;
6284+ if ((ptr - line) - 1 == (long)shl->startcol)
6285+ char_attr = shl->attr;
6286+ if (shl != &search_hl && cur != NULL)
6287+ cur = cur->next;
6288 }
6289 }
6290 #endif
[c2aa910]6291@@ -4460,6 +4551,8 @@
[ba61c16]6292 {
6293 if (mb_utf8)
6294 {
6295+ int i;
6296+
6297 ScreenLinesUC[off] = mb_c;
6298 if ((c & 0xff) == 0)
6299 ScreenLines[off] = 0x80; /* avoid storing zero */
[c2aa910]6300@@ -4548,7 +4641,7 @@
[ba61c16]6301
6302 /*
6303 * At end of screen line and there is more to come: Display the line
6304- * so far. If there is no more to display it is catched above.
6305+ * so far. If there is no more to display it is caught above.
6306 */
6307 if ((
6308 #ifdef FEAT_RIGHTLEFT
[c2aa910]6309@@ -4625,9 +4718,13 @@
[ba61c16]6310 #endif
6311 #ifdef FEAT_MBYTE
6312 && !(has_mbyte
6313- && ((*mb_off2cells)(LineOffset[screen_row]) == 2
6314+ && ((*mb_off2cells)(LineOffset[screen_row],
6315+ LineOffset[screen_row] + screen_Columns)
6316+ == 2
6317 || (*mb_off2cells)(LineOffset[screen_row - 1]
6318- + (int)Columns - 2) == 2))
6319+ + (int)Columns - 2,
6320+ LineOffset[screen_row] + screen_Columns)
6321+ == 2))
6322 #endif
6323 )
6324 {
[c2aa910]6325@@ -4787,6 +4884,10 @@
[ba61c16]6326 {
6327 unsigned off_from;
6328 unsigned off_to;
6329+#ifdef FEAT_MBYTE
6330+ unsigned max_off_from;
6331+ unsigned max_off_to;
6332+#endif
6333 int col = 0;
6334 #if defined(FEAT_GUI) || defined(UNIX) || defined(FEAT_VERTSPLIT)
6335 int hl;
[c2aa910]6336@@ -4813,6 +4914,10 @@
[ba61c16]6337
6338 off_from = (unsigned)(current_ScreenLine - ScreenLines);
6339 off_to = LineOffset[row] + coloff;
6340+#ifdef FEAT_MBYTE
6341+ max_off_from = off_from + screen_Columns;
6342+ max_off_to = LineOffset[row] + screen_Columns;
6343+#endif
6344
6345 #ifdef FEAT_RIGHTLEFT
6346 if (rlflag)
[c2aa910]6347@@ -4847,7 +4952,7 @@
[ba61c16]6348 {
6349 #ifdef FEAT_MBYTE
6350 if (has_mbyte && (col + 1 < endcol))
6351- char_cells = (*mb_off2cells)(off_from);
6352+ char_cells = (*mb_off2cells)(off_from, max_off_from);
6353 else
6354 char_cells = 1;
6355 #endif
[c2aa910]6356@@ -4924,7 +5029,7 @@
[ba61c16]6357 * ScreenLinesUC[] is sufficient. */
6358 if (char_cells == 1
6359 && col + 1 < endcol
6360- && (*mb_off2cells)(off_to) > 1)
6361+ && (*mb_off2cells)(off_to, max_off_to) > 1)
6362 {
6363 /* Writing a single-cell character over a double-cell
6364 * character: need to redraw the next cell. */
[c2aa910]6365@@ -4933,8 +5038,8 @@
[ba61c16]6366 }
6367 else if (char_cells == 2
6368 && col + 2 < endcol
6369- && (*mb_off2cells)(off_to) == 1
6370- && (*mb_off2cells)(off_to + 1) > 1)
6371+ && (*mb_off2cells)(off_to, max_off_to) == 1
6372+ && (*mb_off2cells)(off_to + 1, max_off_to) > 1)
6373 {
6374 /* Writing the second half of a double-cell character over
6375 * a double-cell character: need to redraw the second
[c2aa910]6376@@ -4953,10 +5058,10 @@
[ba61c16]6377 * char over the left halve of an existing one. */
6378 if (has_mbyte && col + char_cells == endcol
6379 && ((char_cells == 1
6380- && (*mb_off2cells)(off_to) > 1)
6381+ && (*mb_off2cells)(off_to, max_off_to) > 1)
6382 || (char_cells == 2
6383- && (*mb_off2cells)(off_to) == 1
6384- && (*mb_off2cells)(off_to + 1) > 1)))
6385+ && (*mb_off2cells)(off_to, max_off_to) == 1
6386+ && (*mb_off2cells)(off_to + 1, max_off_to) > 1)))
6387 clear_next = TRUE;
6388 #endif
6389
[c2aa910]6390@@ -5096,10 +5201,11 @@
[ba61c16]6391 /* find previous character by counting from first
6392 * column and get its width. */
6393 unsigned off = LineOffset[row];
6394+ unsigned max_off = LineOffset[row] + screen_Columns;
6395
6396 while (off < off_to)
6397 {
6398- prev_cells = (*mb_off2cells)(off);
6399+ prev_cells = (*mb_off2cells)(off, max_off);
6400 off += prev_cells;
6401 }
6402 }
[c2aa910]6403@@ -5285,7 +5391,7 @@
[ba61c16]6404 static int skip_status_match_char __ARGS((expand_T *xp, char_u *s));
6405
6406 /*
6407- * Get the lenght of an item as it will be shown in the status line.
6408+ * Get the length of an item as it will be shown in the status line.
6409 */
6410 static int
6411 status_match_len(xp, s)
[c2aa910]6412@@ -5351,7 +5457,7 @@
[ba61c16]6413 int row;
6414 char_u *buf;
6415 int len;
6416- int clen; /* lenght in screen cells */
6417+ int clen; /* length in screen cells */
6418 int fillchar;
6419 int attr;
6420 int i;
[c2aa910]6421@@ -6103,6 +6209,7 @@
[ba61c16]6422 char_u *ptr = text;
6423 int c;
6424 #ifdef FEAT_MBYTE
6425+ unsigned max_off;
6426 int mbyte_blen = 1;
6427 int mbyte_cells = 1;
6428 int u8c = 0;
[c2aa910]6429@@ -6119,8 +6226,12 @@
[ba61c16]6430 return;
6431
6432 off = LineOffset[row] + col;
6433- while (*ptr != NUL && col < screen_Columns
6434- && (len < 0 || (int)(ptr - text) < len))
6435+#ifdef FEAT_MBYTE
6436+ max_off = LineOffset[row] + screen_Columns;
6437+#endif
6438+ while (col < screen_Columns
6439+ && (len < 0 || (int)(ptr - text) < len)
6440+ && *ptr != NUL)
6441 {
6442 c = *ptr;
6443 #ifdef FEAT_MBYTE
[c2aa910]6444@@ -6143,6 +6254,7 @@
6445 else
6446 u8c = utfc_ptr2char(ptr, u8cc);
6447 mbyte_cells = utf_char2cells(u8c);
6448+# ifdef UNICODE16
6449 /* Non-BMP character: display as ? or fullwidth ?. */
6450 if (u8c >= 0x10000)
6451 {
6452@@ -6150,6 +6262,7 @@
6453 if (attr == 0)
6454 attr = hl_attr(HLF_8);
6455 }
6456+# endif
6457 # ifdef FEAT_ARABIC
6458 if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c))
6459 {
6460@@ -6241,19 +6354,19 @@
[ba61c16]6461 else if (has_mbyte
6462 && (len < 0 ? ptr[mbyte_blen] == NUL
6463 : ptr + mbyte_blen >= text + len)
6464- && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
6465+ && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
6466 || (mbyte_cells == 2
6467- && (*mb_off2cells)(off) == 1
6468- && (*mb_off2cells)(off + 1) > 1)))
6469+ && (*mb_off2cells)(off, max_off) == 1
6470+ && (*mb_off2cells)(off + 1, max_off) > 1)))
6471 clear_next_cell = TRUE;
6472
6473 /* Make sure we never leave a second byte of a double-byte behind,
6474 * it confuses mb_off2cells(). */
6475 if (enc_dbcs
6476- && ((mbyte_cells == 1 && (*mb_off2cells)(off) > 1)
6477+ && ((mbyte_cells == 1 && (*mb_off2cells)(off, max_off) > 1)
6478 || (mbyte_cells == 2
6479- && (*mb_off2cells)(off) == 1
6480- && (*mb_off2cells)(off + 1) > 1)))
6481+ && (*mb_off2cells)(off, max_off) == 1
6482+ && (*mb_off2cells)(off + 1, max_off) > 1)))
6483 ScreenLines[off + mbyte_blen] = 0;
6484 #endif
6485 ScreenLines[off] = c;
[c2aa910]6486@@ -6318,7 +6431,7 @@
[ba61c16]6487
6488 #ifdef FEAT_SEARCH_EXTRA
6489 /*
6490- * Prepare for 'searchhl' highlighting.
6491+ * Prepare for 'hlsearch' highlighting.
6492 */
6493 static void
6494 start_search_hl()
[c2aa910]6495@@ -6331,7 +6444,7 @@
[ba61c16]6496 }
6497
6498 /*
6499- * Clean up for 'searchhl' highlighting.
6500+ * Clean up for 'hlsearch' highlighting.
6501 */
6502 static void
6503 end_search_hl()
[c2aa910]6504@@ -6351,18 +6464,28 @@
[ba61c16]6505 win_T *wp;
6506 linenr_T lnum;
6507 {
6508- match_T *shl; /* points to search_hl or match_hl */
6509+ matchitem_T *cur; /* points to the match list */
6510+ match_T *shl; /* points to search_hl or a match */
6511+ int shl_flag; /* flag to indicate whether search_hl
6512+ has been processed or not */
6513 int n;
6514- int i;
6515
6516 /*
6517 * When using a multi-line pattern, start searching at the top
6518 * of the window or just after a closed fold.
6519- * Do this both for search_hl and match_hl[3].
6520+ * Do this both for search_hl and the match list.
6521 */
6522- for (i = 3; i >= 0; --i)
6523+ cur = wp->w_match_head;
6524+ shl_flag = FALSE;
6525+ while (cur != NULL || shl_flag == FALSE)
6526 {
6527- shl = (i == 3) ? &search_hl : &match_hl[i];
6528+ if (shl_flag == FALSE)
6529+ {
6530+ shl = &search_hl;
6531+ shl_flag = TRUE;
6532+ }
6533+ else
6534+ shl = &cur->hl;
6535 if (shl->rm.regprog != NULL
6536 && shl->lnum == 0
6537 && re_multiline(shl->rm.regprog))
[c2aa910]6538@@ -6397,11 +6520,13 @@
[ba61c16]6539 }
6540 }
6541 }
6542+ if (shl != &search_hl && cur != NULL)
6543+ cur = cur->next;
6544 }
6545 }
6546
6547 /*
6548- * Search for a next 'searchl' or ":match" match.
6549+ * Search for a next 'hlsearch' or match.
6550 * Uses shl->buf.
6551 * Sets shl->lnum and shl->rm contents.
6552 * Note: Assumes a previous match is always before "lnum", unless
[c2aa910]6553@@ -6411,7 +6536,7 @@
[ba61c16]6554 static void
6555 next_search_hl(win, shl, lnum, mincol)
6556 win_T *win;
6557- match_T *shl; /* points to search_hl or match_hl */
6558+ match_T *shl; /* points to search_hl or a match */
6559 linenr_T lnum;
6560 colnr_T mincol; /* minimal column for a match */
6561 {
[c2aa910]6562@@ -6479,7 +6604,7 @@
[ba61c16]6563 /* Error while handling regexp: stop using this regexp. */
6564 if (shl == &search_hl)
6565 {
6566- /* don't free the regprog in match_hl[], it's a copy */
6567+ /* don't free regprog in the match list, it's a copy */
6568 vim_free(shl->rm.regprog);
6569 no_hlsearch = TRUE;
6570 }
[c2aa910]6571@@ -6827,6 +6952,9 @@
[ba61c16]6572 {
6573 int r, c;
6574 int off;
6575+#ifdef FEAT_MBYTE
6576+ int max_off;
6577+#endif
6578
6579 /* Can't use ScreenLines unless initialized */
6580 if (ScreenLines == NULL)
[c2aa910]6581@@ -6837,10 +6965,13 @@
[ba61c16]6582 for (r = row; r < row + height; ++r)
6583 {
6584 off = LineOffset[r];
6585+#ifdef FEAT_MBYTE
6586+ max_off = off + screen_Columns;
6587+#endif
6588 for (c = col; c < col + width; ++c)
6589 {
6590 #ifdef FEAT_MBYTE
6591- if (enc_dbcs != 0 && dbcs_off2cells(off + c) > 1)
6592+ if (enc_dbcs != 0 && dbcs_off2cells(off + c, max_off) > 1)
6593 {
6594 screen_char_2(off + c, r, c);
6595 ++c;
[c2aa910]6596@@ -6850,7 +6981,7 @@
[ba61c16]6597 {
6598 screen_char(off + c, r, c);
6599 #ifdef FEAT_MBYTE
6600- if (utf_off2cells(off + c) > 1)
6601+ if (utf_off2cells(off + c, max_off) > 1)
6602 ++c;
6603 #endif
6604 }
6605diff -Naur vim71.orig/src/search.c vim71/src/search.c
6606--- vim71.orig/src/search.c 2007-05-07 12:42:02.000000000 -0700
[2830f42]6607+++ vim71/src/search.c 2007-10-29 08:09:18.000000000 -0700
[ba61c16]6608@@ -101,7 +101,6 @@
6609 static char_u *mr_pattern = NULL; /* pattern used by search_regcomp() */
6610 #ifdef FEAT_RIGHTLEFT
6611 static int mr_pattern_alloced = FALSE; /* mr_pattern was allocated */
6612-static char_u *reverse_text __ARGS((char_u *s));
6613 #endif
6614
6615 #ifdef FEAT_FIND_ID
6616@@ -228,12 +227,12 @@
6617 return mr_pattern;
6618 }
6619
6620-#ifdef FEAT_RIGHTLEFT
6621+#if defined(FEAT_RIGHTLEFT) || defined(PROTO)
6622 /*
6623 * Reverse text into allocated memory.
6624 * Returns the allocated string, NULL when out of memory.
6625 */
6626- static char_u *
6627+ char_u *
6628 reverse_text(s)
6629 char_u *s;
6630 {
6631@@ -573,8 +572,12 @@
6632 /*
6633 * Start searching in current line, unless searching backwards and
6634 * we're in column 0.
6635+ * If we are searching backwards, in column 0, and not including the
6636+ * current position, gain some efficiency by skipping back a line.
6637+ * Otherwise begin the search in the current line.
6638 */
6639- if (dir == BACKWARD && start_pos.col == 0)
6640+ if (dir == BACKWARD && start_pos.col == 0
6641+ && (options & SEARCH_START) == 0)
6642 {
6643 lnum = pos->lnum - 1;
6644 at_first_line = FALSE;
6645@@ -1894,7 +1897,7 @@
6646 }
6647
6648 #ifdef FEAT_RIGHTLEFT
6649- /* This is just guessing: when 'rightleft' is set, search for a maching
6650+ /* This is just guessing: when 'rightleft' is set, search for a matching
6651 * paren/brace in the other direction. */
6652 if (curwin->w_p_rl && vim_strchr((char_u *)"()[]{}<>", initc) != NULL)
6653 backwards = !backwards;
6654@@ -2124,6 +2127,9 @@
6655 else if (!backwards)
6656 inquote = TRUE;
6657 }
6658+
6659+ /* ml_get() only keeps one line, need to get linep again */
6660+ linep = ml_get(pos.lnum);
6661 }
6662 }
6663 }
6664@@ -2795,7 +2801,7 @@
6665 i = inc_cursor();
6666 if (i == -1 || (i >= 1 && last_line)) /* started at last char in file */
6667 return FAIL;
6668- if (i == 1 && eol && count == 0) /* started at last char in line */
6669+ if (i >= 1 && eol && count == 0) /* started at last char in line */
6670 return OK;
6671
6672 /*
6673@@ -3600,13 +3606,16 @@
6674 {
6675 oap->start = start_pos;
6676 oap->motion_type = MCHAR;
6677+ oap->inclusive = FALSE;
6678 if (sol)
6679- {
6680 incl(&curwin->w_cursor);
6681- oap->inclusive = FALSE;
6682- }
6683- else
6684+ else if (lt(start_pos, curwin->w_cursor))
6685+ /* Include the character under the cursor. */
6686 oap->inclusive = TRUE;
6687+ else
6688+ /* End is before the start (no text in between <>, [], etc.): don't
6689+ * operate on any text. */
6690+ curwin->w_cursor = start_pos;
6691 }
6692
6693 return OK;
6694@@ -3734,7 +3743,7 @@
6695
6696 if (in_html_tag(FALSE))
6697 {
6698- /* cursor on start tag, move to just after it */
6699+ /* cursor on start tag, move to its '>' */
6700 while (*ml_get_cursor() != '>')
6701 if (inc_cursor() < 0)
6702 break;
6703@@ -3838,7 +3847,7 @@
6704 /* Exclude the start tag. */
6705 curwin->w_cursor = start_pos;
6706 while (inc_cursor() >= 0)
6707- if (*ml_get_cursor() == '>' && lt(curwin->w_cursor, end_pos))
6708+ if (*ml_get_cursor() == '>')
6709 {
6710 inc_cursor();
6711 start_pos = curwin->w_cursor;
6712@@ -3860,7 +3869,11 @@
6713 #ifdef FEAT_VISUAL
6714 if (VIsual_active)
6715 {
6716- if (*p_sel == 'e')
6717+ /* If the end is before the start there is no text between tags, select
6718+ * the char under the cursor. */
6719+ if (lt(end_pos, start_pos))
6720+ curwin->w_cursor = start_pos;
6721+ else if (*p_sel == 'e')
6722 ++curwin->w_cursor.col;
6723 VIsual = start_pos;
6724 VIsual_mode = 'v';
6725@@ -3872,7 +3885,15 @@
6726 {
6727 oap->start = start_pos;
6728 oap->motion_type = MCHAR;
6729- oap->inclusive = TRUE;
6730+ if (lt(end_pos, start_pos))
6731+ {
6732+ /* End is before the start: there is no text between tags; operate
6733+ * on an empty area. */
6734+ curwin->w_cursor = start_pos;
6735+ oap->inclusive = FALSE;
6736+ }
6737+ else
6738+ oap->inclusive = TRUE;
6739 }
6740 retval = OK;
6741
6742diff -Naur vim71.orig/src/spell.c vim71/src/spell.c
6743--- vim71.orig/src/spell.c 2007-05-07 12:48:38.000000000 -0700
[2830f42]6744+++ vim71/src/spell.c 2007-10-29 08:09:18.000000000 -0700
[ba61c16]6745@@ -7829,7 +7829,7 @@
6746 # if (_MSC_VER <= 1200)
6747 /* This line is required for VC6 without the service pack. Also see the
6748 * matching #pragma below. */
6749-/* # pragma optimize("", off) */
6750+ # pragma optimize("", off)
6751 # endif
6752 #endif
6753
6754@@ -7859,7 +7859,7 @@
6755
6756 #ifdef _MSC_VER
6757 # if (_MSC_VER <= 1200)
6758-/* # pragma optimize("", on) */
6759+ # pragma optimize("", on)
6760 # endif
6761 #endif
6762
6763@@ -12182,7 +12182,9 @@
6764 {
6765 n = mb_cptr2len(p);
6766 c = mb_ptr2char(p);
6767- if (!soundfold && !spell_iswordp(p + n, curbuf))
6768+ if (p[n] == NUL)
6769+ c2 = NUL;
6770+ else if (!soundfold && !spell_iswordp(p + n, curbuf))
6771 c2 = c; /* don't swap non-word char */
6772 else
6773 c2 = mb_ptr2char(p + n);
6774@@ -12190,12 +12192,21 @@
6775 else
6776 #endif
6777 {
6778- if (!soundfold && !spell_iswordp(p + 1, curbuf))
6779+ if (p[1] == NUL)
6780+ c2 = NUL;
6781+ else if (!soundfold && !spell_iswordp(p + 1, curbuf))
6782 c2 = c; /* don't swap non-word char */
6783 else
6784 c2 = p[1];
6785 }
6786
6787+ /* When the second character is NUL we can't swap. */
6788+ if (c2 == NUL)
6789+ {
6790+ sp->ts_state = STATE_REP_INI;
6791+ break;
6792+ }
6793+
6794 /* When characters are identical, swap won't do anything.
6795 * Also get here if the second char is not a word character. */
6796 if (c == c2)
6797diff -Naur vim71.orig/src/structs.h vim71/src/structs.h
6798--- vim71.orig/src/structs.h 2007-05-07 12:50:49.000000000 -0700
[2830f42]6799+++ vim71/src/structs.h 2007-10-29 08:09:48.000000000 -0700
[c2aa910]6800@@ -278,6 +278,9 @@
6801 linenr_T ue_lcount; /* linecount when u_save called */
6802 char_u **ue_array; /* array of lines in undo block */
6803 long ue_size; /* number of lines in ue_array */
6804+#ifdef U_DEBUG
6805+ int ue_magic; /* magic number to check allocation */
6806+#endif
6807 };
6808
6809 struct u_header
6810@@ -300,6 +303,9 @@
6811 visualinfo_T uh_visual; /* Visual areas before undo/after redo */
6812 #endif
6813 time_t uh_time; /* timestamp when the change was made */
6814+#ifdef U_DEBUG
6815+ int uh_magic; /* magic number to check allocation */
6816+#endif
6817 };
6818
6819 /* values for uh_flags */
6820@@ -1453,6 +1459,7 @@
[ba61c16]6821 #ifdef FEAT_MBYTE
6822 char_u *b_start_fenc; /* 'fileencoding' when edit started or NULL */
6823 int b_bad_char; /* "++bad=" argument when edit started or 0 */
6824+ int b_start_bomb; /* 'bomb' when it was read */
6825 #endif
6826
6827 #ifdef FEAT_EVAL
[c2aa910]6828@@ -1694,6 +1701,41 @@
[ba61c16]6829 #define FR_COL 2 /* frame with a column of windows */
6830
6831 /*
6832+ * Struct used for highlighting 'hlsearch' matches, matches defined by
6833+ * ":match" and matches defined by match functions.
6834+ * For 'hlsearch' there is one pattern for all windows. For ":match" and the
6835+ * match functions there is a different pattern for each window.
6836+ */
6837+typedef struct
6838+{
6839+ regmmatch_T rm; /* points to the regexp program; contains last found
6840+ match (may continue in next line) */
6841+ buf_T *buf; /* the buffer to search for a match */
6842+ linenr_T lnum; /* the line to search for a match */
6843+ int attr; /* attributes to be used for a match */
6844+ int attr_cur; /* attributes currently active in win_line() */
6845+ linenr_T first_lnum; /* first lnum to search for multi-line pat */
6846+ colnr_T startcol; /* in win_line() points to char where HL starts */
6847+ colnr_T endcol; /* in win_line() points to char where HL ends */
6848+} match_T;
6849+
6850+/*
6851+ * matchitem_T provides a linked list for storing match items for ":match" and
6852+ * the match functions.
6853+ */
6854+typedef struct matchitem matchitem_T;
6855+struct matchitem
6856+{
6857+ matchitem_T *next;
6858+ int id; /* match ID */
6859+ int priority; /* match priority */
6860+ char_u *pattern; /* pattern to highlight */
6861+ int hlg_id; /* highlight group ID */
6862+ regmmatch_T match; /* regexp program for pattern */
6863+ match_T hl; /* struct for doing the actual highlighting */
6864+};
6865+
6866+/*
6867 * Structure which contains all information that belongs to a window
6868 *
6869 * All row numbers are relative to the start of the window, except w_winrow.
[c2aa910]6870@@ -1934,9 +1976,8 @@
[ba61c16]6871 #endif
6872
6873 #ifdef FEAT_SEARCH_EXTRA
6874- regmmatch_T w_match[3]; /* regexp programs for ":match" */
6875- char_u *(w_match_pat[3]); /* patterns for ":match" */
6876- int w_match_id[3]; /* highlight IDs for ":match" */
6877+ matchitem_T *w_match_head; /* head of match list */
6878+ int w_next_match_id; /* next match ID */
6879 #endif
6880
6881 /*
6882diff -Naur vim71.orig/src/syntax.c vim71/src/syntax.c
6883--- vim71.orig/src/syntax.c 2007-05-07 12:42:55.000000000 -0700
[2830f42]6884+++ vim71/src/syntax.c 2007-10-29 08:09:51.000000000 -0700
[ba61c16]6885@@ -66,8 +66,10 @@
6886 #define HL_TABLE() ((struct hl_group *)((highlight_ga.ga_data)))
6887
6888 #ifdef FEAT_CMDL_COMPL
6889-static int include_default = FALSE; /* include "default" for expansion */
6890-static int include_link = FALSE; /* include "link" for expansion */
6891+/* Flags to indicate an additional string for highlight name completion. */
6892+static int include_none = 0; /* when 1 include "None" */
6893+static int include_default = 0; /* when 1 include "default" */
6894+static int include_link = 0; /* when 2 include "link" and "clear" */
6895 #endif
6896
6897 /*
6898@@ -277,7 +279,8 @@
6899 */
6900 typedef struct state_item
6901 {
6902- int si_idx; /* index of syntax pattern */
6903+ int si_idx; /* index of syntax pattern or
6904+ KEYWORD_IDX */
6905 int si_id; /* highlight group ID for keywords */
6906 int si_trans_id; /* idem, transparancy removed */
6907 int si_m_lnum; /* lnum of the match */
6908@@ -835,9 +838,18 @@
6909 current_lnum = end_lnum;
6910 break;
6911 }
6912- spp = &(SYN_ITEMS(syn_buf)[cur_si->si_idx]);
6913- found_flags = spp->sp_flags;
6914- found_match_idx = spp->sp_sync_idx;
6915+ if (cur_si->si_idx < 0)
6916+ {
6917+ /* Cannot happen? */
6918+ found_flags = 0;
6919+ found_match_idx = KEYWORD_IDX;
6920+ }
6921+ else
6922+ {
6923+ spp = &(SYN_ITEMS(syn_buf)[cur_si->si_idx]);
6924+ found_flags = spp->sp_flags;
6925+ found_match_idx = spp->sp_sync_idx;
6926+ }
6927 found_current_lnum = current_lnum;
6928 found_current_col = current_col;
6929 found_m_endpos = cur_si->si_m_endpos;
6930@@ -1725,6 +1737,13 @@
6931 {
6932 int attr = 0;
6933
6934+ if (can_spell != NULL)
6935+ /* Default: Only do spelling when there is no @Spell cluster or when
6936+ * ":syn spell toplevel" was used. */
6937+ *can_spell = syn_buf->b_syn_spell == SYNSPL_DEFAULT
6938+ ? (syn_buf->b_spell_cluster_id == 0)
6939+ : (syn_buf->b_syn_spell == SYNSPL_TOP);
6940+
6941 /* check for out of memory situation */
6942 if (syn_buf->b_sst_array == NULL)
6943 return 0;
6944@@ -2524,6 +2543,10 @@
6945 stateitem_T *sip = &CUR_STATE(idx);
6946 synpat_T *spp;
6947
6948+ /* This should not happen... */
6949+ if (sip->si_idx < 0)
6950+ return;
6951+
6952 spp = &(SYN_ITEMS(syn_buf)[sip->si_idx]);
6953 if (sip->si_flags & HL_MATCH)
6954 sip->si_id = spp->sp_syn_match_id;
6955@@ -2639,6 +2662,10 @@
6956 lpos_T end_endpos;
6957 int end_idx;
6958
6959+ /* return quickly for a keyword */
6960+ if (sip->si_idx < 0)
6961+ return;
6962+
6963 /* Don't update when it's already done. Can be a match of an end pattern
6964 * that started in a previous line. Watch out: can also be a "keepend"
6965 * from a containing item. */
6966@@ -2751,6 +2778,10 @@
6967 char_u *line;
6968 int had_match = FALSE;
6969
6970+ /* just in case we are invoked for a keyword */
6971+ if (idx < 0)
6972+ return;
6973+
6974 /*
6975 * Check for being called with a START pattern.
6976 * Can happen with a match that continues to the next line, because it
[c2aa910]6977@@ -3323,6 +3354,7 @@
6978 {
6979 vim_free(SYN_ITEMS(buf)[i].sp_cont_list);
6980 vim_free(SYN_ITEMS(buf)[i].sp_next_list);
6981+ vim_free(SYN_ITEMS(buf)[i].sp_syn.cont_in_list);
6982 }
6983 }
6984
6985@@ -4460,8 +4492,8 @@
[ba61c16]6986 current_syn_inc_tag = ++running_syn_inc_tag;
6987 prev_toplvl_grp = curbuf->b_syn_topgrp;
6988 curbuf->b_syn_topgrp = sgl_id;
6989- if (source ? do_source(eap->arg, FALSE, FALSE) == FAIL
6990- : source_runtime(eap->arg, DOSO_NONE) == FAIL)
6991+ if (source ? do_source(eap->arg, FALSE, DOSO_NONE) == FAIL
6992+ : source_runtime(eap->arg, TRUE) == FAIL)
6993 EMSG2(_(e_notopen), eap->arg);
6994 curbuf->b_syn_topgrp = prev_toplvl_grp;
6995 current_syn_inc_tag = prev_syn_inc_tag;
[c2aa910]6996@@ -5956,8 +5988,8 @@
[ba61c16]6997 {
6998 return (buf->b_syn_patterns.ga_len != 0
6999 || buf->b_syn_clusters.ga_len != 0
7000- || curbuf->b_keywtab.ht_used > 0
7001- || curbuf->b_keywtab_ic.ht_used > 0);
7002+ || buf->b_keywtab.ht_used > 0
7003+ || buf->b_keywtab_ic.ht_used > 0);
7004 }
7005
7006 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
[c2aa910]7007@@ -5968,6 +6000,29 @@
[ba61c16]7008 EXP_CASE /* expand ":syn case" arguments */
7009 } expand_what;
7010
7011+/*
7012+ * Reset include_link, include_default, include_none to 0.
7013+ * Called when we are done expanding.
7014+ */
7015+ void
7016+reset_expand_highlight()
7017+{
7018+ include_link = include_default = include_none = 0;
7019+}
7020+
7021+/*
7022+ * Handle command line completion for :match and :echohl command: Add "None"
7023+ * as highlight group.
7024+ */
7025+ void
7026+set_context_in_echohl_cmd(xp, arg)
7027+ expand_T *xp;
7028+ char_u *arg;
7029+{
7030+ xp->xp_context = EXPAND_HIGHLIGHT;
7031+ xp->xp_pattern = arg;
7032+ include_none = 1;
7033+}
7034
7035 /*
7036 * Handle command line completion for :syntax command.
[c2aa910]7037@@ -5983,8 +6038,8 @@
[ba61c16]7038 xp->xp_context = EXPAND_SYNTAX;
7039 expand_what = EXP_SUBCMD;
7040 xp->xp_pattern = arg;
7041- include_link = FALSE;
7042- include_default = FALSE;
7043+ include_link = 0;
7044+ include_default = 0;
7045
7046 /* (part of) subcommand already typed */
7047 if (*arg != NUL)
[c2aa910]7048@@ -8479,7 +8534,7 @@
[ba61c16]7049 syn_id2name(id)
7050 int id;
7051 {
7052- if (id <= 0 || id >= highlight_ga.ga_len)
7053+ if (id <= 0 || id > highlight_ga.ga_len)
7054 return (char_u *)"";
7055 return HL_TABLE()[id - 1].sg_name;
7056 }
[c2aa910]7057@@ -8949,7 +9004,7 @@
[ba61c16]7058 return OK;
7059 }
7060
7061-#ifdef FEAT_CMDL_COMPL
7062+#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
7063
7064 static void highlight_list __ARGS((void));
7065 static void highlight_list_two __ARGS((int cnt, int attr));
[c2aa910]7066@@ -8967,8 +9022,8 @@
[ba61c16]7067 /* Default: expand group names */
7068 xp->xp_context = EXPAND_HIGHLIGHT;
7069 xp->xp_pattern = arg;
7070- include_link = TRUE;
7071- include_default = TRUE;
7072+ include_link = 2;
7073+ include_default = 1;
7074
7075 /* (part of) subcommand already typed */
7076 if (*arg != NUL)
[c2aa910]7077@@ -8976,7 +9031,7 @@
[ba61c16]7078 p = skiptowhite(arg);
7079 if (*p != NUL) /* past "default" or group name */
7080 {
7081- include_default = FALSE;
7082+ include_default = 0;
7083 if (STRNCMP("default", arg, p - arg) == 0)
7084 {
7085 arg = skipwhite(p);
[c2aa910]7086@@ -8985,7 +9040,7 @@
[ba61c16]7087 }
7088 if (*p != NUL) /* past group name */
7089 {
7090- include_link = FALSE;
7091+ include_link = 0;
7092 if (arg[1] == 'i' && arg[0] == 'N')
7093 highlight_list();
7094 if (STRNCMP("link", arg, p - arg) == 0
[c2aa910]7095@@ -9045,31 +9100,25 @@
[ba61c16]7096 expand_T *xp;
7097 int idx;
7098 {
7099- if (idx == highlight_ga.ga_len
7100 #ifdef FEAT_CMDL_COMPL
7101- && include_link
7102-#endif
7103- )
7104+ if (idx == highlight_ga.ga_len && include_none != 0)
7105+ return (char_u *)"none";
7106+ if (idx == highlight_ga.ga_len + include_none && include_default != 0)
7107+ return (char_u *)"default";
7108+ if (idx == highlight_ga.ga_len + include_none + include_default
7109+ && include_link != 0)
7110 return (char_u *)"link";
7111- if (idx == highlight_ga.ga_len + 1
7112-#ifdef FEAT_CMDL_COMPL
7113- && include_link
7114-#endif
7115- )
7116+ if (idx == highlight_ga.ga_len + include_none + include_default + 1
7117+ && include_link != 0)
7118 return (char_u *)"clear";
7119- if (idx == highlight_ga.ga_len + 2
7120-#ifdef FEAT_CMDL_COMPL
7121- && include_default
7122 #endif
7123- )
7124- return (char_u *)"default";
7125 if (idx < 0 || idx >= highlight_ga.ga_len)
7126 return NULL;
7127 return HL_TABLE()[idx].sg_name;
7128 }
7129 #endif
7130
7131-#ifdef FEAT_GUI
7132+#if defined(FEAT_GUI) || defined(PROTO)
7133 /*
7134 * Free all the highlight group fonts.
7135 * Used when quitting for systems which need it.
[c2aa910]7136diff -Naur vim71.orig/src/term.c vim71/src/term.c
7137--- vim71.orig/src/term.c 2007-05-07 12:39:11.000000000 -0700
[2830f42]7138+++ vim71/src/term.c 2007-10-29 08:09:37.000000000 -0700
[c2aa910]7139@@ -4809,6 +4809,8 @@
7140 if (num_bytes == -1)
7141 return -1;
7142 current_tab = (int)bytes[0];
7143+ if (current_tab == 255) /* -1 in a byte gives 255 */
7144+ current_tab = -1;
7145 slen += num_bytes;
7146 }
7147 else if (key_name[0] == (int)KS_TABMENU)
[ba61c16]7148diff -Naur vim71.orig/src/termlib.c vim71/src/termlib.c
7149--- vim71.orig/src/termlib.c 2007-05-07 12:39:49.000000000 -0700
[2830f42]7150+++ vim71/src/termlib.c 2007-10-29 08:09:18.000000000 -0700
[ba61c16]7151@@ -191,7 +191,7 @@
7152 lbuf[0] == '\t' &&
7153 lbuf[1] == ':')
7154 {
7155- strcpy(lbuf, lbuf+2);
7156+ mch_memmove(lbuf, lbuf + 2, strlen(lbuf + 2) + 1);
7157 llen -= 2;
7158 }
7159 if (lbuf[llen-2] == '\\') /* and continuations */
7160diff -Naur vim71.orig/src/testdir/Makefile vim71/src/testdir/Makefile
7161--- vim71.orig/src/testdir/Makefile 2006-04-30 04:08:01.000000000 -0700
[2830f42]7162+++ vim71/src/testdir/Makefile 2007-10-29 08:09:38.000000000 -0700
[ba61c16]7163@@ -1,9 +1,13 @@
7164 #
7165-# Makefile to run al tests for Vim
7166+# Makefile to run all tests for Vim
7167 #
7168
7169 VIMPROG = ../vim
7170
7171+# Uncomment this line for using valgrind.
7172+# The output goes into a file "valgrind.$PID" (sorry, no test number).
[c2aa910]7173+# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --logfile=valgrind
[ba61c16]7174+
7175 SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
7176 test7.out test8.out test9.out test10.out test11.out \
7177 test12.out test13.out test14.out test15.out test17.out \
7178@@ -15,7 +19,8 @@
7179 test43.out test44.out test45.out test46.out test47.out \
7180 test48.out test49.out test51.out test52.out test53.out \
7181 test54.out test55.out test56.out test57.out test58.out \
7182- test59.out test60.out test61.out test62.out
7183+ test59.out test60.out test61.out test62.out test63.out \
7184+ test64.out
7185
7186 SCRIPTS_GUI = test16.out
7187
[c2aa910]7188@@ -34,11 +39,11 @@
7189 $(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG)
7190
7191 clean:
7192- -rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim test.ok X* viminfo
7193+ -rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim test.ok X* valgrind.pid* viminfo
[ba61c16]7194
7195 test1.out: test1.in
7196 -rm -f $*.failed tiny.vim small.vim mbyte.vim test.ok X* viminfo
7197- $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
7198+ $(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
7199 @/bin/sh -c "if diff test.out $*.ok; \
7200 then mv -f test.out $*.out; \
7201 else echo; \
7202@@ -51,7 +56,7 @@
7203 cp $*.ok test.ok
7204 # Sleep a moment to avoid that the xterm title is messed up
7205 @-sleep .2
7206- -$(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
7207+ -$(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in
7208 @/bin/sh -c "if test -f test.out; then\
7209 if diff test.out $*.ok; \
7210 then mv -f test.out $*.out; \
[c2aa910]7211@@ -61,5 +66,9 @@
7212 fi"
7213 -rm -rf X* test.ok viminfo
7214
7215+test49.out: test49.vim
7216+
7217+test60.out: test60.vim
7218+
7219 nolog:
7220 -echo Test results: >test.log
7221diff -Naur vim71.orig/src/testdir/test14.in vim71/src/testdir/test14.in
7222--- vim71.orig/src/testdir/test14.in 2004-06-07 07:32:05.000000000 -0700
[2830f42]7223+++ vim71/src/testdir/test14.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7224@@ -18,6 +18,7 @@
7225 : let tt = "o\<C-V>65\<C-V>x42\<C-V>o103 \<C-V>33a\<C-V>xfg\<C-V>o78\<Esc>"
7226 :endif
7227 :exe "normal " . tt
7228+:unlet tt
7229 :.w >>test.out
7230 :set vb
7231 /^Piece
7232diff -Naur vim71.orig/src/testdir/test26.in vim71/src/testdir/test26.in
7233--- vim71.orig/src/testdir/test26.in 2004-06-07 07:32:05.000000000 -0700
[2830f42]7234+++ vim71/src/testdir/test26.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7235@@ -37,6 +37,7 @@
7236 : endif
7237 : endif
7238 :endwhile
7239+:unlet i j
7240 :'t,$w! test.out
7241 :qa!
7242 ENDTEST
7243diff -Naur vim71.orig/src/testdir/test34.in vim71/src/testdir/test34.in
7244--- vim71.orig/src/testdir/test34.in 2006-04-30 06:33:24.000000000 -0700
[2830f42]7245+++ vim71/src/testdir/test34.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7246@@ -52,7 +52,15 @@
7247 ---*---
7248 (one
7249 (two
7250-[(one again:$-5,$wq! test.out
7251+[(one again:$-5,$w! test.out
7252+:delfunc Table
7253+:delfunc Compute
7254+:delfunc Expr1
7255+:delfunc Expr2
7256+:delfunc ListItem
7257+:delfunc ListReset
7258+:unlet retval counter
7259+:q!
7260 ENDTEST
7261
7262 here
7263diff -Naur vim71.orig/src/testdir/test45.in vim71/src/testdir/test45.in
7264--- vim71.orig/src/testdir/test45.in 2004-06-07 07:32:05.000000000 -0700
[2830f42]7265+++ vim71/src/testdir/test45.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7266@@ -55,6 +55,7 @@
7267 /kk$
7268 :call append("$", foldlevel("."))
7269 :/^last/+1,$w! test.out
7270+:delfun Flvl
7271 :qa!
7272 ENDTEST
7273
7274diff -Naur vim71.orig/src/testdir/test47.in vim71/src/testdir/test47.in
7275--- vim71.orig/src/testdir/test47.in 2004-06-07 07:32:05.000000000 -0700
[2830f42]7276+++ vim71/src/testdir/test47.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7277@@ -34,6 +34,7 @@
7278 :call append("$", two)
7279 :call append("$", three)
7280 :$-2,$w! test.out
7281+:unlet one two three
7282 :qa!
7283 ENDTEST
7284
7285diff -Naur vim71.orig/src/testdir/test49.in vim71/src/testdir/test49.in
7286--- vim71.orig/src/testdir/test49.in 2006-04-28 02:29:54.000000000 -0700
[2830f42]7287+++ vim71/src/testdir/test49.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7288@@ -1,13 +1,29 @@
7289 This is a test of the script language.
7290
7291 If after adding a new test, the test output doesn't appear properly in
7292-test49.failed, try to add one ore more "G"s at the line before ENDTEST.
7293+test49.failed, try to add one ore more "G"s at the line ending in "test.out"
7294
7295 STARTTEST
7296 :so small.vim
7297 :se nocp nomore viminfo+=nviminfo
7298 :so test49.vim
7299-GGGGGGGGGG"rp:.-,$wq! test.out
7300+GGGGGGGGGGGGGG"rp:.-,$w! test.out
7301+:"
7302+:" make valgrind happy
7303+:redir => funclist
7304+:silent func
7305+:redir END
7306+:for line in split(funclist, "\n")
7307+: let name = matchstr(line, 'function \zs[A-Z]\w*\ze(')
7308+: if name != ''
7309+: exe "delfunc " . name
7310+: endif
7311+:endfor
7312+:for v in keys(g:)
7313+: silent! exe "unlet " . v
7314+:endfor
7315+:unlet v
7316+:qa!
7317 ENDTEST
7318
7319 Results of test49.vim:
7320diff -Naur vim71.orig/src/testdir/test55.in vim71/src/testdir/test55.in
7321--- vim71.orig/src/testdir/test55.in 2006-10-15 07:07:05.000000000 -0700
[2830f42]7322+++ vim71/src/testdir/test55.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7323@@ -345,6 +345,10 @@
7324 :endfun
7325 :call Test(1, 2, [3, 4], {5: 6}) " This may take a while
7326 :"
7327+:delfunc Test
7328+:unlet dict
7329+:call garbagecollect(1)
7330+:"
7331 :/^start:/,$wq! test.out
7332 ENDTEST
7333
7334diff -Naur vim71.orig/src/testdir/test56.in vim71/src/testdir/test56.in
7335--- vim71.orig/src/testdir/test56.in 2006-09-03 07:28:41.000000000 -0700
[2830f42]7336+++ vim71/src/testdir/test56.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7337@@ -17,5 +17,5 @@
7338 fun s:DoNothing()
7339 call append(line('$'), "nothing line")
7340 endfun
7341-nnoremap <buffer> _x :call <SID>DoNothing()<bar>call <SID>DoLast()<cr>
7342+nnoremap <buffer> _x :call <SID>DoNothing()<bar>call <SID>DoLast()<bar>delfunc <SID>DoNothing<bar>delfunc <SID>DoLast<cr>
7343 end:
7344diff -Naur vim71.orig/src/testdir/test58.in vim71/src/testdir/test58.in
7345--- vim71.orig/src/testdir/test58.in 2006-04-03 11:24:04.000000000 -0700
[2830f42]7346+++ vim71/src/testdir/test58.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7347@@ -86,6 +86,7 @@
7348 :$put =str
7349 `m]s:let [str, a] = spellbadword()
7350 :$put =str
7351+:unlet str a
7352 :"
7353 :" Postponed prefixes
7354 :call TestOne('2', '1')
7355@@ -100,6 +101,10 @@
7356 :" NOSLITSUGS
7357 :call TestOne('8', '8')
7358 :"
7359+:" clean up for valgrind
7360+:delfunc TestOne
7361+:set spl= enc=latin1
7362+:"
7363 gg:/^test output:/,$wq! test.out
7364 ENDTEST
7365
7366diff -Naur vim71.orig/src/testdir/test59.in vim71/src/testdir/test59.in
7367--- vim71.orig/src/testdir/test59.in 2006-04-03 11:29:24.000000000 -0700
[2830f42]7368+++ vim71/src/testdir/test59.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7369@@ -90,6 +90,7 @@
7370 :$put =str
7371 `m]s:let [str, a] = spellbadword()
7372 :$put =str
7373+:unlet str a
7374 :"
7375 :" Postponed prefixes
7376 :call TestOne('2', '1')
7377@@ -101,6 +102,10 @@
7378 :call TestOne('6', '6')
7379 :call TestOne('7', '7')
7380 :"
7381+:" clean up for valgrind
7382+:delfunc TestOne
7383+:set spl= enc=latin1
7384+:"
7385 gg:/^test output:/,$wq! test.out
7386 ENDTEST
7387
7388diff -Naur vim71.orig/src/testdir/test60.in vim71/src/testdir/test60.in
7389--- vim71.orig/src/testdir/test60.in 2006-05-05 11:41:18.000000000 -0700
[2830f42]7390+++ vim71/src/testdir/test60.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7391@@ -569,6 +569,9 @@
7392 redir END
7393 endfunction
7394 :call TestExists()
7395+:delfunc TestExists
7396+:delfunc RunTest
7397+:delfunc TestFuncArg
7398 :edit! test.out
7399 :set ff=unix
7400 :w
7401diff -Naur vim71.orig/src/testdir/test60.vim vim71/src/testdir/test60.vim
7402--- vim71.orig/src/testdir/test60.vim 2006-01-12 11:45:59.000000000 -0800
[2830f42]7403+++ vim71/src/testdir/test60.vim 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7404@@ -94,4 +94,5 @@
7405 else
7406 echo "FAILED"
7407 endif
7408+unlet str
7409
7410diff -Naur vim71.orig/src/testdir/test62.in vim71/src/testdir/test62.in
7411--- vim71.orig/src/testdir/test62.in 2006-04-30 04:29:15.000000000 -0700
[2830f42]7412+++ vim71/src/testdir/test62.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7413@@ -7,6 +7,7 @@
7414 :let nr = tabpagenr()
7415 :q
7416 :call append(line('$'), 'tab page ' . nr)
7417+:unlet nr
7418 :"
7419 :" Open three tab pages and use ":tabdo"
7420 :0tabnew
7421@@ -23,6 +24,7 @@
7422 :q!
7423 :call append(line('$'), line1)
7424 :call append(line('$'), line2)
7425+:unlet line1 line2
7426 :"
7427 :"
7428 :/^Results/,$w! test.out
[ba61c16]7429diff -Naur vim71.orig/src/testdir/test63.in vim71/src/testdir/test63.in
7430--- vim71.orig/src/testdir/test63.in 1969-12-31 16:00:00.000000000 -0800
[2830f42]7431+++ vim71/src/testdir/test63.in 2007-10-29 08:09:38.000000000 -0700
[ba61c16]7432@@ -0,0 +1,157 @@
7433+Test for ":match", ":2match", ":3match", "clearmatches()", "getmatches()",
7434+"matchadd()", "matcharg()", "matchdelete()", and "setmatches()".
7435+
7436+STARTTEST
7437+:so small.vim
7438+:" --- Check that "matcharg()" returns the correct group and pattern if a match
7439+:" --- is defined.
7440+:let @r = "*** Test 1: "
7441+:highlight MyGroup1 ctermbg=red
7442+:highlight MyGroup2 ctermbg=green
7443+:highlight MyGroup3 ctermbg=blue
7444+:match MyGroup1 /TODO/
7445+:2match MyGroup2 /FIXME/
7446+:3match MyGroup3 /XXX/
7447+:if matcharg(1) == ['MyGroup1', 'TODO'] && matcharg(2) == ['MyGroup2', 'FIXME'] && matcharg(3) == ['MyGroup3', 'XXX']
7448+: let @r .= "OK\n"
7449+:else
7450+: let @r .= "FAILED\n"
7451+:endif
7452+:" --- Check that "matcharg()" returns an empty list if the argument is not 1,
7453+:" --- 2 or 3 (only 0 and 4 are tested).
7454+:let @r .= "*** Test 2: "
7455+:if matcharg(0) == [] && matcharg(4) == []
7456+: let @r .= "OK\n"
7457+:else
7458+: let @r .= "FAILED\n"
7459+:endif
7460+:" --- Check that "matcharg()" returns ['', ''] if a match is not defined.
7461+:let @r .= "*** Test 3: "
7462+:match
7463+:2match
7464+:3match
7465+:if matcharg(1) == ['', ''] && matcharg(2) == ['', ''] && matcharg(3) == ['', '']
7466+: let @r .= "OK\n"
7467+:else
7468+: let @r .= "FAILED\n"
7469+:endif
7470+:" --- Check that "matchadd()" and "getmatches()" agree on added matches and
7471+:" --- that default values apply.
7472+:let @r .= "*** Test 4: "
7473+:let m1 = matchadd("MyGroup1", "TODO")
7474+:let m2 = matchadd("MyGroup2", "FIXME", 42)
7475+:let m3 = matchadd("MyGroup3", "XXX", 60, 17)
7476+:if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 4}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 42, 'id': 5}, {'group': 'MyGroup3', 'pattern': 'XXX', 'priority': 60, 'id': 17}]
7477+: let @r .= "OK\n"
7478+:else
7479+: let @r .= "FAILED\n"
7480+:endif
7481+:" --- Check that "matchdelete()" deletes the matches defined in the previous
7482+:" --- test correctly.
7483+:let @r .= "*** Test 5: "
7484+:call matchdelete(m1)
7485+:call matchdelete(m2)
7486+:call matchdelete(m3)
7487+:unlet m1
7488+:unlet m2
7489+:unlet m3
7490+:if getmatches() == []
7491+: let @r .= "OK\n"
7492+:else
7493+: let @r .= "FAILED\n"
7494+:endif
[c2aa910]7495+:" --- Check that "matchdelete()" returns 0 if successful and otherwise -1.
[ba61c16]7496+:let @r .= "*** Test 6: "
7497+:let m = matchadd("MyGroup1", "TODO")
7498+:let r1 = matchdelete(m)
7499+:let r2 = matchdelete(42)
7500+:if r1 == 0 && r2 == -1
7501+: let @r .= "OK\n"
7502+:else
7503+: let @r .= "FAILED\n"
7504+:endif
7505+:unlet m
7506+:unlet r1
7507+:unlet r2
7508+:" --- Check that "clearmatches()" clears all matches defined by ":match" and
7509+:" --- "matchadd()".
7510+:let @r .= "*** Test 7: "
7511+:let m1 = matchadd("MyGroup1", "TODO")
7512+:let m2 = matchadd("MyGroup2", "FIXME", 42)
7513+:let m3 = matchadd("MyGroup3", "XXX", 60, 17)
7514+:match MyGroup1 /COFFEE/
7515+:2match MyGroup2 /HUMPPA/
7516+:3match MyGroup3 /VIM/
7517+:call clearmatches()
7518+:if getmatches() == []
7519+: let @r .= "OK\n"
7520+:else
7521+: let @r .= "FAILED\n"
7522+:endif
7523+:unlet m1
7524+:unlet m2
7525+:unlet m3
7526+:" --- Check that "setmatches()" restores a list of matches saved by
7527+:" --- "getmatches()" without changes. (Matches with equal priority must also
7528+:" --- remain in the same order.)
7529+:let @r .= "*** Test 8: "
7530+:let m1 = matchadd("MyGroup1", "TODO")
7531+:let m2 = matchadd("MyGroup2", "FIXME", 42)
7532+:let m3 = matchadd("MyGroup3", "XXX", 60, 17)
7533+:match MyGroup1 /COFFEE/
7534+:2match MyGroup2 /HUMPPA/
7535+:3match MyGroup3 /VIM/
7536+:let ml = getmatches()
7537+:call clearmatches()
7538+:call setmatches(ml)
7539+:if getmatches() == ml
7540+: let @r .= "OK\n"
7541+:else
7542+: let @r .= "FAILED\n"
7543+:endif
7544+:call clearmatches()
7545+:unlet m1
7546+:unlet m2
7547+:unlet m3
7548+:unlet ml
7549+:" --- Check that "setmatches()" will not add two matches with the same ID. The
7550+:" --- expected behaviour (for now) is to add the first match but not the
7551+:" --- second and to return 0 (even though it is a matter of debate whether
[c2aa910]7552+:" --- this can be considered successful behaviour).
[ba61c16]7553+:let @r .= "*** Test 9: "
7554+:let r1 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}, {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}])
7555+:if getmatches() == [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}] && r1 == 0
7556+: let @r .= "OK\n"
7557+:else
7558+: let @r .= "FAILED\n"
7559+:endif
7560+:call clearmatches()
7561+:unlet r1
[c2aa910]7562+:" --- Check that "setmatches()" returns 0 if successful and otherwise -1.
[ba61c16]7563+:" --- (A range of valid and invalid input values are tried out to generate the
7564+:" --- return values.)
7565+:let @r .= "*** Test 10: "
7566+:let rs1 = setmatches([])
7567+:let rs2 = setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])
7568+:call clearmatches()
7569+:let rf1 = setmatches(0)
7570+:let rf2 = setmatches([0])
7571+:let rf3 = setmatches([{'wrong key': 'wrong value'}])
7572+:if rs1 == 0 && rs2 == 0 && rf1 == -1 && rf2 == -1 && rf3 == -1
7573+: let @r .= "OK\n"
7574+:else
7575+: let @r .= "FAILED\n"
7576+:endif
7577+:unlet rs1
7578+:unlet rs2
7579+:unlet rf1
7580+:unlet rf2
7581+:unlet rf3
7582+:highlight clear MyGroup1
7583+:highlight clear MyGroup2
7584+:highlight clear MyGroup3
7585+G"rp
7586+:/^Results/,$wq! test.out
7587+ENDTEST
7588+
7589+Results of test63:
7590diff -Naur vim71.orig/src/testdir/test63.ok vim71/src/testdir/test63.ok
7591--- vim71.orig/src/testdir/test63.ok 1969-12-31 16:00:00.000000000 -0800
[2830f42]7592+++ vim71/src/testdir/test63.ok 2007-10-29 08:09:16.000000000 -0700
[ba61c16]7593@@ -0,0 +1,11 @@
7594+Results of test63:
7595+*** Test 1: OK
7596+*** Test 2: OK
7597+*** Test 3: OK
7598+*** Test 4: OK
7599+*** Test 5: OK
7600+*** Test 6: OK
7601+*** Test 7: OK
7602+*** Test 8: OK
7603+*** Test 9: OK
7604+*** Test 10: OK
7605diff -Naur vim71.orig/src/testdir/test64.in vim71/src/testdir/test64.in
7606--- vim71.orig/src/testdir/test64.in 1969-12-31 16:00:00.000000000 -0800
[2830f42]7607+++ vim71/src/testdir/test64.in 2007-10-29 08:09:38.000000000 -0700
[c2aa910]7608@@ -0,0 +1,54 @@
[ba61c16]7609+Test for regexp patterns.
7610+
7611+A pattern that gives the expected result produces OK, so that we know it was
7612+actually tried.
7613+
7614+STARTTEST
7615+:so small.vim
7616+:" tl is a List of Lists with:
7617+:" regexp pattern
7618+:" text to test the pattern on
7619+:" expected match (optional)
7620+:" expected submatch 1 (optional)
7621+:" expected submatch 2 (optional)
7622+:" etc.
7623+:" When there is no match use only the first two items.
7624+:let tl = []
7625+:call add(tl, ['b', 'abcdef', 'b'])
7626+:call add(tl, ['bc*', 'abccccdef', 'bcccc'])
7627+:call add(tl, ['bc\{-}', 'abccccdef', 'b'])
7628+:call add(tl, ['bc\{-}\(d\)', 'abccccdef', 'bccccd', 'd'])
7629+:call add(tl, ['x', 'abcdef'])
7630+:"
7631+:for t in tl
7632+: let l = matchlist(t[1], t[0])
7633+:" check the match itself
7634+: if len(l) == 0 && len(t) > 2
7635+: $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", did not match, expected: \"' . t[2] . '\"'
7636+: elseif len(l) > 0 && len(t) == 2
7637+: $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected no match'
7638+: elseif len(t) > 2 && l[0] != t[2]
7639+: $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", match: \"' . l[0] . '\", expected: \"' . t[2] . '\"'
7640+: else
7641+: $put ='OK'
7642+: endif
7643+: if len(l) > 0
7644+:" check all the nine submatches
7645+: for i in range(1, 9)
7646+: if len(t) <= i + 2
7647+: let e = ''
7648+: else
7649+: let e = t[i + 2]
7650+: endif
7651+: if l[i] != e
7652+: $put ='ERROR: pat: \"' . t[0] . '\", text: \"' . t[1] . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
7653+: endif
7654+: endfor
[c2aa910]7655+: unlet i
[ba61c16]7656+: endif
7657+:endfor
[c2aa910]7658+:unlet t tl e l
[ba61c16]7659+:/^Results/,$wq! test.out
7660+ENDTEST
7661+
7662+Results of test64:
7663diff -Naur vim71.orig/src/testdir/test64.ok vim71/src/testdir/test64.ok
7664--- vim71.orig/src/testdir/test64.ok 1969-12-31 16:00:00.000000000 -0800
[2830f42]7665+++ vim71/src/testdir/test64.ok 2007-10-29 08:09:25.000000000 -0700
[ba61c16]7666@@ -0,0 +1,6 @@
7667+Results of test64:
7668+OK
7669+OK
7670+OK
7671+OK
7672+OK
7673diff -Naur vim71.orig/src/ui.c vim71/src/ui.c
7674--- vim71.orig/src/ui.c 2007-05-07 12:49:09.000000000 -0700
[2830f42]7675+++ vim71/src/ui.c 2007-10-29 08:09:28.000000000 -0700
[ba61c16]7676@@ -1603,8 +1603,6 @@
7677 #if defined(FEAT_GUI) || defined(FEAT_MOUSE_GPM) \
7678 || defined(FEAT_XCLIPBOARD) || defined(VMS) \
7679 || defined(FEAT_SNIFF) || defined(FEAT_CLIENTSERVER) \
7680- || (defined(FEAT_GUI) && (!defined(USE_ON_FLY_SCROLL) \
7681- || defined(FEAT_MENU))) \
7682 || defined(PROTO)
7683 /*
7684 * Add the given bytes to the input buffer
7685@@ -1630,7 +1628,9 @@
7686 }
7687 #endif
7688
7689-#if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) \
7690+#if ((defined(FEAT_XIM) || defined(FEAT_DND)) && defined(FEAT_GUI_GTK)) \
7691+ || defined(FEAT_GUI_MSWIN) \
7692+ || defined(FEAT_GUI_MAC) \
7693 || (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) \
7694 || (defined(FEAT_GUI) && (!defined(USE_ON_FLY_SCROLL) \
7695 || defined(FEAT_MENU))) \
[c2aa910]7696diff -Naur vim71.orig/src/undo.c vim71/src/undo.c
7697--- vim71.orig/src/undo.c 2007-05-07 12:21:14.000000000 -0700
[2830f42]7698+++ vim71/src/undo.c 2007-10-29 08:09:48.000000000 -0700
[c2aa910]7699@@ -76,6 +76,12 @@
7700 * buffer is unloaded.
7701 */
7702
7703+/* Uncomment the next line for including the u_check() function. This warns
7704+ * for errors in the debug information. */
7705+/* #define U_DEBUG 1 */
7706+#define UH_MAGIC 0x18dade /* value for uh_magic when in use */
7707+#define UE_MAGIC 0xabc123 /* value for ue_magic when in use */
7708+
7709 #include "vim.h"
7710
7711 /* See below: use malloc()/free() for memory management. */
7712@@ -113,6 +119,95 @@
7713 */
7714 static int undo_undoes = FALSE;
7715
7716+#ifdef U_DEBUG
7717+/*
7718+ * Check the undo structures for being valid. Print a warning when something
7719+ * looks wrong.
7720+ */
7721+static int seen_b_u_curhead;
7722+static int seen_b_u_newhead;
7723+static int header_count;
7724+
7725+ static void
7726+u_check_tree(u_header_T *uhp,
7727+ u_header_T *exp_uh_next,
7728+ u_header_T *exp_uh_alt_prev)
7729+{
7730+ u_entry_T *uep;
7731+
7732+ if (uhp == NULL)
7733+ return;
7734+ ++header_count;
7735+ if (uhp == curbuf->b_u_curhead && ++seen_b_u_curhead > 1)
7736+ {
7737+ EMSG("b_u_curhead found twice (looping?)");
7738+ return;
7739+ }
7740+ if (uhp == curbuf->b_u_newhead && ++seen_b_u_newhead > 1)
7741+ {
7742+ EMSG("b_u_newhead found twice (looping?)");
7743+ return;
7744+ }
7745+
7746+ if (uhp->uh_magic != UH_MAGIC)
7747+ EMSG("uh_magic wrong (may be using freed memory)");
7748+ else
7749+ {
7750+ /* Check pointers back are correct. */
7751+ if (uhp->uh_next != exp_uh_next)
7752+ {
7753+ EMSG("uh_next wrong");
7754+ smsg((char_u *)"expected: 0x%x, actual: 0x%x",
7755+ exp_uh_next, uhp->uh_next);
7756+ }
7757+ if (uhp->uh_alt_prev != exp_uh_alt_prev)
7758+ {
7759+ EMSG("uh_alt_prev wrong");
7760+ smsg((char_u *)"expected: 0x%x, actual: 0x%x",
7761+ exp_uh_alt_prev, uhp->uh_alt_prev);
7762+ }
7763+
7764+ /* Check the undo tree at this header. */
7765+ for (uep = uhp->uh_entry; uep != NULL; uep = uep->ue_next)
7766+ {
7767+ if (uep->ue_magic != UE_MAGIC)
7768+ {
7769+ EMSG("ue_magic wrong (may be using freed memory)");
7770+ break;
7771+ }
7772+ }
7773+
7774+ /* Check the next alt tree. */
7775+ u_check_tree(uhp->uh_alt_next, uhp->uh_next, uhp);
7776+
7777+ /* Check the next header in this branch. */
7778+ u_check_tree(uhp->uh_prev, uhp, NULL);
7779+ }
7780+}
7781+
7782+ void
7783+u_check(int newhead_may_be_NULL)
7784+{
7785+ seen_b_u_newhead = 0;
7786+ seen_b_u_curhead = 0;
7787+ header_count = 0;
7788+
7789+ u_check_tree(curbuf->b_u_oldhead, NULL, NULL);
7790+
7791+ if (seen_b_u_newhead == 0 && curbuf->b_u_oldhead != NULL
7792+ && !(newhead_may_be_NULL && curbuf->b_u_newhead == NULL))
7793+ EMSGN("b_u_newhead invalid: 0x%x", curbuf->b_u_newhead);
7794+ if (curbuf->b_u_curhead != NULL && seen_b_u_curhead == 0)
7795+ EMSGN("b_u_curhead invalid: 0x%x", curbuf->b_u_curhead);
7796+ if (header_count != curbuf->b_u_numhead)
7797+ {
7798+ EMSG("b_u_numhead invalid");
7799+ smsg((char_u *)"expected: %ld, actual: %ld",
7800+ (long)header_count, (long)curbuf->b_u_numhead);
7801+ }
7802+}
7803+#endif
7804+
7805 /*
7806 * Save the current line for both the "u" and "U" command.
7807 * Returns OK or FAIL.
7808@@ -243,6 +338,9 @@
7809 if (!undo_allowed())
7810 return FAIL;
7811
7812+#ifdef U_DEBUG
7813+ u_check(FALSE);
7814+#endif
7815 #ifdef FEAT_NETBEANS_INTG
7816 /*
7817 * Netbeans defines areas that cannot be modified. Bail out here when
7818@@ -294,6 +392,9 @@
7819 uhp = (u_header_T *)U_ALLOC_LINE((unsigned)sizeof(u_header_T));
7820 if (uhp == NULL)
7821 goto nomem;
7822+#ifdef U_DEBUG
7823+ uhp->uh_magic = UH_MAGIC;
7824+#endif
7825 }
7826 else
7827 uhp = NULL;
7828@@ -316,8 +417,11 @@
7829 {
7830 u_header_T *uhfree = curbuf->b_u_oldhead;
7831
7832- /* If there is no branch only free one header. */
7833- if (uhfree->uh_alt_next == NULL)
7834+ if (uhfree == old_curhead)
7835+ /* Can't reconnect the branch, delete all of it. */
7836+ u_freebranch(curbuf, uhfree, &old_curhead);
7837+ else if (uhfree->uh_alt_next == NULL)
7838+ /* There is no branch, only free one header. */
7839 u_freeheader(curbuf, uhfree, &old_curhead);
7840 else
7841 {
7842@@ -326,6 +430,9 @@
7843 uhfree = uhfree->uh_alt_next;
7844 u_freebranch(curbuf, uhfree, &old_curhead);
7845 }
7846+#ifdef U_DEBUG
7847+ u_check(TRUE);
7848+#endif
7849 }
7850
7851 if (uhp == NULL) /* no undo at all */
7852@@ -478,6 +585,9 @@
7853 uep = (u_entry_T *)U_ALLOC_LINE((unsigned)sizeof(u_entry_T));
7854 if (uep == NULL)
7855 goto nomem;
7856+#ifdef U_DEBUG
7857+ uep->ue_magic = UE_MAGIC;
7858+#endif
7859
7860 uep->ue_size = size;
7861 uep->ue_top = top;
7862@@ -525,6 +635,9 @@
7863 curbuf->b_u_synced = FALSE;
7864 undo_undoes = FALSE;
7865
7866+#ifdef U_DEBUG
7867+ u_check(FALSE);
7868+#endif
7869 return OK;
7870
7871 nomem:
7872@@ -955,6 +1068,9 @@
7873 int empty_buffer; /* buffer became empty */
7874 u_header_T *curhead = curbuf->b_u_curhead;
7875
7876+#ifdef U_DEBUG
7877+ u_check(FALSE);
7878+#endif
7879 old_flags = curhead->uh_flags;
7880 new_flags = (curbuf->b_changed ? UH_CHANGED : 0) +
7881 ((curbuf->b_ml.ml_flags & ML_EMPTY) ? UH_EMPTYBUF : 0);
7882@@ -1186,6 +1302,9 @@
7883 /* The timestamp can be the same for multiple changes, just use the one of
7884 * the undone/redone change. */
7885 curbuf->b_u_seq_time = curhead->uh_time;
7886+#ifdef U_DEBUG
7887+ u_check(FALSE);
7888+#endif
7889 }
7890
7891 /*
7892@@ -1515,7 +1634,7 @@
7893 }
7894
7895 /*
7896- * Free one header and its entry list and adjust the pointers.
7897+ * Free one header "uhp" and its entry list and adjust the pointers.
7898 */
7899 static void
7900 u_freeheader(buf, uhp, uhpp)
7901@@ -1523,6 +1642,8 @@
7902 u_header_T *uhp;
7903 u_header_T **uhpp; /* if not NULL reset when freeing this header */
7904 {
7905+ u_header_T *uhap;
7906+
7907 /* When there is an alternate redo list free that branch completely,
7908 * because we can never go there. */
7909 if (uhp->uh_alt_next != NULL)
7910@@ -1540,7 +1661,8 @@
7911 if (uhp->uh_prev == NULL)
7912 buf->b_u_newhead = uhp->uh_next;
7913 else
7914- uhp->uh_prev->uh_next = uhp->uh_next;
7915+ for (uhap = uhp->uh_prev; uhap != NULL; uhap = uhap->uh_alt_next)
7916+ uhap->uh_next = uhp->uh_next;
7917
7918 u_freeentries(buf, uhp, uhpp);
7919 }
7920@@ -1585,6 +1707,8 @@
7921 /* Check for pointers to the header that become invalid now. */
7922 if (buf->b_u_curhead == uhp)
7923 buf->b_u_curhead = NULL;
7924+ if (buf->b_u_newhead == uhp)
7925+ buf->b_u_newhead = NULL; /* freeing the newest entry */
7926 if (uhpp != NULL && uhp == *uhpp)
7927 *uhpp = NULL;
7928
7929@@ -1594,6 +1718,9 @@
7930 u_freeentry(uep, uep->ue_size);
7931 }
7932
7933+#ifdef U_DEBUG
7934+ uhp->uh_magic = 0;
7935+#endif
7936 U_FREE_LINE((char_u *)uhp);
7937 --buf->b_u_numhead;
7938 }
7939@@ -1609,6 +1736,9 @@
7940 while (n > 0)
7941 U_FREE_LINE(uep->ue_array[--n]);
7942 U_FREE_LINE((char_u *)uep->ue_array);
7943+#ifdef U_DEBUG
7944+ uep->ue_magic = 0;
7945+#endif
7946 U_FREE_LINE((char_u *)uep);
7947 }
7948
[ba61c16]7949diff -Naur vim71.orig/src/version.c vim71/src/version.c
7950--- vim71.orig/src/version.c 2007-05-12 03:23:44.000000000 -0700
[2830f42]7951+++ vim71/src/version.c 2007-10-29 08:09:51.000000000 -0700
7952@@ -667,6 +667,266 @@
[ba61c16]7953 static int included_patches[] =
7954 { /* Add new patch number below this line */
7955 /**/
[2830f42]7956+ 145,
7957+/**/
7958+ 144,
7959+/**/
7960+ 143,
7961+/**/
7962+ 142,
7963+/**/
7964+ 141,
7965+/**/
[c2aa910]7966+ 140,
7967+/**/
7968+ 139,
7969+/**/
7970+ 138,
7971+/**/
7972+ 137,
7973+/**/
7974+ 136,
7975+/**/
7976+ 135,
7977+/**/
7978+ 133,
7979+/**/
7980+ 132,
7981+/**/
7982+ 131,
7983+/**/
7984+ 130,
7985+/**/
7986+ 127,
7987+/**/
7988+ 125,
7989+/**/
7990+ 123,
7991+/**/
7992+ 122,
7993+/**/
7994+ 121,
7995+/**/
7996+ 120,
7997+/**/
7998+ 119,
7999+/**/
8000+ 118,
8001+/**/
8002+ 117,
8003+/**/
8004+ 116,
8005+/**/
8006+ 115,
8007+/**/
8008+ 114,
8009+/**/
8010+ 113,
8011+/**/
8012+ 112,
8013+/**/
8014+ 111,
8015+/**/
8016+ 110,
8017+/**/
8018+ 109,
8019+/**/
8020+ 108,
8021+/**/
8022+ 107,
8023+/**/
8024+ 106,
8025+/**/
8026+ 105,
8027+/**/
8028+ 104,
8029+/**/
8030+ 103,
8031+/**/
8032+ 102,
8033+/**/
8034+ 101,
8035+/**/
8036+ 100,
8037+/**/
8038+ 99,
8039+/**/
8040+ 98,
8041+/**/
8042+ 97,
8043+/**/
8044+ 96,
8045+/**/
8046+ 95,
8047+/**/
[ba61c16]8048+ 94,
8049+/**/
8050+ 93,
8051+/**/
8052+ 90,
8053+/**/
8054+ 89,
8055+/**/
8056+ 87,
8057+/**/
8058+ 86,
8059+/**/
8060+ 85,
8061+/**/
8062+ 84,
8063+/**/
8064+ 83,
8065+/**/
8066+ 82,
8067+/**/
8068+ 81,
8069+/**/
8070+ 79,
8071+/**/
8072+ 78,
8073+/**/
8074+ 77,
8075+/**/
8076+ 76,
8077+/**/
8078+ 75,
8079+/**/
8080+ 74,
8081+/**/
8082+ 73,
8083+/**/
8084+ 71,
8085+/**/
8086+ 69,
8087+/**/
8088+ 68,
8089+/**/
8090+ 67,
8091+/**/
8092+ 66,
8093+/**/
8094+ 64,
8095+/**/
8096+ 63,
8097+/**/
8098+ 62,
8099+/**/
8100+ 61,
8101+/**/
8102+ 60,
8103+/**/
8104+ 59,
8105+/**/
8106+ 58,
8107+/**/
8108+ 57,
8109+/**/
8110+ 56,
8111+/**/
8112+ 55,
8113+/**/
8114+ 54,
8115+/**/
8116+ 53,
8117+/**/
8118+ 52,
8119+/**/
8120+ 51,
8121+/**/
8122+ 50,
8123+/**/
8124+ 49,
8125+/**/
8126+ 48,
8127+/**/
8128+ 47,
8129+/**/
8130+ 46,
8131+/**/
8132+ 45,
8133+/**/
8134+ 44,
8135+/**/
8136+ 43,
8137+/**/
8138+ 42,
8139+/**/
8140+ 40,
8141+/**/
8142+ 39,
8143+/**/
8144+ 38,
8145+/**/
8146+ 37,
8147+/**/
8148+ 36,
8149+/**/
8150+ 35,
8151+/**/
8152+ 34,
8153+/**/
8154+ 33,
8155+/**/
8156+ 32,
8157+/**/
8158+ 31,
8159+/**/
8160+ 30,
8161+/**/
8162+ 29,
8163+/**/
8164+ 28,
8165+/**/
8166+ 27,
8167+/**/
8168+ 26,
8169+/**/
8170+ 25,
8171+/**/
8172+ 24,
8173+/**/
8174+ 23,
8175+/**/
8176+ 22,
8177+/**/
8178+ 21,
8179+/**/
8180+ 20,
8181+/**/
8182+ 19,
8183+/**/
8184+ 18,
8185+/**/
8186+ 17,
8187+/**/
8188+ 16,
8189+/**/
8190+ 15,
8191+/**/
8192+ 14,
8193+/**/
8194+ 13,
8195+/**/
8196+ 12,
8197+/**/
8198+ 11,
8199+/**/
8200+ 10,
8201+/**/
8202+ 9,
8203+/**/
8204+ 8,
8205+/**/
8206+ 6,
8207+/**/
8208+ 5,
8209+/**/
8210+ 4,
8211+/**/
8212+ 2,
8213+/**/
8214+ 1,
8215+/**/
8216 0
8217 };
8218
8219diff -Naur vim71.orig/src/vim.h vim71/src/vim.h
8220--- vim71.orig/src/vim.h 2007-05-12 02:53:29.000000000 -0700
[2830f42]8221+++ vim71/src/vim.h 2007-10-29 08:09:18.000000000 -0700
[ba61c16]8222@@ -1380,8 +1380,14 @@
8223 #endif
8224
8225 #ifdef FEAT_MBYTE
8226-# define MB_STRICMP(d, s) (has_mbyte ? mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL) : STRICMP((d), (s)))
8227-# define MB_STRNICMP(d, s, n) (has_mbyte ? mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n)) : STRNICMP((d), (s), (n)))
8228+/* We need to call mb_stricmp() even when we aren't dealing with a multi-byte
8229+ * encoding because mb_stricmp() takes care of all ascii and non-ascii
8230+ * encodings, including characters with umluats in latin1, etc., while
8231+ * STRICMP() only handles the system locale version, which often does not
8232+ * handle non-ascii properly. */
8233+
8234+# define MB_STRICMP(d, s) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)MAXCOL)
8235+# define MB_STRNICMP(d, s, n) mb_strnicmp((char_u *)(d), (char_u *)(s), (int)(n))
8236 #else
8237 # define MB_STRICMP(d, s) STRICMP((d), (s))
8238 # define MB_STRNICMP(d, s, n) STRNICMP((d), (s), (n))
8239diff -Naur vim71.orig/src/vimtutor vim71/src/vimtutor
8240--- vim71.orig/src/vimtutor 2004-06-07 07:32:27.000000000 -0700
[2830f42]8241+++ vim71/src/vimtutor 2007-10-29 08:09:16.000000000 -0700
[ba61c16]8242@@ -39,18 +39,22 @@
8243 # remove the copy of the tutor on exit
8244 trap "rm -rf $TODELETE" 0 1 2 3 9 11 13 15
8245
8246-# Vim could be called "vim" or "vi". Also check for "vim6", for people who
8247-# have Vim 5.x installed as "vim" and Vim 6.0 as "vim6".
8248-testvim=`which vim6 2>/dev/null`
8249-if test -f "$testvim"; then
8250- VIM=vim6
8251-else
8252- testvim=`which vim`
8253+# Vim could be called "vim" or "vi". Also check for "vimN", for people who
8254+# have Vim installed with its version number.
8255+# We anticipate up to a future Vim 8 version :-).
8256+seq="vim vim8 vim75 vim74 vim73 vim72 vim71 vim70 vim7 vim6 vi"
8257+for i in $seq; do
8258+ testvim=`which $i 2>/dev/null`
8259 if test -f "$testvim"; then
8260- VIM=vim
8261- else
8262- VIM=vi
8263+ VIM=$i
8264+ break
8265 fi
8266+done
8267+
8268+# When no Vim version was found fall back to "vim", you'll get an error message
8269+# below.
8270+if test -z "$VIM"; then
8271+ VIM=vim
8272 fi
8273
8274 # Use Vim to copy the tutor, it knows the value of $VIMRUNTIME
8275diff -Naur vim71.orig/src/window.c vim71/src/window.c
8276--- vim71.orig/src/window.c 2007-05-07 12:25:30.000000000 -0700
[2830f42]8277+++ vim71/src/window.c 2007-10-29 08:09:40.000000000 -0700
[ba61c16]8278@@ -75,6 +75,7 @@
8279 static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
8280
8281 #endif /* FEAT_WINDOWS */
8282+
8283 static win_T *win_alloc __ARGS((win_T *after));
8284 static void win_new_height __ARGS((win_T *, int));
8285
[c2aa910]8286@@ -583,7 +584,7 @@
8287 ++no_mapping;
8288 ++allow_keys; /* no mapping for xchar, but allow key codes */
8289 if (xchar == NUL)
8290- xchar = safe_vgetc();
8291+ xchar = plain_vgetc();
8292 #ifdef FEAT_LANGMAP
8293 LANGMAP_ADJUST(xchar, TRUE);
8294 #endif
[ba61c16]8295@@ -732,7 +733,6 @@
8296 if (flags & WSP_VERT)
8297 {
8298 layout = FR_ROW;
8299- do_equal = (p_ea && new_size == 0 && *p_ead != 'v');
8300
8301 /*
8302 * Check if we are able to split the current window and compute its
8303@@ -769,16 +769,31 @@
8304 * instead, if possible. */
8305 if (oldwin->w_p_wfw)
8306 win_setwidth_win(oldwin->w_width + new_size, oldwin);
8307+
8308+ /* Only make all windows the same width if one of them (except oldwin)
8309+ * is wider than one of the split windows. */
8310+ if (!do_equal && p_ea && size == 0 && *p_ead != 'v'
8311+ && oldwin->w_frame->fr_parent != NULL)
8312+ {
8313+ frp = oldwin->w_frame->fr_parent->fr_child;
8314+ while (frp != NULL)
8315+ {
8316+ if (frp->fr_win != oldwin && frp->fr_win != NULL
8317+ && (frp->fr_win->w_width > new_size
8318+ || frp->fr_win->w_width > oldwin->w_width
8319+ - new_size - STATUS_HEIGHT))
8320+ {
8321+ do_equal = TRUE;
8322+ break;
8323+ }
8324+ frp = frp->fr_next;
8325+ }
8326+ }
8327 }
8328 else
8329 #endif
8330 {
8331 layout = FR_COL;
8332- do_equal = (p_ea && new_size == 0
8333-#ifdef FEAT_VERTSPLIT
8334- && *p_ead != 'h'
8335-#endif
8336- );
8337
8338 /*
8339 * Check if we are able to split the current window and compute its
8340@@ -831,6 +846,29 @@
8341 if (need_status)
8342 oldwin_height -= STATUS_HEIGHT;
8343 }
8344+
8345+ /* Only make all windows the same height if one of them (except oldwin)
8346+ * is higher than one of the split windows. */
8347+ if (!do_equal && p_ea && size == 0
8348+#ifdef FEAT_VERTSPLIT
8349+ && *p_ead != 'h'
8350+#endif
8351+ && oldwin->w_frame->fr_parent != NULL)
8352+ {
8353+ frp = oldwin->w_frame->fr_parent->fr_child;
8354+ while (frp != NULL)
8355+ {
8356+ if (frp->fr_win != oldwin && frp->fr_win != NULL
8357+ && (frp->fr_win->w_height > new_size
8358+ || frp->fr_win->w_height > oldwin_height - new_size
8359+ - STATUS_HEIGHT))
8360+ {
8361+ do_equal = TRUE;
8362+ break;
8363+ }
8364+ frp = frp->fr_next;
8365+ }
8366+ }
8367 }
8368
8369 /*
[c2aa910]8370@@ -1253,7 +1291,7 @@
8371 * Don't execute autocommands while creating the windows. Must do that
8372 * when putting the buffers in the windows.
8373 */
8374- ++autocmd_block;
8375+ block_autocmds();
8376 #endif
8377
8378 /* todo is number of windows left to create */
8379@@ -1275,7 +1313,7 @@
8380 }
8381
8382 #ifdef FEAT_AUTOCMD
8383- --autocmd_block;
8384+ unblock_autocmds();
8385 #endif
8386
8387 /* return actual number of windows */
[ba61c16]8388@@ -2120,7 +2158,7 @@
8389 if (wp->w_p_pvw || bt_quickfix(wp->w_buffer))
8390 {
8391 /*
8392- * The cursor goes to the preview or the quickfix window, try
8393+ * If the cursor goes to the preview or the quickfix window, try
8394 * finding another window to go to.
8395 */
8396 for (;;)
8397@@ -2307,7 +2345,6 @@
8398 frame_T *frp, *frp2, *frp3;
8399 frame_T *frp_close = win->w_frame;
8400 win_T *wp;
8401- int old_size = 0;
8402
8403 /*
8404 * If there is only one window there is nothing to remove.
8405@@ -2328,33 +2365,77 @@
8406 if (frp_close->fr_parent->fr_layout == FR_COL)
8407 {
8408 #endif
8409- /* When 'winfixheight' is set, remember its old size and restore
8410- * it later (it's a simplistic solution...). Don't do this if the
8411- * window will occupy the full height of the screen. */
8412- if (frp2->fr_win != NULL
8413- && (frp2->fr_next != NULL || frp2->fr_prev != NULL)
8414- && frp2->fr_win->w_p_wfh)
8415- old_size = frp2->fr_win->w_height;
8416+ /* When 'winfixheight' is set, try to find another frame in the column
8417+ * (as close to the closed frame as possible) to distribute the height
8418+ * to. */
8419+ if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfh)
8420+ {
8421+ frp = frp_close->fr_prev;
8422+ frp3 = frp_close->fr_next;
8423+ while (frp != NULL || frp3 != NULL)
8424+ {
8425+ if (frp != NULL)
8426+ {
8427+ if (frp->fr_win != NULL && !frp->fr_win->w_p_wfh)
8428+ {
8429+ frp2 = frp;
8430+ wp = frp->fr_win;
8431+ break;
8432+ }
8433+ frp = frp->fr_prev;
8434+ }
8435+ if (frp3 != NULL)
8436+ {
8437+ if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfh)
8438+ {
8439+ frp2 = frp3;
8440+ wp = frp3->fr_win;
8441+ break;
8442+ }
8443+ frp3 = frp3->fr_next;
8444+ }
8445+ }
8446+ }
8447 frame_new_height(frp2, frp2->fr_height + frp_close->fr_height,
8448 frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE);
8449- if (old_size != 0)
8450- win_setheight_win(old_size, frp2->fr_win);
8451 #ifdef FEAT_VERTSPLIT
8452 *dirp = 'v';
8453 }
8454 else
8455 {
8456- /* When 'winfixwidth' is set, remember its old size and restore
8457- * it later (it's a simplistic solution...). Don't do this if the
8458- * window will occupy the full width of the screen. */
8459- if (frp2->fr_win != NULL
8460- && (frp2->fr_next != NULL || frp2->fr_prev != NULL)
8461- && frp2->fr_win->w_p_wfw)
8462- old_size = frp2->fr_win->w_width;
8463+ /* When 'winfixwidth' is set, try to find another frame in the column
8464+ * (as close to the closed frame as possible) to distribute the width
8465+ * to. */
8466+ if (frp2->fr_win != NULL && frp2->fr_win->w_p_wfw)
8467+ {
8468+ frp = frp_close->fr_prev;
8469+ frp3 = frp_close->fr_next;
8470+ while (frp != NULL || frp3 != NULL)
8471+ {
8472+ if (frp != NULL)
8473+ {
8474+ if (frp->fr_win != NULL && !frp->fr_win->w_p_wfw)
8475+ {
8476+ frp2 = frp;
8477+ wp = frp->fr_win;
8478+ break;
8479+ }
8480+ frp = frp->fr_prev;
8481+ }
8482+ if (frp3 != NULL)
8483+ {
8484+ if (frp3->fr_win != NULL && !frp3->fr_win->w_p_wfw)
8485+ {
8486+ frp2 = frp3;
8487+ wp = frp3->fr_win;
8488+ break;
8489+ }
8490+ frp3 = frp3->fr_next;
8491+ }
8492+ }
8493+ }
8494 frame_new_width(frp2, frp2->fr_width + frp_close->fr_width,
8495 frp2 == frp_close->fr_next ? TRUE : FALSE, FALSE);
8496- if (old_size != 0)
8497- win_setwidth_win(old_size, frp2->fr_win);
8498 *dirp = 'h';
8499 }
8500 #endif
[c2aa910]8501@@ -3334,7 +3415,7 @@
8502 * Don't execute autocommands while creating the tab pages. Must do that
8503 * when putting the buffers in the windows.
8504 */
8505- ++autocmd_block;
8506+ block_autocmds();
8507 #endif
8508
8509 for (todo = count - 1; todo > 0; --todo)
8510@@ -3342,7 +3423,7 @@
8511 break;
8512
[ba61c16]8513 #ifdef FEAT_AUTOCMD
[c2aa910]8514- --autocmd_block;
8515+ unblock_autocmds();
8516 #endif
8517
8518 /* return actual number of tab pages */
8519@@ -4081,7 +4162,7 @@
8520 /* Don't execute autocommands while the window is not properly
8521 * initialized yet. gui_create_scrollbar() may trigger a FocusGained
8522 * event. */
8523- ++autocmd_block;
8524+ block_autocmds();
8525 #endif
8526 /*
8527 * link the window in the window list
8528@@ -4126,7 +4207,11 @@
8529 foldInitWin(newwin);
[ba61c16]8530 #endif
[c2aa910]8531 #ifdef FEAT_AUTOCMD
8532- --autocmd_block;
8533+ unblock_autocmds();
8534+#endif
[ba61c16]8535+#ifdef FEAT_SEARCH_EXTRA
8536+ newwin->w_match_head = NULL;
8537+ newwin->w_next_match_id = 4;
[c2aa910]8538 #endif
[ba61c16]8539 }
8540 return newwin;
[c2aa910]8541@@ -4147,7 +4232,7 @@
8542 #ifdef FEAT_AUTOCMD
8543 /* Don't execute autocommands while the window is halfway being deleted.
8544 * gui_mch_destroy_scrollbar() may trigger a FocusGained event. */
8545- ++autocmd_block;
8546+ block_autocmds();
8547 #endif
8548
8549 #ifdef FEAT_MZSCHEME
[ba61c16]8550@@ -4185,11 +4270,11 @@
8551 vim_free(wp->w_tagstack[i].tagname);
8552
8553 vim_free(wp->w_localdir);
8554+
8555 #ifdef FEAT_SEARCH_EXTRA
8556- vim_free(wp->w_match[0].regprog);
8557- vim_free(wp->w_match[1].regprog);
8558- vim_free(wp->w_match[2].regprog);
8559+ clear_matches(wp);
8560 #endif
8561+
8562 #ifdef FEAT_JUMPLIST
8563 free_jumplist(wp);
8564 #endif
[c2aa910]8565@@ -4210,7 +4295,7 @@
8566 vim_free(wp);
8567
8568 #ifdef FEAT_AUTOCMD
8569- --autocmd_block;
8570+ unblock_autocmds();
8571 #endif
8572 }
8573
8574@@ -5438,6 +5523,7 @@
8575 {
8576 EMSG(_(e_noroom));
8577 p_ch = old_p_ch;
8578+ curtab->tp_ch_used = p_ch;
8579 cmdline_row = Rows - p_ch;
8580 break;
8581 }
8582@@ -6174,3 +6260,175 @@
[ba61c16]8583 return FALSE;
8584 }
8585 #endif
8586+
8587+#if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
8588+/*
8589+ * Add match to the match list of window 'wp'. The pattern 'pat' will be
8590+ * highligted with the group 'grp' with priority 'prio'.
8591+ * Optionally, a desired ID 'id' can be specified (greater than or equal to 1).
8592+ * If no particular ID is desired, -1 must be specified for 'id'.
8593+ * Return ID of added match, -1 on failure.
8594+ */
8595+ int
8596+match_add(wp, grp, pat, prio, id)
8597+ win_T *wp;
8598+ char_u *grp;
8599+ char_u *pat;
8600+ int prio;
8601+ int id;
8602+{
8603+ matchitem_T *cur;
8604+ matchitem_T *prev;
8605+ matchitem_T *m;
8606+ int hlg_id;
8607+ regprog_T *regprog;
8608+
8609+ if (*grp == NUL || *pat == NUL)
8610+ return -1;
8611+ if (id < -1 || id == 0)
8612+ {
8613+ EMSGN("E799: Invalid ID: %ld (must be greater than or equal to 1)", id);
8614+ return -1;
8615+ }
8616+ if (id != -1)
8617+ {
8618+ cur = wp->w_match_head;
8619+ while (cur != NULL)
8620+ {
8621+ if (cur->id == id)
8622+ {
8623+ EMSGN("E801: ID already taken: %ld", id);
8624+ return -1;
8625+ }
8626+ cur = cur->next;
8627+ }
8628+ }
8629+ if ((hlg_id = syn_namen2id(grp, STRLEN(grp))) == 0)
8630+ {
8631+ EMSG2(_(e_nogroup), grp);
8632+ return -1;
8633+ }
8634+ if ((regprog = vim_regcomp(pat, RE_MAGIC)) == NULL)
8635+ {
8636+ EMSG2(_(e_invarg2), pat);
8637+ return -1;
8638+ }
8639+
8640+ /* Find available match ID. */
8641+ while (id == -1)
8642+ {
8643+ cur = wp->w_match_head;
8644+ while (cur != NULL && cur->id != wp->w_next_match_id)
8645+ cur = cur->next;
8646+ if (cur == NULL)
8647+ id = wp->w_next_match_id;
8648+ wp->w_next_match_id++;
8649+ }
8650+
8651+ /* Build new match. */
8652+ m = (matchitem_T *)alloc(sizeof(matchitem_T));
8653+ m->id = id;
8654+ m->priority = prio;
8655+ m->pattern = vim_strsave(pat);
8656+ m->hlg_id = hlg_id;
8657+ m->match.regprog = regprog;
8658+ m->match.rmm_ic = FALSE;
8659+ m->match.rmm_maxcol = 0;
8660+
8661+ /* Insert new match. The match list is in ascending order with regard to
8662+ * the match priorities. */
8663+ cur = wp->w_match_head;
8664+ prev = cur;
8665+ while (cur != NULL && prio >= cur->priority)
8666+ {
8667+ prev = cur;
8668+ cur = cur->next;
8669+ }
8670+ if (cur == prev)
8671+ wp->w_match_head = m;
8672+ else
8673+ prev->next = m;
8674+ m->next = cur;
8675+
8676+ redraw_later(SOME_VALID);
8677+ return id;
8678+}
8679+
8680+/*
8681+ * Delete match with ID 'id' in the match list of window 'wp'.
8682+ * Print error messages if 'perr' is TRUE.
8683+ */
8684+ int
8685+match_delete(wp, id, perr)
8686+ win_T *wp;
8687+ int id;
8688+ int perr;
8689+{
8690+ matchitem_T *cur = wp->w_match_head;
8691+ matchitem_T *prev = cur;
8692+
8693+ if (id < 1)
8694+ {
8695+ if (perr == TRUE)
8696+ EMSGN("E802: Invalid ID: %ld (must be greater than or equal to 1)",
8697+ id);
8698+ return -1;
8699+ }
8700+ while (cur != NULL && cur->id != id)
8701+ {
8702+ prev = cur;
8703+ cur = cur->next;
8704+ }
8705+ if (cur == NULL)
8706+ {
8707+ if (perr == TRUE)
8708+ EMSGN("E803: ID not found: %ld", id);
8709+ return -1;
8710+ }
8711+ if (cur == prev)
8712+ wp->w_match_head = cur->next;
8713+ else
8714+ prev->next = cur->next;
8715+ vim_free(cur->match.regprog);
8716+ vim_free(cur->pattern);
8717+ vim_free(cur);
8718+ redraw_later(SOME_VALID);
8719+ return 0;
8720+}
8721+
8722+/*
8723+ * Delete all matches in the match list of window 'wp'.
8724+ */
8725+ void
8726+clear_matches(wp)
8727+ win_T *wp;
8728+{
8729+ matchitem_T *m;
8730+
8731+ while (wp->w_match_head != NULL)
8732+ {
8733+ m = wp->w_match_head->next;
8734+ vim_free(wp->w_match_head->match.regprog);
8735+ vim_free(wp->w_match_head->pattern);
8736+ vim_free(wp->w_match_head);
8737+ wp->w_match_head = m;
8738+ }
8739+ redraw_later(SOME_VALID);
8740+}
8741+
8742+/*
8743+ * Get match from ID 'id' in window 'wp'.
8744+ * Return NULL if match not found.
8745+ */
8746+ matchitem_T *
8747+get_match(wp, id)
8748+ win_T *wp;
8749+ int id;
8750+{
8751+ matchitem_T *cur = wp->w_match_head;
8752+
8753+ while (cur != NULL && cur->id != id)
8754+ cur = cur->next;
8755+ return cur;
8756+}
8757+#endif
Note: See TracBrowser for help on using the repository browser.