mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-03 20:20:56 +02:00
25651: make getpermtext() output indentation more logical
This commit is contained in:
parent
fb67cd46ea
commit
d37f9672cb
7 changed files with 14 additions and 17 deletions
|
@ -1,5 +1,9 @@
|
|||
2008-09-11 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 25651: Src/builtin.c, Src/exec.c, Src/hashtable.c, Src/init.c,
|
||||
Src/text.c, Src/Modules/parameter.c: make indentation for code
|
||||
output by getpermtext() more logical.
|
||||
|
||||
* 25643: Doc/Zsh/builtins.yo, Src/exec.c: keep DEBUG and ZERR
|
||||
traps in subshells.
|
||||
|
||||
|
|
|
@ -390,7 +390,7 @@ getfunction(UNUSED(HashTable ht), const char *name, int dis)
|
|||
((shf->node.flags & PM_TAGGED) ? "Ut" : "U") :
|
||||
((shf->node.flags & PM_TAGGED) ? "t" : "")));
|
||||
} else {
|
||||
char *t = getpermtext(shf->funcdef, NULL), *n, *h;
|
||||
char *t = getpermtext(shf->funcdef, NULL, 1), *n, *h;
|
||||
|
||||
if (shf->funcdef->flags & EF_RUN) {
|
||||
n = nicedupstring(name);
|
||||
|
@ -455,7 +455,8 @@ scanfunctions(UNUSED(HashTable ht), ScanFunc func, int flags, int dis)
|
|||
((shf->node.flags & PM_TAGGED) ? "Ut" : "U") :
|
||||
((shf->node.flags & PM_TAGGED) ? "t" : "")));
|
||||
} else {
|
||||
char *t = getpermtext(((Shfunc) hn)->funcdef, NULL), *n;
|
||||
char *t = getpermtext(((Shfunc) hn)->funcdef, NULL, 1);
|
||||
char *n;
|
||||
|
||||
if (((Shfunc) hn)->funcdef->flags & EF_RUN) {
|
||||
n = nicedupstring(hn->nam);
|
||||
|
|
|
@ -5725,7 +5725,7 @@ bin_trap(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
|
|||
if (!siglists[sig])
|
||||
printf("trap -- '' %s\n", name);
|
||||
else {
|
||||
s = getpermtext(siglists[sig], NULL);
|
||||
s = getpermtext(siglists[sig], NULL, 0);
|
||||
printf("trap -- ");
|
||||
quotedzputs(s, stdout);
|
||||
printf(" %s\n", name);
|
||||
|
|
|
@ -1084,7 +1084,7 @@ execlist(Estate state, int dont_change_job, int exiting)
|
|||
noerrexit = 1;
|
||||
if (ltype & Z_SIMPLE) /* skip the line number */
|
||||
pc2++;
|
||||
pm = setsparam("ZSH_DEBUG_CMD", getpermtext(state->prog, pc2));
|
||||
pm = setsparam("ZSH_DEBUG_CMD", getpermtext(state->prog, pc2, 0));
|
||||
|
||||
exiting = donetrap;
|
||||
ret = lastval;
|
||||
|
|
|
@ -887,7 +887,7 @@ printshfuncnode(HashNode hn, int printflags)
|
|||
if (f->node.flags & PM_UNDEFINED)
|
||||
printf("%c undefined\n\t", hashchar);
|
||||
else
|
||||
t = getpermtext(f->funcdef, NULL);
|
||||
t = getpermtext(f->funcdef, NULL, 1);
|
||||
if (f->node.flags & PM_TAGGED)
|
||||
printf("%c traced\n\t", hashchar);
|
||||
if (!t) {
|
||||
|
|
|
@ -168,7 +168,7 @@ loop(int toplevel, int justonce)
|
|||
else
|
||||
addlinknode(args, "");
|
||||
addlinknode(args, dupstring(getjobtext(prog, NULL)));
|
||||
addlinknode(args, cmdstr = getpermtext(prog, NULL));
|
||||
addlinknode(args, cmdstr = getpermtext(prog, NULL, 0));
|
||||
|
||||
callhookfunc("preexec", args, 1, NULL);
|
||||
|
||||
|
|
14
Src/text.c
14
Src/text.c
|
@ -118,7 +118,7 @@ taddnl(void)
|
|||
|
||||
/**/
|
||||
mod_export char *
|
||||
getpermtext(Eprog prog, Wordcode c)
|
||||
getpermtext(Eprog prog, Wordcode c, int start_indent)
|
||||
{
|
||||
struct estate s;
|
||||
|
||||
|
@ -131,6 +131,7 @@ getpermtext(Eprog prog, Wordcode c)
|
|||
s.pc = c;
|
||||
s.strs = prog->strs;
|
||||
|
||||
tindent = start_indent;
|
||||
tnewlins = 1;
|
||||
tbuf = (char *)zalloc(tsiz = 32);
|
||||
tptr = tbuf;
|
||||
|
@ -162,6 +163,7 @@ getjobtext(Eprog prog, Wordcode c)
|
|||
s.pc = c;
|
||||
s.strs = prog->strs;
|
||||
|
||||
tindent = 0;
|
||||
tnewlins = 0;
|
||||
tbuf = NULL;
|
||||
tptr = jbuf;
|
||||
|
@ -245,16 +247,6 @@ gettext2(Estate state)
|
|||
int stack = 0;
|
||||
wordcode code;
|
||||
|
||||
/*
|
||||
* Hack for parsing "simple" format of function definitions.
|
||||
* In this case there is no surrounding context so the initial
|
||||
* indent should be zero.
|
||||
*/
|
||||
if (wc_code(*state->pc) == WC_FUNCDEF)
|
||||
tindent = 0;
|
||||
else
|
||||
tindent = 1;
|
||||
|
||||
while (1) {
|
||||
if (stack) {
|
||||
if (!(s = tstack))
|
||||
|
|
Loading…
Reference in a new issue