File tcsh-6.18.01-history-merge.dif of Package tcsh.12832

--- sh.hist.c
+++ sh.hist.c	2013-10-15 17:04:45.518796367 +0000
@@ -99,7 +99,7 @@ hremove(struct Hist *hp)
 
 /* Prune length of history list to specified size by history variable. */
 PG_STATIC void
-discardExcess(int histlen)
+discardExcess(int histlen, int flg)
 {
     struct Hist *hp, *np;
     if (histTail == NULL) {
@@ -116,7 +116,7 @@ discardExcess(int histlen)
             break;
     }
     while (histCount > (unsigned)histlen && (np = histTail) != &Histlist) {
-        if (eventno - np->Href >= histlen || histlen == 0)
+        if ((eventno - np->Href >= histlen || histlen == 0) && ! (flg & HIST_MERGE))
             hremove(np), hfree(np);
         else
             break;
@@ -125,7 +125,7 @@ discardExcess(int histlen)
 	return;				/* don't bother doing the full scan */
     for (hp = &Histlist; histCount > (unsigned)histlen &&
 	(np = hp->Hnext) != NULL;)
-        if (eventno - np->Href >= histlen || histlen == 0)
+        if ((eventno - np->Href >= histlen || histlen == 0) || flg & HIST_MERGE)
             hremove(np), hfree(np);
         else
             hp = np;
@@ -153,7 +153,7 @@ savehist(
     }
     if (sp)
         (void) enthist(++eventno, sp, 1, flg, histlen);
-    discardExcess(histlen);
+    discardExcess(histlen, flg);
 }
 
 #define USE_JENKINS_HASH 1
openSUSE Build Service is sponsored by