diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/tty.c | 12 | ||||
-rw-r--r-- | sys/sys/termios.h | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 1bc30ca..a7ba12d 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -667,9 +667,16 @@ ttyoutput(c, tp) if (c == '\n' && ISSET(tp->t_oflag, ONLCR)) { tk_nout++; tp->t_outcc++; - if (putc('\r', &tp->t_outq)) + if (!ISSET(tp->t_lflag, FLUSHO) && putc('\r', &tp->t_outq)) return (c); } + /* If OCRNL is set, translate "\r" into "\n". */ + else if (c == '\r' && ISSET(tp->t_oflag, OCRNL)) + c = '\n'; + /* If ONOCR is set, don't transmit CRs when on column 0. */ + else if (c == '\r' && ISSET(tp->t_oflag, ONOCR) && tp->t_column == 0) + return (-1); + tk_nout++; tp->t_outcc++; if (!ISSET(tp->t_lflag, FLUSHO) && putc(c, &tp->t_outq)) @@ -684,6 +691,9 @@ ttyoutput(c, tp) case CONTROL: break; case NEWLINE: + if (ISSET(tp->t_oflag, ONLCR | ONLRET)) + col = 0; + break; case RETURN: col = 0; break; diff --git a/sys/sys/termios.h b/sys/sys/termios.h index 6111fc3..7e7643f 100644 --- a/sys/sys/termios.h +++ b/sys/sys/termios.h @@ -112,6 +112,9 @@ #define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */ #define OXTABS 0x00000004 /* expand tabs to spaces */ #define ONOEOT 0x00000008 /* discard EOT's (^D) on output) */ +#define OCRNL 0x00000010 /* map CR to NL on output */ +#define ONOCR 0x00000020 /* no CR output at column 0 */ +#define ONLRET 0x00000040 /* NL performs CR function */ #endif /*_POSIX_SOURCE */ /* |