[Orca-checkins] r331 - trunk/orca/lib/Orca
Blair Zajac
blair at orcaware.com
Mon May 31 18:47:16 PDT 2004
Author: blair
Date: Mon May 31 18:45:23 2004
New Revision: 331
Modified:
trunk/orca/lib/Orca/SourceFile.pm
Log:
Fix a bug introduced in revision 310. Bug found by and solution
suggested by Michael Podhorodecki <Michael.Podhorodecki at sensis.com.au>.
* lib/Orca/SourceFile.pm
(deep_clone_plot):
Take an additional argument if the creates hash key should be
restored in the new plot.
In an array context, return both the new plot and the creates hash
reference. In scalar context, return only the new plot.
(add_plots):
Change all calls to deep_clone_plot() to use the new argument.
Fix the bug introduced in revision 310. In the second case with
more than one data in the plot, do not immediately restore the
creates hash key when calling deep_clone_plot(). Instead,
restore it after Data::Dump->Dump is called to avoid the
recursion problem.
Modified: trunk/orca/lib/Orca/SourceFile.pm
==============================================================================
--- trunk/orca/lib/Orca/SourceFile.pm (original)
+++ trunk/orca/lib/Orca/SourceFile.pm Mon May 31 18:45:23 2004
@@ -261,15 +261,23 @@
# really be a method for a single plot, but the plot is not an object
# right now, so it doesn't have any methods that can be given to it.
sub deep_clone_plot {
+ my $plot = shift;
+ my $restore_creates = shift;
+
# Be careful not to make a deep copy of the 'creates' reference,
# since it can cause recursion.
- my $plot = shift;
my $creates = delete $plot->{creates};
my $new_plot = dclone($plot);
$plot->{creates} = $creates;
- $new_plot->{creates} = $creates;
+ if ($restore_creates) {
+ $new_plot->{creates} = $creates;
+ }
- $new_plot;
+ if (wantarray) {
+ ($new_plot, $creates);
+ } else {
+ $new_plot;
+ }
}
sub add_plots {
@@ -391,7 +399,7 @@
# Start by making a deep copy of the plot. Replace the regular
# expression in the first data with the name of the column that
# caused the match.
- $plot = deep_clone_plot($plot);
+ $plot = deep_clone_plot($plot, 1);
# At this point we have a copy of plot. Now go through looking
# for all the columns that match and create an additional data
@@ -505,9 +513,11 @@
# caused the match. Then create string form of the plot object
# using Data::Dumper::Dumper and replace all of the $1, $2,
# ... with what was matched in the first data source.
- $plot = deep_clone_plot($plot);
+ my $creates;
+ ($plot, $creates) = deep_clone_plot($plot, 0);
$plot->{data}[0][$regexp_element_index] = $column_description;
my $d = Data::Dumper->Dump([$plot], [qw(plot)]);
+ $plot->{creates} = $creates;
my $count = 1;
foreach my $match (@matches) {
$d =~ s/\$$count/$match/mge;
More information about the Orca-checkins
mailing list