POV-Ray : Newsgroups : povray.bugreports : Povray BUG: Macro from Within While Loop Server Time
22 Nov 2024 19:41:38 EST (-0500)
  Povray BUG: Macro from Within While Loop (Message 1 to 5 of 5)  
From: Nigel Stewart
Subject: Povray BUG: Macro from Within While Loop
Date: 30 Mar 1999 00:50:39
Message: <922772840.463956541@news.povray.org>
Here is a bugreport crossposted to povray.programming,
povray.bugreports and directly to Chris Young.  It is a
bit hard to reproduce, but if you observe something 
similar on a platform other than Linux, please let me
know.

Description of the problem:

Sometimes, povray will complain the the error message
"#while loop didn't end in file where it started."  This is
observed in a #while loop containing macros.

Analysis:

I have observed this problem in the IMP POV povray
binary, based on POV 3.1e, and the official Povteam 
Linux povray binary of POV 3.1e.  

Based on debugging, it is related to the way POV opens 
and closes files to execute a macro in a file other than 
the one currently being parsed.  For some reason, the
current file is closed (tokenize.c:3272 Invoke_Macro )
and re-opened (tokenize.c:3214 Return_From_Macro)
before parsing continues after the macro expansion.
The while loop parser checks if the corresponding
#while and #end tokens are in the same file 
(tokenize.c:2382 Parse_Directive), based on
file-pointers.  The trouble is, that the "old" file pointer
used for comparison has since been fclose'd, and
may have been recycled for another file.  Most of the time,
fclose recycles the identical file pointer, but sometimes
it is a different file-pointer (pointing to the same file)
and povray decides it's thinking about different files.
This test is implemented as follows:

         case WHILE_COND:
           if (Cond_Stack[CS_Index].While_File != Data_File->File)
           {
              Error("#while loop didn't end in file where it started.");
           }
 
Fix:

Removing the above if block prevents POV from 
falsly reporting the while loop problem.  The check
should be re-implemented some other way, perhaps
by reconsidering the close/open behaviour for macro
expansion.

For further information, talk to nig### [at] eisanetau


-- 
Nigel Stewart (nig### [at] eisanetau)  http://www.eisa.net.au/~nigels/
Postgrad Research Student, RMIT University, Melbourne, Australia
All extremists should be taken out and shot.


Post a reply to this message

From: Nieminen Mika
Subject: Re: Povray BUG: Macro from Within While Loop
Date: 30 Mar 1999 12:14:44
Message: <37010684.0@news.povray.org>
In povray.programming Nigel Stewart <nigels> wrote:
: Sometimes, povray will complain the the error message
: "#while loop didn't end in file where it started."  This is
: observed in a #while loop containing macros.

  Can you post a short example pov-code?

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Nigel Stewart
Subject: Re: Povray BUG: Macro from Within While Loop
Date: 30 Mar 1999 20:08:22
Message: <922842300.1649640683@news.povray.org>
>: Sometimes, povray will complain the the error message
>: "#while loop didn't end in file where it started."  This is
>: observed in a #while loop containing macros.
>
>  Can you post a short example pov-code?

This is difficult because it depends on the behavior of
fopen, which varies from platform to platform.  It is possible
to make it more frequent by manipulating the source, but 
I don't think I'll be able to come up with a POV file to 
reproduce it reliably on other binaries.  Essentially, it is 
tied to manner in which fopen recycles file pointers, often 
it will use the last one that was free'd, but sometimes 
(on Linux anyway) it doesn't...


Post a reply to this message

From: Douglas Partridge
Subject: Re: Povray BUG: Macro from Within While Loop
Date: 31 Mar 1999 01:43:24
Message: <3701C3F5.11C7514F@lawson.appcomp.utas.edu.au>
I have been having a similar problem (with the linux version as well),
although my c programming skills leave quite a lot to be desired, so if you
could post the file and line numbers to remove and what affect this will
have it would be good.


Post a reply to this message

From: Nigel Stewart
Subject: Re: Povray BUG: Macro from Within While Loop
Date: 31 Mar 1999 09:09:28
Message: <922889132.882806098@news.povray.org>
>I have been having a similar problem (with the linux version as well),
>although my c programming skills leave quite a lot to be desired, so if you
>could post the file and line numbers to remove and what affect this will
>have it would be good.

From the file  tokenize.c, comment out the following block...
(It's _near_ line 2382, in the function Parse_Directive, search on 
"While", it should be the second or third....

         case WHILE_COND:
/*
           if (Cond_Stack[CS_Index].While_File != Data_File->File)
           {
              Error("#while loop didn't end in file where it started.");
           }
*/

And please let us know if it solves your problem too!

 
-- 
Nigel Stewart (nig### [at] eisanetau)  http://www.eisa.net.au/~nigels/
Postgrad Research Student, RMIT University, Melbourne, Australia
All extremists should be taken out and shot.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.