Shanks0224 opened a new pull request, #22179: URL: https://github.com/apache/nuttx/pull/22179
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary Fixes to stdio stream handling so that it follows C and POSIX: - `ungetc()` and `fseek()` clear the EOF indicator; reads stop while the EOF indicator is set. - `fdopen()` enables line buffering only for terminals; new streams start with an empty pushback buffer. - `freopen()` updates the stream mode when the path is NULL. - scanf: `%%` skips leading whitespace, `%p` is correct on 64-bit systems, and arguments of conversions that did not match are no longer cleared (`sscanf("30 ", "%d %d", &a, &b)` leaves `b` unchanged). - `fflush()` on a seekable input stream sets the file offset to the stream position and discards pushed-back characters, instead of failing with EBADF. - Correct `flockfile()`/`funlockfile()` usage in `puts()` and `fputws_unlocked()`. - `STDIO_DISABLE_BUFFERING` defaults to `DEFAULT_SMALL`. ## Impact - Code that relied on unmatched scanf arguments being zeroed will now see the old value, as C and POSIX require. - `fflush()` on an input stream now succeeds and repositions the file instead of returning EBADF. - No impact on the build system, documentation or hardware. ## Testing Build host: Linux x86_64. - `sim:nsh` builds with no warning. - scanf (integer, float, string, char conversions) and fflush results on the simulator were compared with glibc and match, except the known differences listed below. - Known differences from glibc, not changed here: `%[` is not supported, and after `ungetc()` followed by `fflush()` the position is one byte behind glibc's. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
