mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.0.1183: code is indented more than necessary
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11805)
This commit is contained in:
committed by
Bram Moolenaar
parent
043d7b2c84
commit
0233bdfa2b
@@ -221,25 +221,26 @@ set_context_in_cscope_cmd(
|
|||||||
expand_what = (cmdidx == CMD_scscope)
|
expand_what = (cmdidx == CMD_scscope)
|
||||||
? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD;
|
? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD;
|
||||||
|
|
||||||
|
if (*arg == NUL)
|
||||||
|
return;
|
||||||
|
|
||||||
// (part of) subcommand already typed
|
// (part of) subcommand already typed
|
||||||
if (*arg != NUL)
|
p = skiptowhite(arg);
|
||||||
{
|
if (*p == NUL)
|
||||||
p = skiptowhite(arg);
|
return;
|
||||||
if (*p != NUL) // past first word
|
|
||||||
{
|
// past first word
|
||||||
xp->xp_pattern = skipwhite(p);
|
xp->xp_pattern = skipwhite(p);
|
||||||
if (*skiptowhite(xp->xp_pattern) != NUL)
|
if (*skiptowhite(xp->xp_pattern) != NUL)
|
||||||
xp->xp_context = EXPAND_NOTHING;
|
xp->xp_context = EXPAND_NOTHING;
|
||||||
else if (STRNICMP(arg, "add", p - arg) == 0)
|
else if (STRNICMP(arg, "add", p - arg) == 0)
|
||||||
xp->xp_context = EXPAND_FILES;
|
xp->xp_context = EXPAND_FILES;
|
||||||
else if (STRNICMP(arg, "kill", p - arg) == 0)
|
else if (STRNICMP(arg, "kill", p - arg) == 0)
|
||||||
expand_what = EXP_CSCOPE_KILL;
|
expand_what = EXP_CSCOPE_KILL;
|
||||||
else if (STRNICMP(arg, "find", p - arg) == 0)
|
else if (STRNICMP(arg, "find", p - arg) == 0)
|
||||||
expand_what = EXP_CSCOPE_FIND;
|
expand_what = EXP_CSCOPE_FIND;
|
||||||
else
|
else
|
||||||
xp->xp_context = EXPAND_NOTHING;
|
xp->xp_context = EXPAND_NOTHING;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
266
src/if_lua.c
266
src/if_lua.c
@@ -505,18 +505,20 @@ luaV_toudata(lua_State *L, int ud, const char *tname)
|
|||||||
{
|
{
|
||||||
void *p = lua_touserdata(L, ud);
|
void *p = lua_touserdata(L, ud);
|
||||||
|
|
||||||
if (p != NULL) // value is userdata?
|
if (p == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// value is userdata
|
||||||
|
if (lua_getmetatable(L, ud)) // does it have a metatable?
|
||||||
{
|
{
|
||||||
if (lua_getmetatable(L, ud)) // does it have a metatable?
|
luaV_getfield(L, tname); // get metatable
|
||||||
|
if (lua_rawequal(L, -1, -2)) // MTs match?
|
||||||
{
|
{
|
||||||
luaV_getfield(L, tname); // get metatable
|
lua_pop(L, 2); // MTs
|
||||||
if (lua_rawequal(L, -1, -2)) // MTs match?
|
return p;
|
||||||
{
|
|
||||||
lua_pop(L, 2); // MTs
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1090,17 +1092,19 @@ luaV_dict_index(lua_State *L)
|
|||||||
dictitem_T *di = dict_find(d, key, -1);
|
dictitem_T *di = dict_find(d, key, -1);
|
||||||
|
|
||||||
if (di == NULL)
|
if (di == NULL)
|
||||||
lua_pushnil(L);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
luaV_pushtypval(L, &di->di_tv);
|
lua_pushnil(L);
|
||||||
if (di->di_tv.v_type == VAR_FUNC) // funcref?
|
return 1;
|
||||||
{
|
|
||||||
luaV_Funcref *f = (luaV_Funcref *) lua_touserdata(L, -1);
|
|
||||||
f->self = d; // keep "self" reference
|
|
||||||
d->dv_refcount++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaV_pushtypval(L, &di->di_tv);
|
||||||
|
if (di->di_tv.v_type == VAR_FUNC) // funcref?
|
||||||
|
{
|
||||||
|
luaV_Funcref *f = (luaV_Funcref *) lua_touserdata(L, -1);
|
||||||
|
f->self = d; // keep "self" reference
|
||||||
|
d->dv_refcount++;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1235,20 +1239,22 @@ luaV_blob_newindex(lua_State *L)
|
|||||||
blob_T *b = luaV_unbox(L, luaV_Blob, 1);
|
blob_T *b = luaV_unbox(L, luaV_Blob, 1);
|
||||||
if (b->bv_lock)
|
if (b->bv_lock)
|
||||||
luaL_error(L, "blob is locked");
|
luaL_error(L, "blob is locked");
|
||||||
if (lua_isnumber(L, 2))
|
|
||||||
|
if (!lua_isnumber(L, 2))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
long len = blob_len(b);
|
||||||
|
int idx = luaL_checkinteger(L, 2);
|
||||||
|
int val = luaL_checkinteger(L, 3);
|
||||||
|
if (idx < len || (idx == len && ga_grow(&b->bv_ga, 1) == OK))
|
||||||
{
|
{
|
||||||
long len = blob_len(b);
|
blob_set(b, idx, (char_u) val);
|
||||||
int idx = luaL_checkinteger(L, 2);
|
if (idx == len)
|
||||||
int val = luaL_checkinteger(L, 3);
|
++b->bv_ga.ga_len;
|
||||||
if (idx < len || (idx == len && ga_grow(&b->bv_ga, 1) == OK))
|
|
||||||
{
|
|
||||||
blob_set(b, idx, (char_u) val);
|
|
||||||
if (idx == len)
|
|
||||||
++b->bv_ga.ga_len;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
luaL_error(L, "index out of range");
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
luaL_error(L, "index out of range");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1943,30 +1949,34 @@ luaV_list(lua_State *L)
|
|||||||
|
|
||||||
if (initarg && lua_type(L, 1) != LUA_TTABLE)
|
if (initarg && lua_type(L, 1) != LUA_TTABLE)
|
||||||
luaL_error(L, "table expected, got %s", luaL_typename(L, 1));
|
luaL_error(L, "table expected, got %s", luaL_typename(L, 1));
|
||||||
|
|
||||||
l = list_alloc();
|
l = list_alloc();
|
||||||
if (l == NULL)
|
if (l == NULL)
|
||||||
lua_pushnil(L);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
luaV_newlist(L, l);
|
lua_pushnil(L);
|
||||||
if (initarg) // traverse table to init list
|
return 1;
|
||||||
{
|
|
||||||
int notnil, i = 0;
|
|
||||||
typval_T v;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
lua_rawgeti(L, 1, ++i);
|
|
||||||
notnil = !lua_isnil(L, -1);
|
|
||||||
if (notnil)
|
|
||||||
{
|
|
||||||
luaV_checktypval(L, -1, &v, "vim.list");
|
|
||||||
list_append_tv(l, &v);
|
|
||||||
clear_tv(&v);
|
|
||||||
}
|
|
||||||
lua_pop(L, 1); // value
|
|
||||||
} while (notnil);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaV_newlist(L, l);
|
||||||
|
if (!initarg)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// traverse table to init list
|
||||||
|
int notnil, i = 0;
|
||||||
|
typval_T v;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
lua_rawgeti(L, 1, ++i);
|
||||||
|
notnil = !lua_isnil(L, -1);
|
||||||
|
if (notnil)
|
||||||
|
{
|
||||||
|
luaV_checktypval(L, -1, &v, "vim.list");
|
||||||
|
list_append_tv(l, &v);
|
||||||
|
clear_tv(&v);
|
||||||
|
}
|
||||||
|
lua_pop(L, 1); // value
|
||||||
|
} while (notnil);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1978,43 +1988,47 @@ luaV_dict(lua_State *L)
|
|||||||
|
|
||||||
if (initarg && lua_type(L, 1) != LUA_TTABLE)
|
if (initarg && lua_type(L, 1) != LUA_TTABLE)
|
||||||
luaL_error(L, "table expected, got %s", luaL_typename(L, 1));
|
luaL_error(L, "table expected, got %s", luaL_typename(L, 1));
|
||||||
|
|
||||||
d = dict_alloc();
|
d = dict_alloc();
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
lua_pushnil(L);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
luaV_newdict(L, d);
|
lua_pushnil(L);
|
||||||
if (initarg) // traverse table to init dict
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
luaV_newdict(L, d);
|
||||||
|
if (!initarg)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// traverse table to init dict
|
||||||
|
lua_pushnil(L);
|
||||||
|
while (lua_next(L, 1))
|
||||||
|
{
|
||||||
|
char_u *key;
|
||||||
|
dictitem_T *di;
|
||||||
|
typval_T v;
|
||||||
|
|
||||||
|
lua_pushvalue(L, -2); // dup key in case it's a number
|
||||||
|
key = (char_u *) lua_tostring(L, -1);
|
||||||
|
if (key == NULL)
|
||||||
{
|
{
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
while (lua_next(L, 1))
|
return 1;
|
||||||
{
|
|
||||||
char_u *key;
|
|
||||||
dictitem_T *di;
|
|
||||||
typval_T v;
|
|
||||||
|
|
||||||
lua_pushvalue(L, -2); // dup key in case it's a number
|
|
||||||
key = (char_u *) lua_tostring(L, -1);
|
|
||||||
if (key == NULL)
|
|
||||||
{
|
|
||||||
lua_pushnil(L);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (*key == NUL)
|
|
||||||
luaL_error(L, "table has empty key");
|
|
||||||
luaV_checktypval(L, -2, &v, "vim.dict"); // value
|
|
||||||
di = dictitem_alloc(key);
|
|
||||||
if (di == NULL || dict_add(d, di) == FAIL)
|
|
||||||
{
|
|
||||||
vim_free(di);
|
|
||||||
lua_pushnil(L);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
di->di_tv = v;
|
|
||||||
lua_pop(L, 2); // key copy and value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (*key == NUL)
|
||||||
|
luaL_error(L, "table has empty key");
|
||||||
|
luaV_checktypval(L, -2, &v, "vim.dict"); // value
|
||||||
|
di = dictitem_alloc(key);
|
||||||
|
if (di == NULL || dict_add(d, di) == FAIL)
|
||||||
|
{
|
||||||
|
vim_free(di);
|
||||||
|
lua_pushnil(L);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
di->di_tv = v;
|
||||||
|
lua_pop(L, 2); // key copy and value
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2026,22 +2040,26 @@ luaV_blob(lua_State *L)
|
|||||||
|
|
||||||
if (initarg && !lua_isstring(L, 1))
|
if (initarg && !lua_isstring(L, 1))
|
||||||
luaL_error(L, "string expected, got %s", luaL_typename(L, 1));
|
luaL_error(L, "string expected, got %s", luaL_typename(L, 1));
|
||||||
|
|
||||||
b = blob_alloc();
|
b = blob_alloc();
|
||||||
if (b == NULL)
|
if (b == NULL)
|
||||||
lua_pushnil(L);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
luaV_newblob(L, b);
|
lua_pushnil(L);
|
||||||
if (initarg)
|
return 1;
|
||||||
{
|
|
||||||
size_t i, l = 0;
|
|
||||||
const char *s = lua_tolstring(L, 1, &l);
|
|
||||||
|
|
||||||
if (ga_grow(&b->bv_ga, (int)l) == OK)
|
|
||||||
for (i = 0; i < l; ++i)
|
|
||||||
ga_append(&b->bv_ga, s[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaV_newblob(L, b);
|
||||||
|
if (!initarg)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// traverse table to init blob
|
||||||
|
size_t i, l = 0;
|
||||||
|
const char *s = lua_tolstring(L, 1, &l);
|
||||||
|
|
||||||
|
if (ga_grow(&b->bv_ga, (int)l) == OK)
|
||||||
|
for (i = 0; i < l; ++i)
|
||||||
|
ga_append(&b->bv_ga, s[i]);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2548,28 +2566,29 @@ lua_isopen(void)
|
|||||||
static int
|
static int
|
||||||
lua_init(void)
|
lua_init(void)
|
||||||
{
|
{
|
||||||
if (!lua_isopen())
|
if (lua_isopen())
|
||||||
{
|
return OK;
|
||||||
|
|
||||||
#ifdef DYNAMIC_LUA
|
#ifdef DYNAMIC_LUA
|
||||||
if (!lua_enabled(TRUE))
|
if (!lua_enabled(TRUE))
|
||||||
{
|
{
|
||||||
emsg(_("Lua library cannot be loaded."));
|
emsg(_("Lua library cannot be loaded."));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
|
||||||
#endif
|
|
||||||
L = luaV_newstate();
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
L = luaV_newstate();
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
lua_end(void)
|
lua_end(void)
|
||||||
{
|
{
|
||||||
if (lua_isopen())
|
if (!lua_isopen())
|
||||||
{
|
return;
|
||||||
lua_close(L);
|
|
||||||
L = NULL;
|
lua_close(L);
|
||||||
}
|
L = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2698,31 +2717,32 @@ set_ref_in_lua(int copyID)
|
|||||||
{
|
{
|
||||||
int aborted = 0;
|
int aborted = 0;
|
||||||
|
|
||||||
if (lua_isopen())
|
if (!lua_isopen())
|
||||||
{
|
return 0;
|
||||||
luaV_getfield(L, LUAVIM_SETREF);
|
|
||||||
// call the function with 1 arg, getting 1 result back
|
luaV_getfield(L, LUAVIM_SETREF);
|
||||||
lua_pushinteger(L, copyID);
|
// call the function with 1 arg, getting 1 result back
|
||||||
lua_call(L, 1, 1);
|
lua_pushinteger(L, copyID);
|
||||||
// get the result
|
lua_call(L, 1, 1);
|
||||||
aborted = lua_tointeger(L, -1);
|
// get the result
|
||||||
// pop result off the stack
|
aborted = lua_tointeger(L, -1);
|
||||||
lua_pop(L, 1);
|
// pop result off the stack
|
||||||
}
|
lua_pop(L, 1);
|
||||||
|
|
||||||
return aborted;
|
return aborted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
update_package_paths_in_lua()
|
update_package_paths_in_lua()
|
||||||
{
|
{
|
||||||
if (lua_isopen())
|
if (!lua_isopen())
|
||||||
{
|
return;
|
||||||
lua_getglobal(L, "vim");
|
|
||||||
lua_getfield(L, -1, "_update_package_paths");
|
|
||||||
|
|
||||||
if (lua_pcall(L, 0, 0, 0))
|
lua_getglobal(L, "vim");
|
||||||
luaV_emsg(L);
|
lua_getfield(L, -1, "_update_package_paths");
|
||||||
}
|
|
||||||
|
if (lua_pcall(L, 0, 0, 0))
|
||||||
|
luaV_emsg(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
171
src/if_mzsch.c
171
src/if_mzsch.c
@@ -1352,24 +1352,24 @@ do_mzscheme_command(exarg_T *eap, void *data, Scheme_Closed_Prim *what)
|
|||||||
void
|
void
|
||||||
mzscheme_buffer_free(buf_T *buf)
|
mzscheme_buffer_free(buf_T *buf)
|
||||||
{
|
{
|
||||||
if (buf->b_mzscheme_ref)
|
if (buf->b_mzscheme_ref == NULL)
|
||||||
{
|
return;
|
||||||
vim_mz_buffer *bp = NULL;
|
|
||||||
MZ_GC_DECL_REG(1);
|
|
||||||
MZ_GC_VAR_IN_REG(0, bp);
|
|
||||||
MZ_GC_REG();
|
|
||||||
|
|
||||||
bp = BUFFER_REF(buf);
|
vim_mz_buffer *bp = NULL;
|
||||||
bp->buf = INVALID_BUFFER_VALUE;
|
MZ_GC_DECL_REG(1);
|
||||||
|
MZ_GC_VAR_IN_REG(0, bp);
|
||||||
|
MZ_GC_REG();
|
||||||
|
|
||||||
|
bp = BUFFER_REF(buf);
|
||||||
|
bp->buf = INVALID_BUFFER_VALUE;
|
||||||
#ifndef MZ_PRECISE_GC
|
#ifndef MZ_PRECISE_GC
|
||||||
scheme_gc_ptr_ok(bp);
|
scheme_gc_ptr_ok(bp);
|
||||||
#else
|
#else
|
||||||
scheme_free_immobile_box(buf->b_mzscheme_ref);
|
scheme_free_immobile_box(buf->b_mzscheme_ref);
|
||||||
#endif
|
#endif
|
||||||
buf->b_mzscheme_ref = NULL;
|
buf->b_mzscheme_ref = NULL;
|
||||||
MZ_GC_CHECK();
|
MZ_GC_CHECK();
|
||||||
MZ_GC_UNREG();
|
MZ_GC_UNREG();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1378,23 +1378,23 @@ mzscheme_buffer_free(buf_T *buf)
|
|||||||
void
|
void
|
||||||
mzscheme_window_free(win_T *win)
|
mzscheme_window_free(win_T *win)
|
||||||
{
|
{
|
||||||
if (win->w_mzscheme_ref)
|
if (win->w_mzscheme_ref == NULL)
|
||||||
{
|
return;
|
||||||
vim_mz_window *wp = NULL;
|
|
||||||
MZ_GC_DECL_REG(1);
|
vim_mz_window *wp = NULL;
|
||||||
MZ_GC_VAR_IN_REG(0, wp);
|
MZ_GC_DECL_REG(1);
|
||||||
MZ_GC_REG();
|
MZ_GC_VAR_IN_REG(0, wp);
|
||||||
wp = WINDOW_REF(win);
|
MZ_GC_REG();
|
||||||
wp->win = INVALID_WINDOW_VALUE;
|
wp = WINDOW_REF(win);
|
||||||
|
wp->win = INVALID_WINDOW_VALUE;
|
||||||
#ifndef MZ_PRECISE_GC
|
#ifndef MZ_PRECISE_GC
|
||||||
scheme_gc_ptr_ok(wp);
|
scheme_gc_ptr_ok(wp);
|
||||||
#else
|
#else
|
||||||
scheme_free_immobile_box(win->w_mzscheme_ref);
|
scheme_free_immobile_box(win->w_mzscheme_ref);
|
||||||
#endif
|
#endif
|
||||||
win->w_mzscheme_ref = NULL;
|
win->w_mzscheme_ref = NULL;
|
||||||
MZ_GC_CHECK();
|
MZ_GC_CHECK();
|
||||||
MZ_GC_UNREG();
|
MZ_GC_UNREG();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1406,15 +1406,15 @@ ex_mzscheme(exarg_T *eap)
|
|||||||
char_u *script;
|
char_u *script;
|
||||||
|
|
||||||
script = script_get(eap, eap->arg);
|
script = script_get(eap, eap->arg);
|
||||||
if (!eap->skip)
|
if (eap->skip)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (script == NULL)
|
||||||
|
do_mzscheme_command(eap, eap->arg, do_eval);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (script == NULL)
|
do_mzscheme_command(eap, script, do_eval);
|
||||||
do_mzscheme_command(eap, eap->arg, do_eval);
|
vim_free(script);
|
||||||
else
|
|
||||||
{
|
|
||||||
do_mzscheme_command(eap, script, do_eval);
|
|
||||||
vim_free(script);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1489,20 +1489,20 @@ ex_mzfile(exarg_T *eap)
|
|||||||
static void
|
static void
|
||||||
init_exn_catching_apply(void)
|
init_exn_catching_apply(void)
|
||||||
{
|
{
|
||||||
if (!exn_catching_apply)
|
if (exn_catching_apply)
|
||||||
{
|
return;
|
||||||
char *e =
|
|
||||||
"(lambda (thunk) "
|
|
||||||
"(with-handlers ([void (lambda (exn) (cons #f exn))]) "
|
|
||||||
"(cons #t (thunk))))";
|
|
||||||
|
|
||||||
exn_catching_apply = scheme_eval_string(e, environment);
|
char *e =
|
||||||
MZ_GC_CHECK();
|
"(lambda (thunk) "
|
||||||
exn_p = scheme_builtin_value("exn?");
|
"(with-handlers ([void (lambda (exn) (cons #f exn))]) "
|
||||||
MZ_GC_CHECK();
|
"(cons #t (thunk))))";
|
||||||
exn_message = scheme_builtin_value("exn-message");
|
|
||||||
MZ_GC_CHECK();
|
exn_catching_apply = scheme_eval_string(e, environment);
|
||||||
}
|
MZ_GC_CHECK();
|
||||||
|
exn_p = scheme_builtin_value("exn?");
|
||||||
|
MZ_GC_CHECK();
|
||||||
|
exn_message = scheme_builtin_value("exn-message");
|
||||||
|
MZ_GC_CHECK();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3827,44 +3827,45 @@ sandbox_check(void)
|
|||||||
static Scheme_Object *
|
static Scheme_Object *
|
||||||
sandbox_file_guard(int argc UNUSED, Scheme_Object **argv)
|
sandbox_file_guard(int argc UNUSED, Scheme_Object **argv)
|
||||||
{
|
{
|
||||||
if (sandbox)
|
if (!sandbox)
|
||||||
|
return scheme_void;
|
||||||
|
|
||||||
|
Scheme_Object *requested_access = argv[2];
|
||||||
|
|
||||||
|
if (M_write == NULL)
|
||||||
{
|
{
|
||||||
Scheme_Object *requested_access = argv[2];
|
MZ_REGISTER_STATIC(M_write);
|
||||||
|
M_write = scheme_intern_symbol("write");
|
||||||
if (M_write == NULL)
|
MZ_GC_CHECK();
|
||||||
{
|
|
||||||
MZ_REGISTER_STATIC(M_write);
|
|
||||||
M_write = scheme_intern_symbol("write");
|
|
||||||
MZ_GC_CHECK();
|
|
||||||
}
|
|
||||||
if (M_read == NULL)
|
|
||||||
{
|
|
||||||
MZ_REGISTER_STATIC(M_read);
|
|
||||||
M_read = scheme_intern_symbol("read");
|
|
||||||
MZ_GC_CHECK();
|
|
||||||
}
|
|
||||||
if (M_execute == NULL)
|
|
||||||
{
|
|
||||||
MZ_REGISTER_STATIC(M_execute);
|
|
||||||
M_execute = scheme_intern_symbol("execute");
|
|
||||||
MZ_GC_CHECK();
|
|
||||||
}
|
|
||||||
if (M_delete == NULL)
|
|
||||||
{
|
|
||||||
MZ_REGISTER_STATIC(M_delete);
|
|
||||||
M_delete = scheme_intern_symbol("delete");
|
|
||||||
MZ_GC_CHECK();
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!SCHEME_NULLP(requested_access))
|
|
||||||
{
|
|
||||||
Scheme_Object *item = SCHEME_CAR(requested_access);
|
|
||||||
if (scheme_eq(item, M_write) || scheme_eq(item, M_read)
|
|
||||||
|| scheme_eq(item, M_execute) || scheme_eq(item, M_delete))
|
|
||||||
raise_vim_exn(_("not allowed in the Vim sandbox"));
|
|
||||||
requested_access = SCHEME_CDR(requested_access);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (M_read == NULL)
|
||||||
|
{
|
||||||
|
MZ_REGISTER_STATIC(M_read);
|
||||||
|
M_read = scheme_intern_symbol("read");
|
||||||
|
MZ_GC_CHECK();
|
||||||
|
}
|
||||||
|
if (M_execute == NULL)
|
||||||
|
{
|
||||||
|
MZ_REGISTER_STATIC(M_execute);
|
||||||
|
M_execute = scheme_intern_symbol("execute");
|
||||||
|
MZ_GC_CHECK();
|
||||||
|
}
|
||||||
|
if (M_delete == NULL)
|
||||||
|
{
|
||||||
|
MZ_REGISTER_STATIC(M_delete);
|
||||||
|
M_delete = scheme_intern_symbol("delete");
|
||||||
|
MZ_GC_CHECK();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!SCHEME_NULLP(requested_access))
|
||||||
|
{
|
||||||
|
Scheme_Object *item = SCHEME_CAR(requested_access);
|
||||||
|
if (scheme_eq(item, M_write) || scheme_eq(item, M_read)
|
||||||
|
|| scheme_eq(item, M_execute) || scheme_eq(item, M_delete))
|
||||||
|
raise_vim_exn(_("not allowed in the Vim sandbox"));
|
||||||
|
requested_access = SCHEME_CDR(requested_access);
|
||||||
|
}
|
||||||
|
|
||||||
return scheme_void;
|
return scheme_void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1393,34 +1393,31 @@ static PySequenceMethods WinListAsSeq = {
|
|||||||
void
|
void
|
||||||
python_buffer_free(buf_T *buf)
|
python_buffer_free(buf_T *buf)
|
||||||
{
|
{
|
||||||
if (BUF_PYTHON_REF(buf) != NULL)
|
BufferObject *bp = BUF_PYTHON_REF(buf);
|
||||||
{
|
if (bp == NULL)
|
||||||
BufferObject *bp = BUF_PYTHON_REF(buf);
|
return;
|
||||||
bp->buf = INVALID_BUFFER_VALUE;
|
bp->buf = INVALID_BUFFER_VALUE;
|
||||||
BUF_PYTHON_REF(buf) = NULL;
|
BUF_PYTHON_REF(buf) = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
python_window_free(win_T *win)
|
python_window_free(win_T *win)
|
||||||
{
|
{
|
||||||
if (WIN_PYTHON_REF(win) != NULL)
|
WindowObject *wp = WIN_PYTHON_REF(win);
|
||||||
{
|
if (wp == NULL)
|
||||||
WindowObject *wp = WIN_PYTHON_REF(win);
|
return;
|
||||||
wp->win = INVALID_WINDOW_VALUE;
|
wp->win = INVALID_WINDOW_VALUE;
|
||||||
WIN_PYTHON_REF(win) = NULL;
|
WIN_PYTHON_REF(win) = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
python_tabpage_free(tabpage_T *tab)
|
python_tabpage_free(tabpage_T *tab)
|
||||||
{
|
{
|
||||||
if (TAB_PYTHON_REF(tab) != NULL)
|
TabPageObject *tp = TAB_PYTHON_REF(tab);
|
||||||
{
|
if (tp == NULL)
|
||||||
TabPageObject *tp = TAB_PYTHON_REF(tab);
|
return;
|
||||||
tp->tab = INVALID_TABPAGE_VALUE;
|
tp->tab = INVALID_TABPAGE_VALUE;
|
||||||
TAB_PYTHON_REF(tab) = NULL;
|
TAB_PYTHON_REF(tab) = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@@ -1835,34 +1835,31 @@ FunctionGetattro(PyObject *self, PyObject *nameobj)
|
|||||||
void
|
void
|
||||||
python3_buffer_free(buf_T *buf)
|
python3_buffer_free(buf_T *buf)
|
||||||
{
|
{
|
||||||
if (BUF_PYTHON_REF(buf) != NULL)
|
BufferObject *bp = BUF_PYTHON_REF(buf);
|
||||||
{
|
if (bp == NULL)
|
||||||
BufferObject *bp = BUF_PYTHON_REF(buf);
|
return;
|
||||||
bp->buf = INVALID_BUFFER_VALUE;
|
bp->buf = INVALID_BUFFER_VALUE;
|
||||||
BUF_PYTHON_REF(buf) = NULL;
|
BUF_PYTHON_REF(buf) = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
python3_window_free(win_T *win)
|
python3_window_free(win_T *win)
|
||||||
{
|
{
|
||||||
if (WIN_PYTHON_REF(win) != NULL)
|
WindowObject *wp = WIN_PYTHON_REF(win);
|
||||||
{
|
if (wp == NULL)
|
||||||
WindowObject *wp = WIN_PYTHON_REF(win);
|
return;
|
||||||
wp->win = INVALID_WINDOW_VALUE;
|
wp->win = INVALID_WINDOW_VALUE;
|
||||||
WIN_PYTHON_REF(win) = NULL;
|
WIN_PYTHON_REF(win) = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
python3_tabpage_free(tabpage_T *tab)
|
python3_tabpage_free(tabpage_T *tab)
|
||||||
{
|
{
|
||||||
if (TAB_PYTHON_REF(tab) != NULL)
|
TabPageObject *tp = TAB_PYTHON_REF(tab);
|
||||||
{
|
if (tp == NULL)
|
||||||
TabPageObject *tp = TAB_PYTHON_REF(tab);
|
return;
|
||||||
tp->tab = INVALID_TABPAGE_VALUE;
|
tp->tab = INVALID_TABPAGE_VALUE;
|
||||||
TAB_PYTHON_REF(tab) = NULL;
|
TAB_PYTHON_REF(tab) = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
163
src/if_ruby.c
163
src/if_ruby.c
@@ -866,44 +866,44 @@ ex_rubydo(exarg_T *eap)
|
|||||||
linenr_T i;
|
linenr_T i;
|
||||||
buf_T *was_curbuf = curbuf;
|
buf_T *was_curbuf = curbuf;
|
||||||
|
|
||||||
if (ensure_ruby_initialized())
|
if (!ensure_ruby_initialized())
|
||||||
{
|
return;
|
||||||
if (u_save(eap->line1 - 1, eap->line2 + 1) != OK)
|
|
||||||
return;
|
|
||||||
for (i = eap->line1; i <= eap->line2; i++)
|
|
||||||
{
|
|
||||||
VALUE line;
|
|
||||||
|
|
||||||
if (i > curbuf->b_ml.ml_line_count)
|
if (u_save(eap->line1 - 1, eap->line2 + 1) != OK)
|
||||||
break;
|
return;
|
||||||
line = vim_str2rb_enc_str((char *)ml_get(i));
|
for (i = eap->line1; i <= eap->line2; i++)
|
||||||
rb_lastline_set(line);
|
{
|
||||||
eval_enc_string_protect((char *) eap->arg, &state);
|
VALUE line;
|
||||||
if (state)
|
|
||||||
{
|
if (i > curbuf->b_ml.ml_line_count)
|
||||||
error_print(state);
|
break;
|
||||||
break;
|
line = vim_str2rb_enc_str((char *)ml_get(i));
|
||||||
}
|
rb_lastline_set(line);
|
||||||
if (was_curbuf != curbuf)
|
eval_enc_string_protect((char *) eap->arg, &state);
|
||||||
break;
|
if (state)
|
||||||
line = rb_lastline_get();
|
{
|
||||||
if (!NIL_P(line))
|
error_print(state);
|
||||||
{
|
break;
|
||||||
if (TYPE(line) != T_STRING)
|
}
|
||||||
{
|
if (was_curbuf != curbuf)
|
||||||
emsg(_(e_dollar_must_be_an_instance_of_string));
|
break;
|
||||||
return;
|
line = rb_lastline_get();
|
||||||
}
|
if (!NIL_P(line))
|
||||||
ml_replace(i, (char_u *) StringValuePtr(line), 1);
|
{
|
||||||
changed();
|
if (TYPE(line) != T_STRING)
|
||||||
#ifdef SYNTAX_HL
|
{
|
||||||
syn_changed(i); // recompute syntax hl. for this line
|
emsg(_(e_dollar_must_be_an_instance_of_string));
|
||||||
#endif
|
return;
|
||||||
}
|
}
|
||||||
|
ml_replace(i, (char_u *) StringValuePtr(line), 1);
|
||||||
|
changed();
|
||||||
|
#ifdef SYNTAX_HL
|
||||||
|
syn_changed(i); // recompute syntax hl. for this line
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
check_cursor();
|
|
||||||
update_curbuf(UPD_NOT_VALID);
|
|
||||||
}
|
}
|
||||||
|
check_cursor();
|
||||||
|
update_curbuf(UPD_NOT_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@@ -918,73 +918,74 @@ ex_rubyfile(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
if (ensure_ruby_initialized())
|
if (!ensure_ruby_initialized())
|
||||||
{
|
return;
|
||||||
VALUE file_to_load = rb_str_new2((const char *)eap->arg);
|
|
||||||
rb_protect(rb_load_wrap, file_to_load, &state);
|
VALUE file_to_load = rb_str_new2((const char *)eap->arg);
|
||||||
if (state)
|
rb_protect(rb_load_wrap, file_to_load, &state);
|
||||||
error_print(state);
|
if (state)
|
||||||
}
|
error_print(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ruby_buffer_free(buf_T *buf)
|
ruby_buffer_free(buf_T *buf)
|
||||||
{
|
{
|
||||||
if (buf->b_ruby_ref)
|
if (buf->b_ruby_ref == NULL)
|
||||||
{
|
return;
|
||||||
rb_hash_aset(objtbl, rb_obj_id((VALUE) buf->b_ruby_ref), Qnil);
|
|
||||||
RDATA(buf->b_ruby_ref)->data = NULL;
|
rb_hash_aset(objtbl, rb_obj_id((VALUE) buf->b_ruby_ref), Qnil);
|
||||||
}
|
RDATA(buf->b_ruby_ref)->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ruby_window_free(win_T *win)
|
ruby_window_free(win_T *win)
|
||||||
{
|
{
|
||||||
if (win->w_ruby_ref)
|
if (win->w_ruby_ref == NULL)
|
||||||
{
|
return;
|
||||||
rb_hash_aset(objtbl, rb_obj_id((VALUE) win->w_ruby_ref), Qnil);
|
|
||||||
RDATA(win->w_ruby_ref)->data = NULL;
|
rb_hash_aset(objtbl, rb_obj_id((VALUE) win->w_ruby_ref), Qnil);
|
||||||
}
|
RDATA(win->w_ruby_ref)->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ensure_ruby_initialized(void)
|
ensure_ruby_initialized(void)
|
||||||
{
|
{
|
||||||
if (!ruby_initialized)
|
if (ruby_initialized)
|
||||||
|
return ruby_initialized;
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RUBY
|
||||||
|
if (ruby_enabled(TRUE))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef DYNAMIC_RUBY
|
|
||||||
if (ruby_enabled(TRUE))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#ifdef MSWIN
|
#ifdef MSWIN
|
||||||
// suggested by Ariya Mizutani
|
// suggested by Ariya Mizutani
|
||||||
int argc = 1;
|
int argc = 1;
|
||||||
char *argv[] = {"gvim.exe"};
|
char *argv[] = {"gvim.exe"};
|
||||||
char **argvp = argv;
|
char **argvp = argv;
|
||||||
ruby_sysinit(&argc, &argvp);
|
ruby_sysinit(&argc, &argvp);
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
ruby_init_stack(ruby_stack_start);
|
|
||||||
ruby_init();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
int dummy_argc = 2;
|
|
||||||
char *dummy_argv[] = {"vim-ruby", "-e_=0"};
|
|
||||||
ruby_options(dummy_argc, dummy_argv);
|
|
||||||
}
|
|
||||||
ruby_script("vim-ruby");
|
|
||||||
ruby_io_init();
|
|
||||||
ruby_vim_init();
|
|
||||||
ruby_initialized = 1;
|
|
||||||
}
|
|
||||||
#ifdef DYNAMIC_RUBY
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
emsg(_(e_sorry_this_command_is_disabled_the_ruby_library_could_not_be_loaded));
|
ruby_init_stack(ruby_stack_start);
|
||||||
return 0;
|
ruby_init();
|
||||||
}
|
}
|
||||||
#endif
|
{
|
||||||
|
int dummy_argc = 2;
|
||||||
|
char *dummy_argv[] = {"vim-ruby", "-e_=0"};
|
||||||
|
ruby_options(dummy_argc, dummy_argv);
|
||||||
|
}
|
||||||
|
ruby_script("vim-ruby");
|
||||||
|
ruby_io_init();
|
||||||
|
ruby_vim_init();
|
||||||
|
ruby_initialized = 1;
|
||||||
}
|
}
|
||||||
|
#ifdef DYNAMIC_RUBY
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emsg(_(e_sorry_this_command_is_disabled_the_ruby_library_could_not_be_loaded));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return ruby_initialized;
|
return ruby_initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -221,31 +221,32 @@ serverRegisterName(
|
|||||||
char_u *p = NULL;
|
char_u *p = NULL;
|
||||||
|
|
||||||
res = DoRegisterName(dpy, name);
|
res = DoRegisterName(dpy, name);
|
||||||
if (res < 0)
|
if (res >= 0)
|
||||||
|
return OK;
|
||||||
|
|
||||||
|
i = 1;
|
||||||
|
do
|
||||||
{
|
{
|
||||||
i = 1;
|
if (res < -1 || i >= 1000)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if (res < -1 || i >= 1000)
|
msg_attr(_("Unable to register a command server name"),
|
||||||
{
|
HL_ATTR(HLF_W));
|
||||||
msg_attr(_("Unable to register a command server name"),
|
return FAIL;
|
||||||
HL_ATTR(HLF_W));
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
if (p == NULL)
|
|
||||||
p = alloc(STRLEN(name) + 10);
|
|
||||||
if (p == NULL)
|
|
||||||
{
|
|
||||||
res = -10;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
sprintf((char *)p, "%s%d", name, i++);
|
|
||||||
res = DoRegisterName(dpy, p);
|
|
||||||
}
|
}
|
||||||
while (res < 0)
|
if (p == NULL)
|
||||||
;
|
p = alloc(STRLEN(name) + 10);
|
||||||
vim_free(p);
|
if (p == NULL)
|
||||||
|
{
|
||||||
|
res = -10;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sprintf((char *)p, "%s%d", name, i++);
|
||||||
|
res = DoRegisterName(dpy, p);
|
||||||
}
|
}
|
||||||
|
while (res < 0)
|
||||||
|
;
|
||||||
|
vim_free(p);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,17 +757,17 @@ serverSendReply(char_u *name, char_u *str)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
length = STRLEN(p_enc) + STRLEN(str) + 14;
|
length = STRLEN(p_enc) + STRLEN(str) + 14;
|
||||||
if ((property = alloc(length + 30)) != NULL)
|
if ((property = alloc(length + 30)) == NULL)
|
||||||
{
|
return -1;
|
||||||
sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x",
|
|
||||||
0, 0, p_enc, 0, str, 0, (unsigned int)commWindow);
|
sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x",
|
||||||
// Add length of what "%x" resulted in.
|
0, 0, p_enc, 0, str, 0, (unsigned int)commWindow);
|
||||||
length += STRLEN(property + length);
|
// Add length of what "%x" resulted in.
|
||||||
res = AppendPropCarefully(dpy, win, commProperty, property, length + 1);
|
length += STRLEN(property + length);
|
||||||
vim_free(property);
|
res = AppendPropCarefully(dpy, win, commProperty, property, length + 1);
|
||||||
return res;
|
vim_free(property);
|
||||||
}
|
|
||||||
return -1;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
12
src/indent.c
12
src/indent.c
@@ -2188,12 +2188,12 @@ fixthisline(int (*get_the_indent)(void))
|
|||||||
{
|
{
|
||||||
int amount = get_the_indent();
|
int amount = get_the_indent();
|
||||||
|
|
||||||
if (amount >= 0)
|
if (amount < 0)
|
||||||
{
|
return;
|
||||||
change_indent(INDENT_SET, amount, FALSE, 0, TRUE);
|
|
||||||
if (linewhite(curwin->w_cursor.lnum))
|
change_indent(INDENT_SET, amount, FALSE, 0, TRUE);
|
||||||
did_ai = TRUE; // delete the indent if the line stays empty
|
if (linewhite(curwin->w_cursor.lnum))
|
||||||
}
|
did_ai = TRUE; // delete the indent if the line stays empty
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1183,
|
||||||
/**/
|
/**/
|
||||||
1182,
|
1182,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user