From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5215 invoked from network); 8 Jul 1999 15:05:54 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 8 Jul 1999 15:05:54 -0000 Received: (qmail 13020 invoked by alias); 8 Jul 1999 15:05:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7046 Received: (qmail 13013 invoked from network); 8 Jul 1999 15:05:42 -0000 Message-Id: <9907081436.AA37605@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: PATCH: pws-25: xtrace for case and for Date: Thu, 08 Jul 1999 16:36:53 +0200 From: Peter Stephenson 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 ()'. 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 Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy