]>
Commit | Line | Data |
---|---|---|
59ab3540 AM |
1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.317 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.317 | |
11 | Problem: Calling debug.debug() in Lua may cause Vim to hang. | |
12 | Solution: Add a better debug method. (Rob Hoelz, Luis Carvalho) | |
13 | Files: src/if_lua.c | |
14 | ||
15 | ||
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 | |
18 | *************** | |
19 | *** 100,105 **** | |
20 | --- 100,106 ---- | |
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 | |
28 | *************** | |
29 | *** 161,166 **** | |
30 | --- 162,168 ---- | |
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); | |
38 | *************** | |
39 | *** 229,234 **** | |
40 | --- 231,237 ---- | |
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}, | |
48 | *************** | |
49 | *** 924,929 **** | |
50 | --- 927,957 ---- | |
51 | } | |
52 | ||
53 | static int | |
54 | + luaV_debug(lua_State *L) | |
55 | + { | |
56 | + lua_settop(L, 0); | |
57 | + lua_getglobal(L, "vim"); | |
58 | + lua_getfield(L, -1, "eval"); | |
59 | + lua_remove(L, -2); /* vim.eval at position 1 */ | |
60 | + for (;;) | |
61 | + { | |
62 | + const char *input; | |
63 | + size_t l; | |
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) | |
69 | + return 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)) | |
73 | + luaV_emsg(L); | |
74 | + lua_settop(L, 1); /* remove eventual returns, but keep vim.eval */ | |
75 | + } | |
76 | + } | |
77 | + | |
78 | + static int | |
79 | luaV_command(lua_State *L) | |
80 | { | |
81 | do_cmdline_cmd((char_u *) luaL_checkstring(L, 1)); | |
82 | *************** | |
83 | *** 1082,1087 **** | |
84 | --- 1110,1120 ---- | |
85 | /* print */ | |
86 | lua_pushcfunction(L, luaV_print); | |
87 | lua_setglobal(L, "print"); | |
88 | + /* debug.debug */ | |
89 | + lua_getglobal(L, "debug"); | |
90 | + lua_pushcfunction(L, luaV_debug); | |
91 | + lua_setfield(L, -2, "debug"); | |
92 | + lua_pop(L, 1); | |
93 | /* free */ | |
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 | |
98 | *************** | |
99 | *** 711,712 **** | |
100 | --- 711,714 ---- | |
101 | { /* Add new patch number below this line */ | |
102 | + /**/ | |
103 | + 317, | |
104 | /**/ | |
105 | ||
106 | -- | |
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. | |
112 | ||
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 /// |