Dash:
[t2-trunk.git] / package / lua / lua-curses / hotfix.patch
blob71c683c76d809282bac5582989cab8ce02728829
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../lua-curses/compile.patch
5 # Copyright (C) 2006 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 diff -ur lcurses-0.1-devel/Makefile lcurses-0.1-devel-t2/Makefile
18 --- lcurses-0.1-devel/Makefile 2004-08-29 22:22:05.000000000 +0200
19 +++ lcurses-0.1-devel-t2/Makefile 2006-02-12 23:08:39.000000000 +0100
20 @@ -5,19 +5,25 @@
21 TMP=/tmp
23 # change these to reflect your Lua installation
24 -LUA=../lua-5.0.2
25 -LUAINC= $(LUA)/include
26 -LUALIB= $(LUA)/lib
27 -LUABIN= $(LUA)/bin
28 +LUA = $(shell lua-config --prefix)
29 +LUAINC = $(shell lua-config --includedir)
30 +LUALIB = $(shell lua-config --libdir)
31 +LUABIN = lua
32 #LUABIN= /mingw/bin
34 +LUALIBDIR = $(shell lua-config --pkglibdir)
35 +LUADATADIR =$(shell lua-config --pkgdatadir)
37 +NCURSESINC=-I/usr/include
38 +NCURSESLIB=-lpanel -lncurses
40 # no need to change anything below here
41 -SHFLAGS= #-fPIC
42 +SHFLAGS= -fPIC
43 CFLAGS= $(INCS) $(DEFS) $(WARN) $(SHFLAGS) -O2
44 -DEFS= # -DDEBUG
45 -WARN= -Wall -Werror -ansi #-ansi -pedantic -Wall
46 -INCS= -I$(LUAINC) #-I../curses
47 -LIBS= -L$(LUALIB) -lpanel -lcurses #../curses/panel.a ../curses/pdcurses.a -llualib -llua
48 +DEFS= -DINCLUDEPANEL
49 +WARN= -Wall -Werror -ansi
50 +INCS= -I$(LUAINC) $(NCURSESINC)
51 +LIBS= -L$(LUALIB) $(NCURSESLIB)
53 MYNAME= curses
54 MYLIB= l$(MYNAME)
55 @@ -37,6 +43,10 @@
56 cui.lua cui.ctrls.lua testcui.lua \
57 firework.lua interp.lua
59 +INSTALL = install
60 +INSTALL_DATA = $(INSTALL) -m 644
61 +INSTALL_EXEC = $(INSTALL) -m 755
63 all: $T
65 lua: lcurses.c lua.c
66 @@ -64,3 +74,10 @@
67 @rm -fr $(TMP)/$(MYLIB)-$(VER)
68 @lsum $(TARFILE) $(DISTDIR)/md5sums.txt
69 @echo 'Done.'
71 +install: $T
72 + $(INSTALL_EXEC) -d $(DESTDIR)$(LUALIBDIR)/
73 + $(INSTALL_EXEC) -d $(DESTDIR)$(LUADATADIR)/cui/
74 + $(INSTALL_EXEC) lcurses.so $(DESTDIR)$(LUALIBDIR)/
75 + $(INSTALL_DATA) cui.lua curses.lua $(DESTDIR)$(LUADATADIR)/
76 + $(INSTALL_DATA) cui/*.lua $(DESTDIR)$(LUADATADIR)/cui/
77 diff -ur lcurses-0.1-devel/cui/__core.lua lcurses-0.1-devel-t2/cui/__core.lua
78 --- lcurses-0.1-devel/cui/__core.lua 2004-08-27 10:19:45.000000000 +0200
79 +++ lcurses-0.1-devel-t2/cui/__core.lua 2006-02-10 03:19:54.000000000 +0100
80 @@ -222,8 +222,7 @@
82 --[[ load curses binding ]------------------------------------------------]]
84 -require('requirelib')
85 -local curses = requirelib('lcurses', 'luaopen_curses', true)
86 +local curses = require('lcurses')
89 --[[ local utils ]--------------------------------------------------------]]
90 diff -ur lcurses-0.1-devel/cui/memory.lua lcurses-0.1-devel-t2/cui/memory.lua
91 --- lcurses-0.1-devel/cui/memory.lua 2004-05-22 19:17:26.000000000 +0200
92 +++ lcurses-0.1-devel-t2/cui/memory.lua 2006-02-10 14:03:03.000000000 +0100
93 @@ -55,7 +55,7 @@
94 local w = self:window()
95 local str = _cui.new_chstr(self.size.x)
96 local t, l = gcinfo()
97 - local info = t..':'..l
98 + local info = t..':'..(l or "nil")
99 local pad = self.size.x - string.len(info)
100 str:set_str(0, ' ', self.color, pad)
101 str:set_str(pad, info, self.color)
102 diff -ur lcurses-0.1-devel/cui.lua lcurses-0.1-devel-t2/cui.lua
103 --- lcurses-0.1-devel/cui.lua 2004-05-22 19:04:45.000000000 +0200
104 +++ lcurses-0.1-devel-t2/cui.lua 2006-02-10 03:17:59.000000000 +0100
105 @@ -3,4 +3,4 @@
106 assert(not cui, 'library already loaded!?')
108 -- load the cui system
109 -require 'cui/__core.lua'
110 +require 'cui/__core'
111 diff -ur lcurses-0.1-devel/curses.lua lcurses-0.1-devel-t2/curses.lua
112 --- lcurses-0.1-devel/curses.lua 2004-07-22 21:13:42.000000000 +0200
113 +++ lcurses-0.1-devel-t2/curses.lua 2006-02-10 03:18:40.000000000 +0100
114 @@ -13,6 +13,5 @@
116 --]]------------------------------------------------------------------------
118 -require('requirelib')
119 +require('lcurses')
121 -curses = requirelib('lcurses', 'luaopen_curses', true)
122 diff -ur lcurses-0.1-devel/lcurses.c lcurses-0.1-devel-t2/lcurses.c
123 --- lcurses-0.1-devel/lcurses.c 2004-08-29 22:22:05.000000000 +0200
124 +++ lcurses-0.1-devel-t2/lcurses.c 2006-02-10 13:28:48.000000000 +0100
125 @@ -649,14 +649,13 @@
126 static int lc_initscr(lua_State *L)
128 WINDOW *w;
130 /* initialize curses */
131 w = initscr();
133 /* no longer used, so clean it up */
134 lua_pushstring(L, RIPOFF_TABLE);
135 lua_pushnil(L);
136 - lua_settable(L, LUA_REGISTRYINDEX);
137 + lua_settable(L, LUA_REGISTRYINDEX);
139 /* failed to initialize */
140 if (w == NULL)
141 @@ -664,10 +663,10 @@
143 #if defined(PDCURSES)
144 /* PDCurses does not enable echo at startup! */
145 - echo();
146 + echo();
147 /* so we don't hang up after user presses a
148 modifier key until a normal key is pressed */
149 - PDC_return_key_modifiers(TRUE);
150 + PDC_return_key_modifiers(TRUE);
151 /*PDC_save_key_modifiers(TRUE);*/
152 #endif
154 @@ -677,7 +676,7 @@
155 #endif
157 /* return stdscr - main window */
158 - lcw_new(L, w);
159 + lcw_new(L, w);
161 /* save main window on registry */
162 lua_pushstring(L, STDSCR_REGISTRY);
163 @@ -687,10 +686,10 @@
164 /* setup curses constants - curses.xxx numbers */
165 register_curses_constants(L);
166 /* setup ascii map table */
167 - init_ascii_map();
168 + init_ascii_map();
170 /* install cleanup handler to help in debugging and screen trashing */
171 - atexit(cleanup);
172 + atexit(cleanup);
173 /* disable interrupt signal
174 signal(SIGINT, SIG_IGN);
175 signal(SIGBREAK, SIG_IGN);
176 @@ -2350,7 +2349,7 @@
180 -int luaopen_curses(lua_State *L)
181 +int luaopen_lcurses(lua_State *L)
184 ** create new metatable for window objects
185 @@ -2379,7 +2378,7 @@
186 ** create global table with curses methods/variables/constants
188 lua_newtable(L);
189 - #if 0
190 + #if 1
191 lua_pushliteral(L, "curses");
192 lua_pushvalue(L, -2);
193 lua_settable(L, LUA_GLOBALSINDEX);
194 @@ -2387,6 +2386,35 @@
195 lua_pushvalue(L, -1);
196 luaL_openlib(L, NULL, curseslib, 1);
201 +#ifdef INCLUDEPANEL
202 + /* metatable with used panels and associated windows */
203 + lua_newtable(L);
205 + /*
206 + ** create new metatable for window objects
207 + */
208 + luaL_newmetatable(L, PANELMETA);
209 + lua_pushliteral(L, "__index");
210 + lua_pushvalue(L, -2); /* push metatable */
211 + lua_rawset(L, -3); /* metatable.__index = metatable */
213 + lua_pushvalue(L, -2); /* upvalue table */
214 + luaL_openlib(L, NULL, panellib, 1);
216 + lua_pop(L, 1); /* remove metatable from stack */
218 + /*
219 + ** create global table with curses methods/variables/constants
220 + */
221 + lua_pop(L, 1);
222 + luaL_openlib(L, "curses", cursespanellib, 1);
223 +#endif
227 return 1;
230 Only in lcurses-0.1-devel-t2/: lcurses.o
231 Only in lcurses-0.1-devel-t2/: lcurses.so
232 diff -ur lcurses-0.1-devel/lpanel.c lcurses-0.1-devel-t2/lpanel.c
233 --- lcurses-0.1-devel/lpanel.c 2003-12-31 05:27:04.000000000 +0100
234 +++ lcurses-0.1-devel-t2/lpanel.c 2006-02-10 13:26:43.000000000 +0100
235 @@ -328,6 +328,7 @@
236 {NULL, NULL}
239 +#ifndef INCLUDEPANEL
241 ** TODO: add upvalue table with lightuserdata keys and weak keyed
242 ** values containing WINDOWS and PANELS used in above functions
243 @@ -357,3 +358,4 @@
244 luaL_openlib(L, "curses", cursespanellib, 1);
245 return 1;
247 +#endif
248 diff -ur lcurses-0.1-devel/test.lua lcurses-0.1-devel-t2/test.lua
249 --- lcurses-0.1-devel/test.lua 2004-08-29 22:22:05.000000000 +0200
250 +++ lcurses-0.1-devel-t2/test.lua 2006-02-10 14:16:27.000000000 +0100
251 @@ -1,5 +1,4 @@
252 ---require('bit')
254 +require('curses')
255 local _topw = {}
256 local top_lines = 10
257 curses.slk_init(2)
258 @@ -122,7 +121,7 @@
259 curses.doupdate()
262 -local ok, msg = xpcall(_main, _TRACEBACK)
263 +local ok, msg = xpcall(_main, debug.traceback)
265 curses.done()
267 diff -ur lcurses-0.1-devel/testcui.lua lcurses-0.1-devel-t2/testcui.lua
268 --- lcurses-0.1-devel/testcui.lua 2004-08-27 01:28:57.000000000 +0200
269 +++ lcurses-0.1-devel-t2/testcui.lua 2006-02-10 13:29:53.000000000 +0100
270 @@ -224,7 +224,7 @@
271 app:close()
274 -local ok, msg = xpcall(run, _TRACEBACK)
275 +local ok, msg = xpcall(run, debug.traceback)
277 if (not ok) then
278 if (not cui.isdone()) then