From owner-freebsd-bugs@FreeBSD.ORG Sat Jun 21 12:10:07 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD49E106567A for ; Sat, 21 Jun 2008 12:10:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B52568FC1E for ; Sat, 21 Jun 2008 12:10:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m5LCA6xl044074 for ; Sat, 21 Jun 2008 12:10:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m5LCA6CO044073; Sat, 21 Jun 2008 12:10:06 GMT (envelope-from gnats) Resent-Date: Sat, 21 Jun 2008 12:10:06 GMT Resent-Message-Id: <200806211210.m5LCA6CO044073@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, James Butler Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FDE71065675 for ; Sat, 21 Jun 2008 12:01:56 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id EF51C8FC19 for ; Sat, 21 Jun 2008 12:01:55 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m5LC1tWB088879 for ; Sat, 21 Jun 2008 12:01:55 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m5LC1tTa088878; Sat, 21 Jun 2008 12:01:55 GMT (envelope-from nobody) Message-Id: <200806211201.m5LC1tTa088878@www.freebsd.org> Date: Sat, 21 Jun 2008 12:01:55 GMT From: James Butler To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/124822: [patch] Editline's ed-search-{prev, next}-history retains previous pattern when it shouldn't X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jun 2008 12:10:07 -0000 >Number: 124822 >Category: bin >Synopsis: [patch] Editline's ed-search-{prev,next}-history retains previous pattern when it shouldn't >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: Sat Jun 21 12:10:06 UTC 2008 >Closed-Date: >Last-Modified: >Originator: James Butler >Release: 7-STABLE >Organization: >Environment: FreeBSD microvac 7.0-STABLE FreeBSD 7.0-STABLE #0: Thu Jun 19 22:12:59 NZST 2008 james@microvac:/usr/obj/usr/src/sys/GENERIC i386 >Description: Editline's ed-search-{prev,next}-history functions save the pattern buffer between invocations; this means that if a history search has previously been performed, then starting a new search with an empty line will instead search on the previous pattern. This seems to be in conflict with editrc(5), and is different to tcsh etc. >How-To-Repeat: With /bin/sh -E: $ bind ed-search-prev-history $ cd $ ls $ l -> Finds 'ls' -> Control-c it $ -> Finds 'ls' $ ls -> Beeps - should find 'cd' >Fix: Clear el->el_search.patbuf if we invoke ed-search-*-history with no chars behind the cursor. The attached patch seems to work for me, though my c-fu is weak. Patch attached with submission follows: --- ./lib/libedit/search.c 2005-08-08 08:51:52.000000000 +1200 +++ /home/james/search.c 2008-06-21 23:05:27.000000000 +1200 @@ -175,8 +175,15 @@ (void) strncpy(el->el_search.patbuf, el->el_line.buffer, el->el_search.patlen); el->el_search.patbuf[el->el_search.patlen] = '\0'; - } else - el->el_search.patlen = strlen(el->el_search.patbuf); + } else { + if (el->el_state.thiscmd == ED_SEARCH_PREV_HISTORY || + el->el_state.thiscmd == ED_SEARCH_NEXT_HISTORY) { + el->el_search.patlen = 0; + el->el_search.patbuf[0] = '\0'; + } else + el->el_search.patlen = + strlen(el->el_search.patbuf); + } } #ifdef SDEBUG (void) fprintf(el->el_errfile, "\neventno = %d\n", >Release-Note: >Audit-Trail: >Unformatted: