stdio: lib_fgets convert \r\n to \n
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
cd74a1df22
commit
68ff73c5fb
@ -142,6 +142,13 @@ FAR char *lib_fgets(FAR char *buf, size_t buflen, FILE *stream,
|
||||
|
||||
if (ch == '\n')
|
||||
{
|
||||
/* Convert \r\n to \n */
|
||||
|
||||
if (nch > 0 && buf[nch - 1] == '\r')
|
||||
{
|
||||
--nch;
|
||||
}
|
||||
|
||||
if (keepnl)
|
||||
{
|
||||
/* Store newline is stored in the buffer */
|
||||
@ -161,7 +168,7 @@ FAR char *lib_fgets(FAR char *buf, size_t buflen, FILE *stream,
|
||||
{
|
||||
/* End of file with no data? */
|
||||
|
||||
if (!nch)
|
||||
if (nch == 0)
|
||||
{
|
||||
/* Yes.. return NULL as the end of file mark */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user