From 88ae0dcb2977b728ced343641043f242b9a6a413 Mon Sep 17 00:00:00 2001 From: edyfox Date: Thu, 21 Jan 2010 06:56:00 +0000 Subject: [PATCH] Merged from the latest developing branch. git-svn-id: https://vim.svn.sourceforge.net/svnroot/vim/trunk@1734 2a77ed30-b011-0410-a7ad-c7884a0aa172 --- runtime/doc/eval.txt | 24 +- runtime/doc/if_mzsch.txt | 17 +- runtime/doc/usr_41.txt | 2 + runtime/tools/README.txt | 2 + runtime/tools/unicode.vim | 280 ++++++++++++ src/buffer.c | 2 +- src/edit.c | 7 +- src/eval.c | 41 +- src/ex_cmds2.c | 46 +- src/ex_getln.c | 3 +- src/fileio.c | 4 +- src/fold.c | 4 +- src/if_cscope.c | 2 +- src/if_mzsch.c | 221 ++++++++++ src/mbyte.c | 1039 ++++++++++++++++++++++++++++++++++++--------- src/netbeans.c | 60 ++- src/normal.c | 19 +- src/ops.c | 4 +- src/popupmnu.c | 33 +- src/proto/eval.pro | 5 + src/proto/if_mzsch.pro | 1 + src/proto/netbeans.pro | 2 +- src/quickfix.c | 12 +- src/screen.c | 9 +- src/spell.c | 11 +- src/syntax.c | 1 - src/testdir/Make_dos.mak | 2 +- src/testdir/Make_ming.mak | 3 +- src/testdir/Makefile | 6 +- src/testdir/main.aap | 4 +- src/testdir/test1.in | 4 + src/testdir/test70.in | 53 +++ src/testdir/test70.ok | 5 + src/ui.c | 2 +- src/version.c | 34 ++ 35 files changed, 1654 insertions(+), 310 deletions(-) create mode 100644 runtime/tools/unicode.vim create mode 100644 src/testdir/test70.in create mode 100644 src/testdir/test70.ok diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index afa38a49..feee51a9 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1815,11 +1815,12 @@ matchlist( {expr}, {pat}[, {start}[, {count}]]) List match and submatches of {pat} in {expr} matchstr( {expr}, {pat}[, {start}[, {count}]]) String {count}'th match of {pat} in {expr} -max({list}) Number maximum value of items in {list} -min({list}) Number minimum value of items in {list} -mkdir({name} [, {path} [, {prot}]]) +max( {list}) Number maximum value of items in {list} +min( {list}) Number minimum value of items in {list} +mkdir( {name} [, {path} [, {prot}]]) Number create directory {name} mode( [expr]) String current editing mode +mzeval( {expr}) any evaluate |MzScheme| expression nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum} nr2char( {expr}) String single char with ASCII value {expr} pathshorten( {expr}) String shorten directory names in a path @@ -4090,6 +4091,23 @@ mode([expr]) Return a string that indicates the current mode. "c" or "n". Also see |visualmode()|. +mzeval({expr}) *mzeval()* + Evaluate MzScheme expression {expr} and return its result + convert to Vim data structures. + Numbers and strings are returned as they are. + Pairs (including lists and improper lists) and vectors are + returned as Vim |Lists|. + Hash tables are represented as Vim |Dictionary| type with keys + converted to strings. + All other types are converted to string with display function. + Examples: > + :mz (define l (list 1 2 3)) + :mz (define h (make-hash)) (hash-set! h "list" l) + :echo mzeval("l") + :echo mzeval("h") +< + {only available when compiled with the |+mzscheme| feature} + nextnonblank({lnum}) *nextnonblank()* Return the line number of the first line at or below {lnum} that is not blank. Example: > diff --git a/runtime/doc/if_mzsch.txt b/runtime/doc/if_mzsch.txt index ceecdba3..484d09aa 100644 --- a/runtime/doc/if_mzsch.txt +++ b/runtime/doc/if_mzsch.txt @@ -1,4 +1,4 @@ -*if_mzsch.txt* For Vim version 7.2. Last change: 2009 Jun 24 +*if_mzsch.txt* For Vim version 7.2. Last change: 2010 Jan 19 VIM REFERENCE MANUAL by Sergey Khorev @@ -9,8 +9,9 @@ The MzScheme Interface to Vim *mzscheme* *MzScheme* 1. Commands |mzscheme-commands| 2. Examples |mzscheme-examples| 3. Threads |mzscheme-threads| -4. The Vim access procedures |mzscheme-vim| -5. Dynamic loading |mzscheme-dynamic| +4. Vim access from MzScheme |mzscheme-vim| +5. mzeval() Vim function |mzscheme-mzeval| +6. Dynamic loading |mzscheme-dynamic| {Vi does not have any of these commands} @@ -142,7 +143,7 @@ Thread scheduling in the console version of Vim is less reliable than in the GUI version. ============================================================================== -5. VIM Functions *mzscheme-vim* +4. Vim access from MzScheme *mzscheme-vim* *mzscheme-vimext* The 'vimext' module provides access to procedures defined in the MzScheme @@ -231,7 +232,13 @@ Windows *mzscheme-window* (set-cursor (line . col) [window]) Set cursor position. ============================================================================== -5. Dynamic loading *mzscheme-dynamic* *E815* +5. mzeval() Vim function *mzscheme-mzeval* + +To facilitate bi-directional interface, you can use |mzeval| function to +evaluate MzScheme expressions and pass their values to VimL. + +============================================================================== +6. Dynamic loading *mzscheme-dynamic* *E815* On MS-Windows the MzScheme libraries can be loaded dynamically. The |:version| output then includes |+mzscheme/dyn|. diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 5305ff18..210179da 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -868,6 +868,8 @@ Various: taglist() get list of matching tags tagfiles() get a list of tags files + mzeval() evaluate |MzScheme| expression + ============================================================================== *41.7* Defining a function diff --git a/runtime/tools/README.txt b/runtime/tools/README.txt index f5274df2..fa176c77 100644 --- a/runtime/tools/README.txt +++ b/runtime/tools/README.txt @@ -32,4 +32,6 @@ vim_vs_net.cmd: MS-Windows command file to use Vim with MS Visual Studio 7 and xcmdsrv_client.c: Example for a client program that communicates with a Vim server through the X-Windows interface. +unicode.vim Vim script to generate tables for src/mbyte.c. + [xxd (and tee for OS/2) can be found in the src directory] diff --git a/runtime/tools/unicode.vim b/runtime/tools/unicode.vim new file mode 100644 index 00000000..f33df420 --- /dev/null +++ b/runtime/tools/unicode.vim @@ -0,0 +1,280 @@ +" Script to extract tables from Unicode .txt files, to be used in src/mbyte.c. +" The format of the UnicodeData.txt file is explained here: +" http://www.unicode.org/Public/5.1.0/ucd/UCD.html +" For the other files see the header. +" +" Usage: Vim -S +" +" Author: Bram Moolenaar +" Last Update: 2010 Jan 12 + +" Parse lines of UnicodeData.txt. Creates a list of lists in s:dataprops. +func! ParseDataToProps() + let s:dataprops = [] + let lnum = 1 + while lnum <= line('$') + let l = split(getline(lnum), '\s*;\s*', 1) + if len(l) != 15 + echoerr 'Found ' . len(l) . ' items in line ' . lnum . ', expected 15' + return + endif + call add(s:dataprops, l) + let lnum += 1 + endwhile +endfunc + +" Parse lines of CaseFolding.txt. Creates a list of lists in s:foldprops. +func! ParseFoldProps() + let s:foldprops = [] + let lnum = 1 + while lnum <= line('$') + let line = getline(lnum) + if line !~ '^#' && line !~ '^\s*$' + let l = split(line, '\s*;\s*', 1) + if len(l) != 4 + echoerr 'Found ' . len(l) . ' items in line ' . lnum . ', expected 4' + return + endif + call add(s:foldprops, l) + endif + let lnum += 1 + endwhile +endfunc + +" Parse lines of EastAsianWidth.txt. Creates a list of lists in s:widthprops. +func! ParseWidthProps() + let s:widthprops = [] + let lnum = 1 + while lnum <= line('$') + let line = getline(lnum) + if line !~ '^#' && line !~ '^\s*$' + let l = split(line, '\s*;\s*', 1) + if len(l) != 2 + echoerr 'Found ' . len(l) . ' items in line ' . lnum . ', expected 2' + return + endif + call add(s:widthprops, l) + endif + let lnum += 1 + endwhile +endfunc + +" Build the toLower or toUpper table in a new buffer. +" Uses s:dataprops. +func! BuildCaseTable(name, index) + let start = -1 + let end = -1 + let step = 0 + let add = -1 + let ranges = [] + for p in s:dataprops + if p[a:index] != '' + let n = ('0x' . p[0]) + 0 + let nl = ('0x' . p[a:index]) + 0 + if start >= 0 && add == nl - n && (step == 0 || n - end == step) + " continue with same range. + let step = n - end + let end = n + else + if start >= 0 + " produce previous range + call Range(ranges, start, end, step, add) + endif + let start = n + let end = n + let step = 0 + let add = nl - n + endif + endif + endfor + if start >= 0 + call Range(ranges, start, end, step, add) + endif + + " New buffer to put the result in. + new + exe "file to" . a:name + call setline(1, "static convertStruct to" . a:name . "[] =") + call setline(2, "{") + call append('$', ranges) + call setline('$', getline('$')[:-2]) " remove last comma + call setline(line('$') + 1, "};") + wincmd p +endfunc + +" Build the foldCase table in a new buffer. +" Uses s:foldprops. +func! BuildFoldTable() + let start = -1 + let end = -1 + let step = 0 + let add = -1 + let ranges = [] + for p in s:foldprops + if p[1] == 'C' || p[1] == 'S' + let n = ('0x' . p[0]) + 0 + let nl = ('0x' . p[2]) + 0 + if start >= 0 && add == nl - n && (step == 0 || n - end == step) + " continue with same range. + let step = n - end + let end = n + else + if start >= 0 + " produce previous range + call Range(ranges, start, end, step, add) + endif + let start = n + let end = n + let step = 0 + let add = nl - n + endif + endif + endfor + if start >= 0 + call Range(ranges, start, end, step, add) + endif + + " New buffer to put the result in. + new + file foldCase + call setline(1, "static convertStruct foldCase[] =") + call setline(2, "{") + call append('$', ranges) + call setline('$', getline('$')[:-2]) " remove last comma + call setline(line('$') + 1, "};") + wincmd p +endfunc + +func! Range(ranges, start, end, step, add) + let s = printf("\t{0x%x,0x%x,%d,%d},", a:start, a:end, a:step == 0 ? -1 : a:step, a:add) + call add(a:ranges, s) +endfunc + +" Build the combining table. +" Uses s:dataprops. +func! BuildCombiningTable() + let start = -1 + let end = -1 + let ranges = [] + for p in s:dataprops + if p[2] == 'Mn' || p[2] == 'Mc' || p[2] == 'Me' + let n = ('0x' . p[0]) + 0 + if start >= 0 && end + 1 == n + " continue with same range. + let end = n + else + if start >= 0 + " produce previous range + call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end)) + endif + let start = n + let end = n + endif + endif + endfor + if start >= 0 + call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end)) + endif + + " New buffer to put the result in. + new + file combining + call setline(1, " static struct interval combining[] =") + call setline(2, " {") + call append('$', ranges) + call setline('$', getline('$')[:-2]) " remove last comma + call setline(line('$') + 1, " };") + wincmd p +endfunc + +" Build the ambiguous table in a new buffer. +" Uses s:widthprops and s:dataprops. +func! BuildAmbiguousTable() + let start = -1 + let end = -1 + let ranges = [] + let dataidx = 0 + for p in s:widthprops + if p[1][0] == 'A' + let n = ('0x' . p[0]) + 0 + " Find this char in the data table. + while 1 + let dn = ('0x' . s:dataprops[dataidx][0]) + 0 + if dn >= n + break + endif + let dataidx += 1 + endwhile + if dn != n + echoerr "Cannot find character " . n . " in data table" + endif + " Only use the char when it's not a composing char. + let dp = s:dataprops[dataidx] + if dp[2] != 'Mn' && dp[2] != 'Mc' && dp[2] != 'Me' + if start >= 0 && end + 1 == n + " continue with same range. + let end = n + else + if start >= 0 + " produce previous range + call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end)) + endif + let start = n + if p[0] =~ '\.\.' + let end = ('0x' . substitute(p[0], '.*\.\.', '', '')) + 0 + else + let end = n + endif + endif + endif + endif + endfor + if start >= 0 + call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end)) + endif + + " New buffer to put the result in. + new + file ambiguous + call setline(1, " static struct interval ambiguous[] =") + call setline(2, " {") + call append('$', ranges) + call setline('$', getline('$')[:-2]) " remove last comma + call setline(line('$') + 1, " };") + wincmd p +endfunc + + + +" Edit the Unicode text file. Requires the netrw plugin. +edit http://unicode.org/Public/UNIDATA/UnicodeData.txt + +" Parse each line, create a list of lists. +call ParseDataToProps() + +" Build the toLower table. +call BuildCaseTable("Lower", 13) + +" Build the toUpper table. +call BuildCaseTable("Upper", 12) + +" Build the ranges of composing chars. +call BuildCombiningTable() + +" Edit the case folding text file. Requires the netrw plugin. +edit http://www.unicode.org/Public/UNIDATA/CaseFolding.txt + +" Parse each line, create a list of lists. +call ParseFoldProps() + +" Build the foldCase table. +call BuildFoldTable() + +" Edit the width text file. Requires the netrw plugin. +edit http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt + +" Parse each line, create a list of lists. +call ParseWidthProps() + +" Build the ambiguous table. +call BuildAmbiguousTable() diff --git a/src/buffer.c b/src/buffer.c index 2d64bca8..a3cd6be3 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -315,7 +315,7 @@ close_buffer(win, buf, action) { #ifdef FEAT_AUTOCMD int is_curbuf; - int nwindows = buf->b_nwindows; + int nwindows; #endif int unload_buf = (action != 0); int del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE); diff --git a/src/edit.c b/src/edit.c index 75b18084..43058f8b 100644 --- a/src/edit.c +++ b/src/edit.c @@ -4048,7 +4048,7 @@ ins_compl_get_exp(ini) save_p_ic = p_ic; p_ic = ignorecase(compl_pattern); - /* Find up to TAG_MANY matches. Avoids that an enourmous number + /* Find up to TAG_MANY matches. Avoids that an enormous number * of matches is found when compl_pattern is empty */ if (find_tags(compl_pattern, &num_matches, &matches, TAG_REGEXP | TAG_NAMES | TAG_NOIC | @@ -4219,7 +4219,7 @@ ins_compl_get_exp(ini) || IObuff[len - 2] == '!')))) IObuff[len++] = ' '; } - /* copy as much as posible of the new word */ + /* copy as much as possible of the new word */ if (tmp_ptr - ptr >= IOSIZE - len) tmp_ptr = ptr + IOSIZE - len - 1; STRNCPY(IObuff + len, ptr, tmp_ptr - ptr); @@ -5827,10 +5827,7 @@ internal_format(textwidth, second_indent, flags, format_only, c) #endif && !has_format_option(FO_WRAP)) - { - textwidth = 0; break; - } if ((startcol = curwin->w_cursor.col) == 0) break; diff --git a/src/eval.c b/src/eval.c index 6bd2aa72..f4f3c7a1 100644 --- a/src/eval.c +++ b/src/eval.c @@ -433,7 +433,6 @@ static listitem_T *list_find __ARGS((list_T *l, long n)); static long list_find_nr __ARGS((list_T *l, long idx, int *errorp)); static long list_idx_of_item __ARGS((list_T *l, listitem_T *item)); static void list_append __ARGS((list_T *l, listitem_T *item)); -static int list_append_tv __ARGS((list_T *l, typval_T *tv)); static int list_append_number __ARGS((list_T *l, varnumber_T n)); static int list_insert_tv __ARGS((list_T *l, typval_T *tv, listitem_T *item)); static int list_extend __ARGS((list_T *l1, list_T *l2, listitem_T *bef)); @@ -448,12 +447,9 @@ static void set_ref_in_list __ARGS((list_T *l, int copyID)); static void set_ref_in_item __ARGS((typval_T *tv, int copyID)); static void dict_unref __ARGS((dict_T *d)); static void dict_free __ARGS((dict_T *d, int recurse)); -static dictitem_T *dictitem_alloc __ARGS((char_u *key)); static dictitem_T *dictitem_copy __ARGS((dictitem_T *org)); static void dictitem_remove __ARGS((dict_T *dict, dictitem_T *item)); -static void dictitem_free __ARGS((dictitem_T *item)); static dict_T *dict_copy __ARGS((dict_T *orig, int deep, int copyID)); -static int dict_add __ARGS((dict_T *d, dictitem_T *item)); static long dict_len __ARGS((dict_T *d)); static dictitem_T *dict_find __ARGS((dict_T *d, char_u *key, int len)); static char_u *dict2string __ARGS((typval_T *tv, int copyID)); @@ -628,6 +624,9 @@ static void f_min __ARGS((typval_T *argvars, typval_T *rettv)); static void f_mkdir __ARGS((typval_T *argvars, typval_T *rettv)); #endif static void f_mode __ARGS((typval_T *argvars, typval_T *rettv)); +#ifdef FEAT_MZSCHEME +static void f_mzeval __ARGS((typval_T *argvars, typval_T *rettv)); +#endif static void f_nextnonblank __ARGS((typval_T *argvars, typval_T *rettv)); static void f_nr2char __ARGS((typval_T *argvars, typval_T *rettv)); static void f_pathshorten __ARGS((typval_T *argvars, typval_T *rettv)); @@ -764,7 +763,6 @@ static void set_var __ARGS((char_u *name, typval_T *varp, int copy)); static int var_check_ro __ARGS((int flags, char_u *name)); static int var_check_fixed __ARGS((int flags, char_u *name)); static int tv_check_lock __ARGS((int lock, char_u *name)); -static void copy_tv __ARGS((typval_T *from, typval_T *to)); static int item_copy __ARGS((typval_T *from, typval_T *to, int deep, int copyID)); static char_u *find_option_end __ARGS((char_u **arg, int *opt_flags)); static char_u *trans_function_name __ARGS((char_u **pp, int skip, int flags, funcdict_T *fd)); @@ -6155,7 +6153,7 @@ list_append(l, item) * Append typval_T "tv" to the end of list "l". * Return FAIL when out of memory. */ - static int + int list_append_tv(l, tv) list_T *l; typval_T *tv; @@ -6475,6 +6473,7 @@ list_join(gap, l, sep, echo, copyID) vim_free(tofree); if (s == NULL) return FAIL; + line_breakcheck(); } return OK; } @@ -6811,7 +6810,7 @@ dict_free(d, recurse) * Note that the value of the item "di_tv" still needs to be initialized! * Returns NULL when out of memory. */ - static dictitem_T * + dictitem_T * dictitem_alloc(key) char_u *key; { @@ -6867,7 +6866,7 @@ dictitem_remove(dict, item) /* * Free a dict item. Also clears the value. */ - static void + void dictitem_free(item) dictitem_T *item; { @@ -6947,7 +6946,7 @@ dict_copy(orig, deep, copyID) * Add item "item" to Dictionary "d". * Returns FAIL when out of memory and when key already existed. */ - static int + int dict_add(d, item) dict_T *d; dictitem_T *item; @@ -7698,6 +7697,9 @@ static struct fst {"mkdir", 1, 3, f_mkdir}, #endif {"mode", 0, 1, f_mode}, +#ifdef FEAT_MZSCHEME + {"mzeval", 1, 1, f_mzeval}, +#endif {"nextnonblank", 1, 1, f_nextnonblank}, {"nr2char", 1, 1, f_nr2char}, {"pathshorten", 1, 1, f_pathshorten}, @@ -11453,7 +11455,7 @@ f_has(argvars, rettv) #if defined(UNIX) && (defined(__CYGWIN32__) || defined(__CYGWIN__)) "win32unix", #endif -#ifdef WIN64 +#if defined(WIN64) || defined(_WIN64) "win64", #endif #ifdef EBCDIC @@ -13590,6 +13592,23 @@ f_mode(argvars, rettv) rettv->v_type = VAR_STRING; } +#ifdef FEAT_MZSCHEME +/* + * "mzeval()" function + */ + static void +f_mzeval(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ + char_u *str; + char_u buf[NUMBUFLEN]; + + str = get_tv_string_buf(&argvars[0], buf); + do_mzeval(str, rettv); +} +#endif + /* * "nextnonblank()" function */ @@ -19273,7 +19292,7 @@ tv_check_lock(lock, name) * It is OK for "from" and "to" to point to the same item. This is used to * make a copy later. */ - static void + void copy_tv(from, to) typval_T *from; typval_T *to; diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 1108ab96..81feac83 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -2496,14 +2496,15 @@ ex_compiler(eap) * To remain backwards compatible "current_compiler" is always * used. A user's compiler plugin may set it, the distributed * plugin will then skip the settings. Afterwards set - * "b:current_compiler" and restore "current_compiler". */ - old_cur_comp = get_var_value((char_u *)"current_compiler"); + * "b:current_compiler" and restore "current_compiler". + * Explicitly prepend "g:" to make it work in a function. */ + old_cur_comp = get_var_value((char_u *)"g:current_compiler"); if (old_cur_comp != NULL) old_cur_comp = vim_strsave(old_cur_comp); do_cmdline_cmd((char_u *) "command -nargs=* CompilerSet setlocal "); } - do_unlet((char_u *)"current_compiler", TRUE); + do_unlet((char_u *)"g:current_compiler", TRUE); do_unlet((char_u *)"b:current_compiler", TRUE); sprintf((char *)buf, "compiler/%s.vim", eap->arg); @@ -2514,7 +2515,7 @@ ex_compiler(eap) do_cmdline_cmd((char_u *)":delcommand CompilerSet"); /* Set "b:current_compiler" from "current_compiler". */ - p = get_var_value((char_u *)"current_compiler"); + p = get_var_value((char_u *)"g:current_compiler"); if (p != NULL) set_internal_string_var((char_u *)"b:current_compiler", p); @@ -2523,12 +2524,12 @@ ex_compiler(eap) { if (old_cur_comp != NULL) { - set_internal_string_var((char_u *)"current_compiler", + set_internal_string_var((char_u *)"g:current_compiler", old_cur_comp); vim_free(old_cur_comp); } else - do_unlet((char_u *)"current_compiler", TRUE); + do_unlet((char_u *)"g:current_compiler", TRUE); } } } @@ -2801,20 +2802,35 @@ source_level(cookie) static char_u *get_one_sourceline __ARGS((struct source_cookie *sp)); -#if defined(WIN32) && defined(FEAT_CSCOPE) +#if (defined(WIN32) && defined(FEAT_CSCOPE)) || defined(HAVE_FD_CLOEXEC) +# define USE_FOPEN_NOINH static FILE *fopen_noinh_readbin __ARGS((char *filename)); /* * Special function to open a file without handle inheritance. + * When possible the handle is closed on exec(). */ static FILE * fopen_noinh_readbin(filename) char *filename; { +# ifdef WIN32 int fd_tmp = mch_open(filename, O_RDONLY | O_BINARY | O_NOINHERIT, 0); +# else + int fd_tmp = mch_open(filename, O_RDONLY, 0); +# endif if (fd_tmp == -1) return NULL; + +# ifdef HAVE_FD_CLOEXEC + { + int fdflags = fcntl(fd_tmp, F_GETFD); + if (fdflags >= 0 && (fdflags & FD_CLOEXEC) == 0) + fcntl(fd_tmp, F_SETFD, fdflags | FD_CLOEXEC); + } +# endif + return fdopen(fd_tmp, READBIN); } #endif @@ -2894,7 +2910,7 @@ do_source(fname, check_other, is_vimrc) apply_autocmds(EVENT_SOURCEPRE, fname_exp, fname_exp, FALSE, curbuf); #endif -#if defined(WIN32) && defined(FEAT_CSCOPE) +#ifdef USE_FOPEN_NOINH cookie.fp = fopen_noinh_readbin((char *)fname_exp); #else cookie.fp = mch_fopen((char *)fname_exp, READBIN); @@ -2915,7 +2931,7 @@ do_source(fname, check_other, is_vimrc) *p = '.'; else *p = '_'; -#if defined(WIN32) && defined(FEAT_CSCOPE) +#ifdef USE_FOPEN_NOINH cookie.fp = fopen_noinh_readbin((char *)fname_exp); #else cookie.fp = mch_fopen((char *)fname_exp, READBIN); @@ -3020,7 +3036,8 @@ do_source(fname, check_other, is_vimrc) #endif #ifdef STARTUPTIME - time_push(&tv_rel, &tv_start); + if (time_fd != NULL) + time_push(&tv_rel, &tv_start); #endif #ifdef FEAT_EVAL @@ -3146,9 +3163,12 @@ do_source(fname, check_other, is_vimrc) verbose_leave(); } #ifdef STARTUPTIME - vim_snprintf((char *)IObuff, IOSIZE, "sourcing %s", fname); - time_msg((char *)IObuff, &tv_start); - time_pop(&tv_rel); + if (time_fd != NULL) + { + vim_snprintf((char *)IObuff, IOSIZE, "sourcing %s", fname); + time_msg((char *)IObuff, &tv_start); + time_pop(&tv_rel); + } #endif #ifdef FEAT_EVAL diff --git a/src/ex_getln.c b/src/ex_getln.c index 08a7855e..d5761f33 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -2193,7 +2193,6 @@ getexmodeline(promptc, cookie, indent) { if (ga_grow(&line_ga, 40) == FAIL) break; - pend = (char_u *)line_ga.ga_data + line_ga.ga_len; /* Get one character at a time. Don't use inchar(), it can't handle * special characters. */ @@ -3314,7 +3313,7 @@ nextwild(xp, type, options) WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE |options, type); vim_free(p1); - /* longest match: make sure it is not shorter (happens with :help */ + /* longest match: make sure it is not shorter, happens with :help */ if (p2 != NULL && type == WILD_LONGEST) { for (j = 0; j < xp->xp_pattern_len; ++j) diff --git a/src/fileio.c b/src/fileio.c index bdc7439c..0e2d1cca 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -7072,8 +7072,8 @@ vim_tempname(extra_char) */ for (i = 0; i < (int)(sizeof(tempdirs) / sizeof(char *)); ++i) { - size_t itmplen; # ifndef HAVE_MKDTEMP + size_t itmplen; long nr; long off; # endif @@ -7091,7 +7091,6 @@ vim_tempname(extra_char) else # endif add_pathsep(itmp); - itmplen = STRLEN(itmp); # ifdef HAVE_MKDTEMP /* Leave room for filename */ @@ -7104,6 +7103,7 @@ vim_tempname(extra_char) * otherwise it doesn't matter. The use of mkdir() avoids any * security problems because of the predictable number. */ nr = (mch_get_pid() + (long)time(NULL)) % 1000000L; + itmplen = STRLEN(itmp); /* Try up to 10000 different values until we find a name that * doesn't exist. */ diff --git a/src/fold.c b/src/fold.c index 2898c01d..405a6ef1 100644 --- a/src/fold.c +++ b/src/fold.c @@ -3239,8 +3239,8 @@ foldlevelMarker(flp) flp->lvl = n; flp->lvl_next = n - 1; /* never start a fold with an end marker */ - if (flp->lvl_next > flp->lvl) - flp->lvl_next = flp->lvl; + if (flp->lvl_next > start_lvl) + flp->lvl_next = start_lvl; } } else diff --git a/src/if_cscope.c b/src/if_cscope.c index bd90eca8..b2a4ce1a 100644 --- a/src/if_cscope.c +++ b/src/if_cscope.c @@ -2069,7 +2069,7 @@ cs_print_tags_priv(matches, cntxts, num_matches) continue; (void)strcpy(tbuf, matches[idx]); - if ((fname = strtok(tbuf, (const char *)"\t")) == NULL) + if (strtok(tbuf, (const char *)"\t") == NULL) continue; if ((fname = strtok(NULL, (const char *)"\t")) == NULL) continue; diff --git a/src/if_mzsch.c b/src/if_mzsch.c index 34994518..af56cd01 100644 --- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -170,6 +170,8 @@ static int mzscheme_init(void); #ifdef FEAT_EVAL static Scheme_Object *vim_to_mzscheme(typval_T *vim_value, int depth, Scheme_Hash_Table *visited); +static int mzscheme_to_vim(Scheme_Object *obj, typval_T *tv, int depth, + Scheme_Hash_Table *visited); #endif #ifdef MZ_PRECISE_GC @@ -2733,6 +2735,225 @@ vim_to_mzscheme(typval_T *vim_value, int depth, Scheme_Hash_Table *visited) MZ_GC_UNREG(); return result; } + + static int +mzscheme_to_vim(Scheme_Object *obj, typval_T *tv, int depth, + Scheme_Hash_Table *visited) +{ + int status = OK; + typval_T *found; + MZ_GC_CHECK(); + if (depth > 100) /* limit the deepest recursion level */ + { + tv->v_type = VAR_NUMBER; + tv->vval.v_number = 0; + return FAIL; + } + + found = (typval_T *)scheme_hash_get(visited, obj); + if (found != NULL) + copy_tv(found, tv); + else if (SCHEME_VOIDP(obj)) + { + tv->v_type = VAR_NUMBER; + tv->vval.v_number = 0; + } + else if (SCHEME_INTP(obj)) + { + tv->v_type = VAR_NUMBER; + tv->vval.v_number = SCHEME_INT_VAL(obj); + } + else if (SCHEME_BOOLP(obj)) + { + tv->v_type = VAR_NUMBER; + tv->vval.v_number = SCHEME_TRUEP(obj); + } +# ifdef FEAT_FLOAT + else if (SCHEME_DBLP(obj)) + { + tv->v_type = VAR_FLOAT; + tv->vval.v_float = SCHEME_DBL_VAL(obj); + } +# endif + else if (SCHEME_STRINGP(obj)) + { + tv->v_type = VAR_STRING; + tv->vval.v_string = vim_strsave((char_u *)SCHEME_STR_VAL(obj)); + } + else if (SCHEME_VECTORP(obj) || SCHEME_NULLP(obj) + || SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj)) + { + list_T *list = list_alloc(); + if (list == NULL) + status = FAIL; + else + { + int i; + Scheme_Object *curr = NULL; + Scheme_Object *cval = NULL; + /* temporary var to hold current element of vectors and pairs */ + typval_T *v; + + MZ_GC_DECL_REG(2); + MZ_GC_VAR_IN_REG(0, curr); + MZ_GC_VAR_IN_REG(1, cval); + MZ_GC_REG(); + + tv->v_type = VAR_LIST; + tv->vval.v_list = list; + ++list->lv_refcount; + + v = (typval_T *)alloc(sizeof(typval_T)); + if (v == NULL) + status = FAIL; + else + { + /* add the value in advance to allow handling of self-referencial + * data structures */ + typval_T *visited_tv = (typval_T *)alloc(sizeof(typval_T)); + copy_tv(tv, visited_tv); + scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv); + + if (SCHEME_VECTORP(obj)) + { + for (i = 0; i < SCHEME_VEC_SIZE(obj); ++i) + { + cval = SCHEME_VEC_ELS(obj)[i]; + status = mzscheme_to_vim(cval, v, depth + 1, visited); + if (status == FAIL) + break; + status = list_append_tv(list, v); + clear_tv(v); + if (status == FAIL) + break; + } + } + else if (SCHEME_PAIRP(obj) || SCHEME_MUTABLE_PAIRP(obj)) + { + for (curr = obj; + SCHEME_PAIRP(curr) || SCHEME_MUTABLE_PAIRP(curr); + curr = SCHEME_CDR(curr)) + { + cval = SCHEME_CAR(curr); + status = mzscheme_to_vim(cval, v, depth + 1, visited); + if (status == FAIL) + break; + status = list_append_tv(list, v); + clear_tv(v); + if (status == FAIL) + break; + } + /* impoper list not terminated with null + * need to handle the last element */ + if (status == OK && !SCHEME_NULLP(curr)) + { + status = mzscheme_to_vim(cval, v, depth + 1, visited); + if (status == OK) + { + status = list_append_tv(list, v); + clear_tv(v); + } + } + } + /* nothing to do for scheme_null */ + vim_free(v); + } + MZ_GC_UNREG(); + } + } + else if (SCHEME_HASHTP(obj)) + { + int i; + dict_T *dict; + Scheme_Object *key = NULL; + Scheme_Object *val = NULL; + + MZ_GC_DECL_REG(2); + MZ_GC_VAR_IN_REG(0, key); + MZ_GC_VAR_IN_REG(1, val); + MZ_GC_REG(); + + dict = dict_alloc(); + if (dict == NULL) + status = FAIL; + else + { + typval_T *visited_tv = (typval_T *)alloc(sizeof(typval_T)); + + tv->v_type = VAR_DICT; + tv->vval.v_dict = dict; + ++dict->dv_refcount; + + copy_tv(tv, visited_tv); + scheme_hash_set(visited, obj, (Scheme_Object *)visited_tv); + + for (i = 0; i < ((Scheme_Hash_Table *)obj)->size; ++i) + { + if (((Scheme_Hash_Table *) obj)->vals[i] != NULL) + { + /* generate item for `diplay'ed Scheme key */ + dictitem_T *item = dictitem_alloc((char_u *)string_to_line( + ((Scheme_Hash_Table *) obj)->keys[i])); + /* convert Scheme val to Vim and add it to the dict */ + if (mzscheme_to_vim(((Scheme_Hash_Table *) obj)->vals[i], + &item->di_tv, depth + 1, visited) == FAIL + || dict_add(dict, item) == FAIL) + { + dictitem_free(item); + status = FAIL; + break; + } + } + + } + } + MZ_GC_UNREG(); + } + else + { + /* `display' any other value to string */ + tv->v_type = VAR_STRING; + tv->vval.v_string = (char_u *)string_to_line(obj); + } + return status; +} + + void +do_mzeval(char_u *str, typval_T *rettv) +{ + int i; + Scheme_Object *ret = NULL; + Scheme_Hash_Table *visited = NULL; + + MZ_GC_DECL_REG(2); + MZ_GC_VAR_IN_REG(0, ret); + MZ_GC_VAR_IN_REG(0, visited); + MZ_GC_REG(); + + if (mzscheme_init()) + { + MZ_GC_UNREG(); + return; + } + + MZ_GC_CHECK(); + visited = scheme_make_hash_table(SCHEME_hash_ptr); + MZ_GC_CHECK(); + + if (eval_with_exn_handling(str, do_eval, &ret) == OK) + mzscheme_to_vim(ret, rettv, 1, visited); + + for (i = 0; i < visited->size; ++i) + { + /* free up remembered objects */ + if (visited->vals[i] != NULL) + { + free_tv((typval_T *)visited->vals[i]); + } + } + + MZ_GC_UNREG(); +} #endif /* diff --git a/src/mbyte.c b/src/mbyte.c index 530a8e90..b5ea2920 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -26,7 +26,7 @@ * Recognizing bytes is easy: 0xxx.xxxx is a single-byte * char, 10xx.xxxx is a trailing byte, 11xx.xxxx is a leading * byte of a multi-byte character. - * To make things complicated, up to two composing characters + * To make things complicated, up to six composing characters * are allowed. These are drawn on top of the first char. * For most editing the sequence of bytes with composing * characters included is considered to be one character. @@ -1153,8 +1153,8 @@ dbcs_ptr2len_len(p, size) struct interval { - unsigned short first; - unsigned short last; + long first; + long last; }; static int intable __ARGS((struct interval *table, size_t size, int c)); @@ -1200,62 +1200,191 @@ intable(table, size, c) utf_char2cells(c) int c; { - /* sorted list of non-overlapping intervals of East Asian Ambiguous - * characters, generated with: - * "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */ - static struct interval ambiguous[] = { - {0x00A1, 0x00A1}, {0x00A4, 0x00A4}, {0x00A7, 0x00A8}, - {0x00AA, 0x00AA}, {0x00AE, 0x00AE}, {0x00B0, 0x00B4}, - {0x00B6, 0x00BA}, {0x00BC, 0x00BF}, {0x00C6, 0x00C6}, - {0x00D0, 0x00D0}, {0x00D7, 0x00D8}, {0x00DE, 0x00E1}, - {0x00E6, 0x00E6}, {0x00E8, 0x00EA}, {0x00EC, 0x00ED}, - {0x00F0, 0x00F0}, {0x00F2, 0x00F3}, {0x00F7, 0x00FA}, - {0x00FC, 0x00FC}, {0x00FE, 0x00FE}, {0x0101, 0x0101}, - {0x0111, 0x0111}, {0x0113, 0x0113}, {0x011B, 0x011B}, - {0x0126, 0x0127}, {0x012B, 0x012B}, {0x0131, 0x0133}, - {0x0138, 0x0138}, {0x013F, 0x0142}, {0x0144, 0x0144}, - {0x0148, 0x014B}, {0x014D, 0x014D}, {0x0152, 0x0153}, - {0x0166, 0x0167}, {0x016B, 0x016B}, {0x01CE, 0x01CE}, - {0x01D0, 0x01D0}, {0x01D2, 0x01D2}, {0x01D4, 0x01D4}, - {0x01D6, 0x01D6}, {0x01D8, 0x01D8}, {0x01DA, 0x01DA}, - {0x01DC, 0x01DC}, {0x0251, 0x0251}, {0x0261, 0x0261}, - {0x02C4, 0x02C4}, {0x02C7, 0x02C7}, {0x02C9, 0x02CB}, - {0x02CD, 0x02CD}, {0x02D0, 0x02D0}, {0x02D8, 0x02DB}, - {0x02DD, 0x02DD}, {0x02DF, 0x02DF}, {0x0391, 0x03A1}, - {0x03A3, 0x03A9}, {0x03B1, 0x03C1}, {0x03C3, 0x03C9}, - {0x0401, 0x0401}, {0x0410, 0x044F}, {0x0451, 0x0451}, - {0x2010, 0x2010}, {0x2013, 0x2016}, {0x2018, 0x2019}, - {0x201C, 0x201D}, {0x2020, 0x2022}, {0x2024, 0x2027}, - {0x2030, 0x2030}, {0x2032, 0x2033}, {0x2035, 0x2035}, - {0x203B, 0x203B}, {0x203E, 0x203E}, {0x2074, 0x2074}, - {0x207F, 0x207F}, {0x2081, 0x2084}, {0x20AC, 0x20AC}, - {0x2103, 0x2103}, {0x2105, 0x2105}, {0x2109, 0x2109}, - {0x2113, 0x2113}, {0x2116, 0x2116}, {0x2121, 0x2122}, - {0x2126, 0x2126}, {0x212B, 0x212B}, {0x2153, 0x2154}, - {0x215B, 0x215E}, {0x2160, 0x216B}, {0x2170, 0x2179}, - {0x2190, 0x2199}, {0x21B8, 0x21B9}, {0x21D2, 0x21D2}, - {0x21D4, 0x21D4}, {0x21E7, 0x21E7}, {0x2200, 0x2200}, - {0x2202, 0x2203}, {0x2207, 0x2208}, {0x220B, 0x220B}, - {0x220F, 0x220F}, {0x2211, 0x2211}, {0x2215, 0x2215}, - {0x221A, 0x221A}, {0x221D, 0x2220}, {0x2223, 0x2223}, - {0x2225, 0x2225}, {0x2227, 0x222C}, {0x222E, 0x222E}, - {0x2234, 0x2237}, {0x223C, 0x223D}, {0x2248, 0x2248}, - {0x224C, 0x224C}, {0x2252, 0x2252}, {0x2260, 0x2261}, - {0x2264, 0x2267}, {0x226A, 0x226B}, {0x226E, 0x226F}, - {0x2282, 0x2283}, {0x2286, 0x2287}, {0x2295, 0x2295}, - {0x2299, 0x2299}, {0x22A5, 0x22A5}, {0x22BF, 0x22BF}, - {0x2312, 0x2312}, {0x2460, 0x24E9}, {0x24EB, 0x254B}, - {0x2550, 0x2573}, {0x2580, 0x258F}, {0x2592, 0x2595}, - {0x25A0, 0x25A1}, {0x25A3, 0x25A9}, {0x25B2, 0x25B3}, - {0x25B6, 0x25B7}, {0x25BC, 0x25BD}, {0x25C0, 0x25C1}, - {0x25C6, 0x25C8}, {0x25CB, 0x25CB}, {0x25CE, 0x25D1}, - {0x25E2, 0x25E5}, {0x25EF, 0x25EF}, {0x2605, 0x2606}, - {0x2609, 0x2609}, {0x260E, 0x260F}, {0x2614, 0x2615}, - {0x261C, 0x261C}, {0x261E, 0x261E}, {0x2640, 0x2640}, - {0x2642, 0x2642}, {0x2660, 0x2661}, {0x2663, 0x2665}, - {0x2667, 0x266A}, {0x266C, 0x266D}, {0x266F, 0x266F}, - {0x273D, 0x273D}, {0x2776, 0x277F}, {0xE000, 0xF8FF}, - {0xFFFD, 0xFFFD}, /* {0xF0000, 0xFFFFD}, {0x100000, 0x10FFFD} */ + /* Sorted list of non-overlapping intervals of East Asian Ambiguous + * characters, generated with ../runtime/tools/unicode.vim. */ + static struct interval ambiguous[] = + { + {0x00a1, 0x00a1}, + {0x00a4, 0x00a4}, + {0x00a7, 0x00a8}, + {0x00aa, 0x00aa}, + {0x00ad, 0x00ae}, + {0x00b0, 0x00b4}, + {0x00b6, 0x00ba}, + {0x00bc, 0x00bf}, + {0x00c6, 0x00c6}, + {0x00d0, 0x00d0}, + {0x00d7, 0x00d8}, + {0x00de, 0x00e1}, + {0x00e6, 0x00e6}, + {0x00e8, 0x00ea}, + {0x00ec, 0x00ed}, + {0x00f0, 0x00f0}, + {0x00f2, 0x00f3}, + {0x00f7, 0x00fa}, + {0x00fc, 0x00fc}, + {0x00fe, 0x00fe}, + {0x0101, 0x0101}, + {0x0111, 0x0111}, + {0x0113, 0x0113}, + {0x011b, 0x011b}, + {0x0126, 0x0127}, + {0x012b, 0x012b}, + {0x0131, 0x0133}, + {0x0138, 0x0138}, + {0x013f, 0x0142}, + {0x0144, 0x0144}, + {0x0148, 0x014b}, + {0x014d, 0x014d}, + {0x0152, 0x0153}, + {0x0166, 0x0167}, + {0x016b, 0x016b}, + {0x01ce, 0x01ce}, + {0x01d0, 0x01d0}, + {0x01d2, 0x01d2}, + {0x01d4, 0x01d4}, + {0x01d6, 0x01d6}, + {0x01d8, 0x01d8}, + {0x01da, 0x01da}, + {0x01dc, 0x01dc}, + {0x0251, 0x0251}, + {0x0261, 0x0261}, + {0x02c4, 0x02c4}, + {0x02c7, 0x02c7}, + {0x02c9, 0x02cb}, + {0x02cd, 0x02cd}, + {0x02d0, 0x02d0}, + {0x02d8, 0x02db}, + {0x02dd, 0x02dd}, + {0x02df, 0x02df}, + {0x0391, 0x03a1}, + {0x03a3, 0x03a9}, + {0x03b1, 0x03c1}, + {0x03c3, 0x03c9}, + {0x0401, 0x0401}, + {0x0410, 0x044f}, + {0x0451, 0x0451}, + {0x2010, 0x2010}, + {0x2013, 0x2016}, + {0x2018, 0x2019}, + {0x201c, 0x201d}, + {0x2020, 0x2022}, + {0x2024, 0x2027}, + {0x2030, 0x2030}, + {0x2032, 0x2033}, + {0x2035, 0x2035}, + {0x203b, 0x203b}, + {0x203e, 0x203e}, + {0x2074, 0x2074}, + {0x207f, 0x207f}, + {0x2081, 0x2084}, + {0x20ac, 0x20ac}, + {0x2103, 0x2103}, + {0x2105, 0x2105}, + {0x2109, 0x2109}, + {0x2113, 0x2113}, + {0x2116, 0x2116}, + {0x2121, 0x2122}, + {0x2126, 0x2126}, + {0x212b, 0x212b}, + {0x2153, 0x2154}, + {0x215b, 0x215e}, + {0x2160, 0x216b}, + {0x2170, 0x2179}, + {0x2189, 0x2189}, + {0x2190, 0x2199}, + {0x21b8, 0x21b9}, + {0x21d2, 0x21d2}, + {0x21d4, 0x21d4}, + {0x21e7, 0x21e7}, + {0x2200, 0x2200}, + {0x2202, 0x2203}, + {0x2207, 0x2208}, + {0x220b, 0x220b}, + {0x220f, 0x220f}, + {0x2211, 0x2211}, + {0x2215, 0x2215}, + {0x221a, 0x221a}, + {0x221d, 0x2220}, + {0x2223, 0x2223}, + {0x2225, 0x2225}, + {0x2227, 0x222c}, + {0x222e, 0x222e}, + {0x2234, 0x2237}, + {0x223c, 0x223d}, + {0x2248, 0x2248}, + {0x224c, 0x224c}, + {0x2252, 0x2252}, + {0x2260, 0x2261}, + {0x2264, 0x2267}, + {0x226a, 0x226b}, + {0x226e, 0x226f}, + {0x2282, 0x2283}, + {0x2286, 0x2287}, + {0x2295, 0x2295}, + {0x2299, 0x2299}, + {0x22a5, 0x22a5}, + {0x22bf, 0x22bf}, + {0x2312, 0x2312}, + {0x2460, 0x24e9}, + {0x24eb, 0x254b}, + {0x2550, 0x2573}, + {0x2580, 0x258f}, + {0x2592, 0x2595}, + {0x25a0, 0x25a1}, + {0x25a3, 0x25a9}, + {0x25b2, 0x25b3}, + {0x25b6, 0x25b7}, + {0x25bc, 0x25bd}, + {0x25c0, 0x25c1}, + {0x25c6, 0x25c8}, + {0x25cb, 0x25cb}, + {0x25ce, 0x25d1}, + {0x25e2, 0x25e5}, + {0x25ef, 0x25ef}, + {0x2605, 0x2606}, + {0x2609, 0x2609}, + {0x260e, 0x260f}, + {0x2614, 0x2615}, + {0x261c, 0x261c}, + {0x261e, 0x261e}, + {0x2640, 0x2640}, + {0x2642, 0x2642}, + {0x2660, 0x2661}, + {0x2663, 0x2665}, + {0x2667, 0x266a}, + {0x266c, 0x266d}, + {0x266f, 0x266f}, + {0x269e, 0x269f}, + {0x26be, 0x26bf}, + {0x26c4, 0x26cd}, + {0x26cf, 0x26e1}, + {0x26e3, 0x26e3}, + {0x26e8, 0x26ff}, + {0x273d, 0x273d}, + {0x2757, 0x2757}, + {0x2776, 0x277f}, + {0x2b55, 0x2b59}, + {0x3248, 0x324f}, + {0xe000, 0xf8ff}, + {0xfffd, 0xfffd}, + {0x1f100, 0x1f10a}, + {0x1f110, 0x1f12d}, + {0x1f131, 0x1f131}, + {0x1f13d, 0x1f13d}, + {0x1f13f, 0x1f13f}, + {0x1f142, 0x1f142}, + {0x1f146, 0x1f146}, + {0x1f14a, 0x1f14e}, + {0x1f157, 0x1f157}, + {0x1f15f, 0x1f15f}, + {0x1f179, 0x1f179}, + {0x1f17b, 0x1f17c}, + {0x1f17f, 0x1f17f}, + {0x1f18a, 0x1f18d}, + {0x1f190, 0x1f190}, + {0xf0000, 0xffffd}, + {0x100000, 0x10fffd} }; if (c >= 0x100) @@ -1807,7 +1936,7 @@ utfc_ptr2len(p) return 1; /* - * Check for composing characters. We can handle only the first two, but + * Check for composing characters. We can handle only the first six, but * skip all of them (otherwise the cursor would get stuck). */ #ifdef FEAT_ARABIC @@ -1855,7 +1984,7 @@ utfc_ptr2len_len(p, size) return 1; /* - * Check for composing characters. We can handle only the first two, but + * Check for composing characters. We can handle only the first six, but * skip all of them (otherwise the cursor would get stuck). */ #ifdef FEAT_ARABIC @@ -1973,38 +2102,198 @@ utf_char2bytes(c, buf) utf_iscomposing(c) int c; { - /* sorted list of non-overlapping intervals */ + /* Sorted list of non-overlapping intervals. + * Generated by ../runtime/tools/unicode.vim. */ static struct interval combining[] = { - {0x0300, 0x034f}, {0x0360, 0x036f}, {0x0483, 0x0486}, {0x0488, 0x0489}, - {0x0591, 0x05a1}, {0x05a3, 0x05b9}, {0x05bb, 0x05bd}, {0x05bf, 0x05bf}, - {0x05c1, 0x05c2}, {0x05c4, 0x05c4}, {0x0610, 0x0615}, {0x064b, 0x0658}, - {0x0670, 0x0670}, {0x06d6, 0x06dc}, {0x06de, 0x06e4}, {0x06e7, 0x06e8}, - {0x06ea, 0x06ed}, {0x0711, 0x0711}, {0x0730, 0x074a}, {0x07a6, 0x07b0}, - {0x0901, 0x0903}, {0x093c, 0x093c}, {0x093e, 0x094d}, {0x0951, 0x0954}, - {0x0962, 0x0963}, {0x0981, 0x0983}, {0x09bc, 0x09bc}, {0x09be, 0x09c4}, - {0x09c7, 0x09c8}, {0x09cb, 0x09cd}, {0x09d7, 0x09d7}, {0x09e2, 0x09e3}, - {0x0a01, 0x0a03}, {0x0a3c, 0x0a3c}, {0x0a3e, 0x0a42}, {0x0a47, 0x0a48}, - {0x0a4b, 0x0a4d}, {0x0a70, 0x0a71}, {0x0a81, 0x0a83}, {0x0abc, 0x0abc}, - {0x0abe, 0x0ac5}, {0x0ac7, 0x0ac9}, {0x0acb, 0x0acd}, {0x0ae2, 0x0ae3}, - {0x0b01, 0x0b03}, {0x0b3c, 0x0b3c}, {0x0b3e, 0x0b43}, {0x0b47, 0x0b48}, - {0x0b4b, 0x0b4d}, {0x0b56, 0x0b57}, {0x0b82, 0x0b82}, {0x0bbe, 0x0bc2}, - {0x0bc6, 0x0bc8}, {0x0bca, 0x0bcd}, {0x0bd7, 0x0bd7}, {0x0c01, 0x0c03}, - {0x0c3e, 0x0c44}, {0x0c46, 0x0c48}, {0x0c4a, 0x0c4d}, {0x0c55, 0x0c56}, - {0x0c82, 0x0c83}, {0x0cbc, 0x0cbc}, {0x0cbe, 0x0cc4}, {0x0cc6, 0x0cc8}, - {0x0cca, 0x0ccd}, {0x0cd5, 0x0cd6}, {0x0d02, 0x0d03}, {0x0d3e, 0x0d43}, - {0x0d46, 0x0d48}, {0x0d4a, 0x0d4d}, {0x0d57, 0x0d57}, {0x0d82, 0x0d83}, - {0x0dca, 0x0dca}, {0x0dcf, 0x0dd4}, {0x0dd6, 0x0dd6}, {0x0dd8, 0x0ddf}, - {0x0df2, 0x0df3}, {0x0e31, 0x0e31}, {0x0e34, 0x0e3a}, {0x0e47, 0x0e4e}, - {0x0eb1, 0x0eb1}, {0x0eb4, 0x0eb9}, {0x0ebb, 0x0ebc}, {0x0ec8, 0x0ecd}, - {0x0f18, 0x0f19}, {0x0f35, 0x0f35}, {0x0f37, 0x0f37}, {0x0f39, 0x0f39}, - {0x0f3e, 0x0f3f}, {0x0f71, 0x0f84}, {0x0f86, 0x0f87}, {0x0f90, 0x0f97}, - {0x0f99, 0x0fbc}, {0x0fc6, 0x0fc6}, {0x102c, 0x1032}, {0x1036, 0x1039}, - {0x1056, 0x1059}, {0x1712, 0x1714}, {0x1732, 0x1734}, {0x1752, 0x1753}, - {0x1772, 0x1773}, {0x17b6, 0x17d3}, {0x17dd, 0x17dd}, {0x180b, 0x180d}, - {0x18a9, 0x18a9}, {0x1920, 0x192b}, {0x1930, 0x193b}, {0x20d0, 0x20ea}, - {0x302a, 0x302f}, {0x3099, 0x309a}, {0xfb1e, 0xfb1e}, {0xfe00, 0xfe0f}, - {0xfe20, 0xfe23}, + {0x0300, 0x036f}, + {0x0483, 0x0489}, + {0x0591, 0x05bd}, + {0x05bf, 0x05bf}, + {0x05c1, 0x05c2}, + {0x05c4, 0x05c5}, + {0x05c7, 0x05c7}, + {0x0610, 0x061a}, + {0x064b, 0x065e}, + {0x0670, 0x0670}, + {0x06d6, 0x06dc}, + {0x06de, 0x06e4}, + {0x06e7, 0x06e8}, + {0x06ea, 0x06ed}, + {0x0711, 0x0711}, + {0x0730, 0x074a}, + {0x07a6, 0x07b0}, + {0x07eb, 0x07f3}, + {0x0816, 0x0819}, + {0x081b, 0x0823}, + {0x0825, 0x0827}, + {0x0829, 0x082d}, + {0x0900, 0x0903}, + {0x093c, 0x093c}, + {0x093e, 0x094e}, + {0x0951, 0x0955}, + {0x0962, 0x0963}, + {0x0981, 0x0983}, + {0x09bc, 0x09bc}, + {0x09be, 0x09c4}, + {0x09c7, 0x09c8}, + {0x09cb, 0x09cd}, + {0x09d7, 0x09d7}, + {0x09e2, 0x09e3}, + {0x0a01, 0x0a03}, + {0x0a3c, 0x0a3c}, + {0x0a3e, 0x0a42}, + {0x0a47, 0x0a48}, + {0x0a4b, 0x0a4d}, + {0x0a51, 0x0a51}, + {0x0a70, 0x0a71}, + {0x0a75, 0x0a75}, + {0x0a81, 0x0a83}, + {0x0abc, 0x0abc}, + {0x0abe, 0x0ac5}, + {0x0ac7, 0x0ac9}, + {0x0acb, 0x0acd}, + {0x0ae2, 0x0ae3}, + {0x0b01, 0x0b03}, + {0x0b3c, 0x0b3c}, + {0x0b3e, 0x0b44}, + {0x0b47, 0x0b48}, + {0x0b4b, 0x0b4d}, + {0x0b56, 0x0b57}, + {0x0b62, 0x0b63}, + {0x0b82, 0x0b82}, + {0x0bbe, 0x0bc2}, + {0x0bc6, 0x0bc8}, + {0x0bca, 0x0bcd}, + {0x0bd7, 0x0bd7}, + {0x0c01, 0x0c03}, + {0x0c3e, 0x0c44}, + {0x0c46, 0x0c48}, + {0x0c4a, 0x0c4d}, + {0x0c55, 0x0c56}, + {0x0c62, 0x0c63}, + {0x0c82, 0x0c83}, + {0x0cbc, 0x0cbc}, + {0x0cbe, 0x0cc4}, + {0x0cc6, 0x0cc8}, + {0x0cca, 0x0ccd}, + {0x0cd5, 0x0cd6}, + {0x0ce2, 0x0ce3}, + {0x0d02, 0x0d03}, + {0x0d3e, 0x0d44}, + {0x0d46, 0x0d48}, + {0x0d4a, 0x0d4d}, + {0x0d57, 0x0d57}, + {0x0d62, 0x0d63}, + {0x0d82, 0x0d83}, + {0x0dca, 0x0dca}, + {0x0dcf, 0x0dd4}, + {0x0dd6, 0x0dd6}, + {0x0dd8, 0x0ddf}, + {0x0df2, 0x0df3}, + {0x0e31, 0x0e31}, + {0x0e34, 0x0e3a}, + {0x0e47, 0x0e4e}, + {0x0eb1, 0x0eb1}, + {0x0eb4, 0x0eb9}, + {0x0ebb, 0x0ebc}, + {0x0ec8, 0x0ecd}, + {0x0f18, 0x0f19}, + {0x0f35, 0x0f35}, + {0x0f37, 0x0f37}, + {0x0f39, 0x0f39}, + {0x0f3e, 0x0f3f}, + {0x0f71, 0x0f84}, + {0x0f86, 0x0f87}, + {0x0f90, 0x0f97}, + {0x0f99, 0x0fbc}, + {0x0fc6, 0x0fc6}, + {0x102b, 0x103e}, + {0x1056, 0x1059}, + {0x105e, 0x1060}, + {0x1062, 0x1064}, + {0x1067, 0x106d}, + {0x1071, 0x1074}, + {0x1082, 0x108d}, + {0x108f, 0x108f}, + {0x109a, 0x109d}, + {0x135f, 0x135f}, + {0x1712, 0x1714}, + {0x1732, 0x1734}, + {0x1752, 0x1753}, + {0x1772, 0x1773}, + {0x17b6, 0x17d3}, + {0x17dd, 0x17dd}, + {0x180b, 0x180d}, + {0x18a9, 0x18a9}, + {0x1920, 0x192b}, + {0x1930, 0x193b}, + {0x19b0, 0x19c0}, + {0x19c8, 0x19c9}, + {0x1a17, 0x1a1b}, + {0x1a55, 0x1a5e}, + {0x1a60, 0x1a7c}, + {0x1a7f, 0x1a7f}, + {0x1b00, 0x1b04}, + {0x1b34, 0x1b44}, + {0x1b6b, 0x1b73}, + {0x1b80, 0x1b82}, + {0x1ba1, 0x1baa}, + {0x1c24, 0x1c37}, + {0x1cd0, 0x1cd2}, + {0x1cd4, 0x1ce8}, + {0x1ced, 0x1ced}, + {0x1cf2, 0x1cf2}, + {0x1dc0, 0x1de6}, + {0x1dfd, 0x1dff}, + {0x20d0, 0x20f0}, + {0x2cef, 0x2cf1}, + {0x2de0, 0x2dff}, + {0x302a, 0x302f}, + {0x3099, 0x309a}, + {0xa66f, 0xa672}, + {0xa67c, 0xa67d}, + {0xa6f0, 0xa6f1}, + {0xa802, 0xa802}, + {0xa806, 0xa806}, + {0xa80b, 0xa80b}, + {0xa823, 0xa827}, + {0xa880, 0xa881}, + {0xa8b4, 0xa8c4}, + {0xa8e0, 0xa8f1}, + {0xa926, 0xa92d}, + {0xa947, 0xa953}, + {0xa980, 0xa983}, + {0xa9b3, 0xa9c0}, + {0xaa29, 0xaa36}, + {0xaa43, 0xaa43}, + {0xaa4c, 0xaa4d}, + {0xaa7b, 0xaa7b}, + {0xaab0, 0xaab0}, + {0xaab2, 0xaab4}, + {0xaab7, 0xaab8}, + {0xaabe, 0xaabf}, + {0xaac1, 0xaac1}, + {0xabe3, 0xabea}, + {0xabec, 0xabed}, + {0xfb1e, 0xfb1e}, + {0xfe00, 0xfe0f}, + {0xfe20, 0xfe26}, + {0x101fd, 0x101fd}, + {0x10a01, 0x10a03}, + {0x10a05, 0x10a06}, + {0x10a0c, 0x10a0f}, + {0x10a38, 0x10a3a}, + {0x10a3f, 0x10a3f}, + {0x11080, 0x11082}, + {0x110b0, 0x110ba}, + {0x1d165, 0x1d169}, + {0x1d16d, 0x1d172}, + {0x1d17b, 0x1d182}, + {0x1d185, 0x1d18b}, + {0x1d1aa, 0x1d1ad}, + {0x1d242, 0x1d244}, + {0xe0100, 0xe01ef} }; return intable(combining, sizeof(combining), c); @@ -2152,15 +2441,16 @@ utf_class(c) * Code for Unicode case-dependent operations. Based on notes in * http://www.unicode.org/Public/UNIDATA/CaseFolding.txt * This code uses simple case folding, not full case folding. + * Last updated for Unicode 5.2. */ /* - * The following table is built by foldExtract.pl < CaseFolding.txt . - * It must be in numeric order, because we use binary search on it. - * An entry such as {0x41,0x5a,1,32} means that UCS-4 characters in the range - * from 0x41 to 0x5a inclusive, stepping by 1, are folded by adding 32. + * The following tables are built by ../runtime/tools/unicode.vim. + * They must be in numeric order, because we use binary search. + * An entry such as {0x41,0x5a,1,32} means that Unicode characters in the + * range from 0x41 to 0x5a inclusive, stepping by 1, are changed to + * folded/upper/lower by adding 32. */ - typedef struct { int rangeStart; @@ -2171,41 +2461,161 @@ typedef struct static convertStruct foldCase[] = { - {0x41,0x5a,1,32}, {0xc0,0xd6,1,32}, {0xd8,0xde,1,32}, - {0x100,0x12e,2,1}, {0x130,0x130,-1,-199}, {0x132,0x136,2,1}, - {0x139,0x147,2,1}, {0x14a,0x176,2,1}, {0x178,0x178,-1,-121}, - {0x179,0x17d,2,1}, {0x181,0x181,-1,210}, {0x182,0x184,2,1}, - {0x186,0x186,-1,206}, {0x187,0x187,-1,1}, {0x189,0x18a,1,205}, - {0x18b,0x18b,-1,1}, {0x18e,0x18e,-1,79}, {0x18f,0x18f,-1,202}, - {0x190,0x190,-1,203}, {0x191,0x191,-1,1}, {0x193,0x193,-1,205}, - {0x194,0x194,-1,207}, {0x196,0x196,-1,211}, {0x197,0x197,-1,209}, - {0x198,0x198,-1,1}, {0x19c,0x19c,-1,211}, {0x19d,0x19d,-1,213}, - {0x19f,0x19f,-1,214}, {0x1a0,0x1a4,2,1}, {0x1a6,0x1a6,-1,218}, - {0x1a7,0x1a7,-1,1}, {0x1a9,0x1a9,-1,218}, {0x1ac,0x1ac,-1,1}, - {0x1ae,0x1ae,-1,218}, {0x1af,0x1af,-1,1}, {0x1b1,0x1b2,1,217}, - {0x1b3,0x1b5,2,1}, {0x1b7,0x1b7,-1,219}, {0x1b8,0x1bc,4,1}, - {0x1c4,0x1c4,-1,2}, {0x1c5,0x1c5,-1,1}, {0x1c7,0x1c7,-1,2}, - {0x1c8,0x1c8,-1,1}, {0x1ca,0x1ca,-1,2}, {0x1cb,0x1db,2,1}, - {0x1de,0x1ee,2,1}, {0x1f1,0x1f1,-1,2}, {0x1f2,0x1f4,2,1}, - {0x1f6,0x1f6,-1,-97}, {0x1f7,0x1f7,-1,-56}, {0x1f8,0x21e,2,1}, - {0x220,0x220,-1,-130}, {0x222,0x232,2,1}, {0x386,0x386,-1,38}, - {0x388,0x38a,1,37}, {0x38c,0x38c,-1,64}, {0x38e,0x38f,1,63}, - {0x391,0x3a1,1,32}, {0x3a3,0x3ab,1,32}, {0x3d8,0x3ee,2,1}, - {0x3f4,0x3f4,-1,-60}, {0x3f7,0x3f7,-1,1}, {0x3f9,0x3f9,-1,-7}, - {0x3fa,0x3fa,-1,1}, {0x400,0x40f,1,80}, {0x410,0x42f,1,32}, - {0x460,0x480,2,1}, {0x48a,0x4be,2,1}, {0x4c1,0x4cd,2,1}, - {0x4d0,0x4f4,2,1}, {0x4f8,0x500,8,1}, {0x502,0x50e,2,1}, - {0x531,0x556,1,48}, {0x1e00,0x1e94,2,1}, {0x1ea0,0x1ef8,2,1}, - {0x1f08,0x1f0f,1,-8}, {0x1f18,0x1f1d,1,-8}, {0x1f28,0x1f2f,1,-8}, - {0x1f38,0x1f3f,1,-8}, {0x1f48,0x1f4d,1,-8}, {0x1f59,0x1f5f,2,-8}, - {0x1f68,0x1f6f,1,-8}, {0x1f88,0x1f8f,1,-8}, {0x1f98,0x1f9f,1,-8}, - {0x1fa8,0x1faf,1,-8}, {0x1fb8,0x1fb9,1,-8}, {0x1fba,0x1fbb,1,-74}, - {0x1fbc,0x1fbc,-1,-9}, {0x1fc8,0x1fcb,1,-86}, {0x1fcc,0x1fcc,-1,-9}, - {0x1fd8,0x1fd9,1,-8}, {0x1fda,0x1fdb,1,-100}, {0x1fe8,0x1fe9,1,-8}, - {0x1fea,0x1feb,1,-112}, {0x1fec,0x1fec,-1,-7}, {0x1ff8,0x1ff9,1,-128}, - {0x1ffa,0x1ffb,1,-126}, {0x1ffc,0x1ffc,-1,-9}, {0x2126,0x2126,-1,-7517}, - {0x212a,0x212a,-1,-8383}, {0x212b,0x212b,-1,-8262}, - {0x2160,0x216f,1,16}, {0x24b6,0x24cf,1,26}, {0xff21,0xff3a,1,32}, + {0x41,0x5a,1,32}, + {0xb5,0xb5,-1,775}, + {0xc0,0xd6,1,32}, + {0xd8,0xde,1,32}, + {0x100,0x12e,2,1}, + {0x132,0x136,2,1}, + {0x139,0x147,2,1}, + {0x14a,0x176,2,1}, + {0x178,0x178,-1,-121}, + {0x179,0x17d,2,1}, + {0x17f,0x17f,-1,-268}, + {0x181,0x181,-1,210}, + {0x182,0x184,2,1}, + {0x186,0x186,-1,206}, + {0x187,0x187,-1,1}, + {0x189,0x18a,1,205}, + {0x18b,0x18b,-1,1}, + {0x18e,0x18e,-1,79}, + {0x18f,0x18f,-1,202}, + {0x190,0x190,-1,203}, + {0x191,0x191,-1,1}, + {0x193,0x193,-1,205}, + {0x194,0x194,-1,207}, + {0x196,0x196,-1,211}, + {0x197,0x197,-1,209}, + {0x198,0x198,-1,1}, + {0x19c,0x19c,-1,211}, + {0x19d,0x19d,-1,213}, + {0x19f,0x19f,-1,214}, + {0x1a0,0x1a4,2,1}, + {0x1a6,0x1a6,-1,218}, + {0x1a7,0x1a7,-1,1}, + {0x1a9,0x1a9,-1,218}, + {0x1ac,0x1ac,-1,1}, + {0x1ae,0x1ae,-1,218}, + {0x1af,0x1af,-1,1}, + {0x1b1,0x1b2,1,217}, + {0x1b3,0x1b5,2,1}, + {0x1b7,0x1b7,-1,219}, + {0x1b8,0x1bc,4,1}, + {0x1c4,0x1c4,-1,2}, + {0x1c5,0x1c5,-1,1}, + {0x1c7,0x1c7,-1,2}, + {0x1c8,0x1c8,-1,1}, + {0x1ca,0x1ca,-1,2}, + {0x1cb,0x1db,2,1}, + {0x1de,0x1ee,2,1}, + {0x1f1,0x1f1,-1,2}, + {0x1f2,0x1f4,2,1}, + {0x1f6,0x1f6,-1,-97}, + {0x1f7,0x1f7,-1,-56}, + {0x1f8,0x21e,2,1}, + {0x220,0x220,-1,-130}, + {0x222,0x232,2,1}, + {0x23a,0x23a,-1,10795}, + {0x23b,0x23b,-1,1}, + {0x23d,0x23d,-1,-163}, + {0x23e,0x23e,-1,10792}, + {0x241,0x241,-1,1}, + {0x243,0x243,-1,-195}, + {0x244,0x244,-1,69}, + {0x245,0x245,-1,71}, + {0x246,0x24e,2,1}, + {0x345,0x345,-1,116}, + {0x370,0x372,2,1}, + {0x376,0x376,-1,1}, + {0x386,0x386,-1,38}, + {0x388,0x38a,1,37}, + {0x38c,0x38c,-1,64}, + {0x38e,0x38f,1,63}, + {0x391,0x3a1,1,32}, + {0x3a3,0x3ab,1,32}, + {0x3c2,0x3c2,-1,1}, + {0x3cf,0x3cf,-1,8}, + {0x3d0,0x3d0,-1,-30}, + {0x3d1,0x3d1,-1,-25}, + {0x3d5,0x3d5,-1,-15}, + {0x3d6,0x3d6,-1,-22}, + {0x3d8,0x3ee,2,1}, + {0x3f0,0x3f0,-1,-54}, + {0x3f1,0x3f1,-1,-48}, + {0x3f4,0x3f4,-1,-60}, + {0x3f5,0x3f5,-1,-64}, + {0x3f7,0x3f7,-1,1}, + {0x3f9,0x3f9,-1,-7}, + {0x3fa,0x3fa,-1,1}, + {0x3fd,0x3ff,1,-130}, + {0x400,0x40f,1,80}, + {0x410,0x42f,1,32}, + {0x460,0x480,2,1}, + {0x48a,0x4be,2,1}, + {0x4c0,0x4c0,-1,15}, + {0x4c1,0x4cd,2,1}, + {0x4d0,0x524,2,1}, + {0x531,0x556,1,48}, + {0x10a0,0x10c5,1,7264}, + {0x1e00,0x1e94,2,1}, + {0x1e9b,0x1e9b,-1,-58}, + {0x1e9e,0x1e9e,-1,-7615}, + {0x1ea0,0x1efe,2,1}, + {0x1f08,0x1f0f,1,-8}, + {0x1f18,0x1f1d,1,-8}, + {0x1f28,0x1f2f,1,-8}, + {0x1f38,0x1f3f,1,-8}, + {0x1f48,0x1f4d,1,-8}, + {0x1f59,0x1f5f,2,-8}, + {0x1f68,0x1f6f,1,-8}, + {0x1f88,0x1f8f,1,-8}, + {0x1f98,0x1f9f,1,-8}, + {0x1fa8,0x1faf,1,-8}, + {0x1fb8,0x1fb9,1,-8}, + {0x1fba,0x1fbb,1,-74}, + {0x1fbc,0x1fbc,-1,-9}, + {0x1fbe,0x1fbe,-1,-7173}, + {0x1fc8,0x1fcb,1,-86}, + {0x1fcc,0x1fcc,-1,-9}, + {0x1fd8,0x1fd9,1,-8}, + {0x1fda,0x1fdb,1,-100}, + {0x1fe8,0x1fe9,1,-8}, + {0x1fea,0x1feb,1,-112}, + {0x1fec,0x1fec,-1,-7}, + {0x1ff8,0x1ff9,1,-128}, + {0x1ffa,0x1ffb,1,-126}, + {0x1ffc,0x1ffc,-1,-9}, + {0x2126,0x2126,-1,-7517}, + {0x212a,0x212a,-1,-8383}, + {0x212b,0x212b,-1,-8262}, + {0x2132,0x2132,-1,28}, + {0x2160,0x216f,1,16}, + {0x2183,0x2183,-1,1}, + {0x24b6,0x24cf,1,26}, + {0x2c00,0x2c2e,1,48}, + {0x2c60,0x2c60,-1,1}, + {0x2c62,0x2c62,-1,-10743}, + {0x2c63,0x2c63,-1,-3814}, + {0x2c64,0x2c64,-1,-10727}, + {0x2c67,0x2c6b,2,1}, + {0x2c6d,0x2c6d,-1,-10780}, + {0x2c6e,0x2c6e,-1,-10749}, + {0x2c6f,0x2c6f,-1,-10783}, + {0x2c70,0x2c70,-1,-10782}, + {0x2c72,0x2c75,3,1}, + {0x2c7e,0x2c7f,1,-10815}, + {0x2c80,0x2ce2,2,1}, + {0x2ceb,0x2ced,2,1}, + {0xa640,0xa65e,2,1}, + {0xa662,0xa66c,2,1}, + {0xa680,0xa696,2,1}, + {0xa722,0xa72e,2,1}, + {0xa732,0xa76e,2,1}, + {0xa779,0xa77b,2,1}, + {0xa77d,0xa77d,-1,-35332}, + {0xa77e,0xa786,2,1}, + {0xa78b,0xa78b,-1,1}, + {0xff21,0xff3a,1,32}, {0x10400,0x10427,1,40} }; @@ -2253,85 +2663,306 @@ utf_fold(a) return utf_convert(a, foldCase, sizeof(foldCase)); } -/* - * The following tables are built by upperLowerExtract.pl < UnicodeData.txt . - * They must be in numeric order, because we use binary search on them. - * An entry such as {0x41,0x5a,1,32} means that UCS-4 characters in the range - * from 0x41 to 0x5a inclusive, stepping by 1, are switched to lower (for - * example) by adding 32. - */ static convertStruct toLower[] = { - {0x41,0x5a,1,32}, {0xc0,0xd6,1,32}, {0xd8,0xde,1,32}, - {0x100,0x12e,2,1}, {0x130,0x130,-1,-199}, {0x132,0x136,2,1}, - {0x139,0x147,2,1}, {0x14a,0x176,2,1}, {0x178,0x178,-1,-121}, - {0x179,0x17d,2,1}, {0x181,0x181,-1,210}, {0x182,0x184,2,1}, - {0x186,0x186,-1,206}, {0x187,0x187,-1,1}, {0x189,0x18a,1,205}, - {0x18b,0x18b,-1,1}, {0x18e,0x18e,-1,79}, {0x18f,0x18f,-1,202}, - {0x190,0x190,-1,203}, {0x191,0x191,-1,1}, {0x193,0x193,-1,205}, - {0x194,0x194,-1,207}, {0x196,0x196,-1,211}, {0x197,0x197,-1,209}, - {0x198,0x198,-1,1}, {0x19c,0x19c,-1,211}, {0x19d,0x19d,-1,213}, - {0x19f,0x19f,-1,214}, {0x1a0,0x1a4,2,1}, {0x1a6,0x1a6,-1,218}, - {0x1a7,0x1a7,-1,1}, {0x1a9,0x1a9,-1,218}, {0x1ac,0x1ac,-1,1}, - {0x1ae,0x1ae,-1,218}, {0x1af,0x1af,-1,1}, {0x1b1,0x1b2,1,217}, - {0x1b3,0x1b5,2,1}, {0x1b7,0x1b7,-1,219}, {0x1b8,0x1bc,4,1}, - {0x1c4,0x1ca,3,2}, {0x1cd,0x1db,2,1}, {0x1de,0x1ee,2,1}, - {0x1f1,0x1f1,-1,2}, {0x1f4,0x1f4,-1,1}, {0x1f6,0x1f6,-1,-97}, - {0x1f7,0x1f7,-1,-56}, {0x1f8,0x21e,2,1}, {0x220,0x220,-1,-130}, - {0x222,0x232,2,1}, {0x386,0x386,-1,38}, {0x388,0x38a,1,37}, - {0x38c,0x38c,-1,64}, {0x38e,0x38f,1,63}, {0x391,0x3a1,1,32}, - {0x3a3,0x3ab,1,32}, {0x3d8,0x3ee,2,1}, {0x3f4,0x3f4,-1,-60}, - {0x3f7,0x3f7,-1,1}, {0x3f9,0x3f9,-1,-7}, {0x3fa,0x3fa,-1,1}, - {0x400,0x40f,1,80}, {0x410,0x42f,1,32}, {0x460,0x480,2,1}, - {0x48a,0x4be,2,1}, {0x4c1,0x4cd,2,1}, {0x4d0,0x4f4,2,1}, - {0x4f8,0x500,8,1}, {0x502,0x50e,2,1}, {0x531,0x556,1,48}, - {0x1e00,0x1e94,2,1}, {0x1ea0,0x1ef8,2,1}, {0x1f08,0x1f0f,1,-8}, - {0x1f18,0x1f1d,1,-8}, {0x1f28,0x1f2f,1,-8}, {0x1f38,0x1f3f,1,-8}, - {0x1f48,0x1f4d,1,-8}, {0x1f59,0x1f5f,2,-8}, {0x1f68,0x1f6f,1,-8}, - {0x1fb8,0x1fb9,1,-8}, {0x1fba,0x1fbb,1,-74}, {0x1fc8,0x1fcb,1,-86}, - {0x1fd8,0x1fd9,1,-8}, {0x1fda,0x1fdb,1,-100}, {0x1fe8,0x1fe9,1,-8}, - {0x1fea,0x1feb,1,-112}, {0x1fec,0x1fec,-1,-7}, {0x1ff8,0x1ff9,1,-128}, - {0x1ffa,0x1ffb,1,-126}, {0x2126,0x2126,-1,-7517}, {0x212a,0x212a,-1,-8383}, - {0x212b,0x212b,-1,-8262}, {0xff21,0xff3a,1,32}, {0x10400,0x10427,1,40} + {0x41,0x5a,1,32}, + {0xc0,0xd6,1,32}, + {0xd8,0xde,1,32}, + {0x100,0x12e,2,1}, + {0x130,0x130,-1,-199}, + {0x132,0x136,2,1}, + {0x139,0x147,2,1}, + {0x14a,0x176,2,1}, + {0x178,0x178,-1,-121}, + {0x179,0x17d,2,1}, + {0x181,0x181,-1,210}, + {0x182,0x184,2,1}, + {0x186,0x186,-1,206}, + {0x187,0x187,-1,1}, + {0x189,0x18a,1,205}, + {0x18b,0x18b,-1,1}, + {0x18e,0x18e,-1,79}, + {0x18f,0x18f,-1,202}, + {0x190,0x190,-1,203}, + {0x191,0x191,-1,1}, + {0x193,0x193,-1,205}, + {0x194,0x194,-1,207}, + {0x196,0x196,-1,211}, + {0x197,0x197,-1,209}, + {0x198,0x198,-1,1}, + {0x19c,0x19c,-1,211}, + {0x19d,0x19d,-1,213}, + {0x19f,0x19f,-1,214}, + {0x1a0,0x1a4,2,1}, + {0x1a6,0x1a6,-1,218}, + {0x1a7,0x1a7,-1,1}, + {0x1a9,0x1a9,-1,218}, + {0x1ac,0x1ac,-1,1}, + {0x1ae,0x1ae,-1,218}, + {0x1af,0x1af,-1,1}, + {0x1b1,0x1b2,1,217}, + {0x1b3,0x1b5,2,1}, + {0x1b7,0x1b7,-1,219}, + {0x1b8,0x1bc,4,1}, + {0x1c4,0x1c4,-1,2}, + {0x1c5,0x1c5,-1,1}, + {0x1c7,0x1c7,-1,2}, + {0x1c8,0x1c8,-1,1}, + {0x1ca,0x1ca,-1,2}, + {0x1cb,0x1db,2,1}, + {0x1de,0x1ee,2,1}, + {0x1f1,0x1f1,-1,2}, + {0x1f2,0x1f4,2,1}, + {0x1f6,0x1f6,-1,-97}, + {0x1f7,0x1f7,-1,-56}, + {0x1f8,0x21e,2,1}, + {0x220,0x220,-1,-130}, + {0x222,0x232,2,1}, + {0x23a,0x23a,-1,10795}, + {0x23b,0x23b,-1,1}, + {0x23d,0x23d,-1,-163}, + {0x23e,0x23e,-1,10792}, + {0x241,0x241,-1,1}, + {0x243,0x243,-1,-195}, + {0x244,0x244,-1,69}, + {0x245,0x245,-1,71}, + {0x246,0x24e,2,1}, + {0x370,0x372,2,1}, + {0x376,0x376,-1,1}, + {0x386,0x386,-1,38}, + {0x388,0x38a,1,37}, + {0x38c,0x38c,-1,64}, + {0x38e,0x38f,1,63}, + {0x391,0x3a1,1,32}, + {0x3a3,0x3ab,1,32}, + {0x3cf,0x3cf,-1,8}, + {0x3d8,0x3ee,2,1}, + {0x3f4,0x3f4,-1,-60}, + {0x3f7,0x3f7,-1,1}, + {0x3f9,0x3f9,-1,-7}, + {0x3fa,0x3fa,-1,1}, + {0x3fd,0x3ff,1,-130}, + {0x400,0x40f,1,80}, + {0x410,0x42f,1,32}, + {0x460,0x480,2,1}, + {0x48a,0x4be,2,1}, + {0x4c0,0x4c0,-1,15}, + {0x4c1,0x4cd,2,1}, + {0x4d0,0x524,2,1}, + {0x531,0x556,1,48}, + {0x10a0,0x10c5,1,7264}, + {0x1e00,0x1e94,2,1}, + {0x1e9e,0x1e9e,-1,-7615}, + {0x1ea0,0x1efe,2,1}, + {0x1f08,0x1f0f,1,-8}, + {0x1f18,0x1f1d,1,-8}, + {0x1f28,0x1f2f,1,-8}, + {0x1f38,0x1f3f,1,-8}, + {0x1f48,0x1f4d,1,-8}, + {0x1f59,0x1f5f,2,-8}, + {0x1f68,0x1f6f,1,-8}, + {0x1f88,0x1f8f,1,-8}, + {0x1f98,0x1f9f,1,-8}, + {0x1fa8,0x1faf,1,-8}, + {0x1fb8,0x1fb9,1,-8}, + {0x1fba,0x1fbb,1,-74}, + {0x1fbc,0x1fbc,-1,-9}, + {0x1fc8,0x1fcb,1,-86}, + {0x1fcc,0x1fcc,-1,-9}, + {0x1fd8,0x1fd9,1,-8}, + {0x1fda,0x1fdb,1,-100}, + {0x1fe8,0x1fe9,1,-8}, + {0x1fea,0x1feb,1,-112}, + {0x1fec,0x1fec,-1,-7}, + {0x1ff8,0x1ff9,1,-128}, + {0x1ffa,0x1ffb,1,-126}, + {0x1ffc,0x1ffc,-1,-9}, + {0x2126,0x2126,-1,-7517}, + {0x212a,0x212a,-1,-8383}, + {0x212b,0x212b,-1,-8262}, + {0x2132,0x2132,-1,28}, + {0x2160,0x216f,1,16}, + {0x2183,0x2183,-1,1}, + {0x24b6,0x24cf,1,26}, + {0x2c00,0x2c2e,1,48}, + {0x2c60,0x2c60,-1,1}, + {0x2c62,0x2c62,-1,-10743}, + {0x2c63,0x2c63,-1,-3814}, + {0x2c64,0x2c64,-1,-10727}, + {0x2c67,0x2c6b,2,1}, + {0x2c6d,0x2c6d,-1,-10780}, + {0x2c6e,0x2c6e,-1,-10749}, + {0x2c6f,0x2c6f,-1,-10783}, + {0x2c70,0x2c70,-1,-10782}, + {0x2c72,0x2c75,3,1}, + {0x2c7e,0x2c7f,1,-10815}, + {0x2c80,0x2ce2,2,1}, + {0x2ceb,0x2ced,2,1}, + {0xa640,0xa65e,2,1}, + {0xa662,0xa66c,2,1}, + {0xa680,0xa696,2,1}, + {0xa722,0xa72e,2,1}, + {0xa732,0xa76e,2,1}, + {0xa779,0xa77b,2,1}, + {0xa77d,0xa77d,-1,-35332}, + {0xa77e,0xa786,2,1}, + {0xa78b,0xa78b,-1,1}, + {0xff21,0xff3a,1,32}, + {0x10400,0x10427,1,40} }; static convertStruct toUpper[] = { - {0x61,0x7a,1,-32}, {0xb5,0xb5,-1,743}, {0xe0,0xf6,1,-32}, - {0xf8,0xfe,1,-32}, {0xff,0xff,-1,121}, {0x101,0x12f,2,-1}, - {0x131,0x131,-1,-232}, {0x133,0x137,2,-1}, {0x13a,0x148,2,-1}, - {0x14b,0x177,2,-1}, {0x17a,0x17e,2,-1}, {0x17f,0x17f,-1,-300}, - {0x183,0x185,2,-1}, {0x188,0x18c,4,-1}, {0x192,0x192,-1,-1}, - {0x195,0x195,-1,97}, {0x199,0x199,-1,-1}, {0x19e,0x19e,-1,130}, - {0x1a1,0x1a5,2,-1}, {0x1a8,0x1ad,5,-1}, {0x1b0,0x1b4,4,-1}, - {0x1b6,0x1b9,3,-1}, {0x1bd,0x1bd,-1,-1}, {0x1bf,0x1bf,-1,56}, - {0x1c5,0x1c6,1,-1}, {0x1c8,0x1c9,1,-1}, {0x1cb,0x1cc,1,-1}, - {0x1ce,0x1dc,2,-1}, {0x1dd,0x1dd,-1,-79}, {0x1df,0x1ef,2,-1}, - {0x1f2,0x1f3,1,-1}, {0x1f5,0x1f9,4,-1}, {0x1fb,0x21f,2,-1}, - {0x223,0x233,2,-1}, {0x253,0x253,-1,-210}, {0x254,0x254,-1,-206}, - {0x256,0x257,1,-205}, {0x259,0x259,-1,-202}, {0x25b,0x25b,-1,-203}, - {0x260,0x260,-1,-205}, {0x263,0x263,-1,-207}, {0x268,0x268,-1,-209}, - {0x269,0x26f,6,-211}, {0x272,0x272,-1,-213}, {0x275,0x275,-1,-214}, - {0x280,0x283,3,-218}, {0x288,0x288,-1,-218}, {0x28a,0x28b,1,-217}, - {0x292,0x292,-1,-219}, {0x3ac,0x3ac,-1,-38}, {0x3ad,0x3af,1,-37}, - {0x3b1,0x3c1,1,-32}, {0x3c2,0x3c2,-1,-31}, {0x3c3,0x3cb,1,-32}, - {0x3cc,0x3cc,-1,-64}, {0x3cd,0x3ce,1,-63}, {0x3d0,0x3d0,-1,-62}, - {0x3d1,0x3d1,-1,-57}, {0x3d5,0x3d5,-1,-47}, {0x3d6,0x3d6,-1,-54}, - {0x3d9,0x3ef,2,-1}, {0x3f0,0x3f0,-1,-86}, {0x3f1,0x3f1,-1,-80}, - {0x3f2,0x3f2,-1,7}, {0x3f5,0x3f5,-1,-96}, {0x3f8,0x3fb,3,-1}, - {0x430,0x44f,1,-32}, {0x450,0x45f,1,-80}, {0x461,0x481,2,-1}, - {0x48b,0x4bf,2,-1}, {0x4c2,0x4ce,2,-1}, {0x4d1,0x4f5,2,-1}, - {0x4f9,0x501,8,-1}, {0x503,0x50f,2,-1}, {0x561,0x586,1,-48}, - {0x1e01,0x1e95,2,-1}, {0x1e9b,0x1e9b,-1,-59}, {0x1ea1,0x1ef9,2,-1}, - {0x1f00,0x1f07,1,8}, {0x1f10,0x1f15,1,8}, {0x1f20,0x1f27,1,8}, - {0x1f30,0x1f37,1,8}, {0x1f40,0x1f45,1,8}, {0x1f51,0x1f57,2,8}, - {0x1f60,0x1f67,1,8}, {0x1f70,0x1f71,1,74}, {0x1f72,0x1f75,1,86}, - {0x1f76,0x1f77,1,100}, {0x1f78,0x1f79,1,128}, {0x1f7a,0x1f7b,1,112}, - {0x1f7c,0x1f7d,1,126}, {0x1f80,0x1f87,1,8}, {0x1f90,0x1f97,1,8}, - {0x1fa0,0x1fa7,1,8}, {0x1fb0,0x1fb1,1,8}, {0x1fb3,0x1fb3,-1,9}, - {0x1fbe,0x1fbe,-1,-7205}, {0x1fc3,0x1fc3,-1,9}, {0x1fd0,0x1fd1,1,8}, - {0x1fe0,0x1fe1,1,8}, {0x1fe5,0x1fe5,-1,7}, {0x1ff3,0x1ff3,-1,9}, - {0xff41,0xff5a,1,-32}, {0x10428,0x1044f,1,-40} + {0x61,0x7a,1,-32}, + {0xb5,0xb5,-1,743}, + {0xe0,0xf6,1,-32}, + {0xf8,0xfe,1,-32}, + {0xff,0xff,-1,121}, + {0x101,0x12f,2,-1}, + {0x131,0x131,-1,-232}, + {0x133,0x137,2,-1}, + {0x13a,0x148,2,-1}, + {0x14b,0x177,2,-1}, + {0x17a,0x17e,2,-1}, + {0x17f,0x17f,-1,-300}, + {0x180,0x180,-1,195}, + {0x183,0x185,2,-1}, + {0x188,0x18c,4,-1}, + {0x192,0x192,-1,-1}, + {0x195,0x195,-1,97}, + {0x199,0x199,-1,-1}, + {0x19a,0x19a,-1,163}, + {0x19e,0x19e,-1,130}, + {0x1a1,0x1a5,2,-1}, + {0x1a8,0x1ad,5,-1}, + {0x1b0,0x1b4,4,-1}, + {0x1b6,0x1b9,3,-1}, + {0x1bd,0x1bd,-1,-1}, + {0x1bf,0x1bf,-1,56}, + {0x1c5,0x1c5,-1,-1}, + {0x1c6,0x1c6,-1,-2}, + {0x1c8,0x1c8,-1,-1}, + {0x1c9,0x1c9,-1,-2}, + {0x1cb,0x1cb,-1,-1}, + {0x1cc,0x1cc,-1,-2}, + {0x1ce,0x1dc,2,-1}, + {0x1dd,0x1dd,-1,-79}, + {0x1df,0x1ef,2,-1}, + {0x1f2,0x1f2,-1,-1}, + {0x1f3,0x1f3,-1,-2}, + {0x1f5,0x1f9,4,-1}, + {0x1fb,0x21f,2,-1}, + {0x223,0x233,2,-1}, + {0x23c,0x23c,-1,-1}, + {0x23f,0x240,1,10815}, + {0x242,0x247,5,-1}, + {0x249,0x24f,2,-1}, + {0x250,0x250,-1,10783}, + {0x251,0x251,-1,10780}, + {0x252,0x252,-1,10782}, + {0x253,0x253,-1,-210}, + {0x254,0x254,-1,-206}, + {0x256,0x257,1,-205}, + {0x259,0x259,-1,-202}, + {0x25b,0x25b,-1,-203}, + {0x260,0x260,-1,-205}, + {0x263,0x263,-1,-207}, + {0x268,0x268,-1,-209}, + {0x269,0x269,-1,-211}, + {0x26b,0x26b,-1,10743}, + {0x26f,0x26f,-1,-211}, + {0x271,0x271,-1,10749}, + {0x272,0x272,-1,-213}, + {0x275,0x275,-1,-214}, + {0x27d,0x27d,-1,10727}, + {0x280,0x283,3,-218}, + {0x288,0x288,-1,-218}, + {0x289,0x289,-1,-69}, + {0x28a,0x28b,1,-217}, + {0x28c,0x28c,-1,-71}, + {0x292,0x292,-1,-219}, + {0x345,0x345,-1,84}, + {0x371,0x373,2,-1}, + {0x377,0x377,-1,-1}, + {0x37b,0x37d,1,130}, + {0x3ac,0x3ac,-1,-38}, + {0x3ad,0x3af,1,-37}, + {0x3b1,0x3c1,1,-32}, + {0x3c2,0x3c2,-1,-31}, + {0x3c3,0x3cb,1,-32}, + {0x3cc,0x3cc,-1,-64}, + {0x3cd,0x3ce,1,-63}, + {0x3d0,0x3d0,-1,-62}, + {0x3d1,0x3d1,-1,-57}, + {0x3d5,0x3d5,-1,-47}, + {0x3d6,0x3d6,-1,-54}, + {0x3d7,0x3d7,-1,-8}, + {0x3d9,0x3ef,2,-1}, + {0x3f0,0x3f0,-1,-86}, + {0x3f1,0x3f1,-1,-80}, + {0x3f2,0x3f2,-1,7}, + {0x3f5,0x3f5,-1,-96}, + {0x3f8,0x3fb,3,-1}, + {0x430,0x44f,1,-32}, + {0x450,0x45f,1,-80}, + {0x461,0x481,2,-1}, + {0x48b,0x4bf,2,-1}, + {0x4c2,0x4ce,2,-1}, + {0x4cf,0x4cf,-1,-15}, + {0x4d1,0x525,2,-1}, + {0x561,0x586,1,-48}, + {0x1d79,0x1d79,-1,35332}, + {0x1d7d,0x1d7d,-1,3814}, + {0x1e01,0x1e95,2,-1}, + {0x1e9b,0x1e9b,-1,-59}, + {0x1ea1,0x1eff,2,-1}, + {0x1f00,0x1f07,1,8}, + {0x1f10,0x1f15,1,8}, + {0x1f20,0x1f27,1,8}, + {0x1f30,0x1f37,1,8}, + {0x1f40,0x1f45,1,8}, + {0x1f51,0x1f57,2,8}, + {0x1f60,0x1f67,1,8}, + {0x1f70,0x1f71,1,74}, + {0x1f72,0x1f75,1,86}, + {0x1f76,0x1f77,1,100}, + {0x1f78,0x1f79,1,128}, + {0x1f7a,0x1f7b,1,112}, + {0x1f7c,0x1f7d,1,126}, + {0x1f80,0x1f87,1,8}, + {0x1f90,0x1f97,1,8}, + {0x1fa0,0x1fa7,1,8}, + {0x1fb0,0x1fb1,1,8}, + {0x1fb3,0x1fb3,-1,9}, + {0x1fbe,0x1fbe,-1,-7205}, + {0x1fc3,0x1fc3,-1,9}, + {0x1fd0,0x1fd1,1,8}, + {0x1fe0,0x1fe1,1,8}, + {0x1fe5,0x1fe5,-1,7}, + {0x1ff3,0x1ff3,-1,9}, + {0x214e,0x214e,-1,-28}, + {0x2170,0x217f,1,-16}, + {0x2184,0x2184,-1,-1}, + {0x24d0,0x24e9,1,-26}, + {0x2c30,0x2c5e,1,-48}, + {0x2c61,0x2c61,-1,-1}, + {0x2c65,0x2c65,-1,-10795}, + {0x2c66,0x2c66,-1,-10792}, + {0x2c68,0x2c6c,2,-1}, + {0x2c73,0x2c76,3,-1}, + {0x2c81,0x2ce3,2,-1}, + {0x2cec,0x2cee,2,-1}, + {0x2d00,0x2d25,1,-7264}, + {0xa641,0xa65f,2,-1}, + {0xa663,0xa66d,2,-1}, + {0xa681,0xa697,2,-1}, + {0xa723,0xa72f,2,-1}, + {0xa733,0xa76f,2,-1}, + {0xa77a,0xa77c,2,-1}, + {0xa77f,0xa787,2,-1}, + {0xa78c,0xa78c,-1,-1}, + {0xff41,0xff5a,1,-32}, + {0x10428,0x1044f,1,-40} }; /* diff --git a/src/netbeans.c b/src/netbeans.c index b013d778..87e0edd1 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -70,7 +70,8 @@ static long pos2off __ARGS((buf_T *, pos_T *)); static pos_T *off2pos __ARGS((buf_T *, long)); static pos_T *get_off_or_lnum __ARGS((buf_T *buf, char_u **argp)); static long get_buf_size __ARGS((buf_T *)); -static void netbeans_keystring __ARGS((int key, char *keystr)); +static int netbeans_keystring __ARGS((char_u *keystr)); +static void postpone_keycommand __ARGS((char_u *keystr)); static void special_keys __ARGS((char_u *args)); static void netbeans_connect __ARGS((void)); @@ -502,7 +503,7 @@ getConnInfo(char *file, char **host, char **port, char **auth) struct keyqueue { - int key; + char_u *keystr; struct keyqueue *next; struct keyqueue *prev; }; @@ -514,13 +515,17 @@ static keyQ_T keyHead; /* dummy node, header for circular queue */ /* * Queue up key commands sent from netbeans. + * We store the string, because it may depend on the global mod_mask and + * :nbkey doesn't have a key number. */ static void -postpone_keycommand(int key) +postpone_keycommand(char_u *keystr) { keyQ_T *node; node = (keyQ_T *)alloc(sizeof(keyQ_T)); + if (node == NULL) + return; /* out of memory, drop the key */ if (keyHead.next == NULL) /* initialize circular queue */ { @@ -534,7 +539,7 @@ postpone_keycommand(int key) keyHead.prev->next = node; keyHead.prev = node; - node->key = key; + node->keystr = vim_strsave(keystr); } /* @@ -543,15 +548,20 @@ postpone_keycommand(int key) static void handle_key_queue(void) { - while (keyHead.next && keyHead.next != &keyHead) + int postponed = FALSE; + + while (!postponed && keyHead.next && keyHead.next != &keyHead) { /* first, unlink the node */ keyQ_T *node = keyHead.next; keyHead.next = node->next; node->next->prev = node->prev; - /* now, send the keycommand */ - netbeans_keycommand(node->key); + /* Now, send the keycommand. This may cause it to be postponed again + * and change keyHead. */ + if (node->keystr != NULL) + postponed = !netbeans_keystring(node->keystr); + vim_free(node->keystr); /* Finally, dispose of the node */ vim_free(node); @@ -873,7 +883,7 @@ nb_parse_cmd(char_u *cmd) { #ifdef NBDEBUG /* - * This happens because the ExtEd can send a cammand or 2 after + * This happens because the ExtEd can send a command or 2 after * doing a stopDocumentListen command. It doesn't harm anything * so I'm disabling it except for debugging. */ @@ -1174,7 +1184,7 @@ nb_quote(char_u *txt) break; } } - *q++ = '\0'; + *q = '\0'; return buf; } @@ -2495,7 +2505,7 @@ nb_do_cmd( } else { - nbdebug((" Buffer has no changes!\n")); + nbdebug((" Buffer has no changes!\n")); } /* =====================================================================*/ } @@ -2658,7 +2668,7 @@ special_keys(char_u *args) ex_nbkey(eap) exarg_T *eap; { - netbeans_keystring(0, (char *)eap->arg); + (void)netbeans_keystring(eap->arg); } @@ -2680,7 +2690,7 @@ nb_init_graphics(void) } /* - * Convert key to netbeans name. + * Convert key to netbeans name. This uses the global "mod_mask". */ static void netbeans_keyname(int key, char *buf) @@ -3070,7 +3080,7 @@ netbeans_removed( } /* - * Send netbeans an unmodufied command. + * Send netbeans an unmodified command. */ void netbeans_unmodified(buf_T *bufp UNUSED) @@ -3127,23 +3137,27 @@ netbeans_button_release(int button) /* * Send a keypress event back to netbeans. This usually simulates some * kind of function key press. This function operates on a key code. + * Return TRUE when the key was sent, FALSE when the command has been + * postponed. */ - void + int netbeans_keycommand(int key) { char keyName[60]; netbeans_keyname(key, keyName); - netbeans_keystring(key, keyName); + return netbeans_keystring((char_u *)keyName); } /* * Send a keypress event back to netbeans. This usually simulates some * kind of function key press. This function operates on a key string. + * Return TRUE when the key was sent, FALSE when the command has been + * postponed. */ - static void -netbeans_keystring(int key, char *keyName) + static int +netbeans_keystring(char_u *keyName) { char buf[2*MAXPATHL]; int bufno = nb_getbufno(curbuf); @@ -3151,7 +3165,7 @@ netbeans_keystring(int key, char *keyName) char_u *q; if (!haveConnection) - return; + return TRUE; if (bufno == -1) @@ -3160,7 +3174,7 @@ netbeans_keystring(int key, char *keyName) q = curbuf->b_ffname == NULL ? (char_u *)"" : nb_quote(curbuf->b_ffname); if (q == NULL) - return; + return TRUE; vim_snprintf(buf, sizeof(buf), "0:fileOpened=%d \"%s\" %s %s\n", 0, q, "T", /* open in NetBeans */ @@ -3170,9 +3184,8 @@ netbeans_keystring(int key, char *keyName) nbdebug(("EVT: %s", buf)); nb_send(buf, "netbeans_keycommand"); - if (key > 0) - postpone_keycommand(key); - return; + postpone_keycommand(keyName); + return FALSE; } /* sync the cursor position */ @@ -3198,6 +3211,7 @@ netbeans_keystring(int key, char *keyName) off, (long)curwin->w_cursor.lnum, (long)curwin->w_cursor.col); nbdebug(("EVT: %s", buf)); nb_send(buf, "netbeans_keycommand"); + return TRUE; } @@ -3366,7 +3380,7 @@ netbeans_gutter_click(linenr_T lnum) /* - * Add a sign of the reqested type at the requested location. + * Add a sign of the requested type at the requested location. * * Reverse engineering: * Apparently an annotation is defined the first time it is used in a buffer. diff --git a/src/normal.c b/src/normal.c index befe4ac9..fade0fc3 100644 --- a/src/normal.c +++ b/src/normal.c @@ -5406,6 +5406,7 @@ nv_ident(cap) int n = 0; /* init for GCC */ int cmdchar; int g_cmd; /* "g" command */ + int tag_cmd = FALSE; char_u *aux_ptr; int isman; int isman_s; @@ -5515,6 +5516,7 @@ nv_ident(cap) break; case ']': + tag_cmd = TRUE; #ifdef FEAT_CSCOPE if (p_cst) STRCPY(buf, "cstag "); @@ -5526,10 +5528,14 @@ nv_ident(cap) default: if (curbuf->b_help) STRCPY(buf, "he! "); - else if (g_cmd) - STRCPY(buf, "tj "); else - sprintf((char *)buf, "%ldta ", cap->count0); + { + tag_cmd = TRUE; + if (g_cmd) + STRCPY(buf, "tj "); + else + sprintf((char *)buf, "%ldta ", cap->count0); + } } /* @@ -5562,8 +5568,10 @@ nv_ident(cap) aux_ptr = (char_u *)(p_magic ? "/.*~[^$\\" : "/^$\\"); else if (cmdchar == '#') aux_ptr = (char_u *)(p_magic ? "/?.*~[^$\\" : "/?^$\\"); - else + else if (tag_cmd) /* Don't escape spaces and Tabs in a tag with a backslash */ + aux_ptr = (char_u *)"\\|\"\n["; + else aux_ptr = (char_u *)"\\|\"\n*?["; p = buf + STRLEN(buf); @@ -7873,6 +7881,9 @@ nv_g_cmd(cap) && vim_iswhite(ptr[curwin->w_cursor.col])) --curwin->w_cursor.col; curwin->w_set_curswant = TRUE; +#ifdef FEAT_VISUAL + adjust_for_sel(cap); +#endif } break; diff --git a/src/ops.c b/src/ops.c index 5b12e68d..4b32b573 100644 --- a/src/ops.c +++ b/src/ops.c @@ -5591,13 +5591,13 @@ x11_export_final_selection() */ if (has_mbyte) { - char_u *conv_str = str; vimconv_T vc; vc.vc_type = CONV_NONE; if (convert_setup(&vc, p_enc, (char_u *)"latin1") == OK) { - int intlen = len; + int intlen = len; + char_u *conv_str; conv_str = string_convert(&vc, str, &intlen); len = intlen; diff --git a/src/popupmnu.c b/src/popupmnu.c index 5808ae19..bef9dd5e 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -345,21 +345,36 @@ pum_redraw() if (st != NULL) { char_u *rt = reverse_text(st); - char_u *rt_saved = rt; - int len, j; if (rt != NULL) { - len = (int)STRLEN(rt); - if (len > pum_width) + char_u *rt_start = rt; + int size; + + size = vim_strsize(rt); + if (size > pum_width) { - for (j = pum_width; j < len; ++j) + do + { + size -= has_mbyte + ? (*mb_ptr2cells)(rt) : 1; mb_ptr_adv(rt); - len = pum_width; + } while (size > pum_width); + + if (size < pum_width) + { + /* Most left character requires + * 2-cells but only 1 cell is + * available on screen. Put a + * '<' on the left of the pum + * item */ + *(--rt) = '<'; + size++; + } } - screen_puts_len(rt, len, row, - col - len + 1, attr); - vim_free(rt_saved); + screen_puts_len(rt, (int)STRLEN(rt), + row, col - size + 1, attr); + vim_free(rt_start); } vim_free(st); } diff --git a/src/proto/eval.pro b/src/proto/eval.pro index d5200467..e817769e 100644 --- a/src/proto/eval.pro +++ b/src/proto/eval.pro @@ -47,10 +47,14 @@ void list_unref __ARGS((list_T *l)); void list_free __ARGS((list_T *l, int recurse)); dictitem_T *dict_lookup __ARGS((hashitem_T *hi)); char_u *list_find_str __ARGS((list_T *l, long idx)); +int list_append_tv __ARGS((list_T *l, typval_T *tv)); int list_append_dict __ARGS((list_T *list, dict_T *dict)); int list_append_string __ARGS((list_T *l, char_u *str, int len)); int garbage_collect __ARGS((void)); dict_T *dict_alloc __ARGS((void)); +dictitem_T *dictitem_alloc __ARGS((char_u *key)); +void dictitem_free __ARGS((dictitem_T *item)); +int dict_add __ARGS((dict_T *d, dictitem_T *item)); int dict_add_nr_str __ARGS((dict_T *d, char *key, long nr, char_u *str)); char_u *get_dict_string __ARGS((dict_T *d, char_u *key, int save)); long get_dict_number __ARGS((dict_T *d, char_u *key)); @@ -77,6 +81,7 @@ char_u *get_var_value __ARGS((char_u *name)); void new_script_vars __ARGS((scid_T id)); void init_var_dict __ARGS((dict_T *dict, dictitem_T *dict_var)); void vars_clear __ARGS((hashtab_T *ht)); +void copy_tv __ARGS((typval_T *from, typval_T *to)); void ex_echo __ARGS((exarg_T *eap)); void ex_echohl __ARGS((exarg_T *eap)); void ex_execute __ARGS((exarg_T *eap)); diff --git a/src/proto/if_mzsch.pro b/src/proto/if_mzsch.pro index 37bfbd89..60e99bdf 100644 --- a/src/proto/if_mzsch.pro +++ b/src/proto/if_mzsch.pro @@ -15,4 +15,5 @@ void mzvim_reset_timer __ARGS((void)); void *mzvim_eval_string __ARGS((char_u *str)); int mzthreads_allowed __ARGS((void)); void mzscheme_main __ARGS((void)); +void do_mzeval __ARGS((char_u *str, typval_T *rettv)); /* vim: set ft=c : */ diff --git a/src/proto/netbeans.pro b/src/proto/netbeans.pro index bb1a1b52..789ac9f4 100644 --- a/src/proto/netbeans.pro +++ b/src/proto/netbeans.pro @@ -16,7 +16,7 @@ void netbeans_inserted __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, char_u void netbeans_removed __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, long len)); void netbeans_unmodified __ARGS((buf_T *bufp)); void netbeans_button_release __ARGS((int button)); -void netbeans_keycommand __ARGS((int key)); +int netbeans_keycommand __ARGS((int key)); void netbeans_save_buffer __ARGS((buf_T *bufp)); void netbeans_deleted_all_lines __ARGS((buf_T *bufp)); int netbeans_is_guarded __ARGS((linenr_T top, linenr_T bot)); diff --git a/src/quickfix.c b/src/quickfix.c index 5fc36bc5..8537a7c5 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -1899,7 +1899,6 @@ qf_list(eap) int i; int idx1 = 1; int idx2 = -1; - int need_return = TRUE; char_u *arg = eap->arg; int all = eap->forceit; /* if not :cl!, only show recognised errors */ @@ -1939,13 +1938,9 @@ qf_list(eap) { if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2) { - if (need_return) - { - msg_putchar('\n'); - if (got_int) - break; - need_return = FALSE; - } + msg_putchar('\n'); + if (got_int) + break; fname = NULL; if (qfp->qf_fnum != 0 @@ -1988,7 +1983,6 @@ qf_list(eap) IObuff, IOSIZE); msg_prt_line(IObuff, FALSE); out_flush(); /* show one line at a time */ - need_return = TRUE; } qfp = qfp->qf_next; diff --git a/src/screen.c b/src/screen.c index 79980e90..d461cede 100644 --- a/src/screen.c +++ b/src/screen.c @@ -6434,6 +6434,13 @@ screen_puts_len(text, len, row, col, attr) else prev_c = u8c; # endif + if (col + mbyte_cells > screen_Columns) + { + /* Only 1 cell left, but character requires 2 cells: + * display a '>' in the last column to avoid wrapping. */ + c = '>'; + mbyte_cells = 1; + } } } #endif @@ -9210,7 +9217,7 @@ unshowmode(force) int force; { /* - * Don't delete it right now, when not redrawing or insided a mapping. + * Don't delete it right now, when not redrawing or inside a mapping. */ if (!redrawing() || (!force && char_avail() && !KeyTyped)) redraw_cmdline = TRUE; /* delete mode later */ diff --git a/src/spell.c b/src/spell.c index 033c353b..98f5e347 100644 --- a/src/spell.c +++ b/src/spell.c @@ -10306,7 +10306,10 @@ spell_suggest(count) /* Figure out if the word should be capitalised. */ need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col); - line = ml_get_curline(); + /* Make a copy of current line since autocommands may free the line. */ + line = vim_strsave(ml_get_curline()); + if (line == NULL) + goto skip; /* Get the list of suggestions. Limit to 'lines' - 2 or the number in * 'spellsuggest', whatever is smaller. */ @@ -10470,6 +10473,8 @@ spell_suggest(count) curwin->w_cursor = prev_cursor; spell_find_cleanup(&sug); +skip: + vim_free(line); } /* @@ -10931,7 +10936,7 @@ spell_suggest_intern(su, interactive) rescore_suggestions(su); /* - * While going throught the soundfold tree "su_maxscore" is the score + * While going through the soundfold tree "su_maxscore" is the score * for the soundfold word, limits the changes that are being tried, * and "su_sfmaxscore" the rescored score, which is set by * cleanup_suggestions(). @@ -11415,7 +11420,7 @@ suggest_trie_walk(su, lp, fword, soundfold) char_u tword[MAXWLEN]; /* good word collected so far */ trystate_T stack[MAXWLEN]; char_u preword[MAXWLEN * 3]; /* word found with proper case; - * concatanation of prefix compound + * concatenation of prefix compound * words and split word. NUL terminated * when going deeper but not when coming * back. */ diff --git a/src/syntax.c b/src/syntax.c index 54b8875e..42460585 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -4167,7 +4167,6 @@ clear_keywtab(ht) if (!HASHITEM_EMPTY(hi)) { --todo; - kp = HI2KE(hi); for (kp = HI2KE(hi); kp != NULL; kp = kp_next) { kp_next = kp->ke_next; diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak index c200a2f2..29f8b868 100644 --- a/src/testdir/Make_dos.mak +++ b/src/testdir/Make_dos.mak @@ -29,7 +29,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \ test42.out test52.out test65.out test66.out test67.out \ test68.out test69.out -SCRIPTS32 = test50.out +SCRIPTS32 = test50.out test70.out SCRIPTS_GUI = test16.out diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak index 26d1e878..760bb21d 100644 --- a/src/testdir/Make_ming.mak +++ b/src/testdir/Make_ming.mak @@ -48,7 +48,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \ test42.out test52.out test65.out test66.out test67.out \ test68.out test69.out -SCRIPTS32 = test50.out +SCRIPTS32 = test50.out test70.out SCRIPTS_GUI = test16.out @@ -78,6 +78,7 @@ clean: -$(DEL) small.vim -$(DEL) tiny.vim -$(DEL) mbyte.vim + -$(DEL) mzscheme.vim -$(DEL) X* -$(DEL) viminfo diff --git a/src/testdir/Makefile b/src/testdir/Makefile index efad475b..073a2841 100644 --- a/src/testdir/Makefile +++ b/src/testdir/Makefile @@ -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 + test69.out test70.out SCRIPTS_GUI = test16.out @@ -44,10 +44,10 @@ report: $(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG) clean: - -rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim test.ok X* valgrind.pid* viminfo + -rm -rf *.out *.failed *.rej *.orig test.log tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X* valgrind.pid* viminfo test1.out: test1.in - -rm -f $*.failed tiny.vim small.vim mbyte.vim test.ok X* viminfo + -rm -f $*.failed tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X* viminfo $(VALGRIND) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in $*.in @/bin/sh -c "if diff test.out $*.ok; \ then mv -f test.out $*.out; \ diff --git a/src/testdir/main.aap b/src/testdir/main.aap index 0293b92f..5fb93ec2 100644 --- a/src/testdir/main.aap +++ b/src/testdir/main.aap @@ -32,11 +32,11 @@ gui: newlog $Scripts $ScriptsGUI $Scripts $ScriptsGUI: $VimProg clean: - :del {r}{force} *.out test.log tiny.vim small.vim mbyte.vim test.ok X* + :del {r}{force} *.out test.log tiny.vim small.vim mbyte.vim mzscheme.vim test.ok X* # test1 is special, it checks for features test1.out: test1.in - :del {force} test1.failed tiny.vim small.vim mbyte.vim + :del {force} test1.failed tiny.vim small.vim mbyte.vim mzscheme.vim :sys {i} $VimProg -u unix.vim -U NONE --noplugin -s dotest.in test1.in @if os.system("diff test.out test1.ok") != 0: :error test1 FAILED - Something basic is wrong diff --git a/src/testdir/test1.in b/src/testdir/test1.in index 6d1bddee..bdcc01d0 100644 --- a/src/testdir/test1.in +++ b/src/testdir/test1.in @@ -13,6 +13,7 @@ set like small.vim above. tiny.vim is sourced by tests that require the If Vim was not compiled with the +multi_byte feature, the mbyte.vim script will be set like small.vim above. mbyte.vim is sourced by tests that require the +multi_byte feature. +Similar logic is applied to the +mzscheme feature, using mzscheme.vim. STARTTEST :" Write a single line to test.out to check if testing works at all. @@ -25,8 +26,11 @@ ae! test.ok w! test.out qa! :w! mbyte.vim +:w! mzscheme.vim :" If +multi_byte feature supported, make mbyte.vim empty. :if has("multi_byte") | sp another | w! mbyte.vim | q | endif +:" If +mzscheme feature supported, make mzscheme.vim empty. +:if has("mzscheme") | sp another | w! mzscheme.vim | q | endif :" If +eval feature supported quit here, leaving tiny.vim and small.vim empty. :" Otherwise write small.vim to skip the test. :if 1 | q! | endif diff --git a/src/testdir/test70.in b/src/testdir/test70.in new file mode 100644 index 00000000..01f43eaf --- /dev/null +++ b/src/testdir/test70.in @@ -0,0 +1,53 @@ +Smoke test for MzScheme interface and mzeval() function + +STARTTEST +:so mzscheme.vim +:set nocompatible viminfo+=nviminfo +:function! MzRequire() +:redir => l:mzversion +:mz (version) +:redir END +:if strpart(l:mzversion, 1, 1) < "4" +:" MzScheme versions < 4.x: +:mz (require (prefix vim- vimext)) +:else +:" newer versions: +:mz (require (prefix-in vim- 'vimext)) +:mz (require r5rs) +:endif +:endfunction +:silent call MzRequire() +:mz (define l '("item0" "dictionary with list OK" "item2")) +:mz (define h (make-hash)) +:mz (hash-set! h "list" l) +/^1 +:" change buffer contents +:mz (vim-set-buff-line (vim-eval "line('.')") "1 changed line 1") +:" scalar test +:let tmp_string = mzeval('"string"') +:let tmp_1000 = mzeval('1000') +:if tmp_string . tmp_1000 == "string1000" +:let scalar_res = "OK" +:else +:let scalar_res = "FAILED" +:endif +:call append(search("^1"), "scalar test " . scalar_res) +:" dictionary containing a list +:let tmp = mzeval("h")["list"][1] +:/^2/put =tmp +:" circular list (at the same time test lists containing lists) +:mz (set-car! (cddr l) l) +:let l2 = mzeval("h")["list"] +:if l2[2] == l2 +:let res = "OK" +:else +:let res = "FAILED" +:endif +:call setline(search("^3"), "circular test " . res) +:?^1?,$w! test.out +:qa! +ENDTEST + +1 line 1 +2 line 2 +3 line 3 diff --git a/src/testdir/test70.ok b/src/testdir/test70.ok new file mode 100644 index 00000000..f8d2d315 --- /dev/null +++ b/src/testdir/test70.ok @@ -0,0 +1,5 @@ +1 changed line 1 +scalar test OK +2 line 2 +dictionary with list OK +circular test OK diff --git a/src/ui.c b/src/ui.c index df8008c8..e9d6beba 100644 --- a/src/ui.c +++ b/src/ui.c @@ -2383,7 +2383,7 @@ yank_cut_buffer0(dpy, cbd) * 'enc' anyway. */ if (has_mbyte) { - char_u *conv_buf = buffer; + char_u *conv_buf; vimconv_T vc; vc.vc_type = CONV_NONE; diff --git a/src/version.c b/src/version.c index a802841b..00c77bab 100644 --- a/src/version.c +++ b/src/version.c @@ -682,6 +682,40 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 344, +/**/ + 343, +/**/ + 342, +/**/ + 341, +/**/ + 340, +/**/ + 339, +/**/ + 338, +/**/ + 337, +/**/ + 336, +/**/ + 335, +/**/ + 334, +/**/ + 333, +/**/ + 332, +/**/ + 331, +/**/ + 330, +/**/ + 329, +/**/ + 328, +/**/ 327, /**/ 326, -- 2.11.4.GIT