Browse Source

AP_Filesystem: fixed gets() posix compat function

it needs to stop at end of line
apm_2208
Andrew Tridgell 3 years ago committed by Peter Barker
parent
commit
6f3b760d0b
  1. 7
      libraries/AP_Filesystem/posix_compat.cpp

7
libraries/AP_Filesystem/posix_compat.cpp

@ -146,15 +146,14 @@ int apfs_fputs(const char *s, APFS_FILE *stream) @@ -146,15 +146,14 @@ int apfs_fputs(const char *s, APFS_FILE *stream)
return ret;
}
#undef fgets
char *apfs_fgets(char *s, int size, APFS_FILE *stream)
{
CHECK_STREAM(stream, NULL);
ssize_t ret = AP::FS().read(stream->fd, s, size-1);
if (ret < 0) {
stream->error = true;
auto &fs = AP::FS();
if (!fs.fgets(s, size, stream->fd)) {
return NULL;
}
s[ret] = 0;
return s;
}

Loading…
Cancel
Save