Index: trunk/extensions/timeline/EasyTimeline.pl |
— | — | @@ -70,8 +70,11 @@ |
71 | 71 | # - change svg encoding from iso-8859-1 -> UTF-8 |
72 | 72 | # - allow font to be specified using -f option as opposed to hardcoded FreeSans. |
73 | 73 | |
74 | | -our $VERSION = "1.13"; |
| 74 | +use strict; |
| 75 | +use warnings; |
75 | 76 | |
| 77 | +our $VERSION = '1.90'; |
| 78 | + |
76 | 79 | use Time::Local; |
77 | 80 | use Getopt::Std; |
78 | 81 | use Cwd; |
— | — | @@ -81,6 +84,7 @@ |
82 | 85 | # Many of these should be refactored. |
83 | 86 | my @PlotLines; |
84 | 87 | my $CntErrors = 0; |
| 88 | +my @Errors; |
85 | 89 | my @Info; |
86 | 90 | my @Warnings; |
87 | 91 | |
— | — | @@ -137,8 +141,8 @@ |
138 | 142 | my $Line; |
139 | 143 | my $NoData; |
140 | 144 | |
141 | | -my %Consts; # see sub GetDefine |
142 | | -my %Colors; # see sub StoreColor |
| 145 | +my %Consts; # see sub GetDefine |
| 146 | +my %Colors; # see sub StoreColor |
143 | 147 | my %BackgroundColors; |
144 | 148 | my %Axis; |
145 | 149 | my @Bars; |
— | — | @@ -158,7 +162,7 @@ |
159 | 163 | my @PlotText; |
160 | 164 | my $MaxBarWidth; |
161 | 165 | my %BarWidths; |
162 | | -my $maxwidth; # XXX problematic |
| 166 | + |
163 | 167 | my $Preset; |
164 | 168 | my @PresetList; |
165 | 169 | my %Scales; |
— | — | @@ -170,8 +174,22 @@ |
171 | 175 | |
172 | 176 | my $firstcmd; |
173 | 177 | |
| 178 | +my @PlotTextsPng; |
| 179 | +my @PlotTextsSvg; |
| 180 | +my @linksSVG; |
| 181 | +my @textsSVG; |
| 182 | + |
| 183 | +my @TextData; |
| 184 | + |
| 185 | +my ($sign, $posy1, $posy2); |
| 186 | + |
| 187 | +my $script; |
| 188 | +my @PlotBarsNow; |
| 189 | + |
| 190 | +my $command; |
| 191 | + |
174 | 192 | # BEGIN |
175 | | -$| = 1; # flush screen output |
| 193 | +local $| = 1; # flush screen output |
176 | 194 | |
177 | 195 | print "EasyTimeline version $VERSION\n" |
178 | 196 | . "Copyright (C) 2004 Erik Zachte\n" |
— | — | @@ -196,10 +214,10 @@ |
197 | 215 | &WritePlotFile; |
198 | 216 | } |
199 | 217 | |
200 | | -if ($CntErrors == 1) { |
| 218 | +if ($CntErrors == 1) { |
201 | 219 | &Abort("1 error found"); |
202 | 220 | } |
203 | | -elsif ($CntErrors > 1) { |
| 221 | +elsif ($CntErrors > 1) { |
204 | 222 | &Abort("$CntErrors errors found"); |
205 | 223 | } |
206 | 224 | else { |
— | — | @@ -231,7 +249,6 @@ |
232 | 250 | exit; |
233 | 251 | |
234 | 252 | sub ParseArguments { |
235 | | - my $options; |
236 | 253 | getopt("iTAPef", \%options); |
237 | 254 | |
238 | 255 | &Abort("Specify input file as: -i filename") if (!defined($options{"i"})); |
— | — | @@ -763,7 +780,7 @@ |
764 | 781 | $barset = ""; # $barcount = "" ; |
765 | 782 | |
766 | 783 | # warn "data: $data"; |
767 | | - my $data2; # = $data; |
| 784 | + my $data2; # = $data; |
768 | 785 | ($data2, $text) = &ExtractText($data2); |
769 | 786 | @Attributes = split(" ", $data2); |
770 | 787 | |
— | — | @@ -1120,7 +1137,7 @@ |
1121 | 1138 | $width = 2.0; |
1122 | 1139 | |
1123 | 1140 | # warn "data: $data"; |
1124 | | - my $data2; # = $data; |
| 1141 | + my $data2; # = $data; |
1125 | 1142 | |
1126 | 1143 | LineData: |
1127 | 1144 | while ((!$InputParsed) && (!$NoData)) { |
— | — | @@ -1690,7 +1707,7 @@ |
1691 | 1708 | sub ParsePlotData { |
1692 | 1709 | my $attrvalue2; |
1693 | 1710 | my $BarsCommandFound = @Bars; |
1694 | | - my $prevbar = ""; |
| 1711 | + my $prevbar = ""; |
1695 | 1712 | my $barndx; |
1696 | 1713 | |
1697 | 1714 | if ( (!(defined($DateFormat))) |
— | — | @@ -2158,11 +2175,14 @@ |
2159 | 2176 | } |
2160 | 2177 | elsif ($#Bars == 0) { |
2161 | 2178 | $bar = $Bars[0]; |
| 2179 | + |
2162 | 2180 | # warn "data: $data"; |
2163 | | - &Info(q(), # $data, |
| 2181 | + &Info( |
| 2182 | + q(), # $data, |
2164 | 2183 | "PlotData incomplete. Attribute 'bar' missing, value '" |
2165 | 2184 | . $Bars[0] |
2166 | | - . "' assumed."); |
| 2185 | + . "' assumed." |
| 2186 | + ); |
2167 | 2187 | } |
2168 | 2188 | else { $bar = "1"; } |
2169 | 2189 | |
— | — | @@ -2292,41 +2312,7 @@ |
2293 | 2313 | if ($align eq "") { $align = "center"; } |
2294 | 2314 | if ($color eq "") { $color = "black"; } |
2295 | 2315 | if ($fontsize eq "") { $fontsize = "S"; } |
2296 | | - # $adjust Doesn't seem to be used anywhere |
2297 | | - # if ($adjust eq "") { $adjust = "0,0"; } |
2298 | 2316 | |
2299 | | - # $textdetails = " textdetails: align=$align size=$size" ; |
2300 | | - # if ($textcolor eq "") |
2301 | | - # { $textcolor = "black" ; } |
2302 | | - # if ($color ne "") |
2303 | | - # { $textdetails .= " color=$textcolor" ; } |
2304 | | - |
2305 | | - # my ($xpos, $ypos) ; |
2306 | | - # my $barcnt = 0 ; |
2307 | | - # for ($b = 0 ; $b <= $#Bars ; $b++) |
2308 | | - # { |
2309 | | - # if (lc($Bars[$b]) eq lc($bar)) |
2310 | | - # { $barcnt = ($b + 1) ; last ; } |
2311 | | - # } |
2312 | | - |
2313 | | - # if ($Axis{"time"} eq "x") |
2314 | | - # { $xpos = "$at(s)" ; $ypos = "[$barcnt](s)" ; } |
2315 | | - # else |
2316 | | - # { $ypos = "$at(s)" ; $xpos = "[$barcnt](s)" ; } |
2317 | | - |
2318 | | - # if ($shift ne "") |
2319 | | - # { |
2320 | | - # my ($shiftx, $shifty) = split (",", $shift) ; |
2321 | | - # if ($shiftx > 0) |
2322 | | - # { $xpos .= "+$shiftx" ; } |
2323 | | - # if ($shiftx < 0) |
2324 | | - # { $xpos .= "$shiftx" ; } |
2325 | | - # if ($shifty > 0) |
2326 | | - # { $ypos .= "+$shifty" ; } |
2327 | | - # if ($shifty < 0) |
2328 | | - # { $ypos .= "$shifty" ; } |
2329 | | - # } |
2330 | | - |
2331 | 2317 | $text =~ s/\,/\#\%\$/g; |
2332 | 2318 | $link =~ s/\,/\#\%\$/g; |
2333 | 2319 | $hint =~ s/\,/\#\%\$/g; |
— | — | @@ -2351,20 +2337,21 @@ |
2352 | 2338 | ); |
2353 | 2339 | } |
2354 | 2340 | |
2355 | | - $maxwidth = 0; |
2356 | | - my $key; |
2357 | | - foreach $key (keys %BarWidths) { |
2358 | | - if ($BarWidths{$key} == 0) { |
| 2341 | + my $maxwidth = 0; |
| 2342 | + foreach my $bar_width (keys %BarWidths) { |
| 2343 | + if ($BarWidths{$bar_width} == 0) { |
2359 | 2344 | &Warning( |
2360 | | - "PlotData incomplete. No bar width defined for bar '$key', assume width from widest bar (used for line marks)." |
| 2345 | + "PlotData incomplete. No bar width defined for bar '$bar_width', assume width from widest bar (used for line marks)." |
2361 | 2346 | ); |
2362 | 2347 | } |
2363 | | - elsif ($BarWidths{$key} > $maxwidth) { |
2364 | | - $maxwidth = $BarWidths{$key}; |
| 2348 | + elsif ($BarWidths{$bar_width} > $maxwidth) { |
| 2349 | + $maxwidth = $BarWidths{$bar_width}; |
2365 | 2350 | } |
2366 | 2351 | } |
2367 | | - foreach $key (keys %BarWidths) { |
2368 | | - if ($BarWidths{$key} == 0) { $BarWidths{$key} = $maxwidth; } |
| 2352 | + foreach my $bar_width (keys %BarWidths) { |
| 2353 | + if ($BarWidths{$bar_width} == 0) { |
| 2354 | + $BarWidths{$bar_width} = $maxwidth; |
| 2355 | + } |
2369 | 2356 | } |
2370 | 2357 | } |
2371 | 2358 | |
— | — | @@ -2470,7 +2457,7 @@ |
2471 | 2458 | |
2472 | 2459 | if (!ValidAttributes("Scale" . $scale)) { return; } |
2473 | 2460 | |
2474 | | - &CheckPreset(Scale . $scale); |
| 2461 | + &CheckPreset('Scale' . $scale); |
2475 | 2462 | |
2476 | 2463 | $Scales{$scale} = $true; |
2477 | 2464 | |
— | — | @@ -2619,8 +2606,8 @@ |
2620 | 2607 | $textcolor = $TextDefs{"textcolor"}; |
2621 | 2608 | } |
2622 | 2609 | |
2623 | | - warn "data: $data"; |
2624 | | - my $data2 = $data; |
| 2610 | + # warn "data: $data"; # XXX $data is probably not really used |
| 2611 | + my $data2; # = $data; # XXX see above |
2625 | 2612 | ($data2, $text) = &ExtractText($data2); |
2626 | 2613 | @Attributes = split(" ", $data2); |
2627 | 2614 | |
— | — | @@ -2773,7 +2760,7 @@ |
2774 | 2761 | if (defined($tabs) && ($tabs ne "")) { |
2775 | 2762 | $tabs =~ s/^\s*$hBrO (.*) $hBrC\s*$/$1/x; |
2776 | 2763 | my @Tabs = split(",", $tabs); |
2777 | | - foreach $tab (@Tabs) { |
| 2764 | + foreach my $tab (@Tabs) { |
2778 | 2765 | $tab =~ s/\s* (.*) \s*$/$1/x; |
2779 | 2766 | if (!($tab =~ /\d+\-(?:center|left|right)$/)) { |
2780 | 2767 | &Error( |
— | — | @@ -2784,7 +2771,7 @@ |
2785 | 2772 | } |
2786 | 2773 | } |
2787 | 2774 | |
2788 | | - @Text = split('\^', $text); |
| 2775 | + my @Text = split('\^', $text); |
2789 | 2776 | if ($#Text > $#Tabs + 1) { |
2790 | 2777 | &Error( "TextData invalid. " |
2791 | 2778 | . $#Text |
— | — | @@ -2811,7 +2798,7 @@ |
2812 | 2799 | |
2813 | 2800 | &CheckPreset("TimeAxis"); |
2814 | 2801 | |
2815 | | - foreach $attribute (keys %Attributes) { |
| 2802 | + foreach my $attribute (keys %Attributes) { |
2816 | 2803 | my $attrvalue = $Attributes{$attribute}; |
2817 | 2804 | |
2818 | 2805 | if ($attribute =~ /Format/i) { |
— | — | @@ -2934,7 +2921,7 @@ |
2935 | 2922 | my ($val, $dim); |
2936 | 2923 | |
2937 | 2924 | if ($Image{"width"} =~ /auto/i) { |
2938 | | - foreach $attribute ("width", "left", "right") { |
| 2925 | + foreach my $attribute ("width", "left", "right") { |
2939 | 2926 | if ($PlotArea{$attribute} =~ /\%/) { |
2940 | 2927 | &Error2( "You specified 'ImageSize = width:auto'.\n" |
2941 | 2928 | . " This implies absolute values in PlotArea attributes 'left', 'right' and/or 'width' (no \%).\n" |
— | — | @@ -2956,7 +2943,7 @@ |
2957 | 2944 | } |
2958 | 2945 | |
2959 | 2946 | if ($Image{"height"} =~ /auto/i) { |
2960 | | - foreach $attribute ("height", "top", "bottom") { |
| 2947 | + foreach my $attribute ("height", "top", "bottom") { |
2961 | 2948 | if ($PlotArea{$attribute} =~ /\%/) { |
2962 | 2949 | &Error2( "You specified 'ImageSize = height:auto'.\n" |
2963 | 2950 | . " This implies absolute values in PlotArea attributes 'top', 'bottom' and/or 'height' (no \%).\n" |
— | — | @@ -3069,6 +3056,7 @@ |
3070 | 3057 | if ( (defined($Scales{"Major"})) |
3071 | 3058 | || (defined($Scales{"Minor"}))) |
3072 | 3059 | { |
| 3060 | + my $margin; |
3073 | 3061 | if (defined($Scales{"Major"})) { $margin = 0.2; } |
3074 | 3062 | else { $margin = 0.05; } |
3075 | 3063 | |
— | — | @@ -3216,10 +3204,10 @@ |
3217 | 3205 | push @PlotTextsPng, $textdetails . "\n"; |
3218 | 3206 | push @PlotTextsSvg, $textdetails . "\n"; |
3219 | 3207 | |
3220 | | - $text2 = $text; |
| 3208 | + my $text2 = $text; |
3221 | 3209 | $text2 =~ s/\[\[//g; |
3222 | 3210 | $text2 =~ s/\]\]//g; |
3223 | | - if ($text2 =~ /^\s/) { |
| 3211 | + if ($text2 =~ /^\s/) { |
3224 | 3212 | push @PlotTextsPng, " text: \n\\$text2\n\n"; |
3225 | 3213 | } |
3226 | 3214 | else { |
— | — | @@ -3239,7 +3227,7 @@ |
3240 | 3228 | $text2 =~ s/^ ([^\[]+) \]\]/\[$lcnt\[$1\]$lcnt\]/x; |
3241 | 3229 | } |
3242 | 3230 | |
3243 | | - $text3 = &EncodeHtml($text2); |
| 3231 | + my $text3 = &EncodeHtml($text2); |
3244 | 3232 | if ($text2 ne $text3) { |
3245 | 3233 | |
3246 | 3234 | # put placeholder in Ploticus input file |
— | — | @@ -3251,7 +3239,7 @@ |
3252 | 3240 | while (length($text3) < length($text2)) { $text3 .= "x"; } |
3253 | 3241 | } |
3254 | 3242 | |
3255 | | - if ($text3 =~ /^\s/) { |
| 3243 | + if ($text3 =~ /^\s/) { |
3256 | 3244 | push @PlotTextsSvg, " text: \n\\$text3\n\n"; |
3257 | 3245 | } |
3258 | 3246 | else { |
— | — | @@ -3299,7 +3287,7 @@ |
3300 | 3288 | my $pos2 = index($text, "]]") + 1; |
3301 | 3289 | if (($pos1 > -1) && ($pos2 > -1)) { |
3302 | 3290 | for (my $i = 0; $i < length($text); $i++) { |
3303 | | - $c = substr($text, $i, 1); |
| 3291 | + my $c = substr($text, $i, 1); |
3304 | 3292 | if ($c ne "\n") { |
3305 | 3293 | if (($i < $pos1) || ($i > $pos2)) { |
3306 | 3294 | substr($text, $i, 1) = " "; |
— | — | @@ -3368,7 +3356,7 @@ |
3369 | 3357 | s/\s* (.*) \s*$/$1/x; |
3370 | 3358 | } |
3371 | 3359 | |
3372 | | - $posx0 = $posx; |
| 3360 | + my $posx0 = $posx; |
3373 | 3361 | my @Text; |
3374 | 3362 | my $dy = 0; |
3375 | 3363 | |
— | — | @@ -3401,32 +3389,37 @@ |
3402 | 3390 | push @Text, $text; |
3403 | 3391 | } |
3404 | 3392 | |
3405 | | - foreach $text (@Text) { # XXX $text should be renamed here |
3406 | | - if ($text !~ /^[\n\s]*$/) { |
| 3393 | + foreach my $text_item (@Text) { |
| 3394 | + if ($text_item !~ /^[\n\s]*$/) { |
3407 | 3395 | $link2 = ""; |
3408 | 3396 | $hint2 = ""; |
3409 | | - ($text, $link2, $hint2) = &ProcessWikiLink($text, $link2, $hint2); |
| 3397 | + ($text_item, $link2, $hint2) = |
| 3398 | + &ProcessWikiLink($text_item, $link2, $hint2); |
3410 | 3399 | |
3411 | 3400 | if ($link2 eq "") { |
3412 | 3401 | $link2 = $link; |
3413 | | - if (($link ne "") && ($text !~ /\[\[.*\]\]/)) { |
3414 | | - $text = "[[" . $text . "]]"; |
| 3402 | + if (($link ne "") && ($text_item !~ /\[\[.*\]\]/)) { |
| 3403 | + $text_item = "[[" . $text_item . "]]"; |
3415 | 3404 | } |
3416 | 3405 | } |
3417 | 3406 | if ($hint2 eq "") { $hint2 = $hint; } |
3418 | 3407 | |
3419 | 3408 | &WriteProcAnnotate( |
3420 | | - $bar, $shiftx, $posx, $posy, $text, |
| 3409 | + $bar, $shiftx, $posx, $posy, $text_item, |
3421 | 3410 | $textcolor, $fontsize, $align, $link2, $hint2 |
3422 | 3411 | ); |
3423 | 3412 | } |
3424 | 3413 | |
3425 | 3414 | if ($#Tabs >= 0) { |
3426 | 3415 | $tab = shift(@Tabs); |
| 3416 | + my $dx; |
3427 | 3417 | ($dx, $align) = split("\-", $tab); |
3428 | 3418 | $posx = $posx0 + &Normalize($dx); |
3429 | 3419 | } |
3430 | | - if ($posy =~ /\+/) { ($posy1, $posy2) = split('\+', $posy); } |
| 3420 | + |
| 3421 | + if ($posy =~ /\+/) { |
| 3422 | + ($posy1, $posy2) = split('\+', $posy); |
| 3423 | + } |
3431 | 3424 | elsif ($posy =~ /.+\-/) { |
3432 | 3425 | if ($posy =~ /^\-/) { |
3433 | 3426 | ($sign, $posy1, $posy2) = split('\-', $posy); |
— | — | @@ -3438,7 +3431,10 @@ |
3439 | 3432 | $posy2 = -$posy2; |
3440 | 3433 | } |
3441 | 3434 | } |
3442 | | - else { $posy1 = $posy; $posy2 = 0; } |
| 3435 | + else { |
| 3436 | + $posy1 = $posy; |
| 3437 | + $posy2 = 0; |
| 3438 | + } |
3443 | 3439 | |
3444 | 3440 | $posy2 -= $dy; |
3445 | 3441 | |
— | — | @@ -3448,38 +3444,12 @@ |
3449 | 3445 | } |
3450 | 3446 | } |
3451 | 3447 | |
3452 | | -sub WriteProcDrawCommandsOld { |
3453 | | - my $posx = shift; |
3454 | | - my $posy = shift; |
3455 | | - my $text = shift; |
3456 | | - my $textcolor = shift; |
3457 | | - my $fontsize = shift; |
3458 | | - my $link = shift; |
3459 | | - my $hint = shift; |
3460 | | - |
3461 | | - $posx0 = $posx; |
3462 | | - my @Text = split('\^', $text); |
3463 | | - my $align = "text"; |
3464 | | - foreach $text (@Text) { |
3465 | | - push @TextData, " mov $posx $posy\n"; |
3466 | | - push @TextData, " textsize $fontsize\n"; |
3467 | | - push @TextData, " color $textcolor\n"; |
3468 | | - push @TextData, " $align $text\n"; |
3469 | | - |
3470 | | - $tab = shift(@Tabs); |
3471 | | - ($dx, $align) = split("\-", $tab); |
3472 | | - $posx = $posx0 + &Normalize($dx); |
3473 | | - if ($align =~ /left/i) { $align = "text"; } |
3474 | | - elsif ($align =~ /right/i) { $align = "rightjust"; } |
3475 | | - else { $align = "centext"; } |
3476 | | - } |
3477 | | -} |
3478 | | - |
3479 | 3448 | sub WritePlotFile { |
3480 | 3449 | &WriteTexts; |
3481 | 3450 | |
3482 | 3451 | $script = ""; |
3483 | | - my ($color); |
| 3452 | + |
| 3453 | + my $AxisBars; |
3484 | 3454 | if ($Axis{"time"} eq "x") { $AxisBars = "y"; } |
3485 | 3455 | else { $AxisBars = "x"; } |
3486 | 3456 | |
— | — | @@ -3491,6 +3461,7 @@ |
3492 | 3462 | # @Bars = @BarsTmp ; |
3493 | 3463 | # } |
3494 | 3464 | |
| 3465 | + my $file_script; |
3495 | 3466 | if ($tmpdir ne "") { |
3496 | 3467 | $file_script = $tmpdir . $pathseparator . "EasyTimeline.txt.$$"; |
3497 | 3468 | } |
— | — | @@ -3518,8 +3489,10 @@ |
3519 | 3490 | } |
3520 | 3491 | $script .= "\n"; |
3521 | 3492 | |
3522 | | - $barcnt = $#Bars + 1; |
| 3493 | + my $barcnt = $#Bars + 1; |
3523 | 3494 | |
| 3495 | + my ($U, $x); |
| 3496 | + |
3524 | 3497 | # if ($AlignBars eq "justify") && ($#Bars > 0) |
3525 | 3498 | # |
3526 | 3499 | # given P = plotwidth in pixels |
— | — | @@ -3550,6 +3523,7 @@ |
3551 | 3524 | $AlignBars = "early"; |
3552 | 3525 | } |
3553 | 3526 | |
| 3527 | + my $extent; |
3554 | 3528 | if ($Axis{"time"} eq "x") { $extent = "height"; } |
3555 | 3529 | else { $extent = "width"; } |
3556 | 3530 | |
— | — | @@ -3560,6 +3534,7 @@ |
3561 | 3535 | |
3562 | 3536 | if ($MaxBarWidth == $PlotArea{$extent}) { $PlotArea{$extent} += 0.01; } |
3563 | 3537 | |
| 3538 | + my ($till, $from); |
3564 | 3539 | if ($MaxBarWidth == $PlotArea{$extent}) { |
3565 | 3540 | $till = 1; |
3566 | 3541 | $from = 1; |
— | — | @@ -3653,7 +3628,7 @@ |
3654 | 3629 | # $script .= " clickmapurl: http://www.wikipedia.org/wiki/Vladimir_Lenin\n" ; |
3655 | 3630 | |
3656 | 3631 | #proc legendentry |
3657 | | - foreach $color (sort keys %Colors) { |
| 3632 | + foreach my $color (sort keys %Colors) { |
3658 | 3633 | $script .= "#proc legendentry\n"; |
3659 | 3634 | $script .= " sampletype: color\n"; |
3660 | 3635 | |
— | — | @@ -3672,9 +3647,9 @@ |
3673 | 3648 | $script .= " delim: comma\n"; |
3674 | 3649 | $script .= " data:\n"; |
3675 | 3650 | |
3676 | | - $maxwidth = 0; |
3677 | | - foreach $entry (@PlotBars) { |
3678 | | - ($width) = split(",", $entry); |
| 3651 | + my $maxwidth = 0; |
| 3652 | + foreach my $entry (@PlotBars) { |
| 3653 | + my ($width) = split(",", $entry); |
3679 | 3654 | if ($width > $maxwidth) { $maxwidth = $width; } |
3680 | 3655 | } |
3681 | 3656 | |
— | — | @@ -3714,8 +3689,9 @@ |
3715 | 3690 | |
3716 | 3691 | $script .= "\n([inc3])\n\n"; # will be replace by rects |
3717 | 3692 | |
3718 | | - %x = %BarWidths; |
3719 | | - foreach $entry (@PlotLines) { |
| 3693 | + # %x = %BarWidths; # XXX doesn't seem to be used |
| 3694 | + my ($bar, $width); |
| 3695 | + foreach my $entry (@PlotLines) { |
3720 | 3696 | ($bar) = split(",", $entry); |
3721 | 3697 | $bar =~ s/\#.*//; |
3722 | 3698 | $width = $BarWidths{$bar}; |
— | — | @@ -3725,6 +3701,9 @@ |
3726 | 3702 | @PlotBarsNow = @PlotLines; |
3727 | 3703 | &PlotBars; |
3728 | 3704 | |
| 3705 | + my ($scriptPng1, $scriptPng2, $scriptPng3); |
| 3706 | + my ($scriptSvg1, $scriptSvg2); |
| 3707 | + |
3729 | 3708 | #proc axis |
3730 | 3709 | if ($#Bars > 0) { |
3731 | 3710 | $scriptPng2 = "#proc " . $AxisBars . "axis\n"; |
— | — | @@ -3750,23 +3729,28 @@ |
3751 | 3730 | $scriptPng2 .= " stubs: text\n"; |
3752 | 3731 | $scriptSvg2 .= " stubs: text\n"; |
3753 | 3732 | |
3754 | | - # XXX huh? Yields a warning. |
3755 | 3733 | my $text; |
3756 | 3734 | my $link; |
3757 | 3735 | my $hint; |
3758 | 3736 | |
| 3737 | + my @Bars2; |
| 3738 | + |
3759 | 3739 | undef(@Bars2); |
3760 | | - foreach $bar (@Bars) { |
3761 | | - if ($AxisBars eq "y") { push @Bars2, $bar; } |
3762 | | - else { unshift @Bars2, $bar; } |
| 3740 | + foreach my $bar_iter (@Bars) { |
| 3741 | + if ($AxisBars eq "y") { |
| 3742 | + push @Bars2, $bar_iter; |
| 3743 | + } |
| 3744 | + else { |
| 3745 | + unshift @Bars2, $bar_iter; |
| 3746 | + } |
3763 | 3747 | } |
3764 | 3748 | |
3765 | | - foreach $bar (@Bars2) { |
| 3749 | + foreach my $bar2_iter (@Bars2) { |
3766 | 3750 | $hint = ""; |
3767 | | - $text = $BarLegend{ lc($bar) }; |
| 3751 | + $text = $BarLegend{ lc($bar2_iter) }; |
3768 | 3752 | if ($text =~ /^\s*$/) { $text = "\\"; } |
3769 | 3753 | |
3770 | | - $link = $BarLink{ lc($bar) }; |
| 3754 | + $link = $BarLink{ lc($bar2_iter) }; |
3771 | 3755 | if (!defined($link)) { |
3772 | 3756 | if ($text =~ /\[.*\]/) { |
3773 | 3757 | ($text, $link, $hint) = |
— | — | @@ -3782,7 +3766,9 @@ |
3783 | 3767 | $scriptSvg2 .= |
3784 | 3768 | "[" . $lcnt . "[" . $text . "]" . $lcnt . "]\n"; |
3785 | 3769 | } |
3786 | | - else { $scriptSvg2 .= "$text\n"; } |
| 3770 | + else { |
| 3771 | + $scriptSvg2 .= "$text\n"; |
| 3772 | + } |
3787 | 3773 | } |
3788 | 3774 | $scriptPng2 .= "\n"; |
3789 | 3775 | $scriptSvg2 .= "\n"; |
— | — | @@ -3803,12 +3789,12 @@ |
3804 | 3790 | $scriptPng2 .= " stubs: text\n"; |
3805 | 3791 | |
3806 | 3792 | $barcnt = $#Bars + 1; |
3807 | | - foreach $bar (@Bars2) { |
| 3793 | + foreach my $bars2_iter (@Bars2) { |
3808 | 3794 | $hint = ""; |
3809 | | - $text = $BarLegend{ lc($bar) }; |
| 3795 | + $text = $BarLegend{ lc($bars2_iter) }; |
3810 | 3796 | if ($text =~ /^\s*$/) { $text = "\\"; } |
3811 | 3797 | |
3812 | | - $link = $BarLink{ lc($bar) }; |
| 3798 | + $link = $BarLink{ lc($bars2_iter) }; |
3813 | 3799 | if (!defined($link)) { |
3814 | 3800 | if ($text =~ /\[.*\]/) { |
3815 | 3801 | ($text, $link, $hint) = |
— | — | @@ -3844,23 +3830,25 @@ |
3845 | 3831 | $script .= "\n([inc2])\n\n"; |
3846 | 3832 | |
3847 | 3833 | if ($#PlotTextsPng >= 0) { |
3848 | | - foreach $command (@PlotTextsPng) { |
3849 | | - if ($command =~ /^\s*location/) { |
3850 | | - $command =~ s/(.*)\[(.*)\](.*)/$1 . ($#Bars - $2 + 2) . $3/xe; |
| 3834 | + foreach my $plot_texts_png_command (@PlotTextsPng) { |
| 3835 | + if ($plot_texts_png_command =~ /^\s*location/) { |
| 3836 | + $plot_texts_png_command =~ |
| 3837 | + s/(.*)\[(.*)\](.*)/$1 . ($#Bars - $2 + 2) . $3/xe; |
3851 | 3838 | } |
3852 | 3839 | |
3853 | | - $scriptPng1 .= $command; |
| 3840 | + $scriptPng1 .= $plot_texts_png_command; |
3854 | 3841 | } |
3855 | 3842 | $scriptPng1 .= "\n"; |
3856 | 3843 | } |
3857 | 3844 | |
3858 | 3845 | if ($#PlotTextsSvg >= 0) { |
3859 | | - foreach $command (@PlotTextsSvg) { |
3860 | | - if ($command =~ /^\s*location/) { |
3861 | | - $command =~ s/(.*)\[(.*)\](.*)/$1 . ($#Bars - $2 + 2) . $3/xe; |
| 3846 | + foreach my $plot_texts_svg_command (@PlotTextsSvg) { |
| 3847 | + if ($plot_texts_svg_command =~ /^\s*location/) { |
| 3848 | + $plot_texts_svg_command =~ |
| 3849 | + s/(.*)\[(.*)\](.*)/$1 . ($#Bars - $2 + 2) . $3/xe; |
3862 | 3850 | } |
3863 | 3851 | |
3864 | | - $scriptSvg1 .= $command; |
| 3852 | + $scriptSvg1 .= $plot_texts_svg_command; |
3865 | 3853 | } |
3866 | 3854 | $scriptSvg1 .= "\n"; |
3867 | 3855 | } |
— | — | @@ -3880,7 +3868,7 @@ |
3881 | 3869 | if ($#TextData >= 0) { |
3882 | 3870 | $script .= "#proc drawcommands\n"; |
3883 | 3871 | $script .= " commands:\n"; |
3884 | | - foreach $entry (@TextData) { $script .= $entry; } |
| 3872 | + foreach my $entry (@TextData) { $script .= $entry; } |
3885 | 3873 | $script .= "\n"; |
3886 | 3874 | } |
3887 | 3875 | |
— | — | @@ -3895,7 +3883,7 @@ |
3896 | 3884 | return; |
3897 | 3885 | } |
3898 | 3886 | |
3899 | | - $perColumn = 999; |
| 3887 | + my $perColumn = 999; |
3900 | 3888 | if ($Legend{"orientation"} =~ /ver/i) { |
3901 | 3889 | if ($Legend{"columns"} > 1) { |
3902 | 3890 | $perColumn = 0; |
— | — | @@ -3905,7 +3893,7 @@ |
3906 | 3894 | } |
3907 | 3895 | } |
3908 | 3896 | |
3909 | | - for ($l = 1; $l <= $Legend{"columns"}; $l++) { |
| 3897 | + for (1 .. $Legend{"columns"}) { |
3910 | 3898 | $script .= "#proc legend\n"; |
3911 | 3899 | $script .= " noclear: yes\n"; |
3912 | 3900 | if ($Legend{"orientation"} =~ /ver/i) { |
— | — | @@ -3920,8 +3908,8 @@ |
3921 | 3909 | . ($Legend{"left"} + 0.2) . " " |
3922 | 3910 | . $Legend{"top"} . "\n"; |
3923 | 3911 | $script .= " specifyorder:\n"; |
3924 | | - for ($l2 = 1; $l2 <= $perColumn; $l2++) { |
3925 | | - $category = shift(@LegendData); |
| 3912 | + for (1 .. $perColumn) { |
| 3913 | + my $category = shift(@LegendData); |
3926 | 3914 | if (defined($category)) { $script .= "$category\n"; } |
3927 | 3915 | } |
3928 | 3916 | $script .= "\n"; |
— | — | @@ -3931,6 +3919,7 @@ |
3932 | 3920 | |
3933 | 3921 | $script .= "#endproc\n"; |
3934 | 3922 | |
| 3923 | + my $pl; |
3935 | 3924 | print "\nGenerating output:\n"; |
3936 | 3925 | if ($ploticus_command ne "") { |
3937 | 3926 | $pl = $ploticus_command; |
— | — | @@ -3944,7 +3933,7 @@ |
3945 | 3934 | . $pl . "\" (" |
3946 | 3935 | . $ploticus_command . ")\n"; |
3947 | 3936 | |
3948 | | - $script_save = $script; |
| 3937 | + my $script_save = $script; |
3949 | 3938 | |
3950 | 3939 | $script =~ s/\(\[inc1\]\)/$scriptSvg1/; |
3951 | 3940 | $script =~ s/\(\[inc2\]\)/$scriptSvg2/; |
— | — | @@ -3968,7 +3957,7 @@ |
3969 | 3958 | print FILE_OUT &DecodeInput($script); |
3970 | 3959 | close "FILE_OUT"; |
3971 | 3960 | |
3972 | | - $map = ($MapSVG) ? "-map" : ""; |
| 3961 | + my $map = ($MapSVG) ? "-map" : ""; |
3973 | 3962 | |
3974 | 3963 | print "Running Ploticus to generate svg file\n"; |
3975 | 3964 | |
— | — | @@ -4053,30 +4042,32 @@ |
4054 | 4043 | } |
4055 | 4044 | } |
4056 | 4045 | |
4057 | | - if (-e $file_htmlmap |
4058 | | - ) # correct click coordinates of right aligned texts (Ploticus bug) |
4059 | | - { |
| 4046 | + # correct click coordinates of right aligned texts (Ploticus bug) |
| 4047 | + if (-e $file_htmlmap) { |
4060 | 4048 | open "FILE_IN", "<", $file_htmlmap; |
4061 | | - @map = <FILE_IN>; |
| 4049 | + my @map = <FILE_IN>; |
4062 | 4050 | close "FILE_IN"; |
4063 | 4051 | |
4064 | | - foreach $line (@map) { |
| 4052 | + my @map2; |
| 4053 | + foreach my $line (@map) { |
4065 | 4054 | chomp $line; |
4066 | 4055 | if ($line =~ /\&\&/) { |
4067 | | - $coords = $line; |
4068 | | - $shift = $line; |
| 4056 | + my $coords = $line; |
| 4057 | + my $shift = $line; |
4069 | 4058 | $coords =~ s/^.*coords\=\"([^\"]*)\".*$/$1/; |
4070 | | - $shift =~ s/^.*\&\&([^\"]*)\".*$/$1/; |
| 4059 | + $shift =~ s/^.*\&\&([^\"]*)\".*$/$1/; # XXX? |
4071 | 4060 | $line =~ s/\&\&[^\"]*//; |
4072 | | - (@updcoords) = split(",", $coords); |
4073 | | - $maplength = $updcoords[2] - $updcoords[0]; |
| 4061 | + my (@updcoords) = split(",", $coords); |
| 4062 | + my $maplength = $updcoords[2] - $updcoords[0]; |
4074 | 4063 | $updcoords[0] = $updcoords[0] - 2 * ($maplength - 25); |
4075 | 4064 | $updcoords[2] = $updcoords[0] + $maplength; |
4076 | | - $coordsnew = join(",", @updcoords); |
| 4065 | + my $coordsnew = join(",", @updcoords); |
4077 | 4066 | $line =~ s/$coords/$coordsnew/; |
4078 | 4067 | push @map2, $line . "\n"; |
4079 | 4068 | } |
4080 | | - else { push @map2, $line . "\n"; } |
| 4069 | + else { |
| 4070 | + push @map2, $line . "\n"; |
| 4071 | + } |
4081 | 4072 | } |
4082 | 4073 | |
4083 | 4074 | open "FILE_OUT", ">", $file_htmlmap; |
— | — | @@ -4086,13 +4077,12 @@ |
4087 | 4078 | |
4088 | 4079 | if (-e $file_vector) { |
4089 | 4080 | open "FILE_IN", "<", $file_vector; |
4090 | | - @svg = <FILE_IN>; |
| 4081 | + my @svg = <FILE_IN>; |
4091 | 4082 | close "FILE_IN"; |
4092 | 4083 | |
4093 | | - foreach $line (@svg) { |
4094 | | - $line =~ s/\{\{(\d+)\}\}x+/$textsSVG[$1]/gxe; |
4095 | | - $line =~ |
4096 | | - s/\[(\d+)\[ (.*?) \]\d+\]/'<a style="fill:blue;" xlink:href="' . $linksSVG[$1] . '">' . $2 . '<\/a>'/gxe; |
| 4084 | + foreach (@svg) { |
| 4085 | + s/\{\{(\d+)\}\}x+/$textsSVG[$1]/gxe; |
| 4086 | + s/\[(\d+)\[ (.*?) \]\d+\]/'<a style="fill:blue;" xlink:href="' . $linksSVG[$1] . '">' . $2 . '<\/a>'/gxe; |
4097 | 4087 | } |
4098 | 4088 | |
4099 | 4089 | open "FILE_OUT", ">", $file_vector; |
— | — | @@ -4105,13 +4095,15 @@ |
4106 | 4096 | $map = ""; |
4107 | 4097 | if ($linkmap) { |
4108 | 4098 | open "FILE_IN", "<", $file_htmlmap; |
4109 | | - while ($line = <FILE_IN>) { $map .= $line; } |
| 4099 | + while (my $line = <FILE_IN>) { |
| 4100 | + $map .= $line; |
| 4101 | + } |
4110 | 4102 | close "FILE_IN"; |
4111 | 4103 | } |
4112 | 4104 | print "Generating html test file\n"; |
4113 | | - $width = sprintf("%.0f", $Image{"width"} * 100); |
4114 | | - $height = sprintf("%.0f", $Image{"height"} * 100); |
4115 | | - $html = <<__HTML__ ; |
| 4105 | + $width = sprintf("%.0f", $Image{"width"} * 100); |
| 4106 | + my $height = sprintf("%.0f", $Image{"height"} * 100); |
| 4107 | + my $html = <<__HTML__ ; |
4116 | 4108 | |
4117 | 4109 | <html> |
4118 | 4110 | <head> |
— | — | @@ -4168,8 +4160,9 @@ |
4169 | 4161 | } |
4170 | 4162 | |
4171 | 4163 | sub WriteTexts { |
4172 | | - my ($line, $xpos, $ypos); |
4173 | | - foreach $line (@PlotText) { |
| 4164 | + my ($xpos, $ypos); |
| 4165 | + |
| 4166 | + foreach my $line (@PlotText) { |
4174 | 4167 | my ( |
4175 | 4168 | $at, $bar, $text, $textcolor, $fontsize, |
4176 | 4169 | $align, $shift, $link, $hint |
— | — | @@ -4191,8 +4184,10 @@ |
4192 | 4185 | } |
4193 | 4186 | else { $ypos = "$at(s)"; $xpos = "[$barcnt](s)"; } |
4194 | 4187 | |
| 4188 | + # XXX - $shiftx was defined inside the if block. |
| 4189 | + my ($shiftx, $shifty); |
4195 | 4190 | if ($shift ne "") { |
4196 | | - my ($shiftx, $shifty) = split(",", $shift); |
| 4191 | + ($shiftx, $shifty) = split(",", $shift); |
4197 | 4192 | if ($shiftx > 0) { $xpos .= "+$shiftx"; } |
4198 | 4193 | if ($shiftx < 0) { $xpos .= "$shiftx"; } |
4199 | 4194 | if ($shifty > 0) { $ypos .= "+$shifty"; } |
— | — | @@ -4208,14 +4203,15 @@ |
4209 | 4204 | } |
4210 | 4205 | |
4211 | 4206 | sub PlotBars { |
| 4207 | + my @PlotBarsLater; |
4212 | 4208 | |
4213 | 4209 | #proc getdata / #proc bars |
4214 | 4210 | while ($#PlotBarsNow >= 0) { |
4215 | 4211 | undef @PlotBarsLater; |
4216 | 4212 | |
4217 | | - $maxwidth = 0; |
4218 | | - foreach $entry (@PlotBarsNow) { |
4219 | | - ($width) = split(",", $entry); |
| 4213 | + my $maxwidth = 0; |
| 4214 | + foreach my $entry (@PlotBarsNow) { |
| 4215 | + my ($width) = split(",", $entry); |
4220 | 4216 | if ($width > $maxwidth) { $maxwidth = $width; } |
4221 | 4217 | } |
4222 | 4218 | |
— | — | @@ -4223,7 +4219,7 @@ |
4224 | 4220 | $script .= " delim: comma\n"; |
4225 | 4221 | $script .= " data:\n"; |
4226 | 4222 | |
4227 | | - foreach $entry (@PlotBarsNow) { |
| 4223 | + foreach my $entry (@PlotBarsNow) { |
4228 | 4224 | my ($width, $bar, $from, $till, $color, $link, $hint) = |
4229 | 4225 | split(",", $entry); |
4230 | 4226 | if ($width < $maxwidth) { |
— | — | @@ -4250,24 +4246,17 @@ |
4251 | 4247 | } |
4252 | 4248 | $script .= "\n"; |
4253 | 4249 | |
4254 | | - #proc bars |
| 4250 | + # proc bars |
4255 | 4251 | $script .= "#proc bars\n"; |
4256 | 4252 | $script .= " axis: " . $Axis{"time"} . "\n"; |
4257 | 4253 | $script .= " barwidth: $maxwidth\n"; |
4258 | 4254 | $script .= " outline: no\n"; |
4259 | 4255 | |
4260 | | - # $script .= " thinbarline: width=5\n" ; |
4261 | 4256 | if ($Axis{"time"} eq "x") { $script .= " horizontalbars: yes\n"; } |
4262 | 4257 | $script .= " locfield: 1\n"; |
4263 | 4258 | $script .= " segmentfields: 2 3\n"; |
4264 | 4259 | $script .= " colorfield: 4\n"; |
4265 | 4260 | |
4266 | | - # $script .= " outline: width=1\n" ; |
4267 | | - # $script .= " barwidthfield: 5\n" ; |
4268 | | - # if ($fields[4] ne "") |
4269 | | - # { $script .= " clickmapurl: " . &LinkToUrl ($text) . "\n" ; } |
4270 | | - # if ($fields[5] ne "") |
4271 | | - # { $script .= " clickmaplabel: $text\n" ; } |
4272 | 4261 | $script .= " clickmapurl: \@\@5\n"; |
4273 | 4262 | $script .= " clickmaplabel: \@\@6\n"; |
4274 | 4263 | $script .= "\n"; |
— | — | @@ -4281,7 +4270,7 @@ |
4282 | 4271 | my $grid = shift; |
4283 | 4272 | my ($color, $from, $till, $start); |
4284 | 4273 | |
4285 | | - %x = %Period; |
| 4274 | + # %x = %Period; # XXX doesn't seem to be used |
4286 | 4275 | |
4287 | 4276 | # if (($DateFormat =~ /\//) && ($grid)) |
4288 | 4277 | # { return ; } |
— | — | @@ -4354,7 +4343,7 @@ |
4355 | 4344 | # $start =~ s/.*\///g ; # delete dd mm if present |
4356 | 4345 | $start = &DateToFloat($start); |
4357 | 4346 | if ($Axis{"order"} =~ /reverse/i) { |
4358 | | - $loop = 0; |
| 4347 | + my $loop = 0; |
4359 | 4348 | $start = -$start; |
4360 | 4349 | while ($start - $Scales{"$scale inc"} >= -$Period{"till"}) { |
4361 | 4350 | $start -= $Scales{"$scale inc"}; |
— | — | @@ -4400,23 +4389,30 @@ |
4401 | 4390 | |
4402 | 4391 | if ($#DrawLines < 0) { return; } |
4403 | 4392 | |
| 4393 | + my @DrawLinesNow; |
4404 | 4394 | undef(@DrawLinesNow); |
4405 | 4395 | |
4406 | | - foreach $line (@DrawLines) { |
4407 | | - if ($line =~ /\|$layer\n/) { push @DrawLinesNow, $line; } |
| 4396 | + foreach my $line (@DrawLines) { |
| 4397 | + if ($line =~ /\|$layer\n/) { |
| 4398 | + push @DrawLinesNow, $line; |
| 4399 | + } |
4408 | 4400 | } |
4409 | 4401 | |
4410 | 4402 | if ($#DrawLinesNow < 0) { return; } |
4411 | 4403 | |
4412 | | - foreach $entry (@DrawLinesNow) { |
| 4404 | + foreach my $entry (@DrawLinesNow) { |
4413 | 4405 | chomp($entry); |
4414 | 4406 | $script .= "#proc line\n"; |
4415 | 4407 | |
| 4408 | + my ($mode, $at, $from, $till, $color, $width, $points); |
| 4409 | + |
4416 | 4410 | # $script .= " notation: scaled\n" ; |
4417 | 4411 | if ($entry =~ /^[12]/) { |
4418 | 4412 | ($mode, $at, $from, $till, $color, $width) = split('\|', $entry); |
4419 | 4413 | } |
4420 | | - else { ($mode, $points, $color, $width) = split('\|', $entry); } |
| 4414 | + else { |
| 4415 | + ($mode, $points, $color, $width) = split('\|', $entry); |
| 4416 | + } |
4421 | 4417 | |
4422 | 4418 | $script .= " linedetails: width=$width color=$color style=0\n"; |
4423 | 4419 | |
— | — | @@ -4470,10 +4466,14 @@ |
4471 | 4467 | } |
4472 | 4468 | } |
4473 | 4469 | |
4474 | | - if ($mode == 3) # draw free line |
4475 | | - { |
4476 | | - @Points = split(",", $points); |
4477 | | - foreach $point (@Points) { $point = &Normalize($point); } |
| 4470 | + # draw free line |
| 4471 | + if ($mode == 3) { |
| 4472 | + my @Points = split(",", $points); |
| 4473 | + |
| 4474 | + foreach my $point (@Points) { |
| 4475 | + $point = &Normalize($point); |
| 4476 | + } |
| 4477 | + |
4478 | 4478 | if ( ($Points[0] > $Image{"width"}) |
4479 | 4479 | || ($Points[1] > $Image{"height"}) |
4480 | 4480 | || ($Points[2] > $Image{"width"}) |
— | — | @@ -4514,7 +4514,9 @@ |
4515 | 4515 | } |
4516 | 4516 | return ($true); |
4517 | 4517 | } |
4518 | | - else { return ($false); } |
| 4518 | + else { |
| 4519 | + return ($false); |
| 4520 | + } |
4519 | 4521 | } |
4520 | 4522 | |
4521 | 4523 | # Can be much simpler |
— | — | @@ -4657,14 +4659,15 @@ |
4658 | 4660 | return (sprintf("%.3f", ($from + $till) / 2)); |
4659 | 4661 | } |
4660 | 4662 | |
4661 | | - $from2 = &DaysFrom1800($from); |
4662 | | - $till2 = &DaysFrom1800($till); |
4663 | | - my $date = &DateFrom1800(int(($from2 + $till2) / 2)); |
| 4663 | + my $from2 = &DaysFrom1800($from); |
| 4664 | + my $till2 = &DaysFrom1800($till); |
| 4665 | + my $date = &DateFrom1800(int(($from2 + $till2) / 2)); |
4664 | 4666 | return ($date); |
4665 | 4667 | } |
4666 | 4668 | |
4667 | 4669 | sub DaysFrom1800 { |
4668 | | - @mmm = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
| 4670 | + my @mmm = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
| 4671 | + my ($day, $month, $year); |
4669 | 4672 | my $date = shift; |
4670 | 4673 | if ($DateFormat eq "dd/mm/yyyy") { |
4671 | 4674 | $day = substr($date, 0, 2); |
— | — | @@ -4681,11 +4684,11 @@ |
4682 | 4685 | return; |
4683 | 4686 | } |
4684 | 4687 | |
4685 | | - $days = ($year - 1800) * 365; |
| 4688 | + my $days = ($year - 1800) * 365; |
4686 | 4689 | $days += int(($year - 1 - 1800) / 4); |
4687 | 4690 | $days -= int(($year - 1 - 1800) / 100); |
4688 | 4691 | if ($month > 1) { |
4689 | | - for ($m = $month - 2; $m >= 0; $m--) { |
| 4692 | + for (my $m = $month - 2; $m >= 0; $m--) { |
4690 | 4693 | $days += $mmm[$m]; |
4691 | 4694 | if ($m == 1) { |
4692 | 4695 | if ((($year % 4) == 0) && (($year % 100) != 0)) { $days++; } |
— | — | @@ -4710,16 +4713,16 @@ |
4711 | 4714 | sub DateFrom1800 { |
4712 | 4715 | my $days = shift; |
4713 | 4716 | |
4714 | | - @mmm = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
| 4717 | + my @mmm = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
4715 | 4718 | |
4716 | | - $year = 1800; |
| 4719 | + my $year = 1800; |
4717 | 4720 | while ($days > 365 + (($year % 4) == 0)) { |
4718 | 4721 | if ((($year % 4) == 0) && (($year % 100) != 0)) { $days -= 366; } |
4719 | 4722 | else { $days -= 365; } |
4720 | 4723 | $year++; |
4721 | 4724 | } |
4722 | 4725 | |
4723 | | - $month = 0; |
| 4726 | + my $month = 0; |
4724 | 4727 | while ($days > $mmm[$month]) { |
4725 | 4728 | $days -= $mmm[$month]; |
4726 | 4729 | if ($month == 1) { |
— | — | @@ -4727,9 +4730,10 @@ |
4728 | 4731 | } |
4729 | 4732 | $month++; |
4730 | 4733 | } |
4731 | | - $day = $days; |
| 4734 | + my $day = $days; |
4732 | 4735 | |
4733 | 4736 | $month++; |
| 4737 | + my $date; |
4734 | 4738 | if ($DateFormat eq "dd/mm/yyyy") { |
4735 | 4739 | $date = sprintf("%02d/%02d/%04d", $day, $month, $year); |
4736 | 4740 | } |
— | — | @@ -4739,6 +4743,7 @@ |
4740 | 4744 | } |
4741 | 4745 | |
4742 | 4746 | sub ExtractText { |
| 4747 | + |
4743 | 4748 | # my $data = shift; |
4744 | 4749 | my $data2 = shift; |
4745 | 4750 | my $text = ""; |
— | — | @@ -4794,7 +4799,7 @@ |
4795 | 4800 | |
4796 | 4801 | sub BarDefined { |
4797 | 4802 | my $bar = shift; |
4798 | | - foreach $bar2 (@Bars) { |
| 4803 | + foreach my $bar2 (@Bars) { |
4799 | 4804 | if (lc($bar2) eq lc($bar)) { return ($true); } |
4800 | 4805 | } |
4801 | 4806 | |
— | — | @@ -4914,27 +4919,32 @@ |
4915 | 4920 | my @Required = split(",", shift); |
4916 | 4921 | my @Allowed = split(",", shift); |
4917 | 4922 | |
4918 | | - my $attribute; |
4919 | 4923 | my %Attributes2 = %Attributes; |
4920 | 4924 | |
4921 | | - $hint = "\nSyntax: '$name ="; |
4922 | | - foreach $attribute (@Required) { $hint .= " $attribute:.."; } |
4923 | | - foreach $attribute (@Allowed) { $hint .= " [$attribute:..]"; } |
| 4925 | + my $hint = "\nSyntax: '$name ="; |
| 4926 | + foreach my $required_attribute (@Required) { |
| 4927 | + $hint .= " $required_attribute:.."; |
| 4928 | + } |
| 4929 | + foreach my $allowed_attribute (@Allowed) { |
| 4930 | + $hint .= " [$allowed_attribute:..]"; |
| 4931 | + } |
4924 | 4932 | $hint .= "'"; |
4925 | 4933 | |
4926 | | - foreach $attribute (@Required) { |
4927 | | - if ( (!defined($Attributes{$attribute})) |
4928 | | - || ($Attributes{$attribute} eq "")) |
| 4934 | + foreach my $required_attribute (@Required) { |
| 4935 | + if ( (!defined($Attributes{$required_attribute})) |
| 4936 | + || ($Attributes{$required_attribute} eq "")) |
4929 | 4937 | { |
4930 | 4938 | &Error("$name definition incomplete. $hint"); |
4931 | 4939 | undef(@Attributes); |
4932 | 4940 | return ($false); |
4933 | 4941 | } |
4934 | | - delete($Attributes2{$attribute}); |
| 4942 | + delete($Attributes2{$required_attribute}); |
4935 | 4943 | } |
4936 | | - foreach $attribute (@Allowed) { delete($Attributes2{$attribute}); } |
| 4944 | + foreach my $allowed_attribute (@Allowed) { |
| 4945 | + delete($Attributes2{$allowed_attribute}); |
| 4946 | + } |
4937 | 4947 | |
4938 | | - @AttrKeys = keys %Attributes2; |
| 4948 | + my @AttrKeys = keys %Attributes2; |
4939 | 4949 | if ($#AttrKeys >= 0) { |
4940 | 4950 | if ($AttrKeys[0] eq "single") { |
4941 | 4951 | &Error( |
— | — | @@ -4955,10 +4965,11 @@ |
4956 | 4966 | |
4957 | 4967 | sub CheckPreset { |
4958 | 4968 | my $command = shift; |
4959 | | - my ($preset, $action, $attrname, $attrvalue); |
| 4969 | + my ($action, $attrname, $attrvalue); |
4960 | 4970 | |
4961 | 4971 | my $newcommand = $true; |
4962 | 4972 | my $addvalue = $true; |
| 4973 | + my $prevcommand; |
4963 | 4974 | if ($command =~ /^$prevcommand$/i) { $newcommand = $false; } |
4964 | 4975 | if ((!$newcommand) && ($command =~ /^(?:DrawLines|PlotData|TextData)$/i)) |
4965 | 4976 | { |
— | — | @@ -4966,8 +4977,9 @@ |
4967 | 4978 | } |
4968 | 4979 | $prevcommand = $command; |
4969 | 4980 | |
4970 | | - foreach $preset (@PresetList) { |
| 4981 | + foreach my $preset (@PresetList) { |
4971 | 4982 | if ($preset =~ /^$command\|/i) { |
| 4983 | + my $attrpreset; |
4972 | 4984 | ($command, $action, $attrname, $attrpreset) = |
4973 | 4985 | split('\|', $preset); |
4974 | 4986 | if ($attrname eq "") { $attrname = "single"; } |
— | — | @@ -5066,7 +5078,7 @@ |
5067 | 5079 | |
5068 | 5080 | my @Show = split("\n", $show); |
5069 | 5081 | $text = ""; |
5070 | | - foreach $part (@Show) { |
| 5082 | + foreach my $part (@Show) { |
5071 | 5083 | if ($brdouble) { $part = "[[" . $hide . "|" . $part . "]]"; } |
5072 | 5084 | else { $part = "[" . $hide . "|" . $part . "]"; } |
5073 | 5085 | } |
— | — | @@ -5122,40 +5134,6 @@ |
5123 | 5135 | $text =~ s/\[+ ([^\]]+) \]+/$1/gx; |
5124 | 5136 | $text =~ s/\{\{\{ ([^\}]*) \}\}\}/[[$1]]/x; |
5125 | 5137 | } |
5126 | | - |
5127 | | - # if ($text =~ /\[\[.+\]\]/) |
5128 | | - # { |
5129 | | - # $wikilink = $true ; |
5130 | | - # $link = $text ; |
5131 | | - # $link =~ s/\n//g ; |
5132 | | - # $link =~ s/^.*?\[\[/[[/x ; |
5133 | | - # $link =~ s/\| .*? \]\].*$/]]/x ; |
5134 | | - # $link =~ s/\]\].*$/]]/x ; |
5135 | | - # $text =~ s/\[\[ [^\|\]]+ \| (.*?) \]\]/[[$1]]/x ; |
5136 | | - # $text =~ s/\[\[ [^\:\]]+ \: (.*?) \]\]/[[$1]]/x ; |
5137 | | - |
5138 | | - # # remove remaining links |
5139 | | - # $text =~ s/\[\[ ([^\]]+) \]\]/^%#$1#%^/x ; |
5140 | | - # $text =~ s/\[+ ([^\]]+) \]+/$1/gx ; |
5141 | | - # $text =~ s/\^$hPerc\# (.*?) \#$hPerc\^/[[$1]]/x ; |
5142 | | - # } |
5143 | | - # elsif ($text =~ /\[.+\]/) |
5144 | | - # { |
5145 | | - # $link = $text ; |
5146 | | - # $link =~ s/\n//g ; |
5147 | | - # $link =~ s/^.*?\[/[/x ; |
5148 | | - # $link =~ s/\| .*? \].*$/]/x ; |
5149 | | - # $link =~ s/\].*$/]/x ; |
5150 | | - # $link =~ s/\[ ([^\]]+) \]/$1/x ; |
5151 | | - # $text =~ s/\[ [^\|\]]+ \| (.*?) \]/[[$1]]/x ; |
5152 | | - |
5153 | | - # # remove remaining links |
5154 | | - # $text =~ s/\[\[ ([^\]]+) \]\]/^%#$1#%^/x ; |
5155 | | - # $text =~ s/\[+ ([^\]]+) \]+/$1/gx ; |
5156 | | - # $text =~ s/\^$hPerc\# (.*?) \#$hPerc\^/[[$1]]/x ; |
5157 | | -## $text =~ s/\[\[ (.*) \]\]/$1/gx ; |
5158 | | - # } |
5159 | | - |
5160 | 5138 | } |
5161 | 5139 | |
5162 | 5140 | if ($wikilink) { |
— | — | @@ -5176,14 +5154,12 @@ |
5177 | 5155 | $link = &EncodeURL($title); |
5178 | 5156 | if (($hint eq "") && ($title ne "")) { $hint = "$wiki: $title"; } |
5179 | 5157 | } |
5180 | | - else { |
5181 | | - |
5182 | | - # $wiki = "en" ; |
| 5158 | + else { # $wiki = "en" ; |
5183 | 5159 | $title = $link; |
5184 | 5160 | $title =~ s/^\[\[(.*)\]\]$/$1/x; |
5185 | 5161 | $title =~ s/ /_/g; |
5186 | | - $link = $articlepath; |
5187 | | - $urlpart = &EncodeURL($title); |
| 5162 | + $link = $articlepath; |
| 5163 | + my $urlpart = &EncodeURL($title); |
5188 | 5164 | $link =~ s/\$1/$urlpart/; |
5189 | 5165 | if (($hint eq "") && ($title ne "")) { $hint = "$title"; } |
5190 | 5166 | } |
— | — | @@ -5303,12 +5279,13 @@ |
5304 | 5280 | "<p>EasyTimeline $VERSION</p><p><b>Timeline generation failed: " |
5305 | 5281 | . &EncodeHtml($msg) |
5306 | 5282 | . "</b></p>\n"; |
5307 | | - foreach $line (@Errors) { print FILE_OUT &EncodeHtml($line) . "\n"; } |
| 5283 | + foreach my $line (@Errors) { |
| 5284 | + print FILE_OUT &EncodeHtml($line) . "\n"; |
| 5285 | + } |
5308 | 5286 | close "FILE_OUT"; |
5309 | 5287 | |
5310 | | - if ($makehtml |
5311 | | - ) # generate html test file, which would normally contain png + svg (+ image map) |
5312 | | - { |
| 5288 | + # generate html test file, which would normally contain png + svg (+ image map) |
| 5289 | + if ($makehtml) { |
5313 | 5290 | open "FILE_IN", "<", $file_errors; |
5314 | 5291 | open "FILE_OUT", ">", $file_html; |
5315 | 5292 | print FILE_OUT |
— | — | @@ -5356,13 +5333,13 @@ |
5357 | 5334 | elsif ($ord >= 240) { $value = $ord - 240; } |
5358 | 5335 | elsif ($ord >= 224) { $value = $ord - 224; } |
5359 | 5336 | else { $value = $ord - 192; } |
5360 | | - for ($c = 1; $c < length($unicode); $c++) { |
| 5337 | + for (my $c = 1; $c < length($unicode); $c++) { |
5361 | 5338 | $value = $value * 64 + ord(substr($unicode, $c, 1)) - 128; |
5362 | 5339 | } |
5363 | 5340 | |
5364 | 5341 | # $html = "\&\#" . $value . ";" ; any unicode can be specified as html char |
5365 | 5342 | |
5366 | | - if (($value >= 128) && ($value <= 255)) { |
| 5343 | + if (($value >= 128) && ($value <= 255)) { |
5367 | 5344 | return (chr($value)); |
5368 | 5345 | } |
5369 | 5346 | else { |