1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-10-02 00:41:44 +02:00

+ 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.
This commit is contained in:
Wayne Davison 2000-07-18 07:55:13 +00:00
parent 2e96c8f074
commit b4c5de44f9

@ -55,12 +55,7 @@ void (*addtoline) _((int));
/**/ /**/
mod_export int stophist; 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 */ /* if != 0, we are expanding the current line */
/**/ /**/
@ -741,7 +736,7 @@ mod_export void
hbegin(int dohist) hbegin(int dohist)
{ {
isfirstln = isfirstch = 1; isfirstln = isfirstch = 1;
errflag = histdone = spaceflag = 0; errflag = histdone = 0;
stophist = (!dohist || !interact || unset(SHINSTDIN)) ? 2 : 0; stophist = (!dohist || !interact || unset(SHINSTDIN)) ? 2 : 0;
if (stophist == 2 || (inbufflags & INP_ALIAS)) { if (stophist == 2 || (inbufflags & INP_ALIAS)) {
chline = hptr = NULL; chline = hptr = NULL;
@ -976,8 +971,10 @@ hend(void)
&& (hist_ignore_all_dups = isset(HISTIGNOREALLDUPS)) != 0) && (hist_ignore_all_dups = isset(HISTIGNOREALLDUPS)) != 0)
histremovedups(); histremovedups();
/* For history sharing, lock history file once for both read and write */ /* 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); readhistfile(hf, 0, HFILE_USE_OPTIONS | HFILE_FAST);
curline.histnum = curhist+1;
}
flag = histdone; flag = histdone;
histdone = 0; histdone = 0;
if (hptr < chline + 1) if (hptr < chline + 1)
@ -990,8 +987,7 @@ hend(void)
} else } else
save = 0; save = 0;
} }
if (!*chline || !strcmp(chline, "\n") || if (chwordpos <= 2 || (isset(HISTIGNORESPACE) && *chline == ' '))
(isset(HISTIGNORESPACE) && spaceflag))
save = 0; save = 0;
} }
if (flag & (HISTFLAG_DONE | HISTFLAG_RECALL)) { if (flag & (HISTFLAG_DONE | HISTFLAG_RECALL)) {
@ -1038,6 +1034,7 @@ hend(void)
*/ */
keepflags = he->flags & HIST_OLD; /* Avoid re-saving */ keepflags = he->flags & HIST_OLD; /* Avoid re-saving */
freehistdata(he, 0); freehistdata(he, 0);
curline.histnum = curhist;
} else { } else {
keepflags = 0; keepflags = 0;
he = prepnexthistent(); he = prepnexthistent();
@ -1073,7 +1070,7 @@ remhist(void)
if (hist_ring == &curline) if (hist_ring == &curline)
return; return;
if (!(histactive & HA_ACTIVE)) { if (!(histactive & HA_ACTIVE)) {
if (!(histactive & HA_JUNKED)) { if (!(histactive & HA_JUNKED) && curline.histnum == curhist) {
freehistnode((HashNode)hist_ring); freehistnode((HashNode)hist_ring);
histactive |= HA_JUNKED; histactive |= HA_JUNKED;
/* curhist-- is delayed until the next hbegin() */ /* curhist-- is delayed until the next hbegin() */