summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/liolib.c (follow)
Commit message (Collapse)AuthorAge
* lua update to 5.1.5William Wilgus2018-11-11
| | | | | | | | Modify Rocklua towards upstream 5.1.5 Clean up some of the Rocklua implementation Change-Id: Iac722e827899cf84f5ca004ef7ae7ddce5f7fbbe
* Lua fix failure to read lines longer than LUAL_BUFFERSIZEWilliam Wilgus2018-11-02
| | | | | | | Readline didn't handle lines longer than LUAL_BUFFERSIZE it now reads these in chunks. Change-Id: Iffe12447e5441ff6b479ce3de1d36df64c276183
* Lua replace fscanfWilliam Wilgus2018-10-29
| | | | | | | | | | | | | | | | | | | | | | Rocklua was using the full fscanf implementation to simply read %ld for the file:read("*n") function wasting 1k on unneeded/unused functionality Instead, I've implemented a filetol function to duplicate it without the extra overhead using strtol which as an added bonus ERANGE errors now resolve to LONG_MIN and LONGMAX instead of integer overflow filetol() reads long int from an open file, skips preceding whitespaces returns -1 if error, 1 on success. *num set to LONG_MAX or LONG_MIN on overflow. If number of digits is > than LUAI_MAXNUMBER2STR filepointer will continue till the next non digit but buffer will stop being filled with characters. Preceding zero is ignored. Change-Id: Ia42d0f73c63a894625bca4581e9b7e1cc7387fd2
* Lua liolibWilliam Wilgus2018-05-28
| | | | | | Add Whitespace to EOF Change-Id: Iac253e7905c59518040d39bb5033e35f0deea948
* Fix lua lseek command / io libWilliam Wilgus2018-05-27
| | | | | | | | | | | | | | | | | | | | | | lua would not return or set arbitrary file positions file:seek("set", 0) worked file:seek("cur") worked but setting an offset or file:seek("end") failed I tracked this down to a bug checking the return of rb->lseek on error lseek returns a negative number and returns the file position otherwise, the function was checking for if(N) instead of if(N < 0) Fixed - limited size of lseek to size of signed LuaNumber Fixed - io:lines() stopped after first line containing only a newline instead of returning a blank line and continuing till EOF this fixes file:read("*l") as well Fixed - ssize_t for read() with error checking Change-Id: Ie859b288fb8f6814f1b3ae30992ecf78f2669de7
* Revert "Update lua plugin to 5.2.3"Marcin Bukat2014-04-02
| | | | | | FILE typedef to *void needs more work to not break sim and application builds. I checked only a few random native builds unfortunately. Sorry for inconvenience.
* Update lua plugin to 5.2.3Richard Quirk2014-04-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this patch the Lua plugin used version 5.1.4. This change reduces the number of modifications in the Lua source using some new defines and because the upstream source is now more flexible. Unless otherwise stated, l*.[ch] files are taken unmodified from the upstream lua-5.2.3. fscanf.c: file descriptors in rockbox are just ints, they are hidden behind a void* now so liolib requires less modifications. fscanf is updated to use void* too. getc.c: this is a new file required for getc implementation in lauxlib.c lauxlib.c: LoadF replaced FILE* with int, the rockbox file descriptor int are cast to FILE* (actually void* due to typedef). getc uses the PREFIX version. stdin is not used, as per 5.1.4. lbaselib.c: now uses strspn in the number parsing. print uses DEBUGF now rather than being commented out. lbitlib.c: use the built-in version from 5.2.3 rather than Reuben Thomas's external library. Backwards compatible and adds some new bit operations. ldo.c: the LUAI_THROW/TRY defines are now in the core lua code, so have been removed from rockconf.h liolib.c: here the implementation has changed to use the LStream from the original source, and cast the FILE* pointers to int. This has reduced the number of modifications from the upstream version. llex.c: the only change from upstream is to remove the locale include. lmathlib.c: updated from the 5.2.3 version and re-applied the changes that were made vs 5.1.4 for random numbers and to remove unsupported float functions. loadlib.c: upstream version, with the 5.1.4 changes for missing functions. lobject.c: upstream version, with ctype.h added and sprintf changed to snprintf. loslib.c: upstream version with locale.h removed and 5.1.4 changes for unsupportable functions. lstrlib.c: sprintf changed to snprintf. ltable.c: upstream with the hashnum function from 5.1.4 to avoid frexp in luai_hashnum. luaconf.h: updated to 5.2.3 version, restored relevant parts from the original 5.1.4 configuration. The COMPAT defines that are no longer available are not included. lundump.c: VERSION macro conflicts with the core Rockbox equivalent. rocklib.c: luaL_reg is no longer available, replaced by luaL_Reg equivalent. Moved checkboolean/optboolean functions to this file and out of core lua files. luaL_getn is no longer available, replaced by luaL_rawlen. luaL_register is deprecated, use the newlib/setfuncs replacements. rli_init has to be called before setting up the newlib to avoid overwriting the rb table. rocklib_aux.pl: use rli_checkboolean from rocklib.c. rocklua.c: new default bits library used, update the library loading code with idiomatic 5.2 code. strcspn.c: no longer needed, but strspn.c is required for strspn in lbaselib.c Change-Id: I0c7945c755f79083afe98ec117e1e8cf13de2651 Reviewed-on: http://gerrit.rockbox.org/774 Tested: Richard Quirk <richard.quirk@gmail.com> Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
* Make open() posix compliant api-wise. A few calls (those with O_CREAT) need ↵Thomas Martitz2010-05-06
| | | | | | the additional optional mode parameter so add it. Impact for the core is almost zero, as open() is a wrapper macro for the real open function which doesn't take the variable parameter. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25844 a1c6a512-1295-4272-9138-f99709370657
* Fix FS#11007: Lua didn't parse negative numbers correct when reading from filesMaurus Cuelenaere2010-02-13
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24632 a1c6a512-1295-4272-9138-f99709370657
* Lua plugin: fix bad behaviour for io.open(path, 'w')Maurus Cuelenaere2009-09-06
| | | | | | | Author: Christophe Gragnic Patch: FS#10592 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22645 a1c6a512-1295-4272-9138-f99709370657
* Lua IOlib: when opening files for writing/appending, check if they exist and ↵Maurus Cuelenaere2009-07-17
| | | | | | if not, add O_CREAT. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21918 a1c6a512-1295-4272-9138-f99709370657
* Lua IOlib: don't create files when they don't existMaurus Cuelenaere2009-07-08
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21715 a1c6a512-1295-4272-9138-f99709370657
* Fix typo & redMaurus Cuelenaere2009-06-28
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21543 a1c6a512-1295-4272-9138-f99709370657
* Lua:Maurus Cuelenaere2009-06-28
* add IO lib (adapted to Rockbox) * remove old IO wrappers * rework helloworld.lua to work with the IO lib * do some stuff in helloworld.lua better (part of FS#10379, by James Callahan) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21541 a1c6a512-1295-4272-9138-f99709370657