summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2010-11-17 12:00:00 +0000
committerrepogen <>2010-11-17 12:00:00 +0000
commit850a3d8f8d2ef75c2e7579f31e3b301a72c279cd (patch)
tree579a35a77bca170f4a8fcb90442a7b226436b099
parentccd28dfe034d5dfd130e5378a147e3e9fe7f6807 (diff)
downloadlua-github-850a3d8f8d2ef75c2e7579f31e3b301a72c279cd.tar.gz
Lua 5.2.0-alpha-rc25.2.0-alpha-rc2
-rw-r--r--doc/contents.html6
-rw-r--r--doc/manual.html266
-rw-r--r--src/lauxlib.h27
-rw-r--r--src/ldblib.c19
-rw-r--r--src/lstrlib.c18
5 files changed, 209 insertions, 127 deletions
diff --git a/doc/contents.html b/doc/contents.html
index 199af668..f309c1f9 100644
--- a/doc/contents.html
+++ b/doc/contents.html
@@ -457,6 +457,7 @@ Freely available under the terms of the
<A HREF="manual.html#luaL_argcheck">luaL_argcheck</A><BR>
<A HREF="manual.html#luaL_argerror">luaL_argerror</A><BR>
<A HREF="manual.html#luaL_buffinit">luaL_buffinit</A><BR>
+<A HREF="manual.html#luaL_buffinitsize">luaL_buffinitsize</A><BR>
<A HREF="manual.html#luaL_callmeta">luaL_callmeta</A><BR>
<A HREF="manual.html#luaL_checkany">luaL_checkany</A><BR>
<A HREF="manual.html#luaL_checkint">luaL_checkint</A><BR>
@@ -474,6 +475,7 @@ Freely available under the terms of the
<A HREF="manual.html#luaL_dofile">luaL_dofile</A><BR>
<A HREF="manual.html#luaL_dostring">luaL_dostring</A><BR>
<A HREF="manual.html#luaL_error">luaL_error</A><BR>
+<A HREF="manual.html#luaL_findtable">luaL_findtable</A><BR>
<A HREF="manual.html#luaL_getmetafield">luaL_getmetafield</A><BR>
<A HREF="manual.html#luaL_getmetatable">luaL_getmetatable</A><BR>
<A HREF="manual.html#luaL_gsub">luaL_gsub</A><BR>
@@ -493,7 +495,9 @@ Freely available under the terms of the
<A HREF="manual.html#luaL_optstring">luaL_optstring</A><BR>
<A HREF="manual.html#luaL_optunsigned">luaL_optunsigned</A><BR>
<A HREF="manual.html#luaL_prepbuffer">luaL_prepbuffer</A><BR>
+<A HREF="manual.html#luaL_prepbuffsize">luaL_prepbuffsize</A><BR>
<A HREF="manual.html#luaL_pushresult">luaL_pushresult</A><BR>
+<A HREF="manual.html#luaL_pushresultsize">luaL_pushresultsize</A><BR>
<A HREF="manual.html#luaL_ref">luaL_ref</A><BR>
<A HREF="manual.html#luaL_requiref">luaL_requiref</A><BR>
<A HREF="manual.html#luaL_setfuncs">luaL_setfuncs</A><BR>
@@ -512,7 +516,7 @@ Freely available under the terms of the
<HR>
<SMALL>
Last update:
-Tue Nov 16 09:56:07 BRST 2010
+Wed Nov 17 14:51:24 BRST 2010
</SMALL>
<!--
Last change: revised for Lua 5.2.0 (alpha)
diff --git a/doc/manual.html b/doc/manual.html
index db1af8c8..15bb204a 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -38,7 +38,7 @@ Freely available under the terms of the
<!-- ====================================================================== -->
<p>
-<!-- $Id: manual.of,v 1.62 2010/11/16 11:38:25 roberto Exp $ -->
+<!-- $Id: manual.of,v 1.63 2010/11/17 15:35:05 roberto Exp $ -->
@@ -1026,7 +1026,7 @@ in which
[<em>a</em>]&nbsp;means an optional <em>a</em>.
Non-terminals are shown like non-terminal,
keywords are shown like <b>kword</b>,
-and other terminal symbols are shown like &lsquo<b>=</b>&rsquo;.
+and other terminal symbols are shown like &lsquo;<b>=</b>&rsquo;.
The complete syntax of Lua can be found in <a href="#9">&sect;9</a>
at the end of this manual.
@@ -1225,7 +1225,7 @@ Before the first assignment to a variable, its value is <b>nil</b>.
Square brackets are used to index a table:
<pre>
- var ::= prefixexp &lsquo<b>[</b>&rsquo; exp &lsquo<b>]</b>&rsquo;
+ var ::= prefixexp &lsquo;<b>[</b>&rsquo; exp &lsquo;<b>]</b>&rsquo;
</pre><p>
The meaning of accesses to table fields can be changed via metatables.
An access to an indexed variable <code>t[i]</code> is equivalent to
@@ -1241,7 +1241,7 @@ The syntax <code>var.Name</code> is just syntactic sugar for
<code>var["Name"]</code>:
<pre>
- var ::= prefixexp &lsquo<b>.</b>&rsquo; Name
+ var ::= prefixexp &lsquo;<b>.</b>&rsquo; Name
</pre>
<p>
@@ -1280,7 +1280,7 @@ start a block with a semicolon
or write two semicolons in sequence:
<pre>
- stat ::= &lsquo<b>;</b>&rsquo;
+ stat ::= &lsquo;<b>;</b>&rsquo;
</pre>
<p>
@@ -1351,9 +1351,9 @@ and a list of expressions on the right side.
The elements in both lists are separated by commas:
<pre>
- stat ::= varlist &lsquo<b>=</b>&rsquo; explist
- varlist ::= var {&lsquo<b>,</b>&rsquo; var}
- explist ::= exp {&lsquo<b>,</b>&rsquo; exp}
+ stat ::= varlist &lsquo;<b>=</b>&rsquo; explist
+ varlist ::= var {&lsquo;<b>,</b>&rsquo; var}
+ explist ::= exp {&lsquo;<b>,</b>&rsquo; exp}
</pre><p>
Expressions are discussed in <a href="#3.4">&sect;3.4</a>.
@@ -1454,11 +1454,11 @@ declared inside the loop block.
The <b>return</b> statement is used to return values
from a function or a chunk (which is just a function).
-Functions and chunks can return more than one value,
-and so the syntax for the <b>return</b> statement is
+Functions can return more than one value,
+so the syntax for the <b>return</b> statement is
<pre>
- stat ::= <b>return</b> [explist] [&lsquo<b>;</b>&rsquo;]
+ stat ::= <b>return</b> [explist] [&lsquo;<b>;</b>&rsquo;]
</pre>
<p>
@@ -1468,7 +1468,7 @@ skipping to the next statement after the loop:
<pre>
- stat ::= <b>break</b> [&lsquo<b>;</b>&rsquo;]
+ stat ::= <b>break</b> [&lsquo;<b>;</b>&rsquo;]
</pre><p>
A <b>break</b> ends the innermost enclosing loop.
@@ -1502,7 +1502,7 @@ control variable runs through an arithmetic progression.
It has the following syntax:
<pre>
- stat ::= <b>for</b> Name &lsquo<b>=</b>&rsquo; exp &lsquo<b>,</b>&rsquo; exp [&lsquo<b>,</b>&rsquo; exp] <b>do</b> block <b>end</b>
+ stat ::= <b>for</b> Name &lsquo;<b>=</b>&rsquo; exp &lsquo;<b>,</b>&rsquo; exp [&lsquo;<b>,</b>&rsquo; exp] <b>do</b> block <b>end</b>
</pre><p>
The <em>block</em> is repeated for <em>name</em> starting at the value of
the first <em>exp</em>, until it passes the second <em>exp</em> by steps of the
@@ -1567,7 +1567,7 @@ The generic <b>for</b> loop has the following syntax:
<pre>
stat ::= <b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b>
- namelist ::= Name {&lsquo<b>,</b>&rsquo; Name}
+ namelist ::= Name {&lsquo;<b>,</b>&rsquo; Name}
</pre><p>
A <b>for</b> statement like
@@ -1638,7 +1638,7 @@ Local variables can be declared anywhere inside a block.
The declaration can include an initial assignment:
<pre>
- stat ::= <b>local</b> namelist [&lsquo<b>=</b>&rsquo; explist]
+ stat ::= <b>local</b> namelist [&lsquo;<b>=</b>&rsquo; explist]
</pre><p>
If present, an initial assignment has the same semantics
of a multiple assignment (see <a href="#3.3.3">&sect;3.3.3</a>).
@@ -1672,10 +1672,10 @@ The basic expressions in Lua are the following:
exp ::= String
exp ::= function
exp ::= tableconstructor
- exp ::= &lsquo<b>...</b>&rsquo;
+ exp ::= &lsquo;<b>...</b>&rsquo;
exp ::= exp binop exp
exp ::= unop exp
- prefixexp ::= var | functioncall | &lsquo<b>(</b>&rsquo; exp &lsquo<b>)</b>&rsquo;
+ prefixexp ::= var | functioncall | &lsquo;<b>(</b>&rsquo; exp &lsquo;<b>)</b>&rsquo;
</pre>
<p>
@@ -1957,10 +1957,10 @@ or to create a table and initialize some of its fields.
The general syntax for constructors is
<pre>
- tableconstructor ::= &lsquo<b>{</b>&rsquo; [fieldlist] &lsquo<b>}</b>&rsquo;
+ tableconstructor ::= &lsquo;<b>{</b>&rsquo; [fieldlist] &lsquo;<b>}</b>&rsquo;
fieldlist ::= field {fieldsep field} [fieldsep]
- field ::= &lsquo<b>[</b>&rsquo; exp &lsquo<b>]</b>&rsquo; &lsquo<b>=</b>&rsquo; exp | Name &lsquo<b>=</b>&rsquo; exp | exp
- fieldsep ::= &lsquo<b>,</b>&rsquo; | &lsquo<b>;</b>&rsquo;
+ field ::= &lsquo;<b>[</b>&rsquo; exp &lsquo;<b>]</b>&rsquo; &lsquo;<b>=</b>&rsquo; exp | Name &lsquo;<b>=</b>&rsquo; exp | exp
+ fieldsep ::= &lsquo;<b>,</b>&rsquo; | &lsquo;<b>;</b>&rsquo;
</pre>
<p>
@@ -2032,7 +2032,7 @@ followed by the original call arguments
The form
<pre>
- functioncall ::= prefixexp &lsquo<b>:</b>&rsquo; Name args
+ functioncall ::= prefixexp &lsquo;<b>:</b>&rsquo; Name args
</pre><p>
can be used to call "methods".
A call <code>v:name(<em>args</em>)</code>
@@ -2044,7 +2044,7 @@ except that <code>v</code> is evaluated only once.
Arguments have the following syntax:
<pre>
- args ::= &lsquo<b>(</b>&rsquo; [explist] &lsquo<b>)</b>&rsquo;
+ args ::= &lsquo;<b>(</b>&rsquo; [explist] &lsquo;<b>)</b>&rsquo;
args ::= tableconstructor
args ::= String
</pre><p>
@@ -2093,7 +2093,7 @@ The syntax for function definition is
<pre>
function ::= <b>function</b> funcbody
- funcbody ::= &lsquo<b>(</b>&rsquo; [parlist] &lsquo<b>)</b>&rsquo; block <b>end</b>
+ funcbody ::= &lsquo;<b>(</b>&rsquo; [parlist] &lsquo;<b>)</b>&rsquo; block <b>end</b>
</pre>
<p>
@@ -2102,7 +2102,7 @@ The following syntactic sugar simplifies function definitions:
<pre>
stat ::= <b>function</b> funcname funcbody
stat ::= <b>local</b> <b>function</b> Name funcbody
- funcname ::= Name {&lsquo<b>.</b>&rsquo; Name} [&lsquo<b>:</b>&rsquo; Name]
+ funcname ::= Name {&lsquo;<b>.</b>&rsquo; Name} [&lsquo;<b>:</b>&rsquo; Name]
</pre><p>
The statement
@@ -2161,7 +2161,7 @@ Parameters act as local variables that are
initialized with the argument values:
<pre>
- parlist ::= namelist [&lsquo<b>,</b>&rsquo; &lsquo<b>...</b>&rsquo;] | &lsquo<b>...</b>&rsquo;
+ parlist ::= namelist [&lsquo;<b>,</b>&rsquo; &lsquo;<b>...</b>&rsquo;] | &lsquo;<b>...</b>&rsquo;
</pre><p>
When a function is called,
the list of arguments is adjusted to
@@ -2217,6 +2217,13 @@ then the function returns with no results.
<p>
+
+There is a system-dependent limit on the number of values
+that a function may return.
+This limit is guaranteed to be larger than 1000.
+
+
+<p>
The <em>colon</em> syntax
is used for defining <em>methods</em>,
that is, functions that have an implicit extra parameter <code>self</code>.
@@ -5321,7 +5328,7 @@ in alphabetical order.
<hr><h3><a name="luaL_addchar"><code>luaL_addchar</code></a></h3><p>
-<span class="apii">[-0, +0, <em>m</em>]</span>
+<span class="apii">[-?, +?, <em>m</em>]</span>
<pre>void luaL_addchar (luaL_Buffer *B, char c);</pre>
<p>
@@ -5333,7 +5340,7 @@ Adds the character <code>c</code> to the buffer <code>B</code>
<hr><h3><a name="luaL_addlstring"><code>luaL_addlstring</code></a></h3><p>
-<span class="apii">[-0, +0, <em>m</em>]</span>
+<span class="apii">[-?, +?, <em>m</em>]</span>
<pre>void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l);</pre>
<p>
@@ -5347,7 +5354,7 @@ The string can contain embedded zeros.
<hr><h3><a name="luaL_addsize"><code>luaL_addsize</code></a></h3><p>
-<span class="apii">[-0, +0, <em>m</em>]</span>
+<span class="apii">[-?, +?, <em>m</em>]</span>
<pre>void luaL_addsize (luaL_Buffer *B, size_t n);</pre>
<p>
@@ -5360,7 +5367,7 @@ buffer area (see <a href="#luaL_prepbuffer"><code>luaL_prepbuffer</code></a>).
<hr><h3><a name="luaL_addstring"><code>luaL_addstring</code></a></h3><p>
-<span class="apii">[-0, +0, <em>m</em>]</span>
+<span class="apii">[-?, +?, <em>m</em>]</span>
<pre>void luaL_addstring (luaL_Buffer *B, const char *s);</pre>
<p>
@@ -5374,7 +5381,7 @@ The string should not contain embedded zeros.
<hr><h3><a name="luaL_addvalue"><code>luaL_addvalue</code></a></h3><p>
-<span class="apii">[-1, +0, <em>m</em>]</span>
+<span class="apii">[-1, +?, <em>m</em>]</span>
<pre>void luaL_addvalue (luaL_Buffer *B);</pre>
<p>
@@ -5463,6 +5470,27 @@ This call leaves the final string on the top of the stack.
</ul>
<p>
+If you know beforehand the total size of the resulting string,
+you can use the buffer like this:
+
+<ul>
+
+<li>First you declare a variable <code>b</code> of type <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>.</li>
+
+<li>Then you initialize it and preallocate a space of
+size <code>sz</code> with a call <code>luaL_buffinitsize(L, &amp;b, sz)</code>.</li>
+
+<li>Then you copy the string into that space.</li>
+
+<li>
+You finish by calling <code>luaL_pushresult(&amp;b, sz)</code>,
+where <code>sz</code> is the total size of the resulting string
+copied into that space.
+</li>
+
+</ul>
+
+<p>
During its normal operation,
a string buffer uses a variable number of stack slots.
So, while using a buffer, you cannot assume that you know where
@@ -5496,6 +5524,18 @@ the buffer must be declared as a variable
+<hr><h3><a name="luaL_buffinitsize"><code>luaL_buffinitsize</code></a></h3><p>
+<span class="apii">[-?, +?, <em>m</em>]</span>
+<pre>char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz);</pre>
+
+<p>
+Equivalent to the sequence
+<a href="#luaL_buffinit"><code>luaL_buffinit</code></a>, <a href="#luaL_prepbuffsize"><code>luaL_prepbuffsize</code></a>.
+
+
+
+
+
<hr><h3><a name="luaL_callmeta"><code>luaL_callmeta</code></a></h3><p>
<span class="apii">[-0, +(0|1), <em>e</em>]</span>
<pre>int luaL_callmeta (lua_State *L, int obj, const char *e);</pre>
@@ -5770,6 +5810,20 @@ as <code>return luaL_error(<em>args</em>)</code>.
+<hr><h3><a name="luaL_findtable"><code>luaL_findtable</code></a></h3><p>
+<span class="apii">[-0, +1, <em>m</em>]</span>
+<pre>void luaL_findtable (lua_State *L, int idx, const char *fname);</pre>
+
+<p>
+Ensures that the value <code>t[fname]</code>,
+where <code>t</code> is the value at the valid index <code>idx</code>,
+is a table,
+and pushes that table onto the stack.
+
+
+
+
+
<hr><h3><a name="luaL_getmetafield"><code>luaL_getmetafield</code></a></h3><p>
<span class="apii">[-0, +(0|1), <em>m</em>]</span>
<pre>int luaL_getmetafield (lua_State *L, int obj, const char *e);</pre>
@@ -5965,42 +6019,6 @@ or <code>NULL</code> if there is a memory allocation error.
-<hr><h3><a name="luaL_setfuncs"><code>luaL_setfuncs</code></a></h3><p>
-<span class="apii">[-nup, +0, <em>e</em>]</span>
-<pre>void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);</pre>
-
-<p>
-Registers all functions in the array <code>l</code>
-(see <a href="#luaL_Reg"><code>luaL_Reg</code></a>) into the table on the top of the stack
-(below optional upvalues, see next).
-The pointer <code>l</code> may be <code>NULL</code>,
-representing an empty list.
-
-
-<p>
-When <code>nup</code> is not zero,
-all functions are created sharing <code>nup</code> upvalues,
-which must be previously pushed on the stack
-on top of the library table.
-These values are popped from the stack after the registration.
-
-
-
-
-
-<hr><h3><a name="luaL_setmetatable"><code>luaL_setmetatable</code></a></h3><p>
-<span class="apii">[-0, +0, <em>-</em>]</span>
-<pre>void luaL_setmetatable (lua_State *L, const char *tname);</pre>
-
-<p>
-Sets the metatable of the object at the top of the stack
-as the metatable associated with name <code>tname</code>
-in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
-
-
-
-
-
<hr><h3><a name="luaL_openlibs"><code>luaL_openlibs</code></a></h3><p>
<span class="apii">[-0, +0, <em>e</em>]</span>
<pre>void luaL_openlibs (lua_State *L);</pre>
@@ -6132,11 +6150,23 @@ Otherwise, raises an error.
<hr><h3><a name="luaL_prepbuffer"><code>luaL_prepbuffer</code></a></h3><p>
-<span class="apii">[-0, +0, <em>-</em>]</span>
+<span class="apii">[-?, +?, <em>m</em>]</span>
<pre>char *luaL_prepbuffer (luaL_Buffer *B);</pre>
<p>
-Returns an address to a space of size <a name="pdf-LUAL_BUFFERSIZE"><code>LUAL_BUFFERSIZE</code></a>
+Equivalent to <a href="#luaL_prepbuffsize"><code>luaL_prepbuffsize</code></a>
+with the predefined size <a name="pdf-LUAL_BUFFERSIZE"><code>LUAL_BUFFERSIZE</code></a>.
+
+
+
+
+
+<hr><h3><a name="luaL_prepbuffsize"><code>luaL_prepbuffsize</code></a></h3><p>
+<span class="apii">[-?, +?, <em>m</em>]</span>
+<pre>char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz);</pre>
+
+<p>
+Returns an address to a space of size <code>sz</code>
where you can copy a string to be added to buffer <code>B</code>
(see <a href="#luaL_Buffer"><code>luaL_Buffer</code></a>).
After copying the string into this space you must call
@@ -6159,6 +6189,17 @@ the top of the stack.
+<hr><h3><a name="luaL_pushresultsize"><code>luaL_pushresultsize</code></a></h3><p>
+<span class="apii">[-?, +1, <em>m</em>]</span>
+<pre>void luaL_pushresultsize (luaL_Buffer *B, size_t sz);</pre>
+
+<p>
+Equivalent to the sequence <a href="#luaL_addsize"><code>luaL_addsize</code></a>, <a href="#luaL_pushresult"><code>luaL_pushresult</code></a>.
+
+
+
+
+
<hr><h3><a name="luaL_ref"><code>luaL_ref</code></a></h3><p>
<span class="apii">[-1, +0, <em>m</em>]</span>
<pre>int luaL_ref (lua_State *L, int t);</pre>
@@ -6229,6 +6270,42 @@ Leaves a copy of that result on the stack.
+<hr><h3><a name="luaL_setfuncs"><code>luaL_setfuncs</code></a></h3><p>
+<span class="apii">[-nup, +0, <em>e</em>]</span>
+<pre>void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);</pre>
+
+<p>
+Registers all functions in the array <code>l</code>
+(see <a href="#luaL_Reg"><code>luaL_Reg</code></a>) into the table on the top of the stack
+(below optional upvalues, see next).
+The pointer <code>l</code> may be <code>NULL</code>,
+representing an empty list.
+
+
+<p>
+When <code>nup</code> is not zero,
+all functions are created sharing <code>nup</code> upvalues,
+which must be previously pushed on the stack
+on top of the library table.
+These values are popped from the stack after the registration.
+
+
+
+
+
+<hr><h3><a name="luaL_setmetatable"><code>luaL_setmetatable</code></a></h3><p>
+<span class="apii">[-0, +0, <em>-</em>]</span>
+<pre>void luaL_setmetatable (lua_State *L, const char *tname);</pre>
+
+<p>
+Sets the metatable of the object at the top of the stack
+as the metatable associated with name <code>tname</code>
+in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>).
+
+
+
+
+
<hr><h3><a name="luaL_testudata"><code>luaL_testudata</code></a></h3><p>
<span class="apii">[-0, +0, <em>m</em>]</span>
<pre>void *luaL_testudata (lua_State *L, int narg, const char *tname);</pre>
@@ -9176,7 +9253,9 @@ within any function, and so have no direct access to local variables.
<p>
-Returns the Lua value associated to userdata <code>u</code>.
+Returns the Lua value associated to <code>u</code>.
+If <code>u</code> is not a userdata,
+returns <b>nil</b>.
@@ -9305,7 +9384,8 @@ The function returns <b>nil</b> if there is no upvalue with the given index.
<p>
Sets the given <code>value</code> as
the Lua value associated to the given <code>udata</code>.
-<code>value</code> must be a table or <b>nil</b>.
+<code>value</code> must be a table or <b>nil</b>;
+<code>udata</code> must be a full userdata.
<p>
@@ -9776,61 +9856,61 @@ Here is the complete syntax of Lua in extended BNF.
chunk ::= block
- block ::= {stat} [laststat [&lsquo<b>;</b>&rsquo;]]
+ block ::= {stat} [laststat [&lsquo;<b>;</b>&rsquo;]]
- stat ::= &lsquo<b>;</b>&rsquo; |
- varlist &lsquo<b>=</b>&rsquo; explist |
+ stat ::= &lsquo;<b>;</b>&rsquo; |
+ varlist &lsquo;<b>=</b>&rsquo; explist |
functioncall |
<b>do</b> block <b>end</b> |
<b>while</b> exp <b>do</b> block <b>end</b> |
<b>repeat</b> block <b>until</b> exp |
<b>if</b> exp <b>then</b> block {<b>elseif</b> exp <b>then</b> block} [<b>else</b> block] <b>end</b> |
- <b>for</b> Name &lsquo<b>=</b>&rsquo; exp &lsquo<b>,</b>&rsquo; exp [&lsquo<b>,</b>&rsquo; exp] <b>do</b> block <b>end</b> |
+ <b>for</b> Name &lsquo;<b>=</b>&rsquo; exp &lsquo;<b>,</b>&rsquo; exp [&lsquo;<b>,</b>&rsquo; exp] <b>do</b> block <b>end</b> |
<b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b> |
<b>function</b> funcname funcbody |
<b>local</b> <b>function</b> Name funcbody |
- <b>local</b> namelist [&lsquo<b>=</b>&rsquo; explist]
+ <b>local</b> namelist [&lsquo;<b>=</b>&rsquo; explist]
laststat ::= <b>return</b> [explist] | <b>break</b>
- funcname ::= Name {&lsquo<b>.</b>&rsquo; Name} [&lsquo<b>:</b>&rsquo; Name]
+ funcname ::= Name {&lsquo;<b>.</b>&rsquo; Name} [&lsquo;<b>:</b>&rsquo; Name]
- varlist ::= var {&lsquo<b>,</b>&rsquo; var}
+ varlist ::= var {&lsquo;<b>,</b>&rsquo; var}
- var ::= Name | prefixexp &lsquo<b>[</b>&rsquo; exp &lsquo<b>]</b>&rsquo; | prefixexp &lsquo<b>.</b>&rsquo; Name
+ var ::= Name | prefixexp &lsquo;<b>[</b>&rsquo; exp &lsquo;<b>]</b>&rsquo; | prefixexp &lsquo;<b>.</b>&rsquo; Name
- namelist ::= Name {&lsquo<b>,</b>&rsquo; Name}
+ namelist ::= Name {&lsquo;<b>,</b>&rsquo; Name}
- explist ::= {exp &lsquo<b>,</b>&rsquo;} exp
+ explist ::= {exp &lsquo;<b>,</b>&rsquo;} exp
- exp ::= <b>nil</b> | <b>false</b> | <b>true</b> | Number | String | &lsquo<b>...</b>&rsquo; | function |
+ exp ::= <b>nil</b> | <b>false</b> | <b>true</b> | Number | String | &lsquo;<b>...</b>&rsquo; | function |
prefixexp | tableconstructor | exp binop exp | unop exp
- prefixexp ::= var | functioncall | &lsquo<b>(</b>&rsquo; exp &lsquo<b>)</b>&rsquo;
+ prefixexp ::= var | functioncall | &lsquo;<b>(</b>&rsquo; exp &lsquo;<b>)</b>&rsquo;
- functioncall ::= prefixexp args | prefixexp &lsquo<b>:</b>&rsquo; Name args
+ functioncall ::= prefixexp args | prefixexp &lsquo;<b>:</b>&rsquo; Name args
- args ::= &lsquo<b>(</b>&rsquo; [explist] &lsquo<b>)</b>&rsquo; | tableconstructor | String
+ args ::= &lsquo;<b>(</b>&rsquo; [explist] &lsquo;<b>)</b>&rsquo; | tableconstructor | String
function ::= <b>function</b> funcbody
- funcbody ::= &lsquo<b>(</b>&rsquo; [parlist] &lsquo<b>)</b>&rsquo; block <b>end</b>
+ funcbody ::= &lsquo;<b>(</b>&rsquo; [parlist] &lsquo;<b>)</b>&rsquo; block <b>end</b>
- parlist ::= namelist [&lsquo<b>,</b>&rsquo; &lsquo<b>...</b>&rsquo;] | &lsquo<b>...</b>&rsquo;
+ parlist ::= namelist [&lsquo;<b>,</b>&rsquo; &lsquo;<b>...</b>&rsquo;] | &lsquo;<b>...</b>&rsquo;
- tableconstructor ::= &lsquo<b>{</b>&rsquo; [fieldlist] &lsquo<b>}</b>&rsquo;
+ tableconstructor ::= &lsquo;<b>{</b>&rsquo; [fieldlist] &lsquo;<b>}</b>&rsquo;
fieldlist ::= field {fieldsep field} [fieldsep]
- field ::= &lsquo<b>[</b>&rsquo; exp &lsquo<b>]</b>&rsquo; &lsquo<b>=</b>&rsquo; exp | Name &lsquo<b>=</b>&rsquo; exp | exp
+ field ::= &lsquo;<b>[</b>&rsquo; exp &lsquo;<b>]</b>&rsquo; &lsquo;<b>=</b>&rsquo; exp | Name &lsquo;<b>=</b>&rsquo; exp | exp
- fieldsep ::= &lsquo<b>,</b>&rsquo; | &lsquo<b>;</b>&rsquo;
+ fieldsep ::= &lsquo;<b>,</b>&rsquo; | &lsquo;<b>;</b>&rsquo;
- binop ::= &lsquo<b>+</b>&rsquo; | &lsquo<b>-</b>&rsquo; | &lsquo<b>*</b>&rsquo; | &lsquo<b>/</b>&rsquo; | &lsquo<b>^</b>&rsquo; | &lsquo<b>%</b>&rsquo; | &lsquo<b>..</b>&rsquo; |
- &lsquo<b>&lt;</b>&rsquo; | &lsquo<b>&lt;=</b>&rsquo; | &lsquo<b>&gt;</b>&rsquo; | &lsquo<b>&gt;=</b>&rsquo; | &lsquo<b>==</b>&rsquo; | &lsquo<b>~=</b>&rsquo; |
+ binop ::= &lsquo;<b>+</b>&rsquo; | &lsquo;<b>-</b>&rsquo; | &lsquo;<b>*</b>&rsquo; | &lsquo;<b>/</b>&rsquo; | &lsquo;<b>^</b>&rsquo; | &lsquo;<b>%</b>&rsquo; | &lsquo;<b>..</b>&rsquo; |
+ &lsquo;<b>&lt;</b>&rsquo; | &lsquo;<b>&lt;=</b>&rsquo; | &lsquo;<b>&gt;</b>&rsquo; | &lsquo;<b>&gt;=</b>&rsquo; | &lsquo;<b>==</b>&rsquo; | &lsquo;<b>~=</b>&rsquo; |
<b>and</b> | <b>or</b>
- unop ::= &lsquo<b>-</b>&rsquo; | <b>not</b> | &lsquo<b>#</b>&rsquo;
+ unop ::= &lsquo;<b>-</b>&rsquo; | <b>not</b> | &lsquo;<b>#</b>&rsquo;
</pre>
@@ -9845,7 +9925,7 @@ Here is the complete syntax of Lua in extended BNF.
<HR>
<SMALL>
Last update:
-Tue Nov 16 09:52:41 BRST 2010
+Wed Nov 17 14:49:08 BRST 2010
</SMALL>
<!--
Last change: revised for Lua 5.2.0 (alpha)
diff --git a/src/lauxlib.h b/src/lauxlib.h
index f4e31bc8..39506456 100644
--- a/src/lauxlib.h
+++ b/src/lauxlib.h
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.h,v 1.111 2010/11/10 18:05:36 roberto Exp $
+** $Id: lauxlib.h,v 1.113 2010/11/16 19:20:01 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -62,6 +62,10 @@ LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
const char *const lst[]);
+/* pre-defined references */
+#define LUA_NOREF (-2)
+#define LUA_REFNIL (-1)
+
LUALIB_API int (luaL_ref) (lua_State *L, int t);
LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
@@ -120,8 +124,6 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
-#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0))
-
/*
** {======================================================
@@ -158,27 +160,14 @@ LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
/* }====================================================== */
+/* compatibility with old module system */
+
LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
int sizehint);
LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
const luaL_Reg *l, int nup);
-
-/* compatibility with ref system */
-
-/* pre-defined references */
-#define LUA_NOREF (-2)
-#define LUA_REFNIL (-1)
-
-#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
- (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
-
-#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref))
-
-#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
-
-
-#define luaL_reg luaL_Reg
+#define luaL_register(L,n,l) (luaL_openlib(L,(n),(l),0))
#endif
diff --git a/src/ldblib.c b/src/ldblib.c
index 04213159..d631dcba 100644
--- a/src/ldblib.c
+++ b/src/ldblib.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldblib.c,v 1.125 2010/11/10 18:06:10 roberto Exp $
+** $Id: ldblib.c,v 1.126 2010/11/16 18:01:28 roberto Exp $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@@ -44,22 +44,19 @@ static int db_setmetatable (lua_State *L) {
}
-static void checkudata (lua_State *L, int narg) {
- if (lua_type(L, narg) == LUA_TLIGHTUSERDATA)
- luaL_argerror(L, narg, "full userdata expected, got light userdata");
- luaL_checktype(L, narg, LUA_TUSERDATA);
-}
-
-
static int db_getuservalue (lua_State *L) {
- checkudata(L, 1);
- lua_getuservalue(L, 1);
+ if (lua_type(L, 1) != LUA_TUSERDATA)
+ lua_pushnil(L);
+ else
+ lua_getuservalue(L, 1);
return 1;
}
static int db_setuservalue (lua_State *L) {
- checkudata(L, 1);
+ if (lua_type(L, 1) == LUA_TLIGHTUSERDATA)
+ luaL_argerror(L, 1, "full userdata expected, got light userdata");
+ luaL_checktype(L, 1, LUA_TUSERDATA);
if (!lua_isnoneornil(L, 2))
luaL_checktype(L, 2, LUA_TTABLE);
lua_settop(L, 2);
diff --git a/src/lstrlib.c b/src/lstrlib.c
index 1cd37def..82c2005e 100644
--- a/src/lstrlib.c
+++ b/src/lstrlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.157 2010/11/08 17:38:37 roberto Exp $
+** $Id: lstrlib.c,v 1.158 2010/11/16 20:39:41 roberto Exp $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -505,6 +505,18 @@ static int push_captures (MatchState *ms, const char *s, const char *e) {
}
+/* check whether pattern has no special characters */
+static int nospecials (const char *p, size_t l) {
+ size_t upto = 0;
+ do {
+ if (strpbrk(p + upto, SPECIALS))
+ return 0; /* pattern has a special character */
+ upto += strlen(p + upto) + 1; /* may have more after \0 */
+ } while (upto <= l);
+ return 1; /* no special chars found */
+}
+
+
static int str_find_aux (lua_State *L, int find) {
size_t ls, lp;
const char *s = luaL_checklstring(L, 1, &ls);
@@ -515,8 +527,8 @@ static int str_find_aux (lua_State *L, int find) {
lua_pushnil(L); /* cannot find anything */
return 1;
}
- if (find && (lua_toboolean(L, 4) || /* explicit request? */
- strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */
+ /* explicit request or no special characters? */
+ if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) {
/* do a plain search */
const char *s2 = lmemfind(s + init - 1, ls - init + 1, p, lp);
if (s2) {