Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

A couple history bugfixes



I noticed that the code that merges identical, adjacent entries could
merge a HIST_TMPSTORE entry with the previous line if it only differed
by the leading spacing, so I fixed this.

Also, if the delayed-drop line is a dup of an older entry (ignoring
leading spaces, as the duplicate-detection code does) and you have
hist_find_no_dups on, history searching would not find the delayed-
drop line.  My fix is to never call addhistnode() or removehashnode()
on a HIST_TMPSTORE item, so the line is never marked as a dup (and is
also never entered into the history hash table).

..wayne..
Index: Src/hashtable.c
@@ -1480,7 +1480,7 @@
     HashNode oldnode = addhashnode2(ht, nam, nodeptr);
     Histent he = (Histent)nodeptr;
     if (oldnode && oldnode != (HashNode)nodeptr) {
-	if (he->flags & (HIST_MAKEUNIQUE | HIST_TMPSTORE)
+	if (he->flags & HIST_MAKEUNIQUE
 	 || (he->flags & HIST_FOREIGN && (Histent)oldnode == he->up)) {
 	    (void) addhashnode2(ht, oldnode->nam, oldnode); /* restore hash */
 	    he->flags |= HIST_DUP;
@@ -1511,7 +1511,7 @@
     if (!he)
 	return;
 
-    if (!(he->flags & HIST_DUP))
+    if (!(he->flags & (HIST_DUP | HIST_TMPSTORE)))
 	removehashnode(histtab, he->text);
 
     zsfree(he->text);
Index: Src/hist.c
@@ -1096,8 +1096,8 @@
 		histreduceblanks();
 	}
 	newflags = save > 0? 0 : HIST_OLD | HIST_TMPSTORE;
-	if ((isset(HISTIGNOREDUPS) || isset(HISTIGNOREALLDUPS)) && hist_ring
-	 && histstrcmp(chline, hist_ring->text) == 0) {
+	if ((isset(HISTIGNOREDUPS) || isset(HISTIGNOREALLDUPS)) && save > 0
+	 && hist_ring && histstrcmp(chline, hist_ring->text) == 0) {
 	    /* This history entry compares the same as the previous.
 	     * In case minor changes were made, we overwrite the
 	     * previous one with the current one.  This also gets the
@@ -1119,7 +1119,8 @@
 	    he->words = (short *)zalloc(chwordpos * sizeof(short));
 	    memcpy(he->words, chwords, chwordpos * sizeof(short));
 	}
-	addhistnode(histtab, he->text, he);
+	if (!(newflags & HIST_TMPSTORE))
+	    addhistnode(histtab, he->text, he);
     }
     zfree(chline, hlinesz);
     zfree(chwords, chwordlen*sizeof(short));


Messages sorted by: Reverse Date, Date, Thread, Author