zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: Re: `foo=foo; (( foo ))' => infinite recursion
Date: Wed, 15 Mar 2000 10:06:57 +0100 (MET)	[thread overview]
Message-ID: <200003150906.KAA14529@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Tue, 14 Mar 2000 17:26:28 +0000


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


             reply	other threads:[~2000-03-15  9:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-15  9:06 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-03-14  8:05 Sven Wischnowsky
2000-03-14 17:26 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200003150906.KAA14529@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).