From a1428cf75eb5277b147a7c7506581fed310d51b0 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Thu, 22 Mar 2012 12:58:55 -0700 Subject: [PATCH] track figures with fignum --- sweavealike.pm | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sweavealike.pm b/sweavealike.pm index d58ad68..1808090 100644 --- a/sweavealike.pm +++ b/sweavealike.pm @@ -126,7 +126,6 @@ sub preprocess { my $image_loc if (exists $param{fig}) { - $pagestate{$param{page}}{$id}{fignum}++; $param{width} = '400' unless exists $param{width} and defined $param{width}; $param{height} = '400' unless exists $param{height} and defined $param{height}; for (qw(width height)) { @@ -134,7 +133,9 @@ sub preprocess { error("invalid $_; must be an integer: $param{$_}"); } } - # because even if the code is duplicated, the figure could still be the same. + # because even if the code is duplicated, the figure could + # still be different, we track the number of figures + $pagestate{$param{page}}{$id}{fignum}++; my $md5 = code_md5($param{code},$param{width},$param{height},$pagestate{$param{page}}{$id}{fignum}); $image_loc = "$param{page}/${md5}.png"; my $image_loc_esc = $image_loc; @@ -203,12 +204,16 @@ sub savestate { # make sure we never try to save an R process for my $page (keys %pagestate) { next unless exists $pagestate{$page}{$id}; - next unless exists $pagestate{$page}{$id}{R}; - if (defined $pagestate{$page}{$id}{R} - and $pagestate{$page}{$id}{R}->is_started()) { - $pagestate{$page}{$id}{R}->stop; + next unless ; + if (exists $pagestate{$page}{$id}{R}) { + if (defined $pagestate{$page}{$id}{R} + and $pagestate{$page}{$id}{R}->is_started()) { + $pagestate{$page}{$id}{R}->stop; + } + } + if (exists $pagestate{$page}{$id}{fignum}) { + delete $pagestate{$page}{$id}{fignum} } - delete $pagestate{$page}{$id}{R}; } } -- 2.39.2