History

Lua 5.2.0-alpha-rc3

Lua Team committed 15 years ago

Commit e22e2031 parent df8e5b67 files · +132 −134Browse files

Unified · Split

7 files
  1. doc/contents.html +11 −11
  2. doc/manual.html +97 −93
  3. doc/readme.html +3 −3
  4. src/lbitlib.c +13 −13
  5. src/llex.c +2 −2
  6. src/lmathlib.c +5 −4
  7. src/lstrlib.c +1 −8
doc/contents.html+11−11
@@ -172,16 +172,16 @@ Freely available under the terms of the · 171 unmodified lines
172<A HREF="manual.html#pdf-xpcall">xpcall</A><BR>172<A HREF="manual.html#pdf-xpcall">xpcall</A><BR>
173 173
174<P>174<P>
175<A HREF="manual.html#pdf-bit32.AND">bit32.AND</A><BR>175<A HREF="manual.html#pdf-bit32.arshift">bit32.arshift</A><BR>
176<A HREF="manual.html#pdf-bit32.NOT">bit32.NOT</A><BR>176<A HREF="manual.html#pdf-bit32.band">bit32.band</A><BR>
177<A HREF="manual.html#pdf-bit32.OR">bit32.OR</A><BR>177<A HREF="manual.html#pdf-bit32.bnot">bit32.bnot</A><BR>
178<A HREF="manual.html#pdf-bit32.ROL">bit32.ROL</A><BR>178<A HREF="manual.html#pdf-bit32.bor">bit32.bor</A><BR>
179<A HREF="manual.html#pdf-bit32.ROR">bit32.ROR</A><BR>179<A HREF="manual.html#pdf-bit32.btest">bit32.btest</A><BR>
180<A HREF="manual.html#pdf-bit32.SAR">bit32.SAR</A><BR>180<A HREF="manual.html#pdf-bit32.bxor">bit32.bxor</A><BR>
181<A HREF="manual.html#pdf-bit32.SHL">bit32.SHL</A><BR>181<A HREF="manual.html#pdf-bit32.lrotate">bit32.lrotate</A><BR>
182<A HREF="manual.html#pdf-bit32.SHR">bit32.SHR</A><BR>182<A HREF="manual.html#pdf-bit32.lshift">bit32.lshift</A><BR>
183<A HREF="manual.html#pdf-bit32.TEST">bit32.TEST</A><BR>183<A HREF="manual.html#pdf-bit32.rrotate">bit32.rrotate</A><BR>
184<A HREF="manual.html#pdf-bit32.XOR">bit32.XOR</A><BR>184<A HREF="manual.html#pdf-bit32.rshift">bit32.rshift</A><BR>
185 185
186<P>186<P>
187<A HREF="manual.html#pdf-coroutine.create">coroutine.create</A><BR>187<A HREF="manual.html#pdf-coroutine.create">coroutine.create</A><BR>
@@ -516,7 +516,7 @@ Freely available under the terms of the · 328 unmodified lines
516<HR>516<HR>
517<SMALL>517<SMALL>
518Last update:518Last update:
519Wed Nov 17 14:51:24 BRST 2010519Mon Nov 22 16:38:54 BRST 2010
520</SMALL>520</SMALL>
521<!--521<!--
522Last change: revised for Lua 5.2.0 (alpha)522Last change: revised for Lua 5.2.0 (alpha)
doc/manual.html+97−93
@@ -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.63 2010/11/17 15:35:05 roberto Exp $ -->41<!-- $Id: manual.of,v 1.66 2010/11/22 18:07:40 roberto Exp $ -->
42 42
43 43
44 44
@@ -53,22 +53,23 @@ It also offers good support for object-oriented programming, · 8 unmodified lines
53functional programming, and data-driven programming.53functional programming, and data-driven programming.
54Lua is intended to be used as a powerful, light-weight54Lua is intended to be used as a powerful, light-weight
55scripting language for any program that needs one.55scripting language for any program that needs one.
56Lua is implemented as a library, written in <em>clean</em> C56Lua is implemented as a library, written in <em>clean</em> C,
57(that is, in the common subset of ANSI&nbsp;C and C++).57the common subset of ANSI&nbsp;C and C++.
58 58
59 59
60<p>60<p>
61Being an extension language, Lua has no notion of a "main" program:61Being an extension language, Lua has no notion of a "main" program:
62it only works <em>embedded</em> in a host client,62it only works <em>embedded</em> in a host client,
63called the <em>embedding program</em> or simply the <em>host</em>.63called the <em>embedding program</em> or simply the <em>host</em>.
64This host program can invoke functions to execute a piece of Lua code,64The host program can invoke functions to execute a piece of Lua code,
65can write and read Lua variables,65can write and read Lua variables,
66and can register C&nbsp;functions to be called by Lua code.66and can register C&nbsp;functions to be called by Lua code.
67Through the use of C&nbsp;functions, Lua can be augmented to cope with67Through the use of C&nbsp;functions, Lua can be augmented to cope with
68a wide range of different domains,68a wide range of different domains,
69thus creating customized programming languages sharing a syntactical framework.69thus creating customized programming languages sharing a syntactical framework.
70The Lua distribution includes a sample host program called <code>lua</code>,70The Lua distribution includes a sample host program called <code>lua</code>,
71which uses the Lua library to offer a complete, standalone Lua interpreter.71which uses the Lua library to offer a complete, standalone Lua interpreter,
72for interactive or batch use.
72 73
73 74
74<p>75<p>
@@ -85,7 +86,7 @@ this document is dry in places. · 10 unmodified lines
85For a discussion of the decisions behind the design of Lua,86For a discussion of the decisions behind the design of Lua,
86see the technical papers available at Lua's web site.87see the technical papers available at Lua's web site.
87For a detailed introduction to programming in Lua,88For a detailed introduction to programming in Lua,
88see Roberto's book, <em>Programming in Lua (Second Edition)</em>.89see Roberto's book, <em>Programming in Lua</em> (second edition).
89 90
90 91
91 92
@@ -126,7 +127,7 @@ any other value makes it true. · 34 unmodified lines
126<em>Number</em> represents real (double-precision floating-point) numbers.127<em>Number</em> represents real (double-precision floating-point) numbers.
127(It is easy to build Lua interpreters that use other128(It is easy to build Lua interpreters that use other
128internal representations for numbers,129internal representations for numbers,
129such as single-precision float or long integers;130such as single-precision floats or long integers;
130see file <code>luaconf.h</code>.)131see file <code>luaconf.h</code>.)
131<em>String</em> represents arrays of characters.132<em>String</em> represents arrays of characters.
132 133
@@ -211,7 +212,7 @@ of a given value. · 78 unmodified lines
211As discussed in <a href="#3.2">&sect;3.2</a> and <a href="#3.3.3">&sect;3.3.3</a>,212As discussed in <a href="#3.2">&sect;3.2</a> and <a href="#3.3.3">&sect;3.3.3</a>,
212any reference to a global name <code>var</code> is syntactically translated 213any reference to a global name <code>var</code> is syntactically translated
213to <code>_ENV.var</code>.214to <code>_ENV.var</code>.
214Moreover, any chunk is compiled in the scope of an external215Moreover, every chunk is compiled in the scope of an external
215variable called <code>_ENV</code> (see <a href="#3.3.2">&sect;3.3.2</a>),216variable called <code>_ENV</code> (see <a href="#3.3.2">&sect;3.3.2</a>),
216so <code>_ENV</code> itself is never a global name in a chunk.217so <code>_ENV</code> itself is never a global name in a chunk.
217 218
@@ -256,7 +257,7 @@ If you change the global environment in the registry · 38 unmodified lines
256(through C code or the debug library),257(through C code or the debug library),
257all chunks loaded after the change will get the new environment.258all chunks loaded after the change will get the new environment.
258Previously loaded chunks are not affected, however,259Previously loaded chunks are not affected, however,
259as each has its own copy of the environment in its <code>_ENV</code> variable.260as each has its own reference to the environment in its <code>_ENV</code> variable.
260Moreover, the variable <a href="#pdf-_G"><code>_G</code></a>261Moreover, the variable <a href="#pdf-_G"><code>_G</code></a>
261(which is stored in the original global environment)262(which is stored in the original global environment)
262is never updated by Lua.263is never updated by Lua.
@@ -271,8 +272,9 @@ is never updated by Lua. · 8 unmodified lines
271Because Lua is an embedded extension language,272Because Lua is an embedded extension language,
272all Lua actions start from C&nbsp;code in the host program273all Lua actions start from C&nbsp;code in the host program
273calling a function from the Lua library (see <a href="#lua_pcall"><code>lua_pcall</code></a>).274calling a function from the Lua library (see <a href="#lua_pcall"><code>lua_pcall</code></a>).
274Whenever an error occurs during Lua compilation or execution,275Whenever an error occurs during
275control returns to C,276the compilation or execution of a Lua chunk,
277control returns to the host,
276which can take appropriate measures278which can take appropriate measures
277(such as printing an error message).279(such as printing an error message).
278 280
@@ -281,7 +283,7 @@ which can take appropriate measures · 2 unmodified lines
281Lua code can explicitly generate an error by calling the283Lua code can explicitly generate an error by calling the
282<a href="#pdf-error"><code>error</code></a> function.284<a href="#pdf-error"><code>error</code></a> function.
283If you need to catch errors in Lua,285If you need to catch errors in Lua,
284you can use the <a href="#pdf-pcall"><code>pcall</code></a> function.286you can use the <a href="#pdf-pcall"><code>pcall</code></a> or the <a href="#pdf-xpcall"><code>xpcall</code></a> function.
285 287
286 288
287 289
@@ -297,27 +299,26 @@ under certain special operations. · 9 unmodified lines
297You can change several aspects of the behavior299You can change several aspects of the behavior
298of operations over a value by setting specific fields in its metatable.300of operations over a value by setting specific fields in its metatable.
299For instance, when a non-numeric value is the operand of an addition,301For instance, when a non-numeric value is the operand of an addition,
300Lua checks for a function in the field "<code>__add</code>" in its metatable.302Lua checks for a function in the field "<code>__add</code>" of the value's metatable.
301If it finds one,303If it finds one,
302Lua calls this function to perform the addition.304Lua calls this function to perform the addition.
303 305
304 306
305<p>307<p>
306We call the keys in a metatable <em>events</em>308The keys in a metatable are derived from the <em>event</em> names;
307and the values <em>metamethods</em>.309the corresponding values are called <em>metamethods</em>.
308In the previous example, the event is <code>"__add"</code> 310In the previous example, the event is <code>"add"</code>
309and the metamethod is the function that performs the addition.311and the metamethod is the function that performs the addition.
310 312
311 313
312<p>314<p>
313You can query the metatable of any value315You can query the metatable of any value
314through the <a href="#pdf-getmetatable"><code>getmetatable</code></a> function.316using the <a href="#pdf-getmetatable"><code>getmetatable</code></a> function.
315 317
316 318
317<p>319<p>
318You can replace the metatable of tables320You can replace the metatable of tables
319through the <a href="#pdf-setmetatable"><code>setmetatable</code></a>321using the <a href="#pdf-setmetatable"><code>setmetatable</code></a> function.
320function.
321You cannot change the metatable of other types from Lua322You cannot change the metatable of other types from Lua
322(except by using the debug library);323(except by using the debug library);
323you must use the C&nbsp;API for that.324you must use the C&nbsp;API for that.
@@ -338,8 +339,6 @@ A metatable controls how an object behaves in arithmetic operations, · 14 unmodified lines
338order comparisons, concatenation, length operation, and indexing.339order comparisons, concatenation, length operation, and indexing.
339A metatable also can define a function to be called when a userdata340A metatable also can define a function to be called when a userdata
340is garbage collected.341is garbage collected.
341For each of these operations Lua associates a specific key
342called an <em>event</em>.
343When Lua performs one of these operations over a value,342When Lua performs one of these operations over a value,
344it checks whether this value has a metatable with the corresponding event.343it checks whether this value has a metatable with the corresponding event.
345If so, the value associated with that key (the metamethod)344If so, the value associated with that key (the metamethod)
@@ -353,11 +352,11 @@ The key for each operation is a string with its name prefixed by · 7 unmodified lines
353two underscores, '<code>__</code>';352two underscores, '<code>__</code>';
354for instance, the key for operation "add" is the353for instance, the key for operation "add" is the
355string "<code>__add</code>".354string "<code>__add</code>".
356The semantics of these operations is better explained by a Lua function
357describing how the interpreter executes the operation.
358 355
359 356
360<p>357<p>
358The semantics of these operations is better explained by a Lua function
359describing how the interpreter executes the operation.
361The code shown here in Lua is only illustrative;360The code shown here in Lua is only illustrative;
362the real behavior is hard coded in the interpreter361the real behavior is hard coded in the interpreter
363and it is much more efficient than this simulation.362and it is much more efficient than this simulation.
@@ -719,7 +718,7 @@ It uses two numbers to control its garbage-collection cycles: · 355 unmodified lines
719the <em>garbage-collector pause</em> and718the <em>garbage-collector pause</em> and
720the <em>garbage-collector step multiplier</em>.719the <em>garbage-collector step multiplier</em>.
721Both use percentage points as units720Both use percentage points as units
722(so that a value of 100 means an internal value of 1).721(e.g., a value of 100 means an internal value of 1).
723 722
724 723
725<p>724<p>
@@ -733,14 +732,15 @@ to double before starting a new cycle. · 7 unmodified lines
733 732
734 733
735<p>734<p>
736The step multiplier735The garbage-collector step multiplier
737controls the relative speed of the collector relative to736controls the relative speed of the collector relative to
738memory allocation.737memory allocation.
739Larger values make the collector more aggressive but also increase738Larger values make the collector more aggressive but also increase
740the size of each incremental step.739the size of each incremental step.
741Values smaller than 100 make the collector too slow and740Values smaller than 100 make the collector too slow and
742can result in the collector never finishing a cycle.741can result in the collector never finishing a cycle.
743The default, 200, means that the collector runs at "twice"742The default is 200,
743which means that the collector runs at "twice"
744the speed of memory allocation.744the speed of memory allocation.
745 745
746 746
@@ -767,7 +767,7 @@ the collector directly (e.g., stop and restart it). · 20 unmodified lines
767 767
768<p>768<p>
769Using the C&nbsp;API,769Using the C&nbsp;API,
770you can set garbage-collector metamethods for userdata (see <a href="#2.4">&sect;2.4</a>).770you can set garbage-collector metamethods for full userdata (see <a href="#2.4">&sect;2.4</a>).
771These metamethods are also called <em>finalizers</em>.771These metamethods are also called <em>finalizers</em>.
772Finalizers allow you to coordinate Lua's garbage collection772Finalizers allow you to coordinate Lua's garbage collection
773with external resource management773with external resource management
@@ -777,12 +777,12 @@ or freeing your own memory). · 3 unmodified lines
777 777
778<p>778<p>
779For a userdata to be finalized when collected,779For a userdata to be finalized when collected,
780you must <em>mark</em> it first.780you must <em>mark</em> it for finalization.
781 781
782You mark a userdata for finalization when you set its metatable782You mark a userdata for finalization when you set its metatable
783and the metatable has a field indexed by the string "<code>__gc</code>".783and the metatable has a field indexed by the string "<code>__gc</code>".
784Note that if you set a metatable without a <code>__gc</code> field784Note that if you set a metatable without a <code>__gc</code> field
785and later create that field,785and later create that field in the metatable,
786the userdata will not be marked for finalization.786the userdata will not be marked for finalization.
787However, after a userdata is marked,787However, after a userdata is marked,
788you can freely change the <code>__gc</code> field of its metatable.788you can freely change the <code>__gc</code> field of its metatable.
@@ -826,7 +826,7 @@ A <em>weak table</em> is a table whose elements are · 37 unmodified lines
826A weak reference is ignored by the garbage collector.826A weak reference is ignored by the garbage collector.
827In other words,827In other words,
828if the only references to an object are weak references,828if the only references to an object are weak references,
829then the garbage collector will collect this object.829then the garbage collector will collect that object.
830 830
831 831
832<p>832<p>
@@ -873,11 +873,11 @@ Lua treats strings and light C functions as non-object values. · 40 unmodified lines
873 873
874 874
875<p>875<p>
876Userdata marked for finalization has a special behavior in weak tables.876Userdata marked for finalization have a special behavior in weak tables.
877When a marked userdata is a value in a weak table,877When a marked userdata is a value in a weak table,
878it is removed from the table the first time it is collected,878it is removed from the table the first time it is collected,
879before running its finalizer.879before running its finalizer.
880When it is a key, however,880However, when it is a key,
881it is removed from the table only when it is really freed,881it is removed from the table only when it is really freed,
882after running its finalizer.882after running its finalizer.
883This behavior allows the finalizer to access values883This behavior allows the finalizer to access values
@@ -901,15 +901,16 @@ a yield function. · 17 unmodified lines
901 901
902 902
903<p>903<p>
904You create a coroutine with a call to <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>.904You create a coroutine by calling <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>.
905Its sole argument is a function905Its sole argument is a function
906that is the main function of the coroutine.906that is the main function of the coroutine.
907The <code>create</code> function only creates a new coroutine and907The <code>create</code> function only creates a new coroutine and
908returns a handle to it (an object of type <em>thread</em>);908returns a handle to it (an object of type <em>thread</em>);
909it does not start the coroutine execution.909it does not start the coroutine.
910 910
911 911
912<p>912<p>
913You execute a coroutine by calling <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>.
913When you first call <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,914When you first call <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
914passing as its first argument915passing as its first argument
915a thread returned by <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,916a thread returned by <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
@@ -962,7 +963,7 @@ any error is propagated to the caller. · 46 unmodified lines
962 963
963 964
964<p>965<p>
965As an example,966As an example of how coroutines work,
966consider the following code:967consider the following code:
967 968
968<pre>969<pre>
@@ -3659,6 +3660,11 @@ the value at the given index; · 2690 unmodified lines
3659this confuses the next call to <a href="#lua_next"><code>lua_next</code></a>.3660this confuses the next call to <a href="#lua_next"><code>lua_next</code></a>.
3660 3661
3661 3662
3663<p>
3664See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
3665the table during its traversal.
3666
3667
3662 3668
3663 3669
3664 3670
@@ -6972,7 +6978,7 @@ and "<code>userdata</code>". · 3307 unmodified lines
6972<hr><h3><a name="pdf-_VERSION"><code>_VERSION</code></a></h3>6978<hr><h3><a name="pdf-_VERSION"><code>_VERSION</code></a></h3>
6973A global variable (not a function) that6979A global variable (not a function) that
6974holds a string containing the current interpreter version.6980holds a string containing the current interpreter version.
6975The current contents of this variable is "<code>Lua 5.1</code>".6981The current contents of this variable is "<code>Lua 5.2</code>".
6976 6982
6977 6983
6978 6984
@@ -7665,9 +7671,9 @@ Here are some examples: · 686 unmodified lines
7665 end)7671 end)
7666 --&gt; x="4+5 = 9"7672 --&gt; x="4+5 = 9"
7667 7673
7668 local t = {name="lua", version="5.1"}7674 local t = {name="lua", version="5.2"}
7669 x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)7675 x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
7670 --&gt; x="lua-5.1.tar.gz"7676 --&gt; x="lua-5.2.tar.gz"
7671</pre>7677</pre>
7672 7678
7673 7679
@@ -8385,8 +8391,6 @@ Returns the hyperbolic tangent of <code>x</code>. · 711 unmodified lines
8385<p>8391<p>
8386This library provides bitwise operations.8392This library provides bitwise operations.
8387It provides all its functions inside the table <a name="pdf-bit32"><code>bit32</code></a>.8393It provides all its functions inside the table <a name="pdf-bit32"><code>bit32</code></a>.
8388It uses upper case for function names to avoid collision with
8389some reserved words (<b>and</b>, <b>or</b>, and <b>not</b>).
8390 8394
8391 8395
8392<p>8396<p>
@@ -8398,12 +8402,34 @@ the remainder of its division by <em>2<sup>32</sup></em> · 5 unmodified lines
8398and truncated to an integer (in some unspecified way),8402and truncated to an integer (in some unspecified way),
8399so that its final value falls in the range <em>[0,2<sup>32</sup> - 1]</em>.8403so that its final value falls in the range <em>[0,2<sup>32</sup> - 1]</em>.
8400Similarly, all results are in the range <em>[0,2<sup>32</sup> - 1]</em>.8404Similarly, all results are in the range <em>[0,2<sup>32</sup> - 1]</em>.
8401Note that <code>bit32.NOT(0)</code> is <code>0xFFFFFFFF</code>,8405Note that <code>bit32.bnot(0)</code> is <code>0xFFFFFFFF</code>,
8402which is different from <code>-1</code>.8406which is different from <code>-1</code>.
8403 8407
8404 8408
8405<p>8409<p>
8406<hr><h3><a name="pdf-bit32.AND"><code>bit32.AND (&middot;&middot;&middot;)</code></a></h3>8410<hr><h3><a name="pdf-bit32.arshift"><code>bit32.arshift (x, disp)</code></a></h3>
8411
8412
8413<p>
8414Returns the number <code>x</code> shifted <code>disp</code> bits to the right.
8415The number <code>disp</code> may be any representable integer.
8416Negative displacements shift to the left.
8417
8418
8419<p>
8420This shift operation is what is called arithmetic shift.
8421Vacant bits on the left are filled
8422with copies of the higher bit of <code>x</code>;
8423vacant bits on the right are filled with zeros.
8424In particular,
8425displacements with absolute values higher than 31
8426result in zero or <code>0xFFFFFFFF</code> (all original bits are shifted out).
8427
8428
8429
8430
8431<p>
8432<hr><h3><a name="pdf-bit32.band"><code>bit32.band (&middot;&middot;&middot;)</code></a></h3>
8407 8433
8408 8434
8409<p>8435<p>
@@ -8413,7 +8439,7 @@ Returns the bitwise and of its operands. · 3 unmodified lines
8413 8439
8414 8440
8415<p>8441<p>
8416<hr><h3><a name="pdf-bit32.NOT"><code>bit32.NOT (x)</code></a></h3>8442<hr><h3><a name="pdf-bit32.bnot"><code>bit32.bnot (x)</code></a></h3>
8417 8443
8418 8444
8419<p>8445<p>
@@ -8422,13 +8448,13 @@ For any integer <code>x</code>, · 2 unmodified lines
8422the following identity holds:8448the following identity holds:
8423 8449
8424<pre>8450<pre>
8425 assert(bit32.NOT(x) == (-1 - x) % 2^32)8451 assert(bit32.bnot(x) == (-1 - x) % 2^32)
8426</pre>8452</pre>
8427 8453
8428 8454
8429 8455
8430<p>8456<p>
8431<hr><h3><a name="pdf-bit32.OR"><code>bit32.OR (&middot;&middot;&middot;)</code></a></h3>8457<hr><h3><a name="pdf-bit32.bor"><code>bit32.bor (&middot;&middot;&middot;)</code></a></h3>
8432 8458
8433 8459
8434<p>8460<p>
@@ -8438,7 +8464,7 @@ Returns the bitwise or of its operands. · 3 unmodified lines
8438 8464
8439 8465
8440<p>8466<p>
8441<hr><h3><a name="pdf-bit32.TEST"><code>bit32.TEST (&middot;&middot;&middot;)</code></a></h3>8467<hr><h3><a name="pdf-bit32.btest"><code>bit32.btest (&middot;&middot;&middot;)</code></a></h3>
8442 8468
8443 8469
8444<p>8470<p>
@@ -8449,7 +8475,7 @@ whether the bitwise and of its operands is different from zero. · 4 unmodified lines
8449 8475
8450 8476
8451<p>8477<p>
8452<hr><h3><a name="pdf-bit32.XOR"><code>bit32.XOR (&middot;&middot;&middot;)</code></a></h3>8478<hr><h3><a name="pdf-bit32.bxor"><code>bit32.bxor (&middot;&middot;&middot;)</code></a></h3>
8453 8479
8454 8480
8455<p>8481<p>
@@ -8459,7 +8485,7 @@ Returns the bitwise exclusive or of its operands. · 3 unmodified lines
8459 8485
8460 8486
8461<p>8487<p>
8462<hr><h3><a name="pdf-bit32.ROL"><code>bit32.ROL (x, disp)</code></a></h3>8488<hr><h3><a name="pdf-bit32.lrotate"><code>bit32.lrotate (x, disp)</code></a></h3>
8463 8489
8464 8490
8465<p>8491<p>
@@ -8472,7 +8498,7 @@ For any valid displacement, · 6 unmodified lines
8472the following identity holds:8498the following identity holds:
8473 8499
8474<pre>8500<pre>
8475 assert(bit32.ROL(x, disp) == bit32.ROL(x, disp % 32))8501 assert(bit32.lrotate(x, disp) == bit32.lrotate(x, disp % 32))
8476</pre><p>8502</pre><p>
8477In particular,8503In particular,
8478negative displacements rotate to the right.8504negative displacements rotate to the right.
@@ -8481,75 +8507,53 @@ negative displacements rotate to the right. · 2 unmodified lines
8481 8507
8482 8508
8483<p>8509<p>
8484<hr><h3><a name="pdf-bit32.ROR"><code>bit32.ROR (x, disp)</code></a></h3>8510<hr><h3><a name="pdf-bit32.lshift"><code>bit32.lshift (x, disp)</code></a></h3>
8485 8511
8486 8512
8487<p>8513<p>
8488Returns the number <code>x</code> rotated <code>disp</code> bits to the right.8514Returns the number <code>x</code> shifted <code>disp</code> bits to the left.
8489The number <code>disp</code> may be any representable integer.8515The number <code>disp</code> may be any representable integer.
8516Negative displacements shift to the right.
8517In any direction, vacant bits are filled with zeros.
8518In particular,
8519displacements with absolute values higher than 31
8520result in zero (all bits are shifted out).
8490 8521
8491 8522
8492<p>8523<p>
8493For any valid displacement,8524For positive displacements,
8494the following identity holds:8525the following equality holds:
8495 8526
8496<pre>8527<pre>
8497 assert(bit32.ROR(x, disp) == bit32.ROR(x, disp % 32))8528 assert(bit32.lshift(b, disp) == (b * 2^disp) % 2^32)
8498</pre><p>8529</pre>
8499In particular,
8500negative displacements rotate to the left.
8501
8502 8530
8503 8531
8504 8532
8505<p>8533<p>
8506<hr><h3><a name="pdf-bit32.SAR"><code>bit32.SAR (x, disp)</code></a></h3>8534<hr><h3><a name="pdf-bit32.rrotate"><code>bit32.rrotate (x, disp)</code></a></h3>
8507 8535
8508 8536
8509<p>8537<p>
8510Returns the number <code>x</code> shifted <code>disp</code> bits to the right.8538Returns the number <code>x</code> rotated <code>disp</code> bits to the right.
8511The number <code>disp</code> may be any representable integer.8539The number <code>disp</code> may be any representable integer.
8512Negative displacements shift to the left.
8513
8514
8515<p>
8516This shift operation is what is called arithmetic shift.
8517Vacant bits on the left are filled
8518with copies of the higher bit of <code>x</code>;
8519vacant bits on the right are filled with zeros.
8520In particular,
8521displacements with absolute values higher than 31
8522result in zero or <code>0xFFFFFFFF</code> (all bits are shifted out).
8523
8524
8525 8540
8526 8541
8527<p>8542<p>
8528<hr><h3><a name="pdf-bit32.SHL"><code>bit32.SHL (x, disp)</code></a></h3>8543For any valid displacement,
8529 8544the following identity holds:
8530 8545
8531<p>8546<pre>
8532Returns the number <code>x</code> shifted <code>disp</code> bits to the left.8547 assert(bit32.rrotate(x, disp) == bit32.rrotate(x, disp % 32))
8533The number <code>disp</code> may be any representable integer.8548</pre><p>
8534Negative displacements shift to the right.
8535In any direction, vacant bits are filled with zeros.
8536In particular,8549In particular,
8537displacements with absolute values higher than 318550negative displacements rotate to the left.
8538result in zero (all bits are shifted out).
8539
8540
8541<p>
8542For positive displacements,
8543the following equality holds:
8544 8551
8545<pre>
8546 assert(bit32.SHL(b, disp) == (b * 2^disp) % 2^32)
8547</pre>
8548 8552
8549 8553
8550 8554
8551<p>8555<p>
8552<hr><h3><a name="pdf-bit32.SHR"><code>bit32.SHR (x, disp)</code></a></h3>8556<hr><h3><a name="pdf-bit32.rshift"><code>bit32.rshift (x, disp)</code></a></h3>
8553 8557
8554 8558
8555<p>8559<p>
@@ -8567,7 +8571,7 @@ For positive displacements, · 11 unmodified lines
8567the following equality holds:8571the following equality holds:
8568 8572
8569<pre>8573<pre>
8570 assert(bit32.SHR(b, disp) == math.floor(b % 2^32 / 2^disp))8574 assert(bit32.rshift(b, disp) == math.floor(b % 2^32 / 2^disp))
8571</pre>8575</pre>
8572 8576
8573<p>8577<p>
@@ -9925,7 +9929,7 @@ Here is the complete syntax of Lua in extended BNF. · 1351 unmodified lines
9925<HR>9929<HR>
9926<SMALL>9930<SMALL>
9927Last update:9931Last update:
9928Wed Nov 17 14:49:08 BRST 20109932Mon Nov 22 16:36:19 BRST 2010
9929</SMALL>9933</SMALL>
9930<!--9934<!--
9931Last change: revised for Lua 5.2.0 (alpha)9935Last change: revised for Lua 5.2.0 (alpha)
doc/readme.html+3−3
@@ -81,7 +81,7 @@ distributed in this package. · 80 unmodified lines
81 81
82<P>82<P>
83Lua is distributed in83Lua is distributed in
84<A HREF="ftp/">source</A>84<A HREF="http://www.lua.org/ftp/">source</A>
85form.85form.
86You need to build it before using it.86You need to build it before using it.
87Building Lua should be straightforward87Building Lua should be straightforward
@@ -354,7 +354,7 @@ Here are the other changes introduced in Lua 5.2: · 266 unmodified lines
354Lua is free software distributed under the terms of the354Lua is free software distributed under the terms of the
355<A HREF="http://www.opensource.org/licenses/mit-license.html">MIT license</A>355<A HREF="http://www.opensource.org/licenses/mit-license.html">MIT license</A>
356reproduced below;356reproduced below;
357it can be used for any purpose, including commercial purposes,357it may be used for any purpose, including commercial purposes,
358at absolutely no cost without having to ask us.358at absolutely no cost without having to ask us.
359 359
360The only requirement is that if you do use Lua,360The only requirement is that if you do use Lua,
@@ -391,7 +391,7 @@ THE SOFTWARE. · 30 unmodified lines
391<HR>391<HR>
392<SMALL>392<SMALL>
393Last update:393Last update:
394Thu Nov 11 15:16:22 BRST 2010394Sat Nov 20 19:23:14 BRST 2010
395</SMALL>395</SMALL>
396<!--396<!--
397Last change: revised for Lua 5.2.0 (alpha)397Last change: revised for Lua 5.2.0 (alpha)
src/lbitlib.c+13−13
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lbitlib.c,v 1.11 2010/11/08 16:31:22 roberto Exp $2** $Id: lbitlib.c,v 1.13 2010/11/22 18:06:33 roberto Exp $
3** Standard library for bitwise operations3** Standard library for bitwise operations
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -130,27 +130,27 @@ static int b_rot (lua_State *L, int i) { · 124 unmodified lines
130}130}
131 131
132 132
133static int b_rol (lua_State *L) {133static int b_lrot (lua_State *L) {
134 return b_rot(L, luaL_checkint(L, 2));134 return b_rot(L, luaL_checkint(L, 2));
135}135}
136 136
137 137
138static int b_ror (lua_State *L) {138static int b_rrot (lua_State *L) {
139 return b_rot(L, -luaL_checkint(L, 2));139 return b_rot(L, -luaL_checkint(L, 2));
140}140}
141 141
142 142
143static const luaL_Reg bitlib[] = {143static const luaL_Reg bitlib[] = {
144 {"AND", b_and},144 {"arshift", b_arshift},
145 {"TEST", b_test},145 {"band", b_and},
146 {"OR", b_or},146 {"bnot", b_not},
147 {"XOR", b_xor},147 {"bor", b_or},
148 {"NOT", b_not},148 {"bxor", b_xor},
149 {"SHL", b_lshift},149 {"lrotate", b_lrot},
150 {"SAR", b_arshift},150 {"lshift", b_lshift},
151 {"SHR", b_rshift},151 {"rrotate", b_rrot},
152 {"ROL", b_rol},152 {"rshift", b_rshift},
153 {"ROR", b_ror},153 {"btest", b_test},
154 {NULL, NULL}154 {NULL, NULL}
155};155};
156 156
src/llex.c+2−2
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: llex.c,v 2.40 2010/10/25 12:24:36 roberto Exp $2** $Id: llex.c,v 2.41 2010/11/18 18:38:44 roberto Exp $
3** Lexical Analyzer3** Lexical Analyzer
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -471,10 +471,10 @@ static int llex (LexState *ls, SemInfo *seminfo) { · 465 unmodified lines
471 } while (lislalnum(ls->current));471 } while (lislalnum(ls->current));
472 ts = luaX_newstring(ls, luaZ_buffer(ls->buff),472 ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
473 luaZ_bufflen(ls->buff));473 luaZ_bufflen(ls->buff));
474 seminfo->ts = ts;
474 if (ts->tsv.reserved > 0) /* reserved word? */475 if (ts->tsv.reserved > 0) /* reserved word? */
475 return ts->tsv.reserved - 1 + FIRST_RESERVED;476 return ts->tsv.reserved - 1 + FIRST_RESERVED;
476 else {477 else {
477 seminfo->ts = ts;
478 return TK_NAME;478 return TK_NAME;
479 }479 }
480 }480 }
src/lmathlib.c+5−4
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lmathlib.c,v 1.78 2010/11/12 15:47:34 roberto Exp $2** $Id: lmathlib.c,v 1.79 2010/11/18 18:38:27 roberto Exp $
3** Standard mathematical library3** Standard mathematical library
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -136,11 +136,12 @@ static int math_log (lua_State *L) { · 130 unmodified lines
136 136
137static int math_log10 (lua_State *L) {137static int math_log10 (lua_State *L) {
138#if !defined(LUA_COMPAT_LOG10)138#if !defined(LUA_COMPAT_LOG10)
139 luaL_error(L, "function " LUA_QL("log10")139 return luaL_error(L, "function " LUA_QL("log10")
140 " is deprecated; use log(x, 10) instead");140 " is deprecated; use log(x, 10) instead");
141#endif141#else
142 lua_pushnumber(L, l_tg(log10)(luaL_checknumber(L, 1)));142 lua_pushnumber(L, l_tg(log10)(luaL_checknumber(L, 1)));
143 return 1;143 return 1;
144#endif
144}145}
145 146
146static int math_exp (lua_State *L) {147static int math_exp (lua_State *L) {
src/lstrlib.c+1−8
@@ -1,5 +1,5 @@
1/*1/*
2** $Id: lstrlib.c,v 1.158 2010/11/16 20:39:41 roberto Exp $2** $Id: lstrlib.c,v 1.159 2010/11/19 16:25:51 roberto Exp $
3** Standard library for string operations and pattern-matching3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -614,12 +614,6 @@ static int gmatch (lua_State *L) { · 608 unmodified lines
614}614}
615 615
616 616
617static int gfind_nodef (lua_State *L) {
618 return luaL_error(L, LUA_QL("string.gfind") " was renamed to "
619 LUA_QL("string.gmatch"));
620}
621
622
623static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,617static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
624 const char *e) {618 const char *e) {
625 size_t l, i;619 size_t l, i;
@@ -912,7 +906,6 @@ static const luaL_Reg strlib[] = { · 286 unmodified lines
912 {"dump", str_dump},906 {"dump", str_dump},
913 {"find", str_find},907 {"find", str_find},
914 {"format", str_format},908 {"format", str_format},
915 {"gfind", gfind_nodef},
916 {"gmatch", gmatch},909 {"gmatch", gmatch},
917 {"gsub", str_gsub},910 {"gsub", str_gsub},
918 {"len", str_len},911 {"len", str_len},