From owner-p4-projects@FreeBSD.ORG Thu Aug 7 22:38:15 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 996B51065675; Thu, 7 Aug 2008 22:38:15 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D8C71065673 for ; Thu, 7 Aug 2008 22:38:15 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 4B4EF8FC1E for ; Thu, 7 Aug 2008 22:38:15 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m77McFJh032404 for ; Thu, 7 Aug 2008 22:38:15 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m77McFpC032402 for perforce@freebsd.org; Thu, 7 Aug 2008 22:38:15 GMT (envelope-from ed@FreeBSD.org) Date: Thu, 7 Aug 2008 22:38:15 GMT Message-Id: <200808072238.m77McFpC032402@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 146878 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2008 22:38:15 -0000 http://perforce.freebsd.org/chv.cgi?CH=146878 Change 146878 by ed@ed_dull on 2008/08/07 22:37:43 Move tty_putchar() into the TTYDISC code, so we can perform proper output processing on characters added by tty_putchar(). This means things like reprinting now even work on stuff like ^T. While there, remove the unushed t_writebytes from struct tty. Affected files ... .. //depot/projects/mpsafetty/sys/kern/tty.c#18 edit .. //depot/projects/mpsafetty/sys/kern/tty_ttydisc.c#8 edit .. //depot/projects/mpsafetty/sys/sys/tty.h#6 edit Differences ... ==== //depot/projects/mpsafetty/sys/kern/tty.c#18 (text+ko) ==== @@ -1612,26 +1612,6 @@ } int -tty_putchar(struct tty *tp, char c) -{ - tty_lock_assert(tp, MA_OWNED); - - if (tty_gone(tp)) - return (-1); - - /* - * Convert \n to \r\n. - * XXX: What about output processing? - */ - if (c == '\n') - ttyoutq_write_nofrag(&tp->t_outq, "\r\n", 2); - else - ttyoutq_write_nofrag(&tp->t_outq, &c, 1); - ttydevsw_outwakeup(tp); - return (0); -} - -int tty_checkoutq(struct tty *tp) { ==== //depot/projects/mpsafetty/sys/kern/tty_ttydisc.c#8 (text+ko) ==== @@ -604,15 +604,8 @@ } static int -ttydisc_echo(struct tty *tp, char c, int quote) +ttydisc_echo_force(struct tty *tp, char c, int quote) { - /* - * Only echo characters when ECHO is turned on, or ECHONL when - * the character is an unquoted newline. - */ - if (!CMP_FLAG(l, ECHO) && - (!CMP_FLAG(l, ECHONL) || c != CNL || quote)) - return (0); if (CMP_FLAG(o, OPOST) && CTL_ECHO(c, quote)) { /* @@ -640,6 +633,22 @@ } } +static int +ttydisc_echo(struct tty *tp, char c, int quote) +{ + + /* + * Only echo characters when ECHO is turned on, or ECHONL when + * the character is an unquoted newline. + */ + if (!CMP_FLAG(l, ECHO) && + (!CMP_FLAG(l, ECHONL) || c != CNL || quote)) + return (0); + + return ttydisc_echo_force(tp, c, quote); +} + + static void ttydisc_reprint_char(void *d, char c, int quote) { @@ -1098,3 +1107,25 @@ return (error); } + +/* + * XXX: not really related to the TTYDISC, but we'd better put + * tty_putchar() here, because we need to perform proper output + * processing. + */ + +int +tty_putchar(struct tty *tp, char c) +{ + tty_lock_assert(tp, MA_OWNED); + + if (tty_gone(tp)) + return (-1); + + ttydisc_echo_force(tp, c, 0); + tp->t_writepos = tp->t_column; + ttyinq_reprintpos_set(&tp->t_inq); + + ttydevsw_outwakeup(tp); + return (0); +} ==== //depot/projects/mpsafetty/sys/sys/tty.h#6 (text+ko) ==== @@ -102,7 +102,6 @@ struct winsize t_winsize; /* (t) Window size */ unsigned int t_column; /* (t) Current cursor position */ unsigned int t_writepos; /* (t) Where input was interrupted */ - unsigned int t_writebytes; /* (t) Amount of bytes written */ /* Init/lock-state devices */ struct termios t_termios_init_in; /* tty%s.init */