Date: Sat, 21 Jun 2008 12:01:55 GMT
From: James Butler <sweetnavelorange@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: bin/124822: [patch] Editline's ed-search-{prev, next}-history retains previous pattern when it shouldn't
Message-ID: <200806211201.m5LC1tTa088878@www.freebsd.org>
Resent-Message-ID: <200806211210.m5LCA6CO044073@freefall.freebsd.org>
index | next in thread | raw e-mail
>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 <C-v><up-arrow> ed-search-prev-history
$ cd
$ ls
$ l<up-arrow>
-> Finds 'ls'
-> Control-c it
$ <up-arrow>
-> Finds 'ls'
$ ls<up-arrow again>
-> 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:
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806211201.m5LC1tTa088878>
