Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tinystdio: fgets returns NULL only when EOF is reached
According to the ISO/IEC_9899_1999, section:7.19.7.2 It is mentioned that when EOF is encountered and no characters were read into the array a null pointer is returned. In the fgets function in picolibc, it always returned NULL when it reaches EOF even if characters were read and that the file is not empty. Accordingly a flag was added that checks if the file is empty or not, there is an added "if" condition that checks on this flag, if EOF was encountered for whether NULL or the pointer to the array that was read will be returned. The case where it returns NULL occurs when EOF and no characters were read. This change checks and handles that fgets returns the pointer to the array correctly when it reaches EOF.
- Loading branch information