forked from aniani/vim
patch 8.1.2387: using old C style comments
Problem: Using old C style comments. Solution: Use // comments where appropriate.
This commit is contained in:
467
src/hardcopy.c
467
src/hardcopy.c
File diff suppressed because it is too large
Load Diff
@@ -30,18 +30,18 @@
|
||||
#include "vim.h"
|
||||
|
||||
#if 0
|
||||
# define HT_DEBUG /* extra checks for table consistency and statistics */
|
||||
# define HT_DEBUG // extra checks for table consistency and statistics
|
||||
|
||||
static long hash_count_lookup = 0; /* count number of hashtab lookups */
|
||||
static long hash_count_perturb = 0; /* count number of "misses" */
|
||||
static long hash_count_lookup = 0; // count number of hashtab lookups
|
||||
static long hash_count_perturb = 0; // count number of "misses"
|
||||
#endif
|
||||
|
||||
/* Magic value for algorithm that walks through the array. */
|
||||
// Magic value for algorithm that walks through the array.
|
||||
#define PERTURB_SHIFT 5
|
||||
|
||||
static int hash_may_resize(hashtab_T *ht, int minitems);
|
||||
|
||||
#if 0 /* currently not used */
|
||||
#if 0 // currently not used
|
||||
/*
|
||||
* Create an empty hash table.
|
||||
* Returns NULL when out of memory.
|
||||
@@ -64,7 +64,7 @@ hash_create(void)
|
||||
void
|
||||
hash_init(hashtab_T *ht)
|
||||
{
|
||||
/* This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray". */
|
||||
// This zeroes all "ht_" entries and all the "hi_key" in "ht_smallarray".
|
||||
vim_memset(ht, 0, sizeof(hashtab_T));
|
||||
ht->ht_array = ht->ht_smallarray;
|
||||
ht->ht_mask = HT_INIT_SIZE - 1;
|
||||
@@ -165,7 +165,7 @@ hash_lookup(hashtab_T *ht, char_u *key, hash_T hash)
|
||||
for (perturb = hash; ; perturb >>= PERTURB_SHIFT)
|
||||
{
|
||||
#ifdef HT_DEBUG
|
||||
++hash_count_perturb; /* count a "miss" for hashtab lookup */
|
||||
++hash_count_perturb; // count a "miss" for hashtab lookup
|
||||
#endif
|
||||
idx = (unsigned)((idx << 2U) + idx + perturb + 1U);
|
||||
hi = &ht->ht_array[idx & ht->ht_mask];
|
||||
@@ -231,7 +231,7 @@ hash_add_item(
|
||||
char_u *key,
|
||||
hash_T hash)
|
||||
{
|
||||
/* If resizing failed before and it fails again we can't add an item. */
|
||||
// If resizing failed before and it fails again we can't add an item.
|
||||
if (ht->ht_error && hash_may_resize(ht, 0) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
@@ -241,11 +241,11 @@ hash_add_item(
|
||||
hi->hi_key = key;
|
||||
hi->hi_hash = hash;
|
||||
|
||||
/* When the space gets low may resize the array. */
|
||||
// When the space gets low may resize the array.
|
||||
return hash_may_resize(ht, 0);
|
||||
}
|
||||
|
||||
#if 0 /* not used */
|
||||
#if 0 // not used
|
||||
/*
|
||||
* Overwrite hashtable item "hi" with "key". "hi" must point to the item that
|
||||
* is to be overwritten. Thus the number of items in the hashtable doesn't
|
||||
@@ -318,7 +318,7 @@ hash_unlock(hashtab_T *ht)
|
||||
static int
|
||||
hash_may_resize(
|
||||
hashtab_T *ht,
|
||||
int minitems) /* minimal number of items */
|
||||
int minitems) // minimal number of items
|
||||
{
|
||||
hashitem_T temparray[HT_INIT_SIZE];
|
||||
hashitem_T *oldarray, *newarray;
|
||||
@@ -330,7 +330,7 @@ hash_may_resize(
|
||||
long_u newmask;
|
||||
hash_T perturb;
|
||||
|
||||
/* Don't resize a locked table. */
|
||||
// Don't resize a locked table.
|
||||
if (ht->ht_locked > 0)
|
||||
return OK;
|
||||
|
||||
@@ -343,8 +343,8 @@ hash_may_resize(
|
||||
|
||||
if (minitems == 0)
|
||||
{
|
||||
/* Return quickly for small tables with at least two NULL items. NULL
|
||||
* items are required for the lookup to decide a key isn't there. */
|
||||
// Return quickly for small tables with at least two NULL items. NULL
|
||||
// items are required for the lookup to decide a key isn't there.
|
||||
if (ht->ht_filled < HT_INIT_SIZE - 1
|
||||
&& ht->ht_array == ht->ht_smallarray)
|
||||
return OK;
|
||||
@@ -360,9 +360,9 @@ hash_may_resize(
|
||||
return OK;
|
||||
|
||||
if (ht->ht_used > 1000)
|
||||
minsize = ht->ht_used * 2; /* it's big, don't make too much room */
|
||||
minsize = ht->ht_used * 2; // it's big, don't make too much room
|
||||
else
|
||||
minsize = ht->ht_used * 4; /* make plenty of room */
|
||||
minsize = ht->ht_used * 4; // make plenty of room
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -375,20 +375,20 @@ hash_may_resize(
|
||||
newsize = HT_INIT_SIZE;
|
||||
while (newsize < minsize)
|
||||
{
|
||||
newsize <<= 1; /* make sure it's always a power of 2 */
|
||||
newsize <<= 1; // make sure it's always a power of 2
|
||||
if (newsize == 0)
|
||||
return FAIL; /* overflow */
|
||||
return FAIL; // overflow
|
||||
}
|
||||
|
||||
if (newsize == HT_INIT_SIZE)
|
||||
{
|
||||
/* Use the small array inside the hashdict structure. */
|
||||
// Use the small array inside the hashdict structure.
|
||||
newarray = ht->ht_smallarray;
|
||||
if (ht->ht_array == newarray)
|
||||
{
|
||||
/* Moving from ht_smallarray to ht_smallarray! Happens when there
|
||||
* are many removed items. Copy the items to be able to clean up
|
||||
* removed items. */
|
||||
// Moving from ht_smallarray to ht_smallarray! Happens when there
|
||||
// are many removed items. Copy the items to be able to clean up
|
||||
// removed items.
|
||||
mch_memmove(temparray, newarray, sizeof(temparray));
|
||||
oldarray = temparray;
|
||||
}
|
||||
@@ -397,13 +397,13 @@ hash_may_resize(
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Allocate an array. */
|
||||
// Allocate an array.
|
||||
newarray = ALLOC_MULT(hashitem_T, newsize);
|
||||
if (newarray == NULL)
|
||||
{
|
||||
/* Out of memory. When there are NULL items still return OK.
|
||||
* Otherwise set ht_error, because lookup may result in a hang if
|
||||
* we add another item. */
|
||||
// Out of memory. When there are NULL items still return OK.
|
||||
// Otherwise set ht_error, because lookup may result in a hang if
|
||||
// we add another item.
|
||||
if (ht->ht_filled < ht->ht_mask)
|
||||
return OK;
|
||||
ht->ht_error = TRUE;
|
||||
@@ -470,8 +470,8 @@ hash_hash(char_u *key)
|
||||
return (hash_T)0;
|
||||
p = key + 1;
|
||||
|
||||
/* A simplistic algorithm that appears to do very well.
|
||||
* Suggested by George Reilly. */
|
||||
// A simplistic algorithm that appears to do very well.
|
||||
// Suggested by George Reilly.
|
||||
while (*p != NUL)
|
||||
hash = hash * 101 + *p++;
|
||||
|
||||
|
378
src/if_cscope.c
378
src/if_cscope.c
File diff suppressed because it is too large
Load Diff
252
src/if_lua.c
252
src/if_lua.c
@@ -15,8 +15,8 @@
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
/* Only do the following when the feature is enabled. Needed for "make
|
||||
* depend". */
|
||||
// Only do the following when the feature is enabled. Needed for "make
|
||||
// depend".
|
||||
#if defined(FEAT_LUA) || defined(PROTO)
|
||||
|
||||
#define LUAVIM_CHUNKNAME "vim chunk"
|
||||
@@ -45,9 +45,9 @@ static const char LUAVIM_FREE[] = "luaV_free";
|
||||
static const char LUAVIM_LUAEVAL[] = "luaV_luaeval";
|
||||
static const char LUAVIM_SETREF[] = "luaV_setref";
|
||||
|
||||
/* most functions are closures with a cache table as first upvalue;
|
||||
* get/setudata manage references to vim userdata in cache table through
|
||||
* object pointers (light userdata) */
|
||||
// most functions are closures with a cache table as first upvalue;
|
||||
// get/setudata manage references to vim userdata in cache table through
|
||||
// object pointers (light userdata)
|
||||
#define luaV_getudata(L, v) \
|
||||
lua_pushlightuserdata((L), (void *) (v)); \
|
||||
lua_rawget((L), lua_upvalueindex(1))
|
||||
@@ -94,7 +94,7 @@ static luaV_Funcref *luaV_pushfuncref(lua_State *L, char_u *name);
|
||||
# define close_dll FreeLibrary
|
||||
#endif
|
||||
|
||||
/* lauxlib */
|
||||
// lauxlib
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
#define luaL_register dll_luaL_register
|
||||
#define luaL_prepbuffer dll_luaL_prepbuffer
|
||||
@@ -119,7 +119,7 @@ static luaV_Funcref *luaV_pushfuncref(lua_State *L, char_u *name);
|
||||
#define luaL_buffinit dll_luaL_buffinit
|
||||
#define luaL_addlstring dll_luaL_addlstring
|
||||
#define luaL_pushresult dll_luaL_pushresult
|
||||
/* lua */
|
||||
// lua
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
#define lua_tonumber dll_lua_tonumber
|
||||
#define lua_tointeger dll_lua_tointeger
|
||||
@@ -177,7 +177,7 @@ static luaV_Funcref *luaV_pushfuncref(lua_State *L, char_u *name);
|
||||
#define lua_rawseti dll_lua_rawseti
|
||||
#define lua_setmetatable dll_lua_setmetatable
|
||||
#define lua_next dll_lua_next
|
||||
/* libs */
|
||||
// libs
|
||||
#define luaopen_base dll_luaopen_base
|
||||
#define luaopen_table dll_luaopen_table
|
||||
#define luaopen_string dll_luaopen_string
|
||||
@@ -188,7 +188,7 @@ static luaV_Funcref *luaV_pushfuncref(lua_State *L, char_u *name);
|
||||
#define luaopen_debug dll_luaopen_debug
|
||||
#define luaL_openlibs dll_luaL_openlibs
|
||||
|
||||
/* lauxlib */
|
||||
// lauxlib
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
void (*dll_luaL_register) (lua_State *L, const char *libname, const luaL_Reg *l);
|
||||
char *(*dll_luaL_prepbuffer) (luaL_Buffer *B);
|
||||
@@ -213,7 +213,7 @@ lua_State *(*dll_luaL_newstate) (void);
|
||||
void (*dll_luaL_buffinit) (lua_State *L, luaL_Buffer *B);
|
||||
void (*dll_luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
|
||||
void (*dll_luaL_pushresult) (luaL_Buffer *B);
|
||||
/* lua */
|
||||
// lua
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
lua_Number (*dll_lua_tonumber) (lua_State *L, int idx);
|
||||
lua_Integer (*dll_lua_tointeger) (lua_State *L, int idx);
|
||||
@@ -282,7 +282,7 @@ void (*dll_lua_rawseti) (lua_State *L, int idx, lua_Integer n);
|
||||
#endif
|
||||
int (*dll_lua_setmetatable) (lua_State *L, int objindex);
|
||||
int (*dll_lua_next) (lua_State *L, int idx);
|
||||
/* libs */
|
||||
// libs
|
||||
int (*dll_luaopen_base) (lua_State *L);
|
||||
int (*dll_luaopen_table) (lua_State *L);
|
||||
int (*dll_luaopen_string) (lua_State *L);
|
||||
@@ -300,7 +300,7 @@ typedef struct {
|
||||
} luaV_Reg;
|
||||
|
||||
static const luaV_Reg luaV_dll[] = {
|
||||
/* lauxlib */
|
||||
// lauxlib
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
{"luaL_register", (luaV_function) &dll_luaL_register},
|
||||
{"luaL_prepbuffer", (luaV_function) &dll_luaL_prepbuffer},
|
||||
@@ -325,7 +325,7 @@ static const luaV_Reg luaV_dll[] = {
|
||||
{"luaL_buffinit", (luaV_function) &dll_luaL_buffinit},
|
||||
{"luaL_addlstring", (luaV_function) &dll_luaL_addlstring},
|
||||
{"luaL_pushresult", (luaV_function) &dll_luaL_pushresult},
|
||||
/* lua */
|
||||
// lua
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
{"lua_tonumber", (luaV_function) &dll_lua_tonumber},
|
||||
{"lua_tointeger", (luaV_function) &dll_lua_tointeger},
|
||||
@@ -383,7 +383,7 @@ static const luaV_Reg luaV_dll[] = {
|
||||
{"lua_rawseti", (luaV_function) &dll_lua_rawseti},
|
||||
{"lua_setmetatable", (luaV_function) &dll_lua_setmetatable},
|
||||
{"lua_next", (luaV_function) &dll_lua_next},
|
||||
/* libs */
|
||||
// libs
|
||||
{"luaopen_base", (luaV_function) &dll_luaopen_base},
|
||||
{"luaopen_table", (luaV_function) &dll_luaopen_table},
|
||||
{"luaopen_string", (luaV_function) &dll_luaopen_string},
|
||||
@@ -433,7 +433,7 @@ lua_link_init(char *libname, int verbose)
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
#endif /* DYNAMIC_LUA */
|
||||
#endif // DYNAMIC_LUA
|
||||
|
||||
#if defined(DYNAMIC_LUA) || defined(PROTO)
|
||||
int
|
||||
@@ -454,7 +454,7 @@ luaL_typeerror(lua_State *L, int narg, const char *tname)
|
||||
#endif
|
||||
|
||||
|
||||
/* ======= Internal ======= */
|
||||
// ======= Internal =======
|
||||
|
||||
static void
|
||||
luaV_newmetatable(lua_State *L, const char *tname)
|
||||
@@ -470,14 +470,14 @@ luaV_toudata(lua_State *L, int ud, const char *tname)
|
||||
{
|
||||
void *p = lua_touserdata(L, ud);
|
||||
|
||||
if (p != NULL) /* value is userdata? */
|
||||
if (p != 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
|
||||
if (lua_rawequal(L, -1, -2)) // MTs match?
|
||||
{
|
||||
lua_pop(L, 2); /* MTs */
|
||||
lua_pop(L, 2); // MTs
|
||||
return p;
|
||||
}
|
||||
}
|
||||
@@ -643,8 +643,10 @@ luaV_totypval(lua_State *L, int pos, typval_T *tv)
|
||||
return status;
|
||||
}
|
||||
|
||||
/* similar to luaL_addlstring, but replaces \0 with \n if toline and
|
||||
* \n with \0 otherwise */
|
||||
/*
|
||||
* similar to luaL_addlstring, but replaces \0 with \n if toline and
|
||||
* \n with \0 otherwise
|
||||
*/
|
||||
static void
|
||||
luaV_addlstring(luaL_Buffer *b, const char *s, size_t l, int toline)
|
||||
{
|
||||
@@ -683,8 +685,10 @@ luaV_toline(lua_State *L, int pos)
|
||||
return (char_u *) lua_tostring(L, -1);
|
||||
}
|
||||
|
||||
/* pops a string s from the top of the stack and calls mf(t) for pieces t of
|
||||
* s separated by newlines */
|
||||
/*
|
||||
* pops a string s from the top of the stack and calls mf(t) for pieces t of
|
||||
* s separated by newlines
|
||||
*/
|
||||
static void
|
||||
luaV_msgfunc(lua_State *L, msgfunc_T mf)
|
||||
{
|
||||
@@ -694,18 +698,18 @@ luaV_msgfunc(lua_State *L, msgfunc_T mf)
|
||||
luaL_buffinit(L, &b);
|
||||
luaV_addlstring(&b, s, l, 0);
|
||||
luaL_pushresult(&b);
|
||||
/* break string */
|
||||
// break string
|
||||
p = s = lua_tolstring(L, -1, &l);
|
||||
while (l--)
|
||||
{
|
||||
if (*p++ == '\0') /* break? */
|
||||
if (*p++ == '\0') // break?
|
||||
{
|
||||
mf((char_u *) s);
|
||||
s = p;
|
||||
}
|
||||
}
|
||||
mf((char_u *) s);
|
||||
lua_pop(L, 2); /* original and modified strings */
|
||||
lua_pop(L, 2); // original and modified strings
|
||||
}
|
||||
|
||||
#define luaV_newtype(typ,tname,luatyp,luatname) \
|
||||
@@ -748,15 +752,15 @@ luaV_msgfunc(lua_State *L, msgfunc_T mf)
|
||||
return 1; \
|
||||
}
|
||||
|
||||
/* ======= List type ======= */
|
||||
// ======= List type =======
|
||||
|
||||
static luaV_List *
|
||||
luaV_newlist(lua_State *L, list_T *lis)
|
||||
{
|
||||
luaV_List *l = (luaV_List *) lua_newuserdata(L, sizeof(luaV_List));
|
||||
*l = lis;
|
||||
lis->lv_refcount++; /* reference in Lua */
|
||||
luaV_setudata(L, lis); /* cache[lis] = udata */
|
||||
lis->lv_refcount++; // reference in Lua
|
||||
luaV_setudata(L, lis); // cache[lis] = udata
|
||||
luaV_getfield(L, LUAVIM_LIST);
|
||||
lua_setmetatable(L, -2);
|
||||
return l;
|
||||
@@ -788,7 +792,7 @@ luaV_list_iter(lua_State *L)
|
||||
luaV_list_call(lua_State *L)
|
||||
{
|
||||
list_T *l = luaV_unbox(L, luaV_List, 1);
|
||||
lua_pushvalue(L, lua_upvalueindex(1)); /* pass cache table along */
|
||||
lua_pushvalue(L, lua_upvalueindex(1)); // pass cache table along
|
||||
lua_pushlightuserdata(L, (void *) l->lv_first);
|
||||
lua_pushcclosure(L, luaV_list_iter, 2);
|
||||
return 1;
|
||||
@@ -798,7 +802,7 @@ luaV_list_call(lua_State *L)
|
||||
luaV_list_index(lua_State *L)
|
||||
{
|
||||
list_T *l = luaV_unbox(L, luaV_List, 1);
|
||||
if (lua_isnumber(L, 2)) /* list item? */
|
||||
if (lua_isnumber(L, 2)) // list item?
|
||||
{
|
||||
listitem_T *li = list_find(l, (long) luaL_checkinteger(L, 2));
|
||||
if (li == NULL)
|
||||
@@ -806,7 +810,7 @@ luaV_list_index(lua_State *L)
|
||||
else
|
||||
luaV_pushtypval(L, &li->li_tv);
|
||||
}
|
||||
else if (lua_isstring(L, 2)) /* method? */
|
||||
else if (lua_isstring(L, 2)) // method?
|
||||
{
|
||||
const char *s = lua_tostring(L, 2);
|
||||
if (strncmp(s, "add", 3) == 0
|
||||
@@ -833,7 +837,7 @@ luaV_list_newindex(lua_State *L)
|
||||
luaL_error(L, "list is locked");
|
||||
li = list_find(l, n);
|
||||
if (li == NULL) return 0;
|
||||
if (lua_isnil(L, 3)) /* remove? */
|
||||
if (lua_isnil(L, 3)) // remove?
|
||||
{
|
||||
vimlist_remove(l, li, li);
|
||||
clear_tv(&li->li_tv);
|
||||
@@ -904,15 +908,15 @@ static const luaL_Reg luaV_List_mt[] = {
|
||||
};
|
||||
|
||||
|
||||
/* ======= Dict type ======= */
|
||||
// ======= Dict type =======
|
||||
|
||||
static luaV_Dict *
|
||||
luaV_newdict(lua_State *L, dict_T *dic)
|
||||
{
|
||||
luaV_Dict *d = (luaV_Dict *) lua_newuserdata(L, sizeof(luaV_Dict));
|
||||
*d = dic;
|
||||
dic->dv_refcount++; /* reference in Lua */
|
||||
luaV_setudata(L, dic); /* cache[dic] = udata */
|
||||
dic->dv_refcount++; // reference in Lua
|
||||
luaV_setudata(L, dic); // cache[dic] = udata
|
||||
luaV_getfield(L, LUAVIM_DICT);
|
||||
lua_setmetatable(L, -2);
|
||||
return d;
|
||||
@@ -956,9 +960,9 @@ luaV_dict_call(lua_State *L)
|
||||
{
|
||||
dict_T *d = luaV_unbox(L, luaV_Dict, 1);
|
||||
hashtab_T *ht = &d->dv_hashtab;
|
||||
lua_pushvalue(L, lua_upvalueindex(1)); /* pass cache table along */
|
||||
lua_pushvalue(L, lua_upvalueindex(1)); // pass cache table along
|
||||
lua_pushlightuserdata(L, (void *) ht->ht_array);
|
||||
lua_pushinteger(L, ht->ht_used); /* # remaining items */
|
||||
lua_pushinteger(L, ht->ht_used); // # remaining items
|
||||
lua_pushcclosure(L, luaV_dict_iter, 3);
|
||||
return 1;
|
||||
}
|
||||
@@ -975,10 +979,10 @@ luaV_dict_index(lua_State *L)
|
||||
else
|
||||
{
|
||||
luaV_pushtypval(L, &di->di_tv);
|
||||
if (di->di_tv.v_type == VAR_FUNC) /* funcref? */
|
||||
if (di->di_tv.v_type == VAR_FUNC) // funcref?
|
||||
{
|
||||
luaV_Funcref *f = (luaV_Funcref *) lua_touserdata(L, -1);
|
||||
f->self = d; /* keep "self" reference */
|
||||
f->self = d; // keep "self" reference
|
||||
d->dv_refcount++;
|
||||
}
|
||||
}
|
||||
@@ -999,14 +1003,14 @@ luaV_dict_newindex(lua_State *L)
|
||||
return 0;
|
||||
if (*key == NUL)
|
||||
luaL_error(L, "empty key");
|
||||
if (!lua_isnil(L, 3)) /* read value? */
|
||||
if (!lua_isnil(L, 3)) // read value?
|
||||
{
|
||||
luaV_checktypval(L, 3, &v, "setting dict item");
|
||||
if (d->dv_scope == VAR_DEF_SCOPE && v.v_type == VAR_FUNC)
|
||||
luaL_error(L, "cannot assign funcref to builtin scope");
|
||||
}
|
||||
di = dict_find(d, key, -1);
|
||||
if (di == NULL) /* non-existing key? */
|
||||
if (di == NULL) // non-existing key?
|
||||
{
|
||||
if (lua_isnil(L, 3))
|
||||
return 0;
|
||||
@@ -1021,7 +1025,7 @@ luaV_dict_newindex(lua_State *L)
|
||||
}
|
||||
else
|
||||
clear_tv(&di->di_tv);
|
||||
if (lua_isnil(L, 3)) /* remove? */
|
||||
if (lua_isnil(L, 3)) // remove?
|
||||
{
|
||||
hashitem_T *hi = hash_find(&d->dv_hashtab, di->di_key);
|
||||
hash_remove(&d->dv_hashtab, hi);
|
||||
@@ -1045,15 +1049,15 @@ static const luaL_Reg luaV_Dict_mt[] = {
|
||||
};
|
||||
|
||||
|
||||
/* ======= Blob type ======= */
|
||||
// ======= Blob type =======
|
||||
|
||||
static luaV_Blob *
|
||||
luaV_newblob(lua_State *L, blob_T *blo)
|
||||
{
|
||||
luaV_Blob *b = (luaV_Blob *) lua_newuserdata(L, sizeof(luaV_Blob));
|
||||
*b = blo;
|
||||
blo->bv_refcount++; /* reference in Lua */
|
||||
luaV_setudata(L, blo); /* cache[blo] = udata */
|
||||
blo->bv_refcount++; // reference in Lua
|
||||
luaV_setudata(L, blo); // cache[blo] = udata
|
||||
luaV_getfield(L, LUAVIM_BLOB);
|
||||
lua_setmetatable(L, -2);
|
||||
return b;
|
||||
@@ -1163,7 +1167,7 @@ static const luaL_Reg luaV_Blob_mt[] = {
|
||||
};
|
||||
|
||||
|
||||
/* ======= Funcref type ======= */
|
||||
// ======= Funcref type =======
|
||||
|
||||
static luaV_Funcref *
|
||||
luaV_newfuncref(lua_State *L, char_u *name)
|
||||
@@ -1202,7 +1206,7 @@ luaV_funcref_gc(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* equivalent to string(funcref) */
|
||||
// equivalent to string(funcref)
|
||||
static int
|
||||
luaV_funcref_len(lua_State *L)
|
||||
{
|
||||
@@ -1254,7 +1258,7 @@ static const luaL_Reg luaV_Funcref_mt[] = {
|
||||
};
|
||||
|
||||
|
||||
/* ======= Buffer type ======= */
|
||||
// ======= Buffer type =======
|
||||
|
||||
luaV_newtype(buf_T, buffer, luaV_Buffer, LUAVIM_BUFFER)
|
||||
luaV_pushtype(buf_T, buffer, luaV_Buffer)
|
||||
@@ -1295,7 +1299,7 @@ luaV_buffer_index(lua_State *L)
|
||||
? "" : (char *) b->b_ffname);
|
||||
else if (strncmp(s, "number", 6) == 0)
|
||||
lua_pushinteger(L, b->b_fnum);
|
||||
/* methods */
|
||||
// methods
|
||||
else if (strncmp(s, "insert", 6) == 0
|
||||
|| strncmp(s, "next", 4) == 0
|
||||
|| strncmp(s, "previous", 8) == 0
|
||||
@@ -1322,7 +1326,7 @@ luaV_buffer_newindex(lua_State *L)
|
||||
#endif
|
||||
if (n < 1 || n > b->b_ml.ml_line_count)
|
||||
luaL_error(L, "invalid line number");
|
||||
if (lua_isnil(L, 3)) /* delete line */
|
||||
if (lua_isnil(L, 3)) // delete line
|
||||
{
|
||||
buf_T *buf = curbuf;
|
||||
curbuf = b;
|
||||
@@ -1339,7 +1343,7 @@ luaV_buffer_newindex(lua_State *L)
|
||||
else
|
||||
{
|
||||
deleted_lines_mark(n, 1L);
|
||||
if (b == curwin->w_buffer) /* fix cursor in current window? */
|
||||
if (b == curwin->w_buffer) // fix cursor in current window?
|
||||
{
|
||||
if (curwin->w_cursor.lnum >= n)
|
||||
{
|
||||
@@ -1356,7 +1360,7 @@ luaV_buffer_newindex(lua_State *L)
|
||||
}
|
||||
curbuf = buf;
|
||||
}
|
||||
else if (lua_isstring(L, 3)) /* update line */
|
||||
else if (lua_isstring(L, 3)) // update line
|
||||
{
|
||||
buf_T *buf = curbuf;
|
||||
curbuf = b;
|
||||
@@ -1392,10 +1396,10 @@ luaV_buffer_insert(lua_State *L)
|
||||
#ifdef HAVE_SANDBOX
|
||||
luaV_checksandbox(L);
|
||||
#endif
|
||||
/* fix insertion line */
|
||||
// fix insertion line
|
||||
if (n < 0) n = 0;
|
||||
if (n > last) n = last;
|
||||
/* insert */
|
||||
// insert
|
||||
buf = curbuf;
|
||||
curbuf = b;
|
||||
if (u_save(n, n + 1) == FAIL)
|
||||
@@ -1456,7 +1460,7 @@ static const luaL_Reg luaV_Buffer_mt[] = {
|
||||
};
|
||||
|
||||
|
||||
/* ======= Window type ======= */
|
||||
// ======= Window type =======
|
||||
|
||||
luaV_newtype(win_T, window, luaV_Window, LUAVIM_WINDOW)
|
||||
luaV_pushtype(win_T, window, luaV_Window)
|
||||
@@ -1486,7 +1490,7 @@ luaV_window_index(lua_State *L)
|
||||
lua_pushinteger(L, w->w_width);
|
||||
else if (strncmp(s, "height", 6) == 0)
|
||||
lua_pushinteger(L, w->w_height);
|
||||
/* methods */
|
||||
// methods
|
||||
else if (strncmp(s, "next", 4) == 0
|
||||
|| strncmp(s, "previous", 8) == 0
|
||||
|| strncmp(s, "isvalid", 7) == 0)
|
||||
@@ -1588,12 +1592,12 @@ static const luaL_Reg luaV_Window_mt[] = {
|
||||
};
|
||||
|
||||
|
||||
/* ======= Vim module ======= */
|
||||
// ======= Vim module =======
|
||||
|
||||
static int
|
||||
luaV_print(lua_State *L)
|
||||
{
|
||||
int i, n = lua_gettop(L); /* nargs */
|
||||
int i, n = lua_gettop(L); // nargs
|
||||
const char *s;
|
||||
size_t l;
|
||||
luaL_Buffer b;
|
||||
@@ -1601,13 +1605,13 @@ luaV_print(lua_State *L)
|
||||
lua_getglobal(L, "tostring");
|
||||
for (i = 1; i <= n; i++)
|
||||
{
|
||||
lua_pushvalue(L, -1); /* tostring */
|
||||
lua_pushvalue(L, i); /* arg */
|
||||
lua_pushvalue(L, -1); // tostring
|
||||
lua_pushvalue(L, i); // arg
|
||||
lua_call(L, 1, 1);
|
||||
s = lua_tolstring(L, -1, &l);
|
||||
if (s == NULL)
|
||||
return luaL_error(L, "cannot convert to string");
|
||||
if (i > 1) luaL_addchar(&b, ' '); /* use space instead of tab */
|
||||
if (i > 1) luaL_addchar(&b, ' '); // use space instead of tab
|
||||
luaV_addlstring(&b, s, l, 0);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
@@ -1623,22 +1627,22 @@ luaV_debug(lua_State *L)
|
||||
lua_settop(L, 0);
|
||||
lua_getglobal(L, "vim");
|
||||
lua_getfield(L, -1, "eval");
|
||||
lua_remove(L, -2); /* vim.eval at position 1 */
|
||||
lua_remove(L, -2); // vim.eval at position 1
|
||||
for (;;)
|
||||
{
|
||||
const char *input;
|
||||
size_t l;
|
||||
lua_pushvalue(L, 1); /* vim.eval */
|
||||
lua_pushvalue(L, 1); // vim.eval
|
||||
lua_pushliteral(L, "input('lua_debug> ')");
|
||||
lua_call(L, 1, 1); /* return string */
|
||||
lua_call(L, 1, 1); // return string
|
||||
input = lua_tolstring(L, -1, &l);
|
||||
if (l == 0 || strcmp(input, "cont") == 0)
|
||||
return 0;
|
||||
msg_putchar('\n'); /* avoid outputting on input line */
|
||||
msg_putchar('\n'); // avoid outputting on input line
|
||||
if (luaL_loadbuffer(L, input, l, "=(debug command)")
|
||||
|| lua_pcall(L, 0, 0, 0))
|
||||
luaV_emsg(L);
|
||||
lua_settop(L, 1); /* remove eventual returns, but keep vim.eval */
|
||||
lua_settop(L, 1); // remove eventual returns, but keep vim.eval
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1688,7 +1692,7 @@ luaV_list(lua_State *L)
|
||||
else
|
||||
{
|
||||
luaV_newlist(L, l);
|
||||
if (initarg) /* traverse table to init list */
|
||||
if (initarg) // traverse table to init list
|
||||
{
|
||||
int notnil, i = 0;
|
||||
typval_T v;
|
||||
@@ -1702,7 +1706,7 @@ luaV_list(lua_State *L)
|
||||
list_append_tv(l, &v);
|
||||
clear_tv(&v);
|
||||
}
|
||||
lua_pop(L, 1); /* value */
|
||||
lua_pop(L, 1); // value
|
||||
} while (notnil);
|
||||
}
|
||||
}
|
||||
@@ -1723,7 +1727,7 @@ luaV_dict(lua_State *L)
|
||||
else
|
||||
{
|
||||
luaV_newdict(L, d);
|
||||
if (initarg) /* traverse table to init dict */
|
||||
if (initarg) // traverse table to init dict
|
||||
{
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 1))
|
||||
@@ -1732,7 +1736,7 @@ luaV_dict(lua_State *L)
|
||||
dictitem_T *di;
|
||||
typval_T v;
|
||||
|
||||
lua_pushvalue(L, -2); /* dup key in case it's a number */
|
||||
lua_pushvalue(L, -2); // dup key in case it's a number
|
||||
key = (char_u *) lua_tostring(L, -1);
|
||||
if (key == NULL)
|
||||
{
|
||||
@@ -1741,7 +1745,7 @@ luaV_dict(lua_State *L)
|
||||
}
|
||||
if (*key == NUL)
|
||||
luaL_error(L, "table has empty key");
|
||||
luaV_checktypval(L, -2, &v, "vim.dict"); /* value */
|
||||
luaV_checktypval(L, -2, &v, "vim.dict"); // value
|
||||
di = dictitem_alloc(key);
|
||||
if (di == NULL || dict_add(d, di) == FAIL)
|
||||
{
|
||||
@@ -1751,7 +1755,7 @@ luaV_dict(lua_State *L)
|
||||
}
|
||||
copy_tv(&v, &di->di_tv);
|
||||
clear_tv(&v);
|
||||
lua_pop(L, 2); /* key copy and value */
|
||||
lua_pop(L, 2); // key copy and value
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1789,7 +1793,7 @@ luaV_blob(lua_State *L)
|
||||
luaV_funcref(lua_State *L)
|
||||
{
|
||||
const char *name = luaL_checkstring(L, 1);
|
||||
/* note: not checking if function exists (needs function_exists) */
|
||||
// note: not checking if function exists (needs function_exists)
|
||||
if (name == NULL || *name == NUL || VIM_ISDIGIT(*name))
|
||||
luaL_error(L, "invalid function name: %s", name);
|
||||
luaV_newfuncref(L, (char_u *) name);
|
||||
@@ -1800,9 +1804,9 @@ luaV_funcref(lua_State *L)
|
||||
luaV_buffer(lua_State *L)
|
||||
{
|
||||
buf_T *buf;
|
||||
if (lua_isstring(L, 1)) /* get by number or name? */
|
||||
if (lua_isstring(L, 1)) // get by number or name?
|
||||
{
|
||||
if (lua_isnumber(L, 1)) /* by number? */
|
||||
if (lua_isnumber(L, 1)) // by number?
|
||||
{
|
||||
int n = lua_tointeger(L, 1);
|
||||
FOR_ALL_BUFFERS(buf)
|
||||
@@ -1825,7 +1829,7 @@ luaV_buffer(lua_State *L)
|
||||
}
|
||||
}
|
||||
else
|
||||
buf = (lua_toboolean(L, 1)) ? firstbuf : curbuf; /* first buffer? */
|
||||
buf = (lua_toboolean(L, 1)) ? firstbuf : curbuf; // first buffer?
|
||||
luaV_pushbuffer(L, buf);
|
||||
return 1;
|
||||
}
|
||||
@@ -1834,14 +1838,14 @@ luaV_buffer(lua_State *L)
|
||||
luaV_window(lua_State *L)
|
||||
{
|
||||
win_T *win;
|
||||
if (lua_isnumber(L, 1)) /* get by number? */
|
||||
if (lua_isnumber(L, 1)) // get by number?
|
||||
{
|
||||
int n = lua_tointeger(L, 1);
|
||||
for (win = firstwin; win != NULL; win = win->w_next, n--)
|
||||
if (n == 1) break;
|
||||
}
|
||||
else
|
||||
win = (lua_toboolean(L, 1)) ? firstwin : curwin; /* first window? */
|
||||
win = (lua_toboolean(L, 1)) ? firstwin : curwin; // first window?
|
||||
luaV_pushwindow(L, win);
|
||||
return 1;
|
||||
}
|
||||
@@ -1862,7 +1866,7 @@ luaV_open(lua_State *L)
|
||||
luaV_type(lua_State *L)
|
||||
{
|
||||
luaL_checkany(L, 1);
|
||||
if (lua_type(L, 1) == LUA_TUSERDATA) /* check vim udata? */
|
||||
if (lua_type(L, 1) == LUA_TUSERDATA) // check vim udata?
|
||||
{
|
||||
lua_settop(L, 1);
|
||||
if (lua_getmetatable(L, 1))
|
||||
@@ -1905,7 +1909,7 @@ luaV_type(lua_State *L)
|
||||
}
|
||||
}
|
||||
}
|
||||
lua_pushstring(L, luaL_typename(L, 1)); /* fallback */
|
||||
lua_pushstring(L, luaL_typename(L, 1)); // fallback
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1925,7 +1929,9 @@ static const luaL_Reg luaV_module[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/* for freeing list, dict, buffer and window objects; lightuserdata as arg */
|
||||
/*
|
||||
* for freeing list, dict, buffer and window objects; lightuserdata as arg
|
||||
*/
|
||||
static int
|
||||
luaV_free(lua_State *L)
|
||||
{
|
||||
@@ -1947,13 +1953,13 @@ luaV_luaeval(lua_State *L)
|
||||
luaL_addlstring(&b, str, l);
|
||||
luaL_pushresult(&b);
|
||||
str = lua_tolstring(L, -1, &l);
|
||||
if (luaL_loadbuffer(L, str, l, LUAVIM_EVALNAME)) /* compile error? */
|
||||
if (luaL_loadbuffer(L, str, l, LUAVIM_EVALNAME)) // compile error?
|
||||
{
|
||||
luaV_emsg(L);
|
||||
return 0;
|
||||
}
|
||||
luaV_pushtypval(L, arg);
|
||||
if (lua_pcall(L, 1, 1, 0)) /* running error? */
|
||||
if (lua_pcall(L, 1, 1, 0)) // running error?
|
||||
{
|
||||
luaV_emsg(L);
|
||||
return 0;
|
||||
@@ -2004,36 +2010,36 @@ luaV_setref(lua_State *L)
|
||||
static int
|
||||
luaopen_vim(lua_State *L)
|
||||
{
|
||||
/* set cache table */
|
||||
// set cache table
|
||||
lua_newtable(L);
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "v");
|
||||
lua_setfield(L, -2, "__mode");
|
||||
lua_setmetatable(L, -2); /* cache is weak-valued */
|
||||
/* print */
|
||||
lua_setmetatable(L, -2); // cache is weak-valued
|
||||
// print
|
||||
lua_pushcfunction(L, luaV_print);
|
||||
lua_setglobal(L, "print");
|
||||
/* debug.debug */
|
||||
// debug.debug
|
||||
lua_getglobal(L, "debug");
|
||||
lua_pushcfunction(L, luaV_debug);
|
||||
lua_setfield(L, -2, "debug");
|
||||
lua_pop(L, 1);
|
||||
/* free */
|
||||
// free
|
||||
lua_pushlightuserdata(L, (void *) LUAVIM_FREE);
|
||||
lua_pushvalue(L, 1); /* cache table */
|
||||
lua_pushvalue(L, 1); // cache table
|
||||
lua_pushcclosure(L, luaV_free, 1);
|
||||
lua_rawset(L, LUA_REGISTRYINDEX);
|
||||
/* luaeval */
|
||||
// luaeval
|
||||
lua_pushlightuserdata(L, (void *) LUAVIM_LUAEVAL);
|
||||
lua_pushvalue(L, 1); /* cache table */
|
||||
lua_pushvalue(L, 1); // cache table
|
||||
lua_pushcclosure(L, luaV_luaeval, 1);
|
||||
lua_rawset(L, LUA_REGISTRYINDEX);
|
||||
/* setref */
|
||||
// setref
|
||||
lua_pushlightuserdata(L, (void *) LUAVIM_SETREF);
|
||||
lua_pushvalue(L, 1); /* cache table */
|
||||
lua_pushvalue(L, 1); // cache table
|
||||
lua_pushcclosure(L, luaV_setref, 1);
|
||||
lua_rawset(L, LUA_REGISTRYINDEX);
|
||||
/* register */
|
||||
// register
|
||||
luaV_newmetatable(L, LUAVIM_LIST);
|
||||
lua_pushvalue(L, 1);
|
||||
luaV_openlib(L, luaV_List_mt, 1);
|
||||
@@ -2047,13 +2053,13 @@ luaopen_vim(lua_State *L)
|
||||
lua_pushvalue(L, 1);
|
||||
luaV_openlib(L, luaV_Funcref_mt, 1);
|
||||
luaV_newmetatable(L, LUAVIM_BUFFER);
|
||||
lua_pushvalue(L, 1); /* cache table */
|
||||
lua_pushvalue(L, 1); // cache table
|
||||
luaV_openlib(L, luaV_Buffer_mt, 1);
|
||||
luaV_newmetatable(L, LUAVIM_WINDOW);
|
||||
lua_pushvalue(L, 1); /* cache table */
|
||||
lua_pushvalue(L, 1); // cache table
|
||||
luaV_openlib(L, luaV_Window_mt, 1);
|
||||
lua_newtable(L); /* vim table */
|
||||
lua_pushvalue(L, 1); /* cache table */
|
||||
lua_newtable(L); // vim table
|
||||
lua_pushvalue(L, 1); // cache table
|
||||
luaV_openlib(L, luaV_module, 1);
|
||||
lua_setglobal(L, LUAVIM_NAME);
|
||||
return 0;
|
||||
@@ -2063,8 +2069,8 @@ luaopen_vim(lua_State *L)
|
||||
luaV_newstate(void)
|
||||
{
|
||||
lua_State *L = luaL_newstate();
|
||||
luaL_openlibs(L); /* core libs */
|
||||
lua_pushcfunction(L, luaopen_vim); /* vim */
|
||||
luaL_openlibs(L); // core libs
|
||||
lua_pushcfunction(L, luaopen_vim); // vim
|
||||
lua_call(L, 0, 0);
|
||||
return L;
|
||||
}
|
||||
@@ -2077,11 +2083,11 @@ luaV_setrange(lua_State *L, int line1, int line2)
|
||||
lua_setfield(L, -2, "firstline");
|
||||
lua_pushinteger(L, line2);
|
||||
lua_setfield(L, -2, "lastline");
|
||||
lua_pop(L, 1); /* vim table */
|
||||
lua_pop(L, 1); // vim table
|
||||
}
|
||||
|
||||
|
||||
/* ======= Interface ======= */
|
||||
// ======= Interface =======
|
||||
|
||||
static lua_State *L = NULL;
|
||||
|
||||
@@ -2121,7 +2127,9 @@ lua_end(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* ex commands */
|
||||
/*
|
||||
* ex commands
|
||||
*/
|
||||
void
|
||||
ex_lua(exarg_T *eap)
|
||||
{
|
||||
@@ -2156,48 +2164,48 @@ ex_luado(exarg_T *eap)
|
||||
}
|
||||
luaV_setrange(L, eap->line1, eap->line2);
|
||||
luaL_buffinit(L, &b);
|
||||
luaL_addlstring(&b, "return function(line, linenr) ", 30); /* header */
|
||||
luaL_addlstring(&b, "return function(line, linenr) ", 30); // header
|
||||
luaL_addlstring(&b, s, strlen(s));
|
||||
luaL_addlstring(&b, " end", 4); /* footer */
|
||||
luaL_addlstring(&b, " end", 4); // footer
|
||||
luaL_pushresult(&b);
|
||||
s = lua_tolstring(L, -1, &len);
|
||||
if (luaL_loadbuffer(L, s, len, LUAVIM_CHUNKNAME))
|
||||
{
|
||||
luaV_emsg(L);
|
||||
lua_pop(L, 1); /* function body */
|
||||
lua_pop(L, 1); // function body
|
||||
return;
|
||||
}
|
||||
lua_call(L, 0, 1);
|
||||
lua_replace(L, -2); /* function -> body */
|
||||
lua_replace(L, -2); // function -> body
|
||||
for (l = eap->line1; l <= eap->line2; l++)
|
||||
{
|
||||
/* Check the line number, the command my have deleted lines. */
|
||||
// Check the line number, the command my have deleted lines.
|
||||
if (l > curbuf->b_ml.ml_line_count)
|
||||
break;
|
||||
|
||||
lua_pushvalue(L, -1); /* function */
|
||||
luaV_pushline(L, curbuf, l); /* current line as arg */
|
||||
lua_pushinteger(L, l); /* current line number as arg */
|
||||
lua_pushvalue(L, -1); // function
|
||||
luaV_pushline(L, curbuf, l); // current line as arg
|
||||
lua_pushinteger(L, l); // current line number as arg
|
||||
if (lua_pcall(L, 2, 1, 0))
|
||||
{
|
||||
luaV_emsg(L);
|
||||
break;
|
||||
}
|
||||
/* Catch the command switching to another buffer. */
|
||||
// Catch the command switching to another buffer.
|
||||
if (curbuf != was_curbuf)
|
||||
break;
|
||||
if (lua_isstring(L, -1)) /* update line? */
|
||||
if (lua_isstring(L, -1)) // update line?
|
||||
{
|
||||
#ifdef HAVE_SANDBOX
|
||||
luaV_checksandbox(L);
|
||||
#endif
|
||||
ml_replace(l, luaV_toline(L, -1), TRUE);
|
||||
changed_bytes(l, 0);
|
||||
lua_pop(L, 1); /* result from luaV_toline */
|
||||
lua_pop(L, 1); // result from luaV_toline
|
||||
}
|
||||
lua_pop(L, 1); /* line */
|
||||
lua_pop(L, 1); // line
|
||||
}
|
||||
lua_pop(L, 1); /* function */
|
||||
lua_pop(L, 1); // function
|
||||
check_cursor();
|
||||
update_screen(NOT_VALID);
|
||||
}
|
||||
@@ -2247,12 +2255,12 @@ set_ref_in_lua(int copyID)
|
||||
if (lua_isopen())
|
||||
{
|
||||
luaV_getfield(L, LUAVIM_SETREF);
|
||||
/* call the function with 1 arg, getting 1 result back */
|
||||
// call the function with 1 arg, getting 1 result back
|
||||
lua_pushinteger(L, copyID);
|
||||
lua_call(L, 1, 1);
|
||||
/* get the result */
|
||||
// get the result
|
||||
aborted = lua_tointeger(L, -1);
|
||||
/* pop result off the stack */
|
||||
// pop result off the stack
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
return aborted;
|
||||
|
451
src/if_mzsch.c
451
src/if_mzsch.c
File diff suppressed because it is too large
Load Diff
@@ -10,14 +10,14 @@
|
||||
* if_perlsfio.c: Special I/O functions for Perl interface.
|
||||
*/
|
||||
|
||||
#define _memory_h /* avoid memset redeclaration */
|
||||
#define IN_PERL_FILE /* don't include if_perl.pro from prot.h */
|
||||
#define _memory_h // avoid memset redeclaration
|
||||
#define IN_PERL_FILE // don't include if_perl.pro from prot.h
|
||||
|
||||
#include "vim.h"
|
||||
|
||||
#if defined(USE_SFIO) || defined(PROTO)
|
||||
|
||||
#ifndef USE_SFIO /* just generating prototypes */
|
||||
#ifndef USE_SFIO // just generating prototypes
|
||||
# define Sfio_t int
|
||||
# define Sfdisc_t int
|
||||
#endif
|
||||
@@ -26,10 +26,10 @@
|
||||
|
||||
static int
|
||||
sfvimwrite(
|
||||
Sfio_t *f, /* stream involved */
|
||||
char *buf, /* buffer to read from */
|
||||
int n, /* number of bytes to write */
|
||||
Sfdisc_t *disc) /* discipline */
|
||||
Sfio_t *f, // stream involved
|
||||
char *buf, // buffer to read from
|
||||
int n, // number of bytes to write
|
||||
Sfdisc_t *disc) // discipline
|
||||
{
|
||||
char_u *str;
|
||||
|
||||
@@ -63,4 +63,4 @@ sfdcnewvim(void)
|
||||
return disc;
|
||||
}
|
||||
|
||||
#endif /* USE_SFIO */
|
||||
#endif // USE_SFIO
|
||||
|
301
src/if_python.c
301
src/if_python.c
@@ -21,16 +21,15 @@
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
/* uncomment this if used with the debug version of python.
|
||||
* Checked on 2.7.4. */
|
||||
/* #define Py_DEBUG */
|
||||
/* Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting
|
||||
*/
|
||||
/* uncomment this if used with the debug version of python, but without its
|
||||
* allocator */
|
||||
/* #define Py_DEBUG_NO_PYMALLOC */
|
||||
// uncomment this if used with the debug version of python.
|
||||
// Checked on 2.7.4.
|
||||
// #define Py_DEBUG
|
||||
// Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting
|
||||
// uncomment this if used with the debug version of python, but without its
|
||||
// allocator
|
||||
// #define Py_DEBUG_NO_PYMALLOC
|
||||
|
||||
/* Python.h defines _POSIX_THREADS itself (if needed) */
|
||||
// Python.h defines _POSIX_THREADS itself (if needed)
|
||||
#ifdef _POSIX_THREADS
|
||||
# undef _POSIX_THREADS
|
||||
#endif
|
||||
@@ -53,13 +52,13 @@
|
||||
# undef HAVE_PUTENV
|
||||
#endif
|
||||
#ifdef HAVE_STDARG_H
|
||||
# undef HAVE_STDARG_H /* Python's config.h defines it as well. */
|
||||
# undef HAVE_STDARG_H // Python's config.h defines it as well.
|
||||
#endif
|
||||
#ifdef _POSIX_C_SOURCE
|
||||
# undef _POSIX_C_SOURCE /* pyconfig.h defines it as well. */
|
||||
# undef _POSIX_C_SOURCE // pyconfig.h defines it as well.
|
||||
#endif
|
||||
#ifdef _XOPEN_SOURCE
|
||||
# undef _XOPEN_SOURCE /* pyconfig.h defines it as well. */
|
||||
# undef _XOPEN_SOURCE // pyconfig.h defines it as well.
|
||||
#endif
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
@@ -70,8 +69,8 @@
|
||||
# undef PY_SSIZE_T_CLEAN
|
||||
#endif
|
||||
|
||||
#undef main /* Defined in python.h - aargh */
|
||||
#undef HAVE_FCNTL_H /* Clash with os_win32.h */
|
||||
#undef main // Defined in python.h - aargh
|
||||
#undef HAVE_FCNTL_H // Clash with os_win32.h
|
||||
|
||||
// Perhaps leave this out for Python 2.6, which supports bytes?
|
||||
#define PyBytes_FromString PyString_FromString
|
||||
@@ -80,7 +79,7 @@
|
||||
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
|
||||
|
||||
#if !defined(FEAT_PYTHON) && defined(PROTO)
|
||||
/* Use this to be able to generate prototypes without python being used. */
|
||||
// Use this to be able to generate prototypes without python being used.
|
||||
# define PyObject Py_ssize_t
|
||||
# define PyThreadState Py_ssize_t
|
||||
# define PyTypeObject Py_ssize_t
|
||||
@@ -112,19 +111,19 @@ struct PyMethodDef { Py_ssize_t a; };
|
||||
#endif
|
||||
#define Py_bytes_fmt "s"
|
||||
|
||||
/* Parser flags */
|
||||
// Parser flags
|
||||
#define single_input 256
|
||||
#define file_input 257
|
||||
#define eval_input 258
|
||||
|
||||
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x020300F0
|
||||
/* Python 2.3: can invoke ":python" recursively. */
|
||||
// Python 2.3: can invoke ":python" recursively.
|
||||
# define PY_CAN_RECURSE
|
||||
#endif
|
||||
|
||||
#if defined(DYNAMIC_PYTHON) || defined(PROTO)
|
||||
# ifndef DYNAMIC_PYTHON
|
||||
# define HINSTANCE long_u /* for generating prototypes */
|
||||
# define HINSTANCE long_u // for generating prototypes
|
||||
# endif
|
||||
|
||||
# ifndef MSWIN
|
||||
@@ -144,8 +143,8 @@ struct PyMethodDef { Py_ssize_t a; };
|
||||
# define symbol_from_dll GetProcAddress
|
||||
# endif
|
||||
|
||||
/* This makes if_python.c compile without warnings against Python 2.5
|
||||
* on Win32 and Win64. */
|
||||
// This makes if_python.c compile without warnings against Python 2.5
|
||||
// on Win32 and Win64.
|
||||
# undef PyRun_SimpleString
|
||||
# undef PyRun_String
|
||||
# undef PyArg_Parse
|
||||
@@ -456,9 +455,9 @@ static void* (*dll_PyCObject_AsVoidPtr)(PyObject *);
|
||||
static int* dll_Py_NoSiteFlag;
|
||||
# endif
|
||||
|
||||
static HINSTANCE hinstPython = 0; /* Instance of python.dll */
|
||||
static HINSTANCE hinstPython = 0; // Instance of python.dll
|
||||
|
||||
/* Imported exception objects */
|
||||
// Imported exception objects
|
||||
static PyObject *imp_PyExc_AttributeError;
|
||||
static PyObject *imp_PyExc_IndexError;
|
||||
static PyObject *imp_PyExc_KeyError;
|
||||
@@ -681,9 +680,9 @@ python_runtime_link_init(char *libname, int verbose)
|
||||
(PYTHON_PROC*)&py_PyUnicode_AsEncodedString;
|
||||
|
||||
# if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON3)
|
||||
/* Can't have Python and Python3 loaded at the same time.
|
||||
* It cause a crash, because RTLD_GLOBAL is needed for
|
||||
* standard C extension libraries of one or both python versions. */
|
||||
// Can't have Python and Python3 loaded at the same time.
|
||||
// It cause a crash, because RTLD_GLOBAL is needed for
|
||||
// standard C extension libraries of one or both python versions.
|
||||
if (python3_loaded())
|
||||
{
|
||||
if (verbose)
|
||||
@@ -715,8 +714,8 @@ python_runtime_link_init(char *libname, int verbose)
|
||||
}
|
||||
}
|
||||
|
||||
/* Load unicode functions separately as only the ucs2 or the ucs4 functions
|
||||
* will be present in the library. */
|
||||
// Load unicode functions separately as only the ucs2 or the ucs4 functions
|
||||
// will be present in the library.
|
||||
*ucs_as_encoded_string = symbol_from_dll(hinstPython,
|
||||
"PyUnicodeUCS2_AsEncodedString");
|
||||
if (*ucs_as_encoded_string == NULL)
|
||||
@@ -775,7 +774,7 @@ get_exceptions(void)
|
||||
Py_XINCREF(imp_PyExc_OverflowError);
|
||||
Py_XDECREF(exmod);
|
||||
}
|
||||
#endif /* DYNAMIC_PYTHON */
|
||||
#endif // DYNAMIC_PYTHON
|
||||
|
||||
static int initialised = 0;
|
||||
#define PYINITIALISED initialised
|
||||
@@ -830,18 +829,16 @@ typedef PySliceObject PySliceObject_T;
|
||||
#include "if_py_both.h"
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Internal function prototypes.
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// Internal function prototypes.
|
||||
|
||||
static int PythonMod_Init(void);
|
||||
|
||||
|
||||
/******************************************************
|
||||
* 1. Python interpreter main program.
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// 1. Python interpreter main program.
|
||||
|
||||
#if PYTHON_API_VERSION < 1007 /* Python 1.4 */
|
||||
#if PYTHON_API_VERSION < 1007 // Python 1.4
|
||||
typedef PyObject PyThreadState;
|
||||
#endif
|
||||
|
||||
@@ -875,7 +872,7 @@ python_end(void)
|
||||
{
|
||||
static int recurse = 0;
|
||||
|
||||
/* If a crash occurs while doing this, don't try again. */
|
||||
// If a crash occurs while doing this, don't try again.
|
||||
if (recurse != 0)
|
||||
return;
|
||||
|
||||
@@ -888,7 +885,7 @@ python_end(void)
|
||||
# ifdef PY_CAN_RECURSE
|
||||
PyGILState_Ensure();
|
||||
# else
|
||||
Python_RestoreThread(); /* enter python */
|
||||
Python_RestoreThread(); // enter python
|
||||
# endif
|
||||
Py_Finalize();
|
||||
}
|
||||
@@ -899,7 +896,7 @@ python_end(void)
|
||||
# ifdef PY_CAN_RECURSE
|
||||
PyGILState_Ensure();
|
||||
# else
|
||||
Python_RestoreThread(); /* enter python */
|
||||
Python_RestoreThread(); // enter python
|
||||
# endif
|
||||
Py_Finalize();
|
||||
}
|
||||
@@ -937,7 +934,7 @@ Python_Init(void)
|
||||
|
||||
if (*p_pyhome != NUL)
|
||||
{
|
||||
/* The string must not change later, make a copy in static memory. */
|
||||
// The string must not change later, make a copy in static memory.
|
||||
py_home_buf = (char *)vim_strsave(p_pyhome);
|
||||
if (py_home_buf != NULL)
|
||||
Py_SetPythonHome(py_home_buf);
|
||||
@@ -950,15 +947,15 @@ Python_Init(void)
|
||||
init_structs();
|
||||
|
||||
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
|
||||
/* Disable implicit 'import site', because it may cause Vim to exit
|
||||
* when it can't be found. */
|
||||
// Disable implicit 'import site', because it may cause Vim to exit
|
||||
// when it can't be found.
|
||||
Py_NoSiteFlag++;
|
||||
#endif
|
||||
|
||||
Py_Initialize();
|
||||
|
||||
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000
|
||||
/* 'import site' explicitly. */
|
||||
// 'import site' explicitly.
|
||||
site = PyImport_ImportModule("site");
|
||||
if (site == NULL)
|
||||
{
|
||||
@@ -968,10 +965,10 @@ Python_Init(void)
|
||||
Py_DECREF(site);
|
||||
#endif
|
||||
|
||||
/* Initialise threads, and below save the state using
|
||||
* PyEval_SaveThread. Without the call to PyEval_SaveThread, thread
|
||||
* specific state (such as the system trace hook), will be lost
|
||||
* between invocations of Python code. */
|
||||
// Initialise threads, and below save the state using
|
||||
// PyEval_SaveThread. Without the call to PyEval_SaveThread, thread
|
||||
// specific state (such as the system trace hook), will be lost
|
||||
// between invocations of Python code.
|
||||
PyEval_InitThreads();
|
||||
#ifdef DYNAMIC_PYTHON
|
||||
get_exceptions();
|
||||
@@ -985,19 +982,18 @@ Python_Init(void)
|
||||
|
||||
globals = PyModule_GetDict(PyImport_AddModule("__main__"));
|
||||
|
||||
/* Remove the element from sys.path that was added because of our
|
||||
* argv[0] value in PythonMod_Init(). Previously we used an empty
|
||||
* string, but depending on the OS we then get an empty entry or
|
||||
* the current directory in sys.path. */
|
||||
// Remove the element from sys.path that was added because of our
|
||||
// argv[0] value in PythonMod_Init(). Previously we used an empty
|
||||
// string, but depending on the OS we then get an empty entry or
|
||||
// the current directory in sys.path.
|
||||
PyRun_SimpleString("import sys; sys.path = filter(lambda x: x != '/must>not&exist', sys.path)");
|
||||
|
||||
/* lock is created and acquired in PyEval_InitThreads() and thread
|
||||
* state is created in Py_Initialize()
|
||||
* there _PyGILState_NoteThreadState() also sets gilcounter to 1
|
||||
* (python must have threads enabled!)
|
||||
* so the following does both: unlock GIL and save thread state in TLS
|
||||
* without deleting thread state
|
||||
*/
|
||||
// lock is created and acquired in PyEval_InitThreads() and thread
|
||||
// state is created in Py_Initialize()
|
||||
// there _PyGILState_NoteThreadState() also sets gilcounter to 1
|
||||
// (python must have threads enabled!)
|
||||
// so the following does both: unlock GIL and save thread state in TLS
|
||||
// without deleting thread state
|
||||
#ifndef PY_CAN_RECURSE
|
||||
saved_python_thread =
|
||||
#endif
|
||||
@@ -1009,11 +1005,10 @@ Python_Init(void)
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
/* We call PythonIO_Flush() here to print any Python errors.
|
||||
* This is OK, as it is possible to call this function even
|
||||
* if PythonIO_Init_io() has not completed successfully (it will
|
||||
* not do anything in this case).
|
||||
*/
|
||||
// We call PythonIO_Flush() here to print any Python errors.
|
||||
// This is OK, as it is possible to call this function even
|
||||
// if PythonIO_Init_io() has not completed successfully (it will
|
||||
// not do anything in this case).
|
||||
PythonIO_Flush();
|
||||
return -1;
|
||||
}
|
||||
@@ -1050,16 +1045,16 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
|
||||
|
||||
init_range(arg);
|
||||
|
||||
Python_Release_Vim(); /* leave vim */
|
||||
Python_Release_Vim(); // leave Vim
|
||||
|
||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
||||
/* Python only works properly when the LC_NUMERIC locale is "C". */
|
||||
// Python only works properly when the LC_NUMERIC locale is "C".
|
||||
saved_locale = setlocale(LC_NUMERIC, NULL);
|
||||
if (saved_locale == NULL || STRCMP(saved_locale, "C") == 0)
|
||||
saved_locale = NULL;
|
||||
else
|
||||
{
|
||||
/* Need to make a copy, value may change when setting new locale. */
|
||||
// Need to make a copy, value may change when setting new locale.
|
||||
saved_locale = (char *) PY_STRSAVE(saved_locale);
|
||||
(void)setlocale(LC_NUMERIC, "C");
|
||||
}
|
||||
@@ -1068,7 +1063,7 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
|
||||
#ifdef PY_CAN_RECURSE
|
||||
pygilstate = PyGILState_Ensure();
|
||||
#else
|
||||
Python_RestoreThread(); /* enter python */
|
||||
Python_RestoreThread(); // enter python
|
||||
#endif
|
||||
|
||||
run((char *) cmd, arg
|
||||
@@ -1080,7 +1075,7 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
|
||||
#ifdef PY_CAN_RECURSE
|
||||
PyGILState_Release(pygilstate);
|
||||
#else
|
||||
Python_SaveThread(); /* leave python */
|
||||
Python_SaveThread(); // leave python
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
||||
@@ -1091,7 +1086,7 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
|
||||
}
|
||||
#endif
|
||||
|
||||
Python_Lock_Vim(); /* enter vim */
|
||||
Python_Lock_Vim(); // enter vim
|
||||
PythonIO_Flush();
|
||||
|
||||
theend:
|
||||
@@ -1138,17 +1133,16 @@ ex_pyfile(exarg_T *eap)
|
||||
if (p_pyx == 0)
|
||||
p_pyx = 2;
|
||||
|
||||
/* Have to do it like this. PyRun_SimpleFile requires you to pass a
|
||||
* stdio file pointer, but Vim and the Python DLL are compiled with
|
||||
* different options under Windows, meaning that stdio pointers aren't
|
||||
* compatible between the two. Yuk.
|
||||
*
|
||||
* Put the string "execfile('file')" into buffer. But, we need to
|
||||
* escape any backslashes or single quotes in the file name, so that
|
||||
* Python won't mangle the file name.
|
||||
*/
|
||||
// Have to do it like this. PyRun_SimpleFile requires you to pass a
|
||||
// stdio file pointer, but Vim and the Python DLL are compiled with
|
||||
// different options under Windows, meaning that stdio pointers aren't
|
||||
// compatible between the two. Yuk.
|
||||
//
|
||||
// Put the string "execfile('file')" into buffer. But, we need to
|
||||
// escape any backslashes or single quotes in the file name, so that
|
||||
// Python won't mangle the file name.
|
||||
strcpy(buffer, "execfile('");
|
||||
p = buffer + 10; /* size of "execfile('" */
|
||||
p = buffer + 10; // size of "execfile('"
|
||||
|
||||
while (*file && p < buffer + (BUFFER_SIZE - 3))
|
||||
{
|
||||
@@ -1157,16 +1151,16 @@ ex_pyfile(exarg_T *eap)
|
||||
*p++ = *file++;
|
||||
}
|
||||
|
||||
/* If we didn't finish the file name, we hit a buffer overflow */
|
||||
// If we didn't finish the file name, we hit a buffer overflow
|
||||
if (*file != '\0')
|
||||
return;
|
||||
|
||||
/* Put in the terminating "')" and a null */
|
||||
// Put in the terminating "')" and a null
|
||||
*p++ = '\'';
|
||||
*p++ = ')';
|
||||
*p++ = '\0';
|
||||
|
||||
/* Execute the file */
|
||||
// Execute the file
|
||||
DoPyCommand(buffer,
|
||||
(rangeinitializer) init_range_cmd,
|
||||
(runner) run_cmd,
|
||||
@@ -1185,12 +1179,10 @@ ex_pydo(exarg_T *eap)
|
||||
(void *)eap);
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
* 2. Python output stream: writes output via [e]msg().
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// 2. Python output stream: writes output via [e]msg().
|
||||
|
||||
/* Implementation functions
|
||||
*/
|
||||
// Implementation functions
|
||||
|
||||
static PyObject *
|
||||
OutputGetattr(PyObject *self, char *name)
|
||||
@@ -1206,53 +1198,47 @@ OutputGetattr(PyObject *self, char *name)
|
||||
return Py_FindMethod(OutputMethods, self, name);
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
* 3. Implementation of the Vim module for Python
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// 3. Implementation of the Vim module for Python
|
||||
|
||||
/* Window type - Implementation functions
|
||||
* --------------------------------------
|
||||
*/
|
||||
// Window type - Implementation functions
|
||||
// --------------------------------------
|
||||
|
||||
#define WindowType_Check(obj) ((obj)->ob_type == &WindowType)
|
||||
|
||||
/* Buffer type - Implementation functions
|
||||
* --------------------------------------
|
||||
*/
|
||||
// Buffer type - Implementation functions
|
||||
// --------------------------------------
|
||||
|
||||
#define BufferType_Check(obj) ((obj)->ob_type == &BufferType)
|
||||
|
||||
static PyInt BufferAssItem(PyObject *, PyInt, PyObject *);
|
||||
static PyInt BufferAssSlice(PyObject *, PyInt, PyInt, PyObject *);
|
||||
|
||||
/* Line range type - Implementation functions
|
||||
* --------------------------------------
|
||||
*/
|
||||
// Line range type - Implementation functions
|
||||
// --------------------------------------
|
||||
|
||||
#define RangeType_Check(obj) ((obj)->ob_type == &RangeType)
|
||||
|
||||
static PyInt RangeAssItem(PyObject *, PyInt, PyObject *);
|
||||
static PyInt RangeAssSlice(PyObject *, PyInt, PyInt, PyObject *);
|
||||
|
||||
/* Current objects type - Implementation functions
|
||||
* -----------------------------------------------
|
||||
*/
|
||||
// Current objects type - Implementation functions
|
||||
// -----------------------------------------------
|
||||
|
||||
static PySequenceMethods BufferAsSeq = {
|
||||
(PyInquiry) BufferLength, /* sq_length, len(x) */
|
||||
(binaryfunc) 0, /* BufferConcat, sq_concat, x+y */
|
||||
(PyIntArgFunc) 0, /* BufferRepeat, sq_repeat, x*n */
|
||||
(PyIntArgFunc) BufferItem, /* sq_item, x[i] */
|
||||
(PyIntIntArgFunc) BufferSlice, /* sq_slice, x[i:j] */
|
||||
(PyIntObjArgProc) BufferAssItem, /* sq_ass_item, x[i]=v */
|
||||
(PyIntIntObjArgProc) BufferAssSlice, /* sq_ass_slice, x[i:j]=v */
|
||||
(PyInquiry) BufferLength, // sq_length, len(x)
|
||||
(binaryfunc) 0, // BufferConcat, sq_concat, x+y
|
||||
(PyIntArgFunc) 0, // BufferRepeat, sq_repeat, x*n
|
||||
(PyIntArgFunc) BufferItem, // sq_item, x[i]
|
||||
(PyIntIntArgFunc) BufferSlice, // sq_slice, x[i:j]
|
||||
(PyIntObjArgProc) BufferAssItem, // sq_ass_item, x[i]=v
|
||||
(PyIntIntObjArgProc) BufferAssSlice, // sq_ass_slice, x[i:j]=v
|
||||
(objobjproc) 0,
|
||||
(binaryfunc) 0,
|
||||
0,
|
||||
};
|
||||
|
||||
/* Buffer object - Implementation
|
||||
*/
|
||||
// Buffer object - Implementation
|
||||
|
||||
static PyObject *
|
||||
BufferGetattr(PyObject *self, char *name)
|
||||
@@ -1272,7 +1258,7 @@ BufferGetattr(PyObject *self, char *name)
|
||||
return Py_FindMethod(BufferMethods, self, name);
|
||||
}
|
||||
|
||||
/******************/
|
||||
//////////////////
|
||||
|
||||
static PyInt
|
||||
BufferAssItem(PyObject *self, PyInt n, PyObject *val)
|
||||
@@ -1287,13 +1273,13 @@ BufferAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
|
||||
}
|
||||
|
||||
static PySequenceMethods RangeAsSeq = {
|
||||
(PyInquiry) RangeLength, /* sq_length, len(x) */
|
||||
(binaryfunc) 0, /* RangeConcat, */ /* sq_concat, x+y */
|
||||
(PyIntArgFunc) 0, /* RangeRepeat, */ /* sq_repeat, x*n */
|
||||
(PyIntArgFunc) RangeItem, /* sq_item, x[i] */
|
||||
(PyIntIntArgFunc) RangeSlice, /* sq_slice, x[i:j] */
|
||||
(PyIntObjArgProc) RangeAssItem, /* sq_ass_item, x[i]=v */
|
||||
(PyIntIntObjArgProc) RangeAssSlice, /* sq_ass_slice, x[i:j]=v */
|
||||
(PyInquiry) RangeLength, // sq_length, len(x)
|
||||
(binaryfunc) 0, /* RangeConcat, */ // sq_concat, x+y
|
||||
(PyIntArgFunc) 0, /* RangeRepeat, */ // sq_repeat, x*n
|
||||
(PyIntArgFunc) RangeItem, // sq_item, x[i]
|
||||
(PyIntIntArgFunc) RangeSlice, // sq_slice, x[i:j]
|
||||
(PyIntObjArgProc) RangeAssItem, // sq_ass_item, x[i]=v
|
||||
(PyIntIntObjArgProc) RangeAssSlice, // sq_ass_slice, x[i:j]=v
|
||||
(objobjproc) 0,
|
||||
#if PY_MAJOR_VERSION >= 2
|
||||
(binaryfunc) 0,
|
||||
@@ -1301,8 +1287,7 @@ static PySequenceMethods RangeAsSeq = {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Line range object - Implementation
|
||||
*/
|
||||
// Line range object - Implementation
|
||||
|
||||
static PyObject *
|
||||
RangeGetattr(PyObject *self, char *name)
|
||||
@@ -1317,7 +1302,7 @@ RangeGetattr(PyObject *self, char *name)
|
||||
return Py_FindMethod(RangeMethods, self, name);
|
||||
}
|
||||
|
||||
/****************/
|
||||
////////////////
|
||||
|
||||
static PyInt
|
||||
RangeAssItem(PyObject *self, PyInt n, PyObject *val)
|
||||
@@ -1337,8 +1322,7 @@ RangeAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
|
||||
&((RangeObject *)(self))->end);
|
||||
}
|
||||
|
||||
/* TabPage object - Implementation
|
||||
*/
|
||||
// TabPage object - Implementation
|
||||
|
||||
static PyObject *
|
||||
TabPageGetattr(PyObject *self, char *name)
|
||||
@@ -1358,8 +1342,7 @@ TabPageGetattr(PyObject *self, char *name)
|
||||
return Py_FindMethod(TabPageMethods, self, name);
|
||||
}
|
||||
|
||||
/* Window object - Implementation
|
||||
*/
|
||||
// Window object - Implementation
|
||||
|
||||
static PyObject *
|
||||
WindowGetattr(PyObject *self, char *name)
|
||||
@@ -1379,17 +1362,16 @@ WindowGetattr(PyObject *self, char *name)
|
||||
return Py_FindMethod(WindowMethods, self, name);
|
||||
}
|
||||
|
||||
/* Tab page list object - Definitions
|
||||
*/
|
||||
// Tab page list object - Definitions
|
||||
|
||||
static PySequenceMethods TabListAsSeq = {
|
||||
(PyInquiry) TabListLength, /* sq_length, len(x) */
|
||||
(binaryfunc) 0, /* sq_concat, x+y */
|
||||
(PyIntArgFunc) 0, /* sq_repeat, x*n */
|
||||
(PyIntArgFunc) TabListItem, /* sq_item, x[i] */
|
||||
(PyIntIntArgFunc) 0, /* sq_slice, x[i:j] */
|
||||
(PyIntObjArgProc) 0, /* sq_ass_item, x[i]=v */
|
||||
(PyIntIntObjArgProc) 0, /* sq_ass_slice, x[i:j]=v */
|
||||
(PyInquiry) TabListLength, // sq_length, len(x)
|
||||
(binaryfunc) 0, // sq_concat, x+y
|
||||
(PyIntArgFunc) 0, // sq_repeat, x*n
|
||||
(PyIntArgFunc) TabListItem, // sq_item, x[i]
|
||||
(PyIntIntArgFunc) 0, // sq_slice, x[i:j]
|
||||
(PyIntObjArgProc) 0, // sq_ass_item, x[i]=v
|
||||
(PyIntIntObjArgProc) 0, // sq_ass_slice, x[i:j]=v
|
||||
(objobjproc) 0,
|
||||
#if PY_MAJOR_VERSION >= 2
|
||||
(binaryfunc) 0,
|
||||
@@ -1397,17 +1379,16 @@ static PySequenceMethods TabListAsSeq = {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Window list object - Definitions
|
||||
*/
|
||||
// Window list object - Definitions
|
||||
|
||||
static PySequenceMethods WinListAsSeq = {
|
||||
(PyInquiry) WinListLength, /* sq_length, len(x) */
|
||||
(binaryfunc) 0, /* sq_concat, x+y */
|
||||
(PyIntArgFunc) 0, /* sq_repeat, x*n */
|
||||
(PyIntArgFunc) WinListItem, /* sq_item, x[i] */
|
||||
(PyIntIntArgFunc) 0, /* sq_slice, x[i:j] */
|
||||
(PyIntObjArgProc) 0, /* sq_ass_item, x[i]=v */
|
||||
(PyIntIntObjArgProc) 0, /* sq_ass_slice, x[i:j]=v */
|
||||
(PyInquiry) WinListLength, // sq_length, len(x)
|
||||
(binaryfunc) 0, // sq_concat, x+y
|
||||
(PyIntArgFunc) 0, // sq_repeat, x*n
|
||||
(PyIntArgFunc) WinListItem, // sq_item, x[i]
|
||||
(PyIntIntArgFunc) 0, // sq_slice, x[i:j]
|
||||
(PyIntObjArgProc) 0, // sq_ass_item, x[i]=v
|
||||
(PyIntIntObjArgProc) 0, // sq_ass_slice, x[i:j]=v
|
||||
(objobjproc) 0,
|
||||
#if PY_MAJOR_VERSION >= 2
|
||||
(binaryfunc) 0,
|
||||
@@ -1415,8 +1396,7 @@ static PySequenceMethods WinListAsSeq = {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* External interface
|
||||
*/
|
||||
// External interface
|
||||
|
||||
void
|
||||
python_buffer_free(buf_T *buf)
|
||||
@@ -1454,13 +1434,13 @@ python_tabpage_free(tabpage_T *tab)
|
||||
static int
|
||||
PythonMod_Init(void)
|
||||
{
|
||||
/* The special value is removed from sys.path in Python_Init(). */
|
||||
// The special value is removed from sys.path in Python_Init().
|
||||
static char *(argv[2]) = {"/must>not&exist/foo", NULL};
|
||||
|
||||
if (init_types())
|
||||
return -1;
|
||||
|
||||
/* Set sys.argv[] to avoid a crash in warn(). */
|
||||
// Set sys.argv[] to avoid a crash in warn().
|
||||
PySys_SetArgv(1, argv);
|
||||
|
||||
vim_module = Py_InitModule4("vim", VimMethods, (char *)NULL,
|
||||
@@ -1475,15 +1455,13 @@ PythonMod_Init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* 4. Utility functions for handling the interface between Vim and Python.
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 4. Utility functions for handling the interface between Vim and Python.
|
||||
|
||||
/* Convert a Vim line into a Python string.
|
||||
* All internal newlines are replaced by null characters.
|
||||
*
|
||||
* On errors, the Python exception data is set, and NULL is returned.
|
||||
*/
|
||||
// Convert a Vim line into a Python string.
|
||||
// All internal newlines are replaced by null characters.
|
||||
//
|
||||
// On errors, the Python exception data is set, and NULL is returned.
|
||||
static PyObject *
|
||||
LineToString(const char *str)
|
||||
{
|
||||
@@ -1491,10 +1469,9 @@ LineToString(const char *str)
|
||||
PyInt len = strlen(str);
|
||||
char *p;
|
||||
|
||||
/* Allocate an Python string object, with uninitialised contents. We
|
||||
* must do it this way, so that we can modify the string in place
|
||||
* later. See the Python source, Objects/stringobject.c for details.
|
||||
*/
|
||||
// Allocate an Python string object, with uninitialised contents. We
|
||||
// must do it this way, so that we can modify the string in place
|
||||
// later. See the Python source, Objects/stringobject.c for details.
|
||||
result = PyString_FromStringAndSize(NULL, len);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
@@ -1568,8 +1545,8 @@ do_pyeval(char_u *str, typval_T *rettv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't generate a prototype for the next function, it generates an error on
|
||||
* newer Python versions. */
|
||||
// Don't generate a prototype for the next function, it generates an error on
|
||||
// newer Python versions.
|
||||
#if PYTHON_API_VERSION < 1007 /* Python 1.4 */ && !defined(PROTO)
|
||||
|
||||
char *
|
||||
@@ -1577,7 +1554,7 @@ Py_GetProgramName(void)
|
||||
{
|
||||
return "vim";
|
||||
}
|
||||
#endif /* Python 1.4 */
|
||||
#endif // Python 1.4
|
||||
|
||||
int
|
||||
set_ref_in_python(int copyID)
|
||||
|
312
src/if_python3.c
312
src/if_python3.c
@@ -22,13 +22,12 @@
|
||||
* Adaptations to support both python3.x and python2.x
|
||||
*/
|
||||
|
||||
/* uncomment this if used with the debug version of python */
|
||||
/* #define Py_DEBUG */
|
||||
/* Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting
|
||||
*/
|
||||
/* uncomment this if used with the debug version of python, but without its
|
||||
* allocator */
|
||||
/* #define Py_DEBUG_NO_PYMALLOC */
|
||||
// uncomment this if used with the debug version of python
|
||||
// #define Py_DEBUG
|
||||
// Note: most of time you can add -DPy_DEBUG to CFLAGS in place of uncommenting
|
||||
// uncomment this if used with the debug version of python, but without its
|
||||
// allocator
|
||||
// #define Py_DEBUG_NO_PYMALLOC
|
||||
|
||||
#include "vim.h"
|
||||
|
||||
@@ -56,30 +55,30 @@
|
||||
# undef HAVE_PUTENV
|
||||
#endif
|
||||
#ifdef HAVE_STDARG_H
|
||||
# undef HAVE_STDARG_H /* Python's config.h defines it as well. */
|
||||
# undef HAVE_STDARG_H // Python's config.h defines it as well.
|
||||
#endif
|
||||
#ifdef _POSIX_C_SOURCE /* defined in feature.h */
|
||||
#ifdef _POSIX_C_SOURCE // defined in feature.h
|
||||
# undef _POSIX_C_SOURCE
|
||||
#endif
|
||||
#ifdef _XOPEN_SOURCE
|
||||
# undef _XOPEN_SOURCE /* pyconfig.h defines it as well. */
|
||||
# undef _XOPEN_SOURCE // pyconfig.h defines it as well.
|
||||
#endif
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#undef main /* Defined in python.h - aargh */
|
||||
#undef HAVE_FCNTL_H /* Clash with os_win32.h */
|
||||
#undef main // Defined in python.h - aargh
|
||||
#undef HAVE_FCNTL_H // Clash with os_win32.h
|
||||
|
||||
/* The "surrogateescape" error handler is new in Python 3.1 */
|
||||
// The "surrogateescape" error handler is new in Python 3.1
|
||||
#if PY_VERSION_HEX >= 0x030100f0
|
||||
# define CODEC_ERROR_HANDLER "surrogateescape"
|
||||
#else
|
||||
# define CODEC_ERROR_HANDLER NULL
|
||||
#endif
|
||||
|
||||
/* Python 3 does not support CObjects, always use Capsules */
|
||||
// Python 3 does not support CObjects, always use Capsules
|
||||
#define PY_USE_CAPSULE
|
||||
|
||||
#define PyInt Py_ssize_t
|
||||
@@ -432,9 +431,9 @@ static void(*py3_PyObject_GC_Del)(void *);
|
||||
static void(*py3_PyObject_GC_UnTrack)(void *);
|
||||
static int (*py3_PyType_IsSubtype)(PyTypeObject *, PyTypeObject *);
|
||||
|
||||
static HINSTANCE hinstPy3 = 0; /* Instance of python.dll */
|
||||
static HINSTANCE hinstPy3 = 0; // Instance of python.dll
|
||||
|
||||
/* Imported exception objects */
|
||||
// Imported exception objects
|
||||
static PyObject *p3imp_PyExc_AttributeError;
|
||||
static PyObject *p3imp_PyExc_IndexError;
|
||||
static PyObject *p3imp_PyExc_KeyError;
|
||||
@@ -664,9 +663,9 @@ py3_runtime_link_init(char *libname, int verbose)
|
||||
(PYTHON_PROC *)&py3_PyUnicode_AsEncodedString;
|
||||
|
||||
# if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON)
|
||||
/* Can't have Python and Python3 loaded at the same time.
|
||||
* It cause a crash, because RTLD_GLOBAL is needed for
|
||||
* standard C extension libraries of one or both python versions. */
|
||||
// Can't have Python and Python3 loaded at the same time.
|
||||
// It cause a crash, because RTLD_GLOBAL is needed for
|
||||
// standard C extension libraries of one or both python versions.
|
||||
if (python_loaded())
|
||||
{
|
||||
if (verbose)
|
||||
@@ -699,8 +698,8 @@ py3_runtime_link_init(char *libname, int verbose)
|
||||
}
|
||||
}
|
||||
|
||||
/* Load unicode functions separately as only the ucs2 or the ucs4 functions
|
||||
* will be present in the library. */
|
||||
// Load unicode functions separately as only the ucs2 or the ucs4 functions
|
||||
// will be present in the library.
|
||||
# if PY_VERSION_HEX >= 0x030300f0
|
||||
*ucs_from_string = symbol_from_dll(hinstPy3, "PyUnicode_FromString");
|
||||
*ucs_decode = symbol_from_dll(hinstPy3, "PyUnicode_Decode");
|
||||
@@ -746,7 +745,8 @@ python3_enabled(int verbose)
|
||||
return py3_runtime_link_init((char *)p_py3dll, verbose) == OK;
|
||||
}
|
||||
|
||||
/* Load the standard Python exceptions - don't import the symbols from the
|
||||
/*
|
||||
* Load the standard Python exceptions - don't import the symbols from the
|
||||
* DLL, as this can cause errors (importing data symbols is not reliable).
|
||||
*/
|
||||
static void
|
||||
@@ -776,7 +776,7 @@ get_py3_exceptions(void)
|
||||
Py_XINCREF(p3imp_PyExc_OverflowError);
|
||||
Py_XDECREF(exmod);
|
||||
}
|
||||
#endif /* DYNAMIC_PYTHON3 */
|
||||
#endif // DYNAMIC_PYTHON3
|
||||
|
||||
static int py3initialised = 0;
|
||||
#define PYINITIALISED py3initialised
|
||||
@@ -843,22 +843,20 @@ static struct PyModuleDef vimmodule;
|
||||
|
||||
#define PY3OBJ_DELETED(obj) (obj->ob_base.ob_refcnt<=0)
|
||||
|
||||
/******************************************************
|
||||
* Internal function prototypes.
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// Internal function prototypes.
|
||||
|
||||
static PyObject *Py3Init_vim(void);
|
||||
|
||||
/******************************************************
|
||||
* 1. Python interpreter main program.
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// 1. Python interpreter main program.
|
||||
|
||||
void
|
||||
python3_end(void)
|
||||
{
|
||||
static int recurse = 0;
|
||||
|
||||
/* If a crash occurs while doing this, don't try again. */
|
||||
// If a crash occurs while doing this, don't try again.
|
||||
if (recurse != 0)
|
||||
return;
|
||||
|
||||
@@ -870,7 +868,7 @@ python3_end(void)
|
||||
#endif
|
||||
if (Py_IsInitialized())
|
||||
{
|
||||
/* acquire lock before finalizing */
|
||||
// acquire lock before finalizing
|
||||
PyGILState_Ensure();
|
||||
|
||||
Py_Finalize();
|
||||
@@ -912,7 +910,7 @@ Python3_Init(void)
|
||||
{
|
||||
size_t len = mbstowcs(NULL, (char *)p_py3home, 0) + 1;
|
||||
|
||||
/* The string must not change later, make a copy in static memory. */
|
||||
// The string must not change later, make a copy in static memory.
|
||||
py_home_buf = ALLOC_MULT(wchar_t, len);
|
||||
if (py_home_buf != NULL && mbstowcs(
|
||||
py_home_buf, (char *)p_py3home, len) != (size_t)-1)
|
||||
@@ -927,10 +925,10 @@ Python3_Init(void)
|
||||
|
||||
Py_Initialize();
|
||||
|
||||
/* Initialise threads, and below save the state using
|
||||
* PyEval_SaveThread. Without the call to PyEval_SaveThread, thread
|
||||
* specific state (such as the system trace hook), will be lost
|
||||
* between invocations of Python code. */
|
||||
// Initialise threads, and below save the state using
|
||||
// PyEval_SaveThread. Without the call to PyEval_SaveThread, thread
|
||||
// specific state (such as the system trace hook), will be lost
|
||||
// between invocations of Python code.
|
||||
PyEval_InitThreads();
|
||||
#ifdef DYNAMIC_PYTHON3
|
||||
get_py3_exceptions();
|
||||
@@ -941,22 +939,20 @@ Python3_Init(void)
|
||||
|
||||
globals = PyModule_GetDict(PyImport_AddModule("__main__"));
|
||||
|
||||
/* Remove the element from sys.path that was added because of our
|
||||
* argv[0] value in Py3Init_vim(). Previously we used an empty
|
||||
* string, but depending on the OS we then get an empty entry or
|
||||
* the current directory in sys.path.
|
||||
* Only after vim has been imported, the element does exist in
|
||||
* sys.path.
|
||||
*/
|
||||
// Remove the element from sys.path that was added because of our
|
||||
// argv[0] value in Py3Init_vim(). Previously we used an empty
|
||||
// string, but depending on the OS we then get an empty entry or
|
||||
// the current directory in sys.path.
|
||||
// Only after vim has been imported, the element does exist in
|
||||
// sys.path.
|
||||
PyRun_SimpleString("import vim; import sys; sys.path = list(filter(lambda x: not x.endswith('must>not&exist'), sys.path))");
|
||||
|
||||
/* lock is created and acquired in PyEval_InitThreads() and thread
|
||||
* state is created in Py_Initialize()
|
||||
* there _PyGILState_NoteThreadState() also sets gilcounter to 1
|
||||
* (python must have threads enabled!)
|
||||
* so the following does both: unlock GIL and save thread state in TLS
|
||||
* without deleting thread state
|
||||
*/
|
||||
// lock is created and acquired in PyEval_InitThreads() and thread
|
||||
// state is created in Py_Initialize()
|
||||
// there _PyGILState_NoteThreadState() also sets gilcounter to 1
|
||||
// (python must have threads enabled!)
|
||||
// so the following does both: unlock GIL and save thread state in TLS
|
||||
// without deleting thread state
|
||||
PyEval_SaveThread();
|
||||
|
||||
py3initialised = 1;
|
||||
@@ -965,11 +961,10 @@ Python3_Init(void)
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
/* We call PythonIO_Flush() here to print any Python errors.
|
||||
* This is OK, as it is possible to call this function even
|
||||
* if PythonIO_Init_io() has not completed successfully (it will
|
||||
* not do anything in this case).
|
||||
*/
|
||||
// We call PythonIO_Flush() here to print any Python errors.
|
||||
// This is OK, as it is possible to call this function even
|
||||
// if PythonIO_Init_io() has not completed successfully (it will
|
||||
// not do anything in this case).
|
||||
PythonIO_Flush();
|
||||
return -1;
|
||||
}
|
||||
@@ -995,16 +990,16 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
|
||||
|
||||
init_range(arg);
|
||||
|
||||
Python_Release_Vim(); /* leave vim */
|
||||
Python_Release_Vim(); // leave Vim
|
||||
|
||||
#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
|
||||
/* Python only works properly when the LC_NUMERIC locale is "C". */
|
||||
// Python only works properly when the LC_NUMERIC locale is "C".
|
||||
saved_locale = setlocale(LC_NUMERIC, NULL);
|
||||
if (saved_locale == NULL || STRCMP(saved_locale, "C") == 0)
|
||||
saved_locale = NULL;
|
||||
else
|
||||
{
|
||||
/* Need to make a copy, value may change when setting new locale. */
|
||||
// Need to make a copy, value may change when setting new locale.
|
||||
saved_locale = (char *)vim_strsave((char_u *)saved_locale);
|
||||
(void)setlocale(LC_NUMERIC, "C");
|
||||
}
|
||||
@@ -1012,8 +1007,8 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
|
||||
|
||||
pygilstate = PyGILState_Ensure();
|
||||
|
||||
/* PyRun_SimpleString expects a UTF-8 string. Wrong encoding may cause
|
||||
* SyntaxError (unicode error). */
|
||||
// PyRun_SimpleString expects a UTF-8 string. Wrong encoding may cause
|
||||
// SyntaxError (unicode error).
|
||||
cmdstr = PyUnicode_Decode(cmd, strlen(cmd),
|
||||
(char *)ENC_OPT, CODEC_ERROR_HANDLER);
|
||||
cmdbytes = PyUnicode_AsEncodedString(cmdstr, "utf-8", CODEC_ERROR_HANDLER);
|
||||
@@ -1032,11 +1027,11 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
|
||||
}
|
||||
#endif
|
||||
|
||||
Python_Lock_Vim(); /* enter vim */
|
||||
Python_Lock_Vim(); // enter Vim
|
||||
PythonIO_Flush();
|
||||
|
||||
theend:
|
||||
return; /* keeps lint happy */
|
||||
return; // keeps lint happy
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1077,22 +1072,21 @@ ex_py3file(exarg_T *eap)
|
||||
if (p_pyx == 0)
|
||||
p_pyx = 3;
|
||||
|
||||
/* Have to do it like this. PyRun_SimpleFile requires you to pass a
|
||||
* stdio file pointer, but Vim and the Python DLL are compiled with
|
||||
* different options under Windows, meaning that stdio pointers aren't
|
||||
* compatible between the two. Yuk.
|
||||
*
|
||||
* construct: exec(compile(open('a_filename', 'rb').read(), 'a_filename', 'exec'))
|
||||
*
|
||||
* Using bytes so that Python can detect the source encoding as it normally
|
||||
* does. The doc does not say "compile" accept bytes, though.
|
||||
*
|
||||
* We need to escape any backslashes or single quotes in the file name, so that
|
||||
* Python won't mangle the file name.
|
||||
*/
|
||||
// Have to do it like this. PyRun_SimpleFile requires you to pass a
|
||||
// stdio file pointer, but Vim and the Python DLL are compiled with
|
||||
// different options under Windows, meaning that stdio pointers aren't
|
||||
// compatible between the two. Yuk.
|
||||
//
|
||||
// construct: exec(compile(open('a_filename', 'rb').read(), 'a_filename', 'exec'))
|
||||
//
|
||||
// Using bytes so that Python can detect the source encoding as it normally
|
||||
// does. The doc does not say "compile" accept bytes, though.
|
||||
//
|
||||
// We need to escape any backslashes or single quotes in the file name, so that
|
||||
// Python won't mangle the file name.
|
||||
|
||||
strcpy(buffer, "exec(compile(open('");
|
||||
p = buffer + 19; /* size of "exec(compile(open('" */
|
||||
p = buffer + 19; // size of "exec(compile(open('"
|
||||
|
||||
for (i=0; i<2; ++i)
|
||||
{
|
||||
@@ -1103,7 +1097,7 @@ ex_py3file(exarg_T *eap)
|
||||
*p++ = '\\';
|
||||
*p++ = *file++;
|
||||
}
|
||||
/* If we didn't finish the file name, we hit a buffer overflow */
|
||||
// If we didn't finish the file name, we hit a buffer overflow
|
||||
if (*file != '\0')
|
||||
return;
|
||||
if (i==0)
|
||||
@@ -1119,7 +1113,7 @@ ex_py3file(exarg_T *eap)
|
||||
}
|
||||
|
||||
|
||||
/* Execute the file */
|
||||
// Execute the file
|
||||
DoPyCommand(buffer,
|
||||
(rangeinitializer) init_range_cmd,
|
||||
(runner) run_cmd,
|
||||
@@ -1138,12 +1132,10 @@ ex_py3do(exarg_T *eap)
|
||||
(void *)eap);
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
* 2. Python output stream: writes output via [e]msg().
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// 2. Python output stream: writes output via [e]msg().
|
||||
|
||||
/* Implementation functions
|
||||
*/
|
||||
// Implementation functions
|
||||
|
||||
static PyObject *
|
||||
OutputGetattro(PyObject *self, PyObject *nameobj)
|
||||
@@ -1168,28 +1160,24 @@ OutputSetattro(PyObject *self, PyObject *nameobj, PyObject *val)
|
||||
return OutputSetattr((OutputObject *)(self), name, val);
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
* 3. Implementation of the Vim module for Python
|
||||
*/
|
||||
///////////////////////////////////////////////////////
|
||||
// 3. Implementation of the Vim module for Python
|
||||
|
||||
/* Window type - Implementation functions
|
||||
* --------------------------------------
|
||||
*/
|
||||
// Window type - Implementation functions
|
||||
// --------------------------------------
|
||||
|
||||
#define WindowType_Check(obj) ((obj)->ob_base.ob_type == &WindowType)
|
||||
|
||||
/* Buffer type - Implementation functions
|
||||
* --------------------------------------
|
||||
*/
|
||||
// Buffer type - Implementation functions
|
||||
// --------------------------------------
|
||||
|
||||
#define BufferType_Check(obj) ((obj)->ob_base.ob_type == &BufferType)
|
||||
|
||||
static PyObject* BufferSubscript(PyObject *self, PyObject *idx);
|
||||
static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
|
||||
|
||||
/* Line range type - Implementation functions
|
||||
* --------------------------------------
|
||||
*/
|
||||
// Line range type - Implementation functions
|
||||
// --------------------------------------
|
||||
|
||||
#define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType)
|
||||
|
||||
@@ -1197,21 +1185,20 @@ static PyObject* RangeSubscript(PyObject *self, PyObject *idx);
|
||||
static Py_ssize_t RangeAsItem(PyObject *, Py_ssize_t, PyObject *);
|
||||
static Py_ssize_t RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
|
||||
|
||||
/* Current objects type - Implementation functions
|
||||
* -----------------------------------------------
|
||||
*/
|
||||
// Current objects type - Implementation functions
|
||||
// -----------------------------------------------
|
||||
|
||||
static PySequenceMethods BufferAsSeq = {
|
||||
(lenfunc) BufferLength, /* sq_length, len(x) */
|
||||
(binaryfunc) 0, /* sq_concat, x+y */
|
||||
(ssizeargfunc) 0, /* sq_repeat, x*n */
|
||||
(ssizeargfunc) BufferItem, /* sq_item, x[i] */
|
||||
0, /* was_sq_slice, x[i:j] */
|
||||
0, /* sq_ass_item, x[i]=v */
|
||||
0, /* sq_ass_slice, x[i:j]=v */
|
||||
0, /* sq_contains */
|
||||
0, /* sq_inplace_concat */
|
||||
0, /* sq_inplace_repeat */
|
||||
(lenfunc) BufferLength, // sq_length, len(x)
|
||||
(binaryfunc) 0, // sq_concat, x+y
|
||||
(ssizeargfunc) 0, // sq_repeat, x*n
|
||||
(ssizeargfunc) BufferItem, // sq_item, x[i]
|
||||
0, // was_sq_slice, x[i:j]
|
||||
0, // sq_ass_item, x[i]=v
|
||||
0, // sq_ass_slice, x[i:j]=v
|
||||
0, // sq_contains
|
||||
0, // sq_inplace_concat
|
||||
0, // sq_inplace_repeat
|
||||
};
|
||||
|
||||
static PyMappingMethods BufferAsMapping = {
|
||||
@@ -1221,8 +1208,7 @@ static PyMappingMethods BufferAsMapping = {
|
||||
};
|
||||
|
||||
|
||||
/* Buffer object
|
||||
*/
|
||||
// Buffer object
|
||||
|
||||
static PyObject *
|
||||
BufferGetattro(PyObject *self, PyObject *nameobj)
|
||||
@@ -1252,7 +1238,7 @@ BufferSetattro(PyObject *self, PyObject *nameobj, PyObject *val)
|
||||
return BufferSetattr((BufferObject *)(self), name, val);
|
||||
}
|
||||
|
||||
/******************/
|
||||
//////////////////
|
||||
|
||||
static PyObject *
|
||||
BufferSubscript(PyObject *self, PyObject* idx)
|
||||
@@ -1315,16 +1301,16 @@ BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val)
|
||||
}
|
||||
|
||||
static PySequenceMethods RangeAsSeq = {
|
||||
(lenfunc) RangeLength, /* sq_length, len(x) */
|
||||
(binaryfunc) 0, /* RangeConcat, sq_concat, x+y */
|
||||
(ssizeargfunc) 0, /* RangeRepeat, sq_repeat, x*n */
|
||||
(ssizeargfunc) RangeItem, /* sq_item, x[i] */
|
||||
0, /* was_sq_slice, x[i:j] */
|
||||
(ssizeobjargproc) RangeAsItem, /* sq_as_item, x[i]=v */
|
||||
0, /* sq_ass_slice, x[i:j]=v */
|
||||
0, /* sq_contains */
|
||||
0, /* sq_inplace_concat */
|
||||
0, /* sq_inplace_repeat */
|
||||
(lenfunc) RangeLength, // sq_length, len(x)
|
||||
(binaryfunc) 0, // RangeConcat, sq_concat, x+y
|
||||
(ssizeargfunc) 0, // RangeRepeat, sq_repeat, x*n
|
||||
(ssizeargfunc) RangeItem, // sq_item, x[i]
|
||||
0, // was_sq_slice, x[i:j]
|
||||
(ssizeobjargproc) RangeAsItem, // sq_as_item, x[i]=v
|
||||
0, // sq_ass_slice, x[i:j]=v
|
||||
0, // sq_contains
|
||||
0, // sq_inplace_concat
|
||||
0, // sq_inplace_repeat
|
||||
};
|
||||
|
||||
static PyMappingMethods RangeAsMapping = {
|
||||
@@ -1333,8 +1319,7 @@ static PyMappingMethods RangeAsMapping = {
|
||||
/* mp_ass_subscript */ (objobjargproc)RangeAsSubscript,
|
||||
};
|
||||
|
||||
/* Line range object - Implementation
|
||||
*/
|
||||
// Line range object - Implementation
|
||||
|
||||
static PyObject *
|
||||
RangeGetattro(PyObject *self, PyObject *nameobj)
|
||||
@@ -1349,7 +1334,7 @@ RangeGetattro(PyObject *self, PyObject *nameobj)
|
||||
return PyObject_GenericGetAttr(self, nameobj);
|
||||
}
|
||||
|
||||
/****************/
|
||||
////////////////
|
||||
|
||||
static Py_ssize_t
|
||||
RangeAsItem(PyObject *self, Py_ssize_t n, PyObject *val)
|
||||
@@ -1420,8 +1405,7 @@ RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val)
|
||||
}
|
||||
}
|
||||
|
||||
/* TabPage object - Implementation
|
||||
*/
|
||||
// TabPage object - Implementation
|
||||
|
||||
static PyObject *
|
||||
TabPageGetattro(PyObject *self, PyObject *nameobj)
|
||||
@@ -1443,8 +1427,7 @@ TabPageGetattro(PyObject *self, PyObject *nameobj)
|
||||
return PyObject_GenericGetAttr(self, nameobj);
|
||||
}
|
||||
|
||||
/* Window object - Implementation
|
||||
*/
|
||||
// Window object - Implementation
|
||||
|
||||
static PyObject *
|
||||
WindowGetattro(PyObject *self, PyObject *nameobj)
|
||||
@@ -1474,39 +1457,38 @@ WindowSetattro(PyObject *self, PyObject *nameobj, PyObject *val)
|
||||
return WindowSetattr((WindowObject *)(self), name, val);
|
||||
}
|
||||
|
||||
/* Tab page list object - Definitions
|
||||
*/
|
||||
// Tab page list object - Definitions
|
||||
|
||||
static PySequenceMethods TabListAsSeq = {
|
||||
(lenfunc) TabListLength, /* sq_length, len(x) */
|
||||
(binaryfunc) 0, /* sq_concat, x+y */
|
||||
(ssizeargfunc) 0, /* sq_repeat, x*n */
|
||||
(ssizeargfunc) TabListItem, /* sq_item, x[i] */
|
||||
0, /* sq_slice, x[i:j] */
|
||||
(ssizeobjargproc)0, /* sq_as_item, x[i]=v */
|
||||
0, /* sq_ass_slice, x[i:j]=v */
|
||||
0, /* sq_contains */
|
||||
0, /* sq_inplace_concat */
|
||||
0, /* sq_inplace_repeat */
|
||||
(lenfunc) TabListLength, // sq_length, len(x)
|
||||
(binaryfunc) 0, // sq_concat, x+y
|
||||
(ssizeargfunc) 0, // sq_repeat, x*n
|
||||
(ssizeargfunc) TabListItem, // sq_item, x[i]
|
||||
0, // sq_slice, x[i:j]
|
||||
(ssizeobjargproc)0, // sq_as_item, x[i]=v
|
||||
0, // sq_ass_slice, x[i:j]=v
|
||||
0, // sq_contains
|
||||
0, // sq_inplace_concat
|
||||
0, // sq_inplace_repeat
|
||||
};
|
||||
|
||||
/* Window list object - Definitions
|
||||
*/
|
||||
// Window list object - Definitions
|
||||
|
||||
static PySequenceMethods WinListAsSeq = {
|
||||
(lenfunc) WinListLength, /* sq_length, len(x) */
|
||||
(binaryfunc) 0, /* sq_concat, x+y */
|
||||
(ssizeargfunc) 0, /* sq_repeat, x*n */
|
||||
(ssizeargfunc) WinListItem, /* sq_item, x[i] */
|
||||
0, /* sq_slice, x[i:j] */
|
||||
(ssizeobjargproc)0, /* sq_as_item, x[i]=v */
|
||||
0, /* sq_ass_slice, x[i:j]=v */
|
||||
0, /* sq_contains */
|
||||
0, /* sq_inplace_concat */
|
||||
0, /* sq_inplace_repeat */
|
||||
(lenfunc) WinListLength, // sq_length, len(x)
|
||||
(binaryfunc) 0, // sq_concat, x+y
|
||||
(ssizeargfunc) 0, // sq_repeat, x*n
|
||||
(ssizeargfunc) WinListItem, // sq_item, x[i]
|
||||
0, // sq_slice, x[i:j]
|
||||
(ssizeobjargproc)0, // sq_as_item, x[i]=v
|
||||
0, // sq_ass_slice, x[i:j]=v
|
||||
0, // sq_contains
|
||||
0, // sq_inplace_concat
|
||||
0, // sq_inplace_repeat
|
||||
};
|
||||
|
||||
/* Current items object - Implementation
|
||||
/*
|
||||
* Current items object - Implementation
|
||||
*/
|
||||
static PyObject *
|
||||
CurrentGetattro(PyObject *self, PyObject *nameobj)
|
||||
@@ -1525,8 +1507,7 @@ CurrentSetattro(PyObject *self, PyObject *nameobj, PyObject *value)
|
||||
return CurrentSetattr(self, name, value);
|
||||
}
|
||||
|
||||
/* Dictionary object - Definitions
|
||||
*/
|
||||
// Dictionary object - Definitions
|
||||
|
||||
static PyObject *
|
||||
DictionaryGetattro(PyObject *self, PyObject *nameobj)
|
||||
@@ -1550,8 +1531,7 @@ DictionarySetattro(PyObject *self, PyObject *nameobj, PyObject *val)
|
||||
return DictionarySetattr((DictionaryObject *)(self), name, val);
|
||||
}
|
||||
|
||||
/* List object - Definitions
|
||||
*/
|
||||
// List object - Definitions
|
||||
|
||||
static PyObject *
|
||||
ListGetattro(PyObject *self, PyObject *nameobj)
|
||||
@@ -1571,8 +1551,7 @@ ListSetattro(PyObject *self, PyObject *nameobj, PyObject *val)
|
||||
return ListSetattr((ListObject *)(self), name, val);
|
||||
}
|
||||
|
||||
/* Function object - Definitions
|
||||
*/
|
||||
// Function object - Definitions
|
||||
|
||||
static PyObject *
|
||||
FunctionGetattro(PyObject *self, PyObject *nameobj)
|
||||
@@ -1589,8 +1568,7 @@ FunctionGetattro(PyObject *self, PyObject *nameobj)
|
||||
return PyObject_GenericGetAttr(self, nameobj);
|
||||
}
|
||||
|
||||
/* External interface
|
||||
*/
|
||||
// External interface
|
||||
|
||||
void
|
||||
python3_buffer_free(buf_T *buf)
|
||||
@@ -1628,13 +1606,13 @@ python3_tabpage_free(tabpage_T *tab)
|
||||
static PyObject *
|
||||
Py3Init_vim(void)
|
||||
{
|
||||
/* The special value is removed from sys.path in Python3_Init(). */
|
||||
// The special value is removed from sys.path in Python3_Init().
|
||||
static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL};
|
||||
|
||||
if (init_types())
|
||||
return NULL;
|
||||
|
||||
/* Set sys.argv[] to avoid a crash in warn(). */
|
||||
// Set sys.argv[] to avoid a crash in warn().
|
||||
PySys_SetArgv(1, argv);
|
||||
|
||||
if ((vim_module = PyModule_Create(&vimmodule)) == NULL)
|
||||
@@ -1649,11 +1627,11 @@ Py3Init_vim(void)
|
||||
return vim_module;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* 4. Utility functions for handling the interface between Vim and Python.
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 4. Utility functions for handling the interface between Vim and Python.
|
||||
|
||||
/* Convert a Vim line into a Python string.
|
||||
/*
|
||||
* Convert a Vim line into a Python string.
|
||||
* All internal newlines are replaced by null characters.
|
||||
*
|
||||
* On errors, the Python exception data is set, and NULL is returned.
|
||||
|
@@ -24,7 +24,7 @@
|
||||
# define NT
|
||||
# endif
|
||||
# ifndef DYNAMIC_RUBY
|
||||
# define IMPORT /* For static dll usage __declspec(dllimport) */
|
||||
# define IMPORT // For static dll usage __declspec(dllimport)
|
||||
# define RUBYEXTERN __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
@@ -87,23 +87,23 @@
|
||||
#endif
|
||||
|
||||
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19
|
||||
/* Ruby 1.9 defines a number of static functions which use rb_num2long and
|
||||
* rb_int2big */
|
||||
// Ruby 1.9 defines a number of static functions which use rb_num2long and
|
||||
// rb_int2big
|
||||
# define rb_num2long rb_num2long_stub
|
||||
# define rb_int2big rb_int2big_stub
|
||||
#endif
|
||||
|
||||
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 19 \
|
||||
&& VIM_SIZEOF_INT < VIM_SIZEOF_LONG
|
||||
/* Ruby 1.9 defines a number of static functions which use rb_fix2int and
|
||||
* rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit) */
|
||||
// Ruby 1.9 defines a number of static functions which use rb_fix2int and
|
||||
// rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit)
|
||||
# define rb_fix2int rb_fix2int_stub
|
||||
# define rb_num2int rb_num2int_stub
|
||||
#endif
|
||||
|
||||
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21
|
||||
/* Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses
|
||||
* rb_gc_writebarrier_unprotect_promoted if USE_RGENGC */
|
||||
// Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses
|
||||
// rb_gc_writebarrier_unprotect_promoted if USE_RGENGC
|
||||
# define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub
|
||||
#endif
|
||||
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 22
|
||||
@@ -126,7 +126,7 @@
|
||||
#undef EXTERN
|
||||
#undef _
|
||||
|
||||
/* T_DATA defined both by Ruby and Mac header files, hack around it... */
|
||||
// T_DATA defined both by Ruby and Mac header files, hack around it...
|
||||
#if defined(MACOS_X)
|
||||
# define __OPENTRANSPORT__
|
||||
# define __OPENTRANSPORTPROTOCOL__
|
||||
@@ -189,7 +189,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(PROTO) && !defined(FEAT_RUBY)
|
||||
/* Define these to be able to generate the function prototypes. */
|
||||
// Define these to be able to generate the function prototypes.
|
||||
# define VALUE int
|
||||
# define RUBY_DATA_FUNC int
|
||||
#endif
|
||||
@@ -218,7 +218,7 @@ static int ruby_convert_to_vim_value(VALUE val, typval_T *rettv);
|
||||
|
||||
#if defined(DYNAMIC_RUBY) || defined(PROTO)
|
||||
# if defined(PROTO) && !defined(HINSTANCE)
|
||||
# define HINSTANCE int /* for generating prototypes */
|
||||
# define HINSTANCE int // for generating prototypes
|
||||
# endif
|
||||
|
||||
/*
|
||||
@@ -273,7 +273,7 @@ static int ruby_convert_to_vim_value(VALUE val, typval_T *rettv);
|
||||
# undef rb_intern
|
||||
# define rb_intern dll_rb_intern
|
||||
|
||||
# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */
|
||||
# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG // 64 bits only
|
||||
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 18
|
||||
# define rb_fix2int dll_rb_fix2int
|
||||
# define rb_num2int dll_rb_num2int
|
||||
@@ -300,10 +300,10 @@ static int ruby_convert_to_vim_value(VALUE val, typval_T *rettv);
|
||||
# undef rb_str_new
|
||||
# define rb_str_new dll_rb_str_new
|
||||
# ifdef rb_str_new2
|
||||
/* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */
|
||||
// Ruby may #define rb_str_new2 to use rb_str_new_cstr.
|
||||
# define need_rb_str_new_cstr 1
|
||||
/* Ruby's headers #define rb_str_new_cstr to make use of GCC's
|
||||
* __builtin_constant_p extension. */
|
||||
// Ruby's headers #define rb_str_new_cstr to make use of GCC's
|
||||
// __builtin_constant_p extension.
|
||||
# undef rb_str_new_cstr
|
||||
# define rb_str_new_cstr dll_rb_str_new_cstr
|
||||
# else
|
||||
@@ -420,7 +420,7 @@ static VALUE (*dll_rb_hash_new) (void);
|
||||
static VALUE (*dll_rb_inspect) (VALUE);
|
||||
static VALUE (*dll_rb_int2inum) (long);
|
||||
static ID (*dll_rb_intern) (const char*);
|
||||
# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */
|
||||
# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG // 64 bits only
|
||||
static long (*dll_rb_fix2int) (VALUE);
|
||||
static long (*dll_rb_num2int) (VALUE);
|
||||
static unsigned long (*dll_rb_num2uint) (VALUE);
|
||||
@@ -445,7 +445,7 @@ static VALUE (*dll_rb_str_cat) (VALUE, const char*, long);
|
||||
static VALUE (*dll_rb_str_concat) (VALUE, VALUE);
|
||||
static VALUE (*dll_rb_str_new) (const char*, long);
|
||||
# ifdef need_rb_str_new_cstr
|
||||
/* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */
|
||||
// Ruby may #define rb_str_new2 to use rb_str_new_cstr.
|
||||
static VALUE (*dll_rb_str_new_cstr) (const char*);
|
||||
# else
|
||||
static VALUE (*dll_rb_str_new2) (const char*);
|
||||
@@ -560,7 +560,7 @@ rb_num2ulong(VALUE x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Do not generate a prototype here, VALUE isn't always defined. */
|
||||
// Do not generate a prototype here, VALUE isn't always defined.
|
||||
# if defined(USE_RGENGC) && USE_RGENGC && !defined(PROTO)
|
||||
# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER == 21
|
||||
void
|
||||
@@ -585,7 +585,7 @@ rb_ary_detransient_stub(VALUE x)
|
||||
}
|
||||
# endif
|
||||
|
||||
static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */
|
||||
static HINSTANCE hinstRuby = NULL; // Instance of ruby.dll
|
||||
|
||||
/*
|
||||
* Table of name to function pointer of ruby.
|
||||
@@ -653,7 +653,7 @@ static struct
|
||||
{"rb_inspect", (RUBY_PROC*)&dll_rb_inspect},
|
||||
{"rb_int2inum", (RUBY_PROC*)&dll_rb_int2inum},
|
||||
{"rb_intern", (RUBY_PROC*)&dll_rb_intern},
|
||||
# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG /* 64 bits only */
|
||||
# if VIM_SIZEOF_INT < VIM_SIZEOF_LONG // 64 bits only
|
||||
{"rb_fix2int", (RUBY_PROC*)&dll_rb_fix2int},
|
||||
{"rb_num2int", (RUBY_PROC*)&dll_rb_num2int},
|
||||
{"rb_num2uint", (RUBY_PROC*)&dll_rb_num2uint},
|
||||
@@ -800,7 +800,7 @@ ruby_enabled(int verbose)
|
||||
{
|
||||
return ruby_runtime_link_init((char *)p_rubydll, verbose) == OK;
|
||||
}
|
||||
#endif /* defined(DYNAMIC_RUBY) || defined(PROTO) */
|
||||
#endif // defined(DYNAMIC_RUBY) || defined(PROTO)
|
||||
|
||||
void
|
||||
ruby_end(void)
|
||||
@@ -918,7 +918,7 @@ ex_rubydo(exarg_T *eap)
|
||||
ml_replace(i, (char_u *) StringValuePtr(line), 1);
|
||||
changed();
|
||||
#ifdef SYNTAX_HL
|
||||
syn_changed(i); /* recompute syntax hl. for this line */
|
||||
syn_changed(i); // recompute syntax hl. for this line
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -978,7 +978,7 @@ ensure_ruby_initialized(void)
|
||||
{
|
||||
#endif
|
||||
#ifdef MSWIN
|
||||
/* suggested by Ariya Mizutani */
|
||||
// suggested by Ariya Mizutani
|
||||
int argc = 1;
|
||||
char *argv[] = {"gvim.exe"};
|
||||
char **argvp = argv;
|
||||
@@ -1112,7 +1112,7 @@ vim_message(VALUE self UNUSED, VALUE str)
|
||||
str = rb_obj_as_string(str);
|
||||
if (RSTRING_LEN(str) > 0)
|
||||
{
|
||||
/* Only do this when the string isn't empty, alloc(0) causes trouble. */
|
||||
// Only do this when the string isn't empty, alloc(0) causes trouble.
|
||||
buff = ALLOCA_N(char, RSTRING_LEN(str) + 1);
|
||||
strcpy(buff, RSTRING_PTR(str));
|
||||
p = strchr(buff, '\n');
|
||||
@@ -1211,7 +1211,7 @@ vim_to_ruby(typval_T *tv)
|
||||
result = rb_str_new(tv->vval.v_blob->bv_ga.ga_data,
|
||||
tv->vval.v_blob->bv_ga.ga_len);
|
||||
}
|
||||
/* else return Qnil; */
|
||||
// else return Qnil;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1319,8 +1319,8 @@ buffer_s_count(void)
|
||||
|
||||
FOR_ALL_BUFFERS(b)
|
||||
{
|
||||
/* Deleted buffers should not be counted
|
||||
* SegPhault - 01/07/05 */
|
||||
// Deleted buffers should not be counted
|
||||
// SegPhault - 01/07/05
|
||||
if (b->b_p_bl)
|
||||
n++;
|
||||
}
|
||||
@@ -1336,8 +1336,8 @@ buffer_s_aref(VALUE self UNUSED, VALUE num)
|
||||
|
||||
FOR_ALL_BUFFERS(b)
|
||||
{
|
||||
/* Deleted buffers should not be counted
|
||||
* SegPhault - 01/07/05 */
|
||||
// Deleted buffers should not be counted
|
||||
// SegPhault - 01/07/05
|
||||
if (!b->b_p_bl)
|
||||
continue;
|
||||
|
||||
@@ -1388,7 +1388,7 @@ buffer_aref(VALUE self, VALUE num)
|
||||
|
||||
if (buf != NULL)
|
||||
return get_buffer_line(buf, (linenr_T)NUM2LONG(num));
|
||||
return Qnil; /* For stop warning */
|
||||
return Qnil; // For stop warning
|
||||
}
|
||||
|
||||
static VALUE
|
||||
@@ -1399,7 +1399,7 @@ set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
|
||||
|
||||
if (n > 0 && n <= buf->b_ml.ml_line_count && line != NULL)
|
||||
{
|
||||
/* set curwin/curbuf for "buf" and save some things */
|
||||
// set curwin/curbuf for "buf" and save some things
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
|
||||
if (u_savesub(n) == OK)
|
||||
@@ -1407,13 +1407,13 @@ set_buffer_line(buf_T *buf, linenr_T n, VALUE str)
|
||||
ml_replace(n, (char_u *)line, TRUE);
|
||||
changed();
|
||||
#ifdef SYNTAX_HL
|
||||
syn_changed(n); /* recompute syntax hl. for this line */
|
||||
syn_changed(n); // recompute syntax hl. for this line
|
||||
#endif
|
||||
}
|
||||
|
||||
/* restore curwin/curbuf and a few other things */
|
||||
// restore curwin/curbuf and a few other things
|
||||
aucmd_restbuf(&aco);
|
||||
/* Careful: autocommands may have made "buf" invalid! */
|
||||
// Careful: autocommands may have made "buf" invalid!
|
||||
|
||||
update_curbuf(NOT_VALID);
|
||||
}
|
||||
@@ -1443,23 +1443,23 @@ buffer_delete(VALUE self, VALUE num)
|
||||
|
||||
if (n > 0 && n <= buf->b_ml.ml_line_count)
|
||||
{
|
||||
/* set curwin/curbuf for "buf" and save some things */
|
||||
// set curwin/curbuf for "buf" and save some things
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
|
||||
if (u_savedel(n, 1) == OK)
|
||||
{
|
||||
ml_delete(n, 0);
|
||||
|
||||
/* Changes to non-active buffers should properly refresh
|
||||
* SegPhault - 01/09/05 */
|
||||
// Changes to non-active buffers should properly refresh
|
||||
// SegPhault - 01/09/05
|
||||
deleted_lines_mark(n, 1L);
|
||||
|
||||
changed();
|
||||
}
|
||||
|
||||
/* restore curwin/curbuf and a few other things */
|
||||
// restore curwin/curbuf and a few other things
|
||||
aucmd_restbuf(&aco);
|
||||
/* Careful: autocommands may have made "buf" invalid! */
|
||||
// Careful: autocommands may have made "buf" invalid!
|
||||
|
||||
update_curbuf(NOT_VALID);
|
||||
}
|
||||
@@ -1484,23 +1484,23 @@ buffer_append(VALUE self, VALUE num, VALUE str)
|
||||
}
|
||||
else if (n >= 0 && n <= buf->b_ml.ml_line_count)
|
||||
{
|
||||
/* set curwin/curbuf for "buf" and save some things */
|
||||
// set curwin/curbuf for "buf" and save some things
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
|
||||
if (u_inssub(n + 1) == OK)
|
||||
{
|
||||
ml_append(n, (char_u *) line, (colnr_T) 0, FALSE);
|
||||
|
||||
/* Changes to non-active buffers should properly refresh screen
|
||||
* SegPhault - 12/20/04 */
|
||||
// Changes to non-active buffers should properly refresh screen
|
||||
// SegPhault - 12/20/04
|
||||
appended_lines_mark(n, 1L);
|
||||
|
||||
changed();
|
||||
}
|
||||
|
||||
/* restore curwin/curbuf and a few other things */
|
||||
// restore curwin/curbuf and a few other things
|
||||
aucmd_restbuf(&aco);
|
||||
/* Careful: autocommands may have made "buf" invalid! */
|
||||
// Careful: autocommands may have made "buf" invalid!
|
||||
|
||||
update_curbuf(NOT_VALID);
|
||||
}
|
||||
@@ -1684,7 +1684,7 @@ window_set_cursor(VALUE self, VALUE pos)
|
||||
win->w_cursor.lnum = NUM2LONG(lnum);
|
||||
win->w_cursor.col = NUM2UINT(col);
|
||||
win->w_set_curswant = TRUE;
|
||||
check_cursor(); /* put cursor on an existing line */
|
||||
check_cursor(); // put cursor on an existing line
|
||||
update_screen(NOT_VALID);
|
||||
return Qnil;
|
||||
}
|
||||
@@ -1739,8 +1739,8 @@ ruby_vim_init(void)
|
||||
objtbl = rb_hash_new();
|
||||
rb_global_variable(&objtbl);
|
||||
|
||||
/* The Vim module used to be called "VIM", but "Vim" is better. Make an
|
||||
* alias "VIM" for backwards compatibility. */
|
||||
// The Vim module used to be called "VIM", but "Vim" is better. Make an
|
||||
// alias "VIM" for backwards compatibility.
|
||||
mVIM = rb_define_module("Vim");
|
||||
rb_define_const(rb_cObject, "VIM", mVIM);
|
||||
rb_define_const(mVIM, "VERSION_MAJOR", INT2NUM(VIM_VERSION_MAJOR));
|
||||
@@ -1775,8 +1775,8 @@ ruby_vim_init(void)
|
||||
rb_define_method(cBuffer, "delete", buffer_delete, 1);
|
||||
rb_define_method(cBuffer, "append", buffer_append, 2);
|
||||
|
||||
/* Added line manipulation functions
|
||||
* SegPhault - 03/07/05 */
|
||||
// Added line manipulation functions
|
||||
// SegPhault - 03/07/05
|
||||
rb_define_method(cBuffer, "line_number", current_line_number, 0);
|
||||
rb_define_method(cBuffer, "line", line_s_current, 0);
|
||||
rb_define_method(cBuffer, "line=", set_current_line, 1);
|
||||
@@ -1801,7 +1801,7 @@ ruby_vim_init(void)
|
||||
void
|
||||
vim_ruby_init(void *stack_start)
|
||||
{
|
||||
/* should get machine stack start address early in main function */
|
||||
// should get machine stack start address early in main function
|
||||
ruby_stack_start = stack_start;
|
||||
}
|
||||
|
||||
|
196
src/if_tcl.c
196
src/if_tcl.c
@@ -67,10 +67,10 @@ TODO:
|
||||
*/
|
||||
|
||||
#include "vim.h"
|
||||
#undef EXTERN /* tcl.h defines it too */
|
||||
#undef EXTERN // tcl.h defines it too
|
||||
|
||||
#ifdef DYNAMIC_TCL
|
||||
# define USE_TCL_STUBS /* use tcl's stubs mechanism */
|
||||
# define USE_TCL_STUBS // use tcl's stubs mechanism
|
||||
#endif
|
||||
|
||||
#include <tcl.h>
|
||||
@@ -106,7 +106,7 @@ static tcl_info tclinfo = { NULL, 0, 0, 0, 0, NULL, NULL };
|
||||
#define VIMOUT ((ClientData)1)
|
||||
#define VIMERR ((ClientData)2)
|
||||
|
||||
/* This appears to be new in Tcl 8.4. */
|
||||
// This appears to be new in Tcl 8.4.
|
||||
#ifndef CONST84
|
||||
# define CONST84
|
||||
#endif
|
||||
@@ -123,9 +123,9 @@ struct ref
|
||||
struct ref *next;
|
||||
|
||||
Tcl_Interp *interp;
|
||||
Tcl_Command cmd; /* Tcl command that represents this object */
|
||||
Tcl_Obj *delcmd; /* Tcl command to call when object is being del. */
|
||||
void *vimobj; /* Vim window or buffer (win_T* or buf_T*) */
|
||||
Tcl_Command cmd; // Tcl command that represents this object
|
||||
Tcl_Obj *delcmd; // Tcl command to call when object is being del.
|
||||
void *vimobj; // Vim window or buffer (win_T* or buf_T*)
|
||||
};
|
||||
static char * tclgetbuffer _ANSI_ARGS_((Tcl_Interp *interp, buf_T *buf));
|
||||
static char * tclgetwindow _ANSI_ARGS_((Tcl_Interp *interp, win_T *win));
|
||||
@@ -142,11 +142,11 @@ static void tclmsg _ANSI_ARGS_((char *text));
|
||||
static void tclerrmsg _ANSI_ARGS_((char *text));
|
||||
static void tclupdatevars _ANSI_ARGS_((void));
|
||||
|
||||
static struct ref refsdeleted; /* dummy object for deleted ref list */
|
||||
static struct ref refsdeleted; // dummy object for deleted ref list
|
||||
|
||||
/*****************************************************************************
|
||||
* TCL interface manager
|
||||
****************************************************************************/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// TCL interface manager
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(DYNAMIC_TCL) || defined(PROTO)
|
||||
# ifndef DYNAMIC_TCL_DLL
|
||||
@@ -156,7 +156,7 @@ static struct ref refsdeleted; /* dummy object for deleted ref list */
|
||||
# define DYNAMIC_TCL_VER "8.3"
|
||||
# endif
|
||||
|
||||
# ifndef DYNAMIC_TCL /* Just generating prototypes */
|
||||
# ifndef DYNAMIC_TCL // Just generating prototypes
|
||||
typedef int HANDLE;
|
||||
# endif
|
||||
|
||||
@@ -230,7 +230,7 @@ tcl_runtime_link_init(char *libname, int verbose)
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
#endif /* defined(DYNAMIC_TCL) || defined(PROTO) */
|
||||
#endif // defined(DYNAMIC_TCL) || defined(PROTO)
|
||||
|
||||
#ifdef DYNAMIC_TCL
|
||||
static char *find_executable_arg = NULL;
|
||||
@@ -270,7 +270,7 @@ tcl_enabled(int verbose)
|
||||
Tcl_DeleteInterp(interp);
|
||||
stubs_initialized = TRUE;
|
||||
}
|
||||
/* FIXME: When Tcl_InitStubs() was failed, how delete interp? */
|
||||
// FIXME: When Tcl_InitStubs() was failed, how delete interp?
|
||||
}
|
||||
}
|
||||
return stubs_initialized;
|
||||
@@ -289,9 +289,9 @@ tcl_end(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Tcl commands
|
||||
****************************************************************************/
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Tcl commands
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Replace standard "exit" command.
|
||||
@@ -321,7 +321,7 @@ exitcmd(
|
||||
case 2:
|
||||
if (Tcl_GetIntFromObj(interp, objv[1], &value) != TCL_OK)
|
||||
break;
|
||||
/* FALLTHROUGH */
|
||||
// FALLTHROUGH
|
||||
case 1:
|
||||
tclinfo.exitvalue = value;
|
||||
|
||||
@@ -402,7 +402,7 @@ buffercmd(
|
||||
Tcl_SetResult(interp, _("invalid buffer number"), TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
Tcl_ResetResult(interp); /* clear error from Tcl_GetIntFromObj */
|
||||
Tcl_ResetResult(interp); // clear error from Tcl_GetIntFromObj
|
||||
|
||||
err = Tcl_GetIndexFromObj(interp, objv[1], bcmdoptions, "option", 0, &idx);
|
||||
if (err != TCL_OK)
|
||||
@@ -576,7 +576,7 @@ bufselfcmd(
|
||||
* Get line number of last line.
|
||||
*/
|
||||
opt = 1;
|
||||
/* fallthrough */
|
||||
// fallthrough
|
||||
case BUF_COUNT:
|
||||
/*
|
||||
* Get number of lines in buffer.
|
||||
@@ -639,7 +639,7 @@ bufselfcmd(
|
||||
err = TCL_ERROR;
|
||||
}
|
||||
}
|
||||
else { /* objc == 3 */
|
||||
else { // objc == 3
|
||||
line = (char *)ml_get_buf(buf, (linenr_T)val1, FALSE);
|
||||
Tcl_SetResult(interp, line, TCL_VOLATILE);
|
||||
}
|
||||
@@ -725,7 +725,7 @@ bufselfcmd(
|
||||
}
|
||||
if (i < lc)
|
||||
{
|
||||
/* append lines */
|
||||
// append lines
|
||||
do
|
||||
{
|
||||
line = Tcl_GetStringFromObj(lv[i], NULL);
|
||||
@@ -738,7 +738,7 @@ bufselfcmd(
|
||||
}
|
||||
else if (n <= val2)
|
||||
{
|
||||
/* did not replace all lines, delete */
|
||||
// did not replace all lines, delete
|
||||
i = n;
|
||||
do
|
||||
{
|
||||
@@ -747,13 +747,13 @@ bufselfcmd(
|
||||
++n;
|
||||
} while (n <= val2);
|
||||
}
|
||||
lc -= val2 - val1 + 1; /* number of lines to be replaced */
|
||||
lc -= val2 - val1 + 1; // number of lines to be replaced
|
||||
mark_adjust((linenr_T)val1, (linenr_T)val2, (long)MAXLNUM,
|
||||
(long)lc);
|
||||
changed_lines((linenr_T)val1, 0, (linenr_T)val2 + 1, (long)lc);
|
||||
break;
|
||||
setListError:
|
||||
u_undo(1); /* ??? */
|
||||
u_undo(1); // ???
|
||||
Tcl_SetResult(interp, _("cannot set line(s)"), TCL_STATIC);
|
||||
err = TCL_ERROR;
|
||||
}
|
||||
@@ -838,7 +838,7 @@ bufselfcmd(
|
||||
|
||||
case BUF_INSERT:
|
||||
opt = 1;
|
||||
/* fallthrough */
|
||||
// fallthrough
|
||||
case BUF_APPEND:
|
||||
if (objc != 4)
|
||||
{
|
||||
@@ -1078,7 +1078,7 @@ winselfcmd(
|
||||
if (err != TCL_OK)
|
||||
break;
|
||||
}
|
||||
else { /* objc == 4 */
|
||||
else { // objc == 4
|
||||
err = tclgetlinenum(interp, objv[2], &val1, win->w_buffer);
|
||||
if (err != TCL_OK)
|
||||
break;
|
||||
@@ -1086,7 +1086,7 @@ winselfcmd(
|
||||
if (err != TCL_OK)
|
||||
break;
|
||||
}
|
||||
/* TODO: should check column */
|
||||
// TODO: should check column
|
||||
win->w_cursor.lnum = val1;
|
||||
win->w_cursor.col = col2vim(val2);
|
||||
win->w_set_curswant = TRUE;
|
||||
@@ -1145,9 +1145,9 @@ exprcmd(
|
||||
return tclvimexpr(interp, objc, objv, 1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Support functions for Tcl commands
|
||||
****************************************************************************/
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Support functions for Tcl commands
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* Get a line number from 'obj' and convert it to vim's range.
|
||||
@@ -1215,7 +1215,7 @@ tclfindwin(buf_T *buf)
|
||||
if (win->w_buffer == buf)
|
||||
return win;
|
||||
}
|
||||
return curwin; /* keep current window context */
|
||||
return curwin; // keep current window context
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1267,7 +1267,7 @@ tcldoexcommand(
|
||||
--emsg_off;
|
||||
err = vimerror(interp);
|
||||
|
||||
/* If the ex command created a new Tcl interpreter, remove it */
|
||||
// If the ex command created a new Tcl interpreter, remove it
|
||||
if (tclinfo.interp)
|
||||
tcldelthisinterp();
|
||||
memcpy(&tclinfo, &saveinfo, sizeof(tcl_info));
|
||||
@@ -1325,7 +1325,7 @@ tclsetoption(
|
||||
{
|
||||
if (isnum)
|
||||
{
|
||||
sval = NULL; /* avoid compiler warning */
|
||||
sval = NULL; // avoid compiler warning
|
||||
err = Tcl_GetIndexFromObj(interp, objv[objn], optkw, "", 0, &idx);
|
||||
if (err != TCL_OK)
|
||||
{
|
||||
@@ -1440,11 +1440,11 @@ delref(ClientData cref)
|
||||
static char *
|
||||
tclgetref(
|
||||
Tcl_Interp *interp,
|
||||
void **refstartP, /* ptr to w_tcl_ref/b_tcl-ref member of
|
||||
win_T/buf_T struct */
|
||||
char *prefix, /* "win" or "buf" */
|
||||
void *vimobj, /* win_T* or buf_T* */
|
||||
Tcl_ObjCmdProc *proc) /* winselfcmd or bufselfcmd */
|
||||
void **refstartP, // ptr to w_tcl_ref/b_tcl-ref member of
|
||||
// win_T/buf_T struct
|
||||
char *prefix, // "win" or "buf"
|
||||
void *vimobj, // win_T* or buf_T*
|
||||
Tcl_ObjCmdProc *proc) // winselfcmd or bufselfcmd
|
||||
{
|
||||
struct ref *ref, *unused = NULL;
|
||||
static char name[VARNAME_SIZE];
|
||||
@@ -1481,7 +1481,7 @@ tclgetref(
|
||||
(*refstartP) = (void *)ref;
|
||||
}
|
||||
|
||||
/* This might break on some exotic systems... */
|
||||
// This might break on some exotic systems...
|
||||
vim_snprintf(name, sizeof(name), "::vim::%s_%lx",
|
||||
prefix, (unsigned long)vimobj);
|
||||
cmd = Tcl_CreateObjCommand(interp, name, proc,
|
||||
@@ -1534,23 +1534,23 @@ tclsetdelcmd(
|
||||
}
|
||||
reflist = reflist->next;
|
||||
}
|
||||
/* This should never happen. Famous last word? */
|
||||
// This should never happen. Famous last word?
|
||||
emsg(_("E280: TCL FATAL ERROR: reflist corrupt!? Please report this to vim-dev@vim.org"));
|
||||
Tcl_SetResult(interp, _("cannot register callback command: buffer/window reference not found"), TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************
|
||||
I/O Channel
|
||||
********************************************/
|
||||
////////////////////////////////////////////
|
||||
// I/O Channel
|
||||
////////////////////////////////////////////
|
||||
|
||||
static int
|
||||
tcl_channel_close(ClientData instance, Tcl_Interp *interp UNUSED)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
/* currently does nothing */
|
||||
// currently does nothing
|
||||
|
||||
if (instance != VIMOUT && instance != VIMERR)
|
||||
{
|
||||
@@ -1568,7 +1568,7 @@ tcl_channel_input(
|
||||
int *errptr)
|
||||
{
|
||||
|
||||
/* input is currently not supported */
|
||||
// input is currently not supported
|
||||
|
||||
Tcl_SetErrno(EINVAL);
|
||||
if (errptr)
|
||||
@@ -1586,10 +1586,9 @@ tcl_channel_output(
|
||||
char_u *str;
|
||||
int result;
|
||||
|
||||
/* The buffer is not guaranteed to be 0-terminated, and we don't if
|
||||
* there is enough room to add a '\0'. So we have to create a copy
|
||||
* of the buffer...
|
||||
*/
|
||||
// The buffer is not guaranteed to be 0-terminated, and we don't if
|
||||
// there is enough room to add a '\0'. So we have to create a copy
|
||||
// of the buffer...
|
||||
str = vim_strnsave((char_u *)buf, bufsiz);
|
||||
if (!str)
|
||||
{
|
||||
@@ -1635,43 +1634,43 @@ tcl_channel_gethandle(
|
||||
|
||||
static Tcl_ChannelType tcl_channel_type =
|
||||
{
|
||||
"vimmessage", /* typeName */
|
||||
TCL_CHANNEL_VERSION_2, /* version */
|
||||
tcl_channel_close, /* closeProc */
|
||||
tcl_channel_input, /* inputProc */
|
||||
tcl_channel_output, /* outputProc */
|
||||
NULL, /* seekProc */
|
||||
NULL, /* setOptionProc */
|
||||
NULL, /* getOptionProc */
|
||||
tcl_channel_watch, /* watchProc */
|
||||
tcl_channel_gethandle, /* getHandleProc */
|
||||
NULL, /* close2Proc */
|
||||
NULL, /* blockModeProc */
|
||||
"vimmessage", // typeName
|
||||
TCL_CHANNEL_VERSION_2, // version
|
||||
tcl_channel_close, // closeProc
|
||||
tcl_channel_input, // inputProc
|
||||
tcl_channel_output, // outputProc
|
||||
NULL, // seekProc
|
||||
NULL, // setOptionProc
|
||||
NULL, // getOptionProc
|
||||
tcl_channel_watch, // watchProc
|
||||
tcl_channel_gethandle, // getHandleProc
|
||||
NULL, // close2Proc
|
||||
NULL, // blockModeProc
|
||||
#ifdef TCL_CHANNEL_VERSION_2
|
||||
NULL, /* flushProc */
|
||||
NULL, /* handlerProc */
|
||||
NULL, // flushProc
|
||||
NULL, // handlerProc
|
||||
#endif
|
||||
/* The following should not be necessary since TCL_CHANNEL_VERSION_2 was
|
||||
* set above */
|
||||
// The following should not be necessary since TCL_CHANNEL_VERSION_2 was
|
||||
// set above
|
||||
#ifdef TCL_CHANNEL_VERSION_3
|
||||
NULL, /* wideSeekProc */
|
||||
NULL, // wideSeekProc
|
||||
#endif
|
||||
#ifdef TCL_CHANNEL_VERSION_4
|
||||
NULL, /* threadActionProc */
|
||||
NULL, // threadActionProc
|
||||
#endif
|
||||
#ifdef TCL_CHANNEL_VERSION_5
|
||||
NULL /* truncateProc */
|
||||
NULL // truncateProc
|
||||
#endif
|
||||
};
|
||||
|
||||
/**********************************
|
||||
Interface to vim
|
||||
**********************************/
|
||||
///////////////////////////////////
|
||||
// Interface to vim
|
||||
//////////////////////////////////
|
||||
|
||||
static void
|
||||
tclupdatevars(void)
|
||||
{
|
||||
char varname[VARNAME_SIZE]; /* must be writeable */
|
||||
char varname[VARNAME_SIZE]; // must be writeable
|
||||
char *name;
|
||||
|
||||
strcpy(varname, VAR_RANGE1);
|
||||
@@ -1699,7 +1698,7 @@ tclupdatevars(void)
|
||||
static int
|
||||
tclinit(exarg_T *eap)
|
||||
{
|
||||
char varname[VARNAME_SIZE]; /* Tcl_LinkVar requires writeable varname */
|
||||
char varname[VARNAME_SIZE]; // Tcl_LinkVar requires writeable varname
|
||||
char *name;
|
||||
|
||||
#ifdef DYNAMIC_TCL
|
||||
@@ -1715,9 +1714,9 @@ tclinit(exarg_T *eap)
|
||||
Tcl_Interp *interp;
|
||||
static Tcl_Channel ch1, ch2;
|
||||
|
||||
/* Create replacement channels for stdout and stderr; this has to be
|
||||
* done each time an interpreter is created since the channels are closed
|
||||
* when the interpreter is deleted */
|
||||
// Create replacement channels for stdout and stderr; this has to be
|
||||
// done each time an interpreter is created since the channels are closed
|
||||
// when the interpreter is deleted
|
||||
ch1 = Tcl_CreateChannel(&tcl_channel_type, "vimout", VIMOUT, TCL_WRITABLE);
|
||||
ch2 = Tcl_CreateChannel(&tcl_channel_type, "vimerr", VIMERR, TCL_WRITABLE);
|
||||
Tcl_SetStdChannel(ch1, TCL_STDOUT);
|
||||
@@ -1732,7 +1731,7 @@ tclinit(exarg_T *eap)
|
||||
return FAIL;
|
||||
}
|
||||
#if 0
|
||||
/* VIM sure is interactive */
|
||||
// VIM sure is interactive
|
||||
Tcl_SetVar(interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
|
||||
@@ -1745,12 +1744,12 @@ tclinit(exarg_T *eap)
|
||||
Tcl_SetChannelOption(interp, ch2, "-translation", "lf");
|
||||
#endif
|
||||
|
||||
/* replace standard Tcl exit command */
|
||||
// replace standard Tcl exit command
|
||||
Tcl_DeleteCommand(interp, "exit");
|
||||
Tcl_CreateObjCommand(interp, "exit", exitcmd,
|
||||
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
||||
|
||||
/* new commands, in ::vim namespace */
|
||||
// new commands, in ::vim namespace
|
||||
Tcl_CreateObjCommand(interp, "::vim::buffer", buffercmd,
|
||||
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
||||
Tcl_CreateObjCommand(interp, "::vim::window", windowcmd,
|
||||
@@ -1764,12 +1763,12 @@ tclinit(exarg_T *eap)
|
||||
Tcl_CreateObjCommand(interp, "::vim::expr", exprcmd,
|
||||
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
|
||||
|
||||
/* "lbase" variable */
|
||||
// "lbase" variable
|
||||
tclinfo.lbase = 1;
|
||||
strcpy(varname, VAR_LBASE);
|
||||
Tcl_LinkVar(interp, varname, (char *)&tclinfo.lbase, TCL_LINK_INT);
|
||||
|
||||
/* "range" variable */
|
||||
// "range" variable
|
||||
tclinfo.range_start = eap->line1;
|
||||
strcpy(varname, VAR_RANGE1);
|
||||
Tcl_LinkVar(interp, varname, (char *)&tclinfo.range_start, TCL_LINK_INT|TCL_LINK_READ_ONLY);
|
||||
@@ -1779,7 +1778,7 @@ tclinit(exarg_T *eap)
|
||||
strcpy(varname, VAR_RANGE3);
|
||||
Tcl_LinkVar(interp, varname, (char *)&tclinfo.range_end, TCL_LINK_INT|TCL_LINK_READ_ONLY);
|
||||
|
||||
/* "current" variable */
|
||||
// "current" variable
|
||||
tclinfo.curbuf = Tcl_Alloc(VARNAME_SIZE);
|
||||
tclinfo.curwin = Tcl_Alloc(VARNAME_SIZE);
|
||||
name = tclgetbuffer(interp, curbuf);
|
||||
@@ -1795,7 +1794,7 @@ tclinit(exarg_T *eap)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Interpreter already exists, just update variables */
|
||||
// Interpreter already exists, just update variables
|
||||
tclinfo.range_start = row2tcl(eap->line1);
|
||||
tclinfo.range_end = row2tcl(eap->line2);
|
||||
tclupdatevars();
|
||||
@@ -1841,15 +1840,14 @@ tcldelthisinterp(void)
|
||||
if (!Tcl_InterpDeleted(tclinfo.interp))
|
||||
Tcl_DeleteInterp(tclinfo.interp);
|
||||
Tcl_Release(tclinfo.interp);
|
||||
/* The interpreter is now gets deleted. All registered commands (esp.
|
||||
* window and buffer commands) are deleted, triggering their deletion
|
||||
* callback, which deletes all refs pointing to this interpreter.
|
||||
* We could garbage-collect the unused ref structs in all windows and
|
||||
* buffers, but unless the user creates hundreds of sub-interpreters
|
||||
* all referring to lots of windows and buffers, this is hardly worth
|
||||
* the effort. Unused refs are recycled by other interpreters, and
|
||||
* all refs are free'd when the window/buffer gets closed by vim.
|
||||
*/
|
||||
// The interpreter is now gets deleted. All registered commands (esp.
|
||||
// window and buffer commands) are deleted, triggering their deletion
|
||||
// callback, which deletes all refs pointing to this interpreter.
|
||||
// We could garbage-collect the unused ref structs in all windows and
|
||||
// buffers, but unless the user creates hundreds of sub-interpreters
|
||||
// all referring to lots of windows and buffers, this is hardly worth
|
||||
// the effort. Unused refs are recycled by other interpreters, and
|
||||
// all refs are free'd when the window/buffer gets closed by vim.
|
||||
|
||||
tclinfo.interp = NULL;
|
||||
Tcl_Free(tclinfo.curbuf);
|
||||
@@ -1862,9 +1860,9 @@ tclexit(int error)
|
||||
{
|
||||
int newerr = OK;
|
||||
|
||||
if (Tcl_InterpDeleted(tclinfo.interp) /* True if we intercepted Tcl's exit command */
|
||||
if (Tcl_InterpDeleted(tclinfo.interp) // True if we intercepted Tcl's exit command
|
||||
#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 5) || TCL_MAJOR_VERSION > 8
|
||||
|| Tcl_LimitExceeded(tclinfo.interp) /* True if the interpreter cannot continue */
|
||||
|| Tcl_LimitExceeded(tclinfo.interp) // True if the interpreter cannot continue
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@@ -1954,7 +1952,7 @@ ex_tcldo(exarg_T *eap)
|
||||
{
|
||||
char *script, *line;
|
||||
int err, rs, re, lnum;
|
||||
char var_lnum[VARNAME_SIZE]; /* must be writeable memory */
|
||||
char var_lnum[VARNAME_SIZE]; // must be writeable memory
|
||||
char var_line[VARNAME_SIZE];
|
||||
linenr_T first_line = 0;
|
||||
linenr_T last_line = 0;
|
||||
@@ -2035,7 +2033,7 @@ tcldelallrefs(struct ref *ref)
|
||||
char *result;
|
||||
|
||||
#ifdef DYNAMIC_TCL
|
||||
/* TODO: this code currently crashes Vim on exit */
|
||||
// TODO: this code currently crashes Vim on exit
|
||||
if (exiting)
|
||||
return;
|
||||
#endif
|
||||
@@ -2070,7 +2068,7 @@ tcl_buffer_free(buf_T *buf)
|
||||
struct ref *reflist;
|
||||
|
||||
#ifdef DYNAMIC_TCL
|
||||
if (!stubs_initialized) /* Not using Tcl, nothing to do. */
|
||||
if (!stubs_initialized) // Not using Tcl, nothing to do.
|
||||
return;
|
||||
#endif
|
||||
|
||||
@@ -2089,7 +2087,7 @@ tcl_window_free(win_T *win)
|
||||
struct ref *reflist;
|
||||
|
||||
#ifdef DYNAMIC_TCL
|
||||
if (!stubs_initialized) /* Not using Tcl, nothing to do. */
|
||||
if (!stubs_initialized) // Not using Tcl, nothing to do.
|
||||
return;
|
||||
#endif
|
||||
|
||||
@@ -2102,4 +2100,4 @@ tcl_window_free(win_T *win)
|
||||
}
|
||||
}
|
||||
|
||||
/* The End */
|
||||
// The End
|
||||
|
155
src/if_xcmdsrv.c
155
src/if_xcmdsrv.c
@@ -64,18 +64,18 @@
|
||||
|
||||
typedef struct PendingCommand
|
||||
{
|
||||
int serial; /* Serial number expected in result. */
|
||||
int code; /* Result Code. 0 is OK */
|
||||
char_u *result; /* String result for command (malloc'ed).
|
||||
* NULL means command still pending. */
|
||||
int serial; // Serial number expected in result.
|
||||
int code; // Result Code. 0 is OK
|
||||
char_u *result; // String result for command (malloc'ed).
|
||||
// NULL means command still pending.
|
||||
struct PendingCommand *nextPtr;
|
||||
/* Next in list of all outstanding commands.
|
||||
* NULL means end of list. */
|
||||
// Next in list of all outstanding commands.
|
||||
// NULL means end of list.
|
||||
} PendingCommand;
|
||||
|
||||
static PendingCommand *pendingCommands = NULL;
|
||||
/* List of all commands currently
|
||||
* being waited for. */
|
||||
// List of all commands currently
|
||||
// being waited for.
|
||||
|
||||
/*
|
||||
* The information below is used for communication between processes
|
||||
@@ -179,7 +179,7 @@ struct x_cmdqueue
|
||||
|
||||
typedef struct x_cmdqueue x_queue_T;
|
||||
|
||||
/* dummy node, header for circular queue */
|
||||
// dummy node, header for circular queue
|
||||
static x_queue_T head = {NULL, 0, NULL, NULL};
|
||||
|
||||
/*
|
||||
@@ -200,12 +200,12 @@ static int IsSerialName(char_u *name);
|
||||
static void save_in_queue(char_u *buf, long_u len);
|
||||
static void server_parse_message(Display *dpy, char_u *propInfo, long_u numItems);
|
||||
|
||||
/* Private variables for the "server" functionality */
|
||||
// Private variables for the "server" functionality
|
||||
static Atom registryProperty = None;
|
||||
static Atom vimProperty = None;
|
||||
static int got_x_error = FALSE;
|
||||
|
||||
static char_u *empty_prop = (char_u *)""; /* empty GetRegProp() result */
|
||||
static char_u *empty_prop = (char_u *)""; // empty GetRegProp() result
|
||||
|
||||
/*
|
||||
* Associate an ASCII name with Vim. Try real hard to get a unique one.
|
||||
@@ -213,8 +213,8 @@ static char_u *empty_prop = (char_u *)""; /* empty GetRegProp() result */
|
||||
*/
|
||||
int
|
||||
serverRegisterName(
|
||||
Display *dpy, /* display to register with */
|
||||
char_u *name) /* the name that will be used as a base */
|
||||
Display *dpy, // display to register with
|
||||
char_u *name) // the name that will be used as a base
|
||||
{
|
||||
int i;
|
||||
int res;
|
||||
@@ -329,25 +329,25 @@ DoRegisterName(Display *dpy, char_u *name)
|
||||
*/
|
||||
void
|
||||
serverChangeRegisteredWindow(
|
||||
Display *dpy, /* Display to register with */
|
||||
Window newwin) /* Re-register to this ID */
|
||||
Display *dpy, // Display to register with
|
||||
Window newwin) // Re-register to this ID
|
||||
{
|
||||
char_u propInfo[MAX_NAME_LENGTH + 20];
|
||||
|
||||
commWindow = newwin;
|
||||
|
||||
/* Always call SendInit() here, to make sure commWindow is marked as a Vim
|
||||
* window. */
|
||||
// Always call SendInit() here, to make sure commWindow is marked as a Vim
|
||||
// window.
|
||||
if (SendInit(dpy) < 0)
|
||||
return;
|
||||
|
||||
/* WARNING: Do not step through this while debugging, it will hangup the X
|
||||
* server! */
|
||||
// WARNING: Do not step through this while debugging, it will hangup the X
|
||||
// server!
|
||||
XGrabServer(dpy);
|
||||
DeleteAnyLingerer(dpy, newwin);
|
||||
if (serverName != NULL)
|
||||
{
|
||||
/* Reinsert name if we was already registered */
|
||||
// Reinsert name if we was already registered
|
||||
(void)LookupName(dpy, serverName, /*delete=*/TRUE, NULL);
|
||||
sprintf((char *)propInfo, "%x %.*s",
|
||||
(int_u)newwin, MAX_NAME_LENGTH, serverName);
|
||||
@@ -365,30 +365,30 @@ serverChangeRegisteredWindow(
|
||||
*/
|
||||
int
|
||||
serverSendToVim(
|
||||
Display *dpy, /* Where to send. */
|
||||
char_u *name, /* Where to send. */
|
||||
char_u *cmd, /* What to send. */
|
||||
char_u **result, /* Result of eval'ed expression */
|
||||
Window *server, /* Actual ID of receiving app */
|
||||
Bool asExpr, /* Interpret as keystrokes or expr ? */
|
||||
int timeout, /* seconds to wait or zero */
|
||||
Bool localLoop, /* Throw away everything but result */
|
||||
int silent) /* don't complain about no server */
|
||||
Display *dpy, // Where to send.
|
||||
char_u *name, // Where to send.
|
||||
char_u *cmd, // What to send.
|
||||
char_u **result, // Result of eval'ed expression
|
||||
Window *server, // Actual ID of receiving app
|
||||
Bool asExpr, // Interpret as keystrokes or expr ?
|
||||
int timeout, // seconds to wait or zero
|
||||
Bool localLoop, // Throw away everything but result
|
||||
int silent) // don't complain about no server
|
||||
{
|
||||
Window w;
|
||||
char_u *property;
|
||||
int length;
|
||||
int res;
|
||||
static int serial = 0; /* Running count of sent commands.
|
||||
* Used to give each command a
|
||||
* different serial number. */
|
||||
static int serial = 0; // Running count of sent commands.
|
||||
// Used to give each command a
|
||||
// different serial number.
|
||||
PendingCommand pending;
|
||||
char_u *loosename = NULL;
|
||||
|
||||
if (result != NULL)
|
||||
*result = NULL;
|
||||
if (name == NULL || *name == NUL)
|
||||
name = (char_u *)"GVIM"; /* use a default name */
|
||||
name = (char_u *)"GVIM"; // use a default name
|
||||
|
||||
if (commProperty == None && dpy != NULL)
|
||||
{
|
||||
@@ -396,7 +396,7 @@ serverSendToVim(
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Execute locally if no display or target is ourselves */
|
||||
// Execute locally if no display or target is ourselves
|
||||
if (dpy == NULL || (serverName != NULL && STRICMP(name, serverName) == 0))
|
||||
return sendToLocalVim(cmd, asExpr, result);
|
||||
|
||||
@@ -411,7 +411,7 @@ serverSendToVim(
|
||||
while (TRUE)
|
||||
{
|
||||
w = LookupName(dpy, name, FALSE, &loosename);
|
||||
/* Check that the window is hot */
|
||||
// Check that the window is hot
|
||||
if (w != None)
|
||||
{
|
||||
if (!WindowValid(dpy, w))
|
||||
@@ -447,11 +447,11 @@ serverSendToVim(
|
||||
0, asExpr ? 'c' : 'k', 0, name, 0, p_enc, 0, cmd);
|
||||
if (name == loosename)
|
||||
vim_free(loosename);
|
||||
/* Add a back reference to our comm window */
|
||||
// Add a back reference to our comm window
|
||||
serial++;
|
||||
sprintf((char *)property + length, "%c-r %x %d",
|
||||
0, (int_u)commWindow, serial);
|
||||
/* Add length of what "-r %x %d" resulted in, skipping the NUL. */
|
||||
// Add length of what "-r %x %d" resulted in, skipping the NUL.
|
||||
length += STRLEN(property + length + 1) + 1;
|
||||
|
||||
res = AppendPropCarefully(dpy, w, commProperty, property, length + 1);
|
||||
@@ -462,7 +462,7 @@ serverSendToVim(
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!asExpr) /* There is no answer for this - Keys are sent async */
|
||||
if (!asExpr) // There is no answer for this - Keys are sent async
|
||||
return 0;
|
||||
|
||||
/*
|
||||
@@ -592,7 +592,7 @@ ServerWait(
|
||||
check_due_timer();
|
||||
#endif
|
||||
|
||||
/* Just look out for the answer without calling back into Vim */
|
||||
// Just look out for the answer without calling back into Vim
|
||||
if (localLoop)
|
||||
{
|
||||
#ifndef HAVE_SELECT
|
||||
@@ -670,9 +670,8 @@ serverGetVimNames(Display *dpy)
|
||||
return ga.ga_data;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------
|
||||
* Reply stuff
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Reply stuff
|
||||
|
||||
static struct ServerReply *
|
||||
ServerReplyFind(Window w, enum ServerReplyOp op)
|
||||
@@ -754,7 +753,7 @@ serverSendReply(char_u *name, char_u *str)
|
||||
{
|
||||
sprintf((char *)property, "%cn%c-E %s%c-n %s%c-w %x",
|
||||
0, 0, p_enc, 0, str, 0, (unsigned int)commWindow);
|
||||
/* Add length of what "%x" resulted in. */
|
||||
// Add length of what "%x" resulted in.
|
||||
length += STRLEN(property + length);
|
||||
res = AppendPropCarefully(dpy, win, commProperty, property, length + 1);
|
||||
vim_free(property);
|
||||
@@ -804,7 +803,7 @@ serverReadReply(
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Last string read. Remove from list */
|
||||
// Last string read. Remove from list
|
||||
ga_clear(&p->strings);
|
||||
ServerReplyFind(win, SROP_Delete);
|
||||
}
|
||||
@@ -864,14 +863,14 @@ SendInit(Display *dpy)
|
||||
WhitePixel(dpy, DefaultScreen(dpy)),
|
||||
WhitePixel(dpy, DefaultScreen(dpy)));
|
||||
XSelectInput(dpy, commWindow, PropertyChangeMask);
|
||||
/* WARNING: Do not step through this while debugging, it will hangup
|
||||
* the X server! */
|
||||
// WARNING: Do not step through this while debugging, it will hangup
|
||||
// the X server!
|
||||
XGrabServer(dpy);
|
||||
DeleteAnyLingerer(dpy, commWindow);
|
||||
XUngrabServer(dpy);
|
||||
}
|
||||
|
||||
/* Make window recognizable as a vim window */
|
||||
// Make window recognizable as a vim window
|
||||
XChangeProperty(dpy, commWindow, vimProperty, XA_STRING,
|
||||
8, PropModeReplace, (char_u *)VIM_VERSION_SHORT,
|
||||
(int)STRLEN(VIM_VERSION_SHORT) + 1);
|
||||
@@ -896,11 +895,11 @@ SendInit(Display *dpy)
|
||||
*/
|
||||
static Window
|
||||
LookupName(
|
||||
Display *dpy, /* Display whose registry to check. */
|
||||
char_u *name, /* Name of a server. */
|
||||
int delete, /* If non-zero, delete info about name. */
|
||||
char_u **loose) /* Do another search matching -999 if not found
|
||||
Return result here if a match is found */
|
||||
Display *dpy, // Display whose registry to check.
|
||||
char_u *name, // Name of a server.
|
||||
int delete, // If non-zero, delete info about name.
|
||||
char_u **loose) // Do another search matching -999 if not found
|
||||
// Return result here if a match is found
|
||||
{
|
||||
char_u *regProp, *entry;
|
||||
char_u *p;
|
||||
@@ -917,7 +916,7 @@ LookupName(
|
||||
* Scan the property for the desired name.
|
||||
*/
|
||||
returnValue = (int_u)None;
|
||||
entry = NULL; /* Not needed, but eliminates compiler warning. */
|
||||
entry = NULL; // Not needed, but eliminates compiler warning.
|
||||
for (p = regProp; (long_u)(p - regProp) < numItems; )
|
||||
{
|
||||
entry = p;
|
||||
@@ -990,8 +989,8 @@ LookupName(
|
||||
*/
|
||||
static void
|
||||
DeleteAnyLingerer(
|
||||
Display *dpy, /* Display whose registry to check. */
|
||||
Window win) /* Window to remove */
|
||||
Display *dpy, // Display whose registry to check.
|
||||
Window win) // Window to remove
|
||||
{
|
||||
char_u *regProp, *entry = NULL;
|
||||
char_u *p;
|
||||
@@ -1004,7 +1003,7 @@ DeleteAnyLingerer(
|
||||
if (GetRegProp(dpy, ®Prop, &numItems, FALSE) == FAIL)
|
||||
return;
|
||||
|
||||
/* Scan the property for the window id. */
|
||||
// Scan the property for the window id.
|
||||
for (p = regProp; (long_u)(p - regProp) < numItems; )
|
||||
{
|
||||
if (*p != 0)
|
||||
@@ -1014,7 +1013,7 @@ DeleteAnyLingerer(
|
||||
{
|
||||
int lastHalf;
|
||||
|
||||
/* Copy down the remainder to delete entry */
|
||||
// Copy down the remainder to delete entry
|
||||
entry = p;
|
||||
while (*p != 0)
|
||||
p++;
|
||||
@@ -1055,7 +1054,7 @@ GetRegProp(
|
||||
Display *dpy,
|
||||
char_u **regPropp,
|
||||
long_u *numItemsp,
|
||||
int domsg) /* When TRUE give error message. */
|
||||
int domsg) // When TRUE give error message.
|
||||
{
|
||||
int result, actualFormat;
|
||||
long_u bytesAfter;
|
||||
@@ -1079,13 +1078,13 @@ GetRegProp(
|
||||
|
||||
if (actualType == None)
|
||||
{
|
||||
/* No prop yet. Logically equal to the empty list */
|
||||
// No prop yet. Logically equal to the empty list
|
||||
*numItemsp = 0;
|
||||
*regPropp = empty_prop;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* If the property is improperly formed, then delete it. */
|
||||
// If the property is improperly formed, then delete it.
|
||||
if (result != Success || actualFormat != 8 || actualType != XA_STRING)
|
||||
{
|
||||
if (*regPropp != NULL)
|
||||
@@ -1110,8 +1109,8 @@ GetRegProp(
|
||||
void
|
||||
serverEventProc(
|
||||
Display *dpy,
|
||||
XEvent *eventPtr, /* Information about event. */
|
||||
int immediate) /* Run event immediately. Should mostly be 0. */
|
||||
XEvent *eventPtr, // Information about event.
|
||||
int immediate) // Run event immediately. Should mostly be 0.
|
||||
{
|
||||
char_u *propInfo;
|
||||
int result, actualFormat;
|
||||
@@ -1135,7 +1134,7 @@ serverEventProc(
|
||||
&actualFormat, &numItems, &bytesAfter,
|
||||
&propInfo);
|
||||
|
||||
/* If the property doesn't exist or is improperly formed then ignore it. */
|
||||
// If the property doesn't exist or is improperly formed then ignore it.
|
||||
if (result != Success || actualType != XA_STRING || actualFormat != 8)
|
||||
{
|
||||
if (propInfo != NULL)
|
||||
@@ -1159,17 +1158,17 @@ save_in_queue(char_u *propInfo, long_u len)
|
||||
|
||||
node = ALLOC_ONE(x_queue_T);
|
||||
if (node == NULL)
|
||||
return; /* out of memory */
|
||||
return; // out of memory
|
||||
node->propInfo = propInfo;
|
||||
node->len = len;
|
||||
|
||||
if (head.next == NULL) /* initialize circular queue */
|
||||
if (head.next == NULL) // initialize circular queue
|
||||
{
|
||||
head.next = &head;
|
||||
head.prev = &head;
|
||||
}
|
||||
|
||||
/* insert node at tail of queue */
|
||||
// insert node at tail of queue
|
||||
node->next = &head;
|
||||
node->prev = head.prev;
|
||||
head.prev->next = node;
|
||||
@@ -1185,7 +1184,7 @@ server_parse_messages(void)
|
||||
x_queue_T *node;
|
||||
|
||||
if (!X_DISPLAY)
|
||||
return; /* cannot happen? */
|
||||
return; // cannot happen?
|
||||
while (head.next != NULL && head.next != &head)
|
||||
{
|
||||
node = head.next;
|
||||
@@ -1214,8 +1213,8 @@ server_waiting(void)
|
||||
static void
|
||||
server_parse_message(
|
||||
Display *dpy,
|
||||
char_u *propInfo, /* A string containing 0 or more X commands */
|
||||
long_u numItems) /* The size of propInfo in bytes. */
|
||||
char_u *propInfo, // A string containing 0 or more X commands
|
||||
long_u numItems) // The size of propInfo in bytes.
|
||||
{
|
||||
char_u *p;
|
||||
int code;
|
||||
@@ -1276,7 +1275,7 @@ server_parse_message(
|
||||
else
|
||||
{
|
||||
p = serial = end + 1;
|
||||
clientWindow = resWindow; /* Remember in global */
|
||||
clientWindow = resWindow; // Remember in global
|
||||
}
|
||||
break;
|
||||
case 'n':
|
||||
@@ -1314,14 +1313,14 @@ server_parse_message(
|
||||
{
|
||||
garray_T reply;
|
||||
|
||||
/* Initialize the result property. */
|
||||
// Initialize the result property.
|
||||
ga_init2(&reply, 1, 100);
|
||||
(void)ga_grow(&reply, 50 + STRLEN(p_enc));
|
||||
sprintf(reply.ga_data, "%cr%c-E %s%c-s %s%c-r ",
|
||||
0, 0, p_enc, 0, serial, 0);
|
||||
reply.ga_len = 14 + STRLEN(p_enc) + STRLEN(serial);
|
||||
|
||||
/* Evaluate the expression and return the result. */
|
||||
// Evaluate the expression and return the result.
|
||||
if (res != NULL)
|
||||
ga_concat(&reply, res);
|
||||
else
|
||||
@@ -1485,11 +1484,11 @@ server_parse_message(
|
||||
*/
|
||||
static int
|
||||
AppendPropCarefully(
|
||||
Display *dpy, /* Display on which to operate. */
|
||||
Window window, /* Window whose property is to be modified. */
|
||||
Atom property, /* Name of property. */
|
||||
char_u *value, /* Characters to append to property. */
|
||||
int length) /* How much to append */
|
||||
Display *dpy, // Display on which to operate.
|
||||
Window window, // Window whose property is to be modified.
|
||||
Atom property, // Name of property.
|
||||
char_u *value, // Characters to append to property.
|
||||
int length) // How much to append
|
||||
{
|
||||
XErrorHandler old_handler;
|
||||
|
||||
@@ -1524,4 +1523,4 @@ IsSerialName(char_u *str)
|
||||
|
||||
return (len > 1 && vim_isdigit(str[len - 1]));
|
||||
}
|
||||
#endif /* FEAT_CLIENTSERVER */
|
||||
#endif // FEAT_CLIENTSERVER
|
||||
|
@@ -742,6 +742,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
2387,
|
||||
/**/
|
||||
2386,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user