From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7717 invoked from network); 15 Mar 2000 09:07:08 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 Mar 2000 09:07:07 -0000 Received: (qmail 26354 invoked by alias); 15 Mar 2000 09:07:01 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10143 Received: (qmail 26342 invoked from network); 15 Mar 2000 09:07:00 -0000 Date: Wed, 15 Mar 2000 10:06:57 +0100 (MET) Message-Id: <200003150906.KAA14529@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Tue, 14 Mar 2000 17:26:28 +0000 Subject: Re: PATCH: Re: `foo=foo; (( foo ))' => infinite recursion Bart Schaefer wrote: > On Mar 14, 9:05am, Sven Wischnowsky wrote: > } Subject: PATCH: Re: `foo=foo; (( foo ))' => infinite recursion > } > } > } Bart Schaefer wrote: > } > } > On Mar 13, 10:34am, Sven Wischnowsky wrote: > } > } Subject: Re: `foo=foo; (( foo ))' => infinite recursion > } > } > } > } What really irritated me was that getnumvalue() called matheval(). > } > > } > Maybe just a recursion counter with a reasonably large limit? > } > } Ok. > > Something is still too aggressive: > > zagzig% foo='x > 0 ? (--x, y += foo) : 1' > zagzig% x=3 > zagzig% echo $[foo] > zsh: math recursion limit exceeded > > `foo' should have been evaluated at most three times, no? > > Maybe there's no real reason to fix this ... Ugh. Evaluating `.. ? .. : ..' or `.. || ..' or `.. && ..' set noeval for the unused part but it still called getnparam() and the like. Bye Sven diff -ru ../z.old/Src/init.c Src/init.c --- ../z.old/Src/init.c Tue Mar 14 16:50:21 2000 +++ Src/init.c Wed Mar 15 10:04:53 2000 @@ -568,6 +568,9 @@ init_eprog(); + zero_mnumber.type = MN_INTEGER; + zero_mnumber.u.l = 0; + getkeyptr = NULL; lineno = 1; diff -ru ../z.old/Src/math.c Src/math.c --- ../z.old/Src/math.c Tue Mar 14 16:50:22 2000 +++ Src/math.c Wed Mar 15 10:04:07 2000 @@ -37,6 +37,11 @@ /**/ int noeval; +/* integer zero */ + +/**/ +mnumber zero_mnumber; + /* last input base we used */ /**/ @@ -1018,13 +1023,13 @@ push(yyval, NULL); break; case ID: - push(getnparam(yylval), yylval); + push((noeval ? zero_mnumber : getnparam(yylval)), yylval); break; case CID: - push(getcvar(yylval), yylval); + push((noeval ? zero_mnumber : getcvar(yylval)), yylval); break; case FUNC: - push(callmathfunc(yylval), yylval); + push((noeval ? zero_mnumber : callmathfunc(yylval)), yylval); break; case M_INPAR: mathparse(TOPPREC); -- Sven Wischnowsky wischnow@informatik.hu-berlin.de