Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Minor change for new isearch code
- X-seq: zsh-workers 1071
- From: Wayne Davison <wayne@xxxxxxxxxxxxxxxxxx>
- To: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- Subject: Re: Minor change for new isearch code
- Date: Tue, 14 May 1996 10:21:48 -0700
- Cc: Zsh hacking and development <zsh-workers@xxxxxxxxxxxxxxx>
- In-reply-to: hzoli's message of Tue, 14 May 1996 05:11:30 +0200.	     <199605140311.FAA01491@xxxxxxxxxxxxxxxxxxxx> 
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---
Messages sorted by:
Reverse Date,
Date,
Thread,
Author