logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0002-support-lua-5.5.patch (18965B)


  1. From ca925be7690b0f895a03487d2c2288ba88968441 Mon Sep 17 00:00:00 2001
  2. From: Christian Hesse <mail@eworm.de>
  3. Date: Mon, 5 Jan 2026 15:01:19 +0100
  4. Subject: [PATCH] support lua 5.5...
  5. ... and replace the functions for unsigned integers with their
  6. signed equivalents, using a type cast where needed.
  7. Actually the functions for unsigned integers were deprecated since
  8. lua 5.3...
  9. https://www.lua.org/manual/5.3/manual.html#8.3
  10. Also lua_newstate() requires a third argument since 5.5...
  11. https://www.lua.org/manual/5.5/manual.html#8.3
  12. Finally the key in a for loop is now const, so use a temporary
  13. variable instead.
  14. ---
  15. configure | 4 +-
  16. lua/lexers/lexer.lua | 2 +-
  17. vis-lua.c | 117 ++++++++++++++++++++++---------------------
  18. 3 files changed, 64 insertions(+), 59 deletions(-)
  19. diff --git a/configure b/configure
  20. index dced540a..54f5a42b 100755
  21. --- a/configure
  22. +++ b/configure
  23. @@ -444,7 +444,7 @@ int main(int argc, char *argv[]) {
  24. }
  25. EOF
  26. - for liblua in lua lua5.4 lua5.3 lua5.2 lua-5.4 lua-5.3 lua-5.2 lua54 lua53 lua52; do
  27. + for liblua in lua lua5.5 lua5.4 lua5.3 lua5.2 lua-5.5 lua-5.4 lua-5.3 lua-5.2 lua55 lua54 lua53 lua52; do
  28. printf " checking for %s... " "$liblua"
  29. if test "$have_pkgconfig" = "yes" ; then
  30. @@ -505,7 +505,7 @@ int main(int argc, char *argv[]) {
  31. }
  32. EOF
  33. - for liblpeg in lpeg lua5.4-lpeg lua5.3-lpeg lua5.2-lpeg; do
  34. + for liblpeg in lpeg lua5.5-lpeg lua5.4-lpeg lua5.3-lpeg lua5.2-lpeg; do
  35. printf " checking for static %s... " "$liblpeg"
  36. if test "$have_pkgconfig" = "yes" ; then
  37. diff --git a/lua/lexers/lexer.lua b/lua/lexers/lexer.lua
  38. index f860d668..51c3b4b8 100644
  39. --- a/lua/lexers/lexer.lua
  40. +++ b/lua/lexers/lexer.lua
  41. @@ -1015,7 +1015,7 @@ function M.embed(lexer, child, start_rule, end_rule)
  42. if child._WORDLISTS then
  43. for name, i in pairs(child._WORDLISTS) do
  44. if type(name) == 'string' and type(i) == 'number' then
  45. - name = child._name .. '.' .. name
  46. + local tname = child._name .. '.' .. name
  47. lexer:word_match(name) -- for side effects
  48. lexer:set_word_list(name, child._WORDLISTS[i])
  49. end
  50. diff --git a/vis-lua.c b/vis-lua.c
  51. index a62daf89..26d3dc45 100644
  52. --- a/vis-lua.c
  53. +++ b/vis-lua.c
  54. @@ -496,7 +496,7 @@ static int newindex_common(lua_State *L) {
  55. }
  56. static size_t getpos(lua_State *L, int narg) {
  57. - return lua_tounsigned(L, narg);
  58. + return (size_t)lua_tointeger(L, narg);
  59. }
  60. static size_t checkpos(lua_State *L, int narg) {
  61. @@ -514,7 +514,7 @@ static void pushpos(lua_State *L, size_t pos) {
  62. if (pos == EPOS)
  63. lua_pushnil(L);
  64. else
  65. - lua_pushunsigned(L, pos);
  66. + lua_pushinteger(L, pos);
  67. }
  68. static void pushrange(lua_State *L, Filerange *r) {
  69. @@ -524,10 +524,10 @@ static void pushrange(lua_State *L, Filerange *r) {
  70. }
  71. lua_createtable(L, 0, 2);
  72. lua_pushstring(L, "start");
  73. - lua_pushunsigned(L, r->start);
  74. + lua_pushinteger(L, r->start);
  75. lua_settable(L, -3);
  76. lua_pushstring(L, "finish");
  77. - lua_pushunsigned(L, r->end);
  78. + lua_pushinteger(L, r->end);
  79. lua_settable(L, -3);
  80. }
  81. @@ -816,7 +816,7 @@ err:
  82. }
  83. static int keymap(lua_State *L, Vis *vis, Win *win) {
  84. - int mode = luaL_checkint(L, 2);
  85. + int mode = luaL_checkinteger(L, 2);
  86. const char *key = luaL_checkstring(L, 3);
  87. const char *help = luaL_optstring(L, 5, NULL);
  88. KeyBinding *binding = vis_binding_new(vis);
  89. @@ -922,7 +922,7 @@ static int map(lua_State *L) {
  90. * @see Window:unmap
  91. */
  92. static int keyunmap(lua_State *L, Vis *vis, Win *win) {
  93. - enum VisMode mode = luaL_checkint(L, 2);
  94. + enum VisMode mode = luaL_checkinteger(L, 2);
  95. const char *key = luaL_checkstring(L, 3);
  96. bool ret;
  97. if (!win)
  98. @@ -968,7 +968,7 @@ static bool binding_collect(const char *key, void *value, void *ctx) {
  99. static int mappings(lua_State *L) {
  100. Vis *vis = obj_ref_check(L, 1, "vis");
  101. lua_newtable(L);
  102. - for (Mode *mode = mode_get(vis, luaL_checkint(L, 2)); mode; mode = mode->parent) {
  103. + for (Mode *mode = mode_get(vis, luaL_checkinteger(L, 2)); mode; mode = mode->parent) {
  104. if (!mode->bindings)
  105. continue;
  106. map_iterate(mode->bindings, binding_collect, vis->lua);
  107. @@ -986,7 +986,7 @@ static int mappings(lua_State *L) {
  108. */
  109. static int motion(lua_State *L) {
  110. Vis *vis = obj_ref_check(L, 1, "vis");
  111. - enum VisMotion id = luaL_checkunsigned(L, 2);
  112. + enum VisMotion id = luaL_checkinteger(L, 2);
  113. // TODO handle var args?
  114. lua_pushboolean(L, vis && vis_motion(vis, id));
  115. return 1;
  116. @@ -997,7 +997,7 @@ static size_t motion_lua(Vis *vis, Win *win, void *data, size_t pos) {
  117. if (!L || !func_ref_get(L, data) || !obj_ref_new(L, win, VIS_LUA_TYPE_WINDOW))
  118. return EPOS;
  119. - lua_pushunsigned(L, pos);
  120. + lua_pushinteger(L, pos);
  121. if (pcall(vis, L, 2, 1) != 0)
  122. return EPOS;
  123. return getpos(L, -1);
  124. @@ -1035,7 +1035,7 @@ static int motion_register(lua_State *L) {
  125. */
  126. static int operator(lua_State *L) {
  127. Vis *vis = obj_ref_check(L, 1, "vis");
  128. - enum VisOperator id = luaL_checkunsigned(L, 2);
  129. + enum VisOperator id = luaL_checkinteger(L, 2);
  130. // TODO handle var args?
  131. lua_pushboolean(L, vis && vis_operator(vis, id));
  132. return 1;
  133. @@ -1094,7 +1094,7 @@ static int operator_register(lua_State *L) {
  134. */
  135. static int textobject(lua_State *L) {
  136. Vis *vis = obj_ref_check(L, 1, "vis");
  137. - enum VisTextObject id = luaL_checkunsigned(L, 2);
  138. + enum VisTextObject id = luaL_checkinteger(L, 2);
  139. lua_pushboolean(L, vis_textobject(vis, id));
  140. return 1;
  141. }
  142. @@ -1103,7 +1103,7 @@ static Filerange textobject_lua(Vis *vis, Win *win, void *data, size_t pos) {
  143. lua_State *L = vis->lua;
  144. if (!L || !func_ref_get(L, data) || !obj_ref_new(L, win, VIS_LUA_TYPE_WINDOW))
  145. return text_range_empty();
  146. - lua_pushunsigned(L, pos);
  147. + lua_pushinteger(L, pos);
  148. if (pcall(vis, L, 2, 2) != 0 || lua_isnil(L, -1))
  149. return text_range_empty();
  150. return text_range_new(getpos(L, -2), getpos(L, -1));
  151. @@ -1205,7 +1205,7 @@ static bool command_lua(Vis *vis, Win *win, void *data, bool force, const char *
  152. return false;
  153. lua_newtable(L);
  154. for (size_t i = 0; argv[i]; i++) {
  155. - lua_pushunsigned(L, i);
  156. + lua_pushinteger(L, i);
  157. lua_pushstring(L, argv[i]);
  158. lua_settable(L, -3);
  159. }
  160. @@ -1320,7 +1320,7 @@ static int replace(lua_State *L) {
  161. */
  162. static int exit_func(lua_State *L) {
  163. Vis *vis = obj_ref_check(L, 1, "vis");
  164. - int code = luaL_checkint(L, 2);
  165. + int code = luaL_checkinteger(L, 2);
  166. vis_exit(vis, code);
  167. return 0;
  168. }
  169. @@ -1475,7 +1475,7 @@ static int vis_index(lua_State *L) {
  170. }
  171. if (strcmp(key, "mode") == 0) {
  172. - lua_pushunsigned(L, vis->mode->id);
  173. + lua_pushinteger(L, vis->mode->id);
  174. return 1;
  175. }
  176. @@ -1494,7 +1494,7 @@ static int vis_index(lua_State *L) {
  177. if (count == VIS_COUNT_UNKNOWN)
  178. lua_pushnil(L);
  179. else
  180. - lua_pushunsigned(L, count);
  181. + lua_pushinteger(L, count);
  182. return 1;
  183. }
  184. @@ -1536,7 +1536,7 @@ static int vis_options_assign(Vis *vis, lua_State *L, const char *key, int next)
  185. vis->change_colors = lua_toboolean(L, next);
  186. } else if (strcmp(key, "escdelay") == 0) {
  187. TermKey *tk = vis->ui->termkey_get(vis->ui);
  188. - termkey_set_waittime(tk, luaL_checkint(L, next));
  189. + termkey_set_waittime(tk, luaL_checkinteger(L, next));
  190. } else if (strcmp(key, "ignorecase") == 0 || strcmp(key, "ic") == 0) {
  191. vis->ignorecase = lua_toboolean(L, next);
  192. } else if (strcmp(key, "loadmethod") == 0) {
  193. @@ -1562,7 +1562,7 @@ static int vis_newindex(lua_State *L) {
  194. if (lua_isstring(L, 2)) {
  195. const char *key = lua_tostring(L, 2);
  196. if (strcmp(key, "mode") == 0) {
  197. - enum VisMode mode = luaL_checkunsigned(L, 3);
  198. + enum VisMode mode = luaL_checkinteger(L, 3);
  199. vis_mode_switch(vis, mode);
  200. return 0;
  201. }
  202. @@ -1572,7 +1572,7 @@ static int vis_newindex(lua_State *L) {
  203. if (lua_isnil(L, 3))
  204. count = VIS_COUNT_UNKNOWN;
  205. else
  206. - count = luaL_checkunsigned(L, 3);
  207. + count = luaL_checkinteger(L, 3);
  208. vis_count_set(vis, count);
  209. return 0;
  210. }
  211. @@ -1677,7 +1677,7 @@ static int vis_options_index(lua_State *L) {
  212. return 1;
  213. } else if (strcmp(key, "escdelay") == 0) {
  214. TermKey *tk = vis->ui->termkey_get(vis->ui);
  215. - lua_pushunsigned(L, termkey_get_waittime(tk));
  216. + lua_pushinteger(L, termkey_get_waittime(tk));
  217. return 1;
  218. } else if (strcmp(key, "ignorecase") == 0 || strcmp(key, "ic") == 0) {
  219. lua_pushboolean(L, vis->ignorecase);
  220. @@ -1739,7 +1739,7 @@ static int ui_index(lua_State *L) {
  221. const char *key = lua_tostring(L, 2);
  222. if (strcmp(key, "layout") == 0) {
  223. - lua_pushunsigned(L, ui_layout_get(ui));
  224. + lua_pushinteger(L, ui_layout_get(ui));
  225. return 1;
  226. }
  227. }
  228. @@ -1754,7 +1754,7 @@ static int ui_newindex(lua_State *L) {
  229. const char *key = lua_tostring(L, 2);
  230. if (strcmp(key, "layout") == 0) {
  231. - ui->arrange(ui, luaL_checkint(L, 3));
  232. + ui->arrange(ui, luaL_checkinteger(L, 3));
  233. return 0;
  234. }
  235. }
  236. @@ -1779,7 +1779,7 @@ static int registers_index(lua_State *L) {
  237. Array data = vis_register_get(vis, reg);
  238. for (size_t i = 0, len = array_length(&data); i < len; i++) {
  239. TextString *string = array_get(&data, i);
  240. - lua_pushunsigned(L, i+1);
  241. + lua_pushinteger(L, i+1);
  242. lua_pushlstring(L, string->data, string->len);
  243. lua_settable(L, -3);
  244. }
  245. @@ -1813,7 +1813,7 @@ static int registers_newindex(lua_State *L) {
  246. static int registers_len(lua_State *L) {
  247. Vis *vis = lua_touserdata(L, lua_upvalueindex(1));
  248. - lua_pushunsigned(L, LENGTH(vis->registers));
  249. + lua_pushinteger(L, LENGTH(vis->registers));
  250. return 1;
  251. }
  252. @@ -1885,21 +1885,21 @@ static int window_index(lua_State *L) {
  253. pushrange(L, &l);
  254. lua_settable(L, -3);
  255. lua_pushstring(L, "width");
  256. - lua_pushunsigned(L, view_width_get(win->view));
  257. + lua_pushinteger(L, view_width_get(win->view));
  258. lua_settable(L, -3);
  259. lua_pushstring(L, "height");
  260. - lua_pushunsigned(L, view_height_get(win->view));
  261. + lua_pushinteger(L, view_height_get(win->view));
  262. lua_settable(L, -3);
  263. return 1;
  264. }
  265. if (strcmp(key, "width") == 0) {
  266. - lua_pushunsigned(L, vis_window_width_get(win));
  267. + lua_pushinteger(L, vis_window_width_get(win));
  268. return 1;
  269. }
  270. if (strcmp(key, "height") == 0) {
  271. - lua_pushunsigned(L, vis_window_height_get(win));
  272. + lua_pushinteger(L, vis_window_height_get(win));
  273. return 1;
  274. }
  275. @@ -1938,7 +1938,7 @@ static int window_options_assign(Win *win, lua_State *L, const char *key, int ne
  276. if (lua_isstring(L, next))
  277. view_breakat_set(win->view, lua_tostring(L, next));
  278. } else if (strcmp(key, "colorcolumn") == 0 || strcmp(key, "cc") == 0) {
  279. - view_colorcolumn_set(win->view, luaL_checkint(L, next));
  280. + view_colorcolumn_set(win->view, luaL_checkinteger(L, next));
  281. } else if (strcmp(key, "cursorline") == 0 || strcmp(key, "cul") == 0) {
  282. if (lua_toboolean(L, next))
  283. flags |= UI_OPTION_CURSOR_LINE;
  284. @@ -1988,9 +1988,9 @@ static int window_options_assign(Win *win, lua_State *L, const char *key, int ne
  285. flags &= ~UI_OPTION_STATUSBAR;
  286. view_options_set(win->view, flags);
  287. } else if (strcmp(key, "wrapcolumn") == 0 || strcmp(key, "wc") == 0) {
  288. - view_wrapcolumn_set(win->view, luaL_checkint(L, next));
  289. + view_wrapcolumn_set(win->view, luaL_checkinteger(L, next));
  290. } else if (strcmp(key, "tabwidth") == 0 || strcmp(key, "tw") == 0) {
  291. - view_tabwidth_set(win->view, luaL_checkint(L, next));
  292. + view_tabwidth_set(win->view, luaL_checkinteger(L, next));
  293. } else if (strcmp(key, "expandtab") == 0 || strcmp(key, "et") == 0) {
  294. win->expandtab = lua_toboolean(L, next);
  295. }
  296. @@ -2086,7 +2086,7 @@ static int window_unmap(lua_State *L) {
  297. */
  298. static int window_style_define(lua_State *L) {
  299. Win *win = obj_ref_check(L, 1, VIS_LUA_TYPE_WINDOW);
  300. - enum UiStyle id = luaL_checkunsigned(L, 2);
  301. + enum UiStyle id = luaL_checkinteger(L, 2);
  302. const char *style = luaL_checkstring(L, 3);
  303. bool ret = view_style_define(win->view, id, style);
  304. lua_pushboolean(L, ret);
  305. @@ -2107,7 +2107,7 @@ static int window_style_define(lua_State *L) {
  306. */
  307. static int window_style(lua_State *L) {
  308. Win *win = obj_ref_check(L, 1, VIS_LUA_TYPE_WINDOW);
  309. - enum UiStyle style = luaL_checkunsigned(L, 2);
  310. + enum UiStyle style = luaL_checkinteger(L, 2);
  311. size_t start = checkpos(L, 3);
  312. size_t end = checkpos(L, 4);
  313. view_style(win->view, style, start, end);
  314. @@ -2132,7 +2132,7 @@ static int window_style(lua_State *L) {
  315. */
  316. static int window_style_pos(lua_State *L) {
  317. Win *win = obj_ref_check(L, 1, VIS_LUA_TYPE_WINDOW);
  318. - enum UiStyle style = luaL_checkunsigned(L, 2);
  319. + enum UiStyle style = luaL_checkinteger(L, 2);
  320. size_t x = checkpos(L, 3);
  321. size_t y = checkpos(L, 4);
  322. bool ret = win->ui->style_set_pos(win->ui, (int)x, (int)y, style);
  323. @@ -2245,7 +2245,7 @@ static int window_options_index(lua_State *L) {
  324. lua_pushstring(L, view_breakat_get(win->view));
  325. return 1;
  326. } else if (strcmp(key, "colorcolumn") == 0 || strcmp(key, "cc") == 0) {
  327. - lua_pushunsigned(L, view_colorcolumn_get(win->view));
  328. + lua_pushinteger(L, view_colorcolumn_get(win->view));
  329. return 1;
  330. } else if (strcmp(key, "cursorline") == 0 || strcmp(key, "cul") == 0) {
  331. lua_pushboolean(L, view_options_get(win->view) & UI_OPTION_CURSOR_LINE);
  332. @@ -2278,7 +2278,7 @@ static int window_options_index(lua_State *L) {
  333. lua_pushinteger(L, view_tabwidth_get(win->view));
  334. return 1;
  335. } else if (strcmp(key, "wrapcolumn") == 0 || strcmp(key, "wc") == 0) {
  336. - lua_pushunsigned(L, view_wrapcolumn_get(win->view));
  337. + lua_pushinteger(L, view_wrapcolumn_get(win->view));
  338. return 1;
  339. }
  340. }
  341. @@ -2302,7 +2302,7 @@ static const struct luaL_Reg window_option_funcs[] = {
  342. static int window_selections_index(lua_State *L) {
  343. View *view = obj_ref_check(L, 1, VIS_LUA_TYPE_SELECTIONS);
  344. - size_t index = luaL_checkunsigned(L, 2);
  345. + size_t index = luaL_checkinteger(L, 2);
  346. size_t count = view_selections_count(view);
  347. if (index == 0 || index > count)
  348. goto err;
  349. @@ -2319,7 +2319,7 @@ err:
  350. static int window_selections_len(lua_State *L) {
  351. View *view = obj_ref_check(L, 1, VIS_LUA_TYPE_SELECTIONS);
  352. - lua_pushunsigned(L, view_selections_count(view));
  353. + lua_pushinteger(L, view_selections_count(view));
  354. return 1;
  355. }
  356. @@ -2442,17 +2442,17 @@ static int window_selection_index(lua_State *L) {
  357. }
  358. if (strcmp(key, "line") == 0) {
  359. - lua_pushunsigned(L, view_cursors_line(sel));
  360. + lua_pushinteger(L, view_cursors_line(sel));
  361. return 1;
  362. }
  363. if (strcmp(key, "col") == 0) {
  364. - lua_pushunsigned(L, view_cursors_col(sel));
  365. + lua_pushinteger(L, view_cursors_col(sel));
  366. return 1;
  367. }
  368. if (strcmp(key, "number") == 0) {
  369. - lua_pushunsigned(L, view_selections_number(sel)+1);
  370. + lua_pushinteger(L, view_selections_number(sel)+1);
  371. return 1;
  372. }
  373. @@ -2601,7 +2601,7 @@ static int file_index(lua_State *L) {
  374. }
  375. if (strcmp(key, "size") == 0) {
  376. - lua_pushunsigned(L, text_size(file->text));
  377. + lua_pushinteger(L, text_size(file->text));
  378. return 1;
  379. }
  380. @@ -2612,7 +2612,7 @@ static int file_index(lua_State *L) {
  381. if (strcmp(key, "permission") == 0) {
  382. struct stat stat = text_stat(file->text);
  383. - lua_pushunsigned(L, stat.st_mode & 0777);
  384. + lua_pushinteger(L, stat.st_mode & 0777);
  385. return 1;
  386. }
  387. @@ -2723,7 +2723,7 @@ static int file_delete(lua_State *L) {
  388. static int file_lines_iterator_it(lua_State *L);
  389. static int file_lines_iterator(lua_State *L) {
  390. File *file = obj_ref_check(L, 1, VIS_LUA_TYPE_FILE);
  391. - size_t line = luaL_optunsigned(L, 2, 1);
  392. + size_t line = luaL_optinteger(L, 2, 1);
  393. size_t *pos = lua_newuserdata(L, sizeof *pos);
  394. *pos = text_pos_by_lineno(file->text, line);
  395. lua_pushcclosure(L, file_lines_iterator_it, 2);
  396. @@ -2812,7 +2812,7 @@ static int file_mark_get(lua_State *L) {
  397. if (pos == EPOS)
  398. lua_pushnil(L);
  399. else
  400. - lua_pushunsigned(L, pos);
  401. + lua_pushinteger(L, pos);
  402. return 1;
  403. }
  404. @@ -2860,7 +2860,7 @@ static const struct luaL_Reg file_funcs[] = {
  405. static int file_lines_index(lua_State *L) {
  406. Text *txt = obj_ref_check(L, 1, VIS_LUA_TYPE_TEXT);
  407. - size_t line = luaL_checkunsigned(L, 2);
  408. + size_t line = luaL_checkinteger(L, 2);
  409. size_t start = text_pos_by_lineno(txt, line);
  410. size_t end = text_line_end(txt, start);
  411. if (start != EPOS && end != EPOS) {
  412. @@ -2879,7 +2879,7 @@ err:
  413. static int file_lines_newindex(lua_State *L) {
  414. Text *txt = obj_ref_check(L, 1, VIS_LUA_TYPE_TEXT);
  415. - size_t line = luaL_checkunsigned(L, 2);
  416. + size_t line = luaL_checkinteger(L, 2);
  417. size_t size;
  418. const char *data = luaL_checklstring(L, 3, &size);
  419. if (line == 0) {
  420. @@ -2907,7 +2907,7 @@ static int file_lines_len(lua_State *L) {
  421. lines = text_lineno_by_pos(txt, size);
  422. if (lines > 1 && text_byte_get(txt, size-1, &lastchar) && lastchar == '\n')
  423. lines--;
  424. - lua_pushunsigned(L, lines);
  425. + lua_pushinteger(L, lines);
  426. return 1;
  427. }
  428. @@ -2934,7 +2934,7 @@ static int window_marks_index(lua_State *L) {
  429. Array arr = vis_mark_get(win, mark);
  430. for (size_t i = 0, len = array_length(&arr); i < len; i++) {
  431. Filerange *range = array_get(&arr, i);
  432. - lua_pushunsigned(L, i+1);
  433. + lua_pushinteger(L, i+1);
  434. pushrange(L, range);
  435. lua_settable(L, -3);
  436. }
  437. @@ -2973,7 +2973,7 @@ static int window_marks_newindex(lua_State *L) {
  438. }
  439. static int window_marks_len(lua_State *L) {
  440. - lua_pushunsigned(L, VIS_MARK_INVALID);
  441. + lua_pushinteger(L, VIS_MARK_INVALID);
  442. return 1;
  443. }
  444. @@ -3208,7 +3208,12 @@ static void *alloc_lua(void *ud, void *ptr, size_t osize, size_t nsize) {
  445. * @function init
  446. */
  447. void vis_lua_init(Vis *vis) {
  448. - lua_State *L = lua_newstate(alloc_lua, vis);
  449. + lua_State *L =
  450. +#if LUA_VERSION_NUM >= 505
  451. + lua_newstate(alloc_lua, vis, luaL_makeseed(NULL));
  452. +#else
  453. + lua_newstate(alloc_lua, vis);
  454. +#endif
  455. if (!L)
  456. return;
  457. vis->lua = L;
  458. @@ -3308,7 +3313,7 @@ void vis_lua_init(Vis *vis) {
  459. };
  460. for (size_t i = 0; i < LENGTH(textobjects); i++) {
  461. - lua_pushunsigned(L, textobjects[i].id);
  462. + lua_pushinteger(L, textobjects[i].id);
  463. lua_pushcclosure(L, file_text_object, 1);
  464. lua_setfield(L, -2, textobjects[i].name);
  465. }
  466. @@ -3341,7 +3346,7 @@ void vis_lua_init(Vis *vis) {
  467. };
  468. for (size_t i = 0; i < LENGTH(styles); i++) {
  469. - lua_pushunsigned(L, styles[i].id);
  470. + lua_pushinteger(L, styles[i].id);
  471. lua_setfield(L, -2, styles[i].name);
  472. }
  473. @@ -3360,7 +3365,7 @@ void vis_lua_init(Vis *vis) {
  474. obj_type_new(L, VIS_LUA_TYPE_UI);
  475. luaL_setfuncs(L, ui_funcs, 0);
  476. - lua_pushunsigned(L, vis->ui->colors(vis->ui));
  477. + lua_pushinteger(L, vis->ui->colors(vis->ui));
  478. lua_setfield(L, -2, "colors");
  479. lua_newtable(L);
  480. static const struct {
  481. @@ -3371,7 +3376,7 @@ void vis_lua_init(Vis *vis) {
  482. { UI_LAYOUT_VERTICAL, "VERTICAL" },
  483. };
  484. for (size_t i = 0; i < LENGTH(layouts); i++) {
  485. - lua_pushunsigned(L, layouts[i].id);
  486. + lua_pushinteger(L, layouts[i].id);
  487. lua_setfield(L, -2, layouts[i].name);
  488. }
  489. lua_setfield(L, -2, "layouts");
  490. @@ -3401,7 +3406,7 @@ void vis_lua_init(Vis *vis) {
  491. { VIS_MODE_REPLACE, "REPLACE" },
  492. };
  493. for (size_t i = 0; i < LENGTH(modes); i++) {
  494. - lua_pushunsigned(L, modes[i].id);
  495. + lua_pushinteger(L, modes[i].id);
  496. lua_setfield(L, -2, modes[i].name);
  497. }
  498. lua_setfield(L, -2, "modes");
  499. --
  500. 2.49.0