forked from espressif/esp-idf
feat(newlib): change line endings on standard input and output
Currently, the newline conversions for the NEWLIB_STDOUT_LINE_ENDING and NEWLIB_STDIN_LINE_ENDING options are only applied by VFS drivers. Without VFS, newline conversion does not occur. Introduce the default conversion of LF to CRLF on stdout and CF to LF on stdin for the default read and write syscalls in newlib. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -33,6 +33,9 @@ ssize_t _write_r_console(struct _reent *r, int fd, const void * data, size_t siz
|
||||
const char* cdata = (const char*) data;
|
||||
if (fd == STDOUT_FILENO || fd == STDERR_FILENO) {
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (cdata[i] == '\n') {
|
||||
esp_rom_output_tx_one_char('\r');
|
||||
}
|
||||
esp_rom_output_tx_one_char(cdata[i]);
|
||||
}
|
||||
return size;
|
||||
@@ -53,6 +56,9 @@ ssize_t _read_r_console(struct _reent *r, int fd, void * data, size_t size)
|
||||
if (status != 0) {
|
||||
break;
|
||||
}
|
||||
if (cdata[received] == '\r') {
|
||||
cdata[received] = '\n';
|
||||
}
|
||||
}
|
||||
if (received == 0) {
|
||||
errno = EWOULDBLOCK;
|
||||
|
Reference in New Issue
Block a user