mirror of
git://git.code.sf.net/p/zsh/code
synced 2026-01-04 09:01:06 +01:00
32882 (cf. Augie Fackler 32879): correct reload of backslash-continuation lines from history, fix bad history write of events ending with backslashes
This commit is contained in:
parent
a8a59f9499
commit
b63ff19dbf
2 changed files with 19 additions and 2 deletions
|
|
@ -1,3 +1,10 @@
|
|||
2014-07-17 Barton E. Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 32882 (cf. Augie Fackler 32879): Src/hist.c: restore correct
|
||||
reload of backslash-continuation lines from history, broken by
|
||||
workers/30443 just before the zsh 5.0.0 release; fix bad history
|
||||
write of events ending with an even number of backslashes.
|
||||
|
||||
2014-07-17 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 32849: Completion/Linux/Command/_ss: new completion function
|
||||
|
|
|
|||
14
Src/hist.c
14
Src/hist.c
|
|
@ -2308,8 +2308,7 @@ readhistline(int start, char **bufp, int *bufsiz, FILE *in)
|
|||
}
|
||||
else {
|
||||
buf[len - 1] = '\0';
|
||||
if (len > 1 && buf[len - 2] == '\\' &&
|
||||
(len < 3 || buf[len - 3] != '\\')) {
|
||||
if (len > 1 && buf[len - 2] == '\\') {
|
||||
buf[--len - 1] = '\n';
|
||||
if (!feof(in))
|
||||
return readhistline(len, bufp, bufsiz, in);
|
||||
|
|
@ -2618,6 +2617,8 @@ savehistfile(char *fn, int err, int writeflags)
|
|||
|
||||
ret = 0;
|
||||
for (; he && he->histnum <= xcurhist; he = down_histent(he)) {
|
||||
int count_backslashes = 0;
|
||||
|
||||
if ((writeflags & HFILE_SKIPDUPS && he->node.flags & HIST_DUP)
|
||||
|| (writeflags & HFILE_SKIPFOREIGN && he->node.flags & HIST_FOREIGN)
|
||||
|| he->node.flags & HIST_TMPSTORE)
|
||||
|
|
@ -2649,9 +2650,18 @@ savehistfile(char *fn, int err, int writeflags)
|
|||
if (*t == '\n')
|
||||
if ((ret = fputc('\\', out)) < 0)
|
||||
break;
|
||||
if (*t == '\\')
|
||||
count_backslashes++;
|
||||
else
|
||||
count_backslashes = 0;
|
||||
if ((ret = fputc(*t, out)) < 0)
|
||||
break;
|
||||
}
|
||||
if (ret < 0)
|
||||
break;
|
||||
if (count_backslashes && (count_backslashes % 2 == 0))
|
||||
if ((ret = fputc(' ', out)) < 0)
|
||||
break;
|
||||
if (ret < 0 || (ret = fputc('\n', out)) < 0)
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue