tcsh/tcsh-6.18.01-history-merge.dif
2015-01-13 17:16:42 +00:00

39 lines
1.3 KiB
Plaintext

--- sh.hist.c
+++ sh.hist.c 2013-10-15 17:04:45.518796367 +0000
@@ -107,7 +107,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) {
@@ -124,7 +124,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;
@@ -133,7 +133,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;
@@ -161,7 +161,7 @@ savehist(
}
if (sp)
(void) enthist(++eventno, sp, 1, flg, histlen);
- discardExcess(histlen);
+ discardExcess(histlen, flg);
}
#define USE_JENKINS_HASH 1