From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id DAA27403 for ; Wed, 15 May 1996 03:46:10 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id NAA18433; Tue, 14 May 1996 13:23:12 -0400 (EDT) Resent-Date: Tue, 14 May 1996 13:23:12 -0400 (EDT) Message-Id: <199605141721.KAA07375@tenor.clari.net> To: Zoltan Hidvegi Cc: Zsh hacking and development Subject: Re: Minor change for new isearch code In-reply-to: hzoli's message of Tue, 14 May 1996 05:11:30 +0200. <199605140311.FAA01491@hzoli.ppp.cs.elte.hu> Date: Tue, 14 May 1996 10:21:48 -0700 From: Wayne Davison Resent-Message-ID: <"bMhl6.0.xV4._5Ccn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1071 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Zoltan Hidvegi writes: > Here is a complete revision of the patches in articles 1062 and 1063 > from Wayne. Fair enough. You missed a couple strlen() -> ztrlen() changes in the history-search-* functions, however. BUT, since your new metadiffer() function can differentiate between an exact match and a substring match, the ztrlen() call isn't even needed if we disallow the 0 return value. My patch is appended. This patch also corrects a minor typo in the comment prior to metadiffer() and moves the assignment of histpos (a trivial optimization). ..wayne.. ---8<------8<------8<------8<---cut here--->8------>8------>8------>8--- Index: utils.c @@ -2948,7 +2948,7 @@ return 1; } -/* Return zero if the metafied string s differs and the non-metafied, * +/* Return zero if the metafied string s and the non-metafied, * * len-long string r are the same. Return -1 if r is a prefix of s * * and return 1 otherwise. */ Index: zle_hist.c @@ -355,8 +355,8 @@ for (t0 = 0; t0 < ll && !iblank(line[t0]); t0++); if (t0 < ll) t0++; + histpos = t0; } - histpos = t0; for (;;) { histline--; if (!(s = zle_get_event(histline))) { @@ -364,8 +364,7 @@ histline = ohistline; return; } - if (strlen(UTOSCP(s)) > t0 && - metadiffer(s, UTOSCP(line), t0) < 1 && + if (metadiffer(s, UTOSCP(line), t0) < 0 && metadiffer(s, UTOSCP(line), ll)) break; } @@ -386,8 +385,8 @@ for (t0 = 0; t0 < ll && !iblank(line[t0]); t0++); if (t0 < ll) t0++; + histpos = t0; } - histpos = t0; for (;;) { histline++; if (!(s = zle_get_event(histline))) { @@ -395,8 +394,7 @@ histline = ohistline; return; } - if ((histline == curhist || strlen(UTOSCP(s)) > t0) && - metadiffer(s, UTOSCP(line), t0) < 1 && + if (metadiffer(s, UTOSCP(line), t0) < (histline == curhist) && metadiffer(s, UTOSCP(line), ll)) break; } @@ -1101,8 +1099,7 @@ histline = ohistline; return; } - if (ztrlen((char *)s) > cs && - metadiffer(s, (char *)line, cs) < 1 && + if (metadiffer(s, (char *)line, cs) < 0 && metadiffer(s, (char *)line, ll)) break; } @@ -1130,8 +1127,7 @@ histline = ohistline; return; } - if ((histline == curhist || ztrlen((char *)s) > cs) && - metadiffer(s, (char *)line, cs) < 1 && + if (metadiffer(s, (char *)line, cs) < (histline == curhist) && metadiffer(s, (char *)line, ll)) break; } ---8<------8<------8<------8<---cut here--->8------>8------>8------>8---