mirror of https://github.com/mgba-emu/mgba.git
VFS: Fix VFileReadline and remove _vfdReadline
This commit is contained in:
parent
101fa29ce9
commit
8eb4f3ca4d
1
CHANGES
1
CHANGES
|
@ -12,6 +12,7 @@ Bugfixes:
|
|||
- 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
|
||||
|
|
|
@ -119,7 +119,7 @@ ssize_t VFileReadline(struct VFile* vf, char* buffer, size_t size) {
|
|||
break;
|
||||
}
|
||||
bytesRead += newRead;
|
||||
if (buffer[bytesRead] == '\n') {
|
||||
if (buffer[bytesRead - newRead] == '\n') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ struct VFileFD {
|
|||
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 @@ struct VFile* VFileFromFD(int 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;
|
||||
|
@ -91,20 +90,6 @@ ssize_t _vfdRead(struct VFile* vf, void* buffer, size_t size) {
|
|||
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) {
|
||||
struct VFileFD* vfd = (struct VFileFD*) vf;
|
||||
return write(vfd->fd, buffer, size);
|
||||
|
|
Loading…
Reference in New Issue