mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
20149: improve prompt-reset code
20150: commit ancient memory leak fix(?) in completion
This commit is contained in:
parent
f63b677f53
commit
86ae90bc1c
8 changed files with 40 additions and 24 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2004-07-11 Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
|
||||
|
||||
* 20150: Src/Zle/compresult.c: repost of ancient attempt
|
||||
to fix memory leak in completion.
|
||||
|
||||
* 20149: Doc/Zsh/zle.yo, Src/init.c, Src/input.c, Src/loop.c,
|
||||
Src/zsh.h, Src/Zle/zle_main.c: alter users/7650 so that
|
||||
prompt variable is always reread; fixes bug that if PS1
|
||||
was altered the prompt string was invalid.
|
||||
|
||||
2004-07-07 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 20142: Test/A06assign.ztst: add test for bug fixed in
|
||||
|
@ -26,8 +36,9 @@
|
|||
|
||||
2004-07-01 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 7650: Doc/Zsh/zle.yo, Src/Zle/iwidgets.list, Src/Zle/zle_main.c:
|
||||
new zle widget prompt-reset redisplays screen with prompt updated.
|
||||
* users/7650: Doc/Zsh/zle.yo, Src/Zle/iwidgets.list,
|
||||
Src/Zle/zle_main.c: new zle widget prompt-reset redisplays screen
|
||||
with prompt updated.
|
||||
|
||||
2004-06-30 Peter Stephenson <pws@csr.com>
|
||||
|
||||
|
|
|
@ -1740,13 +1740,13 @@ Redisplays the edit buffer.
|
|||
tindex(reset-prompt)
|
||||
item(tt(reset-prompt) (unbound) (unbound) (unbound))(
|
||||
Force the prompts on both the left and right of the screen to be
|
||||
re-expanded, then redisplay the edit buffer. Note that this
|
||||
does not reflect changes to the prompt variables themselves, only changes
|
||||
re-expanded, then redisplay the edit buffer. This
|
||||
reflects changes both to the prompt variables themselves and changes
|
||||
in the expansion of the values (for example, changes in time or
|
||||
directory, or changes to the value of variables referred to by the
|
||||
prompt).
|
||||
|
||||
Otherwise, the prompt is only expaned each time zle starts, and
|
||||
Otherwise, the prompt is only expanded each time zle starts, and
|
||||
when the display as been interrupted by output from another part of the
|
||||
shell (such as a job notification) which causes the command line to be
|
||||
reprinted.
|
||||
|
|
|
@ -1768,6 +1768,9 @@ calclist(int showall)
|
|||
g->width += (max - (g->width * g->cols - CM_SPACE)) / g->cols;
|
||||
}
|
||||
}
|
||||
else
|
||||
for (g = amatches; g; g = g->next)
|
||||
zfree(g->widths, 0);
|
||||
listdat.valid = 1;
|
||||
listdat.hidden = hidden;
|
||||
listdat.nlist = nlist;
|
||||
|
|
|
@ -150,7 +150,7 @@ int kungetct;
|
|||
/**/
|
||||
mod_export char *zlenoargs[1] = { NULL };
|
||||
|
||||
static char *raw_lp, *raw_rp;
|
||||
static char **raw_lp, **raw_rp;
|
||||
|
||||
#ifdef FIONREAD
|
||||
static int delayzsetterm;
|
||||
|
@ -742,7 +742,7 @@ zlecore(void)
|
|||
|
||||
/**/
|
||||
unsigned char *
|
||||
zleread(char *lp, char *rp, int flags, int context)
|
||||
zleread(char **lp, char **rp, int flags, int context)
|
||||
{
|
||||
unsigned char *s;
|
||||
int old_errno = errno;
|
||||
|
@ -761,7 +761,8 @@ zleread(char *lp, char *rp, int flags, int context)
|
|||
char *pptbuf;
|
||||
int pptlen;
|
||||
|
||||
pptbuf = unmetafy(promptexpand(lp, 0, NULL, NULL), &pptlen);
|
||||
pptbuf = unmetafy(promptexpand(lp ? *lp : NULL, 0, NULL, NULL),
|
||||
&pptlen);
|
||||
write(2, (WRITE_ARG_2_T)pptbuf, pptlen);
|
||||
free(pptbuf);
|
||||
return (unsigned char *)shingetline();
|
||||
|
@ -788,10 +789,10 @@ zleread(char *lp, char *rp, int flags, int context)
|
|||
eofsent = 0;
|
||||
resetneeded = 0;
|
||||
raw_lp = lp;
|
||||
lpromptbuf = promptexpand(lp, 1, NULL, NULL);
|
||||
lpromptbuf = promptexpand(lp ? *lp : NULL, 1, NULL, NULL);
|
||||
pmpt_attr = txtchange;
|
||||
raw_rp = rp;
|
||||
rpromptbuf = promptexpand(rp, 1, NULL, NULL);
|
||||
rpromptbuf = promptexpand(rp ? *rp : NULL, 1, NULL, NULL);
|
||||
rpmpt_attr = txtchange;
|
||||
free_prepostdisplay();
|
||||
|
||||
|
@ -1169,7 +1170,7 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func))
|
|||
if (OPT_ISSET(ops,'h'))
|
||||
hbegin(2);
|
||||
isfirstln = OPT_ISSET(ops,'e');
|
||||
t = (char *) zleread(p1, p2, OPT_ISSET(ops,'h') ? ZLRF_HISTORY : 0,
|
||||
t = (char *) zleread(&p1, &p2, OPT_ISSET(ops,'h') ? ZLRF_HISTORY : 0,
|
||||
ZLCON_VARED);
|
||||
if (OPT_ISSET(ops,'h'))
|
||||
hend(NULL);
|
||||
|
@ -1315,9 +1316,9 @@ void
|
|||
reexpandprompt(void)
|
||||
{
|
||||
free(lpromptbuf);
|
||||
lpromptbuf = promptexpand(raw_lp, 1, NULL, NULL);
|
||||
lpromptbuf = promptexpand(raw_lp ? *raw_lp : NULL, 1, NULL, NULL);
|
||||
free(rpromptbuf);
|
||||
rpromptbuf = promptexpand(raw_rp, 1, NULL, NULL);
|
||||
rpromptbuf = promptexpand(raw_rp ? *raw_rp : NULL, 1, NULL, NULL);
|
||||
}
|
||||
|
||||
/**/
|
||||
|
|
|
@ -1148,7 +1148,7 @@ mod_export ZleVoidIntFn zlesetkeymapptr = noop_function_int;
|
|||
|
||||
/**/
|
||||
unsigned char *
|
||||
autoload_zleread(char *lp, char *rp, int ha, int con)
|
||||
autoload_zleread(char **lp, char **rp, int ha, int con)
|
||||
{
|
||||
zlereadptr = fallback_zleread;
|
||||
if (load_module("zsh/zle"))
|
||||
|
@ -1158,12 +1158,12 @@ autoload_zleread(char *lp, char *rp, int ha, int con)
|
|||
|
||||
/**/
|
||||
mod_export unsigned char *
|
||||
fallback_zleread(char *lp, UNUSED(char *rp), UNUSED(int ha), UNUSED(int con))
|
||||
fallback_zleread(char **lp, UNUSED(char **rp), UNUSED(int ha), UNUSED(int con))
|
||||
{
|
||||
char *pptbuf;
|
||||
int pptlen;
|
||||
|
||||
pptbuf = unmetafy(promptexpand(lp, 0, NULL, NULL), &pptlen);
|
||||
pptbuf = unmetafy(promptexpand(lp ? *lp : NULL, 0, NULL, NULL), &pptlen);
|
||||
write(2, (WRITE_ARG_2_T)pptbuf, pptlen);
|
||||
free(pptbuf);
|
||||
|
||||
|
|
13
Src/input.c
13
Src/input.c
|
@ -222,21 +222,21 @@ ingetc(void)
|
|||
static int
|
||||
inputline(void)
|
||||
{
|
||||
char *ingetcline, *ingetcpmptl = NULL, *ingetcpmptr = NULL;
|
||||
char *ingetcline, **ingetcpmptl = NULL, **ingetcpmptr = NULL;
|
||||
int context = ZLCON_LINE_START;
|
||||
|
||||
/* If reading code interactively, work out the prompts. */
|
||||
if (interact && isset(SHINSTDIN)) {
|
||||
if (!isfirstln) {
|
||||
ingetcpmptl = prompt2;
|
||||
ingetcpmptl = &prompt2;
|
||||
if (rprompt2)
|
||||
ingetcpmptr = rprompt2;
|
||||
ingetcpmptr = &rprompt2;
|
||||
context = ZLCON_LINE_CONT;
|
||||
}
|
||||
else {
|
||||
ingetcpmptl = prompt;
|
||||
ingetcpmptl = &prompt;
|
||||
if (rprompt)
|
||||
ingetcpmptr = rprompt;
|
||||
ingetcpmptr = &rprompt;
|
||||
}
|
||||
}
|
||||
if (!(interact && isset(SHINSTDIN) && SHTTY != -1 && isset(USEZLE))) {
|
||||
|
@ -255,7 +255,8 @@ inputline(void)
|
|||
*/
|
||||
char *pptbuf;
|
||||
int pptlen;
|
||||
pptbuf = unmetafy(promptexpand(ingetcpmptl, 0, NULL, NULL), &pptlen);
|
||||
pptbuf = unmetafy(promptexpand(ingetcpmptl ? *ingetcpmptl : NULL,
|
||||
0, NULL, NULL), &pptlen);
|
||||
write(2, (WRITE_ARG_2_T)pptbuf, pptlen);
|
||||
free(pptbuf);
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ execselect(Estate state, UNUSED(int do_exec))
|
|||
int oef = errflag;
|
||||
|
||||
isfirstln = 1;
|
||||
str = (char *)zleread(prompt3, NULL, 0, ZLCON_SELECT);
|
||||
str = (char *)zleread(&prompt3, NULL, 0, ZLCON_SELECT);
|
||||
if (errflag)
|
||||
str = NULL;
|
||||
errflag = oef;
|
||||
|
|
|
@ -1800,7 +1800,7 @@ typedef int (*CompctlReadFn) _((char *, char **, Options, char *));
|
|||
|
||||
typedef void (*ZleVoidFn) _((void));
|
||||
typedef void (*ZleVoidIntFn) _((int));
|
||||
typedef unsigned char * (*ZleReadFn) _((char *, char *, int, int));
|
||||
typedef unsigned char * (*ZleReadFn) _((char **, char **, int, int));
|
||||
|
||||
/***************************************/
|
||||
/* Hooks in core. */
|
||||
|
|
Loading…
Reference in a new issue