1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-03 10:21:46 +02:00

Wayne: Fix two history bugs that were causing the

failure of `print -s'.
This commit is contained in:
Bart Schaefer 2000-05-30 03:43:27 +00:00
parent 76868bdc6a
commit 8564aa5c0d
5 changed files with 30 additions and 23 deletions

View file

@ -1,5 +1,10 @@
2000-05-29 Bart Schaefer <schaefer@zsh.org>
* Wayne Davison: 11641: Src/hist.c, Src/Modules/parameter.c,
Src/Zle/compctl.c, Src/Zle/zle_main.c: Make sure `curline' has
sane values at more points during history manipulation, so that
"print -s" from a ZLE widget doesn't cause confusion.
* unposted: Completion/Core/_path_files: Add a comment to explain
the change made in 11635.

View file

@ -1059,7 +1059,7 @@ scanpmhistory(HashTable ht, ScanFunc func, int flags)
{
struct param pm;
int i = addhistnum(curhist, -1, HIST_FOREIGN);
Histent he = quietgethistent(i, GETHIST_UPWARD);
Histent he = gethistent(i, GETHIST_UPWARD);
char buf[40];
pm.flags = PM_SCALAR | PM_READONLY;
@ -1096,7 +1096,7 @@ histwgetfn(Param pm)
LinkList l = newlinklist(), ll;
LinkNode n;
int i = addhistnum(curhist, -1, HIST_FOREIGN), iw;
Histent he = quietgethistent(i, GETHIST_UPWARD);
Histent he = gethistent(i, GETHIST_UPWARD);
ll = bufferwords(NULL, NULL, NULL);
for (n = firstnode(ll); n; incnode(n))

View file

@ -3688,7 +3688,7 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
Patprog pprogc = NULL;
char *e, *h, hpatsav;
int i = addhistnum(curhist,-1,HIST_FOREIGN), n = cc->hnum;
Histent he = quietgethistent(i, GETHIST_UPWARD);
Histent he = gethistent(i, GETHIST_UPWARD);
/* Parse the pattern, if it isn't the null string. */
if (*(cc->hpat)) {

View file

@ -641,8 +641,11 @@ execzlefunc(Thingy func, char **args)
if(!(wflags & ZLE_LASTCOL))
lastcol = -1;
if (wflags & WIDGET_NCOMP) {
int atcurhist = histline == curhist;
compwidget = w;
ret = completecall(args);
if (atcurhist)
histline = curhist;
} else
ret = w->u.fn(args);
if (!(wflags & ZLE_NOTCOMMAND))

View file

@ -853,6 +853,7 @@ movehistent(Histent he, int n, int xflags)
if (!(he->flags & xflags))
n--;
}
checkcurline(he);
return he;
}
@ -880,27 +881,26 @@ gethistent(int ev, int nearmatch)
return NULL;
if (ev - hist_ring->down->histnum < hist_ring->histnum - ev) {
for (he = hist_ring->down; he->histnum <= ev; he = he->down) {
if (he->histnum == ev)
return he;
for (he = hist_ring->down; he->histnum < ev; he = he->down) ;
if (nearmatch == 0) {
if (he->histnum != ev)
return NULL;
}
if (nearmatch < 0)
return up_histent(he);
if (nearmatch > 0)
return he;
else if (nearmatch < 0 && (he = up_histent(he)) == NULL)
return NULL;
}
else {
for (he = hist_ring; he->histnum >= ev; he = he->up) {
if (he->histnum == ev)
return he;
for (he = hist_ring; he->histnum > ev; he = he->up) ;
if (nearmatch == 0) {
if (he->histnum != ev)
return NULL;
}
if (nearmatch < 0)
return he;
if (nearmatch > 0)
return down_histent(he);
else if (nearmatch > 0 && (he = down_histent(he)) == NULL)
return NULL;
}
return NULL;
checkcurline(he);
return he;
}
/**/
@ -1452,22 +1452,21 @@ convamps(char *out, char *in, int inlen)
}
/**/
mod_export Histent
quietgethistent(int ev, int nearmatch)
mod_export void
checkcurline(Histent he)
{
if (ev == curhist && (histactive & HA_ACTIVE)) {
if (he->histnum == curhist && (histactive & HA_ACTIVE)) {
curline.text = chline;
curline.nwords = chwordpos/2;
curline.words = chwords;
}
return gethistent(ev, nearmatch);
}
/**/
mod_export Histent
quietgethist(int ev)
{
return quietgethistent(ev, GETHIST_EXACT);
return gethistent(ev, GETHIST_EXACT);
}
/**/