This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit dc7b3236de6309473e2625e5cc21d32043ead6c1
Author: anpeiyun <[email protected]>
AuthorDate: Fri Aug 22 19:25:57 2025 +0800

    libc/stdio: Clear the EOF indicator in ungetc().
    
    When getc() reads a file stream up to EOF, the EOF indicator of the
    stream is set.  A successful ungetc() pushes a character back, so
    POSIX requires the end-of-file indicator to be cleared.
    
    Clear the indicator once the character has been pushed back.
    
    Signed-off-by: anpeiyun <[email protected]>
    Signed-off-by: ganjing <[email protected]>
---
 libs/libc/stdio/lib_ungetc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libs/libc/stdio/lib_ungetc.c b/libs/libc/stdio/lib_ungetc.c
index d352e9224cb..391732632cb 100644
--- a/libs/libc/stdio/lib_ungetc.c
+++ b/libs/libc/stdio/lib_ungetc.c
@@ -65,6 +65,7 @@ int ungetc(int c, FAR FILE *stream)
     {
       stream->fs_ungotten[nungotten] = c;
       stream->fs_nungotten = nungotten + 1;
+      stream->fs_flags &= ~__FS_FLAG_EOF;
       return c;
     }
   else

Reply via email to