From owner-freebsd-bugs@FreeBSD.ORG Thu Nov 17 00:10:22 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 304FF16A41F for ; Thu, 17 Nov 2005 00:10:22 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9CC6543D46 for ; Thu, 17 Nov 2005 00:10:21 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id jAH0ALjO075455 for ; Thu, 17 Nov 2005 00:10:21 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id jAH0ALAk075454; Thu, 17 Nov 2005 00:10:21 GMT (envelope-from gnats) Resent-Date: Thu, 17 Nov 2005 00:10:21 GMT Resent-Message-Id: <200511170010.jAH0ALAk075454@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Phil Oleson Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CA67916A41F for ; Thu, 17 Nov 2005 00:01:13 +0000 (GMT) (envelope-from oz@nixil.net) Received: from nixil.net (nixil.net [161.58.222.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 71E9E43D46 for ; Thu, 17 Nov 2005 00:01:13 +0000 (GMT) (envelope-from oz@nixil.net) Received: from nixil.net (localhost [127.0.0.1]) by nixil.net (8.13.1/8.13.1) with ESMTP id jAH01Ccb003245 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT) for ; Wed, 16 Nov 2005 17:01:12 -0700 (MST) Received: (from oz@localhost) by nixil.net (8.13.1/8.13.1/Submit) id jAH01CXW003244; Wed, 16 Nov 2005 17:01:12 -0700 (MST) Message-Id: <200511170001.jAH01CXW003244@nixil.net> Date: Wed, 16 Nov 2005 17:01:12 -0700 (MST) From: Phil Oleson To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/89180: big fix for libedit X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Phil Oleson List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2005 00:10:22 -0000 >Number: 89180 >Category: bin >Synopsis: big fix for libedit >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Nov 17 00:10:21 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Phil Oleson >Release: FreeBSD 4.7-RELEASE-p28 i386 >Organization: N/A >Environment: System: FreeBSD nixil.net 4.7-RELEASE-p28 FreeBSD 4.7-RELEASE-p28 #42: Tue Jun 21 10:33:20 MDT 2005 root@fc2:/usr/src/sys/compile/VKERN i386 >Description: Here is the cvs log from netbsd: -------------------------- revision 1.27 date: 2005/11/09 22:11:10; author: christos; state: Exp; lines: +35 -13 Refresh bug reported by Julien Torres: going from: activate -verbose to: reset -activation results in: reset -activationverbose" instead of: reset -activation This is because we choose to insert "reset -" before the current line, and the delete "e -" and insert "ion" in the appropriate place. The cleareol code did not handle this case properly; we now cleareol to the maximum number of characters of the first difference, the second difference and the difference in line length. ---------------------------- >How-To-Repeat: N/A >Fix: Diff attached. --- libedit-patch begins here --- --- refresh.c.orig Mon Nov 14 17:49:42 2005 +++ refresh.c Mon Nov 14 18:00:05 2005 @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $NetBSD: refresh.c,v 1.26 2003/08/07 16:44:33 agc Exp $ + * $NetBSD: refresh.c,v 1.27 2005/11/09 22:11:10 christos Exp $ */ #if !defined(lint) && !defined(SCCSID) @@ -54,6 +54,7 @@ private void re_insert (EditLine *, char *, int, int, char *, int); private void re_delete(EditLine *, char *, int, int, int); private void re_fastputc(EditLine *, int); +private void re_clear_eol(EditLine *, int, int, int); private void re__strncopy(char *, char *, size_t); private void re__copy_and_pad(char *, const char *, size_t); @@ -345,7 +346,7 @@ ELRE_DEBUG(1, (__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n", num, dat, dlen, d)); - ELRE_DEBUG(1, (__F, "s == \"%s\"n", s)); + ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s)); /* open up the space for num chars */ if (num > 0) { @@ -358,7 +359,7 @@ ELRE_DEBUG(1, (__F, "re_insert() after insert: %d at %d max %d, d == \"%s\"\n", num, dat, dlen, d)); - ELRE_DEBUG(1, (__F, "s == \"%s\"n", s)); + ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s)); /* copy the characters */ for (a = d + dat; (a < d + dlen) && (num > 0); num--) @@ -367,7 +368,7 @@ ELRE_DEBUG(1, (__F, "re_insert() after copy: %d at %d max %d, %s == \"%s\"\n", num, dat, dlen, d, s)); - ELRE_DEBUG(1, (__F, "s == \"%s\"n", s)); + ELRE_DEBUG(1, (__F, "s == \"%s\"\n", s)); } @@ -416,6 +417,32 @@ *a++ = *b++; } +/* re_clear_eol(): + * Find the number of characters we need to clear till the end of line + * in order to make sure that we have cleared the previous contents of + * the line. fx and sx is the number of characters inserted or deleted + * int the first or second diff, diff is the difference between the + * number of characters between the new and old line. + */ +private void +re_clear_eol(EditLine *el, int fx, int sx, int diff) +{ + + ELRE_DEBUG(1, (__F, "re_clear_eol sx %d, fx %d, diff %d\n", + sx, fx, diff)); + + if (fx < 0) + fx = -fx; + if (sx < 0) + sx = -sx; + if (fx > diff) + diff = fx; + if (sx > diff) + diff = sx; + + ELRE_DEBUG(1, (__F, "re_clear_eol %d\n", diff)); + term_clear_EOL(el, diff); +} /***************************************************************** re_update_line() is based on finding the middle difference of each line @@ -631,7 +658,7 @@ fx = (nsb - nfd) - (osb - ofd); sx = (nls - nse) - (ols - ose); - ELRE_DEBUG(1, (__F, "\n")); + ELRE_DEBUG(1, (__F, "fx %d, sx %d\n", fx, sx)); ELRE_DEBUG(1, (__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n", ofd - old, osb - old, ose - old, ols - old, oe - old)); ELRE_DEBUG(1, (__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n", @@ -780,9 +807,7 @@ * write (nsb-nfd) chars of new starting at nfd */ term_overwrite(el, nfd, (nsb - nfd)); - ELRE_DEBUG(1, (__F, - "cleareol %d\n", (oe - old) - (ne - new))); - term_clear_EOL(el, (oe - old) - (ne - new)); + re_clear_eol(el, fx, sx, (oe - old) - (ne - new)); /* * Done */ @@ -823,10 +848,7 @@ ELRE_DEBUG(1, (__F, "but with nothing left to save\r\n")); term_overwrite(el, nse, (nls - nse)); - ELRE_DEBUG(1, (__F, - "cleareol %d\n", (oe - old) - (ne - new))); - if ((oe - old) - (ne - new) != 0) - term_clear_EOL(el, (oe - old) - (ne - new)); + re_clear_eol(el, fx, sx, (oe - old) - (ne - new)); } } /* --- libedit-patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: