all repos — mgba @ 6f4871fb7282339ec883a050bfae2c27cd1d8c76

mGBA Game Boy Advance Emulator

VFS: Fix line-reading to return proper values
Jeffrey Pfau jeffrey@endrift.com
Thu, 18 Jun 2015 01:26:46 -0700
commit

6f4871fb7282339ec883a050bfae2c27cd1d8c76

parent

6589eade24599de62c5c2e6ca5dc97560e4bc958

2 files changed, 9 insertions(+), 4 deletions(-)

jump to
M CHANGESCHANGES

@@ -45,6 +45,7 @@ - SDL: Fix SDL build when OpenGL is missing

- ARM7: Fix timing of multiplies to use N cycles - GBA: Fix calls to endian-independent loadstores - GBA Video: Fix windows not affecting sprites + - VFS: Fix line-reading to return proper values Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints
M src/util/vfs.csrc/util/vfs.c

@@ -6,15 +6,19 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "vfs.h" ssize_t VFileReadline(struct VFile* vf, char* buffer, size_t size) { - size_t bytesRead = 0; + ssize_t bytesRead = 0; while (bytesRead < size - 1) { - size_t newRead = vf->read(vf, &buffer[bytesRead], 1); + ssize_t newRead = vf->read(vf, &buffer[bytesRead], 1); + if (newRead <= 0) { + break; + } bytesRead += newRead; - if (!newRead || buffer[bytesRead] == '\n') { + if (buffer[bytesRead] == '\n') { break; } } - return buffer[bytesRead] = '\0'; + buffer[bytesRead] = '\0'; + return bytesRead; } ssize_t VFileWrite32LE(struct VFile* vf, int32_t word) {