1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: Calling debug.debug() in Lua may cause Vim to hang.
12 Solution: Add a better debug method. (Rob Hoelz, Luis Carvalho)
16 *** ../vim-7.3.316/src/if_lua.c 2011-01-17 19:53:20.000000000 +0100
17 --- src/if_lua.c 2011-09-21 17:15:21.000000000 +0200
21 #define lua_setfield dll_lua_setfield
22 #define lua_rawset dll_lua_rawset
23 #define lua_rawseti dll_lua_rawseti
24 + #define lua_remove dll_lua_remove
25 #define lua_setmetatable dll_lua_setmetatable
26 #define lua_call dll_lua_call
27 #define lua_pcall dll_lua_pcall
31 void (*dll_lua_setfield) (lua_State *L, int idx, const char *k);
32 void (*dll_lua_rawset) (lua_State *L, int idx);
33 void (*dll_lua_rawseti) (lua_State *L, int idx, int n);
34 + void (*dll_lua_remove) (lua_State *L, int idx);
35 int (*dll_lua_setmetatable) (lua_State *L, int objindex);
36 void (*dll_lua_call) (lua_State *L, int nargs, int nresults);
37 int (*dll_lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
41 {"lua_setfield", (luaV_function) &dll_lua_setfield},
42 {"lua_rawset", (luaV_function) &dll_lua_rawset},
43 {"lua_rawseti", (luaV_function) &dll_lua_rawseti},
44 + {"lua_remove", (luaV_function) &dll_lua_remove},
45 {"lua_setmetatable", (luaV_function) &dll_lua_setmetatable},
46 {"lua_call", (luaV_function) &dll_lua_call},
47 {"lua_pcall", (luaV_function) &dll_lua_pcall},
54 + luaV_debug(lua_State *L)
57 + lua_getglobal(L, "vim");
58 + lua_getfield(L, -1, "eval");
59 + lua_remove(L, -2); /* vim.eval at position 1 */
64 + lua_pushvalue(L, 1); /* vim.eval */
65 + lua_pushliteral(L, "input('lua_debug> ')");
66 + lua_call(L, 1, 1); /* return string */
67 + input = lua_tolstring(L, -1, &l);
68 + if (l == 0 || strcmp(input, "cont") == 0)
70 + msg_putchar('\n'); /* avoid outputting on input line */
71 + if (luaL_loadbuffer(L, input, l, "=(debug command)")
72 + || lua_pcall(L, 0, 0, 0))
74 + lua_settop(L, 1); /* remove eventual returns, but keep vim.eval */
79 luaV_command(lua_State *L)
81 do_cmdline_cmd((char_u *) luaL_checkstring(L, 1));
86 lua_pushcfunction(L, luaV_print);
87 lua_setglobal(L, "print");
89 + lua_getglobal(L, "debug");
90 + lua_pushcfunction(L, luaV_debug);
91 + lua_setfield(L, -2, "debug");
94 lua_pushlightuserdata(L, (void *) LUAVIM_FREE);
95 lua_pushcfunction(L, luaV_free);
96 *** ../vim-7.3.316/src/version.c 2011-09-21 13:40:13.000000000 +0200
97 --- src/version.c 2011-09-21 17:14:01.000000000 +0200
101 { /* Add new patch number below this line */
107 Q: What is the difference betwee open-source and commercial software?
108 A: If you have a problem with commercial software you can call a phone
109 number and they will tell you it might be solved in a future version.
110 For open-source software there isn't a phone number to call, but you
111 get the solution within a day.
113 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
114 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
115 \\\ an exciting new programming language -- http://www.Zimbu.org ///
116 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///