mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-05-31 20:36:03 +02:00
42322 (tweaked): Fix interactive_comments history with just a coment.
Don't discard the line from the history merely because it produced no synactic words.
This commit is contained in:
parent
110b13e109
commit
758966502c
|
@ -1,3 +1,10 @@
|
|||
2018-01-24 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 42322 (tweaked): Src/hist.c, Src/zsh.h: don't discard a
|
||||
history line with just an interactive comment simply because
|
||||
there were no words, since the comment now doesn't produce
|
||||
words.
|
||||
|
||||
2018-01-23 Barton E. Schaefer <schaefer@zsh.org>
|
||||
|
||||
* Joey Pabalinas: 42313: Src/subst.c: avoid null-pointer deref
|
||||
|
|
13
Src/hist.c
13
Src/hist.c
|
@ -204,6 +204,13 @@ int hlinesz;
|
|||
|
||||
static zlong defev;
|
||||
|
||||
/*
|
||||
* Flag that we stopped reading line when we got to a comment,
|
||||
* but we want to keep it in the histofy even if there were no words
|
||||
* (i.e. the comment was the entire line).
|
||||
*/
|
||||
static int hist_keep_comment;
|
||||
|
||||
/* Remember the last line in the history file so we can find it again. */
|
||||
static struct histfile_stats {
|
||||
char *text;
|
||||
|
@ -258,6 +265,7 @@ hist_context_save(struct hist_stack *hs, int toplevel)
|
|||
hs->addtoline = addtoline;
|
||||
hs->hlinesz = hlinesz;
|
||||
hs->defev = defev;
|
||||
hs->hist_keep_comment = hist_keep_comment;
|
||||
/*
|
||||
* We save and restore the command stack with history
|
||||
* as it's visible to the user interactively, so if
|
||||
|
@ -303,6 +311,7 @@ hist_context_restore(const struct hist_stack *hs, int toplevel)
|
|||
addtoline = hs->addtoline;
|
||||
hlinesz = hs->hlinesz;
|
||||
defev = hs->defev;
|
||||
hist_keep_comment = hs->hist_keep_comment;
|
||||
if (cmdstack)
|
||||
zfree(cmdstack, CMDSTACKSZ);
|
||||
cmdstack = hs->cstack;
|
||||
|
@ -1462,7 +1471,7 @@ hend(Eprog prog)
|
|||
} else
|
||||
save = 0;
|
||||
}
|
||||
if (chwordpos <= 2)
|
||||
if (chwordpos <= 2 && !hist_keep_comment)
|
||||
save = 0;
|
||||
else if (should_ignore_line(prog))
|
||||
save = -1;
|
||||
|
@ -1565,6 +1574,7 @@ hend(Eprog prog)
|
|||
*/
|
||||
while (histsave_stack_pos > stack_pos)
|
||||
pophiststack();
|
||||
hist_keep_comment = 0;
|
||||
unqueue_signals();
|
||||
return !(flag & HISTFLAG_NOEXEC || errflag);
|
||||
}
|
||||
|
@ -1591,6 +1601,7 @@ ihwabort(void)
|
|||
{
|
||||
if (chwordpos%2)
|
||||
chwordpos--;
|
||||
hist_keep_comment = 1;
|
||||
}
|
||||
|
||||
/* add a word to the history List */
|
||||
|
|
Loading…
Reference in New Issue