Compare commits

...

8 Commits

Author SHA1 Message Date
Bram Moolenaar
bbc98db7c4 updated for version 7.3.441
Problem:    Newer versions of MzScheme (Racket) require earlier (trampolined)
            initialisation.
Solution:   Call mzscheme_main() early in main(). (Sergey Khorev)
2012-02-12 01:55:55 +01:00
Bram Moolenaar
efcb54b78c updated for version 7.3.440
Problem:    Vim does not support UTF8_STRING for the X selection.
Solution:   Add UTF8_STRING atom support. (Alex Efros) Use it only when
            'encoding' is set to Unicode.
2012-02-12 01:35:10 +01:00
Bram Moolenaar
be74734429 updated for version 7.3.439
Problem:    Compiler warnings to size casts in Perl interface.
Solution:   Use XS macros. (James McCoy)
2012-02-12 00:31:52 +01:00
Bram Moolenaar
a61d5fbf7a updated for version 7.3.438
Problem:    There is no way to avoid ":doautoall" reading modelines.
Solution:   Add the <nomodeline> argument. Adjust documentation.
2012-02-12 00:18:58 +01:00
Bram Moolenaar
28f2908d95 updated for version 7.3.437
Problem:    Continue looping inside FOR_ALL_TAB_WINDOWS even when already done.
Solution:   Use goto instead of break. (Hirohito Higashi)
2012-02-11 23:45:37 +01:00
Bram Moolenaar
68ba0dd633 updated for version 7.3.436
Problem:    Compiler warnings for types on Windows.
Solution:   Add type casts. (Mike Williams)
2012-02-11 20:44:10 +01:00
Bram Moolenaar
c047b9a49f updated for version 7.3.435
Problem:    Compiler warning for unused variable.
Solution:   Move the variable inside #ifdef.
2012-02-11 20:40:55 +01:00
Bram Moolenaar
3fe37d62d1 updated for version 7.3.434
Problem:    Using join() can be slow.
Solution:   Compute the size of the result before allocation to avoid a lot of
            allocations and copies. (Taro Muraoka)
2012-02-06 00:13:22 +01:00
13 changed files with 257 additions and 103 deletions

View File

@@ -1073,13 +1073,8 @@ option will not cause any commands to be executed.
autocommands for that group. Note: if you use an
undefined group name, Vim gives you an error message.
After applying the autocommands the modelines are
processed, so that their settings overrule the
settings from autocommands, like what happens when
editing a file.
*:doautoa* *:doautoall*
:doautoa[ll] [group] {event} [fname]
:doautoa[ll] [<nomodeline>] [group] {event} [fname]
Like ":doautocmd", but apply the autocommands to each
loaded buffer. Note that [fname] is used to select
the autocommands, not the buffers to which they are
@@ -1090,6 +1085,12 @@ option will not cause any commands to be executed.
This command is intended for autocommands that set
options, change highlighting, and things like that.
After applying the autocommands the modelines are
processed, so that their settings overrule the
settings from autocommands, like what happens when
editing a file. This is skipped when the <nomodeline>
argument is present.
==============================================================================
10. Using autocommands *autocmd-use*

View File

@@ -740,6 +740,8 @@ MZSCHEME_LIB = $(MZSCHEME)\lib\msvc\libmzgc$(MZSCHEME_VER).lib \
!endif
!endif
MZSCHEME_OBJ = $(OUTDIR)\if_mzsch.obj
# increase stack size
MZSCHEME_LIB = $(MZSCHEME_LIB) /STACK:8388608
!endif
# Perl interface

View File

@@ -442,6 +442,7 @@ static int list_concat __ARGS((list_T *l1, list_T *l2, typval_T *tv));
static list_T *list_copy __ARGS((list_T *orig, int deep, int copyID));
static void list_remove __ARGS((list_T *l, listitem_T *item, listitem_T *item2));
static char_u *list2string __ARGS((typval_T *tv, int copyID));
static int list_join_inner __ARGS((garray_T *gap, list_T *l, char_u *sep, int echo_style, int copyID, garray_T *join_gap));
static int list_join __ARGS((garray_T *gap, list_T *l, char_u *sep, int echo, int copyID));
static int free_unref_items __ARGS((int copyID));
static void set_ref_in_ht __ARGS((hashtab_T *ht, int copyID));
@@ -6571,6 +6572,82 @@ list2string(tv, copyID)
return (char_u *)ga.ga_data;
}
typedef struct join_S {
char_u *s;
char_u *tofree;
} join_T;
static int
list_join_inner(gap, l, sep, echo_style, copyID, join_gap)
garray_T *gap; /* to store the result in */
list_T *l;
char_u *sep;
int echo_style;
int copyID;
garray_T *join_gap; /* to keep each list item string */
{
int i;
join_T *p;
int len;
int sumlen = 0;
int first = TRUE;
char_u *tofree;
char_u numbuf[NUMBUFLEN];
listitem_T *item;
char_u *s;
/* Stringify each item in the list. */
for (item = l->lv_first; item != NULL && !got_int; item = item->li_next)
{
if (echo_style)
s = echo_string(&item->li_tv, &tofree, numbuf, copyID);
else
s = tv2string(&item->li_tv, &tofree, numbuf, copyID);
if (s == NULL)
return FAIL;
len = (int)STRLEN(s);
sumlen += len;
ga_grow(join_gap, 1);
p = ((join_T *)join_gap->ga_data) + (join_gap->ga_len++);
if (tofree != NULL || s != numbuf)
{
p->s = s;
p->tofree = tofree;
}
else
{
p->s = vim_strnsave(s, len);
p->tofree = p->s;
}
line_breakcheck();
}
/* Allocate result buffer with its total size, avoid re-allocation and
* multiple copy operations. Add 2 for a tailing ']' and NUL. */
if (join_gap->ga_len >= 2)
sumlen += (int)STRLEN(sep) * (join_gap->ga_len - 1);
if (ga_grow(gap, sumlen + 2) == FAIL)
return FAIL;
for (i = 0; i < join_gap->ga_len && !got_int; ++i)
{
if (first)
first = FALSE;
else
ga_concat(gap, sep);
p = ((join_T *)join_gap->ga_data) + i;
if (p->s != NULL)
ga_concat(gap, p->s);
line_breakcheck();
}
return OK;
}
/*
* Join list "l" into a string in "*gap", using separator "sep".
* When "echo_style" is TRUE use String as echoed, otherwise as inside a List.
@@ -6584,31 +6661,27 @@ list_join(gap, l, sep, echo_style, copyID)
int echo_style;
int copyID;
{
int first = TRUE;
char_u *tofree;
char_u numbuf[NUMBUFLEN];
listitem_T *item;
char_u *s;
garray_T join_ga;
int retval;
join_T *p;
int i;
for (item = l->lv_first; item != NULL && !got_int; item = item->li_next)
ga_init2(&join_ga, (int)sizeof(join_T), l->lv_len);
retval = list_join_inner(gap, l, sep, echo_style, copyID, &join_ga);
/* Dispose each item in join_ga. */
if (join_ga.ga_data != NULL)
{
if (first)
first = FALSE;
else
ga_concat(gap, sep);
if (echo_style)
s = echo_string(&item->li_tv, &tofree, numbuf, copyID);
else
s = tv2string(&item->li_tv, &tofree, numbuf, copyID);
if (s != NULL)
ga_concat(gap, s);
vim_free(tofree);
if (s == NULL)
return FAIL;
line_breakcheck();
p = (join_T *)join_ga.ga_data;
for (i = 0; i < join_ga.ga_len; ++i)
{
vim_free(p->tofree);
++p;
}
ga_clear(&join_ga);
}
return OK;
return retval;
}
/*
@@ -13406,7 +13479,7 @@ get_maparg(argvars, rettv, exact)
char_u *rhs;
int mode;
int abbr = FALSE;
int get_dict = FALSE;
int get_dict = FALSE;
mapblock_T *mp;
int buffer_local;
@@ -14389,7 +14462,7 @@ f_readfile(argvars, rettv)
--prevlen;
}
if (prevlen == 0)
s = vim_strnsave(start, len);
s = vim_strnsave(start, (int)len);
else
{
/* Change "prev" buffer to be the right size. This way
@@ -14456,7 +14529,7 @@ f_readfile(argvars, rettv)
if (dest < buf)
{
adjust_prevlen = buf - dest; /* must be 1 or 2 */
adjust_prevlen = (int)(buf - dest); /* must be 1 or 2 */
dest = buf;
}
if (readlen > p - buf + 1)
@@ -14485,11 +14558,11 @@ f_readfile(argvars, rettv)
* small, to avoid repeatedly 'allocing' large and
* 'reallocing' small. */
if (prevsize == 0)
prevsize = p - start;
prevsize = (long)(p - start);
else
{
long grow50pc = (prevsize * 3) / 2;
long growmin = (p - start) * 2 + prevlen;
long growmin = (long)((p - start) * 2 + prevlen);
prevsize = grow50pc > growmin ? grow50pc : growmin;
}
if ((newprev = vim_realloc(prev, prevsize)) == NULL)
@@ -14502,7 +14575,7 @@ f_readfile(argvars, rettv)
}
/* Add the line part to end of "prev". */
mch_memmove(prev + prevlen, start, p - start);
prevlen += p - start;
prevlen += (long)(p - start);
}
} /* while */

View File

@@ -3400,7 +3400,7 @@ getsourceline(c, cookie, indent)
{
struct source_cookie *sp = (struct source_cookie *)cookie;
char_u *line;
char_u *p, *s;
char_u *p;
#ifdef FEAT_EVAL
/* If breakpoints have been added/deleted need to check for it. */
@@ -3471,6 +3471,8 @@ getsourceline(c, cookie, indent)
#ifdef FEAT_MBYTE
if (line != NULL && sp->conv.vc_type != CONV_NONE)
{
char_u *s;
/* Convert the encoding of the script line. */
s = string_convert(&sp->conv, line, NULL);
if (s != NULL)

View File

@@ -8739,6 +8739,14 @@ ex_doautoall(eap)
int retval;
aco_save_T aco;
buf_T *buf;
char_u *arg = eap->arg;
int call_do_modelines = TRUE;
if (STRNCMP(arg, "<nomodeline>", 12) == 0)
{
call_do_modelines = FALSE;
arg = skipwhite(arg + 12);
}
/*
* This is a bit tricky: For some commands curwin->w_buffer needs to be
@@ -8755,11 +8763,15 @@ ex_doautoall(eap)
aucmd_prepbuf(&aco, buf);
/* execute the autocommands for this buffer */
retval = do_doautocmd(eap->arg, FALSE);
retval = do_doautocmd(arg, FALSE);
/* Execute the modeline settings, but don't set window-local
* options if we are using the current window for another buffer. */
do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
if (call_do_modelines)
{
/* Execute the modeline settings, but don't set window-local
* options if we are using the current window for another
* buffer. */
do_modelines(curwin == aucmd_win ? OPT_NOWIN : 0);
}
/* restore the current window */
aucmd_restbuf(&aco);
@@ -8898,10 +8910,11 @@ aucmd_restbuf(aco)
if (tp != curtab)
goto_tabpage_tp(tp);
win_goto(aucmd_win);
break;
goto win_found;
}
}
}
win_found:
/* Remove the window and frame from the tree of frames. */
(void)winframe_remove(curwin, &dummy, NULL);

View File

@@ -535,6 +535,10 @@ EXTERN win_T *lastwin; /* last window */
EXTERN win_T *prevwin INIT(= NULL); /* previous window */
# define W_NEXT(wp) ((wp)->w_next)
# define FOR_ALL_WINDOWS(wp) for (wp = firstwin; wp != NULL; wp = wp->w_next)
/*
* When using this macro "break" only breaks out of the inner loop. Use "goto"
* to break out of the tabpage loop.
*/
# define FOR_ALL_TAB_WINDOWS(tp, wp) \
for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next) \
for ((wp) = ((tp) == curtab) \

View File

@@ -31,8 +31,6 @@
* depend". */
#if defined(FEAT_MZSCHEME) || defined(PROTO)
#include <assert.h>
/* Base data structures */
#define SCHEME_VIMBUFFERP(obj) SAME_TYPE(SCHEME_TYPE(obj), mz_buffer_type)
#define SCHEME_VIMWINDOWP(obj) SAME_TYPE(SCHEME_TYPE(obj), mz_window_type)
@@ -559,13 +557,6 @@ mzscheme_runtime_link_init(char *sch_dll, char *gc_dll, int verbose)
hMzSch = vimLoadLib(sch_dll);
hMzGC = vimLoadLib(gc_dll);
if (!hMzSch)
{
if (verbose)
EMSG2(_(e_loadlib), sch_dll);
return FAIL;
}
if (!hMzGC)
{
if (verbose)
@@ -573,6 +564,13 @@ mzscheme_runtime_link_init(char *sch_dll, char *gc_dll, int verbose)
return FAIL;
}
if (!hMzSch)
{
if (verbose)
EMSG2(_(e_loadlib), sch_dll);
return FAIL;
}
for (thunk = mzsch_imports; thunk->name; thunk++)
{
if ((*thunk->ptr =
@@ -798,65 +796,68 @@ mzscheme_end(void)
static __declspec(thread) void *tls_space;
#endif
void
mzscheme_main(void)
/*
* Since version 4.x precise GC requires trampolined startup.
* Futures and places in version 5.x need it too.
*/
#if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR >= 400 \
|| MZSCHEME_VERSION_MAJOR >= 500 && (defined(MZ_USE_FUTURES) || defined(MZ_USE_PLACES))
# ifdef DYNAMIC_MZSCHEME
# error Precise GC v.4+ or Racket with futures/places do not support dynamic MzScheme
# endif
# define TRAMPOLINED_MZVIM_STARTUP
#endif
int
mzscheme_main(int argc, char** argv)
{
#if MZSCHEME_VERSION_MAJOR >= 500 && defined(WIN32) && defined(USE_THREAD_LOCAL)
scheme_register_tls_space(&tls_space, 0);
#endif
#if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR >= 400
/* use trampoline for precise GC in MzScheme >= 4.x */
scheme_main_setup(TRUE, mzscheme_env_main, 0, NULL);
#ifdef TRAMPOLINED_MZVIM_STARTUP
return scheme_main_setup(TRUE, mzscheme_env_main, argc, argv);
#else
mzscheme_env_main(NULL, 0, NULL);
return mzscheme_env_main(NULL, argc, argv);
#endif
}
static int
mzscheme_env_main(Scheme_Env *env, int argc UNUSED, char **argv UNUSED)
mzscheme_env_main(Scheme_Env *env, int argc, char **argv)
{
/* neither argument nor return values are used */
#ifdef MZ_PRECISE_GC
# if MZSCHEME_VERSION_MAJOR < 400
/*
* Starting from version 4.x, embedding applications must use
* scheme_main_setup/scheme_main_stack_setup trampolines
* rather than setting stack base directly with scheme_set_stack_base
*/
int vim_main_result;
#ifdef TRAMPOLINED_MZVIM_STARTUP
/* Scheme has created the environment for us */
environment = env;
#else
# ifdef MZ_PRECISE_GC
Scheme_Object *dummy = NULL;
MZ_GC_DECL_REG(1);
MZ_GC_VAR_IN_REG(0, dummy);
stack_base = &__gc_var_stack__;
# else
/* environment has been created by us by Scheme */
environment = env;
# endif
/*
* In 4.x, all activities must be performed inside trampoline
* so we are forced to initialise GC immediately
* This can be postponed in 3.x but I see no point in implementing
* a feature which will work in older versions only.
* One would better use conservative GC if he needs dynamic MzScheme
*/
mzscheme_init();
#else
int dummy = 0;
stack_base = (void *)&dummy;
# endif
#endif
main_loop(FALSE, FALSE);
#if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR < 400
/* mzscheme_main is called as a trampoline from main.
* We trampoline into vim_main2
* Passing argc, argv through from mzscheme_main
*/
vim_main_result = vim_main2(argc, argv);
#if !defined(TRAMPOLINED_MZVIM_STARTUP) && defined(MZ_PRECISE_GC)
/* releasing dummy */
MZ_GC_REG();
MZ_GC_UNREG();
#endif
return 0;
return vim_main_result;
}
static void
startup_mzscheme(void)
{
#if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400
#ifndef TRAMPOLINED_MZVIM_STARTUP
scheme_set_stack_base(stack_base, 1);
#endif
@@ -868,7 +869,7 @@ startup_mzscheme(void)
MZ_REGISTER_STATIC(exn_message);
MZ_REGISTER_STATIC(vim_exn);
#if !defined(MZ_PRECISE_GC) || MZSCHEME_VERSION_MAJOR < 400
#ifndef TRAMPOLINED_MZVIM_STARTUP
/* in newer versions of precise GC the initial env has been created */
environment = scheme_basic_env();
#endif
@@ -3013,7 +3014,6 @@ register_vim_exn(void)
MZ_GC_REG();
tmp = scheme_make_struct_names(exn_name, scheme_null, 0, &nc);
assert(nc <= 5);
mch_memmove(exn_names, tmp, nc * sizeof(Scheme_Object *));
MZ_GC_CHECK();

View File

@@ -611,7 +611,7 @@ newWINrv(rv, ptr)
if (ptr->w_perl_private == NULL)
{
ptr->w_perl_private = newSV(0);
sv_setiv(ptr->w_perl_private, (IV)ptr);
sv_setiv(ptr->w_perl_private, PTR2IV(ptr));
}
else
SvREFCNT_inc(ptr->w_perl_private);
@@ -629,7 +629,7 @@ newBUFrv(rv, ptr)
if (ptr->b_perl_private == NULL)
{
ptr->b_perl_private = newSV(0);
sv_setiv(ptr->b_perl_private, (IV)ptr);
sv_setiv(ptr->b_perl_private, PTR2IV(ptr));
}
else
SvREFCNT_inc(ptr->b_perl_private);

View File

@@ -554,6 +554,31 @@ main
debug_break_level = params.use_debug_break_level;
#endif
#ifdef FEAT_MZSCHEME
/*
* Newer version of MzScheme (Racket) require earlier (trampolined)
* initialisation via scheme_main_setup.
* Implement this by initialising it as early as possible
* and splitting off remaining Vim main into vim_main2
*/
{
/* Pack up preprocessed command line arguments.
* It is safe because Scheme does not access argc/argv. */
char *args[2];
args[0] = (char *)fname;
args[1] = (char *)&params;
return mzscheme_main(2, args);
}
}
int vim_main2(int argc, char **argv)
{
char_u *fname = (char_u *)argv[0];
mparm_T params;
memcpy(&params, argv[1], sizeof(params));
#endif
/* Execute --cmd arguments. */
exe_pre_commands(&params);
@@ -957,14 +982,8 @@ main
/*
* Call the main command loop. This never returns.
* For embedded MzScheme the main_loop will be called by Scheme
* for proper stack tracking
*/
#ifndef FEAT_MZSCHEME
*/
main_loop(FALSE, FALSE);
#else
mzscheme_main();
#endif
return 0;
}

View File

@@ -14,6 +14,7 @@ void mzvim_check_threads __ARGS((void));
void mzvim_reset_timer __ARGS((void));
void *mzvim_eval_string __ARGS((char_u *str));
int mzthreads_allowed __ARGS((void));
void mzscheme_main __ARGS((void));
int mzscheme_main __ARGS((int argc, char **argv));
void do_mzeval __ARGS((char_u *str, typval_T *rettv));
int vim_main2 __ARGS((int argc, char **argv));
/* vim: set ft=c : */

View File

@@ -6,7 +6,7 @@ INPUT
T_VIOBJNOMUNGE
if (sv_isa($arg, \"${ntype}\")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = ($type) tmp;
$var = INT2PTR($type, tmp);
if (!tmp)
croak(\"$ntype no longer exists\");
}

View File

@@ -1917,6 +1917,7 @@ open_app_context()
static Atom vim_atom; /* Vim's own special selection format */
#ifdef FEAT_MBYTE
static Atom vimenc_atom; /* Vim's extended selection format */
static Atom utf8_atom;
#endif
static Atom compound_text_atom;
static Atom text_atom;
@@ -1930,6 +1931,7 @@ x11_setup_atoms(dpy)
vim_atom = XInternAtom(dpy, VIM_ATOM_NAME, False);
#ifdef FEAT_MBYTE
vimenc_atom = XInternAtom(dpy, VIMENC_ATOM_NAME,False);
utf8_atom = XInternAtom(dpy, "UTF8_STRING", False);
#endif
compound_text_atom = XInternAtom(dpy, "COMPOUND_TEXT", False);
text_atom = XInternAtom(dpy, "TEXT", False);
@@ -2074,7 +2076,11 @@ clip_x11_request_selection_cb(w, success, sel_atom, type, value, length,
}
#endif
else if (*type == compound_text_atom || (
else if (*type == compound_text_atom
#ifdef FEAT_MBYTE
|| *type == utf8_atom
#endif
|| (
#ifdef FEAT_MBYTE
enc_dbcs != 0 &&
#endif
@@ -2128,7 +2134,7 @@ clip_x11_request_selection(myShell, dpy, cbd)
#else
1
#endif
; i < 5; i++)
; i < 6; i++)
{
switch (i)
{
@@ -2136,10 +2142,18 @@ clip_x11_request_selection(myShell, dpy, cbd)
case 0: type = vimenc_atom; break;
#endif
case 1: type = vim_atom; break;
case 2: type = compound_text_atom; break;
case 3: type = text_atom; break;
#ifdef FEAT_MBYTE
case 2: type = utf8_atom; break;
#endif
case 3: type = compound_text_atom; break;
case 4: type = text_atom; break;
default: type = XA_STRING;
}
#ifdef FEAT_MBYTE
if (type == utf8_atom && !enc_utf8)
/* Only request utf-8 when 'encoding' is utf8. */
continue;
#endif
success = MAYBE;
XtGetSelectionValue(myShell, cbd->sel_atom, type,
clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
@@ -2230,18 +2244,23 @@ clip_x11_convert_selection_cb(w, sel_atom, target, type, value, length, format)
{
Atom *array;
if ((array = (Atom *)XtMalloc((unsigned)(sizeof(Atom) * 6))) == NULL)
if ((array = (Atom *)XtMalloc((unsigned)(sizeof(Atom) * 7))) == NULL)
return False;
*value = (XtPointer)array;
i = 0;
array[i++] = XA_STRING;
array[i++] = targets_atom;
#ifdef FEAT_MBYTE
array[i++] = vimenc_atom;
#endif
array[i++] = vim_atom;
#ifdef FEAT_MBYTE
if (enc_utf8)
array[i++] = utf8_atom;
#endif
array[i++] = XA_STRING;
array[i++] = text_atom;
array[i++] = compound_text_atom;
*type = XA_ATOM;
/* This used to be: *format = sizeof(Atom) * 8; but that caused
* crashes on 64 bit machines. (Peter Derr) */
@@ -2253,6 +2272,7 @@ clip_x11_convert_selection_cb(w, sel_atom, target, type, value, length, format)
if ( *target != XA_STRING
#ifdef FEAT_MBYTE
&& *target != vimenc_atom
&& *target != utf8_atom
#endif
&& *target != vim_atom
&& *target != text_atom
@@ -2282,13 +2302,16 @@ clip_x11_convert_selection_cb(w, sel_atom, target, type, value, length, format)
return False;
}
if (*target == XA_STRING)
if (*target == XA_STRING
#ifdef FEAT_MBYTE
|| (*target == utf8_atom && enc_utf8)
#endif
)
{
mch_memmove(result, string, (size_t)(*length));
*type = XA_STRING;
*type = *target;
}
else if (*target == compound_text_atom
|| *target == text_atom)
else if (*target == compound_text_atom || *target == text_atom)
{
XTextProperty text_prop;
char *string_nt = (char *)alloc((unsigned)*length + 1);

View File

@@ -714,6 +714,22 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
441,
/**/
440,
/**/
439,
/**/
438,
/**/
437,
/**/
436,
/**/
435,
/**/
434,
/**/
433,
/**/