From e8c6329894561fe6704fbc5d478e3e9a1e9e3ee2 Mon Sep 17 00:00:00 2001 From: edyfox Date: Thu, 3 Dec 2009 02:09:53 +0000 Subject: [PATCH] Merged from the latest developing branch. git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@1690 2a77ed30-b011-0410-a7ad-c7884a0aa172 --- runtime/filetype.vim | 10 +++++--- src/auto/configure | 10 ++++---- src/configure.in | 6 ++--- src/ex_getln.c | 3 ++- src/fileio.c | 2 +- src/mbyte.c | 69 ++++++++++++++++++++++++++++++++++++++-------------- src/misc1.c | 42 ++++++++++++++++++++++++++++++-- src/proto/misc1.pro | 1 + src/regexp.c | 2 ++ src/version.c | 14 +++++++++++ 10 files changed, 125 insertions(+), 34 deletions(-) diff --git a/runtime/filetype.vim b/runtime/filetype.vim index a8e6261e..c34510ed 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -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("") !~ 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 diff --git a/src/auto/configure b/src/auto/configure index 7230ce39..f7be0a77 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -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 diff --git a/src/configure.in b/src/configure.in index 727bfd1b..6e292c4c 100644 --- a/src/configure.in +++ b/src/configure.in @@ -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') ]) diff --git a/src/ex_getln.c b/src/ex_getln.c index 15371288..08a7855e 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -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; diff --git a/src/fileio.c b/src/fileio.c index 805ff873..f63bb60d 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -21,7 +21,7 @@ #include "vim.h" -#ifdef __TANDEM +#if defined(__TANDEM) || defined(__MINT__) # include /* for SSIZE_MAX */ #endif diff --git a/src/mbyte.c b/src/mbyte.c index 87683ba0..530a8e90 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -133,22 +133,40 @@ 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 . */ 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; diff --git a/src/misc1.c b/src/misc1.c index aa902150..3da0d9ae 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -4666,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. @@ -4687,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 @@ -8447,6 +8445,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'. * Returns OK or FAIL. diff --git a/src/proto/misc1.pro b/src/proto/misc1.pro index a54b8b56..a036e3ea 100644 --- a/src/proto/misc1.pro +++ b/src/proto/misc1.pro @@ -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)); diff --git a/src/regexp.c b/src/regexp.c index e507e40e..037222e0 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -7214,6 +7214,8 @@ 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 diff --git a/src/version.c b/src/version.c index 7d3c4359..874b163f 100644 --- a/src/version.c +++ b/src/version.c @@ -682,6 +682,20 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 315, +/**/ + 314, +/**/ + 313, +/**/ + 312, +/**/ + 311, +/**/ + 310, +/**/ + 309, +/**/ 308, /**/ 307, -- 2.11.4.GIT