1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-06-10 17:26:08 +02:00

Wayne: fix for print -s when called from widget; added lines are not immediately available, though (11171)

This commit is contained in:
Sven Wischnowsky 2000-05-05 07:42:36 +00:00
parent c05f118fc2
commit c844ad8712
3 changed files with 49 additions and 26 deletions

View File

@ -1,5 +1,9 @@
2000-05-05 Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
* Wayne: 11171: Src/builtin.c, Src/hist.c: fix for print -s when
called from widget; added lines are not immediately available,
though
* 11172: Src/Zle/computil.c: fix for completion arguments of
options, don't use all of them at once

View File

@ -2777,7 +2777,7 @@ bin_print(char *name, char **args, char *ops, int func)
int nwords = 0, nlen, iwords;
char **pargs = args;
ent = prepnexthistent(zleactive ? curhist++ : ++curhist);
ent = prepnexthistent();
while (*pargs++)
nwords++;
if ((ent->nwords = nwords)) {

View File

@ -704,6 +704,36 @@ nohwe(void)
{
}
/* these functions handle adding/removing curline to/from the hist_ring */
static void
linkcurline(void)
{
if (!hist_ring)
hist_ring = curline.up = curline.down = &curline;
else {
curline.up = hist_ring;
curline.down = hist_ring->down;
hist_ring->down = hist_ring->down->up = &curline;
hist_ring = &curline;
}
curline.histnum = ++curhist;
}
static void
unlinkcurline(void)
{
curline.up->down = curline.down;
curline.down->up = curline.up;
if (hist_ring == &curline) {
if (!histlinect)
hist_ring = NULL;
else
hist_ring = curline.up;
}
curhist--;
}
/* initialize the history mechanism */
/**/
@ -745,15 +775,7 @@ hbegin(int dohist)
if (interact && isset(SHINSTDIN) && !strin) {
histactive = HA_ACTIVE;
attachtty(mypgrp);
if (!hist_ring)
hist_ring = curline.up = curline.down = &curline;
else {
curline.up = hist_ring;
curline.down = hist_ring->down;
hist_ring->down = hist_ring->down->up = &curline;
hist_ring = &curline;
}
curline.histnum = ++curhist;
linkcurline();
defev = addhistnum(curhist, -1, HIST_FOREIGN);
} else
histactive = HA_ACTIVE | HA_NOINC;
@ -883,9 +905,13 @@ gethistent(int ev, int nearmatch)
/**/
Histent
prepnexthistent(int histnum)
prepnexthistent(void)
{
Histent he;
int curline_in_ring = hist_ring == &curline;
if (curline_in_ring)
unlinkcurline();
if (histlinect < histsiz) {
he = (Histent)zcalloc(sizeof *he);
@ -920,8 +946,10 @@ prepnexthistent(int histnum)
}
freehistdata(hist_ring = he, 0);
}
hist_ring->histnum = histnum;
return hist_ring;
he->histnum = ++curhist;
if (curline_in_ring)
linkcurline();
return he;
}
/* say we're done using the history mechanism */
@ -937,17 +965,8 @@ hend(void)
"BUG: chline is NULL in hend()");
if (histdone & HISTFLAG_SETTY)
settyinfo(&shttyinfo);
if (!(histactive & HA_NOINC)) {
curline.up->down = curline.down;
curline.down->up = curline.up;
if (hist_ring == &curline) {
if (!histlinect)
hist_ring = NULL;
else
hist_ring = curline.up;
}
curhist--;
}
if (!(histactive & HA_NOINC))
unlinkcurline();
if (histactive & (HA_NOSTORE|HA_NOINC)) {
zfree(chline, hlinesz);
zfree(chwords, chwordlen*sizeof(short));
@ -1023,7 +1042,7 @@ hend(void)
freehistdata(he, 0);
} else {
keepflags = 0;
he = prepnexthistent(++curhist);
he = prepnexthistent();
}
he->text = ztrdup(chline);
@ -1777,7 +1796,7 @@ readhistfile(char *fn, int err, int readflags)
lasthist.stim = stim;
}
he = prepnexthistent(++curhist);
he = prepnexthistent();
he->text = ztrdup(pt);
he->flags = newflags;
if ((he->stim = stim) == 0)