Roberto Ierusalimschy
7f6f70853c
To-be-closed variable in 'for' loop separated from the state
...
The variable to be closed in a generic 'for' loop now is the
4th value produced in the loop initialization, instead of being
the loop state (the 2nd value produced). That allows a loop to
use a state with a '__toclose' metamethod but do not close it.
(As an example, 'f:lines()' might use the file 'f' as a state
for the loop, but it should not close the file when the loop ends.)
2018-11-07 14:42:05 -02:00
Roberto Ierusalimschy
2fc6b55dae
Removed resource-related "emergency collections"
...
New to-be-closed variables is a better way to ensure the proper release
of resources.
2018-10-31 16:25:29 -03:00
Roberto Ierusalimschy
947a372f58
State in generic 'for' acts as a to-be-closed variable
...
The implicit variable 'state' in a generic 'for' is marked as a
to-be-closed variable, so that the state will be closed as soon
as the loop ends, no matter how.
Taking advantage of this new facility, the call 'io.lines(filename)'
now returns the open file as a second result. Therefore,
an iteraction like 'for l in io.lines(name)...' will close the
file even when the loop ends with a break or an error.
2018-10-31 14:54:45 -03:00
Roberto Ierusalimschy
0a9aca56ca
Added a '__close' metamethod to file handles
2018-10-23 13:57:25 -03:00
Roberto Ierusalimschy
3d838f635c
Added "emergency collection" to 'io.tmpfile' and 'os.tmpname'
...
These operations also can give errors for lack of resources, so they
also will try "emergency collections" in case of resource errors.
Because there are now two libraries with that kind of handling,
'resourcetryagain' was moved to the auxiliary library to be shared
by the libraries.
2018-07-27 15:50:53 -03:00
Roberto Ierusalimschy
e885dee5ab
File operations try an "emergency collection" when failing
...
If a file operation fails do to lack of resources (too many open
files or not enough memory), it does a full garbage collection and
tries the operation again. Lack of resources are "too many open
files" (process wise and system wise) and "not enough memory".
The code is full of '#if's because error codes are not part
of the standard ISO C.
2018-07-25 11:44:46 -03:00
Roberto Ierusalimschy
00008b8ed0
back to one format per argument
2018-03-02 15:25:00 -03:00
Roberto Ierusalimschy
c67603fafb
using new 'lua_newuserdatauv' instead of 'lua_newuserdata'
2018-02-21 10:48:44 -03:00
Roberto Ierusalimschy
c47111bd4e
'io.read' accepts multiple formats in a single string argument
2017-11-16 14:28:36 -02:00
Roberto Ierusalimschy
e4e5aa85a2
detail ('signal' -> 'sign' in comments)
2017-11-16 11:19:06 -02:00
Roberto Ierusalimschy
d266d40dea
error when calling close method without arguments (e.g.,
...
|io.stdin.close()|)
2017-02-09 12:50:05 -02:00
Roberto Ierusalimschy
9903dd52a3
Using LUAI_UAC* types more consistently on vararg calls
2016-12-20 16:37:00 -02:00
Roberto Ierusalimschy
3b91b07fd9
detail (macro 'l_checkmode' reimplemented as function)
2016-09-01 13:14:56 -03:00
Roberto Ierusalimschy
f3b52a6061
'io.read("n")' accepts both a dot and the locale point as its
...
radix character + 'MAXRN' -> 'L_MAXLENNUM' + small detail in
'test2'
2016-05-02 11:03:19 -03:00
Roberto Ierusalimschy
71344b5cac
easy the way to accept other modifiers for 'mode' in 'io.open'
2015-11-23 09:36:11 -02:00
Roberto Ierusalimschy
050e8536bb
bug: 'io.lines' does not check maximum number of options
2015-07-15 11:40:28 -03:00
Roberto Ierusalimschy
5b6ac971f9
detail (comment)
2015-07-07 14:03:34 -03:00
Roberto Ierusalimschy
43cff79bf7
detail
2015-06-21 10:50:29 -03:00
Roberto Ierusalimschy
48d0674c2e
more consistent use of locale radix character across Lua
2015-04-03 15:41:57 -03:00
Roberto Ierusalimschy
d7d44b038d
detail (use 'lua_pushliteral' to push an empty string)
2015-03-06 16:09:08 -03:00
Roberto Ierusalimschy
234fb7f695
clearer(?) code (also avoids a warning about 'c' being used
...
without initialization)
2015-01-02 10:50:28 -02:00
Roberto Ierusalimschy
1735c05ac7
avoid memory errors while a file is locked (when reading a line)
2014-11-21 10:17:33 -02:00
Roberto Ierusalimschy
e75c0148c3
comments (references to "ANSI C" changed to "ISO C", which is the
...
international name
2014-11-02 17:33:33 -02:00
Roberto Ierusalimschy
28fdbcf393
added include for 'lprefix.h', for stuff that must be added before
...
any other header file
2014-11-02 17:19:04 -02:00
Roberto Ierusalimschy
1a69a3ecea
LUA_WIN -> LUA_USE_WINDOWS
2014-10-31 13:54:06 -02:00
Roberto Ierusalimschy
bdf566a8a3
`name' in comments changed to 'name'
2014-10-25 09:50:46 -02:00
Roberto Ierusalimschy
88ff582fd8
detail (using 'sizeof' instead of 'strlen' for length of a constant
...
string)
2014-10-22 14:55:57 -02:00
Roberto Ierusalimschy
6b12b82532
added 'l_' prefix for names that can be redefined externally
2014-10-22 09:44:20 -02:00
Roberto Ierusalimschy
0d31efb365
'lua_stringtonum' -> 'lua_stringtonumber'
2014-10-17 16:17:55 -03:00
Roberto Ierusalimschy
f97c64d7bf
macros 'LUA_QL'/'LUA_QL' deprecated
2014-10-17 13:28:21 -03:00
Roberto Ierusalimschy
89602bf747
'lua_strtonum' -> 'lua_stringtonum'
2014-10-15 11:27:40 -03:00
Roberto Ierusalimschy
2f4d429071
details (comments)
2014-10-03 09:54:57 -03:00
Roberto Ierusalimschy
27f7bd2e83
detail
2014-10-01 13:05:06 -03:00
Roberto Ierusalimschy
56699cd603
small change to avoid bug in some versions of the clang compiler
2014-09-26 11:09:21 -03:00
Roberto Ierusalimschy
3ccbae84d2
added some casts between integral types (to avoid warnings)
2014-07-29 13:01:00 -03:00
Roberto Ierusalimschy
b9dcf9974d
detail (typos in comments)
2014-06-30 16:48:08 -03:00
Roberto Ierusalimschy
e9d86eddf3
if numeral overflows the reading buffer, signal it as invalid input
...
(resulting in nil)
2014-06-02 00:00:51 -03:00
Roberto Ierusalimschy
e966e53791
no more use of 'scanf' for reading numbers
2014-05-21 12:24:21 -03:00
Roberto Ierusalimschy
1ddb251d86
using a more conventional handling of stack space in 'io_readline'
2014-05-15 12:21:06 -03:00
Roberto Ierusalimschy
5a5a834975
new API function 'lua_rotate'
2014-05-13 16:40:28 -03:00
Roberto Ierusalimschy
626124d2d8
old POSIX systems need '<sys/types.h>' for 'off_t'
2014-05-11 11:46:19 -03:00
Roberto Ierusalimschy
2f02d264e9
initial '*' in 'io.read' formats is deprecated
2014-04-15 13:46:45 -03:00
Roberto Ierusalimschy
16f8e44924
with 64-bit integers, file offsets do not need to be floats
2014-03-19 15:57:42 -03:00
Roberto Ierusalimschy
a39489194e
changing prefix of configurable macros from "lua_" to "l_"
2014-03-13 17:07:18 -03:00
Roberto Ierusalimschy
c5bb3643ab
simpler code to read a line from a file (using 'getc' or, if present,
...
'getc_unlocked')
2014-03-06 14:12:02 -03:00
Roberto Ierusalimschy
c6c41e85b2
more uniformity for defining system-dependent features
2014-02-26 12:27:56 -03:00
Roberto Ierusalimschy
5715de344f
'read_all' does not need to grow buffer, as 'luaL_prepbuffsize'
...
already does that
2014-02-21 11:39:50 -03:00
Roberto Ierusalimschy
67c5de9283
comment
2014-01-27 11:28:45 -02:00
Roberto Ierusalimschy
48adb6984c
'io.write' writes integers directly (and correctly)
2013-06-07 16:01:35 -03:00
Roberto Ierusalimschy
27f09415e3
new read format "*i" for reading integers
2013-05-14 12:57:43 -03:00