From owner-freebsd-bugs Tue Jul 8 16:10:13 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id QAA15138 for bugs-outgoing; Tue, 8 Jul 1997 16:10:13 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id QAA15126; Tue, 8 Jul 1997 16:10:04 -0700 (PDT) Resent-Date: Tue, 8 Jul 1997 16:10:04 -0700 (PDT) Resent-Message-Id: <199707082310.QAA15126@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, helbig@MX.BA-Stuttgart.De Received: from helbig.informatik.ba-stuttgart.de (rvc1.informatik.ba-stuttgart.de [141.31.112.22]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id QAA14833 for ; Tue, 8 Jul 1997 16:05:29 -0700 (PDT) Received: (from root@localhost) by helbig.informatik.ba-stuttgart.de (8.8.6/8.8.5) id BAA14379; Wed, 9 Jul 1997 01:05:33 +0200 (MET DST) Message-Id: <199707082305.BAA14379@helbig.informatik.ba-stuttgart.de> Date: Wed, 9 Jul 1997 01:05:33 +0200 (MET DST) From: Wolfgang Helbig Reply-To: helbig@MX.BA-Stuttgart.De To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/4064: libedit's history search is broken Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 4064 >Category: bin >Synopsis: libedit's history search is broken >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jul 8 16:10:01 PDT 1997 >Last-Modified: >Originator: Wolfgang Helbig >Organization: >Release: FreeBSD 3.0-CURRENT i386 >Environment: >Description: The error shows up e. g. in sh(1), which uses the libedit. Do a ``set -o vi'' to enable vi style line editing. If you search for `ls' in the history, the shell will either show all commands that contain a `l', or will beep at you, even if there are commands that contain `ls' in the past. >How-To-Repeat: Enter the following commands to get a history. # sh # set -o vi # lll # llll Now hit the escape key to enter the vi commands, enter /llll, to search for the last occurence of the string `llll' in the history. Depending on whatever, the shell will show you the command `llll', which is correct, or beep at you, which is wrong. Hit the `N'-key to repeat the search, the shell might show you `lll', which is wrong, it should beep at you instead. >Fix: Index: search.c =================================================================== RCS file: /usr/cvsroot/src/lib/libedit/search.c,v retrieving revision 1.5 diff -c -r1.5 search.c *** search.c 1997/06/25 08:14:17 1.5 --- search.c 1997/07/08 21:39:09 *************** *** 464,471 **** (void)strncpy(tmpbuf, el->el_search.patbuf, sizeof(tmpbuf) - 1); el->el_search.patbuf[0] = '.'; el->el_search.patbuf[1] = '*'; ! (void)strncpy(&el->el_search.patbuf[2], tmpbuf, ! sizeof(el->el_search.patbuf) - 3); el->el_search.patlen++; el->el_search.patbuf[el->el_search.patlen++] = '.'; el->el_search.patbuf[el->el_search.patlen++] = '*'; --- 464,470 ---- (void)strncpy(tmpbuf, el->el_search.patbuf, sizeof(tmpbuf) - 1); el->el_search.patbuf[0] = '.'; el->el_search.patbuf[1] = '*'; ! (void)strncpy(&el->el_search.patbuf[2], tmpbuf, EL_BUFSIZ - 3); el->el_search.patlen++; el->el_search.patbuf[el->el_search.patlen++] = '.'; el->el_search.patbuf[el->el_search.patlen++] = '*'; *************** *** 479,486 **** tmpbuf[tmplen++] = '*'; #endif tmpbuf[tmplen] = '\0'; ! (void)strncpy(el->el_search.patbuf, tmpbuf, ! sizeof(el->el_search.patbuf) - 1); el->el_search.patlen = tmplen; } el->el_state.lastcmd = (el_action_t) dir; /* avoid c_setpat */ --- 478,484 ---- tmpbuf[tmplen++] = '*'; #endif tmpbuf[tmplen] = '\0'; ! (void)strncpy(el->el_search.patbuf, tmpbuf, EL_BUFSIZ - 1); el->el_search.patlen = tmplen; } el->el_state.lastcmd = (el_action_t) dir; /* avoid c_setpat */ >Audit-Trail: >Unformatted: