VFS: Fix VFileReadline and remove _vfdReadline
Jeffrey Pfau jeffrey@endrift.com
Sun, 01 Nov 2015 16:49:53 -0800
3 files changed,
3 insertions(+),
17 deletions(-)
M
CHANGES
→
CHANGES
@@ -12,6 +12,7 @@ - GBA: Fix idle skip state being retained between games
- Qt: Fix a race condition in PainterGL that could lead to a crash - Qt: Fix clear button/analog buttons in gamepad mapper on some platforms - GBA Video: Fix _mix for 15-bit color + - VFS: Fix VFileReadline and remove _vfdReadline Misc: - Qt: Window size command line options are now supported - Qt: Increase usability of key mapper
M
src/util/vfs.c
→
src/util/vfs.c
@@ -119,7 +119,7 @@ if (newRead <= 0) {
break; } bytesRead += newRead; - if (buffer[bytesRead] == '\n') { + if (buffer[bytesRead - newRead] == '\n') { break; } }
M
src/util/vfs/vfs-fd.c
→
src/util/vfs/vfs-fd.c
@@ -24,7 +24,6 @@
static bool _vfdClose(struct VFile* vf); static off_t _vfdSeek(struct VFile* vf, off_t offset, int whence); static ssize_t _vfdRead(struct VFile* vf, void* buffer, size_t size); -static ssize_t _vfdReadline(struct VFile* vf, char* buffer, size_t size); static ssize_t _vfdWrite(struct VFile* vf, const void* buffer, size_t size); static void* _vfdMap(struct VFile* vf, size_t size, int flags); static void _vfdUnmap(struct VFile* vf, void* memory, size_t size);@@ -61,7 +60,7 @@ vfd->fd = fd;
vfd->d.close = _vfdClose; vfd->d.seek = _vfdSeek; vfd->d.read = _vfdRead; - vfd->d.readline = _vfdReadline; + vfd->d.readline = VFileReadline; vfd->d.write = _vfdWrite; vfd->d.map = _vfdMap; vfd->d.unmap = _vfdUnmap;@@ -89,20 +88,6 @@
ssize_t _vfdRead(struct VFile* vf, void* buffer, size_t size) { struct VFileFD* vfd = (struct VFileFD*) vf; return read(vfd->fd, buffer, size); -} - -ssize_t _vfdReadline(struct VFile* vf, char* buffer, size_t size) { - struct VFileFD* vfd = (struct VFileFD*) vf; - size_t bytesRead = 0; - while (bytesRead < size - 1) { - size_t newRead = read(vfd->fd, &buffer[bytesRead], 1); - if (!newRead || buffer[bytesRead] == '\n') { - break; - } - bytesRead += newRead; - } - buffer[bytesRead] = '\0'; - return bytesRead; } ssize_t _vfdWrite(struct VFile* vf, const void* buffer, size_t size) {