Skip to content
Browse files

Fix hist_nearend()

The original code, prior to the fix for issue #1271, called sfreserve()
with just the SF_LOCKR. While fixing the core issue of issue #1271 I
noticed the buffer did not have a read/write mode. Which is wrong. What
I didn't realize was that is equivalent to read+write. I incorrectly
included SF_WRITE rather than SF_RDWR.

Fixes #1432
  • Loading branch information...
krader1961 committed Nov 8, 2019
1 parent a205e5a commit a3c2dfbbbdb05f1cc9344b5cd914ac0da268570c
Showing with 4 additions and 2 deletions.
  1. +3 −1
  2. +1 −1 src/cmd/ksh93/edit/history.c
@@ -1,4 +1,4 @@
# ksh git head (version TBD, this is a work in progress)
# ksh 2020.1.0 (this is a work in progress)

## Deprecations

@@ -9,6 +9,8 @@

## Notable fixes and improvements

- Fix `history` command behavior when the *~/.sh_history* file has
specific content (issue #1432).
- A ${.sh.install_prefix}/config.ksh file will be sourced if it exists. It is
the first config file loaded by every ksh instance. It is loaded regardless
of whether the shell is interactive, login, or neither.
@@ -360,7 +360,7 @@ static_fn int hist_nearend(History_t *hp, Sfio_t *iop, off_t size) {
// Skip to marker command and return the number. Numbering commands occur after a null and begin
// with HIST_CMDNO.
while (true) {
cp = buff = (unsigned char *)sfreserve(iop, SF_UNBOUND, SF_LOCKR | SF_WRITE);
cp = buff = (unsigned char *)sfreserve(iop, SF_UNBOUND, SF_LOCKR | SF_RDWR);
if (!cp) break;

n = sfvalue(iop);

0 comments on commit a3c2dfb

Please sign in to comment.
You can’t perform that action at this time.