1 diff -r lua-5.0/doc/manual.html lua-5.0.1/doc/manual.html
3 < <title>Lua 5.0 Reference Manual</title>
5 > <TITLE>Lua: 5.0 reference manual</TITLE>
7 < <a HREF="http://www.lua.org/home.html">
8 < <img SRC="logo.gif" ALT="[Lua logo]" BORDER=0>
11 > <A HREF="http://www.lua.org/home.html"><IMG SRC="logo.gif" ALT="Lua" BORDER=0></A>
13 < © 2003 TeCGraf, PUC-Rio. All rights reserved.
15 > © 2003 Tecgraf, PUC-Rio. All rights reserved.
17 < <h1>1 - Introduction</h1>
19 > <a name="1"><h1>1 - Introduction</h1></a>
21 < It also offers good suport for object-oriented programming,
23 > It also offers good support for object-oriented programming,
25 < <p>The Lua distribuition includes a stand-alone embedding program,
27 > <p>The Lua distribution includes a stand-alone embedding program,
29 < <a name="language"><h1>2 - The Language</h1></a>
31 > <a name="language"><a name="2"><h1>2 - The Language</h1></a></a>
33 < <p><a name="lexical"><h2>2.1 - Lexical Conventions</h2></a>
35 > <p><a name="lexical"><a name="2.1"><h2>2.1 - Lexical Conventions</h2></a></a>
37 < repeat return then true until
40 > repeat return then true until while
42 < <p><a name="TypesSec"><h2>2.2 - Values and Types</h2></a>
44 > <p><a name="TypesSec"><a name="2.2"><h2>2.2 - Values and Types</h2></a></a>
46 < <p><a name="coercion"><h3>2.2.1 - Coercion</h3></a>
48 > <p><a name="coercion"><a name="2.2.1"><h3>2.2.1 - Coercion</h3></a></a>
50 < <p><a name="variables"><h2>2.3 - Variables</h2></a>
52 > <p><a name="variables"><a name="2.3"><h2>2.3 - Variables</h2></a></a>
54 < <p><a name="stats"><h2>2.4 - Statements</h2></a>
56 > <p><a name="stats"><a name="2.4"><h2>2.4 - Statements</h2></a></a>
58 < <p><a name="chunks"><h3>2.4.1 - Chunks</h3></a>
60 > <p><a name="chunks"><a name="2.4.1"><h3>2.4.1 - Chunks</h3></a></a>
62 < <p><h3>2.4.2 - Blocks</h3>
64 > <p><a name="2.4.2"><h3>2.4.2 - Blocks</h3></a>
66 < <p><a name="assignment"><h3>2.4.3 - Assignment</h3></a>
68 > <p><a name="assignment"><a name="2.4.3"><h3>2.4.3 - Assignment</h3></a></a>
70 < before it is assigned 4.
72 > before it is assigned 4.
74 < <p><a name="control"><h3>2.4.4 - Control Structures</h3></a>
76 > <p><a name="control"><a name="2.4.4"><h3>2.4.4 - Control Structures</h3></a></a>
78 < skiping to the next statement after the loop:
80 > skipping to the next statement after the loop:
82 < <p><a name="for"><h3>2.4.5 - For Statement</h3></a>
84 > <p><a name="for"><a name="2.4.5"><h3>2.4.5 - For Statement</h3></a></a>
86 < <p><a name="funcstat"><h3>2.4.6 - Function Calls as Statements</h3></a>
88 > <p><a name="funcstat"><a name="2.4.6"><h3>2.4.6 - Function Calls as Statements</h3></a></a>
90 < <p><a name="localvar"><h3>2.4.7 - Local Declarations</h3></a>
92 > <p><a name="localvar"><a name="2.4.7"><h3>2.4.7 - Local Declarations</h3></a></a>
94 < <p><a name="expressions"><h2>2.5 - Expressions</h2></a>
96 > <p><a name="expressions"><a name="2.5"><h2>2.5 - Expressions</h2></a></a>
98 < <p><h3>2.5.1 - Arithmetic Operators</h3>
100 > <p><a name="2.5.1"><h3>2.5.1 - Arithmetic Operators</h3></a>
102 < <p><a name="rel-ops"><h3>2.5.2 - Relational Operators</h3></a>
104 > <p><a name="rel-ops"><a name="2.5.2"><h3>2.5.2 - Relational Operators</h3></a></a>
106 < <p><h3>2.5.3 - Logical Operators</h3>
108 > <p><a name="2.5.3"><h3>2.5.3 - Logical Operators</h3></a>
110 < <p><a name="concat"><h3>2.5.4 - Concatenation</h3></a>
112 > <p><a name="concat"><a name="2.5.4"><h3>2.5.4 - Concatenation</h3></a></a>
114 < <p><h3>2.5.5 - Precedence</h3>
116 > <p><a name="2.5.5"><h3>2.5.5 - Precedence</h3></a>
118 < As usual, you can use parentheses to change the precedences of an expression.
120 > You can use parentheses to change the precedences in an expression.
122 < <p><a name="tableconstructor"><h3>2.5.6 - Table Constructors</h3></a>
124 > <p><a name="tableconstructor"><a name="2.5.6"><h3>2.5.6 - Table Constructors</h3></a></a>
126 < <p><a name="functioncall"><h3>2.5.7 - Function Calls</h3></a>
128 > <p><a name="functioncall"><a name="2.5.7"><h3>2.5.7 - Function Calls</h3></a></a>
130 < return x, f(x) -- adicional results
132 > return x, f(x) -- additional results
134 < <p><a name="func-def"><h3>2.5.8 - Function Definitions</h3></a>
136 > <p><a name="func-def"><a name="2.5.8"><h3>2.5.8 - Function Definitions</h3></a></a>
138 < <p><a name="visibility"><h2>2.6 - Visibility Rules</h2></a>
140 > <p><a name="visibility"><a name="2.6"><h2>2.6 - Visibility Rules</h2></a></a>
142 < <p><a name="error"><h2>2.7 - Error Handling</h2></a>
144 > <p><a name="error"><a name="2.7"><h2>2.7 - Error Handling</h2></a></a>
146 < <p><a name="metatable"><h2>2.8 - Metatables</h2></a>
148 > <p><a name="metatable"><a name="2.8"><h2>2.8 - Metatables</h2></a></a>
150 < if type(op1) ~= type(op2) then -- diferent types?
152 > if type(op1) ~= type(op2) then -- different types?
154 < <p><a name="GC"><h2>2.9 - Garbage Collection</h2></a>
156 > <p><a name="GC"><a name="2.9"><h2>2.9 - Garbage Collection</h2></a></a>
158 < <p><h3>2.9.1 - Garbage-Collection Metamethods</h3>
160 > <p><a name="2.9.1"><h3>2.9.1 - Garbage-Collection Metamethods</h3></a>
162 < <p><a name="weak-table"><h3>2.9.2 - Weak Tables</h3></a>
164 > <p><a name="weak-table"><a name="2.9.2"><h3>2.9.2 - Weak Tables</h3></a></a>
166 < If the <code>__mode</code> field is a string containing the character `<code>k</code>´,
168 > If the <code>__mode</code> field is a string containing the character `<code>k</code>´,
170 < <p><a name="coroutine"><h2>2.10 - Coroutines</h2></a>
172 > <p><a name="coroutine"><a name="2.10"><h2>2.10 - Coroutines</h2></a></a>
174 < passing as argument the thread returned by <code>coroutine.create</code>,
176 > passing as its first argument the thread returned by <code>coroutine.create</code>,
178 < <a name="API"><h1>3 - The Application Program Interface</h1></a>
180 > <a name="API"><a name="3"><h1>3 - The Application Program Interface</h1></a></a>
182 < <p><a name="mangstate"><h2>3.1 - States</h2></a>
184 > <p><a name="mangstate"><a name="3.1"><h2>3.1 - States</h2></a></a>
186 < <p><h2>3.2 - The Stack and Indices</h2>
188 > <p><a name="3.2"><h2>3.2 - The Stack and Indices</h2></a>
190 < and it is where the C function pushes its results (see <a href="#LuacallC">3.16</a>)
192 > and it is where the C function pushes its results to be returned to the caller (see <a href="#LuacallC">3.16</a>)
194 < it ensures that at least <code>LUA_MINSTACK</code> positions are available.
196 > it ensures that at least <code>LUA_MINSTACK</code> stack positions are available.
198 < <p><h2>3.3 - Stack Manipulation</h2>
200 > <p><a name="3.3"><h2>3.3 - Stack Manipulation</h2></a>
202 < <p><h2>3.4 - Querying the Stack</h2>
204 > <p><a name="3.4"><h2>3.4 - Querying the Stack</h2></a>
206 < <p><a name="lua-to"><h2>3.5 - Getting Values from the Stack</h2></a>
208 > <p><a name="lua-to"><a name="3.5"><h2>3.5 - Getting Values from the Stack</h2></a></a>
210 < <p><a name="pushing"><h2>3.6 - Pushing Values onto the Stack</h2></a>
212 > <p><a name="pushing"><a name="3.6"><h2>3.6 - Pushing Values onto the Stack</h2></a></a>
214 < const char *lua_pushvfstring (lua_State *L, const char *fmt,
217 > const char *lua_pushvfstring (lua_State *L, const char *fmt, va_list argp);
219 < If <code>n</code> is 1, the result is that single string
221 > If <code>n</code> is 1, the result is that single string
223 < <p><a name="GC-API"><h2>3.7 - Controlling Garbage Collection</h2></a>
225 > <p><a name="GC-API"><a name="3.7"><h2>3.7 - Controlling Garbage Collection</h2></a></a>
227 < int lua_getgccount (lua_State *L);
229 > int lua_getgccount (lua_State *L);
231 < <p><a name="userdata"><h2>3.8 - Userdata</h2></a>
233 > <p><a name="userdata"><a name="3.8"><h2>3.8 - Userdata</h2></a></a>
235 < <p><h2>3.9 - Metatables</h2>
237 > <p><a name="3.9"><h2>3.9 - Metatables</h2></a>
239 < <p><h2>3.10 - Loading Lua Chunks</h2>
241 > <p><a name="3.10"><h2>3.10 - Loading Lua Chunks</h2></a>
243 < <p><code>lua_load</code> uses an user-supplied <em>reader</em> function to read the chunk.
245 > <p><code>lua_load</code> uses a user-supplied <em>reader</em> function to read the chunk.
247 < it calls the reader,
249 > <code>lua_load</code> calls the reader,
251 < <p><h2>3.11 - Manipulating Tables</h2>
253 > <p><a name="3.11"><h2>3.11 - Manipulating Tables</h2></a>
255 < <p><a name="globals"><h2>3.12 - Manipulating Environments</h2></a>
257 > <p><a name="globals"><a name="3.12"><h2>3.12 - Manipulating Environments</h2></a></a>
259 < <p><h2>3.13 - Using Tables as Arrays</h2>
261 > <p><a name="3.13"><h2>3.13 - Using Tables as Arrays</h2></a>
263 < <p><h2>3.14 - Calling Functions</h2>
265 > <p><a name="3.14"><h2>3.14 - Calling Functions</h2></a>
267 < <p><a name="lua_pcall"><h2>3.15 - Protected Calls</h2></a>
269 > <p><a name="lua_pcall"><a name="3.15"><h2>3.15 - Protected Calls</h2></a></a>
271 < <p><a name="LuacallC"><h2>3.16 - Defining C Functions</h2></a>
273 > <p><a name="LuacallC"><a name="3.16"><h2>3.16 - Defining C Functions</h2></a></a>
275 < <p><a name="c-closure"><h2>3.17 - Defining C Closures</h2></a>
277 > <p><a name="c-closure"><a name="3.17"><h2>3.17 - Defining C Closures</h2></a></a>
279 < <p><a name="registry"><h2>3.18 - Registry</h2></a>
281 > <p><a name="registry"><a name="3.18"><h2>3.18 - Registry</h2></a></a>
283 < <p><h2>3.19 - Error Handling in C</h2>
285 > <p><a name="3.19"><h2>3.19 - Error Handling in C</h2></a>
287 < to set a recover point,
288 < and any error jumps to the most recent active recover point.
290 > to set a recover point;
291 > any error jumps to the most recent active recover point.
293 < Lua calls a <em>panic function</em>,
295 > Lua calls a <em>panic function</em>
297 < never returning (e.g. doing a long jump).
298 < Nevertheless, the corresponding Lua will not be consistent;
300 > never returning (e.g., by doing a long jump).
301 > Nevertheless, the corresponding Lua state will not be consistent;
303 < Any value returned by <code>func</code> is dicarded.
305 > Any value returned by <code>func</code> is discarded.
307 < <p><h2>3.20 - Threads</h2>
309 > <p><a name="3.20"><h2>3.20 - Threads</h2></a>
311 < <p>You destroy threads with <code>lua_closethread</code>:
313 < void lua_closethread (lua_State *L, lua_State *thread);
315 < You cannot close the sole (or last) thread of a state.
316 < Instead, you must close the state itself.
318 > <p>There is no explicit function to close or to destroy a thread.
319 > Threads are subject to garbage collection,
320 > like any Lua object.
322 < int lua_yield (lua_State *L, int nresults);
324 > int lua_yield (lua_State *L, int nresults);
326 < <code>lua_resume</code> returns 0 if there is no errors running the coroutine,
328 > <code>lua_resume</code> returns 0 if there are no errors running the coroutine,
330 < <a name="debugI"><h1>4 - The Debug Interface</h1></a>
332 > <a name="debugI"><a name="4"><h1>4 - The Debug Interface</h1></a></a>
334 < <p><h2>4.1 - Stack and Function Information</h2>
336 > <p><a name="4.1"><h2>4.1 - Stack and Function Information</h2></a>
338 < When there is no errors, <code>lua_getstack</code> returns 1;
340 > When there are no errors, <code>lua_getstack</code> returns 1;
342 < <p><h2>4.2 - Manipulating Local Variables and Upvalues</h2>
344 > <p><a name="4.2"><h2>4.2 - Manipulating Local Variables and Upvalues</h2></a>
346 < <p><a name="sub-hooks"><h2>4.3 - Hooks</h2></a>
348 > <p><a name="sub-hooks"><a name="4.3"><h2>4.3 - Hooks</h2></a></a>
350 < <a name="libraries"><h1>5 - Standard Libraries</h1></a>
352 > <a name="libraries"><a name="5"><h1>5 - Standard Libraries</h1></a></a>
354 < <p><a name="predefined"><h2>5.1 - Basic Functions</h2></a>
356 > <p><a name="predefined"><a name="5.1"><h2>5.1 - Basic Functions</h2></a></a>
358 < Terminates the last protected function called,
360 > Terminates the last protected function called
362 < <p>if the environment has a <code>"__fenv"</code> field,
364 > <p>If the environment has a <code>"__fenv"</code> field,
366 < That means that any error inside <code>f</code> is not propagated;
368 > That means that any error inside <code>f</code> is not propagated;
370 < which is true if the call succeeds without errors.
372 > which is <B>true</B> if the call succeeds without errors.
374 < <p><h2>5.2 - Coroutine Manipulation</h2>
376 > <p><a name="5.2"><h2>5.2 - Coroutine Manipulation</h2></a>
378 < the basic library, and come inside the table .
380 > the basic library and come inside the table <code>coroutine</code>.
382 < <p><h2>5.3 - String Manipulation</h2>
384 > <p><a name="5.3"><h2>5.3 - String Manipulation</h2></a>
386 < a <em>character class</em> is used to represent a set of characters.
388 > A <em>character class</em> is used to represent a set of characters.
390 < a <em>pattern item</em> may be
392 > A <em>pattern item</em> may be
394 < a <em>pattern</em> is a sequence of pattern items.
396 > A <em>pattern</em> is a sequence of pattern items.
398 < <p><h2>5.4 - Table Manipulation</h2>
400 > <p><a name="5.4"><h2>5.4 - Table Manipulation</h2></a>
402 < <p><a name="mathlib"><h2>5.5 - Mathematical Functions</h2></a>
404 > <p><a name="mathlib"><a name="5.5"><h2>5.5 - Mathematical Functions</h2></a></a>
406 < <p><a name="libio"><h2>5.6 - Input and Output Facilities</h2></a>
408 > <p><a name="libio"><a name="5.6"><h2>5.6 - Input and Output Facilities</h2></a></a>
410 < <p><a name="libiosys"><h2>5.7 - Operating System Facilities</h2></a>
412 > <p><a name="libiosys"><a name="5.7"><h2>5.7 - Operating System Facilities</h2></a></a>
414 < <code>wday</code> (weekday, Sunday is 1),
416 > <code>wday</code> (weekday, Sunday is 1),
418 < <p><h2>5.8 - The Reflexive Debug Interface</h2>
420 > <p><a name="5.8"><h2>5.8 - The Reflexive Debug Interface</h2></a>
422 < <a name="lua-sa"><h1>6 - Lua Stand-alone</h1></a>
424 > <a name="lua-sa"><a name="6"><h1>6 - Lua Stand-alone</h1></a></a>
426 < Vincent Penquerc'h,
428 > Vincent Penquerc'h.
430 < <p> exp ::= <b>nil</b> <b>false</b> <b>true</b> | Number | Literal | function | prefixexp | tableconstructor | exp binop exp | unop exp
432 > <p> exp ::= <b>nil</b> | <b>false</b> | <b>true</b> | Number | Literal | function | prefixexp | tableconstructor | exp binop exp | unop exp
439 > Tue Nov 25 16:08:37 BRST 2003
444 diff -r lua-5.0/include/lua.h lua-5.0.1/include/lua.h
446 < ** $Id: lua.h,v 1.175 2003/03/18 12:31:39 roberto Exp $
448 > ** $Id: lua.h,v 1.175a 2003/03/18 12:31:39 roberto Exp $
450 < #define LUA_VERSION "Lua 5.0"
452 > #define LUA_VERSION "Lua 5.0.1"
453 diff -r lua-5.0/src/ldo.c lua-5.0.1/src/ldo.c
455 < ** $Id: ldo.c,v 1.217 2003/04/03 13:35:34 roberto Exp $
457 > ** $Id: ldo.c,v 1.217a 2003/04/03 13:35:34 roberto Exp $
459 < if (nargs >= L->top - L->base)
460 < luaG_runerror(L, "cannot resume dead coroutine");
462 > lua_assert(nargs < L->top - L->base);
464 < else if (ci->state & CI_YIELD) { /* inside a yield? */
466 > else { /* inside a yield */
467 > lua_assert(ci->state & CI_YIELD);
470 < luaG_runerror(L, "cannot resume non-suspended coroutine");
472 > static int resume_error (lua_State *L, const char *msg) {
473 > L->top = L->ci->base;
474 > setsvalue2s(L->top, luaS_new(L, msg));
482 > if (L->ci == L->base_ci) {
483 > if (nargs >= L->top - L->base)
484 > return resume_error(L, "cannot resume dead coroutine");
486 > else if (!(L->ci->state & CI_YIELD)) /* not inside a yield? */
487 > return resume_error(L, "cannot resume non-suspended coroutine");
488 diff -r lua-5.0/src/lgc.c lua-5.0.1/src/lgc.c
490 < ** $Id: lgc.c,v 1.171 2003/04/03 13:35:34 roberto Exp $
492 > ** $Id: lgc.c,v 1.171a 2003/04/03 13:35:34 roberto Exp $
494 < void luaC_separateudata (lua_State *L) {
496 > size_t luaC_separateudata (lua_State *L) {
497 > size_t deadmem = 0;
499 > deadmem += sizeudata(gcotou(curr)->uv.len);
503 < if (!(ci->state & CI_C) && lim < ci->top)
507 < static void checkSizes (lua_State *L) {
509 > static void checkSizes (lua_State *L, size_t deadmem) {
511 < G(L)->GCthreshold = 2*G(L)->nblocks; /* new threshold */
513 > G(L)->GCthreshold = 2*G(L)->nblocks - deadmem; /* new threshold */
515 < static void mark (lua_State *L) {
517 > static size_t mark (lua_State *L) {
520 < luaC_separateudata(L); /* separate userdata to be preserved */
522 > deadmem = luaC_separateudata(L); /* separate userdata to be preserved */
528 > size_t deadmem = mark(L);
532 > checkSizes(L, deadmem);
533 diff -r lua-5.0/src/lgc.h lua-5.0.1/src/lgc.h
535 < ** $Id: lgc.h,v 1.19 2003/02/28 19:45:15 roberto Exp $
537 > ** $Id: lgc.h,v 1.19a 2003/02/28 19:45:15 roberto Exp $
539 < void luaC_separateudata (lua_State *L);
541 > size_t luaC_separateudata (lua_State *L);
542 diff -r lua-5.0/src/lib/lbaselib.c lua-5.0.1/src/lib/lbaselib.c
544 < ** $Id: lbaselib.c,v 1.130 2003/04/03 13:35:34 roberto Exp $
546 > ** $Id: lbaselib.c,v 1.130a 2003/04/03 13:35:34 roberto Exp $
551 diff -r lua-5.0/src/lib/liolib.c lua-5.0.1/src/lib/liolib.c
553 < ** $Id: liolib.c,v 2.39 2003/03/19 21:16:12 roberto Exp $
555 > ** $Id: liolib.c,v 2.39a 2003/03/19 21:16:12 roberto Exp $
557 < if (lua_isnone(L, 1)) {
559 > if (lua_isnone(L, 1) && lua_type(L, lua_upvalueindex(1)) == LUA_TTABLE) {
564 diff -r lua-5.0/src/lparser.c lua-5.0.1/src/lparser.c
566 < ** $Id: lparser.c,v 1.208 2003/04/03 13:35:34 roberto Exp $
568 > ** $Id: lparser.c,v 1.208a 2003/04/03 13:35:34 roberto Exp $
570 > FuncState *fs = ls->fs;
572 < init_exp(&v, VLOCAL, ls->fs->freereg++);
574 > init_exp(&v, VLOCAL, fs->freereg);
575 > luaK_reserveregs(fs, 1);
577 < luaK_storevar(ls->fs, &v, &b);
579 > luaK_storevar(fs, &v, &b);
580 > /* debug information will only see the variable after this point! */
581 > getlocvar(fs, fs->nactvar - 1).startpc = fs->pc;
582 diff -r lua-5.0/src/luac/Makefile lua-5.0.1/src/luac/Makefile
584 < $(CC) -o $@ $(MYLDFLAGS) $(OBJS) -L$(LIB) -llua -llualib $(EXTRA_LIBS)
586 > $(CC) -o $@ $(MYLDFLAGS) $(OBJS) -L$(LIB) -llua -llualib $(EXTRA_LIBS) $(DLLIB)
587 diff -r lua-5.0/src/luac/luac.c lua-5.0.1/src/luac/luac.c
589 < ** $Id: luac.c,v 1.44 2003/04/07 20:34:20 lhf Exp $
591 > ** $Id: luac.c,v 1.44a 2003/04/07 20:34:20 lhf Exp $
596 diff -r lua-5.0/src/lvm.c lua-5.0.1/src/lvm.c
598 < ** $Id: lvm.c,v 1.284 2003/04/03 13:35:34 roberto Exp $
600 > ** $Id: lvm.c,v 1.284a 2003/04/03 13:35:34 roberto Exp $
602 < if (mask > LUA_MASKLINE) { /* instruction-hook set? */
604 > if (mask & LUA_MASKCOUNT) { /* instruction-hook set? */
606 < L->ci->u.l.pc = &pc;
608 > L->ci->u.l.pc = &pc;
610 < lua_assert(ci->u.l.pc == &pc &&
611 < ttisfunction(ci->base - 1) &&
612 < (ci->state & CI_SAVEDPC));
614 > lua_assert(ttisfunction(ci->base - 1) && (ci->state & CI_SAVEDPC));
615 diff -r lua-5.0/test/luac.lua lua-5.0.1/test/luac.lua
617 < assert(arg[1]~=nil,"usage: lua luac.lua file.lua")
618 < f=assert(io.open("luac.out","w"))
619 < f:write(string.dump(loadfile(arg[1])))
621 > assert(arg[1]~=nil and arg[2]==nil,"usage: lua luac.lua file.lua")
622 > f=assert(io.open("luac.out","wb"))
623 > f:write(string.dump(assert(loadfile(arg[1]))))