Compare commits

...

28 Commits

Author SHA1 Message Date
Bram Moolenaar
0a1c0ece44 updated for version 7.2-320 2009-12-16 18:02:47 +00:00
Bram Moolenaar
088598d7d6 updated for version 7.2-319 2009-12-16 17:49:39 +00:00
Bram Moolenaar
5d985b9cca updated for version 7.2-318 2009-12-16 17:28:07 +00:00
Bram Moolenaar
f5b6386f4f updated for version 7.2-317 2009-12-16 17:13:44 +00:00
Bram Moolenaar
56d1db3067 updated for version 7.2-316 2009-12-16 16:14:51 +00:00
Bram Moolenaar
72951077b9 updated for version 7.2-315 2009-12-02 16:58:33 +00:00
Bram Moolenaar
d7cd61723e updated for version 7.2-314 2009-12-02 16:47:11 +00:00
Bram Moolenaar
d7834d3065 updated for version 7.2-313 2009-12-02 16:14:36 +00:00
Bram Moolenaar
243973325e updated for version 7.2-312 2009-12-02 14:02:39 +00:00
Bram Moolenaar
f4888d0535 updated for version 7.2-311 2009-12-02 12:31:27 +00:00
Bram Moolenaar
43b36a3bc6 updated for version 7.2-310 2009-12-02 11:08:38 +00:00
Bram Moolenaar
d32a319f40 updated for version 7.2-309 2009-11-26 19:40:49 +00:00
Bram Moolenaar
5ea08a893a updated for version 7.2-308 2009-11-25 18:51:24 +00:00
Bram Moolenaar
d3005803d5 updated for version 7.2-307 2009-11-25 17:21:32 +00:00
Bram Moolenaar
099d01d4a7 updated for version 7.2-306 2009-11-25 16:14:45 +00:00
Bram Moolenaar
19f990e497 updated for version 7.2-305 2009-11-25 12:08:03 +00:00
Bram Moolenaar
331dafdbb8 updated for version 7.2-304 2009-11-25 11:38:30 +00:00
Bram Moolenaar
4592dee576 updated for version 7.2-303 2009-11-18 19:11:58 +00:00
Bram Moolenaar
f11021be13 updated for version 7.2-302 2009-11-17 16:57:14 +00:00
Bram Moolenaar
97b9810bdf updated for version 7.2-301 2009-11-17 16:41:01 +00:00
Bram Moolenaar
f05da21900 updated for version 7.2-300 2009-11-17 16:13:15 +00:00
Bram Moolenaar
2d7ff056e1 updated for version 7.2-299 2009-11-17 15:08:26 +00:00
Bram Moolenaar
50daf405f7 updated for version 7.2-298 2009-11-17 13:57:22 +00:00
Bram Moolenaar
cde547a8f3 updated for version 7.2-297 2009-11-17 11:43:06 +00:00
Bram Moolenaar
34ef52dd56 updated for version 7.2-296 2009-11-17 11:31:25 +00:00
Bram Moolenaar
627b1d3862 updated for version 7.2-295 2009-11-17 11:20:35 +00:00
Bram Moolenaar
eaf0339211 updated for version 7.2-294 2009-11-17 11:08:52 +00:00
Bram Moolenaar
d7d5b47dc7 updated for version 7.2-293 2009-11-11 16:30:08 +00:00
34 changed files with 900 additions and 202 deletions

View File

@@ -3802,7 +3802,8 @@ map({expr}, {string}) *map()*
Replace each item in {expr} with the result of evaluating
{string}.
Inside {string} |v:val| has the value of the current item.
For a |Dictionary| |v:key| has the key of the current item.
For a |Dictionary| |v:key| has the key of the current item
and for a |List| |v:key| has the index of the current item.
Example: >
:call map(mylist, '"> " . v:val . " <"')
< This puts "> " before and " <" after each item in "mylist".

View File

@@ -2400,6 +2400,12 @@ au BufNewFile,BufRead /etc/xinetd.d/* call s:StarSetf('xinetd')
au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh')
" Use the filetype detect plugins. They may overrule any of the previously
" detected filetypes.
runtime! ftdetect/*.vim
" Generic configuration file (check this last, it's just guessing!)
au BufNewFile,BufRead,StdinReadPost *
\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
@@ -2408,10 +2414,6 @@ au BufNewFile,BufRead,StdinReadPost *
\ setf conf |
\ endif
" Use the plugin-filetype checks last, they may overrule any of the previously
" detected filetypes.
runtime! ftdetect/*.vim
augroup END

69
src/auto/configure vendored
View File

@@ -5126,7 +5126,7 @@ else
vi_cv_path_python_conf=
for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
for subdir in lib share; do
for subdir in lib64 lib share; do
d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
if test -d "$d" && test -f "$d/config.c"; then
vi_cv_path_python_conf="$d"
@@ -13718,8 +13718,8 @@ $as_echo "$ac_try_echo") >&5
$as_echo "pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group" >&6; }
else
vim_cv_tty_group=world
{ $as_echo "$as_me:$LINENO: result: ptys are world accessable" >&5
$as_echo "ptys are world accessable" >&6; }
{ $as_echo "$as_me:$LINENO: result: ptys are world accessible" >&5
$as_echo "ptys are world accessible" >&6; }
fi
else
@@ -13730,8 +13730,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
vim_cv_tty_group=world
{ $as_echo "$as_me:$LINENO: result: can't determine - assume ptys are world accessable" >&5
$as_echo "can't determine - assume ptys are world accessable" >&6; }
{ $as_echo "$as_me:$LINENO: result: can't determine - assume ptys are world accessible" >&5
$as_echo "can't determine - assume ptys are world accessible" >&6; }
fi
rm -rf conftest.dSYM
@@ -14017,11 +14017,12 @@ fi
for ac_func in bcmp fchdir fchown fseeko fsync ftello getcwd getpseudotty \
getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
memset nanosleep opendir putenv qsort readlink select setenv \
memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
sigvec strcasecmp strerror strftime stricmp strncasecmp \
strnicmp strpbrk strtol tgetent towlower towupper iswupper \
@@ -15173,6 +15174,58 @@ else
$as_echo "yes" >&6; }
fi
{ $as_echo "$as_me:$LINENO: checking for FD_CLOEXEC" >&5
$as_echo_n "checking for FD_CLOEXEC... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if HAVE_FCNTL_H
# include <fcntl.h>
#endif
int
main ()
{
int flag = FD_CLOEXEC;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF
#define HAVE_FD_CLOEXEC 1
_ACEOF
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:$LINENO: result: not usable" >&5
$as_echo "not usable" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:$LINENO: checking for rename" >&5
$as_echo_n "checking for rename... " >&6; }
cat >conftest.$ac_ext <<_ACEOF
@@ -17132,10 +17185,10 @@ $as_echo "yes" >&6; }
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
fi
{ $as_echo "$as_me:$LINENO: checking whether we need -D_FORTIFY_SOURCE=1" >&5
{ $as_echo "$as_me:$LINENO: checking whether we need -D_FORTIFY_SOURCE=1" >&5
$as_echo_n "checking whether we need -D_FORTIFY_SOURCE=1... " >&6; }
if test "$gccmajor" -gt "3"; then
CFLAGS=`echo "$CFLAGS -D_FORTIFY_SOURCE=1" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=2//g' -e 's/-D_FORTIFY_SOURCE=2//g'`
CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -D_FORTIFY_SOURCE=1/'`
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
else

View File

@@ -157,6 +157,7 @@
#undef HAVE_LSTAT
#undef HAVE_MEMCMP
#undef HAVE_MEMSET
#undef HAVE_MKDTEMP
#undef HAVE_NANOSLEEP
#undef HAVE_OPENDIR
#undef HAVE_FLOAT_FUNCS
@@ -387,3 +388,6 @@
/* Define if you want XSMP interaction as well as vanilla swapfile safety */
#undef USE_XSMP_INTERACT
/* Define if fcntl()'s F_SETFD command knows about FD_CLOEXEC */
#undef HAVE_FD_CLOEXEC

View File

@@ -686,7 +686,7 @@ if test "$enable_pythoninterp" = "yes"; then
[
vi_cv_path_python_conf=
for path in "${vi_cv_path_python_pfx}" "${vi_cv_path_python_epfx}"; do
for subdir in lib share; do
for subdir in lib64 lib share; do
d="${path}/${subdir}/python${vi_cv_var_python_version}/config"
if test -d "$d" && test -f "$d/config.c"; then
vi_cv_path_python_conf="$d"
@@ -2557,11 +2557,11 @@ main()
AC_MSG_RESULT([pty mode: $vim_cv_tty_mode, group: $vim_cv_tty_group])
else
vim_cv_tty_group=world
AC_MSG_RESULT([ptys are world accessable])
AC_MSG_RESULT([ptys are world accessible])
fi
],[
vim_cv_tty_group=world
AC_MSG_RESULT([can't determine - assume ptys are world accessable])
AC_MSG_RESULT([can't determine - assume ptys are world accessible])
],[
AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 'vim_cv_tty_mode')
])
@@ -2635,7 +2635,7 @@ fi
dnl Check for functions in one big call, to reduce the size of configure
AC_CHECK_FUNCS(bcmp fchdir fchown fseeko fsync ftello getcwd getpseudotty \
getpwnam getpwuid getrlimit gettimeofday getwd lstat memcmp \
memset nanosleep opendir putenv qsort readlink select setenv \
memset mkdtemp nanosleep opendir putenv qsort readlink select setenv \
setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
sigvec strcasecmp strerror strftime stricmp strncasecmp \
strnicmp strpbrk strtol tgetent towlower towupper iswupper \
@@ -2855,6 +2855,16 @@ else
AC_MSG_RESULT(yes)
fi
dnl make sure the FD_CLOEXEC flag for fcntl()'s F_SETFD command is known
AC_MSG_CHECKING(for FD_CLOEXEC)
AC_TRY_COMPILE(
[#if HAVE_FCNTL_H
# include <fcntl.h>
#endif],
[ int flag = FD_CLOEXEC;],
AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FD_CLOEXEC),
AC_MSG_RESULT(not usable))
dnl rename needs to be checked separately to work on Nextstep with cc
AC_MSG_CHECKING(for rename)
AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
@@ -3231,9 +3241,10 @@ if test "$GCC" = yes; then
fi
dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is
dnl declared as char x[1] but actually longer. Introduced in gcc 4.0.
dnl Also remove duplicate _FORTIFY_SOURCE arguments.
AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1)
if test "$gccmajor" -gt "3"; then
CFLAGS=`echo "$CFLAGS -D_FORTIFY_SOURCE=1" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=2//g' -e 's/-D_FORTIFY_SOURCE=2//g'`
CFLAGS=`echo "$CFLAGS" | sed -e 's/-Wp,-D_FORTIFY_SOURCE=.//g' -e 's/-D_FORTIFY_SOURCE=.//g' -e 's/$/ -D_FORTIFY_SOURCE=1/'`
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)

View File

@@ -181,7 +181,7 @@ static void ins_redraw __ARGS((int ready));
static void ins_ctrl_v __ARGS((void));
static void undisplay_dollar __ARGS((void));
static void insert_special __ARGS((int, int, int));
static void internal_format __ARGS((int textwidth, int second_indent, int flags, int format_only));
static void internal_format __ARGS((int textwidth, int second_indent, int flags, int format_only, int c));
static void check_auto_format __ARGS((int));
static void redo_literal __ARGS((int c));
static void start_arrow __ARGS((pos_T *end_insert_pos));
@@ -2164,7 +2164,7 @@ ins_compl_add_infercase(str, len, icase, fname, dir, flags)
int i, c;
int actual_len; /* Take multi-byte characters */
int actual_compl_length; /* into account. */
int *wca; /* Wide character array. */
int *wca; /* Wide character array. */
int has_lower = FALSE;
int was_letter = FALSE;
@@ -5558,7 +5558,7 @@ insertchar(c, flags, second_indent)
}
if (do_internal)
#endif
internal_format(textwidth, second_indent, flags, c == NUL);
internal_format(textwidth, second_indent, flags, c == NUL, c);
}
if (c == NUL) /* only formatting was wanted */
@@ -5738,11 +5738,12 @@ insertchar(c, flags, second_indent)
* Format text at the current insert position.
*/
static void
internal_format(textwidth, second_indent, flags, format_only)
internal_format(textwidth, second_indent, flags, format_only, c)
int textwidth;
int second_indent;
int flags;
int format_only;
int c; /* character to be inserted (can be NUL) */
{
int cc;
int save_char = NUL;
@@ -5763,7 +5764,11 @@ internal_format(textwidth, second_indent, flags, format_only)
* When 'ai' is off we don't want a space under the cursor to be
* deleted. Replace it with an 'x' temporarily.
*/
if (!curbuf->b_p_ai)
if (!curbuf->b_p_ai
#ifdef FEAT_VREPLACE
&& !(State & VREPLACE_FLAG)
#endif
)
{
cc = gchar_cursor();
if (vim_iswhite(cc))
@@ -5789,9 +5794,11 @@ internal_format(textwidth, second_indent, flags, format_only)
char_u *saved_text = NULL;
#endif
colnr_T col;
colnr_T end_col;
virtcol = get_nolist_virtcol();
if (virtcol < (colnr_T)textwidth)
virtcol = get_nolist_virtcol()
+ char2cells(c != NUL ? c : gchar_cursor());
if (virtcol <= (colnr_T)textwidth)
break;
#ifdef FEAT_COMMENTS
@@ -5831,12 +5838,7 @@ internal_format(textwidth, second_indent, flags, format_only)
coladvance((colnr_T)textwidth);
wantcol = curwin->w_cursor.col;
curwin->w_cursor.col = startcol - 1;
#ifdef FEAT_MBYTE
/* Correct cursor for multi-byte character. */
if (has_mbyte)
mb_adjust_cursor();
#endif
curwin->w_cursor.col = startcol;
foundcol = 0;
/*
@@ -5847,11 +5849,14 @@ internal_format(textwidth, second_indent, flags, format_only)
|| curwin->w_cursor.lnum != Insstart.lnum
|| curwin->w_cursor.col >= Insstart.col)
{
cc = gchar_cursor();
if (curwin->w_cursor.col == startcol && c != NUL)
cc = c;
else
cc = gchar_cursor();
if (WHITECHAR(cc))
{
/* remember position of blank just before text */
end_foundcol = curwin->w_cursor.col;
end_col = curwin->w_cursor.col;
/* find start of sequence of blanks */
while (curwin->w_cursor.col > 0 && WHITECHAR(cc))
@@ -5871,7 +5876,11 @@ internal_format(textwidth, second_indent, flags, format_only)
/* do not break after one-letter words */
if (curwin->w_cursor.col == 0)
break; /* one-letter word at begin */
#ifdef FEAT_COMMENTS
/* do not break "#a b" when 'tw' is 2 */
if (curwin->w_cursor.col <= leader_len)
break;
#endif
col = curwin->w_cursor.col;
dec_cursor();
cc = gchar_cursor();
@@ -5880,26 +5889,60 @@ internal_format(textwidth, second_indent, flags, format_only)
continue; /* one-letter, continue */
curwin->w_cursor.col = col;
}
#ifdef FEAT_MBYTE
if (has_mbyte)
foundcol = curwin->w_cursor.col
+ (*mb_ptr2len)(ml_get_cursor());
else
#endif
foundcol = curwin->w_cursor.col + 1;
if (curwin->w_cursor.col < (colnr_T)wantcol)
inc_cursor();
end_foundcol = end_col + 1;
foundcol = curwin->w_cursor.col;
if (curwin->w_cursor.col <= (colnr_T)wantcol)
break;
}
#ifdef FEAT_MBYTE
else if (cc >= 0x100 && fo_multibyte
&& curwin->w_cursor.col <= (colnr_T)wantcol)
else if (cc >= 0x100 && fo_multibyte)
{
/* Break after or before a multi-byte character. */
if (curwin->w_cursor.col != startcol)
{
#ifdef FEAT_COMMENTS
/* Don't break until after the comment leader */
if (curwin->w_cursor.col < leader_len)
break;
#endif
col = curwin->w_cursor.col;
inc_cursor();
/* Don't change end_foundcol if already set. */
if (foundcol != curwin->w_cursor.col)
{
foundcol = curwin->w_cursor.col;
end_foundcol = foundcol;
if (curwin->w_cursor.col <= (colnr_T)wantcol)
break;
}
curwin->w_cursor.col = col;
}
if (curwin->w_cursor.col == 0)
break;
col = curwin->w_cursor.col;
dec_cursor();
cc = gchar_cursor();
if (WHITECHAR(cc))
continue; /* break with space */
#ifdef FEAT_COMMENTS
/* Don't break until after the comment leader */
if (curwin->w_cursor.col < leader_len)
break;
#endif
curwin->w_cursor.col = col;
foundcol = curwin->w_cursor.col;
if (curwin->w_cursor.col < (colnr_T)wantcol)
foundcol += (*mb_char2len)(cc);
end_foundcol = foundcol;
break;
if (curwin->w_cursor.col <= (colnr_T)wantcol)
break;
}
#endif
if (curwin->w_cursor.col == 0)
@@ -5926,14 +5969,15 @@ internal_format(textwidth, second_indent, flags, format_only)
orig_col = startcol; /* Will start backspacing from here */
else
#endif
replace_offset = startcol - end_foundcol - 1;
replace_offset = startcol - end_foundcol;
/*
* adjust startcol for spaces that will be deleted and
* characters that will remain on top line
*/
curwin->w_cursor.col = foundcol;
while (cc = gchar_cursor(), WHITECHAR(cc))
while ((cc = gchar_cursor(), WHITECHAR(cc))
&& (!fo_white_par || curwin->w_cursor.col < startcol))
inc_cursor();
startcol -= curwin->w_cursor.col;
if (startcol < 0)
@@ -8509,7 +8553,7 @@ ins_bs(c, mode, inserted_space_p)
if (mode == BACKSPACE_LINE
&& (curbuf->b_p_ai
#ifdef FEAT_CINDENT
|| cindent_on()
|| cindent_on()
#endif
)
#ifdef FEAT_RIGHTLEFT

View File

@@ -9928,6 +9928,7 @@ filter_map(argvars, rettv, map)
int todo;
char_u *ermsg = map ? (char_u *)"map()" : (char_u *)"filter()";
int save_did_emsg;
int index = 0;
if (argvars[0].v_type == VAR_LIST)
{
@@ -9961,9 +9962,9 @@ filter_map(argvars, rettv, map)
save_did_emsg = did_emsg;
did_emsg = FALSE;
prepare_vimvar(VV_KEY, &save_key);
if (argvars[0].v_type == VAR_DICT)
{
prepare_vimvar(VV_KEY, &save_key);
vimvars[VV_KEY].vv_type = VAR_STRING;
ht = &d->dv_hashtab;
@@ -9987,24 +9988,27 @@ filter_map(argvars, rettv, map)
}
}
hash_unlock(ht);
restore_vimvar(VV_KEY, &save_key);
}
else
{
vimvars[VV_KEY].vv_type = VAR_NUMBER;
for (li = l->lv_first; li != NULL; li = nli)
{
if (tv_check_lock(li->li_tv.v_lock, ermsg))
break;
nli = li->li_next;
vimvars[VV_KEY].vv_nr = index;
if (filter_map_one(&li->li_tv, expr, map, &rem) == FAIL
|| did_emsg)
break;
if (!map && rem)
listitem_remove(l, li);
++index;
}
}
restore_vimvar(VV_KEY, &save_key);
restore_vimvar(VV_VAL, &save_val);
did_emsg |= save_did_emsg;

View File

@@ -4422,7 +4422,8 @@ ExpandFromContext(xp, pat, num_file, file, options)
flags |= EW_FILE;
else
flags = (flags | EW_DIR) & ~EW_FILE;
ret = expand_wildcards(1, &pat, num_file, file, flags);
/* Expand wildcards, supporting %:h and the like. */
ret = expand_wildcards_eval(&pat, num_file, file, flags);
if (free_pat)
vim_free(pat);
return ret;

View File

@@ -21,7 +21,7 @@
#include "vim.h"
#ifdef __TANDEM
#if defined(__TANDEM) || defined(__MINT__)
# include <limits.h> /* for SSIZE_MAX */
#endif
@@ -146,6 +146,9 @@ static int get_mac_fio_flags __ARGS((char_u *ptr));
# endif
#endif
static int move_lines __ARGS((buf_T *frombuf, buf_T *tobuf));
#ifdef TEMPDIRNAMES
static void vim_settempdir __ARGS((char_u *tempdir));
#endif
#ifdef FEAT_AUTOCMD
static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name");
#endif
@@ -2253,6 +2256,14 @@ failed:
if (!read_buffer && !read_stdin)
close(fd); /* errors are ignored */
#ifdef HAVE_FD_CLOEXEC
else
{
int fdflags = fcntl(fd, F_GETFD);
if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC);
}
#endif
vim_free(buffer);
#ifdef HAVE_DUP
@@ -6986,6 +6997,35 @@ vim_deltempdir()
}
#endif
#ifdef TEMPDIRNAMES
/*
* Directory "tempdir" was created. Expand this name to a full path and put
* it in "vim_tempdir". This avoids that using ":cd" would confuse us.
* "tempdir" must be no longer than MAXPATHL.
*/
static void
vim_settempdir(tempdir)
char_u *tempdir;
{
char_u *buf;
buf = alloc((unsigned)MAXPATHL + 2);
if (buf != NULL)
{
if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL)
STRCPY(buf, tempdir);
# ifdef __EMX__
if (vim_strchr(buf, '/') != NULL)
STRCAT(buf, "/");
else
# endif
add_pathsep(buf);
vim_tempdir = vim_strsave(buf);
vim_free(buf);
}
}
#endif
/*
* vim_tempname(): Return a unique name that can be used for a temp file.
*
@@ -7007,8 +7047,6 @@ vim_tempname(extra_char)
#ifdef TEMPDIRNAMES
static char *(tempdirs[]) = {TEMPDIRNAMES};
int i;
long nr;
long off;
# ifndef EEXIST
struct stat st;
# endif
@@ -7027,6 +7065,12 @@ vim_tempname(extra_char)
*/
for (i = 0; i < (int)(sizeof(tempdirs) / sizeof(char *)); ++i)
{
size_t itmplen;
# ifndef HAVE_MKDTEMP
long nr;
long off;
# endif
/* expand $TMP, leave room for "/v1100000/999999999" */
expand_env((char_u *)tempdirs[i], itmp, TEMPNAMELEN - 20);
if (mch_isdir(itmp)) /* directory exists */
@@ -7040,7 +7084,14 @@ vim_tempname(extra_char)
else
# endif
add_pathsep(itmp);
itmplen = STRLEN(itmp);
# ifdef HAVE_MKDTEMP
/* Leave room for filename */
STRCAT(itmp, "vXXXXXX");
if (mkdtemp((char *)itmp) != NULL)
vim_settempdir(itmp);
# else
/* Get an arbitrary number of up to 6 digits. When it's
* unlikely that it already exists it will be faster,
* otherwise it doesn't matter. The use of mkdir() avoids any
@@ -7052,59 +7103,41 @@ vim_tempname(extra_char)
for (off = 0; off < 10000L; ++off)
{
int r;
#if defined(UNIX) || defined(VMS)
# if defined(UNIX) || defined(VMS)
mode_t umask_save;
#endif
# endif
sprintf((char *)itmp + STRLEN(itmp), "v%ld", nr + off);
# ifndef EEXIST
sprintf((char *)itmp + itmplen, "v%ld", nr + off);
# ifndef EEXIST
/* If mkdir() does not set errno to EEXIST, check for
* existing file here. There is a race condition then,
* although it's fail-safe. */
if (mch_stat((char *)itmp, &st) >= 0)
continue;
# endif
#if defined(UNIX) || defined(VMS)
# endif
# if defined(UNIX) || defined(VMS)
/* Make sure the umask doesn't remove the executable bit.
* "repl" has been reported to use "177". */
umask_save = umask(077);
#endif
# endif
r = vim_mkdir(itmp, 0700);
#if defined(UNIX) || defined(VMS)
# if defined(UNIX) || defined(VMS)
(void)umask(umask_save);
#endif
# endif
if (r == 0)
{
char_u *buf;
/* Directory was created, use this name.
* Expand to full path; When using the current
* directory a ":cd" would confuse us. */
buf = alloc((unsigned)MAXPATHL + 1);
if (buf != NULL)
{
if (vim_FullName(itmp, buf, MAXPATHL, FALSE)
== FAIL)
STRCPY(buf, itmp);
# ifdef __EMX__
if (vim_strchr(buf, '/') != NULL)
STRCAT(buf, "/");
else
# endif
add_pathsep(buf);
vim_tempdir = vim_strsave(buf);
vim_free(buf);
}
vim_settempdir(itmp);
break;
}
# ifdef EEXIST
# ifdef EEXIST
/* If the mkdir() didn't fail because the file/dir exists,
* we probably can't create any dir here, try another
* place. */
if (errno != EEXIST)
# endif
# endif
break;
}
# endif /* HAVE_MKDTEMP */
if (vim_tempdir != NULL)
break;
}
@@ -8576,6 +8609,7 @@ aucmd_restbuf(aco)
curwin = firstwin;
# ifdef FEAT_EVAL
vars_clear(&aucmd_win->w_vars.dv_hashtab); /* free all w: variables */
hash_init(&aucmd_win->w_vars.dv_hashtab); /* re-use the hashtab */
# endif
#else
curwin = aco->save_curwin;

View File

@@ -1274,13 +1274,12 @@ gui_xm_select_font(char_u *current)
XtAppProcessEvent(XtWidgetToApplicationContext(data->dialog),
(XtInputMask)XtIMAll);
XtDestroyWidget(data->dialog);
if (data->old)
{
XFreeFont(XtDisplay(data->dialog), data->old);
XmFontListFree(data->old_list);
}
XtDestroyWidget(data->dialog);
gui_motif_synch_fonts();

View File

@@ -70,14 +70,6 @@ typedef struct
Scheme_Object *port;
} Port_Info;
/* info for do_apply */
typedef struct
{
Scheme_Object *proc;
int argc;
Scheme_Object **argv;
} Apply_Info;
/*
*========================================================================
* Vim-Control Commands
@@ -160,7 +152,6 @@ static Scheme_Object *_apply_thunk_catch_exceptions(
static Scheme_Object *extract_exn_message(Scheme_Object *v);
static Scheme_Object *do_eval(void *, int noargc, Scheme_Object **noargv);
static Scheme_Object *do_load(void *, int noargc, Scheme_Object **noargv);
static Scheme_Object *do_apply(void *, int noargc, Scheme_Object **noargv);
static void register_vim_exn(void);
static vim_mz_buffer *get_buffer_arg(const char *fname, int argnum,
int argc, Scheme_Object **argv);
@@ -1056,7 +1047,7 @@ mzscheme_init(void)
MZ_GC_REG();
config = scheme_config;
MZ_GC_CHECK();
/* recreate ports each call effectivelly clearing these ones */
/* recreate ports each call effectively clearing these ones */
curout = scheme_make_string_output_port();
MZ_GC_CHECK();
curerr = scheme_make_string_output_port();
@@ -1196,36 +1187,6 @@ ex_mzscheme(exarg_T *eap)
}
}
/*
* apply MzScheme procedure with arguments,
* handling errors
*/
Scheme_Object *
mzvim_apply(Scheme_Object *proc, int argc, Scheme_Object **argv)
{
if (mzscheme_init())
return FAIL;
else
{
Apply_Info data = {NULL, 0, NULL};
Scheme_Object *ret = NULL;
MZ_GC_DECL_REG(5);
MZ_GC_VAR_IN_REG(0, ret);
MZ_GC_VAR_IN_REG(1, data.proc);
MZ_GC_ARRAY_VAR_IN_REG(2, data.argv, argc);
MZ_GC_REG();
data.proc = proc;
data.argc = argc;
data.argv = argv;
eval_with_exn_handling(&data, do_apply, &ret);
MZ_GC_UNREG();
return ret;
}
}
static Scheme_Object *
do_load(void *data, int noargc, Scheme_Object **noargv)
{
@@ -1257,7 +1218,7 @@ do_load(void *data, int noargc, Scheme_Object **noargv)
MZ_GC_CHECK();
}
/* errors will be caught in do_mzscheme_comamnd and ex_mzfile */
/* errors will be caught in do_mzscheme_command and ex_mzfile */
scheme_close_input_port(pinfo->port);
MZ_GC_CHECK();
pinfo->port = NULL;
@@ -1348,13 +1309,6 @@ do_eval(void *s, int noargc, Scheme_Object **noargv)
return scheme_eval_string_all((char *)s, environment, TRUE);
}
static Scheme_Object *
do_apply(void *a, int noargc, Scheme_Object **noargv)
{
Apply_Info *info = (Apply_Info *)a;
return scheme_apply(info->proc, info->argc, info->argv);
}
/*
*========================================================================
* 3. MzScheme I/O Handlers
@@ -2128,7 +2082,7 @@ get_buffer_line_list(void *data, int argc, Scheme_Object **argv)
static Scheme_Object *
set_buffer_line(void *data, int argc, Scheme_Object **argv)
{
/* First of all, we check the the of the supplied MzScheme object.
/* First of all, we check the value of the supplied MzScheme object.
* There are three cases:
* 1. #f - this is a deletion.
* 2. A string - this is a replacement.
@@ -2428,7 +2382,7 @@ set_buffer_line_list(void *data, int argc, Scheme_Object **argv)
/*
* (insert-buff-line-list {linenr} {string/string-list} [buffer])
*
* Insert a number of lines into the specified buffer after the specifed line.
* Insert a number of lines into the specified buffer after the specified line.
* The line number is in Vim format (1-based). The lines to be inserted are
* given as an MzScheme list of string objects or as a single string. The lines
* to be added are checked for validity and correct format. Errors are

View File

@@ -366,14 +366,21 @@ main
* Check if the GUI can be started. Reset gui.starting if not.
* Don't know about other systems, stay on the safe side and don't check.
*/
if (gui.starting && gui_init_check() == FAIL)
if (gui.starting)
{
gui.starting = FALSE;
if (gui_init_check() == FAIL)
{
gui.starting = FALSE;
/* When running "evim" or "gvim -y" we need the menus, exit if we
* don't have them. */
if (params.evim_mode)
mch_exit(1);
/* When running "evim" or "gvim -y" we need the menus, exit if we
* don't have them. */
if (params.evim_mode)
mch_exit(1);
}
# if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
/* Re-initialize locale, it may have been altered by gui_init_check() */
init_locale();
# endif
}
# endif
#endif
@@ -3151,7 +3158,7 @@ usage()
main_msg(_("--servername <name>\tSend to/become the Vim server <name>"));
#endif
#ifdef STARTUPTIME
main_msg(_("--startuptime=<file>\tWrite startup timing messages to <file>"));
main_msg(_("--startuptime <file>\tWrite startup timing messages to <file>"));
#endif
#ifdef FEAT_VIMINFO
main_msg(_("-i <viminfo>\t\tUse <viminfo> instead of .viminfo"));
@@ -3685,7 +3692,7 @@ cmdsrv_main(argc, argv, serverName_arg, serverStr)
}
else if (STRICMP(argv[i], "--servername") == 0)
{
/* Alredy processed. Take it out of the command line */
/* Already processed. Take it out of the command line */
i++;
continue;
}

View File

@@ -133,21 +133,39 @@ static int dbcs_char2cells __ARGS((int c));
static int dbcs_ptr2cells_len __ARGS((char_u *p, int size));
static int dbcs_ptr2char __ARGS((char_u *p));
/* Lookup table to quickly get the length in bytes of a UTF-8 character from
* the first byte of a UTF-8 string. Bytes which are illegal when used as the
* first byte have a one, because these will be used separately. */
/*
* Lookup table to quickly get the length in bytes of a UTF-8 character from
* the first byte of a UTF-8 string.
* Bytes which are illegal when used as the first byte have a 1.
* The NUL byte has length 1.
*/
static char utf8len_tab[256] =
{
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /*bogus*/
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /*bogus*/
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1,
};
/*
* Like utf8len_tab above, but using a zero for illegal lead bytes.
*/
static char utf8len_tab_zero[256] =
{
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0,
};
/*
* XIM often causes trouble. Define XIM_DEBUG to get a log of XIM callbacks
* in the "xim.log" file.
@@ -1352,7 +1370,7 @@ utf_ptr2cells_len(p, size)
if (size > 0 && *p >= 0x80)
{
if (utf_ptr2len_len(p, size) < utf8len_tab[*p])
return 1;
return 1; /* truncated */
c = utf_ptr2char(p);
/* An illegal byte is displayed as <xx>. */
if (utf_ptr2len(p) == 1 || c == NUL)
@@ -1473,7 +1491,7 @@ utf_ptr2char(p)
if (p[0] < 0x80) /* be quick for ASCII */
return p[0];
len = utf8len_tab[p[0]];
len = utf8len_tab_zero[p[0]];
if (len > 1 && (p[1] & 0xc0) == 0x80)
{
if (len == 2)
@@ -1723,6 +1741,7 @@ utf_ptr2len(p)
/*
* Return length of UTF-8 character, obtained from the first byte.
* "b" must be between 0 and 255!
* Returns 1 for an invalid first byte value.
*/
int
utf_byte2len(b)
@@ -1737,6 +1756,7 @@ utf_byte2len(b)
* Returns 1 for "".
* Returns 1 for an illegal byte sequence (also in incomplete byte seq.).
* Returns number > "size" for an incomplete byte sequence.
* Never returns zero.
*/
int
utf_ptr2len_len(p, size)
@@ -1747,11 +1767,13 @@ utf_ptr2len_len(p, size)
int i;
int m;
if (*p == NUL)
return 1;
m = len = utf8len_tab[*p];
len = utf8len_tab[*p];
if (len == 1)
return 1; /* NUL, ascii or illegal lead byte */
if (len > size)
m = size; /* incomplete byte sequence. */
else
m = len;
for (i = 1; i < m; ++i)
if ((p[i] & 0xc0) != 0x80)
return 1;
@@ -2505,6 +2527,7 @@ show_utf8()
/*
* mb_head_off() function pointer.
* Return offset from "p" to the first byte of the character it points into.
* If "p" points to the NUL at the end of the string return 0.
* Returns 0 when already at the first byte of a character.
*/
int
@@ -2524,7 +2547,7 @@ dbcs_head_off(base, p)
/* It can't be a trailing byte when not using DBCS, at the start of the
* string or the previous byte can't start a double-byte. */
if (p <= base || MB_BYTE2LEN(p[-1]) == 1)
if (p <= base || MB_BYTE2LEN(p[-1]) == 1 || *p == NUL)
return 0;
/* This is slow: need to start at the base and go forward until the
@@ -2552,7 +2575,8 @@ dbcs_screen_head_off(base, p)
* lead byte in the current cell. */
if (p <= base
|| (enc_dbcs == DBCS_JPNU && p[-1] == 0x8e)
|| MB_BYTE2LEN(p[-1]) == 1)
|| MB_BYTE2LEN(p[-1]) == 1
|| *p == NUL)
return 0;
/* This is slow: need to start at the base and go forward until the
@@ -2578,6 +2602,7 @@ utf_head_off(base, p)
char_u *q;
char_u *s;
int c;
int len;
#ifdef FEAT_ARABIC
char_u *j;
#endif
@@ -2597,8 +2622,8 @@ utf_head_off(base, p)
--q;
/* Check for illegal sequence. Do allow an illegal byte after where we
* started. */
if (utf8len_tab[*q] != (int)(s - q + 1)
&& utf8len_tab[*q] != (int)(p - q + 1))
len = utf8len_tab[*q];
if (len != (int)(s - q + 1) && len != (int)(p - q + 1))
return 0;
if (q <= base)
@@ -2810,9 +2835,9 @@ utf_valid_string(s, end)
while (end == NULL ? *p != NUL : p < end)
{
if ((*p & 0xc0) == 0x80)
l = utf8len_tab_zero[*p];
if (l == 0)
return FALSE; /* invalid lead byte */
l = utf8len_tab[*p];
if (end != NULL && p + l > end)
return FALSE; /* incomplete byte sequence */
++p;
@@ -6117,12 +6142,20 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp)
d = retval;
for (i = 0; i < len; ++i)
{
l = utf_ptr2len(ptr + i);
l = utf_ptr2len_len(ptr + i, len - i);
if (l == 0)
*d++ = NUL;
else if (l == 1)
{
if (unconvlenp != NULL && utf8len_tab[ptr[i]] > len - i)
int l_w = utf8len_tab_zero[ptr[i]];
if (l_w == 0)
{
/* Illegal utf-8 byte cannot be converted */
vim_free(retval);
return NULL;
}
if (unconvlenp != NULL && l_w > len - i)
{
/* Incomplete sequence at the end. */
*unconvlenp = len - i;

View File

@@ -1343,6 +1343,11 @@ mf_do_open(mfp, fname, flags)
}
else
{
#ifdef HAVE_FD_CLOEXEC
int fdflags = fcntl(mfp->mf_fd, F_GETFD);
if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
#endif
#ifdef HAVE_SELINUX
mch_copy_sec(fname, mfp->mf_fname);
#endif

View File

@@ -382,7 +382,7 @@ ml_open(buf)
dp->db_index[0] = --dp->db_txt_start; /* at end of block */
dp->db_free -= 1 + INDEX_SIZE;
dp->db_line_count = 1;
*((char_u *)dp + dp->db_txt_start) = NUL; /* emtpy line */
*((char_u *)dp + dp->db_txt_start) = NUL; /* empty line */
return OK;
@@ -490,6 +490,13 @@ ml_setname(buf)
EMSG(_("E301: Oops, lost the swap file!!!"));
return;
}
#ifdef HAVE_FD_CLOEXEC
{
int fdflags = fcntl(mfp->mf_fd, F_GETFD);
if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0)
fcntl(mfp->mf_fd, F_SETFD, fdflags | FD_CLOEXEC);
}
#endif
}
if (!success)
EMSG(_("E302: Could not rename swap file"));

View File

@@ -1026,12 +1026,14 @@ open_line(dir, flags, old_indent)
int c = 0;
int off = 0;
for (p = lead_flags; *p && *p != ':'; ++p)
for (p = lead_flags; *p != NUL && *p != ':'; )
{
if (*p == COM_RIGHT || *p == COM_LEFT)
c = *p;
c = *p++;
else if (VIM_ISDIGIT(*p) || *p == '-')
off = getdigits(&p);
else
++p;
}
if (c == COM_RIGHT) /* right adjusted leader */
{
@@ -1119,7 +1121,7 @@ open_line(dir, flags, old_indent)
if (i != lead_repl_len)
{
mch_memmove(p + lead_repl_len, p + i,
(size_t)(lead_len - i - (leader - p)));
(size_t)(lead_len - i - (p - leader)));
lead_len += lead_repl_len - i;
}
}
@@ -4664,7 +4666,6 @@ concat_fnames(fname1, fname2, sep)
return dest;
}
#if defined(FEAT_EVAL) || defined(FEAT_GETTEXT) || defined(PROTO)
/*
* Concatenate two strings and return the result in allocated memory.
* Returns NULL when out of memory.
@@ -4685,7 +4686,6 @@ concat_str(str1, str2)
}
return dest;
}
#endif
/*
* Add a path separator to a file name, unless it already ends in a path
@@ -8444,6 +8444,46 @@ fast_breakcheck()
}
}
/*
* Invoke expand_wildcards() for one pattern.
* Expand items like "%:h" before the expansion.
* Returns OK or FAIL.
*/
int
expand_wildcards_eval(pat, num_file, file, flags)
char_u **pat; /* pointer to input pattern */
int *num_file; /* resulting number of files */
char_u ***file; /* array of resulting files */
int flags; /* EW_DIR, etc. */
{
int ret = FAIL;
char_u *eval_pat = NULL;
char_u *exp_pat = *pat;
char_u *ignored_msg;
int usedlen;
if (*exp_pat == '%' || *exp_pat == '#' || *exp_pat == '<')
{
++emsg_off;
eval_pat = eval_vars(exp_pat, exp_pat, &usedlen,
NULL, &ignored_msg, NULL);
--emsg_off;
if (eval_pat != NULL)
exp_pat = concat_str(eval_pat, exp_pat + usedlen);
}
if (exp_pat != NULL)
ret = expand_wildcards(1, &exp_pat, num_file, file, flags);
if (eval_pat != NULL)
{
vim_free(exp_pat);
vim_free(eval_pat);
}
return ret;
}
/*
* Expand wildcards. Calls gen_expand_wildcards() and removes files matching
* 'wildignore'.

View File

@@ -1390,6 +1390,7 @@ vim_strsave_shellescape(string, do_special)
*d++ = '\\'; /* insert backslash */
while (--l >= 0) /* copy the var */
*d++ = *p++;
continue;
}
MB_COPY_CHAR(p, d);

View File

@@ -3991,6 +3991,14 @@ ex_display(eap)
}
else
yb = &(y_regs[i]);
#ifdef FEAT_EVAL
if (name == MB_TOLOWER(redir_reg)
|| (redir_reg == '"' && yb == y_previous))
continue; /* do not list register being written to, the
* pointer can be freed */
#endif
if (yb->y_array != NULL)
{
msg_putchar('\n');
@@ -5589,7 +5597,10 @@ x11_export_final_selection()
vc.vc_type = CONV_NONE;
if (convert_setup(&vc, p_enc, (char_u *)"latin1") == OK)
{
conv_str = string_convert(&vc, str, (int*)&len);
int intlen = len;
conv_str = string_convert(&vc, str, &intlen);
len = intlen;
if (conv_str != NULL)
{
vim_free(str);
@@ -6090,7 +6101,7 @@ str_to_reg(y_ptr, type, str, len, blocklen)
long maxlen;
#endif
if (y_ptr->y_array == NULL) /* NULL means emtpy register */
if (y_ptr->y_array == NULL) /* NULL means empty register */
y_ptr->y_size = 0;
/*

View File

@@ -13,8 +13,6 @@ win_T *get_valid_window __ARGS((void *));
void mzvim_check_threads __ARGS((void));
void mzvim_reset_timer __ARGS((void));
void *mzvim_eval_string __ARGS((char_u *str));
struct Scheme_Object *mzvim_apply __ARGS((struct Scheme_Object *, int argc,
struct Scheme_Object **));
int mzthreads_allowed __ARGS((void));
void mzscheme_main __ARGS((void));
/* vim: set ft=c : */

View File

@@ -85,6 +85,7 @@ void preserve_exit __ARGS((void));
int vim_fexists __ARGS((char_u *fname));
void line_breakcheck __ARGS((void));
void fast_breakcheck __ARGS((void));
int expand_wildcards_eval __ARGS((char_u **pat, int *num_file, char_u ***file, int flags));
int expand_wildcards __ARGS((int num_pat, char_u **pat, int *num_file, char_u ***file, int flags));
int match_suffix __ARGS((char_u *fname));
int unix_expandpath __ARGS((garray_T *gap, char_u *path, int wildoff, int flags, int didstar));

View File

@@ -583,6 +583,7 @@ static int re_has_z; /* \z item detected */
#endif
static char_u *regcode; /* Code-emit pointer, or JUST_CALC_SIZE */
static long regsize; /* Code size. */
static int reg_toolong; /* TRUE when offset out of range */
static char_u had_endbrace[NSUBEXP]; /* flags, TRUE if end of () found */
static unsigned regflags; /* RF_ flags for prog */
static long brace_min[10]; /* Minimums for complex brace repeats */
@@ -1028,9 +1029,11 @@ vim_regcomp(expr, re_flags)
regcomp_start(expr, re_flags);
regcode = r->program;
regc(REGMAGIC);
if (reg(REG_NOPAREN, &flags) == NULL)
if (reg(REG_NOPAREN, &flags) == NULL || reg_toolong)
{
vim_free(r);
if (reg_toolong)
EMSG_RET_NULL(_("E339: Pattern too long"));
return NULL;
}
@@ -1141,6 +1144,7 @@ regcomp_start(expr, re_flags)
re_has_z = 0;
#endif
regsize = 0L;
reg_toolong = FALSE;
regflags = 0;
#if defined(FEAT_SYN_HL) || defined(PROTO)
had_eol = FALSE;
@@ -1228,7 +1232,7 @@ reg(paren, flagp)
{
skipchr();
br = regbranch(&flags);
if (br == NULL)
if (br == NULL || reg_toolong)
return NULL;
regtail(ret, br); /* BRANCH -> BRANCH. */
if (!(flags & HASWIDTH))
@@ -1313,6 +1317,8 @@ regbranch(flagp)
break;
skipchr();
regtail(latest, regnode(END)); /* operand ends */
if (reg_toolong)
break;
reginsert(MATCH, latest);
chain = latest;
}
@@ -1382,7 +1388,7 @@ regconcat(flagp)
break;
default:
latest = regpiece(&flags);
if (latest == NULL)
if (latest == NULL || reg_toolong)
return NULL;
*flagp |= flags & (HASWIDTH | HASNL | HASLOOKBH);
if (chain == NULL) /* First piece. */
@@ -2540,8 +2546,16 @@ regtail(p, val)
offset = (int)(scan - val);
else
offset = (int)(val - scan);
*(scan + 1) = (char_u) (((unsigned)offset >> 8) & 0377);
*(scan + 2) = (char_u) (offset & 0377);
/* When the offset uses more than 16 bits it can no longer fit in the two
* bytes avaliable. Use a global flag to avoid having to check return
* values in too many places. */
if (offset > 0xffff)
reg_toolong = TRUE;
else
{
*(scan + 1) = (char_u) (((unsigned)offset >> 8) & 0377);
*(scan + 2) = (char_u) (offset & 0377);
}
}
/*
@@ -5764,6 +5778,8 @@ do_class:
/*
* regnext - dig the "next" pointer out of a node
* Returns NULL when calculating size, when there is no next item and when
* there is an error.
*/
static char_u *
regnext(p)
@@ -5771,7 +5787,7 @@ regnext(p)
{
int offset;
if (p == JUST_CALC_SIZE)
if (p == JUST_CALC_SIZE || reg_toolong)
return NULL;
offset = NEXT(p);
@@ -6812,6 +6828,8 @@ static int can_f_submatch = FALSE; /* TRUE when submatch() can be used */
* that contains a call to substitute() and submatch(). */
static regmatch_T *submatch_match;
static regmmatch_T *submatch_mmatch;
static linenr_T submatch_firstlnum;
static linenr_T submatch_maxline;
#endif
#if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO)
@@ -6925,7 +6943,6 @@ vim_regsub_both(source, dest, copy, magic, backslash)
}
else
{
linenr_T save_reg_maxline;
win_T *save_reg_win;
int save_ireg_ic;
@@ -6937,7 +6954,8 @@ vim_regsub_both(source, dest, copy, magic, backslash)
* vim_regexec_multi() can't be called recursively. */
submatch_match = reg_match;
submatch_mmatch = reg_mmatch;
save_reg_maxline = reg_maxline;
submatch_firstlnum = reg_firstlnum;
submatch_maxline = reg_maxline;
save_reg_win = reg_win;
save_ireg_ic = ireg_ic;
can_f_submatch = TRUE;
@@ -6960,7 +6978,8 @@ vim_regsub_both(source, dest, copy, magic, backslash)
reg_match = submatch_match;
reg_mmatch = submatch_mmatch;
reg_maxline = save_reg_maxline;
reg_firstlnum = submatch_firstlnum;
reg_maxline = submatch_maxline;
reg_win = save_reg_win;
ireg_ic = save_ireg_ic;
can_f_submatch = FALSE;
@@ -7195,6 +7214,31 @@ exit:
}
#ifdef FEAT_EVAL
static char_u *reg_getline_submatch __ARGS((linenr_T lnum));
/*
* Call reg_getline() with the line numbers from the submatch. If a
* substitute() was used the reg_maxline and other values have been
* overwritten.
*/
static char_u *
reg_getline_submatch(lnum)
linenr_T lnum;
{
char_u *s;
linenr_T save_first = reg_firstlnum;
linenr_T save_max = reg_maxline;
reg_firstlnum = submatch_firstlnum;
reg_maxline = submatch_maxline;
s = reg_getline(lnum);
reg_firstlnum = save_first;
reg_maxline = save_max;
return s;
}
/*
* Used for the submatch() function: get the string from the n'th submatch in
* allocated memory.
@@ -7225,7 +7269,7 @@ reg_submatch(no)
if (lnum < 0 || submatch_mmatch->endpos[no].lnum < 0)
return NULL;
s = reg_getline(lnum) + submatch_mmatch->startpos[no].col;
s = reg_getline_submatch(lnum) + submatch_mmatch->startpos[no].col;
if (s == NULL) /* anti-crash check, cannot happen? */
break;
if (submatch_mmatch->endpos[no].lnum == lnum)
@@ -7251,7 +7295,7 @@ reg_submatch(no)
++lnum;
while (lnum < submatch_mmatch->endpos[no].lnum)
{
s = reg_getline(lnum++);
s = reg_getline_submatch(lnum++);
if (round == 2)
STRCPY(retval + len, s);
len += (int)STRLEN(s);
@@ -7260,7 +7304,7 @@ reg_submatch(no)
++len;
}
if (round == 2)
STRNCPY(retval + len, reg_getline(lnum),
STRNCPY(retval + len, reg_getline_submatch(lnum),
submatch_mmatch->endpos[no].col);
len += submatch_mmatch->endpos[no].col;
if (round == 2)

View File

@@ -323,6 +323,7 @@ update_screen(type)
int did_one;
#endif
/* Don't do anything if the screen structures are (not yet) valid. */
if (!screen_valid(TRUE))
return;
@@ -342,7 +343,9 @@ update_screen(type)
if (curwin->w_lines_valid == 0 && type < NOT_VALID)
type = NOT_VALID;
if (!redrawing())
/* Postpone the redrawing when it's not needed and when being called
* recursively. */
if (!redrawing() || updating_screen)
{
redraw_later(type); /* remember type for next time */
must_redraw = type;
@@ -582,6 +585,7 @@ static void update_finish __ARGS((void));
/*
* Prepare for updating one or more windows.
* Caller must check for "updating_screen" already set to avoid recursiveness.
*/
static void
update_prepare()
@@ -663,7 +667,9 @@ update_debug_sign(buf, lnum)
doit = TRUE;
}
if (!doit)
/* Return when there is nothing to do or screen updating already
* happening. */
if (!doit || updating_screen)
return;
/* update all windows that need updating */
@@ -696,6 +702,10 @@ update_debug_sign(buf, lnum)
updateWindow(wp)
win_T *wp;
{
/* return if already busy updating */
if (updating_screen)
return;
update_prepare();
#ifdef FEAT_CLIPBOARD

View File

@@ -206,7 +206,7 @@ typedef struct syn_pattern
static int current_attr = 0; /* attr of current syntax word */
#ifdef FEAT_EVAL
static int current_id = 0; /* ID of current char for syn_get_id() */
static int current_trans_id = 0; /* idem, transparancy removed */
static int current_trans_id = 0; /* idem, transparency removed */
#endif
typedef struct syn_cluster_S
@@ -282,7 +282,7 @@ typedef struct state_item
int si_idx; /* index of syntax pattern or
KEYWORD_IDX */
int si_id; /* highlight group ID for keywords */
int si_trans_id; /* idem, transparancy removed */
int si_trans_id; /* idem, transparency removed */
int si_m_lnum; /* lnum of the match */
int si_m_startcol; /* starting column of the match */
lpos_T si_m_endpos; /* just after end posn of the match */
@@ -1274,7 +1274,7 @@ syn_stack_cleanup()
dist = syn_buf->b_ml.ml_line_count / (syn_buf->b_sst_len - Rows) + 1;
/*
* Go throught the list to find the "tick" for the oldest entry that can
* Go through the list to find the "tick" for the oldest entry that can
* be removed. Set "above" when the "tick" for the oldest entry is above
* "b_sst_lasttick" (the display tick wraps around).
*/
@@ -2319,7 +2319,7 @@ syn_current_attr(syncing, displaying, can_spell, keep_state)
? (syn_buf->b_spell_cluster_id == 0)
: (syn_buf->b_syn_spell == SYNSPL_TOP);
/* nextgroup ends at end of line, unless "skipnl" or "skipemtpy" present */
/* nextgroup ends at end of line, unless "skipnl" or "skipempty" present */
if (current_next_list != NULL
&& syn_getcurline()[current_col + 1] == NUL
&& !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)))
@@ -6108,7 +6108,7 @@ syn_get_id(wp, lnum, col, trans, spellp, keep_state)
win_T *wp;
long lnum;
colnr_T col;
int trans; /* remove transparancy */
int trans; /* remove transparency */
int *spellp; /* return: can do spell checking */
int keep_state; /* keep state of char at "col" */
{
@@ -7523,7 +7523,7 @@ highlight_clear(idx)
#if defined(FEAT_GUI) || defined(PROTO)
/*
* Set the normal foreground and background colors according to the "Normal"
* highlighighting group. For X11 also set "Menu", "Scrollbar", and
* highlighting group. For X11 also set "Menu", "Scrollbar", and
* "Tooltip" colors.
*/
void
@@ -8647,6 +8647,7 @@ syn_add_group(name)
if (!vim_isprintc(*p))
{
EMSG(_("E669: Unprintable character in group name"));
vim_free(name);
return 0;
}
else if (!ASCII_ISALNUM(*p) && *p != '_')

View File

@@ -26,7 +26,7 @@ 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
test66.out test67.out test68.out test69.out
.SUFFIXES: .in .out
@@ -113,3 +113,5 @@ test64.out: test64.in
test65.out: test65.in
test66.out: test66.in
test67.out: test67.in
test68.out: test68.in
test69.out: test69.in

View File

@@ -26,7 +26,8 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test15.out test17.out test18.out test21.out test26.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
test42.out test52.out test65.out test66.out test67.out \
test68.out test69.out
SCRIPTS32 = test50.out

View File

@@ -45,7 +45,8 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test15.out test17.out test18.out test21.out test26.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
test42.out test52.out test65.out test66.out test67.out \
test68.out test69.out
SCRIPTS32 = test50.out

View File

@@ -26,7 +26,7 @@ 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
test66.out test67.out test68.out test69.out
.SUFFIXES: .in .out

View File

@@ -69,7 +69,7 @@ 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
test66.out test67.out test68.out test69.out
.IFDEF WANT_GUI
SCRIPT_GUI = test16.out

View File

@@ -22,7 +22,8 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
test48.out test49.out test51.out test52.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
test64.out test65.out test66.out test67.out test68.out \
test69.out
SCRIPTS_GUI = test16.out

56
src/testdir/test68.in Normal file
View File

@@ -0,0 +1,56 @@
Test for text formatting.
Results of test68:
STARTTEST
:so small.vim
/^{/+1
:set noai tw=2 fo=t
gRa b
ENDTEST
{
}
STARTTEST
/^{/+1
:set ai tw=2 fo=tw
gqgqjjllab
ENDTEST
{
a b
a
}
STARTTEST
/^{/+1
:set tw=3 fo=t
gqgqo
a 
ENDTEST
{
a 
}
STARTTEST
/^{/+1
:set tw=2 fo=tcq1 comments=:#
gqgqjgqgqo
a b
#a b
ENDTEST
{
a b
#a b
}
STARTTEST
:g/^STARTTEST/.,/^ENDTEST/d
:1;/^Results/,$wq! test.out
ENDTEST

35
src/testdir/test68.ok Normal file
View File

@@ -0,0 +1,35 @@
Results of test68:
{
a
b
}
{
a
b
a
b
}
{
a

a

}
{
a b
#a b
a b
#a b
}

139
src/testdir/test69.in Normal file
View File

@@ -0,0 +1,139 @@
Test for multi-byte text formatting.
STARTTEST
:so mbyte.vim
:set encoding=utf-8
ENDTEST
Results of test69:
STARTTEST
/^{/+1
:set tw=2 fo=t
gqgqjgqgqo
abc 
ENDTEST
{
abc
}
STARTTEST
/^{/+1
:set tw=1 fo=tm
gqgqjgqgqjgqgqjgqgqjgqgqo
a
a

ENDTEST
{
a
a
}
STARTTEST
/^{/+1
:set tw=2 fo=tm
gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo
a
a
a
ab
abc
ab c
ab
ENDTEST
{
a
a
a
ab
abc
ab c
ab
}
STARTTEST
/^{/+1
:set ai tw=2 fo=tm
gqgqjgqgqo
a
ENDTEST
{
a
}
STARTTEST
/^{/+1
:set noai tw=2 fo=tm
gqgqjgqgqo
a
ENDTEST
{
a
}
STARTTEST
/^{/+1
:set tw=2 fo=cqm comments=n:
gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqo
a
a
a

ENDTEST
{
a
a
a
}
STARTTEST
/^{/+1
:set tw=2 fo=tm
Ra
ENDTEST
{
}
STARTTEST
:g/^STARTTEST/.,/^ENDTEST/d
:1;/^Results/,$wq! test.out
ENDTEST

142
src/testdir/test69.ok Normal file
View File

@@ -0,0 +1,142 @@
Results of test69:
{
abc
abc
}
{
a
a
a
a
}
{
a
a
a
ab
abc
ab
c
ab
a
a
a
ab
abc
ab
c
ab
}
{
a
a
}
{
a
a
}
{
a
a
a
a
a
a
}
{
a
}

View File

@@ -681,6 +681,62 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
320,
/**/
319,
/**/
318,
/**/
317,
/**/
316,
/**/
315,
/**/
314,
/**/
313,
/**/
312,
/**/
311,
/**/
310,
/**/
309,
/**/
308,
/**/
307,
/**/
306,
/**/
305,
/**/
304,
/**/
303,
/**/
302,
/**/
301,
/**/
300,
/**/
299,
/**/
298,
/**/
297,
/**/
296,
/**/
295,
/**/
294,
/**/
293,
/**/
292,
/**/