Merge upstream/hg/vim73 into macvim73

Conflicts:
	src/auto/configure
This commit is contained in:
Bjorn Winckler
2010-05-30 18:39:14 +02:00
31 changed files with 340 additions and 162 deletions
+5 -1
View File
@@ -1,7 +1,7 @@
" Vim compiler file
" Compiler: GNU C Compiler
" Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2009-05-01
" Latest Revision: 2010-05-30
if exists("current_compiler")
finish
@@ -18,7 +18,11 @@ CompilerSet errorformat=
\\"%f\"%*\\D%l:\ %m,
\%-G%f:%l:\ %trror:\ (Each\ undeclared\ identifier\ is\ reported\ only\ once,
\%-G%f:%l:\ %trror:\ for\ each\ function\ it\ appears\ in.),
\%f:%l:%c:\ %terror:\ %m,
\%f:%l:%c:\ %tarning:\ %m,
\%f:%l:%c:\ %m,
\%f:%l:\ %terror:\ %m,
\%f:%l:\ %tarning:\ %m,
\%f:%l:\ %m,
\\"%f\"\\,\ line\ %l%*\\D%c%*[^\ ]\ %m,
\%D%*\\a[%*\\d]:\ Entering\ directory\ `%f',
+10
View File
@@ -1943,6 +1943,7 @@ tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr}
to chars in {tostr}
trunc( {expr} Float truncate Float {expr}
type( {name}) Number type of variable {name}
undofile( {name}) String undo file name for {name}
values( {dict}) List values in {dict}
virtcol( {expr}) Number screen column of cursor or mark
visualmode( [expr]) String last visual mode used
@@ -5767,6 +5768,15 @@ type({expr}) The result is a Number, depending on the type of {expr}:
:if type(myvar) == type({})
:if type(myvar) == type(0.0)
undofile({name}) *undofile()*
Return the name of the undo file that would be used for a file
with name {name} when writing. This uses the 'undodir'
option, finding directories that exist. It does not check if
the undo file exist.
Useful in combination with |:wundo| and |:rundo|.
When compiled without the +persistent_undo option this always
returns an empty string.
values({dict}) *values()*
Return a |List| with all the values of {dict}. The |List| is
in arbitrary order.
+3 -3
View File
@@ -775,7 +775,7 @@ is suitable for complex input, such as CJK.
For Chinese, there's a great XIM server named "xcin", you can input both
Traditional and Simplified Chinese characters. And it can accept other
locale if you make a correct input table. Xcin can be found at:
http://xcin.linux.org.tw/
http://cle.linux.org.tw/xcin/
Others are scim: http://scim.freedesktop.org/ and fcitx:
http://www.fcitx.org/
@@ -963,10 +963,10 @@ WHAT IS GLOBAL IME *global-ime*
language version of Global IME at same place.
- Global IME detailed information.
http://www.microsoft.com/windows/ie/features/ime.asp
http://search.microsoft.com/results.aspx?q=global+ime
- Active Input Method Manager (Global IME)
http://msdn.microsoft.com/workshop/misc/AIMM/aimm.asp
http://msdn.microsoft.com/en-us/library/aa741221(v=VS.85).aspx
Support for Global IME is an experimental feature.
+2 -1
View File
@@ -19,7 +19,7 @@ The ":messages" command can be used to view previously given messages. This
is especially useful when messages have been overwritten or truncated. This
depends on the 'shortmess' option.
The number of remembered messages is fixed at 20 for the tiny version and 100
The number of remembered messages is fixed at 20 for the tiny version and 200
for other versions.
*g<*
@@ -585,6 +585,7 @@ when using ":w"), therefore Vim requires using a ! after the command, e.g.:
Messages like this appear when starting up. This is not a Vim problem, your
X11 configuration is wrong. You can find a hint on how to solve this here:
http://groups.yahoo.com/group/solarisonintel/message/12179.
[this URL is no longer valid]
*W10* >
Warning: Changing a readonly file
+2 -1
View File
@@ -183,7 +183,8 @@ anyway you need an additional tool which gives you access to the clipboard
from within a vio application. The freeware package clipbrd.zip by Stefan
Gruendel can be used for this purpose. You might download the package
including precompiled binaries and all sources from:
http://www.stellarcom.org/vim/index.html
http://www.os2site.com/sw/util/clipboard/index.html
http://download.uni-hd.de/ftp/pub/os2/pmtools/
Installation of this package is straight forward: just put the two executables
that come with this package into a directory within your PATH for Vim should
+1 -1
View File
@@ -490,7 +490,7 @@ Traditional Chinese fonts available at:
You can find descriptions of the various fonts in the read me file at
http://examples.oreilly.com/cjkvinfo/adobe/00README
http://examples.oreilly.de/english_examples/cjkvinfo/adobe/00README
Please read your printer documentation on how to install new fonts.
+2 -1
View File
@@ -828,7 +828,8 @@ startup vimrc: >
DESKTOP *desktop.vim* *ft-desktop-syntax*
Primary goal of this syntax file is to highlight .desktop and .directory files
according to freedesktop.org standard: http://pdx.freedesktop.org/Standards/
according to freedesktop.org standard:
http://standards.freedesktop.org/desktop-entry-spec/latest/
But actually almost none implements this standard fully. Thus it will
highlight all Unix ini files. But you can force strict highlighting according
to standard by placing this in your vimrc file: >
+1
View File
@@ -7952,6 +7952,7 @@ undo-tree undo.txt /*undo-tree*
undo-two-ways undo.txt /*undo-two-ways*
undo.txt undo.txt /*undo.txt*
undo_ftplugin usr_41.txt /*undo_ftplugin*
undofile() eval.txt /*undofile()*
unicode mbyte.txt /*unicode*
unix os_unix.txt /*unix*
unlisted-buffer windows.txt /*unlisted-buffer*
-7
View File
@@ -30,10 +30,6 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
*known-bugs*
-------------------- Known bugs and current work -----------------------
Fixes for broken URLs:
Benjamin Haskell, 2010 May 25
Christian Brabandt, 2010 May 26, two messages
Cursor positioning wrong with 0x200e character. (John Becket, 2010 May 6)
E315 when trying to change a file in FileChangedRO autocommand event.
@@ -1093,10 +1089,7 @@ Vim 7.3:
Use register_shell_extension()? (George Reilly, 2010 May 26)
Ron's version: http://dev.ronware.org/p/vim/finfo?name=gvim.nsi
- Persistent undo bugs / fixes:
- Memory leak reproduced by Dominique Pelle, 2010 May 28.
- When there is no undo info (undolevels negative), delete the undo file.
- Need to check all values for evil manipulation.
- Add undofile(name): get undo file name for buffer "name".
- patch for unused functions. (Dominique Pelle, 2010 May 29)
- Also crypt the undo file.
- Also crypt the swap file, each block separately. Change mf_write() and
+17 -3
View File
@@ -243,12 +243,26 @@ respectively:
You can use these in autocommands to explicitly specify the name of the
history file. E.g.: >
au BufReadPost * rundo %:h/UNDO/%:t
au BufWritePost * wundo %:h/UNDO/%:t
au BufReadPost * call ReadUndo()
au BufWritePost * call WriteUndo()
func ReadUndo()
if filereadable(expand('%:h'). '/UNDO/' . expand('%:t'))
rundo %:h/UNDO/%:t
endif
endfunc
func WriteUndo()
let dirname = expand('%:h') . '/UNDO'
if !isdirectory(dirname)
call mkdir(dirname)
endif
wundo %:h/UNDO/%:t
endfunc
You should keep 'undofile' off, otherwise you end up with two undo files for
every write.
Note: I did not verify this always works!
You can use the |undofile()| function to find out the file name that Vim would
use.
Note that while reading/writing files and 'undofile' is set most errors will
be silent, unless 'verbose' is set. With :wundo and :rundo you will get more
+5 -5
View File
@@ -89,10 +89,10 @@ Without it the toolbar and signs will be disabled.
The XPM library is provide by Arnaud Le Hors of the French National Institute
for Research in Computer Science and Control. It can be downloaded from
http://koala.ilog.fr/ftp/pub/xpm. The current release, as of this writing, is
xpm-3.4k-solaris.tgz, which is a gzip'ed tar file. If you create the directory
/usr/local/xpm and untar the file there you can use the uncommented lines in
the Makefile without changing them. If you use another xpm directory you will
need to change the XPM_DIR in src/Makefile.
http://cgit.freedesktop.org/xorg/lib/libXpm. The current release, as of this
writing, is xpm-3.4k-solaris.tgz, which is a gzip'ed tar file. If you create
the directory /usr/local/xpm and untar the file there you can use the
uncommented lines in the Makefile without changing them. If you use another
xpm directory you will need to change the XPM_DIR in src/Makefile.
vim:tw=78:ts=8:ft=help:norl:
+2 -2
View File
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: YAML (YAML Ain't Markup Language)
" Maintainer: Nikolai Weibull <now@bitwi.se>
" Latest Revision: 2006-04-19
" Latest Revision: 2010-05-30
if exists("b:current_syntax")
finish
@@ -17,7 +17,7 @@ syn region yamlComment display oneline start='\%(^\|\s\)#' end='$'
syn match yamlNodeProperty '!\%(![^\\^% ]\+\|[^!][^:/ ]*\)'
syn match yamlAnchor '&.\+'
syn match yamlAnchor '&[^ \t]\+'
syn match yamlAlias '\*.\+'
+75
View File
@@ -15921,6 +15921,81 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
{ echo "$as_me:$LINENO: checking size of time_t" >&5
echo $ECHO_N "checking size of time_t... $ECHO_C" >&6; }
if test "${ac_cv_sizeof_time_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
{ { echo "$as_me:$LINENO: error: failed to compile test program" >&5
echo "$as_me: error: failed to compile test program" >&2;}
{ (exit 1); exit 1; }; }
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdio.h>
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#endif
#include <time.h>
main()
{
FILE *f=fopen("conftestval", "w");
if (!f) exit(1);
fprintf(f, "%d\n", (int)sizeof(time_t));
exit(0);
}
_ACEOF
rm -f conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_sizeof_time_t=`cat conftestval`
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
{ { echo "$as_me:$LINENO: error: failed to determine sizeof(time_t)" >&5
echo "$as_me: error: failed to determine sizeof(time_t)" >&2;}
{ (exit 1); exit 1; }; }
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_time_t" >&5
echo "${ECHO_T}$ac_cv_sizeof_time_t" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_TIME_T $ac_cv_sizeof_time_t
_ACEOF
{ echo "$as_me:$LINENO: checking uint32_t is 32 bits" >&5
echo $ECHO_N "checking uint32_t is 32 bits... $ECHO_C" >&6; }
if test "$cross_compiling" = yes; then
+3
View File
@@ -39,6 +39,9 @@
/* Defined to the size of an int */
#undef SIZEOF_INT
/* Defined to the size of time_t */
#undef SIZEOF_TIME_T
/* Define when wchar_t is only 2 bytes. */
#undef SMALL_WCHAR_T
+23
View File
@@ -3052,6 +3052,29 @@ main()
AC_MSG_RESULT($ac_cv_sizeof_int)
AC_DEFINE_UNQUOTED(SIZEOF_INT, $ac_cv_sizeof_int)
dnl Figure out sizeof(time_t) so that it can be used in #ifdef.
AC_MSG_CHECKING(size of time_t)
AC_CACHE_VAL(ac_cv_sizeof_time_t,
[AC_TRY_RUN([
#include <stdio.h>
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#endif
#include <time.h>
main()
{
FILE *f=fopen("conftestval", "w");
if (!f) exit(1);
fprintf(f, "%d\n", (int)sizeof(time_t));
exit(0);
}],
ac_cv_sizeof_time_t=`cat conftestval`,
AC_MSG_ERROR([failed to determine sizeof(time_t)]),
AC_MSG_ERROR([failed to compile test program]))])
AC_MSG_RESULT($ac_cv_sizeof_time_t)
AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
dnl Make sure that uint32_t is really 32 bits unsigned.
AC_MSG_CHECKING([uint32_t is 32 bits])
AC_TRY_RUN([
+19
View File
@@ -731,6 +731,7 @@ static void f_tr __ARGS((typval_T *argvars, typval_T *rettv));
static void f_trunc __ARGS((typval_T *argvars, typval_T *rettv));
#endif
static void f_type __ARGS((typval_T *argvars, typval_T *rettv));
static void f_undofile __ARGS((typval_T *argvars, typval_T *rettv));
static void f_values __ARGS((typval_T *argvars, typval_T *rettv));
static void f_virtcol __ARGS((typval_T *argvars, typval_T *rettv));
static void f_visualmode __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7825,6 +7826,7 @@ static struct fst
{"trunc", 1, 1, f_trunc},
#endif
{"type", 1, 1, f_type},
{"undofile", 1, 1, f_undofile},
{"values", 1, 1, f_values},
{"virtcol", 1, 1, f_virtcol},
{"visualmode", 0, 1, f_visualmode},
@@ -17603,6 +17605,23 @@ f_type(argvars, rettv)
rettv->vval.v_number = n;
}
/*
* "undofile(name)" function
*/
static void
f_undofile(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
rettv->v_type = VAR_STRING;
#ifdef FEAT_PERSISTENT_UNDO
rettv->vval.v_string = u_get_undo_file_name(get_tv_string(&argvars[0]),
FALSE);
#else
rettv->vval.v_string = NULL;
#endif
}
/*
* "values(dict)" function
*/
+1 -1
View File
@@ -130,7 +130,7 @@
* Message history is fixed at 100 message, 20 for the tiny version.
*/
#ifdef FEAT_SMALL
# define MAX_MSG_HIST_LEN 100
# define MAX_MSG_HIST_LEN 200
#else
# define MAX_MSG_HIST_LEN 20
#endif
+9 -8
View File
@@ -6260,9 +6260,10 @@ put_time(fd, the_time)
/* time_t can be up to 8 bytes in size, more than long_u, thus we
* can't use put_bytes() here.
* Another problem is that ">>" may do an arithmetic shift that keeps the
* sign. A cast to long_u may truncate if time_t is 8 bytes. So only use
* a cast when it is 4 bytes, it's safe to assume that long_u is 4 bytes
* or more and when using 8 bytes the top bit won't be set. */
* sign. This happens for large values of wtime. A cast to long_u may
* truncate if time_t is 8 bytes. So only use a cast when it is 4 bytes,
* it's safe to assume that long_u is 4 bytes or more and when using 8
* bytes the top bit won't be set. */
for (i = 7; i >= 0; --i)
{
if (i + 1 > (int)sizeof(time_t))
@@ -6270,11 +6271,11 @@ put_time(fd, the_time)
putc(0, fd);
else
{
/* use "i" in condition to avoid compiler warning */
if (i >= 0 && sizeof(time_t) > 4)
c = wtime >> (i * 8);
else
c = (long_u)wtime >> (i * 8);
#if defined(SIZEOF_TIME_T) && SIZEOF_TIME_T > 4
c = wtime >> (i * 8);
#else
c = (long_u)wtime >> (i * 8);
#endif
putc(c, fd);
}
}
+2 -1
View File
@@ -7,8 +7,9 @@ int u_inssub __ARGS((linenr_T lnum));
int u_savedel __ARGS((linenr_T lnum, long nlines));
int undo_allowed __ARGS((void));
void u_compute_hash __ARGS((char_u *hash));
void u_read_undo __ARGS((char_u *name, char_u *hash));
char_u *u_get_undo_file_name __ARGS((char_u *buf_ffname, int reading));
void u_write_undo __ARGS((char_u *name, int forceit, buf_T *buf, char_u *hash));
void u_read_undo __ARGS((char_u *name, char_u *hash));
void u_undo __ARGS((int count));
void u_redo __ARGS((int count));
void undo_time __ARGS((long step, int sec, int absolute));
-20
View File
@@ -341,18 +341,6 @@ struct m_info
minfo_T *m_next; /* pointer to next free chunk in the list */
};
/*
* structure used to link blocks in the list of allocated blocks.
*/
typedef struct m_block mblock_T;
struct m_block
{
mblock_T *mb_next; /* pointer to next allocated block */
size_t mb_size; /* total size of all chunks in this block */
size_t mb_maxsize; /* size of largest fee chunk */
minfo_T mb_info; /* head of free chunk list for this block */
};
/*
* things used in memfile.c
*/
@@ -1286,14 +1274,6 @@ struct file_buffer
linenr_T b_u_line_lnum; /* line number of line in u_line */
colnr_T b_u_line_colnr; /* optional column number */
/*
* The following only used in undo.c
*/
mblock_T b_block_head; /* head of allocated memory block list */
minfo_T *b_m_search; /* pointer to chunk before previously
allocated/freed chunk */
mblock_T *b_mb_current; /* block where m_search points in */
#ifdef FEAT_INS_EXPAND
int b_scanned; /* ^N/^P have scanned this buffer */
#endif
+5 -1
View File
@@ -26,7 +26,8 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test48.out test51.out test53.out test54.out test55.out \
test56.out test57.out test58.out test59.out test60.out \
test61.out test62.out test63.out test64.out test65.out \
test66.out test67.out test68.out test69.out
test66.out test67.out test68.out test69.out test70.out \
test71.out test72.out
.SUFFIXES: .in .out
@@ -115,3 +116,6 @@ test66.out: test66.in
test67.out: test67.in
test68.out: test68.in
test69.out: test69.in
test70.out: test70.in
test71.out: test71.in
test72.out: test72.in
+1 -1
View File
@@ -27,7 +27,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test30.out test31.out test32.out test33.out test34.out \
test37.out test38.out test39.out test40.out test41.out \
test42.out test52.out test65.out test66.out test67.out \
test68.out test69.out test71.out
test68.out test69.out test71.out test72.out
SCRIPTS32 = test50.out test70.out
+1 -1
View File
@@ -46,7 +46,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test30.out test31.out test32.out test33.out test34.out \
test37.out test38.out test39.out test40.out test41.out \
test42.out test52.out test65.out test66.out test67.out \
test68.out test69.out test71.out
test68.out test69.out test71.out test72.out
SCRIPTS32 = test50.out test70.out
+2 -1
View File
@@ -26,7 +26,8 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test48.out test51.out test53.out test54.out test55.out \
test56.out test57.out test58.out test59.out test60.out \
test61.out test62.out test63.out test64.out test65.out \
test66.out test67.out test68.out test69.out
test66.out test67.out test68.out test69.out test70.out \
test71.out test72.out
.SUFFIXES: .in .out
+2 -1
View File
@@ -69,7 +69,8 @@ SCRIPT = test1.out test2.out test3.out test4.out test5.out \
test48.out test51.out test53.out test54.out test55.out \
test56.out test57.out test60.out \
test61.out test62.out test63.out test64.out test65.out \
test66.out test67.out test68.out test69.out
test66.out test67.out test68.out test69.out test70.out \
test71.out test72.out
.IFDEF WANT_GUI
SCRIPT_GUI = test16.out
+1 -1
View File
@@ -23,7 +23,7 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
test54.out test55.out test56.out test57.out test58.out \
test59.out test60.out test61.out test62.out test63.out \
test64.out test65.out test66.out test67.out test68.out \
test69.out test70.out test71.out
test69.out test70.out test71.out test72.out
SCRIPTS_GUI = test16.out
-47
View File
@@ -50,53 +50,6 @@ obbbbu:.w >>test.out
obbbb:set ul=100
:undojoin
occccu:.w >>test.out
:"
:" Test 'undofile': first a simple one-line change.
:set nocp ul=100 undofile
:e! Xtestfile
ggdGithis is one line:set ul=100
:s/one/ONE/
:set ul=100
:w
:bwipe!
:e Xtestfile
u:.w >>test.out
:"
:" Test 'undofile', change in original file fails check
:set noundofile
:e! Xtestfile
:s/line/Line/
:w
:set undofile
:bwipe!
:e Xtestfile
u:.w >>test.out
:"
:" Test 'undofile', add 10 lines, delete 6 lines, undo 3
:set undofile
ggdGione
two
three
four
five
six
seven
eight
nine
ten:set ul=100
3Gdd:set ul=100
dd:set ul=100
dd:set ul=100
dd:set ul=100
dd:set ul=100
dd:set ul=100
:w
:bwipe!
:e Xtestfile
uuu:w >>test.out
:"
:" Rename the undo file so that it gets cleaned up.
:call rename(".Xtestfile.un~", "Xtestundo")
:qa!
ENDTEST
-9
View File
@@ -22,12 +22,3 @@
123456abc
aaaa
aaaa
this is one line
this is ONE Line
one
two
six
seven
eight
nine
ten
+60
View File
@@ -0,0 +1,60 @@
Tests for undo file.
Since this script is sourced we need to explicitly break changes up in
undo-able pieces. Do that by setting 'undolevels'.
STARTTEST
:so small.vim
:"
:" Test 'undofile': first a simple one-line change.
:set nocp ul=100 undofile
:e! Xtestfile
ggdGithis is one line:set ul=100
:s/one/ONE/
:set ul=100
:w
:bwipe!
:e Xtestfile
u:.w! test.out
:"
:" Test 'undofile', change in original file fails check
:set noundofile
:e! Xtestfile
:s/line/Line/
:w
:set undofile
:bwipe!
:e Xtestfile
u:.w >>test.out
:"
:" Test 'undofile', add 10 lines, delete 6 lines, undo 3
:set undofile
ggdGione
two
three
four
five
six
seven
eight
nine
ten:set ul=100
3Gdd:set ul=100
dd:set ul=100
dd:set ul=100
dd:set ul=100
dd:set ul=100
dd:set ul=100
:w
:bwipe!
:e Xtestfile
uuu:w >>test.out
:"
:" Rename the undo file so that it gets cleaned up.
:call rename(".Xtestfile.un~", "Xtestundo")
:qa!
ENDTEST
1111 -----
2222 -----
123456789
+9
View File
@@ -0,0 +1,9 @@
this is one line
this is ONE Line
one
two
six
seven
eight
nine
ten
+77 -45
View File
@@ -100,7 +100,6 @@ static void u_freebranch __ARGS((buf_T *buf, u_header_T *uhp, u_header_T **uhpp)
static void u_freeentries __ARGS((buf_T *buf, u_header_T *uhp, u_header_T **uhpp));
static void u_freeentry __ARGS((u_entry_T *, long));
#ifdef FEAT_PERSISTENT_UNDO
static char_u *u_get_undo_file_name __ARGS((char_u *, int reading));
static void corruption_error __ARGS((char *msg, char_u *file_name));
static void u_free_uhp __ARGS((u_header_T *uhp));
static int serialize_uep __ARGS((u_entry_T *uep, FILE *fp));
@@ -698,7 +697,7 @@ u_compute_hash(hash)
* When "reading" is FALSE use the first name where the directory exists.
* Returns NULL when there is no place to write or no file to read.
*/
static char_u *
char_u *
u_get_undo_file_name(buf_ffname, reading)
char_u *buf_ffname;
int reading;
@@ -858,6 +857,8 @@ unserialize_uep(fp, error, file_name)
}
vim_memset(array, 0, sizeof(char_u *) * uep->ue_size);
}
else
array = NULL;
uep->ue_array = array;
for (i = 0; i < uep->ue_size; ++i)
@@ -996,7 +997,12 @@ u_write_undo(name, forceit, buf, hash)
if (file_name == NULL)
{
if (p_verbose > 0)
smsg((char_u *)_("Cannot write undo file in any directory in 'undodir'"));
{
verbose_enter();
smsg((char_u *)
_("Cannot write undo file in any directory in 'undodir'"));
verbose_leave();
}
return;
}
}
@@ -1038,8 +1044,15 @@ u_write_undo(name, forceit, buf, hash)
if (fd < 0)
{
if (name != NULL || p_verbose > 0)
smsg((char_u *)_("Will not overwrite with undo file, cannot read: %s"),
{
if (name == NULL)
verbose_enter();
smsg((char_u *)
_("Will not overwrite with undo file, cannot read: %s"),
file_name);
if (name == NULL)
verbose_leave();
}
goto theend;
}
else
@@ -1053,8 +1066,14 @@ u_write_undo(name, forceit, buf, hash)
|| memcmp(buf, UF_START_MAGIC, UF_START_MAGIC_LEN) != 0)
{
if (name != NULL || p_verbose > 0)
{
if (name == NULL)
verbose_enter();
smsg((char_u *)_("Will not overwrite, this is not an undo file: %s"),
file_name);
if (name == NULL)
verbose_leave();
}
goto theend;
}
}
@@ -1062,6 +1081,15 @@ u_write_undo(name, forceit, buf, hash)
mch_remove(file_name);
}
/* If there is no undo information at all, quit here after deleting any
* existing undo file. */
if (buf->b_u_numhead == 0)
{
if (p_verbose > 0)
verb_msg((char_u *)_("Skipping undo file write, noting to undo"));
goto theend;
}
fd = mch_open((char *)file_name,
O_CREAT|O_EXTRA|O_WRONLY|O_EXCL|O_NOFOLLOW, perm);
if (fd < 0)
@@ -1071,7 +1099,16 @@ u_write_undo(name, forceit, buf, hash)
}
(void)mch_setperm(file_name, perm);
if (p_verbose > 0)
{
verbose_enter();
smsg((char_u *)_("Writing undo file: %s"), file_name);
verbose_leave();
}
#ifdef U_DEBUG
/* Check there is no problem in undo info before writing. */
u_check(FALSE);
#endif
#ifdef UNIX
/*
@@ -1101,6 +1138,9 @@ u_write_undo(name, forceit, buf, hash)
goto theend;
}
/* Undo must be synced. */
u_sync(TRUE);
/* Start writing, first the undo file header. */
if (fwrite(UF_START_MAGIC, (size_t)UF_START_MAGIC_LEN, (size_t)1, fp) != 1)
goto write_error;
@@ -1280,7 +1320,11 @@ u_read_undo(name, hash)
file_name = name;
if (p_verbose > 0)
{
verbose_enter();
smsg((char_u *)_("Reading undo file: %s"), file_name);
verbose_leave();
}
fp = mch_fopen((char *)file_name, "r");
if (fp == NULL)
{
@@ -1316,9 +1360,11 @@ u_read_undo(name, hash)
{
if (p_verbose > 0 || name != NULL)
{
verbose_enter();
if (name == NULL)
verbose_enter();
give_warning((char_u *)_("File contents changed, cannot use undo info"), TRUE);
verbose_leave();
if (name == NULL)
verbose_leave();
}
goto error;
}
@@ -1357,7 +1403,6 @@ u_read_undo(name, hash)
num_head * sizeof(u_header_T *));
if (uhp_table == NULL)
goto error;
vim_memset(uhp_table, 0, num_head * sizeof(u_header_T *));
}
while ((c = get2c(fp)) == UF_HEADER_MAGIC)
@@ -1365,7 +1410,6 @@ u_read_undo(name, hash)
if (num_read_uhps >= num_head)
{
corruption_error("num_head", file_name);
u_free_uhp(uhp);
goto error;
}
@@ -1435,37 +1479,13 @@ u_read_undo(name, hash)
goto error;
}
/* Insertion sort the uhp into the table by its uh_seq. This is
* required because, while the number of uhps is limited to
* num_head, and the uh_seq order is monotonic with respect to
* creation time, the starting uh_seq can be > 0 if any undolevel
* culling was done at undofile write time, and there can be uh_seq
* gaps in the uhps.
*/
for (i = num_read_uhps - 1; i >= -1; i--)
{
/* if i == -1, we've hit the leftmost side of the table, so insert
* at uhp_table[0]. */
if (i == -1 || uhp->uh_seq > uhp_table[i]->uh_seq)
{
/* If we've had to move from the rightmost side of the table,
* we have to shift everything to the right by one spot. */
if (num_read_uhps - i - 1 > 0)
{
memmove(uhp_table + i + 2, uhp_table + i + 1,
(num_read_uhps - i - 1) * sizeof(u_header_T *));
}
uhp_table[i + 1] = uhp;
break;
}
else if (uhp->uh_seq == uhp_table[i]->uh_seq)
{
corruption_error("duplicate uh_seq", file_name);
u_free_uhp(uhp);
goto error;
}
}
num_read_uhps++;
uhp_table[num_read_uhps++] = uhp;
}
if (num_read_uhps != num_head)
{
corruption_error("num_head", file_name);
goto error;
}
if (c != UF_HEADER_END_MAGIC)
@@ -1482,11 +1502,9 @@ u_read_undo(name, hash)
# define SET_FLAG(j)
#endif
/* We've organized all of the uhps into a table sorted by uh_seq. Now we
* iterate through the table and swizzle each sequence number we've
* stored in uh_* into a pointer corresponding to the header with that
* sequence number. Then free curbuf's old undo structure, give curbuf
* the updated {old,new,cur}head pointers, and then free the table. */
/* We have put all of the uhps into a table. Now we iterate through the
* table and swizzle each sequence number we've stored in uh_* into a
* pointer corresponding to the header with that sequence number. */
for (i = 0; i < num_head; i++)
{
uhp = uhp_table[i];
@@ -1496,6 +1514,12 @@ u_read_undo(name, hash)
{
if (uhp_table[j] == NULL)
continue;
if (i != j && uhp_table[i]->uh_seq == uhp_table[j]->uh_seq)
{
corruption_error("duplicate uh_seq", file_name);
goto error;
}
if (uhp_table[j]->uh_seq == (long)uhp->uh_next)
{
uhp->uh_next = uhp_table[j];
@@ -1540,6 +1564,10 @@ u_read_undo(name, hash)
curbuf->b_u_oldhead = old_idx < 0 ? NULL : uhp_table[old_idx];
curbuf->b_u_newhead = new_idx < 0 ? NULL : uhp_table[new_idx];
curbuf->b_u_curhead = cur_idx < 0 ? NULL : uhp_table[cur_idx];
#ifdef U_DEBUG
if (curbuf->b_u_curhead != NULL)
corruption_error("curhead not NULL", file_name);
#endif
curbuf->b_u_line_ptr = line_ptr;
curbuf->b_u_line_lnum = line_lnum;
curbuf->b_u_line_colnr = line_colnr;
@@ -1547,6 +1575,8 @@ u_read_undo(name, hash)
curbuf->b_u_seq_last = seq_last;
curbuf->b_u_seq_cur = seq_cur;
curbuf->b_u_seq_time = seq_time;
curbuf->b_u_synced = TRUE;
vim_free(uhp_table);
#ifdef U_DEBUG
@@ -1565,7 +1595,7 @@ error:
vim_free(line_ptr);
if (uhp_table != NULL)
{
for (i = 0; i < num_head; i++)
for (i = 0; i < num_read_uhps; i++)
if (uhp_table[i] != NULL)
u_free_uhp(uhp_table[i]);
vim_free(uhp_table);
@@ -1924,6 +1954,8 @@ undo_time(step, sec, absolute)
last->uh_alt_next = uhp;
uhp->uh_alt_prev = last;
if (curbuf->b_u_oldhead == uhp)
curbuf->b_u_oldhead = last;
uhp = last;
if (uhp->uh_next != NULL)
uhp->uh_next->uh_prev = uhp;