From ab451a984c9c2808ba4d30130fe627d8473a87da Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Sat, 23 Jun 2018 13:47:06 -0700 Subject: [PATCH] Map CR->NL locally on output instead of using tio.c_oflag |= OCRNL. This mostly is intended to have local echo output exactly what is sent to the remote endpoint. A nice side-effect is, that it also fixes tty-implementations, that can't deal with the OCRNL flag on tio.c_oflag. --- src/tty.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tty.c b/src/tty.c index c823e1b..6a0c5ec 100644 --- a/src/tty.c +++ b/src/tty.c @@ -55,6 +55,7 @@ static bool standard_baudrate = true; static void (*print)(char c); static int fd; static bool map_inlcrnl = false; +static bool map_ocrnl = false; static bool map_onlcrnl = false; static bool map_odelbs = false; @@ -415,7 +416,7 @@ void tty_configure(void) else if (strcmp(token,"ICRNL") == 0) tio.c_iflag |= ICRNL; else if (strcmp(token,"OCRNL") == 0) - tio.c_oflag |= OCRNL; + map_ocrnl = true; else if (strcmp(token,"ODELBS") == 0) map_odelbs = true; else if (strcmp(token,"INLCRNL") == 0) @@ -652,6 +653,8 @@ int tty_connect(void) /* Map output character */ if ((output_char == 127) && (map_odelbs)) output_char = '\b'; + if ((output_char == '\r') && (map_ocrnl)) + output_char = '\n'; /* Map newline character */ if ((output_char == '\n') && (map_onlcrnl)) {