diff options
Diffstat (limited to 'doc/manual.html')
-rw-r--r-- | doc/manual.html | 76 |
1 files changed, 52 insertions, 24 deletions
diff --git a/doc/manual.html b/doc/manual.html index 8b3a85e5..90bb0fc8 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.89 2011/11/25 12:59:54 roberto Exp $ --> +<!-- $Id: manual.of,v 1.90 2011/11/29 17:14:45 roberto Exp $ --> @@ -3659,15 +3659,19 @@ The result is pushed on the stack. <pre>int lua_load (lua_State *L, lua_Reader reader, void *data, - const char *source);</pre> + const char *source, + const char *mode);</pre> <p> -Loads a Lua chunk. +Loads a Lua chunk (without running it). If there are no errors, -<a href="#lua_load"><code>lua_load</code></a> pushes the compiled chunk as a Lua +<code>lua_load</code> pushes the compiled chunk as a Lua function on top of the stack. Otherwise, it pushes an error message. -The return values of <a href="#lua_load"><code>lua_load</code></a> are: + + +<p> +The return values of <code>lua_load</code> are: <ul> @@ -3688,17 +3692,7 @@ It is generated by the garbage collector.) </ul> <p> -This function only loads a chunk; -it does not run it. - - -<p> -<a href="#lua_load"><code>lua_load</code></a> automatically detects whether the chunk is text or binary -and loads it accordingly (see program <code>luac</code>). - - -<p> -The <a href="#lua_load"><code>lua_load</code></a> function uses a user-supplied <code>reader</code> function +The <code>lua_load</code> function uses a user-supplied <code>reader</code> function to read the chunk (see <a href="#lua_Reader"><code>lua_Reader</code></a>). The <code>data</code> argument is an opaque value passed to the reader function. @@ -3709,6 +3703,14 @@ which is used for error messages and in debug information (see <a href="#4.9">&s <p> +id{lua_load} automatically detects whether the chunk is text or binary +and loads it accordingly (see program <code>luac</code>). +The string <code>mode</code> works as in function <a href="#pdf-load"><code>load</code></a>, +with the addition that +a <code>NULL</code> value is equivalent to the string "<code>bt</code>". + + +<p> If the resulting function has one upvalue, this upvalue is set to the value of the global environment stored at index <code>LUA_RIDX_GLOBALS</code> in the registry (see <a href="#4.5">§4.5</a>). @@ -6119,6 +6121,21 @@ Raises an error if the result of the operation is not a number. const char *name);</pre> <p> +Equivalent to <a href="#luaL_loadbufferx"><code>luaL_loadbufferx</code></a> with <code>mode</code> equal to <code>NULL</code>. + + + + + +<hr><h3><a name="luaL_loadbufferx"><code>luaL_loadbufferx</code></a></h3><p> +<span class="apii">[-0, +1, –]</span> +<pre>int luaL_loadbufferx (lua_State *L, + const char *buff, + size_t sz, + const char *name, + const char *mode);</pre> + +<p> Loads a buffer as a Lua chunk. This function uses <a href="#lua_load"><code>lua_load</code></a> to load the chunk in the buffer pointed to by <code>buff</code> with size <code>sz</code>. @@ -6128,6 +6145,7 @@ buffer pointed to by <code>buff</code> with size <code>sz</code>. This function returns the same results as <a href="#lua_load"><code>lua_load</code></a>. <code>name</code> is the chunk name, used for debug information and error messages. +The string <code>mode</code> works as in function <a href="#lua_load"><code>lua_load</code></a>. @@ -6135,12 +6153,15 @@ used for debug information and error messages. <hr><h3><a name="luaL_loadfile"><code>luaL_loadfile</code></a></h3><p> <span class="apii">[-0, +1, <em>m</em>]</span> -<pre>int luaL_loadfile (lua_State *L, const char *filename);</pre><p> +<pre>int luaL_loadfile (lua_State *L, const char *filename);</pre> + +<p> Equivalent to <a href="#luaL_loadfilex"><code>luaL_loadfilex</code></a> with <code>mode</code> equal to <code>NULL</code>. + <hr><h3><a name="luaL_loadfilex"><code>luaL_loadfilex</code></a></h3><p> <span class="apii">[-0, +1, <em>m</em>]</span> <pre>int luaL_loadfilex (lua_State *L, const char *filename, @@ -6156,9 +6177,7 @@ The first line in the file is ignored if it starts with a <code>#</code>. <p> -The string <code>mode</code> works as in function <a href="#pdf-load"><code>load</code></a>, -with the addition that -a <code>NULL</code> value is equivalent to the string "<code>bt</code>". +The string <code>mode</code> works as in function <a href="#lua_load"><code>lua_load</code></a>. <p> @@ -8292,7 +8311,6 @@ of list <code>t</code>. <p> Returns a new table with all parameters stored into keys 1, 2, etc. and with a field "<code>n</code>" with the total number of parameters. -Also returns, as a second result, the total number of parameters. Note that the resulting table may not be a sequence. @@ -9376,6 +9394,11 @@ the host system and on the current locale (that is, <code>os.date()</code> is equivalent to <code>os.date("%c")</code>). +<p> +On some systems, +this function may be not thread safe. + + <p> @@ -10184,8 +10207,8 @@ are potentially insecure when loading untrusted binary data. (Actually, those functions were already insecure because of flaws in the verification algorithm.) When in doubt, -use the <code>mode</code> argument in function <a href="#pdf-load"><code>load</code></a> -to restrict it to loading textual chunks. +use the <code>mode</code> argument of those functions +to restrict them to loading textual chunks. </li> <li> @@ -10260,6 +10283,11 @@ Use the new <a href="#lua_compare"><code>lua_compare</code></a> with appropriate Function <code>lua_objlen</code> was renamed <a href="#lua_rawlen"><code>lua_rawlen</code></a>. </li> +<li> +Function <a href="#lua_load"><code>lua_load</code></a> has an extra parameter, <code>mode</code>. +Pass <code>NULL</code> to simulate the old behavior. +</li> + </ul> @@ -10352,7 +10380,7 @@ Here is the complete syntax of Lua in extended BNF. <HR> <SMALL CLASS="footer"> Last update: -Fri Nov 25 11:37:49 BRST 2011 +Tue Nov 29 15:37:33 BRST 2011 </SMALL> <!-- Last change: revised for Lua 5.2.0 |