diff options
| author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2010-02-13 14:41:00 +0000 |
|---|---|---|
| committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2010-02-13 14:41:00 +0000 |
| commit | 9bf28debd8617bbc5b8e42c9a47a3eb8c78ef43d (patch) | |
| tree | e70216b99f6366b47df34c955a9650227b7ddf82 /apps/plugins/lua/liolib.c | |
| parent | 4c658f74a775bcccadbc682e2a173a9a452ee2a2 (diff) | |
| download | rockbox-9bf28debd8617bbc5b8e42c9a47a3eb8c78ef43d.zip rockbox-9bf28debd8617bbc5b8e42c9a47a3eb8c78ef43d.tar.gz rockbox-9bf28debd8617bbc5b8e42c9a47a3eb8c78ef43d.tar.bz2 rockbox-9bf28debd8617bbc5b8e42c9a47a3eb8c78ef43d.tar.xz | |
Fix FS#11007: Lua didn't parse negative numbers correct when reading from files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24632 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lua/liolib.c')
| -rw-r--r-- | apps/plugins/lua/liolib.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/apps/plugins/lua/liolib.c b/apps/plugins/lua/liolib.c index eea40c0..e50524a 100644 --- a/apps/plugins/lua/liolib.c +++ b/apps/plugins/lua/liolib.c @@ -245,24 +245,13 @@ static int io_lines (lua_State *L) { ** ======================================================= */ - static int read_number (lua_State *L, int *f) { - char buf[10]; /* Maximum uint32 value is 10 chars long */ lua_Number d; - int i = 0; - /* Rather hackish, but we don't have fscanf. - Was: fscanf(f, LUA_NUMBER_SCAN, &d); */ - memset(buf, 0, 10); - rb->read(*f, buf, 10); - while(isdigit(buf[i]) && i < 10) - i++; - if(i == 0) return 0; - else { - rb->lseek(*f, i-10, SEEK_CUR); - d = rb->atoi(buf); + if (PREFIX(fscanf)(*f, LUA_NUMBER_SCAN, &d) == 1) { lua_pushnumber(L, d); return 1; } + else return 0; /* read fails */ } |