diff options
author | Wayne Davison <wayned@users.sourceforge.net> | 2000-07-17 02:07:23 +0000 |
---|---|---|
committer | Wayne Davison <wayned@users.sourceforge.net> | 2000-07-17 02:07:23 +0000 |
commit | 656bce6bf5b146e0d1fbd85cfa52750022e4f759 (patch) | |
tree | 70c8dfadcfa8ee7d99d60294b73aee9e2b78437f | |
parent | 1f781087a8e9054c1b98ea4cd4441921e10983da (diff) | |
download | zsh-656bce6bf5b146e0d1fbd85cfa52750022e4f759.tar.gz zsh-656bce6bf5b146e0d1fbd85cfa52750022e4f759.tar.xz zsh-656bce6bf5b146e0d1fbd85cfa52750022e4f759.zip |
Fix the gethistent() function and enhanced the reliability of the
SHARE_HISTORY option.
-rw-r--r-- | Src/hist.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Src/hist.c b/Src/hist.c index 3bd4d296f..83f661c9b 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -882,21 +882,19 @@ gethistent(int ev, int nearmatch) if (ev - hist_ring->down->histnum < hist_ring->histnum - ev) { for (he = hist_ring->down; he->histnum < ev; he = he->down) ; - if (nearmatch == 0) { - if (he->histnum != ev) + if (he->histnum != ev) { + if (nearmatch == 0 + || (nearmatch < 0 && (he = up_histent(he)) == NULL)) return NULL; } - else if (nearmatch < 0 && (he = up_histent(he)) == NULL) - return NULL; } else { for (he = hist_ring; he->histnum > ev; he = he->up) ; - if (nearmatch == 0) { - if (he->histnum != ev) + if (he->histnum != ev) { + if (nearmatch == 0 + || (nearmatch > 0 && (he = down_histent(he)) == NULL)) return NULL; } - else if (nearmatch > 0 && (he = down_histent(he)) == NULL) - return NULL; } checkcurline(he); @@ -1060,7 +1058,7 @@ hend(void) zfree(chwords, chwordlen*sizeof(short)); chline = NULL; histactive = 0; - if (isset(SHAREHISTORY) || isset(INCAPPENDHISTORY)) + if (isset(SHAREHISTORY)? histfileIsLocked() : isset(INCAPPENDHISTORY)) savehistfile(hf, 0, HFILE_USE_OPTIONS | HFILE_FAST); unlockhistfile(hf); /* It's OK to call this even if we aren't locked */ return !(flag & HISTFLAG_NOEXEC || errflag); @@ -2067,6 +2065,13 @@ unlockhistfile(char *fn) } } +/**/ +int +histfileIsLocked(void) +{ + return lockhistct > 0; +} + /* Get the words in the current buffer. Using the lexer. */ /**/ |