Compare commits

..

11 Commits

Author SHA1 Message Date
Bram Moolenaar
d836bb90ab updated for version 7.2.342
Problem:    Popup menu displayed wrong in 'rightleft' mode when there are
            multi-byte characters.
Solution:   Adjust the column computations. (Dominique Pelle)
2010-01-19 18:06:03 +01:00
Bram Moolenaar
e4ebd29ea9 updated for version 7.2.341
Problem:    Popup menu wraps to next line when double-wide character doesn't
            fit. (Jiang Ma)
Solution:   Display a ">" instead. (Dominique Pelle)
2010-01-19 17:40:46 +01:00
Bram Moolenaar
3ee0229f64 updated for version 7.2.340
Problem:    Gcc warning for condition that can never be true. (James Vega)
Solution:   Use start_lvl instead flp->lvl.
2010-01-19 17:24:25 +01:00
Bram Moolenaar
c4e4198730 updated for version 7.2.339
Problem:    Part of --startuptime patch is missing.
Solution:   Add check for time_fd.
2010-01-19 16:31:47 +01:00
Bram Moolenaar
6b29b0e809 updated for version 7.2.338
Problem:    Part of FD_CLOEXEC change is missing.
Solution:   Include source file skipped because of typo.
2010-01-19 16:22:03 +01:00
Bram Moolenaar
3d63e3f160 updated for version 7.2.337
Problem:    The :compiler command doesn't function properly when invoked in a
            function.
Solution:   Add "g:" before "current_compiler". (Yukihiro Nakadaira)
2010-01-19 16:13:50 +01:00
Bram Moolenaar
7e506b6a42 updated for version 7.2.336
Problem:    MzScheme interface can't evaluate an expression.
Solution:   Add mzeval(). (Sergey Khorev)
2010-01-19 15:55:06 +01:00
Bram Moolenaar
6d8027a6c2 updated for version 7.2.335
Problem:    The CTRL-] command escapes too many characters.
Solution:   Use a different list of characters to be escaped. (Sergey Khorev)
2010-01-19 15:24:27 +01:00
Bram Moolenaar
8065d7fd9c updated for version 7.2.334
Problem:    Postponing keys in Netbeans interface does not work properly.
Solution:   Store the key string instead of the number.  Avoid an infinite
            loop. (Mostly by Xavier de Gaye)
2010-01-19 15:13:14 +01:00
Bram Moolenaar
2660c0ea9b updated for version 7.2.333
Problem:    Warnings from static code analysis.
Solution:   Small changes to various lines. (Dominique Pelle)
2010-01-19 14:59:56 +01:00
Bram Moolenaar
3ea38ef239 updated for version 7.2.332
Problem:    Crash when spell correcting triggers an autocommand that reloads
            the buffer.
Solution:   Make a copy of the line to be modified. (Dominique Pelle)
2010-01-19 13:08:42 +01:00
32 changed files with 518 additions and 103 deletions

View File

@@ -1826,6 +1826,7 @@ 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
@@ -4102,6 +4103,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: >

View File

@@ -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|.

View File

@@ -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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;
@@ -6812,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;
{
@@ -6868,7 +6866,7 @@ dictitem_remove(dict, item)
/*
* Free a dict item. Also clears the value.
*/
static void
void
dictitem_free(item)
dictitem_T *item;
{
@@ -6948,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;
@@ -7699,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},
@@ -13591,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
*/
@@ -19274,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;

View File

@@ -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 <args>");
}
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;
{
int fd_tmp = mch_open(filename, O_RDONLY | O_BINARY | O_NOINHERIT, 0);
int fd_tmp = mch_open(filename, O_RDONLY
# ifdef WIN32
O_BINARY | O_NOINHERIT
# endif
, 0);
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

View File

@@ -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)

View File

@@ -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. */

View File

@@ -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

View File

@@ -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;

View File

@@ -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
/*

View File

@@ -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.

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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));

View File

@@ -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 : */

View File

@@ -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));

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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. */

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -23,7 +23,7 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
test54.out test55.out test56.out test57.out test58.out \
test59.out test60.out test61.out test62.out test63.out \
test64.out test65.out test66.out test67.out test68.out \
test69.out
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; \

View File

@@ -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

View File

@@ -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

53
src/testdir/test70.in Normal file
View File

@@ -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

5
src/testdir/test70.ok Normal file
View File

@@ -0,0 +1,5 @@
1 changed line 1
scalar test OK
2 line 2
dictionary with list OK
circular test OK

View File

@@ -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;

View File

@@ -681,6 +681,28 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
342,
/**/
341,
/**/
340,
/**/
339,
/**/
338,
/**/
337,
/**/
336,
/**/
335,
/**/
334,
/**/
333,
/**/
332,
/**/
331,
/**/