Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: pws-25: xtrace for case and for
- X-seq: zsh-workers 7046
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: pws-25: xtrace for case and for
- Date: Thu, 08 Jul 1999 16:36:53 +0200
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
This was the last missing part on my todo list (we finished the major ones
some time ago, we're now onto minor bits) which didn't involve major bug
probes or new features, so I might as well get it out of the way.
It gives xtrace output for for and case statements. For arithemetic for
statements, all the expressions to be evaluated are printed; for other for
statements, the assigment of the loop variable is printed as a straight
assignment. For case statements, each test is printed with the message
`case <word> (<pattern>)'. A minor problem is that case statements don't
keep track of line numbers, so it will always show up as the line for the
original `case'.
Some of this xtrace output stuff might be neater as subroutines.
--- Src/loop.c.cf Fri Jun 25 09:23:43 1999
+++ Src/loop.c Thu Jul 8 16:33:59 1999
@@ -57,6 +57,13 @@
if (node->condition) {
str = dupstring(node->name);
singsub(&str);
+ if (isset(XTRACE)) {
+ char *str2 = dupstring(str);
+ untokenize(str2);
+ printprompt4();
+ fprintf(stderr, "%s\n", str2);
+ fflush(stderr);
+ }
if (!errflag)
matheval(str);
if (errflag)
@@ -79,9 +86,14 @@
if (!errflag) {
while (iblank(*str))
str++;
- if (*str)
+ if (*str) {
+ if (isset(XTRACE)) {
+ printprompt4();
+ fprintf(stderr, "%s\n", str);
+ fflush(stderr);
+ }
val = matheval(str);
- else
+ } else
val = 1;
}
if (errflag) {
@@ -95,6 +107,11 @@
} else {
if (!args || !(str = (char *) ugetnode(args)))
break;
+ if (isset(XTRACE)) {
+ printprompt4();
+ fprintf(stderr, "%s=%s\n", node->name, str);
+ fflush(stderr);
+ }
setsparam(node->name, ztrdup(str));
}
execlist(node->list, 1,
@@ -107,6 +124,11 @@
}
if (node->condition && !errflag) {
str = dupstring(node->advance);
+ if (isset(XTRACE)) {
+ printprompt4();
+ fprintf(stderr, "%s\n", str);
+ fflush(stderr);
+ }
singsub(&str);
if (!errflag)
matheval(str);
@@ -410,6 +432,13 @@
while (*p) {
char *pat = dupstring(*p + 1);
singsub(&pat);
+ if (isset(XTRACE)) {
+ char *pat2 = dupstring(pat);
+ untokenize(pat2);
+ printprompt4();
+ fprintf(stderr, "case %s (%s)\n", word, pat2);
+ fflush(stderr);
+ }
if (matchpat(word, pat)) {
do {
execlist(*l++, 1, **p == ';' && (flags & CFLAG_EXEC));
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
Messages sorted by:
Reverse Date,
Date,
Thread,
Author