diff src/if_lua.c @ 18798:f0f9692d4487 v8.1.2387

patch 8.1.2387: using old C style comments Commit: https://github.com/vim/vim/commit/2ab2e8608f9b2c85432715bb9a7f226fdbf8cd35 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Dec 4 21:24:53 2019 +0100 patch 8.1.2387: using old C style comments Problem: Using old C style comments. Solution: Use // comments where appropriate.
author Bram Moolenaar <Bram@vim.org>
date Wed, 04 Dec 2019 21:30:04 +0100
parents 026034963159
children ba9f50bfda83
line wrap: on
line diff
--- a/src/if_lua.c
+++ b/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_
 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(lu
 # 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(lu
 #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(lu
 #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(lu
 #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, i
 #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, c
 #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
 {
     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, typ
     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, i
     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;