summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README2
-rw-r--r--doc/manual.css1
-rw-r--r--doc/manual.html28
-rw-r--r--src/loadlib.c17
-rw-r--r--src/lua.c23
5 files changed, 40 insertions, 31 deletions
diff --git a/README b/README
index bfdf7b9e..9c384675 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
-This is Lua 5.2, released on 08 Dec 2011.
+This is Lua 5.2, released on 12 Dec 2011.
For installation instructions, license details, and
further information about Lua, see doc/readme.html.
diff --git a/doc/manual.css b/doc/manual.css
index b158aea3..ac357a89 100644
--- a/doc/manual.css
+++ b/doc/manual.css
@@ -1,5 +1,6 @@
h3 code {
font-family: inherit ;
+ font-size: inherit ;
}
pre, code {
diff --git a/doc/manual.html b/doc/manual.html
index 1ebc21b4..360d3168 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -33,7 +33,7 @@ Freely available under the terms of the
<!-- ====================================================================== -->
<p>
-<!-- $Id: manual.of,v 1.93 2011/12/08 12:12:34 roberto Exp $ -->
+<!-- $Id: manual.of,v 1.94 2011/12/12 15:26:26 roberto Exp $ -->
@@ -2745,7 +2745,7 @@ Lua raises an error whenever it tries to yield across an API call,
except for three functions:
<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>.
All those functions receive a <em>continuation function</em>
-(as a parameter called <code>k</code>) to continue execution after an yield.
+(as a parameter called <code>k</code>) to continue execution after a yield.
<p>
@@ -3371,7 +3371,7 @@ but instead may call the continuation function.
In that case, a call to <a href="#lua_getctx"><code>lua_getctx</code></a> will return the error code
(the value that would be returned by <a href="#lua_pcallk"><code>lua_pcallk</code></a>);
the value of <code>ctx</code> will be set to the context information,
-as in the case of an yield.
+as in the case of a yield.
@@ -6741,7 +6741,8 @@ To have access to these libraries,
the C&nbsp;host program should call the <a href="#luaL_openlibs"><code>luaL_openlibs</code></a> function,
which opens all standard libraries.
Alternatively,
-it can open them individually by calling
+the host program can open them individually by using
+<a href="#luaL_requiref"><code>luaL_requiref</code></a> to call
<a name="pdf-luaopen_base"><code>luaopen_base</code></a> (for the basic library),
<a name="pdf-luaopen_package"><code>luaopen_package</code></a> (for the package library),
<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
<a name="pdf-luaopen_io"><code>luaopen_io</code></a> (for the I/O library),
<a name="pdf-luaopen_os"><code>luaopen_os</code></a> (for the Operating System library),
and <a name="pdf-luaopen_debug"><code>luaopen_debug</code></a> (for the debug library).
-These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>
-and should not be called directly:
-you must call them like any other Lua C&nbsp;function,
-e.g., by using <a href="#lua_call"><code>lua_call</code></a>.
+These functions are declared in <a name="pdf-lualib.h"><code>lualib.h</code></a>.
@@ -9986,10 +9984,11 @@ Otherwise, <code>lua</code> executes the string itself.
<p>
When called with option <code>-E</code>,
besides ignoring <code>LUA_INIT</code>,
-the interpreter also resets the values of
+Lua also ignores
+the values of <code>LUA_PATH</code> and <code>LUA_CPATH</code>,
+setting the values of
<a href="#pdf-package.path"><code>package.path</code></a> and <a href="#pdf-package.cpath"><code>package.cpath</code></a>
-with the default paths defined in <code>luaconf.h</code>,
-in effect ignoring the values of <code>LUA_PATH</code> and <code>LUA_CPATH</code>.
+with the default paths defined in <code>luaconf.h</code>.
<p>
@@ -10291,6 +10290,11 @@ Function <a href="#lua_load"><code>lua_load</code></a> has an extra parameter, <
Pass <code>NULL</code> to simulate the old behavior.
</li>
+<li>
+Function <a href="#lua_resume"><code>lua_resume</code></a> has an extra parameter, <code>from</code>.
+Pass <code>NULL</code> or the thread doing the call.
+</li>
+
</ul>
@@ -10383,7 +10387,7 @@ Here is the complete syntax of Lua in extended BNF.
<HR>
<SMALL CLASS="footer">
Last update:
-Thu Dec 8 10:36:53 BRST 2011
+Mon Dec 12 15:21:08 BRST 2011
</SMALL>
<!--
Last change: revised for Lua 5.2.0
diff --git a/src/loadlib.c b/src/loadlib.c
index b9d76ca8..783bc12b 100644
--- a/src/loadlib.c
+++ b/src/loadlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.107 2011/11/30 12:58:57 roberto Exp $
+** $Id: loadlib.c,v 1.108 2011/12/12 16:34:03 roberto Exp $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -615,12 +615,25 @@ static int ll_seeall (lua_State *L) {
/* auxiliary mark (for internal use) */
#define AUXMARK "\1"
+
+/*
+** return registry.LUA_NOENV as a boolean
+*/
+static int noenv (lua_State *L) {
+ int b;
+ lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
+ b = lua_toboolean(L, -1);
+ lua_pop(L, 1); /* remove value */
+ return b;
+}
+
+
static void setpath (lua_State *L, const char *fieldname, const char *envname1,
const char *envname2, const char *def) {
const char *path = getenv(envname1);
if (path == NULL) /* no environment variable? */
path = getenv(envname2); /* try alternative name */
- if (path == NULL) /* no environment variable? */
+ if (path == NULL || noenv(L)) /* no environment variable? */
lua_pushstring(L, def); /* use default */
else {
/* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
diff --git a/src/lua.c b/src/lua.c
index e1410000..e20ab86d 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -1,5 +1,5 @@
/*
-** $Id: lua.c,v 1.202 2011/08/17 20:19:52 roberto Exp $
+** $Id: lua.c,v 1.203 2011/12/12 16:34:03 roberto Exp $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -439,18 +439,6 @@ static int handle_luainit (lua_State *L) {
}
-static void resetpaths (lua_State *L) {
- lua_getglobal(L, "package");
- if (!lua_istable(L, -1)) /* no module 'package'? */
- return; /* nothing to be done */
- lua_pushliteral(L, LUA_PATH_DEFAULT);
- lua_setfield(L, -2, "path"); /* package.path = default */
- lua_pushliteral(L, LUA_CPATH_DEFAULT);
- lua_setfield(L, -2, "cpath"); /* package.cpath = default */
- lua_pop(L, 1); /* remove 'package' */
-}
-
-
static int pmain (lua_State *L) {
int argc = (int)lua_tointeger(L, 1);
char **argv = (char **)lua_touserdata(L, 2);
@@ -464,14 +452,17 @@ static int pmain (lua_State *L) {
return 0;
}
if (args[has_v]) print_version();
+ if (args[has_E]) { /* option '-E'? */
+ lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */
+ lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
+ }
/* open standard libraries */
luaL_checkversion(L);
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
luaL_openlibs(L); /* open libraries */
lua_gc(L, LUA_GCRESTART, 0);
- if (args[has_E]) /* avoid LUA_INIT? */
- resetpaths(L);
- else if (handle_luainit(L) != LUA_OK) return 0;
+ if (!args[has_E] && handle_luainit(L) != LUA_OK)
+ return 0; /* error running LUA_INIT */
/* execute arguments -e and -l */
if (!runargs(L, argv, (script > 0) ? script : argc)) return 0;
/* execute main script (if there is one) */