Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix unshared history lines
- X-seq: zsh-workers 12265
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Zsh Workers <zsh-workers@xxxxxxxxxxxxxx>
- Subject: PATCH: fix unshared history lines
- Date: Sun, 16 Jul 2000 19:05:05 -0700 (PDT)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
The following patch fixes the breakage in gethistent() that I managed
to introduce back on May 30th. It also ensures that if SHARE_HISTORY
is set, we only save our outstanding history lines if we successfully
locked the history file back before the readhistfile() call (i.e. if
the lock is in place to encompass both operations, not just the one).
This ensures that we don't fail to read in some history events from a
sibling process.
..wayne..
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: Src/hist.c
@@ -882,21 +882,19 @@
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 @@
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);
@@ -2065,6 +2063,13 @@
unlink(lockfile);
free(lockfile);
}
+}
+
+/**/
+int
+histfileIsLocked(void)
+{
+ return lockhistct > 0;
}
/* Get the words in the current buffer. Using the lexer. */
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Messages sorted by:
Reverse Date,
Date,
Thread,
Author