about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2001-05-15 16:32:22 +0000
committerWayne Davison <wayned@users.sourceforge.net>2001-05-15 16:32:22 +0000
commiteb71464b09eb01014934ede89c031f8acddff6b8 (patch)
tree824f7c04c0f84b26056c081a903d4f82a9d12bb4
parent90e59f2e74903a678b53ae2005d721d88d72187e (diff)
downloadzsh-eb71464b09eb01014934ede89c031f8acddff6b8.tar.gz
zsh-eb71464b09eb01014934ede89c031f8acddff6b8.tar.xz
zsh-eb71464b09eb01014934ede89c031f8acddff6b8.zip
Changed addhistnode() to not displace an already-hashed command with
one that is marked HIST_TMPSTORE.  Also changed the function to not
ever destroy the entry we're currently adding (the caller now destroys
the newly-added entry, if it so desires).
-rw-r--r--Src/hashtable.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Src/hashtable.c b/Src/hashtable.c
index 884c98412..e88bc2477 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -1480,10 +1480,11 @@ addhistnode(HashTable ht, char *nam, void *nodeptr)
     HashNode oldnode = addhashnode2(ht, nam, nodeptr);
     Histent he = (Histent)nodeptr;
     if (oldnode && oldnode != (HashNode)nodeptr) {
-	if (he->flags & HIST_MAKEUNIQUE
+	if (he->flags & (HIST_MAKEUNIQUE | HIST_TMPSTORE)
 	 || (he->flags & HIST_FOREIGN && (Histent)oldnode == he->up)) {
+	    (void) addhashnode2(ht, oldnode->nam, oldnode); /* restore hash */
 	    he->flags |= HIST_DUP;
-	    addhashnode(ht, oldnode->nam, oldnode); /* Remove the new dup */
+	    he->flags &= ~HIST_MAKEUNIQUE;
 	}
 	else {
 	    oldnode->flags |= HIST_DUP;