1
0
mirror of https://github.com/libretro/RetroArch synced 2025-02-20 15:40:44 +00:00

Reimplement filestream_gets

This commit is contained in:
twinaphex 2017-12-13 19:19:49 +01:00
parent adb0add226
commit 4dfbfc4d02

@ -330,9 +330,26 @@ error:
char *filestream_gets(RFILE *stream, char *s, size_t len)
{
int c = 0;
char *p = NULL;
if (!stream)
return NULL;
return fgets(s, (int)len, stream->fp);
/* get max bytes or up to a newline */
for (p = s, len--; len > 0; len--)
{
if ((c = filestream_getc(stream)) == EOF)
break;
*p++ = c;
if (c == '\n')
break;
}
*p = 0;
if (p == s || c == EOF)
return NULL;
return (p);
}
int filestream_getc(RFILE *stream)