zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: pws-25: xtrace for case and for
@ 1999-07-08 14:36 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 1999-07-08 14:36 UTC (permalink / raw)
  To: Zsh hackers list

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@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-07-08 15:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-08 14:36 PATCH: pws-25: xtrace for case and for Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).