summary refs log tree commit diff
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2000-07-18 07:55:13 +0000
committerWayne Davison <wayned@users.sourceforge.net>2000-07-18 07:55:13 +0000
commitb4c5de44f991022843f3a2f100240bc34ee77d88 (patch)
tree456a56ea1576a4ee6405d2cccbaa35a61a2e0bb8
parent2e96c8f0742c9b759495226b8b20e3a8363e6d50 (diff)
downloadzsh-b4c5de44f991022843f3a2f100240bc34ee77d88.tar.gz
zsh-b4c5de44f991022843f3a2f100240bc34ee77d88.tar.xz
zsh-b4c5de44f991022843f3a2f100240bc34ee77d88.zip
+ Got rid of the spaceflag variable.
+ Make sure that the curline.histnum variable is accurate at the end
  of our history processing, even if we read in some foreign history
  and/or if we replaced the prior line because it was a duplicate of
  the current one.  This enables the history (fc -l) command to work
  properly, even if the current command was HIST_NO_SPACE-ed away.
+ Don't allow remhist() to remove the last line in the history if we
  didn't store the current command.
-rw-r--r--Src/hist.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/Src/hist.c b/Src/hist.c
index 83f661c9b..28175c3f3 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -55,12 +55,7 @@ void (*addtoline) _((int));
  
 /**/
 mod_export int stophist;
- 
-/* this line began with a space, so junk it if HISTIGNORESPACE is on */
- 
-/**/
-int spaceflag;
- 
+
 /* if != 0, we are expanding the current line */
 
 /**/
@@ -741,7 +736,7 @@ mod_export void
 hbegin(int dohist)
 {
     isfirstln = isfirstch = 1;
-    errflag = histdone = spaceflag = 0;
+    errflag = histdone = 0;
     stophist = (!dohist || !interact || unset(SHINSTDIN)) ? 2 : 0;
     if (stophist == 2 || (inbufflags & INP_ALIAS)) {
 	chline = hptr = NULL;
@@ -976,8 +971,10 @@ hend(void)
      && (hist_ignore_all_dups = isset(HISTIGNOREALLDUPS)) != 0)
 	histremovedups();
     /* For history sharing, lock history file once for both read and write */
-    if (isset(SHAREHISTORY) && lockhistfile(hf, 0))
+    if (isset(SHAREHISTORY) && lockhistfile(hf, 0)) {
 	readhistfile(hf, 0, HFILE_USE_OPTIONS | HFILE_FAST);
+	curline.histnum = curhist+1;
+    }
     flag = histdone;
     histdone = 0;
     if (hptr < chline + 1)
@@ -990,8 +987,7 @@ hend(void)
 	    } else
 		save = 0;
 	}
-	if (!*chline || !strcmp(chline, "\n") ||
-	    (isset(HISTIGNORESPACE) && spaceflag))
+	if (chwordpos <= 2 || (isset(HISTIGNORESPACE) && *chline == ' '))
 	    save = 0;
     }
     if (flag & (HISTFLAG_DONE | HISTFLAG_RECALL)) {
@@ -1038,6 +1034,7 @@ hend(void)
 	     */
 	    keepflags = he->flags & HIST_OLD; /* Avoid re-saving */
 	    freehistdata(he, 0);
+	    curline.histnum = curhist;
 	} else {
 	    keepflags = 0;
 	    he = prepnexthistent();
@@ -1073,7 +1070,7 @@ remhist(void)
     if (hist_ring == &curline)
 	return;
     if (!(histactive & HA_ACTIVE)) {
-	if (!(histactive & HA_JUNKED)) {
+	if (!(histactive & HA_JUNKED) && curline.histnum == curhist) {
 	    freehistnode((HashNode)hist_ring);
 	    histactive |= HA_JUNKED;
 	    /* curhist-- is delayed until the next hbegin() */