Philip Guenther wrote:
Hmm, with that deleted, telnet will set but never clear ICRNL. For
consistency of state/operation, I suspect it would be better to move that
line up above the other block, so that it'll set ICRNL when echo&&crlf,
but clear it otherwise:
Index: sys_bsd.c
===================================================================
RCS file: /cvs/src/usr.bin/telnet/sys_bsd.c,v
retrieving revision 1.28
diff -u -p -r1.28 sys_bsd.c
--- sys_bsd.c 9 Sep 2014 03:41:08 -0000 1.28
+++ sys_bsd.c 21 Jan 2015 03:36:50 -0000
@@ -275,6 +275,7 @@ TerminalNewMode(int f)
prevmode = f&~MODE_FORCE;
tmp_tc = new_tc;
+ tmp_tc.c_iflag &= ~ICRNL;
if (f&MODE_ECHO) {
tmp_tc.c_lflag |= ECHO;
tmp_tc.c_oflag |= ONLCR;
@@ -310,7 +311,6 @@ TerminalNewMode(int f)
tmp_tc.c_lflag |= ICANON;
} else {
tmp_tc.c_lflag &= ~ICANON;
- tmp_tc.c_iflag &= ~ICRNL;
tmp_tc.c_cc[VMIN] = 1;
tmp_tc.c_cc[VTIME] = 0;
}
No, this patch has the same problem as the unpatched code.
It again sets combination "ONLCR -ICRNL ECHO". With this combination,
xterm echoes Return key as ^M (without going to new line) even before
telnet client is able to do anything.
I am on UNIX, so the link communication mode has crlf == 0. ICRNL is
left untouched with my patch, but it is unset with your patch and by the
original code.
crlf variable defines the link communication mode.
But the communication mode between terminal emulator and the telnet
client should not depend on the link communication mode. It is defined
by the termcap/terminfo. It should not be dependent on the link ending
of lines.
tcsetattr() has a bit limited set of features regarding CR/LF handing:
- map CR to NL (input: ICRNL, output: OCRNL)
- map NL to CR (input: INLCR, output: ONLCR)
- ignore CR (input: IGNCR, output: N/A)
- ignore CR at column zero (input: N/A, output: ONOCR)
- NL key performs CR (ONLRET)
- echo CR/LF as ^M/^J (ECHOCTL if not interpreted as control)
- echo NL in no-echo mode (input: N/A, output: ECHONL)
(More about combinations can be found in stty POSIX manual page.)
I see two possible ways to fix:
1) Configure terminal to properly handle Return (NL) key, i. e. send
CR/LF/CR+LF to the telnet client and perform transfer to the beginning
of the new line.
2) Configure terminal to not echo Return key at all, and handle the echo
in the terminal client.
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: [email protected]
Lihovarská 1060/12 tel: +49 911 7405384547
190 00 Praha 9 fax: +420 284 084 001
Czech Republic http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76