You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by bu...@bugzilla.spamassassin.org on 2006/04/03 12:23:29 UTC

[Bug 4829] [review] Using each to iterate through arrays then exiting early causes problems

http://issues.apache.org/SpamAssassin/show_bug.cgi?id=4829





------- Additional Comments From jm@jmason.org  2006-04-03 11:23 -------
IMO that fix is a bit kludgy!  sorry Theo ;) but +1 anyway, since it does the job.

Here's an *addition* -- calling "keys %t" to reset the iterator after
the loop.  I think this is cleaner and less brittle, since it doesn't rely on
completing a full set of iterations to clear the iterator state.

as you can see, it works:

  perl -e '%t=map{$_=>1}qw/1 2 3/; while(($k,$v)=each %t){print "1: $k\n";
last;} keys %t; while(($k,$v)=each %t){print "2: $k\n";}'

I'll attach the patch, anyway, but I don't think it's a biggie if this gets into
3.1.2 as well as 3.2.0, since it's just a cleanup rather than the more important
bugfix that Theo's patch represents.  it's cumulative on top of that patch btw.

btw I also checked for other cases where this can cause trouble elsewhere in the
code, looks like we're clear.




------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.