about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2002-04-17 10:11:29 +0000
committerWayne Davison <wayned@users.sourceforge.net>2002-04-17 10:11:29 +0000
commit0350c1276a53294f2f403a840f434e448ab1cdba (patch)
tree4719d1a90510c1689f229c9b7915910339b4074e /Src
parentbd18159f4c69624ddce1374269758b9c6a589195 (diff)
downloadzsh-0350c1276a53294f2f403a840f434e448ab1cdba.tar.gz
zsh-0350c1276a53294f2f403a840f434e448ab1cdba.tar.xz
zsh-0350c1276a53294f2f403a840f434e448ab1cdba.zip
16890
Diffstat (limited to 'Src')
-rw-r--r--Src/hist.c16
-rw-r--r--Src/params.c20
2 files changed, 30 insertions, 6 deletions
diff --git a/Src/hist.c b/Src/hist.c
index 10ab2cb09..e86252d17 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -100,7 +100,12 @@ mod_export Histent hist_ring;
  
 /**/
 int histsiz;
- 
+
+/* desired history-file size (in lines) */
+
+/**/
+int savehistsiz;
+
 /* if = 1, we have performed history substitution on the current line *
  * if = 2, we have used the 'p' modifier                              */
  
@@ -942,7 +947,7 @@ prepnexthistent(void)
     else {
 	he = hist_ring->down;
 	if (isset(HISTEXPIREDUPSFIRST) && !(he->flags & HIST_DUP)) {
-	    int max_unique_ct = getiparam("SAVEHIST");
+	    int max_unique_ct = savehistsiz;
 	    do {
 		if (max_unique_ct-- <= 0) {
 		    he = hist_ring->down;
@@ -1959,10 +1964,9 @@ savehistfile(char *fn, int err, int writeflags)
     FILE *out;
     Histent he;
     int xcurhist = curhist - !!(histactive & HA_ACTIVE);
-    int savehist = getiparam("SAVEHIST");
     int extended_history = isset(EXTENDEDHISTORY);
 
-    if (!interact || savehist <= 0 || !hist_ring
+    if (!interact || savehistsiz <= 0 || !hist_ring
      || (!fn && !(fn = getsparam("HISTFILE"))))
 	return;
     if (writeflags & HFILE_FAST) {
@@ -1973,7 +1977,7 @@ savehistfile(char *fn, int err, int writeflags)
 	}
 	if (!he || !lockhistfile(fn, 0))
 	    return;
-	if (histfile_linect > savehist + savehist / 5)
+	if (histfile_linect > savehistsiz + savehistsiz / 5)
 	    writeflags &= ~HFILE_FAST;
     }
     else {
@@ -2054,7 +2058,7 @@ savehistfile(char *fn, int err, int writeflags)
 
 	    hist_ring = NULL;
 	    curhist = histlinect = 0;
-	    histsiz = savehist;
+	    histsiz = savehistsiz;
 	    histactive = 0;
 	    createhisttable(); /* sets histtab */
 
diff --git a/Src/params.c b/Src/params.c
index ef6016294..f39f1012d 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -139,6 +139,7 @@ IPDEF1("GID", gidgetfn, gidsetfn, PM_DONTIMPORT | PM_RESTRICTED),
 IPDEF1("EGID", egidgetfn, egidsetfn, PM_DONTIMPORT | PM_RESTRICTED),
 IPDEF1("HISTSIZE", histsizegetfn, histsizesetfn, PM_RESTRICTED),
 IPDEF1("RANDOM", randomgetfn, randomsetfn, 0),
+IPDEF1("SAVEHIST", savehistsizegetfn, savehistsizesetfn, PM_RESTRICTED),
 IPDEF1("SECONDS", secondsgetfn, secondssetfn, 0),
 IPDEF1("UID", uidgetfn, uidsetfn, PM_DONTIMPORT | PM_RESTRICTED),
 IPDEF1("EUID", euidgetfn, euidsetfn, PM_DONTIMPORT | PM_RESTRICTED),
@@ -2775,6 +2776,25 @@ histsizesetfn(Param pm, zlong v)
     resizehistents();
 }
 
+/* Function to get value for special parameter `SAVEHIST' */
+
+/**/
+zlong
+savehistsizegetfn(Param pm)
+{
+    return savehistsiz;
+}
+
+/* Function to set value of special parameter `SAVEHIST' */
+
+/**/
+void
+savehistsizesetfn(Param pm, zlong v)
+{
+    if ((savehistsiz = v) < 0)
+	savehistsiz = 0;
+}
+
 /* Function to get value for special parameter `ERRNO' */
 
 /**/