History

Lua 5.2.0

Lua Team committed 14 years ago

Commit 32bd3eb1 parent 798bf685 files · +40 −31Browse files

Unified · Split

5 files
  1. README +1 −1
  2. doc/manual.css +1 −0
  3. doc/manual.html +16 −12
  4. src/loadlib.c +15 −2
  5. src/lua.c +7 −16
README+1−1
@@ -1,5 +1,5 @@
1 1
2This is Lua 5.2, released on 08 Dec 2011.2This is Lua 5.2, released on 12 Dec 2011.
3 3
4For installation instructions, license details, and4For installation instructions, license details, and
5further information about Lua, see doc/readme.html.5further information about Lua, see doc/readme.html.
doc/manual.css+1−0
@@ -1,5 +1,6 @@
1h3 code {1h3 code {
2 font-family: inherit ;2 font-family: inherit ;
3 font-size: inherit ;
3}4}
4 5
5pre, code {6pre, code {
doc/manual.html+16−12
@@ -33,7 +33,7 @@ Freely available under the terms of the · 32 unmodified lines
33<!-- ====================================================================== -->33<!-- ====================================================================== -->
34<p>34<p>
35 35
36<!-- $Id: manual.of,v 1.93 2011/12/08 12:12:34 roberto Exp $ -->36<!-- $Id: manual.of,v 1.94 2011/12/12 15:26:26 roberto Exp $ -->
37 37
38 38
39 39
@@ -2745,7 +2745,7 @@ Lua raises an error whenever it tries to yield across an API call, · 2705 unmodified lines
2745except for three functions:2745except for three functions:
2746<a href="#lua_yieldk"><code>lua_yieldk</code></a>, <a href="#lua_callk"><code>lua_callk</code></a>, and <a href="#lua_pcallk"><code>lua_pcallk</code></a>.2746<a href="#lua_yieldk"><code>lua_yieldk</code></a>, <a href="#lua_callk"><code>lua_callk</code></a>, and <a href="#lua_pcallk"><code>lua_pcallk</code></a>.
2747All those functions receive a <em>continuation function</em>2747All those functions receive a <em>continuation function</em>
2748(as a parameter called <code>k</code>) to continue execution after an yield.2748(as a parameter called <code>k</code>) to continue execution after a yield.
2749 2749
2750 2750
2751<p>2751<p>
@@ -3371,7 +3371,7 @@ but instead may call the continuation function. · 619 unmodified lines
3371In that case, a call to <a href="#lua_getctx"><code>lua_getctx</code></a> will return the error code3371In that case, a call to <a href="#lua_getctx"><code>lua_getctx</code></a> will return the error code
3372(the value that would be returned by <a href="#lua_pcallk"><code>lua_pcallk</code></a>);3372(the value that would be returned by <a href="#lua_pcallk"><code>lua_pcallk</code></a>);
3373the value of <code>ctx</code> will be set to the context information,3373the value of <code>ctx</code> will be set to the context information,
3374as in the case of an yield.3374as in the case of a yield.
3375 3375
3376 3376
3377 3377
@@ -6741,7 +6741,8 @@ To have access to these libraries, · 3363 unmodified lines
6741the C&nbsp;host program should call the <a href="#luaL_openlibs"><code>luaL_openlibs</code></a> function,6741the C&nbsp;host program should call the <a href="#luaL_openlibs"><code>luaL_openlibs</code></a> function,
6742which opens all standard libraries.6742which opens all standard libraries.
6743Alternatively,6743Alternatively,
6744it can open them individually by calling6744the host program can open them individually by using
6745<a href="#luaL_requiref"><code>luaL_requiref</code></a> to call
6745<a name="pdf-luaopen_base"><code>luaopen_base</code></a> (for the basic library),6746<a name="pdf-luaopen_base"><code>luaopen_base</code></a> (for the basic library),
6746<a name="pdf-luaopen_package"><code>luaopen_package</code></a> (for the package library),6747<a name="pdf-luaopen_package"><code>luaopen_package</code></a> (for the package library),
6747<a name="pdf-luaopen_coroutine"><code>luaopen_coroutine</code></a> (for the coroutine library),6748<a name="pdf-luaopen_coroutine"><code>luaopen_coroutine</code></a> (for the coroutine library),
@@ -6752,10 +6753,7 @@ it can open them individually by calling · 4 unmodified lines
6752<a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library),6753<a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library),
6753<a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the Operating System library),6754<a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the Operating System library),
6754and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library).6755and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library).
6755These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>6756These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>.
6756and should not be called directly:
6757you must call them like any other Lua C&nbsp;function,
6758e.g., by using <a href="#lua_call"><code>lua_call</code></a>.
6759 6757
6760 6758
6761 6759
@@ -9986,10 +9984,11 @@ Otherwise, <code>lua</code> executes the string itself. · 3224 unmodified lines
9986<p>9984<p>
9987When called with option <code>-E</code>,9985When called with option <code>-E</code>,
9988besides ignoring <code>LUA_INIT</code>,9986besides ignoring <code>LUA_INIT</code>,
9989the interpreter also resets the values of9987Lua also ignores
9988the values of <code>LUA_PATH</code> and <code>LUA_CPATH</code>,
9989setting the values of
9990<a href="#pdf-package.path"><code>package.path</code></a> and <a href="#pdf-package.cpath"><code>package.cpath</code></a>9990<a href="#pdf-package.path"><code>package.path</code></a> and <a href="#pdf-package.cpath"><code>package.cpath</code></a>
9991with the default paths defined in <code>luaconf.h</code>,9991with the default paths defined in <code>luaconf.h</code>.
9992in effect ignoring the values of <code>LUA_PATH</code> and <code>LUA_CPATH</code>.
9993 9992
9994 9993
9995<p>9994<p>
@@ -10291,6 +10290,11 @@ Function <a href="#lua_load"><code>lua_load</code></a> has an extra parameter, < · 295 unmodified lines
10291Pass <code>NULL</code> to simulate the old behavior.10290Pass <code>NULL</code> to simulate the old behavior.
10292</li>10291</li>
10293 10292
10293<li>
10294Function <a href="#lua_resume"><code>lua_resume</code></a> has an extra parameter, <code>from</code>.
10295Pass <code>NULL</code> or the thread doing the call.
10296</li>
10297
10294</ul>10298</ul>
10295 10299
10296 10300
@@ -10383,7 +10387,7 @@ Here is the complete syntax of Lua in extended BNF. · 86 unmodified lines
10383<HR>10387<HR>
10384<SMALL CLASS="footer">10388<SMALL CLASS="footer">
10385Last update:10389Last update:
10386Thu Dec 8 10:36:53 BRST 201110390Mon Dec 12 15:21:08 BRST 2011
10387</SMALL>10391</SMALL>
10388<!--10392<!--
10389Last change: revised for Lua 5.2.010393Last change: revised for Lua 5.2.0
src/loadlib.c+15−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: loadlib.c,v 1.107 2011/11/30 12:58:57 roberto Exp $2** $Id: loadlib.c,v 1.108 2011/12/12 16:34:03 roberto Exp $
3** Dynamic library loader for Lua3** Dynamic library loader for Lua
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5**5**
@@ -615,12 +615,25 @@ static int ll_seeall (lua_State *L) { · 609 unmodified lines
615/* auxiliary mark (for internal use) */615/* auxiliary mark (for internal use) */
616#define AUXMARK "\1"616#define AUXMARK "\1"
617 617
618
619/*
620** return registry.LUA_NOENV as a boolean
621*/
622static int noenv (lua_State *L) {
623 int b;
624 lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
625 b = lua_toboolean(L, -1);
626 lua_pop(L, 1); /* remove value */
627 return b;
628}
629
630
618static void setpath (lua_State *L, const char *fieldname, const char *envname1,631static void setpath (lua_State *L, const char *fieldname, const char *envname1,
619 const char *envname2, const char *def) {632 const char *envname2, const char *def) {
620 const char *path = getenv(envname1);633 const char *path = getenv(envname1);
621 if (path == NULL) /* no environment variable? */634 if (path == NULL) /* no environment variable? */
622 path = getenv(envname2); /* try alternative name */635 path = getenv(envname2); /* try alternative name */
623 if (path == NULL) /* no environment variable? */636 if (path == NULL || noenv(L)) /* no environment variable? */
624 lua_pushstring(L, def); /* use default */637 lua_pushstring(L, def); /* use default */
625 else {638 else {
626 /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */639 /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
src/lua.c+7−16
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lua.c,v 1.202 2011/08/17 20:19:52 roberto Exp $2** $Id: lua.c,v 1.203 2011/12/12 16:34:03 roberto Exp $
3** Lua stand-alone interpreter3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -439,18 +439,6 @@ static int handle_luainit (lua_State *L) { · 433 unmodified lines
439}439}
440 440
441 441
442static void resetpaths (lua_State *L) {
443 lua_getglobal(L, "package");
444 if (!lua_istable(L, -1)) /* no module 'package'? */
445 return; /* nothing to be done */
446 lua_pushliteral(L, LUA_PATH_DEFAULT);
447 lua_setfield(L, -2, "path"); /* package.path = default */
448 lua_pushliteral(L, LUA_CPATH_DEFAULT);
449 lua_setfield(L, -2, "cpath"); /* package.cpath = default */
450 lua_pop(L, 1); /* remove 'package' */
451}
452
453
454static int pmain (lua_State *L) {442static int pmain (lua_State *L) {
455 int argc = (int)lua_tointeger(L, 1);443 int argc = (int)lua_tointeger(L, 1);
456 char **argv = (char **)lua_touserdata(L, 2);444 char **argv = (char **)lua_touserdata(L, 2);
@@ -464,14 +452,17 @@ static int pmain (lua_State *L) { · 7 unmodified lines
464 return 0;452 return 0;
465 }453 }
466 if (args[has_v]) print_version();454 if (args[has_v]) print_version();
455 if (args[has_E]) { /* option '-E'? */
456 lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */
457 lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
458 }
467 /* open standard libraries */459 /* open standard libraries */
468 luaL_checkversion(L);460 luaL_checkversion(L);
469 lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */461 lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
470 luaL_openlibs(L); /* open libraries */462 luaL_openlibs(L); /* open libraries */
471 lua_gc(L, LUA_GCRESTART, 0);463 lua_gc(L, LUA_GCRESTART, 0);
472 if (args[has_E]) /* avoid LUA_INIT? */464 if (!args[has_E] && handle_luainit(L) != LUA_OK)
473 resetpaths(L);465 return 0; /* error running LUA_INIT */
474 else if (handle_luainit(L) != LUA_OK) return 0;
475 /* execute arguments -e and -l */466 /* execute arguments -e and -l */
476 if (!runargs(L, argv, (script > 0) ? script : argc)) return 0;467 if (!runargs(L, argv, (script > 0) ? script : argc)) return 0;
477 /* execute main script (if there is one) */468 /* execute main script (if there is one) */