History

Lua 5.2.0-beta-rc3

Lua Team committed 15 years ago

Commit deeb5211 parent 0f2fa0f10 files · +436 −266Browse files

Unified · Split

10 files
  1. README +1 −1
  2. doc/manual.html +210 −202
  3. doc/readme.html +3 −5
  4. src/Makefile +6 −5
  5. src/lctype.c +49 −0
  6. src/lctype.h +95 −0
  7. src/llex.c +48 −20
  8. src/lobject.c +9 −10
  9. src/lparser.c +13 −20
  10. src/lparser.h +2 −3
README+1−1
@@ -1,5 +1,5 @@
1 1
2This is Lua 5.2 (beta), released on 13 Jun 2011.2This is Lua 5.2 (beta), released on 27 Jun 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.html+210−202
@@ -38,7 +38,7 @@ Freely available under the terms of the · 37 unmodified lines
38<!-- ====================================================================== -->38<!-- ====================================================================== -->
39<p>39<p>
40 40
41<!-- $Id: manual.of,v 1.79 2011/06/21 14:35:46 roberto Exp $ -->41<!-- $Id: manual.of,v 1.80 2011/06/27 18:26:28 roberto Exp $ -->
42 42
43 43
44 44
@@ -209,10 +209,11 @@ Thus tables can also carry <em>methods</em> (see <a href="#3.4.10">&sect;3.4.10< · 164 unmodified lines
209 209
210<p>210<p>
211The indexing of tables follows211The indexing of tables follows
212the definition of equality in the language.212the definition of raw equality in the language.
213The expressions <code>a[i]</code> and <code>a[j]</code>213The expressions <code>a[i]</code> and <code>a[j]</code>
214denote the same table element214denote the same table element
215if and only if <code>i == j</code>.215if and only if <code>i</code> and <code>j</code> are raw equal
216(that is, equal without metamethods).
216 217
217 218
218<p>219<p>
@@ -328,7 +329,7 @@ you may give an <em>message handler</em> · 109 unmodified lines
328to be called in case of errors.329to be called in case of errors.
329This function is called with the original error message330This function is called with the original error message
330and returns a new error message.331and returns a new error message.
331It is called before the error unwonds the stack,332It is called before the error unwinds the stack,
332so that it can gather more information about the error,333so that it can gather more information about the error,
333for instance by inspecting the stack and creating a stack traceback.334for instance by inspecting the stack and creating a stack traceback.
334This message handler is still protected by the protected call;335This message handler is still protected by the protected call;
@@ -443,7 +444,7 @@ in the following code. · 108 unmodified lines
443 444
444<ul>445<ul>
445 446
446<li><b>"add":</b>447<li><b>"add": </b>
447the <code>+</code> operation.448the <code>+</code> operation.
448 449
449 450
@@ -481,25 +482,25 @@ the behavior of the <code>op1 + op2</code> is · 31 unmodified lines
481</pre><p>482</pre><p>
482</li>483</li>
483 484
484<li><b>"sub":</b>485<li><b>"sub": </b>
485the <code>-</code> operation.486the <code>-</code> operation.
486 487
487Behavior similar to the "add" operation.488Behavior similar to the "add" operation.
488</li>489</li>
489 490
490<li><b>"mul":</b>491<li><b>"mul": </b>
491the <code>*</code> operation.492the <code>*</code> operation.
492 493
493Behavior similar to the "add" operation.494Behavior similar to the "add" operation.
494</li>495</li>
495 496
496<li><b>"div":</b>497<li><b>"div": </b>
497the <code>/</code> operation.498the <code>/</code> operation.
498 499
499Behavior similar to the "add" operation.500Behavior similar to the "add" operation.
500</li>501</li>
501 502
502<li><b>"mod":</b>503<li><b>"mod": </b>
503the <code>%</code> operation.504the <code>%</code> operation.
504 505
505Behavior similar to the "add" operation,506Behavior similar to the "add" operation,
@@ -507,7 +508,7 @@ with the operation · 1 unmodified line
507<code>o1 - floor(o1/o2)*o2</code> as the primitive operation.508<code>o1 - floor(o1/o2)*o2</code> as the primitive operation.
508</li>509</li>
509 510
510<li><b>"pow":</b>511<li><b>"pow": </b>
511the <code>^</code> (exponentiation) operation.512the <code>^</code> (exponentiation) operation.
512 513
513Behavior similar to the "add" operation,514Behavior similar to the "add" operation,
@@ -515,7 +516,7 @@ with the function <code>pow</code> (from the C&nbsp;math library) · 1 unmodified line
515as the primitive operation.516as the primitive operation.
516</li>517</li>
517 518
518<li><b>"unm":</b>519<li><b>"unm": </b>
519the unary <code>-</code> operation.520the unary <code>-</code> operation.
520 521
521 522
@@ -538,7 +539,7 @@ the unary <code>-</code> operation. · 16 unmodified lines
538</pre><p>539</pre><p>
539</li>540</li>
540 541
541<li><b>"concat":</b>542<li><b>"concat": </b>
542the <code>..</code> (concatenation) operation.543the <code>..</code> (concatenation) operation.
543 544
544 545
@@ -559,7 +560,7 @@ the <code>..</code> (concatenation) operation. · 14 unmodified lines
559</pre><p>560</pre><p>
560</li>561</li>
561 562
562<li><b>"len":</b>563<li><b>"len": </b>
563the <code>#</code> operation.564the <code>#</code> operation.
564 565
565 566
@@ -582,7 +583,7 @@ the <code>#</code> operation. · 16 unmodified lines
582See <a href="#3.4.6">&sect;3.4.6</a> for a description of the length of a table.583See <a href="#3.4.6">&sect;3.4.6</a> for a description of the length of a table.
583</li>584</li>
584 585
585<li><b>"eq":</b>586<li><b>"eq": </b>
586the <code>==</code> operation.587the <code>==</code> operation.
587 588
588The function <code>getequalhandler</code> defines how Lua chooses a metamethod589The function <code>getequalhandler</code> defines how Lua chooses a metamethod
@@ -620,7 +621,7 @@ The "eq" event is defined as follows: · 31 unmodified lines
620</pre><p>621</pre><p>
621</li>622</li>
622 623
623<li><b>"lt":</b>624<li><b>"lt": </b>
624the <code>&lt;</code> operation.625the <code>&lt;</code> operation.
625 626
626 627
@@ -642,7 +643,7 @@ the <code>&lt;</code> operation. · 15 unmodified lines
642</pre><p>643</pre><p>
643</li>644</li>
644 645
645<li><b>"le":</b>646<li><b>"le": </b>
646the <code>&lt;=</code> operation.647the <code>&lt;=</code> operation.
647 648
648 649
@@ -672,7 +673,7 @@ Lua tries the "lt", assuming that <code>a &lt;= b</code> is · 23 unmodified lines
672equivalent to <code>not (b &lt; a)</code>.673equivalent to <code>not (b &lt; a)</code>.
673</li>674</li>
674 675
675<li><b>"index":</b>676<li><b>"index": </b>
676The indexing access <code>table[key]</code>.677The indexing access <code>table[key]</code>.
677Note that the metamethod is tried only678Note that the metamethod is tried only
678when <code>key</code> is not present in <code>table</code>.679when <code>key</code> is not present in <code>table</code>.
@@ -704,7 +705,7 @@ so the metamethod is always tried.) · 25 unmodified lines
704</pre><p>705</pre><p>
705</li>706</li>
706 707
707<li><b>"newindex":</b>708<li><b>"newindex": </b>
708The indexing assignment <code>table[key] = value</code>.709The indexing assignment <code>table[key] = value</code>.
709Note that the metamethod is tried only710Note that the metamethod is tried only
710when <code>key</code> is not present in <code>table</code>.711when <code>key</code> is not present in <code>table</code>.
@@ -733,7 +734,7 @@ when <code>key</code> is not present in <code>table</code>. · 22 unmodified lines
733</pre><p>734</pre><p>
734</li>735</li>
735 736
736<li><b>"call":</b>737<li><b>"call": </b>
737called when Lua calls a value.738called when Lua calls a value.
738 739
739 740
@@ -845,7 +846,7 @@ and the metatable has a field indexed by the string "<code>__gc</code>". · 105 unmodified lines
845Note that if you set a metatable without a <code>__gc</code> field846Note that if you set a metatable without a <code>__gc</code> field
846and later create that field in the metatable,847and later create that field in the metatable,
847the object will not be marked for finalization.848the object will not be marked for finalization.
848However, after a userdata is marked,849However, after an object is marked,
849you can freely change the <code>__gc</code> field of its metatable.850you can freely change the <code>__gc</code> field of its metatable.
850 851
851 852
@@ -873,7 +874,16 @@ the reverse order that they were marked for collection, · 21 unmodified lines
873among those collected in that cycle;874among those collected in that cycle;
874that is, the first finalizer to be called is the one associated875that is, the first finalizer to be called is the one associated
875with the object marked last in the program.876with the object marked last in the program.
876The object memory is freed only in the next garbage-collection cycle.877The execution of each finalizer may occur at any point during
878the execution of the regular code.
879
880
881<p>
882Because the object being collected must still be used by the finalizer
883and even <em>resurrected</em>resurrection
884(e.g., stored by the finalizer in a global variable),
885the object memory is freed only when it becomes completely inaccessible
886(that is, in the next garbage-collection cycle unless it was resurrected).
877 887
878 888
879 889
@@ -1536,9 +1546,10 @@ labels in Lua are considered statements too: · 656 unmodified lines
1536</pre>1546</pre>
1537 1547
1538<p>1548<p>
1539A label is visible in the entire block where it is defined1549A label is visible in the entire block where it is defined,
1540(including nested blocks, but not nested functions).1550except
1541A function cannot have more than one label with a given name.1551inside nested blocks where a label with the same name is defined and
1552inside nested functions.
1542A goto may jump to any visible label as long as it does not1553A goto may jump to any visible label as long as it does not
1543enter into the scope of a local variable.1554enter into the scope of a local variable.
1544 1555
@@ -2592,12 +2603,12 @@ defined as constants in <code>lua.h</code>. · 1047 unmodified lines
2592The following constants are defined:2603The following constants are defined:
2593 2604
2594<ul>2605<ul>
2595<li><b>LUA_RIDX_MAINTHREAD:</b> At this index the registry has2606<li><b>LUA_RIDX_MAINTHREAD: </b> At this index the registry has
2596the main thread of the state.2607the main thread of the state.
2597(The main thread is the one created together with the state.)2608(The main thread is the one created together with the state.)
2598</li>2609</li>
2599 2610
2600<li><b>LUA_RIDX_GLOBALS:</b> At this index the registry has2611<li><b>LUA_RIDX_GLOBALS: </b> At this index the registry has
2601the global environment.2612the global environment.
2602This is the C&nbsp;equivalent to the <a href="#pdf-_G"><code>_G</code></a> global variable.2613This is the C&nbsp;equivalent to the <a href="#pdf-_G"><code>_G</code></a> global variable.
2603</li>2614</li>
@@ -2840,7 +2851,7 @@ but it seems a safe assumption. · 236 unmodified lines
2840 2851
2841 2852
2842<hr><h3><a name="lua_arith"><code>lua_arith</code></a></h3><p>2853<hr><h3><a name="lua_arith"><code>lua_arith</code></a></h3><p>
2843<span class="apii">[-(2/1), +1, <em>e</em>]</span>2854<span class="apii">[-(2|1), +1, <em>e</em>]</span>
2844<pre>int lua_arith (lua_State *L, int op);</pre>2855<pre>int lua_arith (lua_State *L, int op);</pre>
2845 2856
2846<p>2857<p>
@@ -2858,13 +2869,13 @@ The value of <code>op</code> must be one of the following constants: · 11 unmodified lines
2858 2869
2859<ul>2870<ul>
2860 2871
2861<li><b><a name="pdf-LUA_OPADD"><code>LUA_OPADD</code></a>:</b>performs addition (<code>+</code>)</li>2872<li><b><a name="pdf-LUA_OPADD"><code>LUA_OPADD</code></a>: </b> performs addition (<code>+</code>)</li>
2862<li><b><a name="pdf-LUA_OPSUB"><code>LUA_OPSUB</code></a>:</b>performs subtraction (<code>-</code>)</li>2873<li><b><a name="pdf-LUA_OPSUB"><code>LUA_OPSUB</code></a>: </b> performs subtraction (<code>-</code>)</li>
2863<li><b><a name="pdf-LUA_OPMUL"><code>LUA_OPMUL</code></a>:</b>performs multiplication (<code>*</code>)</li>2874<li><b><a name="pdf-LUA_OPMUL"><code>LUA_OPMUL</code></a>: </b> performs multiplication (<code>*</code>)</li>
2864<li><b><a name="pdf-LUA_OPDIV"><code>LUA_OPDIV</code></a>:</b>performs division (<code>/</code>)</li>2875<li><b><a name="pdf-LUA_OPDIV"><code>LUA_OPDIV</code></a>: </b> performs division (<code>/</code>)</li>
2865<li><b><a name="pdf-LUA_OPMOD"><code>LUA_OPMOD</code></a>:</b>performs modulo (<code>%</code>)</li>2876<li><b><a name="pdf-LUA_OPMOD"><code>LUA_OPMOD</code></a>: </b> performs modulo (<code>%</code>)</li>
2866<li><b><a name="pdf-LUA_OPPOW"><code>LUA_OPPOW</code></a>:</b>performs exponentiation (<code>^</code>)</li>2877<li><b><a name="pdf-LUA_OPPOW"><code>LUA_OPPOW</code></a>: </b> performs exponentiation (<code>^</code>)</li>
2867<li><b><a name="pdf-LUA_OPUNM"><code>LUA_OPUNM</code></a>:</b>performs mathematical negation (unary <code>-</code>)</li>2878<li><b><a name="pdf-LUA_OPUNM"><code>LUA_OPUNM</code></a>: </b> performs mathematical negation (unary <code>-</code>)</li>
2868 2879
2869</ul>2880</ul>
2870 2881
@@ -3068,9 +3079,9 @@ The value of <code>op</code> must be one of the following constants: · 197 unmodified lines
3068 3079
3069<ul>3080<ul>
3070 3081
3071<li><b><a name="pdf-LUA_OPEQ"><code>LUA_OPEQ</code></a>:</b>compares for equality (<code>==</code>)</li>3082<li><b><a name="pdf-LUA_OPEQ"><code>LUA_OPEQ</code></a>: </b> compares for equality (<code>==</code>)</li>
3072<li><b><a name="pdf-LUA_OPLT"><code>LUA_OPLT</code></a>:</b>compares for less than (<code>&lt;</code>)</li>3083<li><b><a name="pdf-LUA_OPLT"><code>LUA_OPLT</code></a>: </b> compares for less than (<code>&lt;</code>)</li>
3073<li><b><a name="pdf-LUA_OPLE"><code>LUA_OPLE</code></a>:</b>compares for less or equal (<code>&lt;=</code>)</li>3084<li><b><a name="pdf-LUA_OPLE"><code>LUA_OPLE</code></a>: </b> compares for less or equal (<code>&lt;=</code>)</li>
3074 3085
3075</ul>3086</ul>
3076 3087
@@ -3186,28 +3197,28 @@ according to the value of the parameter <code>what</code>: · 109 unmodified lines
3186 3197
3187<ul>3198<ul>
3188 3199
3189<li><b><code>LUA_GCSTOP</code>:</b>3200<li><b><code>LUA_GCSTOP</code>: </b>
3190stops the garbage collector.3201stops the garbage collector.
3191</li>3202</li>
3192 3203
3193<li><b><code>LUA_GCRESTART</code>:</b>3204<li><b><code>LUA_GCRESTART</code>: </b>
3194restarts the garbage collector.3205restarts the garbage collector.
3195</li>3206</li>
3196 3207
3197<li><b><code>LUA_GCCOLLECT</code>:</b>3208<li><b><code>LUA_GCCOLLECT</code>: </b>
3198performs a full garbage-collection cycle.3209performs a full garbage-collection cycle.
3199</li>3210</li>
3200 3211
3201<li><b><code>LUA_GCCOUNT</code>:</b>3212<li><b><code>LUA_GCCOUNT</code>: </b>
3202returns the current amount of memory (in Kbytes) in use by Lua.3213returns the current amount of memory (in Kbytes) in use by Lua.
3203</li>3214</li>
3204 3215
3205<li><b><code>LUA_GCCOUNTB</code>:</b>3216<li><b><code>LUA_GCCOUNTB</code>: </b>
3206returns the remainder of dividing the current amount of bytes of3217returns the remainder of dividing the current amount of bytes of
3207memory in use by Lua by 1024.3218memory in use by Lua by 1024.
3208</li>3219</li>
3209 3220
3210<li><b><code>LUA_GCSTEP</code>:</b>3221<li><b><code>LUA_GCSTEP</code>: </b>
3211performs an incremental step of garbage collection.3222performs an incremental step of garbage collection.
3212The step "size" is controlled by <code>data</code>3223The step "size" is controlled by <code>data</code>
3213(larger values mean more steps) in a non-specified way.3224(larger values mean more steps) in a non-specified way.
@@ -3217,19 +3228,19 @@ The function returns 1 if the step finished a · 3 unmodified lines
3217garbage-collection cycle.3228garbage-collection cycle.
3218</li>3229</li>
3219 3230
3220<li><b><code>LUA_GCSETPAUSE</code>:</b>3231<li><b><code>LUA_GCSETPAUSE</code>: </b>
3221sets <code>data</code> as the new value3232sets <code>data</code> as the new value
3222for the <em>pause</em> of the collector (see <a href="#2.5">&sect;2.5</a>).3233for the <em>pause</em> of the collector (see <a href="#2.5">&sect;2.5</a>).
3223The function returns the previous value of the pause.3234The function returns the previous value of the pause.
3224</li>3235</li>
3225 3236
3226<li><b><code>LUA_GCSETSTEPMUL</code>:</b>3237<li><b><code>LUA_GCSETSTEPMUL</code>: </b>
3227sets <code>data</code> as the new value for the <em>step multiplier</em> of3238sets <code>data</code> as the new value for the <em>step multiplier</em> of
3228the collector (see <a href="#2.5">&sect;2.5</a>).3239the collector (see <a href="#2.5">&sect;2.5</a>).
3229The function returns the previous value of the step multiplier.3240The function returns the previous value of the step multiplier.
3230</li>3241</li>
3231 3242
3232<li><b><code>LUA_GCISRUNNING</code>:</b>3243<li><b><code>LUA_GCISRUNNING</code>: </b>
3233returns a boolean that tells whether the collector is running3244returns a boolean that tells whether the collector is running
3234(i.e., not stopped).3245(i.e., not stopped).
3235</li>3246</li>
@@ -3293,19 +3304,6 @@ as in the case of an yield. · 57 unmodified lines
3293 3304
3294 3305
3295 3306
3296<hr><h3><a name="lua_getuservalue"><code>lua_getuservalue</code></a></h3><p>
3297<span class="apii">[-0, +1, <em>-</em>]</span>
3298<pre>void lua_getuservalue (lua_State *L, int index);</pre>
3299
3300<p>
3301Pushes onto the stack the Lua value associated with the userdata
3302at the given index.
3303This Lua value must be a table or <b>nil</b>.
3304
3305
3306
3307
3308
3309<hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3><p>3307<hr><h3><a name="lua_getfield"><code>lua_getfield</code></a></h3><p>
3310<span class="apii">[-0, +1, <em>e</em>]</span>3308<span class="apii">[-0, +1, <em>e</em>]</span>
3311<pre>void lua_getfield (lua_State *L, int index, const char *k);</pre>3309<pre>void lua_getfield (lua_State *L, int index, const char *k);</pre>
@@ -3381,6 +3379,19 @@ this result is equal to the number of elements in the stack · 69 unmodified lines
3381 3379
3382 3380
3383 3381
3382<hr><h3><a name="lua_getuservalue"><code>lua_getuservalue</code></a></h3><p>
3383<span class="apii">[-0, +1, <em>-</em>]</span>
3384<pre>void lua_getuservalue (lua_State *L, int index);</pre>
3385
3386<p>
3387Pushes onto the stack the Lua value associated with the userdata
3388at the given index.
3389This Lua value must be a table or <b>nil</b>.
3390
3391
3392
3393
3394
3384<hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3><p>3395<hr><h3><a name="lua_insert"><code>lua_insert</code></a></h3><p>
3385<span class="apii">[-1, +1, <em>-</em>]</span>3396<span class="apii">[-1, +1, <em>-</em>]</span>
3386<pre>void lua_insert (lua_State *L, int index);</pre>3397<pre>void lua_insert (lua_State *L, int index);</pre>
@@ -3590,15 +3601,15 @@ The return values of <a href="#lua_load"><code>lua_load</code></a> are: · 203 unmodified lines
3590 3601
3591<ul>3602<ul>
3592 3603
3593<li><b><a href="#pdf-LUA_OK"><code>LUA_OK</code></a> (0):</b> no errors;</li>3604<li><b><a href="#pdf-LUA_OK"><code>LUA_OK</code></a> (0): </b> no errors;</li>
3594 3605
3595<li><b><a name="pdf-LUA_ERRSYNTAX"><code>LUA_ERRSYNTAX</code></a>:</b>3606<li><b><a name="pdf-LUA_ERRSYNTAX"><code>LUA_ERRSYNTAX</code></a>: </b>
3596syntax error during pre-compilation;</li>3607syntax error during pre-compilation;</li>
3597 3608
3598<li><b><a href="#pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>:</b>3609<li><b><a href="#pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>: </b>
3599memory allocation error.</li>3610memory allocation error.</li>
3600 3611
3601<li><b><a href="#pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>:</b>3612<li><b><a href="#pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>: </b>
3602error while running a <code>__gc</code> metamethod.3613error while running a <code>__gc</code> metamethod.
3603(This error has no relation with the chunk being loaded.3614(This error has no relation with the chunk being loaded.
3604It is generated by the garbage collector.)3615It is generated by the garbage collector.)
@@ -3707,13 +3718,6 @@ and you can detect when it is being collected. · 102 unmodified lines
3707A full userdata is only equal to itself (under raw equality).3718A full userdata is only equal to itself (under raw equality).
3708 3719
3709 3720
3710<p>
3711When Lua collects a full userdata with a <code>gc</code> metamethod,
3712Lua calls the metamethod and marks the userdata as finalized.
3713When this userdata is collected again then
3714Lua frees its corresponding memory.
3715
3716
3717 3721
3718 3722
3719 3723
@@ -3823,23 +3827,23 @@ The <a href="#lua_pcall"><code>lua_pcall</code></a> function returns one of the · 103 unmodified lines
3823 3827
3824<ul>3828<ul>
3825 3829
3826<li><b><a name="pdf-LUA_OK"><code>LUA_OK</code></a> (0):</b>3830<li><b><a name="pdf-LUA_OK"><code>LUA_OK</code></a> (0): </b>
3827success.</li>3831success.</li>
3828 3832
3829<li><b><a name="pdf-LUA_ERRRUN"><code>LUA_ERRRUN</code></a>:</b>3833<li><b><a name="pdf-LUA_ERRRUN"><code>LUA_ERRRUN</code></a>: </b>
3830a runtime error.3834a runtime error.
3831</li>3835</li>
3832 3836
3833<li><b><a name="pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>:</b>3837<li><b><a name="pdf-LUA_ERRMEM"><code>LUA_ERRMEM</code></a>: </b>
3834memory allocation error.3838memory allocation error.
3835For such errors, Lua does not call the message handler.3839For such errors, Lua does not call the message handler.
3836</li>3840</li>
3837 3841
3838<li><b><a name="pdf-LUA_ERRERR"><code>LUA_ERRERR</code></a>:</b>3842<li><b><a name="pdf-LUA_ERRERR"><code>LUA_ERRERR</code></a>: </b>
3839error while running the message handler.3843error while running the message handler.
3840</li>3844</li>
3841 3845
3842<li><b><a name="pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>:</b>3846<li><b><a name="pdf-LUA_ERRGCMM"><code>LUA_ERRGCMM</code></a>: </b>
3843error while running a <code>__gc</code> metamethod.3847error while running a <code>__gc</code> metamethod.
3844(This error typically has no relation with the function being called.3848(This error typically has no relation with the function being called.
3845It is generated by the garbage collector.)3849It is generated by the garbage collector.)
@@ -4018,7 +4022,7 @@ light userdata with the same C&nbsp;address. · 172 unmodified lines
4018 4022
4019<hr><h3><a name="lua_pushliteral"><code>lua_pushliteral</code></a></h3><p>4023<hr><h3><a name="lua_pushliteral"><code>lua_pushliteral</code></a></h3><p>
4020<span class="apii">[-0, +1, <em>m</em>]</span>4024<span class="apii">[-0, +1, <em>m</em>]</span>
4021<pre>void lua_pushliteral (lua_State *L, const char *s);</pre>4025<pre>const char *lua_pushliteral (lua_State *L, const char *s);</pre>
4022 4026
4023<p>4027<p>
4024This macro is equivalent to <a href="#lua_pushlstring"><code>lua_pushlstring</code></a>,4028This macro is equivalent to <a href="#lua_pushlstring"><code>lua_pushlstring</code></a>,
@@ -4341,18 +4345,6 @@ with user data <code>ud</code>. · 316 unmodified lines
4341 4345
4342 4346
4343 4347
4344<hr><h3><a name="lua_setuservalue"><code>lua_setuservalue</code></a></h3><p>
4345<span class="apii">[-1, +0, <em>-</em>]</span>
4346<pre>void lua_setuservalue (lua_State *L, int index);</pre>
4347
4348<p>
4349Pops a table or <b>nil</b> from the stack and sets it as
4350the new value associated to the userdata at the given index.
4351
4352
4353
4354
4355
4356<hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3><p>4348<hr><h3><a name="lua_setfield"><code>lua_setfield</code></a></h3><p>
4357<span class="apii">[-1, +0, <em>e</em>]</span>4349<span class="apii">[-1, +0, <em>e</em>]</span>
4358<pre>void lua_setfield (lua_State *L, int index, const char *k);</pre>4350<pre>void lua_setfield (lua_State *L, int index, const char *k);</pre>
@@ -4433,6 +4425,18 @@ If <code>index</code> is&nbsp;0, then all stack elements are removed. · 74 unmodified lines
4433 4425
4434 4426
4435 4427
4428<hr><h3><a name="lua_setuservalue"><code>lua_setuservalue</code></a></h3><p>
4429<span class="apii">[-1, +0, <em>-</em>]</span>
4430<pre>void lua_setuservalue (lua_State *L, int index);</pre>
4431
4432<p>
4433Pops a table or <b>nil</b> from the stack and sets it as
4434the new value associated to the userdata at the given index.
4435
4436
4437
4438
4439
4436<hr><h3><a name="lua_State"><code>lua_State</code></a></h3>4440<hr><h3><a name="lua_State"><code>lua_State</code></a></h3>
4437<pre>typedef struct lua_State lua_State;</pre>4441<pre>typedef struct lua_State lua_State;</pre>
4438 4442
@@ -4919,7 +4923,7 @@ The fields of <a href="#lua_Debug"><code>lua_Debug</code></a> have the following · 480 unmodified lines
4919 4923
4920<ul>4924<ul>
4921 4925
4922<li><b><code>source</code>:</b>4926<li><b><code>source</code>: </b>
4923the source of the chunk that created the function.4927the source of the chunk that created the function.
4924If <code>source</code> starts with a '<code>@</code>',4928If <code>source</code> starts with a '<code>@</code>',
4925it means that the function was defined in a file where4929it means that the function was defined in a file where
@@ -4931,31 +4935,31 @@ the function was defined in a string where · 5 unmodified lines
4931<code>source</code> is that string.4935<code>source</code> is that string.
4932</li>4936</li>
4933 4937
4934<li><b><code>short_src</code>:</b>4938<li><b><code>short_src</code>: </b>
4935a "printable" version of <code>source</code>, to be used in error messages.4939a "printable" version of <code>source</code>, to be used in error messages.
4936</li>4940</li>
4937 4941
4938<li><b><code>linedefined</code>:</b>4942<li><b><code>linedefined</code>: </b>
4939the line number where the definition of the function starts.4943the line number where the definition of the function starts.
4940</li>4944</li>
4941 4945
4942<li><b><code>lastlinedefined</code>:</b>4946<li><b><code>lastlinedefined</code>: </b>
4943the line number where the definition of the function ends.4947the line number where the definition of the function ends.
4944</li>4948</li>
4945 4949
4946<li><b><code>what</code>:</b>4950<li><b><code>what</code>: </b>
4947the string <code>"Lua"</code> if the function is a Lua function,4951the string <code>"Lua"</code> if the function is a Lua function,
4948<code>"C"</code> if it is a C&nbsp;function,4952<code>"C"</code> if it is a C&nbsp;function,
4949<code>"main"</code> if it is the main part of a chunk.4953<code>"main"</code> if it is the main part of a chunk.
4950</li>4954</li>
4951 4955
4952<li><b><code>currentline</code>:</b>4956<li><b><code>currentline</code>: </b>
4953the current line where the given function is executing.4957the current line where the given function is executing.
4954When no line information is available,4958When no line information is available,
4955<code>currentline</code> is set to -1.4959<code>currentline</code> is set to -1.
4956</li>4960</li>
4957 4961
4958<li><b><code>name</code>:</b>4962<li><b><code>name</code>: </b>
4959a reasonable name for the given function.4963a reasonable name for the given function.
4960Because functions in Lua are first-class values,4964Because functions in Lua are first-class values,
4961they do not have a fixed name:4965they do not have a fixed name:
@@ -4967,7 +4971,7 @@ If it cannot find a name, · 5 unmodified lines
4967then <code>name</code> is set to <code>NULL</code>.4971then <code>name</code> is set to <code>NULL</code>.
4968</li>4972</li>
4969 4973
4970<li><b><code>namewhat</code>:</b>4974<li><b><code>namewhat</code>: </b>
4971explains the <code>name</code> field.4975explains the <code>name</code> field.
4972The value of <code>namewhat</code> can be4976The value of <code>namewhat</code> can be
4973<code>"global"</code>, <code>"local"</code>, <code>"method"</code>,4977<code>"global"</code>, <code>"local"</code>, <code>"method"</code>,
@@ -4976,21 +4980,21 @@ according to how the function was called. · 2 unmodified lines
4976(Lua uses the empty string when no other option seems to apply.)4980(Lua uses the empty string when no other option seems to apply.)
4977</li>4981</li>
4978 4982
4979<li><b><code>istailcall</code>:</b>4983<li><b><code>istailcall</code>: </b>
4980true if this function invocation was called by a tail call.4984true if this function invocation was called by a tail call.
4981In this case, the caller of this level is not in the stack.4985In this case, the caller of this level is not in the stack.
4982</li>4986</li>
4983 4987
4984<li><b><code>nups</code>:</b>4988<li><b><code>nups</code>: </b>
4985the number of upvalues of the function.4989the number of upvalues of the function.
4986</li>4990</li>
4987 4991
4988<li><b><code>nparams</code>:</b>4992<li><b><code>nparams</code>: </b>
4989the number of fixed parameters of the function4993the number of fixed parameters of the function
4990(always 0&nbsp;for C&nbsp;functions).4994(always 0&nbsp;for C&nbsp;functions).
4991</li>4995</li>
4992 4996
4993<li><b><code>isvararg</code>:</b>4997<li><b><code>isvararg</code>: </b>
4994whether the function is a vararg function4998whether the function is a vararg function
4995(always true for C&nbsp;functions).4999(always true for C&nbsp;functions).
4996</li>5000</li>
@@ -5070,29 +5074,30 @@ a value to be pushed on the stack: · 73 unmodified lines
5070 5074
5071<ul>5075<ul>
5072 5076
5073<li><b>'<code>n</code>':</b> fills in the field <code>name</code> and <code>namewhat</code>;5077<li><b>'<code>n</code>': </b> fills in the field <code>name</code> and <code>namewhat</code>;
5074</li>5078</li>
5075 5079
5076<li><b>'<code>S</code>':</b>5080<li><b>'<code>S</code>': </b>
5077fills in the fields <code>source</code>, <code>short_src</code>,5081fills in the fields <code>source</code>, <code>short_src</code>,
5078<code>linedefined</code>, <code>lastlinedefined</code>, and <code>what</code>;5082<code>linedefined</code>, <code>lastlinedefined</code>, and <code>what</code>;
5079</li>5083</li>
5080 5084
5081<li><b>'<code>l</code>':</b> fills in the field <code>currentline</code>;5085<li><b>'<code>l</code>': </b> fills in the field <code>currentline</code>;
5082</li>5086</li>
5083 5087
5084<li><b>'<code>t</code>':</b> fills in the field <code>istailcall</code>;5088<li><b>'<code>t</code>': </b> fills in the field <code>istailcall</code>;
5085</li>5089</li>
5086 5090
5087<li><b>'<code>u</code>':</b> fills in the field <code>nups</code>;5091<li><b>'<code>u</code>': </b> fills in the fields
5092<code>nups</code>, <code>nparams</code>, and <code>isvararg</code>;
5088</li>5093</li>
5089 5094
5090<li><b>'<code>f</code>':</b>5095<li><b>'<code>f</code>': </b>
5091pushes onto the stack the function that is5096pushes onto the stack the function that is
5092running at the given level;5097running at the given level;
5093</li>5098</li>
5094 5099
5095<li><b>'<code>L</code>':</b>5100<li><b>'<code>L</code>': </b>
5096pushes onto the stack a table whose indices are the5101pushes onto the stack a table whose indices are the
5097numbers of the lines that are valid on the function.5102numbers of the lines that are valid on the function.
5098(A <em>valid line</em> is a line with some associated code,5103(A <em>valid line</em> is a line with some associated code,
@@ -5164,7 +5169,8 @@ This function fills parts of a <a href="#lua_Debug"><code>lua_Debug</code></a> s · 65 unmodified lines
5164an identification of the <em>activation record</em>5169an identification of the <em>activation record</em>
5165of the function executing at a given level.5170of the function executing at a given level.
5166Level&nbsp;0 is the current running function,5171Level&nbsp;0 is the current running function,
5167whereas level <em>n+1</em> is the function that has called level <em>n</em>.5172whereas level <em>n+1</em> is the function that has called level <em>n</em>
5173(except for tail calls, which do not count on the stack).
5168When there are no errors, <a href="#lua_getstack"><code>lua_getstack</code></a> returns 1;5174When there are no errors, <a href="#lua_getstack"><code>lua_getstack</code></a> returns 1;
5169when called with a level greater than the stack depth,5175when called with a level greater than the stack depth,
5170it returns 0.5176it returns 0.
@@ -5257,24 +5263,24 @@ For each event, the hook is called as explained below: · 86 unmodified lines
5257 5263
5258<ul>5264<ul>
5259 5265
5260<li><b>The call hook:</b> is called when the interpreter calls a function.5266<li><b>The call hook: </b> is called when the interpreter calls a function.
5261The hook is called just after Lua enters the new function,5267The hook is called just after Lua enters the new function,
5262before the function gets its arguments.5268before the function gets its arguments.
5263</li>5269</li>
5264 5270
5265<li><b>The return hook:</b> is called when the interpreter returns from a function.5271<li><b>The return hook: </b> is called when the interpreter returns from a function.
5266The hook is called just before Lua leaves the function.5272The hook is called just before Lua leaves the function.
5267There is no standard way to access the values5273There is no standard way to access the values
5268to be returned by the function.5274to be returned by the function.
5269</li>5275</li>
5270 5276
5271<li><b>The line hook:</b> is called when the interpreter is about to5277<li><b>The line hook: </b> is called when the interpreter is about to
5272start the execution of a new line of code,5278start the execution of a new line of code,
5273or when it jumps back in the code (even to the same line).5279or when it jumps back in the code (even to the same line).
5274(This event only happens while Lua is executing a Lua function.)5280(This event only happens while Lua is executing a Lua function.)
5275</li>5281</li>
5276 5282
5277<li><b>The count hook:</b> is called after the interpreter executes every5283<li><b>The count hook: </b> is called after the interpreter executes every
5278<code>count</code> instructions.5284<code>count</code> instructions.
5279(This event only happens while Lua is executing a Lua function.)5285(This event only happens while Lua is executing a Lua function.)
5280</li>5286</li>
@@ -5333,7 +5339,7 @@ when the index is greater than the number of upvalues. · 52 unmodified lines
5333 5339
5334<hr><h3><a name="lua_upvalueid"><code>lua_upvalueid</code></a></h3><p>5340<hr><h3><a name="lua_upvalueid"><code>lua_upvalueid</code></a></h3><p>
5335<span class="apii">[-0, +0, <em>-</em>]</span>5341<span class="apii">[-0, +0, <em>-</em>]</span>
5336<pre>void *(lua_upvalueid) (lua_State *L, int funcindex, int n);</pre>5342<pre>void *lua_upvalueid (lua_State *L, int funcindex, int n);</pre>
5337 5343
5338<p>5344<p>
5339Returns an unique identifier for the upvalue numbered <code>n</code>5345Returns an unique identifier for the upvalue numbered <code>n</code>
@@ -5832,7 +5838,7 @@ and returns this number cast to a <a href="#lua_Unsigned"><code>lua_Unsigned</co · 492 unmodified lines
5832 5838
5833<hr><h3><a name="luaL_checkversion"><code>luaL_checkversion</code></a></h3><p>5839<hr><h3><a name="luaL_checkversion"><code>luaL_checkversion</code></a></h3><p>
5834<span class="apii">[-0, +0, <em>-</em>]</span>5840<span class="apii">[-0, +0, <em>-</em>]</span>
5835<pre>void *luaL_checkversion (lua_State *L);</pre>5841<pre>void luaL_checkversion (lua_State *L);</pre>
5836 5842
5837<p>5843<p>
5838Checks whether the core running the call,5844Checks whether the core running the call,
@@ -5919,9 +5925,9 @@ process-related functions in the standard library · 80 unmodified lines
5919 5925
5920 5926
5921<hr><h3><a name="luaL_fileresult"><code>luaL_fileresult</code></a></h3><p>5927<hr><h3><a name="luaL_fileresult"><code>luaL_fileresult</code></a></h3><p>
5922<span class="apii">[-0, +(1/3), <em>m</em>]</span>5928<span class="apii">[-0, +(1|3), <em>m</em>]</span>
5923<pre>int luaL_fileresult (lua_State *L, int stat,5929<pre>int luaL_fileresult (lua_State *L, int stat,
5924 const char *fname)</pre>5930 const char *fname);</pre>
5925 5931
5926<p>5932<p>
5927This function produces the return values for5933This function produces the return values for
@@ -6650,22 +6656,22 @@ It performs different functions according to its first argument, <code>opt</code · 722 unmodified lines
6650 6656
6651<ul>6657<ul>
6652 6658
6653<li><b>"collect":</b>6659<li><b>"collect": </b>
6654performs a full garbage-collection cycle.6660performs a full garbage-collection cycle.
6655This is the default option.6661This is the default option.
6656</li>6662</li>
6657 6663
6658<li><b>"stop":</b>6664<li><b>"stop": </b>
6659stops automatic invocation of the garbage collector.6665stops automatic invocation of the garbage collector.
6660The collector will run only when explcitly invoked,6666The collector will run only when explcitly invoked,
6661until a call to restart it.6667until a call to restart it.
6662</li>6668</li>
6663 6669
6664<li><b>"restart":</b>6670<li><b>"restart": </b>
6665restarts automatic invocation the garbage collector.6671restarts automatic invocation the garbage collector.
6666</li>6672</li>
6667 6673
6668<li><b>"count":</b>6674<li><b>"count": </b>
6669returns the total memory in use by Lua (in Kbytes) and6675returns the total memory in use by Lua (in Kbytes) and
6670a second value with the total memory in bytes modulo 1024.6676a second value with the total memory in bytes modulo 1024.
6671The first value has a fractional part,6677The first value has a fractional part,
@@ -6679,7 +6685,7 @@ so the following equality is always true: · 7 unmodified lines
6679with a non floating-point type for numbers.)6685with a non floating-point type for numbers.)
6680</li>6686</li>
6681 6687
6682<li><b>"step":</b>6688<li><b>"step": </b>
6683performs a garbage-collection step.6689performs a garbage-collection step.
6684The step "size" is controlled by <code>arg</code>6690The step "size" is controlled by <code>arg</code>
6685(larger values mean more steps) in a non-specified way.6691(larger values mean more steps) in a non-specified way.
@@ -6688,19 +6694,19 @@ you must experimentally tune the value of <code>arg</code>. · 2 unmodified lines
6688Returns <b>true</b> if the step finished a collection cycle.6694Returns <b>true</b> if the step finished a collection cycle.
6689</li>6695</li>
6690 6696
6691<li><b>"setpause":</b>6697<li><b>"setpause": </b>
6692sets <code>arg</code> as the new value for the <em>pause</em> of6698sets <code>arg</code> as the new value for the <em>pause</em> of
6693the collector (see <a href="#2.5">&sect;2.5</a>).6699the collector (see <a href="#2.5">&sect;2.5</a>).
6694Returns the previous value for <em>pause</em>.6700Returns the previous value for <em>pause</em>.
6695</li>6701</li>
6696 6702
6697<li><b>"setstepmul":</b>6703<li><b>"setstepmul": </b>
6698sets <code>arg</code> as the new value for the <em>step multiplier</em> of6704sets <code>arg</code> as the new value for the <em>step multiplier</em> of
6699the collector (see <a href="#2.5">&sect;2.5</a>).6705the collector (see <a href="#2.5">&sect;2.5</a>).
6700Returns the previous value for <em>step</em>.6706Returns the previous value for <em>step</em>.
6701</li>6707</li>
6702 6708
6703<li><b>"isrunning":</b>6709<li><b>"isrunning": </b>
6704returns a boolean that tells whether the collector is running6710returns a boolean that tells whether the collector is running
6705(i.e., not stopped).6711(i.e., not stopped).
6706</li>6712</li>
@@ -7757,9 +7763,9 @@ The name <code>gsub</code> comes from <em>Global SUBstitution</em>. · 1050 unmodified lines
7757<p>7763<p>
7758If <code>repl</code> is a string, then its value is used for replacement.7764If <code>repl</code> is a string, then its value is used for replacement.
7759The character&nbsp;<code>%</code> works as an escape character:7765The character&nbsp;<code>%</code> works as an escape character:
7760any sequence in <code>repl</code> of the form <code>%<em>n</em></code>,7766any sequence in <code>repl</code> of the form <code>%<em>d</em></code>,
7761with <em>n</em> between 1 and 9,7767with <em>d</em> between 1 and 9,
7762stands for the value of the <em>n</em>-th captured substring (see below).7768stands for the value of the <em>d</em>-th captured substring (see below).
7763The sequence <code>%0</code> stands for the whole match.7769The sequence <code>%0</code> stands for the whole match.
7764The sequence <code>%%</code> stands for a single&nbsp;<code>%</code>.7770The sequence <code>%%</code> stands for a single&nbsp;<code>%</code>.
7765 7771
@@ -7903,35 +7909,35 @@ The following combinations are allowed in describing a character class: · 137 unmodified lines
7903 7909
7904<ul>7910<ul>
7905 7911
7906<li><b><em>x</em>:</b>7912<li><b><em>x</em>: </b>
7907(where <em>x</em> is not one of the <em>magic characters</em>7913(where <em>x</em> is not one of the <em>magic characters</em>
7908<code>^$()%.[]*+-?</code>)7914<code>^$()%.[]*+-?</code>)
7909represents the character <em>x</em> itself.7915represents the character <em>x</em> itself.
7910</li>7916</li>
7911 7917
7912<li><b><code>.</code>:</b> (a dot) represents all characters.</li>7918<li><b><code>.</code>: </b> (a dot) represents all characters.</li>
7913 7919
7914<li><b><code>%a</code>:</b> represents all letters.</li>7920<li><b><code>%a</code>: </b> represents all letters.</li>
7915 7921
7916<li><b><code>%c</code>:</b> represents all control characters.</li>7922<li><b><code>%c</code>: </b> represents all control characters.</li>
7917 7923
7918<li><b><code>%d</code>:</b> represents all digits.</li>7924<li><b><code>%d</code>: </b> represents all digits.</li>
7919 7925
7920<li><b><code>%g</code>:</b> represents all printable characters except space.</li>7926<li><b><code>%g</code>: </b> represents all printable characters except space.</li>
7921 7927
7922<li><b><code>%l</code>:</b> represents all lowercase letters.</li>7928<li><b><code>%l</code>: </b> represents all lowercase letters.</li>
7923 7929
7924<li><b><code>%p</code>:</b> represents all punctuation characters.</li>7930<li><b><code>%p</code>: </b> represents all punctuation characters.</li>
7925 7931
7926<li><b><code>%s</code>:</b> represents all space characters.</li>7932<li><b><code>%s</code>: </b> represents all space characters.</li>
7927 7933
7928<li><b><code>%u</code>:</b> represents all uppercase letters.</li>7934<li><b><code>%u</code>: </b> represents all uppercase letters.</li>
7929 7935
7930<li><b><code>%w</code>:</b> represents all alphanumeric characters.</li>7936<li><b><code>%w</code>: </b> represents all alphanumeric characters.</li>
7931 7937
7932<li><b><code>%x</code>:</b> represents all hexadecimal digits.</li>7938<li><b><code>%x</code>: </b> represents all hexadecimal digits.</li>
7933 7939
7934<li><b><code>%<em>x</em></code>:</b> (where <em>x</em> is any non-alphanumeric character)7940<li><b><code>%<em>x</em></code>: </b> (where <em>x</em> is any non-alphanumeric character)
7935represents the character <em>x</em>.7941represents the character <em>x</em>.
7936This is the standard way to escape the magic characters.7942This is the standard way to escape the magic characters.
7937Any punctuation character (even the non magic)7943Any punctuation character (even the non magic)
@@ -7939,7 +7945,7 @@ can be preceded by a '<code>%</code>' · 1 unmodified line
7939when used to represent itself in a pattern.7945when used to represent itself in a pattern.
7940</li>7946</li>
7941 7947
7942<li><b><code>[<em>set</em>]</code>:</b>7948<li><b><code>[<em>set</em>]</code>: </b>
7943represents the class which is the union of all7949represents the class which is the union of all
7944characters in <em>set</em>.7950characters in <em>set</em>.
7945A range of characters can be specified by7951A range of characters can be specified by
@@ -7961,7 +7967,7 @@ Therefore, patterns like <code>[%a-z]</code> or <code>[a-%%]</code> · 15 unmodified lines
7961have no meaning.7967have no meaning.
7962</li>7968</li>
7963 7969
7964<li><b><code>[^<em>set</em>]</code>:</b>7970<li><b><code>[^<em>set</em>]</code>: </b>
7965represents the complement of <em>set</em>,7971represents the complement of <em>set</em>,
7966where <em>set</em> is interpreted as above.7972where <em>set</em> is interpreted as above.
7967</li>7973</li>
@@ -8097,13 +8103,11 @@ It provides all its functions inside the table <a name="pdf-table"><code>table</ · 129 unmodified lines
8097 8103
8098 8104
8099<p>8105<p>
8100Currently, all functions in the table library,8106Remember that, whenever an operation needs the length of a table,
8101except <a href="#pdf-table.pack"><code>table.pack</code></a>,8107the table should be a proper sequence
8102work on lists.8108or have a <code>__len</code> metamethod (see <a href="#3.4.6">&sect;3.4.6</a>).
8103A list here means a proper sequence8109All functions ignore non-numeric keys
8104or a table with a <code>__len</code> metamethod (see <a href="#3.4.6">&sect;3.4.6</a>).8110in tables given as arguments.
8105In particular, all functions ignore non-numeric keys
8106in lists given as arguments.
8107 8111
8108 8112
8109<p>8113<p>
@@ -8642,7 +8646,7 @@ Returns the bitwise exclusive or of its operands. · 532 unmodified lines
8642 8646
8643 8647
8644<p>8648<p>
8645<hr><h3><a name="pdf-bit32.extract"><code>bit32.extract (n, field, width)</code></a></h3>8649<hr><h3><a name="pdf-bit32.extract"><code>bit32.extract (n, field [, width])</code></a></h3>
8646 8650
8647 8651
8648<p>8652<p>
@@ -8652,10 +8656,14 @@ Bits are numbered from 0 (least significant) to 31 (most significant). · 3 unmodified lines
8652All accessed bits must be in the range <em>[0, 31]</em>.8656All accessed bits must be in the range <em>[0, 31]</em>.
8653 8657
8654 8658
8659<p>
8660The default for <code>width</code> is 1.
8661
8662
8655 8663
8656 8664
8657<p>8665<p>
8658<hr><h3><a name="pdf-bit32.replace"><code>bit32.replace (n, v, field, width)</code></a></h3>8666<hr><h3><a name="pdf-bit32.replace"><code>bit32.replace (n, v, field [, width])</code></a></h3>
8659 8667
8660 8668
8661<p>8669<p>
@@ -8848,7 +8856,7 @@ instead of returning an error code. · 186 unmodified lines
8848<p>8856<p>
8849Opens the given file name in read mode8857Opens the given file name in read mode
8850and returns an iterator function that8858and returns an iterator function that
8851works like <code>file:lines(&middot;&middot;&middot;)</code> over the oppened file.8859works like <code>file:lines(&middot;&middot;&middot;)</code> over the opened file.
8852When the iterator function detects the end of file,8860When the iterator function detects the end of file,
8853it returns <b>nil</b> (to finish the loop) and automatically closes the file.8861it returns <b>nil</b> (to finish the loop) and automatically closes the file.
8854 8862
@@ -8877,12 +8885,12 @@ or, in case of errors, <b>nil</b> plus an error message. · 22 unmodified lines
8877The <code>mode</code> string can be any of the following:8885The <code>mode</code> string can be any of the following:
8878 8886
8879<ul>8887<ul>
8880<li><b>"r":</b> read mode (the default);</li>8888<li><b>"r": </b> read mode (the default);</li>
8881<li><b>"w":</b> write mode;</li>8889<li><b>"w": </b> write mode;</li>
8882<li><b>"a":</b> append mode;</li>8890<li><b>"a": </b> append mode;</li>
8883<li><b>"r+":</b> update mode, all previous data is preserved;</li>8891<li><b>"r+": </b> update mode, all previous data is preserved;</li>
8884<li><b>"w+":</b> update mode, all previous data is erased;</li>8892<li><b>"w+": </b> update mode, all previous data is erased;</li>
8885<li><b>"a+":</b> append update mode, previous data is preserved,8893<li><b>"a+": </b> append update mode, previous data is preserved,
8886 writing is only allowed at the end of file.</li>8894 writing is only allowed at the end of file.</li>
8887</ul><p>8895</ul><p>
8888The <code>mode</code> string can also have a '<code>b</code>' at the end,8896The <code>mode</code> string can also have a '<code>b</code>' at the end,
@@ -9037,28 +9045,28 @@ The available formats are · 148 unmodified lines
9037 9045
9038<ul>9046<ul>
9039 9047
9040<li><b>"*n":</b>9048<li><b>"*n": </b>
9041reads a number;9049reads a number;
9042this is the only format that returns a number instead of a string.9050this is the only format that returns a number instead of a string.
9043</li>9051</li>
9044 9052
9045<li><b>"*a":</b>9053<li><b>"*a": </b>
9046reads the whole file, starting at the current position.9054reads the whole file, starting at the current position.
9047On end of file, it returns the empty string.9055On end of file, it returns the empty string.
9048</li>9056</li>
9049 9057
9050<li><b>"*l":</b>9058<li><b>"*l": </b>
9051reads the next line skipping the end of line,9059reads the next line skipping the end of line,
9052returning <b>nil</b> on end of file.9060returning <b>nil</b> on end of file.
9053This is the default format.9061This is the default format.
9054</li>9062</li>
9055 9063
9056<li><b>"*L":</b>9064<li><b>"*L": </b>
9057reads the next line keeping the end of line (if present),9065reads the next line keeping the end of line (if present),
9058returning <b>nil</b> on end of file.9066returning <b>nil</b> on end of file.
9059</li>9067</li>
9060 9068
9061<li><b><em>number</em>:</b>9069<li><b><em>number</em>: </b>
9062reads a string with up to this number of characters,9070reads a string with up to this number of characters,
9063returning <b>nil</b> on end of file.9071returning <b>nil</b> on end of file.
9064If number is zero,9072If number is zero,
@@ -9081,9 +9089,9 @@ to the position given by <code>offset</code> plus a base · 16 unmodified lines
9081specified by the string <code>whence</code>, as follows:9089specified by the string <code>whence</code>, as follows:
9082 9090
9083<ul>9091<ul>
9084<li><b>"set":</b> base is position 0 (beginning of the file);</li>9092<li><b>"set": </b> base is position 0 (beginning of the file);</li>
9085<li><b>"cur":</b> base is current position;</li>9093<li><b>"cur": </b> base is current position;</li>
9086<li><b>"end":</b> base is end of file;</li>9094<li><b>"end": </b> base is end of file;</li>
9087</ul><p>9095</ul><p>
9088In case of success, function <code>seek</code> returns the final file position,9096In case of success, function <code>seek</code> returns the final file position,
9089measured in bytes from the beginning of the file.9097measured in bytes from the beginning of the file.
@@ -9114,17 +9122,17 @@ There are three available modes: · 24 unmodified lines
9114 9122
9115<ul>9123<ul>
9116 9124
9117<li><b>"no":</b>9125<li><b>"no": </b>
9118no buffering; the result of any output operation appears immediately.9126no buffering; the result of any output operation appears immediately.
9119</li>9127</li>
9120 9128
9121<li><b>"full":</b>9129<li><b>"full": </b>
9122full buffering; output operation is performed only9130full buffering; output operation is performed only
9123when the buffer is full (or when you explicitly <code>flush</code> the file9131when the buffer is full (or when you explicitly <code>flush</code> the file
9124(see <a href="#pdf-io.flush"><code>io.flush</code></a>)).9132(see <a href="#pdf-io.flush"><code>io.flush</code></a>)).
9125</li>9133</li>
9126 9134
9127<li><b>"line":</b>9135<li><b>"line": </b>
9128line buffering; output is buffered until a newline is output9136line buffering; output is buffered until a newline is output
9129or there is any input from some special files9137or there is any input from some special files
9130(such as a terminal device).9138(such as a terminal device).
@@ -9251,12 +9259,12 @@ as follows: · 120 unmodified lines
9251 9259
9252<ul>9260<ul>
9253 9261
9254<li><b>"<code>exit</code>":</b>9262<li><b>"<code>exit</code>": </b>
9255the command terminated normally;9263the command terminated normally;
9256the following number is the exit status of the command.9264the following number is the exit status of the command.
9257</li>9265</li>
9258 9266
9259<li><b>"<code>signal</code>":</b>9267<li><b>"<code>signal</code>": </b>
9260the command was terminated by a signal;9268the command was terminated by a signal;
9261the following number is the signal that terminated the command.9269the following number is the signal that terminated the command.
9262</li>9270</li>
@@ -9460,18 +9468,6 @@ within any function, and so have no direct access to local variables. · 197 unmodified lines
9460 9468
9461 9469
9462 9470
9463<p>
9464<hr><h3><a name="pdf-debug.getuservalue"><code>debug.getuservalue (u)</code></a></h3>
9465
9466
9467<p>
9468Returns the Lua value associated to <code>u</code>.
9469If <code>u</code> is not a userdata,
9470returns <b>nil</b>.
9471
9472
9473
9474
9475<p>9471<p>
9476<hr><h3><a name="pdf-debug.gethook"><code>debug.gethook ([thread])</code></a></h3>9472<hr><h3><a name="pdf-debug.gethook"><code>debug.gethook ([thread])</code></a></h3>
9477 9473
@@ -9596,18 +9592,13 @@ The function returns <b>nil</b> if there is no upvalue with the given index. · 118 unmodified lines
9596 9592
9597 9593
9598<p>9594<p>
9599<hr><h3><a name="pdf-debug.setuservalue"><code>debug.setuservalue (udata, value)</code></a></h3>9595<hr><h3><a name="pdf-debug.getuservalue"><code>debug.getuservalue (u)</code></a></h3>
9600
9601
9602<p>
9603Sets the given <code>value</code> as
9604the Lua value associated to the given <code>udata</code>.
9605<code>value</code> must be a table or <b>nil</b>;
9606<code>udata</code> must be a full userdata.
9607 9596
9608 9597
9609<p>9598<p>
9610Returns <code>udata</code>.9599Returns the Lua value associated to <code>u</code>.
9600If <code>u</code> is not a userdata,
9601returns <b>nil</b>.
9611 9602
9612 9603
9613 9604
@@ -9624,9 +9615,9 @@ The string mask may have the following characters, · 10 unmodified lines
9624with the given meaning:9615with the given meaning:
9625 9616
9626<ul>9617<ul>
9627<li><b><code>"c"</code>:</b> the hook is called every time Lua calls a function;</li>9618<li><b><code>"c"</code>: </b> the hook is called every time Lua calls a function;</li>
9628<li><b><code>"r"</code>:</b> the hook is called every time Lua returns from a function;</li>9619<li><b><code>"r"</code>: </b> the hook is called every time Lua returns from a function;</li>
9629<li><b><code>"l"</code>:</b> the hook is called every time Lua enters a new line of code.</li>9620<li><b><code>"l"</code>: </b> the hook is called every time Lua enters a new line of code.</li>
9630</ul><p>9621</ul><p>
9631With a <code>count</code> different from zero,9622With a <code>count</code> different from zero,
9632the hook is called after every <code>count</code> instructions.9623the hook is called after every <code>count</code> instructions.
@@ -9701,6 +9692,23 @@ Otherwise, it returns the name of the upvalue. · 68 unmodified lines
9701 9692
9702 9693
9703 9694
9695<p>
9696<hr><h3><a name="pdf-debug.setuservalue"><code>debug.setuservalue (udata, value)</code></a></h3>
9697
9698
9699<p>
9700Sets the given <code>value</code> as
9701the Lua value associated to the given <code>udata</code>.
9702<code>value</code> must be a table or <b>nil</b>;
9703<code>udata</code> must be a full userdata.
9704
9705
9706<p>
9707Returns <code>udata</code>.
9708
9709
9710
9711
9704<p>9712<p>
9705<hr><h3><a name="pdf-debug.traceback"><code>debug.traceback ([thread,] [message [, level]])</code></a></h3>9713<hr><h3><a name="pdf-debug.traceback"><code>debug.traceback ([thread,] [message [, level]])</code></a></h3>
9706 9714
@@ -9772,12 +9780,12 @@ Its usage is: · 65 unmodified lines
9772The options are:9780The options are:
9773 9781
9774<ul>9782<ul>
9775<li><b><code>-e <em>stat</em></code>:</b> executes string <em>stat</em>;</li>9783<li><b><code>-e <em>stat</em></code>: </b> executes string <em>stat</em>;</li>
9776<li><b><code>-l <em>mod</em></code>:</b> "requires" <em>mod</em>;</li>9784<li><b><code>-l <em>mod</em></code>: </b> "requires" <em>mod</em>;</li>
9777<li><b><code>-i</code>:</b> enters interactive mode after running <em>script</em>;</li>9785<li><b><code>-i</code>: </b> enters interactive mode after running <em>script</em>;</li>
9778<li><b><code>-v</code>:</b> prints version information;</li>9786<li><b><code>-v</code>: </b> prints version information;</li>
9779<li><b><code>--</code>:</b> stops handling options;</li>9787<li><b><code>--</code>: </b> stops handling options;</li>
9780<li><b><code>-</code>:</b> executes <code>stdin</code> as a file and stops handling options.</li>9788<li><b><code>-</code>: </b> executes <code>stdin</code> as a file and stops handling options.</li>
9781</ul><p>9789</ul><p>
9782After handling its options, <code>lua</code> runs the given <em>script</em>,9790After handling its options, <code>lua</code> runs the given <em>script</em>,
9783passing to it the given <em>args</em> as string arguments.9791passing to it the given <em>args</em> as string arguments.
@@ -10195,7 +10203,7 @@ Here is the complete syntax of Lua in extended BNF. · 411 unmodified lines
10195<HR>10203<HR>
10196<SMALL CLASS="footer">10204<SMALL CLASS="footer">
10197Last update:10205Last update:
10198Tue Jun 21 19:09:27 BRT 201110206Mon Jun 27 15:48:15 BRT 2011
10199</SMALL>10207</SMALL>
10200<!--10208<!--
10201Last change: revised for Lua 5.2.0 (beta)10209Last change: revised for Lua 5.2.0 (beta)
doc/readme.html+3−5
@@ -145,9 +145,7 @@ and liblua.a (the library). · 144 unmodified lines
145<P>145<P>
146<LI>146<LI>
147 To check that Lua has been built correctly, do "<KBD>make test</KBD>"147 To check that Lua has been built correctly, do "<KBD>make test</KBD>"
148 after building Lua. This will run the interpreter on a simple "Hello world"148 after building Lua. This will run the interpreter and print its version string.
149 Lua program from the test directory.
150 You may want to try other example programs in that directory.
151</OL>149</OL>
152 150
153<H3>Installing Lua</H3>151<H3>Installing Lua</H3>
@@ -162,7 +160,7 @@ and liblua.a (the library). · 8 unmodified lines
162 where xxx is your platform name.160 where xxx is your platform name.
163 161
164<P>162<P>
165 To install Lua locally, then do "<KBD>make local</KBD>".163 To install Lua locally, do "<KBD>make local</KBD>".
166 This will create a directory <TT>install</TT> with subdirectories164 This will create a directory <TT>install</TT> with subdirectories
167 <TT>bin</TT>, <TT>include</TT>, <TT>lib</TT>, <TT>man</TT>,165 <TT>bin</TT>, <TT>include</TT>, <TT>lib</TT>, <TT>man</TT>,
168 and install Lua as listed below.166 and install Lua as listed below.
@@ -399,7 +397,7 @@ THE SOFTWARE. · 230 unmodified lines
399<HR>397<HR>
400<SMALL CLASS="footer">398<SMALL CLASS="footer">
401Last update:399Last update:
402Thu Jun 16 08:21:17 BRT 2011400Fri Jun 24 11:30:57 BRT 2011
403</SMALL>401</SMALL>
404<!--402<!--
405Last change: revised for Lua 5.2.0 (beta)403Last change: revised for Lua 5.2.0 (beta)
src/Makefile+6−5
@@ -28,7 +28,7 @@ MYLIBS= · 27 unmodified lines
28PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris28PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
29 29
30LUA_A= liblua.a30LUA_A= liblua.a
31CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \31CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
32 lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \32 lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
33 ltm.o lundump.o lvm.o lzio.o33 ltm.o lundump.o lvm.o lzio.o
34LIB_O= lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \34LIB_O= lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \
@@ -132,6 +132,7 @@ lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ · 97 unmodified lines
132 lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \132 lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \
133 lstring.h ltable.h lvm.h133 lstring.h ltable.h lvm.h
134lcorolib.o: lcorolib.c lua.h luaconf.h lauxlib.h lualib.h134lcorolib.o: lcorolib.c lua.h luaconf.h lauxlib.h lualib.h
135lctype.o: lctype.c lctype.h lua.h luaconf.h llimits.h
135ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h136ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h
136ldebug.o: ldebug.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \137ldebug.o: ldebug.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \
137 ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h ldebug.h ldo.h \138 ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h ldebug.h ldo.h \
@@ -147,14 +148,14 @@ lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \ · 9 unmodified lines
147 lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h148 lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h
148linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h149linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h
149liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h150liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h
150llex.o: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \151llex.o: llex.c lua.h luaconf.h lctype.h llimits.h ldo.h lobject.h \
151 lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h152 lstate.h ltm.h lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h
152lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h153lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
153lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \154lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
154 ltm.h lzio.h lmem.h ldo.h lgc.h155 ltm.h lzio.h lmem.h ldo.h lgc.h
155loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h156loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
156lobject.o: lobject.c lua.h luaconf.h ldebug.h lstate.h lobject.h \157lobject.o: lobject.c lua.h luaconf.h lctype.h llimits.h ldebug.h lstate.h \
157 llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h lvm.h158 lobject.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h lvm.h
158lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h159lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
159loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h160loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h
160lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \161lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
src/lctype.c+49−0
@@ -0,0 +1,49 @@
1/*
2** $Id: lctype.c,v 1.10 2011/06/24 12:25:33 roberto Exp $
3** 'ctype' functions for Lua
4** See Copyright Notice in lua.h
5*/
6
7#include "lctype.h"
8
9#if !LUA_USE_CTYPE /* { */
10
11#include <limits.h>
12
13LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = {
14 0x00, /* EOZ */
15 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */
16 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
17 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */
18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */
20 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
21 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */
22 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
23 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */
24 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
25 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */
26 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05,
27 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */
28 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
29 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */
30 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00,
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */
36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47};
48
49#endif /* } */
src/lctype.h+95−0
@@ -0,0 +1,95 @@
1/*
2** $Id: lctype.h,v 1.11 2011/06/27 18:22:46 roberto Exp $
3** 'ctype' functions for Lua
4** See Copyright Notice in lua.h
5*/
6
7#ifndef lctype_h
8#define lctype_h
9
10#include "lua.h"
11
12
13/*
14** WARNING: the functions defined here do not necessarily correspond
15** to the similar functions in the standard C ctype.h. They are
16** optimized for the specific needs of Lua
17*/
18
19#if !defined(LUA_USE_CTYPE)
20
21#if 'A' == 65 && '0' == 48
22/* ASCII case: can use its own tables; faster and fixed */
23#define LUA_USE_CTYPE 0
24#else
25/* must use standard C ctype */
26#define LUA_USE_CTYPE 1
27#endif
28
29#endif
30
31
32#if !LUA_USE_CTYPE /* { */
33
34#include <limits.h>
35
36#include "llimits.h"
37
38
39#define ALPHABIT 0
40#define DIGITBIT 1
41#define PRINTBIT 2
42#define SPACEBIT 3
43#define XDIGITBIT 4
44
45
46#define MASK(B) (1 << (B))
47
48
49/*
50** add 1 to char to allow index -1 (EOZ)
51*/
52#define testprop(c,p) (luai_ctype_[(c)+1] & (p))
53
54/*
55** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_'
56*/
57#define lislalpha(c) testprop(c, MASK(ALPHABIT))
58#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT)))
59#define lisdigit(c) testprop(c, MASK(DIGITBIT))
60#define lisspace(c) testprop(c, MASK(SPACEBIT))
61#define lisprint(c) testprop(c, MASK(PRINTBIT))
62#define lisxdigit(c) testprop(c, MASK(XDIGITBIT))
63
64/*
65** this 'ltolower' only works for alphabetic characters
66*/
67#define ltolower(c) ((c) | ('A' ^ 'a'))
68
69
70/* two more entries for 0 and -1 (EOZ) */
71LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
72
73
74#else /* }{ */
75
76/*
77** use standard C ctypes
78*/
79
80#include <ctype.h>
81
82
83#define lislalpha(c) (isalpha(c) || (c) == '_')
84#define lislalnum(c) (isalnum(c) || (c) == '_')
85#define lisdigit(c) (isdigit(c))
86#define lisspace(c) (isspace(c))
87#define lisprint(c) (isprint(c))
88#define lisxdigit(c) (isxdigit(c))
89
90#define ltolower(c) (tolower(c))
91
92#endif /* } */
93
94#endif
95
src/llex.c+48−20
@@ -1,11 +1,11 @@
1/*1/*
2** $Id: llex.c,v 2.50 2011/06/20 16:52:48 roberto Exp $2** $Id: llex.c,v 2.49 2011/06/23 14:54:48 roberto Exp $
3** Lexical Analyzer3** Lexical Analyzer
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
6 6
7 7
8#include <ctype.h>8#include <locale.h>
9#include <string.h>9#include <string.h>
10 10
11#define llex_c11#define llex_c
@@ -13,6 +13,7 @@ · 1 unmodified line
13 13
14#include "lua.h"14#include "lua.h"
15 15
16#include "lctype.h"
16#include "ldo.h"17#include "ldo.h"
17#include "llex.h"18#include "llex.h"
18#include "lobject.h"19#include "lobject.h"
@@ -74,7 +75,7 @@ void luaX_init (lua_State *L) { · 55 unmodified lines
74const char *luaX_token2str (LexState *ls, int token) {75const char *luaX_token2str (LexState *ls, int token) {
75 if (token < FIRST_RESERVED) {76 if (token < FIRST_RESERVED) {
76 lua_assert(token == cast(unsigned char, token));77 lua_assert(token == cast(unsigned char, token));
77 return (isprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) :78 return (lisprint(token)) ? luaO_pushfstring(ls->L, LUA_QL("%c"), token) :
78 luaO_pushfstring(ls->L, "char(%d)", token);79 luaO_pushfstring(ls->L, "char(%d)", token);
79 }80 }
80 else {81 else {
@@ -184,24 +185,52 @@ static int check_next (LexState *ls, const char *set) { · 103 unmodified lines
184}185}
185 186
186 187
188/*
189** change all characters 'from' in buffer to 'to'
190*/
191static void buffreplace (LexState *ls, char from, char to) {
192 size_t n = luaZ_bufflen(ls->buff);
193 char *p = luaZ_buffer(ls->buff);
194 while (n--)
195 if (p[n] == from) p[n] = to;
196}
197
198
199#if !defined(getlocaledecpoint)
200#define getlocaledecpoint() (localeconv()->decimal_point[0])
201#endif
202
187 203
188#define buff2d(b,e) luaO_str2d(luaZ_buffer(b), luaZ_bufflen(b) - 1, e)204#define buff2d(b,e) luaO_str2d(luaZ_buffer(b), luaZ_bufflen(b) - 1, e)
189 205
206/*
207** in case of format error, try to change decimal point separator to
208** the one defined in the current locale and check again
209*/
210static void trydecpoint (LexState *ls, SemInfo *seminfo) {
211 char old = ls->decpoint;
212 ls->decpoint = getlocaledecpoint();
213 buffreplace(ls, old, ls->decpoint); /* try new decimal separator */
214 if (!buff2d(ls->buff, &seminfo->r)) {
215 /* format error with correct decimal point: no more options */
216 buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
217 lexerror(ls, "malformed number", TK_NUMBER);
218 }
219}
220
190 221
191/* LUA_NUMBER */222/* LUA_NUMBER */
192static void read_numeral (LexState *ls, SemInfo *seminfo) {223static void read_numeral (LexState *ls, SemInfo *seminfo) {
193 lua_assert(isdigit(ls->current));224 lua_assert(lisdigit(ls->current));
194 do {225 do {
195 save_and_next(ls);226 save_and_next(ls);
196 if (check_next(ls, "EePp")) /* exponent part? */227 if (check_next(ls, "EePp")) /* exponent part? */
197 check_next(ls, "+-"); /* optional exponent sign */228 check_next(ls, "+-"); /* optional exponent sign */
198 } while (isalnum(ls->current) || ls->current == '.');229 } while (lislalnum(ls->current) || ls->current == '.');
199 save(ls, '\0');230 save(ls, '\0');
200 if (!luaO_str2d(luaZ_buffer(ls->buff),231 buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */
201 luaZ_bufflen(ls->buff) - 1,232 if (!buff2d(ls->buff, &seminfo->r)) /* format error? */
202 &seminfo->r)) /* format error? */233 trydecpoint(ls, seminfo); /* try to update decimal point separator */
203 lexerror(ls, "malformed number", TK_NUMBER);
204
205}234}
206 235
207 236
@@ -260,9 +289,9 @@ static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { · 52 unmodified lines
260static int readhexaesc (LexState *ls) {289static int readhexaesc (LexState *ls) {
261 int c1 = next(ls);290 int c1 = next(ls);
262 int c2 = EOZ;291 int c2 = EOZ;
263 if (isxdigit(c1)) {292 if (lisxdigit(c1)) {
264 c2 = next(ls);293 c2 = next(ls);
265 if (isxdigit(c2))294 if (lisxdigit(c2))
266 return (luaO_hexavalue(c1) << 4) + luaO_hexavalue(c2);295 return (luaO_hexavalue(c1) << 4) + luaO_hexavalue(c2);
267 /* else go through to error */296 /* else go through to error */
268 }297 }
@@ -279,10 +308,10 @@ static int readdecesc (LexState *ls) { · 10 unmodified lines
279 int c1 = ls->current; /* first char must be a digit */308 int c1 = ls->current; /* first char must be a digit */
280 int c2 = next(ls); /* read second char */309 int c2 = next(ls); /* read second char */
281 int c = c1 - '0'; /* partial result */310 int c = c1 - '0'; /* partial result */
282 if (isdigit(c2)) {311 if (lisdigit(c2)) {
283 int c3 = next(ls); /* read third char */312 int c3 = next(ls); /* read third char */
284 c = 10*c + c2 - '0'; /* update result */313 c = 10*c + c2 - '0'; /* update result */
285 if (isdigit(c3)) {314 if (lisdigit(c3)) {
286 c = 10*c + c3 - '0'; /* update result */315 c = 10*c + c3 - '0'; /* update result */
287 if (c > UCHAR_MAX) {316 if (c > UCHAR_MAX) {
288 luaZ_resetbuffer(ls->buff); /* prepare error message */317 luaZ_resetbuffer(ls->buff); /* prepare error message */
@@ -327,14 +356,14 @@ static void read_string (LexState *ls, int del, SemInfo *seminfo) { · 38 unmodified lines
327 case EOZ: continue; /* will raise an error next loop */356 case EOZ: continue; /* will raise an error next loop */
328 case '*': { /* skip following span of spaces */357 case '*': { /* skip following span of spaces */
329 next(ls); /* skip the '*' */358 next(ls); /* skip the '*' */
330 while (isspace(ls->current)) {359 while (lisspace(ls->current)) {
331 if (currIsNewline(ls)) inclinenumber(ls);360 if (currIsNewline(ls)) inclinenumber(ls);
332 else next(ls);361 else next(ls);
333 }362 }
334 continue; /* do not save 'c' */363 continue; /* do not save 'c' */
335 }364 }
336 default: {365 default: {
337 if (!isdigit(ls->current))366 if (!lisdigit(ls->current))
338 c = ls->current; /* handles \\, \", \', and \? */367 c = ls->current; /* handles \\, \", \', and \? */
339 else /* digital escape \ddd */368 else /* digital escape \ddd */
340 c = readdecesc(ls);369 c = readdecesc(ls);
@@ -431,7 +460,7 @@ static int llex (LexState *ls, SemInfo *seminfo) { · 90 unmodified lines
431 return TK_DOTS; /* '...' */460 return TK_DOTS; /* '...' */
432 else return TK_CONCAT; /* '..' */461 else return TK_CONCAT; /* '..' */
433 }462 }
434 else if (!isdigit(ls->current)) return '.';463 else if (!lisdigit(ls->current)) return '.';
435 /* else go through */464 /* else go through */
436 }465 }
437 case '0': case '1': case '2': case '3': case '4':466 case '0': case '1': case '2': case '3': case '4':
@@ -443,12 +472,11 @@ static int llex (LexState *ls, SemInfo *seminfo) { · 5 unmodified lines
443 return TK_EOS;472 return TK_EOS;
444 }473 }
445 default: {474 default: {
446 if (isalpha(ls->current) || ls->current == '_') {475 if (lislalpha(ls->current)) { /* identifier or reserved word? */
447 /* identifier or reserved word */
448 TString *ts;476 TString *ts;
449 do {477 do {
450 save_and_next(ls);478 save_and_next(ls);
451 } while (isalnum(ls->current) || ls->current == '_');479 } while (lislalnum(ls->current));
452 ts = luaX_newstring(ls, luaZ_buffer(ls->buff),480 ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
453 luaZ_bufflen(ls->buff));481 luaZ_bufflen(ls->buff));
454 seminfo->ts = ts;482 seminfo->ts = ts;
src/lobject.c+9−10
@@ -1,10 +1,9 @@
1/*1/*
2** $Id: lobject.c,v 2.51 2011/06/18 17:25:15 roberto Exp $2** $Id: lobject.c,v 2.52 2011/06/24 12:25:02 roberto Exp $
3** Some generic functions over Lua objects3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
6 6
7#include <ctype.h>
8#include <stdarg.h>7#include <stdarg.h>
9#include <stdio.h>8#include <stdio.h>
10#include <stdlib.h>9#include <stdlib.h>
@@ -15,6 +14,7 @@ · 4 unmodified lines
15 14
16#include "lua.h"15#include "lua.h"
17 16
17#include "lctype.h"
18#include "ldebug.h"18#include "ldebug.h"
19#include "ldo.h"19#include "ldo.h"
20#include "lmem.h"20#include "lmem.h"
@@ -85,9 +85,8 @@ lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2) { · 64 unmodified lines
85 85
86 86
87int luaO_hexavalue (int c) {87int luaO_hexavalue (int c) {
88 lua_assert(isxdigit(c));88 if (lisdigit(c)) return c - '0';
89 if (isdigit(c)) return c - '0';89 else return ltolower(c) - 'a' + 10;
90 else return toupper(c) - 'A' + 10;
91}90}
92 91
93 92
@@ -104,7 +103,7 @@ static int isneg (const char **s) { · 10 unmodified lines
104 103
105 104
106static lua_Number readhexa (const char **s, lua_Number r, int *count) {105static lua_Number readhexa (const char **s, lua_Number r, int *count) {
107 while (isxdigit(cast_uchar(**s))) { /* read integer part */106 while (lisxdigit(cast_uchar(**s))) { /* read integer part */
108 r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(*(*s)++)));107 r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(*(*s)++)));
109 (*count)++;108 (*count)++;
110 }109 }
@@ -121,7 +120,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { · 10 unmodified lines
121 int e = 0, i = 0;120 int e = 0, i = 0;
122 int neg = 0; /* 1 if number is negative */121 int neg = 0; /* 1 if number is negative */
123 *endptr = cast(char *, s); /* nothing is valid yet */122 *endptr = cast(char *, s); /* nothing is valid yet */
124 while (isspace(cast_uchar(*s))) s++; /* skip initial spaces */123 while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
125 neg = isneg(&s); /* check signal */124 neg = isneg(&s); /* check signal */
126 if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */125 if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */
127 return 0.0; /* invalid format (no '0x') */126 return 0.0; /* invalid format (no '0x') */
@@ -140,9 +139,9 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { · 12 unmodified lines
140 int neg1;139 int neg1;
141 s++; /* skip 'p' */140 s++; /* skip 'p' */
142 neg1 = isneg(&s); /* signal */141 neg1 = isneg(&s); /* signal */
143 if (!isdigit(cast_uchar(*s)))142 if (!lisdigit(cast_uchar(*s)))
144 goto ret; /* must have at least one digit */143 goto ret; /* must have at least one digit */
145 while (isdigit(cast_uchar(*s))) /* read exponent */144 while (lisdigit(cast_uchar(*s))) /* read exponent */
146 exp1 = exp1 * 10 + *(s++) - '0';145 exp1 = exp1 * 10 + *(s++) - '0';
147 if (neg1) exp1 = -exp1;146 if (neg1) exp1 = -exp1;
148 e += exp1;147 e += exp1;
@@ -163,7 +162,7 @@ int luaO_str2d (const char *s, size_t len, lua_Number *result) { · 14 unmodified lines
163 else162 else
164 *result = lua_str2number(s, &endptr);163 *result = lua_str2number(s, &endptr);
165 if (endptr == s) return 0; /* nothing recognized */164 if (endptr == s) return 0; /* nothing recognized */
166 while (isspace(cast_uchar(*endptr))) endptr++;165 while (lisspace(cast_uchar(*endptr))) endptr++;
167 return (endptr == s + len); /* OK if no trailing characters */166 return (endptr == s + len); /* OK if no trailing characters */
168}167}
169 168
src/lparser.c+13−20
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lparser.c,v 2.111 2011/06/20 16:52:48 roberto Exp $2** $Id: lparser.c,v 2.112 2011/06/27 18:18:59 roberto Exp $
3** Lua Parser3** Lua Parser
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -367,7 +367,7 @@ static int findlabel (LexState *ls, int g) { · 361 unmodified lines
367 /* check labels in current block for a match */367 /* check labels in current block for a match */
368 for (i = bl->firstlabel; i < dyd->label.n; i++) {368 for (i = bl->firstlabel; i < dyd->label.n; i++) {
369 Labeldesc *lb = &dyd->label.arr[i];369 Labeldesc *lb = &dyd->label.arr[i];
370 if (eqstr(lb->name, gt->name) && lb->pc != -1) { /* correct label? */370 if (eqstr(lb->name, gt->name)) { /* correct label? */
371 if (gt->nactvar > lb->nactvar &&371 if (gt->nactvar > lb->nactvar &&
372 (bl->upval || dyd->label.n > bl->firstlabel))372 (bl->upval || dyd->label.n > bl->firstlabel))
373 luaK_patchclose(ls->fs, gt->pc, lb->nactvar);373 luaK_patchclose(ls->fs, gt->pc, lb->nactvar);
@@ -466,12 +466,6 @@ static void undefgoto (LexState *ls, Labeldesc *gt) { · 92 unmodified lines
466}466}
467 467
468 468
469static void invalidatelabels (Labellist *ll, int level) {
470 for (; level < ll->n; level++)
471 ll->arr[level].pc = -1; /* mark label as out of scope */
472}
473
474
475static void leaveblock (FuncState *fs) {469static void leaveblock (FuncState *fs) {
476 BlockCnt *bl = fs->bl;470 BlockCnt *bl = fs->bl;
477 LexState *ls = fs->ls;471 LexState *ls = fs->ls;
@@ -487,7 +481,7 @@ static void leaveblock (FuncState *fs) { · 9 unmodified lines
487 removevars(fs, bl->nactvar);481 removevars(fs, bl->nactvar);
488 lua_assert(bl->nactvar == fs->nactvar);482 lua_assert(bl->nactvar == fs->nactvar);
489 fs->freereg = fs->nactvar; /* free registers */483 fs->freereg = fs->nactvar; /* free registers */
490 invalidatelabels(&ls->dyd->label, bl->firstlabel); /* remove local labels */484 ls->dyd->label.n = bl->firstlabel; /* remove local labels */
491 if (bl->previous) /* inner block? */485 if (bl->previous) /* inner block? */
492 movegotosout(fs, bl); /* update pending gotos to outer block */486 movegotosout(fs, bl); /* update pending gotos to outer block */
493 else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */487 else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */
@@ -532,7 +526,6 @@ static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) { · 38 unmodified lines
532 fs->nlocvars = 0;526 fs->nlocvars = 0;
533 fs->nactvar = 0;527 fs->nactvar = 0;
534 fs->firstlocal = ls->dyd->actvar.n;528 fs->firstlocal = ls->dyd->actvar.n;
535 fs->firstlabel = ls->dyd->label.n;
536 fs->bl = NULL;529 fs->bl = NULL;
537 f = luaF_newproto(L);530 f = luaF_newproto(L);
538 fs->f = f;531 fs->f = f;
@@ -555,7 +548,6 @@ static void close_func (LexState *ls) { · 16 unmodified lines
555 Proto *f = fs->f;548 Proto *f = fs->f;
556 luaK_ret(fs, 0, 0); /* final return */549 luaK_ret(fs, 0, 0); /* final return */
557 leaveblock(fs);550 leaveblock(fs);
558 ls->dyd->label.n = fs->firstlabel; /* remove labels */
559 luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction);551 luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction);
560 f->sizecode = fs->pc;552 f->sizecode = fs->pc;
561 luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int);553 luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int);
@@ -1193,16 +1185,15 @@ static void gotostat (LexState *ls, TString *label, int line) { · 631 unmodified lines
1193}1185}
1194 1186
1195 1187
1196/* check for repeated labels on the same function */1188/* check for repeated labels on the same block */
1197static void checkrepeated (LexState *ls, FuncState *fs, Labellist *ll,1189static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) {
1198 TString *label) {
1199 int i;1190 int i;
1200 for (i = fs->firstlabel; i < ll->n; i++) {1191 for (i = fs->bl->firstlabel; i < ll->n; i++) {
1201 if (eqstr(label, ll->arr[i].name)) {1192 if (eqstr(label, ll->arr[i].name)) {
1202 const char *msg = luaO_pushfstring(ls->L, 1193 const char *msg = luaO_pushfstring(fs->ls->L,
1203 "label " LUA_QS " already defined on line %d",1194 "label " LUA_QS " already defined on line %d",
1204 getstr(label), ll->arr[i].line);1195 getstr(label), ll->arr[i].line);
1205 semerror(ls, msg);1196 semerror(fs->ls, msg);
1206 }1197 }
1207 }1198 }
1208}1199}
@@ -1213,7 +1204,7 @@ static void labelstat (LexState *ls, TString *label, int line) { · 4 unmodified lines
1213 FuncState *fs = ls->fs;1204 FuncState *fs = ls->fs;
1214 Labellist *ll = &ls->dyd->label;1205 Labellist *ll = &ls->dyd->label;
1215 int l; /* index of new label being created */1206 int l; /* index of new label being created */
1216 checkrepeated(ls, fs, ll, label); /* check for repeated labels */1207 checkrepeated(fs, ll, label); /* check for repeated labels */
1217 checknext(ls, TK_DBCOLON); /* skip double colon */1208 checknext(ls, TK_DBCOLON); /* skip double colon */
1218 /* create new entry for this label */1209 /* create new entry for this label */
1219 l = newlabelentry(ls, ll, label, line, fs->pc);1210 l = newlabelentry(ls, ll, label, line, fs->pc);
@@ -1607,5 +1598,7 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, · 387 unmodified lines
1607 L->top--; /* pop name */1598 L->top--; /* pop name */
1608 lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs);1599 lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs);
1609 return funcstate.f;1600 return funcstate.f;
1601 /* all scopes should be correctly finished */
1602 lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0);
1610}1603}
1611 1604
src/lparser.h+2−3
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lparser.h,v 1.69 2011/06/16 16:36:39 roberto Exp $2** $Id: lparser.h,v 1.68 2011/02/23 13:13:10 roberto Exp $
3** Lua Parser3** Lua Parser
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -62,7 +62,7 @@ typedef struct Vardesc { · 56 unmodified lines
62/* description of pending goto statements and label statements */62/* description of pending goto statements and label statements */
63typedef struct Labeldesc {63typedef struct Labeldesc {
64 TString *name; /* label identifier */64 TString *name; /* label identifier */
65 int pc; /* position in code (for labels, -1 means out of scope) */65 int pc; /* position in code */
66 int line; /* line where it appeared */66 int line; /* line where it appeared */
67 lu_byte nactvar; /* local level where it appears in current block */67 lu_byte nactvar; /* local level where it appears in current block */
68} Labeldesc;68} Labeldesc;
@@ -107,7 +107,6 @@ typedef struct FuncState { · 38 unmodified lines
107 int nk; /* number of elements in `k' */107 int nk; /* number of elements in `k' */
108 int np; /* number of elements in `p' */108 int np; /* number of elements in `p' */
109 int firstlocal; /* index of first local var of this function */109 int firstlocal; /* index of first local var of this function */
110 int firstlabel; /* index of first label of this function */
111 short nlocvars; /* number of elements in `locvars' */110 short nlocvars; /* number of elements in `locvars' */
112 lu_byte nactvar; /* number of active local variables */111 lu_byte nactvar; /* number of active local variables */
113 lu_byte nups; /* number of upvalues */112 lu_byte nups; /* number of upvalues */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t